@tmagic/editor 1.1.0-beta.9 → 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 +46 -0
- package/dist/tmagic-editor.mjs +971 -794
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +974 -794
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +10 -10
- package/src/Editor.vue +15 -5
- package/src/components/ContentMenu.vue +4 -4
- package/src/components/Icon.vue +6 -20
- 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 -90
- package/src/layouts/workspace/ViewerMenu.vue +3 -3
- package/src/layouts/workspace/Workspace.vue +133 -138
- package/src/services/componentList.ts +5 -0
- package/src/services/editor.ts +56 -19
- 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/nav-menu.scss +6 -0
- package/src/type.ts +26 -10
- package/src/utils/index.ts +1 -0
- package/src/utils/operator.ts +3 -3
- package/src/utils/props.ts +0 -3
- package/src/utils/scroll-viewer.ts +90 -158
- package/src/utils/stage.ts +91 -0
- package/types/Editor.vue.d.ts +7 -7
- package/types/components/ContentMenu.vue.d.ts +8 -8
- package/types/components/Icon.vue.d.ts +62 -12
- package/types/components/ScrollBar.vue.d.ts +83 -0
- package/types/components/ScrollViewer.vue.d.ts +131 -19
- package/types/components/ToolButton.vue.d.ts +56 -59
- package/types/index.d.ts +2 -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/Workspace.vue.d.ts +54 -4
- package/types/services/componentList.d.ts +1 -0
- package/types/services/editor.d.ts +1 -0
- package/types/services/events.d.ts +1 -0
- package/types/services/props.d.ts +41 -9
- package/types/services/storage.d.ts +1 -0
- package/types/services/ui.d.ts +3 -1
- package/types/type.d.ts +23 -10
- package/types/utils/index.d.ts +1 -0
- package/types/utils/operator.d.ts +1 -1
- package/types/utils/props.d.ts +0 -1
- package/types/utils/scroll-viewer.d.ts +16 -18
- package/types/utils/stage.d.ts +3 -0
package/dist/tmagic-editor.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, createElementBlock, createVNode, unref, withCtx, withModifiers, createCommentVNode, createTextVNode, toDisplayString, watch, onMounted, onUnmounted, reactive, toRaw, createElementVNode, renderSlot, Fragment, normalizeClass, resolveDynamicComponent,
|
|
1
|
+
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, createElementBlock, createVNode, unref, withCtx, withModifiers, createCommentVNode, createTextVNode, toDisplayString, watch, onMounted, onUnmounted, reactive, toRaw, createElementVNode, renderSlot, Fragment, normalizeClass, resolveDynamicComponent, renderList, normalizeProps, mergeProps, markRaw, getCurrentInstance, Teleport, nextTick, toHandlers, createSlots, provide } from 'vue';
|
|
2
2
|
import serialize from 'serialize-javascript';
|
|
3
|
-
import { Delete, Close, Plus, Edit, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back,
|
|
3
|
+
import { Delete, Close, Plus, Edit, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Files, DocumentCopy, Coin, ArrowLeftBold, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons-vue';
|
|
4
4
|
import { throttle, cloneDeep, mergeWith, isEmpty, uniq } from 'lodash-es';
|
|
5
5
|
import * as monaco from 'monaco-editor';
|
|
6
6
|
import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS, ContainerHighlightType } from '@tmagic/stage';
|
|
@@ -19,7 +19,7 @@ if (typeof globalThis === "undefined") {
|
|
|
19
19
|
window.globalThis = window;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const _sfc_main$
|
|
22
|
+
const _sfc_main$o = defineComponent({
|
|
23
23
|
name: "m-fields-vs-code",
|
|
24
24
|
props: ["model", "name", "config", "prop"],
|
|
25
25
|
emits: ["change"],
|
|
@@ -45,7 +45,7 @@ const _export_sfc = (sfc, props) => {
|
|
|
45
45
|
return target;
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
function _sfc_render$
|
|
48
|
+
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
49
49
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
50
50
|
return openBlock(), createBlock(_component_magic_code_editor, {
|
|
51
51
|
style: normalizeStyle(`height: ${_ctx.height}`),
|
|
@@ -54,9 +54,9 @@ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
54
54
|
onSave: _ctx.save
|
|
55
55
|
}, null, 8, ["style", "init-values", "language", "onSave"]);
|
|
56
56
|
}
|
|
57
|
-
const Code = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
57
|
+
const Code = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["render", _sfc_render$b]]);
|
|
58
58
|
|
|
59
|
-
const _sfc_main$
|
|
59
|
+
const _sfc_main$n = defineComponent({
|
|
60
60
|
name: "m-fields-code-link",
|
|
61
61
|
props: {
|
|
62
62
|
config: {
|
|
@@ -112,7 +112,7 @@ const _sfc_main$m = defineComponent({
|
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
-
function _sfc_render$
|
|
115
|
+
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
116
116
|
const _component_m_fields_link = resolveComponent("m-fields-link");
|
|
117
117
|
return openBlock(), createBlock(_component_m_fields_link, {
|
|
118
118
|
config: _ctx.formConfig,
|
|
@@ -121,10 +121,10 @@ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
121
121
|
onChange: _ctx.changeHandler
|
|
122
122
|
}, null, 8, ["config", "model", "onChange"]);
|
|
123
123
|
}
|
|
124
|
-
const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
124
|
+
const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$a]]);
|
|
125
125
|
|
|
126
|
-
const _hoisted_1$
|
|
127
|
-
const _sfc_main$
|
|
126
|
+
const _hoisted_1$b = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
|
|
127
|
+
const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
128
128
|
__name: "UISelect",
|
|
129
129
|
props: {
|
|
130
130
|
config: null,
|
|
@@ -189,7 +189,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
|
189
189
|
style: { "padding": "0" }
|
|
190
190
|
}, {
|
|
191
191
|
default: withCtx(() => [
|
|
192
|
-
_hoisted_1$
|
|
192
|
+
_hoisted_1$b
|
|
193
193
|
]),
|
|
194
194
|
_: 1
|
|
195
195
|
}, 8, ["icon"])
|
|
@@ -199,19 +199,21 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
|
199
199
|
onClick: startSelect,
|
|
200
200
|
style: { "display": "flex" }
|
|
201
201
|
}, [
|
|
202
|
-
|
|
202
|
+
unref(val) ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
203
|
+
key: 0,
|
|
204
|
+
content: "\u6E05\u9664"
|
|
205
|
+
}, {
|
|
203
206
|
default: withCtx(() => [
|
|
204
|
-
|
|
205
|
-
key: 0,
|
|
207
|
+
createVNode(_component_el_button, {
|
|
206
208
|
style: { "padding": "0" },
|
|
207
209
|
type: "danger",
|
|
208
210
|
icon: unref(Close),
|
|
209
211
|
text: "",
|
|
210
212
|
onClick: withModifiers(deleteHandler, ["stop"])
|
|
211
|
-
}, null, 8, ["icon", "onClick"])
|
|
213
|
+
}, null, 8, ["icon", "onClick"])
|
|
212
214
|
]),
|
|
213
215
|
_: 1
|
|
214
|
-
}),
|
|
216
|
+
})) : createCommentVNode("", true),
|
|
215
217
|
createVNode(_component_el_tooltip, {
|
|
216
218
|
content: unref(val) ? unref(toName) + "_" + unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
|
|
217
219
|
}, {
|
|
@@ -250,7 +252,7 @@ const toString = (v, language) => {
|
|
|
250
252
|
}
|
|
251
253
|
return value;
|
|
252
254
|
};
|
|
253
|
-
const _sfc_main$
|
|
255
|
+
const _sfc_main$l = defineComponent({
|
|
254
256
|
name: "magic-code-editor",
|
|
255
257
|
props: {
|
|
256
258
|
initValues: {
|
|
@@ -358,14 +360,14 @@ const _sfc_main$k = defineComponent({
|
|
|
358
360
|
}
|
|
359
361
|
});
|
|
360
362
|
|
|
361
|
-
const _hoisted_1$
|
|
363
|
+
const _hoisted_1$a = {
|
|
362
364
|
ref: "codeEditor",
|
|
363
365
|
class: "magic-code-editor"
|
|
364
366
|
};
|
|
365
|
-
function _sfc_render$
|
|
366
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
367
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
368
|
+
return openBlock(), createElementBlock("div", _hoisted_1$a, null, 512);
|
|
367
369
|
}
|
|
368
|
-
const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
370
|
+
const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$9]]);
|
|
369
371
|
|
|
370
372
|
let $TMAGIC_EDITOR = {};
|
|
371
373
|
const setConfig = (option) => {
|
|
@@ -673,6 +675,9 @@ class WebStorage extends BaseService {
|
|
|
673
675
|
}
|
|
674
676
|
storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
|
|
675
677
|
}
|
|
678
|
+
destroy() {
|
|
679
|
+
this.removeAllListeners();
|
|
680
|
+
}
|
|
676
681
|
getValueAndProtocol(value) {
|
|
677
682
|
let protocol2 = "";
|
|
678
683
|
if (value === null) {
|
|
@@ -693,6 +698,12 @@ class WebStorage extends BaseService {
|
|
|
693
698
|
}
|
|
694
699
|
const storageService = new WebStorage();
|
|
695
700
|
|
|
701
|
+
var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
|
|
702
|
+
ColumnLayout2["LEFT"] = "left";
|
|
703
|
+
ColumnLayout2["CENTER"] = "center";
|
|
704
|
+
ColumnLayout2["RIGHT"] = "right";
|
|
705
|
+
return ColumnLayout2;
|
|
706
|
+
})(ColumnLayout || {});
|
|
696
707
|
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
697
708
|
LayerOffset2["TOP"] = "top";
|
|
698
709
|
LayerOffset2["BOTTOM"] = "bottom";
|
|
@@ -877,6 +888,7 @@ class Props extends BaseService {
|
|
|
877
888
|
"getPropsValue",
|
|
878
889
|
"createId",
|
|
879
890
|
"setNewItemId",
|
|
891
|
+
"fillConfig",
|
|
880
892
|
"getDefaultPropsValue"
|
|
881
893
|
]);
|
|
882
894
|
}
|
|
@@ -886,14 +898,17 @@ class Props extends BaseService {
|
|
|
886
898
|
});
|
|
887
899
|
this.emit("props-configs-change");
|
|
888
900
|
}
|
|
889
|
-
|
|
890
|
-
|
|
901
|
+
async fillConfig(config) {
|
|
902
|
+
return fillConfig(config);
|
|
903
|
+
}
|
|
904
|
+
async setPropsConfig(type, config) {
|
|
905
|
+
this.state.propsConfigMap[type] = await this.fillConfig(Array.isArray(config) ? config : [config]);
|
|
891
906
|
}
|
|
892
907
|
async getPropsConfig(type) {
|
|
893
908
|
if (type === "area") {
|
|
894
909
|
return await this.getPropsConfig("button");
|
|
895
910
|
}
|
|
896
|
-
return cloneDeep(this.state.propsConfigMap[type] ||
|
|
911
|
+
return cloneDeep(this.state.propsConfigMap[type] || await this.fillConfig([]));
|
|
897
912
|
}
|
|
898
913
|
setPropsValues(values) {
|
|
899
914
|
Object.keys(values).forEach((type) => {
|
|
@@ -927,25 +942,14 @@ class Props extends BaseService {
|
|
|
927
942
|
...mergeWith({}, cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
928
943
|
};
|
|
929
944
|
}
|
|
930
|
-
guid(digit = 8) {
|
|
931
|
-
return "x".repeat(digit).replace(/[xy]/g, (c) => {
|
|
932
|
-
const r = Math.random() * 16 | 0;
|
|
933
|
-
const v = c == "x" ? r : r & 3 | 8;
|
|
934
|
-
return v.toString(16);
|
|
935
|
-
});
|
|
936
|
-
}
|
|
937
945
|
async createId(type) {
|
|
938
946
|
return `${type}_${this.guid()}`;
|
|
939
947
|
}
|
|
940
|
-
async setNewItemId(config
|
|
941
|
-
const oldId = config.id;
|
|
948
|
+
async setNewItemId(config) {
|
|
942
949
|
config.id = await this.createId(config.type || "component");
|
|
943
|
-
if (isPop(config) && parent?.type === NodeType.PAGE) {
|
|
944
|
-
updatePopId(oldId, config.id, parent);
|
|
945
|
-
}
|
|
946
950
|
if (config.items && Array.isArray(config.items)) {
|
|
947
951
|
for (const item of config.items) {
|
|
948
|
-
await this.setNewItemId(item
|
|
952
|
+
await this.setNewItemId(item);
|
|
949
953
|
}
|
|
950
954
|
}
|
|
951
955
|
return config;
|
|
@@ -963,22 +967,19 @@ class Props extends BaseService {
|
|
|
963
967
|
name: type
|
|
964
968
|
};
|
|
965
969
|
}
|
|
970
|
+
destroy() {
|
|
971
|
+
this.state.propsConfigMap = {};
|
|
972
|
+
this.state.propsValueMap = {};
|
|
973
|
+
this.removeAllListeners();
|
|
974
|
+
}
|
|
975
|
+
guid(digit = 8) {
|
|
976
|
+
return "x".repeat(digit).replace(/[xy]/g, (c) => {
|
|
977
|
+
const r = Math.random() * 16 | 0;
|
|
978
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
979
|
+
return v.toString(16);
|
|
980
|
+
});
|
|
981
|
+
}
|
|
966
982
|
}
|
|
967
|
-
const updatePopId = (oldId, popId, pageConfig) => {
|
|
968
|
-
pageConfig.items?.forEach((config) => {
|
|
969
|
-
if (config.pop === oldId) {
|
|
970
|
-
config.pop = popId;
|
|
971
|
-
return;
|
|
972
|
-
}
|
|
973
|
-
if (config.popId === oldId) {
|
|
974
|
-
config.popId = popId;
|
|
975
|
-
return;
|
|
976
|
-
}
|
|
977
|
-
if (Array.isArray(config.items)) {
|
|
978
|
-
updatePopId(oldId, popId, config);
|
|
979
|
-
}
|
|
980
|
-
});
|
|
981
|
-
};
|
|
982
983
|
const propsService = new Props();
|
|
983
984
|
|
|
984
985
|
const beforePaste = async (position, config) => {
|
|
@@ -998,7 +999,7 @@ const beforePaste = async (position, config) => {
|
|
|
998
999
|
if (pastePosition.top && configItem.style?.top) {
|
|
999
1000
|
pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
|
|
1000
1001
|
}
|
|
1001
|
-
const pasteConfig = await propsService.setNewItemId(configItem
|
|
1002
|
+
const pasteConfig = await propsService.setNewItemId(configItem);
|
|
1002
1003
|
if (pasteConfig.style) {
|
|
1003
1004
|
const { left, top } = pasteConfig.style;
|
|
1004
1005
|
if (typeof left === "number" || !!left && !isNaN(Number(left))) {
|
|
@@ -1030,10 +1031,10 @@ const getPositionInContainer = (position = {}, id) => {
|
|
|
1030
1031
|
top
|
|
1031
1032
|
};
|
|
1032
1033
|
};
|
|
1033
|
-
const getAddParent = (
|
|
1034
|
+
const getAddParent = (node) => {
|
|
1034
1035
|
const curNode = editorService.get("node");
|
|
1035
1036
|
let parentNode;
|
|
1036
|
-
if (
|
|
1037
|
+
if (isPage(node)) {
|
|
1037
1038
|
parentNode = editorService.get("root");
|
|
1038
1039
|
} else if (curNode.items) {
|
|
1039
1040
|
parentNode = curNode;
|
|
@@ -1069,6 +1070,7 @@ class Editor$1 extends BaseService {
|
|
|
1069
1070
|
"sort",
|
|
1070
1071
|
"copy",
|
|
1071
1072
|
"paste",
|
|
1073
|
+
"doPaste",
|
|
1072
1074
|
"duAlignCenter",
|
|
1073
1075
|
"alignCenter",
|
|
1074
1076
|
"moveLayer",
|
|
@@ -1205,20 +1207,27 @@ class Editor$1 extends BaseService {
|
|
|
1205
1207
|
if ((parent?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && node.type !== NodeType.PAGE) {
|
|
1206
1208
|
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
1207
1209
|
}
|
|
1210
|
+
if (parent.id !== curNode.id) {
|
|
1211
|
+
const index = parent.items.indexOf(curNode);
|
|
1212
|
+
parent?.items?.splice(index + 1, 0, node);
|
|
1213
|
+
} else {
|
|
1214
|
+
parent?.items?.push(node);
|
|
1215
|
+
}
|
|
1208
1216
|
const layout = await this.getLayout(toRaw(parent), node);
|
|
1209
1217
|
node.style = getInitPositionStyle(node.style, layout);
|
|
1210
|
-
await stage?.add({
|
|
1218
|
+
await stage?.add({
|
|
1219
|
+
config: cloneDeep(node),
|
|
1220
|
+
parent: cloneDeep(parent),
|
|
1221
|
+
parentId: parent.id,
|
|
1222
|
+
root: cloneDeep(root)
|
|
1223
|
+
});
|
|
1211
1224
|
node.style = fixNodePosition(node, parent, stage);
|
|
1212
|
-
await stage?.update({ config: cloneDeep(node), root: cloneDeep(root) });
|
|
1213
|
-
parent?.items?.push(node);
|
|
1225
|
+
await stage?.update({ config: cloneDeep(node), parentId: parent.id, root: cloneDeep(root) });
|
|
1214
1226
|
this.addModifiedNodeId(node.id);
|
|
1215
1227
|
return node;
|
|
1216
1228
|
}
|
|
1217
1229
|
async add(addNode, parent) {
|
|
1218
1230
|
const stage = this.get("stage");
|
|
1219
|
-
const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(addNode);
|
|
1220
|
-
if (!parentNode)
|
|
1221
|
-
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1222
1231
|
const addNodes = [];
|
|
1223
1232
|
if (!Array.isArray(addNode)) {
|
|
1224
1233
|
const { type, inputEvent, ...config } = addNode;
|
|
@@ -1228,7 +1237,12 @@ class Editor$1 extends BaseService {
|
|
|
1228
1237
|
} else {
|
|
1229
1238
|
addNodes.push(...addNode);
|
|
1230
1239
|
}
|
|
1231
|
-
const newNodes = await Promise.all(addNodes.map((node) =>
|
|
1240
|
+
const newNodes = await Promise.all(addNodes.map((node) => {
|
|
1241
|
+
const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
|
|
1242
|
+
if (!parentNode)
|
|
1243
|
+
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1244
|
+
return this.doAdd(node, parentNode);
|
|
1245
|
+
}));
|
|
1232
1246
|
if (newNodes.length > 1) {
|
|
1233
1247
|
const newNodeIds = newNodes.map((node) => node.id);
|
|
1234
1248
|
stage?.multiSelect(newNodeIds);
|
|
@@ -1243,7 +1257,7 @@ class Editor$1 extends BaseService {
|
|
|
1243
1257
|
}
|
|
1244
1258
|
this.pushHistoryState();
|
|
1245
1259
|
this.emit("add", newNodes);
|
|
1246
|
-
return
|
|
1260
|
+
return Array.isArray(addNode) ? newNodes : newNodes[0];
|
|
1247
1261
|
}
|
|
1248
1262
|
async doRemove(node) {
|
|
1249
1263
|
const root = this.get("root");
|
|
@@ -1257,7 +1271,7 @@ class Editor$1 extends BaseService {
|
|
|
1257
1271
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1258
1272
|
parent.items?.splice(index, 1);
|
|
1259
1273
|
const stage = this.get("stage");
|
|
1260
|
-
stage?.remove({ id: node.id, root:
|
|
1274
|
+
stage?.remove({ id: node.id, parentId: parent.id, root: cloneDeep(root) });
|
|
1261
1275
|
if (node.type === NodeType.PAGE) {
|
|
1262
1276
|
this.state.pageLength -= 1;
|
|
1263
1277
|
if (root.items[0]) {
|
|
@@ -1283,7 +1297,7 @@ class Editor$1 extends BaseService {
|
|
|
1283
1297
|
const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
|
|
1284
1298
|
await Promise.all(nodes.map((node) => this.doRemove(node)));
|
|
1285
1299
|
this.pushHistoryState();
|
|
1286
|
-
this.emit("remove");
|
|
1300
|
+
this.emit("remove", nodes);
|
|
1287
1301
|
}
|
|
1288
1302
|
async doUpdate(config) {
|
|
1289
1303
|
if (!config?.id)
|
|
@@ -1321,7 +1335,11 @@ class Editor$1 extends BaseService {
|
|
|
1321
1335
|
const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
|
|
1322
1336
|
nodes.splice(targetIndex, 1, newConfig);
|
|
1323
1337
|
this.set("nodes", nodes);
|
|
1324
|
-
this.get("stage")?.update({
|
|
1338
|
+
this.get("stage")?.update({
|
|
1339
|
+
config: cloneDeep(newConfig),
|
|
1340
|
+
parentId: parent.id,
|
|
1341
|
+
root: cloneDeep(this.get("root"))
|
|
1342
|
+
});
|
|
1325
1343
|
if (newConfig.type === NodeType.PAGE) {
|
|
1326
1344
|
this.set("page", newConfig);
|
|
1327
1345
|
}
|
|
@@ -1333,7 +1351,7 @@ class Editor$1 extends BaseService {
|
|
|
1333
1351
|
const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
|
|
1334
1352
|
this.pushHistoryState();
|
|
1335
1353
|
this.emit("update", newNodes);
|
|
1336
|
-
return
|
|
1354
|
+
return Array.isArray(config) ? newNodes : newNodes[0];
|
|
1337
1355
|
}
|
|
1338
1356
|
async sort(id1, id2) {
|
|
1339
1357
|
const node = this.get("node");
|
|
@@ -1345,7 +1363,11 @@ class Editor$1 extends BaseService {
|
|
|
1345
1363
|
parent.items.splice(index2, 0, ...parent.items.splice(index1, 1));
|
|
1346
1364
|
await this.update(parent);
|
|
1347
1365
|
await this.select(node);
|
|
1348
|
-
this.get("stage")?.update({
|
|
1366
|
+
this.get("stage")?.update({
|
|
1367
|
+
config: cloneDeep(node),
|
|
1368
|
+
parentId: parent.id,
|
|
1369
|
+
root: cloneDeep(this.get("root"))
|
|
1370
|
+
});
|
|
1349
1371
|
this.addModifiedNodeId(parent.id);
|
|
1350
1372
|
this.pushHistoryState();
|
|
1351
1373
|
}
|
|
@@ -1358,9 +1380,13 @@ class Editor$1 extends BaseService {
|
|
|
1358
1380
|
const config = await storageService.getItem(COPY_STORAGE_KEY);
|
|
1359
1381
|
if (!Array.isArray(config))
|
|
1360
1382
|
return;
|
|
1361
|
-
const pasteConfigs = await
|
|
1383
|
+
const pasteConfigs = await this.doPaste(config, position);
|
|
1362
1384
|
return this.add(pasteConfigs);
|
|
1363
1385
|
}
|
|
1386
|
+
async doPaste(config, position = {}) {
|
|
1387
|
+
const pasteConfigs = await beforePaste(position, cloneDeep(config));
|
|
1388
|
+
return pasteConfigs;
|
|
1389
|
+
}
|
|
1364
1390
|
async doAlignCenter(config) {
|
|
1365
1391
|
const parent = this.getParentById(config.id);
|
|
1366
1392
|
if (!parent)
|
|
@@ -1405,10 +1431,14 @@ class Editor$1 extends BaseService {
|
|
|
1405
1431
|
} else {
|
|
1406
1432
|
brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
|
|
1407
1433
|
}
|
|
1434
|
+
const grandparent = this.getParentById(parent.id);
|
|
1408
1435
|
this.get("stage")?.update({
|
|
1409
1436
|
config: cloneDeep(toRaw(parent)),
|
|
1437
|
+
parentId: grandparent?.id,
|
|
1410
1438
|
root: cloneDeep(this.get("root"))
|
|
1411
1439
|
});
|
|
1440
|
+
this.addModifiedNodeId(parent.id);
|
|
1441
|
+
this.pushHistoryState();
|
|
1412
1442
|
}
|
|
1413
1443
|
async moveToContainer(config, targetId) {
|
|
1414
1444
|
const { node, parent } = this.getNodeInfo(config.id, false);
|
|
@@ -1418,7 +1448,7 @@ class Editor$1 extends BaseService {
|
|
|
1418
1448
|
const root = cloneDeep(this.get("root"));
|
|
1419
1449
|
const index = getNodeIndex(node, parent);
|
|
1420
1450
|
parent.items?.splice(index, 1);
|
|
1421
|
-
await stage.remove({ id: node.id, root });
|
|
1451
|
+
await stage.remove({ id: node.id, parentId: parent.id, root });
|
|
1422
1452
|
const layout = await this.getLayout(target);
|
|
1423
1453
|
const newConfig = mergeWith(cloneDeep(node), config, (objValue, srcValue) => {
|
|
1424
1454
|
if (Array.isArray(srcValue)) {
|
|
@@ -1428,7 +1458,8 @@ class Editor$1 extends BaseService {
|
|
|
1428
1458
|
newConfig.style = getInitPositionStyle(newConfig.style, layout);
|
|
1429
1459
|
target.items.push(newConfig);
|
|
1430
1460
|
await stage.select(targetId);
|
|
1431
|
-
|
|
1461
|
+
const targetParent = this.getParentById(target.id);
|
|
1462
|
+
await stage.update({ config: cloneDeep(target), parentId: targetParent?.id, root });
|
|
1432
1463
|
await this.select(newConfig);
|
|
1433
1464
|
stage.select(newConfig.id);
|
|
1434
1465
|
this.addModifiedNodeId(target.id);
|
|
@@ -1475,6 +1506,10 @@ class Editor$1 extends BaseService {
|
|
|
1475
1506
|
this.set("nodes", []);
|
|
1476
1507
|
this.set("page", null);
|
|
1477
1508
|
this.set("parent", null);
|
|
1509
|
+
this.set("stage", null);
|
|
1510
|
+
this.set("highlightNode", null);
|
|
1511
|
+
this.set("modifiedNodeIds", /* @__PURE__ */ new Map());
|
|
1512
|
+
this.set("pageLength", /* @__PURE__ */ new Map());
|
|
1478
1513
|
}
|
|
1479
1514
|
resetModifiedNodeId() {
|
|
1480
1515
|
this.get("modifiedNodeIds").clear();
|
|
@@ -1544,8 +1579,8 @@ class Editor$1 extends BaseService {
|
|
|
1544
1579
|
}
|
|
1545
1580
|
const editorService = new Editor$1();
|
|
1546
1581
|
|
|
1547
|
-
|
|
1548
|
-
|
|
1582
|
+
let eventMap = reactive({});
|
|
1583
|
+
let methodMap = reactive({});
|
|
1549
1584
|
class Events extends BaseService {
|
|
1550
1585
|
constructor() {
|
|
1551
1586
|
super([]);
|
|
@@ -1585,6 +1620,11 @@ class Events extends BaseService {
|
|
|
1585
1620
|
getMethod(type) {
|
|
1586
1621
|
return cloneDeep(methodMap[type] || DEFAULT_METHODS);
|
|
1587
1622
|
}
|
|
1623
|
+
destroy() {
|
|
1624
|
+
eventMap = reactive({});
|
|
1625
|
+
methodMap = reactive({});
|
|
1626
|
+
this.removeAllListeners();
|
|
1627
|
+
}
|
|
1588
1628
|
}
|
|
1589
1629
|
const eventsService = new Events();
|
|
1590
1630
|
|
|
@@ -1791,7 +1831,6 @@ const fillConfig = (config = []) => [
|
|
|
1791
1831
|
]
|
|
1792
1832
|
}
|
|
1793
1833
|
];
|
|
1794
|
-
const DEFAULT_CONFIG = fillConfig([]);
|
|
1795
1834
|
|
|
1796
1835
|
const log = (...args) => {
|
|
1797
1836
|
if (process.env.NODE_ENV === "development") {
|
|
@@ -1819,7 +1858,194 @@ const error = (...args) => {
|
|
|
1819
1858
|
}
|
|
1820
1859
|
};
|
|
1821
1860
|
|
|
1822
|
-
const
|
|
1861
|
+
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
1862
|
+
const MIN_LEFT_COLUMN_WIDTH = 45;
|
|
1863
|
+
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
1864
|
+
const MIN_RIGHT_COLUMN_WIDTH = 1;
|
|
1865
|
+
const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
|
|
1866
|
+
const defaultColumnWidth = {
|
|
1867
|
+
left: DEFAULT_LEFT_COLUMN_WIDTH,
|
|
1868
|
+
center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
|
|
1869
|
+
right: DEFAULT_RIGHT_COLUMN_WIDTH
|
|
1870
|
+
};
|
|
1871
|
+
const state = reactive({
|
|
1872
|
+
uiSelectMode: false,
|
|
1873
|
+
showSrc: false,
|
|
1874
|
+
zoom: 1,
|
|
1875
|
+
stageContainerRect: {
|
|
1876
|
+
width: 0,
|
|
1877
|
+
height: 0
|
|
1878
|
+
},
|
|
1879
|
+
stageRect: {
|
|
1880
|
+
width: 375,
|
|
1881
|
+
height: 817
|
|
1882
|
+
},
|
|
1883
|
+
columnWidth: defaultColumnWidth,
|
|
1884
|
+
showGuides: true,
|
|
1885
|
+
showRule: true,
|
|
1886
|
+
propsPanelSize: "small"
|
|
1887
|
+
});
|
|
1888
|
+
class Ui extends BaseService {
|
|
1889
|
+
constructor() {
|
|
1890
|
+
super([]);
|
|
1891
|
+
globalThis.addEventListener("resize", () => {
|
|
1892
|
+
this.setColumnWidth({
|
|
1893
|
+
center: "auto"
|
|
1894
|
+
});
|
|
1895
|
+
});
|
|
1896
|
+
}
|
|
1897
|
+
set(name, value) {
|
|
1898
|
+
const mask = editorService.get("stage")?.mask;
|
|
1899
|
+
if (name === "columnWidth") {
|
|
1900
|
+
this.setColumnWidth(value);
|
|
1901
|
+
return;
|
|
1902
|
+
}
|
|
1903
|
+
if (name === "stageRect") {
|
|
1904
|
+
this.setStageRect(value);
|
|
1905
|
+
return;
|
|
1906
|
+
}
|
|
1907
|
+
if (name === "showGuides") {
|
|
1908
|
+
mask?.showGuides(value);
|
|
1909
|
+
}
|
|
1910
|
+
if (name === "showRule") {
|
|
1911
|
+
mask?.showRule(value);
|
|
1912
|
+
}
|
|
1913
|
+
state[name] = value;
|
|
1914
|
+
}
|
|
1915
|
+
get(name) {
|
|
1916
|
+
return state[name];
|
|
1917
|
+
}
|
|
1918
|
+
initColumnWidth() {
|
|
1919
|
+
const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
|
|
1920
|
+
if (columnWidthCacheData) {
|
|
1921
|
+
try {
|
|
1922
|
+
const columnWidthCache = JSON.parse(columnWidthCacheData);
|
|
1923
|
+
this.setColumnWidth(columnWidthCache);
|
|
1924
|
+
} catch (e) {
|
|
1925
|
+
console.error(e);
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
zoom(zoom) {
|
|
1930
|
+
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
1931
|
+
if (this.get("zoom") < 0.1)
|
|
1932
|
+
this.set("zoom", 0.1);
|
|
1933
|
+
}
|
|
1934
|
+
calcZoom() {
|
|
1935
|
+
const { stageRect, stageContainerRect } = state;
|
|
1936
|
+
const { height, width } = stageContainerRect;
|
|
1937
|
+
if (!width || !height)
|
|
1938
|
+
return 1;
|
|
1939
|
+
const stageWidth = stageRect.width + 30;
|
|
1940
|
+
const stageHeight = stageRect.height + 30;
|
|
1941
|
+
if (width > stageWidth && height > stageHeight) {
|
|
1942
|
+
return 1;
|
|
1943
|
+
}
|
|
1944
|
+
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
1945
|
+
}
|
|
1946
|
+
destroy() {
|
|
1947
|
+
this.removeAllListeners();
|
|
1948
|
+
}
|
|
1949
|
+
setColumnWidth({ left, center, right }) {
|
|
1950
|
+
const columnWidth = {
|
|
1951
|
+
...toRaw(this.get("columnWidth"))
|
|
1952
|
+
};
|
|
1953
|
+
if (left) {
|
|
1954
|
+
columnWidth.left = Math.max(left, MIN_LEFT_COLUMN_WIDTH);
|
|
1955
|
+
}
|
|
1956
|
+
if (right) {
|
|
1957
|
+
columnWidth.right = Math.max(right, MIN_RIGHT_COLUMN_WIDTH);
|
|
1958
|
+
}
|
|
1959
|
+
if (!center || center === "auto") {
|
|
1960
|
+
const bodyWidth = globalThis.document.body.clientWidth;
|
|
1961
|
+
columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
|
|
1962
|
+
if (columnWidth.center <= 0) {
|
|
1963
|
+
columnWidth.left = defaultColumnWidth.left;
|
|
1964
|
+
columnWidth.center = defaultColumnWidth.center;
|
|
1965
|
+
columnWidth.right = defaultColumnWidth.right;
|
|
1966
|
+
}
|
|
1967
|
+
} else {
|
|
1968
|
+
columnWidth.center = center;
|
|
1969
|
+
}
|
|
1970
|
+
globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
|
|
1971
|
+
state.columnWidth = columnWidth;
|
|
1972
|
+
}
|
|
1973
|
+
setStageRect(value) {
|
|
1974
|
+
state.stageRect = {
|
|
1975
|
+
...state.stageRect,
|
|
1976
|
+
...value
|
|
1977
|
+
};
|
|
1978
|
+
state.zoom = this.calcZoom();
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
const uiService = new Ui();
|
|
1982
|
+
|
|
1983
|
+
const root = computed(() => editorService.get("root"));
|
|
1984
|
+
const page = computed(() => editorService.get("page"));
|
|
1985
|
+
const zoom = computed(() => uiService.get("zoom") || 1);
|
|
1986
|
+
const uiSelectMode = computed(() => uiService.get("uiSelectMode"));
|
|
1987
|
+
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
1988
|
+
const useStage = (stageOptions) => {
|
|
1989
|
+
const stage = new StageCore({
|
|
1990
|
+
render: stageOptions.render,
|
|
1991
|
+
runtimeUrl: stageOptions.runtimeUrl,
|
|
1992
|
+
zoom: zoom.value,
|
|
1993
|
+
autoScrollIntoView: stageOptions.autoScrollIntoView,
|
|
1994
|
+
isContainer: stageOptions.isContainer,
|
|
1995
|
+
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
1996
|
+
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
1997
|
+
containerHighlightType: stageOptions.containerHighlightType,
|
|
1998
|
+
canSelect: (el, event, stop) => {
|
|
1999
|
+
const elCanSelect = stageOptions.canSelect(el);
|
|
2000
|
+
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
2001
|
+
document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
|
|
2002
|
+
return stop();
|
|
2003
|
+
}
|
|
2004
|
+
return elCanSelect;
|
|
2005
|
+
},
|
|
2006
|
+
moveableOptions: stageOptions.moveableOptions,
|
|
2007
|
+
updateDragEl: stageOptions.updateDragEl
|
|
2008
|
+
});
|
|
2009
|
+
stage.mask.setGuides([
|
|
2010
|
+
getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
|
|
2011
|
+
getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
|
|
2012
|
+
]);
|
|
2013
|
+
stage.on("select", (el) => {
|
|
2014
|
+
editorService.select(el.id);
|
|
2015
|
+
});
|
|
2016
|
+
stage.on("highlight", (el) => {
|
|
2017
|
+
editorService.highlight(el.id);
|
|
2018
|
+
});
|
|
2019
|
+
stage.on("multiSelect", (els) => {
|
|
2020
|
+
editorService.multiSelect(els.map((el) => el.id));
|
|
2021
|
+
});
|
|
2022
|
+
stage.on("update", (ev) => {
|
|
2023
|
+
if (ev.parentEl) {
|
|
2024
|
+
for (const data of ev.data) {
|
|
2025
|
+
editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
2026
|
+
}
|
|
2027
|
+
return;
|
|
2028
|
+
}
|
|
2029
|
+
editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
2030
|
+
});
|
|
2031
|
+
stage.on("sort", (ev) => {
|
|
2032
|
+
editorService.sort(ev.src, ev.dist);
|
|
2033
|
+
});
|
|
2034
|
+
stage.on("changeGuides", (e) => {
|
|
2035
|
+
uiService.set("showGuides", true);
|
|
2036
|
+
if (!root.value || !page.value)
|
|
2037
|
+
return;
|
|
2038
|
+
const storageKey = getGuideLineKey(e.type === GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY);
|
|
2039
|
+
if (e.guides.length) {
|
|
2040
|
+
globalThis.localStorage.setItem(storageKey, JSON.stringify(e.guides));
|
|
2041
|
+
} else {
|
|
2042
|
+
globalThis.localStorage.removeItem(storageKey);
|
|
2043
|
+
}
|
|
2044
|
+
});
|
|
2045
|
+
return stage;
|
|
2046
|
+
};
|
|
2047
|
+
|
|
2048
|
+
const _sfc_main$k = defineComponent({
|
|
1823
2049
|
components: { Plus },
|
|
1824
2050
|
setup() {
|
|
1825
2051
|
const services = inject("services");
|
|
@@ -1837,13 +2063,13 @@ const _sfc_main$j = defineComponent({
|
|
|
1837
2063
|
}
|
|
1838
2064
|
});
|
|
1839
2065
|
|
|
1840
|
-
const _hoisted_1$
|
|
2066
|
+
const _hoisted_1$9 = { class: "m-editor-empty-panel" };
|
|
1841
2067
|
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
1842
|
-
const _hoisted_3
|
|
1843
|
-
function _sfc_render$
|
|
2068
|
+
const _hoisted_3 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
2069
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1844
2070
|
const _component_plus = resolveComponent("plus");
|
|
1845
2071
|
const _component_el_icon = resolveComponent("el-icon");
|
|
1846
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
2072
|
+
return openBlock(), createElementBlock("div", _hoisted_1$9, [
|
|
1847
2073
|
createElementVNode("div", _hoisted_2$4, [
|
|
1848
2074
|
createElementVNode("div", {
|
|
1849
2075
|
class: "m-editor-empty-button",
|
|
@@ -1857,14 +2083,14 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1857
2083
|
_: 1
|
|
1858
2084
|
})
|
|
1859
2085
|
]),
|
|
1860
|
-
_hoisted_3
|
|
2086
|
+
_hoisted_3
|
|
1861
2087
|
])
|
|
1862
2088
|
])
|
|
1863
2089
|
]);
|
|
1864
2090
|
}
|
|
1865
|
-
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2091
|
+
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$8]]);
|
|
1866
2092
|
|
|
1867
|
-
const _sfc_main$
|
|
2093
|
+
const _sfc_main$j = defineComponent({
|
|
1868
2094
|
name: "m-editor-resize",
|
|
1869
2095
|
props: {
|
|
1870
2096
|
type: {
|
|
@@ -1907,18 +2133,18 @@ const _sfc_main$i = defineComponent({
|
|
|
1907
2133
|
}
|
|
1908
2134
|
});
|
|
1909
2135
|
|
|
1910
|
-
const _hoisted_1$
|
|
2136
|
+
const _hoisted_1$8 = {
|
|
1911
2137
|
ref: "target",
|
|
1912
2138
|
class: "m-editor-resizer"
|
|
1913
2139
|
};
|
|
1914
|
-
function _sfc_render$
|
|
1915
|
-
return openBlock(), createElementBlock("span", _hoisted_1$
|
|
2140
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2141
|
+
return openBlock(), createElementBlock("span", _hoisted_1$8, [
|
|
1916
2142
|
renderSlot(_ctx.$slots, "default")
|
|
1917
2143
|
], 512);
|
|
1918
2144
|
}
|
|
1919
|
-
const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2145
|
+
const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$7]]);
|
|
1920
2146
|
|
|
1921
|
-
const _sfc_main$
|
|
2147
|
+
const _sfc_main$i = defineComponent({
|
|
1922
2148
|
components: {
|
|
1923
2149
|
AddPageBox,
|
|
1924
2150
|
Resizer
|
|
@@ -1948,17 +2174,17 @@ const _sfc_main$h = defineComponent({
|
|
|
1948
2174
|
}
|
|
1949
2175
|
});
|
|
1950
2176
|
|
|
1951
|
-
const _hoisted_1$
|
|
2177
|
+
const _hoisted_1$7 = { class: "m-editor" };
|
|
1952
2178
|
const _hoisted_2$3 = {
|
|
1953
2179
|
key: 1,
|
|
1954
2180
|
class: "m-editor-content"
|
|
1955
2181
|
};
|
|
1956
|
-
function _sfc_render$
|
|
2182
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1957
2183
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
1958
2184
|
const _component_resizer = resolveComponent("resizer");
|
|
1959
2185
|
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
1960
2186
|
const _component_add_page_box = resolveComponent("add-page-box");
|
|
1961
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
2187
|
+
return openBlock(), createElementBlock("div", _hoisted_1$7, [
|
|
1962
2188
|
renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
1963
2189
|
_ctx.showSrc ? (openBlock(), createBlock(_component_magic_code_editor, {
|
|
1964
2190
|
key: 0,
|
|
@@ -1999,211 +2225,112 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1999
2225
|
]))
|
|
2000
2226
|
]);
|
|
2001
2227
|
}
|
|
2002
|
-
const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2228
|
+
const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$6]]);
|
|
2003
2229
|
|
|
2004
|
-
const
|
|
2005
|
-
|
|
2006
|
-
|
|
2230
|
+
const _hoisted_1$6 = ["src"];
|
|
2231
|
+
const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
2232
|
+
__name: "Icon",
|
|
2007
2233
|
props: {
|
|
2008
|
-
icon:
|
|
2009
|
-
type: [String, Object]
|
|
2010
|
-
}
|
|
2234
|
+
icon: null
|
|
2011
2235
|
},
|
|
2012
|
-
setup() {
|
|
2013
|
-
return {
|
|
2014
|
-
|
|
2236
|
+
setup(__props) {
|
|
2237
|
+
return (_ctx, _cache) => {
|
|
2238
|
+
const _component_el_icon = resolveComponent("el-icon");
|
|
2239
|
+
return !__props.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
|
|
2240
|
+
default: withCtx(() => [
|
|
2241
|
+
createVNode(unref(Edit))
|
|
2242
|
+
]),
|
|
2243
|
+
_: 1
|
|
2244
|
+
})) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (openBlock(), createBlock(_component_el_icon, { key: 1 }, {
|
|
2245
|
+
default: withCtx(() => [
|
|
2246
|
+
createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$6)
|
|
2247
|
+
]),
|
|
2248
|
+
_: 1
|
|
2249
|
+
})) : typeof __props.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
2250
|
+
key: 2,
|
|
2251
|
+
class: normalizeClass(__props.icon)
|
|
2252
|
+
}, null, 2)) : (openBlock(), createBlock(_component_el_icon, { key: 3 }, {
|
|
2253
|
+
default: withCtx(() => [
|
|
2254
|
+
(openBlock(), createBlock(resolveDynamicComponent(toRaw(__props.icon))))
|
|
2255
|
+
]),
|
|
2256
|
+
_: 1
|
|
2257
|
+
}));
|
|
2015
2258
|
};
|
|
2016
2259
|
}
|
|
2017
2260
|
});
|
|
2018
2261
|
|
|
2019
|
-
const _hoisted_1$
|
|
2020
|
-
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2021
|
-
const _component_edit = resolveComponent("edit");
|
|
2022
|
-
const _component_el_icon = resolveComponent("el-icon");
|
|
2023
|
-
return !_ctx.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
|
|
2024
|
-
default: withCtx(() => [
|
|
2025
|
-
createVNode(_component_edit)
|
|
2026
|
-
]),
|
|
2027
|
-
_: 1
|
|
2028
|
-
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (openBlock(), createBlock(_component_el_icon, { key: 1 }, {
|
|
2029
|
-
default: withCtx(() => [
|
|
2030
|
-
createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$8)
|
|
2031
|
-
]),
|
|
2032
|
-
_: 1
|
|
2033
|
-
})) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
2034
|
-
key: 2,
|
|
2035
|
-
class: normalizeClass(_ctx.icon)
|
|
2036
|
-
}, null, 2)) : (openBlock(), createBlock(_component_el_icon, { key: 3 }, {
|
|
2037
|
-
default: withCtx(() => [
|
|
2038
|
-
(openBlock(), createBlock(resolveDynamicComponent(_ctx.toRaw(_ctx.icon))))
|
|
2039
|
-
]),
|
|
2040
|
-
_: 1
|
|
2041
|
-
}));
|
|
2042
|
-
}
|
|
2043
|
-
const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
|
|
2044
|
-
|
|
2045
|
-
const _hoisted_1$7 = {
|
|
2262
|
+
const _hoisted_1$5 = {
|
|
2046
2263
|
key: 1,
|
|
2047
2264
|
class: "menu-item-text"
|
|
2048
2265
|
};
|
|
2049
|
-
const _hoisted_2$2 = {
|
|
2050
|
-
|
|
2051
|
-
style: { "margin": "0 5px" }
|
|
2052
|
-
};
|
|
2053
|
-
const _hoisted_3 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2054
|
-
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
2266
|
+
const _hoisted_2$2 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2267
|
+
const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
2055
2268
|
__name: "ToolButton",
|
|
2056
2269
|
props: {
|
|
2057
|
-
data: {
|
|
2058
|
-
type:
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
display: false
|
|
2063
|
-
})
|
|
2064
|
-
},
|
|
2065
|
-
eventType: {
|
|
2066
|
-
type: String,
|
|
2067
|
-
default: "click"
|
|
2068
|
-
}
|
|
2270
|
+
data: { default: () => ({
|
|
2271
|
+
type: "text",
|
|
2272
|
+
display: false
|
|
2273
|
+
}) },
|
|
2274
|
+
eventType: { default: "click" }
|
|
2069
2275
|
},
|
|
2070
2276
|
setup(__props) {
|
|
2071
2277
|
const props = __props;
|
|
2072
2278
|
const services = inject("services");
|
|
2073
|
-
const
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
if (typeof props.data !== "string") {
|
|
2081
|
-
return props.data;
|
|
2082
|
-
}
|
|
2083
|
-
switch (props.data) {
|
|
2084
|
-
case "/":
|
|
2085
|
-
return {
|
|
2086
|
-
type: "divider"
|
|
2087
|
-
};
|
|
2088
|
-
case "zoom":
|
|
2089
|
-
return {
|
|
2090
|
-
type: "zoom"
|
|
2091
|
-
};
|
|
2092
|
-
case "delete":
|
|
2093
|
-
return {
|
|
2094
|
-
type: "button",
|
|
2095
|
-
icon: markRaw(Delete),
|
|
2096
|
-
tooltip: "\u522A\u9664",
|
|
2097
|
-
disabled: () => services?.editorService.get("node")?.type === NodeType.PAGE,
|
|
2098
|
-
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
2099
|
-
};
|
|
2100
|
-
case "undo":
|
|
2101
|
-
return {
|
|
2102
|
-
type: "button",
|
|
2103
|
-
icon: markRaw(Back),
|
|
2104
|
-
tooltip: "\u540E\u9000",
|
|
2105
|
-
disabled: () => !services?.historyService.state.canUndo,
|
|
2106
|
-
handler: () => services?.editorService.undo()
|
|
2107
|
-
};
|
|
2108
|
-
case "redo":
|
|
2109
|
-
return {
|
|
2110
|
-
type: "button",
|
|
2111
|
-
icon: markRaw(Right),
|
|
2112
|
-
tooltip: "\u524D\u8FDB",
|
|
2113
|
-
disabled: () => !services?.historyService.state.canRedo,
|
|
2114
|
-
handler: () => services?.editorService.redo()
|
|
2115
|
-
};
|
|
2116
|
-
case "zoom-in":
|
|
2117
|
-
return {
|
|
2118
|
-
type: "button",
|
|
2119
|
-
icon: markRaw(ZoomIn),
|
|
2120
|
-
tooltip: "\u653E\u5927",
|
|
2121
|
-
handler: zoomInHandler
|
|
2122
|
-
};
|
|
2123
|
-
case "zoom-out":
|
|
2124
|
-
return {
|
|
2125
|
-
type: "button",
|
|
2126
|
-
icon: markRaw(ZoomOut),
|
|
2127
|
-
tooltip: "\u7E2E\u5C0F",
|
|
2128
|
-
handler: zoomOutHandler
|
|
2129
|
-
};
|
|
2130
|
-
case "rule":
|
|
2131
|
-
return {
|
|
2132
|
-
type: "button",
|
|
2133
|
-
icon: markRaw(ScaleToOriginal),
|
|
2134
|
-
tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
|
|
2135
|
-
handler: () => uiService?.set("showRule", !showRule.value)
|
|
2136
|
-
};
|
|
2137
|
-
case "guides":
|
|
2138
|
-
return {
|
|
2139
|
-
type: "button",
|
|
2140
|
-
icon: markRaw(Grid),
|
|
2141
|
-
tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
|
|
2142
|
-
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
2143
|
-
};
|
|
2144
|
-
default:
|
|
2145
|
-
return {
|
|
2146
|
-
type: "text",
|
|
2147
|
-
text: props.data
|
|
2148
|
-
};
|
|
2279
|
+
const disabled = computed(() => {
|
|
2280
|
+
if (typeof props.data === "string")
|
|
2281
|
+
return false;
|
|
2282
|
+
if (props.data.type === "component")
|
|
2283
|
+
return false;
|
|
2284
|
+
if (typeof props.data.disabled === "function") {
|
|
2285
|
+
return props.data.disabled(services);
|
|
2149
2286
|
}
|
|
2287
|
+
return props.data.disabled;
|
|
2150
2288
|
});
|
|
2151
|
-
const
|
|
2152
|
-
if (
|
|
2153
|
-
return false;
|
|
2154
|
-
if (item.value.type === "component")
|
|
2289
|
+
const display = computed(() => {
|
|
2290
|
+
if (!props.data)
|
|
2155
2291
|
return false;
|
|
2156
|
-
if (typeof
|
|
2157
|
-
return
|
|
2292
|
+
if (typeof props.data === "string")
|
|
2293
|
+
return true;
|
|
2294
|
+
if (typeof props.data.display === "function") {
|
|
2295
|
+
return props.data.display(services);
|
|
2158
2296
|
}
|
|
2159
|
-
return
|
|
2297
|
+
return props.data.display ?? true;
|
|
2160
2298
|
});
|
|
2161
|
-
const buttonHandler = (
|
|
2299
|
+
const buttonHandler = (item, event) => {
|
|
2162
2300
|
if (disabled.value)
|
|
2163
2301
|
return;
|
|
2164
|
-
if (typeof
|
|
2165
|
-
|
|
2302
|
+
if (typeof item.handler === "function" && services) {
|
|
2303
|
+
item.handler?.(services, event);
|
|
2166
2304
|
}
|
|
2167
2305
|
};
|
|
2168
|
-
const display = computed(() => {
|
|
2169
|
-
if (!item.value)
|
|
2170
|
-
return false;
|
|
2171
|
-
if (typeof item.value === "string")
|
|
2172
|
-
return true;
|
|
2173
|
-
if (typeof item.value.display === "function") {
|
|
2174
|
-
return item.value.display(services);
|
|
2175
|
-
}
|
|
2176
|
-
return item.value.display ?? true;
|
|
2177
|
-
});
|
|
2178
2306
|
const dropdownHandler = (command) => {
|
|
2179
2307
|
if (command.item.handler) {
|
|
2180
2308
|
command.item.handler(services);
|
|
2181
2309
|
}
|
|
2182
2310
|
};
|
|
2183
|
-
const clickHandler = (
|
|
2311
|
+
const clickHandler = (item, event) => {
|
|
2184
2312
|
if (props.eventType !== "click")
|
|
2185
2313
|
return;
|
|
2186
|
-
if (
|
|
2187
|
-
buttonHandler(
|
|
2314
|
+
if (item.type === "button") {
|
|
2315
|
+
buttonHandler(item, event);
|
|
2188
2316
|
}
|
|
2189
2317
|
};
|
|
2190
|
-
const mousedownHandler = (
|
|
2318
|
+
const mousedownHandler = (item, event) => {
|
|
2191
2319
|
if (props.eventType !== "mousedown")
|
|
2192
2320
|
return;
|
|
2193
|
-
if (
|
|
2194
|
-
buttonHandler(
|
|
2321
|
+
if (item.type === "button") {
|
|
2322
|
+
buttonHandler(item, event);
|
|
2195
2323
|
}
|
|
2196
2324
|
};
|
|
2197
|
-
const mouseupHandler = (
|
|
2325
|
+
const mouseupHandler = (item, event) => {
|
|
2198
2326
|
if (props.eventType !== "mouseup")
|
|
2199
2327
|
return;
|
|
2200
|
-
if (
|
|
2201
|
-
buttonHandler(
|
|
2328
|
+
if (item.type === "button") {
|
|
2329
|
+
buttonHandler(item, event);
|
|
2202
2330
|
}
|
|
2203
2331
|
};
|
|
2204
2332
|
return (_ctx, _cache) => {
|
|
2205
2333
|
const _component_el_divider = resolveComponent("el-divider");
|
|
2206
|
-
const _component_tool_button = resolveComponent("tool-button", true);
|
|
2207
2334
|
const _component_el_button = resolveComponent("el-button");
|
|
2208
2335
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
2209
2336
|
const _component_el_icon = resolveComponent("el-icon");
|
|
@@ -2212,30 +2339,20 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2212
2339
|
const _component_el_dropdown = resolveComponent("el-dropdown");
|
|
2213
2340
|
return unref(display) ? (openBlock(), createElementBlock("div", {
|
|
2214
2341
|
key: 0,
|
|
2215
|
-
class: normalizeClass(["menu-item",
|
|
2216
|
-
onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(
|
|
2217
|
-
onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(
|
|
2218
|
-
onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(
|
|
2342
|
+
class: normalizeClass(["menu-item", `${__props.data.type} ${__props.data.className || ""}`]),
|
|
2343
|
+
onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(__props.data, $event)),
|
|
2344
|
+
onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(__props.data, $event)),
|
|
2345
|
+
onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(__props.data, $event))
|
|
2219
2346
|
}, [
|
|
2220
|
-
|
|
2347
|
+
__props.data.type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
|
|
2221
2348
|
key: 0,
|
|
2222
|
-
direction:
|
|
2223
|
-
}, null, 8, ["direction"])) :
|
|
2224
|
-
|
|
2225
|
-
data: { type: "button", icon: unref(ZoomOut), handler: zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
2226
|
-
"event-type": __props.eventType
|
|
2227
|
-
}, null, 8, ["data", "event-type"]),
|
|
2228
|
-
createElementVNode("span", _hoisted_2$2, toDisplayString(parseInt(`${unref(zoom) * 100}`, 10)) + "%", 1),
|
|
2229
|
-
createVNode(_component_tool_button, {
|
|
2230
|
-
data: { type: "button", icon: unref(ZoomIn), handler: zoomInHandler, tooltip: "\u653E\u5927" },
|
|
2231
|
-
"event-type": __props.eventType
|
|
2232
|
-
}, null, 8, ["data", "event-type"])
|
|
2233
|
-
], 64)) : unref(item).type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
2234
|
-
unref(item).tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
2349
|
+
direction: __props.data.direction || "vertical"
|
|
2350
|
+
}, null, 8, ["direction"])) : __props.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$5, toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
2351
|
+
__props.data.tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
2235
2352
|
key: 0,
|
|
2236
2353
|
effect: "dark",
|
|
2237
2354
|
placement: "bottom-start",
|
|
2238
|
-
content:
|
|
2355
|
+
content: __props.data.tooltip
|
|
2239
2356
|
}, {
|
|
2240
2357
|
default: withCtx(() => [
|
|
2241
2358
|
createVNode(_component_el_button, {
|
|
@@ -2244,11 +2361,11 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2244
2361
|
disabled: unref(disabled)
|
|
2245
2362
|
}, {
|
|
2246
2363
|
default: withCtx(() => [
|
|
2247
|
-
|
|
2364
|
+
__props.data.icon ? (openBlock(), createBlock(_sfc_main$h, {
|
|
2248
2365
|
key: 0,
|
|
2249
|
-
icon:
|
|
2366
|
+
icon: __props.data.icon
|
|
2250
2367
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
2251
|
-
createElementVNode("span", null, toDisplayString(
|
|
2368
|
+
createElementVNode("span", null, toDisplayString(__props.data.text), 1)
|
|
2252
2369
|
]),
|
|
2253
2370
|
_: 1
|
|
2254
2371
|
}, 8, ["disabled"])
|
|
@@ -2261,27 +2378,27 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2261
2378
|
disabled: unref(disabled)
|
|
2262
2379
|
}, {
|
|
2263
2380
|
default: withCtx(() => [
|
|
2264
|
-
|
|
2381
|
+
__props.data.icon ? (openBlock(), createBlock(_sfc_main$h, {
|
|
2265
2382
|
key: 0,
|
|
2266
|
-
icon:
|
|
2383
|
+
icon: __props.data.icon
|
|
2267
2384
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
2268
|
-
createElementVNode("span", null, toDisplayString(
|
|
2385
|
+
createElementVNode("span", null, toDisplayString(__props.data.text), 1)
|
|
2269
2386
|
]),
|
|
2270
2387
|
_: 1
|
|
2271
2388
|
}, 8, ["disabled"]))
|
|
2272
|
-
], 64)) :
|
|
2273
|
-
key:
|
|
2389
|
+
], 64)) : __props.data.type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
|
|
2390
|
+
key: 3,
|
|
2274
2391
|
trigger: "click",
|
|
2275
2392
|
disabled: unref(disabled),
|
|
2276
2393
|
onCommand: dropdownHandler
|
|
2277
2394
|
}, {
|
|
2278
2395
|
dropdown: withCtx(() => [
|
|
2279
|
-
|
|
2396
|
+
__props.data.items && __props.data.items.length ? (openBlock(), createBlock(_component_el_dropdown_menu, { key: 0 }, {
|
|
2280
2397
|
default: withCtx(() => [
|
|
2281
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
2398
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.data.items, (subItem, index) => {
|
|
2282
2399
|
return openBlock(), createBlock(_component_el_dropdown_item, {
|
|
2283
2400
|
key: index,
|
|
2284
|
-
command: {
|
|
2401
|
+
command: { data: __props.data, subItem }
|
|
2285
2402
|
}, {
|
|
2286
2403
|
default: withCtx(() => [
|
|
2287
2404
|
createTextVNode(toDisplayString(subItem.text), 1)
|
|
@@ -2294,8 +2411,8 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2294
2411
|
})) : createCommentVNode("", true)
|
|
2295
2412
|
]),
|
|
2296
2413
|
default: withCtx(() => [
|
|
2297
|
-
createElementVNode("span",
|
|
2298
|
-
createTextVNode(toDisplayString(
|
|
2414
|
+
createElementVNode("span", _hoisted_2$2, [
|
|
2415
|
+
createTextVNode(toDisplayString(__props.data.text), 1),
|
|
2299
2416
|
createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2300
2417
|
default: withCtx(() => [
|
|
2301
2418
|
createVNode(unref(ArrowDown))
|
|
@@ -2305,67 +2422,187 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2305
2422
|
])
|
|
2306
2423
|
]),
|
|
2307
2424
|
_: 1
|
|
2308
|
-
}, 8, ["disabled"])) :
|
|
2425
|
+
}, 8, ["disabled"])) : __props.data.type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(__props.data.component), normalizeProps(mergeProps({ key: 4 }, __props.data.props || {})), null, 16)) : createCommentVNode("", true)
|
|
2309
2426
|
], 34)) : createCommentVNode("", true);
|
|
2310
2427
|
};
|
|
2311
2428
|
}
|
|
2312
2429
|
});
|
|
2313
2430
|
|
|
2314
|
-
const _sfc_main$
|
|
2315
|
-
|
|
2316
|
-
components: { ToolButton: _sfc_main$f },
|
|
2431
|
+
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
2432
|
+
__name: "NavMenu",
|
|
2317
2433
|
props: {
|
|
2318
|
-
data: {
|
|
2319
|
-
|
|
2320
|
-
default: () => ({})
|
|
2321
|
-
},
|
|
2322
|
-
height: {
|
|
2323
|
-
type: Number
|
|
2324
|
-
}
|
|
2434
|
+
data: { default: () => ({}) },
|
|
2435
|
+
height: { default: 35 }
|
|
2325
2436
|
},
|
|
2326
|
-
setup(
|
|
2437
|
+
setup(__props) {
|
|
2438
|
+
const props = __props;
|
|
2327
2439
|
const services = inject("services");
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2440
|
+
const uiService = services?.uiService;
|
|
2441
|
+
const columnWidth = computed(() => services?.uiService.get("columnWidth"));
|
|
2442
|
+
const keys = Object.values(ColumnLayout);
|
|
2443
|
+
const showGuides = computed(() => uiService?.get("showGuides") ?? true);
|
|
2444
|
+
const showRule = computed(() => uiService?.get("showRule") ?? true);
|
|
2445
|
+
const zoom = computed(() => uiService?.get("zoom") ?? 1);
|
|
2446
|
+
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
2447
|
+
const ctrl = isMac ? "Command" : "Ctrl";
|
|
2448
|
+
const getConfig = (item) => {
|
|
2449
|
+
if (typeof item !== "string") {
|
|
2450
|
+
return [item];
|
|
2451
|
+
}
|
|
2452
|
+
const config = [];
|
|
2453
|
+
switch (item) {
|
|
2454
|
+
case "/":
|
|
2455
|
+
config.push({
|
|
2456
|
+
type: "divider",
|
|
2457
|
+
className: "divider"
|
|
2458
|
+
});
|
|
2459
|
+
break;
|
|
2460
|
+
case "zoom":
|
|
2461
|
+
config.push(...getConfig("zoom-out"), ...getConfig(`${parseInt(`${zoom.value * 100}`, 10)}%`), ...getConfig("zoom-in"), ...getConfig("scale-to-original"), ...getConfig("scale-to-fit"));
|
|
2462
|
+
break;
|
|
2463
|
+
case "delete":
|
|
2464
|
+
config.push({
|
|
2465
|
+
type: "button",
|
|
2466
|
+
className: "delete",
|
|
2467
|
+
icon: markRaw(Delete),
|
|
2468
|
+
tooltip: `\u522A\u9664(Delete)`,
|
|
2469
|
+
disabled: () => services?.editorService.get("node")?.type === NodeType.PAGE,
|
|
2470
|
+
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
2471
|
+
});
|
|
2472
|
+
break;
|
|
2473
|
+
case "undo":
|
|
2474
|
+
config.push({
|
|
2475
|
+
type: "button",
|
|
2476
|
+
className: "undo",
|
|
2477
|
+
icon: markRaw(Back),
|
|
2478
|
+
tooltip: `\u540E\u9000(${ctrl}+z)`,
|
|
2479
|
+
disabled: () => !services?.historyService.state.canUndo,
|
|
2480
|
+
handler: () => services?.editorService.undo()
|
|
2481
|
+
});
|
|
2482
|
+
break;
|
|
2483
|
+
case "redo":
|
|
2484
|
+
config.push({
|
|
2485
|
+
type: "button",
|
|
2486
|
+
className: "redo",
|
|
2487
|
+
icon: markRaw(Right),
|
|
2488
|
+
tooltip: `\u524D\u8FDB(${ctrl}+Shift+z)`,
|
|
2489
|
+
disabled: () => !services?.historyService.state.canRedo,
|
|
2490
|
+
handler: () => services?.editorService.redo()
|
|
2491
|
+
});
|
|
2492
|
+
break;
|
|
2493
|
+
case "zoom-in":
|
|
2494
|
+
config.push({
|
|
2495
|
+
type: "button",
|
|
2496
|
+
className: "zoom-in",
|
|
2497
|
+
icon: markRaw(ZoomIn),
|
|
2498
|
+
tooltip: `\u653E\u5927(${ctrl}+=)`,
|
|
2499
|
+
handler: () => uiService?.zoom(0.1)
|
|
2500
|
+
});
|
|
2501
|
+
break;
|
|
2502
|
+
case "zoom-out":
|
|
2503
|
+
config.push({
|
|
2504
|
+
type: "button",
|
|
2505
|
+
className: "zoom-out",
|
|
2506
|
+
icon: markRaw(ZoomOut),
|
|
2507
|
+
tooltip: `\u7E2E\u5C0F(${ctrl}+-)`,
|
|
2508
|
+
handler: () => uiService?.zoom(-0.1)
|
|
2509
|
+
});
|
|
2510
|
+
break;
|
|
2511
|
+
case "scale-to-original":
|
|
2512
|
+
config.push({
|
|
2513
|
+
type: "button",
|
|
2514
|
+
className: "scale-to-original",
|
|
2515
|
+
icon: markRaw(ScaleToOriginal),
|
|
2516
|
+
tooltip: `\u7F29\u653E\u5230\u5B9E\u9645\u5927\u5C0F(${ctrl}+1)`,
|
|
2517
|
+
handler: () => uiService?.set("zoom", 1)
|
|
2518
|
+
});
|
|
2519
|
+
break;
|
|
2520
|
+
case "scale-to-fit":
|
|
2521
|
+
config.push({
|
|
2522
|
+
type: "button",
|
|
2523
|
+
className: "scale-to-fit",
|
|
2524
|
+
icon: markRaw(FullScreen),
|
|
2525
|
+
tooltip: `\u7F29\u653E\u4EE5\u9002\u5E94(${ctrl}+0)`,
|
|
2526
|
+
handler: () => uiService?.set("zoom", uiService.calcZoom())
|
|
2527
|
+
});
|
|
2528
|
+
break;
|
|
2529
|
+
case "rule":
|
|
2530
|
+
config.push({
|
|
2531
|
+
type: "button",
|
|
2532
|
+
className: "rule",
|
|
2533
|
+
icon: markRaw(Memo),
|
|
2534
|
+
tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
|
|
2535
|
+
handler: () => uiService?.set("showRule", !showRule.value)
|
|
2536
|
+
});
|
|
2537
|
+
break;
|
|
2538
|
+
case "guides":
|
|
2539
|
+
config.push({
|
|
2540
|
+
type: "button",
|
|
2541
|
+
className: "guides",
|
|
2542
|
+
icon: markRaw(Grid),
|
|
2543
|
+
tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
|
|
2544
|
+
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
2545
|
+
});
|
|
2546
|
+
break;
|
|
2547
|
+
default:
|
|
2548
|
+
config.push({
|
|
2549
|
+
type: "text",
|
|
2550
|
+
text: item
|
|
2551
|
+
});
|
|
2552
|
+
}
|
|
2553
|
+
return config;
|
|
2331
2554
|
};
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2555
|
+
const buttons = computed(() => {
|
|
2556
|
+
const data = {
|
|
2557
|
+
[ColumnLayout.LEFT]: [],
|
|
2558
|
+
[ColumnLayout.CENTER]: [],
|
|
2559
|
+
[ColumnLayout.RIGHT]: []
|
|
2560
|
+
};
|
|
2561
|
+
keys.forEach((key) => {
|
|
2562
|
+
const items = props.data[key] || [];
|
|
2563
|
+
items.forEach((item) => {
|
|
2564
|
+
data[key].push(...getConfig(item));
|
|
2565
|
+
});
|
|
2566
|
+
});
|
|
2567
|
+
return data;
|
|
2568
|
+
});
|
|
2569
|
+
return (_ctx, _cache) => {
|
|
2342
2570
|
return openBlock(), createElementBlock("div", {
|
|
2343
|
-
class:
|
|
2344
|
-
|
|
2345
|
-
style: normalizeStyle(`width: ${_ctx.columnWidth?.[key]}px`)
|
|
2571
|
+
class: "m-editor-nav-menu",
|
|
2572
|
+
style: normalizeStyle({ height: `${__props.height}px` })
|
|
2346
2573
|
}, [
|
|
2347
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
2348
|
-
return openBlock(),
|
|
2349
|
-
|
|
2350
|
-
key
|
|
2351
|
-
|
|
2574
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(keys), (key) => {
|
|
2575
|
+
return openBlock(), createElementBlock("div", {
|
|
2576
|
+
class: normalizeClass(`menu-${key}`),
|
|
2577
|
+
key,
|
|
2578
|
+
style: normalizeStyle(`width: ${unref(columnWidth)?.[key]}px`)
|
|
2579
|
+
}, [
|
|
2580
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(buttons)[key], (item, index) => {
|
|
2581
|
+
return openBlock(), createBlock(_sfc_main$g, {
|
|
2582
|
+
data: item,
|
|
2583
|
+
key: index
|
|
2584
|
+
}, null, 8, ["data"]);
|
|
2585
|
+
}), 128))
|
|
2586
|
+
], 6);
|
|
2352
2587
|
}), 128))
|
|
2353
|
-
],
|
|
2354
|
-
}
|
|
2355
|
-
|
|
2356
|
-
}
|
|
2357
|
-
const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
|
|
2588
|
+
], 4);
|
|
2589
|
+
};
|
|
2590
|
+
}
|
|
2591
|
+
});
|
|
2358
2592
|
|
|
2359
|
-
const
|
|
2360
|
-
|
|
2593
|
+
const _hoisted_1$4 = { class: "`m-editor-props-panel" };
|
|
2594
|
+
const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
2595
|
+
__name: "PropsPanel",
|
|
2361
2596
|
emits: ["mounted"],
|
|
2362
|
-
setup(
|
|
2597
|
+
setup(__props, { expose, emit }) {
|
|
2363
2598
|
const internalInstance = getCurrentInstance();
|
|
2364
2599
|
const values = ref({});
|
|
2365
2600
|
const configForm = ref();
|
|
2366
2601
|
const curFormConfig = ref([]);
|
|
2367
2602
|
const services = inject("services");
|
|
2368
2603
|
const node = computed(() => services?.editorService.get("node"));
|
|
2604
|
+
const propsPanelSize = computed(() => services?.uiService.get("propsPanelSize") || "small");
|
|
2605
|
+
const stage = computed(() => services?.editorService.get("stage"));
|
|
2369
2606
|
const init = async () => {
|
|
2370
2607
|
if (!node.value) {
|
|
2371
2608
|
curFormConfig.value = [];
|
|
@@ -2380,51 +2617,49 @@ const _sfc_main$d = defineComponent({
|
|
|
2380
2617
|
onMounted(() => {
|
|
2381
2618
|
emit("mounted", internalInstance);
|
|
2382
2619
|
});
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
}
|
|
2620
|
+
watchEffect(() => {
|
|
2621
|
+
if (configForm.value && stage.value) {
|
|
2622
|
+
configForm.value.formState.stage = stage.value;
|
|
2623
|
+
}
|
|
2624
|
+
});
|
|
2625
|
+
const submit = async () => {
|
|
2626
|
+
try {
|
|
2627
|
+
const values2 = await configForm.value?.submitForm();
|
|
2628
|
+
services?.editorService.update(values2);
|
|
2629
|
+
} catch (e) {
|
|
2630
|
+
console.error(e);
|
|
2631
|
+
ElMessage.closeAll();
|
|
2632
|
+
ElMessage.error({
|
|
2633
|
+
duration: 1e4,
|
|
2634
|
+
showClose: true,
|
|
2635
|
+
message: e.message,
|
|
2636
|
+
dangerouslyUseHTMLString: true
|
|
2637
|
+
});
|
|
2402
2638
|
}
|
|
2403
2639
|
};
|
|
2640
|
+
expose({ submit });
|
|
2641
|
+
return (_ctx, _cache) => {
|
|
2642
|
+
const _component_m_form = resolveComponent("m-form");
|
|
2643
|
+
return openBlock(), createElementBlock("div", _hoisted_1$4, [
|
|
2644
|
+
renderSlot(_ctx.$slots, "props-panel-header"),
|
|
2645
|
+
createVNode(_component_m_form, {
|
|
2646
|
+
ref_key: "configForm",
|
|
2647
|
+
ref: configForm,
|
|
2648
|
+
class: normalizeClass(`m-editor-props-panel ${unref(propsPanelSize)}`),
|
|
2649
|
+
"popper-class": `m-editor-props-panel-popper ${unref(propsPanelSize)}`,
|
|
2650
|
+
size: unref(propsPanelSize),
|
|
2651
|
+
"init-values": values.value,
|
|
2652
|
+
config: curFormConfig.value,
|
|
2653
|
+
onChange: submit
|
|
2654
|
+
}, null, 8, ["class", "popper-class", "size", "init-values", "config"])
|
|
2655
|
+
]);
|
|
2656
|
+
};
|
|
2404
2657
|
}
|
|
2405
2658
|
});
|
|
2406
2659
|
|
|
2407
|
-
const
|
|
2408
|
-
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2409
|
-
const _component_m_form = resolveComponent("m-form");
|
|
2410
|
-
return openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
2411
|
-
renderSlot(_ctx.$slots, "props-panel-header"),
|
|
2412
|
-
createVNode(_component_m_form, {
|
|
2413
|
-
class: normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
|
|
2414
|
-
"popper-class": `m-editor-props-panel-popper ${_ctx.propsPanelSize}`,
|
|
2415
|
-
ref: "configForm",
|
|
2416
|
-
size: _ctx.propsPanelSize,
|
|
2417
|
-
"init-values": _ctx.values,
|
|
2418
|
-
config: _ctx.curFormConfig,
|
|
2419
|
-
onChange: _ctx.submit
|
|
2420
|
-
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
|
|
2421
|
-
]);
|
|
2422
|
-
}
|
|
2423
|
-
const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
|
|
2424
|
-
|
|
2425
|
-
const _sfc_main$c = defineComponent({
|
|
2660
|
+
const _sfc_main$d = defineComponent({
|
|
2426
2661
|
name: "ui-component-panel",
|
|
2427
|
-
components: { MIcon },
|
|
2662
|
+
components: { MIcon: _sfc_main$h },
|
|
2428
2663
|
setup() {
|
|
2429
2664
|
const searchText = ref("");
|
|
2430
2665
|
const services = inject("services");
|
|
@@ -2489,9 +2724,9 @@ const _sfc_main$c = defineComponent({
|
|
|
2489
2724
|
}
|
|
2490
2725
|
});
|
|
2491
2726
|
|
|
2492
|
-
const _hoisted_1$
|
|
2727
|
+
const _hoisted_1$3 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
2493
2728
|
const _hoisted_2$1 = ["onClick", "onDragstart"];
|
|
2494
|
-
function _sfc_render$
|
|
2729
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2495
2730
|
const _component_el_input = resolveComponent("el-input");
|
|
2496
2731
|
const _component_m_icon = resolveComponent("m-icon");
|
|
2497
2732
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
@@ -2522,7 +2757,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2522
2757
|
name: index
|
|
2523
2758
|
}, {
|
|
2524
2759
|
title: withCtx(() => [
|
|
2525
|
-
_hoisted_1$
|
|
2760
|
+
_hoisted_1$3,
|
|
2526
2761
|
createTextVNode(toDisplayString(group.title), 1)
|
|
2527
2762
|
]),
|
|
2528
2763
|
default: withCtx(() => [
|
|
@@ -2563,9 +2798,9 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2563
2798
|
_: 3
|
|
2564
2799
|
});
|
|
2565
2800
|
}
|
|
2566
|
-
const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2801
|
+
const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$5]]);
|
|
2567
2802
|
|
|
2568
|
-
const _sfc_main$
|
|
2803
|
+
const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
2569
2804
|
__name: "ContentMenu",
|
|
2570
2805
|
props: {
|
|
2571
2806
|
menuData: { default: () => [] },
|
|
@@ -2654,7 +2889,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
2654
2889
|
}, [
|
|
2655
2890
|
createElementVNode("div", null, [
|
|
2656
2891
|
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.menuData, (item, index) => {
|
|
2657
|
-
return openBlock(), createBlock(_sfc_main$
|
|
2892
|
+
return openBlock(), createBlock(_sfc_main$g, {
|
|
2658
2893
|
"event-type": "mouseup",
|
|
2659
2894
|
data: item,
|
|
2660
2895
|
key: index,
|
|
@@ -2678,8 +2913,8 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
2678
2913
|
}
|
|
2679
2914
|
});
|
|
2680
2915
|
|
|
2681
|
-
const _sfc_main$
|
|
2682
|
-
components: { ContentMenu: _sfc_main$
|
|
2916
|
+
const _sfc_main$b = defineComponent({
|
|
2917
|
+
components: { ContentMenu: _sfc_main$c },
|
|
2683
2918
|
setup() {
|
|
2684
2919
|
const services = inject("services");
|
|
2685
2920
|
const menu = ref();
|
|
@@ -2762,7 +2997,7 @@ const _sfc_main$a = defineComponent({
|
|
|
2762
2997
|
}
|
|
2763
2998
|
});
|
|
2764
2999
|
|
|
2765
|
-
function _sfc_render$
|
|
3000
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2766
3001
|
const _component_content_menu = resolveComponent("content-menu");
|
|
2767
3002
|
return openBlock(), createBlock(_component_content_menu, {
|
|
2768
3003
|
"menu-data": _ctx.menuData,
|
|
@@ -2770,7 +3005,7 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2770
3005
|
style: { "overflow": "initial" }
|
|
2771
3006
|
}, null, 8, ["menu-data"]);
|
|
2772
3007
|
}
|
|
2773
|
-
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3008
|
+
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$4]]);
|
|
2774
3009
|
|
|
2775
3010
|
const throttleTime = 150;
|
|
2776
3011
|
const select = async (data, editorService) => {
|
|
@@ -2821,20 +3056,38 @@ const useDrop = (tree, editorService) => ({
|
|
|
2821
3056
|
}
|
|
2822
3057
|
});
|
|
2823
3058
|
const useStatus = (tree, editorService) => {
|
|
2824
|
-
const highlightNode = ref();
|
|
2825
3059
|
const node = ref();
|
|
2826
3060
|
const page = computed(() => editorService?.get("page"));
|
|
3061
|
+
const expandedKeys = /* @__PURE__ */ new Map();
|
|
3062
|
+
const expandNodes = () => {
|
|
3063
|
+
expandedKeys.forEach((key) => {
|
|
3064
|
+
if (!tree.value)
|
|
3065
|
+
return;
|
|
3066
|
+
tree.value.getNode(key)?.expand();
|
|
3067
|
+
});
|
|
3068
|
+
};
|
|
2827
3069
|
watchEffect(() => {
|
|
2828
3070
|
if (!tree.value)
|
|
2829
3071
|
return;
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
3072
|
+
if (!editorService)
|
|
3073
|
+
return;
|
|
3074
|
+
node.value = editorService.get("node");
|
|
3075
|
+
if (!node.value)
|
|
3076
|
+
return;
|
|
3077
|
+
tree.value.setCurrentKey(node.value.id, true);
|
|
3078
|
+
const parent = editorService.get("parent");
|
|
2833
3079
|
if (!parent?.id)
|
|
2834
3080
|
return;
|
|
2835
3081
|
const treeNode = tree.value.getNode(parent.id);
|
|
2836
3082
|
treeNode?.updateChildren();
|
|
2837
|
-
|
|
3083
|
+
setTimeout(() => {
|
|
3084
|
+
tree.value && Object.entries(tree.value.store.nodesMap).forEach(([id, node2]) => {
|
|
3085
|
+
if (node2.expanded && node2.data.items) {
|
|
3086
|
+
expandedKeys.set(id, id);
|
|
3087
|
+
}
|
|
3088
|
+
});
|
|
3089
|
+
expandNodes();
|
|
3090
|
+
});
|
|
2838
3091
|
});
|
|
2839
3092
|
return {
|
|
2840
3093
|
values: computed(() => page.value ? [page.value] : []),
|
|
@@ -2847,9 +3100,18 @@ const useStatus = (tree, editorService) => {
|
|
|
2847
3100
|
}
|
|
2848
3101
|
resolve([]);
|
|
2849
3102
|
},
|
|
2850
|
-
highlightNode,
|
|
3103
|
+
highlightNode: computed(() => editorService?.get("highlightNode")),
|
|
2851
3104
|
clickNode: node,
|
|
2852
|
-
expandedKeys: computed(() => node.value ? [node.value.id] : [])
|
|
3105
|
+
expandedKeys: computed(() => node.value ? [node.value.id] : []),
|
|
3106
|
+
handleCollapse: (data) => {
|
|
3107
|
+
expandedKeys.delete(data.id);
|
|
3108
|
+
},
|
|
3109
|
+
handleExpand: (data) => {
|
|
3110
|
+
const parent = editorService?.getParentById(data.id);
|
|
3111
|
+
if (!parent?.id)
|
|
3112
|
+
return;
|
|
3113
|
+
expandedKeys.set(parent.id, parent.id);
|
|
3114
|
+
}
|
|
2853
3115
|
};
|
|
2854
3116
|
};
|
|
2855
3117
|
const useFilter = (tree) => ({
|
|
@@ -2870,7 +3132,7 @@ const useFilter = (tree) => ({
|
|
|
2870
3132
|
tree.value?.filter(val);
|
|
2871
3133
|
}
|
|
2872
3134
|
});
|
|
2873
|
-
const _sfc_main$
|
|
3135
|
+
const _sfc_main$a = defineComponent({
|
|
2874
3136
|
name: "magic-editor-layer-panel",
|
|
2875
3137
|
components: { LayerMenu },
|
|
2876
3138
|
setup() {
|
|
@@ -2918,8 +3180,8 @@ const _sfc_main$9 = defineComponent({
|
|
|
2918
3180
|
}
|
|
2919
3181
|
});
|
|
2920
3182
|
|
|
2921
|
-
const _hoisted_1$
|
|
2922
|
-
function _sfc_render$
|
|
3183
|
+
const _hoisted_1$2 = ["id", "onMouseenter"];
|
|
3184
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2923
3185
|
const _component_el_input = resolveComponent("el-input");
|
|
2924
3186
|
const _component_el_tree = resolveComponent("el-tree");
|
|
2925
3187
|
const _component_layer_menu = resolveComponent("layer-menu");
|
|
@@ -2940,6 +3202,7 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2940
3202
|
key: 0,
|
|
2941
3203
|
ref: "tree",
|
|
2942
3204
|
"node-key": "id",
|
|
3205
|
+
"empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
|
|
2943
3206
|
draggable: "",
|
|
2944
3207
|
"default-expanded-keys": _ctx.expandedKeys,
|
|
2945
3208
|
load: _ctx.loadItems,
|
|
@@ -2954,7 +3217,8 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2954
3217
|
onNodeClick: _ctx.clickHandler,
|
|
2955
3218
|
onNodeContextmenu: _ctx.contextmenu,
|
|
2956
3219
|
onNodeDragEnd: _ctx.handleDragEnd,
|
|
2957
|
-
|
|
3220
|
+
onNodeCollapse: _ctx.handleCollapse,
|
|
3221
|
+
onNodeExpand: _ctx.handleExpand
|
|
2958
3222
|
}, {
|
|
2959
3223
|
default: withCtx(({ node, data }) => [
|
|
2960
3224
|
createElementVNode("div", {
|
|
@@ -2970,10 +3234,10 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2970
3234
|
}, () => [
|
|
2971
3235
|
createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
|
|
2972
3236
|
])
|
|
2973
|
-
], 42, _hoisted_1$
|
|
3237
|
+
], 42, _hoisted_1$2)
|
|
2974
3238
|
]),
|
|
2975
3239
|
_: 3
|
|
2976
|
-
}, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : createCommentVNode("", true),
|
|
3240
|
+
}, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd", "onNodeCollapse", "onNodeExpand"])) : createCommentVNode("", true),
|
|
2977
3241
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
2978
3242
|
createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
|
|
2979
3243
|
]))
|
|
@@ -2981,10 +3245,10 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2981
3245
|
_: 3
|
|
2982
3246
|
});
|
|
2983
3247
|
}
|
|
2984
|
-
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3248
|
+
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$3]]);
|
|
2985
3249
|
|
|
2986
|
-
const _sfc_main$
|
|
2987
|
-
components: { MIcon },
|
|
3250
|
+
const _sfc_main$9 = defineComponent({
|
|
3251
|
+
components: { MIcon: _sfc_main$h },
|
|
2988
3252
|
props: {
|
|
2989
3253
|
data: {
|
|
2990
3254
|
type: [Object, String]
|
|
@@ -3021,11 +3285,11 @@ const _sfc_main$8 = defineComponent({
|
|
|
3021
3285
|
}
|
|
3022
3286
|
});
|
|
3023
3287
|
|
|
3024
|
-
const _hoisted_1$
|
|
3288
|
+
const _hoisted_1$1 = {
|
|
3025
3289
|
key: 1,
|
|
3026
3290
|
class: "magic-editor-tab-panel-title"
|
|
3027
3291
|
};
|
|
3028
|
-
function _sfc_render$
|
|
3292
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3029
3293
|
const _component_m_icon = resolveComponent("m-icon");
|
|
3030
3294
|
const _component_el_tab_pane = resolveComponent("el-tab-pane");
|
|
3031
3295
|
return _ctx.config ? (openBlock(), createBlock(_component_el_tab_pane, {
|
|
@@ -3040,7 +3304,7 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3040
3304
|
key: 0,
|
|
3041
3305
|
icon: _ctx.config.icon
|
|
3042
3306
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
3043
|
-
_ctx.config.text ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
3307
|
+
_ctx.config.text ? (openBlock(), createElementBlock("div", _hoisted_1$1, toDisplayString(_ctx.config.text), 1)) : createCommentVNode("", true)
|
|
3044
3308
|
]))
|
|
3045
3309
|
]),
|
|
3046
3310
|
default: withCtx(() => [
|
|
@@ -3071,9 +3335,9 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3071
3335
|
_: 3
|
|
3072
3336
|
}, 8, ["name"])) : createCommentVNode("", true);
|
|
3073
3337
|
}
|
|
3074
|
-
const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3338
|
+
const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$2]]);
|
|
3075
3339
|
|
|
3076
|
-
const _sfc_main$
|
|
3340
|
+
const _sfc_main$8 = defineComponent({
|
|
3077
3341
|
components: { TabPane },
|
|
3078
3342
|
name: "m-sidebar",
|
|
3079
3343
|
props: {
|
|
@@ -3093,7 +3357,7 @@ const _sfc_main$7 = defineComponent({
|
|
|
3093
3357
|
}
|
|
3094
3358
|
});
|
|
3095
3359
|
|
|
3096
|
-
function _sfc_render$
|
|
3360
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3097
3361
|
const _component_tab_pane = resolveComponent("tab-pane");
|
|
3098
3362
|
const _component_el_tabs = resolveComponent("el-tabs");
|
|
3099
3363
|
return _ctx.data.type === "tabs" && _ctx.data.items.length ? (openBlock(), createBlock(_component_el_tabs, {
|
|
@@ -3128,9 +3392,9 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3128
3392
|
_: 3
|
|
3129
3393
|
}, 8, ["modelValue"])) : createCommentVNode("", true);
|
|
3130
3394
|
}
|
|
3131
|
-
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3395
|
+
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$1]]);
|
|
3132
3396
|
|
|
3133
|
-
const _sfc_main$
|
|
3397
|
+
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
3134
3398
|
__name: "PageBarScrollContainer",
|
|
3135
3399
|
setup(__props) {
|
|
3136
3400
|
const services = inject("services");
|
|
@@ -3257,9 +3521,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
3257
3521
|
}
|
|
3258
3522
|
});
|
|
3259
3523
|
|
|
3260
|
-
const _hoisted_1
|
|
3524
|
+
const _hoisted_1 = ["onClick"];
|
|
3261
3525
|
const _hoisted_2 = { class: "m-editor-page-bar-title" };
|
|
3262
|
-
const _sfc_main$
|
|
3526
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
3263
3527
|
__name: "PageBar",
|
|
3264
3528
|
setup(__props) {
|
|
3265
3529
|
const services = inject("services");
|
|
@@ -3283,7 +3547,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3283
3547
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
3284
3548
|
const _component_el_icon = resolveComponent("el-icon");
|
|
3285
3549
|
const _component_el_popover = resolveComponent("el-popover");
|
|
3286
|
-
return openBlock(), createBlock(_sfc_main$
|
|
3550
|
+
return openBlock(), createBlock(_sfc_main$7, null, {
|
|
3287
3551
|
default: withCtx(() => [
|
|
3288
3552
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(root) && unref(root).items || [], (item) => {
|
|
3289
3553
|
return openBlock(), createElementBlock("div", {
|
|
@@ -3299,7 +3563,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3299
3563
|
content: item.name
|
|
3300
3564
|
}, {
|
|
3301
3565
|
default: withCtx(() => [
|
|
3302
|
-
createElementVNode("span", null, toDisplayString(item.name), 1)
|
|
3566
|
+
createElementVNode("span", null, toDisplayString(item.name || item.id), 1)
|
|
3303
3567
|
]),
|
|
3304
3568
|
_: 2
|
|
3305
3569
|
}, 1032, ["content"])
|
|
@@ -3322,7 +3586,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3322
3586
|
default: withCtx(() => [
|
|
3323
3587
|
createElementVNode("div", null, [
|
|
3324
3588
|
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3325
|
-
createVNode(_sfc_main$
|
|
3589
|
+
createVNode(_sfc_main$g, {
|
|
3326
3590
|
data: {
|
|
3327
3591
|
type: "button",
|
|
3328
3592
|
text: "\u590D\u5236",
|
|
@@ -3330,7 +3594,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3330
3594
|
handler: () => copy(item)
|
|
3331
3595
|
}
|
|
3332
3596
|
}, null, 8, ["data"]),
|
|
3333
|
-
createVNode(_sfc_main$
|
|
3597
|
+
createVNode(_sfc_main$g, {
|
|
3334
3598
|
data: {
|
|
3335
3599
|
type: "button",
|
|
3336
3600
|
text: "\u5220\u9664",
|
|
@@ -3343,7 +3607,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3343
3607
|
]),
|
|
3344
3608
|
_: 2
|
|
3345
3609
|
}, 1024)
|
|
3346
|
-
], 10, _hoisted_1
|
|
3610
|
+
], 10, _hoisted_1);
|
|
3347
3611
|
}), 128))
|
|
3348
3612
|
]),
|
|
3349
3613
|
_: 3
|
|
@@ -3352,190 +3616,245 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3352
3616
|
}
|
|
3353
3617
|
});
|
|
3354
3618
|
|
|
3355
|
-
class ScrollViewer
|
|
3356
|
-
enter = false;
|
|
3357
|
-
targetEnter = false;
|
|
3358
|
-
keydown = false;
|
|
3619
|
+
class ScrollViewer extends EventEmitter {
|
|
3359
3620
|
container;
|
|
3360
3621
|
target;
|
|
3361
3622
|
zoom = 1;
|
|
3362
3623
|
scrollLeft = 0;
|
|
3363
3624
|
scrollTop = 0;
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
if (targetWidth < width) {
|
|
3374
|
-
this.target._left = 0;
|
|
3375
|
-
}
|
|
3376
|
-
if (targetHeight < height) {
|
|
3377
|
-
this.target._top = 0;
|
|
3378
|
-
}
|
|
3379
|
-
this.scroll();
|
|
3380
|
-
}
|
|
3625
|
+
scrollHeight = 0;
|
|
3626
|
+
scrollWidth = 0;
|
|
3627
|
+
width = 0;
|
|
3628
|
+
height = 0;
|
|
3629
|
+
translateXCorrectionValue = 0;
|
|
3630
|
+
translateYCorrectionValue = 0;
|
|
3631
|
+
resizeObserver = new ResizeObserver(() => {
|
|
3632
|
+
this.setSize();
|
|
3633
|
+
this.setScrollSize();
|
|
3381
3634
|
});
|
|
3382
3635
|
constructor(options) {
|
|
3636
|
+
super();
|
|
3383
3637
|
this.container = options.container;
|
|
3384
3638
|
this.target = options.target;
|
|
3385
3639
|
this.zoom = options.zoom;
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
this.
|
|
3389
|
-
this.container.addEventListener("mouseleave", this.mouseLeaveHandler);
|
|
3390
|
-
this.target.addEventListener("mouseenter", this.targetMouseEnterHandler);
|
|
3391
|
-
this.target.addEventListener("mouseleave", this.targetMouseLeaveHandler);
|
|
3392
|
-
this.container.addEventListener("wheel", this.wheelHandler);
|
|
3640
|
+
this.container.addEventListener("wheel", this.wheelHandler, false);
|
|
3641
|
+
this.setSize();
|
|
3642
|
+
this.setScrollSize();
|
|
3393
3643
|
this.resizeObserver.observe(this.container);
|
|
3394
3644
|
}
|
|
3395
3645
|
destroy() {
|
|
3396
3646
|
this.resizeObserver.disconnect();
|
|
3397
|
-
this.container.removeEventListener("
|
|
3398
|
-
this.
|
|
3399
|
-
this.target.removeEventListener("mouseenter", this.targetMouseEnterHandler);
|
|
3400
|
-
this.target.removeEventListener("mouseleave", this.targetMouseLeaveHandler);
|
|
3401
|
-
globalThis.removeEventListener("keydown", this.keydownHandler);
|
|
3402
|
-
globalThis.removeEventListener("keyup", this.keyupHandler);
|
|
3647
|
+
this.container.removeEventListener("wheel", this.wheelHandler, false);
|
|
3648
|
+
this.removeAllListeners();
|
|
3403
3649
|
}
|
|
3404
3650
|
setZoom(zoom) {
|
|
3405
3651
|
this.zoom = zoom;
|
|
3652
|
+
this.setScrollSize();
|
|
3406
3653
|
}
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
this.
|
|
3415
|
-
|
|
3416
|
-
|
|
3654
|
+
scrollTo({ left, top }) {
|
|
3655
|
+
if (typeof left !== "undefined") {
|
|
3656
|
+
this.scrollLeft = left;
|
|
3657
|
+
}
|
|
3658
|
+
if (typeof top !== "undefined") {
|
|
3659
|
+
this.scrollTop = top;
|
|
3660
|
+
}
|
|
3661
|
+
const translateX = -this.scrollLeft + this.translateXCorrectionValue;
|
|
3662
|
+
const translateY = -this.scrollTop + this.translateYCorrectionValue;
|
|
3663
|
+
this.target.style.transform = `translate(${translateX}px, ${translateY}px)`;
|
|
3417
3664
|
}
|
|
3418
3665
|
wheelHandler = (event) => {
|
|
3419
|
-
if (this.targetEnter)
|
|
3420
|
-
return;
|
|
3421
3666
|
const { deltaX, deltaY, currentTarget } = event;
|
|
3422
3667
|
if (currentTarget !== this.container)
|
|
3423
3668
|
return;
|
|
3424
|
-
|
|
3425
|
-
this.
|
|
3426
|
-
|
|
3427
|
-
this.scrollTop = this.target._top;
|
|
3428
|
-
};
|
|
3429
|
-
mouseEnterHandler = () => {
|
|
3430
|
-
this.enter = true;
|
|
3431
|
-
};
|
|
3432
|
-
mouseLeaveHandler = () => {
|
|
3433
|
-
this.enter = false;
|
|
3434
|
-
};
|
|
3435
|
-
targetMouseEnterHandler = () => {
|
|
3436
|
-
this.targetEnter = true;
|
|
3437
|
-
};
|
|
3438
|
-
targetMouseLeaveHandler = () => {
|
|
3439
|
-
this.targetEnter = false;
|
|
3440
|
-
};
|
|
3441
|
-
mousedownHandler = (event) => {
|
|
3442
|
-
if (!this.keydown)
|
|
3443
|
-
return;
|
|
3444
|
-
event.stopImmediatePropagation();
|
|
3445
|
-
event.stopPropagation();
|
|
3446
|
-
this.target.style.cursor = "grabbing";
|
|
3447
|
-
this.x = event.clientX;
|
|
3448
|
-
this.y = event.clientY;
|
|
3449
|
-
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3450
|
-
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3451
|
-
};
|
|
3452
|
-
mouseupHandler = () => {
|
|
3453
|
-
this.x = 0;
|
|
3454
|
-
this.y = 0;
|
|
3455
|
-
this.scrollLeft = this.target._left;
|
|
3456
|
-
this.scrollTop = this.target._top;
|
|
3457
|
-
this.removeHandler();
|
|
3458
|
-
};
|
|
3459
|
-
mousemoveHandler = (event) => {
|
|
3460
|
-
event.stopImmediatePropagation();
|
|
3461
|
-
event.stopPropagation();
|
|
3462
|
-
const deltaX = event.clientX - this.x;
|
|
3463
|
-
const deltaY = event.clientY - this.y;
|
|
3464
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3465
|
-
this.scroll();
|
|
3466
|
-
};
|
|
3467
|
-
keydownHandler = (event) => {
|
|
3468
|
-
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3469
|
-
event.preventDefault();
|
|
3470
|
-
event.stopImmediatePropagation();
|
|
3471
|
-
event.stopPropagation();
|
|
3669
|
+
let top;
|
|
3670
|
+
if (this.scrollHeight > this.height) {
|
|
3671
|
+
top = this.scrollTop + this.getPos(deltaY, this.scrollTop, this.scrollHeight, this.height);
|
|
3472
3672
|
}
|
|
3473
|
-
|
|
3474
|
-
|
|
3673
|
+
let left;
|
|
3674
|
+
if (this.scrollWidth > this.width) {
|
|
3675
|
+
left = this.scrollLeft + this.getPos(deltaX, this.scrollLeft, this.scrollWidth, this.width);
|
|
3475
3676
|
}
|
|
3476
|
-
this.
|
|
3477
|
-
this.
|
|
3478
|
-
|
|
3677
|
+
this.scrollTo({ left, top });
|
|
3678
|
+
this.emit("scroll", {
|
|
3679
|
+
scrollLeft: this.scrollLeft,
|
|
3680
|
+
scrollTop: this.scrollTop,
|
|
3681
|
+
scrollHeight: this.scrollHeight,
|
|
3682
|
+
scrollWidth: this.scrollWidth
|
|
3683
|
+
});
|
|
3479
3684
|
};
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3685
|
+
getPos(delta, scrollPos, scrollSize, size) {
|
|
3686
|
+
let pos = 0;
|
|
3687
|
+
if (delta < 0) {
|
|
3688
|
+
if (scrollPos > 0) {
|
|
3689
|
+
pos = Math.max(delta, -scrollPos);
|
|
3690
|
+
}
|
|
3691
|
+
} else {
|
|
3692
|
+
const leftPos = scrollSize - size - scrollPos;
|
|
3693
|
+
if (leftPos > 0) {
|
|
3694
|
+
pos = Math.min(delta, leftPos);
|
|
3695
|
+
}
|
|
3696
|
+
}
|
|
3697
|
+
return pos;
|
|
3698
|
+
}
|
|
3699
|
+
setScrollSize = () => {
|
|
3700
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3701
|
+
this.scrollWidth = targetRect.width * this.zoom + 100;
|
|
3702
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3703
|
+
this.scrollHeight = (targetRect.height + targetMarginTop) * this.zoom + 100;
|
|
3704
|
+
let left;
|
|
3705
|
+
let top;
|
|
3706
|
+
if (this.scrollWidth < this.width) {
|
|
3707
|
+
left = 0;
|
|
3708
|
+
this.translateXCorrectionValue = 0;
|
|
3709
|
+
} else {
|
|
3710
|
+
this.translateXCorrectionValue = (this.scrollWidth - this.width) / 2;
|
|
3483
3711
|
}
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3712
|
+
if (this.scrollHeight < this.height) {
|
|
3713
|
+
top = 0;
|
|
3714
|
+
this.translateYCorrectionValue = 0;
|
|
3715
|
+
} else {
|
|
3716
|
+
this.translateYCorrectionValue = (this.scrollHeight - this.height) / 2;
|
|
3717
|
+
}
|
|
3718
|
+
this.scrollTo({
|
|
3719
|
+
left,
|
|
3720
|
+
top
|
|
3721
|
+
});
|
|
3722
|
+
this.emit("scroll", {
|
|
3723
|
+
scrollLeft: this.scrollLeft,
|
|
3724
|
+
scrollTop: this.scrollTop,
|
|
3725
|
+
scrollHeight: this.scrollHeight,
|
|
3726
|
+
scrollWidth: this.scrollWidth
|
|
3727
|
+
});
|
|
3490
3728
|
};
|
|
3491
|
-
|
|
3729
|
+
setSize = () => {
|
|
3492
3730
|
const { width, height } = this.container.getBoundingClientRect();
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3731
|
+
this.width = width;
|
|
3732
|
+
this.height = height;
|
|
3733
|
+
};
|
|
3734
|
+
}
|
|
3735
|
+
|
|
3736
|
+
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
3737
|
+
__name: "ScrollBar",
|
|
3738
|
+
props: {
|
|
3739
|
+
size: null,
|
|
3740
|
+
scrollSize: null,
|
|
3741
|
+
isHorizontal: { type: Boolean },
|
|
3742
|
+
pos: null
|
|
3743
|
+
},
|
|
3744
|
+
emits: ["scroll"],
|
|
3745
|
+
setup(__props, { emit }) {
|
|
3746
|
+
const props = __props;
|
|
3747
|
+
const bar = ref();
|
|
3748
|
+
const thumb = ref();
|
|
3749
|
+
const thumbSize = computed(() => props.size * (props.size / props.scrollSize));
|
|
3750
|
+
const thumbPos = computed(() => props.pos / props.scrollSize * props.size);
|
|
3751
|
+
const thumbStyle = computed(() => ({
|
|
3752
|
+
[props.isHorizontal ? "width" : "height"]: `${thumbSize.value}px`,
|
|
3753
|
+
transform: `translate${props.isHorizontal ? "X" : "Y"}(${thumbPos.value}px)`
|
|
3754
|
+
}));
|
|
3755
|
+
let gesto;
|
|
3756
|
+
onMounted(() => {
|
|
3757
|
+
if (!thumb.value)
|
|
3758
|
+
return;
|
|
3759
|
+
const thumbEl = thumb.value;
|
|
3760
|
+
gesto = new Gesto(thumbEl, {
|
|
3761
|
+
container: window
|
|
3762
|
+
});
|
|
3763
|
+
gesto.on("dragStart", (e) => {
|
|
3764
|
+
e.inputEvent.stopPropagation();
|
|
3765
|
+
e.inputEvent.preventDefault();
|
|
3766
|
+
}).on("drag", (e) => {
|
|
3767
|
+
scrollBy(getDelta(e));
|
|
3768
|
+
});
|
|
3769
|
+
bar.value?.addEventListener("wheel", wheelHandler, false);
|
|
3770
|
+
});
|
|
3771
|
+
onUnmounted(() => {
|
|
3772
|
+
if (gesto)
|
|
3773
|
+
gesto.off();
|
|
3774
|
+
bar.value?.removeEventListener("wheel", wheelHandler, false);
|
|
3775
|
+
});
|
|
3776
|
+
const wheelHandler = (e) => {
|
|
3777
|
+
const delta = props.isHorizontal ? e.deltaX : e.deltaY;
|
|
3778
|
+
if (delta) {
|
|
3779
|
+
e.preventDefault();
|
|
3502
3780
|
}
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3781
|
+
scrollBy(delta);
|
|
3782
|
+
};
|
|
3783
|
+
const getDelta = (e) => {
|
|
3784
|
+
const ratio = (props.isHorizontal ? e.deltaX : e.deltaY) / props.size;
|
|
3785
|
+
return props.scrollSize * ratio;
|
|
3786
|
+
};
|
|
3787
|
+
const scrollBy = (delta) => {
|
|
3788
|
+
if (delta < 0) {
|
|
3789
|
+
if (props.pos <= 0) {
|
|
3790
|
+
emit("scroll", 0);
|
|
3791
|
+
} else {
|
|
3792
|
+
emit("scroll", -Math.min(-delta, props.pos));
|
|
3793
|
+
}
|
|
3508
3794
|
} else {
|
|
3509
|
-
|
|
3795
|
+
const leftPos = props.size - (thumbSize.value + thumbPos.value);
|
|
3796
|
+
if (leftPos <= 0) {
|
|
3797
|
+
emit("scroll", 0);
|
|
3798
|
+
} else {
|
|
3799
|
+
emit("scroll", Math.min(delta, leftPos));
|
|
3800
|
+
}
|
|
3510
3801
|
}
|
|
3511
|
-
}
|
|
3512
|
-
|
|
3513
|
-
|
|
3802
|
+
};
|
|
3803
|
+
return (_ctx, _cache) => {
|
|
3804
|
+
return openBlock(), createElementBlock("div", {
|
|
3805
|
+
ref_key: "bar",
|
|
3806
|
+
ref: bar,
|
|
3807
|
+
class: normalizeClass(["m-editor-scroll-bar", __props.isHorizontal ? "horizontal" : "vertical"])
|
|
3808
|
+
}, [
|
|
3809
|
+
createElementVNode("div", {
|
|
3810
|
+
ref_key: "thumb",
|
|
3811
|
+
ref: thumb,
|
|
3812
|
+
class: "m-editor-scroll-bar-thumb",
|
|
3813
|
+
style: normalizeStyle(unref(thumbStyle))
|
|
3814
|
+
}, null, 4)
|
|
3815
|
+
], 2);
|
|
3816
|
+
};
|
|
3514
3817
|
}
|
|
3515
|
-
}
|
|
3818
|
+
});
|
|
3516
3819
|
|
|
3517
|
-
const
|
|
3518
|
-
|
|
3820
|
+
const ScrollBar_vue_vue_type_style_index_0_lang = '';
|
|
3821
|
+
|
|
3822
|
+
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
3823
|
+
__name: "ScrollViewer",
|
|
3519
3824
|
props: {
|
|
3520
|
-
width:
|
|
3521
|
-
height:
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
}
|
|
3825
|
+
width: { default: 0 },
|
|
3826
|
+
height: { default: 0 },
|
|
3827
|
+
wrapWidth: { default: 0 },
|
|
3828
|
+
wrapHeight: { default: 0 },
|
|
3829
|
+
zoom: { default: 1 }
|
|
3526
3830
|
},
|
|
3527
|
-
setup(
|
|
3831
|
+
setup(__props, { expose }) {
|
|
3832
|
+
const props = __props;
|
|
3528
3833
|
const container = ref();
|
|
3529
3834
|
const el = ref();
|
|
3835
|
+
const style = computed(() => `
|
|
3836
|
+
width: ${props.width}px;
|
|
3837
|
+
height: ${props.height}px;
|
|
3838
|
+
position: absolute;
|
|
3839
|
+
margin-top: 30px;
|
|
3840
|
+
`);
|
|
3841
|
+
const scrollWidth = ref(0);
|
|
3842
|
+
const scrollHeight = ref(0);
|
|
3530
3843
|
let scrollViewer;
|
|
3531
3844
|
onMounted(() => {
|
|
3532
3845
|
if (!container.value || !el.value)
|
|
3533
3846
|
return;
|
|
3534
|
-
scrollViewer = new ScrollViewer
|
|
3847
|
+
scrollViewer = new ScrollViewer({
|
|
3535
3848
|
container: container.value,
|
|
3536
3849
|
target: el.value,
|
|
3537
3850
|
zoom: props.zoom
|
|
3538
3851
|
});
|
|
3852
|
+
scrollViewer.on("scroll", (data) => {
|
|
3853
|
+
hOffset.value = data.scrollLeft;
|
|
3854
|
+
vOffset.value = data.scrollTop;
|
|
3855
|
+
scrollWidth.value = data.scrollWidth;
|
|
3856
|
+
scrollHeight.value = data.scrollHeight;
|
|
3857
|
+
});
|
|
3539
3858
|
});
|
|
3540
3859
|
onUnmounted(() => {
|
|
3541
3860
|
scrollViewer.destroy();
|
|
@@ -3543,35 +3862,56 @@ const _sfc_main$4 = defineComponent({
|
|
|
3543
3862
|
watch(() => props.zoom, () => {
|
|
3544
3863
|
scrollViewer.setZoom(props.zoom);
|
|
3545
3864
|
});
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3865
|
+
const vOffset = ref(0);
|
|
3866
|
+
const vScrollHandler = (delta) => {
|
|
3867
|
+
vOffset.value += delta;
|
|
3868
|
+
scrollViewer.scrollTo({
|
|
3869
|
+
top: vOffset.value
|
|
3870
|
+
});
|
|
3871
|
+
};
|
|
3872
|
+
const hOffset = ref(0);
|
|
3873
|
+
const hScrollHandler = (delta) => {
|
|
3874
|
+
hOffset.value += delta;
|
|
3875
|
+
scrollViewer.scrollTo({
|
|
3876
|
+
left: hOffset.value
|
|
3877
|
+
});
|
|
3878
|
+
};
|
|
3879
|
+
expose({
|
|
3880
|
+
container
|
|
3881
|
+
});
|
|
3882
|
+
return (_ctx, _cache) => {
|
|
3883
|
+
return openBlock(), createElementBlock("div", {
|
|
3884
|
+
class: "m-editor-scroll-viewer-container",
|
|
3885
|
+
ref_key: "container",
|
|
3886
|
+
ref: container
|
|
3887
|
+
}, [
|
|
3888
|
+
createElementVNode("div", {
|
|
3889
|
+
ref_key: "el",
|
|
3890
|
+
ref: el,
|
|
3891
|
+
style: normalizeStyle(unref(style))
|
|
3892
|
+
}, [
|
|
3893
|
+
renderSlot(_ctx.$slots, "default")
|
|
3894
|
+
], 4),
|
|
3895
|
+
scrollHeight.value > __props.wrapHeight ? (openBlock(), createBlock(_sfc_main$5, {
|
|
3896
|
+
key: 0,
|
|
3897
|
+
"scroll-size": scrollHeight.value,
|
|
3898
|
+
size: __props.wrapHeight,
|
|
3899
|
+
pos: vOffset.value,
|
|
3900
|
+
onScroll: vScrollHandler
|
|
3901
|
+
}, null, 8, ["scroll-size", "size", "pos"])) : createCommentVNode("", true),
|
|
3902
|
+
scrollWidth.value > __props.wrapWidth ? (openBlock(), createBlock(_sfc_main$5, {
|
|
3903
|
+
key: 1,
|
|
3904
|
+
"is-horizontal": true,
|
|
3905
|
+
"scroll-size": scrollWidth.value,
|
|
3906
|
+
pos: hOffset.value,
|
|
3907
|
+
size: __props.wrapWidth,
|
|
3908
|
+
onScroll: hScrollHandler
|
|
3909
|
+
}, null, 8, ["scroll-size", "pos", "size"])) : createCommentVNode("", true)
|
|
3910
|
+
], 512);
|
|
3555
3911
|
};
|
|
3556
3912
|
}
|
|
3557
3913
|
});
|
|
3558
3914
|
|
|
3559
|
-
const _hoisted_1$1 = {
|
|
3560
|
-
class: "m-editor-scroll-viewer-container",
|
|
3561
|
-
ref: "container"
|
|
3562
|
-
};
|
|
3563
|
-
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3564
|
-
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
3565
|
-
createElementVNode("div", {
|
|
3566
|
-
ref: "el",
|
|
3567
|
-
style: normalizeStyle(_ctx.style)
|
|
3568
|
-
}, [
|
|
3569
|
-
renderSlot(_ctx.$slots, "default")
|
|
3570
|
-
], 4)
|
|
3571
|
-
], 512);
|
|
3572
|
-
}
|
|
3573
|
-
const ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$2]]);
|
|
3574
|
-
|
|
3575
3915
|
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
3576
3916
|
__name: "ViewerMenu",
|
|
3577
3917
|
props: {
|
|
@@ -3708,7 +4048,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
3708
4048
|
};
|
|
3709
4049
|
expose({ show });
|
|
3710
4050
|
return (_ctx, _cache) => {
|
|
3711
|
-
return openBlock(), createBlock(_sfc_main$
|
|
4051
|
+
return openBlock(), createBlock(_sfc_main$c, {
|
|
3712
4052
|
"menu-data": menuData,
|
|
3713
4053
|
ref_key: "menu",
|
|
3714
4054
|
ref: menu
|
|
@@ -3729,12 +4069,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3729
4069
|
const menu = ref();
|
|
3730
4070
|
const isMultiSelect = computed(() => services?.editorService.get("nodes")?.length > 1);
|
|
3731
4071
|
const stageRect = computed(() => services?.uiService.get("stageRect"));
|
|
3732
|
-
const
|
|
4072
|
+
const stageContainerRect = computed(() => services?.uiService.get("stageContainerRect"));
|
|
3733
4073
|
const root = computed(() => services?.editorService.get("root"));
|
|
3734
4074
|
const page = computed(() => services?.editorService.get("page"));
|
|
3735
4075
|
const zoom = computed(() => services?.uiService.get("zoom") || 1);
|
|
3736
4076
|
const node = computed(() => services?.editorService.get("node"));
|
|
3737
|
-
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
3738
4077
|
watchEffect(() => {
|
|
3739
4078
|
if (stage)
|
|
3740
4079
|
return;
|
|
@@ -3742,64 +4081,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3742
4081
|
return;
|
|
3743
4082
|
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
|
|
3744
4083
|
return;
|
|
3745
|
-
stage =
|
|
3746
|
-
render: stageOptions.render,
|
|
3747
|
-
runtimeUrl: stageOptions.runtimeUrl,
|
|
3748
|
-
zoom: zoom.value,
|
|
3749
|
-
autoScrollIntoView: stageOptions.autoScrollIntoView,
|
|
3750
|
-
isContainer: stageOptions.isContainer,
|
|
3751
|
-
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
3752
|
-
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
3753
|
-
containerHighlightType: stageOptions.containerHighlightType,
|
|
3754
|
-
canSelect: (el, event, stop) => {
|
|
3755
|
-
const elCanSelect = stageOptions.canSelect(el);
|
|
3756
|
-
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
3757
|
-
document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
|
|
3758
|
-
return stop();
|
|
3759
|
-
}
|
|
3760
|
-
return elCanSelect;
|
|
3761
|
-
},
|
|
3762
|
-
moveableOptions: stageOptions.moveableOptions,
|
|
3763
|
-
updateDragEl: stageOptions.updateDragEl
|
|
3764
|
-
});
|
|
4084
|
+
stage = useStage(stageOptions);
|
|
3765
4085
|
services?.editorService.set("stage", markRaw(stage));
|
|
3766
4086
|
stage?.mount(stageContainer.value);
|
|
3767
|
-
stage.mask.setGuides([
|
|
3768
|
-
getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
|
|
3769
|
-
getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
|
|
3770
|
-
]);
|
|
3771
|
-
stage?.on("select", (el) => {
|
|
3772
|
-
services?.editorService.select(el.id);
|
|
3773
|
-
});
|
|
3774
|
-
stage?.on("highlight", (el) => {
|
|
3775
|
-
services?.editorService.highlight(el.id);
|
|
3776
|
-
});
|
|
3777
|
-
stage?.on("multiSelect", (els) => {
|
|
3778
|
-
services?.editorService.multiSelect(els.map((el) => el.id));
|
|
3779
|
-
});
|
|
3780
|
-
stage?.on("update", (ev) => {
|
|
3781
|
-
if (ev.parentEl) {
|
|
3782
|
-
for (const data of ev.data) {
|
|
3783
|
-
services?.editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
3784
|
-
}
|
|
3785
|
-
return;
|
|
3786
|
-
}
|
|
3787
|
-
services?.editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
3788
|
-
});
|
|
3789
|
-
stage?.on("sort", (ev) => {
|
|
3790
|
-
services?.editorService.sort(ev.src, ev.dist);
|
|
3791
|
-
});
|
|
3792
|
-
stage?.on("changeGuides", (e2) => {
|
|
3793
|
-
services?.uiService.set("showGuides", true);
|
|
3794
|
-
if (!root.value || !page.value)
|
|
3795
|
-
return;
|
|
3796
|
-
const storageKey = getGuideLineKey(e2.type === GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY);
|
|
3797
|
-
if (e2.guides.length) {
|
|
3798
|
-
globalThis.localStorage.setItem(storageKey, JSON.stringify(e2.guides));
|
|
3799
|
-
} else {
|
|
3800
|
-
globalThis.localStorage.removeItem(storageKey);
|
|
3801
|
-
}
|
|
3802
|
-
});
|
|
3803
4087
|
if (!node.value?.id)
|
|
3804
4088
|
return;
|
|
3805
4089
|
stage?.on("runtime-ready", (rt) => {
|
|
@@ -3885,12 +4169,14 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3885
4169
|
}
|
|
3886
4170
|
};
|
|
3887
4171
|
return (_ctx, _cache) => {
|
|
3888
|
-
return openBlock(), createBlock(
|
|
4172
|
+
return openBlock(), createBlock(_sfc_main$4, {
|
|
3889
4173
|
class: "m-editor-stage",
|
|
3890
4174
|
ref_key: "stageWrap",
|
|
3891
4175
|
ref: stageWrap,
|
|
3892
4176
|
width: unref(stageRect)?.width,
|
|
3893
4177
|
height: unref(stageRect)?.height,
|
|
4178
|
+
"wrap-width": unref(stageContainerRect)?.width,
|
|
4179
|
+
"wrap-height": unref(stageContainerRect)?.height,
|
|
3894
4180
|
zoom: unref(zoom)
|
|
3895
4181
|
}, {
|
|
3896
4182
|
default: withCtx(() => [
|
|
@@ -3898,7 +4184,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3898
4184
|
class: "m-editor-stage-container",
|
|
3899
4185
|
ref_key: "stageContainer",
|
|
3900
4186
|
ref: stageContainer,
|
|
3901
|
-
style: normalizeStyle(`transform: scale(${unref(zoom)})
|
|
4187
|
+
style: normalizeStyle(`transform: scale(${unref(zoom)});`),
|
|
3902
4188
|
onContextmenu: contextmenuHandler,
|
|
3903
4189
|
onDrop: dropHandler,
|
|
3904
4190
|
onDragover: dragoverHandler
|
|
@@ -3912,28 +4198,25 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3912
4198
|
]))
|
|
3913
4199
|
]),
|
|
3914
4200
|
_: 1
|
|
3915
|
-
}, 8, ["width", "height", "zoom"]);
|
|
4201
|
+
}, 8, ["width", "height", "wrap-width", "wrap-height", "zoom"]);
|
|
3916
4202
|
};
|
|
3917
4203
|
}
|
|
3918
4204
|
});
|
|
3919
4205
|
|
|
3920
|
-
const _sfc_main$1 = defineComponent({
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
PageBar: _sfc_main$5,
|
|
3924
|
-
MagicStage: _sfc_main$2
|
|
3925
|
-
},
|
|
3926
|
-
setup() {
|
|
4206
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
4207
|
+
__name: "Workspace",
|
|
4208
|
+
setup(__props) {
|
|
3927
4209
|
const services = inject("services");
|
|
3928
4210
|
const workspace = ref();
|
|
3929
4211
|
const nodes = computed(() => services?.editorService.get("nodes"));
|
|
3930
|
-
|
|
4212
|
+
const page = computed(() => services?.editorService.get("page"));
|
|
3931
4213
|
const mouseenterHandler = () => {
|
|
3932
4214
|
workspace.value?.focus();
|
|
3933
4215
|
};
|
|
3934
4216
|
const mouseleaveHandler = () => {
|
|
3935
4217
|
workspace.value?.blur();
|
|
3936
4218
|
};
|
|
4219
|
+
let keycon;
|
|
3937
4220
|
onMounted(() => {
|
|
3938
4221
|
workspace.value?.addEventListener("mouseenter", mouseenterHandler);
|
|
3939
4222
|
workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
|
|
@@ -4010,6 +4293,12 @@ const _sfc_main$1 = defineComponent({
|
|
|
4010
4293
|
}).keydown([ctrl, "numpad-"], (e) => {
|
|
4011
4294
|
e.inputEvent.preventDefault();
|
|
4012
4295
|
services?.uiService.zoom(-0.1);
|
|
4296
|
+
}).keydown([ctrl, "0"], (e) => {
|
|
4297
|
+
e.inputEvent.preventDefault();
|
|
4298
|
+
services?.uiService.set("zoom", services.uiService.calcZoom());
|
|
4299
|
+
}).keydown([ctrl, "1"], (e) => {
|
|
4300
|
+
e.inputEvent.preventDefault();
|
|
4301
|
+
services?.uiService.set("zoom", 1);
|
|
4013
4302
|
});
|
|
4014
4303
|
});
|
|
4015
4304
|
onUnmounted(() => {
|
|
@@ -4017,39 +4306,33 @@ const _sfc_main$1 = defineComponent({
|
|
|
4017
4306
|
workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
|
|
4018
4307
|
keycon.destroy();
|
|
4019
4308
|
});
|
|
4020
|
-
return {
|
|
4021
|
-
|
|
4022
|
-
|
|
4309
|
+
return (_ctx, _cache) => {
|
|
4310
|
+
return openBlock(), createElementBlock("div", {
|
|
4311
|
+
class: "m-editor-workspace",
|
|
4312
|
+
tabindex: "1",
|
|
4313
|
+
ref_key: "workspace",
|
|
4314
|
+
ref: workspace
|
|
4315
|
+
}, [
|
|
4316
|
+
renderSlot(_ctx.$slots, "stage", {}, () => [
|
|
4317
|
+
(openBlock(), createBlock(_sfc_main$2, {
|
|
4318
|
+
key: unref(page)?.id
|
|
4319
|
+
}))
|
|
4320
|
+
]),
|
|
4321
|
+
renderSlot(_ctx.$slots, "workspace-content"),
|
|
4322
|
+
createVNode(_sfc_main$6, null, {
|
|
4323
|
+
"page-bar-title": withCtx(({ page: page2 }) => [
|
|
4324
|
+
renderSlot(_ctx.$slots, "page-bar-title", { page: page2 })
|
|
4325
|
+
]),
|
|
4326
|
+
"page-bar-popover": withCtx(({ page: page2 }) => [
|
|
4327
|
+
renderSlot(_ctx.$slots, "page-bar-popover", { page: page2 })
|
|
4328
|
+
]),
|
|
4329
|
+
_: 3
|
|
4330
|
+
})
|
|
4331
|
+
], 512);
|
|
4023
4332
|
};
|
|
4024
4333
|
}
|
|
4025
4334
|
});
|
|
4026
4335
|
|
|
4027
|
-
const _hoisted_1 = {
|
|
4028
|
-
class: "m-editor-workspace",
|
|
4029
|
-
tabindex: "1",
|
|
4030
|
-
ref: "workspace"
|
|
4031
|
-
};
|
|
4032
|
-
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4033
|
-
const _component_magic_stage = resolveComponent("magic-stage");
|
|
4034
|
-
const _component_page_bar = resolveComponent("page-bar");
|
|
4035
|
-
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
4036
|
-
(openBlock(), createBlock(_component_magic_stage, {
|
|
4037
|
-
key: _ctx.page?.id
|
|
4038
|
-
})),
|
|
4039
|
-
renderSlot(_ctx.$slots, "workspace-content"),
|
|
4040
|
-
createVNode(_component_page_bar, null, {
|
|
4041
|
-
"page-bar-title": withCtx(({ page }) => [
|
|
4042
|
-
renderSlot(_ctx.$slots, "page-bar-title", { page })
|
|
4043
|
-
]),
|
|
4044
|
-
"page-bar-popover": withCtx(({ page }) => [
|
|
4045
|
-
renderSlot(_ctx.$slots, "page-bar-popover", { page })
|
|
4046
|
-
]),
|
|
4047
|
-
_: 3
|
|
4048
|
-
})
|
|
4049
|
-
], 512);
|
|
4050
|
-
}
|
|
4051
|
-
const Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
4052
|
-
|
|
4053
4336
|
class ComponentList extends BaseService {
|
|
4054
4337
|
state = reactive({
|
|
4055
4338
|
list: []
|
|
@@ -4063,136 +4346,20 @@ class ComponentList extends BaseService {
|
|
|
4063
4346
|
getList() {
|
|
4064
4347
|
return this.state.list;
|
|
4065
4348
|
}
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
4070
|
-
const MIN_LEFT_COLUMN_WIDTH = 45;
|
|
4071
|
-
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
4072
|
-
const MIN_RIGHT_COLUMN_WIDTH = 1;
|
|
4073
|
-
const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
|
|
4074
|
-
const defaultColumnWidth = {
|
|
4075
|
-
left: DEFAULT_LEFT_COLUMN_WIDTH,
|
|
4076
|
-
center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
|
|
4077
|
-
right: DEFAULT_RIGHT_COLUMN_WIDTH
|
|
4078
|
-
};
|
|
4079
|
-
const state = reactive({
|
|
4080
|
-
uiSelectMode: false,
|
|
4081
|
-
showSrc: false,
|
|
4082
|
-
zoom: 1,
|
|
4083
|
-
stageContainerRect: {
|
|
4084
|
-
width: 0,
|
|
4085
|
-
height: 0
|
|
4086
|
-
},
|
|
4087
|
-
stageRect: {
|
|
4088
|
-
width: 375,
|
|
4089
|
-
height: 817
|
|
4090
|
-
},
|
|
4091
|
-
columnWidth: defaultColumnWidth,
|
|
4092
|
-
showGuides: true,
|
|
4093
|
-
showRule: true,
|
|
4094
|
-
propsPanelSize: "small"
|
|
4095
|
-
});
|
|
4096
|
-
class Ui extends BaseService {
|
|
4097
|
-
constructor() {
|
|
4098
|
-
super([]);
|
|
4099
|
-
globalThis.addEventListener("resize", () => {
|
|
4100
|
-
this.setColumnWidth({
|
|
4101
|
-
center: "auto"
|
|
4102
|
-
});
|
|
4103
|
-
});
|
|
4104
|
-
const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
|
|
4105
|
-
if (columnWidthCacheData) {
|
|
4106
|
-
try {
|
|
4107
|
-
const columnWidthCache = JSON.parse(columnWidthCacheData);
|
|
4108
|
-
this.setColumnWidth(columnWidthCache);
|
|
4109
|
-
} catch (e) {
|
|
4110
|
-
console.error(e);
|
|
4111
|
-
}
|
|
4112
|
-
}
|
|
4113
|
-
}
|
|
4114
|
-
set(name, value) {
|
|
4115
|
-
const mask = editorService.get("stage")?.mask;
|
|
4116
|
-
if (name === "columnWidth") {
|
|
4117
|
-
this.setColumnWidth(value);
|
|
4118
|
-
return;
|
|
4119
|
-
}
|
|
4120
|
-
if (name === "stageRect") {
|
|
4121
|
-
this.setStageRect(value);
|
|
4122
|
-
return;
|
|
4123
|
-
}
|
|
4124
|
-
if (name === "showGuides") {
|
|
4125
|
-
mask?.showGuides(value);
|
|
4126
|
-
}
|
|
4127
|
-
if (name === "showRule") {
|
|
4128
|
-
mask?.showRule(value);
|
|
4129
|
-
}
|
|
4130
|
-
state[name] = value;
|
|
4131
|
-
if (name === "stageContainerRect") {
|
|
4132
|
-
state.zoom = this.calcZoom();
|
|
4133
|
-
}
|
|
4134
|
-
}
|
|
4135
|
-
get(name) {
|
|
4136
|
-
return state[name];
|
|
4137
|
-
}
|
|
4138
|
-
zoom(zoom) {
|
|
4139
|
-
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
4140
|
-
if (this.get("zoom") < 0.1)
|
|
4141
|
-
this.set("zoom", 0.1);
|
|
4142
|
-
}
|
|
4143
|
-
setColumnWidth({ left, center, right }) {
|
|
4144
|
-
const columnWidth = {
|
|
4145
|
-
...toRaw(this.get("columnWidth"))
|
|
4146
|
-
};
|
|
4147
|
-
if (left) {
|
|
4148
|
-
columnWidth.left = Math.max(left, MIN_LEFT_COLUMN_WIDTH);
|
|
4149
|
-
}
|
|
4150
|
-
if (right) {
|
|
4151
|
-
columnWidth.right = Math.max(right, MIN_RIGHT_COLUMN_WIDTH);
|
|
4152
|
-
}
|
|
4153
|
-
if (!center || center === "auto") {
|
|
4154
|
-
const bodyWidth = globalThis.document.body.clientWidth;
|
|
4155
|
-
columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
|
|
4156
|
-
if (columnWidth.center <= 0) {
|
|
4157
|
-
columnWidth.left = defaultColumnWidth.left;
|
|
4158
|
-
columnWidth.center = defaultColumnWidth.center;
|
|
4159
|
-
columnWidth.right = defaultColumnWidth.right;
|
|
4160
|
-
}
|
|
4161
|
-
} else {
|
|
4162
|
-
columnWidth.center = center;
|
|
4163
|
-
}
|
|
4164
|
-
globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
|
|
4165
|
-
state.columnWidth = columnWidth;
|
|
4166
|
-
}
|
|
4167
|
-
setStageRect(value) {
|
|
4168
|
-
state.stageRect = {
|
|
4169
|
-
...state.stageRect,
|
|
4170
|
-
...value
|
|
4171
|
-
};
|
|
4172
|
-
state.zoom = this.calcZoom();
|
|
4173
|
-
}
|
|
4174
|
-
calcZoom() {
|
|
4175
|
-
const { stageRect, stageContainerRect } = state;
|
|
4176
|
-
const { height, width } = stageContainerRect;
|
|
4177
|
-
if (!width || !height)
|
|
4178
|
-
return 1;
|
|
4179
|
-
const stageWidth = stageRect.width + 30;
|
|
4180
|
-
const stageHeight = stageRect.height + 30;
|
|
4181
|
-
if (width > stageWidth && height > stageHeight) {
|
|
4182
|
-
return 1;
|
|
4183
|
-
}
|
|
4184
|
-
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
4349
|
+
destroy() {
|
|
4350
|
+
this.state.list = [];
|
|
4351
|
+
this.removeAllListeners();
|
|
4185
4352
|
}
|
|
4186
4353
|
}
|
|
4187
|
-
const
|
|
4354
|
+
const componentListService = new ComponentList();
|
|
4188
4355
|
|
|
4189
4356
|
const _sfc_main = defineComponent({
|
|
4190
4357
|
name: "m-editor",
|
|
4191
4358
|
components: {
|
|
4192
|
-
NavMenu,
|
|
4359
|
+
NavMenu: _sfc_main$f,
|
|
4193
4360
|
Sidebar,
|
|
4194
|
-
Workspace,
|
|
4195
|
-
PropsPanel,
|
|
4361
|
+
Workspace: _sfc_main$1,
|
|
4362
|
+
PropsPanel: _sfc_main$e,
|
|
4196
4363
|
Framework
|
|
4197
4364
|
},
|
|
4198
4365
|
props: {
|
|
@@ -4311,7 +4478,15 @@ const _sfc_main = defineComponent({
|
|
|
4311
4478
|
watch(() => props.stageRect, (stageRect) => stageRect && uiService.set("stageRect", stageRect), {
|
|
4312
4479
|
immediate: true
|
|
4313
4480
|
});
|
|
4314
|
-
|
|
4481
|
+
uiService.initColumnWidth();
|
|
4482
|
+
onUnmounted(() => {
|
|
4483
|
+
editorService.destroy();
|
|
4484
|
+
historyService.destroy();
|
|
4485
|
+
propsService.destroy();
|
|
4486
|
+
uiService.destroy();
|
|
4487
|
+
componentListService.destroy();
|
|
4488
|
+
storageService.destroy();
|
|
4489
|
+
});
|
|
4315
4490
|
const services = {
|
|
4316
4491
|
componentListService,
|
|
4317
4492
|
eventsService,
|
|
@@ -4368,6 +4543,9 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4368
4543
|
workspace: withCtx(() => [
|
|
4369
4544
|
renderSlot(_ctx.$slots, "workspace", { editorService: _ctx.editorService }, () => [
|
|
4370
4545
|
createVNode(_component_workspace, null, {
|
|
4546
|
+
stage: withCtx(() => [
|
|
4547
|
+
renderSlot(_ctx.$slots, "stage")
|
|
4548
|
+
]),
|
|
4371
4549
|
"workspace-content": withCtx(() => [
|
|
4372
4550
|
renderSlot(_ctx.$slots, "workspace-content", { editorService: _ctx.editorService })
|
|
4373
4551
|
]),
|
|
@@ -4384,14 +4562,13 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4384
4562
|
"props-panel": withCtx(() => [
|
|
4385
4563
|
renderSlot(_ctx.$slots, "props-panel", {}, () => [
|
|
4386
4564
|
createVNode(_component_props_panel, {
|
|
4387
|
-
ref: "propsPanel",
|
|
4388
4565
|
onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance))
|
|
4389
4566
|
}, {
|
|
4390
4567
|
"props-panel-header": withCtx(() => [
|
|
4391
4568
|
renderSlot(_ctx.$slots, "props-panel-header")
|
|
4392
4569
|
]),
|
|
4393
4570
|
_: 3
|
|
4394
|
-
}
|
|
4571
|
+
})
|
|
4395
4572
|
])
|
|
4396
4573
|
]),
|
|
4397
4574
|
empty: withCtx(() => [
|
|
@@ -4411,12 +4588,12 @@ const index = {
|
|
|
4411
4588
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
4412
4589
|
setConfig(option);
|
|
4413
4590
|
app.component(Editor.name, Editor);
|
|
4414
|
-
app.component("m-fields-ui-select", _sfc_main$
|
|
4591
|
+
app.component("m-fields-ui-select", _sfc_main$m);
|
|
4415
4592
|
app.component(CodeLink.name, CodeLink);
|
|
4416
4593
|
app.component(Code.name, Code);
|
|
4417
4594
|
app.component(CodeEditor.name, CodeEditor);
|
|
4418
4595
|
}
|
|
4419
4596
|
};
|
|
4420
4597
|
|
|
4421
|
-
export { COPY_STORAGE_KEY, ComponentListPanel,
|
|
4598
|
+
export { COPY_STORAGE_KEY, ColumnLayout, ComponentListPanel, _sfc_main$c as ContentMenu, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$h as Icon, Keys, LayerOffset, LayerPanel, Layout, _sfc_main$e as PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$g as ToolButton, V_GUIDE_LINE_STORAGE_KEY, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getRelativeStyle, historyService, info, isFixed, log, propsService, setConfig, setLayout, storageService, uiService, useStage, warn };
|
|
4422
4599
|
//# sourceMappingURL=tmagic-editor.mjs.map
|