@tmagic/editor 1.1.0-beta.7 → 1.1.0
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 +50 -0
- package/dist/tmagic-editor.mjs +1198 -1027
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +1201 -1026
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +10 -10
- package/src/Editor.vue +22 -6
- package/src/components/ContentMenu.vue +4 -4
- package/src/components/Icon.vue +7 -21
- 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 -0
- package/src/layouts/NavMenu.vue +156 -23
- package/src/layouts/PropsPanel.vue +49 -51
- package/src/layouts/sidebar/LayerMenu.vue +3 -3
- package/src/layouts/sidebar/LayerPanel.vue +39 -8
- package/src/layouts/workspace/PageBar.vue +1 -1
- package/src/layouts/workspace/Stage.vue +8 -86
- package/src/layouts/workspace/ViewerMenu.vue +10 -13
- package/src/layouts/workspace/Workspace.vue +133 -138
- package/src/services/componentList.ts +5 -0
- package/src/services/editor.ts +201 -112
- 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 +32 -30
- package/src/theme/component-list-panel.scss +5 -0
- package/src/theme/nav-menu.scss +6 -0
- package/src/type.ts +28 -11
- package/src/utils/editor.ts +17 -10
- package/src/utils/index.ts +1 -0
- package/src/utils/operator.ts +22 -123
- 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 +17 -8
- 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 -0
- package/types/layouts/NavMenu.vue.d.ts +92 -23
- package/types/layouts/PropsPanel.vue.d.ts +25 -208
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +7 -7
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +17 -15
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +3 -3
- package/types/layouts/workspace/Workspace.vue.d.ts +54 -4
- package/types/services/componentList.d.ts +1 -0
- package/types/services/editor.d.ts +10 -17
- 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 +3 -1
- package/types/type.d.ts +25 -11
- package/types/utils/editor.d.ts +4 -1
- package/types/utils/index.d.ts +1 -0
- package/types/utils/operator.d.ts +3 -26
- 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
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
window.globalThis = window;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
const _sfc_main$
|
|
40
|
+
const _sfc_main$o = vue.defineComponent({
|
|
41
41
|
name: "m-fields-vs-code",
|
|
42
42
|
props: ["model", "name", "config", "prop"],
|
|
43
43
|
emits: ["change"],
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
return target;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
function _sfc_render$
|
|
66
|
+
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
67
67
|
const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
|
|
68
68
|
return vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
|
|
69
69
|
style: vue.normalizeStyle(`height: ${_ctx.height}`),
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
onSave: _ctx.save
|
|
73
73
|
}, null, 8, ["style", "init-values", "language", "onSave"]);
|
|
74
74
|
}
|
|
75
|
-
const Code = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
75
|
+
const Code = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["render", _sfc_render$b]]);
|
|
76
76
|
|
|
77
|
-
const _sfc_main$
|
|
77
|
+
const _sfc_main$n = vue.defineComponent({
|
|
78
78
|
name: "m-fields-code-link",
|
|
79
79
|
props: {
|
|
80
80
|
config: {
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
}
|
|
131
131
|
});
|
|
132
132
|
|
|
133
|
-
function _sfc_render$
|
|
133
|
+
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
134
134
|
const _component_m_fields_link = vue.resolveComponent("m-fields-link");
|
|
135
135
|
return vue.openBlock(), vue.createBlock(_component_m_fields_link, {
|
|
136
136
|
config: _ctx.formConfig,
|
|
@@ -139,10 +139,10 @@
|
|
|
139
139
|
onChange: _ctx.changeHandler
|
|
140
140
|
}, null, 8, ["config", "model", "onChange"]);
|
|
141
141
|
}
|
|
142
|
-
const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
142
|
+
const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$a]]);
|
|
143
143
|
|
|
144
|
-
const _hoisted_1$
|
|
145
|
-
const _sfc_main$
|
|
144
|
+
const _hoisted_1$b = /* @__PURE__ */ vue.createTextVNode("\u53D6\u6D88");
|
|
145
|
+
const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
|
|
146
146
|
__name: "UISelect",
|
|
147
147
|
props: {
|
|
148
148
|
config: null,
|
|
@@ -207,7 +207,7 @@
|
|
|
207
207
|
style: { "padding": "0" }
|
|
208
208
|
}, {
|
|
209
209
|
default: vue.withCtx(() => [
|
|
210
|
-
_hoisted_1$
|
|
210
|
+
_hoisted_1$b
|
|
211
211
|
]),
|
|
212
212
|
_: 1
|
|
213
213
|
}, 8, ["icon"])
|
|
@@ -217,19 +217,21 @@
|
|
|
217
217
|
onClick: startSelect,
|
|
218
218
|
style: { "display": "flex" }
|
|
219
219
|
}, [
|
|
220
|
-
vue.
|
|
220
|
+
vue.unref(val) ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
|
|
221
|
+
key: 0,
|
|
222
|
+
content: "\u6E05\u9664"
|
|
223
|
+
}, {
|
|
221
224
|
default: vue.withCtx(() => [
|
|
222
|
-
vue.
|
|
223
|
-
key: 0,
|
|
225
|
+
vue.createVNode(_component_el_button, {
|
|
224
226
|
style: { "padding": "0" },
|
|
225
227
|
type: "danger",
|
|
226
228
|
icon: vue.unref(iconsVue.Close),
|
|
227
229
|
text: "",
|
|
228
230
|
onClick: vue.withModifiers(deleteHandler, ["stop"])
|
|
229
|
-
}, null, 8, ["icon", "onClick"])
|
|
231
|
+
}, null, 8, ["icon", "onClick"])
|
|
230
232
|
]),
|
|
231
233
|
_: 1
|
|
232
|
-
}),
|
|
234
|
+
})) : vue.createCommentVNode("", true),
|
|
233
235
|
vue.createVNode(_component_el_tooltip, {
|
|
234
236
|
content: vue.unref(val) ? vue.unref(toName) + "_" + vue.unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
|
|
235
237
|
}, {
|
|
@@ -268,7 +270,7 @@
|
|
|
268
270
|
}
|
|
269
271
|
return value;
|
|
270
272
|
};
|
|
271
|
-
const _sfc_main$
|
|
273
|
+
const _sfc_main$l = vue.defineComponent({
|
|
272
274
|
name: "magic-code-editor",
|
|
273
275
|
props: {
|
|
274
276
|
initValues: {
|
|
@@ -376,14 +378,14 @@
|
|
|
376
378
|
}
|
|
377
379
|
});
|
|
378
380
|
|
|
379
|
-
const _hoisted_1$
|
|
381
|
+
const _hoisted_1$a = {
|
|
380
382
|
ref: "codeEditor",
|
|
381
383
|
class: "magic-code-editor"
|
|
382
384
|
};
|
|
383
|
-
function _sfc_render$
|
|
384
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
385
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
386
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, null, 512);
|
|
385
387
|
}
|
|
386
|
-
const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
388
|
+
const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$9]]);
|
|
387
389
|
|
|
388
390
|
let $TMAGIC_EDITOR = {};
|
|
389
391
|
const setConfig = (option) => {
|
|
@@ -691,6 +693,9 @@
|
|
|
691
693
|
}
|
|
692
694
|
storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
|
|
693
695
|
}
|
|
696
|
+
destroy() {
|
|
697
|
+
this.removeAllListeners();
|
|
698
|
+
}
|
|
694
699
|
getValueAndProtocol(value) {
|
|
695
700
|
let protocol2 = "";
|
|
696
701
|
if (value === null) {
|
|
@@ -711,6 +716,12 @@
|
|
|
711
716
|
}
|
|
712
717
|
const storageService = new WebStorage();
|
|
713
718
|
|
|
719
|
+
var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
|
|
720
|
+
ColumnLayout2["LEFT"] = "left";
|
|
721
|
+
ColumnLayout2["CENTER"] = "center";
|
|
722
|
+
ColumnLayout2["RIGHT"] = "right";
|
|
723
|
+
return ColumnLayout2;
|
|
724
|
+
})(ColumnLayout || {});
|
|
714
725
|
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
715
726
|
LayerOffset2["TOP"] = "top";
|
|
716
727
|
LayerOffset2["BOTTOM"] = "bottom";
|
|
@@ -761,10 +772,10 @@
|
|
|
761
772
|
top: 0,
|
|
762
773
|
left: 0
|
|
763
774
|
});
|
|
764
|
-
const getMiddleTop = (
|
|
765
|
-
let height = style
|
|
766
|
-
if (!stage || typeof style
|
|
767
|
-
return style
|
|
775
|
+
const getMiddleTop = (node, parentNode, stage) => {
|
|
776
|
+
let height = node.style?.height || 0;
|
|
777
|
+
if (!stage || typeof node.style?.top !== "undefined" || !parentNode.style)
|
|
778
|
+
return node.style?.top;
|
|
768
779
|
if (!utils.isNumber(height)) {
|
|
769
780
|
height = 0;
|
|
770
781
|
}
|
|
@@ -775,12 +786,11 @@
|
|
|
775
786
|
}
|
|
776
787
|
return (parentHeight - height) / 2;
|
|
777
788
|
};
|
|
778
|
-
const getInitPositionStyle = (style = {}, layout
|
|
789
|
+
const getInitPositionStyle = (style = {}, layout) => {
|
|
779
790
|
if (layout === Layout.ABSOLUTE) {
|
|
780
791
|
return {
|
|
781
792
|
...style,
|
|
782
|
-
position: "absolute"
|
|
783
|
-
top: getMiddleTop(style, parentNode, stage)
|
|
793
|
+
position: "absolute"
|
|
784
794
|
};
|
|
785
795
|
}
|
|
786
796
|
if (layout === Layout.RELATIVE) {
|
|
@@ -872,6 +882,16 @@
|
|
|
872
882
|
}
|
|
873
883
|
return config.style.left;
|
|
874
884
|
};
|
|
885
|
+
const fixNodePosition = (config, parent, stage) => {
|
|
886
|
+
if (config.style?.position !== "absolute") {
|
|
887
|
+
return config.style;
|
|
888
|
+
}
|
|
889
|
+
return {
|
|
890
|
+
...config.style || {},
|
|
891
|
+
top: getMiddleTop(config, parent, stage),
|
|
892
|
+
left: fixNodeLeft(config, parent, stage?.renderer.contentWindow?.document)
|
|
893
|
+
};
|
|
894
|
+
};
|
|
875
895
|
|
|
876
896
|
class Props extends BaseService {
|
|
877
897
|
state = vue.reactive({
|
|
@@ -886,6 +906,7 @@
|
|
|
886
906
|
"getPropsValue",
|
|
887
907
|
"createId",
|
|
888
908
|
"setNewItemId",
|
|
909
|
+
"fillConfig",
|
|
889
910
|
"getDefaultPropsValue"
|
|
890
911
|
]);
|
|
891
912
|
}
|
|
@@ -895,14 +916,17 @@
|
|
|
895
916
|
});
|
|
896
917
|
this.emit("props-configs-change");
|
|
897
918
|
}
|
|
898
|
-
|
|
899
|
-
|
|
919
|
+
async fillConfig(config) {
|
|
920
|
+
return fillConfig(config);
|
|
921
|
+
}
|
|
922
|
+
async setPropsConfig(type, config) {
|
|
923
|
+
this.state.propsConfigMap[type] = await this.fillConfig(Array.isArray(config) ? config : [config]);
|
|
900
924
|
}
|
|
901
925
|
async getPropsConfig(type) {
|
|
902
926
|
if (type === "area") {
|
|
903
927
|
return await this.getPropsConfig("button");
|
|
904
928
|
}
|
|
905
|
-
return lodashEs.cloneDeep(this.state.propsConfigMap[type] ||
|
|
929
|
+
return lodashEs.cloneDeep(this.state.propsConfigMap[type] || await this.fillConfig([]));
|
|
906
930
|
}
|
|
907
931
|
setPropsValues(values) {
|
|
908
932
|
Object.keys(values).forEach((type) => {
|
|
@@ -936,25 +960,14 @@
|
|
|
936
960
|
...lodashEs.mergeWith({}, lodashEs.cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
937
961
|
};
|
|
938
962
|
}
|
|
939
|
-
guid(digit = 8) {
|
|
940
|
-
return "x".repeat(digit).replace(/[xy]/g, (c) => {
|
|
941
|
-
const r = Math.random() * 16 | 0;
|
|
942
|
-
const v = c == "x" ? r : r & 3 | 8;
|
|
943
|
-
return v.toString(16);
|
|
944
|
-
});
|
|
945
|
-
}
|
|
946
963
|
async createId(type) {
|
|
947
964
|
return `${type}_${this.guid()}`;
|
|
948
965
|
}
|
|
949
|
-
async setNewItemId(config
|
|
950
|
-
const oldId = config.id;
|
|
966
|
+
async setNewItemId(config) {
|
|
951
967
|
config.id = await this.createId(config.type || "component");
|
|
952
|
-
if (utils.isPop(config) && parent?.type === schema.NodeType.PAGE) {
|
|
953
|
-
updatePopId(oldId, config.id, parent);
|
|
954
|
-
}
|
|
955
968
|
if (config.items && Array.isArray(config.items)) {
|
|
956
969
|
for (const item of config.items) {
|
|
957
|
-
await this.setNewItemId(item
|
|
970
|
+
await this.setNewItemId(item);
|
|
958
971
|
}
|
|
959
972
|
}
|
|
960
973
|
return config;
|
|
@@ -972,22 +985,19 @@
|
|
|
972
985
|
name: type
|
|
973
986
|
};
|
|
974
987
|
}
|
|
988
|
+
destroy() {
|
|
989
|
+
this.state.propsConfigMap = {};
|
|
990
|
+
this.state.propsValueMap = {};
|
|
991
|
+
this.removeAllListeners();
|
|
992
|
+
}
|
|
993
|
+
guid(digit = 8) {
|
|
994
|
+
return "x".repeat(digit).replace(/[xy]/g, (c) => {
|
|
995
|
+
const r = Math.random() * 16 | 0;
|
|
996
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
997
|
+
return v.toString(16);
|
|
998
|
+
});
|
|
999
|
+
}
|
|
975
1000
|
}
|
|
976
|
-
const updatePopId = (oldId, popId, pageConfig) => {
|
|
977
|
-
pageConfig.items?.forEach((config) => {
|
|
978
|
-
if (config.pop === oldId) {
|
|
979
|
-
config.pop = popId;
|
|
980
|
-
return;
|
|
981
|
-
}
|
|
982
|
-
if (config.popId === oldId) {
|
|
983
|
-
config.popId = popId;
|
|
984
|
-
return;
|
|
985
|
-
}
|
|
986
|
-
if (Array.isArray(config.items)) {
|
|
987
|
-
updatePopId(oldId, popId, config);
|
|
988
|
-
}
|
|
989
|
-
});
|
|
990
|
-
};
|
|
991
1001
|
const propsService = new Props();
|
|
992
1002
|
|
|
993
1003
|
const beforePaste = async (position, config) => {
|
|
@@ -1007,7 +1017,7 @@
|
|
|
1007
1017
|
if (pastePosition.top && configItem.style?.top) {
|
|
1008
1018
|
pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
|
|
1009
1019
|
}
|
|
1010
|
-
const pasteConfig = await propsService.setNewItemId(configItem
|
|
1020
|
+
const pasteConfig = await propsService.setNewItemId(configItem);
|
|
1011
1021
|
if (pasteConfig.style) {
|
|
1012
1022
|
const { left, top } = pasteConfig.style;
|
|
1013
1023
|
if (typeof left === "number" || !!left && !isNaN(Number(left))) {
|
|
@@ -1028,36 +1038,6 @@
|
|
|
1028
1038
|
}));
|
|
1029
1039
|
return pasteConfigs;
|
|
1030
1040
|
};
|
|
1031
|
-
const beforeAdd = async (addNode, parent) => {
|
|
1032
|
-
const { type, inputEvent, ...config } = addNode;
|
|
1033
|
-
const curNode = editorService.get("node");
|
|
1034
|
-
let parentNode;
|
|
1035
|
-
const isPage2 = type === schema.NodeType.PAGE;
|
|
1036
|
-
if (isPage2) {
|
|
1037
|
-
parentNode = editorService.get("root");
|
|
1038
|
-
} else if (parent && typeof parent !== "function") {
|
|
1039
|
-
parentNode = parent;
|
|
1040
|
-
} else if (curNode.items) {
|
|
1041
|
-
parentNode = curNode;
|
|
1042
|
-
} else {
|
|
1043
|
-
parentNode = editorService.getParentById(curNode.id, false);
|
|
1044
|
-
}
|
|
1045
|
-
if (!parentNode)
|
|
1046
|
-
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1047
|
-
const layout = await editorService.getLayout(vue.toRaw(parentNode), addNode);
|
|
1048
|
-
const newNode = { ...vue.toRaw(await propsService.getPropsValue(type, config)) };
|
|
1049
|
-
newNode.style = getInitPositionStyle(newNode.style, layout, parentNode, editorService.get("stage"));
|
|
1050
|
-
if ((parentNode?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && newNode.type !== schema.NodeType.PAGE) {
|
|
1051
|
-
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
1052
|
-
}
|
|
1053
|
-
parentNode?.items?.push(newNode);
|
|
1054
|
-
return {
|
|
1055
|
-
parentNode,
|
|
1056
|
-
newNode,
|
|
1057
|
-
layout,
|
|
1058
|
-
isPage: isPage2
|
|
1059
|
-
};
|
|
1060
|
-
};
|
|
1061
1041
|
const getPositionInContainer = (position = {}, id) => {
|
|
1062
1042
|
let { left = 0, top = 0 } = position;
|
|
1063
1043
|
const parentEl = editorService.get("stage")?.renderer?.contentWindow?.document.getElementById(`${id}`);
|
|
@@ -1069,55 +1049,17 @@
|
|
|
1069
1049
|
top
|
|
1070
1050
|
};
|
|
1071
1051
|
};
|
|
1072
|
-
const
|
|
1073
|
-
const
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
newNode.style.left = fixedLeft;
|
|
1080
|
-
await stage?.update({ config: lodashEs.cloneDeep(newNode), root: lodashEs.cloneDeep(root) });
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
};
|
|
1084
|
-
const beforeRemove = async (node) => {
|
|
1085
|
-
if (!node?.id)
|
|
1086
|
-
return;
|
|
1087
|
-
const stage = editorService.get("stage");
|
|
1088
|
-
const root = editorService.get("root");
|
|
1089
|
-
if (!root)
|
|
1090
|
-
throw new Error("\u6CA1\u6709root");
|
|
1091
|
-
const { parent, node: curNode } = editorService.getNodeInfo(node.id, false);
|
|
1092
|
-
if (!parent || !curNode)
|
|
1093
|
-
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1094
|
-
const index = getNodeIndex(curNode, parent);
|
|
1095
|
-
if (typeof index !== "number" || index === -1)
|
|
1096
|
-
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1097
|
-
parent.items?.splice(index, 1);
|
|
1098
|
-
stage?.remove({ id: node.id, root: lodashEs.cloneDeep(root) });
|
|
1099
|
-
if (node.type === schema.NodeType.PAGE) {
|
|
1100
|
-
editorService.state.pageLength -= 1;
|
|
1101
|
-
if (root.items[0]) {
|
|
1102
|
-
await editorService.select(root.items[0]);
|
|
1103
|
-
stage?.select(root.items[0].id);
|
|
1104
|
-
} else {
|
|
1105
|
-
editorService.set("node", null);
|
|
1106
|
-
editorService.set("nodes", []);
|
|
1107
|
-
editorService.set("parent", null);
|
|
1108
|
-
editorService.set("page", null);
|
|
1109
|
-
editorService.set("stage", null);
|
|
1110
|
-
editorService.set("highlightNode", null);
|
|
1111
|
-
editorService.resetModifiedNodeId();
|
|
1112
|
-
historyService.reset();
|
|
1113
|
-
editorService.emit("remove", node);
|
|
1114
|
-
return;
|
|
1115
|
-
}
|
|
1052
|
+
const getAddParent = (node) => {
|
|
1053
|
+
const curNode = editorService.get("node");
|
|
1054
|
+
let parentNode;
|
|
1055
|
+
if (utils.isPage(node)) {
|
|
1056
|
+
parentNode = editorService.get("root");
|
|
1057
|
+
} else if (curNode.items) {
|
|
1058
|
+
parentNode = curNode;
|
|
1116
1059
|
} else {
|
|
1117
|
-
|
|
1118
|
-
stage?.select(parent.id);
|
|
1060
|
+
parentNode = editorService.getParentById(curNode.id, false);
|
|
1119
1061
|
}
|
|
1120
|
-
return
|
|
1062
|
+
return parentNode;
|
|
1121
1063
|
};
|
|
1122
1064
|
|
|
1123
1065
|
class Editor$1 extends BaseService {
|
|
@@ -1137,12 +1079,17 @@
|
|
|
1137
1079
|
super([
|
|
1138
1080
|
"getLayout",
|
|
1139
1081
|
"select",
|
|
1082
|
+
"doAdd",
|
|
1140
1083
|
"add",
|
|
1084
|
+
"doRemove",
|
|
1141
1085
|
"remove",
|
|
1086
|
+
"doUpdate",
|
|
1142
1087
|
"update",
|
|
1143
1088
|
"sort",
|
|
1144
1089
|
"copy",
|
|
1145
1090
|
"paste",
|
|
1091
|
+
"doPaste",
|
|
1092
|
+
"duAlignCenter",
|
|
1146
1093
|
"alignCenter",
|
|
1147
1094
|
"moveLayer",
|
|
1148
1095
|
"moveToContainer",
|
|
@@ -1271,62 +1218,106 @@
|
|
|
1271
1218
|
});
|
|
1272
1219
|
this.set("nodes", nodes);
|
|
1273
1220
|
}
|
|
1274
|
-
async
|
|
1221
|
+
async doAdd(node, parent) {
|
|
1222
|
+
const root = this.get("root");
|
|
1223
|
+
const curNode = this.get("node");
|
|
1275
1224
|
const stage = this.get("stage");
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
this.
|
|
1286
|
-
|
|
1225
|
+
if ((parent?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && node.type !== schema.NodeType.PAGE) {
|
|
1226
|
+
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
1227
|
+
}
|
|
1228
|
+
if (parent.id !== curNode.id) {
|
|
1229
|
+
const index = parent.items.indexOf(curNode);
|
|
1230
|
+
parent?.items?.splice(index + 1, 0, node);
|
|
1231
|
+
} else {
|
|
1232
|
+
parent?.items?.push(node);
|
|
1233
|
+
}
|
|
1234
|
+
const layout = await this.getLayout(vue.toRaw(parent), node);
|
|
1235
|
+
node.style = getInitPositionStyle(node.style, layout);
|
|
1236
|
+
await stage?.add({
|
|
1237
|
+
config: lodashEs.cloneDeep(node),
|
|
1238
|
+
parent: lodashEs.cloneDeep(parent),
|
|
1239
|
+
parentId: parent.id,
|
|
1240
|
+
root: lodashEs.cloneDeep(root)
|
|
1241
|
+
});
|
|
1242
|
+
node.style = fixNodePosition(node, parent, stage);
|
|
1243
|
+
await stage?.update({ config: lodashEs.cloneDeep(node), parentId: parent.id, root: lodashEs.cloneDeep(root) });
|
|
1244
|
+
this.addModifiedNodeId(node.id);
|
|
1245
|
+
return node;
|
|
1287
1246
|
}
|
|
1288
1247
|
async add(addNode, parent) {
|
|
1289
1248
|
const stage = this.get("stage");
|
|
1290
|
-
const
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1249
|
+
const addNodes = [];
|
|
1250
|
+
if (!Array.isArray(addNode)) {
|
|
1251
|
+
const { type, inputEvent, ...config } = addNode;
|
|
1252
|
+
if (!type)
|
|
1253
|
+
throw new Error("\u7EC4\u4EF6\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A");
|
|
1254
|
+
addNodes.push({ ...vue.toRaw(await propsService.getPropsValue(type, config)) });
|
|
1255
|
+
} else {
|
|
1256
|
+
addNodes.push(...addNode);
|
|
1296
1257
|
}
|
|
1297
|
-
|
|
1298
|
-
|
|
1258
|
+
const newNodes = await Promise.all(addNodes.map((node) => {
|
|
1259
|
+
const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
|
|
1260
|
+
if (!parentNode)
|
|
1261
|
+
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1262
|
+
return this.doAdd(node, parentNode);
|
|
1263
|
+
}));
|
|
1264
|
+
if (newNodes.length > 1) {
|
|
1265
|
+
const newNodeIds = newNodes.map((node) => node.id);
|
|
1266
|
+
stage?.multiSelect(newNodeIds);
|
|
1267
|
+
await this.multiSelect(newNodeIds);
|
|
1299
1268
|
} else {
|
|
1300
|
-
|
|
1269
|
+
await this.select(newNodes[0]);
|
|
1270
|
+
if (utils.isPage(newNodes[0])) {
|
|
1271
|
+
this.state.pageLength += 1;
|
|
1272
|
+
} else {
|
|
1273
|
+
stage?.select(newNodes[0].id);
|
|
1274
|
+
}
|
|
1301
1275
|
}
|
|
1302
|
-
this.
|
|
1303
|
-
|
|
1276
|
+
this.pushHistoryState();
|
|
1277
|
+
this.emit("add", newNodes);
|
|
1278
|
+
return Array.isArray(addNode) ? newNodes : newNodes[0];
|
|
1304
1279
|
}
|
|
1305
|
-
async
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1280
|
+
async doRemove(node) {
|
|
1281
|
+
const root = this.get("root");
|
|
1282
|
+
if (!root)
|
|
1283
|
+
throw new Error("\u6CA1\u6709root");
|
|
1284
|
+
const { parent, node: curNode } = this.getNodeInfo(node.id);
|
|
1285
|
+
if (!parent || !curNode)
|
|
1286
|
+
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1287
|
+
const index = getNodeIndex(curNode, parent);
|
|
1288
|
+
if (typeof index !== "number" || index === -1)
|
|
1289
|
+
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1290
|
+
parent.items?.splice(index, 1);
|
|
1291
|
+
const stage = this.get("stage");
|
|
1292
|
+
stage?.remove({ id: node.id, parentId: parent.id, root: lodashEs.cloneDeep(root) });
|
|
1293
|
+
if (node.type === schema.NodeType.PAGE) {
|
|
1294
|
+
this.state.pageLength -= 1;
|
|
1295
|
+
if (root.items[0]) {
|
|
1296
|
+
await this.select(root.items[0]);
|
|
1297
|
+
stage?.select(root.items[0].id);
|
|
1298
|
+
} else {
|
|
1299
|
+
this.set("node", null);
|
|
1300
|
+
this.set("parent", null);
|
|
1301
|
+
this.set("page", null);
|
|
1302
|
+
this.set("stage", null);
|
|
1303
|
+
this.set("highlightNode", null);
|
|
1304
|
+
this.resetModifiedNodeId();
|
|
1305
|
+
historyService.reset();
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
} else {
|
|
1309
|
+
await this.select(parent);
|
|
1310
|
+
stage?.select(parent.id);
|
|
1309
1311
|
}
|
|
1310
|
-
|
|
1311
|
-
const removeParent = await beforeRemove(node);
|
|
1312
|
-
if (!removeParent)
|
|
1313
|
-
return node;
|
|
1314
|
-
this.addModifiedNodeId(removeParent.id);
|
|
1315
|
-
this.pushHistoryState();
|
|
1316
|
-
this.emit("remove", node);
|
|
1317
|
-
return node;
|
|
1312
|
+
this.addModifiedNodeId(parent.id);
|
|
1318
1313
|
}
|
|
1319
|
-
async
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
}));
|
|
1323
|
-
const nodeIds = nodes.map((node) => node.id);
|
|
1324
|
-
this.addModifiedNodeId(nodeIds.join("-"));
|
|
1314
|
+
async remove(nodeOrNodeList) {
|
|
1315
|
+
const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
|
|
1316
|
+
await Promise.all(nodes.map((node) => this.doRemove(node)));
|
|
1325
1317
|
this.pushHistoryState();
|
|
1326
|
-
this.emit("
|
|
1327
|
-
return nodes;
|
|
1318
|
+
this.emit("remove", nodes);
|
|
1328
1319
|
}
|
|
1329
|
-
async
|
|
1320
|
+
async doUpdate(config) {
|
|
1330
1321
|
if (!config?.id)
|
|
1331
1322
|
throw new Error("\u6CA1\u6709\u914D\u7F6E\u6216\u8005\u914D\u7F6E\u7F3A\u5C11id\u503C");
|
|
1332
1323
|
const info = this.getNodeInfo(config.id, false);
|
|
@@ -1362,15 +1353,24 @@
|
|
|
1362
1353
|
const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
|
|
1363
1354
|
nodes.splice(targetIndex, 1, newConfig);
|
|
1364
1355
|
this.set("nodes", nodes);
|
|
1365
|
-
this.get("stage")?.update({
|
|
1356
|
+
this.get("stage")?.update({
|
|
1357
|
+
config: lodashEs.cloneDeep(newConfig),
|
|
1358
|
+
parentId: parent.id,
|
|
1359
|
+
root: lodashEs.cloneDeep(this.get("root"))
|
|
1360
|
+
});
|
|
1366
1361
|
if (newConfig.type === schema.NodeType.PAGE) {
|
|
1367
1362
|
this.set("page", newConfig);
|
|
1368
1363
|
}
|
|
1369
1364
|
this.addModifiedNodeId(newConfig.id);
|
|
1370
|
-
this.pushHistoryState();
|
|
1371
|
-
this.emit("update", newConfig);
|
|
1372
1365
|
return newConfig;
|
|
1373
1366
|
}
|
|
1367
|
+
async update(config) {
|
|
1368
|
+
const nodes = Array.isArray(config) ? config : [config];
|
|
1369
|
+
const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
|
|
1370
|
+
this.pushHistoryState();
|
|
1371
|
+
this.emit("update", newNodes);
|
|
1372
|
+
return Array.isArray(config) ? newNodes : newNodes[0];
|
|
1373
|
+
}
|
|
1374
1374
|
async sort(id1, id2) {
|
|
1375
1375
|
const node = this.get("node");
|
|
1376
1376
|
const parent = lodashEs.cloneDeep(vue.toRaw(this.get("parent")));
|
|
@@ -1381,7 +1381,11 @@
|
|
|
1381
1381
|
parent.items.splice(index2, 0, ...parent.items.splice(index1, 1));
|
|
1382
1382
|
await this.update(parent);
|
|
1383
1383
|
await this.select(node);
|
|
1384
|
-
this.get("stage")?.update({
|
|
1384
|
+
this.get("stage")?.update({
|
|
1385
|
+
config: lodashEs.cloneDeep(node),
|
|
1386
|
+
parentId: parent.id,
|
|
1387
|
+
root: lodashEs.cloneDeep(this.get("root"))
|
|
1388
|
+
});
|
|
1385
1389
|
this.addModifiedNodeId(parent.id);
|
|
1386
1390
|
this.pushHistoryState();
|
|
1387
1391
|
}
|
|
@@ -1392,20 +1396,26 @@
|
|
|
1392
1396
|
}
|
|
1393
1397
|
async paste(position = {}) {
|
|
1394
1398
|
const config = await storageService.getItem(COPY_STORAGE_KEY);
|
|
1395
|
-
if (!config)
|
|
1399
|
+
if (!Array.isArray(config))
|
|
1396
1400
|
return;
|
|
1397
|
-
const pasteConfigs = await
|
|
1398
|
-
return
|
|
1401
|
+
const pasteConfigs = await this.doPaste(config, position);
|
|
1402
|
+
return this.add(pasteConfigs);
|
|
1399
1403
|
}
|
|
1400
|
-
async
|
|
1401
|
-
const
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
+
async doPaste(config, position = {}) {
|
|
1405
|
+
const pasteConfigs = await beforePaste(position, lodashEs.cloneDeep(config));
|
|
1406
|
+
return pasteConfigs;
|
|
1407
|
+
}
|
|
1408
|
+
async doAlignCenter(config) {
|
|
1409
|
+
const parent = this.getParentById(config.id);
|
|
1410
|
+
if (!parent)
|
|
1411
|
+
throw new Error("\u627E\u4E0D\u5230\u7236\u8282\u70B9");
|
|
1412
|
+
const node = lodashEs.cloneDeep(vue.toRaw(config));
|
|
1413
|
+
const layout = await this.getLayout(parent, node);
|
|
1404
1414
|
if (layout === Layout.RELATIVE) {
|
|
1405
|
-
return;
|
|
1415
|
+
return config;
|
|
1406
1416
|
}
|
|
1407
1417
|
if (!node.style)
|
|
1408
|
-
return;
|
|
1418
|
+
return config;
|
|
1409
1419
|
const stage = this.get("stage");
|
|
1410
1420
|
const doc = stage?.renderer.contentWindow?.document;
|
|
1411
1421
|
if (doc) {
|
|
@@ -1417,14 +1427,15 @@
|
|
|
1417
1427
|
} else if (parent.style && utils.isNumber(parent.style?.width) && utils.isNumber(node.style?.width)) {
|
|
1418
1428
|
node.style.left = (parent.style.width - node.style.width) / 2;
|
|
1419
1429
|
}
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
this.
|
|
1427
|
-
|
|
1430
|
+
return node;
|
|
1431
|
+
}
|
|
1432
|
+
async alignCenter(config) {
|
|
1433
|
+
const nodes = Array.isArray(config) ? config : [config];
|
|
1434
|
+
const stage = this.get("stage");
|
|
1435
|
+
const newNodes = await Promise.all(nodes.map((node) => this.doAlignCenter(node)));
|
|
1436
|
+
const newNode = await this.update(newNodes);
|
|
1437
|
+
await stage?.multiSelect(newNodes.map((node) => node.id));
|
|
1438
|
+
return newNode;
|
|
1428
1439
|
}
|
|
1429
1440
|
async moveLayer(offset) {
|
|
1430
1441
|
const parent = this.get("parent");
|
|
@@ -1438,10 +1449,14 @@
|
|
|
1438
1449
|
} else {
|
|
1439
1450
|
brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
|
|
1440
1451
|
}
|
|
1452
|
+
const grandparent = this.getParentById(parent.id);
|
|
1441
1453
|
this.get("stage")?.update({
|
|
1442
1454
|
config: lodashEs.cloneDeep(vue.toRaw(parent)),
|
|
1455
|
+
parentId: grandparent?.id,
|
|
1443
1456
|
root: lodashEs.cloneDeep(this.get("root"))
|
|
1444
1457
|
});
|
|
1458
|
+
this.addModifiedNodeId(parent.id);
|
|
1459
|
+
this.pushHistoryState();
|
|
1445
1460
|
}
|
|
1446
1461
|
async moveToContainer(config, targetId) {
|
|
1447
1462
|
const { node, parent } = this.getNodeInfo(config.id, false);
|
|
@@ -1451,17 +1466,18 @@
|
|
|
1451
1466
|
const root = lodashEs.cloneDeep(this.get("root"));
|
|
1452
1467
|
const index = getNodeIndex(node, parent);
|
|
1453
1468
|
parent.items?.splice(index, 1);
|
|
1454
|
-
await stage.remove({ id: node.id, root });
|
|
1469
|
+
await stage.remove({ id: node.id, parentId: parent.id, root });
|
|
1455
1470
|
const layout = await this.getLayout(target);
|
|
1456
1471
|
const newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), config, (objValue, srcValue) => {
|
|
1457
1472
|
if (Array.isArray(srcValue)) {
|
|
1458
1473
|
return srcValue;
|
|
1459
1474
|
}
|
|
1460
1475
|
});
|
|
1461
|
-
newConfig.style = getInitPositionStyle(newConfig.style, layout
|
|
1476
|
+
newConfig.style = getInitPositionStyle(newConfig.style, layout);
|
|
1462
1477
|
target.items.push(newConfig);
|
|
1463
1478
|
await stage.select(targetId);
|
|
1464
|
-
|
|
1479
|
+
const targetParent = this.getParentById(target.id);
|
|
1480
|
+
await stage.update({ config: lodashEs.cloneDeep(target), parentId: targetParent?.id, root });
|
|
1465
1481
|
await this.select(newConfig);
|
|
1466
1482
|
stage.select(newConfig.id);
|
|
1467
1483
|
this.addModifiedNodeId(target.id);
|
|
@@ -1484,7 +1500,7 @@
|
|
|
1484
1500
|
const node = vue.toRaw(this.get("node"));
|
|
1485
1501
|
if (!node || utils.isPage(node))
|
|
1486
1502
|
return;
|
|
1487
|
-
const { style, id } = node;
|
|
1503
|
+
const { style, id, type } = node;
|
|
1488
1504
|
if (!style || style.position !== "absolute")
|
|
1489
1505
|
return;
|
|
1490
1506
|
if (top && !utils.isNumber(style.top))
|
|
@@ -1493,6 +1509,7 @@
|
|
|
1493
1509
|
return;
|
|
1494
1510
|
this.update({
|
|
1495
1511
|
id,
|
|
1512
|
+
type,
|
|
1496
1513
|
style: {
|
|
1497
1514
|
...style,
|
|
1498
1515
|
left: Number(style.left) + left,
|
|
@@ -1507,6 +1524,10 @@
|
|
|
1507
1524
|
this.set("nodes", []);
|
|
1508
1525
|
this.set("page", null);
|
|
1509
1526
|
this.set("parent", null);
|
|
1527
|
+
this.set("stage", null);
|
|
1528
|
+
this.set("highlightNode", null);
|
|
1529
|
+
this.set("modifiedNodeIds", /* @__PURE__ */ new Map());
|
|
1530
|
+
this.set("pageLength", /* @__PURE__ */ new Map());
|
|
1510
1531
|
}
|
|
1511
1532
|
resetModifiedNodeId() {
|
|
1512
1533
|
this.get("modifiedNodeIds").clear();
|
|
@@ -1576,8 +1597,8 @@
|
|
|
1576
1597
|
}
|
|
1577
1598
|
const editorService = new Editor$1();
|
|
1578
1599
|
|
|
1579
|
-
|
|
1580
|
-
|
|
1600
|
+
let eventMap = vue.reactive({});
|
|
1601
|
+
let methodMap = vue.reactive({});
|
|
1581
1602
|
class Events extends BaseService {
|
|
1582
1603
|
constructor() {
|
|
1583
1604
|
super([]);
|
|
@@ -1617,6 +1638,11 @@
|
|
|
1617
1638
|
getMethod(type) {
|
|
1618
1639
|
return lodashEs.cloneDeep(methodMap[type] || core.DEFAULT_METHODS);
|
|
1619
1640
|
}
|
|
1641
|
+
destroy() {
|
|
1642
|
+
eventMap = vue.reactive({});
|
|
1643
|
+
methodMap = vue.reactive({});
|
|
1644
|
+
this.removeAllListeners();
|
|
1645
|
+
}
|
|
1620
1646
|
}
|
|
1621
1647
|
const eventsService = new Events();
|
|
1622
1648
|
|
|
@@ -1823,7 +1849,6 @@
|
|
|
1823
1849
|
]
|
|
1824
1850
|
}
|
|
1825
1851
|
];
|
|
1826
|
-
const DEFAULT_CONFIG = fillConfig([]);
|
|
1827
1852
|
|
|
1828
1853
|
const log = (...args) => {
|
|
1829
1854
|
if (process.env.NODE_ENV === "development") {
|
|
@@ -1851,116 +1876,303 @@
|
|
|
1851
1876
|
}
|
|
1852
1877
|
};
|
|
1853
1878
|
|
|
1854
|
-
const
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
const _hoisted_1$b = { class: "m-editor-empty-panel" };
|
|
1873
|
-
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
1874
|
-
const _hoisted_3$1 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
1875
|
-
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1876
|
-
const _component_plus = vue.resolveComponent("plus");
|
|
1877
|
-
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
1878
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
|
|
1879
|
-
vue.createElementVNode("div", _hoisted_2$4, [
|
|
1880
|
-
vue.createElementVNode("div", {
|
|
1881
|
-
class: "m-editor-empty-button",
|
|
1882
|
-
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
|
|
1883
|
-
}, [
|
|
1884
|
-
vue.createElementVNode("div", null, [
|
|
1885
|
-
vue.createVNode(_component_el_icon, null, {
|
|
1886
|
-
default: vue.withCtx(() => [
|
|
1887
|
-
vue.createVNode(_component_plus)
|
|
1888
|
-
]),
|
|
1889
|
-
_: 1
|
|
1890
|
-
})
|
|
1891
|
-
]),
|
|
1892
|
-
_hoisted_3$1
|
|
1893
|
-
])
|
|
1894
|
-
])
|
|
1895
|
-
]);
|
|
1896
|
-
}
|
|
1897
|
-
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$d]]);
|
|
1898
|
-
|
|
1899
|
-
const _sfc_main$i = vue.defineComponent({
|
|
1900
|
-
name: "m-editor-resize",
|
|
1901
|
-
props: {
|
|
1902
|
-
type: {
|
|
1903
|
-
type: String
|
|
1904
|
-
}
|
|
1879
|
+
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
1880
|
+
const MIN_LEFT_COLUMN_WIDTH = 45;
|
|
1881
|
+
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
1882
|
+
const MIN_RIGHT_COLUMN_WIDTH = 1;
|
|
1883
|
+
const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
|
|
1884
|
+
const defaultColumnWidth = {
|
|
1885
|
+
left: DEFAULT_LEFT_COLUMN_WIDTH,
|
|
1886
|
+
center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
|
|
1887
|
+
right: DEFAULT_RIGHT_COLUMN_WIDTH
|
|
1888
|
+
};
|
|
1889
|
+
const state = vue.reactive({
|
|
1890
|
+
uiSelectMode: false,
|
|
1891
|
+
showSrc: false,
|
|
1892
|
+
zoom: 1,
|
|
1893
|
+
stageContainerRect: {
|
|
1894
|
+
width: 0,
|
|
1895
|
+
height: 0
|
|
1905
1896
|
},
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
};
|
|
1922
|
-
if (props.type === "left") {
|
|
1923
|
-
left += e.deltaX;
|
|
1924
|
-
} else if (props.type === "right") {
|
|
1925
|
-
right -= e.deltaX;
|
|
1926
|
-
}
|
|
1927
|
-
services.uiService.set("columnWidth", {
|
|
1928
|
-
left,
|
|
1929
|
-
right
|
|
1930
|
-
});
|
|
1897
|
+
stageRect: {
|
|
1898
|
+
width: 375,
|
|
1899
|
+
height: 817
|
|
1900
|
+
},
|
|
1901
|
+
columnWidth: defaultColumnWidth,
|
|
1902
|
+
showGuides: true,
|
|
1903
|
+
showRule: true,
|
|
1904
|
+
propsPanelSize: "small"
|
|
1905
|
+
});
|
|
1906
|
+
class Ui extends BaseService {
|
|
1907
|
+
constructor() {
|
|
1908
|
+
super([]);
|
|
1909
|
+
globalThis.addEventListener("resize", () => {
|
|
1910
|
+
this.setColumnWidth({
|
|
1911
|
+
center: "auto"
|
|
1931
1912
|
});
|
|
1932
1913
|
});
|
|
1933
|
-
vue.onUnmounted(() => {
|
|
1934
|
-
getso?.unset();
|
|
1935
|
-
});
|
|
1936
|
-
return {
|
|
1937
|
-
target
|
|
1938
|
-
};
|
|
1939
1914
|
}
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
}
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1915
|
+
set(name, value) {
|
|
1916
|
+
const mask = editorService.get("stage")?.mask;
|
|
1917
|
+
if (name === "columnWidth") {
|
|
1918
|
+
this.setColumnWidth(value);
|
|
1919
|
+
return;
|
|
1920
|
+
}
|
|
1921
|
+
if (name === "stageRect") {
|
|
1922
|
+
this.setStageRect(value);
|
|
1923
|
+
return;
|
|
1924
|
+
}
|
|
1925
|
+
if (name === "showGuides") {
|
|
1926
|
+
mask?.showGuides(value);
|
|
1927
|
+
}
|
|
1928
|
+
if (name === "showRule") {
|
|
1929
|
+
mask?.showRule(value);
|
|
1930
|
+
}
|
|
1931
|
+
state[name] = value;
|
|
1932
|
+
}
|
|
1933
|
+
get(name) {
|
|
1934
|
+
return state[name];
|
|
1935
|
+
}
|
|
1936
|
+
initColumnWidth() {
|
|
1937
|
+
const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
|
|
1938
|
+
if (columnWidthCacheData) {
|
|
1939
|
+
try {
|
|
1940
|
+
const columnWidthCache = JSON.parse(columnWidthCacheData);
|
|
1941
|
+
this.setColumnWidth(columnWidthCache);
|
|
1942
|
+
} catch (e) {
|
|
1943
|
+
console.error(e);
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
zoom(zoom) {
|
|
1948
|
+
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
1949
|
+
if (this.get("zoom") < 0.1)
|
|
1950
|
+
this.set("zoom", 0.1);
|
|
1951
|
+
}
|
|
1952
|
+
calcZoom() {
|
|
1953
|
+
const { stageRect, stageContainerRect } = state;
|
|
1954
|
+
const { height, width } = stageContainerRect;
|
|
1955
|
+
if (!width || !height)
|
|
1956
|
+
return 1;
|
|
1957
|
+
const stageWidth = stageRect.width + 30;
|
|
1958
|
+
const stageHeight = stageRect.height + 30;
|
|
1959
|
+
if (width > stageWidth && height > stageHeight) {
|
|
1960
|
+
return 1;
|
|
1961
|
+
}
|
|
1962
|
+
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
1963
|
+
}
|
|
1964
|
+
destroy() {
|
|
1965
|
+
this.removeAllListeners();
|
|
1966
|
+
}
|
|
1967
|
+
setColumnWidth({ left, center, right }) {
|
|
1968
|
+
const columnWidth = {
|
|
1969
|
+
...vue.toRaw(this.get("columnWidth"))
|
|
1970
|
+
};
|
|
1971
|
+
if (left) {
|
|
1972
|
+
columnWidth.left = Math.max(left, MIN_LEFT_COLUMN_WIDTH);
|
|
1973
|
+
}
|
|
1974
|
+
if (right) {
|
|
1975
|
+
columnWidth.right = Math.max(right, MIN_RIGHT_COLUMN_WIDTH);
|
|
1976
|
+
}
|
|
1977
|
+
if (!center || center === "auto") {
|
|
1978
|
+
const bodyWidth = globalThis.document.body.clientWidth;
|
|
1979
|
+
columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
|
|
1980
|
+
if (columnWidth.center <= 0) {
|
|
1981
|
+
columnWidth.left = defaultColumnWidth.left;
|
|
1982
|
+
columnWidth.center = defaultColumnWidth.center;
|
|
1983
|
+
columnWidth.right = defaultColumnWidth.right;
|
|
1984
|
+
}
|
|
1985
|
+
} else {
|
|
1986
|
+
columnWidth.center = center;
|
|
1987
|
+
}
|
|
1988
|
+
globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
|
|
1989
|
+
state.columnWidth = columnWidth;
|
|
1990
|
+
}
|
|
1991
|
+
setStageRect(value) {
|
|
1992
|
+
state.stageRect = {
|
|
1993
|
+
...state.stageRect,
|
|
1994
|
+
...value
|
|
1995
|
+
};
|
|
1996
|
+
state.zoom = this.calcZoom();
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
const uiService = new Ui();
|
|
2000
|
+
|
|
2001
|
+
const root = vue.computed(() => editorService.get("root"));
|
|
2002
|
+
const page = vue.computed(() => editorService.get("page"));
|
|
2003
|
+
const zoom = vue.computed(() => uiService.get("zoom") || 1);
|
|
2004
|
+
const uiSelectMode = vue.computed(() => uiService.get("uiSelectMode"));
|
|
2005
|
+
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
2006
|
+
const useStage = (stageOptions) => {
|
|
2007
|
+
const stage = new StageCore__default.default({
|
|
2008
|
+
render: stageOptions.render,
|
|
2009
|
+
runtimeUrl: stageOptions.runtimeUrl,
|
|
2010
|
+
zoom: zoom.value,
|
|
2011
|
+
autoScrollIntoView: stageOptions.autoScrollIntoView,
|
|
2012
|
+
isContainer: stageOptions.isContainer,
|
|
2013
|
+
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
2014
|
+
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
2015
|
+
containerHighlightType: stageOptions.containerHighlightType,
|
|
2016
|
+
canSelect: (el, event, stop) => {
|
|
2017
|
+
const elCanSelect = stageOptions.canSelect(el);
|
|
2018
|
+
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
2019
|
+
document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
|
|
2020
|
+
return stop();
|
|
2021
|
+
}
|
|
2022
|
+
return elCanSelect;
|
|
2023
|
+
},
|
|
2024
|
+
moveableOptions: stageOptions.moveableOptions,
|
|
2025
|
+
updateDragEl: stageOptions.updateDragEl
|
|
2026
|
+
});
|
|
2027
|
+
stage.mask.setGuides([
|
|
2028
|
+
getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
|
|
2029
|
+
getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
|
|
2030
|
+
]);
|
|
2031
|
+
stage.on("select", (el) => {
|
|
2032
|
+
editorService.select(el.id);
|
|
2033
|
+
});
|
|
2034
|
+
stage.on("highlight", (el) => {
|
|
2035
|
+
editorService.highlight(el.id);
|
|
2036
|
+
});
|
|
2037
|
+
stage.on("multiSelect", (els) => {
|
|
2038
|
+
editorService.multiSelect(els.map((el) => el.id));
|
|
2039
|
+
});
|
|
2040
|
+
stage.on("update", (ev) => {
|
|
2041
|
+
if (ev.parentEl) {
|
|
2042
|
+
for (const data of ev.data) {
|
|
2043
|
+
editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
2044
|
+
}
|
|
2045
|
+
return;
|
|
2046
|
+
}
|
|
2047
|
+
editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
2048
|
+
});
|
|
2049
|
+
stage.on("sort", (ev) => {
|
|
2050
|
+
editorService.sort(ev.src, ev.dist);
|
|
2051
|
+
});
|
|
2052
|
+
stage.on("changeGuides", (e) => {
|
|
2053
|
+
uiService.set("showGuides", true);
|
|
2054
|
+
if (!root.value || !page.value)
|
|
2055
|
+
return;
|
|
2056
|
+
const storageKey = getGuideLineKey(e.type === StageCore.GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY);
|
|
2057
|
+
if (e.guides.length) {
|
|
2058
|
+
globalThis.localStorage.setItem(storageKey, JSON.stringify(e.guides));
|
|
2059
|
+
} else {
|
|
2060
|
+
globalThis.localStorage.removeItem(storageKey);
|
|
2061
|
+
}
|
|
2062
|
+
});
|
|
2063
|
+
return stage;
|
|
2064
|
+
};
|
|
2065
|
+
|
|
2066
|
+
const _sfc_main$k = vue.defineComponent({
|
|
2067
|
+
components: { Plus: iconsVue.Plus },
|
|
2068
|
+
setup() {
|
|
2069
|
+
const services = vue.inject("services");
|
|
2070
|
+
return {
|
|
2071
|
+
clickHandler() {
|
|
2072
|
+
const { editorService } = services || {};
|
|
2073
|
+
if (!editorService)
|
|
2074
|
+
return;
|
|
2075
|
+
editorService.add({
|
|
2076
|
+
type: schema.NodeType.PAGE,
|
|
2077
|
+
name: generatePageNameByApp(vue.toRaw(editorService.get("root")))
|
|
2078
|
+
});
|
|
2079
|
+
}
|
|
2080
|
+
};
|
|
2081
|
+
}
|
|
2082
|
+
});
|
|
2083
|
+
|
|
2084
|
+
const _hoisted_1$9 = { class: "m-editor-empty-panel" };
|
|
2085
|
+
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
2086
|
+
const _hoisted_3 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
2087
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2088
|
+
const _component_plus = vue.resolveComponent("plus");
|
|
2089
|
+
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
2090
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
|
|
2091
|
+
vue.createElementVNode("div", _hoisted_2$4, [
|
|
2092
|
+
vue.createElementVNode("div", {
|
|
2093
|
+
class: "m-editor-empty-button",
|
|
2094
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
|
|
2095
|
+
}, [
|
|
2096
|
+
vue.createElementVNode("div", null, [
|
|
2097
|
+
vue.createVNode(_component_el_icon, null, {
|
|
2098
|
+
default: vue.withCtx(() => [
|
|
2099
|
+
vue.createVNode(_component_plus)
|
|
2100
|
+
]),
|
|
2101
|
+
_: 1
|
|
2102
|
+
})
|
|
2103
|
+
]),
|
|
2104
|
+
_hoisted_3
|
|
2105
|
+
])
|
|
2106
|
+
])
|
|
2107
|
+
]);
|
|
2108
|
+
}
|
|
2109
|
+
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$8]]);
|
|
2110
|
+
|
|
2111
|
+
const _sfc_main$j = vue.defineComponent({
|
|
2112
|
+
name: "m-editor-resize",
|
|
2113
|
+
props: {
|
|
2114
|
+
type: {
|
|
2115
|
+
type: String
|
|
2116
|
+
}
|
|
2117
|
+
},
|
|
2118
|
+
setup(props) {
|
|
2119
|
+
const services = vue.inject("services");
|
|
2120
|
+
const target = vue.ref();
|
|
2121
|
+
let getso;
|
|
2122
|
+
vue.onMounted(() => {
|
|
2123
|
+
if (!target.value)
|
|
2124
|
+
return;
|
|
2125
|
+
getso = new Gesto__default.default(target.value, {
|
|
2126
|
+
container: window,
|
|
2127
|
+
pinchOutside: true
|
|
2128
|
+
}).on("drag", (e) => {
|
|
2129
|
+
if (!target.value || !services)
|
|
2130
|
+
return;
|
|
2131
|
+
let { left, right } = {
|
|
2132
|
+
...vue.toRaw(services.uiService.get("columnWidth"))
|
|
2133
|
+
};
|
|
2134
|
+
if (props.type === "left") {
|
|
2135
|
+
left += e.deltaX;
|
|
2136
|
+
} else if (props.type === "right") {
|
|
2137
|
+
right -= e.deltaX;
|
|
2138
|
+
}
|
|
2139
|
+
services.uiService.set("columnWidth", {
|
|
2140
|
+
left,
|
|
2141
|
+
right
|
|
2142
|
+
});
|
|
2143
|
+
});
|
|
2144
|
+
});
|
|
2145
|
+
vue.onUnmounted(() => {
|
|
2146
|
+
getso?.unset();
|
|
2147
|
+
});
|
|
2148
|
+
return {
|
|
2149
|
+
target
|
|
2150
|
+
};
|
|
2151
|
+
}
|
|
2152
|
+
});
|
|
2153
|
+
|
|
2154
|
+
const _hoisted_1$8 = {
|
|
2155
|
+
ref: "target",
|
|
2156
|
+
class: "m-editor-resizer"
|
|
2157
|
+
};
|
|
2158
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2159
|
+
return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$8, [
|
|
2160
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
2161
|
+
], 512);
|
|
2162
|
+
}
|
|
2163
|
+
const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$7]]);
|
|
2164
|
+
|
|
2165
|
+
const _sfc_main$i = vue.defineComponent({
|
|
2166
|
+
components: {
|
|
2167
|
+
AddPageBox,
|
|
2168
|
+
Resizer
|
|
2169
|
+
},
|
|
2170
|
+
props: {
|
|
2171
|
+
codeOptions: {
|
|
2172
|
+
type: Object,
|
|
2173
|
+
default: () => ({})
|
|
2174
|
+
}
|
|
2175
|
+
},
|
|
1964
2176
|
setup() {
|
|
1965
2177
|
const { editorService, uiService } = vue.inject("services") || {};
|
|
1966
2178
|
const root = vue.computed(() => editorService?.get("root"));
|
|
@@ -1980,17 +2192,17 @@
|
|
|
1980
2192
|
}
|
|
1981
2193
|
});
|
|
1982
2194
|
|
|
1983
|
-
const _hoisted_1$
|
|
2195
|
+
const _hoisted_1$7 = { class: "m-editor" };
|
|
1984
2196
|
const _hoisted_2$3 = {
|
|
1985
2197
|
key: 1,
|
|
1986
2198
|
class: "m-editor-content"
|
|
1987
2199
|
};
|
|
1988
|
-
function _sfc_render$
|
|
2200
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1989
2201
|
const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
|
|
1990
2202
|
const _component_resizer = vue.resolveComponent("resizer");
|
|
1991
2203
|
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
|
|
1992
2204
|
const _component_add_page_box = vue.resolveComponent("add-page-box");
|
|
1993
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
2205
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, [
|
|
1994
2206
|
vue.renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
1995
2207
|
_ctx.showSrc ? (vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
|
|
1996
2208
|
key: 0,
|
|
@@ -2031,209 +2243,112 @@
|
|
|
2031
2243
|
]))
|
|
2032
2244
|
]);
|
|
2033
2245
|
}
|
|
2034
|
-
const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2246
|
+
const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$6]]);
|
|
2035
2247
|
|
|
2036
|
-
const
|
|
2037
|
-
|
|
2038
|
-
|
|
2248
|
+
const _hoisted_1$6 = ["src"];
|
|
2249
|
+
const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
|
|
2250
|
+
__name: "Icon",
|
|
2039
2251
|
props: {
|
|
2040
|
-
icon:
|
|
2041
|
-
type: [String, Object]
|
|
2042
|
-
}
|
|
2252
|
+
icon: null
|
|
2043
2253
|
},
|
|
2044
|
-
setup() {
|
|
2045
|
-
return {
|
|
2046
|
-
|
|
2254
|
+
setup(__props) {
|
|
2255
|
+
return (_ctx, _cache) => {
|
|
2256
|
+
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
2257
|
+
return !__props.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
|
|
2258
|
+
default: vue.withCtx(() => [
|
|
2259
|
+
vue.createVNode(vue.unref(iconsVue.Edit))
|
|
2260
|
+
]),
|
|
2261
|
+
_: 1
|
|
2262
|
+
})) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 1 }, {
|
|
2263
|
+
default: vue.withCtx(() => [
|
|
2264
|
+
vue.createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$6)
|
|
2265
|
+
]),
|
|
2266
|
+
_: 1
|
|
2267
|
+
})) : typeof __props.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
|
|
2268
|
+
key: 2,
|
|
2269
|
+
class: vue.normalizeClass(__props.icon)
|
|
2270
|
+
}, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
|
|
2271
|
+
default: vue.withCtx(() => [
|
|
2272
|
+
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.toRaw(__props.icon))))
|
|
2273
|
+
]),
|
|
2274
|
+
_: 1
|
|
2275
|
+
}));
|
|
2047
2276
|
};
|
|
2048
2277
|
}
|
|
2049
2278
|
});
|
|
2050
2279
|
|
|
2051
|
-
const _hoisted_1$
|
|
2052
|
-
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2053
|
-
const _component_edit = vue.resolveComponent("edit");
|
|
2054
|
-
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
2055
|
-
return !_ctx.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
|
|
2056
|
-
default: vue.withCtx(() => [
|
|
2057
|
-
vue.createVNode(_component_edit)
|
|
2058
|
-
]),
|
|
2059
|
-
_: 1
|
|
2060
|
-
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.createElementBlock("img", {
|
|
2061
|
-
key: 1,
|
|
2062
|
-
src: _ctx.icon
|
|
2063
|
-
}, null, 8, _hoisted_1$8)) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
|
|
2064
|
-
key: 2,
|
|
2065
|
-
class: vue.normalizeClass(_ctx.icon)
|
|
2066
|
-
}, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
|
|
2067
|
-
default: vue.withCtx(() => [
|
|
2068
|
-
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.toRaw(_ctx.icon))))
|
|
2069
|
-
]),
|
|
2070
|
-
_: 1
|
|
2071
|
-
}));
|
|
2072
|
-
}
|
|
2073
|
-
const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
|
|
2074
|
-
|
|
2075
|
-
const _hoisted_1$7 = {
|
|
2280
|
+
const _hoisted_1$5 = {
|
|
2076
2281
|
key: 1,
|
|
2077
2282
|
class: "menu-item-text"
|
|
2078
2283
|
};
|
|
2079
|
-
const _hoisted_2$2 = {
|
|
2080
|
-
|
|
2081
|
-
style: { "margin": "0 5px" }
|
|
2082
|
-
};
|
|
2083
|
-
const _hoisted_3 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2084
|
-
const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
2284
|
+
const _hoisted_2$2 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2285
|
+
const _sfc_main$g = /* @__PURE__ */ vue.defineComponent({
|
|
2085
2286
|
__name: "ToolButton",
|
|
2086
2287
|
props: {
|
|
2087
|
-
data: {
|
|
2088
|
-
type:
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
display: false
|
|
2093
|
-
})
|
|
2094
|
-
},
|
|
2095
|
-
eventType: {
|
|
2096
|
-
type: String,
|
|
2097
|
-
default: "click"
|
|
2098
|
-
}
|
|
2288
|
+
data: { default: () => ({
|
|
2289
|
+
type: "text",
|
|
2290
|
+
display: false
|
|
2291
|
+
}) },
|
|
2292
|
+
eventType: { default: "click" }
|
|
2099
2293
|
},
|
|
2100
2294
|
setup(__props) {
|
|
2101
2295
|
const props = __props;
|
|
2102
2296
|
const services = vue.inject("services");
|
|
2103
|
-
const uiService = services?.uiService;
|
|
2104
|
-
const zoom = vue.computed(() => uiService?.get("zoom") ?? 1);
|
|
2105
|
-
const showGuides = vue.computed(() => uiService?.get("showGuides") ?? true);
|
|
2106
|
-
const showRule = vue.computed(() => uiService?.get("showRule") ?? true);
|
|
2107
|
-
const zoomInHandler = () => uiService?.zoom(0.1);
|
|
2108
|
-
const zoomOutHandler = () => uiService?.zoom(-0.1);
|
|
2109
|
-
const item = vue.computed(() => {
|
|
2110
|
-
if (typeof props.data !== "string") {
|
|
2111
|
-
return props.data;
|
|
2112
|
-
}
|
|
2113
|
-
switch (props.data) {
|
|
2114
|
-
case "/":
|
|
2115
|
-
return {
|
|
2116
|
-
type: "divider"
|
|
2117
|
-
};
|
|
2118
|
-
case "zoom":
|
|
2119
|
-
return {
|
|
2120
|
-
type: "zoom"
|
|
2121
|
-
};
|
|
2122
|
-
case "delete":
|
|
2123
|
-
return {
|
|
2124
|
-
type: "button",
|
|
2125
|
-
icon: vue.markRaw(iconsVue.Delete),
|
|
2126
|
-
tooltip: "\u522A\u9664",
|
|
2127
|
-
disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
|
|
2128
|
-
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
2129
|
-
};
|
|
2130
|
-
case "undo":
|
|
2131
|
-
return {
|
|
2132
|
-
type: "button",
|
|
2133
|
-
icon: vue.markRaw(iconsVue.Back),
|
|
2134
|
-
tooltip: "\u540E\u9000",
|
|
2135
|
-
disabled: () => !services?.historyService.state.canUndo,
|
|
2136
|
-
handler: () => services?.editorService.undo()
|
|
2137
|
-
};
|
|
2138
|
-
case "redo":
|
|
2139
|
-
return {
|
|
2140
|
-
type: "button",
|
|
2141
|
-
icon: vue.markRaw(iconsVue.Right),
|
|
2142
|
-
tooltip: "\u524D\u8FDB",
|
|
2143
|
-
disabled: () => !services?.historyService.state.canRedo,
|
|
2144
|
-
handler: () => services?.editorService.redo()
|
|
2145
|
-
};
|
|
2146
|
-
case "zoom-in":
|
|
2147
|
-
return {
|
|
2148
|
-
type: "button",
|
|
2149
|
-
icon: vue.markRaw(iconsVue.ZoomIn),
|
|
2150
|
-
tooltip: "\u653E\u5927",
|
|
2151
|
-
handler: zoomInHandler
|
|
2152
|
-
};
|
|
2153
|
-
case "zoom-out":
|
|
2154
|
-
return {
|
|
2155
|
-
type: "button",
|
|
2156
|
-
icon: vue.markRaw(iconsVue.ZoomOut),
|
|
2157
|
-
tooltip: "\u7E2E\u5C0F",
|
|
2158
|
-
handler: zoomOutHandler
|
|
2159
|
-
};
|
|
2160
|
-
case "rule":
|
|
2161
|
-
return {
|
|
2162
|
-
type: "button",
|
|
2163
|
-
icon: vue.markRaw(iconsVue.ScaleToOriginal),
|
|
2164
|
-
tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
|
|
2165
|
-
handler: () => uiService?.set("showRule", !showRule.value)
|
|
2166
|
-
};
|
|
2167
|
-
case "guides":
|
|
2168
|
-
return {
|
|
2169
|
-
type: "button",
|
|
2170
|
-
icon: vue.markRaw(iconsVue.Grid),
|
|
2171
|
-
tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
|
|
2172
|
-
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
2173
|
-
};
|
|
2174
|
-
default:
|
|
2175
|
-
return {
|
|
2176
|
-
type: "text",
|
|
2177
|
-
text: props.data
|
|
2178
|
-
};
|
|
2179
|
-
}
|
|
2180
|
-
});
|
|
2181
2297
|
const disabled = vue.computed(() => {
|
|
2182
|
-
if (typeof
|
|
2298
|
+
if (typeof props.data === "string")
|
|
2183
2299
|
return false;
|
|
2184
|
-
if (
|
|
2300
|
+
if (props.data.type === "component")
|
|
2185
2301
|
return false;
|
|
2186
|
-
if (typeof
|
|
2187
|
-
return
|
|
2302
|
+
if (typeof props.data.disabled === "function") {
|
|
2303
|
+
return props.data.disabled(services);
|
|
2188
2304
|
}
|
|
2189
|
-
return
|
|
2305
|
+
return props.data.disabled;
|
|
2190
2306
|
});
|
|
2191
|
-
const buttonHandler = (item2, event) => {
|
|
2192
|
-
if (disabled.value)
|
|
2193
|
-
return;
|
|
2194
|
-
if (typeof item2.handler === "function" && services) {
|
|
2195
|
-
item2.handler?.(services, event);
|
|
2196
|
-
}
|
|
2197
|
-
};
|
|
2198
2307
|
const display = vue.computed(() => {
|
|
2199
|
-
if (!
|
|
2308
|
+
if (!props.data)
|
|
2200
2309
|
return false;
|
|
2201
|
-
if (typeof
|
|
2310
|
+
if (typeof props.data === "string")
|
|
2202
2311
|
return true;
|
|
2203
|
-
if (typeof
|
|
2204
|
-
return
|
|
2312
|
+
if (typeof props.data.display === "function") {
|
|
2313
|
+
return props.data.display(services);
|
|
2205
2314
|
}
|
|
2206
|
-
return
|
|
2315
|
+
return props.data.display ?? true;
|
|
2207
2316
|
});
|
|
2317
|
+
const buttonHandler = (item, event) => {
|
|
2318
|
+
if (disabled.value)
|
|
2319
|
+
return;
|
|
2320
|
+
if (typeof item.handler === "function" && services) {
|
|
2321
|
+
item.handler?.(services, event);
|
|
2322
|
+
}
|
|
2323
|
+
};
|
|
2208
2324
|
const dropdownHandler = (command) => {
|
|
2209
2325
|
if (command.item.handler) {
|
|
2210
2326
|
command.item.handler(services);
|
|
2211
2327
|
}
|
|
2212
2328
|
};
|
|
2213
|
-
const clickHandler = (
|
|
2329
|
+
const clickHandler = (item, event) => {
|
|
2214
2330
|
if (props.eventType !== "click")
|
|
2215
2331
|
return;
|
|
2216
|
-
if (
|
|
2217
|
-
buttonHandler(
|
|
2332
|
+
if (item.type === "button") {
|
|
2333
|
+
buttonHandler(item, event);
|
|
2218
2334
|
}
|
|
2219
2335
|
};
|
|
2220
|
-
const mousedownHandler = (
|
|
2336
|
+
const mousedownHandler = (item, event) => {
|
|
2221
2337
|
if (props.eventType !== "mousedown")
|
|
2222
2338
|
return;
|
|
2223
|
-
if (
|
|
2224
|
-
buttonHandler(
|
|
2339
|
+
if (item.type === "button") {
|
|
2340
|
+
buttonHandler(item, event);
|
|
2225
2341
|
}
|
|
2226
2342
|
};
|
|
2227
|
-
const mouseupHandler = (
|
|
2343
|
+
const mouseupHandler = (item, event) => {
|
|
2228
2344
|
if (props.eventType !== "mouseup")
|
|
2229
2345
|
return;
|
|
2230
|
-
if (
|
|
2231
|
-
buttonHandler(
|
|
2346
|
+
if (item.type === "button") {
|
|
2347
|
+
buttonHandler(item, event);
|
|
2232
2348
|
}
|
|
2233
2349
|
};
|
|
2234
2350
|
return (_ctx, _cache) => {
|
|
2235
2351
|
const _component_el_divider = vue.resolveComponent("el-divider");
|
|
2236
|
-
const _component_tool_button = vue.resolveComponent("tool-button", true);
|
|
2237
2352
|
const _component_el_button = vue.resolveComponent("el-button");
|
|
2238
2353
|
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
2239
2354
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
@@ -2242,30 +2357,20 @@
|
|
|
2242
2357
|
const _component_el_dropdown = vue.resolveComponent("el-dropdown");
|
|
2243
2358
|
return vue.unref(display) ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
2244
2359
|
key: 0,
|
|
2245
|
-
class: vue.normalizeClass(["menu-item",
|
|
2246
|
-
onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(
|
|
2247
|
-
onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(
|
|
2248
|
-
onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(
|
|
2360
|
+
class: vue.normalizeClass(["menu-item", `${__props.data.type} ${__props.data.className || ""}`]),
|
|
2361
|
+
onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(__props.data, $event)),
|
|
2362
|
+
onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(__props.data, $event)),
|
|
2363
|
+
onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(__props.data, $event))
|
|
2249
2364
|
}, [
|
|
2250
|
-
|
|
2365
|
+
__props.data.type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
|
|
2251
2366
|
key: 0,
|
|
2252
|
-
direction:
|
|
2253
|
-
}, null, 8, ["direction"])) :
|
|
2254
|
-
vue.
|
|
2255
|
-
data: { type: "button", icon: vue.unref(iconsVue.ZoomOut), handler: zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
2256
|
-
"event-type": __props.eventType
|
|
2257
|
-
}, null, 8, ["data", "event-type"]),
|
|
2258
|
-
vue.createElementVNode("span", _hoisted_2$2, vue.toDisplayString(parseInt(`${vue.unref(zoom) * 100}`, 10)) + "%", 1),
|
|
2259
|
-
vue.createVNode(_component_tool_button, {
|
|
2260
|
-
data: { type: "button", icon: vue.unref(iconsVue.ZoomIn), handler: zoomInHandler, tooltip: "\u653E\u5927" },
|
|
2261
|
-
"event-type": __props.eventType
|
|
2262
|
-
}, null, 8, ["data", "event-type"])
|
|
2263
|
-
], 64)) : vue.unref(item).type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
|
|
2264
|
-
vue.unref(item).tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
|
|
2367
|
+
direction: __props.data.direction || "vertical"
|
|
2368
|
+
}, null, 8, ["direction"])) : __props.data.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$5, vue.toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
|
|
2369
|
+
__props.data.tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
|
|
2265
2370
|
key: 0,
|
|
2266
2371
|
effect: "dark",
|
|
2267
2372
|
placement: "bottom-start",
|
|
2268
|
-
content:
|
|
2373
|
+
content: __props.data.tooltip
|
|
2269
2374
|
}, {
|
|
2270
2375
|
default: vue.withCtx(() => [
|
|
2271
2376
|
vue.createVNode(_component_el_button, {
|
|
@@ -2274,11 +2379,11 @@
|
|
|
2274
2379
|
disabled: vue.unref(disabled)
|
|
2275
2380
|
}, {
|
|
2276
2381
|
default: vue.withCtx(() => [
|
|
2277
|
-
|
|
2382
|
+
__props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$h, {
|
|
2278
2383
|
key: 0,
|
|
2279
|
-
icon:
|
|
2384
|
+
icon: __props.data.icon
|
|
2280
2385
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
2281
|
-
vue.createElementVNode("span", null, vue.toDisplayString(
|
|
2386
|
+
vue.createElementVNode("span", null, vue.toDisplayString(__props.data.text), 1)
|
|
2282
2387
|
]),
|
|
2283
2388
|
_: 1
|
|
2284
2389
|
}, 8, ["disabled"])
|
|
@@ -2291,27 +2396,27 @@
|
|
|
2291
2396
|
disabled: vue.unref(disabled)
|
|
2292
2397
|
}, {
|
|
2293
2398
|
default: vue.withCtx(() => [
|
|
2294
|
-
|
|
2399
|
+
__props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$h, {
|
|
2295
2400
|
key: 0,
|
|
2296
|
-
icon:
|
|
2401
|
+
icon: __props.data.icon
|
|
2297
2402
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
2298
|
-
vue.createElementVNode("span", null, vue.toDisplayString(
|
|
2403
|
+
vue.createElementVNode("span", null, vue.toDisplayString(__props.data.text), 1)
|
|
2299
2404
|
]),
|
|
2300
2405
|
_: 1
|
|
2301
2406
|
}, 8, ["disabled"]))
|
|
2302
|
-
], 64)) :
|
|
2303
|
-
key:
|
|
2407
|
+
], 64)) : __props.data.type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
|
|
2408
|
+
key: 3,
|
|
2304
2409
|
trigger: "click",
|
|
2305
2410
|
disabled: vue.unref(disabled),
|
|
2306
2411
|
onCommand: dropdownHandler
|
|
2307
2412
|
}, {
|
|
2308
2413
|
dropdown: vue.withCtx(() => [
|
|
2309
|
-
|
|
2414
|
+
__props.data.items && __props.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_dropdown_menu, { key: 0 }, {
|
|
2310
2415
|
default: vue.withCtx(() => [
|
|
2311
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(
|
|
2416
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.data.items, (subItem, index) => {
|
|
2312
2417
|
return vue.openBlock(), vue.createBlock(_component_el_dropdown_item, {
|
|
2313
2418
|
key: index,
|
|
2314
|
-
command: {
|
|
2419
|
+
command: { data: __props.data, subItem }
|
|
2315
2420
|
}, {
|
|
2316
2421
|
default: vue.withCtx(() => [
|
|
2317
2422
|
vue.createTextVNode(vue.toDisplayString(subItem.text), 1)
|
|
@@ -2324,8 +2429,8 @@
|
|
|
2324
2429
|
})) : vue.createCommentVNode("", true)
|
|
2325
2430
|
]),
|
|
2326
2431
|
default: vue.withCtx(() => [
|
|
2327
|
-
vue.createElementVNode("span",
|
|
2328
|
-
vue.createTextVNode(vue.toDisplayString(
|
|
2432
|
+
vue.createElementVNode("span", _hoisted_2$2, [
|
|
2433
|
+
vue.createTextVNode(vue.toDisplayString(__props.data.text), 1),
|
|
2329
2434
|
vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2330
2435
|
default: vue.withCtx(() => [
|
|
2331
2436
|
vue.createVNode(vue.unref(iconsVue.ArrowDown))
|
|
@@ -2335,67 +2440,187 @@
|
|
|
2335
2440
|
])
|
|
2336
2441
|
]),
|
|
2337
2442
|
_: 1
|
|
2338
|
-
}, 8, ["disabled"])) :
|
|
2443
|
+
}, 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)
|
|
2339
2444
|
], 34)) : vue.createCommentVNode("", true);
|
|
2340
2445
|
};
|
|
2341
2446
|
}
|
|
2342
2447
|
});
|
|
2343
2448
|
|
|
2344
|
-
const _sfc_main$
|
|
2345
|
-
|
|
2346
|
-
components: { ToolButton: _sfc_main$f },
|
|
2449
|
+
const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
2450
|
+
__name: "NavMenu",
|
|
2347
2451
|
props: {
|
|
2348
|
-
data: {
|
|
2349
|
-
|
|
2350
|
-
default: () => ({})
|
|
2351
|
-
},
|
|
2352
|
-
height: {
|
|
2353
|
-
type: Number
|
|
2354
|
-
}
|
|
2452
|
+
data: { default: () => ({}) },
|
|
2453
|
+
height: { default: 35 }
|
|
2355
2454
|
},
|
|
2356
|
-
setup(
|
|
2455
|
+
setup(__props) {
|
|
2456
|
+
const props = __props;
|
|
2357
2457
|
const services = vue.inject("services");
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2458
|
+
const uiService = services?.uiService;
|
|
2459
|
+
const columnWidth = vue.computed(() => services?.uiService.get("columnWidth"));
|
|
2460
|
+
const keys = Object.values(ColumnLayout);
|
|
2461
|
+
const showGuides = vue.computed(() => uiService?.get("showGuides") ?? true);
|
|
2462
|
+
const showRule = vue.computed(() => uiService?.get("showRule") ?? true);
|
|
2463
|
+
const zoom = vue.computed(() => uiService?.get("zoom") ?? 1);
|
|
2464
|
+
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
2465
|
+
const ctrl = isMac ? "Command" : "Ctrl";
|
|
2466
|
+
const getConfig = (item) => {
|
|
2467
|
+
if (typeof item !== "string") {
|
|
2468
|
+
return [item];
|
|
2469
|
+
}
|
|
2470
|
+
const config = [];
|
|
2471
|
+
switch (item) {
|
|
2472
|
+
case "/":
|
|
2473
|
+
config.push({
|
|
2474
|
+
type: "divider",
|
|
2475
|
+
className: "divider"
|
|
2476
|
+
});
|
|
2477
|
+
break;
|
|
2478
|
+
case "zoom":
|
|
2479
|
+
config.push(...getConfig("zoom-out"), ...getConfig(`${parseInt(`${zoom.value * 100}`, 10)}%`), ...getConfig("zoom-in"), ...getConfig("scale-to-original"), ...getConfig("scale-to-fit"));
|
|
2480
|
+
break;
|
|
2481
|
+
case "delete":
|
|
2482
|
+
config.push({
|
|
2483
|
+
type: "button",
|
|
2484
|
+
className: "delete",
|
|
2485
|
+
icon: vue.markRaw(iconsVue.Delete),
|
|
2486
|
+
tooltip: `\u522A\u9664(Delete)`,
|
|
2487
|
+
disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
|
|
2488
|
+
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
2489
|
+
});
|
|
2490
|
+
break;
|
|
2491
|
+
case "undo":
|
|
2492
|
+
config.push({
|
|
2493
|
+
type: "button",
|
|
2494
|
+
className: "undo",
|
|
2495
|
+
icon: vue.markRaw(iconsVue.Back),
|
|
2496
|
+
tooltip: `\u540E\u9000(${ctrl}+z)`,
|
|
2497
|
+
disabled: () => !services?.historyService.state.canUndo,
|
|
2498
|
+
handler: () => services?.editorService.undo()
|
|
2499
|
+
});
|
|
2500
|
+
break;
|
|
2501
|
+
case "redo":
|
|
2502
|
+
config.push({
|
|
2503
|
+
type: "button",
|
|
2504
|
+
className: "redo",
|
|
2505
|
+
icon: vue.markRaw(iconsVue.Right),
|
|
2506
|
+
tooltip: `\u524D\u8FDB(${ctrl}+Shift+z)`,
|
|
2507
|
+
disabled: () => !services?.historyService.state.canRedo,
|
|
2508
|
+
handler: () => services?.editorService.redo()
|
|
2509
|
+
});
|
|
2510
|
+
break;
|
|
2511
|
+
case "zoom-in":
|
|
2512
|
+
config.push({
|
|
2513
|
+
type: "button",
|
|
2514
|
+
className: "zoom-in",
|
|
2515
|
+
icon: vue.markRaw(iconsVue.ZoomIn),
|
|
2516
|
+
tooltip: `\u653E\u5927(${ctrl}+=)`,
|
|
2517
|
+
handler: () => uiService?.zoom(0.1)
|
|
2518
|
+
});
|
|
2519
|
+
break;
|
|
2520
|
+
case "zoom-out":
|
|
2521
|
+
config.push({
|
|
2522
|
+
type: "button",
|
|
2523
|
+
className: "zoom-out",
|
|
2524
|
+
icon: vue.markRaw(iconsVue.ZoomOut),
|
|
2525
|
+
tooltip: `\u7E2E\u5C0F(${ctrl}+-)`,
|
|
2526
|
+
handler: () => uiService?.zoom(-0.1)
|
|
2527
|
+
});
|
|
2528
|
+
break;
|
|
2529
|
+
case "scale-to-original":
|
|
2530
|
+
config.push({
|
|
2531
|
+
type: "button",
|
|
2532
|
+
className: "scale-to-original",
|
|
2533
|
+
icon: vue.markRaw(iconsVue.ScaleToOriginal),
|
|
2534
|
+
tooltip: `\u7F29\u653E\u5230\u5B9E\u9645\u5927\u5C0F(${ctrl}+1)`,
|
|
2535
|
+
handler: () => uiService?.set("zoom", 1)
|
|
2536
|
+
});
|
|
2537
|
+
break;
|
|
2538
|
+
case "scale-to-fit":
|
|
2539
|
+
config.push({
|
|
2540
|
+
type: "button",
|
|
2541
|
+
className: "scale-to-fit",
|
|
2542
|
+
icon: vue.markRaw(iconsVue.FullScreen),
|
|
2543
|
+
tooltip: `\u7F29\u653E\u4EE5\u9002\u5E94(${ctrl}+0)`,
|
|
2544
|
+
handler: () => uiService?.set("zoom", uiService.calcZoom())
|
|
2545
|
+
});
|
|
2546
|
+
break;
|
|
2547
|
+
case "rule":
|
|
2548
|
+
config.push({
|
|
2549
|
+
type: "button",
|
|
2550
|
+
className: "rule",
|
|
2551
|
+
icon: vue.markRaw(iconsVue.Memo),
|
|
2552
|
+
tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
|
|
2553
|
+
handler: () => uiService?.set("showRule", !showRule.value)
|
|
2554
|
+
});
|
|
2555
|
+
break;
|
|
2556
|
+
case "guides":
|
|
2557
|
+
config.push({
|
|
2558
|
+
type: "button",
|
|
2559
|
+
className: "guides",
|
|
2560
|
+
icon: vue.markRaw(iconsVue.Grid),
|
|
2561
|
+
tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
|
|
2562
|
+
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
2563
|
+
});
|
|
2564
|
+
break;
|
|
2565
|
+
default:
|
|
2566
|
+
config.push({
|
|
2567
|
+
type: "text",
|
|
2568
|
+
text: item
|
|
2569
|
+
});
|
|
2570
|
+
}
|
|
2571
|
+
return config;
|
|
2361
2572
|
};
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2573
|
+
const buttons = vue.computed(() => {
|
|
2574
|
+
const data = {
|
|
2575
|
+
[ColumnLayout.LEFT]: [],
|
|
2576
|
+
[ColumnLayout.CENTER]: [],
|
|
2577
|
+
[ColumnLayout.RIGHT]: []
|
|
2578
|
+
};
|
|
2579
|
+
keys.forEach((key) => {
|
|
2580
|
+
const items = props.data[key] || [];
|
|
2581
|
+
items.forEach((item) => {
|
|
2582
|
+
data[key].push(...getConfig(item));
|
|
2583
|
+
});
|
|
2584
|
+
});
|
|
2585
|
+
return data;
|
|
2586
|
+
});
|
|
2587
|
+
return (_ctx, _cache) => {
|
|
2372
2588
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
2373
|
-
class:
|
|
2374
|
-
|
|
2375
|
-
style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.[key]}px`)
|
|
2589
|
+
class: "m-editor-nav-menu",
|
|
2590
|
+
style: vue.normalizeStyle({ height: `${__props.height}px` })
|
|
2376
2591
|
}, [
|
|
2377
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(
|
|
2378
|
-
return vue.openBlock(), vue.
|
|
2379
|
-
|
|
2380
|
-
key
|
|
2381
|
-
|
|
2592
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(keys), (key) => {
|
|
2593
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
2594
|
+
class: vue.normalizeClass(`menu-${key}`),
|
|
2595
|
+
key,
|
|
2596
|
+
style: vue.normalizeStyle(`width: ${vue.unref(columnWidth)?.[key]}px`)
|
|
2597
|
+
}, [
|
|
2598
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(buttons)[key], (item, index) => {
|
|
2599
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$g, {
|
|
2600
|
+
data: item,
|
|
2601
|
+
key: index
|
|
2602
|
+
}, null, 8, ["data"]);
|
|
2603
|
+
}), 128))
|
|
2604
|
+
], 6);
|
|
2382
2605
|
}), 128))
|
|
2383
|
-
],
|
|
2384
|
-
}
|
|
2385
|
-
|
|
2386
|
-
}
|
|
2387
|
-
const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
|
|
2606
|
+
], 4);
|
|
2607
|
+
};
|
|
2608
|
+
}
|
|
2609
|
+
});
|
|
2388
2610
|
|
|
2389
|
-
const
|
|
2390
|
-
|
|
2611
|
+
const _hoisted_1$4 = { class: "`m-editor-props-panel" };
|
|
2612
|
+
const _sfc_main$e = /* @__PURE__ */ vue.defineComponent({
|
|
2613
|
+
__name: "PropsPanel",
|
|
2391
2614
|
emits: ["mounted"],
|
|
2392
|
-
setup(
|
|
2615
|
+
setup(__props, { expose, emit }) {
|
|
2393
2616
|
const internalInstance = vue.getCurrentInstance();
|
|
2394
2617
|
const values = vue.ref({});
|
|
2395
2618
|
const configForm = vue.ref();
|
|
2396
2619
|
const curFormConfig = vue.ref([]);
|
|
2397
2620
|
const services = vue.inject("services");
|
|
2398
2621
|
const node = vue.computed(() => services?.editorService.get("node"));
|
|
2622
|
+
const propsPanelSize = vue.computed(() => services?.uiService.get("propsPanelSize") || "small");
|
|
2623
|
+
const stage = vue.computed(() => services?.editorService.get("stage"));
|
|
2399
2624
|
const init = async () => {
|
|
2400
2625
|
if (!node.value) {
|
|
2401
2626
|
curFormConfig.value = [];
|
|
@@ -2410,51 +2635,49 @@
|
|
|
2410
2635
|
vue.onMounted(() => {
|
|
2411
2636
|
emit("mounted", internalInstance);
|
|
2412
2637
|
});
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
curFormConfig,
|
|
2417
|
-
propsPanelSize: vue.computed(() => services?.uiService.get("propsPanelSize") || "small"),
|
|
2418
|
-
async submit() {
|
|
2419
|
-
try {
|
|
2420
|
-
const values2 = await configForm.value?.submitForm();
|
|
2421
|
-
services?.editorService.update(values2);
|
|
2422
|
-
} catch (e) {
|
|
2423
|
-
console.error(e);
|
|
2424
|
-
elementPlus.ElMessage.closeAll();
|
|
2425
|
-
elementPlus.ElMessage.error({
|
|
2426
|
-
duration: 1e4,
|
|
2427
|
-
showClose: true,
|
|
2428
|
-
message: e.message,
|
|
2429
|
-
dangerouslyUseHTMLString: true
|
|
2430
|
-
});
|
|
2431
|
-
}
|
|
2638
|
+
vue.watchEffect(() => {
|
|
2639
|
+
if (configForm.value && stage.value) {
|
|
2640
|
+
configForm.value.formState.stage = stage.value;
|
|
2432
2641
|
}
|
|
2642
|
+
});
|
|
2643
|
+
const submit = async () => {
|
|
2644
|
+
try {
|
|
2645
|
+
const values2 = await configForm.value?.submitForm();
|
|
2646
|
+
services?.editorService.update(values2);
|
|
2647
|
+
} catch (e) {
|
|
2648
|
+
console.error(e);
|
|
2649
|
+
elementPlus.ElMessage.closeAll();
|
|
2650
|
+
elementPlus.ElMessage.error({
|
|
2651
|
+
duration: 1e4,
|
|
2652
|
+
showClose: true,
|
|
2653
|
+
message: e.message,
|
|
2654
|
+
dangerouslyUseHTMLString: true
|
|
2655
|
+
});
|
|
2656
|
+
}
|
|
2657
|
+
};
|
|
2658
|
+
expose({ submit });
|
|
2659
|
+
return (_ctx, _cache) => {
|
|
2660
|
+
const _component_m_form = vue.resolveComponent("m-form");
|
|
2661
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, [
|
|
2662
|
+
vue.renderSlot(_ctx.$slots, "props-panel-header"),
|
|
2663
|
+
vue.createVNode(_component_m_form, {
|
|
2664
|
+
ref_key: "configForm",
|
|
2665
|
+
ref: configForm,
|
|
2666
|
+
class: vue.normalizeClass(`m-editor-props-panel ${vue.unref(propsPanelSize)}`),
|
|
2667
|
+
"popper-class": `m-editor-props-panel-popper ${vue.unref(propsPanelSize)}`,
|
|
2668
|
+
size: vue.unref(propsPanelSize),
|
|
2669
|
+
"init-values": values.value,
|
|
2670
|
+
config: curFormConfig.value,
|
|
2671
|
+
onChange: submit
|
|
2672
|
+
}, null, 8, ["class", "popper-class", "size", "init-values", "config"])
|
|
2673
|
+
]);
|
|
2433
2674
|
};
|
|
2434
2675
|
}
|
|
2435
2676
|
});
|
|
2436
2677
|
|
|
2437
|
-
const
|
|
2438
|
-
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2439
|
-
const _component_m_form = vue.resolveComponent("m-form");
|
|
2440
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
|
|
2441
|
-
vue.renderSlot(_ctx.$slots, "props-panel-header"),
|
|
2442
|
-
vue.createVNode(_component_m_form, {
|
|
2443
|
-
class: vue.normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
|
|
2444
|
-
"popper-class": `m-editor-props-panel-popper ${_ctx.propsPanelSize}`,
|
|
2445
|
-
ref: "configForm",
|
|
2446
|
-
size: _ctx.propsPanelSize,
|
|
2447
|
-
"init-values": _ctx.values,
|
|
2448
|
-
config: _ctx.curFormConfig,
|
|
2449
|
-
onChange: _ctx.submit
|
|
2450
|
-
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
|
|
2451
|
-
]);
|
|
2452
|
-
}
|
|
2453
|
-
const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
|
|
2454
|
-
|
|
2455
|
-
const _sfc_main$c = vue.defineComponent({
|
|
2678
|
+
const _sfc_main$d = vue.defineComponent({
|
|
2456
2679
|
name: "ui-component-panel",
|
|
2457
|
-
components: { MIcon },
|
|
2680
|
+
components: { MIcon: _sfc_main$h },
|
|
2458
2681
|
setup() {
|
|
2459
2682
|
const searchText = vue.ref("");
|
|
2460
2683
|
const services = vue.inject("services");
|
|
@@ -2519,9 +2742,9 @@
|
|
|
2519
2742
|
}
|
|
2520
2743
|
});
|
|
2521
2744
|
|
|
2522
|
-
const _hoisted_1$
|
|
2745
|
+
const _hoisted_1$3 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
2523
2746
|
const _hoisted_2$1 = ["onClick", "onDragstart"];
|
|
2524
|
-
function _sfc_render$
|
|
2747
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2525
2748
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
2526
2749
|
const _component_m_icon = vue.resolveComponent("m-icon");
|
|
2527
2750
|
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
@@ -2552,7 +2775,7 @@
|
|
|
2552
2775
|
name: index
|
|
2553
2776
|
}, {
|
|
2554
2777
|
title: vue.withCtx(() => [
|
|
2555
|
-
_hoisted_1$
|
|
2778
|
+
_hoisted_1$3,
|
|
2556
2779
|
vue.createTextVNode(vue.toDisplayString(group.title), 1)
|
|
2557
2780
|
]),
|
|
2558
2781
|
default: vue.withCtx(() => [
|
|
@@ -2593,9 +2816,9 @@
|
|
|
2593
2816
|
_: 3
|
|
2594
2817
|
});
|
|
2595
2818
|
}
|
|
2596
|
-
const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2819
|
+
const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$5]]);
|
|
2597
2820
|
|
|
2598
|
-
const _sfc_main$
|
|
2821
|
+
const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
|
|
2599
2822
|
__name: "ContentMenu",
|
|
2600
2823
|
props: {
|
|
2601
2824
|
menuData: { default: () => [] },
|
|
@@ -2684,7 +2907,7 @@
|
|
|
2684
2907
|
}, [
|
|
2685
2908
|
vue.createElementVNode("div", null, [
|
|
2686
2909
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.menuData, (item, index) => {
|
|
2687
|
-
return vue.openBlock(), vue.createBlock(_sfc_main$
|
|
2910
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$g, {
|
|
2688
2911
|
"event-type": "mouseup",
|
|
2689
2912
|
data: item,
|
|
2690
2913
|
key: index,
|
|
@@ -2708,8 +2931,8 @@
|
|
|
2708
2931
|
}
|
|
2709
2932
|
});
|
|
2710
2933
|
|
|
2711
|
-
const _sfc_main$
|
|
2712
|
-
components: { ContentMenu: _sfc_main$
|
|
2934
|
+
const _sfc_main$b = vue.defineComponent({
|
|
2935
|
+
components: { ContentMenu: _sfc_main$c },
|
|
2713
2936
|
setup() {
|
|
2714
2937
|
const services = vue.inject("services");
|
|
2715
2938
|
const menu = vue.ref();
|
|
@@ -2792,7 +3015,7 @@
|
|
|
2792
3015
|
}
|
|
2793
3016
|
});
|
|
2794
3017
|
|
|
2795
|
-
function _sfc_render$
|
|
3018
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2796
3019
|
const _component_content_menu = vue.resolveComponent("content-menu");
|
|
2797
3020
|
return vue.openBlock(), vue.createBlock(_component_content_menu, {
|
|
2798
3021
|
"menu-data": _ctx.menuData,
|
|
@@ -2800,7 +3023,7 @@
|
|
|
2800
3023
|
style: { "overflow": "initial" }
|
|
2801
3024
|
}, null, 8, ["menu-data"]);
|
|
2802
3025
|
}
|
|
2803
|
-
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3026
|
+
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$4]]);
|
|
2804
3027
|
|
|
2805
3028
|
const throttleTime = 150;
|
|
2806
3029
|
const select = async (data, editorService) => {
|
|
@@ -2851,20 +3074,38 @@
|
|
|
2851
3074
|
}
|
|
2852
3075
|
});
|
|
2853
3076
|
const useStatus = (tree, editorService) => {
|
|
2854
|
-
const highlightNode = vue.ref();
|
|
2855
3077
|
const node = vue.ref();
|
|
2856
3078
|
const page = vue.computed(() => editorService?.get("page"));
|
|
3079
|
+
const expandedKeys = /* @__PURE__ */ new Map();
|
|
3080
|
+
const expandNodes = () => {
|
|
3081
|
+
expandedKeys.forEach((key) => {
|
|
3082
|
+
if (!tree.value)
|
|
3083
|
+
return;
|
|
3084
|
+
tree.value.getNode(key)?.expand();
|
|
3085
|
+
});
|
|
3086
|
+
};
|
|
2857
3087
|
vue.watchEffect(() => {
|
|
2858
3088
|
if (!tree.value)
|
|
2859
3089
|
return;
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
3090
|
+
if (!editorService)
|
|
3091
|
+
return;
|
|
3092
|
+
node.value = editorService.get("node");
|
|
3093
|
+
if (!node.value)
|
|
3094
|
+
return;
|
|
3095
|
+
tree.value.setCurrentKey(node.value.id, true);
|
|
3096
|
+
const parent = editorService.get("parent");
|
|
2863
3097
|
if (!parent?.id)
|
|
2864
3098
|
return;
|
|
2865
3099
|
const treeNode = tree.value.getNode(parent.id);
|
|
2866
3100
|
treeNode?.updateChildren();
|
|
2867
|
-
|
|
3101
|
+
setTimeout(() => {
|
|
3102
|
+
tree.value && Object.entries(tree.value.store.nodesMap).forEach(([id, node2]) => {
|
|
3103
|
+
if (node2.expanded && node2.data.items) {
|
|
3104
|
+
expandedKeys.set(id, id);
|
|
3105
|
+
}
|
|
3106
|
+
});
|
|
3107
|
+
expandNodes();
|
|
3108
|
+
});
|
|
2868
3109
|
});
|
|
2869
3110
|
return {
|
|
2870
3111
|
values: vue.computed(() => page.value ? [page.value] : []),
|
|
@@ -2877,9 +3118,18 @@
|
|
|
2877
3118
|
}
|
|
2878
3119
|
resolve([]);
|
|
2879
3120
|
},
|
|
2880
|
-
highlightNode,
|
|
3121
|
+
highlightNode: vue.computed(() => editorService?.get("highlightNode")),
|
|
2881
3122
|
clickNode: node,
|
|
2882
|
-
expandedKeys: vue.computed(() => node.value ? [node.value.id] : [])
|
|
3123
|
+
expandedKeys: vue.computed(() => node.value ? [node.value.id] : []),
|
|
3124
|
+
handleCollapse: (data) => {
|
|
3125
|
+
expandedKeys.delete(data.id);
|
|
3126
|
+
},
|
|
3127
|
+
handleExpand: (data) => {
|
|
3128
|
+
const parent = editorService?.getParentById(data.id);
|
|
3129
|
+
if (!parent?.id)
|
|
3130
|
+
return;
|
|
3131
|
+
expandedKeys.set(parent.id, parent.id);
|
|
3132
|
+
}
|
|
2883
3133
|
};
|
|
2884
3134
|
};
|
|
2885
3135
|
const useFilter = (tree) => ({
|
|
@@ -2900,7 +3150,7 @@
|
|
|
2900
3150
|
tree.value?.filter(val);
|
|
2901
3151
|
}
|
|
2902
3152
|
});
|
|
2903
|
-
const _sfc_main$
|
|
3153
|
+
const _sfc_main$a = vue.defineComponent({
|
|
2904
3154
|
name: "magic-editor-layer-panel",
|
|
2905
3155
|
components: { LayerMenu },
|
|
2906
3156
|
setup() {
|
|
@@ -2948,8 +3198,8 @@
|
|
|
2948
3198
|
}
|
|
2949
3199
|
});
|
|
2950
3200
|
|
|
2951
|
-
const _hoisted_1$
|
|
2952
|
-
function _sfc_render$
|
|
3201
|
+
const _hoisted_1$2 = ["id", "onMouseenter"];
|
|
3202
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2953
3203
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
2954
3204
|
const _component_el_tree = vue.resolveComponent("el-tree");
|
|
2955
3205
|
const _component_layer_menu = vue.resolveComponent("layer-menu");
|
|
@@ -2970,6 +3220,7 @@
|
|
|
2970
3220
|
key: 0,
|
|
2971
3221
|
ref: "tree",
|
|
2972
3222
|
"node-key": "id",
|
|
3223
|
+
"empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
|
|
2973
3224
|
draggable: "",
|
|
2974
3225
|
"default-expanded-keys": _ctx.expandedKeys,
|
|
2975
3226
|
load: _ctx.loadItems,
|
|
@@ -2984,7 +3235,8 @@
|
|
|
2984
3235
|
onNodeClick: _ctx.clickHandler,
|
|
2985
3236
|
onNodeContextmenu: _ctx.contextmenu,
|
|
2986
3237
|
onNodeDragEnd: _ctx.handleDragEnd,
|
|
2987
|
-
|
|
3238
|
+
onNodeCollapse: _ctx.handleCollapse,
|
|
3239
|
+
onNodeExpand: _ctx.handleExpand
|
|
2988
3240
|
}, {
|
|
2989
3241
|
default: vue.withCtx(({ node, data }) => [
|
|
2990
3242
|
vue.createElementVNode("div", {
|
|
@@ -3000,10 +3252,10 @@
|
|
|
3000
3252
|
}, () => [
|
|
3001
3253
|
vue.createElementVNode("span", null, vue.toDisplayString(`${data.name} (${data.id})`), 1)
|
|
3002
3254
|
])
|
|
3003
|
-
], 42, _hoisted_1$
|
|
3255
|
+
], 42, _hoisted_1$2)
|
|
3004
3256
|
]),
|
|
3005
3257
|
_: 3
|
|
3006
|
-
}, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : vue.createCommentVNode("", true),
|
|
3258
|
+
}, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd", "onNodeCollapse", "onNodeExpand"])) : vue.createCommentVNode("", true),
|
|
3007
3259
|
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
3008
3260
|
vue.createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
|
|
3009
3261
|
]))
|
|
@@ -3011,10 +3263,10 @@
|
|
|
3011
3263
|
_: 3
|
|
3012
3264
|
});
|
|
3013
3265
|
}
|
|
3014
|
-
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3266
|
+
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$3]]);
|
|
3015
3267
|
|
|
3016
|
-
const _sfc_main$
|
|
3017
|
-
components: { MIcon },
|
|
3268
|
+
const _sfc_main$9 = vue.defineComponent({
|
|
3269
|
+
components: { MIcon: _sfc_main$h },
|
|
3018
3270
|
props: {
|
|
3019
3271
|
data: {
|
|
3020
3272
|
type: [Object, String]
|
|
@@ -3051,11 +3303,11 @@
|
|
|
3051
3303
|
}
|
|
3052
3304
|
});
|
|
3053
3305
|
|
|
3054
|
-
const _hoisted_1$
|
|
3306
|
+
const _hoisted_1$1 = {
|
|
3055
3307
|
key: 1,
|
|
3056
3308
|
class: "magic-editor-tab-panel-title"
|
|
3057
3309
|
};
|
|
3058
|
-
function _sfc_render$
|
|
3310
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3059
3311
|
const _component_m_icon = vue.resolveComponent("m-icon");
|
|
3060
3312
|
const _component_el_tab_pane = vue.resolveComponent("el-tab-pane");
|
|
3061
3313
|
return _ctx.config ? (vue.openBlock(), vue.createBlock(_component_el_tab_pane, {
|
|
@@ -3070,7 +3322,7 @@
|
|
|
3070
3322
|
key: 0,
|
|
3071
3323
|
icon: _ctx.config.icon
|
|
3072
3324
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
3073
|
-
_ctx.config.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
3325
|
+
_ctx.config.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, vue.toDisplayString(_ctx.config.text), 1)) : vue.createCommentVNode("", true)
|
|
3074
3326
|
]))
|
|
3075
3327
|
]),
|
|
3076
3328
|
default: vue.withCtx(() => [
|
|
@@ -3101,9 +3353,9 @@
|
|
|
3101
3353
|
_: 3
|
|
3102
3354
|
}, 8, ["name"])) : vue.createCommentVNode("", true);
|
|
3103
3355
|
}
|
|
3104
|
-
const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3356
|
+
const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$2]]);
|
|
3105
3357
|
|
|
3106
|
-
const _sfc_main$
|
|
3358
|
+
const _sfc_main$8 = vue.defineComponent({
|
|
3107
3359
|
components: { TabPane },
|
|
3108
3360
|
name: "m-sidebar",
|
|
3109
3361
|
props: {
|
|
@@ -3123,7 +3375,7 @@
|
|
|
3123
3375
|
}
|
|
3124
3376
|
});
|
|
3125
3377
|
|
|
3126
|
-
function _sfc_render$
|
|
3378
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3127
3379
|
const _component_tab_pane = vue.resolveComponent("tab-pane");
|
|
3128
3380
|
const _component_el_tabs = vue.resolveComponent("el-tabs");
|
|
3129
3381
|
return _ctx.data.type === "tabs" && _ctx.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_tabs, {
|
|
@@ -3158,9 +3410,9 @@
|
|
|
3158
3410
|
_: 3
|
|
3159
3411
|
}, 8, ["modelValue"])) : vue.createCommentVNode("", true);
|
|
3160
3412
|
}
|
|
3161
|
-
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3413
|
+
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$1]]);
|
|
3162
3414
|
|
|
3163
|
-
const _sfc_main$
|
|
3415
|
+
const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
|
|
3164
3416
|
__name: "PageBarScrollContainer",
|
|
3165
3417
|
setup(__props) {
|
|
3166
3418
|
const services = vue.inject("services");
|
|
@@ -3287,9 +3539,9 @@
|
|
|
3287
3539
|
}
|
|
3288
3540
|
});
|
|
3289
3541
|
|
|
3290
|
-
const _hoisted_1
|
|
3542
|
+
const _hoisted_1 = ["onClick"];
|
|
3291
3543
|
const _hoisted_2 = { class: "m-editor-page-bar-title" };
|
|
3292
|
-
const _sfc_main$
|
|
3544
|
+
const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
|
|
3293
3545
|
__name: "PageBar",
|
|
3294
3546
|
setup(__props) {
|
|
3295
3547
|
const services = vue.inject("services");
|
|
@@ -3313,7 +3565,7 @@
|
|
|
3313
3565
|
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
3314
3566
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
3315
3567
|
const _component_el_popover = vue.resolveComponent("el-popover");
|
|
3316
|
-
return vue.openBlock(), vue.createBlock(_sfc_main$
|
|
3568
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$7, null, {
|
|
3317
3569
|
default: vue.withCtx(() => [
|
|
3318
3570
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(root) && vue.unref(root).items || [], (item) => {
|
|
3319
3571
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
@@ -3329,7 +3581,7 @@
|
|
|
3329
3581
|
content: item.name
|
|
3330
3582
|
}, {
|
|
3331
3583
|
default: vue.withCtx(() => [
|
|
3332
|
-
vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
|
|
3584
|
+
vue.createElementVNode("span", null, vue.toDisplayString(item.name || item.id), 1)
|
|
3333
3585
|
]),
|
|
3334
3586
|
_: 2
|
|
3335
3587
|
}, 1032, ["content"])
|
|
@@ -3352,7 +3604,7 @@
|
|
|
3352
3604
|
default: vue.withCtx(() => [
|
|
3353
3605
|
vue.createElementVNode("div", null, [
|
|
3354
3606
|
vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3355
|
-
vue.createVNode(_sfc_main$
|
|
3607
|
+
vue.createVNode(_sfc_main$g, {
|
|
3356
3608
|
data: {
|
|
3357
3609
|
type: "button",
|
|
3358
3610
|
text: "\u590D\u5236",
|
|
@@ -3360,7 +3612,7 @@
|
|
|
3360
3612
|
handler: () => copy(item)
|
|
3361
3613
|
}
|
|
3362
3614
|
}, null, 8, ["data"]),
|
|
3363
|
-
vue.createVNode(_sfc_main$
|
|
3615
|
+
vue.createVNode(_sfc_main$g, {
|
|
3364
3616
|
data: {
|
|
3365
3617
|
type: "button",
|
|
3366
3618
|
text: "\u5220\u9664",
|
|
@@ -3373,7 +3625,7 @@
|
|
|
3373
3625
|
]),
|
|
3374
3626
|
_: 2
|
|
3375
3627
|
}, 1024)
|
|
3376
|
-
], 10, _hoisted_1
|
|
3628
|
+
], 10, _hoisted_1);
|
|
3377
3629
|
}), 128))
|
|
3378
3630
|
]),
|
|
3379
3631
|
_: 3
|
|
@@ -3382,190 +3634,245 @@
|
|
|
3382
3634
|
}
|
|
3383
3635
|
});
|
|
3384
3636
|
|
|
3385
|
-
class ScrollViewer
|
|
3386
|
-
enter = false;
|
|
3387
|
-
targetEnter = false;
|
|
3388
|
-
keydown = false;
|
|
3637
|
+
class ScrollViewer extends events.EventEmitter {
|
|
3389
3638
|
container;
|
|
3390
3639
|
target;
|
|
3391
3640
|
zoom = 1;
|
|
3392
3641
|
scrollLeft = 0;
|
|
3393
3642
|
scrollTop = 0;
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
if (targetWidth < width) {
|
|
3404
|
-
this.target._left = 0;
|
|
3405
|
-
}
|
|
3406
|
-
if (targetHeight < height) {
|
|
3407
|
-
this.target._top = 0;
|
|
3408
|
-
}
|
|
3409
|
-
this.scroll();
|
|
3410
|
-
}
|
|
3643
|
+
scrollHeight = 0;
|
|
3644
|
+
scrollWidth = 0;
|
|
3645
|
+
width = 0;
|
|
3646
|
+
height = 0;
|
|
3647
|
+
translateXCorrectionValue = 0;
|
|
3648
|
+
translateYCorrectionValue = 0;
|
|
3649
|
+
resizeObserver = new ResizeObserver(() => {
|
|
3650
|
+
this.setSize();
|
|
3651
|
+
this.setScrollSize();
|
|
3411
3652
|
});
|
|
3412
3653
|
constructor(options) {
|
|
3654
|
+
super();
|
|
3413
3655
|
this.container = options.container;
|
|
3414
3656
|
this.target = options.target;
|
|
3415
3657
|
this.zoom = options.zoom;
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
this.
|
|
3419
|
-
this.container.addEventListener("mouseleave", this.mouseLeaveHandler);
|
|
3420
|
-
this.target.addEventListener("mouseenter", this.targetMouseEnterHandler);
|
|
3421
|
-
this.target.addEventListener("mouseleave", this.targetMouseLeaveHandler);
|
|
3422
|
-
this.container.addEventListener("wheel", this.wheelHandler);
|
|
3658
|
+
this.container.addEventListener("wheel", this.wheelHandler, false);
|
|
3659
|
+
this.setSize();
|
|
3660
|
+
this.setScrollSize();
|
|
3423
3661
|
this.resizeObserver.observe(this.container);
|
|
3424
3662
|
}
|
|
3425
3663
|
destroy() {
|
|
3426
3664
|
this.resizeObserver.disconnect();
|
|
3427
|
-
this.container.removeEventListener("
|
|
3428
|
-
this.
|
|
3429
|
-
this.target.removeEventListener("mouseenter", this.targetMouseEnterHandler);
|
|
3430
|
-
this.target.removeEventListener("mouseleave", this.targetMouseLeaveHandler);
|
|
3431
|
-
globalThis.removeEventListener("keydown", this.keydownHandler);
|
|
3432
|
-
globalThis.removeEventListener("keyup", this.keyupHandler);
|
|
3665
|
+
this.container.removeEventListener("wheel", this.wheelHandler, false);
|
|
3666
|
+
this.removeAllListeners();
|
|
3433
3667
|
}
|
|
3434
3668
|
setZoom(zoom) {
|
|
3435
3669
|
this.zoom = zoom;
|
|
3670
|
+
this.setScrollSize();
|
|
3436
3671
|
}
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
this.
|
|
3445
|
-
|
|
3446
|
-
|
|
3672
|
+
scrollTo({ left, top }) {
|
|
3673
|
+
if (typeof left !== "undefined") {
|
|
3674
|
+
this.scrollLeft = left;
|
|
3675
|
+
}
|
|
3676
|
+
if (typeof top !== "undefined") {
|
|
3677
|
+
this.scrollTop = top;
|
|
3678
|
+
}
|
|
3679
|
+
const translateX = -this.scrollLeft + this.translateXCorrectionValue;
|
|
3680
|
+
const translateY = -this.scrollTop + this.translateYCorrectionValue;
|
|
3681
|
+
this.target.style.transform = `translate(${translateX}px, ${translateY}px)`;
|
|
3447
3682
|
}
|
|
3448
3683
|
wheelHandler = (event) => {
|
|
3449
|
-
if (this.targetEnter)
|
|
3450
|
-
return;
|
|
3451
3684
|
const { deltaX, deltaY, currentTarget } = event;
|
|
3452
3685
|
if (currentTarget !== this.container)
|
|
3453
3686
|
return;
|
|
3454
|
-
|
|
3455
|
-
this.
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
this.
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
this.targetEnter = false;
|
|
3470
|
-
};
|
|
3471
|
-
mousedownHandler = (event) => {
|
|
3472
|
-
if (!this.keydown)
|
|
3473
|
-
return;
|
|
3474
|
-
event.stopImmediatePropagation();
|
|
3475
|
-
event.stopPropagation();
|
|
3476
|
-
this.target.style.cursor = "grabbing";
|
|
3477
|
-
this.x = event.clientX;
|
|
3478
|
-
this.y = event.clientY;
|
|
3479
|
-
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3480
|
-
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3481
|
-
};
|
|
3482
|
-
mouseupHandler = () => {
|
|
3483
|
-
this.x = 0;
|
|
3484
|
-
this.y = 0;
|
|
3485
|
-
this.scrollLeft = this.target._left;
|
|
3486
|
-
this.scrollTop = this.target._top;
|
|
3487
|
-
this.removeHandler();
|
|
3488
|
-
};
|
|
3489
|
-
mousemoveHandler = (event) => {
|
|
3490
|
-
event.stopImmediatePropagation();
|
|
3491
|
-
event.stopPropagation();
|
|
3492
|
-
const deltaX = event.clientX - this.x;
|
|
3493
|
-
const deltaY = event.clientY - this.y;
|
|
3494
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3495
|
-
this.scroll();
|
|
3687
|
+
let top;
|
|
3688
|
+
if (this.scrollHeight > this.height) {
|
|
3689
|
+
top = this.scrollTop + this.getPos(deltaY, this.scrollTop, this.scrollHeight, this.height);
|
|
3690
|
+
}
|
|
3691
|
+
let left;
|
|
3692
|
+
if (this.scrollWidth > this.width) {
|
|
3693
|
+
left = this.scrollLeft + this.getPos(deltaX, this.scrollLeft, this.scrollWidth, this.width);
|
|
3694
|
+
}
|
|
3695
|
+
this.scrollTo({ left, top });
|
|
3696
|
+
this.emit("scroll", {
|
|
3697
|
+
scrollLeft: this.scrollLeft,
|
|
3698
|
+
scrollTop: this.scrollTop,
|
|
3699
|
+
scrollHeight: this.scrollHeight,
|
|
3700
|
+
scrollWidth: this.scrollWidth
|
|
3701
|
+
});
|
|
3496
3702
|
};
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3703
|
+
getPos(delta, scrollPos, scrollSize, size) {
|
|
3704
|
+
let pos = 0;
|
|
3705
|
+
if (delta < 0) {
|
|
3706
|
+
if (scrollPos > 0) {
|
|
3707
|
+
pos = Math.max(delta, -scrollPos);
|
|
3708
|
+
}
|
|
3709
|
+
} else {
|
|
3710
|
+
const leftPos = scrollSize - size - scrollPos;
|
|
3711
|
+
if (leftPos > 0) {
|
|
3712
|
+
pos = Math.min(delta, leftPos);
|
|
3713
|
+
}
|
|
3502
3714
|
}
|
|
3503
|
-
|
|
3504
|
-
|
|
3715
|
+
return pos;
|
|
3716
|
+
}
|
|
3717
|
+
setScrollSize = () => {
|
|
3718
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3719
|
+
this.scrollWidth = targetRect.width * this.zoom + 100;
|
|
3720
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3721
|
+
this.scrollHeight = (targetRect.height + targetMarginTop) * this.zoom + 100;
|
|
3722
|
+
let left;
|
|
3723
|
+
let top;
|
|
3724
|
+
if (this.scrollWidth < this.width) {
|
|
3725
|
+
left = 0;
|
|
3726
|
+
this.translateXCorrectionValue = 0;
|
|
3727
|
+
} else {
|
|
3728
|
+
this.translateXCorrectionValue = (this.scrollWidth - this.width) / 2;
|
|
3505
3729
|
}
|
|
3506
|
-
this.
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3512
|
-
return;
|
|
3730
|
+
if (this.scrollHeight < this.height) {
|
|
3731
|
+
top = 0;
|
|
3732
|
+
this.translateYCorrectionValue = 0;
|
|
3733
|
+
} else {
|
|
3734
|
+
this.translateYCorrectionValue = (this.scrollHeight - this.height) / 2;
|
|
3513
3735
|
}
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3736
|
+
this.scrollTo({
|
|
3737
|
+
left,
|
|
3738
|
+
top
|
|
3739
|
+
});
|
|
3740
|
+
this.emit("scroll", {
|
|
3741
|
+
scrollLeft: this.scrollLeft,
|
|
3742
|
+
scrollTop: this.scrollTop,
|
|
3743
|
+
scrollHeight: this.scrollHeight,
|
|
3744
|
+
scrollWidth: this.scrollWidth
|
|
3745
|
+
});
|
|
3520
3746
|
};
|
|
3521
|
-
|
|
3747
|
+
setSize = () => {
|
|
3522
3748
|
const { width, height } = this.container.getBoundingClientRect();
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3749
|
+
this.width = width;
|
|
3750
|
+
this.height = height;
|
|
3751
|
+
};
|
|
3752
|
+
}
|
|
3753
|
+
|
|
3754
|
+
const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
|
|
3755
|
+
__name: "ScrollBar",
|
|
3756
|
+
props: {
|
|
3757
|
+
size: null,
|
|
3758
|
+
scrollSize: null,
|
|
3759
|
+
isHorizontal: { type: Boolean },
|
|
3760
|
+
pos: null
|
|
3761
|
+
},
|
|
3762
|
+
emits: ["scroll"],
|
|
3763
|
+
setup(__props, { emit }) {
|
|
3764
|
+
const props = __props;
|
|
3765
|
+
const bar = vue.ref();
|
|
3766
|
+
const thumb = vue.ref();
|
|
3767
|
+
const thumbSize = vue.computed(() => props.size * (props.size / props.scrollSize));
|
|
3768
|
+
const thumbPos = vue.computed(() => props.pos / props.scrollSize * props.size);
|
|
3769
|
+
const thumbStyle = vue.computed(() => ({
|
|
3770
|
+
[props.isHorizontal ? "width" : "height"]: `${thumbSize.value}px`,
|
|
3771
|
+
transform: `translate${props.isHorizontal ? "X" : "Y"}(${thumbPos.value}px)`
|
|
3772
|
+
}));
|
|
3773
|
+
let gesto;
|
|
3774
|
+
vue.onMounted(() => {
|
|
3775
|
+
if (!thumb.value)
|
|
3776
|
+
return;
|
|
3777
|
+
const thumbEl = thumb.value;
|
|
3778
|
+
gesto = new Gesto__default.default(thumbEl, {
|
|
3779
|
+
container: window
|
|
3780
|
+
});
|
|
3781
|
+
gesto.on("dragStart", (e) => {
|
|
3782
|
+
e.inputEvent.stopPropagation();
|
|
3783
|
+
e.inputEvent.preventDefault();
|
|
3784
|
+
}).on("drag", (e) => {
|
|
3785
|
+
scrollBy(getDelta(e));
|
|
3786
|
+
});
|
|
3787
|
+
bar.value?.addEventListener("wheel", wheelHandler, false);
|
|
3788
|
+
});
|
|
3789
|
+
vue.onUnmounted(() => {
|
|
3790
|
+
if (gesto)
|
|
3791
|
+
gesto.off();
|
|
3792
|
+
bar.value?.removeEventListener("wheel", wheelHandler, false);
|
|
3793
|
+
});
|
|
3794
|
+
const wheelHandler = (e) => {
|
|
3795
|
+
const delta = props.isHorizontal ? e.deltaX : e.deltaY;
|
|
3796
|
+
if (delta) {
|
|
3797
|
+
e.preventDefault();
|
|
3532
3798
|
}
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3799
|
+
scrollBy(delta);
|
|
3800
|
+
};
|
|
3801
|
+
const getDelta = (e) => {
|
|
3802
|
+
const ratio = (props.isHorizontal ? e.deltaX : e.deltaY) / props.size;
|
|
3803
|
+
return props.scrollSize * ratio;
|
|
3804
|
+
};
|
|
3805
|
+
const scrollBy = (delta) => {
|
|
3806
|
+
if (delta < 0) {
|
|
3807
|
+
if (props.pos <= 0) {
|
|
3808
|
+
emit("scroll", 0);
|
|
3809
|
+
} else {
|
|
3810
|
+
emit("scroll", -Math.min(-delta, props.pos));
|
|
3811
|
+
}
|
|
3538
3812
|
} else {
|
|
3539
|
-
|
|
3813
|
+
const leftPos = props.size - (thumbSize.value + thumbPos.value);
|
|
3814
|
+
if (leftPos <= 0) {
|
|
3815
|
+
emit("scroll", 0);
|
|
3816
|
+
} else {
|
|
3817
|
+
emit("scroll", Math.min(delta, leftPos));
|
|
3818
|
+
}
|
|
3540
3819
|
}
|
|
3541
|
-
}
|
|
3542
|
-
|
|
3543
|
-
|
|
3820
|
+
};
|
|
3821
|
+
return (_ctx, _cache) => {
|
|
3822
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
3823
|
+
ref_key: "bar",
|
|
3824
|
+
ref: bar,
|
|
3825
|
+
class: vue.normalizeClass(["m-editor-scroll-bar", __props.isHorizontal ? "horizontal" : "vertical"])
|
|
3826
|
+
}, [
|
|
3827
|
+
vue.createElementVNode("div", {
|
|
3828
|
+
ref_key: "thumb",
|
|
3829
|
+
ref: thumb,
|
|
3830
|
+
class: "m-editor-scroll-bar-thumb",
|
|
3831
|
+
style: vue.normalizeStyle(vue.unref(thumbStyle))
|
|
3832
|
+
}, null, 4)
|
|
3833
|
+
], 2);
|
|
3834
|
+
};
|
|
3544
3835
|
}
|
|
3545
|
-
}
|
|
3836
|
+
});
|
|
3546
3837
|
|
|
3547
|
-
const
|
|
3548
|
-
|
|
3838
|
+
const ScrollBar_vue_vue_type_style_index_0_lang = '';
|
|
3839
|
+
|
|
3840
|
+
const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
|
|
3841
|
+
__name: "ScrollViewer",
|
|
3549
3842
|
props: {
|
|
3550
|
-
width:
|
|
3551
|
-
height:
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
}
|
|
3843
|
+
width: { default: 0 },
|
|
3844
|
+
height: { default: 0 },
|
|
3845
|
+
wrapWidth: { default: 0 },
|
|
3846
|
+
wrapHeight: { default: 0 },
|
|
3847
|
+
zoom: { default: 1 }
|
|
3556
3848
|
},
|
|
3557
|
-
setup(
|
|
3849
|
+
setup(__props, { expose }) {
|
|
3850
|
+
const props = __props;
|
|
3558
3851
|
const container = vue.ref();
|
|
3559
3852
|
const el = vue.ref();
|
|
3853
|
+
const style = vue.computed(() => `
|
|
3854
|
+
width: ${props.width}px;
|
|
3855
|
+
height: ${props.height}px;
|
|
3856
|
+
position: absolute;
|
|
3857
|
+
margin-top: 30px;
|
|
3858
|
+
`);
|
|
3859
|
+
const scrollWidth = vue.ref(0);
|
|
3860
|
+
const scrollHeight = vue.ref(0);
|
|
3560
3861
|
let scrollViewer;
|
|
3561
3862
|
vue.onMounted(() => {
|
|
3562
3863
|
if (!container.value || !el.value)
|
|
3563
3864
|
return;
|
|
3564
|
-
scrollViewer = new ScrollViewer
|
|
3865
|
+
scrollViewer = new ScrollViewer({
|
|
3565
3866
|
container: container.value,
|
|
3566
3867
|
target: el.value,
|
|
3567
3868
|
zoom: props.zoom
|
|
3568
3869
|
});
|
|
3870
|
+
scrollViewer.on("scroll", (data) => {
|
|
3871
|
+
hOffset.value = data.scrollLeft;
|
|
3872
|
+
vOffset.value = data.scrollTop;
|
|
3873
|
+
scrollWidth.value = data.scrollWidth;
|
|
3874
|
+
scrollHeight.value = data.scrollHeight;
|
|
3875
|
+
});
|
|
3569
3876
|
});
|
|
3570
3877
|
vue.onUnmounted(() => {
|
|
3571
3878
|
scrollViewer.destroy();
|
|
@@ -3573,35 +3880,56 @@
|
|
|
3573
3880
|
vue.watch(() => props.zoom, () => {
|
|
3574
3881
|
scrollViewer.setZoom(props.zoom);
|
|
3575
3882
|
});
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3883
|
+
const vOffset = vue.ref(0);
|
|
3884
|
+
const vScrollHandler = (delta) => {
|
|
3885
|
+
vOffset.value += delta;
|
|
3886
|
+
scrollViewer.scrollTo({
|
|
3887
|
+
top: vOffset.value
|
|
3888
|
+
});
|
|
3889
|
+
};
|
|
3890
|
+
const hOffset = vue.ref(0);
|
|
3891
|
+
const hScrollHandler = (delta) => {
|
|
3892
|
+
hOffset.value += delta;
|
|
3893
|
+
scrollViewer.scrollTo({
|
|
3894
|
+
left: hOffset.value
|
|
3895
|
+
});
|
|
3896
|
+
};
|
|
3897
|
+
expose({
|
|
3898
|
+
container
|
|
3899
|
+
});
|
|
3900
|
+
return (_ctx, _cache) => {
|
|
3901
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
3902
|
+
class: "m-editor-scroll-viewer-container",
|
|
3903
|
+
ref_key: "container",
|
|
3904
|
+
ref: container
|
|
3905
|
+
}, [
|
|
3906
|
+
vue.createElementVNode("div", {
|
|
3907
|
+
ref_key: "el",
|
|
3908
|
+
ref: el,
|
|
3909
|
+
style: vue.normalizeStyle(vue.unref(style))
|
|
3910
|
+
}, [
|
|
3911
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
3912
|
+
], 4),
|
|
3913
|
+
scrollHeight.value > __props.wrapHeight ? (vue.openBlock(), vue.createBlock(_sfc_main$5, {
|
|
3914
|
+
key: 0,
|
|
3915
|
+
"scroll-size": scrollHeight.value,
|
|
3916
|
+
size: __props.wrapHeight,
|
|
3917
|
+
pos: vOffset.value,
|
|
3918
|
+
onScroll: vScrollHandler
|
|
3919
|
+
}, null, 8, ["scroll-size", "size", "pos"])) : vue.createCommentVNode("", true),
|
|
3920
|
+
scrollWidth.value > __props.wrapWidth ? (vue.openBlock(), vue.createBlock(_sfc_main$5, {
|
|
3921
|
+
key: 1,
|
|
3922
|
+
"is-horizontal": true,
|
|
3923
|
+
"scroll-size": scrollWidth.value,
|
|
3924
|
+
pos: hOffset.value,
|
|
3925
|
+
size: __props.wrapWidth,
|
|
3926
|
+
onScroll: hScrollHandler
|
|
3927
|
+
}, null, 8, ["scroll-size", "pos", "size"])) : vue.createCommentVNode("", true)
|
|
3928
|
+
], 512);
|
|
3585
3929
|
};
|
|
3586
3930
|
}
|
|
3587
3931
|
});
|
|
3588
3932
|
|
|
3589
|
-
const _hoisted_1$1 = {
|
|
3590
|
-
class: "m-editor-scroll-viewer-container",
|
|
3591
|
-
ref: "container"
|
|
3592
|
-
};
|
|
3593
|
-
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3594
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
|
|
3595
|
-
vue.createElementVNode("div", {
|
|
3596
|
-
ref: "el",
|
|
3597
|
-
style: vue.normalizeStyle(_ctx.style)
|
|
3598
|
-
}, [
|
|
3599
|
-
vue.renderSlot(_ctx.$slots, "default")
|
|
3600
|
-
], 4)
|
|
3601
|
-
], 512);
|
|
3602
|
-
}
|
|
3603
|
-
const ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$2]]);
|
|
3604
|
-
|
|
3605
3933
|
const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
3606
3934
|
__name: "ViewerMenu",
|
|
3607
3935
|
props: {
|
|
@@ -3623,11 +3951,11 @@
|
|
|
3623
3951
|
{
|
|
3624
3952
|
type: "button",
|
|
3625
3953
|
text: "\u6C34\u5E73\u5C45\u4E2D",
|
|
3626
|
-
display: () => canCenter.value
|
|
3954
|
+
display: () => canCenter.value,
|
|
3627
3955
|
handler: () => {
|
|
3628
|
-
if (!
|
|
3956
|
+
if (!nodes.value)
|
|
3629
3957
|
return;
|
|
3630
|
-
editorService?.alignCenter(
|
|
3958
|
+
editorService?.alignCenter(nodes.value);
|
|
3631
3959
|
}
|
|
3632
3960
|
},
|
|
3633
3961
|
{
|
|
@@ -3723,10 +4051,6 @@
|
|
|
3723
4051
|
},
|
|
3724
4052
|
...stageContentMenu
|
|
3725
4053
|
]);
|
|
3726
|
-
vue.onMounted(async () => {
|
|
3727
|
-
const data = await storageService.getItem(COPY_STORAGE_KEY);
|
|
3728
|
-
canPaste.value = data !== "undefined" && !!data;
|
|
3729
|
-
});
|
|
3730
4054
|
vue.watch(parent, async () => {
|
|
3731
4055
|
if (!parent.value || !editorService)
|
|
3732
4056
|
return canCenter.value = false;
|
|
@@ -3735,12 +4059,14 @@
|
|
|
3735
4059
|
const isTypeConform = nodes.value?.every((selectedNode) => ![schema.NodeType.ROOT, schema.NodeType.PAGE, "pop"].includes(`${selectedNode?.type}`));
|
|
3736
4060
|
canCenter.value = isLayoutConform && !!isTypeConform;
|
|
3737
4061
|
}, { immediate: true });
|
|
3738
|
-
const show = (e) => {
|
|
4062
|
+
const show = async (e) => {
|
|
3739
4063
|
menu.value?.show(e);
|
|
4064
|
+
const data = await storageService.getItem(COPY_STORAGE_KEY);
|
|
4065
|
+
canPaste.value = data !== "undefined" && !!data;
|
|
3740
4066
|
};
|
|
3741
4067
|
expose({ show });
|
|
3742
4068
|
return (_ctx, _cache) => {
|
|
3743
|
-
return vue.openBlock(), vue.createBlock(_sfc_main$
|
|
4069
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$c, {
|
|
3744
4070
|
"menu-data": menuData,
|
|
3745
4071
|
ref_key: "menu",
|
|
3746
4072
|
ref: menu
|
|
@@ -3761,12 +4087,11 @@
|
|
|
3761
4087
|
const menu = vue.ref();
|
|
3762
4088
|
const isMultiSelect = vue.computed(() => services?.editorService.get("nodes")?.length > 1);
|
|
3763
4089
|
const stageRect = vue.computed(() => services?.uiService.get("stageRect"));
|
|
3764
|
-
const
|
|
4090
|
+
const stageContainerRect = vue.computed(() => services?.uiService.get("stageContainerRect"));
|
|
3765
4091
|
const root = vue.computed(() => services?.editorService.get("root"));
|
|
3766
4092
|
const page = vue.computed(() => services?.editorService.get("page"));
|
|
3767
4093
|
const zoom = vue.computed(() => services?.uiService.get("zoom") || 1);
|
|
3768
4094
|
const node = vue.computed(() => services?.editorService.get("node"));
|
|
3769
|
-
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
3770
4095
|
vue.watchEffect(() => {
|
|
3771
4096
|
if (stage)
|
|
3772
4097
|
return;
|
|
@@ -3774,61 +4099,9 @@
|
|
|
3774
4099
|
return;
|
|
3775
4100
|
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
|
|
3776
4101
|
return;
|
|
3777
|
-
stage =
|
|
3778
|
-
render: stageOptions.render,
|
|
3779
|
-
runtimeUrl: stageOptions.runtimeUrl,
|
|
3780
|
-
zoom: zoom.value,
|
|
3781
|
-
autoScrollIntoView: stageOptions.autoScrollIntoView,
|
|
3782
|
-
isContainer: stageOptions.isContainer,
|
|
3783
|
-
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
3784
|
-
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
3785
|
-
canSelect: (el, event, stop) => {
|
|
3786
|
-
const elCanSelect = stageOptions.canSelect(el);
|
|
3787
|
-
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
3788
|
-
document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
|
|
3789
|
-
return stop();
|
|
3790
|
-
}
|
|
3791
|
-
return elCanSelect;
|
|
3792
|
-
},
|
|
3793
|
-
moveableOptions: stageOptions.moveableOptions,
|
|
3794
|
-
updateDragEl: stageOptions.updateDragEl
|
|
3795
|
-
});
|
|
4102
|
+
stage = useStage(stageOptions);
|
|
3796
4103
|
services?.editorService.set("stage", vue.markRaw(stage));
|
|
3797
4104
|
stage?.mount(stageContainer.value);
|
|
3798
|
-
stage.mask.setGuides([
|
|
3799
|
-
getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
|
|
3800
|
-
getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
|
|
3801
|
-
]);
|
|
3802
|
-
stage?.on("select", (el) => {
|
|
3803
|
-
services?.editorService.select(el.id);
|
|
3804
|
-
});
|
|
3805
|
-
stage?.on("highlight", (el) => {
|
|
3806
|
-
services?.editorService.highlight(el.id);
|
|
3807
|
-
});
|
|
3808
|
-
stage?.on("multiSelect", (els) => {
|
|
3809
|
-
services?.editorService.multiSelect(els.map((el) => el.id));
|
|
3810
|
-
});
|
|
3811
|
-
stage?.on("update", (ev) => {
|
|
3812
|
-
if (ev.parentEl) {
|
|
3813
|
-
services?.editorService.moveToContainer({ id: ev.el.id, style: ev.style }, ev.parentEl.id);
|
|
3814
|
-
return;
|
|
3815
|
-
}
|
|
3816
|
-
services?.editorService.update({ id: ev.el.id, style: ev.style });
|
|
3817
|
-
});
|
|
3818
|
-
stage?.on("sort", (ev) => {
|
|
3819
|
-
services?.editorService.sort(ev.src, ev.dist);
|
|
3820
|
-
});
|
|
3821
|
-
stage?.on("changeGuides", (e2) => {
|
|
3822
|
-
services?.uiService.set("showGuides", true);
|
|
3823
|
-
if (!root.value || !page.value)
|
|
3824
|
-
return;
|
|
3825
|
-
const storageKey = getGuideLineKey(e2.type === StageCore.GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY);
|
|
3826
|
-
if (e2.guides.length) {
|
|
3827
|
-
globalThis.localStorage.setItem(storageKey, JSON.stringify(e2.guides));
|
|
3828
|
-
} else {
|
|
3829
|
-
globalThis.localStorage.removeItem(storageKey);
|
|
3830
|
-
}
|
|
3831
|
-
});
|
|
3832
4105
|
if (!node.value?.id)
|
|
3833
4106
|
return;
|
|
3834
4107
|
stage?.on("runtime-ready", (rt) => {
|
|
@@ -3914,12 +4187,14 @@
|
|
|
3914
4187
|
}
|
|
3915
4188
|
};
|
|
3916
4189
|
return (_ctx, _cache) => {
|
|
3917
|
-
return vue.openBlock(), vue.createBlock(
|
|
4190
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$4, {
|
|
3918
4191
|
class: "m-editor-stage",
|
|
3919
4192
|
ref_key: "stageWrap",
|
|
3920
4193
|
ref: stageWrap,
|
|
3921
4194
|
width: vue.unref(stageRect)?.width,
|
|
3922
4195
|
height: vue.unref(stageRect)?.height,
|
|
4196
|
+
"wrap-width": vue.unref(stageContainerRect)?.width,
|
|
4197
|
+
"wrap-height": vue.unref(stageContainerRect)?.height,
|
|
3923
4198
|
zoom: vue.unref(zoom)
|
|
3924
4199
|
}, {
|
|
3925
4200
|
default: vue.withCtx(() => [
|
|
@@ -3927,7 +4202,7 @@
|
|
|
3927
4202
|
class: "m-editor-stage-container",
|
|
3928
4203
|
ref_key: "stageContainer",
|
|
3929
4204
|
ref: stageContainer,
|
|
3930
|
-
style: vue.normalizeStyle(`transform: scale(${vue.unref(zoom)})
|
|
4205
|
+
style: vue.normalizeStyle(`transform: scale(${vue.unref(zoom)});`),
|
|
3931
4206
|
onContextmenu: contextmenuHandler,
|
|
3932
4207
|
onDrop: dropHandler,
|
|
3933
4208
|
onDragover: dragoverHandler
|
|
@@ -3941,28 +4216,25 @@
|
|
|
3941
4216
|
]))
|
|
3942
4217
|
]),
|
|
3943
4218
|
_: 1
|
|
3944
|
-
}, 8, ["width", "height", "zoom"]);
|
|
4219
|
+
}, 8, ["width", "height", "wrap-width", "wrap-height", "zoom"]);
|
|
3945
4220
|
};
|
|
3946
4221
|
}
|
|
3947
4222
|
});
|
|
3948
4223
|
|
|
3949
|
-
const _sfc_main$1 = vue.defineComponent({
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
PageBar: _sfc_main$5,
|
|
3953
|
-
MagicStage: _sfc_main$2
|
|
3954
|
-
},
|
|
3955
|
-
setup() {
|
|
4224
|
+
const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
4225
|
+
__name: "Workspace",
|
|
4226
|
+
setup(__props) {
|
|
3956
4227
|
const services = vue.inject("services");
|
|
3957
4228
|
const workspace = vue.ref();
|
|
3958
4229
|
const nodes = vue.computed(() => services?.editorService.get("nodes"));
|
|
3959
|
-
|
|
4230
|
+
const page = vue.computed(() => services?.editorService.get("page"));
|
|
3960
4231
|
const mouseenterHandler = () => {
|
|
3961
4232
|
workspace.value?.focus();
|
|
3962
4233
|
};
|
|
3963
4234
|
const mouseleaveHandler = () => {
|
|
3964
4235
|
workspace.value?.blur();
|
|
3965
4236
|
};
|
|
4237
|
+
let keycon;
|
|
3966
4238
|
vue.onMounted(() => {
|
|
3967
4239
|
workspace.value?.addEventListener("mouseenter", mouseenterHandler);
|
|
3968
4240
|
workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
|
|
@@ -3984,7 +4256,7 @@
|
|
|
3984
4256
|
nodes.value && services?.editorService.copy(nodes.value);
|
|
3985
4257
|
}).keydown([ctrl, "v"], (e) => {
|
|
3986
4258
|
e.inputEvent.preventDefault();
|
|
3987
|
-
nodes.value && services?.editorService.paste();
|
|
4259
|
+
nodes.value && services?.editorService.paste({ offsetX: 10, offsetY: 10 });
|
|
3988
4260
|
}).keydown([ctrl, "x"], (e) => {
|
|
3989
4261
|
e.inputEvent.preventDefault();
|
|
3990
4262
|
if (!nodes.value || utils.isPage(nodes.value[0]))
|
|
@@ -4039,6 +4311,12 @@
|
|
|
4039
4311
|
}).keydown([ctrl, "numpad-"], (e) => {
|
|
4040
4312
|
e.inputEvent.preventDefault();
|
|
4041
4313
|
services?.uiService.zoom(-0.1);
|
|
4314
|
+
}).keydown([ctrl, "0"], (e) => {
|
|
4315
|
+
e.inputEvent.preventDefault();
|
|
4316
|
+
services?.uiService.set("zoom", services.uiService.calcZoom());
|
|
4317
|
+
}).keydown([ctrl, "1"], (e) => {
|
|
4318
|
+
e.inputEvent.preventDefault();
|
|
4319
|
+
services?.uiService.set("zoom", 1);
|
|
4042
4320
|
});
|
|
4043
4321
|
});
|
|
4044
4322
|
vue.onUnmounted(() => {
|
|
@@ -4046,39 +4324,33 @@
|
|
|
4046
4324
|
workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
|
|
4047
4325
|
keycon.destroy();
|
|
4048
4326
|
});
|
|
4049
|
-
return {
|
|
4050
|
-
|
|
4051
|
-
|
|
4327
|
+
return (_ctx, _cache) => {
|
|
4328
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
4329
|
+
class: "m-editor-workspace",
|
|
4330
|
+
tabindex: "1",
|
|
4331
|
+
ref_key: "workspace",
|
|
4332
|
+
ref: workspace
|
|
4333
|
+
}, [
|
|
4334
|
+
vue.renderSlot(_ctx.$slots, "stage", {}, () => [
|
|
4335
|
+
(vue.openBlock(), vue.createBlock(_sfc_main$2, {
|
|
4336
|
+
key: vue.unref(page)?.id
|
|
4337
|
+
}))
|
|
4338
|
+
]),
|
|
4339
|
+
vue.renderSlot(_ctx.$slots, "workspace-content"),
|
|
4340
|
+
vue.createVNode(_sfc_main$6, null, {
|
|
4341
|
+
"page-bar-title": vue.withCtx(({ page: page2 }) => [
|
|
4342
|
+
vue.renderSlot(_ctx.$slots, "page-bar-title", { page: page2 })
|
|
4343
|
+
]),
|
|
4344
|
+
"page-bar-popover": vue.withCtx(({ page: page2 }) => [
|
|
4345
|
+
vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: page2 })
|
|
4346
|
+
]),
|
|
4347
|
+
_: 3
|
|
4348
|
+
})
|
|
4349
|
+
], 512);
|
|
4052
4350
|
};
|
|
4053
4351
|
}
|
|
4054
4352
|
});
|
|
4055
4353
|
|
|
4056
|
-
const _hoisted_1 = {
|
|
4057
|
-
class: "m-editor-workspace",
|
|
4058
|
-
tabindex: "1",
|
|
4059
|
-
ref: "workspace"
|
|
4060
|
-
};
|
|
4061
|
-
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4062
|
-
const _component_magic_stage = vue.resolveComponent("magic-stage");
|
|
4063
|
-
const _component_page_bar = vue.resolveComponent("page-bar");
|
|
4064
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
|
|
4065
|
-
(vue.openBlock(), vue.createBlock(_component_magic_stage, {
|
|
4066
|
-
key: _ctx.page?.id
|
|
4067
|
-
})),
|
|
4068
|
-
vue.renderSlot(_ctx.$slots, "workspace-content"),
|
|
4069
|
-
vue.createVNode(_component_page_bar, null, {
|
|
4070
|
-
"page-bar-title": vue.withCtx(({ page }) => [
|
|
4071
|
-
vue.renderSlot(_ctx.$slots, "page-bar-title", { page })
|
|
4072
|
-
]),
|
|
4073
|
-
"page-bar-popover": vue.withCtx(({ page }) => [
|
|
4074
|
-
vue.renderSlot(_ctx.$slots, "page-bar-popover", { page })
|
|
4075
|
-
]),
|
|
4076
|
-
_: 3
|
|
4077
|
-
})
|
|
4078
|
-
], 512);
|
|
4079
|
-
}
|
|
4080
|
-
const Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
4081
|
-
|
|
4082
4354
|
class ComponentList extends BaseService {
|
|
4083
4355
|
state = vue.reactive({
|
|
4084
4356
|
list: []
|
|
@@ -4092,136 +4364,20 @@
|
|
|
4092
4364
|
getList() {
|
|
4093
4365
|
return this.state.list;
|
|
4094
4366
|
}
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
4099
|
-
const MIN_LEFT_COLUMN_WIDTH = 45;
|
|
4100
|
-
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
4101
|
-
const MIN_RIGHT_COLUMN_WIDTH = 1;
|
|
4102
|
-
const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
|
|
4103
|
-
const defaultColumnWidth = {
|
|
4104
|
-
left: DEFAULT_LEFT_COLUMN_WIDTH,
|
|
4105
|
-
center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
|
|
4106
|
-
right: DEFAULT_RIGHT_COLUMN_WIDTH
|
|
4107
|
-
};
|
|
4108
|
-
const state = vue.reactive({
|
|
4109
|
-
uiSelectMode: false,
|
|
4110
|
-
showSrc: false,
|
|
4111
|
-
zoom: 1,
|
|
4112
|
-
stageContainerRect: {
|
|
4113
|
-
width: 0,
|
|
4114
|
-
height: 0
|
|
4115
|
-
},
|
|
4116
|
-
stageRect: {
|
|
4117
|
-
width: 375,
|
|
4118
|
-
height: 817
|
|
4119
|
-
},
|
|
4120
|
-
columnWidth: defaultColumnWidth,
|
|
4121
|
-
showGuides: true,
|
|
4122
|
-
showRule: true,
|
|
4123
|
-
propsPanelSize: "small"
|
|
4124
|
-
});
|
|
4125
|
-
class Ui extends BaseService {
|
|
4126
|
-
constructor() {
|
|
4127
|
-
super([]);
|
|
4128
|
-
globalThis.addEventListener("resize", () => {
|
|
4129
|
-
this.setColumnWidth({
|
|
4130
|
-
center: "auto"
|
|
4131
|
-
});
|
|
4132
|
-
});
|
|
4133
|
-
const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
|
|
4134
|
-
if (columnWidthCacheData) {
|
|
4135
|
-
try {
|
|
4136
|
-
const columnWidthCache = JSON.parse(columnWidthCacheData);
|
|
4137
|
-
this.setColumnWidth(columnWidthCache);
|
|
4138
|
-
} catch (e) {
|
|
4139
|
-
console.error(e);
|
|
4140
|
-
}
|
|
4141
|
-
}
|
|
4142
|
-
}
|
|
4143
|
-
set(name, value) {
|
|
4144
|
-
const mask = editorService.get("stage")?.mask;
|
|
4145
|
-
if (name === "columnWidth") {
|
|
4146
|
-
this.setColumnWidth(value);
|
|
4147
|
-
return;
|
|
4148
|
-
}
|
|
4149
|
-
if (name === "stageRect") {
|
|
4150
|
-
this.setStageRect(value);
|
|
4151
|
-
return;
|
|
4152
|
-
}
|
|
4153
|
-
if (name === "showGuides") {
|
|
4154
|
-
mask?.showGuides(value);
|
|
4155
|
-
}
|
|
4156
|
-
if (name === "showRule") {
|
|
4157
|
-
mask?.showRule(value);
|
|
4158
|
-
}
|
|
4159
|
-
state[name] = value;
|
|
4160
|
-
if (name === "stageContainerRect") {
|
|
4161
|
-
state.zoom = this.calcZoom();
|
|
4162
|
-
}
|
|
4163
|
-
}
|
|
4164
|
-
get(name) {
|
|
4165
|
-
return state[name];
|
|
4166
|
-
}
|
|
4167
|
-
zoom(zoom) {
|
|
4168
|
-
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
4169
|
-
if (this.get("zoom") < 0.1)
|
|
4170
|
-
this.set("zoom", 0.1);
|
|
4171
|
-
}
|
|
4172
|
-
setColumnWidth({ left, center, right }) {
|
|
4173
|
-
const columnWidth = {
|
|
4174
|
-
...vue.toRaw(this.get("columnWidth"))
|
|
4175
|
-
};
|
|
4176
|
-
if (left) {
|
|
4177
|
-
columnWidth.left = Math.max(left, MIN_LEFT_COLUMN_WIDTH);
|
|
4178
|
-
}
|
|
4179
|
-
if (right) {
|
|
4180
|
-
columnWidth.right = Math.max(right, MIN_RIGHT_COLUMN_WIDTH);
|
|
4181
|
-
}
|
|
4182
|
-
if (!center || center === "auto") {
|
|
4183
|
-
const bodyWidth = globalThis.document.body.clientWidth;
|
|
4184
|
-
columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
|
|
4185
|
-
if (columnWidth.center <= 0) {
|
|
4186
|
-
columnWidth.left = defaultColumnWidth.left;
|
|
4187
|
-
columnWidth.center = defaultColumnWidth.center;
|
|
4188
|
-
columnWidth.right = defaultColumnWidth.right;
|
|
4189
|
-
}
|
|
4190
|
-
} else {
|
|
4191
|
-
columnWidth.center = center;
|
|
4192
|
-
}
|
|
4193
|
-
globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
|
|
4194
|
-
state.columnWidth = columnWidth;
|
|
4195
|
-
}
|
|
4196
|
-
setStageRect(value) {
|
|
4197
|
-
state.stageRect = {
|
|
4198
|
-
...state.stageRect,
|
|
4199
|
-
...value
|
|
4200
|
-
};
|
|
4201
|
-
state.zoom = this.calcZoom();
|
|
4202
|
-
}
|
|
4203
|
-
calcZoom() {
|
|
4204
|
-
const { stageRect, stageContainerRect } = state;
|
|
4205
|
-
const { height, width } = stageContainerRect;
|
|
4206
|
-
if (!width || !height)
|
|
4207
|
-
return 1;
|
|
4208
|
-
const stageWidth = stageRect.width + 30;
|
|
4209
|
-
const stageHeight = stageRect.height + 30;
|
|
4210
|
-
if (width > stageWidth && height > stageHeight) {
|
|
4211
|
-
return 1;
|
|
4212
|
-
}
|
|
4213
|
-
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
4367
|
+
destroy() {
|
|
4368
|
+
this.state.list = [];
|
|
4369
|
+
this.removeAllListeners();
|
|
4214
4370
|
}
|
|
4215
4371
|
}
|
|
4216
|
-
const
|
|
4372
|
+
const componentListService = new ComponentList();
|
|
4217
4373
|
|
|
4218
4374
|
const _sfc_main = vue.defineComponent({
|
|
4219
4375
|
name: "m-editor",
|
|
4220
4376
|
components: {
|
|
4221
|
-
NavMenu,
|
|
4377
|
+
NavMenu: _sfc_main$f,
|
|
4222
4378
|
Sidebar,
|
|
4223
|
-
Workspace,
|
|
4224
|
-
PropsPanel,
|
|
4379
|
+
Workspace: _sfc_main$1,
|
|
4380
|
+
PropsPanel: _sfc_main$e,
|
|
4225
4381
|
Framework
|
|
4226
4382
|
},
|
|
4227
4383
|
props: {
|
|
@@ -4288,6 +4444,10 @@
|
|
|
4288
4444
|
type: Number,
|
|
4289
4445
|
default: 800
|
|
4290
4446
|
},
|
|
4447
|
+
containerHighlightType: {
|
|
4448
|
+
type: String,
|
|
4449
|
+
default: StageCore.ContainerHighlightType.DEFAULT
|
|
4450
|
+
},
|
|
4291
4451
|
stageRect: {
|
|
4292
4452
|
type: [String, Object]
|
|
4293
4453
|
},
|
|
@@ -4336,7 +4496,15 @@
|
|
|
4336
4496
|
vue.watch(() => props.stageRect, (stageRect) => stageRect && uiService.set("stageRect", stageRect), {
|
|
4337
4497
|
immediate: true
|
|
4338
4498
|
});
|
|
4339
|
-
|
|
4499
|
+
uiService.initColumnWidth();
|
|
4500
|
+
vue.onUnmounted(() => {
|
|
4501
|
+
editorService.destroy();
|
|
4502
|
+
historyService.destroy();
|
|
4503
|
+
propsService.destroy();
|
|
4504
|
+
uiService.destroy();
|
|
4505
|
+
componentListService.destroy();
|
|
4506
|
+
storageService.destroy();
|
|
4507
|
+
});
|
|
4340
4508
|
const services = {
|
|
4341
4509
|
componentListService,
|
|
4342
4510
|
eventsService,
|
|
@@ -4358,7 +4526,8 @@
|
|
|
4358
4526
|
updateDragEl: props.updateDragEl,
|
|
4359
4527
|
isContainer: props.isContainer,
|
|
4360
4528
|
containerHighlightClassName: props.containerHighlightClassName,
|
|
4361
|
-
containerHighlightDuration: props.containerHighlightDuration
|
|
4529
|
+
containerHighlightDuration: props.containerHighlightDuration,
|
|
4530
|
+
containerHighlightType: props.containerHighlightType
|
|
4362
4531
|
}));
|
|
4363
4532
|
return services;
|
|
4364
4533
|
}
|
|
@@ -4392,6 +4561,9 @@
|
|
|
4392
4561
|
workspace: vue.withCtx(() => [
|
|
4393
4562
|
vue.renderSlot(_ctx.$slots, "workspace", { editorService: _ctx.editorService }, () => [
|
|
4394
4563
|
vue.createVNode(_component_workspace, null, {
|
|
4564
|
+
stage: vue.withCtx(() => [
|
|
4565
|
+
vue.renderSlot(_ctx.$slots, "stage")
|
|
4566
|
+
]),
|
|
4395
4567
|
"workspace-content": vue.withCtx(() => [
|
|
4396
4568
|
vue.renderSlot(_ctx.$slots, "workspace-content", { editorService: _ctx.editorService })
|
|
4397
4569
|
]),
|
|
@@ -4408,14 +4580,13 @@
|
|
|
4408
4580
|
"props-panel": vue.withCtx(() => [
|
|
4409
4581
|
vue.renderSlot(_ctx.$slots, "props-panel", {}, () => [
|
|
4410
4582
|
vue.createVNode(_component_props_panel, {
|
|
4411
|
-
ref: "propsPanel",
|
|
4412
4583
|
onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance))
|
|
4413
4584
|
}, {
|
|
4414
4585
|
"props-panel-header": vue.withCtx(() => [
|
|
4415
4586
|
vue.renderSlot(_ctx.$slots, "props-panel-header")
|
|
4416
4587
|
]),
|
|
4417
4588
|
_: 3
|
|
4418
|
-
}
|
|
4589
|
+
})
|
|
4419
4590
|
])
|
|
4420
4591
|
]),
|
|
4421
4592
|
empty: vue.withCtx(() => [
|
|
@@ -4435,7 +4606,7 @@
|
|
|
4435
4606
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
4436
4607
|
setConfig(option);
|
|
4437
4608
|
app.component(Editor.name, Editor);
|
|
4438
|
-
app.component("m-fields-ui-select", _sfc_main$
|
|
4609
|
+
app.component("m-fields-ui-select", _sfc_main$m);
|
|
4439
4610
|
app.component(CodeLink.name, CodeLink);
|
|
4440
4611
|
app.component(Code.name, Code);
|
|
4441
4612
|
app.component(CodeEditor.name, CodeEditor);
|
|
@@ -4443,18 +4614,20 @@
|
|
|
4443
4614
|
};
|
|
4444
4615
|
|
|
4445
4616
|
exports.COPY_STORAGE_KEY = COPY_STORAGE_KEY;
|
|
4617
|
+
exports.ColumnLayout = ColumnLayout;
|
|
4446
4618
|
exports.ComponentListPanel = ComponentListPanel;
|
|
4447
|
-
exports.
|
|
4619
|
+
exports.ContentMenu = _sfc_main$c;
|
|
4448
4620
|
exports.Fixed2Other = Fixed2Other;
|
|
4449
4621
|
exports.H_GUIDE_LINE_STORAGE_KEY = H_GUIDE_LINE_STORAGE_KEY;
|
|
4622
|
+
exports.Icon = _sfc_main$h;
|
|
4450
4623
|
exports.Keys = Keys;
|
|
4451
4624
|
exports.LayerOffset = LayerOffset;
|
|
4452
4625
|
exports.LayerPanel = LayerPanel;
|
|
4453
4626
|
exports.Layout = Layout;
|
|
4454
|
-
exports.PropsPanel =
|
|
4627
|
+
exports.PropsPanel = _sfc_main$e;
|
|
4455
4628
|
exports.TMagicCodeEditor = CodeEditor;
|
|
4456
4629
|
exports.TMagicEditor = Editor;
|
|
4457
|
-
exports.ToolButton = _sfc_main$
|
|
4630
|
+
exports.ToolButton = _sfc_main$g;
|
|
4458
4631
|
exports.V_GUIDE_LINE_STORAGE_KEY = V_GUIDE_LINE_STORAGE_KEY;
|
|
4459
4632
|
exports.change2Fixed = change2Fixed;
|
|
4460
4633
|
exports.debug = debug;
|
|
@@ -4464,6 +4637,7 @@
|
|
|
4464
4637
|
exports.eventsService = eventsService;
|
|
4465
4638
|
exports.fillConfig = fillConfig;
|
|
4466
4639
|
exports.fixNodeLeft = fixNodeLeft;
|
|
4640
|
+
exports.fixNodePosition = fixNodePosition;
|
|
4467
4641
|
exports.generatePageName = generatePageName;
|
|
4468
4642
|
exports.generatePageNameByApp = generatePageNameByApp;
|
|
4469
4643
|
exports.getConfig = getConfig;
|
|
@@ -4482,6 +4656,7 @@
|
|
|
4482
4656
|
exports.setLayout = setLayout;
|
|
4483
4657
|
exports.storageService = storageService;
|
|
4484
4658
|
exports.uiService = uiService;
|
|
4659
|
+
exports.useStage = useStage;
|
|
4485
4660
|
exports.warn = warn;
|
|
4486
4661
|
|
|
4487
4662
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|