<commit_before>#= require rich_text/text
#= require rich_text/input
#= require rich_text/renderer

class RichText.Controller
  constructor: (@element) ->
    @element.setAttribute("contenteditable", "true")
    @text = new RichText.Text
    @input = new RichText.Input @element
    @input.delegate = this
    @input.install()
    @renderer = new RichText.Renderer(@text)

  didTypeCharacter: (character) ->
    @insertString(character)

  insertString: (string) ->
    @text.appendText(new RichText.Text(string))
    @render()

  render: ->
    @element.innerHTML = ""
    @element.appendChild(@renderer.render())<commit_msg>Force cursor to the end after typing<commit_after>#= require rich_text/text
#= require rich_text/input
#= require rich_text/renderer

class RichText.Controller
  constructor: (@element) ->
    @element.setAttribute("contenteditable", "true")
    @text = new RichText.Text
    @input = new RichText.Input @element
    @input.delegate = this
    @input.install()
    @renderer = new RichText.Renderer(@text)

  didTypeCharacter: (character) ->
    @insertString(character)

  insertString: (string) ->
    @text.appendText(new RichText.Text(string))
    @render()

  render: ->
    @element.innerHTML = ""
    @element.appendChild(@renderer.render())
    @updateSelection()

  updateSelection: ->
    selection = window.getSelection()
    selection.removeAllRanges()
    selection.selectAllChildren(@element)
    selection.collapseToEnd()
{'fraction_non_alphanumeric': 0.1327857631759069, 'fraction_numerical': 0.0, 'mean_word_length': 4.041379310344827, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '7198066', 'n_tokens_mistral': 432, 'n_tokens_neox': 432, 'n_words': 86}