<commit_before>import './style.scss'
import { Component } from '../Component'
import { ContextType } from '../../modules/context.type'
import * as CodeMirror from 'codemirror'

// JS mode
import 'codemirror/mode/javascript/javascript'
// CSS
import 'codemirror/lib/codemirror.css'
import 'codemirror/theme/bespin.css'

// UGLY UI state...
let code = null
let block

const FOOCODE =
"// This is a comment\n\nexport const render =\n( a, b ) => {\n  // ... do something\n  return { text: '' }\n}"

export const Editor = Component
( { source: [ 'block', 'source' ]
  , block: [ 'block' ]
  }
, ( { state, signals }: ContextType ) => {
    const create = ( _, { elm } ) => {
      if ( code === null ) {
        code = false
        setTimeout
        ( () => {
            code = CodeMirror
            ( elm
            , { value: state.source || ''
              , lineNumbers: true
              , theme: 'bespin'
              , mode: 'javascript'
              }
            )
          }
        , 100
        )
      }
    }

    if ( block !== state.block && code ) {
      console.log ( 'RENDER Block' )
      block = state.block
      code.setValue ( state.source || FOOCODE )
    }

    return <div class='Editor'>
        <div hook-create={ create }></div><commit_msg>We can store source code, youpi.<commit_after>import './style.scss'
import { Component } from '../Component'
import { ContextType } from '../../modules/context.type'
import * as CodeMirror from 'codemirror'

// JS mode
import 'codemirror/mode/javascript/javascript'
// CSS
import 'codemirror/lib/codemirror.css'
import 'codemirror/theme/bespin.css'

// UGLY UI state...
let code = null
let block

const FOOCODE =
"// This is a comment\n\nexport const render =\n( a, b ) => {\n  // ... do something\n  return { text: '' }\n}"

export const Editor = Component
( { source: [ 'block', 'source' ]
  , block: [ 'block' ]
  }
, ( { state, signals }: ContextType ) => {
    const create = ( _, { elm } ) => {
      if ( code === null ) {
        code = false
        setTimeout
        ( () => {
            code = CodeMirror
            ( elm
            , { value: state.source || ''
              , lineNumbers: true
              , theme: 'bespin'
              , mode: 'javascript'
              }
            )
            code.on
            ( 'blur', () => {
                signals.block.source
                ( { value: code.getValue () } )
              }
            )
          }
        , 100
        )
      }
    }

    if ( block !== state.block && code ) {
      block = state.block
      code.setValue ( state.source || '' )
    }

    return <div class='Editor'>
        <div hook-create={ create }></div>
{'fraction_non_alphanumeric': 0.15478841870824053, 'fraction_numerical': 0.0022271714922048997, 'mean_word_length': 1.676266137040715, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 18, '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': '5182703', 'n_tokens_mistral': 836, 'n_tokens_neox': 826, 'n_words': 207}