![]() 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 : |
/*** module: node_modules/absol-form/js/blockeditor/BlockEditor.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _OOP = _interopRequireDefault(require("absol/src/HTML5/OOP")); var _BaseEditor = _interopRequireDefault(require("../core/BaseEditor")); var _FCore = require("../core/FCore"); require("../../css/blockeditor.css"); var _BEBase = _interopRequireDefault(require("./types/BEBase")); require("./types/BEFunction"); require("./types/BEEntry"); require("./types/BEFileDownloader"); require("./types/BEPropsGate"); require("./types/BERadioGroup"); require("./types/BESnackBar"); require("./types/BETimer"); var _R = _interopRequireDefault(require("../R")); var _CMDTool = _interopRequireDefault(require("../fragment/CMDTool")); var _BlockEditorCmd = _interopRequireWildcard(require("./BlockEditorCmd")); var _ClipboardManager = _interopRequireDefault(require("../ClipboardManager")); var _BoardTable = _interopRequireDefault(require("absol-acomp/js/BoardTable")); function BlockEditor() { _BaseEditor.default.call(this); this.cmdRunner.assign(_BlockEditorCmd.default); this.activatedBlocks = []; this.CMDTool = new _CMDTool.default(); this.CMDTool.attach(this); this.CMDTool.bindWithEditor(this); var self = this; Object.keys(_BlockEditorCmd.BlockEditorCmdDescriptors).forEach(function (cmd) { if (_BlockEditorCmd.BlockEditorCmdDescriptors[cmd].bindKey) self.bindKeyToCmd(_BlockEditorCmd.BlockEditorCmdDescriptors[cmd].bindKey.win, cmd); }); } _OOP.default.mixClass(BlockEditor, _BaseEditor.default); BlockEditor.prototype.clipboardType = "CB_BLOCKS"; BlockEditor.prototype.createView = function () { this.$view = (0, _FCore._)({ attr: { tabindex: 1 }, class: 'as-block-editor', child: [{ class: 'as-block-editor-header', child: this.CMDTool.getView() }, { tag: _BoardTable.default.tag, class: ['as-block-editor-body', 'as-bscroller'] }] }); this.$cmdToolCtn = (0, _FCore.$)('.as-block-editor-header', this.$view); this.$body = (0, _FCore.$)('.as-block-editor-body', this.$view).on('orderchange', this.ev_blockOrderChange.bind(this)); this.$view.on('keydown', this.ev_cmdKeyDown.bind(this)); }; BlockEditor.prototype.onAttached = function () { /*** * * @type {LayoutEditor} */ this.layoutEditor = this.getContext(_R.default.LAYOUT_EDITOR); /*** * * @type {FormEditor} */ this.formEditor = this.getContext(_R.default.FORM_EDITOR); }; BlockEditor.prototype.onStart = function () { this.selfHolder = this.formEditor.getEditorHolderByEditor(this); this.CMDTool.start(); }; BlockEditor.prototype.onStop = function () { if (this.selfHolder.tabframe.modified) this.layoutEditor.setBlockData(this.getData()); }; BlockEditor.prototype.setData = function (data) { var self = this; this._data = data; this.$body.clearChild(); this.blocks = data.map(function (it) { var clazz = _BEBase.default.prototype.tag2Class[it.tag] || _BEBase.default; var block = new clazz(self); block.setData(it); block.on('select', function (event) { if (self.isActivatedBlock(block)) { if (event.shiftKey && self.activatedBlocks.length > 1) { self.deactivateBlock(block); } else self.activateBlock(block); } else { self.activateBlock(block, event.shiftKey); } }); return block; }); this.blocks.forEach(function (blk) { self.$body.addChild(blk.getView()); }); }; BlockEditor.prototype.getData = function () { return this.blocks.map(function (blk) { return blk.getData(); }); }; BlockEditor.prototype.getCmdNames = function () { return Object.keys(_BlockEditorCmd.default); }; BlockEditor.prototype.getCmdDescriptor = function (name) { var descriptor = _BlockEditorCmd.BlockEditorCmdDescriptors[name]; var res = Object.assign({ type: 'trigger', desc: 'command: ' + name, icon: 'span.mdi.mdi-apple-keyboard-command' }, descriptor); if (name === 'cut' || name === 'copy' || name === 'delete') { res.disabled = this.activatedBlocks.length === 0; if (name === 'delete' || name === 'cut') { res.disabled = res.disabled || this.activatedBlocks.some(function (blk) { return blk._data && blk._data.attributes && blk._data.attributes.permissions && blk._data.attributes.permissions.edit_attributes === "GENERATOR"; }); } } else if (name === 'paste') { res.disabled = !_ClipboardManager.default.get(this.clipboardType); } return res; }; BlockEditor.prototype.getCmdGroupTree = function () { var tree = _BlockEditorCmd.BlockEditorCmdTree; return tree; }; BlockEditor.prototype.activateBlock = function (block, append) { var idx = this.activatedBlocks.indexOf(block); if (idx >= 0) { this.activatedBlocks.splice(idx, 1); if (!append) { this.activatedBlocks.splice(0, this.activatedBlocks.length).forEach(function (blk) { blk.getView().removeClass('as-activated').removeClass('as-focus'); }); } this.activatedBlocks.push(block); } else { if (!append) { this.activatedBlocks.splice(0, this.activatedBlocks.length).forEach(function (blk) { blk.getView().removeClass('as-activated').removeClass('as-focus'); }); } this.activatedBlocks.push(block); block.getView().addClass('as-activated'); } this.activatedBlocks.forEach(function (blk, i, arr) { if (i + 1 === arr.length) { blk.getView().addClass('as-focus'); } else { blk.getView().removeClass('as-focus'); } }); this.notifyCmdDescriptorsChange(); }; BlockEditor.prototype.deactivateBlock = function (block) { var idx = this.activatedBlocks.indexOf(block); if (idx < 0) return; this.activatedBlocks.splice(idx, 1); block.getView().removeClass('as-activated'); this.notifyCmdDescriptorsChange(); }; BlockEditor.prototype.deleteBlock = function (block) { this.deactivateBlock(block); var idx = this.blocks.indexOf(block); if (idx < 0) return; this.blocks.splice(idx, 1); block.destroy(); block.getView().remove(); this.notifyUnsaved(); }; BlockEditor.prototype.isActivatedBlock = function (block) { return this.activatedBlocks.indexOf(block) >= 0; }; BlockEditor.prototype.setClipboardBlocks = function (blocks) { if (blocks.length === 0) return; var jsonData = JSON.stringify(blocks.map(function (blk) { return blk.getData(); })); _ClipboardManager.default.set(this.clipboardType, jsonData); this.notifyCmdDescriptorsChange(); }; BlockEditor.prototype.getClipboardBlocks = function () { var jsonData = _ClipboardManager.default.get(this.clipboardType); var blocks; try { blocks = jsonData && JSON.parse(jsonData); } catch (err) {} if (blocks && blocks.length > 0) { return blocks; } return null; }; BlockEditor.prototype.findBlockById = function (id) { var block; for (var i = 0; i < this.blocks.length; ++i) { block = this.blocks[i]; if (block._data && block._data.attributes && block._data.attributes.id === id) { return block; } } return null; }; BlockEditor.prototype.ev_blockOrderChange = function (event) { var from = event.from; var to = event.to; var block = this.blocks.splice(from, 1)[0]; this.blocks.splice(to, 0, block); this.notifyUnsaved(); this.layoutEditor.notifyUnsaved(); }; BlockEditor.prototype.notifyUnsaved = function () { this.selfHolder.tabframe.modified = true; this.layoutEditor.notifyUnsaved(); }; BlockEditor.prototype.notifySaved = function () { this.selfHolder.tabframe.modified = false; }; var _default = BlockEditor; exports.default = _default;