@tmagic/editor 1.0.0-beta.9 → 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/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 +65 -33
- package/dist/tmagic-editor.es.js +1379 -806
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +1381 -808
- 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 -7
- package/dist/types/src/services/BaseService.d.ts +4 -1
- package/dist/types/src/services/editor.d.ts +5 -2
- 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 +15 -9
- package/dist/types/src/utils/editor.d.ts +4 -3
- package/dist/types/src/utils/polyfills.d.ts +0 -0
- package/package.json +36 -12
- package/src/components/ContentMenu.vue +107 -0
- package/src/components/ScrollViewer.vue +1 -1
- package/src/components/ToolButton.vue +69 -30
- package/src/fields/UISelect.vue +14 -6
- package/src/index.ts +2 -0
- package/src/layouts/CodeEditor.vue +20 -10
- package/src/layouts/Framework.vue +6 -6
- package/src/layouts/PropsPanel.vue +4 -3
- package/src/layouts/sidebar/ComponentListPanel.vue +25 -3
- package/src/layouts/sidebar/LayerMenu.vue +91 -96
- package/src/layouts/sidebar/LayerPanel.vue +31 -54
- package/src/layouts/sidebar/Sidebar.vue +13 -52
- package/src/layouts/sidebar/TabPane.vue +68 -0
- package/src/layouts/workspace/PageBar.vue +136 -13
- package/src/layouts/workspace/Stage.vue +50 -75
- package/src/layouts/workspace/ViewerMenu.vue +104 -67
- package/src/layouts/workspace/Workspace.vue +106 -23
- package/src/services/BaseService.ts +70 -22
- package/src/services/editor.ts +148 -39
- 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 +1 -0
- package/src/theme/component-list-panel.scss +2 -0
- package/src/theme/content-menu.scss +33 -26
- package/src/theme/layer-panel.scss +2 -1
- package/src/theme/nav-menu.scss +6 -2
- package/src/theme/page-bar.scss +35 -3
- package/src/theme/props-panel.scss +13 -13
- package/src/type.ts +16 -9
- package/src/utils/editor.ts +31 -6
- 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 -979
- package/dist/types/src/layouts/workspace/Stage.vue.d.ts +0 -193
- 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,15 +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 { Plus, Edit, ArrowDown, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Delete, Files, Coin, CaretBottom } from '@element-plus/icons';
|
|
5
6
|
import { NodeType } from '@tmagic/schema';
|
|
6
|
-
import {
|
|
7
|
-
import { toLine, isPop, getNodePath } from '@tmagic/utils';
|
|
7
|
+
import { toLine, isPop, getNodePath, isNumber, isPage } from '@tmagic/utils';
|
|
8
8
|
import { EventEmitter as EventEmitter$2 } from 'events';
|
|
9
9
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
10
10
|
import { ElMessage } from 'element-plus';
|
|
11
|
+
import KeyController from 'keycon';
|
|
11
12
|
import StageCore from '@tmagic/stage';
|
|
12
13
|
|
|
14
|
+
if (typeof window.global === "undefined") {
|
|
15
|
+
window.global = window;
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
var _export_sfc = (sfc, props) => {
|
|
14
19
|
const target = sfc.__vccOpts || sfc;
|
|
15
20
|
for (const [key, val] of props) {
|
|
@@ -18,7 +23,7 @@ var _export_sfc = (sfc, props) => {
|
|
|
18
23
|
return target;
|
|
19
24
|
};
|
|
20
25
|
|
|
21
|
-
const _sfc_main$
|
|
26
|
+
const _sfc_main$m = defineComponent({
|
|
22
27
|
name: "m-fields-vs-code",
|
|
23
28
|
props: ["model", "name", "config", "prop"],
|
|
24
29
|
emits: ["change"],
|
|
@@ -35,7 +40,7 @@ const _sfc_main$k = defineComponent({
|
|
|
35
40
|
};
|
|
36
41
|
}
|
|
37
42
|
});
|
|
38
|
-
function _sfc_render$
|
|
43
|
+
function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) {
|
|
39
44
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
40
45
|
return openBlock(), createBlock(_component_magic_code_editor, {
|
|
41
46
|
style: normalizeStyle(`height: ${_ctx.height}`),
|
|
@@ -44,9 +49,9 @@ function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
44
49
|
onSave: _ctx.save
|
|
45
50
|
}, null, 8, ["style", "init-values", "language", "onSave"]);
|
|
46
51
|
}
|
|
47
|
-
var Code = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
52
|
+
var Code = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$m]]);
|
|
48
53
|
|
|
49
|
-
const _sfc_main$
|
|
54
|
+
const _sfc_main$l = defineComponent({
|
|
50
55
|
name: "m-fields-code-link",
|
|
51
56
|
props: {
|
|
52
57
|
config: {
|
|
@@ -101,7 +106,7 @@ const _sfc_main$j = defineComponent({
|
|
|
101
106
|
};
|
|
102
107
|
}
|
|
103
108
|
});
|
|
104
|
-
function _sfc_render$
|
|
109
|
+
function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) {
|
|
105
110
|
const _component_m_fields_link = resolveComponent("m-fields-link");
|
|
106
111
|
return openBlock(), createBlock(_component_m_fields_link, {
|
|
107
112
|
config: _ctx.formConfig,
|
|
@@ -110,11 +115,11 @@ function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
110
115
|
onChange: _ctx.changeHandler
|
|
111
116
|
}, null, 8, ["config", "model", "onChange"]);
|
|
112
117
|
}
|
|
113
|
-
var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
118
|
+
var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$l]]);
|
|
114
119
|
|
|
115
120
|
var UISelect_vue_vue_type_style_index_0_lang = '';
|
|
116
121
|
|
|
117
|
-
const _sfc_main$
|
|
122
|
+
const _sfc_main$k = defineComponent({
|
|
118
123
|
name: "m-fields-ui-select",
|
|
119
124
|
props: {
|
|
120
125
|
labelWidth: String,
|
|
@@ -152,6 +157,9 @@ const _sfc_main$i = defineComponent({
|
|
|
152
157
|
}
|
|
153
158
|
};
|
|
154
159
|
return {
|
|
160
|
+
Delete: markRaw(Delete),
|
|
161
|
+
Pointer: markRaw(Pointer),
|
|
162
|
+
Close: markRaw(Close),
|
|
155
163
|
val,
|
|
156
164
|
uiSelectMode,
|
|
157
165
|
toName: computed(() => {
|
|
@@ -176,34 +184,64 @@ const _sfc_main$i = defineComponent({
|
|
|
176
184
|
};
|
|
177
185
|
}
|
|
178
186
|
});
|
|
179
|
-
const _hoisted_1$
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const _hoisted_2$7 = [
|
|
184
|
-
_hoisted_1$e
|
|
185
|
-
];
|
|
186
|
-
const _hoisted_3$5 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-thumb" }, null, -1);
|
|
187
|
-
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");
|
|
188
191
|
return _ctx.uiSelectMode ? (openBlock(), createElementBlock("div", {
|
|
189
192
|
key: 0,
|
|
190
193
|
class: "m-fields-ui-select",
|
|
191
194
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.cancelHandler && _ctx.cancelHandler(...args))
|
|
192
|
-
},
|
|
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", {
|
|
193
208
|
key: 1,
|
|
194
209
|
class: "m-fields-ui-select",
|
|
195
|
-
onClick: _cache[
|
|
210
|
+
onClick: _cache[1] || (_cache[1] = (...args) => _ctx.startSelect && _ctx.startSelect(...args)),
|
|
211
|
+
style: { "display": "flex" }
|
|
196
212
|
}, [
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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"])
|
|
204
242
|
]));
|
|
205
243
|
}
|
|
206
|
-
var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
244
|
+
var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$k]]);
|
|
207
245
|
|
|
208
246
|
const toString = (v, language) => {
|
|
209
247
|
let value = "";
|
|
@@ -220,7 +258,7 @@ const toString = (v, language) => {
|
|
|
220
258
|
}
|
|
221
259
|
return value;
|
|
222
260
|
};
|
|
223
|
-
const _sfc_main$
|
|
261
|
+
const _sfc_main$j = defineComponent({
|
|
224
262
|
name: "magic-code-editor",
|
|
225
263
|
props: {
|
|
226
264
|
initValues: {
|
|
@@ -230,12 +268,16 @@ const _sfc_main$h = defineComponent({
|
|
|
230
268
|
type: [String, Object]
|
|
231
269
|
},
|
|
232
270
|
type: {
|
|
233
|
-
type:
|
|
271
|
+
type: String,
|
|
234
272
|
default: () => ""
|
|
235
273
|
},
|
|
236
274
|
language: {
|
|
237
|
-
type:
|
|
275
|
+
type: String,
|
|
238
276
|
default: () => "javascript"
|
|
277
|
+
},
|
|
278
|
+
options: {
|
|
279
|
+
type: Object,
|
|
280
|
+
default: () => ({})
|
|
239
281
|
}
|
|
240
282
|
},
|
|
241
283
|
emits: ["initd", "save"],
|
|
@@ -245,6 +287,10 @@ const _sfc_main$h = defineComponent({
|
|
|
245
287
|
const values = ref("");
|
|
246
288
|
const loading = ref(false);
|
|
247
289
|
const codeEditor = ref();
|
|
290
|
+
const resizeObserver = new globalThis.ResizeObserver(throttle(() => {
|
|
291
|
+
vsEditor?.layout();
|
|
292
|
+
vsDiffEditor?.layout();
|
|
293
|
+
}, 300));
|
|
248
294
|
const setEditorValue = (v, m) => {
|
|
249
295
|
values.value = toString(v, props.language);
|
|
250
296
|
if (props.type === "diff") {
|
|
@@ -257,10 +303,6 @@ const _sfc_main$h = defineComponent({
|
|
|
257
303
|
}
|
|
258
304
|
return vsEditor?.setValue(values.value);
|
|
259
305
|
};
|
|
260
|
-
const resizeHandler = () => {
|
|
261
|
-
vsEditor?.layout();
|
|
262
|
-
vsDiffEditor?.layout();
|
|
263
|
-
};
|
|
264
306
|
const getEditorValue = () => props.type === "diff" ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue();
|
|
265
307
|
const init = async () => {
|
|
266
308
|
if (!codeEditor.value)
|
|
@@ -271,8 +313,9 @@ const _sfc_main$h = defineComponent({
|
|
|
271
313
|
tabSize: 2,
|
|
272
314
|
theme: "vs-dark",
|
|
273
315
|
fontFamily: 'dm, Menlo, Monaco, "Courier New", monospace',
|
|
274
|
-
fontSize:
|
|
275
|
-
formatOnPaste: true
|
|
316
|
+
fontSize: 14,
|
|
317
|
+
formatOnPaste: true,
|
|
318
|
+
...props.options
|
|
276
319
|
};
|
|
277
320
|
if (props.type === "diff") {
|
|
278
321
|
vsDiffEditor = monaco.editor.createDiffEditor(codeEditor.value, options);
|
|
@@ -293,7 +336,7 @@ const _sfc_main$h = defineComponent({
|
|
|
293
336
|
emit("save", getEditorValue());
|
|
294
337
|
});
|
|
295
338
|
}
|
|
296
|
-
|
|
339
|
+
resizeObserver.observe(codeEditor.value);
|
|
297
340
|
};
|
|
298
341
|
watch(() => props.initValues, (v, preV) => {
|
|
299
342
|
if (v !== preV) {
|
|
@@ -308,7 +351,7 @@ const _sfc_main$h = defineComponent({
|
|
|
308
351
|
init();
|
|
309
352
|
});
|
|
310
353
|
onUnmounted(() => {
|
|
311
|
-
|
|
354
|
+
resizeObserver.disconnect();
|
|
312
355
|
});
|
|
313
356
|
return {
|
|
314
357
|
values,
|
|
@@ -325,14 +368,14 @@ const _sfc_main$h = defineComponent({
|
|
|
325
368
|
};
|
|
326
369
|
}
|
|
327
370
|
});
|
|
328
|
-
const _hoisted_1$
|
|
371
|
+
const _hoisted_1$b = {
|
|
329
372
|
ref: "codeEditor",
|
|
330
373
|
class: "magic-code-editor"
|
|
331
374
|
};
|
|
332
|
-
function _sfc_render$
|
|
333
|
-
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);
|
|
334
377
|
}
|
|
335
|
-
var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
378
|
+
var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$j]]);
|
|
336
379
|
|
|
337
380
|
let $TMAGIC_EDITOR = {};
|
|
338
381
|
const setConfig = (option) => {
|
|
@@ -341,9 +384,6 @@ const setConfig = (option) => {
|
|
|
341
384
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
342
385
|
|
|
343
386
|
class UndoRedo {
|
|
344
|
-
elementList;
|
|
345
|
-
listCursor;
|
|
346
|
-
listMaxSize;
|
|
347
387
|
constructor(listMaxSize = 200) {
|
|
348
388
|
const minListMaxSize = 2;
|
|
349
389
|
this.elementList = [];
|
|
@@ -416,11 +456,40 @@ const compose = (middleware) => {
|
|
|
416
456
|
|
|
417
457
|
const methodName = (prefix, name) => `${prefix}${name[0].toUpperCase()}${name.substring(1)}`;
|
|
418
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
|
+
};
|
|
419
486
|
class BaseService extends EventEmitter$2 {
|
|
420
|
-
|
|
421
|
-
middleware = {};
|
|
422
|
-
constructor(methods) {
|
|
487
|
+
constructor(methods = [], serialMethods = []) {
|
|
423
488
|
super();
|
|
489
|
+
this.pluginOptionsList = {};
|
|
490
|
+
this.middleware = {};
|
|
491
|
+
this.taskList = [];
|
|
492
|
+
this.doingTask = false;
|
|
424
493
|
methods.forEach((propertyName) => {
|
|
425
494
|
const scope = this;
|
|
426
495
|
const sourceMethod = scope[propertyName];
|
|
@@ -432,27 +501,23 @@ class BaseService extends EventEmitter$2 {
|
|
|
432
501
|
const fn = compose(this.middleware[propertyName]);
|
|
433
502
|
Object.defineProperty(scope, propertyName, {
|
|
434
503
|
value: async (...args) => {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
let beforeReturnValue = await beforeMethod(...beforeArgs) || [];
|
|
438
|
-
if (isError(beforeReturnValue))
|
|
439
|
-
throw beforeReturnValue;
|
|
440
|
-
if (!Array.isArray(beforeReturnValue)) {
|
|
441
|
-
beforeReturnValue = [beforeReturnValue];
|
|
442
|
-
}
|
|
443
|
-
beforeArgs = beforeArgs.map((v, index) => {
|
|
444
|
-
if (typeof beforeReturnValue[index] === "undefined")
|
|
445
|
-
return v;
|
|
446
|
-
return beforeReturnValue[index];
|
|
447
|
-
});
|
|
504
|
+
if (!serialMethods.includes(propertyName)) {
|
|
505
|
+
return doAction(args, scope, sourceMethod, beforeMethodName, afterMethodName, fn);
|
|
448
506
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
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();
|
|
454
519
|
}
|
|
455
|
-
return
|
|
520
|
+
return promise;
|
|
456
521
|
}
|
|
457
522
|
});
|
|
458
523
|
});
|
|
@@ -469,19 +534,34 @@ class BaseService extends EventEmitter$2 {
|
|
|
469
534
|
this.pluginOptionsList[methodName2].push(method);
|
|
470
535
|
});
|
|
471
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
|
+
}
|
|
472
546
|
}
|
|
473
547
|
|
|
474
548
|
class History extends BaseService {
|
|
475
|
-
state = reactive({
|
|
476
|
-
pageSteps: {},
|
|
477
|
-
pageId: void 0,
|
|
478
|
-
canRedo: false,
|
|
479
|
-
canUndo: false
|
|
480
|
-
});
|
|
481
549
|
constructor() {
|
|
482
550
|
super([]);
|
|
551
|
+
this.state = reactive({
|
|
552
|
+
pageSteps: {},
|
|
553
|
+
pageId: void 0,
|
|
554
|
+
canRedo: false,
|
|
555
|
+
canUndo: false
|
|
556
|
+
});
|
|
483
557
|
this.on("change", this.setCanUndoRedo);
|
|
484
558
|
}
|
|
559
|
+
reset() {
|
|
560
|
+
this.state.pageSteps = {};
|
|
561
|
+
this.state.pageId = void 0;
|
|
562
|
+
this.state.canRedo = false;
|
|
563
|
+
this.state.canUndo = false;
|
|
564
|
+
}
|
|
485
565
|
changePage(page) {
|
|
486
566
|
if (!page)
|
|
487
567
|
return;
|
|
@@ -545,12 +625,12 @@ class History extends BaseService {
|
|
|
545
625
|
var historyService = new History();
|
|
546
626
|
|
|
547
627
|
class Props extends BaseService {
|
|
548
|
-
state = reactive({
|
|
549
|
-
propsConfigMap: {},
|
|
550
|
-
propsValueMap: {}
|
|
551
|
-
});
|
|
552
628
|
constructor() {
|
|
553
629
|
super(["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue"]);
|
|
630
|
+
this.state = reactive({
|
|
631
|
+
propsConfigMap: {},
|
|
632
|
+
propsValueMap: {}
|
|
633
|
+
});
|
|
554
634
|
}
|
|
555
635
|
setPropsConfigs(configs) {
|
|
556
636
|
Object.keys(configs).forEach((type) => {
|
|
@@ -575,7 +655,7 @@ class Props extends BaseService {
|
|
|
575
655
|
setPropsValue(type, value) {
|
|
576
656
|
this.state.propsValueMap[type] = value;
|
|
577
657
|
}
|
|
578
|
-
async getPropsValue(type) {
|
|
658
|
+
async getPropsValue(type, defaultValue = {}) {
|
|
579
659
|
if (type === "area") {
|
|
580
660
|
const value = await this.getPropsValue("button");
|
|
581
661
|
value.className = "action-area";
|
|
@@ -587,7 +667,7 @@ class Props extends BaseService {
|
|
|
587
667
|
}
|
|
588
668
|
return cloneDeep({
|
|
589
669
|
...getDefaultPropsValue(type),
|
|
590
|
-
...this.state.propsValueMap[type] || {}
|
|
670
|
+
...mergeWith(this.state.propsValueMap[type] || {}, defaultValue)
|
|
591
671
|
});
|
|
592
672
|
}
|
|
593
673
|
}
|
|
@@ -648,7 +728,7 @@ const updatePopId = (oldId, popId, pageConfig) => {
|
|
|
648
728
|
};
|
|
649
729
|
const setNewItemId = (config, parent) => {
|
|
650
730
|
const oldId = config.id;
|
|
651
|
-
config.id = generateId(config.type);
|
|
731
|
+
config.id = generateId(config.type || "component");
|
|
652
732
|
config.name = `${config.name?.replace(/_(\d+)$/, "")}_${config.id}`;
|
|
653
733
|
if (isPop(config) && parent?.type === NodeType.PAGE) {
|
|
654
734
|
updatePopId(oldId, config.id, parent);
|
|
@@ -671,11 +751,25 @@ const toRelative = (node) => {
|
|
|
671
751
|
};
|
|
672
752
|
return node;
|
|
673
753
|
};
|
|
674
|
-
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) => {
|
|
675
769
|
if (layout === Layout.ABSOLUTE) {
|
|
676
770
|
node.style = {
|
|
677
771
|
position: "absolute",
|
|
678
|
-
...node
|
|
772
|
+
...setTop2Middle(node, parentNode, stage)
|
|
679
773
|
};
|
|
680
774
|
return node;
|
|
681
775
|
}
|
|
@@ -722,7 +816,9 @@ const Fixed2Other = async (node, root, getLayout) => {
|
|
|
722
816
|
const cur = path.pop();
|
|
723
817
|
const offset = {
|
|
724
818
|
left: cur?.style?.left || 0,
|
|
725
|
-
top: cur?.style?.top || 0
|
|
819
|
+
top: cur?.style?.top || 0,
|
|
820
|
+
right: "",
|
|
821
|
+
bottom: ""
|
|
726
822
|
};
|
|
727
823
|
path.forEach((value) => {
|
|
728
824
|
offset.left = offset.left - globalThis.parseFloat(value.style?.left || 0);
|
|
@@ -756,16 +852,6 @@ const error = (...args) => {
|
|
|
756
852
|
};
|
|
757
853
|
|
|
758
854
|
class Editor$1 extends BaseService {
|
|
759
|
-
isHistoryStateChange = false;
|
|
760
|
-
state = reactive({
|
|
761
|
-
root: null,
|
|
762
|
-
page: null,
|
|
763
|
-
parent: null,
|
|
764
|
-
node: null,
|
|
765
|
-
stage: null,
|
|
766
|
-
highlightNode: null,
|
|
767
|
-
modifiedNodeIds: /* @__PURE__ */ new Map()
|
|
768
|
-
});
|
|
769
855
|
constructor() {
|
|
770
856
|
super([
|
|
771
857
|
"getLayout",
|
|
@@ -778,14 +864,27 @@ class Editor$1 extends BaseService {
|
|
|
778
864
|
"paste",
|
|
779
865
|
"alignCenter",
|
|
780
866
|
"moveLayer",
|
|
867
|
+
"move",
|
|
781
868
|
"undo",
|
|
782
869
|
"redo",
|
|
783
870
|
"highlight"
|
|
784
|
-
]);
|
|
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
|
+
});
|
|
785
883
|
}
|
|
786
884
|
set(name, value) {
|
|
787
885
|
this.state[name] = value;
|
|
788
886
|
if (name === "root") {
|
|
887
|
+
this.state.pageLength = value?.items?.length || 0;
|
|
789
888
|
this.emit("root-change", value);
|
|
790
889
|
}
|
|
791
890
|
}
|
|
@@ -793,7 +892,7 @@ class Editor$1 extends BaseService {
|
|
|
793
892
|
return this.state[name];
|
|
794
893
|
}
|
|
795
894
|
getNodeInfo(id) {
|
|
796
|
-
const root = this.get("root");
|
|
895
|
+
const root = toRaw(this.get("root"));
|
|
797
896
|
if (!root)
|
|
798
897
|
return {};
|
|
799
898
|
if (id === root.id) {
|
|
@@ -824,11 +923,13 @@ class Editor$1 extends BaseService {
|
|
|
824
923
|
const { parent } = this.getNodeInfo(id);
|
|
825
924
|
return parent;
|
|
826
925
|
}
|
|
827
|
-
async getLayout(node) {
|
|
828
|
-
if (node
|
|
829
|
-
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;
|
|
830
931
|
}
|
|
831
|
-
if (!
|
|
932
|
+
if (!parent.style?.position) {
|
|
832
933
|
return Layout.RELATIVE;
|
|
833
934
|
}
|
|
834
935
|
return Layout.ABSOLUTE;
|
|
@@ -843,19 +944,44 @@ class Editor$1 extends BaseService {
|
|
|
843
944
|
} else {
|
|
844
945
|
historyService.empty();
|
|
845
946
|
}
|
|
947
|
+
this.emit("select", node);
|
|
846
948
|
return node;
|
|
847
949
|
}
|
|
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
|
+
}
|
|
848
972
|
highlight(config2) {
|
|
849
973
|
const { node } = this.selectedConfigExceptionHandler(config2);
|
|
850
|
-
const
|
|
851
|
-
if (
|
|
974
|
+
const currentHighlightNode = this.get("highlightNode");
|
|
975
|
+
if (currentHighlightNode === node)
|
|
852
976
|
return;
|
|
853
977
|
this.set("highlightNode", node);
|
|
854
978
|
}
|
|
855
|
-
async add(
|
|
979
|
+
async add(addNode, parent) {
|
|
980
|
+
const { type, ...config2 } = addNode;
|
|
856
981
|
const curNode = this.get("node");
|
|
857
982
|
let parentNode;
|
|
858
|
-
|
|
983
|
+
const isPage2 = type === NodeType.PAGE;
|
|
984
|
+
if (isPage2) {
|
|
859
985
|
parentNode = this.get("root");
|
|
860
986
|
} else if (parent && typeof parent !== "function") {
|
|
861
987
|
parentNode = parent;
|
|
@@ -866,18 +992,24 @@ class Editor$1 extends BaseService {
|
|
|
866
992
|
}
|
|
867
993
|
if (!parentNode)
|
|
868
994
|
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
869
|
-
const layout = await this.getLayout(parentNode);
|
|
870
|
-
const newNode = initPosition({ ...toRaw(await propsService.getPropsValue(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"));
|
|
871
997
|
if ((parentNode?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && newNode.type !== NodeType.PAGE) {
|
|
872
998
|
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
873
999
|
}
|
|
874
1000
|
parentNode?.items?.push(newNode);
|
|
875
|
-
|
|
1001
|
+
const stage = this.get("stage");
|
|
1002
|
+
await stage?.add({ config: cloneDeep(newNode), root: cloneDeep(this.get("root")) });
|
|
876
1003
|
await this.select(newNode);
|
|
877
1004
|
this.addModifiedNodeId(newNode.id);
|
|
878
|
-
if (
|
|
1005
|
+
if (!isPage2) {
|
|
879
1006
|
this.pushHistoryState();
|
|
880
1007
|
}
|
|
1008
|
+
stage?.select(newNode.id);
|
|
1009
|
+
if (isPage2) {
|
|
1010
|
+
this.state.pageLength += 1;
|
|
1011
|
+
}
|
|
1012
|
+
this.emit("add", newNode);
|
|
881
1013
|
return newNode;
|
|
882
1014
|
}
|
|
883
1015
|
async remove(node) {
|
|
@@ -893,14 +1025,31 @@ class Editor$1 extends BaseService {
|
|
|
893
1025
|
if (typeof index !== "number" || index === -1)
|
|
894
1026
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
895
1027
|
parent.items?.splice(index, 1);
|
|
896
|
-
|
|
1028
|
+
const stage = this.get("stage");
|
|
1029
|
+
stage?.remove({ id: node.id, root: this.get("root") });
|
|
897
1030
|
if (node.type === NodeType.PAGE) {
|
|
898
|
-
|
|
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
|
+
}
|
|
899
1046
|
} else {
|
|
900
1047
|
await this.select(parent);
|
|
1048
|
+
stage?.select(parent.id);
|
|
901
1049
|
}
|
|
902
1050
|
this.addModifiedNodeId(parent.id);
|
|
903
1051
|
this.pushHistoryState();
|
|
1052
|
+
this.emit("remove", node);
|
|
904
1053
|
return node;
|
|
905
1054
|
}
|
|
906
1055
|
async update(config2) {
|
|
@@ -935,7 +1084,7 @@ class Editor$1 extends BaseService {
|
|
|
935
1084
|
newConfig = setLayout(newConfig, newLayout);
|
|
936
1085
|
}
|
|
937
1086
|
parentNodeItems[index] = newConfig;
|
|
938
|
-
if (newConfig.id === this.get("node").id) {
|
|
1087
|
+
if (`${newConfig.id}` === `${this.get("node").id}`) {
|
|
939
1088
|
this.set("node", newConfig);
|
|
940
1089
|
}
|
|
941
1090
|
this.get("stage")?.update({ config: cloneDeep(newConfig), root: this.get("root") });
|
|
@@ -944,6 +1093,7 @@ class Editor$1 extends BaseService {
|
|
|
944
1093
|
}
|
|
945
1094
|
this.addModifiedNodeId(newConfig.id);
|
|
946
1095
|
this.pushHistoryState();
|
|
1096
|
+
this.emit("update", newConfig);
|
|
947
1097
|
return newConfig;
|
|
948
1098
|
}
|
|
949
1099
|
async sort(id1, id2) {
|
|
@@ -987,7 +1137,7 @@ class Editor$1 extends BaseService {
|
|
|
987
1137
|
async alignCenter(config2) {
|
|
988
1138
|
const parent = this.get("parent");
|
|
989
1139
|
const node = this.get("node");
|
|
990
|
-
const layout = await this.getLayout(parent);
|
|
1140
|
+
const layout = await this.getLayout(toRaw(parent), toRaw(node));
|
|
991
1141
|
if (layout === Layout.RELATIVE) {
|
|
992
1142
|
return;
|
|
993
1143
|
}
|
|
@@ -1024,6 +1174,26 @@ class Editor$1 extends BaseService {
|
|
|
1024
1174
|
await this.changeHistoryState(value);
|
|
1025
1175
|
return value;
|
|
1026
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
|
+
}
|
|
1027
1197
|
destroy() {
|
|
1028
1198
|
this.removeAllListeners();
|
|
1029
1199
|
this.set("root", null);
|
|
@@ -1056,7 +1226,12 @@ class Editor$1 extends BaseService {
|
|
|
1056
1226
|
this.isHistoryStateChange = true;
|
|
1057
1227
|
await this.update(value.data);
|
|
1058
1228
|
this.set("modifiedNodeIds", value.modifiedNodeIds);
|
|
1059
|
-
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);
|
|
1060
1235
|
}
|
|
1061
1236
|
async toggleFixedPosition(dist, src, root) {
|
|
1062
1237
|
let newConfig = cloneDeep(dist);
|
|
@@ -1248,6 +1423,25 @@ const fillConfig = (config = []) => [
|
|
|
1248
1423
|
defaultValue: "100% 100%"
|
|
1249
1424
|
}
|
|
1250
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
|
+
]
|
|
1251
1445
|
}
|
|
1252
1446
|
]
|
|
1253
1447
|
}
|
|
@@ -1280,7 +1474,7 @@ const fillConfig = (config = []) => [
|
|
|
1280
1474
|
type: "select",
|
|
1281
1475
|
options: (mForm, { model }) => {
|
|
1282
1476
|
const node = editorService.getNodeById(model.to);
|
|
1283
|
-
if (!node)
|
|
1477
|
+
if (!node?.type)
|
|
1284
1478
|
return [];
|
|
1285
1479
|
return eventsService.getMethod(node.type).map((option) => ({
|
|
1286
1480
|
text: option.label,
|
|
@@ -1315,7 +1509,7 @@ const getDefaultPropsValue = (type) => ({
|
|
|
1315
1509
|
name: type
|
|
1316
1510
|
});
|
|
1317
1511
|
|
|
1318
|
-
const _sfc_main$
|
|
1512
|
+
const _sfc_main$i = defineComponent({
|
|
1319
1513
|
components: { Plus },
|
|
1320
1514
|
setup() {
|
|
1321
1515
|
const services = inject("services");
|
|
@@ -1332,14 +1526,14 @@ const _sfc_main$g = defineComponent({
|
|
|
1332
1526
|
};
|
|
1333
1527
|
}
|
|
1334
1528
|
});
|
|
1335
|
-
const _hoisted_1$
|
|
1336
|
-
const _hoisted_2$
|
|
1337
|
-
const _hoisted_3$
|
|
1338
|
-
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) {
|
|
1339
1533
|
const _component_plus = resolveComponent("plus");
|
|
1340
1534
|
const _component_el_icon = resolveComponent("el-icon");
|
|
1341
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
1342
|
-
createElementVNode("div", _hoisted_2$
|
|
1535
|
+
return openBlock(), createElementBlock("div", _hoisted_1$a, [
|
|
1536
|
+
createElementVNode("div", _hoisted_2$4, [
|
|
1343
1537
|
createElementVNode("div", {
|
|
1344
1538
|
class: "m-editor-empty-button",
|
|
1345
1539
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
|
|
@@ -1352,12 +1546,12 @@ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1352
1546
|
_: 1
|
|
1353
1547
|
})
|
|
1354
1548
|
]),
|
|
1355
|
-
_hoisted_3$
|
|
1549
|
+
_hoisted_3$2
|
|
1356
1550
|
])
|
|
1357
1551
|
])
|
|
1358
1552
|
]);
|
|
1359
1553
|
}
|
|
1360
|
-
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1554
|
+
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
|
|
1361
1555
|
|
|
1362
1556
|
/*
|
|
1363
1557
|
Copyright (c) 2018 Daybrush
|
|
@@ -1761,8 +1955,8 @@ Copyright (c) 2019 Daybrush
|
|
|
1761
1955
|
name: gesto
|
|
1762
1956
|
license: MIT
|
|
1763
1957
|
author: Daybrush
|
|
1764
|
-
repository: git+https://github.com/daybrush/
|
|
1765
|
-
version: 1.
|
|
1958
|
+
repository: git+https://github.com/daybrush/gesto.git
|
|
1959
|
+
version: 1.7.0
|
|
1766
1960
|
*/
|
|
1767
1961
|
|
|
1768
1962
|
/*! *****************************************************************************
|
|
@@ -1931,19 +2125,6 @@ function () {
|
|
|
1931
2125
|
|
|
1932
2126
|
var __proto = ClientStore.prototype;
|
|
1933
2127
|
|
|
1934
|
-
__proto.addClients = function (clients) {
|
|
1935
|
-
if (clients === void 0) {
|
|
1936
|
-
clients = this.prevClients;
|
|
1937
|
-
}
|
|
1938
|
-
|
|
1939
|
-
var position = this.getPosition(clients);
|
|
1940
|
-
var deltaX = position.deltaX,
|
|
1941
|
-
deltaY = position.deltaY;
|
|
1942
|
-
this.movement += Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
1943
|
-
this.prevClients = clients;
|
|
1944
|
-
return position;
|
|
1945
|
-
};
|
|
1946
|
-
|
|
1947
2128
|
__proto.getAngle = function (clients) {
|
|
1948
2129
|
if (clients === void 0) {
|
|
1949
2130
|
clients = this.prevClients;
|
|
@@ -1960,8 +2141,17 @@ function () {
|
|
|
1960
2141
|
return getRotatiion(clients) - getRotatiion(this.startClients);
|
|
1961
2142
|
};
|
|
1962
2143
|
|
|
1963
|
-
__proto.getPosition = function (clients) {
|
|
1964
|
-
|
|
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;
|
|
1965
2155
|
};
|
|
1966
2156
|
|
|
1967
2157
|
__proto.getPositions = function (clients) {
|
|
@@ -2010,10 +2200,6 @@ function () {
|
|
|
2010
2200
|
client.clientX -= deltaX;
|
|
2011
2201
|
client.clientY -= deltaY;
|
|
2012
2202
|
});
|
|
2013
|
-
this.prevClients.forEach(function (client) {
|
|
2014
|
-
client.clientX -= deltaX;
|
|
2015
|
-
client.clientY -= deltaY;
|
|
2016
|
-
});
|
|
2017
2203
|
};
|
|
2018
2204
|
|
|
2019
2205
|
return ClientStore;
|
|
@@ -2052,6 +2238,7 @@ function (_super) {
|
|
|
2052
2238
|
_this.targets = [];
|
|
2053
2239
|
_this.prevTime = 0;
|
|
2054
2240
|
_this.doubleFlag = false;
|
|
2241
|
+
_this._dragFlag = false;
|
|
2055
2242
|
|
|
2056
2243
|
_this.onDragStart = function (e, isTrusted) {
|
|
2057
2244
|
if (isTrusted === void 0) {
|
|
@@ -2082,7 +2269,8 @@ function (_super) {
|
|
|
2082
2269
|
if (checkInput || activeElement === target) {
|
|
2083
2270
|
// force false or already focused.
|
|
2084
2271
|
return false;
|
|
2085
|
-
}
|
|
2272
|
+
} // no focus
|
|
2273
|
+
|
|
2086
2274
|
|
|
2087
2275
|
if (activeElement && hasContentEditable && activeElement.isContentEditable && activeElement.contains(target)) {
|
|
2088
2276
|
return false;
|
|
@@ -2098,6 +2286,7 @@ function (_super) {
|
|
|
2098
2286
|
_this.clientStores = [new ClientStore(getEventClients(e))];
|
|
2099
2287
|
_this.flag = true;
|
|
2100
2288
|
_this.isDrag = false;
|
|
2289
|
+
_this._dragFlag = true;
|
|
2101
2290
|
_this.datas = {};
|
|
2102
2291
|
|
|
2103
2292
|
if (preventRightClick && (e.which === 3 || e.button === 2)) {
|
|
@@ -2113,7 +2302,14 @@ function (_super) {
|
|
|
2113
2302
|
inputEvent: e,
|
|
2114
2303
|
isTrusted: isTrusted,
|
|
2115
2304
|
isDouble: _this.doubleFlag
|
|
2116
|
-
}, _this.getCurrentStore().getPosition()
|
|
2305
|
+
}, _this.getCurrentStore().getPosition(), {
|
|
2306
|
+
preventDefault: function () {
|
|
2307
|
+
e.preventDefault();
|
|
2308
|
+
},
|
|
2309
|
+
preventDrag: function () {
|
|
2310
|
+
_this._dragFlag = false;
|
|
2311
|
+
}
|
|
2312
|
+
}));
|
|
2117
2313
|
|
|
2118
2314
|
if (result === false) {
|
|
2119
2315
|
_this.initDrag();
|
|
@@ -2162,24 +2358,26 @@ function (_super) {
|
|
|
2162
2358
|
|
|
2163
2359
|
var result = _this.moveClients(clients, e, false);
|
|
2164
2360
|
|
|
2165
|
-
if (_this.
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
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
|
+
}));
|
|
2170
2367
|
|
|
2171
|
-
|
|
2172
|
-
|
|
2368
|
+
if (dragResult === false) {
|
|
2369
|
+
_this.stop();
|
|
2173
2370
|
|
|
2174
|
-
|
|
2371
|
+
return;
|
|
2372
|
+
}
|
|
2175
2373
|
}
|
|
2176
|
-
}
|
|
2177
2374
|
|
|
2178
|
-
|
|
2179
|
-
|
|
2375
|
+
if (_this.pinchFlag) {
|
|
2376
|
+
_this.onPinch(e, clients);
|
|
2377
|
+
}
|
|
2180
2378
|
}
|
|
2181
2379
|
|
|
2182
|
-
_this.getCurrentStore().
|
|
2380
|
+
_this.getCurrentStore().getPosition(clients, true);
|
|
2183
2381
|
};
|
|
2184
2382
|
|
|
2185
2383
|
_this.onDragEnd = function (e) {
|
|
@@ -2197,7 +2395,7 @@ function (_super) {
|
|
|
2197
2395
|
|
|
2198
2396
|
_this.flag = false;
|
|
2199
2397
|
|
|
2200
|
-
var position = _this.
|
|
2398
|
+
var position = _this._getPosition();
|
|
2201
2399
|
|
|
2202
2400
|
var currentTime = now();
|
|
2203
2401
|
var isDouble = !_this.isDrag && _this.doubleFlag;
|
|
@@ -2391,7 +2589,23 @@ function (_super) {
|
|
|
2391
2589
|
return this;
|
|
2392
2590
|
};
|
|
2393
2591
|
/**
|
|
2394
|
-
*
|
|
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.
|
|
2395
2609
|
*/
|
|
2396
2610
|
|
|
2397
2611
|
|
|
@@ -2507,9 +2721,12 @@ function (_super) {
|
|
|
2507
2721
|
};
|
|
2508
2722
|
|
|
2509
2723
|
__proto.moveClients = function (clients, inputEvent, isAdd) {
|
|
2510
|
-
var
|
|
2511
|
-
|
|
2512
|
-
|
|
2724
|
+
var position = this._getPosition(clients, isAdd);
|
|
2725
|
+
|
|
2726
|
+
if (position.deltaX || position.deltaY) {
|
|
2727
|
+
this.isDrag = true;
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2513
2730
|
return __assign({
|
|
2514
2731
|
datas: this.datas
|
|
2515
2732
|
}, position, {
|
|
@@ -2521,12 +2738,31 @@ function (_super) {
|
|
|
2521
2738
|
});
|
|
2522
2739
|
};
|
|
2523
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
|
+
|
|
2524
2760
|
return Gesto;
|
|
2525
2761
|
}(EventEmitter$1);
|
|
2526
2762
|
|
|
2527
2763
|
var Gesto$1 = Gesto;
|
|
2528
2764
|
|
|
2529
|
-
const _sfc_main$
|
|
2765
|
+
const _sfc_main$h = defineComponent({
|
|
2530
2766
|
name: "m-editor-resize",
|
|
2531
2767
|
props: {
|
|
2532
2768
|
type: {
|
|
@@ -2568,33 +2804,33 @@ const _sfc_main$f = defineComponent({
|
|
|
2568
2804
|
};
|
|
2569
2805
|
}
|
|
2570
2806
|
});
|
|
2571
|
-
const _hoisted_1$
|
|
2807
|
+
const _hoisted_1$9 = {
|
|
2572
2808
|
ref: "target",
|
|
2573
2809
|
class: "m-editor-resizer"
|
|
2574
2810
|
};
|
|
2575
|
-
function _sfc_render$
|
|
2576
|
-
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, [
|
|
2577
2813
|
renderSlot(_ctx.$slots, "default")
|
|
2578
2814
|
], 512);
|
|
2579
2815
|
}
|
|
2580
|
-
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2816
|
+
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
|
|
2581
2817
|
|
|
2582
|
-
const _sfc_main$
|
|
2818
|
+
const _sfc_main$g = defineComponent({
|
|
2583
2819
|
components: {
|
|
2584
2820
|
AddPageBox,
|
|
2585
2821
|
Resizer
|
|
2586
2822
|
},
|
|
2587
2823
|
setup() {
|
|
2588
|
-
const
|
|
2589
|
-
const root = computed(() =>
|
|
2824
|
+
const { editorService, uiService } = inject("services") || {};
|
|
2825
|
+
const root = computed(() => editorService?.get("root"));
|
|
2590
2826
|
return {
|
|
2591
2827
|
root,
|
|
2592
|
-
pageLength: computed(() =>
|
|
2593
|
-
showSrc: computed(() =>
|
|
2594
|
-
columnWidth: computed(() =>
|
|
2828
|
+
pageLength: computed(() => editorService?.get("pageLength") || 0),
|
|
2829
|
+
showSrc: computed(() => uiService?.get("showSrc")),
|
|
2830
|
+
columnWidth: computed(() => uiService?.get("columnWidth")),
|
|
2595
2831
|
saveCode(value) {
|
|
2596
2832
|
try {
|
|
2597
|
-
|
|
2833
|
+
editorService?.set("root", eval(value));
|
|
2598
2834
|
} catch (e) {
|
|
2599
2835
|
console.error(e);
|
|
2600
2836
|
}
|
|
@@ -2602,24 +2838,24 @@ const _sfc_main$e = defineComponent({
|
|
|
2602
2838
|
};
|
|
2603
2839
|
}
|
|
2604
2840
|
});
|
|
2605
|
-
const _hoisted_1$
|
|
2606
|
-
const _hoisted_2$
|
|
2841
|
+
const _hoisted_1$8 = { class: "m-editor" };
|
|
2842
|
+
const _hoisted_2$3 = {
|
|
2607
2843
|
key: 1,
|
|
2608
2844
|
class: "m-editor-content"
|
|
2609
2845
|
};
|
|
2610
|
-
function _sfc_render$
|
|
2846
|
+
function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2611
2847
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
2612
2848
|
const _component_resizer = resolveComponent("resizer");
|
|
2613
2849
|
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
2614
2850
|
const _component_add_page_box = resolveComponent("add-page-box");
|
|
2615
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
2851
|
+
return openBlock(), createElementBlock("div", _hoisted_1$8, [
|
|
2616
2852
|
renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
2617
2853
|
_ctx.showSrc ? (openBlock(), createBlock(_component_magic_code_editor, {
|
|
2618
2854
|
key: 0,
|
|
2619
2855
|
class: "m-editor-content",
|
|
2620
2856
|
"init-values": _ctx.root,
|
|
2621
2857
|
onSave: _ctx.saveCode
|
|
2622
|
-
}, null, 8, ["init-values", "onSave"])) : (openBlock(), createElementBlock("div", _hoisted_2$
|
|
2858
|
+
}, null, 8, ["init-values", "onSave"])) : (openBlock(), createElementBlock("div", _hoisted_2$3, [
|
|
2623
2859
|
createElementVNode("div", {
|
|
2624
2860
|
class: "m-editor-framework-left",
|
|
2625
2861
|
style: normalizeStyle(`width: ${_ctx.columnWidth?.left}px`)
|
|
@@ -2652,9 +2888,9 @@ function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2652
2888
|
]))
|
|
2653
2889
|
]);
|
|
2654
2890
|
}
|
|
2655
|
-
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2891
|
+
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
|
|
2656
2892
|
|
|
2657
|
-
const _sfc_main$
|
|
2893
|
+
const _sfc_main$f = defineComponent({
|
|
2658
2894
|
name: "m-icon",
|
|
2659
2895
|
components: { Edit },
|
|
2660
2896
|
props: {
|
|
@@ -2668,8 +2904,8 @@ const _sfc_main$d = defineComponent({
|
|
|
2668
2904
|
};
|
|
2669
2905
|
}
|
|
2670
2906
|
});
|
|
2671
|
-
const _hoisted_1$
|
|
2672
|
-
function _sfc_render$
|
|
2907
|
+
const _hoisted_1$7 = ["src"];
|
|
2908
|
+
function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2673
2909
|
const _component_edit = resolveComponent("edit");
|
|
2674
2910
|
const _component_el_icon = resolveComponent("el-icon");
|
|
2675
2911
|
return !_ctx.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
|
|
@@ -2680,7 +2916,7 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2680
2916
|
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (openBlock(), createElementBlock("img", {
|
|
2681
2917
|
key: 1,
|
|
2682
2918
|
src: _ctx.icon
|
|
2683
|
-
}, null, 8, _hoisted_1$
|
|
2919
|
+
}, null, 8, _hoisted_1$7)) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
2684
2920
|
key: 2,
|
|
2685
2921
|
class: normalizeClass(_ctx.icon)
|
|
2686
2922
|
}, null, 2)) : (openBlock(), createBlock(_component_el_icon, { key: 3 }, {
|
|
@@ -2690,9 +2926,9 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2690
2926
|
_: 1
|
|
2691
2927
|
}));
|
|
2692
2928
|
}
|
|
2693
|
-
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2929
|
+
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
|
|
2694
2930
|
|
|
2695
|
-
const _sfc_main$
|
|
2931
|
+
const _sfc_main$e = defineComponent({
|
|
2696
2932
|
components: { MIcon, ArrowDown },
|
|
2697
2933
|
props: {
|
|
2698
2934
|
data: {
|
|
@@ -2702,16 +2938,20 @@ const _sfc_main$c = defineComponent({
|
|
|
2702
2938
|
type: "text",
|
|
2703
2939
|
display: false
|
|
2704
2940
|
})
|
|
2941
|
+
},
|
|
2942
|
+
eventType: {
|
|
2943
|
+
type: String,
|
|
2944
|
+
default: "click"
|
|
2705
2945
|
}
|
|
2706
2946
|
},
|
|
2707
2947
|
setup(props) {
|
|
2708
2948
|
const services = inject("services");
|
|
2709
2949
|
const uiService = services?.uiService;
|
|
2710
|
-
const zoomInHandler = () => uiService?.set("zoom", zoom.value + 0.1);
|
|
2711
|
-
const zoomOutHandler = () => uiService?.set("zoom", zoom.value - 0.1);
|
|
2712
2950
|
const zoom = computed(() => uiService?.get("zoom") ?? 1);
|
|
2713
2951
|
const showGuides = computed(() => uiService?.get("showGuides") ?? true);
|
|
2714
2952
|
const showRule = computed(() => uiService?.get("showRule") ?? true);
|
|
2953
|
+
const zoomInHandler = () => uiService?.zoom(0.1);
|
|
2954
|
+
const zoomOutHandler = () => uiService?.zoom(-0.1);
|
|
2715
2955
|
const item = computed(() => {
|
|
2716
2956
|
if (typeof props.data !== "string") {
|
|
2717
2957
|
return props.data;
|
|
@@ -2728,7 +2968,7 @@ const _sfc_main$c = defineComponent({
|
|
|
2728
2968
|
case "delete":
|
|
2729
2969
|
return {
|
|
2730
2970
|
type: "button",
|
|
2731
|
-
icon: Delete,
|
|
2971
|
+
icon: markRaw(Delete),
|
|
2732
2972
|
tooltip: "\u522A\u9664",
|
|
2733
2973
|
disabled: () => services?.editorService.get("node")?.type === NodeType.PAGE,
|
|
2734
2974
|
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
@@ -2736,7 +2976,7 @@ const _sfc_main$c = defineComponent({
|
|
|
2736
2976
|
case "undo":
|
|
2737
2977
|
return {
|
|
2738
2978
|
type: "button",
|
|
2739
|
-
icon: Back,
|
|
2979
|
+
icon: markRaw(Back),
|
|
2740
2980
|
tooltip: "\u540E\u9000",
|
|
2741
2981
|
disabled: () => !services?.historyService.state.canUndo,
|
|
2742
2982
|
handler: () => services?.editorService.undo()
|
|
@@ -2744,7 +2984,7 @@ const _sfc_main$c = defineComponent({
|
|
|
2744
2984
|
case "redo":
|
|
2745
2985
|
return {
|
|
2746
2986
|
type: "button",
|
|
2747
|
-
icon: Right,
|
|
2987
|
+
icon: markRaw(Right),
|
|
2748
2988
|
tooltip: "\u524D\u8FDB",
|
|
2749
2989
|
disabled: () => !services?.historyService.state.canRedo,
|
|
2750
2990
|
handler: () => services?.editorService.redo()
|
|
@@ -2752,28 +2992,28 @@ const _sfc_main$c = defineComponent({
|
|
|
2752
2992
|
case "zoom-in":
|
|
2753
2993
|
return {
|
|
2754
2994
|
type: "button",
|
|
2755
|
-
icon: ZoomIn,
|
|
2995
|
+
icon: markRaw(ZoomIn),
|
|
2756
2996
|
tooltip: "\u653E\u5927",
|
|
2757
2997
|
handler: zoomInHandler
|
|
2758
2998
|
};
|
|
2759
2999
|
case "zoom-out":
|
|
2760
3000
|
return {
|
|
2761
3001
|
type: "button",
|
|
2762
|
-
icon: ZoomOut,
|
|
3002
|
+
icon: markRaw(ZoomOut),
|
|
2763
3003
|
tooltip: "\u7E2E\u5C0F",
|
|
2764
3004
|
handler: zoomOutHandler
|
|
2765
3005
|
};
|
|
2766
3006
|
case "rule":
|
|
2767
3007
|
return {
|
|
2768
3008
|
type: "button",
|
|
2769
|
-
icon: ScaleToOriginal,
|
|
3009
|
+
icon: markRaw(ScaleToOriginal),
|
|
2770
3010
|
tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
|
|
2771
3011
|
handler: () => uiService?.set("showRule", !showRule.value)
|
|
2772
3012
|
};
|
|
2773
3013
|
case "guides":
|
|
2774
3014
|
return {
|
|
2775
3015
|
type: "button",
|
|
2776
|
-
icon: Grid,
|
|
3016
|
+
icon: markRaw(Grid),
|
|
2777
3017
|
tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
|
|
2778
3018
|
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
2779
3019
|
};
|
|
@@ -2794,9 +3034,16 @@ const _sfc_main$c = defineComponent({
|
|
|
2794
3034
|
}
|
|
2795
3035
|
return item.value.disabled;
|
|
2796
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
|
+
};
|
|
2797
3044
|
return {
|
|
2798
|
-
ZoomIn,
|
|
2799
|
-
ZoomOut,
|
|
3045
|
+
ZoomIn: markRaw(ZoomIn),
|
|
3046
|
+
ZoomOut: markRaw(ZoomOut),
|
|
2800
3047
|
item,
|
|
2801
3048
|
zoom,
|
|
2802
3049
|
disabled,
|
|
@@ -2817,31 +3064,42 @@ const _sfc_main$c = defineComponent({
|
|
|
2817
3064
|
command.item.handler(services);
|
|
2818
3065
|
}
|
|
2819
3066
|
},
|
|
2820
|
-
|
|
2821
|
-
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")
|
|
3076
|
+
return;
|
|
3077
|
+
if (item2.type === "button") {
|
|
3078
|
+
buttonHandler(item2, event);
|
|
3079
|
+
}
|
|
3080
|
+
},
|
|
3081
|
+
mouseupHandler(item2, event) {
|
|
3082
|
+
if (props.eventType !== "mouseup")
|
|
2822
3083
|
return;
|
|
2823
|
-
if (
|
|
2824
|
-
item2
|
|
3084
|
+
if (item2.type === "button") {
|
|
3085
|
+
buttonHandler(item2, event);
|
|
2825
3086
|
}
|
|
2826
3087
|
}
|
|
2827
3088
|
};
|
|
2828
3089
|
}
|
|
2829
3090
|
});
|
|
2830
|
-
const _hoisted_1$
|
|
2831
|
-
key: 0,
|
|
2832
|
-
class: "menu-item"
|
|
2833
|
-
};
|
|
2834
|
-
const _hoisted_2$4 = {
|
|
3091
|
+
const _hoisted_1$6 = {
|
|
2835
3092
|
key: 1,
|
|
2836
3093
|
class: "menu-item-text"
|
|
2837
3094
|
};
|
|
2838
|
-
const
|
|
3095
|
+
const _hoisted_2$2 = {
|
|
2839
3096
|
class: "menu-item-text",
|
|
2840
3097
|
style: { "margin": "0 5px" }
|
|
2841
3098
|
};
|
|
2842
|
-
const
|
|
2843
|
-
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) {
|
|
2844
3101
|
const _component_el_divider = resolveComponent("el-divider");
|
|
3102
|
+
const _component_tool_button = resolveComponent("tool-button", true);
|
|
2845
3103
|
const _component_m_icon = resolveComponent("m-icon");
|
|
2846
3104
|
const _component_el_button = resolveComponent("el-button");
|
|
2847
3105
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
@@ -2850,44 +3108,66 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2850
3108
|
const _component_el_dropdown_item = resolveComponent("el-dropdown-item");
|
|
2851
3109
|
const _component_el_dropdown_menu = resolveComponent("el-dropdown-menu");
|
|
2852
3110
|
const _component_el_dropdown = resolveComponent("el-dropdown");
|
|
2853
|
-
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
|
+
}, [
|
|
2854
3118
|
_ctx.item.type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
|
|
2855
3119
|
key: 0,
|
|
2856
|
-
direction: "vertical"
|
|
2857
|
-
})) : _ctx.item.type === "text" ? (openBlock(), createElementBlock("div",
|
|
2858
|
-
createVNode(
|
|
2859
|
-
icon: _ctx.
|
|
2860
|
-
|
|
2861
|
-
}, null, 8, ["
|
|
2862
|
-
createElementVNode("span",
|
|
2863
|
-
createVNode(
|
|
2864
|
-
icon: _ctx.
|
|
2865
|
-
|
|
2866
|
-
}, null, 8, ["
|
|
2867
|
-
], 64)) : _ctx.item.type === "button" ? (openBlock(),
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
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, {
|
|
2891
3171
|
key: 4,
|
|
2892
3172
|
trigger: "click",
|
|
2893
3173
|
disabled: _ctx.disabled,
|
|
@@ -2912,7 +3192,7 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2912
3192
|
})) : createCommentVNode("", true)
|
|
2913
3193
|
]),
|
|
2914
3194
|
default: withCtx(() => [
|
|
2915
|
-
createElementVNode("span",
|
|
3195
|
+
createElementVNode("span", _hoisted_3$1, [
|
|
2916
3196
|
createTextVNode(toDisplayString(_ctx.item.text), 1),
|
|
2917
3197
|
createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2918
3198
|
default: withCtx(() => [
|
|
@@ -2924,11 +3204,11 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2924
3204
|
]),
|
|
2925
3205
|
_: 1
|
|
2926
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)
|
|
2927
|
-
])) : createCommentVNode("", true);
|
|
3207
|
+
], 34)) : createCommentVNode("", true);
|
|
2928
3208
|
}
|
|
2929
|
-
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3209
|
+
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
|
|
2930
3210
|
|
|
2931
|
-
const _sfc_main$
|
|
3211
|
+
const _sfc_main$d = defineComponent({
|
|
2932
3212
|
name: "nav-menu",
|
|
2933
3213
|
components: { ToolButton },
|
|
2934
3214
|
props: {
|
|
@@ -2948,7 +3228,7 @@ const _sfc_main$b = defineComponent({
|
|
|
2948
3228
|
};
|
|
2949
3229
|
}
|
|
2950
3230
|
});
|
|
2951
|
-
function _sfc_render$
|
|
3231
|
+
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2952
3232
|
const _component_tool_button = resolveComponent("tool-button");
|
|
2953
3233
|
return openBlock(), createElementBlock("div", {
|
|
2954
3234
|
class: "m-editor-nav-menu",
|
|
@@ -2970,9 +3250,9 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2970
3250
|
}), 128))
|
|
2971
3251
|
], 4);
|
|
2972
3252
|
}
|
|
2973
|
-
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3253
|
+
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
|
|
2974
3254
|
|
|
2975
|
-
const _sfc_main$
|
|
3255
|
+
const _sfc_main$c = defineComponent({
|
|
2976
3256
|
name: "m-editor-props-panel",
|
|
2977
3257
|
emits: ["mounted"],
|
|
2978
3258
|
setup(props, { emit }) {
|
|
@@ -2987,9 +3267,9 @@ const _sfc_main$a = defineComponent({
|
|
|
2987
3267
|
curFormConfig.value = [];
|
|
2988
3268
|
return;
|
|
2989
3269
|
}
|
|
2990
|
-
values.value = node.value;
|
|
2991
3270
|
const type = node.value.type || (node.value.items ? "container" : "text");
|
|
2992
3271
|
curFormConfig.value = await services?.propsService.getPropsConfig(type) || [];
|
|
3272
|
+
values.value = node.value;
|
|
2993
3273
|
};
|
|
2994
3274
|
watchEffect(init);
|
|
2995
3275
|
services?.propsService.on("props-configs-change", init);
|
|
@@ -3000,6 +3280,7 @@ const _sfc_main$a = defineComponent({
|
|
|
3000
3280
|
values,
|
|
3001
3281
|
configForm,
|
|
3002
3282
|
curFormConfig,
|
|
3283
|
+
propsPanelSize: computed(() => services?.uiService.get("propsPanelSize") || "small"),
|
|
3003
3284
|
async submit() {
|
|
3004
3285
|
try {
|
|
3005
3286
|
const values2 = await configForm.value?.submitForm();
|
|
@@ -3018,21 +3299,21 @@ const _sfc_main$a = defineComponent({
|
|
|
3018
3299
|
};
|
|
3019
3300
|
}
|
|
3020
3301
|
});
|
|
3021
|
-
function _sfc_render$
|
|
3302
|
+
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3022
3303
|
const _component_m_form = resolveComponent("m-form");
|
|
3023
3304
|
return openBlock(), createBlock(_component_m_form, {
|
|
3024
|
-
class:
|
|
3305
|
+
class: normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
|
|
3025
3306
|
"popper-class": "m-editor-props-panel-popper",
|
|
3026
3307
|
ref: "configForm",
|
|
3027
|
-
size:
|
|
3308
|
+
size: _ctx.propsPanelSize,
|
|
3028
3309
|
"init-values": _ctx.values,
|
|
3029
3310
|
config: _ctx.curFormConfig,
|
|
3030
3311
|
onChange: _ctx.submit
|
|
3031
|
-
}, null, 8, ["init-values", "config", "onChange"]);
|
|
3312
|
+
}, null, 8, ["class", "size", "init-values", "config", "onChange"]);
|
|
3032
3313
|
}
|
|
3033
|
-
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3314
|
+
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
|
|
3034
3315
|
|
|
3035
|
-
const _sfc_main$
|
|
3316
|
+
const _sfc_main$b = defineComponent({
|
|
3036
3317
|
name: "ui-component-panel",
|
|
3037
3318
|
components: { MIcon },
|
|
3038
3319
|
setup() {
|
|
@@ -3047,19 +3328,29 @@ const _sfc_main$9 = defineComponent({
|
|
|
3047
3328
|
searchText,
|
|
3048
3329
|
collapseValue,
|
|
3049
3330
|
list,
|
|
3050
|
-
appendComponent({ text, type,
|
|
3331
|
+
appendComponent({ text, type, data = {} }) {
|
|
3051
3332
|
services?.editorService.add({
|
|
3052
3333
|
name: text,
|
|
3053
3334
|
type,
|
|
3054
|
-
...
|
|
3335
|
+
...data
|
|
3055
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
|
+
}
|
|
3056
3347
|
}
|
|
3057
3348
|
};
|
|
3058
3349
|
}
|
|
3059
3350
|
});
|
|
3060
|
-
const _hoisted_1$
|
|
3061
|
-
const _hoisted_2$
|
|
3062
|
-
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) {
|
|
3063
3354
|
const _component_el_input = resolveComponent("el-input");
|
|
3064
3355
|
const _component_m_icon = resolveComponent("m-icon");
|
|
3065
3356
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
@@ -3089,15 +3380,17 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3089
3380
|
name: index
|
|
3090
3381
|
}, {
|
|
3091
3382
|
title: withCtx(() => [
|
|
3092
|
-
_hoisted_1$
|
|
3383
|
+
_hoisted_1$5,
|
|
3093
3384
|
createTextVNode(toDisplayString(group.title), 1)
|
|
3094
3385
|
]),
|
|
3095
3386
|
default: withCtx(() => [
|
|
3096
3387
|
(openBlock(true), createElementBlock(Fragment, null, renderList(group.items, (item) => {
|
|
3097
3388
|
return openBlock(), createElementBlock("div", {
|
|
3098
3389
|
class: "component-item",
|
|
3390
|
+
draggable: "true",
|
|
3099
3391
|
key: item.type,
|
|
3100
|
-
onClick: ($event) => _ctx.appendComponent(item)
|
|
3392
|
+
onClick: ($event) => _ctx.appendComponent(item),
|
|
3393
|
+
onDragstart: ($event) => _ctx.dragstartHandler(item, $event)
|
|
3101
3394
|
}, [
|
|
3102
3395
|
createVNode(_component_m_icon, {
|
|
3103
3396
|
icon: item.icon
|
|
@@ -3112,7 +3405,7 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3112
3405
|
]),
|
|
3113
3406
|
_: 2
|
|
3114
3407
|
}, 1032, ["content"])
|
|
3115
|
-
],
|
|
3408
|
+
], 40, _hoisted_2$1);
|
|
3116
3409
|
}), 128))
|
|
3117
3410
|
]),
|
|
3118
3411
|
_: 2
|
|
@@ -3126,133 +3419,211 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3126
3419
|
_: 1
|
|
3127
3420
|
});
|
|
3128
3421
|
}
|
|
3129
|
-
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3422
|
+
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
|
|
3130
3423
|
|
|
3131
|
-
const _sfc_main$
|
|
3132
|
-
|
|
3424
|
+
const _sfc_main$a = defineComponent({
|
|
3425
|
+
components: { ToolButton },
|
|
3133
3426
|
props: {
|
|
3134
|
-
|
|
3427
|
+
menuData: {
|
|
3135
3428
|
type: Array,
|
|
3136
3429
|
default: () => []
|
|
3137
3430
|
}
|
|
3138
3431
|
},
|
|
3139
|
-
setup(
|
|
3140
|
-
const
|
|
3141
|
-
const
|
|
3142
|
-
const
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
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
|
+
});
|
|
3452
|
+
return {
|
|
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;
|
|
3466
|
+
}
|
|
3467
|
+
menuStyle.value = {
|
|
3468
|
+
top: `${top}px`,
|
|
3469
|
+
left: `${e.clientX}px`
|
|
3470
|
+
};
|
|
3159
3471
|
});
|
|
3160
3472
|
},
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
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
|
+
}
|
|
3169
3485
|
}
|
|
3170
3486
|
};
|
|
3171
3487
|
}
|
|
3172
3488
|
});
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
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);
|
|
3519
|
+
}
|
|
3520
|
+
var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
|
|
3521
|
+
|
|
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"]);
|
|
3241
3610
|
}
|
|
3242
|
-
var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3611
|
+
var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
|
|
3243
3612
|
|
|
3244
3613
|
const throttleTime = 150;
|
|
3245
|
-
const select = (data, editorService) => {
|
|
3614
|
+
const select = async (data, editorService) => {
|
|
3246
3615
|
if (!data.id) {
|
|
3247
3616
|
throw new Error("\u6CA1\u6709id");
|
|
3248
3617
|
}
|
|
3249
|
-
editorService?.select(data);
|
|
3618
|
+
await editorService?.select(data);
|
|
3619
|
+
editorService?.get("stage")?.select(data.id);
|
|
3250
3620
|
};
|
|
3251
3621
|
const highlight = (data, editorService) => {
|
|
3252
3622
|
if (!data?.id) {
|
|
3253
3623
|
throw new Error("\u6CA1\u6709id");
|
|
3254
3624
|
}
|
|
3255
3625
|
editorService?.highlight(data);
|
|
3626
|
+
editorService?.get("stage")?.highlight(data.id);
|
|
3256
3627
|
};
|
|
3257
3628
|
const useDrop = (tree, editorService) => ({
|
|
3258
3629
|
allowDrop: (draggingNode, dropNode, type) => {
|
|
@@ -3307,7 +3678,8 @@ const useStatus = (tree, editorService) => {
|
|
|
3307
3678
|
resolve([]);
|
|
3308
3679
|
},
|
|
3309
3680
|
highlightNode,
|
|
3310
|
-
clickNode: node
|
|
3681
|
+
clickNode: node,
|
|
3682
|
+
expandedKeys: computed(() => node.value ? [node.value.id] : [])
|
|
3311
3683
|
};
|
|
3312
3684
|
};
|
|
3313
3685
|
const useFilter = (tree) => ({
|
|
@@ -3319,67 +3691,46 @@ const useFilter = (tree) => ({
|
|
|
3319
3691
|
let name = "";
|
|
3320
3692
|
if (data.name) {
|
|
3321
3693
|
name = data.name;
|
|
3322
|
-
} else if (data.type) {
|
|
3323
|
-
name = data.type;
|
|
3324
3694
|
} else if (data.items) {
|
|
3325
3695
|
name = "container";
|
|
3326
3696
|
}
|
|
3327
|
-
return name.indexOf(value) !== -1;
|
|
3697
|
+
return `${data.id}${name}${data.type}`.indexOf(value) !== -1;
|
|
3328
3698
|
},
|
|
3329
3699
|
filterTextChangeHandler(val) {
|
|
3330
3700
|
tree.value?.filter(val);
|
|
3331
3701
|
}
|
|
3332
3702
|
});
|
|
3333
|
-
const
|
|
3334
|
-
const menuStyle = ref({
|
|
3335
|
-
position: "absolute",
|
|
3336
|
-
left: "0",
|
|
3337
|
-
top: "0",
|
|
3338
|
-
display: "none"
|
|
3339
|
-
});
|
|
3340
|
-
onMounted(() => {
|
|
3341
|
-
document.addEventListener("click", () => {
|
|
3342
|
-
menuStyle.value.display = "none";
|
|
3343
|
-
}, true);
|
|
3344
|
-
});
|
|
3345
|
-
return {
|
|
3346
|
-
menuStyle,
|
|
3347
|
-
contextmenu(event, data) {
|
|
3348
|
-
const bodyHeight = globalThis.document.body.clientHeight;
|
|
3349
|
-
const left = `${event.clientX + 20}px`;
|
|
3350
|
-
let top = `${event.clientY - 10}px`;
|
|
3351
|
-
if (event.clientY + 300 > bodyHeight) {
|
|
3352
|
-
top = `${bodyHeight - 300}px`;
|
|
3353
|
-
}
|
|
3354
|
-
menuStyle.value.left = left;
|
|
3355
|
-
menuStyle.value.top = top;
|
|
3356
|
-
menuStyle.value.display = "";
|
|
3357
|
-
select(data, editorService);
|
|
3358
|
-
}
|
|
3359
|
-
};
|
|
3360
|
-
};
|
|
3361
|
-
const _sfc_main$7 = defineComponent({
|
|
3703
|
+
const _sfc_main$8 = defineComponent({
|
|
3362
3704
|
name: "magic-editor-layer-panel",
|
|
3363
3705
|
components: { LayerMenu },
|
|
3364
3706
|
setup() {
|
|
3365
3707
|
const services = inject("services");
|
|
3366
3708
|
const tree = ref();
|
|
3709
|
+
const menu = ref();
|
|
3367
3710
|
const clicked = ref(false);
|
|
3368
3711
|
const editorService = services?.editorService;
|
|
3369
3712
|
const highlightHandler = throttle((data) => {
|
|
3370
3713
|
highlight(data, editorService);
|
|
3371
3714
|
}, throttleTime);
|
|
3372
|
-
const
|
|
3715
|
+
const toggleClickFlag = () => {
|
|
3373
3716
|
clicked.value = !clicked.value;
|
|
3374
3717
|
};
|
|
3375
3718
|
const statusData = useStatus(tree, editorService);
|
|
3376
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
|
+
});
|
|
3377
3725
|
return {
|
|
3378
3726
|
tree,
|
|
3727
|
+
menu,
|
|
3379
3728
|
...statusData,
|
|
3380
3729
|
...useDrop(tree, editorService),
|
|
3381
3730
|
...useFilter(tree),
|
|
3382
|
-
|
|
3731
|
+
highlightHandler,
|
|
3732
|
+
toggleClickFlag,
|
|
3733
|
+
canHighlight,
|
|
3383
3734
|
clickHandler(data) {
|
|
3384
3735
|
if (services?.uiService.get("uiSelectMode")) {
|
|
3385
3736
|
document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
|
|
@@ -3388,14 +3739,16 @@ const _sfc_main$7 = defineComponent({
|
|
|
3388
3739
|
tree.value?.setCurrentKey(data.id);
|
|
3389
3740
|
select(data, editorService);
|
|
3390
3741
|
},
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3742
|
+
async contextmenu(event, data) {
|
|
3743
|
+
event.preventDefault();
|
|
3744
|
+
await select(data, editorService);
|
|
3745
|
+
menu.value?.show(event);
|
|
3746
|
+
}
|
|
3394
3747
|
};
|
|
3395
3748
|
}
|
|
3396
3749
|
});
|
|
3397
|
-
const _hoisted_1$
|
|
3398
|
-
function _sfc_render$
|
|
3750
|
+
const _hoisted_1$4 = ["id", "onMouseenter"];
|
|
3751
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3399
3752
|
const _component_el_input = resolveComponent("el-input");
|
|
3400
3753
|
const _component_el_tree = resolveComponent("el-tree");
|
|
3401
3754
|
const _component_layer_menu = resolveComponent("layer-menu");
|
|
@@ -3416,6 +3769,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3416
3769
|
ref: "tree",
|
|
3417
3770
|
"node-key": "id",
|
|
3418
3771
|
draggable: "",
|
|
3772
|
+
"default-expanded-keys": _ctx.expandedKeys,
|
|
3419
3773
|
load: _ctx.loadItems,
|
|
3420
3774
|
data: _ctx.values,
|
|
3421
3775
|
"expand-on-click-node": false,
|
|
@@ -3434,8 +3788,8 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3434
3788
|
createElementVNode("div", {
|
|
3435
3789
|
id: data.id,
|
|
3436
3790
|
class: normalizeClass(["cus-tree-node", { "cus-tree-node-hover": _ctx.canHighlight && data.id === _ctx.highlightNode?.id }]),
|
|
3437
|
-
onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.
|
|
3438
|
-
onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.
|
|
3791
|
+
onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
|
|
3792
|
+
onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
|
|
3439
3793
|
onMouseenter: ($event) => _ctx.highlightHandler(data)
|
|
3440
3794
|
}, [
|
|
3441
3795
|
renderSlot(_ctx.$slots, "layer-node-content", {
|
|
@@ -3444,42 +3798,33 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3444
3798
|
}, () => [
|
|
3445
3799
|
createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
|
|
3446
3800
|
])
|
|
3447
|
-
], 42, _hoisted_1$
|
|
3801
|
+
], 42, _hoisted_1$4)
|
|
3448
3802
|
]),
|
|
3449
3803
|
_: 3
|
|
3450
|
-
}, 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),
|
|
3451
3805
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
3452
|
-
createVNode(_component_layer_menu, {
|
|
3453
|
-
style: normalizeStyle(_ctx.menuStyle)
|
|
3454
|
-
}, null, 8, ["style"])
|
|
3806
|
+
createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
|
|
3455
3807
|
]))
|
|
3456
3808
|
]),
|
|
3457
3809
|
_: 3
|
|
3458
3810
|
});
|
|
3459
3811
|
}
|
|
3460
|
-
var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3812
|
+
var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
|
|
3461
3813
|
|
|
3462
|
-
const _sfc_main$
|
|
3463
|
-
name: "m-sidebar",
|
|
3814
|
+
const _sfc_main$7 = defineComponent({
|
|
3464
3815
|
components: { MIcon },
|
|
3465
3816
|
props: {
|
|
3466
3817
|
data: {
|
|
3467
|
-
type: Object
|
|
3468
|
-
default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer"] })
|
|
3818
|
+
type: Object
|
|
3469
3819
|
}
|
|
3470
3820
|
},
|
|
3471
3821
|
setup(props) {
|
|
3472
|
-
const activeTabName = ref(props.data?.status);
|
|
3473
|
-
watch(() => props.data?.status, (status) => {
|
|
3474
|
-
activeTabName.value = status || "0";
|
|
3475
|
-
});
|
|
3476
3822
|
return {
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
return item;
|
|
3823
|
+
config: computed(() => {
|
|
3824
|
+
if (typeof props.data !== "string") {
|
|
3825
|
+
return props.data;
|
|
3481
3826
|
}
|
|
3482
|
-
switch (
|
|
3827
|
+
switch (props.data) {
|
|
3483
3828
|
case "component-list":
|
|
3484
3829
|
return {
|
|
3485
3830
|
type: "component",
|
|
@@ -3497,21 +3842,75 @@ const _sfc_main$6 = defineComponent({
|
|
|
3497
3842
|
slots: {}
|
|
3498
3843
|
};
|
|
3499
3844
|
default:
|
|
3500
|
-
return
|
|
3845
|
+
return void 0;
|
|
3501
3846
|
}
|
|
3502
|
-
})
|
|
3847
|
+
})
|
|
3503
3848
|
};
|
|
3504
3849
|
}
|
|
3505
3850
|
});
|
|
3506
|
-
const _hoisted_1$
|
|
3851
|
+
const _hoisted_1$3 = {
|
|
3507
3852
|
key: 1,
|
|
3508
3853
|
class: "magic-editor-tab-panel-title"
|
|
3509
3854
|
};
|
|
3510
|
-
function _sfc_render$
|
|
3855
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3511
3856
|
const _component_m_icon = resolveComponent("m-icon");
|
|
3512
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");
|
|
3513
3912
|
const _component_el_tabs = resolveComponent("el-tabs");
|
|
3514
|
-
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, {
|
|
3515
3914
|
key: 0,
|
|
3516
3915
|
class: "m-editor-sidebar",
|
|
3517
3916
|
modelValue: _ctx.activeTabName,
|
|
@@ -3520,35 +3919,11 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3520
3919
|
"tab-position": "left"
|
|
3521
3920
|
}, {
|
|
3522
3921
|
default: withCtx(() => [
|
|
3523
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.items, (item) => {
|
|
3524
|
-
return openBlock(), createBlock(
|
|
3525
|
-
key:
|
|
3526
|
-
|
|
3527
|
-
},
|
|
3528
|
-
label: withCtx(() => [
|
|
3529
|
-
createElementVNode("span", null, [
|
|
3530
|
-
item.icon ? (openBlock(), createBlock(_component_m_icon, {
|
|
3531
|
-
key: 0,
|
|
3532
|
-
icon: item.icon
|
|
3533
|
-
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
3534
|
-
item.text ? (openBlock(), createElementBlock("div", _hoisted_1$4, toDisplayString(item.text), 1)) : createCommentVNode("", true)
|
|
3535
|
-
])
|
|
3536
|
-
]),
|
|
3537
|
-
default: withCtx(() => [
|
|
3538
|
-
(openBlock(), createBlock(resolveDynamicComponent(item.component), mergeProps(item.props || {}, toHandlers(item.listeners || {})), createSlots({ _: 2 }, [
|
|
3539
|
-
item.slots?.layerNodeContent ? {
|
|
3540
|
-
name: "layer-node-content",
|
|
3541
|
-
fn: withCtx(({ data, node }) => [
|
|
3542
|
-
(openBlock(), createBlock(resolveDynamicComponent(item.slots.layerNodeContent), {
|
|
3543
|
-
data,
|
|
3544
|
-
node
|
|
3545
|
-
}, null, 8, ["data", "node"]))
|
|
3546
|
-
])
|
|
3547
|
-
} : void 0
|
|
3548
|
-
]), 1040))
|
|
3549
|
-
]),
|
|
3550
|
-
_: 2
|
|
3551
|
-
}, 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"]);
|
|
3552
3927
|
}), 128))
|
|
3553
3928
|
]),
|
|
3554
3929
|
_: 1
|
|
@@ -3556,13 +3931,81 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3556
3931
|
}
|
|
3557
3932
|
var Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6]]);
|
|
3558
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
|
+
};
|
|
3559
3998
|
const _sfc_main$5 = defineComponent({
|
|
3560
|
-
components: { CaretBottom, Plus },
|
|
3999
|
+
components: { ArrowLeftBold, ArrowRightBold, CaretBottom, Plus, ToolButton },
|
|
3561
4000
|
setup() {
|
|
3562
4001
|
const services = inject("services");
|
|
3563
4002
|
const editorService = services?.editorService;
|
|
4003
|
+
const root = computed(() => editorService?.get("root"));
|
|
3564
4004
|
return {
|
|
3565
|
-
|
|
4005
|
+
Delete: markRaw(Delete),
|
|
4006
|
+
DocumentCopy: markRaw(DocumentCopy),
|
|
4007
|
+
...useScroll(root),
|
|
4008
|
+
root,
|
|
3566
4009
|
page: computed(() => editorService?.get("page")),
|
|
3567
4010
|
switchPage(page) {
|
|
3568
4011
|
editorService?.select(page);
|
|
@@ -3589,112 +4032,228 @@ const _sfc_main$5 = defineComponent({
|
|
|
3589
4032
|
};
|
|
3590
4033
|
}
|
|
3591
4034
|
});
|
|
3592
|
-
const _hoisted_1$
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
const
|
|
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" };
|
|
3597
4041
|
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3598
4042
|
const _component_plus = resolveComponent("plus");
|
|
3599
4043
|
const _component_el_icon = resolveComponent("el-icon");
|
|
4044
|
+
const _component_arrow_left_bold = resolveComponent("arrow-left-bold");
|
|
3600
4045
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
4046
|
+
const _component_tool_button = resolveComponent("tool-button");
|
|
3601
4047
|
const _component_caret_bottom = resolveComponent("caret-bottom");
|
|
3602
4048
|
const _component_el_popover = resolveComponent("el-popover");
|
|
3603
|
-
|
|
4049
|
+
const _component_arrow_right_bold = resolveComponent("arrow-right-bold");
|
|
4050
|
+
return openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
3604
4051
|
createElementVNode("div", {
|
|
3605
|
-
|
|
4052
|
+
id: "m-editor-page-bar-add-icon",
|
|
4053
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3606
4054
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.addPage && _ctx.addPage(...args))
|
|
3607
4055
|
}, [
|
|
3608
|
-
createVNode(_component_el_icon,
|
|
4056
|
+
createVNode(_component_el_icon, null, {
|
|
3609
4057
|
default: withCtx(() => [
|
|
3610
4058
|
createVNode(_component_plus)
|
|
3611
4059
|
]),
|
|
3612
4060
|
_: 1
|
|
3613
4061
|
})
|
|
3614
4062
|
]),
|
|
3615
|
-
_ctx.
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
createVNode(_component_el_tooltip, {
|
|
3624
|
-
effect: "dark",
|
|
3625
|
-
placement: "top-start",
|
|
3626
|
-
content: item.name
|
|
3627
|
-
}, {
|
|
3628
|
-
default: withCtx(() => [
|
|
3629
|
-
createElementVNode("span", null, toDisplayString(item.name), 1)
|
|
3630
|
-
]),
|
|
3631
|
-
_: 2
|
|
3632
|
-
}, 1032, ["content"])
|
|
3633
|
-
])
|
|
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)
|
|
3634
4071
|
]),
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
]),
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
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"])
|
|
3660
4099
|
])
|
|
3661
4100
|
]),
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
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);
|
|
3667
4155
|
}
|
|
3668
4156
|
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
|
|
3669
4157
|
|
|
3670
4158
|
class ScrollViewer$1 {
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
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();
|
|
3693
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);
|
|
3694
4191
|
this.scroll();
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
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
|
+
};
|
|
3698
4257
|
this.container = options.container;
|
|
3699
4258
|
this.target = options.target;
|
|
3700
4259
|
this.zoom = options.zoom;
|
|
@@ -3730,79 +4289,6 @@ class ScrollViewer$1 {
|
|
|
3730
4289
|
document.removeEventListener("mousemove", this.mousemoveHandler);
|
|
3731
4290
|
document.removeEventListener("mouseup", this.mouseupHandler);
|
|
3732
4291
|
}
|
|
3733
|
-
wheelHandler = (event) => {
|
|
3734
|
-
if (this.targetEnter)
|
|
3735
|
-
return;
|
|
3736
|
-
const { deltaX, deltaY, currentTarget } = event;
|
|
3737
|
-
if (currentTarget !== this.container)
|
|
3738
|
-
return;
|
|
3739
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3740
|
-
this.scroll();
|
|
3741
|
-
this.scrollLeft = this.target._left;
|
|
3742
|
-
this.scrollTop = this.target._top;
|
|
3743
|
-
};
|
|
3744
|
-
mouseEnterHandler = () => {
|
|
3745
|
-
this.enter = true;
|
|
3746
|
-
};
|
|
3747
|
-
mouseLeaveHandler = () => {
|
|
3748
|
-
this.enter = false;
|
|
3749
|
-
};
|
|
3750
|
-
targetMouseEnterHandler = () => {
|
|
3751
|
-
this.targetEnter = true;
|
|
3752
|
-
};
|
|
3753
|
-
targetMouseLeaveHandler = () => {
|
|
3754
|
-
this.targetEnter = false;
|
|
3755
|
-
};
|
|
3756
|
-
mousedownHandler = (event) => {
|
|
3757
|
-
if (!this.keydown)
|
|
3758
|
-
return;
|
|
3759
|
-
event.stopImmediatePropagation();
|
|
3760
|
-
event.stopPropagation();
|
|
3761
|
-
this.target.style.cursor = "grabbing";
|
|
3762
|
-
this.x = event.clientX;
|
|
3763
|
-
this.y = event.clientY;
|
|
3764
|
-
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3765
|
-
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3766
|
-
};
|
|
3767
|
-
mouseupHandler = () => {
|
|
3768
|
-
this.x = 0;
|
|
3769
|
-
this.y = 0;
|
|
3770
|
-
this.scrollLeft = this.target._left;
|
|
3771
|
-
this.scrollTop = this.target._top;
|
|
3772
|
-
this.removeHandler();
|
|
3773
|
-
};
|
|
3774
|
-
mousemoveHandler = (event) => {
|
|
3775
|
-
event.stopImmediatePropagation();
|
|
3776
|
-
event.stopPropagation();
|
|
3777
|
-
const deltaX = event.clientX - this.x;
|
|
3778
|
-
const deltaY = event.clientY - this.y;
|
|
3779
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3780
|
-
this.scroll();
|
|
3781
|
-
};
|
|
3782
|
-
keydownHandler = (event) => {
|
|
3783
|
-
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3784
|
-
event.preventDefault();
|
|
3785
|
-
event.stopImmediatePropagation();
|
|
3786
|
-
event.stopPropagation();
|
|
3787
|
-
}
|
|
3788
|
-
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3789
|
-
return;
|
|
3790
|
-
}
|
|
3791
|
-
this.keydown = true;
|
|
3792
|
-
this.target.style.cursor = "grab";
|
|
3793
|
-
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3794
|
-
};
|
|
3795
|
-
keyupHandler = (event) => {
|
|
3796
|
-
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3797
|
-
return;
|
|
3798
|
-
}
|
|
3799
|
-
event.preventDefault();
|
|
3800
|
-
event.stopImmediatePropagation();
|
|
3801
|
-
event.stopPropagation();
|
|
3802
|
-
this.keydown = false;
|
|
3803
|
-
event.preventDefault();
|
|
3804
|
-
this.removeHandler();
|
|
3805
|
-
};
|
|
3806
4292
|
setScrollOffset(deltaX, deltaY) {
|
|
3807
4293
|
const { width, height } = this.container.getBoundingClientRect();
|
|
3808
4294
|
const targetRect = this.target.getBoundingClientRect();
|
|
@@ -3863,19 +4349,19 @@ const _sfc_main$4 = defineComponent({
|
|
|
3863
4349
|
el,
|
|
3864
4350
|
style: computed(() => `
|
|
3865
4351
|
width: ${props.width}px;
|
|
3866
|
-
height: ${props.height}px;
|
|
4352
|
+
height: ${(props.height || 0) - 40}px;
|
|
3867
4353
|
position: absolute;
|
|
3868
4354
|
margin-top: 30px;
|
|
3869
4355
|
`)
|
|
3870
4356
|
};
|
|
3871
4357
|
}
|
|
3872
4358
|
});
|
|
3873
|
-
const _hoisted_1$
|
|
4359
|
+
const _hoisted_1$1 = {
|
|
3874
4360
|
class: "m-editor-scroll-viewer-container",
|
|
3875
4361
|
ref: "container"
|
|
3876
4362
|
};
|
|
3877
4363
|
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3878
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
4364
|
+
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
3879
4365
|
createElementVNode("div", {
|
|
3880
4366
|
ref: "el",
|
|
3881
4367
|
style: normalizeStyle(_ctx.style)
|
|
@@ -3887,7 +4373,7 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3887
4373
|
var ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]);
|
|
3888
4374
|
|
|
3889
4375
|
const _sfc_main$3 = defineComponent({
|
|
3890
|
-
|
|
4376
|
+
components: { ContentMenu },
|
|
3891
4377
|
setup() {
|
|
3892
4378
|
const services = inject("services");
|
|
3893
4379
|
const editorService = services?.editorService;
|
|
@@ -3896,6 +4382,7 @@ const _sfc_main$3 = defineComponent({
|
|
|
3896
4382
|
const canCenter = ref(false);
|
|
3897
4383
|
const node = computed(() => editorService?.get("node"));
|
|
3898
4384
|
const parent = computed(() => editorService?.get("parent"));
|
|
4385
|
+
const isPage = computed(() => node.value?.type === NodeType.PAGE);
|
|
3899
4386
|
onMounted(() => {
|
|
3900
4387
|
const data = globalThis.localStorage.getItem(COPY_STORAGE_KEY);
|
|
3901
4388
|
canPaste.value = data !== "undefined" && !!data;
|
|
@@ -3908,133 +4395,114 @@ const _sfc_main$3 = defineComponent({
|
|
|
3908
4395
|
}, { immediate: true });
|
|
3909
4396
|
return {
|
|
3910
4397
|
menu,
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
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);
|
|
3944
4493
|
}
|
|
3945
4494
|
};
|
|
3946
4495
|
}
|
|
3947
4496
|
});
|
|
3948
|
-
const _hoisted_1$1 = {
|
|
3949
|
-
class: "magic-editor-content-menu",
|
|
3950
|
-
ref: "menu"
|
|
3951
|
-
};
|
|
3952
|
-
const _hoisted_2 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
3953
|
-
const _hoisted_3 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
3954
|
-
const _hoisted_4 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
3955
4497
|
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
onClick: _cache[0] || (_cache[0] = () => _ctx.center())
|
|
3962
|
-
}, "\u6C34\u5E73\u5C45\u4E2D")) : createCommentVNode("", true),
|
|
3963
|
-
createElementVNode("div", {
|
|
3964
|
-
class: "magic-editor-content-menu-item",
|
|
3965
|
-
onClick: _cache[1] || (_cache[1] = () => _ctx.copy())
|
|
3966
|
-
}, "\u590D\u5236"),
|
|
3967
|
-
_ctx.canPaste ? (openBlock(), createElementBlock("div", {
|
|
3968
|
-
key: 1,
|
|
3969
|
-
class: "magic-editor-content-menu-item",
|
|
3970
|
-
onClick: _cache[2] || (_cache[2] = (...args) => _ctx.paste && _ctx.paste(...args))
|
|
3971
|
-
}, "\u7C98\u8D34")) : createCommentVNode("", true),
|
|
3972
|
-
_ctx.canMoveZPos ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
3973
|
-
_hoisted_2,
|
|
3974
|
-
createElementVNode("div", {
|
|
3975
|
-
class: "magic-editor-content-menu-item",
|
|
3976
|
-
onClick: _cache[3] || (_cache[3] = (...args) => _ctx.topItem && _ctx.topItem(...args))
|
|
3977
|
-
}, "\u4E0A\u79FB\u4E00\u5C42"),
|
|
3978
|
-
createElementVNode("div", {
|
|
3979
|
-
class: "magic-editor-content-menu-item",
|
|
3980
|
-
onClick: _cache[4] || (_cache[4] = (...args) => _ctx.bottomItem && _ctx.bottomItem(...args))
|
|
3981
|
-
}, "\u4E0B\u79FB\u4E00\u5C42"),
|
|
3982
|
-
createElementVNode("div", {
|
|
3983
|
-
class: "magic-editor-content-menu-item",
|
|
3984
|
-
onClick: _cache[5] || (_cache[5] = (...args) => _ctx.top && _ctx.top(...args))
|
|
3985
|
-
}, "\u7F6E\u9876"),
|
|
3986
|
-
createElementVNode("div", {
|
|
3987
|
-
class: "magic-editor-content-menu-item",
|
|
3988
|
-
onClick: _cache[6] || (_cache[6] = (...args) => _ctx.bottom && _ctx.bottom(...args))
|
|
3989
|
-
}, "\u7F6E\u5E95")
|
|
3990
|
-
], 64)) : createCommentVNode("", true),
|
|
3991
|
-
_ctx.canDelete ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
3992
|
-
_hoisted_3,
|
|
3993
|
-
createElementVNode("div", {
|
|
3994
|
-
class: "magic-editor-content-menu-item",
|
|
3995
|
-
onClick: _cache[7] || (_cache[7] = () => _ctx.remove())
|
|
3996
|
-
}, "\u5220\u9664")
|
|
3997
|
-
], 64)) : createCommentVNode("", true),
|
|
3998
|
-
_hoisted_4,
|
|
3999
|
-
createElementVNode("div", {
|
|
4000
|
-
class: "magic-editor-content-menu-item",
|
|
4001
|
-
onClick: _cache[8] || (_cache[8] = (...args) => _ctx.clearGuides && _ctx.clearGuides(...args))
|
|
4002
|
-
}, "\u6E05\u7A7A\u53C2\u8003\u7EBF")
|
|
4003
|
-
])
|
|
4004
|
-
], 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"]);
|
|
4005
4503
|
}
|
|
4006
4504
|
var ViewerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
|
|
4007
4505
|
|
|
4008
|
-
const useMenu = () => {
|
|
4009
|
-
const menu = ref();
|
|
4010
|
-
const menuStyle = ref({
|
|
4011
|
-
display: "none",
|
|
4012
|
-
left: "0",
|
|
4013
|
-
top: "0"
|
|
4014
|
-
});
|
|
4015
|
-
onMounted(() => {
|
|
4016
|
-
document.addEventListener("click", () => {
|
|
4017
|
-
menuStyle.value.display = "none";
|
|
4018
|
-
}, true);
|
|
4019
|
-
});
|
|
4020
|
-
return {
|
|
4021
|
-
menu,
|
|
4022
|
-
menuStyle,
|
|
4023
|
-
contextmenuHandler(e) {
|
|
4024
|
-
e.preventDefault();
|
|
4025
|
-
const menuHeight = menu.value?.$el.clientHeight;
|
|
4026
|
-
let top = e.clientY;
|
|
4027
|
-
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
4028
|
-
top = document.body.clientHeight - menuHeight;
|
|
4029
|
-
}
|
|
4030
|
-
menuStyle.value = {
|
|
4031
|
-
display: "block",
|
|
4032
|
-
top: `${top}px`,
|
|
4033
|
-
left: `${e.clientX}px`
|
|
4034
|
-
};
|
|
4035
|
-
}
|
|
4036
|
-
};
|
|
4037
|
-
};
|
|
4038
4506
|
const _sfc_main$2 = defineComponent({
|
|
4039
4507
|
name: "magic-stage",
|
|
4040
4508
|
components: {
|
|
@@ -4057,18 +4525,17 @@ const _sfc_main$2 = defineComponent({
|
|
|
4057
4525
|
})
|
|
4058
4526
|
}
|
|
4059
4527
|
},
|
|
4060
|
-
|
|
4061
|
-
setup(props, { emit }) {
|
|
4528
|
+
setup(props) {
|
|
4062
4529
|
const services = inject("services");
|
|
4063
4530
|
const stageWrap = ref();
|
|
4064
4531
|
const stageContainer = ref();
|
|
4532
|
+
const menu = ref();
|
|
4065
4533
|
const stageRect = computed(() => services?.uiService.get("stageRect"));
|
|
4066
4534
|
const uiSelectMode = computed(() => services?.uiService.get("uiSelectMode"));
|
|
4067
4535
|
const root = computed(() => services?.editorService.get("root"));
|
|
4068
4536
|
const page = computed(() => services?.editorService.get("page"));
|
|
4069
|
-
const zoom = computed(() => services?.uiService.get("zoom"));
|
|
4537
|
+
const zoom = computed(() => services?.uiService.get("zoom") || 1);
|
|
4070
4538
|
const node = computed(() => services?.editorService.get("node"));
|
|
4071
|
-
const highlightNode = computed(() => services?.editorService.get("highlightNode"));
|
|
4072
4539
|
let stage = null;
|
|
4073
4540
|
let runtime = null;
|
|
4074
4541
|
watchEffect(() => {
|
|
@@ -4082,9 +4549,9 @@ const _sfc_main$2 = defineComponent({
|
|
|
4082
4549
|
render: props.render,
|
|
4083
4550
|
runtimeUrl: props.runtimeUrl,
|
|
4084
4551
|
zoom: zoom.value,
|
|
4085
|
-
canSelect: (el, stop) => {
|
|
4552
|
+
canSelect: (el, event, stop) => {
|
|
4086
4553
|
const elCanSelect = props.canSelect(el);
|
|
4087
|
-
if (uiSelectMode.value && elCanSelect) {
|
|
4554
|
+
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
4088
4555
|
document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
|
|
4089
4556
|
return stop();
|
|
4090
4557
|
}
|
|
@@ -4092,19 +4559,19 @@ const _sfc_main$2 = defineComponent({
|
|
|
4092
4559
|
},
|
|
4093
4560
|
moveableOptions: props.moveableOptions
|
|
4094
4561
|
});
|
|
4095
|
-
services?.editorService.set("stage", stage);
|
|
4562
|
+
services?.editorService.set("stage", markRaw(stage));
|
|
4096
4563
|
stage?.mount(stageContainer.value);
|
|
4097
4564
|
stage?.on("select", (el) => {
|
|
4098
|
-
|
|
4565
|
+
services?.editorService.select(el.id);
|
|
4099
4566
|
});
|
|
4100
4567
|
stage?.on("highlight", (el) => {
|
|
4101
|
-
|
|
4568
|
+
services?.editorService.highlight(el.id);
|
|
4102
4569
|
});
|
|
4103
4570
|
stage?.on("update", (ev) => {
|
|
4104
|
-
|
|
4571
|
+
services?.editorService.update({ id: ev.el.id, style: ev.style });
|
|
4105
4572
|
});
|
|
4106
4573
|
stage?.on("sort", (ev) => {
|
|
4107
|
-
|
|
4574
|
+
services?.editorService.sort(ev.src, ev.dist);
|
|
4108
4575
|
});
|
|
4109
4576
|
stage?.on("changeGuides", () => {
|
|
4110
4577
|
services?.uiService.set("showGuides", true);
|
|
@@ -4130,16 +4597,6 @@ const _sfc_main$2 = defineComponent({
|
|
|
4130
4597
|
runtime.updateRootConfig(cloneDeep(toRaw(root2)));
|
|
4131
4598
|
}
|
|
4132
4599
|
});
|
|
4133
|
-
watch(() => node.value?.id, (id) => {
|
|
4134
|
-
nextTick(() => {
|
|
4135
|
-
id && stage?.select(id);
|
|
4136
|
-
});
|
|
4137
|
-
});
|
|
4138
|
-
watch(() => highlightNode.value?.id, (id) => {
|
|
4139
|
-
nextTick(() => {
|
|
4140
|
-
id && stage?.highlight(id);
|
|
4141
|
-
});
|
|
4142
|
-
});
|
|
4143
4600
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
4144
4601
|
for (const { contentRect } of entries) {
|
|
4145
4602
|
services?.uiService.set("stageContainerRect", {
|
|
@@ -4159,9 +4616,36 @@ const _sfc_main$2 = defineComponent({
|
|
|
4159
4616
|
return {
|
|
4160
4617
|
stageWrap,
|
|
4161
4618
|
stageContainer,
|
|
4619
|
+
menu,
|
|
4162
4620
|
stageRect,
|
|
4163
4621
|
zoom,
|
|
4164
|
-
|
|
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
|
+
}
|
|
4165
4649
|
};
|
|
4166
4650
|
}
|
|
4167
4651
|
});
|
|
@@ -4179,14 +4663,13 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4179
4663
|
createElementVNode("div", {
|
|
4180
4664
|
class: "m-editor-stage-container",
|
|
4181
4665
|
ref: "stageContainer",
|
|
4666
|
+
style: normalizeStyle(`transform: scale(${_ctx.zoom})`),
|
|
4182
4667
|
onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
|
|
4183
|
-
|
|
4668
|
+
onDrop: _cache[1] || (_cache[1] = (...args) => _ctx.dropHandler && _ctx.dropHandler(...args)),
|
|
4669
|
+
onDragover: _cache[2] || (_cache[2] = (...args) => _ctx.dragoverHandler && _ctx.dragoverHandler(...args))
|
|
4184
4670
|
}, null, 36),
|
|
4185
4671
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
4186
|
-
createVNode(_component_viewer_menu, {
|
|
4187
|
-
ref: "menu",
|
|
4188
|
-
style: normalizeStyle(_ctx.menuStyle)
|
|
4189
|
-
}, null, 8, ["style"])
|
|
4672
|
+
createVNode(_component_viewer_menu, { ref: "menu" }, null, 512)
|
|
4190
4673
|
]))
|
|
4191
4674
|
]),
|
|
4192
4675
|
_: 1
|
|
@@ -4214,24 +4697,93 @@ const _sfc_main$1 = defineComponent({
|
|
|
4214
4697
|
},
|
|
4215
4698
|
setup() {
|
|
4216
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
|
+
});
|
|
4217
4776
|
return {
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
services?.editorService.select(el.id);
|
|
4221
|
-
},
|
|
4222
|
-
updateNodeHandler(node) {
|
|
4223
|
-
services?.editorService.update(node);
|
|
4224
|
-
},
|
|
4225
|
-
sortNodeHandler(ev) {
|
|
4226
|
-
services?.editorService.sort(ev.src, ev.dist);
|
|
4227
|
-
},
|
|
4228
|
-
highlightHandler(el) {
|
|
4229
|
-
services?.editorService.highlight(el.id);
|
|
4230
|
-
}
|
|
4777
|
+
workspace,
|
|
4778
|
+
page: computed(() => services?.editorService.get("page"))
|
|
4231
4779
|
};
|
|
4232
4780
|
}
|
|
4233
4781
|
});
|
|
4234
|
-
const _hoisted_1 = {
|
|
4782
|
+
const _hoisted_1 = {
|
|
4783
|
+
class: "m-editor-workspace",
|
|
4784
|
+
tabindex: "1",
|
|
4785
|
+
ref: "workspace"
|
|
4786
|
+
};
|
|
4235
4787
|
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4236
4788
|
const _component_magic_stage = resolveComponent("magic-stage");
|
|
4237
4789
|
const _component_page_bar = resolveComponent("page-bar");
|
|
@@ -4241,12 +4793,8 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4241
4793
|
"runtime-url": _ctx.runtimeUrl,
|
|
4242
4794
|
render: _ctx.render,
|
|
4243
4795
|
"moveable-options": _ctx.moveableOptions,
|
|
4244
|
-
"can-select": _ctx.canSelect
|
|
4245
|
-
|
|
4246
|
-
onHighlight: _ctx.highlightHandler,
|
|
4247
|
-
onUpdate: _ctx.updateNodeHandler,
|
|
4248
|
-
onSort: _ctx.sortNodeHandler
|
|
4249
|
-
}, null, 8, ["runtime-url", "render", "moveable-options", "can-select", "onSelect", "onHighlight", "onUpdate", "onSort"])),
|
|
4796
|
+
"can-select": _ctx.canSelect
|
|
4797
|
+
}, null, 8, ["runtime-url", "render", "moveable-options", "can-select"])),
|
|
4250
4798
|
renderSlot(_ctx.$slots, "workspace-content"),
|
|
4251
4799
|
createVNode(_component_page_bar, null, {
|
|
4252
4800
|
"page-bar-title": withCtx(({ page }) => [
|
|
@@ -4257,16 +4805,16 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4257
4805
|
]),
|
|
4258
4806
|
_: 3
|
|
4259
4807
|
})
|
|
4260
|
-
]);
|
|
4808
|
+
], 512);
|
|
4261
4809
|
}
|
|
4262
4810
|
var Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
4263
4811
|
|
|
4264
4812
|
class ComponentList extends BaseService {
|
|
4265
|
-
state = reactive({
|
|
4266
|
-
list: []
|
|
4267
|
-
});
|
|
4268
4813
|
constructor() {
|
|
4269
4814
|
super([]);
|
|
4815
|
+
this.state = reactive({
|
|
4816
|
+
list: []
|
|
4817
|
+
});
|
|
4270
4818
|
}
|
|
4271
4819
|
setList(componentGroupList) {
|
|
4272
4820
|
this.state.list = componentGroupList;
|
|
@@ -4277,6 +4825,14 @@ class ComponentList extends BaseService {
|
|
|
4277
4825
|
}
|
|
4278
4826
|
var componentListService = new ComponentList();
|
|
4279
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
|
+
};
|
|
4280
4836
|
const state = reactive({
|
|
4281
4837
|
uiSelectMode: false,
|
|
4282
4838
|
showSrc: false,
|
|
@@ -4289,13 +4845,10 @@ const state = reactive({
|
|
|
4289
4845
|
width: 375,
|
|
4290
4846
|
height: 817
|
|
4291
4847
|
},
|
|
4292
|
-
columnWidth:
|
|
4293
|
-
left: 310,
|
|
4294
|
-
center: globalThis.document.body.clientWidth - 310 - 400,
|
|
4295
|
-
right: 400
|
|
4296
|
-
},
|
|
4848
|
+
columnWidth: defaultColumnWidth,
|
|
4297
4849
|
showGuides: true,
|
|
4298
|
-
showRule: true
|
|
4850
|
+
showRule: true,
|
|
4851
|
+
propsPanelSize: "small"
|
|
4299
4852
|
});
|
|
4300
4853
|
class Ui extends BaseService {
|
|
4301
4854
|
constructor() {
|
|
@@ -4305,6 +4858,15 @@ class Ui extends BaseService {
|
|
|
4305
4858
|
center: "auto"
|
|
4306
4859
|
});
|
|
4307
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
|
+
}
|
|
4308
4870
|
}
|
|
4309
4871
|
set(name, value) {
|
|
4310
4872
|
const mask = editorService.get("stage")?.mask;
|
|
@@ -4330,6 +4892,11 @@ class Ui extends BaseService {
|
|
|
4330
4892
|
get(name) {
|
|
4331
4893
|
return state[name];
|
|
4332
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
|
+
}
|
|
4333
4900
|
setColumnWidth({ left, center, right }) {
|
|
4334
4901
|
const columnWidth = {
|
|
4335
4902
|
...toRaw(this.get("columnWidth"))
|
|
@@ -4343,9 +4910,15 @@ class Ui extends BaseService {
|
|
|
4343
4910
|
if (!center || center === "auto") {
|
|
4344
4911
|
const bodyWidth = globalThis.document.body.clientWidth;
|
|
4345
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
|
+
}
|
|
4346
4918
|
} else {
|
|
4347
4919
|
columnWidth.center = center;
|
|
4348
4920
|
}
|
|
4921
|
+
globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
|
|
4349
4922
|
state.columnWidth = columnWidth;
|
|
4350
4923
|
}
|
|
4351
4924
|
setStageRect(value) {
|
|
@@ -4543,5 +5116,5 @@ var index = {
|
|
|
4543
5116
|
}
|
|
4544
5117
|
};
|
|
4545
5118
|
|
|
4546
|
-
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 };
|
|
4547
5120
|
//# sourceMappingURL=tmagic-editor.es.js.map
|