[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/plg_editors_tinymce/js/plugins/highlighter/ -> plugin.js (source)

   1  /**
   2   * plugin.js
   3   *
   4   * Original code by Arjan Haverkamp
   5   * Copyright 2013-2015 Arjan Haverkamp ([email protected])
   6   */
   7  window.tinymce.PluginManager.add('highlightPlus', (editor, url) => {
   8    const showSourceEditor = () => {
   9      editor.focus();
  10      editor.selection.collapse(true);
  11      if (!editor.settings.codemirror) editor.settings.codemirror = {}; // Insert caret marker
  12  
  13      if (editor.settings.codemirror && editor.settings.codemirror.saveCursorPosition) {
  14        editor.selection.setContent('<span style="display: none;" class="CmCaReT">&#x0;</span>');
  15      }
  16  
  17      let codemirrorWidth = 800;
  18  
  19      if (editor.settings.codemirror.width) {
  20        codemirrorWidth = editor.settings.codemirror.width;
  21      }
  22  
  23      let codemirrorHeight = 550;
  24  
  25      if (editor.settings.codemirror.height) {
  26        codemirrorHeight = editor.settings.codemirror.height;
  27      }
  28  
  29      const buttonsConfig = [{
  30        type: 'custom',
  31        text: 'Ok',
  32        name: 'codemirrorOk',
  33        primary: true
  34      }, {
  35        type: 'cancel',
  36        text: 'Cancel',
  37        name: 'codemirrorCancel'
  38      }];
  39      const config = {
  40        title: 'Source code',
  41        url: `$url}/source.html`,
  42        width: codemirrorWidth,
  43        height: codemirrorHeight,
  44        resizable: true,
  45        maximizable: true,
  46        fullScreen: editor.settings.codemirror.fullscreen,
  47        saveCursorPosition: false,
  48        buttons: buttonsConfig
  49      };
  50  
  51      config.onAction = (dialogApi, actionData) => {
  52        if (actionData.name === 'codemirrorOk') {
  53          const doc = document.querySelectorAll('.tox-dialog__body-iframe iframe')[0];
  54          doc.contentWindow.tinymceHighlighterSubmit();
  55          editor.undoManager.add(); // eslint-disable-next-line no-use-before-define
  56  
  57          win.close();
  58        }
  59      };
  60  
  61      const win = editor.windowManager.openUrl(config);
  62  
  63      if (editor.settings.codemirror.fullscreen) {
  64        win.fullscreen(true);
  65      }
  66    };
  67  
  68    editor.ui.registry.addButton('code', {
  69      icon: 'sourcecode',
  70      title: 'Source code+',
  71      tooltip: 'Source code+',
  72      onAction: showSourceEditor
  73    });
  74    editor.ui.registry.addMenuItem('code', {
  75      icon: 'sourcecode',
  76      text: 'Source code+',
  77      onAction: showSourceEditor,
  78      context: 'tools'
  79    });
  80  });


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer