static render()

in src/executable-code/executable-fragment.js [61:97]


  static render(element, options = {}) {
    const instance = Monkberry.render(ExecutableFragment, element, {
      directives: directives,
    });

    instance.arrayClasses = [];
    instance.initialized = false;
    instance.state = {
      theme: '',
      code: '',
      foldButtonHover: false,
      folded: true,
      output: null,
    };
    instance.codemirror = new CodeMirror();

    instance.on('click', SELECTORS.FOLD_BUTTON, () => {
      instance.update({ folded: !instance.state.folded });
    });

    instance.on('keyup', (event) => {
      if (window.navigator.appVersion.indexOf(MAC) !== -1) {
        if (event.keyCode === KEY_CODES.R && event.ctrlKey) {
          instance.execute();
        }
      } else {
        if (event.keyCode === KEY_CODES.F9 && event.ctrlKey) {
          instance.execute();
        }
      }
    });

    const events = options.eventFunctions;
    if (events && events.getInstance) events.getInstance(instance);

    return instance;
  }