@tmagic/editor 1.0.0-beta.8 → 1.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/style.css +24 -10
- package/dist/tmagic-editor.es.js +158 -76
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +160 -79
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/layouts/sidebar/LayerPanel.vue.d.ts +8 -2
- package/dist/types/src/layouts/workspace/Stage.vue.d.ts +2 -1
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +1 -0
- package/dist/types/src/services/editor.d.ts +11 -4
- package/dist/types/src/type.d.ts +1 -0
- package/dist/types/src/utils/editor.d.ts +1 -1
- package/package.json +5 -5
- package/src/components/ToolButton.vue +3 -1
- package/src/layouts/AddPageBox.vue +3 -1
- package/src/layouts/sidebar/LayerPanel.vue +55 -11
- package/src/layouts/workspace/PageBar.vue +9 -4
- package/src/layouts/workspace/Stage.vue +18 -2
- package/src/layouts/workspace/ViewerMenu.vue +5 -3
- package/src/layouts/workspace/Workspace.vue +5 -0
- package/src/services/editor.ts +53 -29
- package/src/theme/common/var.scss +2 -2
- package/src/theme/layer-panel.scss +9 -0
- package/src/theme/page-bar.scss +8 -0
- package/src/type.ts +1 -0
- package/src/utils/editor.ts +4 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('monaco-editor'), require('@element-plus/icons'), require('lodash-es'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('element-plus'), require('@tmagic/stage')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', 'monaco-editor', '@element-plus/icons', 'lodash-es', '@tmagic/utils', 'events', '@tmagic/core', 'element-plus', '@tmagic/stage'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.vue, global.serialize, global.monaco, global.icons, global.lodashEs, global.utils, global.events, global.core, global.elementPlus, global.StageCore));
|
|
5
|
-
})(this, (function (exports, vue, serialize, monaco, icons, lodashEs, utils, events, core, elementPlus, StageCore) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('monaco-editor'), require('@element-plus/icons'), require('@tmagic/schema'), require('lodash-es'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('element-plus'), require('@tmagic/stage')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', 'monaco-editor', '@element-plus/icons', '@tmagic/schema', 'lodash-es', '@tmagic/utils', 'events', '@tmagic/core', 'element-plus', '@tmagic/stage'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.vue, global.serialize, global.monaco, global.icons, global.schema, global.lodashEs, global.utils, global.events, global.core, global.elementPlus, global.StageCore));
|
|
5
|
+
})(this, (function (exports, vue, serialize, monaco, icons, schema, lodashEs, utils, events, core, elementPlus, StageCore) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -194,12 +194,12 @@
|
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
196
|
});
|
|
197
|
-
const _hoisted_1$
|
|
197
|
+
const _hoisted_1$e = /* @__PURE__ */ vue.createElementVNode("i", {
|
|
198
198
|
class: "el-icon-delete",
|
|
199
199
|
style: { "color": "rgb(221, 75, 57)" }
|
|
200
200
|
}, "\u53D6\u6D88", -1);
|
|
201
201
|
const _hoisted_2$7 = [
|
|
202
|
-
_hoisted_1$
|
|
202
|
+
_hoisted_1$e
|
|
203
203
|
];
|
|
204
204
|
const _hoisted_3$5 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-thumb" }, null, -1);
|
|
205
205
|
function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
@@ -343,12 +343,12 @@
|
|
|
343
343
|
};
|
|
344
344
|
}
|
|
345
345
|
});
|
|
346
|
-
const _hoisted_1$
|
|
346
|
+
const _hoisted_1$d = {
|
|
347
347
|
ref: "codeEditor",
|
|
348
348
|
class: "magic-code-editor"
|
|
349
349
|
};
|
|
350
350
|
function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
|
|
351
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
351
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$d, null, 512);
|
|
352
352
|
}
|
|
353
353
|
var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
|
|
354
354
|
|
|
@@ -632,7 +632,7 @@
|
|
|
632
632
|
const generateId = (type) => `${type}_${lodashEs.random(1e4, false)}`;
|
|
633
633
|
const getPageList = (app) => {
|
|
634
634
|
if (app.items && Array.isArray(app.items)) {
|
|
635
|
-
return app.items.filter((item) => item.type ===
|
|
635
|
+
return app.items.filter((item) => item.type === schema.NodeType.PAGE);
|
|
636
636
|
}
|
|
637
637
|
return [];
|
|
638
638
|
};
|
|
@@ -668,7 +668,7 @@
|
|
|
668
668
|
const oldId = config.id;
|
|
669
669
|
config.id = generateId(config.type);
|
|
670
670
|
config.name = `${config.name?.replace(/_(\d+)$/, "")}_${config.id}`;
|
|
671
|
-
if (utils.isPop(config) && parent?.type ===
|
|
671
|
+
if (utils.isPop(config) && parent?.type === schema.NodeType.PAGE) {
|
|
672
672
|
updatePopId(oldId, config.id, parent);
|
|
673
673
|
}
|
|
674
674
|
if (config.items && Array.isArray(config.items)) {
|
|
@@ -781,6 +781,7 @@
|
|
|
781
781
|
parent: null,
|
|
782
782
|
node: null,
|
|
783
783
|
stage: null,
|
|
784
|
+
highlightNode: null,
|
|
784
785
|
modifiedNodeIds: /* @__PURE__ */ new Map()
|
|
785
786
|
});
|
|
786
787
|
constructor() {
|
|
@@ -796,7 +797,8 @@
|
|
|
796
797
|
"alignCenter",
|
|
797
798
|
"moveLayer",
|
|
798
799
|
"undo",
|
|
799
|
-
"redo"
|
|
800
|
+
"redo",
|
|
801
|
+
"highlight"
|
|
800
802
|
]);
|
|
801
803
|
}
|
|
802
804
|
set(name, value) {
|
|
@@ -823,7 +825,7 @@
|
|
|
823
825
|
info.node = path[path.length - 1];
|
|
824
826
|
info.parent = path[path.length - 2];
|
|
825
827
|
path.forEach((item) => {
|
|
826
|
-
if (item.type ===
|
|
828
|
+
if (item.type === schema.NodeType.PAGE) {
|
|
827
829
|
info.page = item;
|
|
828
830
|
return;
|
|
829
831
|
}
|
|
@@ -850,21 +852,7 @@
|
|
|
850
852
|
return Layout.ABSOLUTE;
|
|
851
853
|
}
|
|
852
854
|
async select(config2) {
|
|
853
|
-
|
|
854
|
-
if (typeof config2 === "string" || typeof config2 === "number") {
|
|
855
|
-
id = config2;
|
|
856
|
-
} else {
|
|
857
|
-
id = config2.id;
|
|
858
|
-
}
|
|
859
|
-
if (!id) {
|
|
860
|
-
throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
|
|
861
|
-
}
|
|
862
|
-
const { node, parent, page } = this.getNodeInfo(id);
|
|
863
|
-
if (!node)
|
|
864
|
-
throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
|
|
865
|
-
if (node.id === this.state.root?.id) {
|
|
866
|
-
throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
|
|
867
|
-
}
|
|
855
|
+
const { node, page, parent } = this.selectedConfigExceptionHandler(config2);
|
|
868
856
|
this.set("node", node);
|
|
869
857
|
this.set("page", page || null);
|
|
870
858
|
this.set("parent", parent || null);
|
|
@@ -875,10 +863,17 @@
|
|
|
875
863
|
}
|
|
876
864
|
return node;
|
|
877
865
|
}
|
|
866
|
+
highlight(config2) {
|
|
867
|
+
const { node } = this.selectedConfigExceptionHandler(config2);
|
|
868
|
+
const currentHighligtNode = this.get("highlightNode");
|
|
869
|
+
if (currentHighligtNode === node)
|
|
870
|
+
return;
|
|
871
|
+
this.set("highlightNode", node);
|
|
872
|
+
}
|
|
878
873
|
async add({ type, ...config2 }, parent) {
|
|
879
874
|
const curNode = this.get("node");
|
|
880
875
|
let parentNode;
|
|
881
|
-
if (type ===
|
|
876
|
+
if (type === schema.NodeType.PAGE) {
|
|
882
877
|
parentNode = this.get("root");
|
|
883
878
|
} else if (parent && typeof parent !== "function") {
|
|
884
879
|
parentNode = parent;
|
|
@@ -891,14 +886,16 @@
|
|
|
891
886
|
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
892
887
|
const layout = await this.getLayout(parentNode);
|
|
893
888
|
const newNode = initPosition({ ...vue.toRaw(await propsService.getPropsValue(type)), ...config2 }, layout);
|
|
894
|
-
if ((parentNode?.type ===
|
|
889
|
+
if ((parentNode?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && newNode.type !== schema.NodeType.PAGE) {
|
|
895
890
|
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
896
891
|
}
|
|
897
892
|
parentNode?.items?.push(newNode);
|
|
898
893
|
await this.get("stage")?.add({ config: lodashEs.cloneDeep(newNode), root: lodashEs.cloneDeep(this.get("root")) });
|
|
899
894
|
await this.select(newNode);
|
|
900
895
|
this.addModifiedNodeId(newNode.id);
|
|
901
|
-
|
|
896
|
+
if (type !== schema.NodeType.PAGE) {
|
|
897
|
+
this.pushHistoryState();
|
|
898
|
+
}
|
|
902
899
|
return newNode;
|
|
903
900
|
}
|
|
904
901
|
async remove(node) {
|
|
@@ -915,7 +912,7 @@
|
|
|
915
912
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
916
913
|
parent.items?.splice(index, 1);
|
|
917
914
|
this.get("stage")?.remove({ id: node.id, root: this.get("root") });
|
|
918
|
-
if (node.type ===
|
|
915
|
+
if (node.type === schema.NodeType.PAGE) {
|
|
919
916
|
await this.select(root.items[0] || root);
|
|
920
917
|
} else {
|
|
921
918
|
await this.select(parent);
|
|
@@ -939,7 +936,7 @@
|
|
|
939
936
|
});
|
|
940
937
|
if (!newConfig.type)
|
|
941
938
|
throw new Error("\u914D\u7F6E\u7F3A\u5C11type\u503C");
|
|
942
|
-
if (newConfig.type ===
|
|
939
|
+
if (newConfig.type === schema.NodeType.ROOT) {
|
|
943
940
|
this.set("root", newConfig);
|
|
944
941
|
return newConfig;
|
|
945
942
|
}
|
|
@@ -960,7 +957,7 @@
|
|
|
960
957
|
this.set("node", newConfig);
|
|
961
958
|
}
|
|
962
959
|
this.get("stage")?.update({ config: lodashEs.cloneDeep(newConfig), root: this.get("root") });
|
|
963
|
-
if (newConfig.type ===
|
|
960
|
+
if (newConfig.type === schema.NodeType.PAGE) {
|
|
964
961
|
this.set("page", newConfig);
|
|
965
962
|
}
|
|
966
963
|
this.addModifiedNodeId(newConfig.id);
|
|
@@ -1090,6 +1087,28 @@
|
|
|
1090
1087
|
}
|
|
1091
1088
|
return newConfig;
|
|
1092
1089
|
}
|
|
1090
|
+
selectedConfigExceptionHandler(config2) {
|
|
1091
|
+
let id;
|
|
1092
|
+
if (typeof config2 === "string" || typeof config2 === "number") {
|
|
1093
|
+
id = config2;
|
|
1094
|
+
} else {
|
|
1095
|
+
id = config2.id;
|
|
1096
|
+
}
|
|
1097
|
+
if (!id) {
|
|
1098
|
+
throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
|
|
1099
|
+
}
|
|
1100
|
+
const { node, parent, page } = this.getNodeInfo(id);
|
|
1101
|
+
if (!node)
|
|
1102
|
+
throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
|
|
1103
|
+
if (node.id === this.state.root?.id) {
|
|
1104
|
+
throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
|
|
1105
|
+
}
|
|
1106
|
+
return {
|
|
1107
|
+
node,
|
|
1108
|
+
parent,
|
|
1109
|
+
page
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1093
1112
|
}
|
|
1094
1113
|
var editorService = new Editor$1();
|
|
1095
1114
|
|
|
@@ -1324,20 +1343,20 @@
|
|
|
1324
1343
|
if (!editorService)
|
|
1325
1344
|
return;
|
|
1326
1345
|
editorService.add({
|
|
1327
|
-
type:
|
|
1346
|
+
type: schema.NodeType.PAGE,
|
|
1328
1347
|
name: generatePageNameByApp(vue.toRaw(editorService.get("root")))
|
|
1329
1348
|
});
|
|
1330
1349
|
}
|
|
1331
1350
|
};
|
|
1332
1351
|
}
|
|
1333
1352
|
});
|
|
1334
|
-
const _hoisted_1$
|
|
1353
|
+
const _hoisted_1$c = { class: "m-editor-empty-panel" };
|
|
1335
1354
|
const _hoisted_2$6 = { class: "m-editor-empty-content" };
|
|
1336
1355
|
const _hoisted_3$4 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
1337
1356
|
function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1338
1357
|
const _component_plus = vue.resolveComponent("plus");
|
|
1339
1358
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
1340
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
1359
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, [
|
|
1341
1360
|
vue.createElementVNode("div", _hoisted_2$6, [
|
|
1342
1361
|
vue.createElementVNode("div", {
|
|
1343
1362
|
class: "m-editor-empty-button",
|
|
@@ -2567,12 +2586,12 @@
|
|
|
2567
2586
|
};
|
|
2568
2587
|
}
|
|
2569
2588
|
});
|
|
2570
|
-
const _hoisted_1$
|
|
2589
|
+
const _hoisted_1$b = {
|
|
2571
2590
|
ref: "target",
|
|
2572
2591
|
class: "m-editor-resizer"
|
|
2573
2592
|
};
|
|
2574
2593
|
function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2575
|
-
return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$
|
|
2594
|
+
return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$b, [
|
|
2576
2595
|
vue.renderSlot(_ctx.$slots, "default")
|
|
2577
2596
|
], 512);
|
|
2578
2597
|
}
|
|
@@ -2601,7 +2620,7 @@
|
|
|
2601
2620
|
};
|
|
2602
2621
|
}
|
|
2603
2622
|
});
|
|
2604
|
-
const _hoisted_1$
|
|
2623
|
+
const _hoisted_1$a = { class: "m-editor" };
|
|
2605
2624
|
const _hoisted_2$5 = {
|
|
2606
2625
|
key: 1,
|
|
2607
2626
|
class: "m-editor-content"
|
|
@@ -2611,7 +2630,7 @@
|
|
|
2611
2630
|
const _component_resizer = vue.resolveComponent("resizer");
|
|
2612
2631
|
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
|
|
2613
2632
|
const _component_add_page_box = vue.resolveComponent("add-page-box");
|
|
2614
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
2633
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
|
|
2615
2634
|
vue.renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
2616
2635
|
_ctx.showSrc ? (vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
|
|
2617
2636
|
key: 0,
|
|
@@ -2667,7 +2686,7 @@
|
|
|
2667
2686
|
};
|
|
2668
2687
|
}
|
|
2669
2688
|
});
|
|
2670
|
-
const _hoisted_1$
|
|
2689
|
+
const _hoisted_1$9 = ["src"];
|
|
2671
2690
|
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2672
2691
|
const _component_edit = vue.resolveComponent("edit");
|
|
2673
2692
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
@@ -2679,7 +2698,7 @@
|
|
|
2679
2698
|
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.createElementBlock("img", {
|
|
2680
2699
|
key: 1,
|
|
2681
2700
|
src: _ctx.icon
|
|
2682
|
-
}, null, 8, _hoisted_1$
|
|
2701
|
+
}, null, 8, _hoisted_1$9)) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
|
|
2683
2702
|
key: 2,
|
|
2684
2703
|
class: vue.normalizeClass(_ctx.icon)
|
|
2685
2704
|
}, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
|
|
@@ -2729,7 +2748,7 @@
|
|
|
2729
2748
|
type: "button",
|
|
2730
2749
|
icon: icons.Delete,
|
|
2731
2750
|
tooltip: "\u522A\u9664",
|
|
2732
|
-
disabled: () => services?.editorService.get("node")?.type ===
|
|
2751
|
+
disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
|
|
2733
2752
|
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
2734
2753
|
};
|
|
2735
2754
|
case "undo":
|
|
@@ -2826,7 +2845,7 @@
|
|
|
2826
2845
|
};
|
|
2827
2846
|
}
|
|
2828
2847
|
});
|
|
2829
|
-
const _hoisted_1$
|
|
2848
|
+
const _hoisted_1$8 = {
|
|
2830
2849
|
key: 0,
|
|
2831
2850
|
class: "menu-item"
|
|
2832
2851
|
};
|
|
@@ -2849,7 +2868,7 @@
|
|
|
2849
2868
|
const _component_el_dropdown_item = vue.resolveComponent("el-dropdown-item");
|
|
2850
2869
|
const _component_el_dropdown_menu = vue.resolveComponent("el-dropdown-menu");
|
|
2851
2870
|
const _component_el_dropdown = vue.resolveComponent("el-dropdown");
|
|
2852
|
-
return _ctx.display ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
2871
|
+
return _ctx.display ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
|
|
2853
2872
|
_ctx.item.type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
|
|
2854
2873
|
key: 0,
|
|
2855
2874
|
direction: "vertical"
|
|
@@ -3056,7 +3075,7 @@
|
|
|
3056
3075
|
};
|
|
3057
3076
|
}
|
|
3058
3077
|
});
|
|
3059
|
-
const _hoisted_1$
|
|
3078
|
+
const _hoisted_1$7 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
3060
3079
|
const _hoisted_2$3 = ["onClick"];
|
|
3061
3080
|
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3062
3081
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
@@ -3088,7 +3107,7 @@
|
|
|
3088
3107
|
name: index
|
|
3089
3108
|
}, {
|
|
3090
3109
|
title: vue.withCtx(() => [
|
|
3091
|
-
_hoisted_1$
|
|
3110
|
+
_hoisted_1$7,
|
|
3092
3111
|
vue.createTextVNode(vue.toDisplayString(group.title), 1)
|
|
3093
3112
|
]),
|
|
3094
3113
|
default: vue.withCtx(() => [
|
|
@@ -3169,7 +3188,7 @@
|
|
|
3169
3188
|
};
|
|
3170
3189
|
}
|
|
3171
3190
|
});
|
|
3172
|
-
const _hoisted_1$
|
|
3191
|
+
const _hoisted_1$6 = {
|
|
3173
3192
|
key: 0,
|
|
3174
3193
|
class: "magic-editor-content-menu"
|
|
3175
3194
|
};
|
|
@@ -3178,7 +3197,7 @@
|
|
|
3178
3197
|
const _hoisted_4$2 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
|
|
3179
3198
|
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3180
3199
|
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
|
|
3181
|
-
return _ctx.node ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
3200
|
+
return _ctx.node ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
|
|
3182
3201
|
_ctx.node.items ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3183
3202
|
key: 0,
|
|
3184
3203
|
class: "magic-editor-content-menu-item",
|
|
@@ -3240,20 +3259,27 @@
|
|
|
3240
3259
|
}
|
|
3241
3260
|
var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
|
|
3242
3261
|
|
|
3262
|
+
const throttleTime = 150;
|
|
3243
3263
|
const select = (data, editorService) => {
|
|
3244
3264
|
if (!data.id) {
|
|
3245
3265
|
throw new Error("\u6CA1\u6709id");
|
|
3246
3266
|
}
|
|
3247
3267
|
editorService?.select(data);
|
|
3248
3268
|
};
|
|
3269
|
+
const highlight = (data, editorService) => {
|
|
3270
|
+
if (!data?.id) {
|
|
3271
|
+
throw new Error("\u6CA1\u6709id");
|
|
3272
|
+
}
|
|
3273
|
+
editorService?.highlight(data);
|
|
3274
|
+
};
|
|
3249
3275
|
const useDrop = (tree, editorService) => ({
|
|
3250
3276
|
allowDrop: (draggingNode, dropNode, type) => {
|
|
3251
3277
|
const { data } = dropNode || {};
|
|
3252
3278
|
const { data: ingData } = draggingNode;
|
|
3253
3279
|
const { type: ingType } = ingData;
|
|
3254
|
-
if (ingType !==
|
|
3280
|
+
if (ingType !== schema.NodeType.PAGE && data.type === schema.NodeType.PAGE)
|
|
3255
3281
|
return false;
|
|
3256
|
-
if (ingType ===
|
|
3282
|
+
if (ingType === schema.NodeType.PAGE && data.type !== schema.NodeType.PAGE)
|
|
3257
3283
|
return false;
|
|
3258
3284
|
if (!data || !data.type)
|
|
3259
3285
|
return false;
|
|
@@ -3272,29 +3298,34 @@
|
|
|
3272
3298
|
}
|
|
3273
3299
|
});
|
|
3274
3300
|
const useStatus = (tree, editorService) => {
|
|
3301
|
+
const highlightNode = vue.ref();
|
|
3302
|
+
const node = vue.ref();
|
|
3275
3303
|
const page = vue.computed(() => editorService?.get("page"));
|
|
3276
3304
|
vue.watchEffect(() => {
|
|
3277
3305
|
if (!tree.value)
|
|
3278
3306
|
return;
|
|
3279
|
-
|
|
3280
|
-
node && tree.value.setCurrentKey(node.id, true);
|
|
3307
|
+
node.value = editorService?.get("node");
|
|
3308
|
+
node.value && tree.value.setCurrentKey(node.value.id, true);
|
|
3281
3309
|
const parent = editorService?.get("parent");
|
|
3282
3310
|
if (!parent?.id)
|
|
3283
3311
|
return;
|
|
3284
3312
|
const treeNode = tree.value.getNode(parent.id);
|
|
3285
3313
|
treeNode?.updateChildren();
|
|
3314
|
+
highlightNode.value = editorService?.get("highlightNode");
|
|
3286
3315
|
});
|
|
3287
3316
|
return {
|
|
3288
3317
|
values: vue.computed(() => page.value ? [page.value] : []),
|
|
3289
|
-
loadItems: (
|
|
3290
|
-
if (Array.isArray(
|
|
3291
|
-
return resolve(
|
|
3318
|
+
loadItems: (node2, resolve) => {
|
|
3319
|
+
if (Array.isArray(node2.data)) {
|
|
3320
|
+
return resolve(node2.data);
|
|
3292
3321
|
}
|
|
3293
|
-
if (Array.isArray(
|
|
3294
|
-
return resolve(
|
|
3322
|
+
if (Array.isArray(node2.data?.items)) {
|
|
3323
|
+
return resolve(node2.data?.items);
|
|
3295
3324
|
}
|
|
3296
3325
|
resolve([]);
|
|
3297
|
-
}
|
|
3326
|
+
},
|
|
3327
|
+
highlightNode,
|
|
3328
|
+
clickNode: node
|
|
3298
3329
|
};
|
|
3299
3330
|
};
|
|
3300
3331
|
const useFilter = (tree) => ({
|
|
@@ -3351,11 +3382,20 @@
|
|
|
3351
3382
|
setup() {
|
|
3352
3383
|
const services = vue.inject("services");
|
|
3353
3384
|
const tree = vue.ref();
|
|
3385
|
+
const clicked = vue.ref(false);
|
|
3354
3386
|
const editorService = services?.editorService;
|
|
3387
|
+
const highlightHandler = lodashEs.throttle((data) => {
|
|
3388
|
+
highlight(data, editorService);
|
|
3389
|
+
}, throttleTime);
|
|
3390
|
+
const toogleClickFlag = () => {
|
|
3391
|
+
clicked.value = !clicked.value;
|
|
3392
|
+
};
|
|
3393
|
+
const statusData = useStatus(tree, editorService);
|
|
3394
|
+
const canHighlight = vue.computed(() => statusData.highlightNode.value?.id !== statusData.clickNode.value?.id && !clicked.value);
|
|
3355
3395
|
return {
|
|
3356
3396
|
tree,
|
|
3397
|
+
...statusData,
|
|
3357
3398
|
...useDrop(tree, editorService),
|
|
3358
|
-
...useStatus(tree, editorService),
|
|
3359
3399
|
...useFilter(tree),
|
|
3360
3400
|
...useContentMenu(editorService),
|
|
3361
3401
|
clickHandler(data) {
|
|
@@ -3363,11 +3403,16 @@
|
|
|
3363
3403
|
document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
|
|
3364
3404
|
return;
|
|
3365
3405
|
}
|
|
3406
|
+
tree.value?.setCurrentKey(data.id);
|
|
3366
3407
|
select(data, editorService);
|
|
3367
|
-
}
|
|
3408
|
+
},
|
|
3409
|
+
highlightHandler,
|
|
3410
|
+
toogleClickFlag,
|
|
3411
|
+
canHighlight
|
|
3368
3412
|
};
|
|
3369
3413
|
}
|
|
3370
3414
|
});
|
|
3415
|
+
const _hoisted_1$5 = ["id", "onMouseenter"];
|
|
3371
3416
|
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3372
3417
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
3373
3418
|
const _component_el_tree = vue.resolveComponent("el-tree");
|
|
@@ -3404,12 +3449,20 @@
|
|
|
3404
3449
|
"empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684"
|
|
3405
3450
|
}, {
|
|
3406
3451
|
default: vue.withCtx(({ node, data }) => [
|
|
3407
|
-
vue.
|
|
3408
|
-
|
|
3409
|
-
data
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3452
|
+
vue.createElementVNode("div", {
|
|
3453
|
+
id: data.id,
|
|
3454
|
+
class: vue.normalizeClass(["cus-tree-node", { "cus-tree-node-hover": _ctx.canHighlight && data.id === _ctx.highlightNode?.id }]),
|
|
3455
|
+
onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.toogleClickFlag && _ctx.toogleClickFlag(...args)),
|
|
3456
|
+
onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.toogleClickFlag && _ctx.toogleClickFlag(...args)),
|
|
3457
|
+
onMouseenter: ($event) => _ctx.highlightHandler(data)
|
|
3458
|
+
}, [
|
|
3459
|
+
vue.renderSlot(_ctx.$slots, "layer-node-content", {
|
|
3460
|
+
node,
|
|
3461
|
+
data
|
|
3462
|
+
}, () => [
|
|
3463
|
+
vue.createElementVNode("span", null, vue.toDisplayString(`${data.name} (${data.id})`), 1)
|
|
3464
|
+
])
|
|
3465
|
+
], 42, _hoisted_1$5)
|
|
3413
3466
|
]),
|
|
3414
3467
|
_: 3
|
|
3415
3468
|
}, 8, ["load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : vue.createCommentVNode("", true),
|
|
@@ -3536,7 +3589,7 @@
|
|
|
3536
3589
|
if (!editorService)
|
|
3537
3590
|
return;
|
|
3538
3591
|
const pageConfig = {
|
|
3539
|
-
type:
|
|
3592
|
+
type: schema.NodeType.PAGE,
|
|
3540
3593
|
name: generatePageNameByApp(vue.toRaw(editorService.get("root")))
|
|
3541
3594
|
};
|
|
3542
3595
|
editorService.add(pageConfig);
|
|
@@ -3556,11 +3609,13 @@
|
|
|
3556
3609
|
});
|
|
3557
3610
|
const _hoisted_1$3 = { class: "m-editor-page-bar" };
|
|
3558
3611
|
const _hoisted_2$1 = ["onClick"];
|
|
3559
|
-
const _hoisted_3$1 =
|
|
3612
|
+
const _hoisted_3$1 = { class: "m-editor-page-bar-title" };
|
|
3560
3613
|
const _hoisted_4$1 = ["onClick"];
|
|
3614
|
+
const _hoisted_5 = ["onClick"];
|
|
3561
3615
|
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3562
3616
|
const _component_plus = vue.resolveComponent("plus");
|
|
3563
3617
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
3618
|
+
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
3564
3619
|
const _component_caret_bottom = vue.resolveComponent("caret-bottom");
|
|
3565
3620
|
const _component_el_popover = vue.resolveComponent("el-popover");
|
|
3566
3621
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, [
|
|
@@ -3581,8 +3636,19 @@
|
|
|
3581
3636
|
class: vue.normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
|
|
3582
3637
|
onClick: ($event) => _ctx.switchPage(item)
|
|
3583
3638
|
}, [
|
|
3584
|
-
vue.
|
|
3585
|
-
vue.
|
|
3639
|
+
vue.createElementVNode("div", _hoisted_3$1, [
|
|
3640
|
+
vue.renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
|
|
3641
|
+
vue.createVNode(_component_el_tooltip, {
|
|
3642
|
+
effect: "dark",
|
|
3643
|
+
placement: "top-start",
|
|
3644
|
+
content: item.name
|
|
3645
|
+
}, {
|
|
3646
|
+
default: vue.withCtx(() => [
|
|
3647
|
+
vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
|
|
3648
|
+
]),
|
|
3649
|
+
_: 2
|
|
3650
|
+
}, 1032, ["content"])
|
|
3651
|
+
])
|
|
3586
3652
|
]),
|
|
3587
3653
|
vue.createVNode(_component_el_popover, {
|
|
3588
3654
|
placement: "top",
|
|
@@ -3603,11 +3669,11 @@
|
|
|
3603
3669
|
vue.createElementVNode("div", {
|
|
3604
3670
|
class: "magic-editor-content-menu-item",
|
|
3605
3671
|
onClick: () => _ctx.copy(item)
|
|
3606
|
-
}, "\u590D\u5236", 8,
|
|
3672
|
+
}, "\u590D\u5236", 8, _hoisted_4$1),
|
|
3607
3673
|
vue.createElementVNode("div", {
|
|
3608
3674
|
class: "magic-editor-content-menu-item",
|
|
3609
3675
|
onClick: () => _ctx.remove(item)
|
|
3610
|
-
}, "\u5220\u9664", 8,
|
|
3676
|
+
}, "\u5220\u9664", 8, _hoisted_5)
|
|
3611
3677
|
])
|
|
3612
3678
|
])
|
|
3613
3679
|
]),
|
|
@@ -3856,13 +3922,13 @@
|
|
|
3856
3922
|
if (!parent.value || !editorService)
|
|
3857
3923
|
return canCenter.value = false;
|
|
3858
3924
|
const layout = await editorService.getLayout(parent.value);
|
|
3859
|
-
canCenter.value = [Layout.ABSOLUTE, Layout.FIXED].includes(layout) && ![
|
|
3925
|
+
canCenter.value = [Layout.ABSOLUTE, Layout.FIXED].includes(layout) && ![schema.NodeType.ROOT, schema.NodeType.PAGE, "pop"].includes(`${node.value?.type}`);
|
|
3860
3926
|
}, { immediate: true });
|
|
3861
3927
|
return {
|
|
3862
3928
|
menu,
|
|
3863
3929
|
canPaste,
|
|
3864
|
-
canDelete: vue.computed(() => node.value?.type !==
|
|
3865
|
-
canMoveZPos: vue.computed(() => node.value?.type !==
|
|
3930
|
+
canDelete: vue.computed(() => node.value?.type !== schema.NodeType.PAGE),
|
|
3931
|
+
canMoveZPos: vue.computed(() => node.value?.type !== schema.NodeType.PAGE),
|
|
3866
3932
|
canCenter,
|
|
3867
3933
|
center() {
|
|
3868
3934
|
node.value && editorService?.alignCenter(node.value);
|
|
@@ -4009,7 +4075,7 @@
|
|
|
4009
4075
|
})
|
|
4010
4076
|
}
|
|
4011
4077
|
},
|
|
4012
|
-
emits: ["select", "update", "sort"],
|
|
4078
|
+
emits: ["select", "update", "sort", "highlight"],
|
|
4013
4079
|
setup(props, { emit }) {
|
|
4014
4080
|
const services = vue.inject("services");
|
|
4015
4081
|
const stageWrap = vue.ref();
|
|
@@ -4020,6 +4086,7 @@
|
|
|
4020
4086
|
const page = vue.computed(() => services?.editorService.get("page"));
|
|
4021
4087
|
const zoom = vue.computed(() => services?.uiService.get("zoom"));
|
|
4022
4088
|
const node = vue.computed(() => services?.editorService.get("node"));
|
|
4089
|
+
const highlightNode = vue.computed(() => services?.editorService.get("highlightNode"));
|
|
4023
4090
|
let stage = null;
|
|
4024
4091
|
let runtime = null;
|
|
4025
4092
|
vue.watchEffect(() => {
|
|
@@ -4045,7 +4112,12 @@
|
|
|
4045
4112
|
});
|
|
4046
4113
|
services?.editorService.set("stage", stage);
|
|
4047
4114
|
stage?.mount(stageContainer.value);
|
|
4048
|
-
stage?.on("select", (el) =>
|
|
4115
|
+
stage?.on("select", (el) => {
|
|
4116
|
+
emit("select", el);
|
|
4117
|
+
});
|
|
4118
|
+
stage?.on("highlight", (el) => {
|
|
4119
|
+
emit("highlight", el);
|
|
4120
|
+
});
|
|
4049
4121
|
stage?.on("update", (ev) => {
|
|
4050
4122
|
emit("update", { id: ev.el.id, style: ev.style });
|
|
4051
4123
|
});
|
|
@@ -4081,6 +4153,11 @@
|
|
|
4081
4153
|
id && stage?.select(id);
|
|
4082
4154
|
});
|
|
4083
4155
|
});
|
|
4156
|
+
vue.watch(() => highlightNode.value?.id, (id) => {
|
|
4157
|
+
vue.nextTick(() => {
|
|
4158
|
+
id && stage?.highlight(id);
|
|
4159
|
+
});
|
|
4160
|
+
});
|
|
4084
4161
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
4085
4162
|
for (const { contentRect } of entries) {
|
|
4086
4163
|
services?.uiService.set("stageContainerRect", {
|
|
@@ -4165,6 +4242,9 @@
|
|
|
4165
4242
|
},
|
|
4166
4243
|
sortNodeHandler(ev) {
|
|
4167
4244
|
services?.editorService.sort(ev.src, ev.dist);
|
|
4245
|
+
},
|
|
4246
|
+
highlightHandler(el) {
|
|
4247
|
+
services?.editorService.highlight(el.id);
|
|
4168
4248
|
}
|
|
4169
4249
|
};
|
|
4170
4250
|
}
|
|
@@ -4181,9 +4261,10 @@
|
|
|
4181
4261
|
"moveable-options": _ctx.moveableOptions,
|
|
4182
4262
|
"can-select": _ctx.canSelect,
|
|
4183
4263
|
onSelect: _ctx.selectHandler,
|
|
4264
|
+
onHighlight: _ctx.highlightHandler,
|
|
4184
4265
|
onUpdate: _ctx.updateNodeHandler,
|
|
4185
4266
|
onSort: _ctx.sortNodeHandler
|
|
4186
|
-
}, null, 8, ["runtime-url", "render", "moveable-options", "can-select", "onSelect", "onUpdate", "onSort"])),
|
|
4267
|
+
}, null, 8, ["runtime-url", "render", "moveable-options", "can-select", "onSelect", "onHighlight", "onUpdate", "onSort"])),
|
|
4187
4268
|
vue.renderSlot(_ctx.$slots, "workspace-content"),
|
|
4188
4269
|
vue.createVNode(_component_page_bar, null, {
|
|
4189
4270
|
"page-bar-title": vue.withCtx(({ page }) => [
|