@tmagic/editor 1.0.0-beta.13 → 1.0.0-beta.14
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/coverage/clover.xml +646 -550
- package/coverage/coverage-final.json +19 -18
- package/coverage/lcov-report/index.html +55 -55
- package/coverage/lcov-report/src/Editor.vue.html +1 -1
- package/coverage/lcov-report/{layouts/sidebar/LayerMenu.vue.html → src/components/ContentMenu.vue.html} +137 -95
- package/coverage/lcov-report/src/components/Icon.vue.html +5 -5
- package/coverage/lcov-report/src/components/ScrollViewer.vue.html +1 -1
- package/coverage/lcov-report/src/components/ToolButton.vue.html +180 -63
- package/coverage/lcov-report/src/components/index.html +34 -19
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/Framework.vue.html +13 -13
- package/coverage/lcov-report/src/layouts/NavMenu.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/Resizer.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/index.html +15 -15
- package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +78 -12
- package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +149 -92
- package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +43 -121
- package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/sidebar/index.html +40 -40
- package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +99 -12
- package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +86 -95
- package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +208 -97
- package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +3 -3
- package/coverage/lcov-report/src/layouts/workspace/index.html +35 -35
- package/coverage/lcov-report/src/services/BaseService.ts.html +11 -11
- package/coverage/lcov-report/src/services/componentList.ts.html +1 -1
- package/coverage/lcov-report/src/services/editor.ts.html +102 -9
- package/coverage/lcov-report/src/services/events.ts.html +1 -1
- package/coverage/lcov-report/src/services/history.ts.html +29 -8
- package/coverage/lcov-report/src/services/index.html +25 -25
- package/coverage/lcov-report/src/services/props.ts.html +4 -7
- package/coverage/lcov-report/src/services/ui.ts.html +1 -1
- package/coverage/lcov-report/src/type.ts.html +8 -14
- package/coverage/lcov-report/src/utils/compose.ts.html +4 -4
- package/coverage/lcov-report/src/utils/config.ts.html +1 -1
- package/coverage/lcov-report/src/utils/editor.ts.html +2 -2
- package/coverage/lcov-report/src/utils/index.html +1 -1
- package/coverage/lcov-report/src/utils/index.ts.html +1 -1
- package/coverage/lcov-report/src/utils/logger.ts.html +1 -1
- package/coverage/lcov-report/src/utils/props.ts.html +59 -2
- package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +1 -1
- package/coverage/lcov-report/src/utils/undo-redo.ts.html +1 -1
- package/coverage/lcov.info +1623 -1354
- package/dist/style.css +39 -18
- package/dist/tmagic-editor.es.js +598 -412
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +595 -408
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/Editor.vue.d.ts +1 -1
- package/dist/types/src/components/ToolButton.vue.d.ts +12 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +1 -0
- package/dist/types/src/layouts/workspace/PageBar.vue.d.ts +2 -0
- package/dist/types/src/services/history.d.ts +1 -0
- package/dist/types/src/services/props.d.ts +2 -2
- package/dist/types/src/type.d.ts +6 -8
- package/dist/types/src/utils/polyfills.d.ts +0 -0
- package/package.json +8 -7
- package/src/components/ContentMenu.vue +107 -0
- package/src/components/ToolButton.vue +66 -27
- package/src/index.ts +2 -0
- package/src/layouts/Framework.vue +6 -6
- package/src/layouts/sidebar/ComponentListPanel.vue +23 -1
- package/src/layouts/sidebar/LayerMenu.vue +91 -72
- package/src/layouts/sidebar/LayerPanel.vue +23 -49
- package/src/layouts/workspace/PageBar.vue +35 -6
- package/src/layouts/workspace/Stage.vue +41 -44
- package/src/layouts/workspace/ViewerMenu.vue +104 -67
- package/src/layouts/workspace/Workspace.vue +2 -2
- package/src/services/editor.ts +32 -1
- package/src/services/history.ts +7 -0
- package/src/services/props.ts +2 -3
- package/src/theme/common/var.scss +1 -0
- package/src/theme/component-list-panel.scss +2 -0
- package/src/theme/content-menu.scss +33 -26
- package/src/theme/layer-panel.scss +1 -1
- package/src/theme/page-bar.scss +22 -1
- package/src/type.ts +6 -8
- package/src/utils/editor.ts +1 -1
- package/src/utils/polyfills.ts +22 -0
- package/src/utils/props.ts +19 -0
- package/coverage/lcov-report/Icon.vue.html +0 -172
- package/coverage/lcov-report/ToolButton.vue.html +0 -655
- package/coverage/lcov-report/layouts/sidebar/index.html +0 -116
- package/coverage/lcov-report/utils/index.html +0 -116
- package/coverage/lcov-report/utils/undo-redo.ts.html +0 -313
- package/dist/types/src/layouts/sidebar/LayerPanel.vue.d.ts +0 -980
- package/dist/types/src/layouts/workspace/Stage.vue.d.ts +0 -188
- package/dist/types/src/layouts/workspace/ViewerMenu.vue.d.ts +0 -18
package/dist/tmagic-editor.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, createElementBlock, createElementVNode, toDisplayString, withModifiers, createCommentVNode, watch, onMounted, onUnmounted, reactive, toRaw, createVNode, withCtx, renderSlot, Fragment, normalizeClass, resolveDynamicComponent, renderList, createTextVNode, normalizeProps, mergeProps, getCurrentInstance,
|
|
1
|
+
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, createElementBlock, createElementVNode, toDisplayString, withModifiers, createCommentVNode, watch, onMounted, onUnmounted, reactive, toRaw, createVNode, withCtx, renderSlot, Fragment, normalizeClass, resolveDynamicComponent, markRaw, renderList, createTextVNode, normalizeProps, mergeProps, getCurrentInstance, nextTick, withDirectives, Teleport, vShow, toHandlers, createSlots, provide } from 'vue';
|
|
2
2
|
import serialize from 'serialize-javascript';
|
|
3
3
|
import * as monaco from 'monaco-editor';
|
|
4
|
-
import { Plus, Edit, ArrowDown, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Delete, Files, Coin, ArrowLeftBold, ArrowRightBold, CaretBottom } from '@element-plus/icons';
|
|
4
|
+
import { Plus, Edit, ArrowDown, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Delete, Files, DocumentCopy, Coin, ArrowLeftBold, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons';
|
|
5
5
|
import { NodeType } from '@tmagic/schema';
|
|
6
|
-
import { cloneDeep,
|
|
6
|
+
import { cloneDeep, mergeWith, random, throttle } from 'lodash-es';
|
|
7
7
|
import { toLine, isPop, getNodePath, isNumber, isPage } from '@tmagic/utils';
|
|
8
8
|
import { EventEmitter as EventEmitter$2 } from 'events';
|
|
9
9
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
@@ -11,6 +11,10 @@ import { ElMessage } from 'element-plus';
|
|
|
11
11
|
import KeyController from 'keycon';
|
|
12
12
|
import StageCore from '@tmagic/stage';
|
|
13
13
|
|
|
14
|
+
if (typeof window.global === "undefined") {
|
|
15
|
+
window.global = window;
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
var _export_sfc = (sfc, props) => {
|
|
15
19
|
const target = sfc.__vccOpts || sfc;
|
|
16
20
|
for (const [key, val] of props) {
|
|
@@ -19,7 +23,7 @@ var _export_sfc = (sfc, props) => {
|
|
|
19
23
|
return target;
|
|
20
24
|
};
|
|
21
25
|
|
|
22
|
-
const _sfc_main$
|
|
26
|
+
const _sfc_main$l = defineComponent({
|
|
23
27
|
name: "m-fields-vs-code",
|
|
24
28
|
props: ["model", "name", "config", "prop"],
|
|
25
29
|
emits: ["change"],
|
|
@@ -36,7 +40,7 @@ const _sfc_main$k = defineComponent({
|
|
|
36
40
|
};
|
|
37
41
|
}
|
|
38
42
|
});
|
|
39
|
-
function _sfc_render$
|
|
43
|
+
function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) {
|
|
40
44
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
41
45
|
return openBlock(), createBlock(_component_magic_code_editor, {
|
|
42
46
|
style: normalizeStyle(`height: ${_ctx.height}`),
|
|
@@ -45,9 +49,9 @@ function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
45
49
|
onSave: _ctx.save
|
|
46
50
|
}, null, 8, ["style", "init-values", "language", "onSave"]);
|
|
47
51
|
}
|
|
48
|
-
var Code = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
52
|
+
var Code = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$l]]);
|
|
49
53
|
|
|
50
|
-
const _sfc_main$
|
|
54
|
+
const _sfc_main$k = defineComponent({
|
|
51
55
|
name: "m-fields-code-link",
|
|
52
56
|
props: {
|
|
53
57
|
config: {
|
|
@@ -102,7 +106,7 @@ const _sfc_main$j = defineComponent({
|
|
|
102
106
|
};
|
|
103
107
|
}
|
|
104
108
|
});
|
|
105
|
-
function _sfc_render$
|
|
109
|
+
function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
|
|
106
110
|
const _component_m_fields_link = resolveComponent("m-fields-link");
|
|
107
111
|
return openBlock(), createBlock(_component_m_fields_link, {
|
|
108
112
|
config: _ctx.formConfig,
|
|
@@ -111,11 +115,11 @@ function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
111
115
|
onChange: _ctx.changeHandler
|
|
112
116
|
}, null, 8, ["config", "model", "onChange"]);
|
|
113
117
|
}
|
|
114
|
-
var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
118
|
+
var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$k]]);
|
|
115
119
|
|
|
116
120
|
var UISelect_vue_vue_type_style_index_0_lang = '';
|
|
117
121
|
|
|
118
|
-
const _sfc_main$
|
|
122
|
+
const _sfc_main$j = defineComponent({
|
|
119
123
|
name: "m-fields-ui-select",
|
|
120
124
|
props: {
|
|
121
125
|
labelWidth: String,
|
|
@@ -177,25 +181,25 @@ const _sfc_main$i = defineComponent({
|
|
|
177
181
|
};
|
|
178
182
|
}
|
|
179
183
|
});
|
|
180
|
-
const _hoisted_1$
|
|
184
|
+
const _hoisted_1$c = /* @__PURE__ */ createElementVNode("i", {
|
|
181
185
|
class: "el-icon-delete",
|
|
182
186
|
style: { "color": "rgb(221, 75, 57)" }
|
|
183
187
|
}, "\u53D6\u6D88", -1);
|
|
184
|
-
const _hoisted_2$
|
|
185
|
-
_hoisted_1$
|
|
188
|
+
const _hoisted_2$5 = [
|
|
189
|
+
_hoisted_1$c
|
|
186
190
|
];
|
|
187
|
-
const _hoisted_3$
|
|
188
|
-
function _sfc_render$
|
|
191
|
+
const _hoisted_3$3 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-thumb" }, null, -1);
|
|
192
|
+
function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
|
|
189
193
|
return _ctx.uiSelectMode ? (openBlock(), createElementBlock("div", {
|
|
190
194
|
key: 0,
|
|
191
195
|
class: "m-fields-ui-select",
|
|
192
196
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.cancelHandler && _ctx.cancelHandler(...args))
|
|
193
|
-
}, _hoisted_2$
|
|
197
|
+
}, _hoisted_2$5)) : (openBlock(), createElementBlock("div", {
|
|
194
198
|
key: 1,
|
|
195
199
|
class: "m-fields-ui-select",
|
|
196
200
|
onClick: _cache[2] || (_cache[2] = (...args) => _ctx.startSelect && _ctx.startSelect(...args))
|
|
197
201
|
}, [
|
|
198
|
-
_hoisted_3$
|
|
202
|
+
_hoisted_3$3,
|
|
199
203
|
createElementVNode("span", null, toDisplayString(_ctx.val ? _ctx.toName + "_" + _ctx.val : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1),
|
|
200
204
|
_ctx.val ? (openBlock(), createElementBlock("i", {
|
|
201
205
|
key: 0,
|
|
@@ -204,7 +208,7 @@ function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
204
208
|
})) : createCommentVNode("", true)
|
|
205
209
|
]));
|
|
206
210
|
}
|
|
207
|
-
var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
211
|
+
var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$j]]);
|
|
208
212
|
|
|
209
213
|
const toString = (v, language) => {
|
|
210
214
|
let value = "";
|
|
@@ -221,7 +225,7 @@ const toString = (v, language) => {
|
|
|
221
225
|
}
|
|
222
226
|
return value;
|
|
223
227
|
};
|
|
224
|
-
const _sfc_main$
|
|
228
|
+
const _sfc_main$i = defineComponent({
|
|
225
229
|
name: "magic-code-editor",
|
|
226
230
|
props: {
|
|
227
231
|
initValues: {
|
|
@@ -326,14 +330,14 @@ const _sfc_main$h = defineComponent({
|
|
|
326
330
|
};
|
|
327
331
|
}
|
|
328
332
|
});
|
|
329
|
-
const _hoisted_1$
|
|
333
|
+
const _hoisted_1$b = {
|
|
330
334
|
ref: "codeEditor",
|
|
331
335
|
class: "magic-code-editor"
|
|
332
336
|
};
|
|
333
|
-
function _sfc_render$
|
|
334
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
337
|
+
function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
338
|
+
return openBlock(), createElementBlock("div", _hoisted_1$b, null, 512);
|
|
335
339
|
}
|
|
336
|
-
var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
340
|
+
var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
|
|
337
341
|
|
|
338
342
|
let $TMAGIC_EDITOR = {};
|
|
339
343
|
const setConfig = (option) => {
|
|
@@ -514,6 +518,12 @@ class History extends BaseService {
|
|
|
514
518
|
});
|
|
515
519
|
this.on("change", this.setCanUndoRedo);
|
|
516
520
|
}
|
|
521
|
+
reset() {
|
|
522
|
+
this.state.pageSteps = {};
|
|
523
|
+
this.state.pageId = void 0;
|
|
524
|
+
this.state.canRedo = false;
|
|
525
|
+
this.state.canUndo = false;
|
|
526
|
+
}
|
|
517
527
|
changePage(page) {
|
|
518
528
|
if (!page)
|
|
519
529
|
return;
|
|
@@ -619,8 +629,7 @@ class Props extends BaseService {
|
|
|
619
629
|
}
|
|
620
630
|
return cloneDeep({
|
|
621
631
|
...getDefaultPropsValue(type),
|
|
622
|
-
...defaultValue
|
|
623
|
-
...this.state.propsValueMap[type] || {}
|
|
632
|
+
...mergeWith(this.state.propsValueMap[type] || {}, defaultValue)
|
|
624
633
|
});
|
|
625
634
|
}
|
|
626
635
|
}
|
|
@@ -707,7 +716,7 @@ const toRelative = (node) => {
|
|
|
707
716
|
const setTop2Middle = (node, parentNode, stage) => {
|
|
708
717
|
const style = node.style || {};
|
|
709
718
|
const height = style.height || 0;
|
|
710
|
-
if (!stage || style.top || !parentNode.style || !isNumber(height))
|
|
719
|
+
if (!stage || typeof style.top !== "undefined" || !parentNode.style || !isNumber(height))
|
|
711
720
|
return style;
|
|
712
721
|
const { height: parentHeight } = parentNode.style;
|
|
713
722
|
if (isPage(parentNode)) {
|
|
@@ -817,6 +826,7 @@ class Editor$1 extends BaseService {
|
|
|
817
826
|
"paste",
|
|
818
827
|
"alignCenter",
|
|
819
828
|
"moveLayer",
|
|
829
|
+
"move",
|
|
820
830
|
"undo",
|
|
821
831
|
"redo",
|
|
822
832
|
"highlight"
|
|
@@ -829,12 +839,14 @@ class Editor$1 extends BaseService {
|
|
|
829
839
|
node: null,
|
|
830
840
|
stage: null,
|
|
831
841
|
highlightNode: null,
|
|
832
|
-
modifiedNodeIds: /* @__PURE__ */ new Map()
|
|
842
|
+
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
843
|
+
pageLength: 0
|
|
833
844
|
});
|
|
834
845
|
}
|
|
835
846
|
set(name, value) {
|
|
836
847
|
this.state[name] = value;
|
|
837
848
|
if (name === "root") {
|
|
849
|
+
this.state.pageLength = value?.items?.length || 0;
|
|
838
850
|
this.emit("root-change", value);
|
|
839
851
|
}
|
|
840
852
|
}
|
|
@@ -894,6 +906,7 @@ class Editor$1 extends BaseService {
|
|
|
894
906
|
} else {
|
|
895
907
|
historyService.empty();
|
|
896
908
|
}
|
|
909
|
+
this.emit("select", node);
|
|
897
910
|
return node;
|
|
898
911
|
}
|
|
899
912
|
async selectNextNode() {
|
|
@@ -929,7 +942,8 @@ class Editor$1 extends BaseService {
|
|
|
929
942
|
const { type, ...config2 } = addNode;
|
|
930
943
|
const curNode = this.get("node");
|
|
931
944
|
let parentNode;
|
|
932
|
-
|
|
945
|
+
const isPage2 = type === NodeType.PAGE;
|
|
946
|
+
if (isPage2) {
|
|
933
947
|
parentNode = this.get("root");
|
|
934
948
|
} else if (parent && typeof parent !== "function") {
|
|
935
949
|
parentNode = parent;
|
|
@@ -954,6 +968,10 @@ class Editor$1 extends BaseService {
|
|
|
954
968
|
this.pushHistoryState();
|
|
955
969
|
}
|
|
956
970
|
stage?.select(newNode.id);
|
|
971
|
+
if (isPage2) {
|
|
972
|
+
this.state.pageLength += 1;
|
|
973
|
+
}
|
|
974
|
+
this.emit("add", newNode);
|
|
957
975
|
return newNode;
|
|
958
976
|
}
|
|
959
977
|
async remove(node) {
|
|
@@ -972,9 +990,20 @@ class Editor$1 extends BaseService {
|
|
|
972
990
|
const stage = this.get("stage");
|
|
973
991
|
stage?.remove({ id: node.id, root: this.get("root") });
|
|
974
992
|
if (node.type === NodeType.PAGE) {
|
|
993
|
+
this.state.pageLength -= 1;
|
|
975
994
|
if (root.items[0]) {
|
|
976
995
|
await this.select(root.items[0]);
|
|
977
996
|
stage?.select(root.items[0].id);
|
|
997
|
+
} else {
|
|
998
|
+
this.set("node", null);
|
|
999
|
+
this.set("parent", null);
|
|
1000
|
+
this.set("page", null);
|
|
1001
|
+
this.set("stage", null);
|
|
1002
|
+
this.set("highlightNode", null);
|
|
1003
|
+
this.resetModifiedNodeId();
|
|
1004
|
+
historyService.reset();
|
|
1005
|
+
this.emit("remove", node);
|
|
1006
|
+
return node;
|
|
978
1007
|
}
|
|
979
1008
|
} else {
|
|
980
1009
|
await this.select(parent);
|
|
@@ -982,6 +1011,7 @@ class Editor$1 extends BaseService {
|
|
|
982
1011
|
}
|
|
983
1012
|
this.addModifiedNodeId(parent.id);
|
|
984
1013
|
this.pushHistoryState();
|
|
1014
|
+
this.emit("remove", node);
|
|
985
1015
|
return node;
|
|
986
1016
|
}
|
|
987
1017
|
async update(config2) {
|
|
@@ -1025,6 +1055,7 @@ class Editor$1 extends BaseService {
|
|
|
1025
1055
|
}
|
|
1026
1056
|
this.addModifiedNodeId(newConfig.id);
|
|
1027
1057
|
this.pushHistoryState();
|
|
1058
|
+
this.emit("update", newConfig);
|
|
1028
1059
|
return newConfig;
|
|
1029
1060
|
}
|
|
1030
1061
|
async sort(id1, id2) {
|
|
@@ -1354,6 +1385,25 @@ const fillConfig = (config = []) => [
|
|
|
1354
1385
|
defaultValue: "100% 100%"
|
|
1355
1386
|
}
|
|
1356
1387
|
]
|
|
1388
|
+
},
|
|
1389
|
+
{
|
|
1390
|
+
type: "fieldset",
|
|
1391
|
+
legend: "\u5B57\u4F53",
|
|
1392
|
+
items: [
|
|
1393
|
+
{
|
|
1394
|
+
name: "color",
|
|
1395
|
+
text: "\u989C\u8272",
|
|
1396
|
+
type: "colorPicker"
|
|
1397
|
+
},
|
|
1398
|
+
{
|
|
1399
|
+
name: "fontSize",
|
|
1400
|
+
text: "\u5927\u5C0F"
|
|
1401
|
+
},
|
|
1402
|
+
{
|
|
1403
|
+
name: "fontWeight",
|
|
1404
|
+
text: "\u7C97\u7EC6"
|
|
1405
|
+
}
|
|
1406
|
+
]
|
|
1357
1407
|
}
|
|
1358
1408
|
]
|
|
1359
1409
|
}
|
|
@@ -1421,7 +1471,7 @@ const getDefaultPropsValue = (type) => ({
|
|
|
1421
1471
|
name: type
|
|
1422
1472
|
});
|
|
1423
1473
|
|
|
1424
|
-
const _sfc_main$
|
|
1474
|
+
const _sfc_main$h = defineComponent({
|
|
1425
1475
|
components: { Plus },
|
|
1426
1476
|
setup() {
|
|
1427
1477
|
const services = inject("services");
|
|
@@ -1438,14 +1488,14 @@ const _sfc_main$g = defineComponent({
|
|
|
1438
1488
|
};
|
|
1439
1489
|
}
|
|
1440
1490
|
});
|
|
1441
|
-
const _hoisted_1$
|
|
1442
|
-
const _hoisted_2$
|
|
1443
|
-
const _hoisted_3$
|
|
1444
|
-
function _sfc_render$
|
|
1491
|
+
const _hoisted_1$a = { class: "m-editor-empty-panel" };
|
|
1492
|
+
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
1493
|
+
const _hoisted_3$2 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
1494
|
+
function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1445
1495
|
const _component_plus = resolveComponent("plus");
|
|
1446
1496
|
const _component_el_icon = resolveComponent("el-icon");
|
|
1447
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
1448
|
-
createElementVNode("div", _hoisted_2$
|
|
1497
|
+
return openBlock(), createElementBlock("div", _hoisted_1$a, [
|
|
1498
|
+
createElementVNode("div", _hoisted_2$4, [
|
|
1449
1499
|
createElementVNode("div", {
|
|
1450
1500
|
class: "m-editor-empty-button",
|
|
1451
1501
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
|
|
@@ -1458,12 +1508,12 @@ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1458
1508
|
_: 1
|
|
1459
1509
|
})
|
|
1460
1510
|
]),
|
|
1461
|
-
_hoisted_3$
|
|
1511
|
+
_hoisted_3$2
|
|
1462
1512
|
])
|
|
1463
1513
|
])
|
|
1464
1514
|
]);
|
|
1465
1515
|
}
|
|
1466
|
-
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1516
|
+
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
|
|
1467
1517
|
|
|
1468
1518
|
/*
|
|
1469
1519
|
Copyright (c) 2018 Daybrush
|
|
@@ -2674,7 +2724,7 @@ function (_super) {
|
|
|
2674
2724
|
|
|
2675
2725
|
var Gesto$1 = Gesto;
|
|
2676
2726
|
|
|
2677
|
-
const _sfc_main$
|
|
2727
|
+
const _sfc_main$g = defineComponent({
|
|
2678
2728
|
name: "m-editor-resize",
|
|
2679
2729
|
props: {
|
|
2680
2730
|
type: {
|
|
@@ -2716,33 +2766,33 @@ const _sfc_main$f = defineComponent({
|
|
|
2716
2766
|
};
|
|
2717
2767
|
}
|
|
2718
2768
|
});
|
|
2719
|
-
const _hoisted_1$
|
|
2769
|
+
const _hoisted_1$9 = {
|
|
2720
2770
|
ref: "target",
|
|
2721
2771
|
class: "m-editor-resizer"
|
|
2722
2772
|
};
|
|
2723
|
-
function _sfc_render$
|
|
2724
|
-
return openBlock(), createElementBlock("span", _hoisted_1$
|
|
2773
|
+
function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2774
|
+
return openBlock(), createElementBlock("span", _hoisted_1$9, [
|
|
2725
2775
|
renderSlot(_ctx.$slots, "default")
|
|
2726
2776
|
], 512);
|
|
2727
2777
|
}
|
|
2728
|
-
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2778
|
+
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
|
|
2729
2779
|
|
|
2730
|
-
const _sfc_main$
|
|
2780
|
+
const _sfc_main$f = defineComponent({
|
|
2731
2781
|
components: {
|
|
2732
2782
|
AddPageBox,
|
|
2733
2783
|
Resizer
|
|
2734
2784
|
},
|
|
2735
2785
|
setup() {
|
|
2736
|
-
const
|
|
2737
|
-
const root = computed(() =>
|
|
2786
|
+
const { editorService, uiService } = inject("services") || {};
|
|
2787
|
+
const root = computed(() => editorService?.get("root"));
|
|
2738
2788
|
return {
|
|
2739
2789
|
root,
|
|
2740
|
-
pageLength: computed(() =>
|
|
2741
|
-
showSrc: computed(() =>
|
|
2742
|
-
columnWidth: computed(() =>
|
|
2790
|
+
pageLength: computed(() => editorService?.get("pageLength") || 0),
|
|
2791
|
+
showSrc: computed(() => uiService?.get("showSrc")),
|
|
2792
|
+
columnWidth: computed(() => uiService?.get("columnWidth")),
|
|
2743
2793
|
saveCode(value) {
|
|
2744
2794
|
try {
|
|
2745
|
-
|
|
2795
|
+
editorService?.set("root", eval(value));
|
|
2746
2796
|
} catch (e) {
|
|
2747
2797
|
console.error(e);
|
|
2748
2798
|
}
|
|
@@ -2750,24 +2800,24 @@ const _sfc_main$e = defineComponent({
|
|
|
2750
2800
|
};
|
|
2751
2801
|
}
|
|
2752
2802
|
});
|
|
2753
|
-
const _hoisted_1$
|
|
2754
|
-
const _hoisted_2$
|
|
2803
|
+
const _hoisted_1$8 = { class: "m-editor" };
|
|
2804
|
+
const _hoisted_2$3 = {
|
|
2755
2805
|
key: 1,
|
|
2756
2806
|
class: "m-editor-content"
|
|
2757
2807
|
};
|
|
2758
|
-
function _sfc_render$
|
|
2808
|
+
function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2759
2809
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
2760
2810
|
const _component_resizer = resolveComponent("resizer");
|
|
2761
2811
|
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
2762
2812
|
const _component_add_page_box = resolveComponent("add-page-box");
|
|
2763
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
2813
|
+
return openBlock(), createElementBlock("div", _hoisted_1$8, [
|
|
2764
2814
|
renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
2765
2815
|
_ctx.showSrc ? (openBlock(), createBlock(_component_magic_code_editor, {
|
|
2766
2816
|
key: 0,
|
|
2767
2817
|
class: "m-editor-content",
|
|
2768
2818
|
"init-values": _ctx.root,
|
|
2769
2819
|
onSave: _ctx.saveCode
|
|
2770
|
-
}, null, 8, ["init-values", "onSave"])) : (openBlock(), createElementBlock("div", _hoisted_2$
|
|
2820
|
+
}, null, 8, ["init-values", "onSave"])) : (openBlock(), createElementBlock("div", _hoisted_2$3, [
|
|
2771
2821
|
createElementVNode("div", {
|
|
2772
2822
|
class: "m-editor-framework-left",
|
|
2773
2823
|
style: normalizeStyle(`width: ${_ctx.columnWidth?.left}px`)
|
|
@@ -2800,9 +2850,9 @@ function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2800
2850
|
]))
|
|
2801
2851
|
]);
|
|
2802
2852
|
}
|
|
2803
|
-
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2853
|
+
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
|
|
2804
2854
|
|
|
2805
|
-
const _sfc_main$
|
|
2855
|
+
const _sfc_main$e = defineComponent({
|
|
2806
2856
|
name: "m-icon",
|
|
2807
2857
|
components: { Edit },
|
|
2808
2858
|
props: {
|
|
@@ -2816,8 +2866,8 @@ const _sfc_main$d = defineComponent({
|
|
|
2816
2866
|
};
|
|
2817
2867
|
}
|
|
2818
2868
|
});
|
|
2819
|
-
const _hoisted_1$
|
|
2820
|
-
function _sfc_render$
|
|
2869
|
+
const _hoisted_1$7 = ["src"];
|
|
2870
|
+
function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2821
2871
|
const _component_edit = resolveComponent("edit");
|
|
2822
2872
|
const _component_el_icon = resolveComponent("el-icon");
|
|
2823
2873
|
return !_ctx.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
|
|
@@ -2828,7 +2878,7 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2828
2878
|
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (openBlock(), createElementBlock("img", {
|
|
2829
2879
|
key: 1,
|
|
2830
2880
|
src: _ctx.icon
|
|
2831
|
-
}, null, 8, _hoisted_1$
|
|
2881
|
+
}, null, 8, _hoisted_1$7)) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
2832
2882
|
key: 2,
|
|
2833
2883
|
class: normalizeClass(_ctx.icon)
|
|
2834
2884
|
}, null, 2)) : (openBlock(), createBlock(_component_el_icon, { key: 3 }, {
|
|
@@ -2838,9 +2888,9 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2838
2888
|
_: 1
|
|
2839
2889
|
}));
|
|
2840
2890
|
}
|
|
2841
|
-
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2891
|
+
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
|
|
2842
2892
|
|
|
2843
|
-
const _sfc_main$
|
|
2893
|
+
const _sfc_main$d = defineComponent({
|
|
2844
2894
|
components: { MIcon, ArrowDown },
|
|
2845
2895
|
props: {
|
|
2846
2896
|
data: {
|
|
@@ -2850,6 +2900,10 @@ const _sfc_main$c = defineComponent({
|
|
|
2850
2900
|
type: "text",
|
|
2851
2901
|
display: false
|
|
2852
2902
|
})
|
|
2903
|
+
},
|
|
2904
|
+
eventType: {
|
|
2905
|
+
type: String,
|
|
2906
|
+
default: "click"
|
|
2853
2907
|
}
|
|
2854
2908
|
},
|
|
2855
2909
|
setup(props) {
|
|
@@ -2876,7 +2930,7 @@ const _sfc_main$c = defineComponent({
|
|
|
2876
2930
|
case "delete":
|
|
2877
2931
|
return {
|
|
2878
2932
|
type: "button",
|
|
2879
|
-
icon: Delete,
|
|
2933
|
+
icon: markRaw(Delete),
|
|
2880
2934
|
tooltip: "\u522A\u9664",
|
|
2881
2935
|
disabled: () => services?.editorService.get("node")?.type === NodeType.PAGE,
|
|
2882
2936
|
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
@@ -2884,7 +2938,7 @@ const _sfc_main$c = defineComponent({
|
|
|
2884
2938
|
case "undo":
|
|
2885
2939
|
return {
|
|
2886
2940
|
type: "button",
|
|
2887
|
-
icon: Back,
|
|
2941
|
+
icon: markRaw(Back),
|
|
2888
2942
|
tooltip: "\u540E\u9000",
|
|
2889
2943
|
disabled: () => !services?.historyService.state.canUndo,
|
|
2890
2944
|
handler: () => services?.editorService.undo()
|
|
@@ -2892,7 +2946,7 @@ const _sfc_main$c = defineComponent({
|
|
|
2892
2946
|
case "redo":
|
|
2893
2947
|
return {
|
|
2894
2948
|
type: "button",
|
|
2895
|
-
icon: Right,
|
|
2949
|
+
icon: markRaw(Right),
|
|
2896
2950
|
tooltip: "\u524D\u8FDB",
|
|
2897
2951
|
disabled: () => !services?.historyService.state.canRedo,
|
|
2898
2952
|
handler: () => services?.editorService.redo()
|
|
@@ -2900,28 +2954,28 @@ const _sfc_main$c = defineComponent({
|
|
|
2900
2954
|
case "zoom-in":
|
|
2901
2955
|
return {
|
|
2902
2956
|
type: "button",
|
|
2903
|
-
icon: ZoomIn,
|
|
2957
|
+
icon: markRaw(ZoomIn),
|
|
2904
2958
|
tooltip: "\u653E\u5927",
|
|
2905
2959
|
handler: zoomInHandler
|
|
2906
2960
|
};
|
|
2907
2961
|
case "zoom-out":
|
|
2908
2962
|
return {
|
|
2909
2963
|
type: "button",
|
|
2910
|
-
icon: ZoomOut,
|
|
2964
|
+
icon: markRaw(ZoomOut),
|
|
2911
2965
|
tooltip: "\u7E2E\u5C0F",
|
|
2912
2966
|
handler: zoomOutHandler
|
|
2913
2967
|
};
|
|
2914
2968
|
case "rule":
|
|
2915
2969
|
return {
|
|
2916
2970
|
type: "button",
|
|
2917
|
-
icon: ScaleToOriginal,
|
|
2971
|
+
icon: markRaw(ScaleToOriginal),
|
|
2918
2972
|
tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
|
|
2919
2973
|
handler: () => uiService?.set("showRule", !showRule.value)
|
|
2920
2974
|
};
|
|
2921
2975
|
case "guides":
|
|
2922
2976
|
return {
|
|
2923
2977
|
type: "button",
|
|
2924
|
-
icon: Grid,
|
|
2978
|
+
icon: markRaw(Grid),
|
|
2925
2979
|
tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
|
|
2926
2980
|
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
2927
2981
|
};
|
|
@@ -2942,9 +2996,16 @@ const _sfc_main$c = defineComponent({
|
|
|
2942
2996
|
}
|
|
2943
2997
|
return item.value.disabled;
|
|
2944
2998
|
});
|
|
2999
|
+
const buttonHandler = (item2, event) => {
|
|
3000
|
+
if (disabled.value)
|
|
3001
|
+
return;
|
|
3002
|
+
if (typeof item2.handler === "function" && services) {
|
|
3003
|
+
item2.handler?.(services, event);
|
|
3004
|
+
}
|
|
3005
|
+
};
|
|
2945
3006
|
return {
|
|
2946
|
-
ZoomIn,
|
|
2947
|
-
ZoomOut,
|
|
3007
|
+
ZoomIn: markRaw(ZoomIn),
|
|
3008
|
+
ZoomOut: markRaw(ZoomOut),
|
|
2948
3009
|
item,
|
|
2949
3010
|
zoom,
|
|
2950
3011
|
disabled,
|
|
@@ -2965,31 +3026,42 @@ const _sfc_main$c = defineComponent({
|
|
|
2965
3026
|
command.item.handler(services);
|
|
2966
3027
|
}
|
|
2967
3028
|
},
|
|
2968
|
-
|
|
2969
|
-
if (
|
|
3029
|
+
clickHandler(item2, event) {
|
|
3030
|
+
if (props.eventType !== "click")
|
|
3031
|
+
return;
|
|
3032
|
+
if (item2.type === "button") {
|
|
3033
|
+
buttonHandler(item2, event);
|
|
3034
|
+
}
|
|
3035
|
+
},
|
|
3036
|
+
mousedownHandler(item2, event) {
|
|
3037
|
+
if (props.eventType !== "mousedown")
|
|
2970
3038
|
return;
|
|
2971
|
-
if (
|
|
2972
|
-
item2
|
|
3039
|
+
if (item2.type === "button") {
|
|
3040
|
+
buttonHandler(item2, event);
|
|
3041
|
+
}
|
|
3042
|
+
},
|
|
3043
|
+
mouseupHandler(item2, event) {
|
|
3044
|
+
if (props.eventType !== "mouseup")
|
|
3045
|
+
return;
|
|
3046
|
+
if (item2.type === "button") {
|
|
3047
|
+
buttonHandler(item2, event);
|
|
2973
3048
|
}
|
|
2974
3049
|
}
|
|
2975
3050
|
};
|
|
2976
3051
|
}
|
|
2977
3052
|
});
|
|
2978
|
-
const _hoisted_1$
|
|
2979
|
-
key: 0,
|
|
2980
|
-
class: "menu-item"
|
|
2981
|
-
};
|
|
2982
|
-
const _hoisted_2$4 = {
|
|
3053
|
+
const _hoisted_1$6 = {
|
|
2983
3054
|
key: 1,
|
|
2984
3055
|
class: "menu-item-text"
|
|
2985
3056
|
};
|
|
2986
|
-
const
|
|
3057
|
+
const _hoisted_2$2 = {
|
|
2987
3058
|
class: "menu-item-text",
|
|
2988
3059
|
style: { "margin": "0 5px" }
|
|
2989
3060
|
};
|
|
2990
|
-
const
|
|
2991
|
-
function _sfc_render$
|
|
3061
|
+
const _hoisted_3$1 = { class: "el-dropdown-link menubar-menu-button" };
|
|
3062
|
+
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2992
3063
|
const _component_el_divider = resolveComponent("el-divider");
|
|
3064
|
+
const _component_tool_button = resolveComponent("tool-button", true);
|
|
2993
3065
|
const _component_m_icon = resolveComponent("m-icon");
|
|
2994
3066
|
const _component_el_button = resolveComponent("el-button");
|
|
2995
3067
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
@@ -2998,60 +3070,66 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2998
3070
|
const _component_el_dropdown_item = resolveComponent("el-dropdown-item");
|
|
2999
3071
|
const _component_el_dropdown_menu = resolveComponent("el-dropdown-menu");
|
|
3000
3072
|
const _component_el_dropdown = resolveComponent("el-dropdown");
|
|
3001
|
-
return _ctx.display ? (openBlock(), createElementBlock("div",
|
|
3073
|
+
return _ctx.display ? (openBlock(), createElementBlock("div", {
|
|
3074
|
+
key: 0,
|
|
3075
|
+
class: normalizeClass(["menu-item", _ctx.item.type]),
|
|
3076
|
+
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.clickHandler(_ctx.item, $event)),
|
|
3077
|
+
onMousedown: _cache[1] || (_cache[1] = ($event) => _ctx.mousedownHandler(_ctx.item, $event)),
|
|
3078
|
+
onMouseup: _cache[2] || (_cache[2] = ($event) => _ctx.mouseupHandler(_ctx.item, $event))
|
|
3079
|
+
}, [
|
|
3002
3080
|
_ctx.item.type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
|
|
3003
3081
|
key: 0,
|
|
3004
|
-
direction: "vertical"
|
|
3005
|
-
})) : _ctx.item.type === "text" ? (openBlock(), createElementBlock("div",
|
|
3006
|
-
createVNode(
|
|
3007
|
-
|
|
3008
|
-
type:
|
|
3082
|
+
direction: _ctx.item.direction || "vertical"
|
|
3083
|
+
}, null, 8, ["direction"])) : _ctx.item.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$6, toDisplayString(_ctx.item.text), 1)) : _ctx.item.type === "zoom" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
3084
|
+
createVNode(_component_tool_button, {
|
|
3085
|
+
data: { type: "button", icon: _ctx.ZoomIn, handler: _ctx.zoomInHandler, tooltip: "\u653E\u5927" },
|
|
3086
|
+
"event-type": _ctx.eventType
|
|
3087
|
+
}, null, 8, ["data", "event-type"]),
|
|
3088
|
+
createElementVNode("span", _hoisted_2$2, toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
|
|
3089
|
+
createVNode(_component_tool_button, {
|
|
3090
|
+
data: { type: "button", icon: _ctx.ZoomOut, handler: _ctx.zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
3091
|
+
"event-type": _ctx.eventType
|
|
3092
|
+
}, null, 8, ["data", "event-type"])
|
|
3093
|
+
], 64)) : _ctx.item.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
3094
|
+
_ctx.item.tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
3095
|
+
key: 0,
|
|
3096
|
+
effect: "dark",
|
|
3097
|
+
placement: "bottom-start",
|
|
3098
|
+
content: _ctx.item.tooltip
|
|
3009
3099
|
}, {
|
|
3010
3100
|
default: withCtx(() => [
|
|
3011
|
-
createVNode(
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3101
|
+
createVNode(_component_el_button, {
|
|
3102
|
+
size: "small",
|
|
3103
|
+
type: "text",
|
|
3104
|
+
disabled: _ctx.disabled
|
|
3105
|
+
}, {
|
|
3106
|
+
default: withCtx(() => [
|
|
3107
|
+
_ctx.item.icon ? (openBlock(), createBlock(_component_m_icon, {
|
|
3108
|
+
key: 0,
|
|
3109
|
+
icon: _ctx.item.icon
|
|
3110
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
3111
|
+
createElementVNode("span", null, toDisplayString(_ctx.item.text), 1)
|
|
3112
|
+
]),
|
|
3113
|
+
_: 1
|
|
3114
|
+
}, 8, ["disabled"])
|
|
3015
3115
|
]),
|
|
3016
3116
|
_: 1
|
|
3017
|
-
}),
|
|
3018
|
-
|
|
3019
|
-
createVNode(_component_el_button, {
|
|
3117
|
+
}, 8, ["content"])) : (openBlock(), createBlock(_component_el_button, {
|
|
3118
|
+
key: 1,
|
|
3020
3119
|
size: "small",
|
|
3021
|
-
type: "text"
|
|
3120
|
+
type: "text",
|
|
3121
|
+
disabled: _ctx.disabled
|
|
3022
3122
|
}, {
|
|
3023
3123
|
default: withCtx(() => [
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
}, null, 8, ["icon"
|
|
3124
|
+
_ctx.item.icon ? (openBlock(), createBlock(_component_m_icon, {
|
|
3125
|
+
key: 0,
|
|
3126
|
+
icon: _ctx.item.icon
|
|
3127
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
3128
|
+
createElementVNode("span", null, toDisplayString(_ctx.item.text), 1)
|
|
3028
3129
|
]),
|
|
3029
3130
|
_: 1
|
|
3030
|
-
})
|
|
3031
|
-
], 64)) : _ctx.item.type === "
|
|
3032
|
-
key: 3,
|
|
3033
|
-
effect: "dark",
|
|
3034
|
-
placement: "bottom-start",
|
|
3035
|
-
content: _ctx.item.tooltip || _ctx.item.text
|
|
3036
|
-
}, {
|
|
3037
|
-
default: withCtx(() => [
|
|
3038
|
-
createVNode(_component_el_button, {
|
|
3039
|
-
size: "small",
|
|
3040
|
-
type: "text",
|
|
3041
|
-
disabled: _ctx.disabled,
|
|
3042
|
-
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.buttonHandler(_ctx.item))
|
|
3043
|
-
}, {
|
|
3044
|
-
default: withCtx(() => [
|
|
3045
|
-
createVNode(_component_m_icon, {
|
|
3046
|
-
icon: _ctx.item.icon
|
|
3047
|
-
}, null, 8, ["icon"]),
|
|
3048
|
-
createElementVNode("span", null, toDisplayString(_ctx.item.text), 1)
|
|
3049
|
-
]),
|
|
3050
|
-
_: 1
|
|
3051
|
-
}, 8, ["disabled"])
|
|
3052
|
-
]),
|
|
3053
|
-
_: 1
|
|
3054
|
-
}, 8, ["content"])) : _ctx.item.type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
|
|
3131
|
+
}, 8, ["disabled"]))
|
|
3132
|
+
], 64)) : _ctx.item.type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
|
|
3055
3133
|
key: 4,
|
|
3056
3134
|
trigger: "click",
|
|
3057
3135
|
disabled: _ctx.disabled,
|
|
@@ -3076,7 +3154,7 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3076
3154
|
})) : createCommentVNode("", true)
|
|
3077
3155
|
]),
|
|
3078
3156
|
default: withCtx(() => [
|
|
3079
|
-
createElementVNode("span",
|
|
3157
|
+
createElementVNode("span", _hoisted_3$1, [
|
|
3080
3158
|
createTextVNode(toDisplayString(_ctx.item.text), 1),
|
|
3081
3159
|
createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
3082
3160
|
default: withCtx(() => [
|
|
@@ -3088,11 +3166,11 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3088
3166
|
]),
|
|
3089
3167
|
_: 1
|
|
3090
3168
|
}, 8, ["disabled", "onCommand"])) : _ctx.item.type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.item.component), normalizeProps(mergeProps({ key: 5 }, _ctx.item.props || {})), null, 16)) : createCommentVNode("", true)
|
|
3091
|
-
])) : createCommentVNode("", true);
|
|
3169
|
+
], 34)) : createCommentVNode("", true);
|
|
3092
3170
|
}
|
|
3093
|
-
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3171
|
+
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
|
|
3094
3172
|
|
|
3095
|
-
const _sfc_main$
|
|
3173
|
+
const _sfc_main$c = defineComponent({
|
|
3096
3174
|
name: "nav-menu",
|
|
3097
3175
|
components: { ToolButton },
|
|
3098
3176
|
props: {
|
|
@@ -3112,7 +3190,7 @@ const _sfc_main$b = defineComponent({
|
|
|
3112
3190
|
};
|
|
3113
3191
|
}
|
|
3114
3192
|
});
|
|
3115
|
-
function _sfc_render$
|
|
3193
|
+
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3116
3194
|
const _component_tool_button = resolveComponent("tool-button");
|
|
3117
3195
|
return openBlock(), createElementBlock("div", {
|
|
3118
3196
|
class: "m-editor-nav-menu",
|
|
@@ -3134,9 +3212,9 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3134
3212
|
}), 128))
|
|
3135
3213
|
], 4);
|
|
3136
3214
|
}
|
|
3137
|
-
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3215
|
+
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
|
|
3138
3216
|
|
|
3139
|
-
const _sfc_main$
|
|
3217
|
+
const _sfc_main$b = defineComponent({
|
|
3140
3218
|
name: "m-editor-props-panel",
|
|
3141
3219
|
emits: ["mounted"],
|
|
3142
3220
|
setup(props, { emit }) {
|
|
@@ -3182,7 +3260,7 @@ const _sfc_main$a = defineComponent({
|
|
|
3182
3260
|
};
|
|
3183
3261
|
}
|
|
3184
3262
|
});
|
|
3185
|
-
function _sfc_render$
|
|
3263
|
+
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3186
3264
|
const _component_m_form = resolveComponent("m-form");
|
|
3187
3265
|
return openBlock(), createBlock(_component_m_form, {
|
|
3188
3266
|
class: "m-editor-props-panel",
|
|
@@ -3194,9 +3272,9 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3194
3272
|
onChange: _ctx.submit
|
|
3195
3273
|
}, null, 8, ["init-values", "config", "onChange"]);
|
|
3196
3274
|
}
|
|
3197
|
-
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3275
|
+
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
|
|
3198
3276
|
|
|
3199
|
-
const _sfc_main$
|
|
3277
|
+
const _sfc_main$a = defineComponent({
|
|
3200
3278
|
name: "ui-component-panel",
|
|
3201
3279
|
components: { MIcon },
|
|
3202
3280
|
setup() {
|
|
@@ -3217,13 +3295,23 @@ const _sfc_main$9 = defineComponent({
|
|
|
3217
3295
|
type,
|
|
3218
3296
|
...data
|
|
3219
3297
|
});
|
|
3298
|
+
},
|
|
3299
|
+
dragstartHandler({ text, type, data = {} }, e) {
|
|
3300
|
+
if (e.dataTransfer) {
|
|
3301
|
+
e.dataTransfer.effectAllowed = "move";
|
|
3302
|
+
e.dataTransfer.setData("data", serialize({
|
|
3303
|
+
name: text,
|
|
3304
|
+
type,
|
|
3305
|
+
...data
|
|
3306
|
+
}).replace(/"(\w+)":\s/g, "$1: "));
|
|
3307
|
+
}
|
|
3220
3308
|
}
|
|
3221
3309
|
};
|
|
3222
3310
|
}
|
|
3223
3311
|
});
|
|
3224
|
-
const _hoisted_1$
|
|
3225
|
-
const _hoisted_2$
|
|
3226
|
-
function _sfc_render$
|
|
3312
|
+
const _hoisted_1$5 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
3313
|
+
const _hoisted_2$1 = ["onClick", "onDragstart"];
|
|
3314
|
+
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3227
3315
|
const _component_el_input = resolveComponent("el-input");
|
|
3228
3316
|
const _component_m_icon = resolveComponent("m-icon");
|
|
3229
3317
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
@@ -3253,15 +3341,17 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3253
3341
|
name: index
|
|
3254
3342
|
}, {
|
|
3255
3343
|
title: withCtx(() => [
|
|
3256
|
-
_hoisted_1$
|
|
3344
|
+
_hoisted_1$5,
|
|
3257
3345
|
createTextVNode(toDisplayString(group.title), 1)
|
|
3258
3346
|
]),
|
|
3259
3347
|
default: withCtx(() => [
|
|
3260
3348
|
(openBlock(true), createElementBlock(Fragment, null, renderList(group.items, (item) => {
|
|
3261
3349
|
return openBlock(), createElementBlock("div", {
|
|
3262
3350
|
class: "component-item",
|
|
3351
|
+
draggable: "true",
|
|
3263
3352
|
key: item.type,
|
|
3264
|
-
onClick: ($event) => _ctx.appendComponent(item)
|
|
3353
|
+
onClick: ($event) => _ctx.appendComponent(item),
|
|
3354
|
+
onDragstart: ($event) => _ctx.dragstartHandler(item, $event)
|
|
3265
3355
|
}, [
|
|
3266
3356
|
createVNode(_component_m_icon, {
|
|
3267
3357
|
icon: item.icon
|
|
@@ -3276,7 +3366,7 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3276
3366
|
]),
|
|
3277
3367
|
_: 2
|
|
3278
3368
|
}, 1032, ["content"])
|
|
3279
|
-
],
|
|
3369
|
+
], 40, _hoisted_2$1);
|
|
3280
3370
|
}), 128))
|
|
3281
3371
|
]),
|
|
3282
3372
|
_: 2
|
|
@@ -3290,98 +3380,194 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3290
3380
|
_: 1
|
|
3291
3381
|
});
|
|
3292
3382
|
}
|
|
3293
|
-
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3383
|
+
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
|
|
3384
|
+
|
|
3385
|
+
const _sfc_main$9 = defineComponent({
|
|
3386
|
+
components: { ToolButton },
|
|
3387
|
+
props: {
|
|
3388
|
+
menuData: {
|
|
3389
|
+
type: Array,
|
|
3390
|
+
default: () => []
|
|
3391
|
+
}
|
|
3392
|
+
},
|
|
3393
|
+
setup() {
|
|
3394
|
+
const menu = ref();
|
|
3395
|
+
const subMenu = ref();
|
|
3396
|
+
const visible = ref(false);
|
|
3397
|
+
const subMenuData = ref([]);
|
|
3398
|
+
const menuStyle = ref({
|
|
3399
|
+
left: "0",
|
|
3400
|
+
top: "0"
|
|
3401
|
+
});
|
|
3402
|
+
const hide = () => {
|
|
3403
|
+
visible.value = false;
|
|
3404
|
+
};
|
|
3405
|
+
onMounted(() => {
|
|
3406
|
+
globalThis.addEventListener("mousedown", (e) => {
|
|
3407
|
+
if (!visible.value || e.target && menu.value?.contains(e.target)) {
|
|
3408
|
+
return;
|
|
3409
|
+
}
|
|
3410
|
+
hide();
|
|
3411
|
+
}, true);
|
|
3412
|
+
});
|
|
3413
|
+
return {
|
|
3414
|
+
menu,
|
|
3415
|
+
subMenu,
|
|
3416
|
+
visible,
|
|
3417
|
+
menuStyle,
|
|
3418
|
+
subMenuData,
|
|
3419
|
+
hide,
|
|
3420
|
+
show(e) {
|
|
3421
|
+
visible.value = true;
|
|
3422
|
+
nextTick(() => {
|
|
3423
|
+
const menuHeight = menu.value?.clientHeight || 0;
|
|
3424
|
+
let top = e.clientY;
|
|
3425
|
+
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
3426
|
+
top = document.body.clientHeight - menuHeight;
|
|
3427
|
+
}
|
|
3428
|
+
menuStyle.value = {
|
|
3429
|
+
top: `${top}px`,
|
|
3430
|
+
left: `${e.clientX}px`
|
|
3431
|
+
};
|
|
3432
|
+
});
|
|
3433
|
+
},
|
|
3434
|
+
showSubMenu(item) {
|
|
3435
|
+
const menuItem = item;
|
|
3436
|
+
if (typeof item !== "object" || !menuItem.items?.length) {
|
|
3437
|
+
return;
|
|
3438
|
+
}
|
|
3439
|
+
subMenuData.value = menuItem.items;
|
|
3440
|
+
if (menu.value) {
|
|
3441
|
+
subMenu.value.show({
|
|
3442
|
+
clientX: menu.value.offsetLeft + menu.value.clientWidth,
|
|
3443
|
+
clientY: menu.value.offsetTop
|
|
3444
|
+
});
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
};
|
|
3448
|
+
}
|
|
3449
|
+
});
|
|
3450
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3451
|
+
const _component_tool_button = resolveComponent("tool-button");
|
|
3452
|
+
const _component_content_menu = resolveComponent("content-menu", true);
|
|
3453
|
+
return _ctx.menuData.length ? withDirectives((openBlock(), createElementBlock("div", {
|
|
3454
|
+
key: 0,
|
|
3455
|
+
class: "magic-editor-content-menu",
|
|
3456
|
+
ref: "menu",
|
|
3457
|
+
style: normalizeStyle(_ctx.menuStyle)
|
|
3458
|
+
}, [
|
|
3459
|
+
createElementVNode("div", null, [
|
|
3460
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menuData, (item, index) => {
|
|
3461
|
+
return openBlock(), createBlock(_component_tool_button, {
|
|
3462
|
+
"event-type": "mouseup",
|
|
3463
|
+
data: item,
|
|
3464
|
+
key: index,
|
|
3465
|
+
onMouseup: _ctx.hide,
|
|
3466
|
+
onMouseenter: ($event) => _ctx.showSubMenu(item)
|
|
3467
|
+
}, null, 8, ["data", "onMouseup", "onMouseenter"]);
|
|
3468
|
+
}), 128))
|
|
3469
|
+
]),
|
|
3470
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
3471
|
+
createVNode(_component_content_menu, {
|
|
3472
|
+
class: "sub-menu",
|
|
3473
|
+
ref: "subMenu",
|
|
3474
|
+
"menu-data": _ctx.subMenuData
|
|
3475
|
+
}, null, 8, ["menu-data"])
|
|
3476
|
+
]))
|
|
3477
|
+
], 4)), [
|
|
3478
|
+
[vShow, _ctx.visible]
|
|
3479
|
+
]) : createCommentVNode("", true);
|
|
3480
|
+
}
|
|
3481
|
+
var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
|
|
3294
3482
|
|
|
3295
3483
|
const _sfc_main$8 = defineComponent({
|
|
3296
|
-
|
|
3484
|
+
components: { ContentMenu },
|
|
3297
3485
|
setup() {
|
|
3298
3486
|
const services = inject("services");
|
|
3299
|
-
const
|
|
3487
|
+
const menu = ref();
|
|
3300
3488
|
const node = computed(() => services?.editorService.get("node"));
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3489
|
+
const isRoot = computed(() => node.value?.type === NodeType.ROOT);
|
|
3490
|
+
const isPage = computed(() => node.value?.type === NodeType.PAGE);
|
|
3491
|
+
const componentList = computed(() => services?.componentListService.getList() || []);
|
|
3492
|
+
const createMenuItems = (group) => group.items.map((component) => ({
|
|
3493
|
+
text: component.text,
|
|
3494
|
+
type: "button",
|
|
3495
|
+
icon: component.icon,
|
|
3496
|
+
handler: () => {
|
|
3306
3497
|
services?.editorService.add({
|
|
3307
|
-
name:
|
|
3308
|
-
type:
|
|
3309
|
-
...
|
|
3498
|
+
name: component.text,
|
|
3499
|
+
type: component.type,
|
|
3500
|
+
...component.data || {}
|
|
3310
3501
|
});
|
|
3311
|
-
}
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3502
|
+
}
|
|
3503
|
+
}));
|
|
3504
|
+
const getSubMenuData = computed(() => {
|
|
3505
|
+
if (node.value?.type === "tabs") {
|
|
3506
|
+
return [
|
|
3507
|
+
{
|
|
3508
|
+
text: "\u6807\u7B7E\u9875",
|
|
3509
|
+
type: "button",
|
|
3510
|
+
icon: Files,
|
|
3511
|
+
handler: () => {
|
|
3512
|
+
services?.editorService.add({
|
|
3513
|
+
type: "tab-pane"
|
|
3514
|
+
});
|
|
3515
|
+
}
|
|
3516
|
+
}
|
|
3517
|
+
];
|
|
3518
|
+
}
|
|
3519
|
+
if (node.value?.items) {
|
|
3520
|
+
return componentList.value.reduce((subMenuData, group, index) => subMenuData.concat(createMenuItems(group), index < componentList.value.length - 1 ? [
|
|
3521
|
+
{
|
|
3522
|
+
type: "divider",
|
|
3523
|
+
direction: "horizontal"
|
|
3524
|
+
}
|
|
3525
|
+
] : []), []) || [];
|
|
3526
|
+
}
|
|
3527
|
+
return [];
|
|
3528
|
+
});
|
|
3529
|
+
return {
|
|
3530
|
+
menu,
|
|
3531
|
+
menuData: computed(() => [
|
|
3532
|
+
{
|
|
3533
|
+
type: "button",
|
|
3534
|
+
text: "\u65B0\u589E",
|
|
3535
|
+
icon: markRaw(Plus),
|
|
3536
|
+
display: () => node.value?.items,
|
|
3537
|
+
items: getSubMenuData.value
|
|
3538
|
+
},
|
|
3539
|
+
{
|
|
3540
|
+
type: "button",
|
|
3541
|
+
text: "\u590D\u5236",
|
|
3542
|
+
icon: markRaw(DocumentCopy),
|
|
3543
|
+
display: () => !isRoot.value,
|
|
3544
|
+
handler: () => {
|
|
3545
|
+
node.value && services?.editorService.copy(node.value);
|
|
3546
|
+
}
|
|
3547
|
+
},
|
|
3548
|
+
{
|
|
3549
|
+
type: "button",
|
|
3550
|
+
text: "\u5220\u9664",
|
|
3551
|
+
icon: markRaw(Delete),
|
|
3552
|
+
display: () => !isRoot.value && !isPage.value,
|
|
3553
|
+
handler: () => {
|
|
3554
|
+
node.value && services?.editorService.remove(node.value);
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
]),
|
|
3558
|
+
show(e) {
|
|
3559
|
+
menu.value?.show(e);
|
|
3320
3560
|
}
|
|
3321
3561
|
};
|
|
3322
3562
|
}
|
|
3323
3563
|
});
|
|
3324
|
-
const _hoisted_1$6 = {
|
|
3325
|
-
key: 0,
|
|
3326
|
-
class: "magic-editor-content-menu"
|
|
3327
|
-
};
|
|
3328
|
-
const _hoisted_2$2 = ["onClick"];
|
|
3329
|
-
const _hoisted_3$2 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
3330
3564
|
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3331
|
-
const
|
|
3332
|
-
return
|
|
3333
|
-
_ctx.
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
onMouseleave: _cache[1] || (_cache[1] = ($event) => _ctx.setSubVisitable(false))
|
|
3338
|
-
}, " \u65B0\u589E ", 32)) : createCommentVNode("", true),
|
|
3339
|
-
_ctx.node.type !== "app" ? (openBlock(), createElementBlock("div", {
|
|
3340
|
-
key: 1,
|
|
3341
|
-
class: "magic-editor-content-menu-item",
|
|
3342
|
-
onClick: _cache[2] || (_cache[2] = () => _ctx.copy(_ctx.node))
|
|
3343
|
-
}, "\u590D\u5236")) : createCommentVNode("", true),
|
|
3344
|
-
_ctx.node.type !== "app" && _ctx.node.type !== "page" ? (openBlock(), createElementBlock("div", {
|
|
3345
|
-
key: 2,
|
|
3346
|
-
class: "magic-editor-content-menu-item",
|
|
3347
|
-
onClick: _cache[3] || (_cache[3] = () => _ctx.remove())
|
|
3348
|
-
}, " \u5220\u9664 ")) : createCommentVNode("", true),
|
|
3349
|
-
withDirectives(createElementVNode("div", {
|
|
3350
|
-
class: "subMenu",
|
|
3351
|
-
onMouseenter: _cache[5] || (_cache[5] = ($event) => _ctx.setSubVisitable(true)),
|
|
3352
|
-
onMouseleave: _cache[6] || (_cache[6] = ($event) => _ctx.setSubVisitable(false))
|
|
3353
|
-
}, [
|
|
3354
|
-
createVNode(_component_el_scrollbar, null, {
|
|
3355
|
-
default: withCtx(() => [
|
|
3356
|
-
_ctx.node.type === "tabs" ? (openBlock(), createElementBlock("div", {
|
|
3357
|
-
key: 0,
|
|
3358
|
-
class: "magic-editor-content-menu-item",
|
|
3359
|
-
onClick: _cache[4] || (_cache[4] = () => _ctx.append({
|
|
3360
|
-
type: "tab-pane"
|
|
3361
|
-
}))
|
|
3362
|
-
}, " \u6807\u7B7E ")) : _ctx.node.items ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(_ctx.componentGroupList, (list) => {
|
|
3363
|
-
return openBlock(), createElementBlock("div", {
|
|
3364
|
-
key: list.title
|
|
3365
|
-
}, [
|
|
3366
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(list.items, (item) => {
|
|
3367
|
-
return openBlock(), createElementBlock(Fragment, null, [
|
|
3368
|
-
item ? (openBlock(), createElementBlock("div", {
|
|
3369
|
-
class: "magic-editor-content-menu-item",
|
|
3370
|
-
key: item.type,
|
|
3371
|
-
onClick: () => _ctx.append(item)
|
|
3372
|
-
}, toDisplayString(item.text), 9, _hoisted_2$2)) : createCommentVNode("", true)
|
|
3373
|
-
], 64);
|
|
3374
|
-
}), 256)),
|
|
3375
|
-
_hoisted_3$2
|
|
3376
|
-
]);
|
|
3377
|
-
}), 128)) : createCommentVNode("", true)
|
|
3378
|
-
]),
|
|
3379
|
-
_: 1
|
|
3380
|
-
})
|
|
3381
|
-
], 544), [
|
|
3382
|
-
[vShow, _ctx.subVisible]
|
|
3383
|
-
])
|
|
3384
|
-
])) : createCommentVNode("", true);
|
|
3565
|
+
const _component_content_menu = resolveComponent("content-menu");
|
|
3566
|
+
return openBlock(), createBlock(_component_content_menu, {
|
|
3567
|
+
"menu-data": _ctx.menuData,
|
|
3568
|
+
ref: "menu",
|
|
3569
|
+
style: { "overflow": "initial" }
|
|
3570
|
+
}, null, 8, ["menu-data"]);
|
|
3385
3571
|
}
|
|
3386
3572
|
var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
|
|
3387
3573
|
|
|
@@ -3475,56 +3661,37 @@ const useFilter = (tree) => ({
|
|
|
3475
3661
|
tree.value?.filter(val);
|
|
3476
3662
|
}
|
|
3477
3663
|
});
|
|
3478
|
-
const useContentMenu = (editorService) => {
|
|
3479
|
-
const menuStyle = ref({
|
|
3480
|
-
position: "absolute",
|
|
3481
|
-
left: "0",
|
|
3482
|
-
top: "0",
|
|
3483
|
-
display: "none"
|
|
3484
|
-
});
|
|
3485
|
-
onMounted(() => {
|
|
3486
|
-
document.addEventListener("click", () => {
|
|
3487
|
-
menuStyle.value.display = "none";
|
|
3488
|
-
}, true);
|
|
3489
|
-
});
|
|
3490
|
-
return {
|
|
3491
|
-
menuStyle,
|
|
3492
|
-
contextmenu(event, data) {
|
|
3493
|
-
const bodyHeight = globalThis.document.body.clientHeight;
|
|
3494
|
-
const left = `${event.clientX + 20}px`;
|
|
3495
|
-
let top = `${event.clientY - 10}px`;
|
|
3496
|
-
if (event.clientY + 300 > bodyHeight) {
|
|
3497
|
-
top = `${bodyHeight - 300}px`;
|
|
3498
|
-
}
|
|
3499
|
-
menuStyle.value.left = left;
|
|
3500
|
-
menuStyle.value.top = top;
|
|
3501
|
-
menuStyle.value.display = "";
|
|
3502
|
-
select(data, editorService);
|
|
3503
|
-
}
|
|
3504
|
-
};
|
|
3505
|
-
};
|
|
3506
3664
|
const _sfc_main$7 = defineComponent({
|
|
3507
3665
|
name: "magic-editor-layer-panel",
|
|
3508
3666
|
components: { LayerMenu },
|
|
3509
3667
|
setup() {
|
|
3510
3668
|
const services = inject("services");
|
|
3511
3669
|
const tree = ref();
|
|
3670
|
+
const menu = ref();
|
|
3512
3671
|
const clicked = ref(false);
|
|
3513
3672
|
const editorService = services?.editorService;
|
|
3514
3673
|
const highlightHandler = throttle((data) => {
|
|
3515
3674
|
highlight(data, editorService);
|
|
3516
3675
|
}, throttleTime);
|
|
3517
|
-
const
|
|
3676
|
+
const toggleClickFlag = () => {
|
|
3518
3677
|
clicked.value = !clicked.value;
|
|
3519
3678
|
};
|
|
3520
3679
|
const statusData = useStatus(tree, editorService);
|
|
3521
3680
|
const canHighlight = computed(() => statusData.highlightNode.value?.id !== statusData.clickNode.value?.id && !clicked.value);
|
|
3681
|
+
editorService?.on("remove", () => {
|
|
3682
|
+
setTimeout(() => {
|
|
3683
|
+
tree.value?.getNode(editorService.get("node").id)?.updateChildren();
|
|
3684
|
+
}, 0);
|
|
3685
|
+
});
|
|
3522
3686
|
return {
|
|
3523
3687
|
tree,
|
|
3688
|
+
menu,
|
|
3524
3689
|
...statusData,
|
|
3525
3690
|
...useDrop(tree, editorService),
|
|
3526
3691
|
...useFilter(tree),
|
|
3527
|
-
|
|
3692
|
+
highlightHandler,
|
|
3693
|
+
toggleClickFlag,
|
|
3694
|
+
canHighlight,
|
|
3528
3695
|
clickHandler(data) {
|
|
3529
3696
|
if (services?.uiService.get("uiSelectMode")) {
|
|
3530
3697
|
document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
|
|
@@ -3533,13 +3700,15 @@ const _sfc_main$7 = defineComponent({
|
|
|
3533
3700
|
tree.value?.setCurrentKey(data.id);
|
|
3534
3701
|
select(data, editorService);
|
|
3535
3702
|
},
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3703
|
+
async contextmenu(event, data) {
|
|
3704
|
+
event.preventDefault();
|
|
3705
|
+
await select(data, editorService);
|
|
3706
|
+
menu.value?.show(event);
|
|
3707
|
+
}
|
|
3539
3708
|
};
|
|
3540
3709
|
}
|
|
3541
3710
|
});
|
|
3542
|
-
const _hoisted_1$
|
|
3711
|
+
const _hoisted_1$4 = ["id", "onMouseenter"];
|
|
3543
3712
|
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3544
3713
|
const _component_el_input = resolveComponent("el-input");
|
|
3545
3714
|
const _component_el_tree = resolveComponent("el-tree");
|
|
@@ -3580,8 +3749,8 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3580
3749
|
createElementVNode("div", {
|
|
3581
3750
|
id: data.id,
|
|
3582
3751
|
class: normalizeClass(["cus-tree-node", { "cus-tree-node-hover": _ctx.canHighlight && data.id === _ctx.highlightNode?.id }]),
|
|
3583
|
-
onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.
|
|
3584
|
-
onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.
|
|
3752
|
+
onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
|
|
3753
|
+
onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
|
|
3585
3754
|
onMouseenter: ($event) => _ctx.highlightHandler(data)
|
|
3586
3755
|
}, [
|
|
3587
3756
|
renderSlot(_ctx.$slots, "layer-node-content", {
|
|
@@ -3590,14 +3759,12 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3590
3759
|
}, () => [
|
|
3591
3760
|
createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
|
|
3592
3761
|
])
|
|
3593
|
-
], 42, _hoisted_1$
|
|
3762
|
+
], 42, _hoisted_1$4)
|
|
3594
3763
|
]),
|
|
3595
3764
|
_: 3
|
|
3596
3765
|
}, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : createCommentVNode("", true),
|
|
3597
3766
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
3598
|
-
createVNode(_component_layer_menu, {
|
|
3599
|
-
style: normalizeStyle(_ctx.menuStyle)
|
|
3600
|
-
}, null, 8, ["style"])
|
|
3767
|
+
createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
|
|
3601
3768
|
]))
|
|
3602
3769
|
]),
|
|
3603
3770
|
_: 3
|
|
@@ -3649,7 +3816,7 @@ const _sfc_main$6 = defineComponent({
|
|
|
3649
3816
|
};
|
|
3650
3817
|
}
|
|
3651
3818
|
});
|
|
3652
|
-
const _hoisted_1$
|
|
3819
|
+
const _hoisted_1$3 = {
|
|
3653
3820
|
key: 1,
|
|
3654
3821
|
class: "magic-editor-tab-panel-title"
|
|
3655
3822
|
};
|
|
@@ -3677,7 +3844,7 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3677
3844
|
key: 0,
|
|
3678
3845
|
icon: item.icon
|
|
3679
3846
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
3680
|
-
item.text ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
3847
|
+
item.text ? (openBlock(), createElementBlock("div", _hoisted_1$3, toDisplayString(item.text), 1)) : createCommentVNode("", true)
|
|
3681
3848
|
])
|
|
3682
3849
|
]),
|
|
3683
3850
|
default: withCtx(() => [
|
|
@@ -3767,12 +3934,14 @@ const useScroll = (root) => {
|
|
|
3767
3934
|
};
|
|
3768
3935
|
};
|
|
3769
3936
|
const _sfc_main$5 = defineComponent({
|
|
3770
|
-
components: { ArrowLeftBold, ArrowRightBold, CaretBottom, Plus },
|
|
3937
|
+
components: { ArrowLeftBold, ArrowRightBold, CaretBottom, Plus, ToolButton },
|
|
3771
3938
|
setup() {
|
|
3772
3939
|
const services = inject("services");
|
|
3773
3940
|
const editorService = services?.editorService;
|
|
3774
3941
|
const root = computed(() => editorService?.get("root"));
|
|
3775
3942
|
return {
|
|
3943
|
+
Delete: markRaw(Delete),
|
|
3944
|
+
DocumentCopy: markRaw(DocumentCopy),
|
|
3776
3945
|
...useScroll(root),
|
|
3777
3946
|
root,
|
|
3778
3947
|
page: computed(() => editorService?.get("page")),
|
|
@@ -3801,23 +3970,22 @@ const _sfc_main$5 = defineComponent({
|
|
|
3801
3970
|
};
|
|
3802
3971
|
}
|
|
3803
3972
|
});
|
|
3804
|
-
const _hoisted_1$
|
|
3973
|
+
const _hoisted_1$2 = {
|
|
3805
3974
|
class: "m-editor-page-bar",
|
|
3806
3975
|
ref: "pageBar"
|
|
3807
3976
|
};
|
|
3808
|
-
const _hoisted_2
|
|
3809
|
-
const _hoisted_3
|
|
3810
|
-
const _hoisted_4$1 = ["onClick"];
|
|
3811
|
-
const _hoisted_5 = ["onClick"];
|
|
3977
|
+
const _hoisted_2 = ["onClick"];
|
|
3978
|
+
const _hoisted_3 = { class: "m-editor-page-bar-title" };
|
|
3812
3979
|
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3813
3980
|
const _component_plus = resolveComponent("plus");
|
|
3814
3981
|
const _component_el_icon = resolveComponent("el-icon");
|
|
3815
3982
|
const _component_arrow_left_bold = resolveComponent("arrow-left-bold");
|
|
3816
3983
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
3984
|
+
const _component_tool_button = resolveComponent("tool-button");
|
|
3817
3985
|
const _component_caret_bottom = resolveComponent("caret-bottom");
|
|
3818
3986
|
const _component_el_popover = resolveComponent("el-popover");
|
|
3819
3987
|
const _component_arrow_right_bold = resolveComponent("arrow-right-bold");
|
|
3820
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
3988
|
+
return openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
3821
3989
|
createElementVNode("div", {
|
|
3822
3990
|
id: "m-editor-page-bar-add-icon",
|
|
3823
3991
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
@@ -3854,7 +4022,7 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3854
4022
|
class: normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
|
|
3855
4023
|
onClick: ($event) => _ctx.switchPage(item)
|
|
3856
4024
|
}, [
|
|
3857
|
-
createElementVNode("div", _hoisted_3
|
|
4025
|
+
createElementVNode("div", _hoisted_3, [
|
|
3858
4026
|
renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
|
|
3859
4027
|
createVNode(_component_el_tooltip, {
|
|
3860
4028
|
effect: "dark",
|
|
@@ -3869,6 +4037,7 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3869
4037
|
])
|
|
3870
4038
|
]),
|
|
3871
4039
|
createVNode(_component_el_popover, {
|
|
4040
|
+
"popper-class": "page-bar-popover",
|
|
3872
4041
|
placement: "top",
|
|
3873
4042
|
width: 160,
|
|
3874
4043
|
trigger: "hover"
|
|
@@ -3884,20 +4053,28 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3884
4053
|
default: withCtx(() => [
|
|
3885
4054
|
createElementVNode("div", null, [
|
|
3886
4055
|
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
},
|
|
4056
|
+
createVNode(_component_tool_button, {
|
|
4057
|
+
data: {
|
|
4058
|
+
type: "button",
|
|
4059
|
+
text: "\u590D\u5236",
|
|
4060
|
+
icon: _ctx.DocumentCopy,
|
|
4061
|
+
handler: () => _ctx.copy(item)
|
|
4062
|
+
}
|
|
4063
|
+
}, null, 8, ["data"]),
|
|
4064
|
+
createVNode(_component_tool_button, {
|
|
4065
|
+
data: {
|
|
4066
|
+
type: "button",
|
|
4067
|
+
text: "\u5220\u9664",
|
|
4068
|
+
icon: _ctx.Delete,
|
|
4069
|
+
handler: () => _ctx.remove(item)
|
|
4070
|
+
}
|
|
4071
|
+
}, null, 8, ["data"])
|
|
3895
4072
|
])
|
|
3896
4073
|
])
|
|
3897
4074
|
]),
|
|
3898
4075
|
_: 2
|
|
3899
4076
|
}, 1024)
|
|
3900
|
-
], 10, _hoisted_2
|
|
4077
|
+
], 10, _hoisted_2);
|
|
3901
4078
|
}), 128))
|
|
3902
4079
|
], 4)) : createCommentVNode("", true),
|
|
3903
4080
|
_ctx.canScroll ? (openBlock(), createElementBlock("div", {
|
|
@@ -4117,12 +4294,12 @@ const _sfc_main$4 = defineComponent({
|
|
|
4117
4294
|
};
|
|
4118
4295
|
}
|
|
4119
4296
|
});
|
|
4120
|
-
const _hoisted_1$
|
|
4297
|
+
const _hoisted_1$1 = {
|
|
4121
4298
|
class: "m-editor-scroll-viewer-container",
|
|
4122
4299
|
ref: "container"
|
|
4123
4300
|
};
|
|
4124
4301
|
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4125
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
4302
|
+
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
4126
4303
|
createElementVNode("div", {
|
|
4127
4304
|
ref: "el",
|
|
4128
4305
|
style: normalizeStyle(_ctx.style)
|
|
@@ -4134,7 +4311,7 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4134
4311
|
var ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]);
|
|
4135
4312
|
|
|
4136
4313
|
const _sfc_main$3 = defineComponent({
|
|
4137
|
-
|
|
4314
|
+
components: { ContentMenu },
|
|
4138
4315
|
setup() {
|
|
4139
4316
|
const services = inject("services");
|
|
4140
4317
|
const editorService = services?.editorService;
|
|
@@ -4143,6 +4320,7 @@ const _sfc_main$3 = defineComponent({
|
|
|
4143
4320
|
const canCenter = ref(false);
|
|
4144
4321
|
const node = computed(() => editorService?.get("node"));
|
|
4145
4322
|
const parent = computed(() => editorService?.get("parent"));
|
|
4323
|
+
const isPage = computed(() => node.value?.type === NodeType.PAGE);
|
|
4146
4324
|
onMounted(() => {
|
|
4147
4325
|
const data = globalThis.localStorage.getItem(COPY_STORAGE_KEY);
|
|
4148
4326
|
canPaste.value = data !== "undefined" && !!data;
|
|
@@ -4155,133 +4333,114 @@ const _sfc_main$3 = defineComponent({
|
|
|
4155
4333
|
}, { immediate: true });
|
|
4156
4334
|
return {
|
|
4157
4335
|
menu,
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4336
|
+
menuData: reactive([
|
|
4337
|
+
{
|
|
4338
|
+
type: "button",
|
|
4339
|
+
text: "\u6C34\u5E73\u5C45\u4E2D",
|
|
4340
|
+
display: () => canCenter.value,
|
|
4341
|
+
handler: () => {
|
|
4342
|
+
node.value && editorService?.alignCenter(node.value);
|
|
4343
|
+
}
|
|
4344
|
+
},
|
|
4345
|
+
{
|
|
4346
|
+
type: "button",
|
|
4347
|
+
text: "\u590D\u5236",
|
|
4348
|
+
icon: markRaw(DocumentCopy),
|
|
4349
|
+
handler: () => {
|
|
4350
|
+
node.value && editorService?.copy(node.value);
|
|
4351
|
+
canPaste.value = true;
|
|
4352
|
+
}
|
|
4353
|
+
},
|
|
4354
|
+
{
|
|
4355
|
+
type: "button",
|
|
4356
|
+
text: "\u7C98\u8D34",
|
|
4357
|
+
display: () => canPaste.value,
|
|
4358
|
+
handler: () => {
|
|
4359
|
+
const top = menu.value?.$el.offsetTop || 0;
|
|
4360
|
+
const left = menu.value?.$el.offsetLeft || 0;
|
|
4361
|
+
editorService?.paste({ left, top });
|
|
4362
|
+
}
|
|
4363
|
+
},
|
|
4364
|
+
{
|
|
4365
|
+
type: "divider",
|
|
4366
|
+
direction: "horizontal",
|
|
4367
|
+
display: () => !isPage.value
|
|
4368
|
+
},
|
|
4369
|
+
{
|
|
4370
|
+
type: "button",
|
|
4371
|
+
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
4372
|
+
icon: markRaw(Top),
|
|
4373
|
+
display: () => !isPage.value,
|
|
4374
|
+
handler: () => {
|
|
4375
|
+
editorService?.moveLayer(1);
|
|
4376
|
+
}
|
|
4377
|
+
},
|
|
4378
|
+
{
|
|
4379
|
+
type: "button",
|
|
4380
|
+
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
4381
|
+
icon: markRaw(Bottom),
|
|
4382
|
+
display: () => !isPage.value,
|
|
4383
|
+
handler: () => {
|
|
4384
|
+
editorService?.moveLayer(-1);
|
|
4385
|
+
}
|
|
4386
|
+
},
|
|
4387
|
+
{
|
|
4388
|
+
type: "button",
|
|
4389
|
+
text: "\u7F6E\u9876",
|
|
4390
|
+
display: () => !isPage.value,
|
|
4391
|
+
handler: () => {
|
|
4392
|
+
editorService?.moveLayer(LayerOffset.TOP);
|
|
4393
|
+
}
|
|
4394
|
+
},
|
|
4395
|
+
{
|
|
4396
|
+
type: "button",
|
|
4397
|
+
text: "\u7F6E\u5E95",
|
|
4398
|
+
display: () => !isPage.value,
|
|
4399
|
+
handler: () => {
|
|
4400
|
+
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
4401
|
+
}
|
|
4402
|
+
},
|
|
4403
|
+
{
|
|
4404
|
+
type: "divider",
|
|
4405
|
+
direction: "horizontal",
|
|
4406
|
+
display: () => !isPage.value
|
|
4407
|
+
},
|
|
4408
|
+
{
|
|
4409
|
+
type: "button",
|
|
4410
|
+
text: "\u5220\u9664",
|
|
4411
|
+
icon: Delete,
|
|
4412
|
+
display: () => !isPage.value,
|
|
4413
|
+
handler: () => {
|
|
4414
|
+
node.value && editorService?.remove(node.value);
|
|
4415
|
+
}
|
|
4416
|
+
},
|
|
4417
|
+
{
|
|
4418
|
+
type: "divider",
|
|
4419
|
+
direction: "horizontal"
|
|
4420
|
+
},
|
|
4421
|
+
{
|
|
4422
|
+
type: "button",
|
|
4423
|
+
text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
|
|
4424
|
+
handler: () => {
|
|
4425
|
+
editorService?.get("stage").clearGuides();
|
|
4426
|
+
}
|
|
4427
|
+
}
|
|
4428
|
+
]),
|
|
4429
|
+
show(e) {
|
|
4430
|
+
menu.value?.show(e);
|
|
4191
4431
|
}
|
|
4192
4432
|
};
|
|
4193
4433
|
}
|
|
4194
4434
|
});
|
|
4195
|
-
const _hoisted_1$1 = {
|
|
4196
|
-
class: "magic-editor-content-menu",
|
|
4197
|
-
ref: "menu"
|
|
4198
|
-
};
|
|
4199
|
-
const _hoisted_2 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
4200
|
-
const _hoisted_3 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
4201
|
-
const _hoisted_4 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
4202
4435
|
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
onClick: _cache[0] || (_cache[0] = () => _ctx.center())
|
|
4209
|
-
}, "\u6C34\u5E73\u5C45\u4E2D")) : createCommentVNode("", true),
|
|
4210
|
-
createElementVNode("div", {
|
|
4211
|
-
class: "magic-editor-content-menu-item",
|
|
4212
|
-
onClick: _cache[1] || (_cache[1] = () => _ctx.copy())
|
|
4213
|
-
}, "\u590D\u5236"),
|
|
4214
|
-
_ctx.canPaste ? (openBlock(), createElementBlock("div", {
|
|
4215
|
-
key: 1,
|
|
4216
|
-
class: "magic-editor-content-menu-item",
|
|
4217
|
-
onClick: _cache[2] || (_cache[2] = (...args) => _ctx.paste && _ctx.paste(...args))
|
|
4218
|
-
}, "\u7C98\u8D34")) : createCommentVNode("", true),
|
|
4219
|
-
_ctx.canMoveZPos ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
4220
|
-
_hoisted_2,
|
|
4221
|
-
createElementVNode("div", {
|
|
4222
|
-
class: "magic-editor-content-menu-item",
|
|
4223
|
-
onClick: _cache[3] || (_cache[3] = (...args) => _ctx.topItem && _ctx.topItem(...args))
|
|
4224
|
-
}, "\u4E0A\u79FB\u4E00\u5C42"),
|
|
4225
|
-
createElementVNode("div", {
|
|
4226
|
-
class: "magic-editor-content-menu-item",
|
|
4227
|
-
onClick: _cache[4] || (_cache[4] = (...args) => _ctx.bottomItem && _ctx.bottomItem(...args))
|
|
4228
|
-
}, "\u4E0B\u79FB\u4E00\u5C42"),
|
|
4229
|
-
createElementVNode("div", {
|
|
4230
|
-
class: "magic-editor-content-menu-item",
|
|
4231
|
-
onClick: _cache[5] || (_cache[5] = (...args) => _ctx.top && _ctx.top(...args))
|
|
4232
|
-
}, "\u7F6E\u9876"),
|
|
4233
|
-
createElementVNode("div", {
|
|
4234
|
-
class: "magic-editor-content-menu-item",
|
|
4235
|
-
onClick: _cache[6] || (_cache[6] = (...args) => _ctx.bottom && _ctx.bottom(...args))
|
|
4236
|
-
}, "\u7F6E\u5E95")
|
|
4237
|
-
], 64)) : createCommentVNode("", true),
|
|
4238
|
-
_ctx.canDelete ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
4239
|
-
_hoisted_3,
|
|
4240
|
-
createElementVNode("div", {
|
|
4241
|
-
class: "magic-editor-content-menu-item",
|
|
4242
|
-
onClick: _cache[7] || (_cache[7] = () => _ctx.remove())
|
|
4243
|
-
}, "\u5220\u9664")
|
|
4244
|
-
], 64)) : createCommentVNode("", true),
|
|
4245
|
-
_hoisted_4,
|
|
4246
|
-
createElementVNode("div", {
|
|
4247
|
-
class: "magic-editor-content-menu-item",
|
|
4248
|
-
onClick: _cache[8] || (_cache[8] = (...args) => _ctx.clearGuides && _ctx.clearGuides(...args))
|
|
4249
|
-
}, "\u6E05\u7A7A\u53C2\u8003\u7EBF")
|
|
4250
|
-
])
|
|
4251
|
-
], 512);
|
|
4436
|
+
const _component_content_menu = resolveComponent("content-menu");
|
|
4437
|
+
return openBlock(), createBlock(_component_content_menu, {
|
|
4438
|
+
"menu-data": _ctx.menuData,
|
|
4439
|
+
ref: "menu"
|
|
4440
|
+
}, null, 8, ["menu-data"]);
|
|
4252
4441
|
}
|
|
4253
4442
|
var ViewerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
|
|
4254
4443
|
|
|
4255
|
-
const useMenu = () => {
|
|
4256
|
-
const menu = ref();
|
|
4257
|
-
const menuStyle = ref({
|
|
4258
|
-
display: "none",
|
|
4259
|
-
left: "0",
|
|
4260
|
-
top: "0"
|
|
4261
|
-
});
|
|
4262
|
-
onMounted(() => {
|
|
4263
|
-
document.addEventListener("click", () => {
|
|
4264
|
-
menuStyle.value.display = "none";
|
|
4265
|
-
}, true);
|
|
4266
|
-
});
|
|
4267
|
-
return {
|
|
4268
|
-
menu,
|
|
4269
|
-
menuStyle,
|
|
4270
|
-
contextmenuHandler(e) {
|
|
4271
|
-
e.preventDefault();
|
|
4272
|
-
const menuHeight = menu.value?.$el.clientHeight;
|
|
4273
|
-
let top = e.clientY;
|
|
4274
|
-
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
4275
|
-
top = document.body.clientHeight - menuHeight;
|
|
4276
|
-
}
|
|
4277
|
-
menuStyle.value = {
|
|
4278
|
-
display: "block",
|
|
4279
|
-
top: `${top}px`,
|
|
4280
|
-
left: `${e.clientX}px`
|
|
4281
|
-
};
|
|
4282
|
-
}
|
|
4283
|
-
};
|
|
4284
|
-
};
|
|
4285
4444
|
const _sfc_main$2 = defineComponent({
|
|
4286
4445
|
name: "magic-stage",
|
|
4287
4446
|
components: {
|
|
@@ -4308,11 +4467,12 @@ const _sfc_main$2 = defineComponent({
|
|
|
4308
4467
|
const services = inject("services");
|
|
4309
4468
|
const stageWrap = ref();
|
|
4310
4469
|
const stageContainer = ref();
|
|
4470
|
+
const menu = ref();
|
|
4311
4471
|
const stageRect = computed(() => services?.uiService.get("stageRect"));
|
|
4312
4472
|
const uiSelectMode = computed(() => services?.uiService.get("uiSelectMode"));
|
|
4313
4473
|
const root = computed(() => services?.editorService.get("root"));
|
|
4314
4474
|
const page = computed(() => services?.editorService.get("page"));
|
|
4315
|
-
const zoom = computed(() => services?.uiService.get("zoom"));
|
|
4475
|
+
const zoom = computed(() => services?.uiService.get("zoom") || 1);
|
|
4316
4476
|
const node = computed(() => services?.editorService.get("node"));
|
|
4317
4477
|
let stage = null;
|
|
4318
4478
|
let runtime = null;
|
|
@@ -4394,9 +4554,36 @@ const _sfc_main$2 = defineComponent({
|
|
|
4394
4554
|
return {
|
|
4395
4555
|
stageWrap,
|
|
4396
4556
|
stageContainer,
|
|
4557
|
+
menu,
|
|
4397
4558
|
stageRect,
|
|
4398
4559
|
zoom,
|
|
4399
|
-
|
|
4560
|
+
contextmenuHandler(e2) {
|
|
4561
|
+
e2.preventDefault();
|
|
4562
|
+
menu.value?.show(e2);
|
|
4563
|
+
},
|
|
4564
|
+
dragoverHandler(e2) {
|
|
4565
|
+
e2.preventDefault();
|
|
4566
|
+
if (e2.dataTransfer) {
|
|
4567
|
+
e2.dataTransfer.dropEffect = "move";
|
|
4568
|
+
}
|
|
4569
|
+
},
|
|
4570
|
+
async dropHandler(e) {
|
|
4571
|
+
e.preventDefault();
|
|
4572
|
+
if (e.dataTransfer && page.value && stageContainer.value && stage) {
|
|
4573
|
+
const config = eval(`(${e.dataTransfer.getData("data")})`);
|
|
4574
|
+
const layout = await services?.editorService.getLayout(page.value);
|
|
4575
|
+
const containerRect = stageContainer.value.getBoundingClientRect();
|
|
4576
|
+
const { scrollTop, scrollLeft } = stage.mask;
|
|
4577
|
+
if (layout === Layout.ABSOLUTE) {
|
|
4578
|
+
config.style = {
|
|
4579
|
+
position: "absolute",
|
|
4580
|
+
top: e.clientY - containerRect.top + scrollTop,
|
|
4581
|
+
left: e.clientX - containerRect.left + scrollLeft
|
|
4582
|
+
};
|
|
4583
|
+
}
|
|
4584
|
+
services?.editorService.add(config, page.value);
|
|
4585
|
+
}
|
|
4586
|
+
}
|
|
4400
4587
|
};
|
|
4401
4588
|
}
|
|
4402
4589
|
});
|
|
@@ -4414,14 +4601,13 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4414
4601
|
createElementVNode("div", {
|
|
4415
4602
|
class: "m-editor-stage-container",
|
|
4416
4603
|
ref: "stageContainer",
|
|
4604
|
+
style: normalizeStyle(`transform: scale(${_ctx.zoom})`),
|
|
4417
4605
|
onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
|
|
4418
|
-
|
|
4606
|
+
onDrop: _cache[1] || (_cache[1] = (...args) => _ctx.dropHandler && _ctx.dropHandler(...args)),
|
|
4607
|
+
onDragover: _cache[2] || (_cache[2] = (...args) => _ctx.dragoverHandler && _ctx.dragoverHandler(...args))
|
|
4419
4608
|
}, null, 36),
|
|
4420
4609
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
4421
|
-
createVNode(_component_viewer_menu, {
|
|
4422
|
-
ref: "menu",
|
|
4423
|
-
style: normalizeStyle(_ctx.menuStyle)
|
|
4424
|
-
}, null, 8, ["style"])
|
|
4610
|
+
createVNode(_component_viewer_menu, { ref: "menu" }, null, 512)
|
|
4425
4611
|
]))
|
|
4426
4612
|
]),
|
|
4427
4613
|
_: 1
|
|
@@ -4468,10 +4654,10 @@ const _sfc_main$1 = defineComponent({
|
|
|
4468
4654
|
}).keydown([ctrl, "c"], (e) => {
|
|
4469
4655
|
e.inputEvent.preventDefault();
|
|
4470
4656
|
node.value && services?.editorService.copy(node.value);
|
|
4471
|
-
}).
|
|
4657
|
+
}).keydown([ctrl, "v"], (e) => {
|
|
4472
4658
|
e.inputEvent.preventDefault();
|
|
4473
4659
|
node.value && services?.editorService.paste();
|
|
4474
|
-
}).
|
|
4660
|
+
}).keydown([ctrl, "x"], (e) => {
|
|
4475
4661
|
e.inputEvent.preventDefault();
|
|
4476
4662
|
if (!node.value || isPage(node.value))
|
|
4477
4663
|
return;
|
|
@@ -4850,5 +5036,5 @@ var index = {
|
|
|
4850
5036
|
}
|
|
4851
5037
|
};
|
|
4852
5038
|
|
|
4853
|
-
export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, generateId, generatePageName, generatePageNameByApp, getConfig, getDefaultPropsValue, getNodeIndex, getPageList, getPageNameList, historyService, info, initPosition, isFixed, log, propsService, setConfig, setLayout, setNewItemId, toRelative, uiService, warn };
|
|
5039
|
+
export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, ToolButton, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, generateId, generatePageName, generatePageNameByApp, getConfig, getDefaultPropsValue, getNodeIndex, getPageList, getPageNameList, historyService, info, initPosition, isFixed, log, propsService, setConfig, setLayout, setNewItemId, toRelative, uiService, warn };
|
|
4854
5040
|
//# sourceMappingURL=tmagic-editor.es.js.map
|