UNPKG

vue-admin-core

Version:
75 lines (70 loc) 2.22 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var snabbdom = require('snabbdom'); var editor = require('@wangeditor/editor'); var mitt = require('./mitt.js'); var plugin = require('./plugin.js'); function renderVariable(elem, children, editor$1) { const selected = editor.DomEditor.isNodeSelected(editor$1, elem); const { label = "", value = "" } = elem; const vnode = snabbdom.h( "span", { props: { contentEditable: false // 不可编辑 }, style: { marginLeft: "3px", marginRight: "3px", backgroundColor: "var(--el-color-primary-light-9)", border: selected ? "2px solid var(--w-e-textarea-selected-border-color)" : "2px solid transparent", borderRadius: "3px", padding: "0 3px", cursor: "pointer", color: "var(--el-color-primary)", borderColor: "var(--el-color-primary-light-8)" }, on: { click: (e) => { if (editor$1.isDisabled()) return; const { top, left, isRight } = plugin.getLeftAndTop(editor$1, elem); const { width, height } = e.target.getBoundingClientRect(); mitt.default.emit("show", { top: top + height, left: left - (!isRight ? width : 0), value }); setTimeout(() => { function _hide() { mitt.default.emit("hide", editor$1); } editor$1.once("fullScreen", _hide); editor$1.once("unFullScreen", _hide); editor$1.once("scroll", _hide); editor$1.once("modalOrPanelShow", _hide); editor$1.once("modalOrPanelHide", _hide); function hideOnChange() { if (editor$1.selection != null) { _hide(); editor$1.off("change", hideOnChange); } } editor$1.on("change", hideOnChange); }); } } }, `${label}` // 如 `${张三}` ); return vnode; } const conf = { type: "variable", // 节点 type ,重要!!! renderElem: renderVariable }; exports.default = conf; //# sourceMappingURL=render-elem.js.map