@tmagic/editor 1.1.0-beta.9 → 1.1.2
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 +53 -4
- package/dist/tmagic-editor.mjs +1134 -928
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +1138 -929
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +10 -10
- package/src/Editor.vue +28 -8
- package/src/components/ContentMenu.vue +4 -4
- package/src/components/Icon.vue +11 -23
- package/src/components/ScrollBar.vue +147 -0
- package/src/components/ScrollViewer.vue +89 -44
- package/src/components/ToolButton.vue +40 -138
- package/src/fields/UISelect.vue +2 -2
- package/src/index.ts +2 -2
- package/src/layouts/NavMenu.vue +156 -23
- package/src/layouts/PropsPanel.vue +49 -51
- package/src/layouts/sidebar/ComponentListPanel.vue +78 -90
- package/src/layouts/sidebar/LayerMenu.vue +3 -3
- package/src/layouts/sidebar/LayerPanel.vue +39 -8
- package/src/layouts/sidebar/Sidebar.vue +4 -0
- package/src/layouts/sidebar/TabPane.vue +12 -0
- package/src/layouts/workspace/PageBar.vue +2 -2
- package/src/layouts/workspace/PageBarScrollContainer.vue +13 -3
- package/src/layouts/workspace/Stage.vue +10 -92
- package/src/layouts/workspace/ViewerMenu.vue +3 -3
- package/src/layouts/workspace/Workspace.vue +133 -138
- package/src/services/componentList.ts +5 -0
- package/src/services/editor.ts +57 -20
- package/src/services/events.ts +8 -2
- package/src/services/props.ts +31 -52
- package/src/services/storage.ts +4 -0
- package/src/services/ui.ts +33 -30
- package/src/theme/component-list-panel.scss +0 -5
- package/src/theme/content-menu.scss +4 -0
- package/src/theme/icon.scss +6 -0
- package/src/theme/index.scss +1 -0
- package/src/theme/nav-menu.scss +6 -0
- package/src/type.ts +28 -10
- package/src/utils/index.ts +1 -0
- package/src/utils/operator.ts +3 -3
- package/src/utils/props.ts +0 -3
- package/src/utils/scroll-viewer.ts +90 -158
- package/src/utils/stage.ts +91 -0
- package/types/Editor.vue.d.ts +7 -7
- package/types/components/ContentMenu.vue.d.ts +8 -8
- package/types/components/Icon.vue.d.ts +62 -12
- package/types/components/ScrollBar.vue.d.ts +83 -0
- package/types/components/ScrollViewer.vue.d.ts +131 -19
- package/types/components/ToolButton.vue.d.ts +56 -59
- package/types/index.d.ts +2 -1
- package/types/layouts/NavMenu.vue.d.ts +92 -23
- package/types/layouts/PropsPanel.vue.d.ts +25 -208
- package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +50 -12
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +7 -7
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +17 -15
- package/types/layouts/workspace/Workspace.vue.d.ts +54 -4
- package/types/services/componentList.d.ts +1 -0
- package/types/services/editor.d.ts +1 -0
- package/types/services/events.d.ts +1 -0
- package/types/services/props.d.ts +41 -9
- package/types/services/storage.d.ts +1 -0
- package/types/services/ui.d.ts +4 -1
- package/types/type.d.ts +25 -10
- package/types/utils/index.d.ts +1 -0
- package/types/utils/operator.d.ts +1 -1
- package/types/utils/props.d.ts +0 -1
- package/types/utils/scroll-viewer.d.ts +16 -18
- package/types/utils/stage.d.ts +3 -0
- package/src/utils/polyfills.ts +0 -8
- package/types/utils/polyfills.d.ts +0 -0
|
@@ -30,14 +30,7 @@
|
|
|
30
30
|
const Gesto__default = /*#__PURE__*/_interopDefaultLegacy(Gesto);
|
|
31
31
|
const KeyController__default = /*#__PURE__*/_interopDefaultLegacy(KeyController);
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
window.global = window;
|
|
35
|
-
}
|
|
36
|
-
if (typeof globalThis === "undefined") {
|
|
37
|
-
window.globalThis = window;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const _sfc_main$n = vue.defineComponent({
|
|
33
|
+
const _sfc_main$o = vue.defineComponent({
|
|
41
34
|
name: "m-fields-vs-code",
|
|
42
35
|
props: ["model", "name", "config", "prop"],
|
|
43
36
|
emits: ["change"],
|
|
@@ -63,7 +56,7 @@
|
|
|
63
56
|
return target;
|
|
64
57
|
};
|
|
65
58
|
|
|
66
|
-
function _sfc_render$
|
|
59
|
+
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
67
60
|
const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
|
|
68
61
|
return vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
|
|
69
62
|
style: vue.normalizeStyle(`height: ${_ctx.height}`),
|
|
@@ -72,9 +65,9 @@
|
|
|
72
65
|
onSave: _ctx.save
|
|
73
66
|
}, null, 8, ["style", "init-values", "language", "onSave"]);
|
|
74
67
|
}
|
|
75
|
-
const Code = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
68
|
+
const Code = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["render", _sfc_render$a]]);
|
|
76
69
|
|
|
77
|
-
const _sfc_main$
|
|
70
|
+
const _sfc_main$n = vue.defineComponent({
|
|
78
71
|
name: "m-fields-code-link",
|
|
79
72
|
props: {
|
|
80
73
|
config: {
|
|
@@ -130,7 +123,7 @@
|
|
|
130
123
|
}
|
|
131
124
|
});
|
|
132
125
|
|
|
133
|
-
function _sfc_render$
|
|
126
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
134
127
|
const _component_m_fields_link = vue.resolveComponent("m-fields-link");
|
|
135
128
|
return vue.openBlock(), vue.createBlock(_component_m_fields_link, {
|
|
136
129
|
config: _ctx.formConfig,
|
|
@@ -139,10 +132,10 @@
|
|
|
139
132
|
onChange: _ctx.changeHandler
|
|
140
133
|
}, null, 8, ["config", "model", "onChange"]);
|
|
141
134
|
}
|
|
142
|
-
const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
135
|
+
const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$9]]);
|
|
143
136
|
|
|
144
|
-
const _hoisted_1$
|
|
145
|
-
const _sfc_main$
|
|
137
|
+
const _hoisted_1$c = /* @__PURE__ */ vue.createTextVNode("\u53D6\u6D88");
|
|
138
|
+
const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
|
|
146
139
|
__name: "UISelect",
|
|
147
140
|
props: {
|
|
148
141
|
config: null,
|
|
@@ -207,7 +200,7 @@
|
|
|
207
200
|
style: { "padding": "0" }
|
|
208
201
|
}, {
|
|
209
202
|
default: vue.withCtx(() => [
|
|
210
|
-
_hoisted_1$
|
|
203
|
+
_hoisted_1$c
|
|
211
204
|
]),
|
|
212
205
|
_: 1
|
|
213
206
|
}, 8, ["icon"])
|
|
@@ -217,19 +210,21 @@
|
|
|
217
210
|
onClick: startSelect,
|
|
218
211
|
style: { "display": "flex" }
|
|
219
212
|
}, [
|
|
220
|
-
vue.
|
|
213
|
+
vue.unref(val) ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
|
|
214
|
+
key: 0,
|
|
215
|
+
content: "\u6E05\u9664"
|
|
216
|
+
}, {
|
|
221
217
|
default: vue.withCtx(() => [
|
|
222
|
-
vue.
|
|
223
|
-
key: 0,
|
|
218
|
+
vue.createVNode(_component_el_button, {
|
|
224
219
|
style: { "padding": "0" },
|
|
225
220
|
type: "danger",
|
|
226
221
|
icon: vue.unref(iconsVue.Close),
|
|
227
222
|
text: "",
|
|
228
223
|
onClick: vue.withModifiers(deleteHandler, ["stop"])
|
|
229
|
-
}, null, 8, ["icon", "onClick"])
|
|
224
|
+
}, null, 8, ["icon", "onClick"])
|
|
230
225
|
]),
|
|
231
226
|
_: 1
|
|
232
|
-
}),
|
|
227
|
+
})) : vue.createCommentVNode("", true),
|
|
233
228
|
vue.createVNode(_component_el_tooltip, {
|
|
234
229
|
content: vue.unref(val) ? vue.unref(toName) + "_" + vue.unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
|
|
235
230
|
}, {
|
|
@@ -268,7 +263,7 @@
|
|
|
268
263
|
}
|
|
269
264
|
return value;
|
|
270
265
|
};
|
|
271
|
-
const _sfc_main$
|
|
266
|
+
const _sfc_main$l = vue.defineComponent({
|
|
272
267
|
name: "magic-code-editor",
|
|
273
268
|
props: {
|
|
274
269
|
initValues: {
|
|
@@ -376,14 +371,14 @@
|
|
|
376
371
|
}
|
|
377
372
|
});
|
|
378
373
|
|
|
379
|
-
const _hoisted_1$
|
|
374
|
+
const _hoisted_1$b = {
|
|
380
375
|
ref: "codeEditor",
|
|
381
376
|
class: "magic-code-editor"
|
|
382
377
|
};
|
|
383
|
-
function _sfc_render$
|
|
384
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
378
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
379
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, null, 512);
|
|
385
380
|
}
|
|
386
|
-
const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
381
|
+
const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$8]]);
|
|
387
382
|
|
|
388
383
|
let $TMAGIC_EDITOR = {};
|
|
389
384
|
const setConfig = (option) => {
|
|
@@ -691,6 +686,9 @@
|
|
|
691
686
|
}
|
|
692
687
|
storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
|
|
693
688
|
}
|
|
689
|
+
destroy() {
|
|
690
|
+
this.removeAllListeners();
|
|
691
|
+
}
|
|
694
692
|
getValueAndProtocol(value) {
|
|
695
693
|
let protocol2 = "";
|
|
696
694
|
if (value === null) {
|
|
@@ -711,6 +709,12 @@
|
|
|
711
709
|
}
|
|
712
710
|
const storageService = new WebStorage();
|
|
713
711
|
|
|
712
|
+
var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
|
|
713
|
+
ColumnLayout2["LEFT"] = "left";
|
|
714
|
+
ColumnLayout2["CENTER"] = "center";
|
|
715
|
+
ColumnLayout2["RIGHT"] = "right";
|
|
716
|
+
return ColumnLayout2;
|
|
717
|
+
})(ColumnLayout || {});
|
|
714
718
|
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
715
719
|
LayerOffset2["TOP"] = "top";
|
|
716
720
|
LayerOffset2["BOTTOM"] = "bottom";
|
|
@@ -895,6 +899,7 @@
|
|
|
895
899
|
"getPropsValue",
|
|
896
900
|
"createId",
|
|
897
901
|
"setNewItemId",
|
|
902
|
+
"fillConfig",
|
|
898
903
|
"getDefaultPropsValue"
|
|
899
904
|
]);
|
|
900
905
|
}
|
|
@@ -904,14 +909,17 @@
|
|
|
904
909
|
});
|
|
905
910
|
this.emit("props-configs-change");
|
|
906
911
|
}
|
|
907
|
-
|
|
908
|
-
|
|
912
|
+
async fillConfig(config) {
|
|
913
|
+
return fillConfig(config);
|
|
914
|
+
}
|
|
915
|
+
async setPropsConfig(type, config) {
|
|
916
|
+
this.state.propsConfigMap[type] = await this.fillConfig(Array.isArray(config) ? config : [config]);
|
|
909
917
|
}
|
|
910
918
|
async getPropsConfig(type) {
|
|
911
919
|
if (type === "area") {
|
|
912
920
|
return await this.getPropsConfig("button");
|
|
913
921
|
}
|
|
914
|
-
return lodashEs.cloneDeep(this.state.propsConfigMap[type] ||
|
|
922
|
+
return lodashEs.cloneDeep(this.state.propsConfigMap[type] || await this.fillConfig([]));
|
|
915
923
|
}
|
|
916
924
|
setPropsValues(values) {
|
|
917
925
|
Object.keys(values).forEach((type) => {
|
|
@@ -945,25 +953,14 @@
|
|
|
945
953
|
...lodashEs.mergeWith({}, lodashEs.cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
946
954
|
};
|
|
947
955
|
}
|
|
948
|
-
guid(digit = 8) {
|
|
949
|
-
return "x".repeat(digit).replace(/[xy]/g, (c) => {
|
|
950
|
-
const r = Math.random() * 16 | 0;
|
|
951
|
-
const v = c == "x" ? r : r & 3 | 8;
|
|
952
|
-
return v.toString(16);
|
|
953
|
-
});
|
|
954
|
-
}
|
|
955
956
|
async createId(type) {
|
|
956
957
|
return `${type}_${this.guid()}`;
|
|
957
958
|
}
|
|
958
|
-
async setNewItemId(config
|
|
959
|
-
const oldId = config.id;
|
|
959
|
+
async setNewItemId(config) {
|
|
960
960
|
config.id = await this.createId(config.type || "component");
|
|
961
|
-
if (utils.isPop(config) && parent?.type === schema.NodeType.PAGE) {
|
|
962
|
-
updatePopId(oldId, config.id, parent);
|
|
963
|
-
}
|
|
964
961
|
if (config.items && Array.isArray(config.items)) {
|
|
965
962
|
for (const item of config.items) {
|
|
966
|
-
await this.setNewItemId(item
|
|
963
|
+
await this.setNewItemId(item);
|
|
967
964
|
}
|
|
968
965
|
}
|
|
969
966
|
return config;
|
|
@@ -981,22 +978,19 @@
|
|
|
981
978
|
name: type
|
|
982
979
|
};
|
|
983
980
|
}
|
|
981
|
+
destroy() {
|
|
982
|
+
this.state.propsConfigMap = {};
|
|
983
|
+
this.state.propsValueMap = {};
|
|
984
|
+
this.removeAllListeners();
|
|
985
|
+
}
|
|
986
|
+
guid(digit = 8) {
|
|
987
|
+
return "x".repeat(digit).replace(/[xy]/g, (c) => {
|
|
988
|
+
const r = Math.random() * 16 | 0;
|
|
989
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
990
|
+
return v.toString(16);
|
|
991
|
+
});
|
|
992
|
+
}
|
|
984
993
|
}
|
|
985
|
-
const updatePopId = (oldId, popId, pageConfig) => {
|
|
986
|
-
pageConfig.items?.forEach((config) => {
|
|
987
|
-
if (config.pop === oldId) {
|
|
988
|
-
config.pop = popId;
|
|
989
|
-
return;
|
|
990
|
-
}
|
|
991
|
-
if (config.popId === oldId) {
|
|
992
|
-
config.popId = popId;
|
|
993
|
-
return;
|
|
994
|
-
}
|
|
995
|
-
if (Array.isArray(config.items)) {
|
|
996
|
-
updatePopId(oldId, popId, config);
|
|
997
|
-
}
|
|
998
|
-
});
|
|
999
|
-
};
|
|
1000
994
|
const propsService = new Props();
|
|
1001
995
|
|
|
1002
996
|
const beforePaste = async (position, config) => {
|
|
@@ -1016,7 +1010,7 @@
|
|
|
1016
1010
|
if (pastePosition.top && configItem.style?.top) {
|
|
1017
1011
|
pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
|
|
1018
1012
|
}
|
|
1019
|
-
const pasteConfig = await propsService.setNewItemId(configItem
|
|
1013
|
+
const pasteConfig = await propsService.setNewItemId(configItem);
|
|
1020
1014
|
if (pasteConfig.style) {
|
|
1021
1015
|
const { left, top } = pasteConfig.style;
|
|
1022
1016
|
if (typeof left === "number" || !!left && !isNaN(Number(left))) {
|
|
@@ -1048,10 +1042,10 @@
|
|
|
1048
1042
|
top
|
|
1049
1043
|
};
|
|
1050
1044
|
};
|
|
1051
|
-
const getAddParent = (
|
|
1045
|
+
const getAddParent = (node) => {
|
|
1052
1046
|
const curNode = editorService.get("node");
|
|
1053
1047
|
let parentNode;
|
|
1054
|
-
if (
|
|
1048
|
+
if (utils.isPage(node)) {
|
|
1055
1049
|
parentNode = editorService.get("root");
|
|
1056
1050
|
} else if (curNode.items) {
|
|
1057
1051
|
parentNode = curNode;
|
|
@@ -1087,6 +1081,7 @@
|
|
|
1087
1081
|
"sort",
|
|
1088
1082
|
"copy",
|
|
1089
1083
|
"paste",
|
|
1084
|
+
"doPaste",
|
|
1090
1085
|
"duAlignCenter",
|
|
1091
1086
|
"alignCenter",
|
|
1092
1087
|
"moveLayer",
|
|
@@ -1223,20 +1218,27 @@
|
|
|
1223
1218
|
if ((parent?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && node.type !== schema.NodeType.PAGE) {
|
|
1224
1219
|
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
1225
1220
|
}
|
|
1221
|
+
if (parent.id !== curNode.id) {
|
|
1222
|
+
const index = parent.items.indexOf(curNode);
|
|
1223
|
+
parent?.items?.splice(index + 1, 0, node);
|
|
1224
|
+
} else {
|
|
1225
|
+
parent?.items?.push(node);
|
|
1226
|
+
}
|
|
1226
1227
|
const layout = await this.getLayout(vue.toRaw(parent), node);
|
|
1227
1228
|
node.style = getInitPositionStyle(node.style, layout);
|
|
1228
|
-
await stage?.add({
|
|
1229
|
+
await stage?.add({
|
|
1230
|
+
config: lodashEs.cloneDeep(node),
|
|
1231
|
+
parent: lodashEs.cloneDeep(parent),
|
|
1232
|
+
parentId: parent.id,
|
|
1233
|
+
root: lodashEs.cloneDeep(root)
|
|
1234
|
+
});
|
|
1229
1235
|
node.style = fixNodePosition(node, parent, stage);
|
|
1230
|
-
await stage?.update({ config: lodashEs.cloneDeep(node), root: lodashEs.cloneDeep(root) });
|
|
1231
|
-
parent?.items?.push(node);
|
|
1236
|
+
await stage?.update({ config: lodashEs.cloneDeep(node), parentId: parent.id, root: lodashEs.cloneDeep(root) });
|
|
1232
1237
|
this.addModifiedNodeId(node.id);
|
|
1233
1238
|
return node;
|
|
1234
1239
|
}
|
|
1235
1240
|
async add(addNode, parent) {
|
|
1236
1241
|
const stage = this.get("stage");
|
|
1237
|
-
const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(addNode);
|
|
1238
|
-
if (!parentNode)
|
|
1239
|
-
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1240
1242
|
const addNodes = [];
|
|
1241
1243
|
if (!Array.isArray(addNode)) {
|
|
1242
1244
|
const { type, inputEvent, ...config } = addNode;
|
|
@@ -1246,7 +1248,12 @@
|
|
|
1246
1248
|
} else {
|
|
1247
1249
|
addNodes.push(...addNode);
|
|
1248
1250
|
}
|
|
1249
|
-
const newNodes = await Promise.all(addNodes.map((node) =>
|
|
1251
|
+
const newNodes = await Promise.all(addNodes.map((node) => {
|
|
1252
|
+
const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
|
|
1253
|
+
if (!parentNode)
|
|
1254
|
+
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1255
|
+
return this.doAdd(node, parentNode);
|
|
1256
|
+
}));
|
|
1250
1257
|
if (newNodes.length > 1) {
|
|
1251
1258
|
const newNodeIds = newNodes.map((node) => node.id);
|
|
1252
1259
|
stage?.multiSelect(newNodeIds);
|
|
@@ -1261,7 +1268,7 @@
|
|
|
1261
1268
|
}
|
|
1262
1269
|
this.pushHistoryState();
|
|
1263
1270
|
this.emit("add", newNodes);
|
|
1264
|
-
return
|
|
1271
|
+
return Array.isArray(addNode) ? newNodes : newNodes[0];
|
|
1265
1272
|
}
|
|
1266
1273
|
async doRemove(node) {
|
|
1267
1274
|
const root = this.get("root");
|
|
@@ -1275,14 +1282,14 @@
|
|
|
1275
1282
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1276
1283
|
parent.items?.splice(index, 1);
|
|
1277
1284
|
const stage = this.get("stage");
|
|
1278
|
-
stage?.remove({ id: node.id, root:
|
|
1285
|
+
stage?.remove({ id: node.id, parentId: parent.id, root: lodashEs.cloneDeep(root) });
|
|
1279
1286
|
if (node.type === schema.NodeType.PAGE) {
|
|
1280
1287
|
this.state.pageLength -= 1;
|
|
1281
1288
|
if (root.items[0]) {
|
|
1282
1289
|
await this.select(root.items[0]);
|
|
1283
1290
|
stage?.select(root.items[0].id);
|
|
1284
1291
|
} else {
|
|
1285
|
-
this.set("
|
|
1292
|
+
this.set("nodes", [root]);
|
|
1286
1293
|
this.set("parent", null);
|
|
1287
1294
|
this.set("page", null);
|
|
1288
1295
|
this.set("stage", null);
|
|
@@ -1301,7 +1308,7 @@
|
|
|
1301
1308
|
const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
|
|
1302
1309
|
await Promise.all(nodes.map((node) => this.doRemove(node)));
|
|
1303
1310
|
this.pushHistoryState();
|
|
1304
|
-
this.emit("remove");
|
|
1311
|
+
this.emit("remove", nodes);
|
|
1305
1312
|
}
|
|
1306
1313
|
async doUpdate(config) {
|
|
1307
1314
|
if (!config?.id)
|
|
@@ -1339,7 +1346,11 @@
|
|
|
1339
1346
|
const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
|
|
1340
1347
|
nodes.splice(targetIndex, 1, newConfig);
|
|
1341
1348
|
this.set("nodes", nodes);
|
|
1342
|
-
this.get("stage")?.update({
|
|
1349
|
+
this.get("stage")?.update({
|
|
1350
|
+
config: lodashEs.cloneDeep(newConfig),
|
|
1351
|
+
parentId: parent.id,
|
|
1352
|
+
root: lodashEs.cloneDeep(this.get("root"))
|
|
1353
|
+
});
|
|
1343
1354
|
if (newConfig.type === schema.NodeType.PAGE) {
|
|
1344
1355
|
this.set("page", newConfig);
|
|
1345
1356
|
}
|
|
@@ -1351,7 +1362,7 @@
|
|
|
1351
1362
|
const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
|
|
1352
1363
|
this.pushHistoryState();
|
|
1353
1364
|
this.emit("update", newNodes);
|
|
1354
|
-
return
|
|
1365
|
+
return Array.isArray(config) ? newNodes : newNodes[0];
|
|
1355
1366
|
}
|
|
1356
1367
|
async sort(id1, id2) {
|
|
1357
1368
|
const node = this.get("node");
|
|
@@ -1363,7 +1374,11 @@
|
|
|
1363
1374
|
parent.items.splice(index2, 0, ...parent.items.splice(index1, 1));
|
|
1364
1375
|
await this.update(parent);
|
|
1365
1376
|
await this.select(node);
|
|
1366
|
-
this.get("stage")?.update({
|
|
1377
|
+
this.get("stage")?.update({
|
|
1378
|
+
config: lodashEs.cloneDeep(node),
|
|
1379
|
+
parentId: parent.id,
|
|
1380
|
+
root: lodashEs.cloneDeep(this.get("root"))
|
|
1381
|
+
});
|
|
1367
1382
|
this.addModifiedNodeId(parent.id);
|
|
1368
1383
|
this.pushHistoryState();
|
|
1369
1384
|
}
|
|
@@ -1376,9 +1391,13 @@
|
|
|
1376
1391
|
const config = await storageService.getItem(COPY_STORAGE_KEY);
|
|
1377
1392
|
if (!Array.isArray(config))
|
|
1378
1393
|
return;
|
|
1379
|
-
const pasteConfigs = await
|
|
1394
|
+
const pasteConfigs = await this.doPaste(config, position);
|
|
1380
1395
|
return this.add(pasteConfigs);
|
|
1381
1396
|
}
|
|
1397
|
+
async doPaste(config, position = {}) {
|
|
1398
|
+
const pasteConfigs = await beforePaste(position, lodashEs.cloneDeep(config));
|
|
1399
|
+
return pasteConfigs;
|
|
1400
|
+
}
|
|
1382
1401
|
async doAlignCenter(config) {
|
|
1383
1402
|
const parent = this.getParentById(config.id);
|
|
1384
1403
|
if (!parent)
|
|
@@ -1423,10 +1442,14 @@
|
|
|
1423
1442
|
} else {
|
|
1424
1443
|
brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
|
|
1425
1444
|
}
|
|
1445
|
+
const grandparent = this.getParentById(parent.id);
|
|
1426
1446
|
this.get("stage")?.update({
|
|
1427
1447
|
config: lodashEs.cloneDeep(vue.toRaw(parent)),
|
|
1448
|
+
parentId: grandparent?.id,
|
|
1428
1449
|
root: lodashEs.cloneDeep(this.get("root"))
|
|
1429
1450
|
});
|
|
1451
|
+
this.addModifiedNodeId(parent.id);
|
|
1452
|
+
this.pushHistoryState();
|
|
1430
1453
|
}
|
|
1431
1454
|
async moveToContainer(config, targetId) {
|
|
1432
1455
|
const { node, parent } = this.getNodeInfo(config.id, false);
|
|
@@ -1436,7 +1459,7 @@
|
|
|
1436
1459
|
const root = lodashEs.cloneDeep(this.get("root"));
|
|
1437
1460
|
const index = getNodeIndex(node, parent);
|
|
1438
1461
|
parent.items?.splice(index, 1);
|
|
1439
|
-
await stage.remove({ id: node.id, root });
|
|
1462
|
+
await stage.remove({ id: node.id, parentId: parent.id, root });
|
|
1440
1463
|
const layout = await this.getLayout(target);
|
|
1441
1464
|
const newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), config, (objValue, srcValue) => {
|
|
1442
1465
|
if (Array.isArray(srcValue)) {
|
|
@@ -1446,7 +1469,8 @@
|
|
|
1446
1469
|
newConfig.style = getInitPositionStyle(newConfig.style, layout);
|
|
1447
1470
|
target.items.push(newConfig);
|
|
1448
1471
|
await stage.select(targetId);
|
|
1449
|
-
|
|
1472
|
+
const targetParent = this.getParentById(target.id);
|
|
1473
|
+
await stage.update({ config: lodashEs.cloneDeep(target), parentId: targetParent?.id, root });
|
|
1450
1474
|
await this.select(newConfig);
|
|
1451
1475
|
stage.select(newConfig.id);
|
|
1452
1476
|
this.addModifiedNodeId(target.id);
|
|
@@ -1493,6 +1517,10 @@
|
|
|
1493
1517
|
this.set("nodes", []);
|
|
1494
1518
|
this.set("page", null);
|
|
1495
1519
|
this.set("parent", null);
|
|
1520
|
+
this.set("stage", null);
|
|
1521
|
+
this.set("highlightNode", null);
|
|
1522
|
+
this.set("modifiedNodeIds", /* @__PURE__ */ new Map());
|
|
1523
|
+
this.set("pageLength", /* @__PURE__ */ new Map());
|
|
1496
1524
|
}
|
|
1497
1525
|
resetModifiedNodeId() {
|
|
1498
1526
|
this.get("modifiedNodeIds").clear();
|
|
@@ -1562,8 +1590,8 @@
|
|
|
1562
1590
|
}
|
|
1563
1591
|
const editorService = new Editor$1();
|
|
1564
1592
|
|
|
1565
|
-
|
|
1566
|
-
|
|
1593
|
+
let eventMap = vue.reactive({});
|
|
1594
|
+
let methodMap = vue.reactive({});
|
|
1567
1595
|
class Events extends BaseService {
|
|
1568
1596
|
constructor() {
|
|
1569
1597
|
super([]);
|
|
@@ -1603,6 +1631,11 @@
|
|
|
1603
1631
|
getMethod(type) {
|
|
1604
1632
|
return lodashEs.cloneDeep(methodMap[type] || core.DEFAULT_METHODS);
|
|
1605
1633
|
}
|
|
1634
|
+
destroy() {
|
|
1635
|
+
eventMap = vue.reactive({});
|
|
1636
|
+
methodMap = vue.reactive({});
|
|
1637
|
+
this.removeAllListeners();
|
|
1638
|
+
}
|
|
1606
1639
|
}
|
|
1607
1640
|
const eventsService = new Events();
|
|
1608
1641
|
|
|
@@ -1809,7 +1842,6 @@
|
|
|
1809
1842
|
]
|
|
1810
1843
|
}
|
|
1811
1844
|
];
|
|
1812
|
-
const DEFAULT_CONFIG = fillConfig([]);
|
|
1813
1845
|
|
|
1814
1846
|
const log = (...args) => {
|
|
1815
1847
|
if (process.env.NODE_ENV === "development") {
|
|
@@ -1837,7 +1869,195 @@
|
|
|
1837
1869
|
}
|
|
1838
1870
|
};
|
|
1839
1871
|
|
|
1840
|
-
const
|
|
1872
|
+
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
1873
|
+
const MIN_LEFT_COLUMN_WIDTH = 45;
|
|
1874
|
+
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
1875
|
+
const MIN_RIGHT_COLUMN_WIDTH = 1;
|
|
1876
|
+
const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
|
|
1877
|
+
const defaultColumnWidth = {
|
|
1878
|
+
left: DEFAULT_LEFT_COLUMN_WIDTH,
|
|
1879
|
+
center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
|
|
1880
|
+
right: DEFAULT_RIGHT_COLUMN_WIDTH
|
|
1881
|
+
};
|
|
1882
|
+
const state = vue.reactive({
|
|
1883
|
+
uiSelectMode: false,
|
|
1884
|
+
showSrc: false,
|
|
1885
|
+
zoom: 1,
|
|
1886
|
+
stageContainerRect: {
|
|
1887
|
+
width: 0,
|
|
1888
|
+
height: 0
|
|
1889
|
+
},
|
|
1890
|
+
stageRect: {
|
|
1891
|
+
width: 375,
|
|
1892
|
+
height: 817
|
|
1893
|
+
},
|
|
1894
|
+
columnWidth: defaultColumnWidth,
|
|
1895
|
+
showGuides: true,
|
|
1896
|
+
showRule: true,
|
|
1897
|
+
propsPanelSize: "small",
|
|
1898
|
+
showAddPageButton: true
|
|
1899
|
+
});
|
|
1900
|
+
class Ui extends BaseService {
|
|
1901
|
+
constructor() {
|
|
1902
|
+
super([]);
|
|
1903
|
+
globalThis.addEventListener("resize", () => {
|
|
1904
|
+
this.setColumnWidth({
|
|
1905
|
+
center: "auto"
|
|
1906
|
+
});
|
|
1907
|
+
});
|
|
1908
|
+
}
|
|
1909
|
+
set(name, value) {
|
|
1910
|
+
const mask = editorService.get("stage")?.mask;
|
|
1911
|
+
if (name === "columnWidth") {
|
|
1912
|
+
this.setColumnWidth(value);
|
|
1913
|
+
return;
|
|
1914
|
+
}
|
|
1915
|
+
if (name === "stageRect") {
|
|
1916
|
+
this.setStageRect(value);
|
|
1917
|
+
return;
|
|
1918
|
+
}
|
|
1919
|
+
if (name === "showGuides") {
|
|
1920
|
+
mask?.showGuides(value);
|
|
1921
|
+
}
|
|
1922
|
+
if (name === "showRule") {
|
|
1923
|
+
mask?.showRule(value);
|
|
1924
|
+
}
|
|
1925
|
+
state[name] = value;
|
|
1926
|
+
}
|
|
1927
|
+
get(name) {
|
|
1928
|
+
return state[name];
|
|
1929
|
+
}
|
|
1930
|
+
initColumnWidth() {
|
|
1931
|
+
const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
|
|
1932
|
+
if (columnWidthCacheData) {
|
|
1933
|
+
try {
|
|
1934
|
+
const columnWidthCache = JSON.parse(columnWidthCacheData);
|
|
1935
|
+
this.setColumnWidth(columnWidthCache);
|
|
1936
|
+
} catch (e) {
|
|
1937
|
+
console.error(e);
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
zoom(zoom) {
|
|
1942
|
+
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
1943
|
+
if (this.get("zoom") < 0.1)
|
|
1944
|
+
this.set("zoom", 0.1);
|
|
1945
|
+
}
|
|
1946
|
+
calcZoom() {
|
|
1947
|
+
const { stageRect, stageContainerRect } = state;
|
|
1948
|
+
const { height, width } = stageContainerRect;
|
|
1949
|
+
if (!width || !height)
|
|
1950
|
+
return 1;
|
|
1951
|
+
const stageWidth = stageRect.width + 30;
|
|
1952
|
+
const stageHeight = stageRect.height + 30;
|
|
1953
|
+
if (width > stageWidth && height > stageHeight) {
|
|
1954
|
+
return 1;
|
|
1955
|
+
}
|
|
1956
|
+
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
1957
|
+
}
|
|
1958
|
+
destroy() {
|
|
1959
|
+
this.removeAllListeners();
|
|
1960
|
+
}
|
|
1961
|
+
setColumnWidth({ left, center, right }) {
|
|
1962
|
+
const columnWidth = {
|
|
1963
|
+
...vue.toRaw(this.get("columnWidth"))
|
|
1964
|
+
};
|
|
1965
|
+
if (left) {
|
|
1966
|
+
columnWidth.left = Math.max(left, MIN_LEFT_COLUMN_WIDTH);
|
|
1967
|
+
}
|
|
1968
|
+
if (right) {
|
|
1969
|
+
columnWidth.right = Math.max(right, MIN_RIGHT_COLUMN_WIDTH);
|
|
1970
|
+
}
|
|
1971
|
+
if (!center || center === "auto") {
|
|
1972
|
+
const bodyWidth = globalThis.document.body.clientWidth;
|
|
1973
|
+
columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
|
|
1974
|
+
if (columnWidth.center <= 0) {
|
|
1975
|
+
columnWidth.left = defaultColumnWidth.left;
|
|
1976
|
+
columnWidth.center = defaultColumnWidth.center;
|
|
1977
|
+
columnWidth.right = defaultColumnWidth.right;
|
|
1978
|
+
}
|
|
1979
|
+
} else {
|
|
1980
|
+
columnWidth.center = center;
|
|
1981
|
+
}
|
|
1982
|
+
globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
|
|
1983
|
+
state.columnWidth = columnWidth;
|
|
1984
|
+
}
|
|
1985
|
+
setStageRect(value) {
|
|
1986
|
+
state.stageRect = {
|
|
1987
|
+
...state.stageRect,
|
|
1988
|
+
...value
|
|
1989
|
+
};
|
|
1990
|
+
state.zoom = this.calcZoom();
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
const uiService = new Ui();
|
|
1994
|
+
|
|
1995
|
+
const root = vue.computed(() => editorService.get("root"));
|
|
1996
|
+
const page = vue.computed(() => editorService.get("page"));
|
|
1997
|
+
const zoom = vue.computed(() => uiService.get("zoom") || 1);
|
|
1998
|
+
const uiSelectMode = vue.computed(() => uiService.get("uiSelectMode"));
|
|
1999
|
+
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
2000
|
+
const useStage = (stageOptions) => {
|
|
2001
|
+
const stage = new StageCore__default.default({
|
|
2002
|
+
render: stageOptions.render,
|
|
2003
|
+
runtimeUrl: stageOptions.runtimeUrl,
|
|
2004
|
+
zoom: zoom.value,
|
|
2005
|
+
autoScrollIntoView: stageOptions.autoScrollIntoView,
|
|
2006
|
+
isContainer: stageOptions.isContainer,
|
|
2007
|
+
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
2008
|
+
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
2009
|
+
containerHighlightType: stageOptions.containerHighlightType,
|
|
2010
|
+
canSelect: (el, event, stop) => {
|
|
2011
|
+
const elCanSelect = stageOptions.canSelect(el);
|
|
2012
|
+
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
2013
|
+
document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
|
|
2014
|
+
return stop();
|
|
2015
|
+
}
|
|
2016
|
+
return elCanSelect;
|
|
2017
|
+
},
|
|
2018
|
+
moveableOptions: stageOptions.moveableOptions,
|
|
2019
|
+
updateDragEl: stageOptions.updateDragEl
|
|
2020
|
+
});
|
|
2021
|
+
stage.mask.setGuides([
|
|
2022
|
+
getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
|
|
2023
|
+
getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
|
|
2024
|
+
]);
|
|
2025
|
+
stage.on("select", (el) => {
|
|
2026
|
+
editorService.select(el.id);
|
|
2027
|
+
});
|
|
2028
|
+
stage.on("highlight", (el) => {
|
|
2029
|
+
editorService.highlight(el.id);
|
|
2030
|
+
});
|
|
2031
|
+
stage.on("multiSelect", (els) => {
|
|
2032
|
+
editorService.multiSelect(els.map((el) => el.id));
|
|
2033
|
+
});
|
|
2034
|
+
stage.on("update", (ev) => {
|
|
2035
|
+
if (ev.parentEl) {
|
|
2036
|
+
for (const data of ev.data) {
|
|
2037
|
+
editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
2038
|
+
}
|
|
2039
|
+
return;
|
|
2040
|
+
}
|
|
2041
|
+
editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
2042
|
+
});
|
|
2043
|
+
stage.on("sort", (ev) => {
|
|
2044
|
+
editorService.sort(ev.src, ev.dist);
|
|
2045
|
+
});
|
|
2046
|
+
stage.on("changeGuides", (e) => {
|
|
2047
|
+
uiService.set("showGuides", true);
|
|
2048
|
+
if (!root.value || !page.value)
|
|
2049
|
+
return;
|
|
2050
|
+
const storageKey = getGuideLineKey(e.type === StageCore.GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY);
|
|
2051
|
+
if (e.guides.length) {
|
|
2052
|
+
globalThis.localStorage.setItem(storageKey, JSON.stringify(e.guides));
|
|
2053
|
+
} else {
|
|
2054
|
+
globalThis.localStorage.removeItem(storageKey);
|
|
2055
|
+
}
|
|
2056
|
+
});
|
|
2057
|
+
return stage;
|
|
2058
|
+
};
|
|
2059
|
+
|
|
2060
|
+
const _sfc_main$k = vue.defineComponent({
|
|
1841
2061
|
components: { Plus: iconsVue.Plus },
|
|
1842
2062
|
setup() {
|
|
1843
2063
|
const services = vue.inject("services");
|
|
@@ -1855,13 +2075,13 @@
|
|
|
1855
2075
|
}
|
|
1856
2076
|
});
|
|
1857
2077
|
|
|
1858
|
-
const _hoisted_1$
|
|
2078
|
+
const _hoisted_1$a = { class: "m-editor-empty-panel" };
|
|
1859
2079
|
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
1860
|
-
const _hoisted_3
|
|
1861
|
-
function _sfc_render$
|
|
2080
|
+
const _hoisted_3 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
2081
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1862
2082
|
const _component_plus = vue.resolveComponent("plus");
|
|
1863
2083
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
1864
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
2084
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
|
|
1865
2085
|
vue.createElementVNode("div", _hoisted_2$4, [
|
|
1866
2086
|
vue.createElementVNode("div", {
|
|
1867
2087
|
class: "m-editor-empty-button",
|
|
@@ -1875,14 +2095,14 @@
|
|
|
1875
2095
|
_: 1
|
|
1876
2096
|
})
|
|
1877
2097
|
]),
|
|
1878
|
-
_hoisted_3
|
|
2098
|
+
_hoisted_3
|
|
1879
2099
|
])
|
|
1880
2100
|
])
|
|
1881
2101
|
]);
|
|
1882
2102
|
}
|
|
1883
|
-
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2103
|
+
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$7]]);
|
|
1884
2104
|
|
|
1885
|
-
const _sfc_main$
|
|
2105
|
+
const _sfc_main$j = vue.defineComponent({
|
|
1886
2106
|
name: "m-editor-resize",
|
|
1887
2107
|
props: {
|
|
1888
2108
|
type: {
|
|
@@ -1925,18 +2145,18 @@
|
|
|
1925
2145
|
}
|
|
1926
2146
|
});
|
|
1927
2147
|
|
|
1928
|
-
const _hoisted_1$
|
|
2148
|
+
const _hoisted_1$9 = {
|
|
1929
2149
|
ref: "target",
|
|
1930
2150
|
class: "m-editor-resizer"
|
|
1931
2151
|
};
|
|
1932
|
-
function _sfc_render$
|
|
1933
|
-
return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$
|
|
2152
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2153
|
+
return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$9, [
|
|
1934
2154
|
vue.renderSlot(_ctx.$slots, "default")
|
|
1935
2155
|
], 512);
|
|
1936
2156
|
}
|
|
1937
|
-
const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2157
|
+
const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$6]]);
|
|
1938
2158
|
|
|
1939
|
-
const _sfc_main$
|
|
2159
|
+
const _sfc_main$i = vue.defineComponent({
|
|
1940
2160
|
components: {
|
|
1941
2161
|
AddPageBox,
|
|
1942
2162
|
Resizer
|
|
@@ -1966,17 +2186,17 @@
|
|
|
1966
2186
|
}
|
|
1967
2187
|
});
|
|
1968
2188
|
|
|
1969
|
-
const _hoisted_1$
|
|
2189
|
+
const _hoisted_1$8 = { class: "m-editor" };
|
|
1970
2190
|
const _hoisted_2$3 = {
|
|
1971
2191
|
key: 1,
|
|
1972
2192
|
class: "m-editor-content"
|
|
1973
2193
|
};
|
|
1974
|
-
function _sfc_render$
|
|
2194
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1975
2195
|
const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
|
|
1976
2196
|
const _component_resizer = vue.resolveComponent("resizer");
|
|
1977
2197
|
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
|
|
1978
2198
|
const _component_add_page_box = vue.resolveComponent("add-page-box");
|
|
1979
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
2199
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
|
|
1980
2200
|
vue.renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
1981
2201
|
_ctx.showSrc ? (vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
|
|
1982
2202
|
key: 0,
|
|
@@ -2017,211 +2237,121 @@
|
|
|
2017
2237
|
]))
|
|
2018
2238
|
]);
|
|
2019
2239
|
}
|
|
2020
|
-
const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2240
|
+
const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$5]]);
|
|
2021
2241
|
|
|
2022
|
-
const
|
|
2023
|
-
|
|
2024
|
-
|
|
2242
|
+
const _hoisted_1$7 = ["src"];
|
|
2243
|
+
const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
|
|
2244
|
+
__name: "Icon",
|
|
2025
2245
|
props: {
|
|
2026
|
-
icon:
|
|
2027
|
-
type: [String, Object]
|
|
2028
|
-
}
|
|
2246
|
+
icon: null
|
|
2029
2247
|
},
|
|
2030
|
-
setup() {
|
|
2031
|
-
return {
|
|
2032
|
-
|
|
2248
|
+
setup(__props) {
|
|
2249
|
+
return (_ctx, _cache) => {
|
|
2250
|
+
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
2251
|
+
return !__props.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, {
|
|
2252
|
+
key: 0,
|
|
2253
|
+
class: "magic-editor-icon"
|
|
2254
|
+
}, {
|
|
2255
|
+
default: vue.withCtx(() => [
|
|
2256
|
+
vue.createVNode(vue.unref(iconsVue.Edit))
|
|
2257
|
+
]),
|
|
2258
|
+
_: 1
|
|
2259
|
+
})) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (vue.openBlock(), vue.createBlock(_component_el_icon, {
|
|
2260
|
+
key: 1,
|
|
2261
|
+
class: "magic-editor-icon"
|
|
2262
|
+
}, {
|
|
2263
|
+
default: vue.withCtx(() => [
|
|
2264
|
+
vue.createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$7)
|
|
2265
|
+
]),
|
|
2266
|
+
_: 1
|
|
2267
|
+
})) : typeof __props.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
|
|
2268
|
+
key: 2,
|
|
2269
|
+
class: vue.normalizeClass(["magic-editor-icon", __props.icon])
|
|
2270
|
+
}, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, {
|
|
2271
|
+
key: 3,
|
|
2272
|
+
class: "magic-editor-icon"
|
|
2273
|
+
}, {
|
|
2274
|
+
default: vue.withCtx(() => [
|
|
2275
|
+
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.toRaw(__props.icon))))
|
|
2276
|
+
]),
|
|
2277
|
+
_: 1
|
|
2278
|
+
}));
|
|
2033
2279
|
};
|
|
2034
2280
|
}
|
|
2035
2281
|
});
|
|
2036
2282
|
|
|
2037
|
-
const _hoisted_1$
|
|
2038
|
-
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2039
|
-
const _component_edit = vue.resolveComponent("edit");
|
|
2040
|
-
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
2041
|
-
return !_ctx.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
|
|
2042
|
-
default: vue.withCtx(() => [
|
|
2043
|
-
vue.createVNode(_component_edit)
|
|
2044
|
-
]),
|
|
2045
|
-
_: 1
|
|
2046
|
-
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 1 }, {
|
|
2047
|
-
default: vue.withCtx(() => [
|
|
2048
|
-
vue.createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$8)
|
|
2049
|
-
]),
|
|
2050
|
-
_: 1
|
|
2051
|
-
})) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
|
|
2052
|
-
key: 2,
|
|
2053
|
-
class: vue.normalizeClass(_ctx.icon)
|
|
2054
|
-
}, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
|
|
2055
|
-
default: vue.withCtx(() => [
|
|
2056
|
-
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.toRaw(_ctx.icon))))
|
|
2057
|
-
]),
|
|
2058
|
-
_: 1
|
|
2059
|
-
}));
|
|
2060
|
-
}
|
|
2061
|
-
const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
|
|
2062
|
-
|
|
2063
|
-
const _hoisted_1$7 = {
|
|
2283
|
+
const _hoisted_1$6 = {
|
|
2064
2284
|
key: 1,
|
|
2065
2285
|
class: "menu-item-text"
|
|
2066
2286
|
};
|
|
2067
|
-
const _hoisted_2$2 = {
|
|
2068
|
-
|
|
2069
|
-
style: { "margin": "0 5px" }
|
|
2070
|
-
};
|
|
2071
|
-
const _hoisted_3 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2072
|
-
const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
2287
|
+
const _hoisted_2$2 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2288
|
+
const _sfc_main$g = /* @__PURE__ */ vue.defineComponent({
|
|
2073
2289
|
__name: "ToolButton",
|
|
2074
2290
|
props: {
|
|
2075
|
-
data: {
|
|
2076
|
-
type:
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
display: false
|
|
2081
|
-
})
|
|
2082
|
-
},
|
|
2083
|
-
eventType: {
|
|
2084
|
-
type: String,
|
|
2085
|
-
default: "click"
|
|
2086
|
-
}
|
|
2291
|
+
data: { default: () => ({
|
|
2292
|
+
type: "text",
|
|
2293
|
+
display: false
|
|
2294
|
+
}) },
|
|
2295
|
+
eventType: { default: "click" }
|
|
2087
2296
|
},
|
|
2088
2297
|
setup(__props) {
|
|
2089
2298
|
const props = __props;
|
|
2090
2299
|
const services = vue.inject("services");
|
|
2091
|
-
const
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
if (typeof props.data !== "string") {
|
|
2099
|
-
return props.data;
|
|
2100
|
-
}
|
|
2101
|
-
switch (props.data) {
|
|
2102
|
-
case "/":
|
|
2103
|
-
return {
|
|
2104
|
-
type: "divider"
|
|
2105
|
-
};
|
|
2106
|
-
case "zoom":
|
|
2107
|
-
return {
|
|
2108
|
-
type: "zoom"
|
|
2109
|
-
};
|
|
2110
|
-
case "delete":
|
|
2111
|
-
return {
|
|
2112
|
-
type: "button",
|
|
2113
|
-
icon: vue.markRaw(iconsVue.Delete),
|
|
2114
|
-
tooltip: "\u522A\u9664",
|
|
2115
|
-
disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
|
|
2116
|
-
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
2117
|
-
};
|
|
2118
|
-
case "undo":
|
|
2119
|
-
return {
|
|
2120
|
-
type: "button",
|
|
2121
|
-
icon: vue.markRaw(iconsVue.Back),
|
|
2122
|
-
tooltip: "\u540E\u9000",
|
|
2123
|
-
disabled: () => !services?.historyService.state.canUndo,
|
|
2124
|
-
handler: () => services?.editorService.undo()
|
|
2125
|
-
};
|
|
2126
|
-
case "redo":
|
|
2127
|
-
return {
|
|
2128
|
-
type: "button",
|
|
2129
|
-
icon: vue.markRaw(iconsVue.Right),
|
|
2130
|
-
tooltip: "\u524D\u8FDB",
|
|
2131
|
-
disabled: () => !services?.historyService.state.canRedo,
|
|
2132
|
-
handler: () => services?.editorService.redo()
|
|
2133
|
-
};
|
|
2134
|
-
case "zoom-in":
|
|
2135
|
-
return {
|
|
2136
|
-
type: "button",
|
|
2137
|
-
icon: vue.markRaw(iconsVue.ZoomIn),
|
|
2138
|
-
tooltip: "\u653E\u5927",
|
|
2139
|
-
handler: zoomInHandler
|
|
2140
|
-
};
|
|
2141
|
-
case "zoom-out":
|
|
2142
|
-
return {
|
|
2143
|
-
type: "button",
|
|
2144
|
-
icon: vue.markRaw(iconsVue.ZoomOut),
|
|
2145
|
-
tooltip: "\u7E2E\u5C0F",
|
|
2146
|
-
handler: zoomOutHandler
|
|
2147
|
-
};
|
|
2148
|
-
case "rule":
|
|
2149
|
-
return {
|
|
2150
|
-
type: "button",
|
|
2151
|
-
icon: vue.markRaw(iconsVue.ScaleToOriginal),
|
|
2152
|
-
tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
|
|
2153
|
-
handler: () => uiService?.set("showRule", !showRule.value)
|
|
2154
|
-
};
|
|
2155
|
-
case "guides":
|
|
2156
|
-
return {
|
|
2157
|
-
type: "button",
|
|
2158
|
-
icon: vue.markRaw(iconsVue.Grid),
|
|
2159
|
-
tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
|
|
2160
|
-
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
2161
|
-
};
|
|
2162
|
-
default:
|
|
2163
|
-
return {
|
|
2164
|
-
type: "text",
|
|
2165
|
-
text: props.data
|
|
2166
|
-
};
|
|
2300
|
+
const disabled = vue.computed(() => {
|
|
2301
|
+
if (typeof props.data === "string")
|
|
2302
|
+
return false;
|
|
2303
|
+
if (props.data.type === "component")
|
|
2304
|
+
return false;
|
|
2305
|
+
if (typeof props.data.disabled === "function") {
|
|
2306
|
+
return props.data.disabled(services);
|
|
2167
2307
|
}
|
|
2308
|
+
return props.data.disabled;
|
|
2168
2309
|
});
|
|
2169
|
-
const
|
|
2170
|
-
if (
|
|
2171
|
-
return false;
|
|
2172
|
-
if (item.value.type === "component")
|
|
2310
|
+
const display = vue.computed(() => {
|
|
2311
|
+
if (!props.data)
|
|
2173
2312
|
return false;
|
|
2174
|
-
if (typeof
|
|
2175
|
-
return
|
|
2313
|
+
if (typeof props.data === "string")
|
|
2314
|
+
return true;
|
|
2315
|
+
if (typeof props.data.display === "function") {
|
|
2316
|
+
return props.data.display(services);
|
|
2176
2317
|
}
|
|
2177
|
-
return
|
|
2318
|
+
return props.data.display ?? true;
|
|
2178
2319
|
});
|
|
2179
|
-
const buttonHandler = (
|
|
2320
|
+
const buttonHandler = (item, event) => {
|
|
2180
2321
|
if (disabled.value)
|
|
2181
2322
|
return;
|
|
2182
|
-
if (typeof
|
|
2183
|
-
|
|
2323
|
+
if (typeof item.handler === "function" && services) {
|
|
2324
|
+
item.handler?.(services, event);
|
|
2184
2325
|
}
|
|
2185
2326
|
};
|
|
2186
|
-
const display = vue.computed(() => {
|
|
2187
|
-
if (!item.value)
|
|
2188
|
-
return false;
|
|
2189
|
-
if (typeof item.value === "string")
|
|
2190
|
-
return true;
|
|
2191
|
-
if (typeof item.value.display === "function") {
|
|
2192
|
-
return item.value.display(services);
|
|
2193
|
-
}
|
|
2194
|
-
return item.value.display ?? true;
|
|
2195
|
-
});
|
|
2196
2327
|
const dropdownHandler = (command) => {
|
|
2197
2328
|
if (command.item.handler) {
|
|
2198
2329
|
command.item.handler(services);
|
|
2199
2330
|
}
|
|
2200
2331
|
};
|
|
2201
|
-
const clickHandler = (
|
|
2332
|
+
const clickHandler = (item, event) => {
|
|
2202
2333
|
if (props.eventType !== "click")
|
|
2203
2334
|
return;
|
|
2204
|
-
if (
|
|
2205
|
-
buttonHandler(
|
|
2335
|
+
if (item.type === "button") {
|
|
2336
|
+
buttonHandler(item, event);
|
|
2206
2337
|
}
|
|
2207
2338
|
};
|
|
2208
|
-
const mousedownHandler = (
|
|
2339
|
+
const mousedownHandler = (item, event) => {
|
|
2209
2340
|
if (props.eventType !== "mousedown")
|
|
2210
2341
|
return;
|
|
2211
|
-
if (
|
|
2212
|
-
buttonHandler(
|
|
2342
|
+
if (item.type === "button") {
|
|
2343
|
+
buttonHandler(item, event);
|
|
2213
2344
|
}
|
|
2214
2345
|
};
|
|
2215
|
-
const mouseupHandler = (
|
|
2346
|
+
const mouseupHandler = (item, event) => {
|
|
2216
2347
|
if (props.eventType !== "mouseup")
|
|
2217
2348
|
return;
|
|
2218
|
-
if (
|
|
2219
|
-
buttonHandler(
|
|
2349
|
+
if (item.type === "button") {
|
|
2350
|
+
buttonHandler(item, event);
|
|
2220
2351
|
}
|
|
2221
2352
|
};
|
|
2222
2353
|
return (_ctx, _cache) => {
|
|
2223
2354
|
const _component_el_divider = vue.resolveComponent("el-divider");
|
|
2224
|
-
const _component_tool_button = vue.resolveComponent("tool-button", true);
|
|
2225
2355
|
const _component_el_button = vue.resolveComponent("el-button");
|
|
2226
2356
|
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
2227
2357
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
@@ -2230,30 +2360,20 @@
|
|
|
2230
2360
|
const _component_el_dropdown = vue.resolveComponent("el-dropdown");
|
|
2231
2361
|
return vue.unref(display) ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
2232
2362
|
key: 0,
|
|
2233
|
-
class: vue.normalizeClass(["menu-item",
|
|
2234
|
-
onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(
|
|
2235
|
-
onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(
|
|
2236
|
-
onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(
|
|
2363
|
+
class: vue.normalizeClass(["menu-item", `${__props.data.type} ${__props.data.className || ""}`]),
|
|
2364
|
+
onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(__props.data, $event)),
|
|
2365
|
+
onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(__props.data, $event)),
|
|
2366
|
+
onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(__props.data, $event))
|
|
2237
2367
|
}, [
|
|
2238
|
-
|
|
2368
|
+
__props.data.type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
|
|
2239
2369
|
key: 0,
|
|
2240
|
-
direction:
|
|
2241
|
-
}, null, 8, ["direction"])) :
|
|
2242
|
-
vue.
|
|
2243
|
-
data: { type: "button", icon: vue.unref(iconsVue.ZoomOut), handler: zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
2244
|
-
"event-type": __props.eventType
|
|
2245
|
-
}, null, 8, ["data", "event-type"]),
|
|
2246
|
-
vue.createElementVNode("span", _hoisted_2$2, vue.toDisplayString(parseInt(`${vue.unref(zoom) * 100}`, 10)) + "%", 1),
|
|
2247
|
-
vue.createVNode(_component_tool_button, {
|
|
2248
|
-
data: { type: "button", icon: vue.unref(iconsVue.ZoomIn), handler: zoomInHandler, tooltip: "\u653E\u5927" },
|
|
2249
|
-
"event-type": __props.eventType
|
|
2250
|
-
}, null, 8, ["data", "event-type"])
|
|
2251
|
-
], 64)) : vue.unref(item).type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
|
|
2252
|
-
vue.unref(item).tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
|
|
2370
|
+
direction: __props.data.direction || "vertical"
|
|
2371
|
+
}, null, 8, ["direction"])) : __props.data.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, vue.toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
|
|
2372
|
+
__props.data.tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
|
|
2253
2373
|
key: 0,
|
|
2254
2374
|
effect: "dark",
|
|
2255
2375
|
placement: "bottom-start",
|
|
2256
|
-
content:
|
|
2376
|
+
content: __props.data.tooltip
|
|
2257
2377
|
}, {
|
|
2258
2378
|
default: vue.withCtx(() => [
|
|
2259
2379
|
vue.createVNode(_component_el_button, {
|
|
@@ -2262,11 +2382,11 @@
|
|
|
2262
2382
|
disabled: vue.unref(disabled)
|
|
2263
2383
|
}, {
|
|
2264
2384
|
default: vue.withCtx(() => [
|
|
2265
|
-
|
|
2385
|
+
__props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$h, {
|
|
2266
2386
|
key: 0,
|
|
2267
|
-
icon:
|
|
2387
|
+
icon: __props.data.icon
|
|
2268
2388
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
2269
|
-
vue.createElementVNode("span", null, vue.toDisplayString(
|
|
2389
|
+
vue.createElementVNode("span", null, vue.toDisplayString(__props.data.text), 1)
|
|
2270
2390
|
]),
|
|
2271
2391
|
_: 1
|
|
2272
2392
|
}, 8, ["disabled"])
|
|
@@ -2279,27 +2399,27 @@
|
|
|
2279
2399
|
disabled: vue.unref(disabled)
|
|
2280
2400
|
}, {
|
|
2281
2401
|
default: vue.withCtx(() => [
|
|
2282
|
-
|
|
2402
|
+
__props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$h, {
|
|
2283
2403
|
key: 0,
|
|
2284
|
-
icon:
|
|
2404
|
+
icon: __props.data.icon
|
|
2285
2405
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
2286
|
-
vue.createElementVNode("span", null, vue.toDisplayString(
|
|
2406
|
+
vue.createElementVNode("span", null, vue.toDisplayString(__props.data.text), 1)
|
|
2287
2407
|
]),
|
|
2288
2408
|
_: 1
|
|
2289
2409
|
}, 8, ["disabled"]))
|
|
2290
|
-
], 64)) :
|
|
2291
|
-
key:
|
|
2410
|
+
], 64)) : __props.data.type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
|
|
2411
|
+
key: 3,
|
|
2292
2412
|
trigger: "click",
|
|
2293
2413
|
disabled: vue.unref(disabled),
|
|
2294
2414
|
onCommand: dropdownHandler
|
|
2295
2415
|
}, {
|
|
2296
2416
|
dropdown: vue.withCtx(() => [
|
|
2297
|
-
|
|
2417
|
+
__props.data.items && __props.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_dropdown_menu, { key: 0 }, {
|
|
2298
2418
|
default: vue.withCtx(() => [
|
|
2299
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(
|
|
2419
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.data.items, (subItem, index) => {
|
|
2300
2420
|
return vue.openBlock(), vue.createBlock(_component_el_dropdown_item, {
|
|
2301
2421
|
key: index,
|
|
2302
|
-
command: {
|
|
2422
|
+
command: { data: __props.data, subItem }
|
|
2303
2423
|
}, {
|
|
2304
2424
|
default: vue.withCtx(() => [
|
|
2305
2425
|
vue.createTextVNode(vue.toDisplayString(subItem.text), 1)
|
|
@@ -2312,8 +2432,8 @@
|
|
|
2312
2432
|
})) : vue.createCommentVNode("", true)
|
|
2313
2433
|
]),
|
|
2314
2434
|
default: vue.withCtx(() => [
|
|
2315
|
-
vue.createElementVNode("span",
|
|
2316
|
-
vue.createTextVNode(vue.toDisplayString(
|
|
2435
|
+
vue.createElementVNode("span", _hoisted_2$2, [
|
|
2436
|
+
vue.createTextVNode(vue.toDisplayString(__props.data.text), 1),
|
|
2317
2437
|
vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2318
2438
|
default: vue.withCtx(() => [
|
|
2319
2439
|
vue.createVNode(vue.unref(iconsVue.ArrowDown))
|
|
@@ -2323,67 +2443,187 @@
|
|
|
2323
2443
|
])
|
|
2324
2444
|
]),
|
|
2325
2445
|
_: 1
|
|
2326
|
-
}, 8, ["disabled"])) :
|
|
2446
|
+
}, 8, ["disabled"])) : __props.data.type === "component" ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(__props.data.component), vue.normalizeProps(vue.mergeProps({ key: 4 }, __props.data.props || {})), null, 16)) : vue.createCommentVNode("", true)
|
|
2327
2447
|
], 34)) : vue.createCommentVNode("", true);
|
|
2328
2448
|
};
|
|
2329
2449
|
}
|
|
2330
2450
|
});
|
|
2331
2451
|
|
|
2332
|
-
const _sfc_main$
|
|
2333
|
-
|
|
2334
|
-
components: { ToolButton: _sfc_main$f },
|
|
2452
|
+
const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
2453
|
+
__name: "NavMenu",
|
|
2335
2454
|
props: {
|
|
2336
|
-
data: {
|
|
2337
|
-
|
|
2338
|
-
default: () => ({})
|
|
2339
|
-
},
|
|
2340
|
-
height: {
|
|
2341
|
-
type: Number
|
|
2342
|
-
}
|
|
2455
|
+
data: { default: () => ({}) },
|
|
2456
|
+
height: { default: 35 }
|
|
2343
2457
|
},
|
|
2344
|
-
setup(
|
|
2458
|
+
setup(__props) {
|
|
2459
|
+
const props = __props;
|
|
2345
2460
|
const services = vue.inject("services");
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2461
|
+
const uiService = services?.uiService;
|
|
2462
|
+
const columnWidth = vue.computed(() => services?.uiService.get("columnWidth"));
|
|
2463
|
+
const keys = Object.values(ColumnLayout);
|
|
2464
|
+
const showGuides = vue.computed(() => uiService?.get("showGuides") ?? true);
|
|
2465
|
+
const showRule = vue.computed(() => uiService?.get("showRule") ?? true);
|
|
2466
|
+
const zoom = vue.computed(() => uiService?.get("zoom") ?? 1);
|
|
2467
|
+
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
2468
|
+
const ctrl = isMac ? "Command" : "Ctrl";
|
|
2469
|
+
const getConfig = (item) => {
|
|
2470
|
+
if (typeof item !== "string") {
|
|
2471
|
+
return [item];
|
|
2472
|
+
}
|
|
2473
|
+
const config = [];
|
|
2474
|
+
switch (item) {
|
|
2475
|
+
case "/":
|
|
2476
|
+
config.push({
|
|
2477
|
+
type: "divider",
|
|
2478
|
+
className: "divider"
|
|
2479
|
+
});
|
|
2480
|
+
break;
|
|
2481
|
+
case "zoom":
|
|
2482
|
+
config.push(...getConfig("zoom-out"), ...getConfig(`${parseInt(`${zoom.value * 100}`, 10)}%`), ...getConfig("zoom-in"), ...getConfig("scale-to-original"), ...getConfig("scale-to-fit"));
|
|
2483
|
+
break;
|
|
2484
|
+
case "delete":
|
|
2485
|
+
config.push({
|
|
2486
|
+
type: "button",
|
|
2487
|
+
className: "delete",
|
|
2488
|
+
icon: vue.markRaw(iconsVue.Delete),
|
|
2489
|
+
tooltip: `\u522A\u9664(Delete)`,
|
|
2490
|
+
disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
|
|
2491
|
+
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
2492
|
+
});
|
|
2493
|
+
break;
|
|
2494
|
+
case "undo":
|
|
2495
|
+
config.push({
|
|
2496
|
+
type: "button",
|
|
2497
|
+
className: "undo",
|
|
2498
|
+
icon: vue.markRaw(iconsVue.Back),
|
|
2499
|
+
tooltip: `\u540E\u9000(${ctrl}+z)`,
|
|
2500
|
+
disabled: () => !services?.historyService.state.canUndo,
|
|
2501
|
+
handler: () => services?.editorService.undo()
|
|
2502
|
+
});
|
|
2503
|
+
break;
|
|
2504
|
+
case "redo":
|
|
2505
|
+
config.push({
|
|
2506
|
+
type: "button",
|
|
2507
|
+
className: "redo",
|
|
2508
|
+
icon: vue.markRaw(iconsVue.Right),
|
|
2509
|
+
tooltip: `\u524D\u8FDB(${ctrl}+Shift+z)`,
|
|
2510
|
+
disabled: () => !services?.historyService.state.canRedo,
|
|
2511
|
+
handler: () => services?.editorService.redo()
|
|
2512
|
+
});
|
|
2513
|
+
break;
|
|
2514
|
+
case "zoom-in":
|
|
2515
|
+
config.push({
|
|
2516
|
+
type: "button",
|
|
2517
|
+
className: "zoom-in",
|
|
2518
|
+
icon: vue.markRaw(iconsVue.ZoomIn),
|
|
2519
|
+
tooltip: `\u653E\u5927(${ctrl}+=)`,
|
|
2520
|
+
handler: () => uiService?.zoom(0.1)
|
|
2521
|
+
});
|
|
2522
|
+
break;
|
|
2523
|
+
case "zoom-out":
|
|
2524
|
+
config.push({
|
|
2525
|
+
type: "button",
|
|
2526
|
+
className: "zoom-out",
|
|
2527
|
+
icon: vue.markRaw(iconsVue.ZoomOut),
|
|
2528
|
+
tooltip: `\u7E2E\u5C0F(${ctrl}+-)`,
|
|
2529
|
+
handler: () => uiService?.zoom(-0.1)
|
|
2530
|
+
});
|
|
2531
|
+
break;
|
|
2532
|
+
case "scale-to-original":
|
|
2533
|
+
config.push({
|
|
2534
|
+
type: "button",
|
|
2535
|
+
className: "scale-to-original",
|
|
2536
|
+
icon: vue.markRaw(iconsVue.ScaleToOriginal),
|
|
2537
|
+
tooltip: `\u7F29\u653E\u5230\u5B9E\u9645\u5927\u5C0F(${ctrl}+1)`,
|
|
2538
|
+
handler: () => uiService?.set("zoom", 1)
|
|
2539
|
+
});
|
|
2540
|
+
break;
|
|
2541
|
+
case "scale-to-fit":
|
|
2542
|
+
config.push({
|
|
2543
|
+
type: "button",
|
|
2544
|
+
className: "scale-to-fit",
|
|
2545
|
+
icon: vue.markRaw(iconsVue.FullScreen),
|
|
2546
|
+
tooltip: `\u7F29\u653E\u4EE5\u9002\u5E94(${ctrl}+0)`,
|
|
2547
|
+
handler: () => uiService?.set("zoom", uiService.calcZoom())
|
|
2548
|
+
});
|
|
2549
|
+
break;
|
|
2550
|
+
case "rule":
|
|
2551
|
+
config.push({
|
|
2552
|
+
type: "button",
|
|
2553
|
+
className: "rule",
|
|
2554
|
+
icon: vue.markRaw(iconsVue.Memo),
|
|
2555
|
+
tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
|
|
2556
|
+
handler: () => uiService?.set("showRule", !showRule.value)
|
|
2557
|
+
});
|
|
2558
|
+
break;
|
|
2559
|
+
case "guides":
|
|
2560
|
+
config.push({
|
|
2561
|
+
type: "button",
|
|
2562
|
+
className: "guides",
|
|
2563
|
+
icon: vue.markRaw(iconsVue.Grid),
|
|
2564
|
+
tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
|
|
2565
|
+
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
2566
|
+
});
|
|
2567
|
+
break;
|
|
2568
|
+
default:
|
|
2569
|
+
config.push({
|
|
2570
|
+
type: "text",
|
|
2571
|
+
text: item
|
|
2572
|
+
});
|
|
2573
|
+
}
|
|
2574
|
+
return config;
|
|
2349
2575
|
};
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2576
|
+
const buttons = vue.computed(() => {
|
|
2577
|
+
const data = {
|
|
2578
|
+
[ColumnLayout.LEFT]: [],
|
|
2579
|
+
[ColumnLayout.CENTER]: [],
|
|
2580
|
+
[ColumnLayout.RIGHT]: []
|
|
2581
|
+
};
|
|
2582
|
+
keys.forEach((key) => {
|
|
2583
|
+
const items = props.data[key] || [];
|
|
2584
|
+
items.forEach((item) => {
|
|
2585
|
+
data[key].push(...getConfig(item));
|
|
2586
|
+
});
|
|
2587
|
+
});
|
|
2588
|
+
return data;
|
|
2589
|
+
});
|
|
2590
|
+
return (_ctx, _cache) => {
|
|
2360
2591
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
2361
|
-
class:
|
|
2362
|
-
|
|
2363
|
-
style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.[key]}px`)
|
|
2592
|
+
class: "m-editor-nav-menu",
|
|
2593
|
+
style: vue.normalizeStyle({ height: `${__props.height}px` })
|
|
2364
2594
|
}, [
|
|
2365
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(
|
|
2366
|
-
return vue.openBlock(), vue.
|
|
2367
|
-
|
|
2368
|
-
key
|
|
2369
|
-
|
|
2595
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(keys), (key) => {
|
|
2596
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
2597
|
+
class: vue.normalizeClass(`menu-${key}`),
|
|
2598
|
+
key,
|
|
2599
|
+
style: vue.normalizeStyle(`width: ${vue.unref(columnWidth)?.[key]}px`)
|
|
2600
|
+
}, [
|
|
2601
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(buttons)[key], (item, index) => {
|
|
2602
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$g, {
|
|
2603
|
+
data: item,
|
|
2604
|
+
key: index
|
|
2605
|
+
}, null, 8, ["data"]);
|
|
2606
|
+
}), 128))
|
|
2607
|
+
], 6);
|
|
2370
2608
|
}), 128))
|
|
2371
|
-
],
|
|
2372
|
-
}
|
|
2373
|
-
|
|
2374
|
-
}
|
|
2375
|
-
const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
|
|
2609
|
+
], 4);
|
|
2610
|
+
};
|
|
2611
|
+
}
|
|
2612
|
+
});
|
|
2376
2613
|
|
|
2377
|
-
const
|
|
2378
|
-
|
|
2614
|
+
const _hoisted_1$5 = { class: "`m-editor-props-panel" };
|
|
2615
|
+
const _sfc_main$e = /* @__PURE__ */ vue.defineComponent({
|
|
2616
|
+
__name: "PropsPanel",
|
|
2379
2617
|
emits: ["mounted"],
|
|
2380
|
-
setup(
|
|
2618
|
+
setup(__props, { expose, emit }) {
|
|
2381
2619
|
const internalInstance = vue.getCurrentInstance();
|
|
2382
2620
|
const values = vue.ref({});
|
|
2383
2621
|
const configForm = vue.ref();
|
|
2384
2622
|
const curFormConfig = vue.ref([]);
|
|
2385
2623
|
const services = vue.inject("services");
|
|
2386
2624
|
const node = vue.computed(() => services?.editorService.get("node"));
|
|
2625
|
+
const propsPanelSize = vue.computed(() => services?.uiService.get("propsPanelSize") || "small");
|
|
2626
|
+
const stage = vue.computed(() => services?.editorService.get("stage"));
|
|
2387
2627
|
const init = async () => {
|
|
2388
2628
|
if (!node.value) {
|
|
2389
2629
|
curFormConfig.value = [];
|
|
@@ -2398,52 +2638,51 @@
|
|
|
2398
2638
|
vue.onMounted(() => {
|
|
2399
2639
|
emit("mounted", internalInstance);
|
|
2400
2640
|
});
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
}
|
|
2641
|
+
vue.watchEffect(() => {
|
|
2642
|
+
if (configForm.value && stage.value) {
|
|
2643
|
+
configForm.value.formState.stage = stage.value;
|
|
2644
|
+
}
|
|
2645
|
+
});
|
|
2646
|
+
const submit = async () => {
|
|
2647
|
+
try {
|
|
2648
|
+
const values2 = await configForm.value?.submitForm();
|
|
2649
|
+
services?.editorService.update(values2);
|
|
2650
|
+
} catch (e) {
|
|
2651
|
+
console.error(e);
|
|
2652
|
+
elementPlus.ElMessage.closeAll();
|
|
2653
|
+
elementPlus.ElMessage.error({
|
|
2654
|
+
duration: 1e4,
|
|
2655
|
+
showClose: true,
|
|
2656
|
+
message: e.message,
|
|
2657
|
+
dangerouslyUseHTMLString: true
|
|
2658
|
+
});
|
|
2420
2659
|
}
|
|
2421
2660
|
};
|
|
2661
|
+
expose({ submit });
|
|
2662
|
+
return (_ctx, _cache) => {
|
|
2663
|
+
const _component_m_form = vue.resolveComponent("m-form");
|
|
2664
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$5, [
|
|
2665
|
+
vue.renderSlot(_ctx.$slots, "props-panel-header"),
|
|
2666
|
+
vue.createVNode(_component_m_form, {
|
|
2667
|
+
ref_key: "configForm",
|
|
2668
|
+
ref: configForm,
|
|
2669
|
+
class: vue.normalizeClass(`m-editor-props-panel ${vue.unref(propsPanelSize)}`),
|
|
2670
|
+
"popper-class": `m-editor-props-panel-popper ${vue.unref(propsPanelSize)}`,
|
|
2671
|
+
size: vue.unref(propsPanelSize),
|
|
2672
|
+
"init-values": values.value,
|
|
2673
|
+
config: curFormConfig.value,
|
|
2674
|
+
onChange: submit
|
|
2675
|
+
}, null, 8, ["class", "popper-class", "size", "init-values", "config"])
|
|
2676
|
+
]);
|
|
2677
|
+
};
|
|
2422
2678
|
}
|
|
2423
2679
|
});
|
|
2424
2680
|
|
|
2425
|
-
const _hoisted_1$
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
vue.createVNode(_component_m_form, {
|
|
2431
|
-
class: vue.normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
|
|
2432
|
-
"popper-class": `m-editor-props-panel-popper ${_ctx.propsPanelSize}`,
|
|
2433
|
-
ref: "configForm",
|
|
2434
|
-
size: _ctx.propsPanelSize,
|
|
2435
|
-
"init-values": _ctx.values,
|
|
2436
|
-
config: _ctx.curFormConfig,
|
|
2437
|
-
onChange: _ctx.submit
|
|
2438
|
-
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
|
|
2439
|
-
]);
|
|
2440
|
-
}
|
|
2441
|
-
const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
|
|
2442
|
-
|
|
2443
|
-
const _sfc_main$c = vue.defineComponent({
|
|
2444
|
-
name: "ui-component-panel",
|
|
2445
|
-
components: { MIcon },
|
|
2446
|
-
setup() {
|
|
2681
|
+
const _hoisted_1$4 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
2682
|
+
const _hoisted_2$1 = ["onClick", "onDragstart"];
|
|
2683
|
+
const _sfc_main$d = /* @__PURE__ */ vue.defineComponent({
|
|
2684
|
+
__name: "ComponentListPanel",
|
|
2685
|
+
setup(__props) {
|
|
2447
2686
|
const searchText = vue.ref("");
|
|
2448
2687
|
const services = vue.inject("services");
|
|
2449
2688
|
const stageOptions = vue.inject("stageOptions");
|
|
@@ -2456,134 +2695,126 @@
|
|
|
2456
2695
|
let timeout;
|
|
2457
2696
|
let clientX;
|
|
2458
2697
|
let clientY;
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2698
|
+
const appendComponent = ({ text, type, data = {} }) => {
|
|
2699
|
+
services?.editorService.add({
|
|
2700
|
+
name: text,
|
|
2701
|
+
type,
|
|
2702
|
+
...data
|
|
2703
|
+
});
|
|
2704
|
+
};
|
|
2705
|
+
const dragstartHandler = ({ text, type, data = {} }, e) => {
|
|
2706
|
+
if (e.dataTransfer) {
|
|
2707
|
+
e.dataTransfer.effectAllowed = "move";
|
|
2708
|
+
e.dataTransfer.setData("data", serialize__default.default({
|
|
2465
2709
|
name: text,
|
|
2466
2710
|
type,
|
|
2467
2711
|
...data
|
|
2468
|
-
});
|
|
2469
|
-
}
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
}
|
|
2480
|
-
|
|
2712
|
+
}).replace(/"(\w+)":\s/g, "$1: "));
|
|
2713
|
+
}
|
|
2714
|
+
};
|
|
2715
|
+
const dragendHandler = () => {
|
|
2716
|
+
if (timeout) {
|
|
2717
|
+
globalThis.clearTimeout(timeout);
|
|
2718
|
+
timeout = void 0;
|
|
2719
|
+
}
|
|
2720
|
+
const doc = stage.value?.renderer.contentWindow?.document;
|
|
2721
|
+
if (doc && stageOptions) {
|
|
2722
|
+
utils.removeClassNameByClassName(doc, stageOptions.containerHighlightClassName);
|
|
2723
|
+
}
|
|
2724
|
+
clientX = 0;
|
|
2725
|
+
clientY = 0;
|
|
2726
|
+
};
|
|
2727
|
+
const dragHandler = (e) => {
|
|
2728
|
+
if (e.clientX !== clientX || e.clientY !== clientY) {
|
|
2729
|
+
clientX = e.clientX;
|
|
2730
|
+
clientY = e.clientY;
|
|
2481
2731
|
if (timeout) {
|
|
2482
2732
|
globalThis.clearTimeout(timeout);
|
|
2483
2733
|
timeout = void 0;
|
|
2484
2734
|
}
|
|
2485
|
-
|
|
2486
|
-
if (doc && stageOptions) {
|
|
2487
|
-
utils.removeClassNameByClassName(doc, stageOptions.containerHighlightClassName);
|
|
2488
|
-
}
|
|
2489
|
-
clientX = 0;
|
|
2490
|
-
clientY = 0;
|
|
2491
|
-
},
|
|
2492
|
-
dragHandler(e) {
|
|
2493
|
-
if (e.clientX !== clientX || e.clientY !== clientY) {
|
|
2494
|
-
clientX = e.clientX;
|
|
2495
|
-
clientY = e.clientY;
|
|
2496
|
-
if (timeout) {
|
|
2497
|
-
globalThis.clearTimeout(timeout);
|
|
2498
|
-
timeout = void 0;
|
|
2499
|
-
}
|
|
2500
|
-
return;
|
|
2501
|
-
}
|
|
2502
|
-
if (timeout || !stage.value)
|
|
2503
|
-
return;
|
|
2504
|
-
timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
|
|
2735
|
+
return;
|
|
2505
2736
|
}
|
|
2737
|
+
if (timeout || !stage.value)
|
|
2738
|
+
return;
|
|
2739
|
+
timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
|
|
2506
2740
|
};
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
const _component_m_icon = vue.resolveComponent("m-icon");
|
|
2515
|
-
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
2516
|
-
const _component_el_collapse_item = vue.resolveComponent("el-collapse-item");
|
|
2517
|
-
const _component_el_collapse = vue.resolveComponent("el-collapse");
|
|
2518
|
-
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
|
|
2519
|
-
return vue.openBlock(), vue.createBlock(_component_el_scrollbar, null, {
|
|
2520
|
-
default: vue.withCtx(() => [
|
|
2521
|
-
vue.renderSlot(_ctx.$slots, "component-list-panel-header"),
|
|
2522
|
-
vue.createVNode(_component_el_collapse, {
|
|
2523
|
-
class: "ui-component-panel",
|
|
2524
|
-
"model-value": _ctx.collapseValue
|
|
2525
|
-
}, {
|
|
2741
|
+
return (_ctx, _cache) => {
|
|
2742
|
+
const _component_el_input = vue.resolveComponent("el-input");
|
|
2743
|
+
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
2744
|
+
const _component_el_collapse_item = vue.resolveComponent("el-collapse-item");
|
|
2745
|
+
const _component_el_collapse = vue.resolveComponent("el-collapse");
|
|
2746
|
+
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
|
|
2747
|
+
return vue.openBlock(), vue.createBlock(_component_el_scrollbar, null, {
|
|
2526
2748
|
default: vue.withCtx(() => [
|
|
2527
|
-
vue.
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
},
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2749
|
+
vue.renderSlot(_ctx.$slots, "component-list-panel-header"),
|
|
2750
|
+
vue.createVNode(_component_el_collapse, {
|
|
2751
|
+
class: "ui-component-panel",
|
|
2752
|
+
"model-value": vue.unref(collapseValue)
|
|
2753
|
+
}, {
|
|
2754
|
+
default: vue.withCtx(() => [
|
|
2755
|
+
vue.createVNode(_component_el_input, {
|
|
2756
|
+
"prefix-icon": "el-icon-search",
|
|
2757
|
+
placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
|
|
2758
|
+
class: "search-input",
|
|
2759
|
+
size: "small",
|
|
2760
|
+
clearable: "",
|
|
2761
|
+
modelValue: searchText.value,
|
|
2762
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchText.value = $event)
|
|
2763
|
+
}, null, 8, ["modelValue"]),
|
|
2764
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(list), (group, index) => {
|
|
2765
|
+
return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
|
|
2766
|
+
group.items && group.items.length ? (vue.openBlock(), vue.createBlock(_component_el_collapse_item, {
|
|
2767
|
+
key: index,
|
|
2768
|
+
name: index
|
|
2769
|
+
}, {
|
|
2770
|
+
title: vue.withCtx(() => [
|
|
2771
|
+
_hoisted_1$4,
|
|
2772
|
+
vue.createTextVNode(vue.toDisplayString(group.title), 1)
|
|
2773
|
+
]),
|
|
2774
|
+
default: vue.withCtx(() => [
|
|
2775
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(group.items, (item) => {
|
|
2776
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
2777
|
+
class: "component-item",
|
|
2778
|
+
draggable: "true",
|
|
2779
|
+
key: item.type,
|
|
2780
|
+
onClick: ($event) => appendComponent(item),
|
|
2781
|
+
onDragstart: ($event) => dragstartHandler(item, $event),
|
|
2782
|
+
onDragend: dragendHandler,
|
|
2783
|
+
onDrag: dragHandler
|
|
2784
|
+
}, [
|
|
2785
|
+
vue.renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
|
|
2786
|
+
vue.createVNode(_sfc_main$h, {
|
|
2787
|
+
icon: item.icon
|
|
2788
|
+
}, null, 8, ["icon"]),
|
|
2789
|
+
vue.createVNode(_component_el_tooltip, {
|
|
2790
|
+
effect: "dark",
|
|
2791
|
+
placement: "bottom",
|
|
2792
|
+
content: item.text
|
|
2793
|
+
}, {
|
|
2794
|
+
default: vue.withCtx(() => [
|
|
2795
|
+
vue.createElementVNode("span", null, vue.toDisplayString(item.text), 1)
|
|
2796
|
+
]),
|
|
2797
|
+
_: 2
|
|
2798
|
+
}, 1032, ["content"])
|
|
2799
|
+
])
|
|
2800
|
+
], 40, _hoisted_2$1);
|
|
2801
|
+
}), 128))
|
|
2802
|
+
]),
|
|
2803
|
+
_: 2
|
|
2804
|
+
}, 1032, ["name"])) : vue.createCommentVNode("", true)
|
|
2805
|
+
], 64);
|
|
2806
|
+
}), 256))
|
|
2807
|
+
]),
|
|
2808
|
+
_: 3
|
|
2809
|
+
}, 8, ["model-value"])
|
|
2577
2810
|
]),
|
|
2578
|
-
_:
|
|
2579
|
-
}
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
}
|
|
2584
|
-
const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
|
|
2811
|
+
_: 3
|
|
2812
|
+
});
|
|
2813
|
+
};
|
|
2814
|
+
}
|
|
2815
|
+
});
|
|
2585
2816
|
|
|
2586
|
-
const _sfc_main$
|
|
2817
|
+
const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
|
|
2587
2818
|
__name: "ContentMenu",
|
|
2588
2819
|
props: {
|
|
2589
2820
|
menuData: { default: () => [] },
|
|
@@ -2672,7 +2903,7 @@
|
|
|
2672
2903
|
}, [
|
|
2673
2904
|
vue.createElementVNode("div", null, [
|
|
2674
2905
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.menuData, (item, index) => {
|
|
2675
|
-
return vue.openBlock(), vue.createBlock(_sfc_main$
|
|
2906
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$g, {
|
|
2676
2907
|
"event-type": "mouseup",
|
|
2677
2908
|
data: item,
|
|
2678
2909
|
key: index,
|
|
@@ -2696,8 +2927,8 @@
|
|
|
2696
2927
|
}
|
|
2697
2928
|
});
|
|
2698
2929
|
|
|
2699
|
-
const _sfc_main$
|
|
2700
|
-
components: { ContentMenu: _sfc_main$
|
|
2930
|
+
const _sfc_main$b = vue.defineComponent({
|
|
2931
|
+
components: { ContentMenu: _sfc_main$c },
|
|
2701
2932
|
setup() {
|
|
2702
2933
|
const services = vue.inject("services");
|
|
2703
2934
|
const menu = vue.ref();
|
|
@@ -2780,7 +3011,7 @@
|
|
|
2780
3011
|
}
|
|
2781
3012
|
});
|
|
2782
3013
|
|
|
2783
|
-
function _sfc_render$
|
|
3014
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2784
3015
|
const _component_content_menu = vue.resolveComponent("content-menu");
|
|
2785
3016
|
return vue.openBlock(), vue.createBlock(_component_content_menu, {
|
|
2786
3017
|
"menu-data": _ctx.menuData,
|
|
@@ -2788,7 +3019,7 @@
|
|
|
2788
3019
|
style: { "overflow": "initial" }
|
|
2789
3020
|
}, null, 8, ["menu-data"]);
|
|
2790
3021
|
}
|
|
2791
|
-
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3022
|
+
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$4]]);
|
|
2792
3023
|
|
|
2793
3024
|
const throttleTime = 150;
|
|
2794
3025
|
const select = async (data, editorService) => {
|
|
@@ -2839,20 +3070,38 @@
|
|
|
2839
3070
|
}
|
|
2840
3071
|
});
|
|
2841
3072
|
const useStatus = (tree, editorService) => {
|
|
2842
|
-
const highlightNode = vue.ref();
|
|
2843
3073
|
const node = vue.ref();
|
|
2844
3074
|
const page = vue.computed(() => editorService?.get("page"));
|
|
3075
|
+
const expandedKeys = /* @__PURE__ */ new Map();
|
|
3076
|
+
const expandNodes = () => {
|
|
3077
|
+
expandedKeys.forEach((key) => {
|
|
3078
|
+
if (!tree.value)
|
|
3079
|
+
return;
|
|
3080
|
+
tree.value.getNode(key)?.expand();
|
|
3081
|
+
});
|
|
3082
|
+
};
|
|
2845
3083
|
vue.watchEffect(() => {
|
|
2846
3084
|
if (!tree.value)
|
|
2847
3085
|
return;
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
3086
|
+
if (!editorService)
|
|
3087
|
+
return;
|
|
3088
|
+
node.value = editorService.get("node");
|
|
3089
|
+
if (!node.value)
|
|
3090
|
+
return;
|
|
3091
|
+
tree.value.setCurrentKey(node.value.id, true);
|
|
3092
|
+
const parent = editorService.get("parent");
|
|
2851
3093
|
if (!parent?.id)
|
|
2852
3094
|
return;
|
|
2853
3095
|
const treeNode = tree.value.getNode(parent.id);
|
|
2854
3096
|
treeNode?.updateChildren();
|
|
2855
|
-
|
|
3097
|
+
setTimeout(() => {
|
|
3098
|
+
tree.value && Object.entries(tree.value.store.nodesMap).forEach(([id, node2]) => {
|
|
3099
|
+
if (node2.expanded && node2.data.items) {
|
|
3100
|
+
expandedKeys.set(id, id);
|
|
3101
|
+
}
|
|
3102
|
+
});
|
|
3103
|
+
expandNodes();
|
|
3104
|
+
});
|
|
2856
3105
|
});
|
|
2857
3106
|
return {
|
|
2858
3107
|
values: vue.computed(() => page.value ? [page.value] : []),
|
|
@@ -2865,9 +3114,18 @@
|
|
|
2865
3114
|
}
|
|
2866
3115
|
resolve([]);
|
|
2867
3116
|
},
|
|
2868
|
-
highlightNode,
|
|
3117
|
+
highlightNode: vue.computed(() => editorService?.get("highlightNode")),
|
|
2869
3118
|
clickNode: node,
|
|
2870
|
-
expandedKeys: vue.computed(() => node.value ? [node.value.id] : [])
|
|
3119
|
+
expandedKeys: vue.computed(() => node.value ? [node.value.id] : []),
|
|
3120
|
+
handleCollapse: (data) => {
|
|
3121
|
+
expandedKeys.delete(data.id);
|
|
3122
|
+
},
|
|
3123
|
+
handleExpand: (data) => {
|
|
3124
|
+
const parent = editorService?.getParentById(data.id);
|
|
3125
|
+
if (!parent?.id)
|
|
3126
|
+
return;
|
|
3127
|
+
expandedKeys.set(parent.id, parent.id);
|
|
3128
|
+
}
|
|
2871
3129
|
};
|
|
2872
3130
|
};
|
|
2873
3131
|
const useFilter = (tree) => ({
|
|
@@ -2888,7 +3146,7 @@
|
|
|
2888
3146
|
tree.value?.filter(val);
|
|
2889
3147
|
}
|
|
2890
3148
|
});
|
|
2891
|
-
const _sfc_main$
|
|
3149
|
+
const _sfc_main$a = vue.defineComponent({
|
|
2892
3150
|
name: "magic-editor-layer-panel",
|
|
2893
3151
|
components: { LayerMenu },
|
|
2894
3152
|
setup() {
|
|
@@ -2936,8 +3194,8 @@
|
|
|
2936
3194
|
}
|
|
2937
3195
|
});
|
|
2938
3196
|
|
|
2939
|
-
const _hoisted_1$
|
|
2940
|
-
function _sfc_render$
|
|
3197
|
+
const _hoisted_1$3 = ["id", "onMouseenter"];
|
|
3198
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2941
3199
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
2942
3200
|
const _component_el_tree = vue.resolveComponent("el-tree");
|
|
2943
3201
|
const _component_layer_menu = vue.resolveComponent("layer-menu");
|
|
@@ -2958,6 +3216,7 @@
|
|
|
2958
3216
|
key: 0,
|
|
2959
3217
|
ref: "tree",
|
|
2960
3218
|
"node-key": "id",
|
|
3219
|
+
"empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
|
|
2961
3220
|
draggable: "",
|
|
2962
3221
|
"default-expanded-keys": _ctx.expandedKeys,
|
|
2963
3222
|
load: _ctx.loadItems,
|
|
@@ -2972,7 +3231,8 @@
|
|
|
2972
3231
|
onNodeClick: _ctx.clickHandler,
|
|
2973
3232
|
onNodeContextmenu: _ctx.contextmenu,
|
|
2974
3233
|
onNodeDragEnd: _ctx.handleDragEnd,
|
|
2975
|
-
|
|
3234
|
+
onNodeCollapse: _ctx.handleCollapse,
|
|
3235
|
+
onNodeExpand: _ctx.handleExpand
|
|
2976
3236
|
}, {
|
|
2977
3237
|
default: vue.withCtx(({ node, data }) => [
|
|
2978
3238
|
vue.createElementVNode("div", {
|
|
@@ -2988,10 +3248,10 @@
|
|
|
2988
3248
|
}, () => [
|
|
2989
3249
|
vue.createElementVNode("span", null, vue.toDisplayString(`${data.name} (${data.id})`), 1)
|
|
2990
3250
|
])
|
|
2991
|
-
], 42, _hoisted_1$
|
|
3251
|
+
], 42, _hoisted_1$3)
|
|
2992
3252
|
]),
|
|
2993
3253
|
_: 3
|
|
2994
|
-
}, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : vue.createCommentVNode("", true),
|
|
3254
|
+
}, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd", "onNodeCollapse", "onNodeExpand"])) : vue.createCommentVNode("", true),
|
|
2995
3255
|
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
2996
3256
|
vue.createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
|
|
2997
3257
|
]))
|
|
@@ -2999,10 +3259,10 @@
|
|
|
2999
3259
|
_: 3
|
|
3000
3260
|
});
|
|
3001
3261
|
}
|
|
3002
|
-
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3262
|
+
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$3]]);
|
|
3003
3263
|
|
|
3004
|
-
const _sfc_main$
|
|
3005
|
-
components: { MIcon },
|
|
3264
|
+
const _sfc_main$9 = vue.defineComponent({
|
|
3265
|
+
components: { MIcon: _sfc_main$h },
|
|
3006
3266
|
props: {
|
|
3007
3267
|
data: {
|
|
3008
3268
|
type: [Object, String]
|
|
@@ -3020,7 +3280,7 @@
|
|
|
3020
3280
|
type: "component",
|
|
3021
3281
|
icon: iconsVue.Coin,
|
|
3022
3282
|
text: "\u7EC4\u4EF6",
|
|
3023
|
-
component:
|
|
3283
|
+
component: _sfc_main$d,
|
|
3024
3284
|
slots: {}
|
|
3025
3285
|
};
|
|
3026
3286
|
case "layer":
|
|
@@ -3039,11 +3299,11 @@
|
|
|
3039
3299
|
}
|
|
3040
3300
|
});
|
|
3041
3301
|
|
|
3042
|
-
const _hoisted_1$
|
|
3302
|
+
const _hoisted_1$2 = {
|
|
3043
3303
|
key: 1,
|
|
3044
3304
|
class: "magic-editor-tab-panel-title"
|
|
3045
3305
|
};
|
|
3046
|
-
function _sfc_render$
|
|
3306
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3047
3307
|
const _component_m_icon = vue.resolveComponent("m-icon");
|
|
3048
3308
|
const _component_el_tab_pane = vue.resolveComponent("el-tab-pane");
|
|
3049
3309
|
return _ctx.config ? (vue.openBlock(), vue.createBlock(_component_el_tab_pane, {
|
|
@@ -3058,7 +3318,7 @@
|
|
|
3058
3318
|
key: 0,
|
|
3059
3319
|
icon: _ctx.config.icon
|
|
3060
3320
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
3061
|
-
_ctx.config.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
3321
|
+
_ctx.config.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, vue.toDisplayString(_ctx.config.text), 1)) : vue.createCommentVNode("", true)
|
|
3062
3322
|
]))
|
|
3063
3323
|
]),
|
|
3064
3324
|
default: vue.withCtx(() => [
|
|
@@ -3069,6 +3329,18 @@
|
|
|
3069
3329
|
_ctx.data === "component-list" ? vue.renderSlot(_ctx.$slots, "component-list-panel-header", { key: 0 }) : _ctx.config.slots?.componentListPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.slots.componentListPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
|
|
3070
3330
|
])
|
|
3071
3331
|
} : void 0,
|
|
3332
|
+
_ctx.data === "component-list" || _ctx.config.slots?.componentListItem ? {
|
|
3333
|
+
name: "component-list-item",
|
|
3334
|
+
fn: vue.withCtx(({ component }) => [
|
|
3335
|
+
_ctx.data === "component-list" ? vue.renderSlot(_ctx.$slots, "component-list-item", {
|
|
3336
|
+
key: 0,
|
|
3337
|
+
component
|
|
3338
|
+
}) : _ctx.config.slots?.componentListItem ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.slots.componentListItem), {
|
|
3339
|
+
key: 1,
|
|
3340
|
+
component
|
|
3341
|
+
}, null, 8, ["component"])) : vue.createCommentVNode("", true)
|
|
3342
|
+
])
|
|
3343
|
+
} : void 0,
|
|
3072
3344
|
_ctx.data === "layer" || _ctx.config.slots?.layerPanelHeader ? {
|
|
3073
3345
|
name: "layer-panel-header",
|
|
3074
3346
|
fn: vue.withCtx(() => [
|
|
@@ -3089,9 +3361,9 @@
|
|
|
3089
3361
|
_: 3
|
|
3090
3362
|
}, 8, ["name"])) : vue.createCommentVNode("", true);
|
|
3091
3363
|
}
|
|
3092
|
-
const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3364
|
+
const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$2]]);
|
|
3093
3365
|
|
|
3094
|
-
const _sfc_main$
|
|
3366
|
+
const _sfc_main$8 = vue.defineComponent({
|
|
3095
3367
|
components: { TabPane },
|
|
3096
3368
|
name: "m-sidebar",
|
|
3097
3369
|
props: {
|
|
@@ -3111,7 +3383,7 @@
|
|
|
3111
3383
|
}
|
|
3112
3384
|
});
|
|
3113
3385
|
|
|
3114
|
-
function _sfc_render$
|
|
3386
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3115
3387
|
const _component_tab_pane = vue.resolveComponent("tab-pane");
|
|
3116
3388
|
const _component_el_tabs = vue.resolveComponent("el-tabs");
|
|
3117
3389
|
return _ctx.data.type === "tabs" && _ctx.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_tabs, {
|
|
@@ -3139,6 +3411,12 @@
|
|
|
3139
3411
|
fn: vue.withCtx(() => [
|
|
3140
3412
|
vue.renderSlot(_ctx.$slots, "component-list-panel-header")
|
|
3141
3413
|
])
|
|
3414
|
+
} : void 0,
|
|
3415
|
+
item === "component-list" ? {
|
|
3416
|
+
name: "component-list-item",
|
|
3417
|
+
fn: vue.withCtx(({ component }) => [
|
|
3418
|
+
vue.renderSlot(_ctx.$slots, "component-list-item", { component })
|
|
3419
|
+
])
|
|
3142
3420
|
} : void 0
|
|
3143
3421
|
]), 1032, ["data"]);
|
|
3144
3422
|
}), 128))
|
|
@@ -3146,18 +3424,24 @@
|
|
|
3146
3424
|
_: 3
|
|
3147
3425
|
}, 8, ["modelValue"])) : vue.createCommentVNode("", true);
|
|
3148
3426
|
}
|
|
3149
|
-
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3427
|
+
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$1]]);
|
|
3150
3428
|
|
|
3151
|
-
const
|
|
3429
|
+
const _hoisted_1$1 = {
|
|
3430
|
+
key: 1,
|
|
3431
|
+
style: { "width": "21px" }
|
|
3432
|
+
};
|
|
3433
|
+
const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
|
|
3152
3434
|
__name: "PageBarScrollContainer",
|
|
3153
3435
|
setup(__props) {
|
|
3154
3436
|
const services = vue.inject("services");
|
|
3155
3437
|
const editorService = services?.editorService;
|
|
3438
|
+
const uiService = services?.uiService;
|
|
3156
3439
|
const pageBar = vue.ref();
|
|
3157
3440
|
const itemsContainer = vue.ref();
|
|
3158
3441
|
const pageBarWidth = vue.ref(0);
|
|
3159
3442
|
const canScroll = vue.ref(false);
|
|
3160
|
-
const
|
|
3443
|
+
const showAddPageButton = vue.computed(() => uiService?.get("showAddPageButton"));
|
|
3444
|
+
const itemsContainerWidth = vue.computed(() => pageBarWidth.value - 35 * 2 - (showAddPageButton.value ? 35 : 21));
|
|
3161
3445
|
let translateLeft = 0;
|
|
3162
3446
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
3163
3447
|
for (const { contentRect } of entries) {
|
|
@@ -3168,7 +3452,7 @@
|
|
|
3168
3452
|
});
|
|
3169
3453
|
const setCanScroll = () => {
|
|
3170
3454
|
if (itemsContainer.value) {
|
|
3171
|
-
canScroll.value = itemsContainer.value.scrollWidth >
|
|
3455
|
+
canScroll.value = itemsContainer.value.scrollWidth > itemsContainerWidth.value;
|
|
3172
3456
|
}
|
|
3173
3457
|
};
|
|
3174
3458
|
const scroll = (type) => {
|
|
@@ -3225,7 +3509,8 @@
|
|
|
3225
3509
|
ref_key: "pageBar",
|
|
3226
3510
|
ref: pageBar
|
|
3227
3511
|
}, [
|
|
3228
|
-
vue.
|
|
3512
|
+
vue.unref(showAddPageButton) ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3513
|
+
key: 0,
|
|
3229
3514
|
id: "m-editor-page-bar-add-icon",
|
|
3230
3515
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3231
3516
|
onClick: addPage
|
|
@@ -3236,9 +3521,9 @@
|
|
|
3236
3521
|
]),
|
|
3237
3522
|
_: 1
|
|
3238
3523
|
})
|
|
3239
|
-
]),
|
|
3524
|
+
])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1)),
|
|
3240
3525
|
canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3241
|
-
key:
|
|
3526
|
+
key: 2,
|
|
3242
3527
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3243
3528
|
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
3244
3529
|
}, [
|
|
@@ -3250,7 +3535,7 @@
|
|
|
3250
3535
|
})
|
|
3251
3536
|
])) : vue.createCommentVNode("", true),
|
|
3252
3537
|
vue.unref(root) ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3253
|
-
key:
|
|
3538
|
+
key: 3,
|
|
3254
3539
|
class: "m-editor-page-bar-items",
|
|
3255
3540
|
ref_key: "itemsContainer",
|
|
3256
3541
|
ref: itemsContainer,
|
|
@@ -3259,7 +3544,7 @@
|
|
|
3259
3544
|
vue.renderSlot(_ctx.$slots, "default")
|
|
3260
3545
|
], 4)) : vue.createCommentVNode("", true),
|
|
3261
3546
|
canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3262
|
-
key:
|
|
3547
|
+
key: 4,
|
|
3263
3548
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3264
3549
|
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
3265
3550
|
}, [
|
|
@@ -3275,9 +3560,9 @@
|
|
|
3275
3560
|
}
|
|
3276
3561
|
});
|
|
3277
3562
|
|
|
3278
|
-
const _hoisted_1
|
|
3563
|
+
const _hoisted_1 = ["onClick"];
|
|
3279
3564
|
const _hoisted_2 = { class: "m-editor-page-bar-title" };
|
|
3280
|
-
const _sfc_main$
|
|
3565
|
+
const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
|
|
3281
3566
|
__name: "PageBar",
|
|
3282
3567
|
setup(__props) {
|
|
3283
3568
|
const services = vue.inject("services");
|
|
@@ -3301,7 +3586,7 @@
|
|
|
3301
3586
|
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
3302
3587
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
3303
3588
|
const _component_el_popover = vue.resolveComponent("el-popover");
|
|
3304
|
-
return vue.openBlock(), vue.createBlock(_sfc_main$
|
|
3589
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$7, null, {
|
|
3305
3590
|
default: vue.withCtx(() => [
|
|
3306
3591
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(root) && vue.unref(root).items || [], (item) => {
|
|
3307
3592
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
@@ -3317,7 +3602,7 @@
|
|
|
3317
3602
|
content: item.name
|
|
3318
3603
|
}, {
|
|
3319
3604
|
default: vue.withCtx(() => [
|
|
3320
|
-
vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
|
|
3605
|
+
vue.createElementVNode("span", null, vue.toDisplayString(item.name || item.id), 1)
|
|
3321
3606
|
]),
|
|
3322
3607
|
_: 2
|
|
3323
3608
|
}, 1032, ["content"])
|
|
@@ -3340,7 +3625,7 @@
|
|
|
3340
3625
|
default: vue.withCtx(() => [
|
|
3341
3626
|
vue.createElementVNode("div", null, [
|
|
3342
3627
|
vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3343
|
-
vue.createVNode(_sfc_main$
|
|
3628
|
+
vue.createVNode(_sfc_main$g, {
|
|
3344
3629
|
data: {
|
|
3345
3630
|
type: "button",
|
|
3346
3631
|
text: "\u590D\u5236",
|
|
@@ -3348,7 +3633,7 @@
|
|
|
3348
3633
|
handler: () => copy(item)
|
|
3349
3634
|
}
|
|
3350
3635
|
}, null, 8, ["data"]),
|
|
3351
|
-
vue.createVNode(_sfc_main$
|
|
3636
|
+
vue.createVNode(_sfc_main$g, {
|
|
3352
3637
|
data: {
|
|
3353
3638
|
type: "button",
|
|
3354
3639
|
text: "\u5220\u9664",
|
|
@@ -3361,7 +3646,7 @@
|
|
|
3361
3646
|
]),
|
|
3362
3647
|
_: 2
|
|
3363
3648
|
}, 1024)
|
|
3364
|
-
], 10, _hoisted_1
|
|
3649
|
+
], 10, _hoisted_1);
|
|
3365
3650
|
}), 128))
|
|
3366
3651
|
]),
|
|
3367
3652
|
_: 3
|
|
@@ -3370,190 +3655,245 @@
|
|
|
3370
3655
|
}
|
|
3371
3656
|
});
|
|
3372
3657
|
|
|
3373
|
-
class ScrollViewer
|
|
3374
|
-
enter = false;
|
|
3375
|
-
targetEnter = false;
|
|
3376
|
-
keydown = false;
|
|
3658
|
+
class ScrollViewer extends events.EventEmitter {
|
|
3377
3659
|
container;
|
|
3378
3660
|
target;
|
|
3379
3661
|
zoom = 1;
|
|
3380
3662
|
scrollLeft = 0;
|
|
3381
3663
|
scrollTop = 0;
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
if (targetWidth < width) {
|
|
3392
|
-
this.target._left = 0;
|
|
3393
|
-
}
|
|
3394
|
-
if (targetHeight < height) {
|
|
3395
|
-
this.target._top = 0;
|
|
3396
|
-
}
|
|
3397
|
-
this.scroll();
|
|
3398
|
-
}
|
|
3664
|
+
scrollHeight = 0;
|
|
3665
|
+
scrollWidth = 0;
|
|
3666
|
+
width = 0;
|
|
3667
|
+
height = 0;
|
|
3668
|
+
translateXCorrectionValue = 0;
|
|
3669
|
+
translateYCorrectionValue = 0;
|
|
3670
|
+
resizeObserver = new ResizeObserver(() => {
|
|
3671
|
+
this.setSize();
|
|
3672
|
+
this.setScrollSize();
|
|
3399
3673
|
});
|
|
3400
3674
|
constructor(options) {
|
|
3675
|
+
super();
|
|
3401
3676
|
this.container = options.container;
|
|
3402
3677
|
this.target = options.target;
|
|
3403
3678
|
this.zoom = options.zoom;
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
this.
|
|
3407
|
-
this.container.addEventListener("mouseleave", this.mouseLeaveHandler);
|
|
3408
|
-
this.target.addEventListener("mouseenter", this.targetMouseEnterHandler);
|
|
3409
|
-
this.target.addEventListener("mouseleave", this.targetMouseLeaveHandler);
|
|
3410
|
-
this.container.addEventListener("wheel", this.wheelHandler);
|
|
3679
|
+
this.container.addEventListener("wheel", this.wheelHandler, false);
|
|
3680
|
+
this.setSize();
|
|
3681
|
+
this.setScrollSize();
|
|
3411
3682
|
this.resizeObserver.observe(this.container);
|
|
3412
3683
|
}
|
|
3413
3684
|
destroy() {
|
|
3414
3685
|
this.resizeObserver.disconnect();
|
|
3415
|
-
this.container.removeEventListener("
|
|
3416
|
-
this.
|
|
3417
|
-
this.target.removeEventListener("mouseenter", this.targetMouseEnterHandler);
|
|
3418
|
-
this.target.removeEventListener("mouseleave", this.targetMouseLeaveHandler);
|
|
3419
|
-
globalThis.removeEventListener("keydown", this.keydownHandler);
|
|
3420
|
-
globalThis.removeEventListener("keyup", this.keyupHandler);
|
|
3686
|
+
this.container.removeEventListener("wheel", this.wheelHandler, false);
|
|
3687
|
+
this.removeAllListeners();
|
|
3421
3688
|
}
|
|
3422
3689
|
setZoom(zoom) {
|
|
3423
3690
|
this.zoom = zoom;
|
|
3691
|
+
this.setScrollSize();
|
|
3424
3692
|
}
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
this.
|
|
3433
|
-
|
|
3434
|
-
|
|
3693
|
+
scrollTo({ left, top }) {
|
|
3694
|
+
if (typeof left !== "undefined") {
|
|
3695
|
+
this.scrollLeft = left;
|
|
3696
|
+
}
|
|
3697
|
+
if (typeof top !== "undefined") {
|
|
3698
|
+
this.scrollTop = top;
|
|
3699
|
+
}
|
|
3700
|
+
const translateX = -this.scrollLeft + this.translateXCorrectionValue;
|
|
3701
|
+
const translateY = -this.scrollTop + this.translateYCorrectionValue;
|
|
3702
|
+
this.target.style.transform = `translate(${translateX}px, ${translateY}px)`;
|
|
3435
3703
|
}
|
|
3436
3704
|
wheelHandler = (event) => {
|
|
3437
|
-
if (this.targetEnter)
|
|
3438
|
-
return;
|
|
3439
3705
|
const { deltaX, deltaY, currentTarget } = event;
|
|
3440
3706
|
if (currentTarget !== this.container)
|
|
3441
3707
|
return;
|
|
3442
|
-
|
|
3443
|
-
this.
|
|
3444
|
-
|
|
3445
|
-
this.scrollTop = this.target._top;
|
|
3446
|
-
};
|
|
3447
|
-
mouseEnterHandler = () => {
|
|
3448
|
-
this.enter = true;
|
|
3449
|
-
};
|
|
3450
|
-
mouseLeaveHandler = () => {
|
|
3451
|
-
this.enter = false;
|
|
3452
|
-
};
|
|
3453
|
-
targetMouseEnterHandler = () => {
|
|
3454
|
-
this.targetEnter = true;
|
|
3455
|
-
};
|
|
3456
|
-
targetMouseLeaveHandler = () => {
|
|
3457
|
-
this.targetEnter = false;
|
|
3458
|
-
};
|
|
3459
|
-
mousedownHandler = (event) => {
|
|
3460
|
-
if (!this.keydown)
|
|
3461
|
-
return;
|
|
3462
|
-
event.stopImmediatePropagation();
|
|
3463
|
-
event.stopPropagation();
|
|
3464
|
-
this.target.style.cursor = "grabbing";
|
|
3465
|
-
this.x = event.clientX;
|
|
3466
|
-
this.y = event.clientY;
|
|
3467
|
-
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3468
|
-
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3469
|
-
};
|
|
3470
|
-
mouseupHandler = () => {
|
|
3471
|
-
this.x = 0;
|
|
3472
|
-
this.y = 0;
|
|
3473
|
-
this.scrollLeft = this.target._left;
|
|
3474
|
-
this.scrollTop = this.target._top;
|
|
3475
|
-
this.removeHandler();
|
|
3476
|
-
};
|
|
3477
|
-
mousemoveHandler = (event) => {
|
|
3478
|
-
event.stopImmediatePropagation();
|
|
3479
|
-
event.stopPropagation();
|
|
3480
|
-
const deltaX = event.clientX - this.x;
|
|
3481
|
-
const deltaY = event.clientY - this.y;
|
|
3482
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3483
|
-
this.scroll();
|
|
3484
|
-
};
|
|
3485
|
-
keydownHandler = (event) => {
|
|
3486
|
-
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3487
|
-
event.preventDefault();
|
|
3488
|
-
event.stopImmediatePropagation();
|
|
3489
|
-
event.stopPropagation();
|
|
3708
|
+
let top;
|
|
3709
|
+
if (this.scrollHeight > this.height) {
|
|
3710
|
+
top = this.scrollTop + this.getPos(deltaY, this.scrollTop, this.scrollHeight, this.height);
|
|
3490
3711
|
}
|
|
3491
|
-
|
|
3492
|
-
|
|
3712
|
+
let left;
|
|
3713
|
+
if (this.scrollWidth > this.width) {
|
|
3714
|
+
left = this.scrollLeft + this.getPos(deltaX, this.scrollLeft, this.scrollWidth, this.width);
|
|
3493
3715
|
}
|
|
3494
|
-
this.
|
|
3495
|
-
this.
|
|
3496
|
-
|
|
3716
|
+
this.scrollTo({ left, top });
|
|
3717
|
+
this.emit("scroll", {
|
|
3718
|
+
scrollLeft: this.scrollLeft,
|
|
3719
|
+
scrollTop: this.scrollTop,
|
|
3720
|
+
scrollHeight: this.scrollHeight,
|
|
3721
|
+
scrollWidth: this.scrollWidth
|
|
3722
|
+
});
|
|
3497
3723
|
};
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3724
|
+
getPos(delta, scrollPos, scrollSize, size) {
|
|
3725
|
+
let pos = 0;
|
|
3726
|
+
if (delta < 0) {
|
|
3727
|
+
if (scrollPos > 0) {
|
|
3728
|
+
pos = Math.max(delta, -scrollPos);
|
|
3729
|
+
}
|
|
3730
|
+
} else {
|
|
3731
|
+
const leftPos = scrollSize - size - scrollPos;
|
|
3732
|
+
if (leftPos > 0) {
|
|
3733
|
+
pos = Math.min(delta, leftPos);
|
|
3734
|
+
}
|
|
3735
|
+
}
|
|
3736
|
+
return pos;
|
|
3737
|
+
}
|
|
3738
|
+
setScrollSize = () => {
|
|
3739
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3740
|
+
this.scrollWidth = targetRect.width * this.zoom + 100;
|
|
3741
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3742
|
+
this.scrollHeight = (targetRect.height + targetMarginTop) * this.zoom + 100;
|
|
3743
|
+
let left;
|
|
3744
|
+
let top;
|
|
3745
|
+
if (this.scrollWidth < this.width) {
|
|
3746
|
+
left = 0;
|
|
3747
|
+
this.translateXCorrectionValue = 0;
|
|
3748
|
+
} else {
|
|
3749
|
+
this.translateXCorrectionValue = (this.scrollWidth - this.width) / 2;
|
|
3750
|
+
}
|
|
3751
|
+
if (this.scrollHeight < this.height) {
|
|
3752
|
+
top = 0;
|
|
3753
|
+
this.translateYCorrectionValue = 0;
|
|
3754
|
+
} else {
|
|
3755
|
+
this.translateYCorrectionValue = (this.scrollHeight - this.height) / 2;
|
|
3501
3756
|
}
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3757
|
+
this.scrollTo({
|
|
3758
|
+
left,
|
|
3759
|
+
top
|
|
3760
|
+
});
|
|
3761
|
+
this.emit("scroll", {
|
|
3762
|
+
scrollLeft: this.scrollLeft,
|
|
3763
|
+
scrollTop: this.scrollTop,
|
|
3764
|
+
scrollHeight: this.scrollHeight,
|
|
3765
|
+
scrollWidth: this.scrollWidth
|
|
3766
|
+
});
|
|
3508
3767
|
};
|
|
3509
|
-
|
|
3768
|
+
setSize = () => {
|
|
3510
3769
|
const { width, height } = this.container.getBoundingClientRect();
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3770
|
+
this.width = width;
|
|
3771
|
+
this.height = height;
|
|
3772
|
+
};
|
|
3773
|
+
}
|
|
3774
|
+
|
|
3775
|
+
const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
|
|
3776
|
+
__name: "ScrollBar",
|
|
3777
|
+
props: {
|
|
3778
|
+
size: null,
|
|
3779
|
+
scrollSize: null,
|
|
3780
|
+
isHorizontal: { type: Boolean },
|
|
3781
|
+
pos: null
|
|
3782
|
+
},
|
|
3783
|
+
emits: ["scroll"],
|
|
3784
|
+
setup(__props, { emit }) {
|
|
3785
|
+
const props = __props;
|
|
3786
|
+
const bar = vue.ref();
|
|
3787
|
+
const thumb = vue.ref();
|
|
3788
|
+
const thumbSize = vue.computed(() => props.size * (props.size / props.scrollSize));
|
|
3789
|
+
const thumbPos = vue.computed(() => props.pos / props.scrollSize * props.size);
|
|
3790
|
+
const thumbStyle = vue.computed(() => ({
|
|
3791
|
+
[props.isHorizontal ? "width" : "height"]: `${thumbSize.value}px`,
|
|
3792
|
+
transform: `translate${props.isHorizontal ? "X" : "Y"}(${thumbPos.value}px)`
|
|
3793
|
+
}));
|
|
3794
|
+
let gesto;
|
|
3795
|
+
vue.onMounted(() => {
|
|
3796
|
+
if (!thumb.value)
|
|
3797
|
+
return;
|
|
3798
|
+
const thumbEl = thumb.value;
|
|
3799
|
+
gesto = new Gesto__default.default(thumbEl, {
|
|
3800
|
+
container: window
|
|
3801
|
+
});
|
|
3802
|
+
gesto.on("dragStart", (e) => {
|
|
3803
|
+
e.inputEvent.stopPropagation();
|
|
3804
|
+
e.inputEvent.preventDefault();
|
|
3805
|
+
}).on("drag", (e) => {
|
|
3806
|
+
scrollBy(getDelta(e));
|
|
3807
|
+
});
|
|
3808
|
+
bar.value?.addEventListener("wheel", wheelHandler, false);
|
|
3809
|
+
});
|
|
3810
|
+
vue.onUnmounted(() => {
|
|
3811
|
+
if (gesto)
|
|
3812
|
+
gesto.off();
|
|
3813
|
+
bar.value?.removeEventListener("wheel", wheelHandler, false);
|
|
3814
|
+
});
|
|
3815
|
+
const wheelHandler = (e) => {
|
|
3816
|
+
const delta = props.isHorizontal ? e.deltaX : e.deltaY;
|
|
3817
|
+
if (delta) {
|
|
3818
|
+
e.preventDefault();
|
|
3520
3819
|
}
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3820
|
+
scrollBy(delta);
|
|
3821
|
+
};
|
|
3822
|
+
const getDelta = (e) => {
|
|
3823
|
+
const ratio = (props.isHorizontal ? e.deltaX : e.deltaY) / props.size;
|
|
3824
|
+
return props.scrollSize * ratio;
|
|
3825
|
+
};
|
|
3826
|
+
const scrollBy = (delta) => {
|
|
3827
|
+
if (delta < 0) {
|
|
3828
|
+
if (props.pos <= 0) {
|
|
3829
|
+
emit("scroll", 0);
|
|
3830
|
+
} else {
|
|
3831
|
+
emit("scroll", -Math.min(-delta, props.pos));
|
|
3832
|
+
}
|
|
3526
3833
|
} else {
|
|
3527
|
-
|
|
3834
|
+
const leftPos = props.size - (thumbSize.value + thumbPos.value);
|
|
3835
|
+
if (leftPos <= 0) {
|
|
3836
|
+
emit("scroll", 0);
|
|
3837
|
+
} else {
|
|
3838
|
+
emit("scroll", Math.min(delta, leftPos));
|
|
3839
|
+
}
|
|
3528
3840
|
}
|
|
3529
|
-
}
|
|
3530
|
-
|
|
3531
|
-
|
|
3841
|
+
};
|
|
3842
|
+
return (_ctx, _cache) => {
|
|
3843
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
3844
|
+
ref_key: "bar",
|
|
3845
|
+
ref: bar,
|
|
3846
|
+
class: vue.normalizeClass(["m-editor-scroll-bar", __props.isHorizontal ? "horizontal" : "vertical"])
|
|
3847
|
+
}, [
|
|
3848
|
+
vue.createElementVNode("div", {
|
|
3849
|
+
ref_key: "thumb",
|
|
3850
|
+
ref: thumb,
|
|
3851
|
+
class: "m-editor-scroll-bar-thumb",
|
|
3852
|
+
style: vue.normalizeStyle(vue.unref(thumbStyle))
|
|
3853
|
+
}, null, 4)
|
|
3854
|
+
], 2);
|
|
3855
|
+
};
|
|
3532
3856
|
}
|
|
3533
|
-
}
|
|
3857
|
+
});
|
|
3534
3858
|
|
|
3535
|
-
const
|
|
3536
|
-
|
|
3859
|
+
const ScrollBar_vue_vue_type_style_index_0_lang = '';
|
|
3860
|
+
|
|
3861
|
+
const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
|
|
3862
|
+
__name: "ScrollViewer",
|
|
3537
3863
|
props: {
|
|
3538
|
-
width:
|
|
3539
|
-
height:
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
}
|
|
3864
|
+
width: { default: 0 },
|
|
3865
|
+
height: { default: 0 },
|
|
3866
|
+
wrapWidth: { default: 0 },
|
|
3867
|
+
wrapHeight: { default: 0 },
|
|
3868
|
+
zoom: { default: 1 }
|
|
3544
3869
|
},
|
|
3545
|
-
setup(
|
|
3870
|
+
setup(__props, { expose }) {
|
|
3871
|
+
const props = __props;
|
|
3546
3872
|
const container = vue.ref();
|
|
3547
3873
|
const el = vue.ref();
|
|
3874
|
+
const style = vue.computed(() => `
|
|
3875
|
+
width: ${props.width}px;
|
|
3876
|
+
height: ${props.height}px;
|
|
3877
|
+
position: absolute;
|
|
3878
|
+
margin-top: 30px;
|
|
3879
|
+
`);
|
|
3880
|
+
const scrollWidth = vue.ref(0);
|
|
3881
|
+
const scrollHeight = vue.ref(0);
|
|
3548
3882
|
let scrollViewer;
|
|
3549
3883
|
vue.onMounted(() => {
|
|
3550
3884
|
if (!container.value || !el.value)
|
|
3551
3885
|
return;
|
|
3552
|
-
scrollViewer = new ScrollViewer
|
|
3886
|
+
scrollViewer = new ScrollViewer({
|
|
3553
3887
|
container: container.value,
|
|
3554
3888
|
target: el.value,
|
|
3555
3889
|
zoom: props.zoom
|
|
3556
3890
|
});
|
|
3891
|
+
scrollViewer.on("scroll", (data) => {
|
|
3892
|
+
hOffset.value = data.scrollLeft;
|
|
3893
|
+
vOffset.value = data.scrollTop;
|
|
3894
|
+
scrollWidth.value = data.scrollWidth;
|
|
3895
|
+
scrollHeight.value = data.scrollHeight;
|
|
3896
|
+
});
|
|
3557
3897
|
});
|
|
3558
3898
|
vue.onUnmounted(() => {
|
|
3559
3899
|
scrollViewer.destroy();
|
|
@@ -3561,35 +3901,56 @@
|
|
|
3561
3901
|
vue.watch(() => props.zoom, () => {
|
|
3562
3902
|
scrollViewer.setZoom(props.zoom);
|
|
3563
3903
|
});
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3904
|
+
const vOffset = vue.ref(0);
|
|
3905
|
+
const vScrollHandler = (delta) => {
|
|
3906
|
+
vOffset.value += delta;
|
|
3907
|
+
scrollViewer.scrollTo({
|
|
3908
|
+
top: vOffset.value
|
|
3909
|
+
});
|
|
3910
|
+
};
|
|
3911
|
+
const hOffset = vue.ref(0);
|
|
3912
|
+
const hScrollHandler = (delta) => {
|
|
3913
|
+
hOffset.value += delta;
|
|
3914
|
+
scrollViewer.scrollTo({
|
|
3915
|
+
left: hOffset.value
|
|
3916
|
+
});
|
|
3917
|
+
};
|
|
3918
|
+
expose({
|
|
3919
|
+
container
|
|
3920
|
+
});
|
|
3921
|
+
return (_ctx, _cache) => {
|
|
3922
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
3923
|
+
class: "m-editor-scroll-viewer-container",
|
|
3924
|
+
ref_key: "container",
|
|
3925
|
+
ref: container
|
|
3926
|
+
}, [
|
|
3927
|
+
vue.createElementVNode("div", {
|
|
3928
|
+
ref_key: "el",
|
|
3929
|
+
ref: el,
|
|
3930
|
+
style: vue.normalizeStyle(vue.unref(style))
|
|
3931
|
+
}, [
|
|
3932
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
3933
|
+
], 4),
|
|
3934
|
+
scrollHeight.value > __props.wrapHeight ? (vue.openBlock(), vue.createBlock(_sfc_main$5, {
|
|
3935
|
+
key: 0,
|
|
3936
|
+
"scroll-size": scrollHeight.value,
|
|
3937
|
+
size: __props.wrapHeight,
|
|
3938
|
+
pos: vOffset.value,
|
|
3939
|
+
onScroll: vScrollHandler
|
|
3940
|
+
}, null, 8, ["scroll-size", "size", "pos"])) : vue.createCommentVNode("", true),
|
|
3941
|
+
scrollWidth.value > __props.wrapWidth ? (vue.openBlock(), vue.createBlock(_sfc_main$5, {
|
|
3942
|
+
key: 1,
|
|
3943
|
+
"is-horizontal": true,
|
|
3944
|
+
"scroll-size": scrollWidth.value,
|
|
3945
|
+
pos: hOffset.value,
|
|
3946
|
+
size: __props.wrapWidth,
|
|
3947
|
+
onScroll: hScrollHandler
|
|
3948
|
+
}, null, 8, ["scroll-size", "pos", "size"])) : vue.createCommentVNode("", true)
|
|
3949
|
+
], 512);
|
|
3573
3950
|
};
|
|
3574
3951
|
}
|
|
3575
3952
|
});
|
|
3576
3953
|
|
|
3577
|
-
const _hoisted_1$1 = {
|
|
3578
|
-
class: "m-editor-scroll-viewer-container",
|
|
3579
|
-
ref: "container"
|
|
3580
|
-
};
|
|
3581
|
-
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3582
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
|
|
3583
|
-
vue.createElementVNode("div", {
|
|
3584
|
-
ref: "el",
|
|
3585
|
-
style: vue.normalizeStyle(_ctx.style)
|
|
3586
|
-
}, [
|
|
3587
|
-
vue.renderSlot(_ctx.$slots, "default")
|
|
3588
|
-
], 4)
|
|
3589
|
-
], 512);
|
|
3590
|
-
}
|
|
3591
|
-
const ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$2]]);
|
|
3592
|
-
|
|
3593
3954
|
const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
3594
3955
|
__name: "ViewerMenu",
|
|
3595
3956
|
props: {
|
|
@@ -3726,7 +4087,7 @@
|
|
|
3726
4087
|
};
|
|
3727
4088
|
expose({ show });
|
|
3728
4089
|
return (_ctx, _cache) => {
|
|
3729
|
-
return vue.openBlock(), vue.createBlock(_sfc_main$
|
|
4090
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$c, {
|
|
3730
4091
|
"menu-data": menuData,
|
|
3731
4092
|
ref_key: "menu",
|
|
3732
4093
|
ref: menu
|
|
@@ -3747,12 +4108,11 @@
|
|
|
3747
4108
|
const menu = vue.ref();
|
|
3748
4109
|
const isMultiSelect = vue.computed(() => services?.editorService.get("nodes")?.length > 1);
|
|
3749
4110
|
const stageRect = vue.computed(() => services?.uiService.get("stageRect"));
|
|
3750
|
-
const
|
|
4111
|
+
const stageContainerRect = vue.computed(() => services?.uiService.get("stageContainerRect"));
|
|
3751
4112
|
const root = vue.computed(() => services?.editorService.get("root"));
|
|
3752
4113
|
const page = vue.computed(() => services?.editorService.get("page"));
|
|
3753
4114
|
const zoom = vue.computed(() => services?.uiService.get("zoom") || 1);
|
|
3754
4115
|
const node = vue.computed(() => services?.editorService.get("node"));
|
|
3755
|
-
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
3756
4116
|
vue.watchEffect(() => {
|
|
3757
4117
|
if (stage)
|
|
3758
4118
|
return;
|
|
@@ -3760,64 +4120,9 @@
|
|
|
3760
4120
|
return;
|
|
3761
4121
|
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
|
|
3762
4122
|
return;
|
|
3763
|
-
stage =
|
|
3764
|
-
render: stageOptions.render,
|
|
3765
|
-
runtimeUrl: stageOptions.runtimeUrl,
|
|
3766
|
-
zoom: zoom.value,
|
|
3767
|
-
autoScrollIntoView: stageOptions.autoScrollIntoView,
|
|
3768
|
-
isContainer: stageOptions.isContainer,
|
|
3769
|
-
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
3770
|
-
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
3771
|
-
containerHighlightType: stageOptions.containerHighlightType,
|
|
3772
|
-
canSelect: (el, event, stop) => {
|
|
3773
|
-
const elCanSelect = stageOptions.canSelect(el);
|
|
3774
|
-
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
3775
|
-
document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
|
|
3776
|
-
return stop();
|
|
3777
|
-
}
|
|
3778
|
-
return elCanSelect;
|
|
3779
|
-
},
|
|
3780
|
-
moveableOptions: stageOptions.moveableOptions,
|
|
3781
|
-
updateDragEl: stageOptions.updateDragEl
|
|
3782
|
-
});
|
|
4123
|
+
stage = useStage(stageOptions);
|
|
3783
4124
|
services?.editorService.set("stage", vue.markRaw(stage));
|
|
3784
4125
|
stage?.mount(stageContainer.value);
|
|
3785
|
-
stage.mask.setGuides([
|
|
3786
|
-
getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
|
|
3787
|
-
getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
|
|
3788
|
-
]);
|
|
3789
|
-
stage?.on("select", (el) => {
|
|
3790
|
-
services?.editorService.select(el.id);
|
|
3791
|
-
});
|
|
3792
|
-
stage?.on("highlight", (el) => {
|
|
3793
|
-
services?.editorService.highlight(el.id);
|
|
3794
|
-
});
|
|
3795
|
-
stage?.on("multiSelect", (els) => {
|
|
3796
|
-
services?.editorService.multiSelect(els.map((el) => el.id));
|
|
3797
|
-
});
|
|
3798
|
-
stage?.on("update", (ev) => {
|
|
3799
|
-
if (ev.parentEl) {
|
|
3800
|
-
for (const data of ev.data) {
|
|
3801
|
-
services?.editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
3802
|
-
}
|
|
3803
|
-
return;
|
|
3804
|
-
}
|
|
3805
|
-
services?.editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
3806
|
-
});
|
|
3807
|
-
stage?.on("sort", (ev) => {
|
|
3808
|
-
services?.editorService.sort(ev.src, ev.dist);
|
|
3809
|
-
});
|
|
3810
|
-
stage?.on("changeGuides", (e2) => {
|
|
3811
|
-
services?.uiService.set("showGuides", true);
|
|
3812
|
-
if (!root.value || !page.value)
|
|
3813
|
-
return;
|
|
3814
|
-
const storageKey = getGuideLineKey(e2.type === StageCore.GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY);
|
|
3815
|
-
if (e2.guides.length) {
|
|
3816
|
-
globalThis.localStorage.setItem(storageKey, JSON.stringify(e2.guides));
|
|
3817
|
-
} else {
|
|
3818
|
-
globalThis.localStorage.removeItem(storageKey);
|
|
3819
|
-
}
|
|
3820
|
-
});
|
|
3821
4126
|
if (!node.value?.id)
|
|
3822
4127
|
return;
|
|
3823
4128
|
stage?.on("runtime-ready", (rt) => {
|
|
@@ -3895,20 +4200,22 @@
|
|
|
3895
4200
|
config.style = {
|
|
3896
4201
|
...style,
|
|
3897
4202
|
position,
|
|
3898
|
-
top,
|
|
3899
|
-
left
|
|
4203
|
+
top: top / zoom.value,
|
|
4204
|
+
left: left / zoom.value
|
|
3900
4205
|
};
|
|
3901
4206
|
config.inputEvent = e;
|
|
3902
4207
|
services?.editorService.add(config, parent);
|
|
3903
4208
|
}
|
|
3904
4209
|
};
|
|
3905
4210
|
return (_ctx, _cache) => {
|
|
3906
|
-
return vue.openBlock(), vue.createBlock(
|
|
4211
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$4, {
|
|
3907
4212
|
class: "m-editor-stage",
|
|
3908
4213
|
ref_key: "stageWrap",
|
|
3909
4214
|
ref: stageWrap,
|
|
3910
4215
|
width: vue.unref(stageRect)?.width,
|
|
3911
4216
|
height: vue.unref(stageRect)?.height,
|
|
4217
|
+
"wrap-width": vue.unref(stageContainerRect)?.width,
|
|
4218
|
+
"wrap-height": vue.unref(stageContainerRect)?.height,
|
|
3912
4219
|
zoom: vue.unref(zoom)
|
|
3913
4220
|
}, {
|
|
3914
4221
|
default: vue.withCtx(() => [
|
|
@@ -3916,7 +4223,7 @@
|
|
|
3916
4223
|
class: "m-editor-stage-container",
|
|
3917
4224
|
ref_key: "stageContainer",
|
|
3918
4225
|
ref: stageContainer,
|
|
3919
|
-
style: vue.normalizeStyle(`transform: scale(${vue.unref(zoom)})
|
|
4226
|
+
style: vue.normalizeStyle(`transform: scale(${vue.unref(zoom)});`),
|
|
3920
4227
|
onContextmenu: contextmenuHandler,
|
|
3921
4228
|
onDrop: dropHandler,
|
|
3922
4229
|
onDragover: dragoverHandler
|
|
@@ -3930,28 +4237,25 @@
|
|
|
3930
4237
|
]))
|
|
3931
4238
|
]),
|
|
3932
4239
|
_: 1
|
|
3933
|
-
}, 8, ["width", "height", "zoom"]);
|
|
4240
|
+
}, 8, ["width", "height", "wrap-width", "wrap-height", "zoom"]);
|
|
3934
4241
|
};
|
|
3935
4242
|
}
|
|
3936
4243
|
});
|
|
3937
4244
|
|
|
3938
|
-
const _sfc_main$1 = vue.defineComponent({
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
PageBar: _sfc_main$5,
|
|
3942
|
-
MagicStage: _sfc_main$2
|
|
3943
|
-
},
|
|
3944
|
-
setup() {
|
|
4245
|
+
const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
4246
|
+
__name: "Workspace",
|
|
4247
|
+
setup(__props) {
|
|
3945
4248
|
const services = vue.inject("services");
|
|
3946
4249
|
const workspace = vue.ref();
|
|
3947
4250
|
const nodes = vue.computed(() => services?.editorService.get("nodes"));
|
|
3948
|
-
|
|
4251
|
+
const page = vue.computed(() => services?.editorService.get("page"));
|
|
3949
4252
|
const mouseenterHandler = () => {
|
|
3950
4253
|
workspace.value?.focus();
|
|
3951
4254
|
};
|
|
3952
4255
|
const mouseleaveHandler = () => {
|
|
3953
4256
|
workspace.value?.blur();
|
|
3954
4257
|
};
|
|
4258
|
+
let keycon;
|
|
3955
4259
|
vue.onMounted(() => {
|
|
3956
4260
|
workspace.value?.addEventListener("mouseenter", mouseenterHandler);
|
|
3957
4261
|
workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
|
|
@@ -4028,6 +4332,12 @@
|
|
|
4028
4332
|
}).keydown([ctrl, "numpad-"], (e) => {
|
|
4029
4333
|
e.inputEvent.preventDefault();
|
|
4030
4334
|
services?.uiService.zoom(-0.1);
|
|
4335
|
+
}).keydown([ctrl, "0"], (e) => {
|
|
4336
|
+
e.inputEvent.preventDefault();
|
|
4337
|
+
services?.uiService.set("zoom", services.uiService.calcZoom());
|
|
4338
|
+
}).keydown([ctrl, "1"], (e) => {
|
|
4339
|
+
e.inputEvent.preventDefault();
|
|
4340
|
+
services?.uiService.set("zoom", 1);
|
|
4031
4341
|
});
|
|
4032
4342
|
});
|
|
4033
4343
|
vue.onUnmounted(() => {
|
|
@@ -4035,39 +4345,33 @@
|
|
|
4035
4345
|
workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
|
|
4036
4346
|
keycon.destroy();
|
|
4037
4347
|
});
|
|
4038
|
-
return {
|
|
4039
|
-
|
|
4040
|
-
|
|
4348
|
+
return (_ctx, _cache) => {
|
|
4349
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
4350
|
+
class: "m-editor-workspace",
|
|
4351
|
+
tabindex: "1",
|
|
4352
|
+
ref_key: "workspace",
|
|
4353
|
+
ref: workspace
|
|
4354
|
+
}, [
|
|
4355
|
+
vue.renderSlot(_ctx.$slots, "stage", {}, () => [
|
|
4356
|
+
(vue.openBlock(), vue.createBlock(_sfc_main$2, {
|
|
4357
|
+
key: vue.unref(page)?.id
|
|
4358
|
+
}))
|
|
4359
|
+
]),
|
|
4360
|
+
vue.renderSlot(_ctx.$slots, "workspace-content"),
|
|
4361
|
+
vue.createVNode(_sfc_main$6, null, {
|
|
4362
|
+
"page-bar-title": vue.withCtx(({ page: page2 }) => [
|
|
4363
|
+
vue.renderSlot(_ctx.$slots, "page-bar-title", { page: page2 })
|
|
4364
|
+
]),
|
|
4365
|
+
"page-bar-popover": vue.withCtx(({ page: page2 }) => [
|
|
4366
|
+
vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: page2 })
|
|
4367
|
+
]),
|
|
4368
|
+
_: 3
|
|
4369
|
+
})
|
|
4370
|
+
], 512);
|
|
4041
4371
|
};
|
|
4042
4372
|
}
|
|
4043
4373
|
});
|
|
4044
4374
|
|
|
4045
|
-
const _hoisted_1 = {
|
|
4046
|
-
class: "m-editor-workspace",
|
|
4047
|
-
tabindex: "1",
|
|
4048
|
-
ref: "workspace"
|
|
4049
|
-
};
|
|
4050
|
-
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4051
|
-
const _component_magic_stage = vue.resolveComponent("magic-stage");
|
|
4052
|
-
const _component_page_bar = vue.resolveComponent("page-bar");
|
|
4053
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
|
|
4054
|
-
(vue.openBlock(), vue.createBlock(_component_magic_stage, {
|
|
4055
|
-
key: _ctx.page?.id
|
|
4056
|
-
})),
|
|
4057
|
-
vue.renderSlot(_ctx.$slots, "workspace-content"),
|
|
4058
|
-
vue.createVNode(_component_page_bar, null, {
|
|
4059
|
-
"page-bar-title": vue.withCtx(({ page }) => [
|
|
4060
|
-
vue.renderSlot(_ctx.$slots, "page-bar-title", { page })
|
|
4061
|
-
]),
|
|
4062
|
-
"page-bar-popover": vue.withCtx(({ page }) => [
|
|
4063
|
-
vue.renderSlot(_ctx.$slots, "page-bar-popover", { page })
|
|
4064
|
-
]),
|
|
4065
|
-
_: 3
|
|
4066
|
-
})
|
|
4067
|
-
], 512);
|
|
4068
|
-
}
|
|
4069
|
-
const Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
4070
|
-
|
|
4071
4375
|
class ComponentList extends BaseService {
|
|
4072
4376
|
state = vue.reactive({
|
|
4073
4377
|
list: []
|
|
@@ -4081,136 +4385,20 @@
|
|
|
4081
4385
|
getList() {
|
|
4082
4386
|
return this.state.list;
|
|
4083
4387
|
}
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
4088
|
-
const MIN_LEFT_COLUMN_WIDTH = 45;
|
|
4089
|
-
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
4090
|
-
const MIN_RIGHT_COLUMN_WIDTH = 1;
|
|
4091
|
-
const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
|
|
4092
|
-
const defaultColumnWidth = {
|
|
4093
|
-
left: DEFAULT_LEFT_COLUMN_WIDTH,
|
|
4094
|
-
center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
|
|
4095
|
-
right: DEFAULT_RIGHT_COLUMN_WIDTH
|
|
4096
|
-
};
|
|
4097
|
-
const state = vue.reactive({
|
|
4098
|
-
uiSelectMode: false,
|
|
4099
|
-
showSrc: false,
|
|
4100
|
-
zoom: 1,
|
|
4101
|
-
stageContainerRect: {
|
|
4102
|
-
width: 0,
|
|
4103
|
-
height: 0
|
|
4104
|
-
},
|
|
4105
|
-
stageRect: {
|
|
4106
|
-
width: 375,
|
|
4107
|
-
height: 817
|
|
4108
|
-
},
|
|
4109
|
-
columnWidth: defaultColumnWidth,
|
|
4110
|
-
showGuides: true,
|
|
4111
|
-
showRule: true,
|
|
4112
|
-
propsPanelSize: "small"
|
|
4113
|
-
});
|
|
4114
|
-
class Ui extends BaseService {
|
|
4115
|
-
constructor() {
|
|
4116
|
-
super([]);
|
|
4117
|
-
globalThis.addEventListener("resize", () => {
|
|
4118
|
-
this.setColumnWidth({
|
|
4119
|
-
center: "auto"
|
|
4120
|
-
});
|
|
4121
|
-
});
|
|
4122
|
-
const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
|
|
4123
|
-
if (columnWidthCacheData) {
|
|
4124
|
-
try {
|
|
4125
|
-
const columnWidthCache = JSON.parse(columnWidthCacheData);
|
|
4126
|
-
this.setColumnWidth(columnWidthCache);
|
|
4127
|
-
} catch (e) {
|
|
4128
|
-
console.error(e);
|
|
4129
|
-
}
|
|
4130
|
-
}
|
|
4131
|
-
}
|
|
4132
|
-
set(name, value) {
|
|
4133
|
-
const mask = editorService.get("stage")?.mask;
|
|
4134
|
-
if (name === "columnWidth") {
|
|
4135
|
-
this.setColumnWidth(value);
|
|
4136
|
-
return;
|
|
4137
|
-
}
|
|
4138
|
-
if (name === "stageRect") {
|
|
4139
|
-
this.setStageRect(value);
|
|
4140
|
-
return;
|
|
4141
|
-
}
|
|
4142
|
-
if (name === "showGuides") {
|
|
4143
|
-
mask?.showGuides(value);
|
|
4144
|
-
}
|
|
4145
|
-
if (name === "showRule") {
|
|
4146
|
-
mask?.showRule(value);
|
|
4147
|
-
}
|
|
4148
|
-
state[name] = value;
|
|
4149
|
-
if (name === "stageContainerRect") {
|
|
4150
|
-
state.zoom = this.calcZoom();
|
|
4151
|
-
}
|
|
4152
|
-
}
|
|
4153
|
-
get(name) {
|
|
4154
|
-
return state[name];
|
|
4155
|
-
}
|
|
4156
|
-
zoom(zoom) {
|
|
4157
|
-
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
4158
|
-
if (this.get("zoom") < 0.1)
|
|
4159
|
-
this.set("zoom", 0.1);
|
|
4160
|
-
}
|
|
4161
|
-
setColumnWidth({ left, center, right }) {
|
|
4162
|
-
const columnWidth = {
|
|
4163
|
-
...vue.toRaw(this.get("columnWidth"))
|
|
4164
|
-
};
|
|
4165
|
-
if (left) {
|
|
4166
|
-
columnWidth.left = Math.max(left, MIN_LEFT_COLUMN_WIDTH);
|
|
4167
|
-
}
|
|
4168
|
-
if (right) {
|
|
4169
|
-
columnWidth.right = Math.max(right, MIN_RIGHT_COLUMN_WIDTH);
|
|
4170
|
-
}
|
|
4171
|
-
if (!center || center === "auto") {
|
|
4172
|
-
const bodyWidth = globalThis.document.body.clientWidth;
|
|
4173
|
-
columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
|
|
4174
|
-
if (columnWidth.center <= 0) {
|
|
4175
|
-
columnWidth.left = defaultColumnWidth.left;
|
|
4176
|
-
columnWidth.center = defaultColumnWidth.center;
|
|
4177
|
-
columnWidth.right = defaultColumnWidth.right;
|
|
4178
|
-
}
|
|
4179
|
-
} else {
|
|
4180
|
-
columnWidth.center = center;
|
|
4181
|
-
}
|
|
4182
|
-
globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
|
|
4183
|
-
state.columnWidth = columnWidth;
|
|
4184
|
-
}
|
|
4185
|
-
setStageRect(value) {
|
|
4186
|
-
state.stageRect = {
|
|
4187
|
-
...state.stageRect,
|
|
4188
|
-
...value
|
|
4189
|
-
};
|
|
4190
|
-
state.zoom = this.calcZoom();
|
|
4191
|
-
}
|
|
4192
|
-
calcZoom() {
|
|
4193
|
-
const { stageRect, stageContainerRect } = state;
|
|
4194
|
-
const { height, width } = stageContainerRect;
|
|
4195
|
-
if (!width || !height)
|
|
4196
|
-
return 1;
|
|
4197
|
-
const stageWidth = stageRect.width + 30;
|
|
4198
|
-
const stageHeight = stageRect.height + 30;
|
|
4199
|
-
if (width > stageWidth && height > stageHeight) {
|
|
4200
|
-
return 1;
|
|
4201
|
-
}
|
|
4202
|
-
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
4388
|
+
destroy() {
|
|
4389
|
+
this.state.list = [];
|
|
4390
|
+
this.removeAllListeners();
|
|
4203
4391
|
}
|
|
4204
4392
|
}
|
|
4205
|
-
const
|
|
4393
|
+
const componentListService = new ComponentList();
|
|
4206
4394
|
|
|
4207
4395
|
const _sfc_main = vue.defineComponent({
|
|
4208
4396
|
name: "m-editor",
|
|
4209
4397
|
components: {
|
|
4210
|
-
NavMenu,
|
|
4398
|
+
NavMenu: _sfc_main$f,
|
|
4211
4399
|
Sidebar,
|
|
4212
|
-
Workspace,
|
|
4213
|
-
PropsPanel,
|
|
4400
|
+
Workspace: _sfc_main$1,
|
|
4401
|
+
PropsPanel: _sfc_main$e,
|
|
4214
4402
|
Framework
|
|
4215
4403
|
},
|
|
4216
4404
|
props: {
|
|
@@ -4294,9 +4482,14 @@
|
|
|
4294
4482
|
},
|
|
4295
4483
|
emits: ["props-panel-mounted", "update:modelValue"],
|
|
4296
4484
|
setup(props, { emit }) {
|
|
4297
|
-
editorService.on("root-change", () => {
|
|
4298
|
-
const node = editorService.get("node")
|
|
4299
|
-
node
|
|
4485
|
+
editorService.on("root-change", (value) => {
|
|
4486
|
+
const node = editorService.get("node");
|
|
4487
|
+
const nodeId = node?.id || props.defaultSelected;
|
|
4488
|
+
if (nodeId && node !== value) {
|
|
4489
|
+
editorService.select(nodeId);
|
|
4490
|
+
} else {
|
|
4491
|
+
editorService.set("nodes", [value]);
|
|
4492
|
+
}
|
|
4300
4493
|
emit("update:modelValue", vue.toRaw(editorService.get("root")));
|
|
4301
4494
|
});
|
|
4302
4495
|
vue.watch(() => props.modelValue, (modelValue) => editorService.set("root", modelValue), {
|
|
@@ -4329,7 +4522,15 @@
|
|
|
4329
4522
|
vue.watch(() => props.stageRect, (stageRect) => stageRect && uiService.set("stageRect", stageRect), {
|
|
4330
4523
|
immediate: true
|
|
4331
4524
|
});
|
|
4332
|
-
|
|
4525
|
+
uiService.initColumnWidth();
|
|
4526
|
+
vue.onUnmounted(() => {
|
|
4527
|
+
editorService.destroy();
|
|
4528
|
+
historyService.destroy();
|
|
4529
|
+
propsService.destroy();
|
|
4530
|
+
uiService.destroy();
|
|
4531
|
+
componentListService.destroy();
|
|
4532
|
+
storageService.destroy();
|
|
4533
|
+
});
|
|
4333
4534
|
const services = {
|
|
4334
4535
|
componentListService,
|
|
4335
4536
|
eventsService,
|
|
@@ -4379,6 +4580,9 @@
|
|
|
4379
4580
|
"component-list-panel-header": vue.withCtx(() => [
|
|
4380
4581
|
vue.renderSlot(_ctx.$slots, "component-list-panel-header")
|
|
4381
4582
|
]),
|
|
4583
|
+
"component-list-item": vue.withCtx(({ component }) => [
|
|
4584
|
+
vue.renderSlot(_ctx.$slots, "component-list-item", { component })
|
|
4585
|
+
]),
|
|
4382
4586
|
_: 3
|
|
4383
4587
|
}, 8, ["data"])
|
|
4384
4588
|
])
|
|
@@ -4386,6 +4590,9 @@
|
|
|
4386
4590
|
workspace: vue.withCtx(() => [
|
|
4387
4591
|
vue.renderSlot(_ctx.$slots, "workspace", { editorService: _ctx.editorService }, () => [
|
|
4388
4592
|
vue.createVNode(_component_workspace, null, {
|
|
4593
|
+
stage: vue.withCtx(() => [
|
|
4594
|
+
vue.renderSlot(_ctx.$slots, "stage")
|
|
4595
|
+
]),
|
|
4389
4596
|
"workspace-content": vue.withCtx(() => [
|
|
4390
4597
|
vue.renderSlot(_ctx.$slots, "workspace-content", { editorService: _ctx.editorService })
|
|
4391
4598
|
]),
|
|
@@ -4402,14 +4609,13 @@
|
|
|
4402
4609
|
"props-panel": vue.withCtx(() => [
|
|
4403
4610
|
vue.renderSlot(_ctx.$slots, "props-panel", {}, () => [
|
|
4404
4611
|
vue.createVNode(_component_props_panel, {
|
|
4405
|
-
ref: "propsPanel",
|
|
4406
4612
|
onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance))
|
|
4407
4613
|
}, {
|
|
4408
4614
|
"props-panel-header": vue.withCtx(() => [
|
|
4409
4615
|
vue.renderSlot(_ctx.$slots, "props-panel-header")
|
|
4410
4616
|
]),
|
|
4411
4617
|
_: 3
|
|
4412
|
-
}
|
|
4618
|
+
})
|
|
4413
4619
|
])
|
|
4414
4620
|
]),
|
|
4415
4621
|
empty: vue.withCtx(() => [
|
|
@@ -4429,7 +4635,7 @@
|
|
|
4429
4635
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
4430
4636
|
setConfig(option);
|
|
4431
4637
|
app.component(Editor.name, Editor);
|
|
4432
|
-
app.component("m-fields-ui-select", _sfc_main$
|
|
4638
|
+
app.component("m-fields-ui-select", _sfc_main$m);
|
|
4433
4639
|
app.component(CodeLink.name, CodeLink);
|
|
4434
4640
|
app.component(Code.name, Code);
|
|
4435
4641
|
app.component(CodeEditor.name, CodeEditor);
|
|
@@ -4437,18 +4643,20 @@
|
|
|
4437
4643
|
};
|
|
4438
4644
|
|
|
4439
4645
|
exports.COPY_STORAGE_KEY = COPY_STORAGE_KEY;
|
|
4440
|
-
exports.
|
|
4441
|
-
exports.
|
|
4646
|
+
exports.ColumnLayout = ColumnLayout;
|
|
4647
|
+
exports.ComponentListPanel = _sfc_main$d;
|
|
4648
|
+
exports.ContentMenu = _sfc_main$c;
|
|
4442
4649
|
exports.Fixed2Other = Fixed2Other;
|
|
4443
4650
|
exports.H_GUIDE_LINE_STORAGE_KEY = H_GUIDE_LINE_STORAGE_KEY;
|
|
4651
|
+
exports.Icon = _sfc_main$h;
|
|
4444
4652
|
exports.Keys = Keys;
|
|
4445
4653
|
exports.LayerOffset = LayerOffset;
|
|
4446
4654
|
exports.LayerPanel = LayerPanel;
|
|
4447
4655
|
exports.Layout = Layout;
|
|
4448
|
-
exports.PropsPanel =
|
|
4656
|
+
exports.PropsPanel = _sfc_main$e;
|
|
4449
4657
|
exports.TMagicCodeEditor = CodeEditor;
|
|
4450
4658
|
exports.TMagicEditor = Editor;
|
|
4451
|
-
exports.ToolButton = _sfc_main$
|
|
4659
|
+
exports.ToolButton = _sfc_main$g;
|
|
4452
4660
|
exports.V_GUIDE_LINE_STORAGE_KEY = V_GUIDE_LINE_STORAGE_KEY;
|
|
4453
4661
|
exports.change2Fixed = change2Fixed;
|
|
4454
4662
|
exports.debug = debug;
|
|
@@ -4477,6 +4685,7 @@
|
|
|
4477
4685
|
exports.setLayout = setLayout;
|
|
4478
4686
|
exports.storageService = storageService;
|
|
4479
4687
|
exports.uiService = uiService;
|
|
4688
|
+
exports.useStage = useStage;
|
|
4480
4689
|
exports.warn = warn;
|
|
4481
4690
|
|
|
4482
4691
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|