<commit_before>import { LEYLIM_ROOT } from './constant';
import editorButtons from './editorButtons';


export default class Editor {
  constructor(options) {
    this.options = options;
    this.editorNode = null;
    const _editorButtons = options.filter ? options.filter(editorButtons) : editorButtons;

    if (options.merge) {
      this.buttons = _editorButtons.concat(options.buttons);
    } else {
      this.buttons = options.buttons;
    }

    this.init();
    this.catchSelection();
  }

  /**
   * @todo when selection contains any button add active class to selected button
   * @memberof Editor
   */
  catchSelection() {
    document.onselectionchange = (e) => {
      const selection = window.getSelection();
      // console.log(selection);
    }
  }


  init() {
    const buttons = this.buttons;
    const rootNode = document.querySelector(`.${LEYLIM_ROOT}`);
    const editorNode = document.createElement('div');
    this.editorNode = editorNode;
    editorNode.classList.add('leylim-editor');


    for (let ii = 0; ii < buttons.length; ii++) {
      const buttonNode = document.createElement('A');
      buttonNode.href = '#';
      buttonNode.classList.add('leylim-editor__button');
      buttonNode.innerHTML = `<i class="${buttons[ii].icon}"></i>${buttons[ii].innerText || ''}`;
      buttonNode.onclick = (e) => this.onClick(e, buttons[ii]);

      editorNode.appendChild(buttonNode);
    }
    rootNode.appendChild(editorNode);
  }

  /**
   * @todo provide selection object for commandObject handler (customEditorButtons)
   *
   * @memberof Editor
   */
  onClick = (e, commandObject) => {<commit_msg>remove dead code<commit_after>import { LEYLIM_ROOT } from './constant';
import editorButtons from './editorButtons';


export default class Editor {
  constructor(options) {
    this.options = options;
    this.editorNode = null;
    const _editorButtons = options.filter ? options.filter(editorButtons) : editorButtons;

    if (options.merge) {
      this.buttons = _editorButtons.concat(options.buttons);
    } else {
      this.buttons = options.buttons;
    }

    this.init();
    // this.catchSelection();
  }

  /**
   * @todo when selection contains any button add active class to selected button
   * @memberof Editor
   */
  // catchSelection() {
  //   document.onselectionchange = (e) => {
  //     const selection = window.getSelection();
  //     // console.log(selection);
  //   }
  // }


  init() {
    const buttons = this.buttons;
    const rootNode = document.querySelector(`.${LEYLIM_ROOT}`);
    const editorNode = document.createElement('div');
    this.editorNode = editorNode;
    editorNode.classList.add('leylim-editor');


    for (let ii = 0; ii < buttons.length; ii++) {
      const buttonNode = document.createElement('A');
      buttonNode.href = '#';
      buttonNode.classList.add('leylim-editor__button');
      buttonNode.innerHTML = `<i class="${buttons[ii].icon}"></i>${buttons[ii].innerText || ''}`;
      buttonNode.onclick = (e) => this.onClick(e, buttons[ii]);

      editorNode.appendChild(buttonNode);
    }
    rootNode.appendChild(editorNode);
  }

  /**
   * @todo provide selection object for commandObject handler (customEditorButtons)
   *
   * @memberof Editor
   */
  onClick = (e, commandObject) => {
{'fraction_non_alphanumeric': 0.1436396835057821, 'fraction_numerical': 0.0006086427267194157, 'mean_word_length': 3.181933842239186, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '2916300', 'n_tokens_mistral': 972, 'n_tokens_neox': 973, 'n_words': 200}