<commit_before>import { Component } from 'substance'
import renderModelComponent from './renderModelComponent'
import { PREVIEW_MODE, METADATA_MODE } from '../ArticleConstants'
import FigureMetadataComponent from './FigureMetadataComponent'
import PreviewComponent from './PreviewComponent'

export default class FigureComponent extends Component {
  render ($$) {
    const model = this.props.model
    let mode = this.props.mode || 'manuscript'

    // delegating to a implementation in case of 'metadata'
    if (mode === METADATA_MODE) {
      return $$(FigureMetadataComponent, { model }).ref('metadata')
    }

    let el = $$('div')
      .addClass('sc-' + model.type)
      .attr('data-id', model.id)
    el.addClass(`sm-${mode}`)

    // TODO: this component should listen to label updates
    let label = model.getLabel()
    let contentModel = model.getContent()
    let figureContent = renderModelComponent(this.context, $$, {
      model: contentModel
    }).ref('content').addClass('se-content')
    el.addClass(`sm-${contentModel.type}`)

    console.log('figureContent', contentModel)
    if (mode === PREVIEW_MODE) {
      el.append(
        $$(PreviewComponent, {
          id: this.props.model.id,
          thumbnail: contentModel.type === 'graphic' ? figureContent : undefined,
          label
        })
      )
    } else {
      let labelEl = $$('div').addClass('se-label').text(label)
      el.append(labelEl)
      el.append(figureContent)
      el.append(
        renderModelComponent(this.context, $$, {
          model: model.getTitle(),
          label: this.getLabel('title')
        }).ref('title').addClass('se-title')
      )
      el.append(
        renderModelComponent(this.context, $$, {
          model: model.getCaption(),
          label: this.getLabel('caption')
        }).ref('caption').addClass('se-caption')
      )
    }<commit_msg>Silence.<commit_after>import { Component } from 'substance'
import renderModelComponent from './renderModelComponent'
import { PREVIEW_MODE, METADATA_MODE } from '../ArticleConstants'
import FigureMetadataComponent from './FigureMetadataComponent'
import PreviewComponent from './PreviewComponent'

export default class FigureComponent extends Component {
  render ($$) {
    const model = this.props.model
    let mode = this.props.mode || 'manuscript'

    // delegating to a implementation in case of 'metadata'
    if (mode === METADATA_MODE) {
      return $$(FigureMetadataComponent, { model }).ref('metadata')
    }

    let el = $$('div')
      .addClass('sc-' + model.type)
      .attr('data-id', model.id)
    el.addClass(`sm-${mode}`)

    // TODO: this component should listen to label updates
    let label = model.getLabel()
    let contentModel = model.getContent()
    let figureContent = renderModelComponent(this.context, $$, {
      model: contentModel
    }).ref('content').addClass('se-content')
    el.addClass(`sm-${contentModel.type}`)

    if (mode === PREVIEW_MODE) {
      el.append(
        $$(PreviewComponent, {
          id: this.props.model.id,
          thumbnail: contentModel.type === 'graphic' ? figureContent : undefined,
          label
        })
      )
    } else {
      let labelEl = $$('div').addClass('se-label').text(label)
      el.append(labelEl)
      el.append(figureContent)
      el.append(
        renderModelComponent(this.context, $$, {
          model: model.getTitle(),
          label: this.getLabel('title')
        }).ref('title').addClass('se-title')
      )
      el.append(
        renderModelComponent(this.context, $$, {
          model: model.getCaption(),
          label: this.getLabel('caption')
        }).ref('caption').addClass('se-caption')
      )
    }
{'fraction_non_alphanumeric': 0.14490016189962224, 'fraction_numerical': 0.0, 'mean_word_length': 2.8414507772020725, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2633255', 'n_tokens_mistral': 1052, 'n_tokens_neox': 1030, 'n_words': 226}