[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/plg_editors_none/js/ -> joomla-editor-none-es5.js (source)

   1  (function () {
   2    'use strict';
   3  
   4    function _inheritsLoose(subClass, superClass) {
   5      subClass.prototype = Object.create(superClass.prototype);
   6      subClass.prototype.constructor = subClass;
   7  
   8      _setPrototypeOf(subClass, superClass);
   9    }
  10  
  11    function _getPrototypeOf(o) {
  12      _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  13        return o.__proto__ || Object.getPrototypeOf(o);
  14      };
  15      return _getPrototypeOf(o);
  16    }
  17  
  18    function _setPrototypeOf(o, p) {
  19      _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  20        o.__proto__ = p;
  21        return o;
  22      };
  23  
  24      return _setPrototypeOf(o, p);
  25    }
  26  
  27    function _isNativeReflectConstruct() {
  28      if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  29      if (Reflect.construct.sham) return false;
  30      if (typeof Proxy === "function") return true;
  31  
  32      try {
  33        Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
  34        return true;
  35      } catch (e) {
  36        return false;
  37      }
  38    }
  39  
  40    function _construct(Parent, args, Class) {
  41      if (_isNativeReflectConstruct()) {
  42        _construct = Reflect.construct;
  43      } else {
  44        _construct = function _construct(Parent, args, Class) {
  45          var a = [null];
  46          a.push.apply(a, args);
  47          var Constructor = Function.bind.apply(Parent, a);
  48          var instance = new Constructor();
  49          if (Class) _setPrototypeOf(instance, Class.prototype);
  50          return instance;
  51        };
  52      }
  53  
  54      return _construct.apply(null, arguments);
  55    }
  56  
  57    function _isNativeFunction(fn) {
  58      return Function.toString.call(fn).indexOf("[native code]") !== -1;
  59    }
  60  
  61    function _wrapNativeSuper(Class) {
  62      var _cache = typeof Map === "function" ? new Map() : undefined;
  63  
  64      _wrapNativeSuper = function _wrapNativeSuper(Class) {
  65        if (Class === null || !_isNativeFunction(Class)) return Class;
  66  
  67        if (typeof Class !== "function") {
  68          throw new TypeError("Super expression must either be null or a function");
  69        }
  70  
  71        if (typeof _cache !== "undefined") {
  72          if (_cache.has(Class)) return _cache.get(Class);
  73  
  74          _cache.set(Class, Wrapper);
  75        }
  76  
  77        function Wrapper() {
  78          return _construct(Class, arguments, _getPrototypeOf(this).constructor);
  79        }
  80  
  81        Wrapper.prototype = Object.create(Class.prototype, {
  82          constructor: {
  83            value: Wrapper,
  84            enumerable: false,
  85            writable: true,
  86            configurable: true
  87          }
  88        });
  89        return _setPrototypeOf(Wrapper, Class);
  90      };
  91  
  92      return _wrapNativeSuper(Class);
  93    }
  94  
  95    function _assertThisInitialized(self) {
  96      if (self === void 0) {
  97        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  98      }
  99  
 100      return self;
 101    }
 102  
 103    /**
 104     * @copyright  (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
 105     * @license    GNU General Public License version 2 or later; see LICENSE.txt
 106     */
 107    window.customElements.define('joomla-editor-none', /*#__PURE__*/function (_HTMLElement) {
 108      _inheritsLoose(_class, _HTMLElement);
 109  
 110      function _class() {
 111        var _this;
 112  
 113        _this = _HTMLElement.call(this) || this; // Properties
 114  
 115        _this.editor = ''; // Bindings
 116  
 117        _this.unregisterEditor = _this.unregisterEditor.bind(_assertThisInitialized(_this));
 118        _this.registerEditor = _this.registerEditor.bind(_assertThisInitialized(_this));
 119        _this.childrenChange = _this.childrenChange.bind(_assertThisInitialized(_this));
 120        _this.getSelection = _this.getSelection.bind(_assertThisInitialized(_this)); // Watch for children changes.
 121        // eslint-disable-next-line no-return-assign
 122  
 123        new MutationObserver(function () {
 124          return _this.childrenChange();
 125        }).observe(_assertThisInitialized(_this), {
 126          childList: true
 127        });
 128        return _this;
 129      }
 130      /**
 131       * Lifecycle
 132       */
 133  
 134  
 135      var _proto = _class.prototype;
 136  
 137      _proto.connectedCallback = function connectedCallback() {
 138        // Note the mutation observer won't fire for initial contents,
 139        // so childrenChange is also called here.
 140        this.childrenChange();
 141      }
 142      /**
 143       * Lifecycle
 144       */
 145      ;
 146  
 147      _proto.disconnectedCallback = function disconnectedCallback() {
 148        this.unregisterEditor();
 149      }
 150      /**
 151       * Get the selected text
 152       */
 153      ;
 154  
 155      _proto.getSelection = function getSelection() {
 156        if (document.selection) {
 157          // IE support
 158          this.editor.focus();
 159          return document.selection.createRange();
 160        }
 161  
 162        if (this.editor.selectionStart || this.editor.selectionStart === 0) {
 163          // MOZILLA/NETSCAPE support
 164          return this.editor.value.substring(this.editor.selectionStart, this.editor.selectionEnd);
 165        }
 166  
 167        return this.editor.value;
 168      }
 169      /**
 170       * Register the editor
 171       */
 172      ;
 173  
 174      _proto.registerEditor = function registerEditor() {
 175        var _this2 = this;
 176  
 177        if (!window.Joomla || !window.Joomla.editors || typeof window.Joomla.editors !== 'object') {
 178          throw new Error('The Joomla API is not correctly registered.');
 179        }
 180  
 181        window.Joomla.editors.instances[this.editor.id] = {
 182          id: function id() {
 183            return _this2.editor.id;
 184          },
 185          element: function element() {
 186            return _this2.editor;
 187          },
 188          // eslint-disable-next-line no-return-assign
 189          getValue: function getValue() {
 190            return _this2.editor.value;
 191          },
 192          // eslint-disable-next-line no-return-assign
 193          setValue: function setValue(text) {
 194            return _this2.editor.value = text;
 195          },
 196          // eslint-disable-next-line no-return-assign
 197          getSelection: function getSelection() {
 198            return _this2.getSelection();
 199          },
 200          // eslint-disable-next-line no-return-assign
 201          disable: function disable(disabled) {
 202            _this2.editor.disabled = disabled;
 203            _this2.editor.readOnly = disabled;
 204          },
 205          // eslint-disable-next-line no-return-assign
 206          replaceSelection: function replaceSelection(text) {
 207            if (_this2.editor.selectionStart || _this2.editor.selectionStart === 0) {
 208              _this2.editor.value = _this2.editor.value.substring(0, _this2.editor.selectionStart) + text + _this2.editor.value.substring(_this2.editor.selectionEnd, _this2.editor.value.length);
 209            } else {
 210              _this2.editor.value += text;
 211            }
 212          },
 213          onSave: function onSave() {}
 214        };
 215      }
 216      /**
 217       * Remove the editor from the Joomla API
 218       */
 219      ;
 220  
 221      _proto.unregisterEditor = function unregisterEditor() {
 222        if (this.editor) {
 223          delete window.Joomla.editors.instances[this.editor.id];
 224        }
 225      }
 226      /**
 227       * Called when element's child list changes
 228       */
 229      ;
 230  
 231      _proto.childrenChange = function childrenChange() {
 232        // Ensure the first child is an input with a textarea type.
 233        if (this.firstElementChild && this.firstElementChild.tagName && this.firstElementChild.tagName.toLowerCase() === 'textarea' && this.firstElementChild.getAttribute('id')) {
 234          this.editor = this.firstElementChild;
 235          this.unregisterEditor();
 236          this.registerEditor();
 237        }
 238      };
 239  
 240      return _class;
 241    }( /*#__PURE__*/_wrapNativeSuper(HTMLElement)));
 242  
 243  })();


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