VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/www/html/libs/absol-full/dist/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/libs/absol-full/dist/js/mdls__absol-acomp__js__ckeditor__CKPlaceholder.js
/*** module: node_modules/absol-acomp/js/ckeditor/CKPlaceholder.js ***/
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _ACore = _interopRequireWildcard(require("../../ACore"));

require("../../css/ckplaceholder.css");

var _plugins = require("./plugins");

var _CKStickyToolbarController = _interopRequireDefault(require("./CKStickyToolbarController"));

var _Dom = _interopRequireDefault(require("absol/src/HTML5/Dom"));




_Dom.default.documentReady.then(function () {
  setTimeout(_plugins.ckInit, 100);
});
/***
 * @extends AElement
 * @constructor
 */


function CKPlaceholder() {
  (0, _plugins.ckInit)();
  this.$attachhook = (0, _ACore._)('attachhook').addTo(this);
  this.$attachhook.once('attached', this.eventHandler.attached);
  this._pendingData = '';
  this.isReady = false;
  this.editor = null;
  this._extensions = [];
  this._config = this._makeInitConfig();
  this.afterReady = new Promise(rs => {
    this.on('editorready', rs);
  });
  this.stickyToolbarCtrl = null;
  /***
   * @type {{}}
   * @name config
   * @memberOf CKPlaceholder#
   */

  /***
   * @type {string[]}
   * @name extensions
   * @memberOf CKPlaceholder#
   */

  /***
   *
   * @type {boolean}
   */

  this.stickyToolbar = true;
}

CKPlaceholder.tag = 'CKPlaceholder'.toLowerCase();

CKPlaceholder.render = function () {
  return (0, _ACore._)({
    extendEvent: ['editorcreated', 'editorready', 'change', 'command', 'focus'],
    class: 'as-ck-placeholder'
  });
};

CKPlaceholder.prototype.mode = 'replace';
/**
 *
 * @param {string}data
 * @private
 * @returns {string}
 */

CKPlaceholder.prototype._implicit = function (data) {
  if (typeof data !== "string") data = '';
  var self = this;
  return this._extensions.reverse().reduce(function (ac, cr) {
    var extension = _plugins.CKExtensionDict[cr];

    if (extension.implicit) {
      ac = extension.implicit(ac, self);
    }

    return ac;
  }, data);
};
/**
 *
 * @param {string}data
 * @private
 * @returns {string}
 */


CKPlaceholder.prototype._explicit = function (data) {
  var self = this;
  return this._extensions.reduce(function (ac, cr) {
    var extension = _plugins.CKExtensionDict[cr];

    if (extension && extension.explicit) {
      ac = extension.explicit(ac, self);
    }

    return ac;
  }, data);
};
/***
 * @returns {{}}
 * @protected
 */


CKPlaceholder.prototype._makeInitConfig = function () {
  return {};
};

CKPlaceholder.prototype.selectNext = function () {
  var editor = this.editor;
  if (!editor) return;
  var ranges = editor.getSelection().getRanges(); // var startIndex = editor.element.getHtml().indexOf(findString);
  // if (startIndex != -1)  {
  //     ranges[0].setStart(element.getFirst(), startIndex);
  //     ranges[0].setEnd(element.getFirst(), startIndex + findString.length);
  //     sel.selectRanges([ranges[0]]);
  // }
};
/***
 * @memberOf CKPlaceholder#
 * @type {{}}
 */


CKPlaceholder.eventHandler = {};
/***
 * @this CKPlaceholder
 */

CKPlaceholder.eventHandler.attached = function () {
  this.$attachhook.remove();
  this.editor = this.mode === 'replace' ? CKEDITOR.replace(this, (0, _plugins.ckMakeDefaultConfig)(this.config, this.extensions, this)) : CKEDITOR.inline(this, (0, _plugins.ckMakeDefaultConfig)(this.config, this.extensions, this));
  this.editor.placeHolderElt = this;
  this.editor.on('instanceReady', this.eventHandler.instanceReady);
  this.editor.on('change', this.eventHandler.change);

  if (this.mode === 'replace') {
    this.editor.on('focus', function (event) {
      this.emit('focus', {
        target: this,
        type: 'focus',
        originalEvent: event
      });
    }.bind(this));
  }

  this._extensions.forEach(function (name) {
    var e = _plugins.CKExtensionDict[name];

    if (e && e.extendMethods) {
      Object.assign(this, e.extendMethods);
    }
  }.bind(this));

  this.emit('editorcreated', {
    type: 'editorcreated',
    target: this,
    editor: this.editor
  }, this);
};

CKPlaceholder.eventHandler.instanceReady = function () {
  this.isReady = true;

  if (this._pendingData && this._pendingData.length > 0) {
    this.editor.setData(this._implicit(this._pendingData));
    this._pendingData = null;
  }

  this.emit('editorready', {
    type: 'editorready',
    target: this,
    editor: this.editor
  }, this);
};

CKPlaceholder.eventHandler.change = function () {
  this.emit('change', {
    type: 'change',
    target: this,
    editor: this.editor
  }, this);
};

CKPlaceholder.property = {};
CKPlaceholder.property.data = {
  /***
   * @this CKPlaceholder
   * @param data
   */
  set: function (data) {
    if (typeof data !== "string") data = '';

    if (this.isReady) {
      this.editor.setData(this._implicit(data));
    } else {
      this._pendingData = data;
    }
  },

  /***
   * @this CKPlaceholder
   * @returns {string}
   */
  get: function () {
    if (this.isReady) return this._explicit(this.editor.getData());
    return this._pendingData;
  }
};
CKPlaceholder.property.rawData = {
  get: function () {
    if (this.editor) this.editor.getData();else return this._implicit(this._pendingData);
  }
};
CKPlaceholder.property.config = {
  set: function (value) {
    if (this.editor) {
      throw new Error("Can not set config after the CKEditor created");
    }

    this._config = Object.assign(this._makeInitConfig(), value);
  },
  get: function () {
    return this._config;
  }
};
CKPlaceholder.property.extensions = {
  set: function (value) {
    if (this.editor) {
      throw new Error("Can not set extensions after the CKEditor created");
    }

    value = value || [];
    if (typeof value === "string") value = [value];
    if (!(value instanceof Array)) value = [];
    this._extensions = value.filter(function (c) {
      return typeof c === "string" && c.length > 0 && _plugins.CKExtensionDict[c];
    });
    this._extensions = value;
  },
  get: function () {
    return this._extensions;
  }
};
CKPlaceholder.property.stickyToolbar = {
  set: function (value) {
    if (value) {
      this.addClass('as-has-sticky-toolbar');
    } else {
      return this.removeClass('as-has-sticky-toolbar');
    }

    this.afterReady.then(() => {
      if (this.mode !== 'replace') return;

      if (this.stickyToolbar) {
        if (!this.stickyToolbarCtrl) {
          this.stickyToolbarCtrl = new _CKStickyToolbarController.default(this);
        }

        this.stickyToolbarCtrl.start();
      } else {
        this.editor.container.$.classList.remove('as-has-sticky-toolbar');
        if (this.stickyToolbarCtrl) this.stickyToolbarCtrl.stop();
      }
    });
  },
  get: function () {
    return this.hasClass('as-has-sticky-toolbar');
  }
};

_ACore.default.install(CKPlaceholder);

var _default = CKPlaceholder;
exports.default = _default;

VaKeR 2022