[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/vendor/tinymce/plugins/code/ -> plugin.js (source)

   1  /**
   2   * Copyright (c) Tiny Technologies, Inc. All rights reserved.
   3   * Licensed under the LGPL or a commercial license.
   4   * For LGPL see License.txt in the project root for license information.
   5   * For commercial licenses see https://www.tiny.cloud/
   6   *
   7   * Version: 5.10.5 (2022-05-25)
   8   */
   9  (function () {
  10      'use strict';
  11  
  12      var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
  13  
  14      var setContent = function (editor, html) {
  15        editor.focus();
  16        editor.undoManager.transact(function () {
  17          editor.setContent(html);
  18        });
  19        editor.selection.setCursorLocation();
  20        editor.nodeChanged();
  21      };
  22      var getContent = function (editor) {
  23        return editor.getContent({ source_view: true });
  24      };
  25  
  26      var open = function (editor) {
  27        var editorContent = getContent(editor);
  28        editor.windowManager.open({
  29          title: 'Source Code',
  30          size: 'large',
  31          body: {
  32            type: 'panel',
  33            items: [{
  34                type: 'textarea',
  35                name: 'code'
  36              }]
  37          },
  38          buttons: [
  39            {
  40              type: 'cancel',
  41              name: 'cancel',
  42              text: 'Cancel'
  43            },
  44            {
  45              type: 'submit',
  46              name: 'save',
  47              text: 'Save',
  48              primary: true
  49            }
  50          ],
  51          initialData: { code: editorContent },
  52          onSubmit: function (api) {
  53            setContent(editor, api.getData().code);
  54            api.close();
  55          }
  56        });
  57      };
  58  
  59      var register$1 = function (editor) {
  60        editor.addCommand('mceCodeEditor', function () {
  61          open(editor);
  62        });
  63      };
  64  
  65      var register = function (editor) {
  66        var onAction = function () {
  67          return editor.execCommand('mceCodeEditor');
  68        };
  69        editor.ui.registry.addButton('code', {
  70          icon: 'sourcecode',
  71          tooltip: 'Source code',
  72          onAction: onAction
  73        });
  74        editor.ui.registry.addMenuItem('code', {
  75          icon: 'sourcecode',
  76          text: 'Source code',
  77          onAction: onAction
  78        });
  79      };
  80  
  81      function Plugin () {
  82        global.add('code', function (editor) {
  83          register$1(editor);
  84          register(editor);
  85          return {};
  86        });
  87      }
  88  
  89      Plugin();
  90  
  91  }());


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