<commit_before>const specialCharacterGroups = require('./specialCharacters')
const latexCommandsWithSvg = require('./latexCommandsWithSvg')

module.exports = {
    init,
}

function init(mathEditor, hasRichTextFocus, l, baseUrl)  {
    const $toolbar = $(`
        <div class="rich-text-editor-tools" data-js="tools" style="display: none">
            <div class="rich-text-editor-tools-button-wrapper">
                <div class="rich-text-editor-toolbar-wrapper">
                    <button class="rich-text-editor-characters-expand-collapse" data-js="expandCollapseCharacters" style="z-index: 100"></button>
                </div>
            </div>
            <div class="rich-text-editor-tools-row">
                <div class="rich-text-editor-toolbar-wrapper">
                    <div class="rich-text-editor-toolbar-characters rich-text-editor-toolbar rich-text-editor-toolbar-button-list" data-js="charactersList"></div>
                </div>
            </div>
            <div class="rich-text-editor-tools-row">
                <div class="rich-text-editor-toolbar-wrapper rich-text-editor-equation-wrapper">
                    <div class="rich-text-editor-toolbar-equation rich-text-editor-toolbar rich-text-editor-toolbar-button-list" data-js="mathToolbar"></div>
                </div>
            </div>
            <div class="rich-text-editor-tools-button-wrapper">
                <div class="rich-text-editor-toolbar-wrapper">
                    <button class="rich-text-editor-new-equation rich-text-editor-button rich-text-editor-button-action" data-js="newEquation" data-command="Ctrl-E">Σ ${l.insertEquation}</button>
                </div>
            </div>
        </div>
        `)
        .on('mousedown', '[data-js="expandCollapseCharacters"]', e => {
            e.preventDefault()
            $toolbar.toggleClass('rich-text-editor-characters-expanded')
        })

    const $newEquation = $toolbar.find('[data-js="newEquation"]')
    const $mathToolbar = $toolbar.find('[data-js="mathToolbar"]')
    initSpecialCharacterToolbar($toolbar, mathEditor, hasRichTextFocus)
    initMathToolbar($mathToolbar, mathEditor, baseUrl)
    initNewEquation($newEquation, mathEditor, hasRichTextFocus)

    return $toolbar
}

const specialCharacterToButton = char => `<button class="rich-text-editor-button rich-text-editor-button-grid${char.popular ? ' rich-text-editor-characters-popular' :''}" ${char.latexCommand ? `data-command="${char.latexCommand}"` : ''}>${char.character}</button>`

const popularInGroup = group => group.characters.filter(character => character.popular).length<commit_msg>Don't loose focus when clicking between buttons<commit_after>const specialCharacterGroups = require('./specialCharacters')
const latexCommandsWithSvg = require('./latexCommandsWithSvg')

module.exports = {
    init,
}

function init(mathEditor, hasRichTextFocus, l, baseUrl)  {
    const $toolbar = $(`
        <div class="rich-text-editor-tools" data-js="tools" style="display: none">
            <div class="rich-text-editor-tools-button-wrapper">
                <div class="rich-text-editor-toolbar-wrapper">
                    <button class="rich-text-editor-characters-expand-collapse" data-js="expandCollapseCharacters" style="z-index: 100"></button>
                </div>
            </div>
            <div class="rich-text-editor-tools-row">
                <div class="rich-text-editor-toolbar-wrapper">
                    <div class="rich-text-editor-toolbar-characters rich-text-editor-toolbar rich-text-editor-toolbar-button-list" data-js="charactersList"></div>
                </div>
            </div>
            <div class="rich-text-editor-tools-row">
                <div class="rich-text-editor-toolbar-wrapper rich-text-editor-equation-wrapper">
                    <div class="rich-text-editor-toolbar-equation rich-text-editor-toolbar rich-text-editor-toolbar-button-list" data-js="mathToolbar"></div>
                </div>
            </div>
            <div class="rich-text-editor-tools-button-wrapper">
                <div class="rich-text-editor-toolbar-wrapper">
                    <button class="rich-text-editor-new-equation rich-text-editor-button rich-text-editor-button-action" data-js="newEquation" data-command="Ctrl-E">Σ ${l.insertEquation}</button>
                </div>
            </div>
        </div>
        `)
        .on('mousedown', e => {
            e.preventDefault()
        })
        .on('mousedown', '[data-js="expandCollapseCharacters"]', e => {
            e.preventDefault()
            $toolbar.toggleClass('rich-text-editor-characters-expanded')
        })

    const $newEquation = $toolbar.find('[data-js="newEquation"]')
    const $mathToolbar = $toolbar.find('[data-js="mathToolbar"]')
    initSpecialCharacterToolbar($toolbar, mathEditor, hasRichTextFocus)
    initMathToolbar($mathToolbar, mathEditor, baseUrl)
    initNewEquation($newEquation, mathEditor, hasRichTextFocus)

    return $toolbar
}

const specialCharacterToButton = char => `<button class="rich-text-editor-button rich-text-editor-button-grid${char.popular ? ' rich-text-editor-characters-popular' :''}" ${char.latexCommand ? `data-command="${char.latexCommand}"` : ''}>${char.character}</button>`

const popularInGroup = group => group.characters.filter(character => character.popular).length
{'fraction_non_alphanumeric': 0.1527259148618372, 'fraction_numerical': 0.0011202389843166542, 'mean_word_length': 2.8346456692913384, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 68, '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': '2705370', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1509, 'n_words': 218}