![]() 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-form/js/fragment/ |
Upload File : |
import BaseEditor from "../core/BaseEditor"; import FCore from "../core/FCore"; import '../../css/cmdtool.css'; var _ = FCore._; var $ = FCore.$; function CMDTool() { BaseEditor.call(this); this.$dockElt = null; this.cmdTree = []; this.$buttons = {};// button dictionaryx this.$visiable = []; this.updateVisiable = this.updateVisiable.bind(this); this.refresh = this.refresh.bind(this); } Object.defineProperties(CMDTool.prototype, Object.getOwnPropertyDescriptors(BaseEditor.prototype)); CMDTool.prototype.constructor = CMDTool; CMDTool.prototype.CONFIG_STORE_KEY = "AS_CMDTool_config"; CMDTool.prototype.config = { }; /** * @param {import('../editor/editor').default} editor */ CMDTool.prototype.bindWithEditor = function (editor) { // this.updateVisiable is binded if (this.editor){ this.editor.off('cmddescriptorschange', this.updateVisiable); this.editor.off('cmdchange', this.refresh); } this.editor = editor; if (this.editor) { this.editor.on('cmdchange', this.refresh); this.editor.on("cmddescriptorschange", this.updateVisiable); } this.refresh(); }; CMDTool.prototype.onStart = function () { this.getView(); }; CMDTool.prototype.updateVisiable = function () { if (!this.editor) return; var self = this; Object.keys(this.$buttons).forEach(function (name) { var descriptor = self.editor.getCmdDescriptor(name); self.$buttons[name].disabled = descriptor.disabled; }); }; CMDTool.prototype.onResume = function () { this.updateVisiable(); }; CMDTool.prototype.getView = function () { if (this.$view) return this.$view; this.$view = _({ tag: 'bscroller', class: "as-form-cmd-tool", }); this.refresh(); return this.$view; }; CMDTool.prototype.refresh = function () { if (!this.editor) return; this.getView(); this.$view.clearChild(); this.$buttons = {}; var groupTree = this.editor.getCmdGroupTree(); var self = this; function visit(node) { if (node instanceof Array) { return _({ class: 'as-from-tool-group-buttons', child: node.map(visit) }) } else { var descriptor = self.editor.getCmdDescriptor(node); var title = descriptor.desc; if (descriptor.bindKey && descriptor.bindKey.win) { title += ' (' + descriptor.bindKey.win + ')'; } self.$buttons[node] = _({ tag: 'button', class: ['as-from-tool-button'], attr: { title: title }, child: descriptor.icon, props: { disabled: !!descriptor.disabled }, on: { click: function () { self.execCmd.apply(self, [node].concat(descriptor.args || [])); } } }); return self.$buttons[node]; } } this.$view.addChild(visit(groupTree)); }; CMDTool.prototype.execCmd = function () { this.editor.execCmd.apply(this.editor, arguments); }; CMDTool.prototype.ev_cmdKeyDown = function (event) { this.editor.ev_cmdKeyDown(event);//repeat event } export default CMDTool;