@tmagic/editor 1.0.0-beta.7 → 1.0.0-rc.1
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/LICENSE +5432 -0
- package/README.md +1 -0
- package/coverage/clover.xml +1560 -0
- package/coverage/coverage-final.json +36 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +206 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/Editor.vue.html +787 -0
- package/coverage/lcov-report/src/components/ContentMenu.vue.html +406 -0
- package/coverage/lcov-report/src/components/Icon.vue.html +172 -0
- package/coverage/lcov-report/src/components/ScrollViewer.vue.html +283 -0
- package/coverage/lcov-report/src/components/ToolButton.vue.html +772 -0
- package/coverage/lcov-report/src/components/index.html +161 -0
- package/coverage/lcov-report/src/index.html +131 -0
- package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +214 -0
- package/coverage/lcov-report/src/layouts/Framework.vue.html +304 -0
- package/coverage/lcov-report/src/layouts/NavMenu.vue.html +208 -0
- package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +319 -0
- package/coverage/lcov-report/src/layouts/Resizer.vue.html +268 -0
- package/coverage/lcov-report/src/layouts/index.html +176 -0
- package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +358 -0
- package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +421 -0
- package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +775 -0
- package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +226 -0
- package/coverage/lcov-report/src/layouts/sidebar/TabPane.vue.html +289 -0
- package/coverage/lcov-report/src/layouts/sidebar/index.html +176 -0
- package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +718 -0
- package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +757 -0
- package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +532 -0
- package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +586 -0
- package/coverage/lcov-report/src/layouts/workspace/index.html +161 -0
- package/coverage/lcov-report/src/services/BaseService.ts.html +643 -0
- package/coverage/lcov-report/src/services/componentList.ts.html +229 -0
- package/coverage/lcov-report/src/services/editor.ts.html +2077 -0
- package/coverage/lcov-report/src/services/events.ts.html +331 -0
- package/coverage/lcov-report/src/services/history.ts.html +478 -0
- package/coverage/lcov-report/src/services/index.html +206 -0
- package/coverage/lcov-report/src/services/props.ts.html +415 -0
- package/coverage/lcov-report/src/services/ui.ts.html +580 -0
- package/coverage/lcov-report/src/type.ts.html +850 -0
- package/coverage/lcov-report/src/utils/compose.ts.html +184 -0
- package/coverage/lcov-report/src/utils/config.ts.html +172 -0
- package/coverage/lcov-report/src/utils/editor.ts.html +838 -0
- package/coverage/lcov-report/src/utils/index.html +221 -0
- package/coverage/lcov-report/src/utils/index.ts.html +151 -0
- package/coverage/lcov-report/src/utils/logger.ts.html +226 -0
- package/coverage/lcov-report/src/utils/props.ts.html +796 -0
- package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +733 -0
- package/coverage/lcov-report/src/utils/undo-redo.ts.html +313 -0
- package/coverage/lcov.info +3708 -0
- package/dist/style.css +94 -38
- package/dist/tmagic-editor.es.js +1474 -817
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +1475 -819
- 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/fields/UISelect.vue.d.ts +4 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/layouts/CodeEditor.vue.d.ts +13 -4
- package/dist/types/src/layouts/PropsPanel.vue.d.ts +2 -1
- package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +2 -1
- package/dist/types/src/layouts/sidebar/Sidebar.vue.d.ts +2 -3
- package/dist/types/src/layouts/sidebar/TabPane.vue.d.ts +14 -0
- package/dist/types/src/layouts/workspace/PageBar.vue.d.ts +10 -3
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +4 -6
- package/dist/types/src/services/BaseService.d.ts +4 -1
- package/dist/types/src/services/editor.d.ts +16 -6
- package/dist/types/src/services/history.d.ts +1 -0
- package/dist/types/src/services/props.d.ts +2 -2
- package/dist/types/src/services/ui.d.ts +2 -0
- package/dist/types/src/type.d.ts +16 -9
- package/dist/types/src/utils/editor.d.ts +5 -4
- package/dist/types/src/utils/polyfills.d.ts +0 -0
- package/package.json +37 -12
- package/src/components/ContentMenu.vue +107 -0
- package/src/components/ScrollViewer.vue +1 -1
- package/src/components/ToolButton.vue +72 -31
- package/src/fields/UISelect.vue +14 -6
- package/src/index.ts +2 -0
- package/src/layouts/AddPageBox.vue +3 -1
- package/src/layouts/CodeEditor.vue +20 -10
- package/src/layouts/Framework.vue +6 -6
- package/src/layouts/PropsPanel.vue +5 -3
- package/src/layouts/sidebar/ComponentListPanel.vue +25 -3
- package/src/layouts/sidebar/LayerMenu.vue +91 -96
- package/src/layouts/sidebar/LayerPanel.vue +80 -59
- package/src/layouts/sidebar/Sidebar.vue +13 -52
- package/src/layouts/sidebar/TabPane.vue +68 -0
- package/src/layouts/workspace/PageBar.vue +145 -17
- package/src/layouts/workspace/Stage.vue +55 -64
- package/src/layouts/workspace/ViewerMenu.vue +107 -68
- package/src/layouts/workspace/Workspace.vue +106 -18
- package/src/services/BaseService.ts +70 -22
- package/src/services/editor.ts +198 -63
- package/src/services/history.ts +7 -0
- package/src/services/props.ts +3 -3
- package/src/services/ui.ts +35 -5
- package/src/theme/common/var.scss +3 -2
- package/src/theme/component-list-panel.scss +2 -0
- package/src/theme/content-menu.scss +33 -26
- package/src/theme/layer-panel.scss +10 -0
- package/src/theme/nav-menu.scss +6 -2
- package/src/theme/page-bar.scss +42 -2
- package/src/theme/props-panel.scss +20 -6
- package/src/type.ts +17 -9
- package/src/utils/editor.ts +35 -9
- package/{vite.config.ts → src/utils/polyfills.ts} +4 -12
- package/src/utils/props.ts +20 -1
- package/dist/types/src/layouts/sidebar/LayerMenu.vue.d.ts +0 -31
- package/dist/types/src/layouts/sidebar/LayerPanel.vue.d.ts +0 -973
- package/dist/types/src/layouts/workspace/Stage.vue.d.ts +0 -192
- package/dist/types/src/layouts/workspace/ViewerMenu.vue.d.ts +0 -18
- package/tsconfig.json +0 -9
package/dist/tmagic-editor.es.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, createElementBlock,
|
|
1
|
+
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, markRaw, createElementBlock, createVNode, withCtx, withModifiers, createCommentVNode, createTextVNode, toDisplayString, watch, onMounted, onUnmounted, reactive, toRaw, createElementVNode, renderSlot, Fragment, normalizeClass, resolveDynamicComponent, renderList, normalizeProps, mergeProps, getCurrentInstance, nextTick, withDirectives, Teleport, vShow, toHandlers, createSlots, provide } from 'vue';
|
|
2
2
|
import serialize from 'serialize-javascript';
|
|
3
|
+
import { Delete, Pointer, Close, Plus, Edit, ArrowDown, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Files, DocumentCopy, Coin, ArrowLeftBold, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons';
|
|
4
|
+
import { throttle, cloneDeep, mergeWith, random } from 'lodash-es';
|
|
3
5
|
import * as monaco from 'monaco-editor';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { toLine, isPop, getNodePath } from '@tmagic/utils';
|
|
6
|
+
import { NodeType } from '@tmagic/schema';
|
|
7
|
+
import { toLine, isPop, getNodePath, isNumber, isPage } from '@tmagic/utils';
|
|
7
8
|
import { EventEmitter as EventEmitter$2 } from 'events';
|
|
8
9
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
9
10
|
import { ElMessage } from 'element-plus';
|
|
11
|
+
import KeyController from 'keycon';
|
|
10
12
|
import StageCore from '@tmagic/stage';
|
|
11
13
|
|
|
14
|
+
if (typeof window.global === "undefined") {
|
|
15
|
+
window.global = window;
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
var _export_sfc = (sfc, props) => {
|
|
13
19
|
const target = sfc.__vccOpts || sfc;
|
|
14
20
|
for (const [key, val] of props) {
|
|
@@ -17,7 +23,7 @@ var _export_sfc = (sfc, props) => {
|
|
|
17
23
|
return target;
|
|
18
24
|
};
|
|
19
25
|
|
|
20
|
-
const _sfc_main$
|
|
26
|
+
const _sfc_main$m = defineComponent({
|
|
21
27
|
name: "m-fields-vs-code",
|
|
22
28
|
props: ["model", "name", "config", "prop"],
|
|
23
29
|
emits: ["change"],
|
|
@@ -34,7 +40,7 @@ const _sfc_main$k = defineComponent({
|
|
|
34
40
|
};
|
|
35
41
|
}
|
|
36
42
|
});
|
|
37
|
-
function _sfc_render$
|
|
43
|
+
function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) {
|
|
38
44
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
39
45
|
return openBlock(), createBlock(_component_magic_code_editor, {
|
|
40
46
|
style: normalizeStyle(`height: ${_ctx.height}`),
|
|
@@ -43,9 +49,9 @@ function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
43
49
|
onSave: _ctx.save
|
|
44
50
|
}, null, 8, ["style", "init-values", "language", "onSave"]);
|
|
45
51
|
}
|
|
46
|
-
var Code = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
52
|
+
var Code = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$m]]);
|
|
47
53
|
|
|
48
|
-
const _sfc_main$
|
|
54
|
+
const _sfc_main$l = defineComponent({
|
|
49
55
|
name: "m-fields-code-link",
|
|
50
56
|
props: {
|
|
51
57
|
config: {
|
|
@@ -100,7 +106,7 @@ const _sfc_main$j = defineComponent({
|
|
|
100
106
|
};
|
|
101
107
|
}
|
|
102
108
|
});
|
|
103
|
-
function _sfc_render$
|
|
109
|
+
function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) {
|
|
104
110
|
const _component_m_fields_link = resolveComponent("m-fields-link");
|
|
105
111
|
return openBlock(), createBlock(_component_m_fields_link, {
|
|
106
112
|
config: _ctx.formConfig,
|
|
@@ -109,11 +115,11 @@ function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
109
115
|
onChange: _ctx.changeHandler
|
|
110
116
|
}, null, 8, ["config", "model", "onChange"]);
|
|
111
117
|
}
|
|
112
|
-
var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
118
|
+
var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$l]]);
|
|
113
119
|
|
|
114
120
|
var UISelect_vue_vue_type_style_index_0_lang = '';
|
|
115
121
|
|
|
116
|
-
const _sfc_main$
|
|
122
|
+
const _sfc_main$k = defineComponent({
|
|
117
123
|
name: "m-fields-ui-select",
|
|
118
124
|
props: {
|
|
119
125
|
labelWidth: String,
|
|
@@ -151,6 +157,9 @@ const _sfc_main$i = defineComponent({
|
|
|
151
157
|
}
|
|
152
158
|
};
|
|
153
159
|
return {
|
|
160
|
+
Delete: markRaw(Delete),
|
|
161
|
+
Pointer: markRaw(Pointer),
|
|
162
|
+
Close: markRaw(Close),
|
|
154
163
|
val,
|
|
155
164
|
uiSelectMode,
|
|
156
165
|
toName: computed(() => {
|
|
@@ -175,34 +184,64 @@ const _sfc_main$i = defineComponent({
|
|
|
175
184
|
};
|
|
176
185
|
}
|
|
177
186
|
});
|
|
178
|
-
const _hoisted_1$
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const _hoisted_2$7 = [
|
|
183
|
-
_hoisted_1$d
|
|
184
|
-
];
|
|
185
|
-
const _hoisted_3$5 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-thumb" }, null, -1);
|
|
186
|
-
function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
187
|
+
const _hoisted_1$c = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
|
|
188
|
+
function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
|
|
189
|
+
const _component_el_button = resolveComponent("el-button");
|
|
190
|
+
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
187
191
|
return _ctx.uiSelectMode ? (openBlock(), createElementBlock("div", {
|
|
188
192
|
key: 0,
|
|
189
193
|
class: "m-fields-ui-select",
|
|
190
194
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.cancelHandler && _ctx.cancelHandler(...args))
|
|
191
|
-
},
|
|
195
|
+
}, [
|
|
196
|
+
createVNode(_component_el_button, {
|
|
197
|
+
type: "danger",
|
|
198
|
+
icon: _ctx.Delete,
|
|
199
|
+
text: "",
|
|
200
|
+
style: { "padding": "0" }
|
|
201
|
+
}, {
|
|
202
|
+
default: withCtx(() => [
|
|
203
|
+
_hoisted_1$c
|
|
204
|
+
]),
|
|
205
|
+
_: 1
|
|
206
|
+
}, 8, ["icon"])
|
|
207
|
+
])) : (openBlock(), createElementBlock("div", {
|
|
192
208
|
key: 1,
|
|
193
209
|
class: "m-fields-ui-select",
|
|
194
|
-
onClick: _cache[
|
|
210
|
+
onClick: _cache[1] || (_cache[1] = (...args) => _ctx.startSelect && _ctx.startSelect(...args)),
|
|
211
|
+
style: { "display": "flex" }
|
|
195
212
|
}, [
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
213
|
+
createVNode(_component_el_tooltip, { content: "\u6E05\u9664" }, {
|
|
214
|
+
default: withCtx(() => [
|
|
215
|
+
_ctx.val ? (openBlock(), createBlock(_component_el_button, {
|
|
216
|
+
key: 0,
|
|
217
|
+
style: { "padding": "0" },
|
|
218
|
+
type: "danger",
|
|
219
|
+
icon: _ctx.Close,
|
|
220
|
+
text: "",
|
|
221
|
+
onClick: withModifiers(_ctx.deleteHandler, ["stop"])
|
|
222
|
+
}, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
|
|
223
|
+
]),
|
|
224
|
+
_: 1
|
|
225
|
+
}),
|
|
226
|
+
createVNode(_component_el_tooltip, {
|
|
227
|
+
content: _ctx.val ? _ctx.toName + "_" + _ctx.val : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
|
|
228
|
+
}, {
|
|
229
|
+
default: withCtx(() => [
|
|
230
|
+
createVNode(_component_el_button, {
|
|
231
|
+
text: "",
|
|
232
|
+
style: { "padding": "0", "margin": "0" }
|
|
233
|
+
}, {
|
|
234
|
+
default: withCtx(() => [
|
|
235
|
+
createTextVNode(toDisplayString(_ctx.val ? _ctx.toName + "_" + _ctx.val : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1)
|
|
236
|
+
]),
|
|
237
|
+
_: 1
|
|
238
|
+
})
|
|
239
|
+
]),
|
|
240
|
+
_: 1
|
|
241
|
+
}, 8, ["content"])
|
|
203
242
|
]));
|
|
204
243
|
}
|
|
205
|
-
var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
244
|
+
var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$k]]);
|
|
206
245
|
|
|
207
246
|
const toString = (v, language) => {
|
|
208
247
|
let value = "";
|
|
@@ -219,7 +258,7 @@ const toString = (v, language) => {
|
|
|
219
258
|
}
|
|
220
259
|
return value;
|
|
221
260
|
};
|
|
222
|
-
const _sfc_main$
|
|
261
|
+
const _sfc_main$j = defineComponent({
|
|
223
262
|
name: "magic-code-editor",
|
|
224
263
|
props: {
|
|
225
264
|
initValues: {
|
|
@@ -229,12 +268,16 @@ const _sfc_main$h = defineComponent({
|
|
|
229
268
|
type: [String, Object]
|
|
230
269
|
},
|
|
231
270
|
type: {
|
|
232
|
-
type:
|
|
271
|
+
type: String,
|
|
233
272
|
default: () => ""
|
|
234
273
|
},
|
|
235
274
|
language: {
|
|
236
|
-
type:
|
|
275
|
+
type: String,
|
|
237
276
|
default: () => "javascript"
|
|
277
|
+
},
|
|
278
|
+
options: {
|
|
279
|
+
type: Object,
|
|
280
|
+
default: () => ({})
|
|
238
281
|
}
|
|
239
282
|
},
|
|
240
283
|
emits: ["initd", "save"],
|
|
@@ -244,6 +287,10 @@ const _sfc_main$h = defineComponent({
|
|
|
244
287
|
const values = ref("");
|
|
245
288
|
const loading = ref(false);
|
|
246
289
|
const codeEditor = ref();
|
|
290
|
+
const resizeObserver = new globalThis.ResizeObserver(throttle(() => {
|
|
291
|
+
vsEditor?.layout();
|
|
292
|
+
vsDiffEditor?.layout();
|
|
293
|
+
}, 300));
|
|
247
294
|
const setEditorValue = (v, m) => {
|
|
248
295
|
values.value = toString(v, props.language);
|
|
249
296
|
if (props.type === "diff") {
|
|
@@ -256,10 +303,6 @@ const _sfc_main$h = defineComponent({
|
|
|
256
303
|
}
|
|
257
304
|
return vsEditor?.setValue(values.value);
|
|
258
305
|
};
|
|
259
|
-
const resizeHandler = () => {
|
|
260
|
-
vsEditor?.layout();
|
|
261
|
-
vsDiffEditor?.layout();
|
|
262
|
-
};
|
|
263
306
|
const getEditorValue = () => props.type === "diff" ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue();
|
|
264
307
|
const init = async () => {
|
|
265
308
|
if (!codeEditor.value)
|
|
@@ -270,8 +313,9 @@ const _sfc_main$h = defineComponent({
|
|
|
270
313
|
tabSize: 2,
|
|
271
314
|
theme: "vs-dark",
|
|
272
315
|
fontFamily: 'dm, Menlo, Monaco, "Courier New", monospace',
|
|
273
|
-
fontSize:
|
|
274
|
-
formatOnPaste: true
|
|
316
|
+
fontSize: 14,
|
|
317
|
+
formatOnPaste: true,
|
|
318
|
+
...props.options
|
|
275
319
|
};
|
|
276
320
|
if (props.type === "diff") {
|
|
277
321
|
vsDiffEditor = monaco.editor.createDiffEditor(codeEditor.value, options);
|
|
@@ -292,7 +336,7 @@ const _sfc_main$h = defineComponent({
|
|
|
292
336
|
emit("save", getEditorValue());
|
|
293
337
|
});
|
|
294
338
|
}
|
|
295
|
-
|
|
339
|
+
resizeObserver.observe(codeEditor.value);
|
|
296
340
|
};
|
|
297
341
|
watch(() => props.initValues, (v, preV) => {
|
|
298
342
|
if (v !== preV) {
|
|
@@ -307,7 +351,7 @@ const _sfc_main$h = defineComponent({
|
|
|
307
351
|
init();
|
|
308
352
|
});
|
|
309
353
|
onUnmounted(() => {
|
|
310
|
-
|
|
354
|
+
resizeObserver.disconnect();
|
|
311
355
|
});
|
|
312
356
|
return {
|
|
313
357
|
values,
|
|
@@ -324,14 +368,14 @@ const _sfc_main$h = defineComponent({
|
|
|
324
368
|
};
|
|
325
369
|
}
|
|
326
370
|
});
|
|
327
|
-
const _hoisted_1$
|
|
371
|
+
const _hoisted_1$b = {
|
|
328
372
|
ref: "codeEditor",
|
|
329
373
|
class: "magic-code-editor"
|
|
330
374
|
};
|
|
331
|
-
function _sfc_render$
|
|
332
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
375
|
+
function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
|
|
376
|
+
return openBlock(), createElementBlock("div", _hoisted_1$b, null, 512);
|
|
333
377
|
}
|
|
334
|
-
var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
378
|
+
var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$j]]);
|
|
335
379
|
|
|
336
380
|
let $TMAGIC_EDITOR = {};
|
|
337
381
|
const setConfig = (option) => {
|
|
@@ -340,9 +384,6 @@ const setConfig = (option) => {
|
|
|
340
384
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
341
385
|
|
|
342
386
|
class UndoRedo {
|
|
343
|
-
elementList;
|
|
344
|
-
listCursor;
|
|
345
|
-
listMaxSize;
|
|
346
387
|
constructor(listMaxSize = 200) {
|
|
347
388
|
const minListMaxSize = 2;
|
|
348
389
|
this.elementList = [];
|
|
@@ -415,11 +456,40 @@ const compose = (middleware) => {
|
|
|
415
456
|
|
|
416
457
|
const methodName = (prefix, name) => `${prefix}${name[0].toUpperCase()}${name.substring(1)}`;
|
|
417
458
|
const isError = (error) => Object.prototype.toString.call(error) === "[object Error]";
|
|
459
|
+
const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethodName, fn) => {
|
|
460
|
+
try {
|
|
461
|
+
let beforeArgs = args;
|
|
462
|
+
for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
|
|
463
|
+
let beforeReturnValue = await beforeMethod(...beforeArgs) || [];
|
|
464
|
+
if (isError(beforeReturnValue))
|
|
465
|
+
throw beforeReturnValue;
|
|
466
|
+
if (!Array.isArray(beforeReturnValue)) {
|
|
467
|
+
beforeReturnValue = [beforeReturnValue];
|
|
468
|
+
}
|
|
469
|
+
beforeArgs = beforeArgs.map((v, index) => {
|
|
470
|
+
if (typeof beforeReturnValue[index] === "undefined")
|
|
471
|
+
return v;
|
|
472
|
+
return beforeReturnValue[index];
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
|
|
476
|
+
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
477
|
+
returnValue = await afterMethod(returnValue, ...beforeArgs);
|
|
478
|
+
if (isError(returnValue))
|
|
479
|
+
throw returnValue;
|
|
480
|
+
}
|
|
481
|
+
return returnValue;
|
|
482
|
+
} catch (error) {
|
|
483
|
+
throw error;
|
|
484
|
+
}
|
|
485
|
+
};
|
|
418
486
|
class BaseService extends EventEmitter$2 {
|
|
419
|
-
|
|
420
|
-
middleware = {};
|
|
421
|
-
constructor(methods) {
|
|
487
|
+
constructor(methods = [], serialMethods = []) {
|
|
422
488
|
super();
|
|
489
|
+
this.pluginOptionsList = {};
|
|
490
|
+
this.middleware = {};
|
|
491
|
+
this.taskList = [];
|
|
492
|
+
this.doingTask = false;
|
|
423
493
|
methods.forEach((propertyName) => {
|
|
424
494
|
const scope = this;
|
|
425
495
|
const sourceMethod = scope[propertyName];
|
|
@@ -431,27 +501,23 @@ class BaseService extends EventEmitter$2 {
|
|
|
431
501
|
const fn = compose(this.middleware[propertyName]);
|
|
432
502
|
Object.defineProperty(scope, propertyName, {
|
|
433
503
|
value: async (...args) => {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
let beforeReturnValue = await beforeMethod(...beforeArgs) || [];
|
|
437
|
-
if (isError(beforeReturnValue))
|
|
438
|
-
throw beforeReturnValue;
|
|
439
|
-
if (!Array.isArray(beforeReturnValue)) {
|
|
440
|
-
beforeReturnValue = [beforeReturnValue];
|
|
441
|
-
}
|
|
442
|
-
beforeArgs = beforeArgs.map((v, index) => {
|
|
443
|
-
if (typeof beforeReturnValue[index] === "undefined")
|
|
444
|
-
return v;
|
|
445
|
-
return beforeReturnValue[index];
|
|
446
|
-
});
|
|
504
|
+
if (!serialMethods.includes(propertyName)) {
|
|
505
|
+
return doAction(args, scope, sourceMethod, beforeMethodName, afterMethodName, fn);
|
|
447
506
|
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
507
|
+
const promise = new Promise((resolve, reject) => {
|
|
508
|
+
this.taskList.push(async () => {
|
|
509
|
+
try {
|
|
510
|
+
const value = await doAction(args, scope, sourceMethod, beforeMethodName, afterMethodName, fn);
|
|
511
|
+
resolve(value);
|
|
512
|
+
} catch (e) {
|
|
513
|
+
reject(e);
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
});
|
|
517
|
+
if (!this.doingTask) {
|
|
518
|
+
this.doTask();
|
|
453
519
|
}
|
|
454
|
-
return
|
|
520
|
+
return promise;
|
|
455
521
|
}
|
|
456
522
|
});
|
|
457
523
|
});
|
|
@@ -468,19 +534,34 @@ class BaseService extends EventEmitter$2 {
|
|
|
468
534
|
this.pluginOptionsList[methodName2].push(method);
|
|
469
535
|
});
|
|
470
536
|
}
|
|
537
|
+
async doTask() {
|
|
538
|
+
this.doingTask = true;
|
|
539
|
+
let task = this.taskList.shift();
|
|
540
|
+
while (task) {
|
|
541
|
+
await task();
|
|
542
|
+
task = this.taskList.shift();
|
|
543
|
+
}
|
|
544
|
+
this.doingTask = false;
|
|
545
|
+
}
|
|
471
546
|
}
|
|
472
547
|
|
|
473
548
|
class History extends BaseService {
|
|
474
|
-
state = reactive({
|
|
475
|
-
pageSteps: {},
|
|
476
|
-
pageId: void 0,
|
|
477
|
-
canRedo: false,
|
|
478
|
-
canUndo: false
|
|
479
|
-
});
|
|
480
549
|
constructor() {
|
|
481
550
|
super([]);
|
|
551
|
+
this.state = reactive({
|
|
552
|
+
pageSteps: {},
|
|
553
|
+
pageId: void 0,
|
|
554
|
+
canRedo: false,
|
|
555
|
+
canUndo: false
|
|
556
|
+
});
|
|
482
557
|
this.on("change", this.setCanUndoRedo);
|
|
483
558
|
}
|
|
559
|
+
reset() {
|
|
560
|
+
this.state.pageSteps = {};
|
|
561
|
+
this.state.pageId = void 0;
|
|
562
|
+
this.state.canRedo = false;
|
|
563
|
+
this.state.canUndo = false;
|
|
564
|
+
}
|
|
484
565
|
changePage(page) {
|
|
485
566
|
if (!page)
|
|
486
567
|
return;
|
|
@@ -544,12 +625,12 @@ class History extends BaseService {
|
|
|
544
625
|
var historyService = new History();
|
|
545
626
|
|
|
546
627
|
class Props extends BaseService {
|
|
547
|
-
state = reactive({
|
|
548
|
-
propsConfigMap: {},
|
|
549
|
-
propsValueMap: {}
|
|
550
|
-
});
|
|
551
628
|
constructor() {
|
|
552
629
|
super(["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue"]);
|
|
630
|
+
this.state = reactive({
|
|
631
|
+
propsConfigMap: {},
|
|
632
|
+
propsValueMap: {}
|
|
633
|
+
});
|
|
553
634
|
}
|
|
554
635
|
setPropsConfigs(configs) {
|
|
555
636
|
Object.keys(configs).forEach((type) => {
|
|
@@ -574,7 +655,7 @@ class Props extends BaseService {
|
|
|
574
655
|
setPropsValue(type, value) {
|
|
575
656
|
this.state.propsValueMap[type] = value;
|
|
576
657
|
}
|
|
577
|
-
async getPropsValue(type) {
|
|
658
|
+
async getPropsValue(type, defaultValue = {}) {
|
|
578
659
|
if (type === "area") {
|
|
579
660
|
const value = await this.getPropsValue("button");
|
|
580
661
|
value.className = "action-area";
|
|
@@ -586,7 +667,7 @@ class Props extends BaseService {
|
|
|
586
667
|
}
|
|
587
668
|
return cloneDeep({
|
|
588
669
|
...getDefaultPropsValue(type),
|
|
589
|
-
...this.state.propsValueMap[type] || {}
|
|
670
|
+
...mergeWith(this.state.propsValueMap[type] || {}, defaultValue)
|
|
590
671
|
});
|
|
591
672
|
}
|
|
592
673
|
}
|
|
@@ -613,7 +694,7 @@ const COPY_STORAGE_KEY = "$MagicEditorCopyData";
|
|
|
613
694
|
const generateId = (type) => `${type}_${random(1e4, false)}`;
|
|
614
695
|
const getPageList = (app) => {
|
|
615
696
|
if (app.items && Array.isArray(app.items)) {
|
|
616
|
-
return app.items.filter((item) => item.type ===
|
|
697
|
+
return app.items.filter((item) => item.type === NodeType.PAGE);
|
|
617
698
|
}
|
|
618
699
|
return [];
|
|
619
700
|
};
|
|
@@ -647,9 +728,9 @@ const updatePopId = (oldId, popId, pageConfig) => {
|
|
|
647
728
|
};
|
|
648
729
|
const setNewItemId = (config, parent) => {
|
|
649
730
|
const oldId = config.id;
|
|
650
|
-
config.id = generateId(config.type);
|
|
731
|
+
config.id = generateId(config.type || "component");
|
|
651
732
|
config.name = `${config.name?.replace(/_(\d+)$/, "")}_${config.id}`;
|
|
652
|
-
if (isPop(config) && parent?.type ===
|
|
733
|
+
if (isPop(config) && parent?.type === NodeType.PAGE) {
|
|
653
734
|
updatePopId(oldId, config.id, parent);
|
|
654
735
|
}
|
|
655
736
|
if (config.items && Array.isArray(config.items)) {
|
|
@@ -670,11 +751,25 @@ const toRelative = (node) => {
|
|
|
670
751
|
};
|
|
671
752
|
return node;
|
|
672
753
|
};
|
|
673
|
-
const
|
|
754
|
+
const setTop2Middle = (node, parentNode, stage) => {
|
|
755
|
+
const style = node.style || {};
|
|
756
|
+
const height = style.height || 0;
|
|
757
|
+
if (!stage || typeof style.top !== "undefined" || !parentNode.style || !isNumber(height))
|
|
758
|
+
return style;
|
|
759
|
+
const { height: parentHeight } = parentNode.style;
|
|
760
|
+
if (isPage(parentNode)) {
|
|
761
|
+
const { scrollTop = 0, wrapperHeight } = stage.mask;
|
|
762
|
+
style.top = (wrapperHeight - height) / 2 + scrollTop;
|
|
763
|
+
} else {
|
|
764
|
+
style.top = (parentHeight - height) / 2;
|
|
765
|
+
}
|
|
766
|
+
return style;
|
|
767
|
+
};
|
|
768
|
+
const initPosition = (node, layout, parentNode, stage) => {
|
|
674
769
|
if (layout === Layout.ABSOLUTE) {
|
|
675
770
|
node.style = {
|
|
676
771
|
position: "absolute",
|
|
677
|
-
...node
|
|
772
|
+
...setTop2Middle(node, parentNode, stage)
|
|
678
773
|
};
|
|
679
774
|
return node;
|
|
680
775
|
}
|
|
@@ -721,7 +816,9 @@ const Fixed2Other = async (node, root, getLayout) => {
|
|
|
721
816
|
const cur = path.pop();
|
|
722
817
|
const offset = {
|
|
723
818
|
left: cur?.style?.left || 0,
|
|
724
|
-
top: cur?.style?.top || 0
|
|
819
|
+
top: cur?.style?.top || 0,
|
|
820
|
+
right: "",
|
|
821
|
+
bottom: ""
|
|
725
822
|
};
|
|
726
823
|
path.forEach((value) => {
|
|
727
824
|
offset.left = offset.left - globalThis.parseFloat(value.style?.left || 0);
|
|
@@ -755,15 +852,6 @@ const error = (...args) => {
|
|
|
755
852
|
};
|
|
756
853
|
|
|
757
854
|
class Editor$1 extends BaseService {
|
|
758
|
-
isHistoryStateChange = false;
|
|
759
|
-
state = reactive({
|
|
760
|
-
root: null,
|
|
761
|
-
page: null,
|
|
762
|
-
parent: null,
|
|
763
|
-
node: null,
|
|
764
|
-
stage: null,
|
|
765
|
-
modifiedNodeIds: /* @__PURE__ */ new Map()
|
|
766
|
-
});
|
|
767
855
|
constructor() {
|
|
768
856
|
super([
|
|
769
857
|
"getLayout",
|
|
@@ -776,13 +864,27 @@ class Editor$1 extends BaseService {
|
|
|
776
864
|
"paste",
|
|
777
865
|
"alignCenter",
|
|
778
866
|
"moveLayer",
|
|
867
|
+
"move",
|
|
779
868
|
"undo",
|
|
780
|
-
"redo"
|
|
781
|
-
|
|
869
|
+
"redo",
|
|
870
|
+
"highlight"
|
|
871
|
+
], ["select", "update", "moveLayer"]);
|
|
872
|
+
this.isHistoryStateChange = false;
|
|
873
|
+
this.state = reactive({
|
|
874
|
+
root: null,
|
|
875
|
+
page: null,
|
|
876
|
+
parent: null,
|
|
877
|
+
node: null,
|
|
878
|
+
stage: null,
|
|
879
|
+
highlightNode: null,
|
|
880
|
+
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
881
|
+
pageLength: 0
|
|
882
|
+
});
|
|
782
883
|
}
|
|
783
884
|
set(name, value) {
|
|
784
885
|
this.state[name] = value;
|
|
785
886
|
if (name === "root") {
|
|
887
|
+
this.state.pageLength = value?.items?.length || 0;
|
|
786
888
|
this.emit("root-change", value);
|
|
787
889
|
}
|
|
788
890
|
}
|
|
@@ -790,7 +892,7 @@ class Editor$1 extends BaseService {
|
|
|
790
892
|
return this.state[name];
|
|
791
893
|
}
|
|
792
894
|
getNodeInfo(id) {
|
|
793
|
-
const root = this.get("root");
|
|
895
|
+
const root = toRaw(this.get("root"));
|
|
794
896
|
if (!root)
|
|
795
897
|
return {};
|
|
796
898
|
if (id === root.id) {
|
|
@@ -804,7 +906,7 @@ class Editor$1 extends BaseService {
|
|
|
804
906
|
info.node = path[path.length - 1];
|
|
805
907
|
info.parent = path[path.length - 2];
|
|
806
908
|
path.forEach((item) => {
|
|
807
|
-
if (item.type ===
|
|
909
|
+
if (item.type === NodeType.PAGE) {
|
|
808
910
|
info.page = item;
|
|
809
911
|
return;
|
|
810
912
|
}
|
|
@@ -821,31 +923,19 @@ class Editor$1 extends BaseService {
|
|
|
821
923
|
const { parent } = this.getNodeInfo(id);
|
|
822
924
|
return parent;
|
|
823
925
|
}
|
|
824
|
-
async getLayout(node) {
|
|
825
|
-
if (node
|
|
826
|
-
return
|
|
926
|
+
async getLayout(parent, node) {
|
|
927
|
+
if (node && typeof node !== "function" && isFixed(node))
|
|
928
|
+
return Layout.FIXED;
|
|
929
|
+
if (parent.layout) {
|
|
930
|
+
return parent.layout;
|
|
827
931
|
}
|
|
828
|
-
if (!
|
|
932
|
+
if (!parent.style?.position) {
|
|
829
933
|
return Layout.RELATIVE;
|
|
830
934
|
}
|
|
831
935
|
return Layout.ABSOLUTE;
|
|
832
936
|
}
|
|
833
937
|
async select(config2) {
|
|
834
|
-
|
|
835
|
-
if (typeof config2 === "string" || typeof config2 === "number") {
|
|
836
|
-
id = config2;
|
|
837
|
-
} else {
|
|
838
|
-
id = config2.id;
|
|
839
|
-
}
|
|
840
|
-
if (!id) {
|
|
841
|
-
throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
|
|
842
|
-
}
|
|
843
|
-
const { node, parent, page } = this.getNodeInfo(id);
|
|
844
|
-
if (!node)
|
|
845
|
-
throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
|
|
846
|
-
if (node.id === this.state.root?.id) {
|
|
847
|
-
throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
|
|
848
|
-
}
|
|
938
|
+
const { node, page, parent } = this.selectedConfigExceptionHandler(config2);
|
|
849
939
|
this.set("node", node);
|
|
850
940
|
this.set("page", page || null);
|
|
851
941
|
this.set("parent", parent || null);
|
|
@@ -854,12 +944,44 @@ class Editor$1 extends BaseService {
|
|
|
854
944
|
} else {
|
|
855
945
|
historyService.empty();
|
|
856
946
|
}
|
|
947
|
+
this.emit("select", node);
|
|
857
948
|
return node;
|
|
858
949
|
}
|
|
859
|
-
async
|
|
950
|
+
async selectNextNode() {
|
|
951
|
+
const node = toRaw(this.get("node"));
|
|
952
|
+
if (!node || isPage(node) || node.type === NodeType.ROOT)
|
|
953
|
+
return node;
|
|
954
|
+
const parent = toRaw(this.getParentById(node.id));
|
|
955
|
+
if (!parent)
|
|
956
|
+
return node;
|
|
957
|
+
const index = getNodeIndex(node, parent);
|
|
958
|
+
const nextNode = parent.items[index + 1] || parent.items[0];
|
|
959
|
+
await this.select(nextNode);
|
|
960
|
+
this.get("stage")?.select(nextNode.id);
|
|
961
|
+
return nextNode;
|
|
962
|
+
}
|
|
963
|
+
async selectNextPage() {
|
|
964
|
+
const root = toRaw(this.get("root"));
|
|
965
|
+
const page = toRaw(this.get("page"));
|
|
966
|
+
const index = getNodeIndex(page, root);
|
|
967
|
+
const nextPage = root.items[index + 1] || root.items[0];
|
|
968
|
+
await this.select(nextPage);
|
|
969
|
+
this.get("stage")?.select(nextPage.id);
|
|
970
|
+
return nextPage;
|
|
971
|
+
}
|
|
972
|
+
highlight(config2) {
|
|
973
|
+
const { node } = this.selectedConfigExceptionHandler(config2);
|
|
974
|
+
const currentHighlightNode = this.get("highlightNode");
|
|
975
|
+
if (currentHighlightNode === node)
|
|
976
|
+
return;
|
|
977
|
+
this.set("highlightNode", node);
|
|
978
|
+
}
|
|
979
|
+
async add(addNode, parent) {
|
|
980
|
+
const { type, ...config2 } = addNode;
|
|
860
981
|
const curNode = this.get("node");
|
|
861
982
|
let parentNode;
|
|
862
|
-
|
|
983
|
+
const isPage2 = type === NodeType.PAGE;
|
|
984
|
+
if (isPage2) {
|
|
863
985
|
parentNode = this.get("root");
|
|
864
986
|
} else if (parent && typeof parent !== "function") {
|
|
865
987
|
parentNode = parent;
|
|
@@ -870,16 +992,24 @@ class Editor$1 extends BaseService {
|
|
|
870
992
|
}
|
|
871
993
|
if (!parentNode)
|
|
872
994
|
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
873
|
-
const layout = await this.getLayout(parentNode);
|
|
874
|
-
const newNode = initPosition({ ...toRaw(await propsService.getPropsValue(type
|
|
875
|
-
if ((parentNode?.type ===
|
|
995
|
+
const layout = await this.getLayout(toRaw(parentNode), addNode);
|
|
996
|
+
const newNode = initPosition({ ...toRaw(await propsService.getPropsValue(type, config2)) }, layout, parentNode, this.get("stage"));
|
|
997
|
+
if ((parentNode?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && newNode.type !== NodeType.PAGE) {
|
|
876
998
|
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
877
999
|
}
|
|
878
1000
|
parentNode?.items?.push(newNode);
|
|
879
|
-
|
|
1001
|
+
const stage = this.get("stage");
|
|
1002
|
+
await stage?.add({ config: cloneDeep(newNode), root: cloneDeep(this.get("root")) });
|
|
880
1003
|
await this.select(newNode);
|
|
881
1004
|
this.addModifiedNodeId(newNode.id);
|
|
882
|
-
|
|
1005
|
+
if (!isPage2) {
|
|
1006
|
+
this.pushHistoryState();
|
|
1007
|
+
}
|
|
1008
|
+
stage?.select(newNode.id);
|
|
1009
|
+
if (isPage2) {
|
|
1010
|
+
this.state.pageLength += 1;
|
|
1011
|
+
}
|
|
1012
|
+
this.emit("add", newNode);
|
|
883
1013
|
return newNode;
|
|
884
1014
|
}
|
|
885
1015
|
async remove(node) {
|
|
@@ -895,14 +1025,31 @@ class Editor$1 extends BaseService {
|
|
|
895
1025
|
if (typeof index !== "number" || index === -1)
|
|
896
1026
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
897
1027
|
parent.items?.splice(index, 1);
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
1028
|
+
const stage = this.get("stage");
|
|
1029
|
+
stage?.remove({ id: node.id, root: this.get("root") });
|
|
1030
|
+
if (node.type === NodeType.PAGE) {
|
|
1031
|
+
this.state.pageLength -= 1;
|
|
1032
|
+
if (root.items[0]) {
|
|
1033
|
+
await this.select(root.items[0]);
|
|
1034
|
+
stage?.select(root.items[0].id);
|
|
1035
|
+
} else {
|
|
1036
|
+
this.set("node", null);
|
|
1037
|
+
this.set("parent", null);
|
|
1038
|
+
this.set("page", null);
|
|
1039
|
+
this.set("stage", null);
|
|
1040
|
+
this.set("highlightNode", null);
|
|
1041
|
+
this.resetModifiedNodeId();
|
|
1042
|
+
historyService.reset();
|
|
1043
|
+
this.emit("remove", node);
|
|
1044
|
+
return node;
|
|
1045
|
+
}
|
|
901
1046
|
} else {
|
|
902
1047
|
await this.select(parent);
|
|
1048
|
+
stage?.select(parent.id);
|
|
903
1049
|
}
|
|
904
1050
|
this.addModifiedNodeId(parent.id);
|
|
905
1051
|
this.pushHistoryState();
|
|
1052
|
+
this.emit("remove", node);
|
|
906
1053
|
return node;
|
|
907
1054
|
}
|
|
908
1055
|
async update(config2) {
|
|
@@ -920,7 +1067,7 @@ class Editor$1 extends BaseService {
|
|
|
920
1067
|
});
|
|
921
1068
|
if (!newConfig.type)
|
|
922
1069
|
throw new Error("\u914D\u7F6E\u7F3A\u5C11type\u503C");
|
|
923
|
-
if (newConfig.type ===
|
|
1070
|
+
if (newConfig.type === NodeType.ROOT) {
|
|
924
1071
|
this.set("root", newConfig);
|
|
925
1072
|
return newConfig;
|
|
926
1073
|
}
|
|
@@ -937,15 +1084,16 @@ class Editor$1 extends BaseService {
|
|
|
937
1084
|
newConfig = setLayout(newConfig, newLayout);
|
|
938
1085
|
}
|
|
939
1086
|
parentNodeItems[index] = newConfig;
|
|
940
|
-
if (newConfig.id === this.get("node").id) {
|
|
1087
|
+
if (`${newConfig.id}` === `${this.get("node").id}`) {
|
|
941
1088
|
this.set("node", newConfig);
|
|
942
1089
|
}
|
|
943
1090
|
this.get("stage")?.update({ config: cloneDeep(newConfig), root: this.get("root") });
|
|
944
|
-
if (newConfig.type ===
|
|
1091
|
+
if (newConfig.type === NodeType.PAGE) {
|
|
945
1092
|
this.set("page", newConfig);
|
|
946
1093
|
}
|
|
947
1094
|
this.addModifiedNodeId(newConfig.id);
|
|
948
1095
|
this.pushHistoryState();
|
|
1096
|
+
this.emit("update", newConfig);
|
|
949
1097
|
return newConfig;
|
|
950
1098
|
}
|
|
951
1099
|
async sort(id1, id2) {
|
|
@@ -958,6 +1106,7 @@ class Editor$1 extends BaseService {
|
|
|
958
1106
|
parent.items.splice(index2, 0, ...parent.items.splice(index1, 1));
|
|
959
1107
|
await this.update(parent);
|
|
960
1108
|
await this.select(node);
|
|
1109
|
+
this.get("stage")?.update({ config: cloneDeep(node), root: this.get("root") });
|
|
961
1110
|
this.addModifiedNodeId(parent.id);
|
|
962
1111
|
this.pushHistoryState();
|
|
963
1112
|
}
|
|
@@ -988,7 +1137,7 @@ class Editor$1 extends BaseService {
|
|
|
988
1137
|
async alignCenter(config2) {
|
|
989
1138
|
const parent = this.get("parent");
|
|
990
1139
|
const node = this.get("node");
|
|
991
|
-
const layout = await this.getLayout(parent);
|
|
1140
|
+
const layout = await this.getLayout(toRaw(parent), toRaw(node));
|
|
992
1141
|
if (layout === Layout.RELATIVE) {
|
|
993
1142
|
return;
|
|
994
1143
|
}
|
|
@@ -1025,6 +1174,26 @@ class Editor$1 extends BaseService {
|
|
|
1025
1174
|
await this.changeHistoryState(value);
|
|
1026
1175
|
return value;
|
|
1027
1176
|
}
|
|
1177
|
+
async move(left, top) {
|
|
1178
|
+
const node = toRaw(this.get("node"));
|
|
1179
|
+
if (!node || isPage(node))
|
|
1180
|
+
return;
|
|
1181
|
+
const { style, id } = node;
|
|
1182
|
+
if (!style || style.position !== "absolute")
|
|
1183
|
+
return;
|
|
1184
|
+
if (top && !isNumber(style.top))
|
|
1185
|
+
return;
|
|
1186
|
+
if (left && !isNumber(style.left))
|
|
1187
|
+
return;
|
|
1188
|
+
this.update({
|
|
1189
|
+
id,
|
|
1190
|
+
style: {
|
|
1191
|
+
...style,
|
|
1192
|
+
left: Number(style.left) + left,
|
|
1193
|
+
top: Number(style.top) + top
|
|
1194
|
+
}
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1028
1197
|
destroy() {
|
|
1029
1198
|
this.removeAllListeners();
|
|
1030
1199
|
this.set("root", null);
|
|
@@ -1057,7 +1226,12 @@ class Editor$1 extends BaseService {
|
|
|
1057
1226
|
this.isHistoryStateChange = true;
|
|
1058
1227
|
await this.update(value.data);
|
|
1059
1228
|
this.set("modifiedNodeIds", value.modifiedNodeIds);
|
|
1060
|
-
setTimeout(() =>
|
|
1229
|
+
setTimeout(async () => {
|
|
1230
|
+
if (!value.nodeId)
|
|
1231
|
+
return;
|
|
1232
|
+
await this.select(value.nodeId);
|
|
1233
|
+
this.get("stage")?.select(value.nodeId);
|
|
1234
|
+
}, 0);
|
|
1061
1235
|
}
|
|
1062
1236
|
async toggleFixedPosition(dist, src, root) {
|
|
1063
1237
|
let newConfig = cloneDeep(dist);
|
|
@@ -1070,6 +1244,28 @@ class Editor$1 extends BaseService {
|
|
|
1070
1244
|
}
|
|
1071
1245
|
return newConfig;
|
|
1072
1246
|
}
|
|
1247
|
+
selectedConfigExceptionHandler(config2) {
|
|
1248
|
+
let id;
|
|
1249
|
+
if (typeof config2 === "string" || typeof config2 === "number") {
|
|
1250
|
+
id = config2;
|
|
1251
|
+
} else {
|
|
1252
|
+
id = config2.id;
|
|
1253
|
+
}
|
|
1254
|
+
if (!id) {
|
|
1255
|
+
throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
|
|
1256
|
+
}
|
|
1257
|
+
const { node, parent, page } = this.getNodeInfo(id);
|
|
1258
|
+
if (!node)
|
|
1259
|
+
throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
|
|
1260
|
+
if (node.id === this.state.root?.id) {
|
|
1261
|
+
throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
|
|
1262
|
+
}
|
|
1263
|
+
return {
|
|
1264
|
+
node,
|
|
1265
|
+
parent,
|
|
1266
|
+
page
|
|
1267
|
+
};
|
|
1268
|
+
}
|
|
1073
1269
|
}
|
|
1074
1270
|
var editorService = new Editor$1();
|
|
1075
1271
|
|
|
@@ -1227,6 +1423,25 @@ const fillConfig = (config = []) => [
|
|
|
1227
1423
|
defaultValue: "100% 100%"
|
|
1228
1424
|
}
|
|
1229
1425
|
]
|
|
1426
|
+
},
|
|
1427
|
+
{
|
|
1428
|
+
type: "fieldset",
|
|
1429
|
+
legend: "\u5B57\u4F53",
|
|
1430
|
+
items: [
|
|
1431
|
+
{
|
|
1432
|
+
name: "color",
|
|
1433
|
+
text: "\u989C\u8272",
|
|
1434
|
+
type: "colorPicker"
|
|
1435
|
+
},
|
|
1436
|
+
{
|
|
1437
|
+
name: "fontSize",
|
|
1438
|
+
text: "\u5927\u5C0F"
|
|
1439
|
+
},
|
|
1440
|
+
{
|
|
1441
|
+
name: "fontWeight",
|
|
1442
|
+
text: "\u7C97\u7EC6"
|
|
1443
|
+
}
|
|
1444
|
+
]
|
|
1230
1445
|
}
|
|
1231
1446
|
]
|
|
1232
1447
|
}
|
|
@@ -1259,7 +1474,7 @@ const fillConfig = (config = []) => [
|
|
|
1259
1474
|
type: "select",
|
|
1260
1475
|
options: (mForm, { model }) => {
|
|
1261
1476
|
const node = editorService.getNodeById(model.to);
|
|
1262
|
-
if (!node)
|
|
1477
|
+
if (!node?.type)
|
|
1263
1478
|
return [];
|
|
1264
1479
|
return eventsService.getMethod(node.type).map((option) => ({
|
|
1265
1480
|
text: option.label,
|
|
@@ -1294,7 +1509,7 @@ const getDefaultPropsValue = (type) => ({
|
|
|
1294
1509
|
name: type
|
|
1295
1510
|
});
|
|
1296
1511
|
|
|
1297
|
-
const _sfc_main$
|
|
1512
|
+
const _sfc_main$i = defineComponent({
|
|
1298
1513
|
components: { Plus },
|
|
1299
1514
|
setup() {
|
|
1300
1515
|
const services = inject("services");
|
|
@@ -1304,21 +1519,21 @@ const _sfc_main$g = defineComponent({
|
|
|
1304
1519
|
if (!editorService)
|
|
1305
1520
|
return;
|
|
1306
1521
|
editorService.add({
|
|
1307
|
-
type:
|
|
1522
|
+
type: NodeType.PAGE,
|
|
1308
1523
|
name: generatePageNameByApp(toRaw(editorService.get("root")))
|
|
1309
1524
|
});
|
|
1310
1525
|
}
|
|
1311
1526
|
};
|
|
1312
1527
|
}
|
|
1313
1528
|
});
|
|
1314
|
-
const _hoisted_1$
|
|
1315
|
-
const _hoisted_2$
|
|
1316
|
-
const _hoisted_3$
|
|
1317
|
-
function _sfc_render$
|
|
1529
|
+
const _hoisted_1$a = { class: "m-editor-empty-panel" };
|
|
1530
|
+
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
1531
|
+
const _hoisted_3$2 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
1532
|
+
function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1318
1533
|
const _component_plus = resolveComponent("plus");
|
|
1319
1534
|
const _component_el_icon = resolveComponent("el-icon");
|
|
1320
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
1321
|
-
createElementVNode("div", _hoisted_2$
|
|
1535
|
+
return openBlock(), createElementBlock("div", _hoisted_1$a, [
|
|
1536
|
+
createElementVNode("div", _hoisted_2$4, [
|
|
1322
1537
|
createElementVNode("div", {
|
|
1323
1538
|
class: "m-editor-empty-button",
|
|
1324
1539
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
|
|
@@ -1331,12 +1546,12 @@ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1331
1546
|
_: 1
|
|
1332
1547
|
})
|
|
1333
1548
|
]),
|
|
1334
|
-
_hoisted_3$
|
|
1549
|
+
_hoisted_3$2
|
|
1335
1550
|
])
|
|
1336
1551
|
])
|
|
1337
1552
|
]);
|
|
1338
1553
|
}
|
|
1339
|
-
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1554
|
+
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
|
|
1340
1555
|
|
|
1341
1556
|
/*
|
|
1342
1557
|
Copyright (c) 2018 Daybrush
|
|
@@ -1740,8 +1955,8 @@ Copyright (c) 2019 Daybrush
|
|
|
1740
1955
|
name: gesto
|
|
1741
1956
|
license: MIT
|
|
1742
1957
|
author: Daybrush
|
|
1743
|
-
repository: git+https://github.com/daybrush/
|
|
1744
|
-
version: 1.
|
|
1958
|
+
repository: git+https://github.com/daybrush/gesto.git
|
|
1959
|
+
version: 1.7.0
|
|
1745
1960
|
*/
|
|
1746
1961
|
|
|
1747
1962
|
/*! *****************************************************************************
|
|
@@ -1910,19 +2125,6 @@ function () {
|
|
|
1910
2125
|
|
|
1911
2126
|
var __proto = ClientStore.prototype;
|
|
1912
2127
|
|
|
1913
|
-
__proto.addClients = function (clients) {
|
|
1914
|
-
if (clients === void 0) {
|
|
1915
|
-
clients = this.prevClients;
|
|
1916
|
-
}
|
|
1917
|
-
|
|
1918
|
-
var position = this.getPosition(clients);
|
|
1919
|
-
var deltaX = position.deltaX,
|
|
1920
|
-
deltaY = position.deltaY;
|
|
1921
|
-
this.movement += Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
1922
|
-
this.prevClients = clients;
|
|
1923
|
-
return position;
|
|
1924
|
-
};
|
|
1925
|
-
|
|
1926
2128
|
__proto.getAngle = function (clients) {
|
|
1927
2129
|
if (clients === void 0) {
|
|
1928
2130
|
clients = this.prevClients;
|
|
@@ -1939,8 +2141,17 @@ function () {
|
|
|
1939
2141
|
return getRotatiion(clients) - getRotatiion(this.startClients);
|
|
1940
2142
|
};
|
|
1941
2143
|
|
|
1942
|
-
__proto.getPosition = function (clients) {
|
|
1943
|
-
|
|
2144
|
+
__proto.getPosition = function (clients, isAdd) {
|
|
2145
|
+
if (clients === void 0) {
|
|
2146
|
+
clients = this.prevClients;
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
var position = getPosition(clients || this.prevClients, this.prevClients, this.startClients);
|
|
2150
|
+
var deltaX = position.deltaX,
|
|
2151
|
+
deltaY = position.deltaY;
|
|
2152
|
+
this.movement += Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
2153
|
+
this.prevClients = clients;
|
|
2154
|
+
return position;
|
|
1944
2155
|
};
|
|
1945
2156
|
|
|
1946
2157
|
__proto.getPositions = function (clients) {
|
|
@@ -1989,10 +2200,6 @@ function () {
|
|
|
1989
2200
|
client.clientX -= deltaX;
|
|
1990
2201
|
client.clientY -= deltaY;
|
|
1991
2202
|
});
|
|
1992
|
-
this.prevClients.forEach(function (client) {
|
|
1993
|
-
client.clientX -= deltaX;
|
|
1994
|
-
client.clientY -= deltaY;
|
|
1995
|
-
});
|
|
1996
2203
|
};
|
|
1997
2204
|
|
|
1998
2205
|
return ClientStore;
|
|
@@ -2031,6 +2238,7 @@ function (_super) {
|
|
|
2031
2238
|
_this.targets = [];
|
|
2032
2239
|
_this.prevTime = 0;
|
|
2033
2240
|
_this.doubleFlag = false;
|
|
2241
|
+
_this._dragFlag = false;
|
|
2034
2242
|
|
|
2035
2243
|
_this.onDragStart = function (e, isTrusted) {
|
|
2036
2244
|
if (isTrusted === void 0) {
|
|
@@ -2061,7 +2269,8 @@ function (_super) {
|
|
|
2061
2269
|
if (checkInput || activeElement === target) {
|
|
2062
2270
|
// force false or already focused.
|
|
2063
2271
|
return false;
|
|
2064
|
-
}
|
|
2272
|
+
} // no focus
|
|
2273
|
+
|
|
2065
2274
|
|
|
2066
2275
|
if (activeElement && hasContentEditable && activeElement.isContentEditable && activeElement.contains(target)) {
|
|
2067
2276
|
return false;
|
|
@@ -2077,6 +2286,7 @@ function (_super) {
|
|
|
2077
2286
|
_this.clientStores = [new ClientStore(getEventClients(e))];
|
|
2078
2287
|
_this.flag = true;
|
|
2079
2288
|
_this.isDrag = false;
|
|
2289
|
+
_this._dragFlag = true;
|
|
2080
2290
|
_this.datas = {};
|
|
2081
2291
|
|
|
2082
2292
|
if (preventRightClick && (e.which === 3 || e.button === 2)) {
|
|
@@ -2092,7 +2302,14 @@ function (_super) {
|
|
|
2092
2302
|
inputEvent: e,
|
|
2093
2303
|
isTrusted: isTrusted,
|
|
2094
2304
|
isDouble: _this.doubleFlag
|
|
2095
|
-
}, _this.getCurrentStore().getPosition()
|
|
2305
|
+
}, _this.getCurrentStore().getPosition(), {
|
|
2306
|
+
preventDefault: function () {
|
|
2307
|
+
e.preventDefault();
|
|
2308
|
+
},
|
|
2309
|
+
preventDrag: function () {
|
|
2310
|
+
_this._dragFlag = false;
|
|
2311
|
+
}
|
|
2312
|
+
}));
|
|
2096
2313
|
|
|
2097
2314
|
if (result === false) {
|
|
2098
2315
|
_this.initDrag();
|
|
@@ -2141,24 +2358,26 @@ function (_super) {
|
|
|
2141
2358
|
|
|
2142
2359
|
var result = _this.moveClients(clients, e, false);
|
|
2143
2360
|
|
|
2144
|
-
if (_this.
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2361
|
+
if (_this._dragFlag) {
|
|
2362
|
+
if (_this.pinchFlag || result.deltaX || result.deltaY) {
|
|
2363
|
+
var dragResult = _this.emit("drag", __assign({}, result, {
|
|
2364
|
+
isScroll: !!isScroll,
|
|
2365
|
+
inputEvent: e
|
|
2366
|
+
}));
|
|
2149
2367
|
|
|
2150
|
-
|
|
2151
|
-
|
|
2368
|
+
if (dragResult === false) {
|
|
2369
|
+
_this.stop();
|
|
2152
2370
|
|
|
2153
|
-
|
|
2371
|
+
return;
|
|
2372
|
+
}
|
|
2154
2373
|
}
|
|
2155
|
-
}
|
|
2156
2374
|
|
|
2157
|
-
|
|
2158
|
-
|
|
2375
|
+
if (_this.pinchFlag) {
|
|
2376
|
+
_this.onPinch(e, clients);
|
|
2377
|
+
}
|
|
2159
2378
|
}
|
|
2160
2379
|
|
|
2161
|
-
_this.getCurrentStore().
|
|
2380
|
+
_this.getCurrentStore().getPosition(clients, true);
|
|
2162
2381
|
};
|
|
2163
2382
|
|
|
2164
2383
|
_this.onDragEnd = function (e) {
|
|
@@ -2176,7 +2395,7 @@ function (_super) {
|
|
|
2176
2395
|
|
|
2177
2396
|
_this.flag = false;
|
|
2178
2397
|
|
|
2179
|
-
var position = _this.
|
|
2398
|
+
var position = _this._getPosition();
|
|
2180
2399
|
|
|
2181
2400
|
var currentTime = now();
|
|
2182
2401
|
var isDouble = !_this.isDrag && _this.doubleFlag;
|
|
@@ -2370,7 +2589,23 @@ function (_super) {
|
|
|
2370
2589
|
return this;
|
|
2371
2590
|
};
|
|
2372
2591
|
/**
|
|
2373
|
-
*
|
|
2592
|
+
* Get the current event state while dragging.
|
|
2593
|
+
*/
|
|
2594
|
+
|
|
2595
|
+
|
|
2596
|
+
__proto.getCurrentEvent = function (inputEvent) {
|
|
2597
|
+
return __assign({
|
|
2598
|
+
datas: this.datas
|
|
2599
|
+
}, this._getPosition(), {
|
|
2600
|
+
movement: this.getMovement(),
|
|
2601
|
+
isDrag: this.isDrag,
|
|
2602
|
+
isPinch: this.isPinch,
|
|
2603
|
+
isScroll: false,
|
|
2604
|
+
inputEvent: inputEvent
|
|
2605
|
+
});
|
|
2606
|
+
};
|
|
2607
|
+
/**
|
|
2608
|
+
* Get & Set the event data while dragging.
|
|
2374
2609
|
*/
|
|
2375
2610
|
|
|
2376
2611
|
|
|
@@ -2486,9 +2721,12 @@ function (_super) {
|
|
|
2486
2721
|
};
|
|
2487
2722
|
|
|
2488
2723
|
__proto.moveClients = function (clients, inputEvent, isAdd) {
|
|
2489
|
-
var
|
|
2490
|
-
|
|
2491
|
-
|
|
2724
|
+
var position = this._getPosition(clients, isAdd);
|
|
2725
|
+
|
|
2726
|
+
if (position.deltaX || position.deltaY) {
|
|
2727
|
+
this.isDrag = true;
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2492
2730
|
return __assign({
|
|
2493
2731
|
datas: this.datas
|
|
2494
2732
|
}, position, {
|
|
@@ -2500,12 +2738,31 @@ function (_super) {
|
|
|
2500
2738
|
});
|
|
2501
2739
|
};
|
|
2502
2740
|
|
|
2741
|
+
__proto._getPosition = function (clients, isAdd) {
|
|
2742
|
+
var store = this.getCurrentStore();
|
|
2743
|
+
var position = store.getPosition(clients, isAdd);
|
|
2744
|
+
|
|
2745
|
+
var _a = this.clientStores.slice(1).reduce(function (prev, cur) {
|
|
2746
|
+
var storePosition = cur.getPosition();
|
|
2747
|
+
prev.distX += storePosition.distX;
|
|
2748
|
+
prev.distY += storePosition.distY;
|
|
2749
|
+
return prev;
|
|
2750
|
+
}, position),
|
|
2751
|
+
distX = _a.distX,
|
|
2752
|
+
distY = _a.distY;
|
|
2753
|
+
|
|
2754
|
+
return __assign({}, position, {
|
|
2755
|
+
distX: distX,
|
|
2756
|
+
distY: distY
|
|
2757
|
+
});
|
|
2758
|
+
};
|
|
2759
|
+
|
|
2503
2760
|
return Gesto;
|
|
2504
2761
|
}(EventEmitter$1);
|
|
2505
2762
|
|
|
2506
2763
|
var Gesto$1 = Gesto;
|
|
2507
2764
|
|
|
2508
|
-
const _sfc_main$
|
|
2765
|
+
const _sfc_main$h = defineComponent({
|
|
2509
2766
|
name: "m-editor-resize",
|
|
2510
2767
|
props: {
|
|
2511
2768
|
type: {
|
|
@@ -2547,33 +2804,33 @@ const _sfc_main$f = defineComponent({
|
|
|
2547
2804
|
};
|
|
2548
2805
|
}
|
|
2549
2806
|
});
|
|
2550
|
-
const _hoisted_1$
|
|
2807
|
+
const _hoisted_1$9 = {
|
|
2551
2808
|
ref: "target",
|
|
2552
2809
|
class: "m-editor-resizer"
|
|
2553
2810
|
};
|
|
2554
|
-
function _sfc_render$
|
|
2555
|
-
return openBlock(), createElementBlock("span", _hoisted_1$
|
|
2811
|
+
function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2812
|
+
return openBlock(), createElementBlock("span", _hoisted_1$9, [
|
|
2556
2813
|
renderSlot(_ctx.$slots, "default")
|
|
2557
2814
|
], 512);
|
|
2558
2815
|
}
|
|
2559
|
-
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2816
|
+
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
|
|
2560
2817
|
|
|
2561
|
-
const _sfc_main$
|
|
2818
|
+
const _sfc_main$g = defineComponent({
|
|
2562
2819
|
components: {
|
|
2563
2820
|
AddPageBox,
|
|
2564
2821
|
Resizer
|
|
2565
2822
|
},
|
|
2566
2823
|
setup() {
|
|
2567
|
-
const
|
|
2568
|
-
const root = computed(() =>
|
|
2824
|
+
const { editorService, uiService } = inject("services") || {};
|
|
2825
|
+
const root = computed(() => editorService?.get("root"));
|
|
2569
2826
|
return {
|
|
2570
2827
|
root,
|
|
2571
|
-
pageLength: computed(() =>
|
|
2572
|
-
showSrc: computed(() =>
|
|
2573
|
-
columnWidth: computed(() =>
|
|
2828
|
+
pageLength: computed(() => editorService?.get("pageLength") || 0),
|
|
2829
|
+
showSrc: computed(() => uiService?.get("showSrc")),
|
|
2830
|
+
columnWidth: computed(() => uiService?.get("columnWidth")),
|
|
2574
2831
|
saveCode(value) {
|
|
2575
2832
|
try {
|
|
2576
|
-
|
|
2833
|
+
editorService?.set("root", eval(value));
|
|
2577
2834
|
} catch (e) {
|
|
2578
2835
|
console.error(e);
|
|
2579
2836
|
}
|
|
@@ -2581,24 +2838,24 @@ const _sfc_main$e = defineComponent({
|
|
|
2581
2838
|
};
|
|
2582
2839
|
}
|
|
2583
2840
|
});
|
|
2584
|
-
const _hoisted_1$
|
|
2585
|
-
const _hoisted_2$
|
|
2841
|
+
const _hoisted_1$8 = { class: "m-editor" };
|
|
2842
|
+
const _hoisted_2$3 = {
|
|
2586
2843
|
key: 1,
|
|
2587
2844
|
class: "m-editor-content"
|
|
2588
2845
|
};
|
|
2589
|
-
function _sfc_render$
|
|
2846
|
+
function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2590
2847
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
2591
2848
|
const _component_resizer = resolveComponent("resizer");
|
|
2592
2849
|
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
2593
2850
|
const _component_add_page_box = resolveComponent("add-page-box");
|
|
2594
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
2851
|
+
return openBlock(), createElementBlock("div", _hoisted_1$8, [
|
|
2595
2852
|
renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
2596
2853
|
_ctx.showSrc ? (openBlock(), createBlock(_component_magic_code_editor, {
|
|
2597
2854
|
key: 0,
|
|
2598
2855
|
class: "m-editor-content",
|
|
2599
2856
|
"init-values": _ctx.root,
|
|
2600
2857
|
onSave: _ctx.saveCode
|
|
2601
|
-
}, null, 8, ["init-values", "onSave"])) : (openBlock(), createElementBlock("div", _hoisted_2$
|
|
2858
|
+
}, null, 8, ["init-values", "onSave"])) : (openBlock(), createElementBlock("div", _hoisted_2$3, [
|
|
2602
2859
|
createElementVNode("div", {
|
|
2603
2860
|
class: "m-editor-framework-left",
|
|
2604
2861
|
style: normalizeStyle(`width: ${_ctx.columnWidth?.left}px`)
|
|
@@ -2631,9 +2888,9 @@ function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2631
2888
|
]))
|
|
2632
2889
|
]);
|
|
2633
2890
|
}
|
|
2634
|
-
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2891
|
+
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
|
|
2635
2892
|
|
|
2636
|
-
const _sfc_main$
|
|
2893
|
+
const _sfc_main$f = defineComponent({
|
|
2637
2894
|
name: "m-icon",
|
|
2638
2895
|
components: { Edit },
|
|
2639
2896
|
props: {
|
|
@@ -2647,8 +2904,8 @@ const _sfc_main$d = defineComponent({
|
|
|
2647
2904
|
};
|
|
2648
2905
|
}
|
|
2649
2906
|
});
|
|
2650
|
-
const _hoisted_1$
|
|
2651
|
-
function _sfc_render$
|
|
2907
|
+
const _hoisted_1$7 = ["src"];
|
|
2908
|
+
function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2652
2909
|
const _component_edit = resolveComponent("edit");
|
|
2653
2910
|
const _component_el_icon = resolveComponent("el-icon");
|
|
2654
2911
|
return !_ctx.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
|
|
@@ -2659,7 +2916,7 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2659
2916
|
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (openBlock(), createElementBlock("img", {
|
|
2660
2917
|
key: 1,
|
|
2661
2918
|
src: _ctx.icon
|
|
2662
|
-
}, null, 8, _hoisted_1$
|
|
2919
|
+
}, null, 8, _hoisted_1$7)) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
2663
2920
|
key: 2,
|
|
2664
2921
|
class: normalizeClass(_ctx.icon)
|
|
2665
2922
|
}, null, 2)) : (openBlock(), createBlock(_component_el_icon, { key: 3 }, {
|
|
@@ -2669,9 +2926,9 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2669
2926
|
_: 1
|
|
2670
2927
|
}));
|
|
2671
2928
|
}
|
|
2672
|
-
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2929
|
+
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
|
|
2673
2930
|
|
|
2674
|
-
const _sfc_main$
|
|
2931
|
+
const _sfc_main$e = defineComponent({
|
|
2675
2932
|
components: { MIcon, ArrowDown },
|
|
2676
2933
|
props: {
|
|
2677
2934
|
data: {
|
|
@@ -2681,16 +2938,20 @@ const _sfc_main$c = defineComponent({
|
|
|
2681
2938
|
type: "text",
|
|
2682
2939
|
display: false
|
|
2683
2940
|
})
|
|
2941
|
+
},
|
|
2942
|
+
eventType: {
|
|
2943
|
+
type: String,
|
|
2944
|
+
default: "click"
|
|
2684
2945
|
}
|
|
2685
2946
|
},
|
|
2686
2947
|
setup(props) {
|
|
2687
2948
|
const services = inject("services");
|
|
2688
2949
|
const uiService = services?.uiService;
|
|
2689
|
-
const zoomInHandler = () => uiService?.set("zoom", zoom.value + 0.1);
|
|
2690
|
-
const zoomOutHandler = () => uiService?.set("zoom", zoom.value - 0.1);
|
|
2691
2950
|
const zoom = computed(() => uiService?.get("zoom") ?? 1);
|
|
2692
2951
|
const showGuides = computed(() => uiService?.get("showGuides") ?? true);
|
|
2693
2952
|
const showRule = computed(() => uiService?.get("showRule") ?? true);
|
|
2953
|
+
const zoomInHandler = () => uiService?.zoom(0.1);
|
|
2954
|
+
const zoomOutHandler = () => uiService?.zoom(-0.1);
|
|
2694
2955
|
const item = computed(() => {
|
|
2695
2956
|
if (typeof props.data !== "string") {
|
|
2696
2957
|
return props.data;
|
|
@@ -2707,15 +2968,15 @@ const _sfc_main$c = defineComponent({
|
|
|
2707
2968
|
case "delete":
|
|
2708
2969
|
return {
|
|
2709
2970
|
type: "button",
|
|
2710
|
-
icon: Delete,
|
|
2971
|
+
icon: markRaw(Delete),
|
|
2711
2972
|
tooltip: "\u522A\u9664",
|
|
2712
|
-
disabled: () => services?.editorService.get("node")?.type ===
|
|
2973
|
+
disabled: () => services?.editorService.get("node")?.type === NodeType.PAGE,
|
|
2713
2974
|
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
2714
2975
|
};
|
|
2715
2976
|
case "undo":
|
|
2716
2977
|
return {
|
|
2717
2978
|
type: "button",
|
|
2718
|
-
icon: Back,
|
|
2979
|
+
icon: markRaw(Back),
|
|
2719
2980
|
tooltip: "\u540E\u9000",
|
|
2720
2981
|
disabled: () => !services?.historyService.state.canUndo,
|
|
2721
2982
|
handler: () => services?.editorService.undo()
|
|
@@ -2723,7 +2984,7 @@ const _sfc_main$c = defineComponent({
|
|
|
2723
2984
|
case "redo":
|
|
2724
2985
|
return {
|
|
2725
2986
|
type: "button",
|
|
2726
|
-
icon: Right,
|
|
2987
|
+
icon: markRaw(Right),
|
|
2727
2988
|
tooltip: "\u524D\u8FDB",
|
|
2728
2989
|
disabled: () => !services?.historyService.state.canRedo,
|
|
2729
2990
|
handler: () => services?.editorService.redo()
|
|
@@ -2731,28 +2992,28 @@ const _sfc_main$c = defineComponent({
|
|
|
2731
2992
|
case "zoom-in":
|
|
2732
2993
|
return {
|
|
2733
2994
|
type: "button",
|
|
2734
|
-
icon: ZoomIn,
|
|
2995
|
+
icon: markRaw(ZoomIn),
|
|
2735
2996
|
tooltip: "\u653E\u5927",
|
|
2736
2997
|
handler: zoomInHandler
|
|
2737
2998
|
};
|
|
2738
2999
|
case "zoom-out":
|
|
2739
3000
|
return {
|
|
2740
3001
|
type: "button",
|
|
2741
|
-
icon: ZoomOut,
|
|
3002
|
+
icon: markRaw(ZoomOut),
|
|
2742
3003
|
tooltip: "\u7E2E\u5C0F",
|
|
2743
3004
|
handler: zoomOutHandler
|
|
2744
3005
|
};
|
|
2745
3006
|
case "rule":
|
|
2746
3007
|
return {
|
|
2747
3008
|
type: "button",
|
|
2748
|
-
icon: ScaleToOriginal,
|
|
3009
|
+
icon: markRaw(ScaleToOriginal),
|
|
2749
3010
|
tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
|
|
2750
3011
|
handler: () => uiService?.set("showRule", !showRule.value)
|
|
2751
3012
|
};
|
|
2752
3013
|
case "guides":
|
|
2753
3014
|
return {
|
|
2754
3015
|
type: "button",
|
|
2755
|
-
icon: Grid,
|
|
3016
|
+
icon: markRaw(Grid),
|
|
2756
3017
|
tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
|
|
2757
3018
|
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
2758
3019
|
};
|
|
@@ -2773,9 +3034,16 @@ const _sfc_main$c = defineComponent({
|
|
|
2773
3034
|
}
|
|
2774
3035
|
return item.value.disabled;
|
|
2775
3036
|
});
|
|
3037
|
+
const buttonHandler = (item2, event) => {
|
|
3038
|
+
if (disabled.value)
|
|
3039
|
+
return;
|
|
3040
|
+
if (typeof item2.handler === "function" && services) {
|
|
3041
|
+
item2.handler?.(services, event);
|
|
3042
|
+
}
|
|
3043
|
+
};
|
|
2776
3044
|
return {
|
|
2777
|
-
ZoomIn,
|
|
2778
|
-
ZoomOut,
|
|
3045
|
+
ZoomIn: markRaw(ZoomIn),
|
|
3046
|
+
ZoomOut: markRaw(ZoomOut),
|
|
2779
3047
|
item,
|
|
2780
3048
|
zoom,
|
|
2781
3049
|
disabled,
|
|
@@ -2796,31 +3064,42 @@ const _sfc_main$c = defineComponent({
|
|
|
2796
3064
|
command.item.handler(services);
|
|
2797
3065
|
}
|
|
2798
3066
|
},
|
|
2799
|
-
|
|
2800
|
-
if (
|
|
3067
|
+
clickHandler(item2, event) {
|
|
3068
|
+
if (props.eventType !== "click")
|
|
3069
|
+
return;
|
|
3070
|
+
if (item2.type === "button") {
|
|
3071
|
+
buttonHandler(item2, event);
|
|
3072
|
+
}
|
|
3073
|
+
},
|
|
3074
|
+
mousedownHandler(item2, event) {
|
|
3075
|
+
if (props.eventType !== "mousedown")
|
|
2801
3076
|
return;
|
|
2802
|
-
if (
|
|
2803
|
-
item2
|
|
3077
|
+
if (item2.type === "button") {
|
|
3078
|
+
buttonHandler(item2, event);
|
|
3079
|
+
}
|
|
3080
|
+
},
|
|
3081
|
+
mouseupHandler(item2, event) {
|
|
3082
|
+
if (props.eventType !== "mouseup")
|
|
3083
|
+
return;
|
|
3084
|
+
if (item2.type === "button") {
|
|
3085
|
+
buttonHandler(item2, event);
|
|
2804
3086
|
}
|
|
2805
3087
|
}
|
|
2806
3088
|
};
|
|
2807
3089
|
}
|
|
2808
3090
|
});
|
|
2809
|
-
const _hoisted_1$
|
|
2810
|
-
key: 0,
|
|
2811
|
-
class: "menu-item"
|
|
2812
|
-
};
|
|
2813
|
-
const _hoisted_2$4 = {
|
|
3091
|
+
const _hoisted_1$6 = {
|
|
2814
3092
|
key: 1,
|
|
2815
3093
|
class: "menu-item-text"
|
|
2816
3094
|
};
|
|
2817
|
-
const
|
|
3095
|
+
const _hoisted_2$2 = {
|
|
2818
3096
|
class: "menu-item-text",
|
|
2819
3097
|
style: { "margin": "0 5px" }
|
|
2820
3098
|
};
|
|
2821
|
-
const
|
|
2822
|
-
function _sfc_render$
|
|
3099
|
+
const _hoisted_3$1 = { class: "el-dropdown-link menubar-menu-button" };
|
|
3100
|
+
function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2823
3101
|
const _component_el_divider = resolveComponent("el-divider");
|
|
3102
|
+
const _component_tool_button = resolveComponent("tool-button", true);
|
|
2824
3103
|
const _component_m_icon = resolveComponent("m-icon");
|
|
2825
3104
|
const _component_el_button = resolveComponent("el-button");
|
|
2826
3105
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
@@ -2829,48 +3108,70 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2829
3108
|
const _component_el_dropdown_item = resolveComponent("el-dropdown-item");
|
|
2830
3109
|
const _component_el_dropdown_menu = resolveComponent("el-dropdown-menu");
|
|
2831
3110
|
const _component_el_dropdown = resolveComponent("el-dropdown");
|
|
2832
|
-
return _ctx.display ? (openBlock(), createElementBlock("div",
|
|
3111
|
+
return _ctx.display ? (openBlock(), createElementBlock("div", {
|
|
3112
|
+
key: 0,
|
|
3113
|
+
class: normalizeClass(["menu-item", _ctx.item.type]),
|
|
3114
|
+
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.clickHandler(_ctx.item, $event)),
|
|
3115
|
+
onMousedown: _cache[1] || (_cache[1] = ($event) => _ctx.mousedownHandler(_ctx.item, $event)),
|
|
3116
|
+
onMouseup: _cache[2] || (_cache[2] = ($event) => _ctx.mouseupHandler(_ctx.item, $event))
|
|
3117
|
+
}, [
|
|
2833
3118
|
_ctx.item.type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
|
|
2834
3119
|
key: 0,
|
|
2835
|
-
direction: "vertical"
|
|
2836
|
-
})) : _ctx.item.type === "text" ? (openBlock(), createElementBlock("div",
|
|
2837
|
-
createVNode(
|
|
2838
|
-
icon: _ctx.
|
|
2839
|
-
|
|
2840
|
-
}, null, 8, ["
|
|
2841
|
-
createElementVNode("span",
|
|
2842
|
-
createVNode(
|
|
2843
|
-
icon: _ctx.
|
|
2844
|
-
|
|
2845
|
-
}, null, 8, ["
|
|
2846
|
-
], 64)) : _ctx.item.type === "button" ? (openBlock(),
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
3120
|
+
direction: _ctx.item.direction || "vertical"
|
|
3121
|
+
}, 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 }, [
|
|
3122
|
+
createVNode(_component_tool_button, {
|
|
3123
|
+
data: { type: "button", icon: _ctx.ZoomOut, handler: _ctx.zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
3124
|
+
"event-type": _ctx.eventType
|
|
3125
|
+
}, null, 8, ["data", "event-type"]),
|
|
3126
|
+
createElementVNode("span", _hoisted_2$2, toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
|
|
3127
|
+
createVNode(_component_tool_button, {
|
|
3128
|
+
data: { type: "button", icon: _ctx.ZoomIn, handler: _ctx.zoomInHandler, tooltip: "\u653E\u5927" },
|
|
3129
|
+
"event-type": _ctx.eventType
|
|
3130
|
+
}, null, 8, ["data", "event-type"])
|
|
3131
|
+
], 64)) : _ctx.item.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
3132
|
+
_ctx.item.tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
3133
|
+
key: 0,
|
|
3134
|
+
effect: "dark",
|
|
3135
|
+
placement: "bottom-start",
|
|
3136
|
+
content: _ctx.item.tooltip
|
|
3137
|
+
}, {
|
|
3138
|
+
default: withCtx(() => [
|
|
3139
|
+
createVNode(_component_el_button, {
|
|
3140
|
+
size: "small",
|
|
3141
|
+
text: "",
|
|
3142
|
+
disabled: _ctx.disabled
|
|
3143
|
+
}, {
|
|
3144
|
+
default: withCtx(() => [
|
|
3145
|
+
_ctx.item.icon ? (openBlock(), createBlock(_component_m_icon, {
|
|
3146
|
+
key: 0,
|
|
3147
|
+
icon: _ctx.item.icon
|
|
3148
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
3149
|
+
createElementVNode("span", null, toDisplayString(_ctx.item.text), 1)
|
|
3150
|
+
]),
|
|
3151
|
+
_: 1
|
|
3152
|
+
}, 8, ["disabled"])
|
|
3153
|
+
]),
|
|
3154
|
+
_: 1
|
|
3155
|
+
}, 8, ["content"])) : (openBlock(), createBlock(_component_el_button, {
|
|
3156
|
+
key: 1,
|
|
3157
|
+
size: "small",
|
|
3158
|
+
text: "",
|
|
3159
|
+
disabled: _ctx.disabled
|
|
3160
|
+
}, {
|
|
3161
|
+
default: withCtx(() => [
|
|
3162
|
+
_ctx.item.icon ? (openBlock(), createBlock(_component_m_icon, {
|
|
3163
|
+
key: 0,
|
|
3164
|
+
icon: _ctx.item.icon
|
|
3165
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
3166
|
+
createElementVNode("span", null, toDisplayString(_ctx.item.text), 1)
|
|
3167
|
+
]),
|
|
3168
|
+
_: 1
|
|
3169
|
+
}, 8, ["disabled"]))
|
|
3170
|
+
], 64)) : _ctx.item.type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
|
|
3171
|
+
key: 4,
|
|
3172
|
+
trigger: "click",
|
|
3173
|
+
disabled: _ctx.disabled,
|
|
3174
|
+
onCommand: _ctx.dropdownHandler
|
|
2874
3175
|
}, {
|
|
2875
3176
|
dropdown: withCtx(() => [
|
|
2876
3177
|
_ctx.item.items && _ctx.item.items.length ? (openBlock(), createBlock(_component_el_dropdown_menu, { key: 0 }, {
|
|
@@ -2891,7 +3192,7 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2891
3192
|
})) : createCommentVNode("", true)
|
|
2892
3193
|
]),
|
|
2893
3194
|
default: withCtx(() => [
|
|
2894
|
-
createElementVNode("span",
|
|
3195
|
+
createElementVNode("span", _hoisted_3$1, [
|
|
2895
3196
|
createTextVNode(toDisplayString(_ctx.item.text), 1),
|
|
2896
3197
|
createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2897
3198
|
default: withCtx(() => [
|
|
@@ -2903,11 +3204,11 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2903
3204
|
]),
|
|
2904
3205
|
_: 1
|
|
2905
3206
|
}, 8, ["disabled", "onCommand"])) : _ctx.item.type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.item.component), normalizeProps(mergeProps({ key: 5 }, _ctx.item.props || {})), null, 16)) : createCommentVNode("", true)
|
|
2906
|
-
])) : createCommentVNode("", true);
|
|
3207
|
+
], 34)) : createCommentVNode("", true);
|
|
2907
3208
|
}
|
|
2908
|
-
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3209
|
+
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
|
|
2909
3210
|
|
|
2910
|
-
const _sfc_main$
|
|
3211
|
+
const _sfc_main$d = defineComponent({
|
|
2911
3212
|
name: "nav-menu",
|
|
2912
3213
|
components: { ToolButton },
|
|
2913
3214
|
props: {
|
|
@@ -2927,7 +3228,7 @@ const _sfc_main$b = defineComponent({
|
|
|
2927
3228
|
};
|
|
2928
3229
|
}
|
|
2929
3230
|
});
|
|
2930
|
-
function _sfc_render$
|
|
3231
|
+
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2931
3232
|
const _component_tool_button = resolveComponent("tool-button");
|
|
2932
3233
|
return openBlock(), createElementBlock("div", {
|
|
2933
3234
|
class: "m-editor-nav-menu",
|
|
@@ -2949,9 +3250,9 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2949
3250
|
}), 128))
|
|
2950
3251
|
], 4);
|
|
2951
3252
|
}
|
|
2952
|
-
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3253
|
+
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
|
|
2953
3254
|
|
|
2954
|
-
const _sfc_main$
|
|
3255
|
+
const _sfc_main$c = defineComponent({
|
|
2955
3256
|
name: "m-editor-props-panel",
|
|
2956
3257
|
emits: ["mounted"],
|
|
2957
3258
|
setup(props, { emit }) {
|
|
@@ -2966,9 +3267,9 @@ const _sfc_main$a = defineComponent({
|
|
|
2966
3267
|
curFormConfig.value = [];
|
|
2967
3268
|
return;
|
|
2968
3269
|
}
|
|
2969
|
-
values.value = node.value;
|
|
2970
3270
|
const type = node.value.type || (node.value.items ? "container" : "text");
|
|
2971
3271
|
curFormConfig.value = await services?.propsService.getPropsConfig(type) || [];
|
|
3272
|
+
values.value = node.value;
|
|
2972
3273
|
};
|
|
2973
3274
|
watchEffect(init);
|
|
2974
3275
|
services?.propsService.on("props-configs-change", init);
|
|
@@ -2979,6 +3280,7 @@ const _sfc_main$a = defineComponent({
|
|
|
2979
3280
|
values,
|
|
2980
3281
|
configForm,
|
|
2981
3282
|
curFormConfig,
|
|
3283
|
+
propsPanelSize: computed(() => services?.uiService.get("propsPanelSize") || "small"),
|
|
2982
3284
|
async submit() {
|
|
2983
3285
|
try {
|
|
2984
3286
|
const values2 = await configForm.value?.submitForm();
|
|
@@ -2997,20 +3299,21 @@ const _sfc_main$a = defineComponent({
|
|
|
2997
3299
|
};
|
|
2998
3300
|
}
|
|
2999
3301
|
});
|
|
3000
|
-
function _sfc_render$
|
|
3302
|
+
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3001
3303
|
const _component_m_form = resolveComponent("m-form");
|
|
3002
3304
|
return openBlock(), createBlock(_component_m_form, {
|
|
3003
|
-
class:
|
|
3305
|
+
class: normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
|
|
3306
|
+
"popper-class": "m-editor-props-panel-popper",
|
|
3004
3307
|
ref: "configForm",
|
|
3005
|
-
size:
|
|
3308
|
+
size: _ctx.propsPanelSize,
|
|
3006
3309
|
"init-values": _ctx.values,
|
|
3007
3310
|
config: _ctx.curFormConfig,
|
|
3008
3311
|
onChange: _ctx.submit
|
|
3009
|
-
}, null, 8, ["init-values", "config", "onChange"]);
|
|
3312
|
+
}, null, 8, ["class", "size", "init-values", "config", "onChange"]);
|
|
3010
3313
|
}
|
|
3011
|
-
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3314
|
+
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
|
|
3012
3315
|
|
|
3013
|
-
const _sfc_main$
|
|
3316
|
+
const _sfc_main$b = defineComponent({
|
|
3014
3317
|
name: "ui-component-panel",
|
|
3015
3318
|
components: { MIcon },
|
|
3016
3319
|
setup() {
|
|
@@ -3025,19 +3328,29 @@ const _sfc_main$9 = defineComponent({
|
|
|
3025
3328
|
searchText,
|
|
3026
3329
|
collapseValue,
|
|
3027
3330
|
list,
|
|
3028
|
-
appendComponent({ text, type,
|
|
3331
|
+
appendComponent({ text, type, data = {} }) {
|
|
3029
3332
|
services?.editorService.add({
|
|
3030
3333
|
name: text,
|
|
3031
3334
|
type,
|
|
3032
|
-
...
|
|
3335
|
+
...data
|
|
3033
3336
|
});
|
|
3337
|
+
},
|
|
3338
|
+
dragstartHandler({ text, type, data = {} }, e) {
|
|
3339
|
+
if (e.dataTransfer) {
|
|
3340
|
+
e.dataTransfer.effectAllowed = "move";
|
|
3341
|
+
e.dataTransfer.setData("data", serialize({
|
|
3342
|
+
name: text,
|
|
3343
|
+
type,
|
|
3344
|
+
...data
|
|
3345
|
+
}).replace(/"(\w+)":\s/g, "$1: "));
|
|
3346
|
+
}
|
|
3034
3347
|
}
|
|
3035
3348
|
};
|
|
3036
3349
|
}
|
|
3037
3350
|
});
|
|
3038
|
-
const _hoisted_1$
|
|
3039
|
-
const _hoisted_2$
|
|
3040
|
-
function _sfc_render$
|
|
3351
|
+
const _hoisted_1$5 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
3352
|
+
const _hoisted_2$1 = ["onClick", "onDragstart"];
|
|
3353
|
+
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3041
3354
|
const _component_el_input = resolveComponent("el-input");
|
|
3042
3355
|
const _component_m_icon = resolveComponent("m-icon");
|
|
3043
3356
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
@@ -3067,15 +3380,17 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3067
3380
|
name: index
|
|
3068
3381
|
}, {
|
|
3069
3382
|
title: withCtx(() => [
|
|
3070
|
-
_hoisted_1$
|
|
3383
|
+
_hoisted_1$5,
|
|
3071
3384
|
createTextVNode(toDisplayString(group.title), 1)
|
|
3072
3385
|
]),
|
|
3073
3386
|
default: withCtx(() => [
|
|
3074
3387
|
(openBlock(true), createElementBlock(Fragment, null, renderList(group.items, (item) => {
|
|
3075
3388
|
return openBlock(), createElementBlock("div", {
|
|
3076
3389
|
class: "component-item",
|
|
3390
|
+
draggable: "true",
|
|
3077
3391
|
key: item.type,
|
|
3078
|
-
onClick: ($event) => _ctx.appendComponent(item)
|
|
3392
|
+
onClick: ($event) => _ctx.appendComponent(item),
|
|
3393
|
+
onDragstart: ($event) => _ctx.dragstartHandler(item, $event)
|
|
3079
3394
|
}, [
|
|
3080
3395
|
createVNode(_component_m_icon, {
|
|
3081
3396
|
icon: item.icon
|
|
@@ -3090,7 +3405,7 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3090
3405
|
]),
|
|
3091
3406
|
_: 2
|
|
3092
3407
|
}, 1032, ["content"])
|
|
3093
|
-
],
|
|
3408
|
+
], 40, _hoisted_2$1);
|
|
3094
3409
|
}), 128))
|
|
3095
3410
|
]),
|
|
3096
3411
|
_: 2
|
|
@@ -3104,135 +3419,220 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3104
3419
|
_: 1
|
|
3105
3420
|
});
|
|
3106
3421
|
}
|
|
3107
|
-
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3422
|
+
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
|
|
3108
3423
|
|
|
3109
|
-
const _sfc_main$
|
|
3110
|
-
|
|
3424
|
+
const _sfc_main$a = defineComponent({
|
|
3425
|
+
components: { ToolButton },
|
|
3111
3426
|
props: {
|
|
3112
|
-
|
|
3427
|
+
menuData: {
|
|
3113
3428
|
type: Array,
|
|
3114
3429
|
default: () => []
|
|
3115
3430
|
}
|
|
3116
3431
|
},
|
|
3117
|
-
setup(
|
|
3118
|
-
const
|
|
3119
|
-
const
|
|
3120
|
-
const
|
|
3432
|
+
setup() {
|
|
3433
|
+
const menu = ref();
|
|
3434
|
+
const subMenu = ref();
|
|
3435
|
+
const visible = ref(false);
|
|
3436
|
+
const subMenuData = ref([]);
|
|
3437
|
+
const menuStyle = ref({
|
|
3438
|
+
left: "0",
|
|
3439
|
+
top: "0"
|
|
3440
|
+
});
|
|
3441
|
+
const hide = () => {
|
|
3442
|
+
visible.value = false;
|
|
3443
|
+
};
|
|
3444
|
+
onMounted(() => {
|
|
3445
|
+
globalThis.addEventListener("mousedown", (e) => {
|
|
3446
|
+
if (!visible.value || e.target && menu.value?.contains(e.target)) {
|
|
3447
|
+
return;
|
|
3448
|
+
}
|
|
3449
|
+
hide();
|
|
3450
|
+
}, true);
|
|
3451
|
+
});
|
|
3121
3452
|
return {
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3453
|
+
menu,
|
|
3454
|
+
subMenu,
|
|
3455
|
+
visible,
|
|
3456
|
+
menuStyle,
|
|
3457
|
+
subMenuData,
|
|
3458
|
+
hide,
|
|
3459
|
+
show(e) {
|
|
3460
|
+
visible.value = true;
|
|
3461
|
+
nextTick(() => {
|
|
3462
|
+
const menuHeight = menu.value?.clientHeight || 0;
|
|
3463
|
+
let top = e.clientY;
|
|
3464
|
+
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
3465
|
+
top = document.body.clientHeight - menuHeight;
|
|
3129
3466
|
}
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
services?.editorService.add({
|
|
3135
|
-
name: config.text,
|
|
3136
|
-
type: config.type
|
|
3467
|
+
menuStyle.value = {
|
|
3468
|
+
top: `${top}px`,
|
|
3469
|
+
left: `${e.clientX}px`
|
|
3470
|
+
};
|
|
3137
3471
|
});
|
|
3138
3472
|
},
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3473
|
+
showSubMenu(item) {
|
|
3474
|
+
const menuItem = item;
|
|
3475
|
+
if (typeof item !== "object" || !menuItem.items?.length) {
|
|
3476
|
+
return;
|
|
3477
|
+
}
|
|
3478
|
+
subMenuData.value = menuItem.items;
|
|
3479
|
+
if (menu.value) {
|
|
3480
|
+
subMenu.value.show({
|
|
3481
|
+
clientX: menu.value.offsetLeft + menu.value.clientWidth,
|
|
3482
|
+
clientY: menu.value.offsetTop
|
|
3483
|
+
});
|
|
3484
|
+
}
|
|
3147
3485
|
}
|
|
3148
3486
|
};
|
|
3149
3487
|
}
|
|
3150
3488
|
});
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
}, [
|
|
3182
|
-
createVNode(_component_el_scrollbar, null, {
|
|
3183
|
-
default: withCtx(() => [
|
|
3184
|
-
_ctx.node.type === "tabs" ? (openBlock(), createElementBlock("div", {
|
|
3185
|
-
key: 0,
|
|
3186
|
-
class: "magic-editor-content-menu-item",
|
|
3187
|
-
onClick: _cache[4] || (_cache[4] = () => _ctx.append({
|
|
3188
|
-
type: "tab-pane"
|
|
3189
|
-
}))
|
|
3190
|
-
}, " \u6807\u7B7E ")) : _ctx.node.type === "app" ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(_ctx.menu.app, (item) => {
|
|
3191
|
-
return openBlock(), createElementBlock("div", {
|
|
3192
|
-
class: "magic-editor-content-menu-item",
|
|
3193
|
-
key: item.type,
|
|
3194
|
-
onClick: () => _ctx.append(item)
|
|
3195
|
-
}, toDisplayString(item.text), 9, _hoisted_2$2);
|
|
3196
|
-
}), 128)) : _ctx.node.items ? (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(_ctx.menu.component, (list) => {
|
|
3197
|
-
return openBlock(), createElementBlock("div", {
|
|
3198
|
-
key: list.title
|
|
3199
|
-
}, [
|
|
3200
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(list.items, (item) => {
|
|
3201
|
-
return openBlock(), createElementBlock(Fragment, null, [
|
|
3202
|
-
item ? (openBlock(), createElementBlock("div", {
|
|
3203
|
-
class: "magic-editor-content-menu-item",
|
|
3204
|
-
key: item.type,
|
|
3205
|
-
onClick: () => _ctx.append(item)
|
|
3206
|
-
}, toDisplayString(item.text), 9, _hoisted_3$2)) : createCommentVNode("", true)
|
|
3207
|
-
], 64);
|
|
3208
|
-
}), 256)),
|
|
3209
|
-
_hoisted_4$2
|
|
3210
|
-
]);
|
|
3211
|
-
}), 128)) : createCommentVNode("", true)
|
|
3212
|
-
]),
|
|
3213
|
-
_: 1
|
|
3214
|
-
})
|
|
3215
|
-
], 544), [
|
|
3216
|
-
[vShow, _ctx.subVisible]
|
|
3217
|
-
])
|
|
3218
|
-
])) : createCommentVNode("", true);
|
|
3489
|
+
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3490
|
+
const _component_tool_button = resolveComponent("tool-button");
|
|
3491
|
+
const _component_content_menu = resolveComponent("content-menu", true);
|
|
3492
|
+
return _ctx.menuData.length ? withDirectives((openBlock(), createElementBlock("div", {
|
|
3493
|
+
key: 0,
|
|
3494
|
+
class: "magic-editor-content-menu",
|
|
3495
|
+
ref: "menu",
|
|
3496
|
+
style: normalizeStyle(_ctx.menuStyle)
|
|
3497
|
+
}, [
|
|
3498
|
+
createElementVNode("div", null, [
|
|
3499
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menuData, (item, index) => {
|
|
3500
|
+
return openBlock(), createBlock(_component_tool_button, {
|
|
3501
|
+
"event-type": "mouseup",
|
|
3502
|
+
data: item,
|
|
3503
|
+
key: index,
|
|
3504
|
+
onMouseup: _ctx.hide,
|
|
3505
|
+
onMouseenter: ($event) => _ctx.showSubMenu(item)
|
|
3506
|
+
}, null, 8, ["data", "onMouseup", "onMouseenter"]);
|
|
3507
|
+
}), 128))
|
|
3508
|
+
]),
|
|
3509
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
3510
|
+
createVNode(_component_content_menu, {
|
|
3511
|
+
class: "sub-menu",
|
|
3512
|
+
ref: "subMenu",
|
|
3513
|
+
"menu-data": _ctx.subMenuData
|
|
3514
|
+
}, null, 8, ["menu-data"])
|
|
3515
|
+
]))
|
|
3516
|
+
], 4)), [
|
|
3517
|
+
[vShow, _ctx.visible]
|
|
3518
|
+
]) : createCommentVNode("", true);
|
|
3219
3519
|
}
|
|
3220
|
-
var
|
|
3520
|
+
var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
|
|
3221
3521
|
|
|
3222
|
-
const
|
|
3522
|
+
const _sfc_main$9 = defineComponent({
|
|
3523
|
+
components: { ContentMenu },
|
|
3524
|
+
setup() {
|
|
3525
|
+
const services = inject("services");
|
|
3526
|
+
const menu = ref();
|
|
3527
|
+
const node = computed(() => services?.editorService.get("node"));
|
|
3528
|
+
const isRoot = computed(() => node.value?.type === NodeType.ROOT);
|
|
3529
|
+
const isPage = computed(() => node.value?.type === NodeType.PAGE);
|
|
3530
|
+
const componentList = computed(() => services?.componentListService.getList() || []);
|
|
3531
|
+
const createMenuItems = (group) => group.items.map((component) => ({
|
|
3532
|
+
text: component.text,
|
|
3533
|
+
type: "button",
|
|
3534
|
+
icon: component.icon,
|
|
3535
|
+
handler: () => {
|
|
3536
|
+
services?.editorService.add({
|
|
3537
|
+
name: component.text,
|
|
3538
|
+
type: component.type,
|
|
3539
|
+
...component.data || {}
|
|
3540
|
+
});
|
|
3541
|
+
}
|
|
3542
|
+
}));
|
|
3543
|
+
const getSubMenuData = computed(() => {
|
|
3544
|
+
if (node.value?.type === "tabs") {
|
|
3545
|
+
return [
|
|
3546
|
+
{
|
|
3547
|
+
text: "\u6807\u7B7E\u9875",
|
|
3548
|
+
type: "button",
|
|
3549
|
+
icon: Files,
|
|
3550
|
+
handler: () => {
|
|
3551
|
+
services?.editorService.add({
|
|
3552
|
+
type: "tab-pane"
|
|
3553
|
+
});
|
|
3554
|
+
}
|
|
3555
|
+
}
|
|
3556
|
+
];
|
|
3557
|
+
}
|
|
3558
|
+
if (node.value?.items) {
|
|
3559
|
+
return componentList.value.reduce((subMenuData, group, index) => subMenuData.concat(createMenuItems(group), index < componentList.value.length - 1 ? [
|
|
3560
|
+
{
|
|
3561
|
+
type: "divider",
|
|
3562
|
+
direction: "horizontal"
|
|
3563
|
+
}
|
|
3564
|
+
] : []), []) || [];
|
|
3565
|
+
}
|
|
3566
|
+
return [];
|
|
3567
|
+
});
|
|
3568
|
+
return {
|
|
3569
|
+
menu,
|
|
3570
|
+
menuData: computed(() => [
|
|
3571
|
+
{
|
|
3572
|
+
type: "button",
|
|
3573
|
+
text: "\u65B0\u589E",
|
|
3574
|
+
icon: markRaw(Plus),
|
|
3575
|
+
display: () => node.value?.items,
|
|
3576
|
+
items: getSubMenuData.value
|
|
3577
|
+
},
|
|
3578
|
+
{
|
|
3579
|
+
type: "button",
|
|
3580
|
+
text: "\u590D\u5236",
|
|
3581
|
+
icon: markRaw(DocumentCopy),
|
|
3582
|
+
display: () => !isRoot.value,
|
|
3583
|
+
handler: () => {
|
|
3584
|
+
node.value && services?.editorService.copy(node.value);
|
|
3585
|
+
}
|
|
3586
|
+
},
|
|
3587
|
+
{
|
|
3588
|
+
type: "button",
|
|
3589
|
+
text: "\u5220\u9664",
|
|
3590
|
+
icon: markRaw(Delete),
|
|
3591
|
+
display: () => !isRoot.value && !isPage.value,
|
|
3592
|
+
handler: () => {
|
|
3593
|
+
node.value && services?.editorService.remove(node.value);
|
|
3594
|
+
}
|
|
3595
|
+
}
|
|
3596
|
+
]),
|
|
3597
|
+
show(e) {
|
|
3598
|
+
menu.value?.show(e);
|
|
3599
|
+
}
|
|
3600
|
+
};
|
|
3601
|
+
}
|
|
3602
|
+
});
|
|
3603
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3604
|
+
const _component_content_menu = resolveComponent("content-menu");
|
|
3605
|
+
return openBlock(), createBlock(_component_content_menu, {
|
|
3606
|
+
"menu-data": _ctx.menuData,
|
|
3607
|
+
ref: "menu",
|
|
3608
|
+
style: { "overflow": "initial" }
|
|
3609
|
+
}, null, 8, ["menu-data"]);
|
|
3610
|
+
}
|
|
3611
|
+
var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
|
|
3612
|
+
|
|
3613
|
+
const throttleTime = 150;
|
|
3614
|
+
const select = async (data, editorService) => {
|
|
3223
3615
|
if (!data.id) {
|
|
3224
3616
|
throw new Error("\u6CA1\u6709id");
|
|
3225
3617
|
}
|
|
3226
|
-
editorService?.select(data);
|
|
3618
|
+
await editorService?.select(data);
|
|
3619
|
+
editorService?.get("stage")?.select(data.id);
|
|
3620
|
+
};
|
|
3621
|
+
const highlight = (data, editorService) => {
|
|
3622
|
+
if (!data?.id) {
|
|
3623
|
+
throw new Error("\u6CA1\u6709id");
|
|
3624
|
+
}
|
|
3625
|
+
editorService?.highlight(data);
|
|
3626
|
+
editorService?.get("stage")?.highlight(data.id);
|
|
3227
3627
|
};
|
|
3228
3628
|
const useDrop = (tree, editorService) => ({
|
|
3229
3629
|
allowDrop: (draggingNode, dropNode, type) => {
|
|
3230
3630
|
const { data } = dropNode || {};
|
|
3231
3631
|
const { data: ingData } = draggingNode;
|
|
3232
3632
|
const { type: ingType } = ingData;
|
|
3233
|
-
if (ingType !==
|
|
3633
|
+
if (ingType !== NodeType.PAGE && data.type === NodeType.PAGE)
|
|
3234
3634
|
return false;
|
|
3235
|
-
if (ingType ===
|
|
3635
|
+
if (ingType === NodeType.PAGE && data.type !== NodeType.PAGE)
|
|
3236
3636
|
return false;
|
|
3237
3637
|
if (!data || !data.type)
|
|
3238
3638
|
return false;
|
|
@@ -3251,29 +3651,35 @@ const useDrop = (tree, editorService) => ({
|
|
|
3251
3651
|
}
|
|
3252
3652
|
});
|
|
3253
3653
|
const useStatus = (tree, editorService) => {
|
|
3654
|
+
const highlightNode = ref();
|
|
3655
|
+
const node = ref();
|
|
3254
3656
|
const page = computed(() => editorService?.get("page"));
|
|
3255
3657
|
watchEffect(() => {
|
|
3256
3658
|
if (!tree.value)
|
|
3257
3659
|
return;
|
|
3258
|
-
|
|
3259
|
-
node && tree.value.setCurrentKey(node.id, true);
|
|
3660
|
+
node.value = editorService?.get("node");
|
|
3661
|
+
node.value && tree.value.setCurrentKey(node.value.id, true);
|
|
3260
3662
|
const parent = editorService?.get("parent");
|
|
3261
3663
|
if (!parent?.id)
|
|
3262
3664
|
return;
|
|
3263
3665
|
const treeNode = tree.value.getNode(parent.id);
|
|
3264
3666
|
treeNode?.updateChildren();
|
|
3667
|
+
highlightNode.value = editorService?.get("highlightNode");
|
|
3265
3668
|
});
|
|
3266
3669
|
return {
|
|
3267
3670
|
values: computed(() => page.value ? [page.value] : []),
|
|
3268
|
-
loadItems: (
|
|
3269
|
-
if (Array.isArray(
|
|
3270
|
-
return resolve(
|
|
3671
|
+
loadItems: (node2, resolve) => {
|
|
3672
|
+
if (Array.isArray(node2.data)) {
|
|
3673
|
+
return resolve(node2.data);
|
|
3271
3674
|
}
|
|
3272
|
-
if (Array.isArray(
|
|
3273
|
-
return resolve(
|
|
3675
|
+
if (Array.isArray(node2.data?.items)) {
|
|
3676
|
+
return resolve(node2.data?.items);
|
|
3274
3677
|
}
|
|
3275
3678
|
resolve([]);
|
|
3276
|
-
}
|
|
3679
|
+
},
|
|
3680
|
+
highlightNode,
|
|
3681
|
+
clickNode: node,
|
|
3682
|
+
expandedKeys: computed(() => node.value ? [node.value.id] : [])
|
|
3277
3683
|
};
|
|
3278
3684
|
};
|
|
3279
3685
|
const useFilter = (tree) => ({
|
|
@@ -3285,69 +3691,64 @@ const useFilter = (tree) => ({
|
|
|
3285
3691
|
let name = "";
|
|
3286
3692
|
if (data.name) {
|
|
3287
3693
|
name = data.name;
|
|
3288
|
-
} else if (data.type) {
|
|
3289
|
-
name = data.type;
|
|
3290
3694
|
} else if (data.items) {
|
|
3291
3695
|
name = "container";
|
|
3292
3696
|
}
|
|
3293
|
-
return name.indexOf(value) !== -1;
|
|
3697
|
+
return `${data.id}${name}${data.type}`.indexOf(value) !== -1;
|
|
3294
3698
|
},
|
|
3295
3699
|
filterTextChangeHandler(val) {
|
|
3296
3700
|
tree.value?.filter(val);
|
|
3297
3701
|
}
|
|
3298
3702
|
});
|
|
3299
|
-
const
|
|
3300
|
-
const menuStyle = ref({
|
|
3301
|
-
position: "absolute",
|
|
3302
|
-
left: "0",
|
|
3303
|
-
top: "0",
|
|
3304
|
-
display: "none"
|
|
3305
|
-
});
|
|
3306
|
-
onMounted(() => {
|
|
3307
|
-
document.addEventListener("click", () => {
|
|
3308
|
-
menuStyle.value.display = "none";
|
|
3309
|
-
}, true);
|
|
3310
|
-
});
|
|
3311
|
-
return {
|
|
3312
|
-
menuStyle,
|
|
3313
|
-
contextmenu(event, data) {
|
|
3314
|
-
const bodyHeight = globalThis.document.body.clientHeight;
|
|
3315
|
-
const left = `${event.clientX + 20}px`;
|
|
3316
|
-
let top = `${event.clientY - 10}px`;
|
|
3317
|
-
if (event.clientY + 300 > bodyHeight) {
|
|
3318
|
-
top = `${bodyHeight - 300}px`;
|
|
3319
|
-
}
|
|
3320
|
-
menuStyle.value.left = left;
|
|
3321
|
-
menuStyle.value.top = top;
|
|
3322
|
-
menuStyle.value.display = "";
|
|
3323
|
-
select(data, editorService);
|
|
3324
|
-
}
|
|
3325
|
-
};
|
|
3326
|
-
};
|
|
3327
|
-
const _sfc_main$7 = defineComponent({
|
|
3703
|
+
const _sfc_main$8 = defineComponent({
|
|
3328
3704
|
name: "magic-editor-layer-panel",
|
|
3329
3705
|
components: { LayerMenu },
|
|
3330
3706
|
setup() {
|
|
3331
3707
|
const services = inject("services");
|
|
3332
3708
|
const tree = ref();
|
|
3709
|
+
const menu = ref();
|
|
3710
|
+
const clicked = ref(false);
|
|
3333
3711
|
const editorService = services?.editorService;
|
|
3712
|
+
const highlightHandler = throttle((data) => {
|
|
3713
|
+
highlight(data, editorService);
|
|
3714
|
+
}, throttleTime);
|
|
3715
|
+
const toggleClickFlag = () => {
|
|
3716
|
+
clicked.value = !clicked.value;
|
|
3717
|
+
};
|
|
3718
|
+
const statusData = useStatus(tree, editorService);
|
|
3719
|
+
const canHighlight = computed(() => statusData.highlightNode.value?.id !== statusData.clickNode.value?.id && !clicked.value);
|
|
3720
|
+
editorService?.on("remove", () => {
|
|
3721
|
+
setTimeout(() => {
|
|
3722
|
+
tree.value?.getNode(editorService.get("node").id)?.updateChildren();
|
|
3723
|
+
}, 0);
|
|
3724
|
+
});
|
|
3334
3725
|
return {
|
|
3335
3726
|
tree,
|
|
3727
|
+
menu,
|
|
3728
|
+
...statusData,
|
|
3336
3729
|
...useDrop(tree, editorService),
|
|
3337
|
-
...useStatus(tree, editorService),
|
|
3338
3730
|
...useFilter(tree),
|
|
3339
|
-
|
|
3731
|
+
highlightHandler,
|
|
3732
|
+
toggleClickFlag,
|
|
3733
|
+
canHighlight,
|
|
3340
3734
|
clickHandler(data) {
|
|
3341
3735
|
if (services?.uiService.get("uiSelectMode")) {
|
|
3342
3736
|
document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
|
|
3343
3737
|
return;
|
|
3344
3738
|
}
|
|
3739
|
+
tree.value?.setCurrentKey(data.id);
|
|
3345
3740
|
select(data, editorService);
|
|
3741
|
+
},
|
|
3742
|
+
async contextmenu(event, data) {
|
|
3743
|
+
event.preventDefault();
|
|
3744
|
+
await select(data, editorService);
|
|
3745
|
+
menu.value?.show(event);
|
|
3346
3746
|
}
|
|
3347
3747
|
};
|
|
3348
3748
|
}
|
|
3349
3749
|
});
|
|
3350
|
-
|
|
3750
|
+
const _hoisted_1$4 = ["id", "onMouseenter"];
|
|
3751
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3351
3752
|
const _component_el_input = resolveComponent("el-input");
|
|
3352
3753
|
const _component_el_tree = resolveComponent("el-tree");
|
|
3353
3754
|
const _component_layer_menu = resolveComponent("layer-menu");
|
|
@@ -3368,6 +3769,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3368
3769
|
ref: "tree",
|
|
3369
3770
|
"node-key": "id",
|
|
3370
3771
|
draggable: "",
|
|
3772
|
+
"default-expanded-keys": _ctx.expandedKeys,
|
|
3371
3773
|
load: _ctx.loadItems,
|
|
3372
3774
|
data: _ctx.values,
|
|
3373
3775
|
"expand-on-click-node": false,
|
|
@@ -3383,47 +3785,46 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3383
3785
|
"empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684"
|
|
3384
3786
|
}, {
|
|
3385
3787
|
default: withCtx(({ node, data }) => [
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
data
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3788
|
+
createElementVNode("div", {
|
|
3789
|
+
id: data.id,
|
|
3790
|
+
class: normalizeClass(["cus-tree-node", { "cus-tree-node-hover": _ctx.canHighlight && data.id === _ctx.highlightNode?.id }]),
|
|
3791
|
+
onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
|
|
3792
|
+
onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
|
|
3793
|
+
onMouseenter: ($event) => _ctx.highlightHandler(data)
|
|
3794
|
+
}, [
|
|
3795
|
+
renderSlot(_ctx.$slots, "layer-node-content", {
|
|
3796
|
+
node,
|
|
3797
|
+
data
|
|
3798
|
+
}, () => [
|
|
3799
|
+
createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
|
|
3800
|
+
])
|
|
3801
|
+
], 42, _hoisted_1$4)
|
|
3392
3802
|
]),
|
|
3393
3803
|
_: 3
|
|
3394
|
-
}, 8, ["load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : createCommentVNode("", true),
|
|
3804
|
+
}, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : createCommentVNode("", true),
|
|
3395
3805
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
3396
|
-
createVNode(_component_layer_menu, {
|
|
3397
|
-
style: normalizeStyle(_ctx.menuStyle)
|
|
3398
|
-
}, null, 8, ["style"])
|
|
3806
|
+
createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
|
|
3399
3807
|
]))
|
|
3400
3808
|
]),
|
|
3401
3809
|
_: 3
|
|
3402
3810
|
});
|
|
3403
3811
|
}
|
|
3404
|
-
var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3812
|
+
var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
|
|
3405
3813
|
|
|
3406
|
-
const _sfc_main$
|
|
3407
|
-
name: "m-sidebar",
|
|
3814
|
+
const _sfc_main$7 = defineComponent({
|
|
3408
3815
|
components: { MIcon },
|
|
3409
3816
|
props: {
|
|
3410
3817
|
data: {
|
|
3411
|
-
type: Object
|
|
3412
|
-
default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer"] })
|
|
3818
|
+
type: Object
|
|
3413
3819
|
}
|
|
3414
3820
|
},
|
|
3415
3821
|
setup(props) {
|
|
3416
|
-
const activeTabName = ref(props.data?.status);
|
|
3417
|
-
watch(() => props.data?.status, (status) => {
|
|
3418
|
-
activeTabName.value = status || "0";
|
|
3419
|
-
});
|
|
3420
3822
|
return {
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
return item;
|
|
3823
|
+
config: computed(() => {
|
|
3824
|
+
if (typeof props.data !== "string") {
|
|
3825
|
+
return props.data;
|
|
3425
3826
|
}
|
|
3426
|
-
switch (
|
|
3827
|
+
switch (props.data) {
|
|
3427
3828
|
case "component-list":
|
|
3428
3829
|
return {
|
|
3429
3830
|
type: "component",
|
|
@@ -3441,21 +3842,75 @@ const _sfc_main$6 = defineComponent({
|
|
|
3441
3842
|
slots: {}
|
|
3442
3843
|
};
|
|
3443
3844
|
default:
|
|
3444
|
-
return
|
|
3845
|
+
return void 0;
|
|
3445
3846
|
}
|
|
3446
|
-
})
|
|
3847
|
+
})
|
|
3447
3848
|
};
|
|
3448
3849
|
}
|
|
3449
3850
|
});
|
|
3450
|
-
const _hoisted_1$
|
|
3851
|
+
const _hoisted_1$3 = {
|
|
3451
3852
|
key: 1,
|
|
3452
3853
|
class: "magic-editor-tab-panel-title"
|
|
3453
3854
|
};
|
|
3454
|
-
function _sfc_render$
|
|
3855
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3455
3856
|
const _component_m_icon = resolveComponent("m-icon");
|
|
3456
3857
|
const _component_el_tab_pane = resolveComponent("el-tab-pane");
|
|
3858
|
+
return _ctx.config ? (openBlock(), createBlock(_component_el_tab_pane, {
|
|
3859
|
+
key: 0,
|
|
3860
|
+
name: _ctx.config.text
|
|
3861
|
+
}, {
|
|
3862
|
+
label: withCtx(() => [
|
|
3863
|
+
(openBlock(), createElementBlock("div", {
|
|
3864
|
+
key: _ctx.config.text
|
|
3865
|
+
}, [
|
|
3866
|
+
_ctx.config.icon ? (openBlock(), createBlock(_component_m_icon, {
|
|
3867
|
+
key: 0,
|
|
3868
|
+
icon: _ctx.config.icon
|
|
3869
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
3870
|
+
_ctx.config.text ? (openBlock(), createElementBlock("div", _hoisted_1$3, toDisplayString(_ctx.config.text), 1)) : createCommentVNode("", true)
|
|
3871
|
+
]))
|
|
3872
|
+
]),
|
|
3873
|
+
default: withCtx(() => [
|
|
3874
|
+
(openBlock(), createBlock(resolveDynamicComponent(_ctx.config.component), mergeProps(_ctx.config.props || {}, toHandlers(_ctx.config?.listeners || {})), createSlots({ _: 2 }, [
|
|
3875
|
+
_ctx.config.slots?.layerNodeContent ? {
|
|
3876
|
+
name: "layer-node-content",
|
|
3877
|
+
fn: withCtx(({ data, node }) => [
|
|
3878
|
+
(openBlock(), createBlock(resolveDynamicComponent(_ctx.config.slots?.layerNodeContent), {
|
|
3879
|
+
data,
|
|
3880
|
+
node
|
|
3881
|
+
}, null, 8, ["data", "node"]))
|
|
3882
|
+
])
|
|
3883
|
+
} : void 0
|
|
3884
|
+
]), 1040))
|
|
3885
|
+
]),
|
|
3886
|
+
_: 1
|
|
3887
|
+
}, 8, ["name"])) : createCommentVNode("", true);
|
|
3888
|
+
}
|
|
3889
|
+
var TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7]]);
|
|
3890
|
+
|
|
3891
|
+
const _sfc_main$6 = defineComponent({
|
|
3892
|
+
components: { TabPane },
|
|
3893
|
+
name: "m-sidebar",
|
|
3894
|
+
props: {
|
|
3895
|
+
data: {
|
|
3896
|
+
type: Object,
|
|
3897
|
+
default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer"] })
|
|
3898
|
+
}
|
|
3899
|
+
},
|
|
3900
|
+
setup(props) {
|
|
3901
|
+
const activeTabName = ref(props.data?.status);
|
|
3902
|
+
watch(() => props.data?.status, (status) => {
|
|
3903
|
+
activeTabName.value = status || "0";
|
|
3904
|
+
});
|
|
3905
|
+
return {
|
|
3906
|
+
activeTabName
|
|
3907
|
+
};
|
|
3908
|
+
}
|
|
3909
|
+
});
|
|
3910
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3911
|
+
const _component_tab_pane = resolveComponent("tab-pane");
|
|
3457
3912
|
const _component_el_tabs = resolveComponent("el-tabs");
|
|
3458
|
-
return _ctx.data.type === "tabs" ? (openBlock(), createBlock(_component_el_tabs, {
|
|
3913
|
+
return _ctx.data.type === "tabs" && _ctx.data.items.length ? (openBlock(), createBlock(_component_el_tabs, {
|
|
3459
3914
|
key: 0,
|
|
3460
3915
|
class: "m-editor-sidebar",
|
|
3461
3916
|
modelValue: _ctx.activeTabName,
|
|
@@ -3464,35 +3919,11 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3464
3919
|
"tab-position": "left"
|
|
3465
3920
|
}, {
|
|
3466
3921
|
default: withCtx(() => [
|
|
3467
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.items, (item) => {
|
|
3468
|
-
return openBlock(), createBlock(
|
|
3469
|
-
key:
|
|
3470
|
-
|
|
3471
|
-
},
|
|
3472
|
-
label: withCtx(() => [
|
|
3473
|
-
createElementVNode("span", null, [
|
|
3474
|
-
item.icon ? (openBlock(), createBlock(_component_m_icon, {
|
|
3475
|
-
key: 0,
|
|
3476
|
-
icon: item.icon
|
|
3477
|
-
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
3478
|
-
item.text ? (openBlock(), createElementBlock("div", _hoisted_1$4, toDisplayString(item.text), 1)) : createCommentVNode("", true)
|
|
3479
|
-
])
|
|
3480
|
-
]),
|
|
3481
|
-
default: withCtx(() => [
|
|
3482
|
-
(openBlock(), createBlock(resolveDynamicComponent(item.component), mergeProps(item.props || {}, toHandlers(item.listeners || {})), createSlots({ _: 2 }, [
|
|
3483
|
-
item.slots?.layerNodeContent ? {
|
|
3484
|
-
name: "layer-node-content",
|
|
3485
|
-
fn: withCtx(({ data, node }) => [
|
|
3486
|
-
(openBlock(), createBlock(resolveDynamicComponent(item.slots.layerNodeContent), {
|
|
3487
|
-
data,
|
|
3488
|
-
node
|
|
3489
|
-
}, null, 8, ["data", "node"]))
|
|
3490
|
-
])
|
|
3491
|
-
} : void 0
|
|
3492
|
-
]), 1040))
|
|
3493
|
-
]),
|
|
3494
|
-
_: 2
|
|
3495
|
-
}, 1032, ["name"]);
|
|
3922
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data.items, (item, index) => {
|
|
3923
|
+
return openBlock(), createBlock(_component_tab_pane, {
|
|
3924
|
+
key: index,
|
|
3925
|
+
data: item
|
|
3926
|
+
}, null, 8, ["data"]);
|
|
3496
3927
|
}), 128))
|
|
3497
3928
|
]),
|
|
3498
3929
|
_: 1
|
|
@@ -3500,13 +3931,81 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3500
3931
|
}
|
|
3501
3932
|
var Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6]]);
|
|
3502
3933
|
|
|
3934
|
+
const useScroll = (root) => {
|
|
3935
|
+
const pageBar = ref();
|
|
3936
|
+
const itemsContainer = ref();
|
|
3937
|
+
const pageBarWidth = ref(0);
|
|
3938
|
+
const canScroll = ref(false);
|
|
3939
|
+
const itemsContainerWidth = computed(() => pageBarWidth.value - 105);
|
|
3940
|
+
let translateLeft = 0;
|
|
3941
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
3942
|
+
for (const { contentRect } of entries) {
|
|
3943
|
+
const { width } = contentRect;
|
|
3944
|
+
pageBarWidth.value = width || 0;
|
|
3945
|
+
setCanScroll();
|
|
3946
|
+
}
|
|
3947
|
+
});
|
|
3948
|
+
const setCanScroll = () => {
|
|
3949
|
+
if (itemsContainer.value) {
|
|
3950
|
+
canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
|
|
3951
|
+
}
|
|
3952
|
+
};
|
|
3953
|
+
const scroll = (type) => {
|
|
3954
|
+
if (!itemsContainer.value)
|
|
3955
|
+
return;
|
|
3956
|
+
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
3957
|
+
if (type === "left") {
|
|
3958
|
+
translateLeft += 100;
|
|
3959
|
+
if (translateLeft > 0) {
|
|
3960
|
+
translateLeft = 0;
|
|
3961
|
+
}
|
|
3962
|
+
} else if (type === "right") {
|
|
3963
|
+
translateLeft -= 100;
|
|
3964
|
+
if (-translateLeft > maxScrollLeft) {
|
|
3965
|
+
translateLeft = -maxScrollLeft;
|
|
3966
|
+
}
|
|
3967
|
+
} else if (type === "start") {
|
|
3968
|
+
translateLeft = 0;
|
|
3969
|
+
} else if (type === "end") {
|
|
3970
|
+
translateLeft = -maxScrollLeft;
|
|
3971
|
+
}
|
|
3972
|
+
itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
|
|
3973
|
+
};
|
|
3974
|
+
onMounted(() => {
|
|
3975
|
+
pageBar.value && resizeObserver.observe(pageBar.value);
|
|
3976
|
+
});
|
|
3977
|
+
onUnmounted(() => {
|
|
3978
|
+
resizeObserver.disconnect();
|
|
3979
|
+
});
|
|
3980
|
+
watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
|
|
3981
|
+
setTimeout(() => {
|
|
3982
|
+
setCanScroll();
|
|
3983
|
+
if (length < preLength) {
|
|
3984
|
+
scroll("start");
|
|
3985
|
+
} else {
|
|
3986
|
+
scroll("end");
|
|
3987
|
+
}
|
|
3988
|
+
});
|
|
3989
|
+
});
|
|
3990
|
+
return {
|
|
3991
|
+
pageBar,
|
|
3992
|
+
itemsContainer,
|
|
3993
|
+
canScroll,
|
|
3994
|
+
itemsContainerWidth,
|
|
3995
|
+
scroll
|
|
3996
|
+
};
|
|
3997
|
+
};
|
|
3503
3998
|
const _sfc_main$5 = defineComponent({
|
|
3504
|
-
components: { CaretBottom, Plus },
|
|
3999
|
+
components: { ArrowLeftBold, ArrowRightBold, CaretBottom, Plus, ToolButton },
|
|
3505
4000
|
setup() {
|
|
3506
4001
|
const services = inject("services");
|
|
3507
4002
|
const editorService = services?.editorService;
|
|
4003
|
+
const root = computed(() => editorService?.get("root"));
|
|
3508
4004
|
return {
|
|
3509
|
-
|
|
4005
|
+
Delete: markRaw(Delete),
|
|
4006
|
+
DocumentCopy: markRaw(DocumentCopy),
|
|
4007
|
+
...useScroll(root),
|
|
4008
|
+
root,
|
|
3510
4009
|
page: computed(() => editorService?.get("page")),
|
|
3511
4010
|
switchPage(page) {
|
|
3512
4011
|
editorService?.select(page);
|
|
@@ -3515,7 +4014,7 @@ const _sfc_main$5 = defineComponent({
|
|
|
3515
4014
|
if (!editorService)
|
|
3516
4015
|
return;
|
|
3517
4016
|
const pageConfig = {
|
|
3518
|
-
type:
|
|
4017
|
+
type: NodeType.PAGE,
|
|
3519
4018
|
name: generatePageNameByApp(toRaw(editorService.get("root")))
|
|
3520
4019
|
};
|
|
3521
4020
|
editorService.add(pageConfig);
|
|
@@ -3533,99 +4032,228 @@ const _sfc_main$5 = defineComponent({
|
|
|
3533
4032
|
};
|
|
3534
4033
|
}
|
|
3535
4034
|
});
|
|
3536
|
-
const _hoisted_1$
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
4035
|
+
const _hoisted_1$2 = {
|
|
4036
|
+
class: "m-editor-page-bar",
|
|
4037
|
+
ref: "pageBar"
|
|
4038
|
+
};
|
|
4039
|
+
const _hoisted_2 = ["onClick"];
|
|
4040
|
+
const _hoisted_3 = { class: "m-editor-page-bar-title" };
|
|
3540
4041
|
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3541
4042
|
const _component_plus = resolveComponent("plus");
|
|
3542
4043
|
const _component_el_icon = resolveComponent("el-icon");
|
|
4044
|
+
const _component_arrow_left_bold = resolveComponent("arrow-left-bold");
|
|
4045
|
+
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
4046
|
+
const _component_tool_button = resolveComponent("tool-button");
|
|
3543
4047
|
const _component_caret_bottom = resolveComponent("caret-bottom");
|
|
3544
4048
|
const _component_el_popover = resolveComponent("el-popover");
|
|
3545
|
-
|
|
4049
|
+
const _component_arrow_right_bold = resolveComponent("arrow-right-bold");
|
|
4050
|
+
return openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
3546
4051
|
createElementVNode("div", {
|
|
3547
|
-
|
|
4052
|
+
id: "m-editor-page-bar-add-icon",
|
|
4053
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3548
4054
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.addPage && _ctx.addPage(...args))
|
|
3549
4055
|
}, [
|
|
3550
|
-
createVNode(_component_el_icon,
|
|
4056
|
+
createVNode(_component_el_icon, null, {
|
|
3551
4057
|
default: withCtx(() => [
|
|
3552
4058
|
createVNode(_component_plus)
|
|
3553
4059
|
]),
|
|
3554
4060
|
_: 1
|
|
3555
4061
|
})
|
|
3556
4062
|
]),
|
|
3557
|
-
_ctx.
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
4063
|
+
_ctx.canScroll ? (openBlock(), createElementBlock("div", {
|
|
4064
|
+
key: 0,
|
|
4065
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4066
|
+
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.scroll("left"))
|
|
4067
|
+
}, [
|
|
4068
|
+
createVNode(_component_el_icon, null, {
|
|
4069
|
+
default: withCtx(() => [
|
|
4070
|
+
createVNode(_component_arrow_left_bold)
|
|
3565
4071
|
]),
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
]),
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
4072
|
+
_: 1
|
|
4073
|
+
})
|
|
4074
|
+
])) : createCommentVNode("", true),
|
|
4075
|
+
_ctx.root ? (openBlock(), createElementBlock("div", {
|
|
4076
|
+
key: 1,
|
|
4077
|
+
class: "m-editor-page-bar-items",
|
|
4078
|
+
ref: "itemsContainer",
|
|
4079
|
+
style: normalizeStyle(`width: ${_ctx.itemsContainerWidth}px`)
|
|
4080
|
+
}, [
|
|
4081
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.root.items, (item) => {
|
|
4082
|
+
return openBlock(), createElementBlock("div", {
|
|
4083
|
+
key: item.key,
|
|
4084
|
+
class: normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
|
|
4085
|
+
onClick: ($event) => _ctx.switchPage(item)
|
|
4086
|
+
}, [
|
|
4087
|
+
createElementVNode("div", _hoisted_3, [
|
|
4088
|
+
renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
|
|
4089
|
+
createVNode(_component_el_tooltip, {
|
|
4090
|
+
effect: "dark",
|
|
4091
|
+
placement: "top-start",
|
|
4092
|
+
content: item.name
|
|
4093
|
+
}, {
|
|
4094
|
+
default: withCtx(() => [
|
|
4095
|
+
createElementVNode("span", null, toDisplayString(item.name), 1)
|
|
4096
|
+
]),
|
|
4097
|
+
_: 2
|
|
4098
|
+
}, 1032, ["content"])
|
|
3591
4099
|
])
|
|
3592
4100
|
]),
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
4101
|
+
createVNode(_component_el_popover, {
|
|
4102
|
+
"popper-class": "page-bar-popover",
|
|
4103
|
+
placement: "top",
|
|
4104
|
+
width: 160,
|
|
4105
|
+
trigger: "hover"
|
|
4106
|
+
}, {
|
|
4107
|
+
reference: withCtx(() => [
|
|
4108
|
+
createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
|
|
4109
|
+
default: withCtx(() => [
|
|
4110
|
+
createVNode(_component_caret_bottom)
|
|
4111
|
+
]),
|
|
4112
|
+
_: 1
|
|
4113
|
+
})
|
|
4114
|
+
]),
|
|
4115
|
+
default: withCtx(() => [
|
|
4116
|
+
createElementVNode("div", null, [
|
|
4117
|
+
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
4118
|
+
createVNode(_component_tool_button, {
|
|
4119
|
+
data: {
|
|
4120
|
+
type: "button",
|
|
4121
|
+
text: "\u590D\u5236",
|
|
4122
|
+
icon: _ctx.DocumentCopy,
|
|
4123
|
+
handler: () => _ctx.copy(item)
|
|
4124
|
+
}
|
|
4125
|
+
}, null, 8, ["data"]),
|
|
4126
|
+
createVNode(_component_tool_button, {
|
|
4127
|
+
data: {
|
|
4128
|
+
type: "button",
|
|
4129
|
+
text: "\u5220\u9664",
|
|
4130
|
+
icon: _ctx.Delete,
|
|
4131
|
+
handler: () => _ctx.remove(item)
|
|
4132
|
+
}
|
|
4133
|
+
}, null, 8, ["data"])
|
|
4134
|
+
])
|
|
4135
|
+
])
|
|
4136
|
+
]),
|
|
4137
|
+
_: 2
|
|
4138
|
+
}, 1024)
|
|
4139
|
+
], 10, _hoisted_2);
|
|
4140
|
+
}), 128))
|
|
4141
|
+
], 4)) : createCommentVNode("", true),
|
|
4142
|
+
_ctx.canScroll ? (openBlock(), createElementBlock("div", {
|
|
4143
|
+
key: 2,
|
|
4144
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4145
|
+
onClick: _cache[2] || (_cache[2] = ($event) => _ctx.scroll("right"))
|
|
4146
|
+
}, [
|
|
4147
|
+
createVNode(_component_el_icon, null, {
|
|
4148
|
+
default: withCtx(() => [
|
|
4149
|
+
createVNode(_component_arrow_right_bold)
|
|
4150
|
+
]),
|
|
4151
|
+
_: 1
|
|
4152
|
+
})
|
|
4153
|
+
])) : createCommentVNode("", true)
|
|
4154
|
+
], 512);
|
|
3598
4155
|
}
|
|
3599
4156
|
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
|
|
3600
4157
|
|
|
3601
4158
|
class ScrollViewer$1 {
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
4159
|
+
constructor(options) {
|
|
4160
|
+
this.enter = false;
|
|
4161
|
+
this.targetEnter = false;
|
|
4162
|
+
this.keydown = false;
|
|
4163
|
+
this.zoom = 1;
|
|
4164
|
+
this.scrollLeft = 0;
|
|
4165
|
+
this.scrollTop = 0;
|
|
4166
|
+
this.x = 0;
|
|
4167
|
+
this.y = 0;
|
|
4168
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
4169
|
+
for (const { contentRect } of entries) {
|
|
4170
|
+
const { width, height } = contentRect;
|
|
4171
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
4172
|
+
const targetWidth = targetRect.width * this.zoom;
|
|
4173
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
4174
|
+
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
4175
|
+
if (targetWidth < width) {
|
|
4176
|
+
this.target._left = 0;
|
|
4177
|
+
}
|
|
4178
|
+
if (targetHeight < height) {
|
|
4179
|
+
this.target._top = 0;
|
|
4180
|
+
}
|
|
4181
|
+
this.scroll();
|
|
3624
4182
|
}
|
|
4183
|
+
});
|
|
4184
|
+
this.wheelHandler = (event) => {
|
|
4185
|
+
if (this.targetEnter)
|
|
4186
|
+
return;
|
|
4187
|
+
const { deltaX, deltaY, currentTarget } = event;
|
|
4188
|
+
if (currentTarget !== this.container)
|
|
4189
|
+
return;
|
|
4190
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3625
4191
|
this.scroll();
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
4192
|
+
this.scrollLeft = this.target._left;
|
|
4193
|
+
this.scrollTop = this.target._top;
|
|
4194
|
+
};
|
|
4195
|
+
this.mouseEnterHandler = () => {
|
|
4196
|
+
this.enter = true;
|
|
4197
|
+
};
|
|
4198
|
+
this.mouseLeaveHandler = () => {
|
|
4199
|
+
this.enter = false;
|
|
4200
|
+
};
|
|
4201
|
+
this.targetMouseEnterHandler = () => {
|
|
4202
|
+
this.targetEnter = true;
|
|
4203
|
+
};
|
|
4204
|
+
this.targetMouseLeaveHandler = () => {
|
|
4205
|
+
this.targetEnter = false;
|
|
4206
|
+
};
|
|
4207
|
+
this.mousedownHandler = (event) => {
|
|
4208
|
+
if (!this.keydown)
|
|
4209
|
+
return;
|
|
4210
|
+
event.stopImmediatePropagation();
|
|
4211
|
+
event.stopPropagation();
|
|
4212
|
+
this.target.style.cursor = "grabbing";
|
|
4213
|
+
this.x = event.clientX;
|
|
4214
|
+
this.y = event.clientY;
|
|
4215
|
+
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
4216
|
+
document.addEventListener("mouseup", this.mouseupHandler);
|
|
4217
|
+
};
|
|
4218
|
+
this.mouseupHandler = () => {
|
|
4219
|
+
this.x = 0;
|
|
4220
|
+
this.y = 0;
|
|
4221
|
+
this.scrollLeft = this.target._left;
|
|
4222
|
+
this.scrollTop = this.target._top;
|
|
4223
|
+
this.removeHandler();
|
|
4224
|
+
};
|
|
4225
|
+
this.mousemoveHandler = (event) => {
|
|
4226
|
+
event.stopImmediatePropagation();
|
|
4227
|
+
event.stopPropagation();
|
|
4228
|
+
const deltaX = event.clientX - this.x;
|
|
4229
|
+
const deltaY = event.clientY - this.y;
|
|
4230
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
4231
|
+
this.scroll();
|
|
4232
|
+
};
|
|
4233
|
+
this.keydownHandler = (event) => {
|
|
4234
|
+
if (event.code === Keys.ESCAPE && this.enter) {
|
|
4235
|
+
event.preventDefault();
|
|
4236
|
+
event.stopImmediatePropagation();
|
|
4237
|
+
event.stopPropagation();
|
|
4238
|
+
}
|
|
4239
|
+
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
4240
|
+
return;
|
|
4241
|
+
}
|
|
4242
|
+
this.keydown = true;
|
|
4243
|
+
this.target.style.cursor = "grab";
|
|
4244
|
+
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
4245
|
+
};
|
|
4246
|
+
this.keyupHandler = (event) => {
|
|
4247
|
+
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
4248
|
+
return;
|
|
4249
|
+
}
|
|
4250
|
+
event.preventDefault();
|
|
4251
|
+
event.stopImmediatePropagation();
|
|
4252
|
+
event.stopPropagation();
|
|
4253
|
+
this.keydown = false;
|
|
4254
|
+
event.preventDefault();
|
|
4255
|
+
this.removeHandler();
|
|
4256
|
+
};
|
|
3629
4257
|
this.container = options.container;
|
|
3630
4258
|
this.target = options.target;
|
|
3631
4259
|
this.zoom = options.zoom;
|
|
@@ -3661,79 +4289,6 @@ class ScrollViewer$1 {
|
|
|
3661
4289
|
document.removeEventListener("mousemove", this.mousemoveHandler);
|
|
3662
4290
|
document.removeEventListener("mouseup", this.mouseupHandler);
|
|
3663
4291
|
}
|
|
3664
|
-
wheelHandler = (event) => {
|
|
3665
|
-
if (this.targetEnter)
|
|
3666
|
-
return;
|
|
3667
|
-
const { deltaX, deltaY, currentTarget } = event;
|
|
3668
|
-
if (currentTarget !== this.container)
|
|
3669
|
-
return;
|
|
3670
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3671
|
-
this.scroll();
|
|
3672
|
-
this.scrollLeft = this.target._left;
|
|
3673
|
-
this.scrollTop = this.target._top;
|
|
3674
|
-
};
|
|
3675
|
-
mouseEnterHandler = () => {
|
|
3676
|
-
this.enter = true;
|
|
3677
|
-
};
|
|
3678
|
-
mouseLeaveHandler = () => {
|
|
3679
|
-
this.enter = false;
|
|
3680
|
-
};
|
|
3681
|
-
targetMouseEnterHandler = () => {
|
|
3682
|
-
this.targetEnter = true;
|
|
3683
|
-
};
|
|
3684
|
-
targetMouseLeaveHandler = () => {
|
|
3685
|
-
this.targetEnter = false;
|
|
3686
|
-
};
|
|
3687
|
-
mousedownHandler = (event) => {
|
|
3688
|
-
if (!this.keydown)
|
|
3689
|
-
return;
|
|
3690
|
-
event.stopImmediatePropagation();
|
|
3691
|
-
event.stopPropagation();
|
|
3692
|
-
this.target.style.cursor = "grabbing";
|
|
3693
|
-
this.x = event.clientX;
|
|
3694
|
-
this.y = event.clientY;
|
|
3695
|
-
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3696
|
-
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3697
|
-
};
|
|
3698
|
-
mouseupHandler = () => {
|
|
3699
|
-
this.x = 0;
|
|
3700
|
-
this.y = 0;
|
|
3701
|
-
this.scrollLeft = this.target._left;
|
|
3702
|
-
this.scrollTop = this.target._top;
|
|
3703
|
-
this.removeHandler();
|
|
3704
|
-
};
|
|
3705
|
-
mousemoveHandler = (event) => {
|
|
3706
|
-
event.stopImmediatePropagation();
|
|
3707
|
-
event.stopPropagation();
|
|
3708
|
-
const deltaX = event.clientX - this.x;
|
|
3709
|
-
const deltaY = event.clientY - this.y;
|
|
3710
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3711
|
-
this.scroll();
|
|
3712
|
-
};
|
|
3713
|
-
keydownHandler = (event) => {
|
|
3714
|
-
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3715
|
-
event.preventDefault();
|
|
3716
|
-
event.stopImmediatePropagation();
|
|
3717
|
-
event.stopPropagation();
|
|
3718
|
-
}
|
|
3719
|
-
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3720
|
-
return;
|
|
3721
|
-
}
|
|
3722
|
-
this.keydown = true;
|
|
3723
|
-
this.target.style.cursor = "grab";
|
|
3724
|
-
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3725
|
-
};
|
|
3726
|
-
keyupHandler = (event) => {
|
|
3727
|
-
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3728
|
-
return;
|
|
3729
|
-
}
|
|
3730
|
-
event.preventDefault();
|
|
3731
|
-
event.stopImmediatePropagation();
|
|
3732
|
-
event.stopPropagation();
|
|
3733
|
-
this.keydown = false;
|
|
3734
|
-
event.preventDefault();
|
|
3735
|
-
this.removeHandler();
|
|
3736
|
-
};
|
|
3737
4292
|
setScrollOffset(deltaX, deltaY) {
|
|
3738
4293
|
const { width, height } = this.container.getBoundingClientRect();
|
|
3739
4294
|
const targetRect = this.target.getBoundingClientRect();
|
|
@@ -3794,19 +4349,19 @@ const _sfc_main$4 = defineComponent({
|
|
|
3794
4349
|
el,
|
|
3795
4350
|
style: computed(() => `
|
|
3796
4351
|
width: ${props.width}px;
|
|
3797
|
-
height: ${props.height}px;
|
|
4352
|
+
height: ${(props.height || 0) - 40}px;
|
|
3798
4353
|
position: absolute;
|
|
3799
4354
|
margin-top: 30px;
|
|
3800
4355
|
`)
|
|
3801
4356
|
};
|
|
3802
4357
|
}
|
|
3803
4358
|
});
|
|
3804
|
-
const _hoisted_1$
|
|
4359
|
+
const _hoisted_1$1 = {
|
|
3805
4360
|
class: "m-editor-scroll-viewer-container",
|
|
3806
4361
|
ref: "container"
|
|
3807
4362
|
};
|
|
3808
4363
|
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3809
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
4364
|
+
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
3810
4365
|
createElementVNode("div", {
|
|
3811
4366
|
ref: "el",
|
|
3812
4367
|
style: normalizeStyle(_ctx.style)
|
|
@@ -3818,7 +4373,7 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3818
4373
|
var ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]);
|
|
3819
4374
|
|
|
3820
4375
|
const _sfc_main$3 = defineComponent({
|
|
3821
|
-
|
|
4376
|
+
components: { ContentMenu },
|
|
3822
4377
|
setup() {
|
|
3823
4378
|
const services = inject("services");
|
|
3824
4379
|
const editorService = services?.editorService;
|
|
@@ -3827,6 +4382,7 @@ const _sfc_main$3 = defineComponent({
|
|
|
3827
4382
|
const canCenter = ref(false);
|
|
3828
4383
|
const node = computed(() => editorService?.get("node"));
|
|
3829
4384
|
const parent = computed(() => editorService?.get("parent"));
|
|
4385
|
+
const isPage = computed(() => node.value?.type === NodeType.PAGE);
|
|
3830
4386
|
onMounted(() => {
|
|
3831
4387
|
const data = globalThis.localStorage.getItem(COPY_STORAGE_KEY);
|
|
3832
4388
|
canPaste.value = data !== "undefined" && !!data;
|
|
@@ -3835,137 +4391,118 @@ const _sfc_main$3 = defineComponent({
|
|
|
3835
4391
|
if (!parent.value || !editorService)
|
|
3836
4392
|
return canCenter.value = false;
|
|
3837
4393
|
const layout = await editorService.getLayout(parent.value);
|
|
3838
|
-
canCenter.value = [Layout.ABSOLUTE, Layout.FIXED].includes(layout) && ![
|
|
4394
|
+
canCenter.value = [Layout.ABSOLUTE, Layout.FIXED].includes(layout) && ![NodeType.ROOT, NodeType.PAGE, "pop"].includes(`${node.value?.type}`);
|
|
3839
4395
|
}, { immediate: true });
|
|
3840
4396
|
return {
|
|
3841
4397
|
menu,
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
4398
|
+
menuData: reactive([
|
|
4399
|
+
{
|
|
4400
|
+
type: "button",
|
|
4401
|
+
text: "\u6C34\u5E73\u5C45\u4E2D",
|
|
4402
|
+
display: () => canCenter.value,
|
|
4403
|
+
handler: () => {
|
|
4404
|
+
node.value && editorService?.alignCenter(node.value);
|
|
4405
|
+
}
|
|
4406
|
+
},
|
|
4407
|
+
{
|
|
4408
|
+
type: "button",
|
|
4409
|
+
text: "\u590D\u5236",
|
|
4410
|
+
icon: markRaw(DocumentCopy),
|
|
4411
|
+
handler: () => {
|
|
4412
|
+
node.value && editorService?.copy(node.value);
|
|
4413
|
+
canPaste.value = true;
|
|
4414
|
+
}
|
|
4415
|
+
},
|
|
4416
|
+
{
|
|
4417
|
+
type: "button",
|
|
4418
|
+
text: "\u7C98\u8D34",
|
|
4419
|
+
display: () => canPaste.value,
|
|
4420
|
+
handler: () => {
|
|
4421
|
+
const top = menu.value?.$el.offsetTop || 0;
|
|
4422
|
+
const left = menu.value?.$el.offsetLeft || 0;
|
|
4423
|
+
editorService?.paste({ left, top });
|
|
4424
|
+
}
|
|
4425
|
+
},
|
|
4426
|
+
{
|
|
4427
|
+
type: "divider",
|
|
4428
|
+
direction: "horizontal",
|
|
4429
|
+
display: () => !isPage.value
|
|
4430
|
+
},
|
|
4431
|
+
{
|
|
4432
|
+
type: "button",
|
|
4433
|
+
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
4434
|
+
icon: markRaw(Top),
|
|
4435
|
+
display: () => !isPage.value,
|
|
4436
|
+
handler: () => {
|
|
4437
|
+
editorService?.moveLayer(1);
|
|
4438
|
+
}
|
|
4439
|
+
},
|
|
4440
|
+
{
|
|
4441
|
+
type: "button",
|
|
4442
|
+
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
4443
|
+
icon: markRaw(Bottom),
|
|
4444
|
+
display: () => !isPage.value,
|
|
4445
|
+
handler: () => {
|
|
4446
|
+
editorService?.moveLayer(-1);
|
|
4447
|
+
}
|
|
4448
|
+
},
|
|
4449
|
+
{
|
|
4450
|
+
type: "button",
|
|
4451
|
+
text: "\u7F6E\u9876",
|
|
4452
|
+
display: () => !isPage.value,
|
|
4453
|
+
handler: () => {
|
|
4454
|
+
editorService?.moveLayer(LayerOffset.TOP);
|
|
4455
|
+
}
|
|
4456
|
+
},
|
|
4457
|
+
{
|
|
4458
|
+
type: "button",
|
|
4459
|
+
text: "\u7F6E\u5E95",
|
|
4460
|
+
display: () => !isPage.value,
|
|
4461
|
+
handler: () => {
|
|
4462
|
+
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
4463
|
+
}
|
|
4464
|
+
},
|
|
4465
|
+
{
|
|
4466
|
+
type: "divider",
|
|
4467
|
+
direction: "horizontal",
|
|
4468
|
+
display: () => !isPage.value
|
|
4469
|
+
},
|
|
4470
|
+
{
|
|
4471
|
+
type: "button",
|
|
4472
|
+
text: "\u5220\u9664",
|
|
4473
|
+
icon: Delete,
|
|
4474
|
+
display: () => !isPage.value,
|
|
4475
|
+
handler: () => {
|
|
4476
|
+
node.value && editorService?.remove(node.value);
|
|
4477
|
+
}
|
|
4478
|
+
},
|
|
4479
|
+
{
|
|
4480
|
+
type: "divider",
|
|
4481
|
+
direction: "horizontal"
|
|
4482
|
+
},
|
|
4483
|
+
{
|
|
4484
|
+
type: "button",
|
|
4485
|
+
text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
|
|
4486
|
+
handler: () => {
|
|
4487
|
+
editorService?.get("stage").clearGuides();
|
|
4488
|
+
}
|
|
4489
|
+
}
|
|
4490
|
+
]),
|
|
4491
|
+
show(e) {
|
|
4492
|
+
menu.value?.show(e);
|
|
3875
4493
|
}
|
|
3876
4494
|
};
|
|
3877
4495
|
}
|
|
3878
4496
|
});
|
|
3879
|
-
const _hoisted_1$1 = {
|
|
3880
|
-
class: "magic-editor-content-menu",
|
|
3881
|
-
ref: "menu"
|
|
3882
|
-
};
|
|
3883
|
-
const _hoisted_2 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
3884
|
-
const _hoisted_3 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
3885
|
-
const _hoisted_4 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
3886
4497
|
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
onClick: _cache[0] || (_cache[0] = () => _ctx.center())
|
|
3893
|
-
}, "\u6C34\u5E73\u5C45\u4E2D")) : createCommentVNode("", true),
|
|
3894
|
-
createElementVNode("div", {
|
|
3895
|
-
class: "magic-editor-content-menu-item",
|
|
3896
|
-
onClick: _cache[1] || (_cache[1] = () => _ctx.copy())
|
|
3897
|
-
}, "\u590D\u5236"),
|
|
3898
|
-
_ctx.canPaste ? (openBlock(), createElementBlock("div", {
|
|
3899
|
-
key: 1,
|
|
3900
|
-
class: "magic-editor-content-menu-item",
|
|
3901
|
-
onClick: _cache[2] || (_cache[2] = (...args) => _ctx.paste && _ctx.paste(...args))
|
|
3902
|
-
}, "\u7C98\u8D34")) : createCommentVNode("", true),
|
|
3903
|
-
_ctx.canMoveZPos ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
3904
|
-
_hoisted_2,
|
|
3905
|
-
createElementVNode("div", {
|
|
3906
|
-
class: "magic-editor-content-menu-item",
|
|
3907
|
-
onClick: _cache[3] || (_cache[3] = (...args) => _ctx.topItem && _ctx.topItem(...args))
|
|
3908
|
-
}, "\u4E0A\u79FB\u4E00\u5C42"),
|
|
3909
|
-
createElementVNode("div", {
|
|
3910
|
-
class: "magic-editor-content-menu-item",
|
|
3911
|
-
onClick: _cache[4] || (_cache[4] = (...args) => _ctx.bottomItem && _ctx.bottomItem(...args))
|
|
3912
|
-
}, "\u4E0B\u79FB\u4E00\u5C42"),
|
|
3913
|
-
createElementVNode("div", {
|
|
3914
|
-
class: "magic-editor-content-menu-item",
|
|
3915
|
-
onClick: _cache[5] || (_cache[5] = (...args) => _ctx.top && _ctx.top(...args))
|
|
3916
|
-
}, "\u7F6E\u9876"),
|
|
3917
|
-
createElementVNode("div", {
|
|
3918
|
-
class: "magic-editor-content-menu-item",
|
|
3919
|
-
onClick: _cache[6] || (_cache[6] = (...args) => _ctx.bottom && _ctx.bottom(...args))
|
|
3920
|
-
}, "\u7F6E\u5E95")
|
|
3921
|
-
], 64)) : createCommentVNode("", true),
|
|
3922
|
-
_ctx.canDelete ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
3923
|
-
_hoisted_3,
|
|
3924
|
-
createElementVNode("div", {
|
|
3925
|
-
class: "magic-editor-content-menu-item",
|
|
3926
|
-
onClick: _cache[7] || (_cache[7] = () => _ctx.remove())
|
|
3927
|
-
}, "\u5220\u9664")
|
|
3928
|
-
], 64)) : createCommentVNode("", true),
|
|
3929
|
-
_hoisted_4,
|
|
3930
|
-
createElementVNode("div", {
|
|
3931
|
-
class: "magic-editor-content-menu-item",
|
|
3932
|
-
onClick: _cache[8] || (_cache[8] = (...args) => _ctx.clearGuides && _ctx.clearGuides(...args))
|
|
3933
|
-
}, "\u6E05\u7A7A\u53C2\u8003\u7EBF")
|
|
3934
|
-
])
|
|
3935
|
-
], 512);
|
|
4498
|
+
const _component_content_menu = resolveComponent("content-menu");
|
|
4499
|
+
return openBlock(), createBlock(_component_content_menu, {
|
|
4500
|
+
"menu-data": _ctx.menuData,
|
|
4501
|
+
ref: "menu"
|
|
4502
|
+
}, null, 8, ["menu-data"]);
|
|
3936
4503
|
}
|
|
3937
4504
|
var ViewerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
|
|
3938
4505
|
|
|
3939
|
-
const useMenu = () => {
|
|
3940
|
-
const menu = ref();
|
|
3941
|
-
const menuStyle = ref({
|
|
3942
|
-
display: "none",
|
|
3943
|
-
left: "0",
|
|
3944
|
-
top: "0"
|
|
3945
|
-
});
|
|
3946
|
-
onMounted(() => {
|
|
3947
|
-
document.addEventListener("click", () => {
|
|
3948
|
-
menuStyle.value.display = "none";
|
|
3949
|
-
}, true);
|
|
3950
|
-
});
|
|
3951
|
-
return {
|
|
3952
|
-
menu,
|
|
3953
|
-
menuStyle,
|
|
3954
|
-
contextmenuHandler(e) {
|
|
3955
|
-
e.preventDefault();
|
|
3956
|
-
const menuHeight = menu.value?.$el.clientHeight;
|
|
3957
|
-
let top = e.clientY;
|
|
3958
|
-
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
3959
|
-
top = document.body.clientHeight - menuHeight;
|
|
3960
|
-
}
|
|
3961
|
-
menuStyle.value = {
|
|
3962
|
-
display: "block",
|
|
3963
|
-
top: `${top}px`,
|
|
3964
|
-
left: `${e.clientX}px`
|
|
3965
|
-
};
|
|
3966
|
-
}
|
|
3967
|
-
};
|
|
3968
|
-
};
|
|
3969
4506
|
const _sfc_main$2 = defineComponent({
|
|
3970
4507
|
name: "magic-stage",
|
|
3971
4508
|
components: {
|
|
@@ -3988,16 +4525,16 @@ const _sfc_main$2 = defineComponent({
|
|
|
3988
4525
|
})
|
|
3989
4526
|
}
|
|
3990
4527
|
},
|
|
3991
|
-
|
|
3992
|
-
setup(props, { emit }) {
|
|
4528
|
+
setup(props) {
|
|
3993
4529
|
const services = inject("services");
|
|
3994
4530
|
const stageWrap = ref();
|
|
3995
4531
|
const stageContainer = ref();
|
|
4532
|
+
const menu = ref();
|
|
3996
4533
|
const stageRect = computed(() => services?.uiService.get("stageRect"));
|
|
3997
4534
|
const uiSelectMode = computed(() => services?.uiService.get("uiSelectMode"));
|
|
3998
4535
|
const root = computed(() => services?.editorService.get("root"));
|
|
3999
4536
|
const page = computed(() => services?.editorService.get("page"));
|
|
4000
|
-
const zoom = computed(() => services?.uiService.get("zoom"));
|
|
4537
|
+
const zoom = computed(() => services?.uiService.get("zoom") || 1);
|
|
4001
4538
|
const node = computed(() => services?.editorService.get("node"));
|
|
4002
4539
|
let stage = null;
|
|
4003
4540
|
let runtime = null;
|
|
@@ -4012,9 +4549,9 @@ const _sfc_main$2 = defineComponent({
|
|
|
4012
4549
|
render: props.render,
|
|
4013
4550
|
runtimeUrl: props.runtimeUrl,
|
|
4014
4551
|
zoom: zoom.value,
|
|
4015
|
-
canSelect: (el, stop) => {
|
|
4552
|
+
canSelect: (el, event, stop) => {
|
|
4016
4553
|
const elCanSelect = props.canSelect(el);
|
|
4017
|
-
if (uiSelectMode.value && elCanSelect) {
|
|
4554
|
+
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
4018
4555
|
document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
|
|
4019
4556
|
return stop();
|
|
4020
4557
|
}
|
|
@@ -4022,14 +4559,19 @@ const _sfc_main$2 = defineComponent({
|
|
|
4022
4559
|
},
|
|
4023
4560
|
moveableOptions: props.moveableOptions
|
|
4024
4561
|
});
|
|
4025
|
-
services?.editorService.set("stage", stage);
|
|
4562
|
+
services?.editorService.set("stage", markRaw(stage));
|
|
4026
4563
|
stage?.mount(stageContainer.value);
|
|
4027
|
-
stage?.on("select", (el) =>
|
|
4564
|
+
stage?.on("select", (el) => {
|
|
4565
|
+
services?.editorService.select(el.id);
|
|
4566
|
+
});
|
|
4567
|
+
stage?.on("highlight", (el) => {
|
|
4568
|
+
services?.editorService.highlight(el.id);
|
|
4569
|
+
});
|
|
4028
4570
|
stage?.on("update", (ev) => {
|
|
4029
|
-
|
|
4571
|
+
services?.editorService.update({ id: ev.el.id, style: ev.style });
|
|
4030
4572
|
});
|
|
4031
4573
|
stage?.on("sort", (ev) => {
|
|
4032
|
-
|
|
4574
|
+
services?.editorService.sort(ev.src, ev.dist);
|
|
4033
4575
|
});
|
|
4034
4576
|
stage?.on("changeGuides", () => {
|
|
4035
4577
|
services?.uiService.set("showGuides", true);
|
|
@@ -4055,11 +4597,6 @@ const _sfc_main$2 = defineComponent({
|
|
|
4055
4597
|
runtime.updateRootConfig(cloneDeep(toRaw(root2)));
|
|
4056
4598
|
}
|
|
4057
4599
|
});
|
|
4058
|
-
watch(() => node.value?.id, (id) => {
|
|
4059
|
-
nextTick(() => {
|
|
4060
|
-
id && stage?.select(id);
|
|
4061
|
-
});
|
|
4062
|
-
});
|
|
4063
4600
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
4064
4601
|
for (const { contentRect } of entries) {
|
|
4065
4602
|
services?.uiService.set("stageContainerRect", {
|
|
@@ -4079,9 +4616,36 @@ const _sfc_main$2 = defineComponent({
|
|
|
4079
4616
|
return {
|
|
4080
4617
|
stageWrap,
|
|
4081
4618
|
stageContainer,
|
|
4619
|
+
menu,
|
|
4082
4620
|
stageRect,
|
|
4083
4621
|
zoom,
|
|
4084
|
-
|
|
4622
|
+
contextmenuHandler(e2) {
|
|
4623
|
+
e2.preventDefault();
|
|
4624
|
+
menu.value?.show(e2);
|
|
4625
|
+
},
|
|
4626
|
+
dragoverHandler(e2) {
|
|
4627
|
+
e2.preventDefault();
|
|
4628
|
+
if (e2.dataTransfer) {
|
|
4629
|
+
e2.dataTransfer.dropEffect = "move";
|
|
4630
|
+
}
|
|
4631
|
+
},
|
|
4632
|
+
async dropHandler(e) {
|
|
4633
|
+
e.preventDefault();
|
|
4634
|
+
if (e.dataTransfer && page.value && stageContainer.value && stage) {
|
|
4635
|
+
const config = eval(`(${e.dataTransfer.getData("data")})`);
|
|
4636
|
+
const layout = await services?.editorService.getLayout(page.value);
|
|
4637
|
+
const containerRect = stageContainer.value.getBoundingClientRect();
|
|
4638
|
+
const { scrollTop, scrollLeft } = stage.mask;
|
|
4639
|
+
if (layout === Layout.ABSOLUTE) {
|
|
4640
|
+
config.style = {
|
|
4641
|
+
position: "absolute",
|
|
4642
|
+
top: e.clientY - containerRect.top + scrollTop,
|
|
4643
|
+
left: e.clientX - containerRect.left + scrollLeft
|
|
4644
|
+
};
|
|
4645
|
+
}
|
|
4646
|
+
services?.editorService.add(config, page.value);
|
|
4647
|
+
}
|
|
4648
|
+
}
|
|
4085
4649
|
};
|
|
4086
4650
|
}
|
|
4087
4651
|
});
|
|
@@ -4099,14 +4663,13 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4099
4663
|
createElementVNode("div", {
|
|
4100
4664
|
class: "m-editor-stage-container",
|
|
4101
4665
|
ref: "stageContainer",
|
|
4666
|
+
style: normalizeStyle(`transform: scale(${_ctx.zoom})`),
|
|
4102
4667
|
onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
|
|
4103
|
-
|
|
4668
|
+
onDrop: _cache[1] || (_cache[1] = (...args) => _ctx.dropHandler && _ctx.dropHandler(...args)),
|
|
4669
|
+
onDragover: _cache[2] || (_cache[2] = (...args) => _ctx.dragoverHandler && _ctx.dragoverHandler(...args))
|
|
4104
4670
|
}, null, 36),
|
|
4105
4671
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
4106
|
-
createVNode(_component_viewer_menu, {
|
|
4107
|
-
ref: "menu",
|
|
4108
|
-
style: normalizeStyle(_ctx.menuStyle)
|
|
4109
|
-
}, null, 8, ["style"])
|
|
4672
|
+
createVNode(_component_viewer_menu, { ref: "menu" }, null, 512)
|
|
4110
4673
|
]))
|
|
4111
4674
|
]),
|
|
4112
4675
|
_: 1
|
|
@@ -4134,21 +4697,93 @@ const _sfc_main$1 = defineComponent({
|
|
|
4134
4697
|
},
|
|
4135
4698
|
setup() {
|
|
4136
4699
|
const services = inject("services");
|
|
4700
|
+
const workspace = ref();
|
|
4701
|
+
const node = computed(() => services?.editorService.get("node"));
|
|
4702
|
+
let keycon;
|
|
4703
|
+
const mouseenterHandler = () => {
|
|
4704
|
+
workspace.value?.focus();
|
|
4705
|
+
};
|
|
4706
|
+
onMounted(() => {
|
|
4707
|
+
workspace.value?.addEventListener("mouseenter", mouseenterHandler);
|
|
4708
|
+
keycon = new KeyController(workspace.value);
|
|
4709
|
+
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
4710
|
+
const ctrl = isMac ? "meta" : "ctrl";
|
|
4711
|
+
keycon.keyup("delete", (e) => {
|
|
4712
|
+
e.inputEvent.preventDefault();
|
|
4713
|
+
if (!node.value || isPage(node.value))
|
|
4714
|
+
return;
|
|
4715
|
+
services?.editorService.remove(node.value);
|
|
4716
|
+
}).keydown([ctrl, "c"], (e) => {
|
|
4717
|
+
e.inputEvent.preventDefault();
|
|
4718
|
+
node.value && services?.editorService.copy(node.value);
|
|
4719
|
+
}).keydown([ctrl, "v"], (e) => {
|
|
4720
|
+
e.inputEvent.preventDefault();
|
|
4721
|
+
node.value && services?.editorService.paste();
|
|
4722
|
+
}).keydown([ctrl, "x"], (e) => {
|
|
4723
|
+
e.inputEvent.preventDefault();
|
|
4724
|
+
if (!node.value || isPage(node.value))
|
|
4725
|
+
return;
|
|
4726
|
+
services?.editorService.copy(node.value);
|
|
4727
|
+
services?.editorService.remove(node.value);
|
|
4728
|
+
}).keydown([ctrl, "z"], (e) => {
|
|
4729
|
+
e.inputEvent.preventDefault();
|
|
4730
|
+
services?.editorService.undo();
|
|
4731
|
+
}).keydown([ctrl, "shift", "z"], (e) => {
|
|
4732
|
+
e.inputEvent.preventDefault();
|
|
4733
|
+
services?.editorService.redo();
|
|
4734
|
+
}).keydown("up", (e) => {
|
|
4735
|
+
e.inputEvent.preventDefault();
|
|
4736
|
+
services?.editorService.move(0, -1);
|
|
4737
|
+
}).keydown("down", (e) => {
|
|
4738
|
+
e.inputEvent.preventDefault();
|
|
4739
|
+
services?.editorService.move(0, 1);
|
|
4740
|
+
}).keydown("left", (e) => {
|
|
4741
|
+
e.inputEvent.preventDefault();
|
|
4742
|
+
services?.editorService.move(-1, 0);
|
|
4743
|
+
}).keydown("right", (e) => {
|
|
4744
|
+
e.inputEvent.preventDefault();
|
|
4745
|
+
services?.editorService.move(1, 0);
|
|
4746
|
+
}).keydown([ctrl, "up"], (e) => {
|
|
4747
|
+
e.inputEvent.preventDefault();
|
|
4748
|
+
services?.editorService.move(0, -10);
|
|
4749
|
+
}).keydown([ctrl, "down"], (e) => {
|
|
4750
|
+
e.inputEvent.preventDefault();
|
|
4751
|
+
services?.editorService.move(0, 10);
|
|
4752
|
+
}).keydown([ctrl, "left"], (e) => {
|
|
4753
|
+
e.inputEvent.preventDefault();
|
|
4754
|
+
services?.editorService.move(-10, 0);
|
|
4755
|
+
}).keydown([ctrl, "right"], (e) => {
|
|
4756
|
+
e.inputEvent.preventDefault();
|
|
4757
|
+
services?.editorService.move(10, 0);
|
|
4758
|
+
}).keydown("tab", (e) => {
|
|
4759
|
+
e.inputEvent.preventDefault();
|
|
4760
|
+
services?.editorService.selectNextNode();
|
|
4761
|
+
}).keydown([ctrl, "tab"], (e) => {
|
|
4762
|
+
e.inputEvent.preventDefault();
|
|
4763
|
+
services?.editorService.selectNextPage();
|
|
4764
|
+
}).keydown([ctrl, "="], (e) => {
|
|
4765
|
+
e.inputEvent.preventDefault();
|
|
4766
|
+
services?.uiService.zoom(0.1);
|
|
4767
|
+
}).keydown([ctrl, "-"], (e) => {
|
|
4768
|
+
e.inputEvent.preventDefault();
|
|
4769
|
+
services?.uiService.zoom(-0.1);
|
|
4770
|
+
});
|
|
4771
|
+
});
|
|
4772
|
+
onUnmounted(() => {
|
|
4773
|
+
workspace.value?.removeEventListener("mouseenter", mouseenterHandler);
|
|
4774
|
+
keycon.destroy();
|
|
4775
|
+
});
|
|
4137
4776
|
return {
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
services?.editorService.select(el.id);
|
|
4141
|
-
},
|
|
4142
|
-
updateNodeHandler(node) {
|
|
4143
|
-
services?.editorService.update(node);
|
|
4144
|
-
},
|
|
4145
|
-
sortNodeHandler(ev) {
|
|
4146
|
-
services?.editorService.sort(ev.src, ev.dist);
|
|
4147
|
-
}
|
|
4777
|
+
workspace,
|
|
4778
|
+
page: computed(() => services?.editorService.get("page"))
|
|
4148
4779
|
};
|
|
4149
4780
|
}
|
|
4150
4781
|
});
|
|
4151
|
-
const _hoisted_1 = {
|
|
4782
|
+
const _hoisted_1 = {
|
|
4783
|
+
class: "m-editor-workspace",
|
|
4784
|
+
tabindex: "1",
|
|
4785
|
+
ref: "workspace"
|
|
4786
|
+
};
|
|
4152
4787
|
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4153
4788
|
const _component_magic_stage = resolveComponent("magic-stage");
|
|
4154
4789
|
const _component_page_bar = resolveComponent("page-bar");
|
|
@@ -4158,11 +4793,8 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4158
4793
|
"runtime-url": _ctx.runtimeUrl,
|
|
4159
4794
|
render: _ctx.render,
|
|
4160
4795
|
"moveable-options": _ctx.moveableOptions,
|
|
4161
|
-
"can-select": _ctx.canSelect
|
|
4162
|
-
|
|
4163
|
-
onUpdate: _ctx.updateNodeHandler,
|
|
4164
|
-
onSort: _ctx.sortNodeHandler
|
|
4165
|
-
}, null, 8, ["runtime-url", "render", "moveable-options", "can-select", "onSelect", "onUpdate", "onSort"])),
|
|
4796
|
+
"can-select": _ctx.canSelect
|
|
4797
|
+
}, null, 8, ["runtime-url", "render", "moveable-options", "can-select"])),
|
|
4166
4798
|
renderSlot(_ctx.$slots, "workspace-content"),
|
|
4167
4799
|
createVNode(_component_page_bar, null, {
|
|
4168
4800
|
"page-bar-title": withCtx(({ page }) => [
|
|
@@ -4173,16 +4805,16 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4173
4805
|
]),
|
|
4174
4806
|
_: 3
|
|
4175
4807
|
})
|
|
4176
|
-
]);
|
|
4808
|
+
], 512);
|
|
4177
4809
|
}
|
|
4178
4810
|
var Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
4179
4811
|
|
|
4180
4812
|
class ComponentList extends BaseService {
|
|
4181
|
-
state = reactive({
|
|
4182
|
-
list: []
|
|
4183
|
-
});
|
|
4184
4813
|
constructor() {
|
|
4185
4814
|
super([]);
|
|
4815
|
+
this.state = reactive({
|
|
4816
|
+
list: []
|
|
4817
|
+
});
|
|
4186
4818
|
}
|
|
4187
4819
|
setList(componentGroupList) {
|
|
4188
4820
|
this.state.list = componentGroupList;
|
|
@@ -4193,6 +4825,14 @@ class ComponentList extends BaseService {
|
|
|
4193
4825
|
}
|
|
4194
4826
|
var componentListService = new ComponentList();
|
|
4195
4827
|
|
|
4828
|
+
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
4829
|
+
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
4830
|
+
const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
|
|
4831
|
+
const defaultColumnWidth = {
|
|
4832
|
+
left: DEFAULT_LEFT_COLUMN_WIDTH,
|
|
4833
|
+
center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
|
|
4834
|
+
right: DEFAULT_RIGHT_COLUMN_WIDTH
|
|
4835
|
+
};
|
|
4196
4836
|
const state = reactive({
|
|
4197
4837
|
uiSelectMode: false,
|
|
4198
4838
|
showSrc: false,
|
|
@@ -4205,13 +4845,10 @@ const state = reactive({
|
|
|
4205
4845
|
width: 375,
|
|
4206
4846
|
height: 817
|
|
4207
4847
|
},
|
|
4208
|
-
columnWidth:
|
|
4209
|
-
left: 310,
|
|
4210
|
-
center: globalThis.document.body.clientWidth - 310 - 400,
|
|
4211
|
-
right: 400
|
|
4212
|
-
},
|
|
4848
|
+
columnWidth: defaultColumnWidth,
|
|
4213
4849
|
showGuides: true,
|
|
4214
|
-
showRule: true
|
|
4850
|
+
showRule: true,
|
|
4851
|
+
propsPanelSize: "small"
|
|
4215
4852
|
});
|
|
4216
4853
|
class Ui extends BaseService {
|
|
4217
4854
|
constructor() {
|
|
@@ -4221,6 +4858,15 @@ class Ui extends BaseService {
|
|
|
4221
4858
|
center: "auto"
|
|
4222
4859
|
});
|
|
4223
4860
|
});
|
|
4861
|
+
const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
|
|
4862
|
+
if (columnWidthCacheData) {
|
|
4863
|
+
try {
|
|
4864
|
+
const columnWidthCache = JSON.parse(columnWidthCacheData);
|
|
4865
|
+
this.setColumnWidth(columnWidthCache);
|
|
4866
|
+
} catch (e) {
|
|
4867
|
+
console.error(e);
|
|
4868
|
+
}
|
|
4869
|
+
}
|
|
4224
4870
|
}
|
|
4225
4871
|
set(name, value) {
|
|
4226
4872
|
const mask = editorService.get("stage")?.mask;
|
|
@@ -4246,6 +4892,11 @@ class Ui extends BaseService {
|
|
|
4246
4892
|
get(name) {
|
|
4247
4893
|
return state[name];
|
|
4248
4894
|
}
|
|
4895
|
+
zoom(zoom) {
|
|
4896
|
+
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
4897
|
+
if (this.get("zoom") < 0.1)
|
|
4898
|
+
this.set("zoom", 0.1);
|
|
4899
|
+
}
|
|
4249
4900
|
setColumnWidth({ left, center, right }) {
|
|
4250
4901
|
const columnWidth = {
|
|
4251
4902
|
...toRaw(this.get("columnWidth"))
|
|
@@ -4259,9 +4910,15 @@ class Ui extends BaseService {
|
|
|
4259
4910
|
if (!center || center === "auto") {
|
|
4260
4911
|
const bodyWidth = globalThis.document.body.clientWidth;
|
|
4261
4912
|
columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
|
|
4913
|
+
if (columnWidth.center <= 0) {
|
|
4914
|
+
columnWidth.left = defaultColumnWidth.left;
|
|
4915
|
+
columnWidth.center = defaultColumnWidth.center;
|
|
4916
|
+
columnWidth.right = defaultColumnWidth.right;
|
|
4917
|
+
}
|
|
4262
4918
|
} else {
|
|
4263
4919
|
columnWidth.center = center;
|
|
4264
4920
|
}
|
|
4921
|
+
globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
|
|
4265
4922
|
state.columnWidth = columnWidth;
|
|
4266
4923
|
}
|
|
4267
4924
|
setStageRect(value) {
|
|
@@ -4459,5 +5116,5 @@ var index = {
|
|
|
4459
5116
|
}
|
|
4460
5117
|
};
|
|
4461
5118
|
|
|
4462
|
-
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 };
|
|
5119
|
+
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 };
|
|
4463
5120
|
//# sourceMappingURL=tmagic-editor.es.js.map
|