CoreFiles by mySites.guru
plugin.js87 lines, 2,411 bytes, from Joomla_4.1.0-beta1-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta7
md5
985c4d982c472df80bce72c3516aaba2
sha1
e00dc4c88990ccb8b5656e46c6eb70d765c83464
sha256
155644e09d45b40701d326ed665087825f2f4a7228d0c64de8c90ef5eeae75a8
/**
 * plugin.js
 *
 * Original code by Arjan Haverkamp
 * Copyright 2013-2015 Arjan Haverkamp ([email protected])
 *
 * Adapted for use in Joomla by Dimitrios Grammatikogiannis
 */
  /* eslint-disable no-undef */
  tinymce.PluginManager.add('highlightPlus', function(editor, url) {
    function showSourceEditor() {
      editor.focus();
      editor.selection.collapse(true);

      if (!editor.settings.codemirror) editor.settings.codemirror = {};

      // Insert caret marker
      if (editor.settings.codemirror && editor.settings.codemirror.saveCursorPosition) {
        editor.selection.setContent('<span style="display: none;" class="CmCaReT">&#x0;</span>');
      }

      let codemirrorWidth = 800;
      if (editor.settings.codemirror.width) {
        codemirrorWidth = editor.settings.codemirror.width;
      }

      let codemirrorHeight = 550;
      if (editor.settings.codemirror.height) {
        codemirrorHeight = editor.settings.codemirror.height;
      }

      const buttonsConfig = [
        {
          type: 'custom',
          text: 'Ok',
          name: 'codemirrorOk',
          primary: true
        },
        {
          type: 'cancel',
          text: 'Cancel',
          name: 'codemirrorCancel'
        }
      ]

      const config = {
        title: 'Source code',
        url: url + '/source.html',
        width: codemirrorWidth,
        height: codemirrorHeight,
        resizable: true,
        maximizable: true,
        fullScreen: editor.settings.codemirror.fullscreen,
        saveCursorPosition: false,
        buttons: buttonsConfig
      }

      config.onAction = function (dialogApi, actionData) {
        if (actionData.name === 'codemirrorOk') {
          const doc = document.querySelectorAll('.tox-dialog__body-iframe iframe')[0];
          doc.contentWindow.tinymceHighlighterSubmit();
          editor.undoManager.add();
          win.close();
        }
      }

      const win = editor.windowManager.openUrl(config);

      if (editor.settings.codemirror.fullscreen) {
        win.fullscreen(true);
      }
    }

    editor.ui.registry.addButton('code', {
      icon: 'sourcecode',
      title: 'Source code+',
      tooltip: 'Source code+',
      onAction: showSourceEditor
    });

    editor.ui.registry.addMenuItem('code', {
      icon: 'sourcecode',
      text: 'Source code+',
      onAction: showSourceEditor,
      context: 'tools'
    });
  });

The same content is in 3 releases, Joomla 4.1.0-beta1 to 4.1.0-beta3. See them all, or every version of this file.