@tmagic/editor 1.1.0-beta.10 → 1.1.0-beta.13
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 +862 -740
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +864 -739
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +10 -10
- package/src/Editor.vue +4 -3
- 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/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/editor.ts +17 -6
- package/src/services/props.ts +26 -53
- package/src/services/ui.ts +16 -20
- 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 +1 -1
- 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/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/editor.d.ts +1 -0
- package/types/services/props.d.ts +40 -9
- package/types/services/ui.d.ts +1 -1
- package/types/type.d.ts +23 -10
- package/types/utils/index.d.ts +1 -0
- 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$c(_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$c]]);
|
|
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$b(_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$b]]);
|
|
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$a(_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$a]]);
|
|
369
371
|
|
|
370
372
|
let $TMAGIC_EDITOR = {};
|
|
371
373
|
const setConfig = (option) => {
|
|
@@ -693,6 +695,12 @@ class WebStorage extends BaseService {
|
|
|
693
695
|
}
|
|
694
696
|
const storageService = new WebStorage();
|
|
695
697
|
|
|
698
|
+
var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
|
|
699
|
+
ColumnLayout2["LEFT"] = "left";
|
|
700
|
+
ColumnLayout2["CENTER"] = "center";
|
|
701
|
+
ColumnLayout2["RIGHT"] = "right";
|
|
702
|
+
return ColumnLayout2;
|
|
703
|
+
})(ColumnLayout || {});
|
|
696
704
|
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
697
705
|
LayerOffset2["TOP"] = "top";
|
|
698
706
|
LayerOffset2["BOTTOM"] = "bottom";
|
|
@@ -877,6 +885,7 @@ class Props extends BaseService {
|
|
|
877
885
|
"getPropsValue",
|
|
878
886
|
"createId",
|
|
879
887
|
"setNewItemId",
|
|
888
|
+
"fillConfig",
|
|
880
889
|
"getDefaultPropsValue"
|
|
881
890
|
]);
|
|
882
891
|
}
|
|
@@ -886,14 +895,17 @@ class Props extends BaseService {
|
|
|
886
895
|
});
|
|
887
896
|
this.emit("props-configs-change");
|
|
888
897
|
}
|
|
889
|
-
|
|
890
|
-
|
|
898
|
+
async fillConfig(config) {
|
|
899
|
+
return fillConfig(config);
|
|
900
|
+
}
|
|
901
|
+
async setPropsConfig(type, config) {
|
|
902
|
+
this.state.propsConfigMap[type] = await this.fillConfig(Array.isArray(config) ? config : [config]);
|
|
891
903
|
}
|
|
892
904
|
async getPropsConfig(type) {
|
|
893
905
|
if (type === "area") {
|
|
894
906
|
return await this.getPropsConfig("button");
|
|
895
907
|
}
|
|
896
|
-
return cloneDeep(this.state.propsConfigMap[type] ||
|
|
908
|
+
return cloneDeep(this.state.propsConfigMap[type] || await this.fillConfig([]));
|
|
897
909
|
}
|
|
898
910
|
setPropsValues(values) {
|
|
899
911
|
Object.keys(values).forEach((type) => {
|
|
@@ -927,25 +939,14 @@ class Props extends BaseService {
|
|
|
927
939
|
...mergeWith({}, cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
928
940
|
};
|
|
929
941
|
}
|
|
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
942
|
async createId(type) {
|
|
938
943
|
return `${type}_${this.guid()}`;
|
|
939
944
|
}
|
|
940
|
-
async setNewItemId(config
|
|
941
|
-
const oldId = config.id;
|
|
945
|
+
async setNewItemId(config) {
|
|
942
946
|
config.id = await this.createId(config.type || "component");
|
|
943
|
-
if (isPop(config) && parent?.type === NodeType.PAGE) {
|
|
944
|
-
updatePopId(oldId, config.id, parent);
|
|
945
|
-
}
|
|
946
947
|
if (config.items && Array.isArray(config.items)) {
|
|
947
948
|
for (const item of config.items) {
|
|
948
|
-
await this.setNewItemId(item
|
|
949
|
+
await this.setNewItemId(item);
|
|
949
950
|
}
|
|
950
951
|
}
|
|
951
952
|
return config;
|
|
@@ -963,22 +964,14 @@ class Props extends BaseService {
|
|
|
963
964
|
name: type
|
|
964
965
|
};
|
|
965
966
|
}
|
|
967
|
+
guid(digit = 8) {
|
|
968
|
+
return "x".repeat(digit).replace(/[xy]/g, (c) => {
|
|
969
|
+
const r = Math.random() * 16 | 0;
|
|
970
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
971
|
+
return v.toString(16);
|
|
972
|
+
});
|
|
973
|
+
}
|
|
966
974
|
}
|
|
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
975
|
const propsService = new Props();
|
|
983
976
|
|
|
984
977
|
const beforePaste = async (position, config) => {
|
|
@@ -998,7 +991,7 @@ const beforePaste = async (position, config) => {
|
|
|
998
991
|
if (pastePosition.top && configItem.style?.top) {
|
|
999
992
|
pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
|
|
1000
993
|
}
|
|
1001
|
-
const pasteConfig = await propsService.setNewItemId(configItem
|
|
994
|
+
const pasteConfig = await propsService.setNewItemId(configItem);
|
|
1002
995
|
if (pasteConfig.style) {
|
|
1003
996
|
const { left, top } = pasteConfig.style;
|
|
1004
997
|
if (typeof left === "number" || !!left && !isNaN(Number(left))) {
|
|
@@ -1069,6 +1062,7 @@ class Editor$1 extends BaseService {
|
|
|
1069
1062
|
"sort",
|
|
1070
1063
|
"copy",
|
|
1071
1064
|
"paste",
|
|
1065
|
+
"doPaste",
|
|
1072
1066
|
"duAlignCenter",
|
|
1073
1067
|
"alignCenter",
|
|
1074
1068
|
"moveLayer",
|
|
@@ -1250,7 +1244,7 @@ class Editor$1 extends BaseService {
|
|
|
1250
1244
|
}
|
|
1251
1245
|
this.pushHistoryState();
|
|
1252
1246
|
this.emit("add", newNodes);
|
|
1253
|
-
return
|
|
1247
|
+
return Array.isArray(addNode) ? newNodes : newNodes[0];
|
|
1254
1248
|
}
|
|
1255
1249
|
async doRemove(node) {
|
|
1256
1250
|
const root = this.get("root");
|
|
@@ -1344,7 +1338,7 @@ class Editor$1 extends BaseService {
|
|
|
1344
1338
|
const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
|
|
1345
1339
|
this.pushHistoryState();
|
|
1346
1340
|
this.emit("update", newNodes);
|
|
1347
|
-
return
|
|
1341
|
+
return Array.isArray(config) ? newNodes : newNodes[0];
|
|
1348
1342
|
}
|
|
1349
1343
|
async sort(id1, id2) {
|
|
1350
1344
|
const node = this.get("node");
|
|
@@ -1373,9 +1367,13 @@ class Editor$1 extends BaseService {
|
|
|
1373
1367
|
const config = await storageService.getItem(COPY_STORAGE_KEY);
|
|
1374
1368
|
if (!Array.isArray(config))
|
|
1375
1369
|
return;
|
|
1376
|
-
const pasteConfigs = await
|
|
1370
|
+
const pasteConfigs = await this.doPaste(config, position);
|
|
1377
1371
|
return this.add(pasteConfigs);
|
|
1378
1372
|
}
|
|
1373
|
+
async doPaste(config, position = {}) {
|
|
1374
|
+
const pasteConfigs = await beforePaste(position, cloneDeep(config));
|
|
1375
|
+
return pasteConfigs;
|
|
1376
|
+
}
|
|
1379
1377
|
async doAlignCenter(config) {
|
|
1380
1378
|
const parent = this.getParentById(config.id);
|
|
1381
1379
|
if (!parent)
|
|
@@ -1420,11 +1418,14 @@ class Editor$1 extends BaseService {
|
|
|
1420
1418
|
} else {
|
|
1421
1419
|
brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
|
|
1422
1420
|
}
|
|
1421
|
+
const grandparent = this.getParentById(parent.id);
|
|
1423
1422
|
this.get("stage")?.update({
|
|
1424
1423
|
config: cloneDeep(toRaw(parent)),
|
|
1425
|
-
parentId:
|
|
1424
|
+
parentId: grandparent?.id,
|
|
1426
1425
|
root: cloneDeep(this.get("root"))
|
|
1427
1426
|
});
|
|
1427
|
+
this.addModifiedNodeId(parent.id);
|
|
1428
|
+
this.pushHistoryState();
|
|
1428
1429
|
}
|
|
1429
1430
|
async moveToContainer(config, targetId) {
|
|
1430
1431
|
const { node, parent } = this.getNodeInfo(config.id, false);
|
|
@@ -1444,7 +1445,8 @@ class Editor$1 extends BaseService {
|
|
|
1444
1445
|
newConfig.style = getInitPositionStyle(newConfig.style, layout);
|
|
1445
1446
|
target.items.push(newConfig);
|
|
1446
1447
|
await stage.select(targetId);
|
|
1447
|
-
|
|
1448
|
+
const targetParent = this.getParentById(target.id);
|
|
1449
|
+
await stage.update({ config: cloneDeep(target), parentId: targetParent?.id, root });
|
|
1448
1450
|
await this.select(newConfig);
|
|
1449
1451
|
stage.select(newConfig.id);
|
|
1450
1452
|
this.addModifiedNodeId(target.id);
|
|
@@ -1807,7 +1809,6 @@ const fillConfig = (config = []) => [
|
|
|
1807
1809
|
]
|
|
1808
1810
|
}
|
|
1809
1811
|
];
|
|
1810
|
-
const DEFAULT_CONFIG = fillConfig([]);
|
|
1811
1812
|
|
|
1812
1813
|
const log = (...args) => {
|
|
1813
1814
|
if (process.env.NODE_ENV === "development") {
|
|
@@ -1835,7 +1836,189 @@ const error = (...args) => {
|
|
|
1835
1836
|
}
|
|
1836
1837
|
};
|
|
1837
1838
|
|
|
1838
|
-
const
|
|
1839
|
+
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
1840
|
+
const MIN_LEFT_COLUMN_WIDTH = 45;
|
|
1841
|
+
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
1842
|
+
const MIN_RIGHT_COLUMN_WIDTH = 1;
|
|
1843
|
+
const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
|
|
1844
|
+
const defaultColumnWidth = {
|
|
1845
|
+
left: DEFAULT_LEFT_COLUMN_WIDTH,
|
|
1846
|
+
center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
|
|
1847
|
+
right: DEFAULT_RIGHT_COLUMN_WIDTH
|
|
1848
|
+
};
|
|
1849
|
+
const state = reactive({
|
|
1850
|
+
uiSelectMode: false,
|
|
1851
|
+
showSrc: false,
|
|
1852
|
+
zoom: 1,
|
|
1853
|
+
stageContainerRect: {
|
|
1854
|
+
width: 0,
|
|
1855
|
+
height: 0
|
|
1856
|
+
},
|
|
1857
|
+
stageRect: {
|
|
1858
|
+
width: 375,
|
|
1859
|
+
height: 817
|
|
1860
|
+
},
|
|
1861
|
+
columnWidth: defaultColumnWidth,
|
|
1862
|
+
showGuides: true,
|
|
1863
|
+
showRule: true,
|
|
1864
|
+
propsPanelSize: "small"
|
|
1865
|
+
});
|
|
1866
|
+
class Ui extends BaseService {
|
|
1867
|
+
constructor() {
|
|
1868
|
+
super([]);
|
|
1869
|
+
globalThis.addEventListener("resize", () => {
|
|
1870
|
+
this.setColumnWidth({
|
|
1871
|
+
center: "auto"
|
|
1872
|
+
});
|
|
1873
|
+
});
|
|
1874
|
+
const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
|
|
1875
|
+
if (columnWidthCacheData) {
|
|
1876
|
+
try {
|
|
1877
|
+
const columnWidthCache = JSON.parse(columnWidthCacheData);
|
|
1878
|
+
this.setColumnWidth(columnWidthCache);
|
|
1879
|
+
} catch (e) {
|
|
1880
|
+
console.error(e);
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
set(name, value) {
|
|
1885
|
+
const mask = editorService.get("stage")?.mask;
|
|
1886
|
+
if (name === "columnWidth") {
|
|
1887
|
+
this.setColumnWidth(value);
|
|
1888
|
+
return;
|
|
1889
|
+
}
|
|
1890
|
+
if (name === "stageRect") {
|
|
1891
|
+
this.setStageRect(value);
|
|
1892
|
+
return;
|
|
1893
|
+
}
|
|
1894
|
+
if (name === "showGuides") {
|
|
1895
|
+
mask?.showGuides(value);
|
|
1896
|
+
}
|
|
1897
|
+
if (name === "showRule") {
|
|
1898
|
+
mask?.showRule(value);
|
|
1899
|
+
}
|
|
1900
|
+
state[name] = value;
|
|
1901
|
+
}
|
|
1902
|
+
get(name) {
|
|
1903
|
+
return state[name];
|
|
1904
|
+
}
|
|
1905
|
+
zoom(zoom) {
|
|
1906
|
+
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
1907
|
+
if (this.get("zoom") < 0.1)
|
|
1908
|
+
this.set("zoom", 0.1);
|
|
1909
|
+
}
|
|
1910
|
+
calcZoom() {
|
|
1911
|
+
const { stageRect, stageContainerRect } = state;
|
|
1912
|
+
const { height, width } = stageContainerRect;
|
|
1913
|
+
if (!width || !height)
|
|
1914
|
+
return 1;
|
|
1915
|
+
const stageWidth = stageRect.width + 30;
|
|
1916
|
+
const stageHeight = stageRect.height + 30;
|
|
1917
|
+
if (width > stageWidth && height > stageHeight) {
|
|
1918
|
+
return 1;
|
|
1919
|
+
}
|
|
1920
|
+
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
1921
|
+
}
|
|
1922
|
+
setColumnWidth({ left, center, right }) {
|
|
1923
|
+
const columnWidth = {
|
|
1924
|
+
...toRaw(this.get("columnWidth"))
|
|
1925
|
+
};
|
|
1926
|
+
if (left) {
|
|
1927
|
+
columnWidth.left = Math.max(left, MIN_LEFT_COLUMN_WIDTH);
|
|
1928
|
+
}
|
|
1929
|
+
if (right) {
|
|
1930
|
+
columnWidth.right = Math.max(right, MIN_RIGHT_COLUMN_WIDTH);
|
|
1931
|
+
}
|
|
1932
|
+
if (!center || center === "auto") {
|
|
1933
|
+
const bodyWidth = globalThis.document.body.clientWidth;
|
|
1934
|
+
columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
|
|
1935
|
+
if (columnWidth.center <= 0) {
|
|
1936
|
+
columnWidth.left = defaultColumnWidth.left;
|
|
1937
|
+
columnWidth.center = defaultColumnWidth.center;
|
|
1938
|
+
columnWidth.right = defaultColumnWidth.right;
|
|
1939
|
+
}
|
|
1940
|
+
} else {
|
|
1941
|
+
columnWidth.center = center;
|
|
1942
|
+
}
|
|
1943
|
+
globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
|
|
1944
|
+
state.columnWidth = columnWidth;
|
|
1945
|
+
}
|
|
1946
|
+
setStageRect(value) {
|
|
1947
|
+
state.stageRect = {
|
|
1948
|
+
...state.stageRect,
|
|
1949
|
+
...value
|
|
1950
|
+
};
|
|
1951
|
+
state.zoom = this.calcZoom();
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
const uiService = new Ui();
|
|
1955
|
+
|
|
1956
|
+
const root = computed(() => editorService.get("root"));
|
|
1957
|
+
const page = computed(() => editorService.get("page"));
|
|
1958
|
+
const zoom = computed(() => uiService.get("zoom") || 1);
|
|
1959
|
+
const uiSelectMode = computed(() => uiService.get("uiSelectMode"));
|
|
1960
|
+
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
1961
|
+
const useStage = (stageOptions) => {
|
|
1962
|
+
const stage = new StageCore({
|
|
1963
|
+
render: stageOptions.render,
|
|
1964
|
+
runtimeUrl: stageOptions.runtimeUrl,
|
|
1965
|
+
zoom: zoom.value,
|
|
1966
|
+
autoScrollIntoView: stageOptions.autoScrollIntoView,
|
|
1967
|
+
isContainer: stageOptions.isContainer,
|
|
1968
|
+
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
1969
|
+
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
1970
|
+
containerHighlightType: stageOptions.containerHighlightType,
|
|
1971
|
+
canSelect: (el, event, stop) => {
|
|
1972
|
+
const elCanSelect = stageOptions.canSelect(el);
|
|
1973
|
+
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
1974
|
+
document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
|
|
1975
|
+
return stop();
|
|
1976
|
+
}
|
|
1977
|
+
return elCanSelect;
|
|
1978
|
+
},
|
|
1979
|
+
moveableOptions: stageOptions.moveableOptions,
|
|
1980
|
+
updateDragEl: stageOptions.updateDragEl
|
|
1981
|
+
});
|
|
1982
|
+
stage.mask.setGuides([
|
|
1983
|
+
getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
|
|
1984
|
+
getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
|
|
1985
|
+
]);
|
|
1986
|
+
stage.on("select", (el) => {
|
|
1987
|
+
editorService.select(el.id);
|
|
1988
|
+
});
|
|
1989
|
+
stage.on("highlight", (el) => {
|
|
1990
|
+
editorService.highlight(el.id);
|
|
1991
|
+
});
|
|
1992
|
+
stage.on("multiSelect", (els) => {
|
|
1993
|
+
editorService.multiSelect(els.map((el) => el.id));
|
|
1994
|
+
});
|
|
1995
|
+
stage.on("update", (ev) => {
|
|
1996
|
+
if (ev.parentEl) {
|
|
1997
|
+
for (const data of ev.data) {
|
|
1998
|
+
editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
1999
|
+
}
|
|
2000
|
+
return;
|
|
2001
|
+
}
|
|
2002
|
+
editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
2003
|
+
});
|
|
2004
|
+
stage.on("sort", (ev) => {
|
|
2005
|
+
editorService.sort(ev.src, ev.dist);
|
|
2006
|
+
});
|
|
2007
|
+
stage.on("changeGuides", (e) => {
|
|
2008
|
+
uiService.set("showGuides", true);
|
|
2009
|
+
if (!root.value || !page.value)
|
|
2010
|
+
return;
|
|
2011
|
+
const storageKey = getGuideLineKey(e.type === GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY);
|
|
2012
|
+
if (e.guides.length) {
|
|
2013
|
+
globalThis.localStorage.setItem(storageKey, JSON.stringify(e.guides));
|
|
2014
|
+
} else {
|
|
2015
|
+
globalThis.localStorage.removeItem(storageKey);
|
|
2016
|
+
}
|
|
2017
|
+
});
|
|
2018
|
+
return stage;
|
|
2019
|
+
};
|
|
2020
|
+
|
|
2021
|
+
const _sfc_main$k = defineComponent({
|
|
1839
2022
|
components: { Plus },
|
|
1840
2023
|
setup() {
|
|
1841
2024
|
const services = inject("services");
|
|
@@ -1853,13 +2036,13 @@ const _sfc_main$j = defineComponent({
|
|
|
1853
2036
|
}
|
|
1854
2037
|
});
|
|
1855
2038
|
|
|
1856
|
-
const _hoisted_1$
|
|
2039
|
+
const _hoisted_1$9 = { class: "m-editor-empty-panel" };
|
|
1857
2040
|
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
1858
|
-
const _hoisted_3
|
|
1859
|
-
function _sfc_render$
|
|
2041
|
+
const _hoisted_3 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
2042
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1860
2043
|
const _component_plus = resolveComponent("plus");
|
|
1861
2044
|
const _component_el_icon = resolveComponent("el-icon");
|
|
1862
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
2045
|
+
return openBlock(), createElementBlock("div", _hoisted_1$9, [
|
|
1863
2046
|
createElementVNode("div", _hoisted_2$4, [
|
|
1864
2047
|
createElementVNode("div", {
|
|
1865
2048
|
class: "m-editor-empty-button",
|
|
@@ -1873,14 +2056,14 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1873
2056
|
_: 1
|
|
1874
2057
|
})
|
|
1875
2058
|
]),
|
|
1876
|
-
_hoisted_3
|
|
2059
|
+
_hoisted_3
|
|
1877
2060
|
])
|
|
1878
2061
|
])
|
|
1879
2062
|
]);
|
|
1880
2063
|
}
|
|
1881
|
-
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2064
|
+
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$9]]);
|
|
1882
2065
|
|
|
1883
|
-
const _sfc_main$
|
|
2066
|
+
const _sfc_main$j = defineComponent({
|
|
1884
2067
|
name: "m-editor-resize",
|
|
1885
2068
|
props: {
|
|
1886
2069
|
type: {
|
|
@@ -1923,18 +2106,18 @@ const _sfc_main$i = defineComponent({
|
|
|
1923
2106
|
}
|
|
1924
2107
|
});
|
|
1925
2108
|
|
|
1926
|
-
const _hoisted_1$
|
|
2109
|
+
const _hoisted_1$8 = {
|
|
1927
2110
|
ref: "target",
|
|
1928
2111
|
class: "m-editor-resizer"
|
|
1929
2112
|
};
|
|
1930
|
-
function _sfc_render$
|
|
1931
|
-
return openBlock(), createElementBlock("span", _hoisted_1$
|
|
2113
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2114
|
+
return openBlock(), createElementBlock("span", _hoisted_1$8, [
|
|
1932
2115
|
renderSlot(_ctx.$slots, "default")
|
|
1933
2116
|
], 512);
|
|
1934
2117
|
}
|
|
1935
|
-
const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2118
|
+
const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$8]]);
|
|
1936
2119
|
|
|
1937
|
-
const _sfc_main$
|
|
2120
|
+
const _sfc_main$i = defineComponent({
|
|
1938
2121
|
components: {
|
|
1939
2122
|
AddPageBox,
|
|
1940
2123
|
Resizer
|
|
@@ -1964,17 +2147,17 @@ const _sfc_main$h = defineComponent({
|
|
|
1964
2147
|
}
|
|
1965
2148
|
});
|
|
1966
2149
|
|
|
1967
|
-
const _hoisted_1$
|
|
2150
|
+
const _hoisted_1$7 = { class: "m-editor" };
|
|
1968
2151
|
const _hoisted_2$3 = {
|
|
1969
2152
|
key: 1,
|
|
1970
2153
|
class: "m-editor-content"
|
|
1971
2154
|
};
|
|
1972
|
-
function _sfc_render$
|
|
2155
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1973
2156
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
1974
2157
|
const _component_resizer = resolveComponent("resizer");
|
|
1975
2158
|
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
1976
2159
|
const _component_add_page_box = resolveComponent("add-page-box");
|
|
1977
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
2160
|
+
return openBlock(), createElementBlock("div", _hoisted_1$7, [
|
|
1978
2161
|
renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
1979
2162
|
_ctx.showSrc ? (openBlock(), createBlock(_component_magic_code_editor, {
|
|
1980
2163
|
key: 0,
|
|
@@ -2015,211 +2198,112 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2015
2198
|
]))
|
|
2016
2199
|
]);
|
|
2017
2200
|
}
|
|
2018
|
-
const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2201
|
+
const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$7]]);
|
|
2019
2202
|
|
|
2020
|
-
const
|
|
2021
|
-
|
|
2022
|
-
|
|
2203
|
+
const _hoisted_1$6 = ["src"];
|
|
2204
|
+
const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
2205
|
+
__name: "Icon",
|
|
2023
2206
|
props: {
|
|
2024
|
-
icon:
|
|
2025
|
-
type: [String, Object]
|
|
2026
|
-
}
|
|
2207
|
+
icon: null
|
|
2027
2208
|
},
|
|
2028
|
-
setup() {
|
|
2029
|
-
return {
|
|
2030
|
-
|
|
2209
|
+
setup(__props) {
|
|
2210
|
+
return (_ctx, _cache) => {
|
|
2211
|
+
const _component_el_icon = resolveComponent("el-icon");
|
|
2212
|
+
return !__props.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
|
|
2213
|
+
default: withCtx(() => [
|
|
2214
|
+
createVNode(unref(Edit))
|
|
2215
|
+
]),
|
|
2216
|
+
_: 1
|
|
2217
|
+
})) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (openBlock(), createBlock(_component_el_icon, { key: 1 }, {
|
|
2218
|
+
default: withCtx(() => [
|
|
2219
|
+
createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$6)
|
|
2220
|
+
]),
|
|
2221
|
+
_: 1
|
|
2222
|
+
})) : typeof __props.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
2223
|
+
key: 2,
|
|
2224
|
+
class: normalizeClass(__props.icon)
|
|
2225
|
+
}, null, 2)) : (openBlock(), createBlock(_component_el_icon, { key: 3 }, {
|
|
2226
|
+
default: withCtx(() => [
|
|
2227
|
+
(openBlock(), createBlock(resolveDynamicComponent(toRaw(__props.icon))))
|
|
2228
|
+
]),
|
|
2229
|
+
_: 1
|
|
2230
|
+
}));
|
|
2031
2231
|
};
|
|
2032
2232
|
}
|
|
2033
2233
|
});
|
|
2034
2234
|
|
|
2035
|
-
const _hoisted_1$
|
|
2036
|
-
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2037
|
-
const _component_edit = resolveComponent("edit");
|
|
2038
|
-
const _component_el_icon = resolveComponent("el-icon");
|
|
2039
|
-
return !_ctx.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
|
|
2040
|
-
default: withCtx(() => [
|
|
2041
|
-
createVNode(_component_edit)
|
|
2042
|
-
]),
|
|
2043
|
-
_: 1
|
|
2044
|
-
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (openBlock(), createBlock(_component_el_icon, { key: 1 }, {
|
|
2045
|
-
default: withCtx(() => [
|
|
2046
|
-
createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$8)
|
|
2047
|
-
]),
|
|
2048
|
-
_: 1
|
|
2049
|
-
})) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
2050
|
-
key: 2,
|
|
2051
|
-
class: normalizeClass(_ctx.icon)
|
|
2052
|
-
}, null, 2)) : (openBlock(), createBlock(_component_el_icon, { key: 3 }, {
|
|
2053
|
-
default: withCtx(() => [
|
|
2054
|
-
(openBlock(), createBlock(resolveDynamicComponent(_ctx.toRaw(_ctx.icon))))
|
|
2055
|
-
]),
|
|
2056
|
-
_: 1
|
|
2057
|
-
}));
|
|
2058
|
-
}
|
|
2059
|
-
const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
|
|
2060
|
-
|
|
2061
|
-
const _hoisted_1$7 = {
|
|
2235
|
+
const _hoisted_1$5 = {
|
|
2062
2236
|
key: 1,
|
|
2063
2237
|
class: "menu-item-text"
|
|
2064
2238
|
};
|
|
2065
|
-
const _hoisted_2$2 = {
|
|
2066
|
-
|
|
2067
|
-
style: { "margin": "0 5px" }
|
|
2068
|
-
};
|
|
2069
|
-
const _hoisted_3 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2070
|
-
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
2239
|
+
const _hoisted_2$2 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2240
|
+
const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
2071
2241
|
__name: "ToolButton",
|
|
2072
2242
|
props: {
|
|
2073
|
-
data: {
|
|
2074
|
-
type:
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
display: false
|
|
2079
|
-
})
|
|
2080
|
-
},
|
|
2081
|
-
eventType: {
|
|
2082
|
-
type: String,
|
|
2083
|
-
default: "click"
|
|
2084
|
-
}
|
|
2243
|
+
data: { default: () => ({
|
|
2244
|
+
type: "text",
|
|
2245
|
+
display: false
|
|
2246
|
+
}) },
|
|
2247
|
+
eventType: { default: "click" }
|
|
2085
2248
|
},
|
|
2086
2249
|
setup(__props) {
|
|
2087
2250
|
const props = __props;
|
|
2088
2251
|
const services = inject("services");
|
|
2089
|
-
const
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
if (typeof props.data !== "string") {
|
|
2097
|
-
return props.data;
|
|
2098
|
-
}
|
|
2099
|
-
switch (props.data) {
|
|
2100
|
-
case "/":
|
|
2101
|
-
return {
|
|
2102
|
-
type: "divider"
|
|
2103
|
-
};
|
|
2104
|
-
case "zoom":
|
|
2105
|
-
return {
|
|
2106
|
-
type: "zoom"
|
|
2107
|
-
};
|
|
2108
|
-
case "delete":
|
|
2109
|
-
return {
|
|
2110
|
-
type: "button",
|
|
2111
|
-
icon: markRaw(Delete),
|
|
2112
|
-
tooltip: "\u522A\u9664",
|
|
2113
|
-
disabled: () => services?.editorService.get("node")?.type === NodeType.PAGE,
|
|
2114
|
-
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
2115
|
-
};
|
|
2116
|
-
case "undo":
|
|
2117
|
-
return {
|
|
2118
|
-
type: "button",
|
|
2119
|
-
icon: markRaw(Back),
|
|
2120
|
-
tooltip: "\u540E\u9000",
|
|
2121
|
-
disabled: () => !services?.historyService.state.canUndo,
|
|
2122
|
-
handler: () => services?.editorService.undo()
|
|
2123
|
-
};
|
|
2124
|
-
case "redo":
|
|
2125
|
-
return {
|
|
2126
|
-
type: "button",
|
|
2127
|
-
icon: markRaw(Right),
|
|
2128
|
-
tooltip: "\u524D\u8FDB",
|
|
2129
|
-
disabled: () => !services?.historyService.state.canRedo,
|
|
2130
|
-
handler: () => services?.editorService.redo()
|
|
2131
|
-
};
|
|
2132
|
-
case "zoom-in":
|
|
2133
|
-
return {
|
|
2134
|
-
type: "button",
|
|
2135
|
-
icon: markRaw(ZoomIn),
|
|
2136
|
-
tooltip: "\u653E\u5927",
|
|
2137
|
-
handler: zoomInHandler
|
|
2138
|
-
};
|
|
2139
|
-
case "zoom-out":
|
|
2140
|
-
return {
|
|
2141
|
-
type: "button",
|
|
2142
|
-
icon: markRaw(ZoomOut),
|
|
2143
|
-
tooltip: "\u7E2E\u5C0F",
|
|
2144
|
-
handler: zoomOutHandler
|
|
2145
|
-
};
|
|
2146
|
-
case "rule":
|
|
2147
|
-
return {
|
|
2148
|
-
type: "button",
|
|
2149
|
-
icon: markRaw(ScaleToOriginal),
|
|
2150
|
-
tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
|
|
2151
|
-
handler: () => uiService?.set("showRule", !showRule.value)
|
|
2152
|
-
};
|
|
2153
|
-
case "guides":
|
|
2154
|
-
return {
|
|
2155
|
-
type: "button",
|
|
2156
|
-
icon: markRaw(Grid),
|
|
2157
|
-
tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
|
|
2158
|
-
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
2159
|
-
};
|
|
2160
|
-
default:
|
|
2161
|
-
return {
|
|
2162
|
-
type: "text",
|
|
2163
|
-
text: props.data
|
|
2164
|
-
};
|
|
2252
|
+
const disabled = computed(() => {
|
|
2253
|
+
if (typeof props.data === "string")
|
|
2254
|
+
return false;
|
|
2255
|
+
if (props.data.type === "component")
|
|
2256
|
+
return false;
|
|
2257
|
+
if (typeof props.data.disabled === "function") {
|
|
2258
|
+
return props.data.disabled(services);
|
|
2165
2259
|
}
|
|
2260
|
+
return props.data.disabled;
|
|
2166
2261
|
});
|
|
2167
|
-
const
|
|
2168
|
-
if (
|
|
2169
|
-
return false;
|
|
2170
|
-
if (item.value.type === "component")
|
|
2262
|
+
const display = computed(() => {
|
|
2263
|
+
if (!props.data)
|
|
2171
2264
|
return false;
|
|
2172
|
-
if (typeof
|
|
2173
|
-
return
|
|
2265
|
+
if (typeof props.data === "string")
|
|
2266
|
+
return true;
|
|
2267
|
+
if (typeof props.data.display === "function") {
|
|
2268
|
+
return props.data.display(services);
|
|
2174
2269
|
}
|
|
2175
|
-
return
|
|
2270
|
+
return props.data.display ?? true;
|
|
2176
2271
|
});
|
|
2177
|
-
const buttonHandler = (
|
|
2272
|
+
const buttonHandler = (item, event) => {
|
|
2178
2273
|
if (disabled.value)
|
|
2179
2274
|
return;
|
|
2180
|
-
if (typeof
|
|
2181
|
-
|
|
2275
|
+
if (typeof item.handler === "function" && services) {
|
|
2276
|
+
item.handler?.(services, event);
|
|
2182
2277
|
}
|
|
2183
2278
|
};
|
|
2184
|
-
const display = computed(() => {
|
|
2185
|
-
if (!item.value)
|
|
2186
|
-
return false;
|
|
2187
|
-
if (typeof item.value === "string")
|
|
2188
|
-
return true;
|
|
2189
|
-
if (typeof item.value.display === "function") {
|
|
2190
|
-
return item.value.display(services);
|
|
2191
|
-
}
|
|
2192
|
-
return item.value.display ?? true;
|
|
2193
|
-
});
|
|
2194
2279
|
const dropdownHandler = (command) => {
|
|
2195
2280
|
if (command.item.handler) {
|
|
2196
2281
|
command.item.handler(services);
|
|
2197
2282
|
}
|
|
2198
2283
|
};
|
|
2199
|
-
const clickHandler = (
|
|
2284
|
+
const clickHandler = (item, event) => {
|
|
2200
2285
|
if (props.eventType !== "click")
|
|
2201
2286
|
return;
|
|
2202
|
-
if (
|
|
2203
|
-
buttonHandler(
|
|
2287
|
+
if (item.type === "button") {
|
|
2288
|
+
buttonHandler(item, event);
|
|
2204
2289
|
}
|
|
2205
2290
|
};
|
|
2206
|
-
const mousedownHandler = (
|
|
2291
|
+
const mousedownHandler = (item, event) => {
|
|
2207
2292
|
if (props.eventType !== "mousedown")
|
|
2208
2293
|
return;
|
|
2209
|
-
if (
|
|
2210
|
-
buttonHandler(
|
|
2294
|
+
if (item.type === "button") {
|
|
2295
|
+
buttonHandler(item, event);
|
|
2211
2296
|
}
|
|
2212
2297
|
};
|
|
2213
|
-
const mouseupHandler = (
|
|
2298
|
+
const mouseupHandler = (item, event) => {
|
|
2214
2299
|
if (props.eventType !== "mouseup")
|
|
2215
2300
|
return;
|
|
2216
|
-
if (
|
|
2217
|
-
buttonHandler(
|
|
2301
|
+
if (item.type === "button") {
|
|
2302
|
+
buttonHandler(item, event);
|
|
2218
2303
|
}
|
|
2219
2304
|
};
|
|
2220
2305
|
return (_ctx, _cache) => {
|
|
2221
2306
|
const _component_el_divider = resolveComponent("el-divider");
|
|
2222
|
-
const _component_tool_button = resolveComponent("tool-button", true);
|
|
2223
2307
|
const _component_el_button = resolveComponent("el-button");
|
|
2224
2308
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
2225
2309
|
const _component_el_icon = resolveComponent("el-icon");
|
|
@@ -2228,30 +2312,20 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2228
2312
|
const _component_el_dropdown = resolveComponent("el-dropdown");
|
|
2229
2313
|
return unref(display) ? (openBlock(), createElementBlock("div", {
|
|
2230
2314
|
key: 0,
|
|
2231
|
-
class: normalizeClass(["menu-item",
|
|
2232
|
-
onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(
|
|
2233
|
-
onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(
|
|
2234
|
-
onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(
|
|
2315
|
+
class: normalizeClass(["menu-item", `${__props.data.type} ${__props.data.className || ""}`]),
|
|
2316
|
+
onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(__props.data, $event)),
|
|
2317
|
+
onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(__props.data, $event)),
|
|
2318
|
+
onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(__props.data, $event))
|
|
2235
2319
|
}, [
|
|
2236
|
-
|
|
2320
|
+
__props.data.type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
|
|
2237
2321
|
key: 0,
|
|
2238
|
-
direction:
|
|
2239
|
-
}, null, 8, ["direction"])) :
|
|
2240
|
-
|
|
2241
|
-
data: { type: "button", icon: unref(ZoomOut), handler: zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
2242
|
-
"event-type": __props.eventType
|
|
2243
|
-
}, null, 8, ["data", "event-type"]),
|
|
2244
|
-
createElementVNode("span", _hoisted_2$2, toDisplayString(parseInt(`${unref(zoom) * 100}`, 10)) + "%", 1),
|
|
2245
|
-
createVNode(_component_tool_button, {
|
|
2246
|
-
data: { type: "button", icon: unref(ZoomIn), handler: zoomInHandler, tooltip: "\u653E\u5927" },
|
|
2247
|
-
"event-type": __props.eventType
|
|
2248
|
-
}, null, 8, ["data", "event-type"])
|
|
2249
|
-
], 64)) : unref(item).type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
2250
|
-
unref(item).tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
2322
|
+
direction: __props.data.direction || "vertical"
|
|
2323
|
+
}, 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 }, [
|
|
2324
|
+
__props.data.tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
2251
2325
|
key: 0,
|
|
2252
2326
|
effect: "dark",
|
|
2253
2327
|
placement: "bottom-start",
|
|
2254
|
-
content:
|
|
2328
|
+
content: __props.data.tooltip
|
|
2255
2329
|
}, {
|
|
2256
2330
|
default: withCtx(() => [
|
|
2257
2331
|
createVNode(_component_el_button, {
|
|
@@ -2260,11 +2334,11 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2260
2334
|
disabled: unref(disabled)
|
|
2261
2335
|
}, {
|
|
2262
2336
|
default: withCtx(() => [
|
|
2263
|
-
|
|
2337
|
+
__props.data.icon ? (openBlock(), createBlock(_sfc_main$h, {
|
|
2264
2338
|
key: 0,
|
|
2265
|
-
icon:
|
|
2339
|
+
icon: __props.data.icon
|
|
2266
2340
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
2267
|
-
createElementVNode("span", null, toDisplayString(
|
|
2341
|
+
createElementVNode("span", null, toDisplayString(__props.data.text), 1)
|
|
2268
2342
|
]),
|
|
2269
2343
|
_: 1
|
|
2270
2344
|
}, 8, ["disabled"])
|
|
@@ -2277,27 +2351,27 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2277
2351
|
disabled: unref(disabled)
|
|
2278
2352
|
}, {
|
|
2279
2353
|
default: withCtx(() => [
|
|
2280
|
-
|
|
2354
|
+
__props.data.icon ? (openBlock(), createBlock(_sfc_main$h, {
|
|
2281
2355
|
key: 0,
|
|
2282
|
-
icon:
|
|
2356
|
+
icon: __props.data.icon
|
|
2283
2357
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
2284
|
-
createElementVNode("span", null, toDisplayString(
|
|
2358
|
+
createElementVNode("span", null, toDisplayString(__props.data.text), 1)
|
|
2285
2359
|
]),
|
|
2286
2360
|
_: 1
|
|
2287
2361
|
}, 8, ["disabled"]))
|
|
2288
|
-
], 64)) :
|
|
2289
|
-
key:
|
|
2362
|
+
], 64)) : __props.data.type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
|
|
2363
|
+
key: 3,
|
|
2290
2364
|
trigger: "click",
|
|
2291
2365
|
disabled: unref(disabled),
|
|
2292
2366
|
onCommand: dropdownHandler
|
|
2293
2367
|
}, {
|
|
2294
2368
|
dropdown: withCtx(() => [
|
|
2295
|
-
|
|
2369
|
+
__props.data.items && __props.data.items.length ? (openBlock(), createBlock(_component_el_dropdown_menu, { key: 0 }, {
|
|
2296
2370
|
default: withCtx(() => [
|
|
2297
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
2371
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.data.items, (subItem, index) => {
|
|
2298
2372
|
return openBlock(), createBlock(_component_el_dropdown_item, {
|
|
2299
2373
|
key: index,
|
|
2300
|
-
command: {
|
|
2374
|
+
command: { data: __props.data, subItem }
|
|
2301
2375
|
}, {
|
|
2302
2376
|
default: withCtx(() => [
|
|
2303
2377
|
createTextVNode(toDisplayString(subItem.text), 1)
|
|
@@ -2310,8 +2384,8 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2310
2384
|
})) : createCommentVNode("", true)
|
|
2311
2385
|
]),
|
|
2312
2386
|
default: withCtx(() => [
|
|
2313
|
-
createElementVNode("span",
|
|
2314
|
-
createTextVNode(toDisplayString(
|
|
2387
|
+
createElementVNode("span", _hoisted_2$2, [
|
|
2388
|
+
createTextVNode(toDisplayString(__props.data.text), 1),
|
|
2315
2389
|
createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2316
2390
|
default: withCtx(() => [
|
|
2317
2391
|
createVNode(unref(ArrowDown))
|
|
@@ -2321,58 +2395,175 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2321
2395
|
])
|
|
2322
2396
|
]),
|
|
2323
2397
|
_: 1
|
|
2324
|
-
}, 8, ["disabled"])) :
|
|
2398
|
+
}, 8, ["disabled"])) : __props.data.type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(__props.data.component), normalizeProps(mergeProps({ key: 4 }, __props.data.props || {})), null, 16)) : createCommentVNode("", true)
|
|
2325
2399
|
], 34)) : createCommentVNode("", true);
|
|
2326
2400
|
};
|
|
2327
2401
|
}
|
|
2328
2402
|
});
|
|
2329
2403
|
|
|
2330
|
-
const _sfc_main$
|
|
2331
|
-
|
|
2332
|
-
components: { ToolButton: _sfc_main$f },
|
|
2404
|
+
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
2405
|
+
__name: "NavMenu",
|
|
2333
2406
|
props: {
|
|
2334
|
-
data: {
|
|
2335
|
-
|
|
2336
|
-
default: () => ({})
|
|
2337
|
-
},
|
|
2338
|
-
height: {
|
|
2339
|
-
type: Number
|
|
2340
|
-
}
|
|
2407
|
+
data: { default: () => ({}) },
|
|
2408
|
+
height: { default: 35 }
|
|
2341
2409
|
},
|
|
2342
|
-
setup(
|
|
2410
|
+
setup(__props) {
|
|
2411
|
+
const props = __props;
|
|
2343
2412
|
const services = inject("services");
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2413
|
+
const uiService = services?.uiService;
|
|
2414
|
+
const columnWidth = computed(() => services?.uiService.get("columnWidth"));
|
|
2415
|
+
const keys = Object.values(ColumnLayout);
|
|
2416
|
+
const showGuides = computed(() => uiService?.get("showGuides") ?? true);
|
|
2417
|
+
const showRule = computed(() => uiService?.get("showRule") ?? true);
|
|
2418
|
+
const zoom = computed(() => uiService?.get("zoom") ?? 1);
|
|
2419
|
+
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
2420
|
+
const ctrl = isMac ? "Command" : "Ctrl";
|
|
2421
|
+
const getConfig = (item) => {
|
|
2422
|
+
if (typeof item !== "string") {
|
|
2423
|
+
return [item];
|
|
2424
|
+
}
|
|
2425
|
+
const config = [];
|
|
2426
|
+
switch (item) {
|
|
2427
|
+
case "/":
|
|
2428
|
+
config.push({
|
|
2429
|
+
type: "divider",
|
|
2430
|
+
className: "divider"
|
|
2431
|
+
});
|
|
2432
|
+
break;
|
|
2433
|
+
case "zoom":
|
|
2434
|
+
config.push(...getConfig("zoom-out"), ...getConfig(`${parseInt(`${zoom.value * 100}`, 10)}%`), ...getConfig("zoom-in"), ...getConfig("scale-to-original"), ...getConfig("scale-to-fit"));
|
|
2435
|
+
break;
|
|
2436
|
+
case "delete":
|
|
2437
|
+
config.push({
|
|
2438
|
+
type: "button",
|
|
2439
|
+
className: "delete",
|
|
2440
|
+
icon: markRaw(Delete),
|
|
2441
|
+
tooltip: `\u522A\u9664(Delete)`,
|
|
2442
|
+
disabled: () => services?.editorService.get("node")?.type === NodeType.PAGE,
|
|
2443
|
+
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
2444
|
+
});
|
|
2445
|
+
break;
|
|
2446
|
+
case "undo":
|
|
2447
|
+
config.push({
|
|
2448
|
+
type: "button",
|
|
2449
|
+
className: "undo",
|
|
2450
|
+
icon: markRaw(Back),
|
|
2451
|
+
tooltip: `\u540E\u9000(${ctrl}+z)`,
|
|
2452
|
+
disabled: () => !services?.historyService.state.canUndo,
|
|
2453
|
+
handler: () => services?.editorService.undo()
|
|
2454
|
+
});
|
|
2455
|
+
break;
|
|
2456
|
+
case "redo":
|
|
2457
|
+
config.push({
|
|
2458
|
+
type: "button",
|
|
2459
|
+
className: "redo",
|
|
2460
|
+
icon: markRaw(Right),
|
|
2461
|
+
tooltip: `\u524D\u8FDB(${ctrl}+Shift+z)`,
|
|
2462
|
+
disabled: () => !services?.historyService.state.canRedo,
|
|
2463
|
+
handler: () => services?.editorService.redo()
|
|
2464
|
+
});
|
|
2465
|
+
break;
|
|
2466
|
+
case "zoom-in":
|
|
2467
|
+
config.push({
|
|
2468
|
+
type: "button",
|
|
2469
|
+
className: "zoom-in",
|
|
2470
|
+
icon: markRaw(ZoomIn),
|
|
2471
|
+
tooltip: `\u653E\u5927(${ctrl}+=)`,
|
|
2472
|
+
handler: () => uiService?.zoom(0.1)
|
|
2473
|
+
});
|
|
2474
|
+
break;
|
|
2475
|
+
case "zoom-out":
|
|
2476
|
+
config.push({
|
|
2477
|
+
type: "button",
|
|
2478
|
+
className: "zoom-out",
|
|
2479
|
+
icon: markRaw(ZoomOut),
|
|
2480
|
+
tooltip: `\u7E2E\u5C0F(${ctrl}+-)`,
|
|
2481
|
+
handler: () => uiService?.zoom(-0.1)
|
|
2482
|
+
});
|
|
2483
|
+
break;
|
|
2484
|
+
case "scale-to-original":
|
|
2485
|
+
config.push({
|
|
2486
|
+
type: "button",
|
|
2487
|
+
className: "scale-to-original",
|
|
2488
|
+
icon: markRaw(ScaleToOriginal),
|
|
2489
|
+
tooltip: `\u7F29\u653E\u5230\u5B9E\u9645\u5927\u5C0F(${ctrl}+1)`,
|
|
2490
|
+
handler: () => uiService?.set("zoom", 1)
|
|
2491
|
+
});
|
|
2492
|
+
break;
|
|
2493
|
+
case "scale-to-fit":
|
|
2494
|
+
config.push({
|
|
2495
|
+
type: "button",
|
|
2496
|
+
className: "scale-to-fit",
|
|
2497
|
+
icon: markRaw(FullScreen),
|
|
2498
|
+
tooltip: `\u7F29\u653E\u4EE5\u9002\u5E94(${ctrl}+0)`,
|
|
2499
|
+
handler: () => uiService?.set("zoom", uiService.calcZoom())
|
|
2500
|
+
});
|
|
2501
|
+
break;
|
|
2502
|
+
case "rule":
|
|
2503
|
+
config.push({
|
|
2504
|
+
type: "button",
|
|
2505
|
+
className: "rule",
|
|
2506
|
+
icon: markRaw(Memo),
|
|
2507
|
+
tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
|
|
2508
|
+
handler: () => uiService?.set("showRule", !showRule.value)
|
|
2509
|
+
});
|
|
2510
|
+
break;
|
|
2511
|
+
case "guides":
|
|
2512
|
+
config.push({
|
|
2513
|
+
type: "button",
|
|
2514
|
+
className: "guides",
|
|
2515
|
+
icon: markRaw(Grid),
|
|
2516
|
+
tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
|
|
2517
|
+
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
2518
|
+
});
|
|
2519
|
+
break;
|
|
2520
|
+
default:
|
|
2521
|
+
config.push({
|
|
2522
|
+
type: "text",
|
|
2523
|
+
text: item
|
|
2524
|
+
});
|
|
2525
|
+
}
|
|
2526
|
+
return config;
|
|
2347
2527
|
};
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2528
|
+
const buttons = computed(() => {
|
|
2529
|
+
const data = {
|
|
2530
|
+
[ColumnLayout.LEFT]: [],
|
|
2531
|
+
[ColumnLayout.CENTER]: [],
|
|
2532
|
+
[ColumnLayout.RIGHT]: []
|
|
2533
|
+
};
|
|
2534
|
+
keys.forEach((key) => {
|
|
2535
|
+
const items = props.data[key] || [];
|
|
2536
|
+
items.forEach((item) => {
|
|
2537
|
+
data[key].push(...getConfig(item));
|
|
2538
|
+
});
|
|
2539
|
+
});
|
|
2540
|
+
return data;
|
|
2541
|
+
});
|
|
2542
|
+
return (_ctx, _cache) => {
|
|
2358
2543
|
return openBlock(), createElementBlock("div", {
|
|
2359
|
-
class:
|
|
2360
|
-
|
|
2361
|
-
style: normalizeStyle(`width: ${_ctx.columnWidth?.[key]}px`)
|
|
2544
|
+
class: "m-editor-nav-menu",
|
|
2545
|
+
style: normalizeStyle({ height: `${__props.height}px` })
|
|
2362
2546
|
}, [
|
|
2363
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
2364
|
-
return openBlock(),
|
|
2365
|
-
|
|
2366
|
-
key
|
|
2367
|
-
|
|
2547
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(keys), (key) => {
|
|
2548
|
+
return openBlock(), createElementBlock("div", {
|
|
2549
|
+
class: normalizeClass(`menu-${key}`),
|
|
2550
|
+
key,
|
|
2551
|
+
style: normalizeStyle(`width: ${unref(columnWidth)?.[key]}px`)
|
|
2552
|
+
}, [
|
|
2553
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(buttons)[key], (item, index) => {
|
|
2554
|
+
return openBlock(), createBlock(_sfc_main$g, {
|
|
2555
|
+
data: item,
|
|
2556
|
+
key: index
|
|
2557
|
+
}, null, 8, ["data"]);
|
|
2558
|
+
}), 128))
|
|
2559
|
+
], 6);
|
|
2368
2560
|
}), 128))
|
|
2369
|
-
],
|
|
2370
|
-
}
|
|
2371
|
-
|
|
2372
|
-
}
|
|
2373
|
-
const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
|
|
2561
|
+
], 4);
|
|
2562
|
+
};
|
|
2563
|
+
}
|
|
2564
|
+
});
|
|
2374
2565
|
|
|
2375
|
-
const _sfc_main$
|
|
2566
|
+
const _sfc_main$e = defineComponent({
|
|
2376
2567
|
name: "m-editor-props-panel",
|
|
2377
2568
|
emits: ["mounted"],
|
|
2378
2569
|
setup(props, { emit }) {
|
|
@@ -2420,10 +2611,10 @@ const _sfc_main$d = defineComponent({
|
|
|
2420
2611
|
}
|
|
2421
2612
|
});
|
|
2422
2613
|
|
|
2423
|
-
const _hoisted_1$
|
|
2424
|
-
function _sfc_render$
|
|
2614
|
+
const _hoisted_1$4 = { class: "`m-editor-props-panel" };
|
|
2615
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2425
2616
|
const _component_m_form = resolveComponent("m-form");
|
|
2426
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
2617
|
+
return openBlock(), createElementBlock("div", _hoisted_1$4, [
|
|
2427
2618
|
renderSlot(_ctx.$slots, "props-panel-header"),
|
|
2428
2619
|
createVNode(_component_m_form, {
|
|
2429
2620
|
class: normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
|
|
@@ -2436,11 +2627,11 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2436
2627
|
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
|
|
2437
2628
|
]);
|
|
2438
2629
|
}
|
|
2439
|
-
const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2630
|
+
const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$6]]);
|
|
2440
2631
|
|
|
2441
|
-
const _sfc_main$
|
|
2632
|
+
const _sfc_main$d = defineComponent({
|
|
2442
2633
|
name: "ui-component-panel",
|
|
2443
|
-
components: { MIcon },
|
|
2634
|
+
components: { MIcon: _sfc_main$h },
|
|
2444
2635
|
setup() {
|
|
2445
2636
|
const searchText = ref("");
|
|
2446
2637
|
const services = inject("services");
|
|
@@ -2505,9 +2696,9 @@ const _sfc_main$c = defineComponent({
|
|
|
2505
2696
|
}
|
|
2506
2697
|
});
|
|
2507
2698
|
|
|
2508
|
-
const _hoisted_1$
|
|
2699
|
+
const _hoisted_1$3 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
2509
2700
|
const _hoisted_2$1 = ["onClick", "onDragstart"];
|
|
2510
|
-
function _sfc_render$
|
|
2701
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2511
2702
|
const _component_el_input = resolveComponent("el-input");
|
|
2512
2703
|
const _component_m_icon = resolveComponent("m-icon");
|
|
2513
2704
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
@@ -2538,7 +2729,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2538
2729
|
name: index
|
|
2539
2730
|
}, {
|
|
2540
2731
|
title: withCtx(() => [
|
|
2541
|
-
_hoisted_1$
|
|
2732
|
+
_hoisted_1$3,
|
|
2542
2733
|
createTextVNode(toDisplayString(group.title), 1)
|
|
2543
2734
|
]),
|
|
2544
2735
|
default: withCtx(() => [
|
|
@@ -2579,9 +2770,9 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2579
2770
|
_: 3
|
|
2580
2771
|
});
|
|
2581
2772
|
}
|
|
2582
|
-
const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2773
|
+
const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$5]]);
|
|
2583
2774
|
|
|
2584
|
-
const _sfc_main$
|
|
2775
|
+
const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
2585
2776
|
__name: "ContentMenu",
|
|
2586
2777
|
props: {
|
|
2587
2778
|
menuData: { default: () => [] },
|
|
@@ -2670,7 +2861,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
2670
2861
|
}, [
|
|
2671
2862
|
createElementVNode("div", null, [
|
|
2672
2863
|
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.menuData, (item, index) => {
|
|
2673
|
-
return openBlock(), createBlock(_sfc_main$
|
|
2864
|
+
return openBlock(), createBlock(_sfc_main$g, {
|
|
2674
2865
|
"event-type": "mouseup",
|
|
2675
2866
|
data: item,
|
|
2676
2867
|
key: index,
|
|
@@ -2694,8 +2885,8 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
2694
2885
|
}
|
|
2695
2886
|
});
|
|
2696
2887
|
|
|
2697
|
-
const _sfc_main$
|
|
2698
|
-
components: { ContentMenu: _sfc_main$
|
|
2888
|
+
const _sfc_main$b = defineComponent({
|
|
2889
|
+
components: { ContentMenu: _sfc_main$c },
|
|
2699
2890
|
setup() {
|
|
2700
2891
|
const services = inject("services");
|
|
2701
2892
|
const menu = ref();
|
|
@@ -2778,7 +2969,7 @@ const _sfc_main$a = defineComponent({
|
|
|
2778
2969
|
}
|
|
2779
2970
|
});
|
|
2780
2971
|
|
|
2781
|
-
function _sfc_render$
|
|
2972
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2782
2973
|
const _component_content_menu = resolveComponent("content-menu");
|
|
2783
2974
|
return openBlock(), createBlock(_component_content_menu, {
|
|
2784
2975
|
"menu-data": _ctx.menuData,
|
|
@@ -2786,7 +2977,7 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2786
2977
|
style: { "overflow": "initial" }
|
|
2787
2978
|
}, null, 8, ["menu-data"]);
|
|
2788
2979
|
}
|
|
2789
|
-
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2980
|
+
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$4]]);
|
|
2790
2981
|
|
|
2791
2982
|
const throttleTime = 150;
|
|
2792
2983
|
const select = async (data, editorService) => {
|
|
@@ -2837,20 +3028,38 @@ const useDrop = (tree, editorService) => ({
|
|
|
2837
3028
|
}
|
|
2838
3029
|
});
|
|
2839
3030
|
const useStatus = (tree, editorService) => {
|
|
2840
|
-
const highlightNode = ref();
|
|
2841
3031
|
const node = ref();
|
|
2842
3032
|
const page = computed(() => editorService?.get("page"));
|
|
3033
|
+
const expandedKeys = /* @__PURE__ */ new Map();
|
|
3034
|
+
const expandNodes = () => {
|
|
3035
|
+
expandedKeys.forEach((key) => {
|
|
3036
|
+
if (!tree.value)
|
|
3037
|
+
return;
|
|
3038
|
+
tree.value.getNode(key)?.expand();
|
|
3039
|
+
});
|
|
3040
|
+
};
|
|
2843
3041
|
watchEffect(() => {
|
|
2844
3042
|
if (!tree.value)
|
|
2845
3043
|
return;
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
3044
|
+
if (!editorService)
|
|
3045
|
+
return;
|
|
3046
|
+
node.value = editorService.get("node");
|
|
3047
|
+
if (!node.value)
|
|
3048
|
+
return;
|
|
3049
|
+
tree.value.setCurrentKey(node.value.id, true);
|
|
3050
|
+
const parent = editorService.get("parent");
|
|
2849
3051
|
if (!parent?.id)
|
|
2850
3052
|
return;
|
|
2851
3053
|
const treeNode = tree.value.getNode(parent.id);
|
|
2852
3054
|
treeNode?.updateChildren();
|
|
2853
|
-
|
|
3055
|
+
setTimeout(() => {
|
|
3056
|
+
tree.value && Object.entries(tree.value.store.nodesMap).forEach(([id, node2]) => {
|
|
3057
|
+
if (node2.expanded && node2.data.items) {
|
|
3058
|
+
expandedKeys.set(id, id);
|
|
3059
|
+
}
|
|
3060
|
+
});
|
|
3061
|
+
expandNodes();
|
|
3062
|
+
});
|
|
2854
3063
|
});
|
|
2855
3064
|
return {
|
|
2856
3065
|
values: computed(() => page.value ? [page.value] : []),
|
|
@@ -2863,9 +3072,18 @@ const useStatus = (tree, editorService) => {
|
|
|
2863
3072
|
}
|
|
2864
3073
|
resolve([]);
|
|
2865
3074
|
},
|
|
2866
|
-
highlightNode,
|
|
3075
|
+
highlightNode: computed(() => editorService?.get("highlightNode")),
|
|
2867
3076
|
clickNode: node,
|
|
2868
|
-
expandedKeys: computed(() => node.value ? [node.value.id] : [])
|
|
3077
|
+
expandedKeys: computed(() => node.value ? [node.value.id] : []),
|
|
3078
|
+
handleCollapse: (data) => {
|
|
3079
|
+
expandedKeys.delete(data.id);
|
|
3080
|
+
},
|
|
3081
|
+
handleExpand: (data) => {
|
|
3082
|
+
const parent = editorService?.getParentById(data.id);
|
|
3083
|
+
if (!parent?.id)
|
|
3084
|
+
return;
|
|
3085
|
+
expandedKeys.set(parent.id, parent.id);
|
|
3086
|
+
}
|
|
2869
3087
|
};
|
|
2870
3088
|
};
|
|
2871
3089
|
const useFilter = (tree) => ({
|
|
@@ -2886,7 +3104,7 @@ const useFilter = (tree) => ({
|
|
|
2886
3104
|
tree.value?.filter(val);
|
|
2887
3105
|
}
|
|
2888
3106
|
});
|
|
2889
|
-
const _sfc_main$
|
|
3107
|
+
const _sfc_main$a = defineComponent({
|
|
2890
3108
|
name: "magic-editor-layer-panel",
|
|
2891
3109
|
components: { LayerMenu },
|
|
2892
3110
|
setup() {
|
|
@@ -2934,8 +3152,8 @@ const _sfc_main$9 = defineComponent({
|
|
|
2934
3152
|
}
|
|
2935
3153
|
});
|
|
2936
3154
|
|
|
2937
|
-
const _hoisted_1$
|
|
2938
|
-
function _sfc_render$
|
|
3155
|
+
const _hoisted_1$2 = ["id", "onMouseenter"];
|
|
3156
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2939
3157
|
const _component_el_input = resolveComponent("el-input");
|
|
2940
3158
|
const _component_el_tree = resolveComponent("el-tree");
|
|
2941
3159
|
const _component_layer_menu = resolveComponent("layer-menu");
|
|
@@ -2956,6 +3174,7 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2956
3174
|
key: 0,
|
|
2957
3175
|
ref: "tree",
|
|
2958
3176
|
"node-key": "id",
|
|
3177
|
+
"empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
|
|
2959
3178
|
draggable: "",
|
|
2960
3179
|
"default-expanded-keys": _ctx.expandedKeys,
|
|
2961
3180
|
load: _ctx.loadItems,
|
|
@@ -2970,7 +3189,8 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2970
3189
|
onNodeClick: _ctx.clickHandler,
|
|
2971
3190
|
onNodeContextmenu: _ctx.contextmenu,
|
|
2972
3191
|
onNodeDragEnd: _ctx.handleDragEnd,
|
|
2973
|
-
|
|
3192
|
+
onNodeCollapse: _ctx.handleCollapse,
|
|
3193
|
+
onNodeExpand: _ctx.handleExpand
|
|
2974
3194
|
}, {
|
|
2975
3195
|
default: withCtx(({ node, data }) => [
|
|
2976
3196
|
createElementVNode("div", {
|
|
@@ -2986,10 +3206,10 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2986
3206
|
}, () => [
|
|
2987
3207
|
createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
|
|
2988
3208
|
])
|
|
2989
|
-
], 42, _hoisted_1$
|
|
3209
|
+
], 42, _hoisted_1$2)
|
|
2990
3210
|
]),
|
|
2991
3211
|
_: 3
|
|
2992
|
-
}, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : createCommentVNode("", true),
|
|
3212
|
+
}, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd", "onNodeCollapse", "onNodeExpand"])) : createCommentVNode("", true),
|
|
2993
3213
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
2994
3214
|
createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
|
|
2995
3215
|
]))
|
|
@@ -2997,10 +3217,10 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2997
3217
|
_: 3
|
|
2998
3218
|
});
|
|
2999
3219
|
}
|
|
3000
|
-
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3220
|
+
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$3]]);
|
|
3001
3221
|
|
|
3002
|
-
const _sfc_main$
|
|
3003
|
-
components: { MIcon },
|
|
3222
|
+
const _sfc_main$9 = defineComponent({
|
|
3223
|
+
components: { MIcon: _sfc_main$h },
|
|
3004
3224
|
props: {
|
|
3005
3225
|
data: {
|
|
3006
3226
|
type: [Object, String]
|
|
@@ -3037,11 +3257,11 @@ const _sfc_main$8 = defineComponent({
|
|
|
3037
3257
|
}
|
|
3038
3258
|
});
|
|
3039
3259
|
|
|
3040
|
-
const _hoisted_1$
|
|
3260
|
+
const _hoisted_1$1 = {
|
|
3041
3261
|
key: 1,
|
|
3042
3262
|
class: "magic-editor-tab-panel-title"
|
|
3043
3263
|
};
|
|
3044
|
-
function _sfc_render$
|
|
3264
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3045
3265
|
const _component_m_icon = resolveComponent("m-icon");
|
|
3046
3266
|
const _component_el_tab_pane = resolveComponent("el-tab-pane");
|
|
3047
3267
|
return _ctx.config ? (openBlock(), createBlock(_component_el_tab_pane, {
|
|
@@ -3056,7 +3276,7 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3056
3276
|
key: 0,
|
|
3057
3277
|
icon: _ctx.config.icon
|
|
3058
3278
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
3059
|
-
_ctx.config.text ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
3279
|
+
_ctx.config.text ? (openBlock(), createElementBlock("div", _hoisted_1$1, toDisplayString(_ctx.config.text), 1)) : createCommentVNode("", true)
|
|
3060
3280
|
]))
|
|
3061
3281
|
]),
|
|
3062
3282
|
default: withCtx(() => [
|
|
@@ -3087,9 +3307,9 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3087
3307
|
_: 3
|
|
3088
3308
|
}, 8, ["name"])) : createCommentVNode("", true);
|
|
3089
3309
|
}
|
|
3090
|
-
const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3310
|
+
const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$2]]);
|
|
3091
3311
|
|
|
3092
|
-
const _sfc_main$
|
|
3312
|
+
const _sfc_main$8 = defineComponent({
|
|
3093
3313
|
components: { TabPane },
|
|
3094
3314
|
name: "m-sidebar",
|
|
3095
3315
|
props: {
|
|
@@ -3109,7 +3329,7 @@ const _sfc_main$7 = defineComponent({
|
|
|
3109
3329
|
}
|
|
3110
3330
|
});
|
|
3111
3331
|
|
|
3112
|
-
function _sfc_render$
|
|
3332
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3113
3333
|
const _component_tab_pane = resolveComponent("tab-pane");
|
|
3114
3334
|
const _component_el_tabs = resolveComponent("el-tabs");
|
|
3115
3335
|
return _ctx.data.type === "tabs" && _ctx.data.items.length ? (openBlock(), createBlock(_component_el_tabs, {
|
|
@@ -3144,9 +3364,9 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3144
3364
|
_: 3
|
|
3145
3365
|
}, 8, ["modelValue"])) : createCommentVNode("", true);
|
|
3146
3366
|
}
|
|
3147
|
-
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3367
|
+
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$1]]);
|
|
3148
3368
|
|
|
3149
|
-
const _sfc_main$
|
|
3369
|
+
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
3150
3370
|
__name: "PageBarScrollContainer",
|
|
3151
3371
|
setup(__props) {
|
|
3152
3372
|
const services = inject("services");
|
|
@@ -3273,9 +3493,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
3273
3493
|
}
|
|
3274
3494
|
});
|
|
3275
3495
|
|
|
3276
|
-
const _hoisted_1
|
|
3496
|
+
const _hoisted_1 = ["onClick"];
|
|
3277
3497
|
const _hoisted_2 = { class: "m-editor-page-bar-title" };
|
|
3278
|
-
const _sfc_main$
|
|
3498
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
3279
3499
|
__name: "PageBar",
|
|
3280
3500
|
setup(__props) {
|
|
3281
3501
|
const services = inject("services");
|
|
@@ -3299,7 +3519,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3299
3519
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
3300
3520
|
const _component_el_icon = resolveComponent("el-icon");
|
|
3301
3521
|
const _component_el_popover = resolveComponent("el-popover");
|
|
3302
|
-
return openBlock(), createBlock(_sfc_main$
|
|
3522
|
+
return openBlock(), createBlock(_sfc_main$7, null, {
|
|
3303
3523
|
default: withCtx(() => [
|
|
3304
3524
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(root) && unref(root).items || [], (item) => {
|
|
3305
3525
|
return openBlock(), createElementBlock("div", {
|
|
@@ -3315,7 +3535,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3315
3535
|
content: item.name
|
|
3316
3536
|
}, {
|
|
3317
3537
|
default: withCtx(() => [
|
|
3318
|
-
createElementVNode("span", null, toDisplayString(item.name), 1)
|
|
3538
|
+
createElementVNode("span", null, toDisplayString(item.name || item.id), 1)
|
|
3319
3539
|
]),
|
|
3320
3540
|
_: 2
|
|
3321
3541
|
}, 1032, ["content"])
|
|
@@ -3338,7 +3558,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3338
3558
|
default: withCtx(() => [
|
|
3339
3559
|
createElementVNode("div", null, [
|
|
3340
3560
|
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3341
|
-
createVNode(_sfc_main$
|
|
3561
|
+
createVNode(_sfc_main$g, {
|
|
3342
3562
|
data: {
|
|
3343
3563
|
type: "button",
|
|
3344
3564
|
text: "\u590D\u5236",
|
|
@@ -3346,7 +3566,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3346
3566
|
handler: () => copy(item)
|
|
3347
3567
|
}
|
|
3348
3568
|
}, null, 8, ["data"]),
|
|
3349
|
-
createVNode(_sfc_main$
|
|
3569
|
+
createVNode(_sfc_main$g, {
|
|
3350
3570
|
data: {
|
|
3351
3571
|
type: "button",
|
|
3352
3572
|
text: "\u5220\u9664",
|
|
@@ -3359,7 +3579,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3359
3579
|
]),
|
|
3360
3580
|
_: 2
|
|
3361
3581
|
}, 1024)
|
|
3362
|
-
], 10, _hoisted_1
|
|
3582
|
+
], 10, _hoisted_1);
|
|
3363
3583
|
}), 128))
|
|
3364
3584
|
]),
|
|
3365
3585
|
_: 3
|
|
@@ -3368,190 +3588,245 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3368
3588
|
}
|
|
3369
3589
|
});
|
|
3370
3590
|
|
|
3371
|
-
class ScrollViewer
|
|
3372
|
-
enter = false;
|
|
3373
|
-
targetEnter = false;
|
|
3374
|
-
keydown = false;
|
|
3591
|
+
class ScrollViewer extends EventEmitter {
|
|
3375
3592
|
container;
|
|
3376
3593
|
target;
|
|
3377
3594
|
zoom = 1;
|
|
3378
3595
|
scrollLeft = 0;
|
|
3379
3596
|
scrollTop = 0;
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
if (targetWidth < width) {
|
|
3390
|
-
this.target._left = 0;
|
|
3391
|
-
}
|
|
3392
|
-
if (targetHeight < height) {
|
|
3393
|
-
this.target._top = 0;
|
|
3394
|
-
}
|
|
3395
|
-
this.scroll();
|
|
3396
|
-
}
|
|
3597
|
+
scrollHeight = 0;
|
|
3598
|
+
scrollWidth = 0;
|
|
3599
|
+
width = 0;
|
|
3600
|
+
height = 0;
|
|
3601
|
+
translateXCorrectionValue = 0;
|
|
3602
|
+
translateYCorrectionValue = 0;
|
|
3603
|
+
resizeObserver = new ResizeObserver(() => {
|
|
3604
|
+
this.setSize();
|
|
3605
|
+
this.setScrollSize();
|
|
3397
3606
|
});
|
|
3398
3607
|
constructor(options) {
|
|
3608
|
+
super();
|
|
3399
3609
|
this.container = options.container;
|
|
3400
3610
|
this.target = options.target;
|
|
3401
3611
|
this.zoom = options.zoom;
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
this.
|
|
3405
|
-
this.container.addEventListener("mouseleave", this.mouseLeaveHandler);
|
|
3406
|
-
this.target.addEventListener("mouseenter", this.targetMouseEnterHandler);
|
|
3407
|
-
this.target.addEventListener("mouseleave", this.targetMouseLeaveHandler);
|
|
3408
|
-
this.container.addEventListener("wheel", this.wheelHandler);
|
|
3612
|
+
this.container.addEventListener("wheel", this.wheelHandler, false);
|
|
3613
|
+
this.setSize();
|
|
3614
|
+
this.setScrollSize();
|
|
3409
3615
|
this.resizeObserver.observe(this.container);
|
|
3410
3616
|
}
|
|
3411
3617
|
destroy() {
|
|
3412
3618
|
this.resizeObserver.disconnect();
|
|
3413
|
-
this.container.removeEventListener("
|
|
3414
|
-
this.
|
|
3415
|
-
this.target.removeEventListener("mouseenter", this.targetMouseEnterHandler);
|
|
3416
|
-
this.target.removeEventListener("mouseleave", this.targetMouseLeaveHandler);
|
|
3417
|
-
globalThis.removeEventListener("keydown", this.keydownHandler);
|
|
3418
|
-
globalThis.removeEventListener("keyup", this.keyupHandler);
|
|
3619
|
+
this.container.removeEventListener("wheel", this.wheelHandler, false);
|
|
3620
|
+
this.removeAllListeners();
|
|
3419
3621
|
}
|
|
3420
3622
|
setZoom(zoom) {
|
|
3421
3623
|
this.zoom = zoom;
|
|
3624
|
+
this.setScrollSize();
|
|
3422
3625
|
}
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
this.
|
|
3431
|
-
|
|
3432
|
-
|
|
3626
|
+
scrollTo({ left, top }) {
|
|
3627
|
+
if (typeof left !== "undefined") {
|
|
3628
|
+
this.scrollLeft = left;
|
|
3629
|
+
}
|
|
3630
|
+
if (typeof top !== "undefined") {
|
|
3631
|
+
this.scrollTop = top;
|
|
3632
|
+
}
|
|
3633
|
+
const translateX = -this.scrollLeft + this.translateXCorrectionValue;
|
|
3634
|
+
const translateY = -this.scrollTop + this.translateYCorrectionValue;
|
|
3635
|
+
this.target.style.transform = `translate(${translateX}px, ${translateY}px)`;
|
|
3433
3636
|
}
|
|
3434
3637
|
wheelHandler = (event) => {
|
|
3435
|
-
if (this.targetEnter)
|
|
3436
|
-
return;
|
|
3437
3638
|
const { deltaX, deltaY, currentTarget } = event;
|
|
3438
3639
|
if (currentTarget !== this.container)
|
|
3439
3640
|
return;
|
|
3440
|
-
|
|
3441
|
-
this.
|
|
3442
|
-
|
|
3443
|
-
this.scrollTop = this.target._top;
|
|
3444
|
-
};
|
|
3445
|
-
mouseEnterHandler = () => {
|
|
3446
|
-
this.enter = true;
|
|
3447
|
-
};
|
|
3448
|
-
mouseLeaveHandler = () => {
|
|
3449
|
-
this.enter = false;
|
|
3450
|
-
};
|
|
3451
|
-
targetMouseEnterHandler = () => {
|
|
3452
|
-
this.targetEnter = true;
|
|
3453
|
-
};
|
|
3454
|
-
targetMouseLeaveHandler = () => {
|
|
3455
|
-
this.targetEnter = false;
|
|
3456
|
-
};
|
|
3457
|
-
mousedownHandler = (event) => {
|
|
3458
|
-
if (!this.keydown)
|
|
3459
|
-
return;
|
|
3460
|
-
event.stopImmediatePropagation();
|
|
3461
|
-
event.stopPropagation();
|
|
3462
|
-
this.target.style.cursor = "grabbing";
|
|
3463
|
-
this.x = event.clientX;
|
|
3464
|
-
this.y = event.clientY;
|
|
3465
|
-
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3466
|
-
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3467
|
-
};
|
|
3468
|
-
mouseupHandler = () => {
|
|
3469
|
-
this.x = 0;
|
|
3470
|
-
this.y = 0;
|
|
3471
|
-
this.scrollLeft = this.target._left;
|
|
3472
|
-
this.scrollTop = this.target._top;
|
|
3473
|
-
this.removeHandler();
|
|
3474
|
-
};
|
|
3475
|
-
mousemoveHandler = (event) => {
|
|
3476
|
-
event.stopImmediatePropagation();
|
|
3477
|
-
event.stopPropagation();
|
|
3478
|
-
const deltaX = event.clientX - this.x;
|
|
3479
|
-
const deltaY = event.clientY - this.y;
|
|
3480
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3481
|
-
this.scroll();
|
|
3482
|
-
};
|
|
3483
|
-
keydownHandler = (event) => {
|
|
3484
|
-
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3485
|
-
event.preventDefault();
|
|
3486
|
-
event.stopImmediatePropagation();
|
|
3487
|
-
event.stopPropagation();
|
|
3641
|
+
let top;
|
|
3642
|
+
if (this.scrollHeight > this.height) {
|
|
3643
|
+
top = this.scrollTop + this.getPos(deltaY, this.scrollTop, this.scrollHeight, this.height);
|
|
3488
3644
|
}
|
|
3489
|
-
|
|
3490
|
-
|
|
3645
|
+
let left;
|
|
3646
|
+
if (this.scrollWidth > this.width) {
|
|
3647
|
+
left = this.scrollLeft + this.getPos(deltaX, this.scrollLeft, this.scrollWidth, this.width);
|
|
3491
3648
|
}
|
|
3492
|
-
this.
|
|
3493
|
-
this.
|
|
3494
|
-
|
|
3649
|
+
this.scrollTo({ left, top });
|
|
3650
|
+
this.emit("scroll", {
|
|
3651
|
+
scrollLeft: this.scrollLeft,
|
|
3652
|
+
scrollTop: this.scrollTop,
|
|
3653
|
+
scrollHeight: this.scrollHeight,
|
|
3654
|
+
scrollWidth: this.scrollWidth
|
|
3655
|
+
});
|
|
3495
3656
|
};
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3657
|
+
getPos(delta, scrollPos, scrollSize, size) {
|
|
3658
|
+
let pos = 0;
|
|
3659
|
+
if (delta < 0) {
|
|
3660
|
+
if (scrollPos > 0) {
|
|
3661
|
+
pos = Math.max(delta, -scrollPos);
|
|
3662
|
+
}
|
|
3663
|
+
} else {
|
|
3664
|
+
const leftPos = scrollSize - size - scrollPos;
|
|
3665
|
+
if (leftPos > 0) {
|
|
3666
|
+
pos = Math.min(delta, leftPos);
|
|
3667
|
+
}
|
|
3499
3668
|
}
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
this.
|
|
3669
|
+
return pos;
|
|
3670
|
+
}
|
|
3671
|
+
setScrollSize = () => {
|
|
3672
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3673
|
+
this.scrollWidth = targetRect.width * this.zoom + 100;
|
|
3674
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3675
|
+
this.scrollHeight = (targetRect.height + targetMarginTop) * this.zoom + 100;
|
|
3676
|
+
let left;
|
|
3677
|
+
let top;
|
|
3678
|
+
if (this.scrollWidth < this.width) {
|
|
3679
|
+
left = 0;
|
|
3680
|
+
this.translateXCorrectionValue = 0;
|
|
3681
|
+
} else {
|
|
3682
|
+
this.translateXCorrectionValue = (this.scrollWidth - this.width) / 2;
|
|
3683
|
+
}
|
|
3684
|
+
if (this.scrollHeight < this.height) {
|
|
3685
|
+
top = 0;
|
|
3686
|
+
this.translateYCorrectionValue = 0;
|
|
3687
|
+
} else {
|
|
3688
|
+
this.translateYCorrectionValue = (this.scrollHeight - this.height) / 2;
|
|
3689
|
+
}
|
|
3690
|
+
this.scrollTo({
|
|
3691
|
+
left,
|
|
3692
|
+
top
|
|
3693
|
+
});
|
|
3694
|
+
this.emit("scroll", {
|
|
3695
|
+
scrollLeft: this.scrollLeft,
|
|
3696
|
+
scrollTop: this.scrollTop,
|
|
3697
|
+
scrollHeight: this.scrollHeight,
|
|
3698
|
+
scrollWidth: this.scrollWidth
|
|
3699
|
+
});
|
|
3506
3700
|
};
|
|
3507
|
-
|
|
3701
|
+
setSize = () => {
|
|
3508
3702
|
const { width, height } = this.container.getBoundingClientRect();
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3703
|
+
this.width = width;
|
|
3704
|
+
this.height = height;
|
|
3705
|
+
};
|
|
3706
|
+
}
|
|
3707
|
+
|
|
3708
|
+
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
3709
|
+
__name: "ScrollBar",
|
|
3710
|
+
props: {
|
|
3711
|
+
size: null,
|
|
3712
|
+
scrollSize: null,
|
|
3713
|
+
isHorizontal: { type: Boolean },
|
|
3714
|
+
pos: null
|
|
3715
|
+
},
|
|
3716
|
+
emits: ["scroll"],
|
|
3717
|
+
setup(__props, { emit }) {
|
|
3718
|
+
const props = __props;
|
|
3719
|
+
const bar = ref();
|
|
3720
|
+
const thumb = ref();
|
|
3721
|
+
const thumbSize = computed(() => props.size * (props.size / props.scrollSize));
|
|
3722
|
+
const thumbPos = computed(() => props.pos / props.scrollSize * props.size);
|
|
3723
|
+
const thumbStyle = computed(() => ({
|
|
3724
|
+
[props.isHorizontal ? "width" : "height"]: `${thumbSize.value}px`,
|
|
3725
|
+
transform: `translate${props.isHorizontal ? "X" : "Y"}(${thumbPos.value}px)`
|
|
3726
|
+
}));
|
|
3727
|
+
let gesto;
|
|
3728
|
+
onMounted(() => {
|
|
3729
|
+
if (!thumb.value)
|
|
3730
|
+
return;
|
|
3731
|
+
const thumbEl = thumb.value;
|
|
3732
|
+
gesto = new Gesto(thumbEl, {
|
|
3733
|
+
container: window
|
|
3734
|
+
});
|
|
3735
|
+
gesto.on("dragStart", (e) => {
|
|
3736
|
+
e.inputEvent.stopPropagation();
|
|
3737
|
+
e.inputEvent.preventDefault();
|
|
3738
|
+
}).on("drag", (e) => {
|
|
3739
|
+
scrollBy(getDelta(e));
|
|
3740
|
+
});
|
|
3741
|
+
bar.value?.addEventListener("wheel", wheelHandler, false);
|
|
3742
|
+
});
|
|
3743
|
+
onUnmounted(() => {
|
|
3744
|
+
if (gesto)
|
|
3745
|
+
gesto.off();
|
|
3746
|
+
bar.value?.removeEventListener("wheel", wheelHandler, false);
|
|
3747
|
+
});
|
|
3748
|
+
const wheelHandler = (e) => {
|
|
3749
|
+
const delta = props.isHorizontal ? e.deltaX : e.deltaY;
|
|
3750
|
+
if (delta) {
|
|
3751
|
+
e.preventDefault();
|
|
3518
3752
|
}
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3753
|
+
scrollBy(delta);
|
|
3754
|
+
};
|
|
3755
|
+
const getDelta = (e) => {
|
|
3756
|
+
const ratio = (props.isHorizontal ? e.deltaX : e.deltaY) / props.size;
|
|
3757
|
+
return props.scrollSize * ratio;
|
|
3758
|
+
};
|
|
3759
|
+
const scrollBy = (delta) => {
|
|
3760
|
+
if (delta < 0) {
|
|
3761
|
+
if (props.pos <= 0) {
|
|
3762
|
+
emit("scroll", 0);
|
|
3763
|
+
} else {
|
|
3764
|
+
emit("scroll", -Math.min(-delta, props.pos));
|
|
3765
|
+
}
|
|
3524
3766
|
} else {
|
|
3525
|
-
|
|
3767
|
+
const leftPos = props.size - (thumbSize.value + thumbPos.value);
|
|
3768
|
+
if (leftPos <= 0) {
|
|
3769
|
+
emit("scroll", 0);
|
|
3770
|
+
} else {
|
|
3771
|
+
emit("scroll", Math.min(delta, leftPos));
|
|
3772
|
+
}
|
|
3526
3773
|
}
|
|
3527
|
-
}
|
|
3528
|
-
|
|
3529
|
-
|
|
3774
|
+
};
|
|
3775
|
+
return (_ctx, _cache) => {
|
|
3776
|
+
return openBlock(), createElementBlock("div", {
|
|
3777
|
+
ref_key: "bar",
|
|
3778
|
+
ref: bar,
|
|
3779
|
+
class: normalizeClass(["m-editor-scroll-bar", __props.isHorizontal ? "horizontal" : "vertical"])
|
|
3780
|
+
}, [
|
|
3781
|
+
createElementVNode("div", {
|
|
3782
|
+
ref_key: "thumb",
|
|
3783
|
+
ref: thumb,
|
|
3784
|
+
class: "m-editor-scroll-bar-thumb",
|
|
3785
|
+
style: normalizeStyle(unref(thumbStyle))
|
|
3786
|
+
}, null, 4)
|
|
3787
|
+
], 2);
|
|
3788
|
+
};
|
|
3530
3789
|
}
|
|
3531
|
-
}
|
|
3790
|
+
});
|
|
3791
|
+
|
|
3792
|
+
const ScrollBar_vue_vue_type_style_index_0_lang = '';
|
|
3532
3793
|
|
|
3533
|
-
const _sfc_main$4 = defineComponent({
|
|
3534
|
-
|
|
3794
|
+
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
3795
|
+
__name: "ScrollViewer",
|
|
3535
3796
|
props: {
|
|
3536
|
-
width:
|
|
3537
|
-
height:
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
}
|
|
3797
|
+
width: { default: 0 },
|
|
3798
|
+
height: { default: 0 },
|
|
3799
|
+
wrapWidth: { default: 0 },
|
|
3800
|
+
wrapHeight: { default: 0 },
|
|
3801
|
+
zoom: { default: 1 }
|
|
3542
3802
|
},
|
|
3543
|
-
setup(
|
|
3803
|
+
setup(__props, { expose }) {
|
|
3804
|
+
const props = __props;
|
|
3544
3805
|
const container = ref();
|
|
3545
3806
|
const el = ref();
|
|
3807
|
+
const style = computed(() => `
|
|
3808
|
+
width: ${props.width}px;
|
|
3809
|
+
height: ${props.height}px;
|
|
3810
|
+
position: absolute;
|
|
3811
|
+
margin-top: 30px;
|
|
3812
|
+
`);
|
|
3813
|
+
const scrollWidth = ref(0);
|
|
3814
|
+
const scrollHeight = ref(0);
|
|
3546
3815
|
let scrollViewer;
|
|
3547
3816
|
onMounted(() => {
|
|
3548
3817
|
if (!container.value || !el.value)
|
|
3549
3818
|
return;
|
|
3550
|
-
scrollViewer = new ScrollViewer
|
|
3819
|
+
scrollViewer = new ScrollViewer({
|
|
3551
3820
|
container: container.value,
|
|
3552
3821
|
target: el.value,
|
|
3553
3822
|
zoom: props.zoom
|
|
3554
3823
|
});
|
|
3824
|
+
scrollViewer.on("scroll", (data) => {
|
|
3825
|
+
hOffset.value = data.scrollLeft;
|
|
3826
|
+
vOffset.value = data.scrollTop;
|
|
3827
|
+
scrollWidth.value = data.scrollWidth;
|
|
3828
|
+
scrollHeight.value = data.scrollHeight;
|
|
3829
|
+
});
|
|
3555
3830
|
});
|
|
3556
3831
|
onUnmounted(() => {
|
|
3557
3832
|
scrollViewer.destroy();
|
|
@@ -3559,35 +3834,56 @@ const _sfc_main$4 = defineComponent({
|
|
|
3559
3834
|
watch(() => props.zoom, () => {
|
|
3560
3835
|
scrollViewer.setZoom(props.zoom);
|
|
3561
3836
|
});
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3837
|
+
const vOffset = ref(0);
|
|
3838
|
+
const vScrollHandler = (delta) => {
|
|
3839
|
+
vOffset.value += delta;
|
|
3840
|
+
scrollViewer.scrollTo({
|
|
3841
|
+
top: vOffset.value
|
|
3842
|
+
});
|
|
3843
|
+
};
|
|
3844
|
+
const hOffset = ref(0);
|
|
3845
|
+
const hScrollHandler = (delta) => {
|
|
3846
|
+
hOffset.value += delta;
|
|
3847
|
+
scrollViewer.scrollTo({
|
|
3848
|
+
left: hOffset.value
|
|
3849
|
+
});
|
|
3850
|
+
};
|
|
3851
|
+
expose({
|
|
3852
|
+
container
|
|
3853
|
+
});
|
|
3854
|
+
return (_ctx, _cache) => {
|
|
3855
|
+
return openBlock(), createElementBlock("div", {
|
|
3856
|
+
class: "m-editor-scroll-viewer-container",
|
|
3857
|
+
ref_key: "container",
|
|
3858
|
+
ref: container
|
|
3859
|
+
}, [
|
|
3860
|
+
createElementVNode("div", {
|
|
3861
|
+
ref_key: "el",
|
|
3862
|
+
ref: el,
|
|
3863
|
+
style: normalizeStyle(unref(style))
|
|
3864
|
+
}, [
|
|
3865
|
+
renderSlot(_ctx.$slots, "default")
|
|
3866
|
+
], 4),
|
|
3867
|
+
scrollHeight.value > __props.wrapHeight ? (openBlock(), createBlock(_sfc_main$5, {
|
|
3868
|
+
key: 0,
|
|
3869
|
+
"scroll-size": scrollHeight.value,
|
|
3870
|
+
size: __props.wrapHeight,
|
|
3871
|
+
pos: vOffset.value,
|
|
3872
|
+
onScroll: vScrollHandler
|
|
3873
|
+
}, null, 8, ["scroll-size", "size", "pos"])) : createCommentVNode("", true),
|
|
3874
|
+
scrollWidth.value > __props.wrapWidth ? (openBlock(), createBlock(_sfc_main$5, {
|
|
3875
|
+
key: 1,
|
|
3876
|
+
"is-horizontal": true,
|
|
3877
|
+
"scroll-size": scrollWidth.value,
|
|
3878
|
+
pos: hOffset.value,
|
|
3879
|
+
size: __props.wrapWidth,
|
|
3880
|
+
onScroll: hScrollHandler
|
|
3881
|
+
}, null, 8, ["scroll-size", "pos", "size"])) : createCommentVNode("", true)
|
|
3882
|
+
], 512);
|
|
3571
3883
|
};
|
|
3572
3884
|
}
|
|
3573
3885
|
});
|
|
3574
3886
|
|
|
3575
|
-
const _hoisted_1$1 = {
|
|
3576
|
-
class: "m-editor-scroll-viewer-container",
|
|
3577
|
-
ref: "container"
|
|
3578
|
-
};
|
|
3579
|
-
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3580
|
-
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
3581
|
-
createElementVNode("div", {
|
|
3582
|
-
ref: "el",
|
|
3583
|
-
style: normalizeStyle(_ctx.style)
|
|
3584
|
-
}, [
|
|
3585
|
-
renderSlot(_ctx.$slots, "default")
|
|
3586
|
-
], 4)
|
|
3587
|
-
], 512);
|
|
3588
|
-
}
|
|
3589
|
-
const ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$2]]);
|
|
3590
|
-
|
|
3591
3887
|
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
3592
3888
|
__name: "ViewerMenu",
|
|
3593
3889
|
props: {
|
|
@@ -3724,7 +4020,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
3724
4020
|
};
|
|
3725
4021
|
expose({ show });
|
|
3726
4022
|
return (_ctx, _cache) => {
|
|
3727
|
-
return openBlock(), createBlock(_sfc_main$
|
|
4023
|
+
return openBlock(), createBlock(_sfc_main$c, {
|
|
3728
4024
|
"menu-data": menuData,
|
|
3729
4025
|
ref_key: "menu",
|
|
3730
4026
|
ref: menu
|
|
@@ -3745,12 +4041,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3745
4041
|
const menu = ref();
|
|
3746
4042
|
const isMultiSelect = computed(() => services?.editorService.get("nodes")?.length > 1);
|
|
3747
4043
|
const stageRect = computed(() => services?.uiService.get("stageRect"));
|
|
3748
|
-
const
|
|
4044
|
+
const stageContainerRect = computed(() => services?.uiService.get("stageContainerRect"));
|
|
3749
4045
|
const root = computed(() => services?.editorService.get("root"));
|
|
3750
4046
|
const page = computed(() => services?.editorService.get("page"));
|
|
3751
4047
|
const zoom = computed(() => services?.uiService.get("zoom") || 1);
|
|
3752
4048
|
const node = computed(() => services?.editorService.get("node"));
|
|
3753
|
-
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
3754
4049
|
watchEffect(() => {
|
|
3755
4050
|
if (stage)
|
|
3756
4051
|
return;
|
|
@@ -3758,64 +4053,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3758
4053
|
return;
|
|
3759
4054
|
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
|
|
3760
4055
|
return;
|
|
3761
|
-
stage =
|
|
3762
|
-
render: stageOptions.render,
|
|
3763
|
-
runtimeUrl: stageOptions.runtimeUrl,
|
|
3764
|
-
zoom: zoom.value,
|
|
3765
|
-
autoScrollIntoView: stageOptions.autoScrollIntoView,
|
|
3766
|
-
isContainer: stageOptions.isContainer,
|
|
3767
|
-
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
3768
|
-
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
3769
|
-
containerHighlightType: stageOptions.containerHighlightType,
|
|
3770
|
-
canSelect: (el, event, stop) => {
|
|
3771
|
-
const elCanSelect = stageOptions.canSelect(el);
|
|
3772
|
-
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
3773
|
-
document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
|
|
3774
|
-
return stop();
|
|
3775
|
-
}
|
|
3776
|
-
return elCanSelect;
|
|
3777
|
-
},
|
|
3778
|
-
moveableOptions: stageOptions.moveableOptions,
|
|
3779
|
-
updateDragEl: stageOptions.updateDragEl
|
|
3780
|
-
});
|
|
4056
|
+
stage = useStage(stageOptions);
|
|
3781
4057
|
services?.editorService.set("stage", markRaw(stage));
|
|
3782
4058
|
stage?.mount(stageContainer.value);
|
|
3783
|
-
stage.mask.setGuides([
|
|
3784
|
-
getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
|
|
3785
|
-
getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
|
|
3786
|
-
]);
|
|
3787
|
-
stage?.on("select", (el) => {
|
|
3788
|
-
services?.editorService.select(el.id);
|
|
3789
|
-
});
|
|
3790
|
-
stage?.on("highlight", (el) => {
|
|
3791
|
-
services?.editorService.highlight(el.id);
|
|
3792
|
-
});
|
|
3793
|
-
stage?.on("multiSelect", (els) => {
|
|
3794
|
-
services?.editorService.multiSelect(els.map((el) => el.id));
|
|
3795
|
-
});
|
|
3796
|
-
stage?.on("update", (ev) => {
|
|
3797
|
-
if (ev.parentEl) {
|
|
3798
|
-
for (const data of ev.data) {
|
|
3799
|
-
services?.editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
3800
|
-
}
|
|
3801
|
-
return;
|
|
3802
|
-
}
|
|
3803
|
-
services?.editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
3804
|
-
});
|
|
3805
|
-
stage?.on("sort", (ev) => {
|
|
3806
|
-
services?.editorService.sort(ev.src, ev.dist);
|
|
3807
|
-
});
|
|
3808
|
-
stage?.on("changeGuides", (e2) => {
|
|
3809
|
-
services?.uiService.set("showGuides", true);
|
|
3810
|
-
if (!root.value || !page.value)
|
|
3811
|
-
return;
|
|
3812
|
-
const storageKey = getGuideLineKey(e2.type === GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY);
|
|
3813
|
-
if (e2.guides.length) {
|
|
3814
|
-
globalThis.localStorage.setItem(storageKey, JSON.stringify(e2.guides));
|
|
3815
|
-
} else {
|
|
3816
|
-
globalThis.localStorage.removeItem(storageKey);
|
|
3817
|
-
}
|
|
3818
|
-
});
|
|
3819
4059
|
if (!node.value?.id)
|
|
3820
4060
|
return;
|
|
3821
4061
|
stage?.on("runtime-ready", (rt) => {
|
|
@@ -3901,12 +4141,14 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3901
4141
|
}
|
|
3902
4142
|
};
|
|
3903
4143
|
return (_ctx, _cache) => {
|
|
3904
|
-
return openBlock(), createBlock(
|
|
4144
|
+
return openBlock(), createBlock(_sfc_main$4, {
|
|
3905
4145
|
class: "m-editor-stage",
|
|
3906
4146
|
ref_key: "stageWrap",
|
|
3907
4147
|
ref: stageWrap,
|
|
3908
4148
|
width: unref(stageRect)?.width,
|
|
3909
4149
|
height: unref(stageRect)?.height,
|
|
4150
|
+
"wrap-width": unref(stageContainerRect)?.width,
|
|
4151
|
+
"wrap-height": unref(stageContainerRect)?.height,
|
|
3910
4152
|
zoom: unref(zoom)
|
|
3911
4153
|
}, {
|
|
3912
4154
|
default: withCtx(() => [
|
|
@@ -3914,7 +4156,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3914
4156
|
class: "m-editor-stage-container",
|
|
3915
4157
|
ref_key: "stageContainer",
|
|
3916
4158
|
ref: stageContainer,
|
|
3917
|
-
style: normalizeStyle(`transform: scale(${unref(zoom)})
|
|
4159
|
+
style: normalizeStyle(`transform: scale(${unref(zoom)});`),
|
|
3918
4160
|
onContextmenu: contextmenuHandler,
|
|
3919
4161
|
onDrop: dropHandler,
|
|
3920
4162
|
onDragover: dragoverHandler
|
|
@@ -3928,28 +4170,25 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3928
4170
|
]))
|
|
3929
4171
|
]),
|
|
3930
4172
|
_: 1
|
|
3931
|
-
}, 8, ["width", "height", "zoom"]);
|
|
4173
|
+
}, 8, ["width", "height", "wrap-width", "wrap-height", "zoom"]);
|
|
3932
4174
|
};
|
|
3933
4175
|
}
|
|
3934
4176
|
});
|
|
3935
4177
|
|
|
3936
|
-
const _sfc_main$1 = defineComponent({
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
PageBar: _sfc_main$5,
|
|
3940
|
-
MagicStage: _sfc_main$2
|
|
3941
|
-
},
|
|
3942
|
-
setup() {
|
|
4178
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
4179
|
+
__name: "Workspace",
|
|
4180
|
+
setup(__props) {
|
|
3943
4181
|
const services = inject("services");
|
|
3944
4182
|
const workspace = ref();
|
|
3945
4183
|
const nodes = computed(() => services?.editorService.get("nodes"));
|
|
3946
|
-
|
|
4184
|
+
const page = computed(() => services?.editorService.get("page"));
|
|
3947
4185
|
const mouseenterHandler = () => {
|
|
3948
4186
|
workspace.value?.focus();
|
|
3949
4187
|
};
|
|
3950
4188
|
const mouseleaveHandler = () => {
|
|
3951
4189
|
workspace.value?.blur();
|
|
3952
4190
|
};
|
|
4191
|
+
let keycon;
|
|
3953
4192
|
onMounted(() => {
|
|
3954
4193
|
workspace.value?.addEventListener("mouseenter", mouseenterHandler);
|
|
3955
4194
|
workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
|
|
@@ -4026,6 +4265,12 @@ const _sfc_main$1 = defineComponent({
|
|
|
4026
4265
|
}).keydown([ctrl, "numpad-"], (e) => {
|
|
4027
4266
|
e.inputEvent.preventDefault();
|
|
4028
4267
|
services?.uiService.zoom(-0.1);
|
|
4268
|
+
}).keydown([ctrl, "0"], (e) => {
|
|
4269
|
+
e.inputEvent.preventDefault();
|
|
4270
|
+
services?.uiService.set("zoom", services.uiService.calcZoom());
|
|
4271
|
+
}).keydown([ctrl, "1"], (e) => {
|
|
4272
|
+
e.inputEvent.preventDefault();
|
|
4273
|
+
services?.uiService.set("zoom", 1);
|
|
4029
4274
|
});
|
|
4030
4275
|
});
|
|
4031
4276
|
onUnmounted(() => {
|
|
@@ -4033,39 +4278,33 @@ const _sfc_main$1 = defineComponent({
|
|
|
4033
4278
|
workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
|
|
4034
4279
|
keycon.destroy();
|
|
4035
4280
|
});
|
|
4036
|
-
return {
|
|
4037
|
-
|
|
4038
|
-
|
|
4281
|
+
return (_ctx, _cache) => {
|
|
4282
|
+
return openBlock(), createElementBlock("div", {
|
|
4283
|
+
class: "m-editor-workspace",
|
|
4284
|
+
tabindex: "1",
|
|
4285
|
+
ref_key: "workspace",
|
|
4286
|
+
ref: workspace
|
|
4287
|
+
}, [
|
|
4288
|
+
renderSlot(_ctx.$slots, "stage", {}, () => [
|
|
4289
|
+
(openBlock(), createBlock(_sfc_main$2, {
|
|
4290
|
+
key: unref(page)?.id
|
|
4291
|
+
}))
|
|
4292
|
+
]),
|
|
4293
|
+
renderSlot(_ctx.$slots, "workspace-content"),
|
|
4294
|
+
createVNode(_sfc_main$6, null, {
|
|
4295
|
+
"page-bar-title": withCtx(({ page: page2 }) => [
|
|
4296
|
+
renderSlot(_ctx.$slots, "page-bar-title", { page: page2 })
|
|
4297
|
+
]),
|
|
4298
|
+
"page-bar-popover": withCtx(({ page: page2 }) => [
|
|
4299
|
+
renderSlot(_ctx.$slots, "page-bar-popover", { page: page2 })
|
|
4300
|
+
]),
|
|
4301
|
+
_: 3
|
|
4302
|
+
})
|
|
4303
|
+
], 512);
|
|
4039
4304
|
};
|
|
4040
4305
|
}
|
|
4041
4306
|
});
|
|
4042
4307
|
|
|
4043
|
-
const _hoisted_1 = {
|
|
4044
|
-
class: "m-editor-workspace",
|
|
4045
|
-
tabindex: "1",
|
|
4046
|
-
ref: "workspace"
|
|
4047
|
-
};
|
|
4048
|
-
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4049
|
-
const _component_magic_stage = resolveComponent("magic-stage");
|
|
4050
|
-
const _component_page_bar = resolveComponent("page-bar");
|
|
4051
|
-
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
4052
|
-
(openBlock(), createBlock(_component_magic_stage, {
|
|
4053
|
-
key: _ctx.page?.id
|
|
4054
|
-
})),
|
|
4055
|
-
renderSlot(_ctx.$slots, "workspace-content"),
|
|
4056
|
-
createVNode(_component_page_bar, null, {
|
|
4057
|
-
"page-bar-title": withCtx(({ page }) => [
|
|
4058
|
-
renderSlot(_ctx.$slots, "page-bar-title", { page })
|
|
4059
|
-
]),
|
|
4060
|
-
"page-bar-popover": withCtx(({ page }) => [
|
|
4061
|
-
renderSlot(_ctx.$slots, "page-bar-popover", { page })
|
|
4062
|
-
]),
|
|
4063
|
-
_: 3
|
|
4064
|
-
})
|
|
4065
|
-
], 512);
|
|
4066
|
-
}
|
|
4067
|
-
const Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
4068
|
-
|
|
4069
4308
|
class ComponentList extends BaseService {
|
|
4070
4309
|
state = reactive({
|
|
4071
4310
|
list: []
|
|
@@ -4082,132 +4321,12 @@ class ComponentList extends BaseService {
|
|
|
4082
4321
|
}
|
|
4083
4322
|
const componentListService = new ComponentList();
|
|
4084
4323
|
|
|
4085
|
-
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
4086
|
-
const MIN_LEFT_COLUMN_WIDTH = 45;
|
|
4087
|
-
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
4088
|
-
const MIN_RIGHT_COLUMN_WIDTH = 1;
|
|
4089
|
-
const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
|
|
4090
|
-
const defaultColumnWidth = {
|
|
4091
|
-
left: DEFAULT_LEFT_COLUMN_WIDTH,
|
|
4092
|
-
center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
|
|
4093
|
-
right: DEFAULT_RIGHT_COLUMN_WIDTH
|
|
4094
|
-
};
|
|
4095
|
-
const state = reactive({
|
|
4096
|
-
uiSelectMode: false,
|
|
4097
|
-
showSrc: false,
|
|
4098
|
-
zoom: 1,
|
|
4099
|
-
stageContainerRect: {
|
|
4100
|
-
width: 0,
|
|
4101
|
-
height: 0
|
|
4102
|
-
},
|
|
4103
|
-
stageRect: {
|
|
4104
|
-
width: 375,
|
|
4105
|
-
height: 817
|
|
4106
|
-
},
|
|
4107
|
-
columnWidth: defaultColumnWidth,
|
|
4108
|
-
showGuides: true,
|
|
4109
|
-
showRule: true,
|
|
4110
|
-
propsPanelSize: "small"
|
|
4111
|
-
});
|
|
4112
|
-
class Ui extends BaseService {
|
|
4113
|
-
constructor() {
|
|
4114
|
-
super([]);
|
|
4115
|
-
globalThis.addEventListener("resize", () => {
|
|
4116
|
-
this.setColumnWidth({
|
|
4117
|
-
center: "auto"
|
|
4118
|
-
});
|
|
4119
|
-
});
|
|
4120
|
-
const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
|
|
4121
|
-
if (columnWidthCacheData) {
|
|
4122
|
-
try {
|
|
4123
|
-
const columnWidthCache = JSON.parse(columnWidthCacheData);
|
|
4124
|
-
this.setColumnWidth(columnWidthCache);
|
|
4125
|
-
} catch (e) {
|
|
4126
|
-
console.error(e);
|
|
4127
|
-
}
|
|
4128
|
-
}
|
|
4129
|
-
}
|
|
4130
|
-
set(name, value) {
|
|
4131
|
-
const mask = editorService.get("stage")?.mask;
|
|
4132
|
-
if (name === "columnWidth") {
|
|
4133
|
-
this.setColumnWidth(value);
|
|
4134
|
-
return;
|
|
4135
|
-
}
|
|
4136
|
-
if (name === "stageRect") {
|
|
4137
|
-
this.setStageRect(value);
|
|
4138
|
-
return;
|
|
4139
|
-
}
|
|
4140
|
-
if (name === "showGuides") {
|
|
4141
|
-
mask?.showGuides(value);
|
|
4142
|
-
}
|
|
4143
|
-
if (name === "showRule") {
|
|
4144
|
-
mask?.showRule(value);
|
|
4145
|
-
}
|
|
4146
|
-
state[name] = value;
|
|
4147
|
-
if (name === "stageContainerRect") {
|
|
4148
|
-
state.zoom = this.calcZoom();
|
|
4149
|
-
}
|
|
4150
|
-
}
|
|
4151
|
-
get(name) {
|
|
4152
|
-
return state[name];
|
|
4153
|
-
}
|
|
4154
|
-
zoom(zoom) {
|
|
4155
|
-
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
4156
|
-
if (this.get("zoom") < 0.1)
|
|
4157
|
-
this.set("zoom", 0.1);
|
|
4158
|
-
}
|
|
4159
|
-
setColumnWidth({ left, center, right }) {
|
|
4160
|
-
const columnWidth = {
|
|
4161
|
-
...toRaw(this.get("columnWidth"))
|
|
4162
|
-
};
|
|
4163
|
-
if (left) {
|
|
4164
|
-
columnWidth.left = Math.max(left, MIN_LEFT_COLUMN_WIDTH);
|
|
4165
|
-
}
|
|
4166
|
-
if (right) {
|
|
4167
|
-
columnWidth.right = Math.max(right, MIN_RIGHT_COLUMN_WIDTH);
|
|
4168
|
-
}
|
|
4169
|
-
if (!center || center === "auto") {
|
|
4170
|
-
const bodyWidth = globalThis.document.body.clientWidth;
|
|
4171
|
-
columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
|
|
4172
|
-
if (columnWidth.center <= 0) {
|
|
4173
|
-
columnWidth.left = defaultColumnWidth.left;
|
|
4174
|
-
columnWidth.center = defaultColumnWidth.center;
|
|
4175
|
-
columnWidth.right = defaultColumnWidth.right;
|
|
4176
|
-
}
|
|
4177
|
-
} else {
|
|
4178
|
-
columnWidth.center = center;
|
|
4179
|
-
}
|
|
4180
|
-
globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
|
|
4181
|
-
state.columnWidth = columnWidth;
|
|
4182
|
-
}
|
|
4183
|
-
setStageRect(value) {
|
|
4184
|
-
state.stageRect = {
|
|
4185
|
-
...state.stageRect,
|
|
4186
|
-
...value
|
|
4187
|
-
};
|
|
4188
|
-
state.zoom = this.calcZoom();
|
|
4189
|
-
}
|
|
4190
|
-
calcZoom() {
|
|
4191
|
-
const { stageRect, stageContainerRect } = state;
|
|
4192
|
-
const { height, width } = stageContainerRect;
|
|
4193
|
-
if (!width || !height)
|
|
4194
|
-
return 1;
|
|
4195
|
-
const stageWidth = stageRect.width + 30;
|
|
4196
|
-
const stageHeight = stageRect.height + 30;
|
|
4197
|
-
if (width > stageWidth && height > stageHeight) {
|
|
4198
|
-
return 1;
|
|
4199
|
-
}
|
|
4200
|
-
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
4201
|
-
}
|
|
4202
|
-
}
|
|
4203
|
-
const uiService = new Ui();
|
|
4204
|
-
|
|
4205
4324
|
const _sfc_main = defineComponent({
|
|
4206
4325
|
name: "m-editor",
|
|
4207
4326
|
components: {
|
|
4208
|
-
NavMenu,
|
|
4327
|
+
NavMenu: _sfc_main$f,
|
|
4209
4328
|
Sidebar,
|
|
4210
|
-
Workspace,
|
|
4329
|
+
Workspace: _sfc_main$1,
|
|
4211
4330
|
PropsPanel,
|
|
4212
4331
|
Framework
|
|
4213
4332
|
},
|
|
@@ -4384,6 +4503,9 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4384
4503
|
workspace: withCtx(() => [
|
|
4385
4504
|
renderSlot(_ctx.$slots, "workspace", { editorService: _ctx.editorService }, () => [
|
|
4386
4505
|
createVNode(_component_workspace, null, {
|
|
4506
|
+
stage: withCtx(() => [
|
|
4507
|
+
renderSlot(_ctx.$slots, "stage")
|
|
4508
|
+
]),
|
|
4387
4509
|
"workspace-content": withCtx(() => [
|
|
4388
4510
|
renderSlot(_ctx.$slots, "workspace-content", { editorService: _ctx.editorService })
|
|
4389
4511
|
]),
|
|
@@ -4427,12 +4549,12 @@ const index = {
|
|
|
4427
4549
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
4428
4550
|
setConfig(option);
|
|
4429
4551
|
app.component(Editor.name, Editor);
|
|
4430
|
-
app.component("m-fields-ui-select", _sfc_main$
|
|
4552
|
+
app.component("m-fields-ui-select", _sfc_main$m);
|
|
4431
4553
|
app.component(CodeLink.name, CodeLink);
|
|
4432
4554
|
app.component(Code.name, Code);
|
|
4433
4555
|
app.component(CodeEditor.name, CodeEditor);
|
|
4434
4556
|
}
|
|
4435
4557
|
};
|
|
4436
4558
|
|
|
4437
|
-
export { COPY_STORAGE_KEY, ComponentListPanel,
|
|
4559
|
+
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, 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 };
|
|
4438
4560
|
//# sourceMappingURL=tmagic-editor.mjs.map
|