@tmagic/editor 1.0.0-beta.9 → 1.0.0-rc.11
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/dist/style.css +72 -36
- package/dist/tmagic-editor.es.js +1555 -2080
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +1555 -2082
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/Editor.vue.d.ts +50 -2
- package/dist/types/src/fields/Code.vue.d.ts +4 -4
- package/dist/types/src/fields/CodeLink.vue.d.ts +1 -3
- 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/Framework.vue.d.ts +15 -3
- package/dist/types/src/layouts/PropsPanel.vue.d.ts +4 -5
- 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/Workspace.vue.d.ts +5 -32
- package/dist/types/src/services/BaseService.d.ts +5 -2
- package/dist/types/src/services/editor.d.ts +11 -5
- package/dist/types/src/services/history.d.ts +2 -18
- package/dist/types/src/services/props.d.ts +8 -2
- package/dist/types/src/services/ui.d.ts +2 -0
- package/dist/types/src/type.d.ts +24 -9
- package/dist/types/src/utils/editor.d.ts +4 -9
- package/dist/types/src/utils/polyfills.d.ts +0 -0
- package/dist/types/src/utils/props.d.ts +10 -1
- package/package.json +35 -12
- package/src/Editor.vue +44 -9
- package/src/components/ContentMenu.vue +140 -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 -13
- package/src/layouts/Framework.vue +20 -7
- package/src/layouts/PropsPanel.vue +5 -4
- package/src/layouts/sidebar/ComponentListPanel.vue +25 -3
- package/src/layouts/sidebar/LayerMenu.vue +93 -95
- 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 +62 -104
- package/src/layouts/workspace/ViewerMenu.vue +119 -67
- package/src/layouts/workspace/Workspace.vue +124 -46
- package/src/services/BaseService.ts +71 -23
- package/src/services/editor.ts +196 -52
- package/src/services/history.ts +7 -0
- package/src/services/props.ts +64 -9
- 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 +36 -3
- package/src/theme/props-panel.scss +19 -17
- package/src/theme/workspace.scss +4 -0
- package/src/type.ts +26 -9
- package/src/utils/editor.ts +35 -55
- package/src/utils/polyfills.ts +8 -0
- package/src/utils/props.ts +51 -8
- package/LICENSE +0 -5432
- package/dist/types/src/components/ToolButton.vue.d.ts +0 -35
- package/dist/types/src/fields/UISelect.vue.d.ts +0 -32
- 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/PageBar.vue.d.ts +0 -11
- 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/vite.config.ts +0 -30
package/dist/tmagic-editor.es.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
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, Teleport, 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 {
|
|
8
|
-
import { EventEmitter as EventEmitter$2 } from 'events';
|
|
7
|
+
import { toLine, isPop, getNodePath, isNumber, isPage } from '@tmagic/utils';
|
|
8
|
+
import { EventEmitter } from 'events';
|
|
9
9
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
10
|
+
import Gesto from 'gesto';
|
|
10
11
|
import { ElMessage } from 'element-plus';
|
|
12
|
+
import KeyController from 'keycon';
|
|
11
13
|
import StageCore from '@tmagic/stage';
|
|
12
14
|
|
|
15
|
+
if (typeof global === "undefined") {
|
|
16
|
+
window.global = window;
|
|
17
|
+
}
|
|
18
|
+
if (typeof globalThis === "undefined") {
|
|
19
|
+
window.globalThis = window;
|
|
20
|
+
}
|
|
21
|
+
|
|
13
22
|
var _export_sfc = (sfc, props) => {
|
|
14
23
|
const target = sfc.__vccOpts || sfc;
|
|
15
24
|
for (const [key, val] of props) {
|
|
@@ -18,7 +27,7 @@ var _export_sfc = (sfc, props) => {
|
|
|
18
27
|
return target;
|
|
19
28
|
};
|
|
20
29
|
|
|
21
|
-
const _sfc_main$
|
|
30
|
+
const _sfc_main$m = defineComponent({
|
|
22
31
|
name: "m-fields-vs-code",
|
|
23
32
|
props: ["model", "name", "config", "prop"],
|
|
24
33
|
emits: ["change"],
|
|
@@ -35,7 +44,7 @@ const _sfc_main$k = defineComponent({
|
|
|
35
44
|
};
|
|
36
45
|
}
|
|
37
46
|
});
|
|
38
|
-
function _sfc_render$
|
|
47
|
+
function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) {
|
|
39
48
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
40
49
|
return openBlock(), createBlock(_component_magic_code_editor, {
|
|
41
50
|
style: normalizeStyle(`height: ${_ctx.height}`),
|
|
@@ -44,9 +53,9 @@ function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
44
53
|
onSave: _ctx.save
|
|
45
54
|
}, null, 8, ["style", "init-values", "language", "onSave"]);
|
|
46
55
|
}
|
|
47
|
-
var Code = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
56
|
+
var Code = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$m]]);
|
|
48
57
|
|
|
49
|
-
const _sfc_main$
|
|
58
|
+
const _sfc_main$l = defineComponent({
|
|
50
59
|
name: "m-fields-code-link",
|
|
51
60
|
props: {
|
|
52
61
|
config: {
|
|
@@ -101,7 +110,7 @@ const _sfc_main$j = defineComponent({
|
|
|
101
110
|
};
|
|
102
111
|
}
|
|
103
112
|
});
|
|
104
|
-
function _sfc_render$
|
|
113
|
+
function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) {
|
|
105
114
|
const _component_m_fields_link = resolveComponent("m-fields-link");
|
|
106
115
|
return openBlock(), createBlock(_component_m_fields_link, {
|
|
107
116
|
config: _ctx.formConfig,
|
|
@@ -110,11 +119,11 @@ function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
110
119
|
onChange: _ctx.changeHandler
|
|
111
120
|
}, null, 8, ["config", "model", "onChange"]);
|
|
112
121
|
}
|
|
113
|
-
var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
122
|
+
var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$l]]);
|
|
114
123
|
|
|
115
|
-
var UISelect_vue_vue_type_style_index_0_lang =
|
|
124
|
+
var UISelect_vue_vue_type_style_index_0_lang = /* #__PURE__ */ (() => ".m-fields-ui-select {\n cursor: pointer;\n}\n.m-fields-ui-select i {\n margin-right: 3px;\n}\n.m-fields-ui-select span {\n color: #2882e0;\n}")();
|
|
116
125
|
|
|
117
|
-
const _sfc_main$
|
|
126
|
+
const _sfc_main$k = defineComponent({
|
|
118
127
|
name: "m-fields-ui-select",
|
|
119
128
|
props: {
|
|
120
129
|
labelWidth: String,
|
|
@@ -152,6 +161,9 @@ const _sfc_main$i = defineComponent({
|
|
|
152
161
|
}
|
|
153
162
|
};
|
|
154
163
|
return {
|
|
164
|
+
Delete: markRaw(Delete),
|
|
165
|
+
Pointer: markRaw(Pointer),
|
|
166
|
+
Close: markRaw(Close),
|
|
155
167
|
val,
|
|
156
168
|
uiSelectMode,
|
|
157
169
|
toName: computed(() => {
|
|
@@ -176,34 +188,64 @@ const _sfc_main$i = defineComponent({
|
|
|
176
188
|
};
|
|
177
189
|
}
|
|
178
190
|
});
|
|
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) {
|
|
191
|
+
const _hoisted_1$c = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
|
|
192
|
+
function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
|
|
193
|
+
const _component_el_button = resolveComponent("el-button");
|
|
194
|
+
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
188
195
|
return _ctx.uiSelectMode ? (openBlock(), createElementBlock("div", {
|
|
189
196
|
key: 0,
|
|
190
197
|
class: "m-fields-ui-select",
|
|
191
198
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.cancelHandler && _ctx.cancelHandler(...args))
|
|
192
|
-
},
|
|
199
|
+
}, [
|
|
200
|
+
createVNode(_component_el_button, {
|
|
201
|
+
type: "danger",
|
|
202
|
+
icon: _ctx.Delete,
|
|
203
|
+
text: "",
|
|
204
|
+
style: { "padding": "0" }
|
|
205
|
+
}, {
|
|
206
|
+
default: withCtx(() => [
|
|
207
|
+
_hoisted_1$c
|
|
208
|
+
]),
|
|
209
|
+
_: 1
|
|
210
|
+
}, 8, ["icon"])
|
|
211
|
+
])) : (openBlock(), createElementBlock("div", {
|
|
193
212
|
key: 1,
|
|
194
213
|
class: "m-fields-ui-select",
|
|
195
|
-
onClick: _cache[
|
|
214
|
+
onClick: _cache[1] || (_cache[1] = (...args) => _ctx.startSelect && _ctx.startSelect(...args)),
|
|
215
|
+
style: { "display": "flex" }
|
|
196
216
|
}, [
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
217
|
+
createVNode(_component_el_tooltip, { content: "\u6E05\u9664" }, {
|
|
218
|
+
default: withCtx(() => [
|
|
219
|
+
_ctx.val ? (openBlock(), createBlock(_component_el_button, {
|
|
220
|
+
key: 0,
|
|
221
|
+
style: { "padding": "0" },
|
|
222
|
+
type: "danger",
|
|
223
|
+
icon: _ctx.Close,
|
|
224
|
+
text: "",
|
|
225
|
+
onClick: withModifiers(_ctx.deleteHandler, ["stop"])
|
|
226
|
+
}, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
|
|
227
|
+
]),
|
|
228
|
+
_: 1
|
|
229
|
+
}),
|
|
230
|
+
createVNode(_component_el_tooltip, {
|
|
231
|
+
content: _ctx.val ? _ctx.toName + "_" + _ctx.val : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
|
|
232
|
+
}, {
|
|
233
|
+
default: withCtx(() => [
|
|
234
|
+
createVNode(_component_el_button, {
|
|
235
|
+
text: "",
|
|
236
|
+
style: { "padding": "0", "margin": "0" }
|
|
237
|
+
}, {
|
|
238
|
+
default: withCtx(() => [
|
|
239
|
+
createTextVNode(toDisplayString(_ctx.val ? _ctx.toName + "_" + _ctx.val : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1)
|
|
240
|
+
]),
|
|
241
|
+
_: 1
|
|
242
|
+
})
|
|
243
|
+
]),
|
|
244
|
+
_: 1
|
|
245
|
+
}, 8, ["content"])
|
|
204
246
|
]));
|
|
205
247
|
}
|
|
206
|
-
var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
248
|
+
var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$k]]);
|
|
207
249
|
|
|
208
250
|
const toString = (v, language) => {
|
|
209
251
|
let value = "";
|
|
@@ -220,7 +262,7 @@ const toString = (v, language) => {
|
|
|
220
262
|
}
|
|
221
263
|
return value;
|
|
222
264
|
};
|
|
223
|
-
const _sfc_main$
|
|
265
|
+
const _sfc_main$j = defineComponent({
|
|
224
266
|
name: "magic-code-editor",
|
|
225
267
|
props: {
|
|
226
268
|
initValues: {
|
|
@@ -230,12 +272,16 @@ const _sfc_main$h = defineComponent({
|
|
|
230
272
|
type: [String, Object]
|
|
231
273
|
},
|
|
232
274
|
type: {
|
|
233
|
-
type:
|
|
275
|
+
type: String,
|
|
234
276
|
default: () => ""
|
|
235
277
|
},
|
|
236
278
|
language: {
|
|
237
|
-
type:
|
|
279
|
+
type: String,
|
|
238
280
|
default: () => "javascript"
|
|
281
|
+
},
|
|
282
|
+
options: {
|
|
283
|
+
type: Object,
|
|
284
|
+
default: () => ({})
|
|
239
285
|
}
|
|
240
286
|
},
|
|
241
287
|
emits: ["initd", "save"],
|
|
@@ -245,6 +291,10 @@ const _sfc_main$h = defineComponent({
|
|
|
245
291
|
const values = ref("");
|
|
246
292
|
const loading = ref(false);
|
|
247
293
|
const codeEditor = ref();
|
|
294
|
+
const resizeObserver = new globalThis.ResizeObserver(throttle(() => {
|
|
295
|
+
vsEditor?.layout();
|
|
296
|
+
vsDiffEditor?.layout();
|
|
297
|
+
}, 300));
|
|
248
298
|
const setEditorValue = (v, m) => {
|
|
249
299
|
values.value = toString(v, props.language);
|
|
250
300
|
if (props.type === "diff") {
|
|
@@ -257,10 +307,6 @@ const _sfc_main$h = defineComponent({
|
|
|
257
307
|
}
|
|
258
308
|
return vsEditor?.setValue(values.value);
|
|
259
309
|
};
|
|
260
|
-
const resizeHandler = () => {
|
|
261
|
-
vsEditor?.layout();
|
|
262
|
-
vsDiffEditor?.layout();
|
|
263
|
-
};
|
|
264
310
|
const getEditorValue = () => props.type === "diff" ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue();
|
|
265
311
|
const init = async () => {
|
|
266
312
|
if (!codeEditor.value)
|
|
@@ -268,11 +314,8 @@ const _sfc_main$h = defineComponent({
|
|
|
268
314
|
const options = {
|
|
269
315
|
value: values.value,
|
|
270
316
|
language: props.language,
|
|
271
|
-
tabSize: 2,
|
|
272
317
|
theme: "vs-dark",
|
|
273
|
-
|
|
274
|
-
fontSize: 15,
|
|
275
|
-
formatOnPaste: true
|
|
318
|
+
...props.options
|
|
276
319
|
};
|
|
277
320
|
if (props.type === "diff") {
|
|
278
321
|
vsDiffEditor = monaco.editor.createDiffEditor(codeEditor.value, options);
|
|
@@ -285,6 +328,7 @@ const _sfc_main$h = defineComponent({
|
|
|
285
328
|
codeEditor.value.addEventListener("keydown", (e) => {
|
|
286
329
|
if (e.keyCode === 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
|
|
287
330
|
e.preventDefault();
|
|
331
|
+
e.stopPropagation();
|
|
288
332
|
emit("save", getEditorValue());
|
|
289
333
|
}
|
|
290
334
|
});
|
|
@@ -293,7 +337,7 @@ const _sfc_main$h = defineComponent({
|
|
|
293
337
|
emit("save", getEditorValue());
|
|
294
338
|
});
|
|
295
339
|
}
|
|
296
|
-
|
|
340
|
+
resizeObserver.observe(codeEditor.value);
|
|
297
341
|
};
|
|
298
342
|
watch(() => props.initValues, (v, preV) => {
|
|
299
343
|
if (v !== preV) {
|
|
@@ -308,7 +352,7 @@ const _sfc_main$h = defineComponent({
|
|
|
308
352
|
init();
|
|
309
353
|
});
|
|
310
354
|
onUnmounted(() => {
|
|
311
|
-
|
|
355
|
+
resizeObserver.disconnect();
|
|
312
356
|
});
|
|
313
357
|
return {
|
|
314
358
|
values,
|
|
@@ -325,14 +369,14 @@ const _sfc_main$h = defineComponent({
|
|
|
325
369
|
};
|
|
326
370
|
}
|
|
327
371
|
});
|
|
328
|
-
const _hoisted_1$
|
|
372
|
+
const _hoisted_1$b = {
|
|
329
373
|
ref: "codeEditor",
|
|
330
374
|
class: "magic-code-editor"
|
|
331
375
|
};
|
|
332
|
-
function _sfc_render$
|
|
333
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
376
|
+
function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
|
|
377
|
+
return openBlock(), createElementBlock("div", _hoisted_1$b, null, 512);
|
|
334
378
|
}
|
|
335
|
-
var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
379
|
+
var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$j]]);
|
|
336
380
|
|
|
337
381
|
let $TMAGIC_EDITOR = {};
|
|
338
382
|
const setConfig = (option) => {
|
|
@@ -341,9 +385,6 @@ const setConfig = (option) => {
|
|
|
341
385
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
342
386
|
|
|
343
387
|
class UndoRedo {
|
|
344
|
-
elementList;
|
|
345
|
-
listCursor;
|
|
346
|
-
listMaxSize;
|
|
347
388
|
constructor(listMaxSize = 200) {
|
|
348
389
|
const minListMaxSize = 2;
|
|
349
390
|
this.elementList = [];
|
|
@@ -416,11 +457,40 @@ const compose = (middleware) => {
|
|
|
416
457
|
|
|
417
458
|
const methodName = (prefix, name) => `${prefix}${name[0].toUpperCase()}${name.substring(1)}`;
|
|
418
459
|
const isError = (error) => Object.prototype.toString.call(error) === "[object Error]";
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
460
|
+
const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethodName, fn) => {
|
|
461
|
+
try {
|
|
462
|
+
let beforeArgs = args;
|
|
463
|
+
for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
|
|
464
|
+
let beforeReturnValue = await beforeMethod(...beforeArgs) || [];
|
|
465
|
+
if (isError(beforeReturnValue))
|
|
466
|
+
throw beforeReturnValue;
|
|
467
|
+
if (!Array.isArray(beforeReturnValue)) {
|
|
468
|
+
beforeReturnValue = [beforeReturnValue];
|
|
469
|
+
}
|
|
470
|
+
beforeArgs = beforeArgs.map((v, index) => {
|
|
471
|
+
if (typeof beforeReturnValue[index] === "undefined")
|
|
472
|
+
return v;
|
|
473
|
+
return beforeReturnValue[index];
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
|
|
477
|
+
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
478
|
+
returnValue = await afterMethod(returnValue, ...beforeArgs);
|
|
479
|
+
if (isError(returnValue))
|
|
480
|
+
throw returnValue;
|
|
481
|
+
}
|
|
482
|
+
return returnValue;
|
|
483
|
+
} catch (error) {
|
|
484
|
+
throw error;
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
class BaseService extends EventEmitter {
|
|
488
|
+
constructor(methods = [], serialMethods = []) {
|
|
423
489
|
super();
|
|
490
|
+
this.pluginOptionsList = {};
|
|
491
|
+
this.middleware = {};
|
|
492
|
+
this.taskList = [];
|
|
493
|
+
this.doingTask = false;
|
|
424
494
|
methods.forEach((propertyName) => {
|
|
425
495
|
const scope = this;
|
|
426
496
|
const sourceMethod = scope[propertyName];
|
|
@@ -432,27 +502,23 @@ class BaseService extends EventEmitter$2 {
|
|
|
432
502
|
const fn = compose(this.middleware[propertyName]);
|
|
433
503
|
Object.defineProperty(scope, propertyName, {
|
|
434
504
|
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
|
-
});
|
|
505
|
+
if (!serialMethods.includes(propertyName)) {
|
|
506
|
+
return doAction(args, scope, sourceMethod, beforeMethodName, afterMethodName, fn);
|
|
448
507
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
508
|
+
const promise = new Promise((resolve, reject) => {
|
|
509
|
+
this.taskList.push(async () => {
|
|
510
|
+
try {
|
|
511
|
+
const value = await doAction(args, scope, sourceMethod, beforeMethodName, afterMethodName, fn);
|
|
512
|
+
resolve(value);
|
|
513
|
+
} catch (e) {
|
|
514
|
+
reject(e);
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
});
|
|
518
|
+
if (!this.doingTask) {
|
|
519
|
+
this.doTask();
|
|
454
520
|
}
|
|
455
|
-
return
|
|
521
|
+
return promise;
|
|
456
522
|
}
|
|
457
523
|
});
|
|
458
524
|
});
|
|
@@ -469,19 +535,34 @@ class BaseService extends EventEmitter$2 {
|
|
|
469
535
|
this.pluginOptionsList[methodName2].push(method);
|
|
470
536
|
});
|
|
471
537
|
}
|
|
538
|
+
async doTask() {
|
|
539
|
+
this.doingTask = true;
|
|
540
|
+
let task = this.taskList.shift();
|
|
541
|
+
while (task) {
|
|
542
|
+
await task();
|
|
543
|
+
task = this.taskList.shift();
|
|
544
|
+
}
|
|
545
|
+
this.doingTask = false;
|
|
546
|
+
}
|
|
472
547
|
}
|
|
473
548
|
|
|
474
549
|
class History extends BaseService {
|
|
475
|
-
state = reactive({
|
|
476
|
-
pageSteps: {},
|
|
477
|
-
pageId: void 0,
|
|
478
|
-
canRedo: false,
|
|
479
|
-
canUndo: false
|
|
480
|
-
});
|
|
481
550
|
constructor() {
|
|
482
551
|
super([]);
|
|
552
|
+
this.state = reactive({
|
|
553
|
+
pageSteps: {},
|
|
554
|
+
pageId: void 0,
|
|
555
|
+
canRedo: false,
|
|
556
|
+
canUndo: false
|
|
557
|
+
});
|
|
483
558
|
this.on("change", this.setCanUndoRedo);
|
|
484
559
|
}
|
|
560
|
+
reset() {
|
|
561
|
+
this.state.pageSteps = {};
|
|
562
|
+
this.state.pageId = void 0;
|
|
563
|
+
this.state.canRedo = false;
|
|
564
|
+
this.state.canUndo = false;
|
|
565
|
+
}
|
|
485
566
|
changePage(page) {
|
|
486
567
|
if (!page)
|
|
487
568
|
return;
|
|
@@ -545,12 +626,12 @@ class History extends BaseService {
|
|
|
545
626
|
var historyService = new History();
|
|
546
627
|
|
|
547
628
|
class Props extends BaseService {
|
|
548
|
-
state = reactive({
|
|
549
|
-
propsConfigMap: {},
|
|
550
|
-
propsValueMap: {}
|
|
551
|
-
});
|
|
552
629
|
constructor() {
|
|
553
|
-
super(["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue"]);
|
|
630
|
+
super(["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue", "createId", "setNewItemId"]);
|
|
631
|
+
this.state = reactive({
|
|
632
|
+
propsConfigMap: {},
|
|
633
|
+
propsValueMap: {}
|
|
634
|
+
});
|
|
554
635
|
}
|
|
555
636
|
setPropsConfigs(configs) {
|
|
556
637
|
Object.keys(configs).forEach((type) => {
|
|
@@ -575,7 +656,7 @@ class Props extends BaseService {
|
|
|
575
656
|
setPropsValue(type, value) {
|
|
576
657
|
this.state.propsValueMap[type] = value;
|
|
577
658
|
}
|
|
578
|
-
async getPropsValue(type) {
|
|
659
|
+
async getPropsValue(type, defaultValue = {}) {
|
|
579
660
|
if (type === "area") {
|
|
580
661
|
const value = await this.getPropsValue("button");
|
|
581
662
|
value.className = "action-area";
|
|
@@ -585,12 +666,44 @@ class Props extends BaseService {
|
|
|
585
666
|
}
|
|
586
667
|
return value;
|
|
587
668
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
669
|
+
const data = cloneDeep(defaultValue);
|
|
670
|
+
await this.setNewItemId(data);
|
|
671
|
+
return {
|
|
672
|
+
...getDefaultPropsValue(type, await this.createId(type)),
|
|
673
|
+
...mergeWith(cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
async createId(type) {
|
|
677
|
+
return `${type}_${random(1e4, false)}`;
|
|
678
|
+
}
|
|
679
|
+
async setNewItemId(config, parent) {
|
|
680
|
+
const oldId = config.id;
|
|
681
|
+
config.id = await this.createId(config.type || "component");
|
|
682
|
+
if (isPop(config) && parent?.type === NodeType.PAGE) {
|
|
683
|
+
updatePopId(oldId, config.id, parent);
|
|
684
|
+
}
|
|
685
|
+
if (config.items && Array.isArray(config.items)) {
|
|
686
|
+
for (const item of config.items) {
|
|
687
|
+
await this.setNewItemId(item, config);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
592
690
|
}
|
|
593
691
|
}
|
|
692
|
+
const updatePopId = (oldId, popId, pageConfig) => {
|
|
693
|
+
pageConfig.items?.forEach((config) => {
|
|
694
|
+
if (config.pop === oldId) {
|
|
695
|
+
config.pop = popId;
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
if (config.popId === oldId) {
|
|
699
|
+
config.popId = popId;
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
if (Array.isArray(config.items)) {
|
|
703
|
+
updatePopId(oldId, popId, config);
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
};
|
|
594
707
|
var propsService = new Props();
|
|
595
708
|
|
|
596
709
|
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
@@ -611,7 +724,6 @@ var Keys = /* @__PURE__ */ ((Keys2) => {
|
|
|
611
724
|
})(Keys || {});
|
|
612
725
|
|
|
613
726
|
const COPY_STORAGE_KEY = "$MagicEditorCopyData";
|
|
614
|
-
const generateId = (type) => `${type}_${random(1e4, false)}`;
|
|
615
727
|
const getPageList = (app) => {
|
|
616
728
|
if (app.items && Array.isArray(app.items)) {
|
|
617
729
|
return app.items.filter((item) => item.type === NodeType.PAGE);
|
|
@@ -631,32 +743,6 @@ const generatePageName = (pageNameList) => {
|
|
|
631
743
|
return pageName;
|
|
632
744
|
};
|
|
633
745
|
const generatePageNameByApp = (app) => generatePageName(getPageNameList(getPageList(app)));
|
|
634
|
-
const updatePopId = (oldId, popId, pageConfig) => {
|
|
635
|
-
pageConfig.items?.forEach((config) => {
|
|
636
|
-
if (config.pop === oldId) {
|
|
637
|
-
config.pop = popId;
|
|
638
|
-
return;
|
|
639
|
-
}
|
|
640
|
-
if (config.popId === oldId) {
|
|
641
|
-
config.popId = popId;
|
|
642
|
-
return;
|
|
643
|
-
}
|
|
644
|
-
if (Array.isArray(config.items)) {
|
|
645
|
-
updatePopId(oldId, popId, config);
|
|
646
|
-
}
|
|
647
|
-
});
|
|
648
|
-
};
|
|
649
|
-
const setNewItemId = (config, parent) => {
|
|
650
|
-
const oldId = config.id;
|
|
651
|
-
config.id = generateId(config.type);
|
|
652
|
-
config.name = `${config.name?.replace(/_(\d+)$/, "")}_${config.id}`;
|
|
653
|
-
if (isPop(config) && parent?.type === NodeType.PAGE) {
|
|
654
|
-
updatePopId(oldId, config.id, parent);
|
|
655
|
-
}
|
|
656
|
-
if (config.items && Array.isArray(config.items)) {
|
|
657
|
-
config.items.forEach((item) => setNewItemId(item, config));
|
|
658
|
-
}
|
|
659
|
-
};
|
|
660
746
|
const isFixed = (node) => node.style?.position === "fixed";
|
|
661
747
|
const getNodeIndex = (node, parent) => {
|
|
662
748
|
const items = parent?.items || [];
|
|
@@ -671,11 +757,28 @@ const toRelative = (node) => {
|
|
|
671
757
|
};
|
|
672
758
|
return node;
|
|
673
759
|
};
|
|
674
|
-
const
|
|
760
|
+
const setTop2Middle = (node, parentNode, stage) => {
|
|
761
|
+
const style = node.style || {};
|
|
762
|
+
let height = style.height || 0;
|
|
763
|
+
if (!stage || typeof style.top !== "undefined" || !parentNode.style)
|
|
764
|
+
return style;
|
|
765
|
+
if (!isNumber(height)) {
|
|
766
|
+
height = 0;
|
|
767
|
+
}
|
|
768
|
+
const { height: parentHeight } = parentNode.style;
|
|
769
|
+
if (isPage(parentNode)) {
|
|
770
|
+
const { scrollTop = 0, wrapperHeight } = stage.mask;
|
|
771
|
+
style.top = (wrapperHeight - height) / 2 + scrollTop;
|
|
772
|
+
} else {
|
|
773
|
+
style.top = (parentHeight - height) / 2;
|
|
774
|
+
}
|
|
775
|
+
return style;
|
|
776
|
+
};
|
|
777
|
+
const initPosition = (node, layout, parentNode, stage) => {
|
|
675
778
|
if (layout === Layout.ABSOLUTE) {
|
|
676
779
|
node.style = {
|
|
677
780
|
position: "absolute",
|
|
678
|
-
...node
|
|
781
|
+
...setTop2Middle(node, parentNode, stage)
|
|
679
782
|
};
|
|
680
783
|
return node;
|
|
681
784
|
}
|
|
@@ -722,7 +825,9 @@ const Fixed2Other = async (node, root, getLayout) => {
|
|
|
722
825
|
const cur = path.pop();
|
|
723
826
|
const offset = {
|
|
724
827
|
left: cur?.style?.left || 0,
|
|
725
|
-
top: cur?.style?.top || 0
|
|
828
|
+
top: cur?.style?.top || 0,
|
|
829
|
+
right: "",
|
|
830
|
+
bottom: ""
|
|
726
831
|
};
|
|
727
832
|
path.forEach((value) => {
|
|
728
833
|
offset.left = offset.left - globalThis.parseFloat(value.style?.left || 0);
|
|
@@ -756,16 +861,6 @@ const error = (...args) => {
|
|
|
756
861
|
};
|
|
757
862
|
|
|
758
863
|
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
864
|
constructor() {
|
|
770
865
|
super([
|
|
771
866
|
"getLayout",
|
|
@@ -778,22 +873,38 @@ class Editor$1 extends BaseService {
|
|
|
778
873
|
"paste",
|
|
779
874
|
"alignCenter",
|
|
780
875
|
"moveLayer",
|
|
876
|
+
"move",
|
|
781
877
|
"undo",
|
|
782
878
|
"redo",
|
|
783
879
|
"highlight"
|
|
784
|
-
]);
|
|
880
|
+
], ["select", "update", "moveLayer"]);
|
|
881
|
+
this.isHistoryStateChange = false;
|
|
882
|
+
this.state = reactive({
|
|
883
|
+
root: null,
|
|
884
|
+
page: null,
|
|
885
|
+
parent: null,
|
|
886
|
+
node: null,
|
|
887
|
+
stage: null,
|
|
888
|
+
highlightNode: null,
|
|
889
|
+
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
890
|
+
pageLength: 0
|
|
891
|
+
});
|
|
785
892
|
}
|
|
786
893
|
set(name, value) {
|
|
787
894
|
this.state[name] = value;
|
|
788
895
|
if (name === "root") {
|
|
896
|
+
this.state.pageLength = value?.items?.length || 0;
|
|
789
897
|
this.emit("root-change", value);
|
|
790
898
|
}
|
|
791
899
|
}
|
|
792
900
|
get(name) {
|
|
793
901
|
return this.state[name];
|
|
794
902
|
}
|
|
795
|
-
getNodeInfo(id) {
|
|
796
|
-
|
|
903
|
+
getNodeInfo(id, raw = true) {
|
|
904
|
+
let root = this.get("root");
|
|
905
|
+
if (raw) {
|
|
906
|
+
root = toRaw(root);
|
|
907
|
+
}
|
|
797
908
|
if (!root)
|
|
798
909
|
return {};
|
|
799
910
|
if (id === root.id) {
|
|
@@ -814,21 +925,23 @@ class Editor$1 extends BaseService {
|
|
|
814
925
|
});
|
|
815
926
|
return info;
|
|
816
927
|
}
|
|
817
|
-
getNodeById(id) {
|
|
818
|
-
const { node } = this.getNodeInfo(id);
|
|
928
|
+
getNodeById(id, raw = true) {
|
|
929
|
+
const { node } = this.getNodeInfo(id, raw);
|
|
819
930
|
return node;
|
|
820
931
|
}
|
|
821
|
-
getParentById(id) {
|
|
932
|
+
getParentById(id, raw = true) {
|
|
822
933
|
if (!this.get("root"))
|
|
823
934
|
return;
|
|
824
|
-
const { parent } = this.getNodeInfo(id);
|
|
935
|
+
const { parent } = this.getNodeInfo(id, raw);
|
|
825
936
|
return parent;
|
|
826
937
|
}
|
|
827
|
-
async getLayout(node) {
|
|
828
|
-
if (node
|
|
829
|
-
return
|
|
938
|
+
async getLayout(parent, node) {
|
|
939
|
+
if (node && typeof node !== "function" && isFixed(node))
|
|
940
|
+
return Layout.FIXED;
|
|
941
|
+
if (parent.layout) {
|
|
942
|
+
return parent.layout;
|
|
830
943
|
}
|
|
831
|
-
if (!
|
|
944
|
+
if (!parent.style?.position) {
|
|
832
945
|
return Layout.RELATIVE;
|
|
833
946
|
}
|
|
834
947
|
return Layout.ABSOLUTE;
|
|
@@ -843,41 +956,79 @@ class Editor$1 extends BaseService {
|
|
|
843
956
|
} else {
|
|
844
957
|
historyService.empty();
|
|
845
958
|
}
|
|
959
|
+
if (node?.id) {
|
|
960
|
+
this.get("stage")?.renderer.runtime?.getApp?.()?.emit("editor:select", {
|
|
961
|
+
node,
|
|
962
|
+
page,
|
|
963
|
+
parent
|
|
964
|
+
}, getNodePath(node.id, this.get("root").items));
|
|
965
|
+
}
|
|
966
|
+
this.emit("select", node);
|
|
846
967
|
return node;
|
|
847
968
|
}
|
|
969
|
+
async selectNextNode() {
|
|
970
|
+
const node = toRaw(this.get("node"));
|
|
971
|
+
if (!node || isPage(node) || node.type === NodeType.ROOT)
|
|
972
|
+
return node;
|
|
973
|
+
const parent = toRaw(this.getParentById(node.id));
|
|
974
|
+
if (!parent)
|
|
975
|
+
return node;
|
|
976
|
+
const index = getNodeIndex(node, parent);
|
|
977
|
+
const nextNode = parent.items[index + 1] || parent.items[0];
|
|
978
|
+
await this.select(nextNode);
|
|
979
|
+
this.get("stage")?.select(nextNode.id);
|
|
980
|
+
return nextNode;
|
|
981
|
+
}
|
|
982
|
+
async selectNextPage() {
|
|
983
|
+
const root = toRaw(this.get("root"));
|
|
984
|
+
const page = toRaw(this.get("page"));
|
|
985
|
+
const index = getNodeIndex(page, root);
|
|
986
|
+
const nextPage = root.items[index + 1] || root.items[0];
|
|
987
|
+
await this.select(nextPage);
|
|
988
|
+
this.get("stage")?.select(nextPage.id);
|
|
989
|
+
return nextPage;
|
|
990
|
+
}
|
|
848
991
|
highlight(config2) {
|
|
849
992
|
const { node } = this.selectedConfigExceptionHandler(config2);
|
|
850
|
-
const
|
|
851
|
-
if (
|
|
993
|
+
const currentHighlightNode = this.get("highlightNode");
|
|
994
|
+
if (currentHighlightNode === node)
|
|
852
995
|
return;
|
|
853
996
|
this.set("highlightNode", node);
|
|
854
997
|
}
|
|
855
|
-
async add(
|
|
998
|
+
async add(addNode, parent) {
|
|
999
|
+
const { type, ...config2 } = addNode;
|
|
856
1000
|
const curNode = this.get("node");
|
|
857
1001
|
let parentNode;
|
|
858
|
-
|
|
1002
|
+
const isPage2 = type === NodeType.PAGE;
|
|
1003
|
+
if (isPage2) {
|
|
859
1004
|
parentNode = this.get("root");
|
|
860
1005
|
} else if (parent && typeof parent !== "function") {
|
|
861
1006
|
parentNode = parent;
|
|
862
1007
|
} else if (curNode.items) {
|
|
863
1008
|
parentNode = curNode;
|
|
864
1009
|
} else {
|
|
865
|
-
parentNode = this.getParentById(curNode.id);
|
|
1010
|
+
parentNode = this.getParentById(curNode.id, false);
|
|
866
1011
|
}
|
|
867
1012
|
if (!parentNode)
|
|
868
1013
|
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
|
|
1014
|
+
const layout = await this.getLayout(toRaw(parentNode), addNode);
|
|
1015
|
+
const newNode = initPosition({ ...toRaw(await propsService.getPropsValue(type, config2)) }, layout, parentNode, this.get("stage"));
|
|
871
1016
|
if ((parentNode?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && newNode.type !== NodeType.PAGE) {
|
|
872
1017
|
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
873
1018
|
}
|
|
874
1019
|
parentNode?.items?.push(newNode);
|
|
875
|
-
|
|
1020
|
+
const stage = this.get("stage");
|
|
1021
|
+
await stage?.add({ config: cloneDeep(newNode), root: cloneDeep(this.get("root")) });
|
|
876
1022
|
await this.select(newNode);
|
|
877
1023
|
this.addModifiedNodeId(newNode.id);
|
|
878
|
-
if (
|
|
1024
|
+
if (!isPage2) {
|
|
879
1025
|
this.pushHistoryState();
|
|
880
1026
|
}
|
|
1027
|
+
stage?.select(newNode.id);
|
|
1028
|
+
if (isPage2) {
|
|
1029
|
+
this.state.pageLength += 1;
|
|
1030
|
+
}
|
|
1031
|
+
this.emit("add", newNode);
|
|
881
1032
|
return newNode;
|
|
882
1033
|
}
|
|
883
1034
|
async remove(node) {
|
|
@@ -886,27 +1037,44 @@ class Editor$1 extends BaseService {
|
|
|
886
1037
|
const root = this.get("root");
|
|
887
1038
|
if (!root)
|
|
888
1039
|
throw new Error("\u6CA1\u6709root");
|
|
889
|
-
const { parent, node: curNode } = this.getNodeInfo(node.id);
|
|
1040
|
+
const { parent, node: curNode } = this.getNodeInfo(node.id, false);
|
|
890
1041
|
if (!parent || !curNode)
|
|
891
1042
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
892
1043
|
const index = getNodeIndex(curNode, parent);
|
|
893
1044
|
if (typeof index !== "number" || index === -1)
|
|
894
1045
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
895
1046
|
parent.items?.splice(index, 1);
|
|
896
|
-
|
|
1047
|
+
const stage = this.get("stage");
|
|
1048
|
+
stage?.remove({ id: node.id, root: this.get("root") });
|
|
897
1049
|
if (node.type === NodeType.PAGE) {
|
|
898
|
-
|
|
1050
|
+
this.state.pageLength -= 1;
|
|
1051
|
+
if (root.items[0]) {
|
|
1052
|
+
await this.select(root.items[0]);
|
|
1053
|
+
stage?.select(root.items[0].id);
|
|
1054
|
+
} else {
|
|
1055
|
+
this.set("node", null);
|
|
1056
|
+
this.set("parent", null);
|
|
1057
|
+
this.set("page", null);
|
|
1058
|
+
this.set("stage", null);
|
|
1059
|
+
this.set("highlightNode", null);
|
|
1060
|
+
this.resetModifiedNodeId();
|
|
1061
|
+
historyService.reset();
|
|
1062
|
+
this.emit("remove", node);
|
|
1063
|
+
return node;
|
|
1064
|
+
}
|
|
899
1065
|
} else {
|
|
900
1066
|
await this.select(parent);
|
|
1067
|
+
stage?.select(parent.id);
|
|
901
1068
|
}
|
|
902
1069
|
this.addModifiedNodeId(parent.id);
|
|
903
1070
|
this.pushHistoryState();
|
|
1071
|
+
this.emit("remove", node);
|
|
904
1072
|
return node;
|
|
905
1073
|
}
|
|
906
1074
|
async update(config2) {
|
|
907
1075
|
if (!config2?.id)
|
|
908
1076
|
throw new Error("\u6CA1\u6709\u914D\u7F6E\u6216\u8005\u914D\u7F6E\u7F3A\u5C11id\u503C");
|
|
909
|
-
const info = this.getNodeInfo(config2.id);
|
|
1077
|
+
const info = this.getNodeInfo(config2.id, false);
|
|
910
1078
|
if (!info.node)
|
|
911
1079
|
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config2.id}\u7684\u8282\u70B9`);
|
|
912
1080
|
const node = cloneDeep(toRaw(info.node));
|
|
@@ -935,7 +1103,7 @@ class Editor$1 extends BaseService {
|
|
|
935
1103
|
newConfig = setLayout(newConfig, newLayout);
|
|
936
1104
|
}
|
|
937
1105
|
parentNodeItems[index] = newConfig;
|
|
938
|
-
if (newConfig.id === this.get("node").id) {
|
|
1106
|
+
if (`${newConfig.id}` === `${this.get("node").id}`) {
|
|
939
1107
|
this.set("node", newConfig);
|
|
940
1108
|
}
|
|
941
1109
|
this.get("stage")?.update({ config: cloneDeep(newConfig), root: this.get("root") });
|
|
@@ -944,6 +1112,7 @@ class Editor$1 extends BaseService {
|
|
|
944
1112
|
}
|
|
945
1113
|
this.addModifiedNodeId(newConfig.id);
|
|
946
1114
|
this.pushHistoryState();
|
|
1115
|
+
this.emit("update", newConfig);
|
|
947
1116
|
return newConfig;
|
|
948
1117
|
}
|
|
949
1118
|
async sort(id1, id2) {
|
|
@@ -975,23 +1144,36 @@ class Editor$1 extends BaseService {
|
|
|
975
1144
|
console.error(e);
|
|
976
1145
|
return;
|
|
977
1146
|
}
|
|
978
|
-
setNewItemId(config, this.get("root"));
|
|
1147
|
+
await propsService.setNewItemId(config, this.get("root"));
|
|
979
1148
|
if (config.style) {
|
|
980
1149
|
config.style = {
|
|
981
1150
|
...config.style,
|
|
982
1151
|
...position
|
|
983
1152
|
};
|
|
984
1153
|
}
|
|
1154
|
+
if (isPage(config)) {
|
|
1155
|
+
config.name = generatePageNameByApp(this.get("root"));
|
|
1156
|
+
}
|
|
985
1157
|
return await this.add(config);
|
|
986
1158
|
}
|
|
987
1159
|
async alignCenter(config2) {
|
|
988
1160
|
const parent = this.get("parent");
|
|
989
1161
|
const node = this.get("node");
|
|
990
|
-
const layout = await this.getLayout(parent);
|
|
1162
|
+
const layout = await this.getLayout(toRaw(parent), toRaw(node));
|
|
991
1163
|
if (layout === Layout.RELATIVE) {
|
|
992
1164
|
return;
|
|
993
1165
|
}
|
|
994
|
-
if (
|
|
1166
|
+
if (!node.style)
|
|
1167
|
+
return;
|
|
1168
|
+
const stage = this.get("stage");
|
|
1169
|
+
const doc = stage?.renderer.contentWindow?.document;
|
|
1170
|
+
if (doc) {
|
|
1171
|
+
const parentEl = doc.getElementById(`${parent.id}`);
|
|
1172
|
+
const el = doc.getElementById(`${node.id}`);
|
|
1173
|
+
if (parentEl && el) {
|
|
1174
|
+
node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
|
|
1175
|
+
}
|
|
1176
|
+
} else if (parent.style && isNumber(parent.style?.width) && isNumber(node.style?.width)) {
|
|
995
1177
|
node.style.left = (parent.style.width - node.style.width) / 2;
|
|
996
1178
|
}
|
|
997
1179
|
await this.update(node);
|
|
@@ -1005,9 +1187,9 @@ class Editor$1 extends BaseService {
|
|
|
1005
1187
|
const node = this.get("node");
|
|
1006
1188
|
const brothers = parent?.items || [];
|
|
1007
1189
|
const index = brothers.findIndex((item) => `${item.id}` === `${node?.id}`);
|
|
1008
|
-
if (offset === LayerOffset.
|
|
1190
|
+
if (offset === LayerOffset.TOP) {
|
|
1009
1191
|
brothers.splice(brothers.length - 1, 0, brothers.splice(index, 1)[0]);
|
|
1010
|
-
} else if (offset === LayerOffset.
|
|
1192
|
+
} else if (offset === LayerOffset.BOTTOM) {
|
|
1011
1193
|
brothers.splice(0, 0, brothers.splice(index, 1)[0]);
|
|
1012
1194
|
} else {
|
|
1013
1195
|
brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
|
|
@@ -1024,6 +1206,26 @@ class Editor$1 extends BaseService {
|
|
|
1024
1206
|
await this.changeHistoryState(value);
|
|
1025
1207
|
return value;
|
|
1026
1208
|
}
|
|
1209
|
+
async move(left, top) {
|
|
1210
|
+
const node = toRaw(this.get("node"));
|
|
1211
|
+
if (!node || isPage(node))
|
|
1212
|
+
return;
|
|
1213
|
+
const { style, id } = node;
|
|
1214
|
+
if (!style || style.position !== "absolute")
|
|
1215
|
+
return;
|
|
1216
|
+
if (top && !isNumber(style.top))
|
|
1217
|
+
return;
|
|
1218
|
+
if (left && !isNumber(style.left))
|
|
1219
|
+
return;
|
|
1220
|
+
this.update({
|
|
1221
|
+
id,
|
|
1222
|
+
style: {
|
|
1223
|
+
...style,
|
|
1224
|
+
left: Number(style.left) + left,
|
|
1225
|
+
top: Number(style.top) + top
|
|
1226
|
+
}
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1027
1229
|
destroy() {
|
|
1028
1230
|
this.removeAllListeners();
|
|
1029
1231
|
this.set("root", null);
|
|
@@ -1056,7 +1258,12 @@ class Editor$1 extends BaseService {
|
|
|
1056
1258
|
this.isHistoryStateChange = true;
|
|
1057
1259
|
await this.update(value.data);
|
|
1058
1260
|
this.set("modifiedNodeIds", value.modifiedNodeIds);
|
|
1059
|
-
setTimeout(() =>
|
|
1261
|
+
setTimeout(async () => {
|
|
1262
|
+
if (!value.nodeId)
|
|
1263
|
+
return;
|
|
1264
|
+
await this.select(value.nodeId);
|
|
1265
|
+
this.get("stage")?.select(value.nodeId);
|
|
1266
|
+
}, 0);
|
|
1060
1267
|
}
|
|
1061
1268
|
async toggleFixedPosition(dist, src, root) {
|
|
1062
1269
|
let newConfig = cloneDeep(dist);
|
|
@@ -1248,6 +1455,40 @@ const fillConfig = (config = []) => [
|
|
|
1248
1455
|
defaultValue: "100% 100%"
|
|
1249
1456
|
}
|
|
1250
1457
|
]
|
|
1458
|
+
},
|
|
1459
|
+
{
|
|
1460
|
+
type: "fieldset",
|
|
1461
|
+
legend: "\u5B57\u4F53",
|
|
1462
|
+
items: [
|
|
1463
|
+
{
|
|
1464
|
+
name: "color",
|
|
1465
|
+
text: "\u989C\u8272",
|
|
1466
|
+
type: "colorPicker"
|
|
1467
|
+
},
|
|
1468
|
+
{
|
|
1469
|
+
name: "fontSize",
|
|
1470
|
+
text: "\u5927\u5C0F"
|
|
1471
|
+
},
|
|
1472
|
+
{
|
|
1473
|
+
name: "fontWeight",
|
|
1474
|
+
text: "\u7C97\u7EC6"
|
|
1475
|
+
}
|
|
1476
|
+
]
|
|
1477
|
+
},
|
|
1478
|
+
{
|
|
1479
|
+
type: "fieldset",
|
|
1480
|
+
legend: "\u53D8\u5F62",
|
|
1481
|
+
name: "transform",
|
|
1482
|
+
items: [
|
|
1483
|
+
{
|
|
1484
|
+
name: "rotate",
|
|
1485
|
+
text: "\u65CB\u8F6C\u89D2\u5EA6"
|
|
1486
|
+
},
|
|
1487
|
+
{
|
|
1488
|
+
name: "scale",
|
|
1489
|
+
text: "\u7F29\u653E"
|
|
1490
|
+
}
|
|
1491
|
+
]
|
|
1251
1492
|
}
|
|
1252
1493
|
]
|
|
1253
1494
|
}
|
|
@@ -1280,7 +1521,7 @@ const fillConfig = (config = []) => [
|
|
|
1280
1521
|
type: "select",
|
|
1281
1522
|
options: (mForm, { model }) => {
|
|
1282
1523
|
const node = editorService.getNodeById(model.to);
|
|
1283
|
-
if (!node)
|
|
1524
|
+
if (!node?.type)
|
|
1284
1525
|
return [];
|
|
1285
1526
|
return eventsService.getMethod(node.type).map((option) => ({
|
|
1286
1527
|
text: option.label,
|
|
@@ -1308,14 +1549,21 @@ const fillConfig = (config = []) => [
|
|
|
1308
1549
|
}
|
|
1309
1550
|
];
|
|
1310
1551
|
const DEFAULT_CONFIG = fillConfig([]);
|
|
1311
|
-
const getDefaultPropsValue = (type) => ({
|
|
1552
|
+
const getDefaultPropsValue = (type, id) => ["page", "container"].includes(type) ? {
|
|
1553
|
+
type,
|
|
1554
|
+
id,
|
|
1555
|
+
layout: "absolute",
|
|
1556
|
+
style: {},
|
|
1557
|
+
name: type,
|
|
1558
|
+
items: []
|
|
1559
|
+
} : {
|
|
1312
1560
|
type,
|
|
1313
|
-
id
|
|
1561
|
+
id,
|
|
1314
1562
|
style: {},
|
|
1315
1563
|
name: type
|
|
1316
|
-
}
|
|
1564
|
+
};
|
|
1317
1565
|
|
|
1318
|
-
const _sfc_main$
|
|
1566
|
+
const _sfc_main$i = defineComponent({
|
|
1319
1567
|
components: { Plus },
|
|
1320
1568
|
setup() {
|
|
1321
1569
|
const services = inject("services");
|
|
@@ -1332,14 +1580,14 @@ const _sfc_main$g = defineComponent({
|
|
|
1332
1580
|
};
|
|
1333
1581
|
}
|
|
1334
1582
|
});
|
|
1335
|
-
const _hoisted_1$
|
|
1336
|
-
const _hoisted_2$
|
|
1337
|
-
const _hoisted_3$
|
|
1338
|
-
function _sfc_render$
|
|
1583
|
+
const _hoisted_1$a = { class: "m-editor-empty-panel" };
|
|
1584
|
+
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
1585
|
+
const _hoisted_3$2 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
1586
|
+
function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1339
1587
|
const _component_plus = resolveComponent("plus");
|
|
1340
1588
|
const _component_el_icon = resolveComponent("el-icon");
|
|
1341
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
1342
|
-
createElementVNode("div", _hoisted_2$
|
|
1589
|
+
return openBlock(), createElementBlock("div", _hoisted_1$a, [
|
|
1590
|
+
createElementVNode("div", _hoisted_2$4, [
|
|
1343
1591
|
createElementVNode("div", {
|
|
1344
1592
|
class: "m-editor-empty-button",
|
|
1345
1593
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
|
|
@@ -1352,1249 +1600,88 @@ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1352
1600
|
_: 1
|
|
1353
1601
|
})
|
|
1354
1602
|
]),
|
|
1355
|
-
_hoisted_3$
|
|
1603
|
+
_hoisted_3$2
|
|
1356
1604
|
])
|
|
1357
1605
|
])
|
|
1358
1606
|
]);
|
|
1359
1607
|
}
|
|
1360
|
-
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1361
|
-
|
|
1362
|
-
/*
|
|
1363
|
-
Copyright (c) 2018 Daybrush
|
|
1364
|
-
@name: @daybrush/utils
|
|
1365
|
-
license: MIT
|
|
1366
|
-
author: Daybrush
|
|
1367
|
-
repository: https://github.com/daybrush/utils
|
|
1368
|
-
@version 1.6.0
|
|
1369
|
-
*/
|
|
1370
|
-
/**
|
|
1371
|
-
* get string "object"
|
|
1372
|
-
* @memberof Consts
|
|
1373
|
-
* @example
|
|
1374
|
-
import {OBJECT} from "@daybrush/utils";
|
|
1375
|
-
|
|
1376
|
-
console.log(OBJECT); // "object"
|
|
1377
|
-
*/
|
|
1378
|
-
|
|
1379
|
-
var OBJECT = "object";
|
|
1380
|
-
/**
|
|
1381
|
-
* Check the type that the value is object.
|
|
1382
|
-
* @memberof Utils
|
|
1383
|
-
* @param {string} value - Value to check the type
|
|
1384
|
-
* @return {} true if the type is correct, false otherwise
|
|
1385
|
-
* @example
|
|
1386
|
-
import {isObject} from "@daybrush/utils";
|
|
1387
|
-
|
|
1388
|
-
console.log(isObject({})); // true
|
|
1389
|
-
console.log(isObject(undefined)); // false
|
|
1390
|
-
console.log(isObject("")); // false
|
|
1391
|
-
console.log(isObject(null)); // false
|
|
1392
|
-
*/
|
|
1393
|
-
|
|
1394
|
-
function isObject(value) {
|
|
1395
|
-
return value && typeof value === OBJECT;
|
|
1396
|
-
}
|
|
1397
|
-
/**
|
|
1398
|
-
* Date.now() method
|
|
1399
|
-
* @memberof CrossBrowser
|
|
1400
|
-
* @return {number} milliseconds
|
|
1401
|
-
* @example
|
|
1402
|
-
import {now} from "@daybrush/utils";
|
|
1403
|
-
|
|
1404
|
-
console.log(now()); // 12121324241(milliseconds)
|
|
1405
|
-
*/
|
|
1406
|
-
|
|
1407
|
-
function now() {
|
|
1408
|
-
return Date.now ? Date.now() : new Date().getTime();
|
|
1409
|
-
}
|
|
1410
|
-
/**
|
|
1411
|
-
* Returns the index of the first element in the array that satisfies the provided testing function.
|
|
1412
|
-
* @function
|
|
1413
|
-
* @memberof CrossBrowser
|
|
1414
|
-
* @param - The array `findIndex` was called upon.
|
|
1415
|
-
* @param - A function to execute on each value in the array until the function returns true, indicating that the satisfying element was found.
|
|
1416
|
-
* @param - Returns defaultIndex if not found by the function.
|
|
1417
|
-
* @example
|
|
1418
|
-
import { findIndex } from "@daybrush/utils";
|
|
1608
|
+
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
|
|
1419
1609
|
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
defaultIndex = -1;
|
|
1426
|
-
}
|
|
1427
|
-
|
|
1428
|
-
var length = arr.length;
|
|
1429
|
-
|
|
1430
|
-
for (var i = 0; i < length; ++i) {
|
|
1431
|
-
if (callback(arr[i], i, arr)) {
|
|
1432
|
-
return i;
|
|
1610
|
+
const _sfc_main$h = defineComponent({
|
|
1611
|
+
name: "m-editor-resize",
|
|
1612
|
+
props: {
|
|
1613
|
+
type: {
|
|
1614
|
+
type: String
|
|
1433
1615
|
}
|
|
1616
|
+
},
|
|
1617
|
+
setup(props) {
|
|
1618
|
+
const services = inject("services");
|
|
1619
|
+
const target = ref();
|
|
1620
|
+
let getso;
|
|
1621
|
+
onMounted(() => {
|
|
1622
|
+
if (!target.value)
|
|
1623
|
+
return;
|
|
1624
|
+
getso = new Gesto(target.value, {
|
|
1625
|
+
container: window,
|
|
1626
|
+
pinchOutside: true
|
|
1627
|
+
}).on("drag", (e) => {
|
|
1628
|
+
if (!target.value || !services)
|
|
1629
|
+
return;
|
|
1630
|
+
let { left, right } = {
|
|
1631
|
+
...toRaw(services.uiService.get("columnWidth"))
|
|
1632
|
+
};
|
|
1633
|
+
if (props.type === "left") {
|
|
1634
|
+
left += e.deltaX;
|
|
1635
|
+
} else if (props.type === "right") {
|
|
1636
|
+
right -= e.deltaX;
|
|
1637
|
+
}
|
|
1638
|
+
services.uiService.set("columnWidth", {
|
|
1639
|
+
left,
|
|
1640
|
+
right
|
|
1641
|
+
});
|
|
1642
|
+
});
|
|
1643
|
+
});
|
|
1644
|
+
onUnmounted(() => {
|
|
1645
|
+
getso?.unset();
|
|
1646
|
+
});
|
|
1647
|
+
return {
|
|
1648
|
+
target
|
|
1649
|
+
};
|
|
1434
1650
|
}
|
|
1435
|
-
|
|
1436
|
-
return defaultIndex;
|
|
1437
|
-
}
|
|
1438
|
-
/**
|
|
1439
|
-
* Sets up a function that will be called whenever the specified event is delivered to the target
|
|
1440
|
-
* @memberof DOM
|
|
1441
|
-
* @param - event target
|
|
1442
|
-
* @param - A case-sensitive string representing the event type to listen for.
|
|
1443
|
-
* @param - The object which receives a notification (an object that implements the Event interface) when an event of the specified type occurs
|
|
1444
|
-
* @param - An options object that specifies characteristics about the event listener.
|
|
1445
|
-
* @example
|
|
1446
|
-
import {addEvent} from "@daybrush/utils";
|
|
1447
|
-
|
|
1448
|
-
addEvent(el, "click", e => {
|
|
1449
|
-
console.log(e);
|
|
1450
1651
|
});
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
el.addEventListener(type, listener, options);
|
|
1455
|
-
}
|
|
1456
|
-
/**
|
|
1457
|
-
* removes from the EventTarget an event listener previously registered with EventTarget.addEventListener()
|
|
1458
|
-
* @memberof DOM
|
|
1459
|
-
* @param - event target
|
|
1460
|
-
* @param - A case-sensitive string representing the event type to listen for.
|
|
1461
|
-
* @param - The EventListener function of the event handler to remove from the event target.
|
|
1462
|
-
* @param - An options object that specifies characteristics about the event listener.
|
|
1463
|
-
* @example
|
|
1464
|
-
import {addEvent, removeEvent} from "@daybrush/utils";
|
|
1465
|
-
const listener = e => {
|
|
1466
|
-
console.log(e);
|
|
1467
|
-
};
|
|
1468
|
-
addEvent(el, "click", listener);
|
|
1469
|
-
removeEvent(el, "click", listener);
|
|
1470
|
-
*/
|
|
1471
|
-
|
|
1472
|
-
function removeEvent(el, type, listener, options) {
|
|
1473
|
-
el.removeEventListener(type, listener, options);
|
|
1474
|
-
}
|
|
1475
|
-
|
|
1476
|
-
/*
|
|
1477
|
-
Copyright (c) 2019 Daybrush
|
|
1478
|
-
name: @scena/event-emitter
|
|
1479
|
-
license: MIT
|
|
1480
|
-
author: Daybrush
|
|
1481
|
-
repository: git+https://github.com/daybrush/gesture.git
|
|
1482
|
-
version: 1.0.5
|
|
1483
|
-
*/
|
|
1484
|
-
|
|
1485
|
-
/*! *****************************************************************************
|
|
1486
|
-
Copyright (c) Microsoft Corporation.
|
|
1487
|
-
|
|
1488
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
1489
|
-
purpose with or without fee is hereby granted.
|
|
1490
|
-
|
|
1491
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1492
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1493
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1494
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1495
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1496
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1497
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
1498
|
-
***************************************************************************** */
|
|
1499
|
-
var __assign$1 = function () {
|
|
1500
|
-
__assign$1 = Object.assign || function __assign(t) {
|
|
1501
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1502
|
-
s = arguments[i];
|
|
1503
|
-
|
|
1504
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
|
-
return t;
|
|
1508
|
-
};
|
|
1509
|
-
|
|
1510
|
-
return __assign$1.apply(this, arguments);
|
|
1652
|
+
const _hoisted_1$9 = {
|
|
1653
|
+
ref: "target",
|
|
1654
|
+
class: "m-editor-resizer"
|
|
1511
1655
|
};
|
|
1512
|
-
function
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
return r;
|
|
1656
|
+
function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1657
|
+
return openBlock(), createElementBlock("span", _hoisted_1$9, [
|
|
1658
|
+
renderSlot(_ctx.$slots, "default")
|
|
1659
|
+
], 512);
|
|
1518
1660
|
}
|
|
1661
|
+
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
|
|
1519
1662
|
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
}
|
|
1530
|
-
/**
|
|
1531
|
-
* Add a listener to the registered event.
|
|
1532
|
-
* @param - Name of the event to be added
|
|
1533
|
-
* @param - listener function of the event to be added
|
|
1534
|
-
* @example
|
|
1535
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1536
|
-
* cosnt emitter = new EventEmitter();
|
|
1537
|
-
*
|
|
1538
|
-
* // Add listener in "a" event
|
|
1539
|
-
* emitter.on("a", () => {
|
|
1540
|
-
* });
|
|
1541
|
-
* // Add listeners
|
|
1542
|
-
* emitter.on({
|
|
1543
|
-
* a: () => {},
|
|
1544
|
-
* b: () => {},
|
|
1545
|
-
* });
|
|
1546
|
-
*/
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
var __proto = EventEmitter.prototype;
|
|
1550
|
-
|
|
1551
|
-
__proto.on = function (eventName, listener) {
|
|
1552
|
-
if (isObject(eventName)) {
|
|
1553
|
-
for (var name in eventName) {
|
|
1554
|
-
this.on(name, eventName[name]);
|
|
1555
|
-
}
|
|
1556
|
-
} else {
|
|
1557
|
-
this._addEvent(eventName, listener, {});
|
|
1663
|
+
const _sfc_main$g = defineComponent({
|
|
1664
|
+
components: {
|
|
1665
|
+
AddPageBox,
|
|
1666
|
+
Resizer
|
|
1667
|
+
},
|
|
1668
|
+
props: {
|
|
1669
|
+
codeOptions: {
|
|
1670
|
+
type: Object,
|
|
1671
|
+
default: () => ({})
|
|
1558
1672
|
}
|
|
1559
|
-
|
|
1560
|
-
return this;
|
|
1561
|
-
};
|
|
1562
|
-
/**
|
|
1563
|
-
* Remove listeners registered in the event target.
|
|
1564
|
-
* @param - Name of the event to be removed
|
|
1565
|
-
* @param - listener function of the event to be removed
|
|
1566
|
-
* @example
|
|
1567
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1568
|
-
* cosnt emitter = new EventEmitter();
|
|
1569
|
-
*
|
|
1570
|
-
* // Remove all listeners.
|
|
1571
|
-
* emitter.off();
|
|
1572
|
-
*
|
|
1573
|
-
* // Remove all listeners in "A" event.
|
|
1574
|
-
* emitter.off("a");
|
|
1575
|
-
*
|
|
1576
|
-
*
|
|
1577
|
-
* // Remove "listener" listener in "a" event.
|
|
1578
|
-
* emitter.off("a", listener);
|
|
1579
|
-
*/
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
__proto.off = function (eventName, listener) {
|
|
1583
|
-
if (!eventName) {
|
|
1584
|
-
this._events = {};
|
|
1585
|
-
} else if (isObject(eventName)) {
|
|
1586
|
-
for (var name in eventName) {
|
|
1587
|
-
this.off(name);
|
|
1588
|
-
}
|
|
1589
|
-
} else if (!listener) {
|
|
1590
|
-
this._events[eventName] = [];
|
|
1591
|
-
} else {
|
|
1592
|
-
var events = this._events[eventName];
|
|
1593
|
-
|
|
1594
|
-
if (events) {
|
|
1595
|
-
var index = findIndex(events, function (e) {
|
|
1596
|
-
return e.listener === listener;
|
|
1597
|
-
});
|
|
1598
|
-
|
|
1599
|
-
if (index > -1) {
|
|
1600
|
-
events.splice(index, 1);
|
|
1601
|
-
}
|
|
1602
|
-
}
|
|
1603
|
-
}
|
|
1604
|
-
|
|
1605
|
-
return this;
|
|
1606
|
-
};
|
|
1607
|
-
/**
|
|
1608
|
-
* Add a disposable listener and Use promise to the registered event.
|
|
1609
|
-
* @param - Name of the event to be added
|
|
1610
|
-
* @param - disposable listener function of the event to be added
|
|
1611
|
-
* @example
|
|
1612
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1613
|
-
* cosnt emitter = new EventEmitter();
|
|
1614
|
-
*
|
|
1615
|
-
* // Add a disposable listener in "a" event
|
|
1616
|
-
* emitter.once("a", () => {
|
|
1617
|
-
* });
|
|
1618
|
-
*
|
|
1619
|
-
* // Use Promise
|
|
1620
|
-
* emitter.once("a").then(e => {
|
|
1621
|
-
* });
|
|
1622
|
-
*/
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
__proto.once = function (eventName, listener) {
|
|
1626
|
-
var _this = this;
|
|
1627
|
-
|
|
1628
|
-
if (listener) {
|
|
1629
|
-
this._addEvent(eventName, listener, {
|
|
1630
|
-
once: true
|
|
1631
|
-
});
|
|
1632
|
-
}
|
|
1633
|
-
|
|
1634
|
-
return new Promise(function (resolve) {
|
|
1635
|
-
_this._addEvent(eventName, resolve, {
|
|
1636
|
-
once: true
|
|
1637
|
-
});
|
|
1638
|
-
});
|
|
1639
|
-
};
|
|
1640
|
-
/**
|
|
1641
|
-
* Fires an event to call listeners.
|
|
1642
|
-
* @param - Event name
|
|
1643
|
-
* @param - Event parameter
|
|
1644
|
-
* @return If false, stop the event.
|
|
1645
|
-
* @example
|
|
1646
|
-
*
|
|
1647
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1648
|
-
*
|
|
1649
|
-
*
|
|
1650
|
-
* const emitter = new EventEmitter();
|
|
1651
|
-
*
|
|
1652
|
-
* emitter.on("a", e => {
|
|
1653
|
-
* });
|
|
1654
|
-
*
|
|
1655
|
-
*
|
|
1656
|
-
* emitter.emit("a", {
|
|
1657
|
-
* a: 1,
|
|
1658
|
-
* });
|
|
1659
|
-
*/
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
__proto.emit = function (eventName, param) {
|
|
1663
|
-
var _this = this;
|
|
1664
|
-
|
|
1665
|
-
if (param === void 0) {
|
|
1666
|
-
param = {};
|
|
1667
|
-
}
|
|
1668
|
-
|
|
1669
|
-
var events = this._events[eventName];
|
|
1670
|
-
|
|
1671
|
-
if (!eventName || !events) {
|
|
1672
|
-
return true;
|
|
1673
|
-
}
|
|
1674
|
-
|
|
1675
|
-
var isStop = false;
|
|
1676
|
-
param.eventType = eventName;
|
|
1677
|
-
|
|
1678
|
-
param.stop = function () {
|
|
1679
|
-
isStop = true;
|
|
1680
|
-
};
|
|
1681
|
-
|
|
1682
|
-
param.currentTarget = this;
|
|
1683
|
-
|
|
1684
|
-
__spreadArrays(events).forEach(function (info) {
|
|
1685
|
-
info.listener(param);
|
|
1686
|
-
|
|
1687
|
-
if (info.once) {
|
|
1688
|
-
_this.off(eventName, info.listener);
|
|
1689
|
-
}
|
|
1690
|
-
});
|
|
1691
|
-
|
|
1692
|
-
return !isStop;
|
|
1693
|
-
};
|
|
1694
|
-
/**
|
|
1695
|
-
* Fires an event to call listeners.
|
|
1696
|
-
* @param - Event name
|
|
1697
|
-
* @param - Event parameter
|
|
1698
|
-
* @return If false, stop the event.
|
|
1699
|
-
* @example
|
|
1700
|
-
*
|
|
1701
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1702
|
-
*
|
|
1703
|
-
*
|
|
1704
|
-
* const emitter = new EventEmitter();
|
|
1705
|
-
*
|
|
1706
|
-
* emitter.on("a", e => {
|
|
1707
|
-
* });
|
|
1708
|
-
*
|
|
1709
|
-
*
|
|
1710
|
-
* emitter.emit("a", {
|
|
1711
|
-
* a: 1,
|
|
1712
|
-
* });
|
|
1713
|
-
*/
|
|
1714
|
-
|
|
1715
|
-
/**
|
|
1716
|
-
* Fires an event to call listeners.
|
|
1717
|
-
* @param - Event name
|
|
1718
|
-
* @param - Event parameter
|
|
1719
|
-
* @return If false, stop the event.
|
|
1720
|
-
* @example
|
|
1721
|
-
*
|
|
1722
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1723
|
-
*
|
|
1724
|
-
*
|
|
1725
|
-
* const emitter = new EventEmitter();
|
|
1726
|
-
*
|
|
1727
|
-
* emitter.on("a", e => {
|
|
1728
|
-
* });
|
|
1729
|
-
*
|
|
1730
|
-
* // emit
|
|
1731
|
-
* emitter.trigger("a", {
|
|
1732
|
-
* a: 1,
|
|
1733
|
-
* });
|
|
1734
|
-
*/
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
__proto.trigger = function (eventName, param) {
|
|
1738
|
-
if (param === void 0) {
|
|
1739
|
-
param = {};
|
|
1740
|
-
}
|
|
1741
|
-
|
|
1742
|
-
return this.emit(eventName, param);
|
|
1743
|
-
};
|
|
1744
|
-
|
|
1745
|
-
__proto._addEvent = function (eventName, listener, options) {
|
|
1746
|
-
var events = this._events;
|
|
1747
|
-
events[eventName] = events[eventName] || [];
|
|
1748
|
-
var listeners = events[eventName];
|
|
1749
|
-
listeners.push(__assign$1({
|
|
1750
|
-
listener: listener
|
|
1751
|
-
}, options));
|
|
1752
|
-
};
|
|
1753
|
-
|
|
1754
|
-
return EventEmitter;
|
|
1755
|
-
}();
|
|
1756
|
-
|
|
1757
|
-
var EventEmitter$1 = EventEmitter;
|
|
1758
|
-
|
|
1759
|
-
/*
|
|
1760
|
-
Copyright (c) 2019 Daybrush
|
|
1761
|
-
name: gesto
|
|
1762
|
-
license: MIT
|
|
1763
|
-
author: Daybrush
|
|
1764
|
-
repository: git+https://github.com/daybrush/gesture.git
|
|
1765
|
-
version: 1.5.0
|
|
1766
|
-
*/
|
|
1767
|
-
|
|
1768
|
-
/*! *****************************************************************************
|
|
1769
|
-
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1770
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
1771
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
1772
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1773
|
-
|
|
1774
|
-
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
1775
|
-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
1776
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
1777
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
1778
|
-
|
|
1779
|
-
See the Apache Version 2.0 License for specific language governing permissions
|
|
1780
|
-
and limitations under the License.
|
|
1781
|
-
***************************************************************************** */
|
|
1782
|
-
|
|
1783
|
-
/* global Reflect, Promise */
|
|
1784
|
-
var extendStatics = function (d, b) {
|
|
1785
|
-
extendStatics = Object.setPrototypeOf || {
|
|
1786
|
-
__proto__: []
|
|
1787
|
-
} instanceof Array && function (d, b) {
|
|
1788
|
-
d.__proto__ = b;
|
|
1789
|
-
} || function (d, b) {
|
|
1790
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
1791
|
-
};
|
|
1792
|
-
|
|
1793
|
-
return extendStatics(d, b);
|
|
1794
|
-
};
|
|
1795
|
-
|
|
1796
|
-
function __extends(d, b) {
|
|
1797
|
-
extendStatics(d, b);
|
|
1798
|
-
|
|
1799
|
-
function __() {
|
|
1800
|
-
this.constructor = d;
|
|
1801
|
-
}
|
|
1802
|
-
|
|
1803
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1804
|
-
}
|
|
1805
|
-
var __assign = function () {
|
|
1806
|
-
__assign = Object.assign || function __assign(t) {
|
|
1807
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1808
|
-
s = arguments[i];
|
|
1809
|
-
|
|
1810
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
1811
|
-
}
|
|
1812
|
-
|
|
1813
|
-
return t;
|
|
1814
|
-
};
|
|
1815
|
-
|
|
1816
|
-
return __assign.apply(this, arguments);
|
|
1817
|
-
};
|
|
1818
|
-
|
|
1819
|
-
function getRad(pos1, pos2) {
|
|
1820
|
-
var distX = pos2[0] - pos1[0];
|
|
1821
|
-
var distY = pos2[1] - pos1[1];
|
|
1822
|
-
var rad = Math.atan2(distY, distX);
|
|
1823
|
-
return rad >= 0 ? rad : rad + Math.PI * 2;
|
|
1824
|
-
}
|
|
1825
|
-
function getRotatiion(touches) {
|
|
1826
|
-
return getRad([touches[0].clientX, touches[0].clientY], [touches[1].clientX, touches[1].clientY]) / Math.PI * 180;
|
|
1827
|
-
}
|
|
1828
|
-
function isMultiTouch(e) {
|
|
1829
|
-
return e.touches && e.touches.length >= 2;
|
|
1830
|
-
}
|
|
1831
|
-
function getEventClients(e) {
|
|
1832
|
-
if (e.touches) {
|
|
1833
|
-
return getClients(e.touches);
|
|
1834
|
-
} else {
|
|
1835
|
-
return [getClient(e)];
|
|
1836
|
-
}
|
|
1837
|
-
}
|
|
1838
|
-
function getPosition(clients, prevClients, startClients) {
|
|
1839
|
-
var length = startClients.length;
|
|
1840
|
-
|
|
1841
|
-
var _a = getAverageClient(clients, length),
|
|
1842
|
-
clientX = _a.clientX,
|
|
1843
|
-
clientY = _a.clientY,
|
|
1844
|
-
originalClientX = _a.originalClientX,
|
|
1845
|
-
originalClientY = _a.originalClientY;
|
|
1846
|
-
|
|
1847
|
-
var _b = getAverageClient(prevClients, length),
|
|
1848
|
-
prevX = _b.clientX,
|
|
1849
|
-
prevY = _b.clientY;
|
|
1850
|
-
|
|
1851
|
-
var _c = getAverageClient(startClients, length),
|
|
1852
|
-
startX = _c.clientX,
|
|
1853
|
-
startY = _c.clientY;
|
|
1854
|
-
|
|
1855
|
-
var deltaX = clientX - prevX;
|
|
1856
|
-
var deltaY = clientY - prevY;
|
|
1857
|
-
var distX = clientX - startX;
|
|
1858
|
-
var distY = clientY - startY;
|
|
1859
|
-
return {
|
|
1860
|
-
clientX: originalClientX,
|
|
1861
|
-
clientY: originalClientY,
|
|
1862
|
-
deltaX: deltaX,
|
|
1863
|
-
deltaY: deltaY,
|
|
1864
|
-
distX: distX,
|
|
1865
|
-
distY: distY
|
|
1866
|
-
};
|
|
1867
|
-
}
|
|
1868
|
-
function getDist(clients) {
|
|
1869
|
-
return Math.sqrt(Math.pow(clients[0].clientX - clients[1].clientX, 2) + Math.pow(clients[0].clientY - clients[1].clientY, 2));
|
|
1870
|
-
}
|
|
1871
|
-
function getClients(touches) {
|
|
1872
|
-
var length = Math.min(touches.length, 2);
|
|
1873
|
-
var clients = [];
|
|
1874
|
-
|
|
1875
|
-
for (var i = 0; i < length; ++i) {
|
|
1876
|
-
clients.push(getClient(touches[i]));
|
|
1877
|
-
}
|
|
1878
|
-
|
|
1879
|
-
return clients;
|
|
1880
|
-
}
|
|
1881
|
-
function getClient(e) {
|
|
1882
|
-
return {
|
|
1883
|
-
clientX: e.clientX,
|
|
1884
|
-
clientY: e.clientY
|
|
1885
|
-
};
|
|
1886
|
-
}
|
|
1887
|
-
function getAverageClient(clients, length) {
|
|
1888
|
-
if (length === void 0) {
|
|
1889
|
-
length = clients.length;
|
|
1890
|
-
}
|
|
1891
|
-
|
|
1892
|
-
var sumClient = {
|
|
1893
|
-
clientX: 0,
|
|
1894
|
-
clientY: 0,
|
|
1895
|
-
originalClientX: 0,
|
|
1896
|
-
originalClientY: 0
|
|
1897
|
-
};
|
|
1898
|
-
|
|
1899
|
-
for (var i = 0; i < length; ++i) {
|
|
1900
|
-
var client = clients[i];
|
|
1901
|
-
sumClient.originalClientX += "originalClientX" in client ? client.originalClientX : client.clientX;
|
|
1902
|
-
sumClient.originalClientY += "originalClientY" in client ? client.originalClientY : client.clientY;
|
|
1903
|
-
sumClient.clientX += client.clientX;
|
|
1904
|
-
sumClient.clientY += client.clientY;
|
|
1905
|
-
}
|
|
1906
|
-
|
|
1907
|
-
if (!length) {
|
|
1908
|
-
return sumClient;
|
|
1909
|
-
}
|
|
1910
|
-
|
|
1911
|
-
return {
|
|
1912
|
-
clientX: sumClient.clientX / length,
|
|
1913
|
-
clientY: sumClient.clientY / length,
|
|
1914
|
-
originalClientX: sumClient.originalClientX / length,
|
|
1915
|
-
originalClientY: sumClient.originalClientY / length
|
|
1916
|
-
};
|
|
1917
|
-
}
|
|
1918
|
-
|
|
1919
|
-
var ClientStore =
|
|
1920
|
-
/*#__PURE__*/
|
|
1921
|
-
function () {
|
|
1922
|
-
function ClientStore(clients) {
|
|
1923
|
-
this.prevClients = [];
|
|
1924
|
-
this.startClients = [];
|
|
1925
|
-
this.movement = 0;
|
|
1926
|
-
this.length = 0;
|
|
1927
|
-
this.startClients = clients;
|
|
1928
|
-
this.prevClients = clients;
|
|
1929
|
-
this.length = clients.length;
|
|
1930
|
-
}
|
|
1931
|
-
|
|
1932
|
-
var __proto = ClientStore.prototype;
|
|
1933
|
-
|
|
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
|
-
__proto.getAngle = function (clients) {
|
|
1948
|
-
if (clients === void 0) {
|
|
1949
|
-
clients = this.prevClients;
|
|
1950
|
-
}
|
|
1951
|
-
|
|
1952
|
-
return getRotatiion(clients);
|
|
1953
|
-
};
|
|
1954
|
-
|
|
1955
|
-
__proto.getRotation = function (clients) {
|
|
1956
|
-
if (clients === void 0) {
|
|
1957
|
-
clients = this.prevClients;
|
|
1958
|
-
}
|
|
1959
|
-
|
|
1960
|
-
return getRotatiion(clients) - getRotatiion(this.startClients);
|
|
1961
|
-
};
|
|
1962
|
-
|
|
1963
|
-
__proto.getPosition = function (clients) {
|
|
1964
|
-
return getPosition(clients || this.prevClients, this.prevClients, this.startClients);
|
|
1965
|
-
};
|
|
1966
|
-
|
|
1967
|
-
__proto.getPositions = function (clients) {
|
|
1968
|
-
if (clients === void 0) {
|
|
1969
|
-
clients = this.prevClients;
|
|
1970
|
-
}
|
|
1971
|
-
|
|
1972
|
-
var prevClients = this.prevClients;
|
|
1973
|
-
return this.startClients.map(function (startClient, i) {
|
|
1974
|
-
return getPosition([clients[i]], [prevClients[i]], [startClient]);
|
|
1975
|
-
});
|
|
1976
|
-
};
|
|
1977
|
-
|
|
1978
|
-
__proto.getMovement = function (clients) {
|
|
1979
|
-
var movement = this.movement;
|
|
1980
|
-
|
|
1981
|
-
if (!clients) {
|
|
1982
|
-
return movement;
|
|
1983
|
-
}
|
|
1984
|
-
|
|
1985
|
-
var currentClient = getAverageClient(clients, this.length);
|
|
1986
|
-
var prevClient = getAverageClient(this.prevClients, this.length);
|
|
1987
|
-
var deltaX = currentClient.clientX - prevClient.clientX;
|
|
1988
|
-
var deltaY = currentClient.clientY - prevClient.clientY;
|
|
1989
|
-
return Math.sqrt(deltaX * deltaX + deltaY * deltaY) + movement;
|
|
1990
|
-
};
|
|
1991
|
-
|
|
1992
|
-
__proto.getDistance = function (clients) {
|
|
1993
|
-
if (clients === void 0) {
|
|
1994
|
-
clients = this.prevClients;
|
|
1995
|
-
}
|
|
1996
|
-
|
|
1997
|
-
return getDist(clients);
|
|
1998
|
-
};
|
|
1999
|
-
|
|
2000
|
-
__proto.getScale = function (clients) {
|
|
2001
|
-
if (clients === void 0) {
|
|
2002
|
-
clients = this.prevClients;
|
|
2003
|
-
}
|
|
2004
|
-
|
|
2005
|
-
return getDist(clients) / getDist(this.startClients);
|
|
2006
|
-
};
|
|
2007
|
-
|
|
2008
|
-
__proto.move = function (deltaX, deltaY) {
|
|
2009
|
-
this.startClients.forEach(function (client) {
|
|
2010
|
-
client.clientX -= deltaX;
|
|
2011
|
-
client.clientY -= deltaY;
|
|
2012
|
-
});
|
|
2013
|
-
this.prevClients.forEach(function (client) {
|
|
2014
|
-
client.clientX -= deltaX;
|
|
2015
|
-
client.clientY -= deltaY;
|
|
2016
|
-
});
|
|
2017
|
-
};
|
|
2018
|
-
|
|
2019
|
-
return ClientStore;
|
|
2020
|
-
}();
|
|
2021
|
-
|
|
2022
|
-
var INPUT_TAGNAMES = ["textarea", "input"];
|
|
2023
|
-
/**
|
|
2024
|
-
* You can set up drag, pinch events in any browser.
|
|
2025
|
-
*/
|
|
2026
|
-
|
|
2027
|
-
var Gesto =
|
|
2028
|
-
/*#__PURE__*/
|
|
2029
|
-
function (_super) {
|
|
2030
|
-
__extends(Gesto, _super);
|
|
2031
|
-
/**
|
|
2032
|
-
*
|
|
2033
|
-
*/
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
function Gesto(targets, options) {
|
|
2037
|
-
if (options === void 0) {
|
|
2038
|
-
options = {};
|
|
2039
|
-
}
|
|
2040
|
-
|
|
2041
|
-
var _this = _super.call(this) || this;
|
|
2042
|
-
|
|
2043
|
-
_this.options = {};
|
|
2044
|
-
_this.flag = false;
|
|
2045
|
-
_this.pinchFlag = false;
|
|
2046
|
-
_this.datas = {};
|
|
2047
|
-
_this.isDrag = false;
|
|
2048
|
-
_this.isPinch = false;
|
|
2049
|
-
_this.isMouse = false;
|
|
2050
|
-
_this.isTouch = false;
|
|
2051
|
-
_this.clientStores = [];
|
|
2052
|
-
_this.targets = [];
|
|
2053
|
-
_this.prevTime = 0;
|
|
2054
|
-
_this.doubleFlag = false;
|
|
2055
|
-
|
|
2056
|
-
_this.onDragStart = function (e, isTrusted) {
|
|
2057
|
-
if (isTrusted === void 0) {
|
|
2058
|
-
isTrusted = true;
|
|
2059
|
-
}
|
|
2060
|
-
|
|
2061
|
-
if (!_this.flag && e.cancelable === false) {
|
|
2062
|
-
return;
|
|
2063
|
-
}
|
|
2064
|
-
|
|
2065
|
-
var _a = _this.options,
|
|
2066
|
-
container = _a.container,
|
|
2067
|
-
pinchOutside = _a.pinchOutside,
|
|
2068
|
-
preventRightClick = _a.preventRightClick,
|
|
2069
|
-
preventDefault = _a.preventDefault,
|
|
2070
|
-
checkInput = _a.checkInput;
|
|
2071
|
-
var isTouch = _this.isTouch;
|
|
2072
|
-
var isDragStart = !_this.flag;
|
|
2073
|
-
|
|
2074
|
-
if (isDragStart) {
|
|
2075
|
-
var activeElement = document.activeElement;
|
|
2076
|
-
var target = e.target;
|
|
2077
|
-
var tagName = target.tagName.toLowerCase();
|
|
2078
|
-
var hasInput = INPUT_TAGNAMES.indexOf(tagName) > -1;
|
|
2079
|
-
var hasContentEditable = target.isContentEditable;
|
|
2080
|
-
|
|
2081
|
-
if (hasInput || hasContentEditable) {
|
|
2082
|
-
if (checkInput || activeElement === target) {
|
|
2083
|
-
// force false or already focused.
|
|
2084
|
-
return false;
|
|
2085
|
-
}
|
|
2086
|
-
|
|
2087
|
-
if (activeElement && hasContentEditable && activeElement.isContentEditable && activeElement.contains(target)) {
|
|
2088
|
-
return false;
|
|
2089
|
-
}
|
|
2090
|
-
} else if ((preventDefault || e.type === "touchstart") && activeElement) {
|
|
2091
|
-
var activeTagName = activeElement.tagName;
|
|
2092
|
-
|
|
2093
|
-
if (activeElement.isContentEditable || INPUT_TAGNAMES.indexOf(activeTagName) > -1) {
|
|
2094
|
-
activeElement.blur();
|
|
2095
|
-
}
|
|
2096
|
-
}
|
|
2097
|
-
|
|
2098
|
-
_this.clientStores = [new ClientStore(getEventClients(e))];
|
|
2099
|
-
_this.flag = true;
|
|
2100
|
-
_this.isDrag = false;
|
|
2101
|
-
_this.datas = {};
|
|
2102
|
-
|
|
2103
|
-
if (preventRightClick && (e.which === 3 || e.button === 2)) {
|
|
2104
|
-
_this.initDrag();
|
|
2105
|
-
|
|
2106
|
-
return false;
|
|
2107
|
-
}
|
|
2108
|
-
|
|
2109
|
-
_this.doubleFlag = now() - _this.prevTime < 200;
|
|
2110
|
-
|
|
2111
|
-
var result = _this.emit("dragStart", __assign({
|
|
2112
|
-
datas: _this.datas,
|
|
2113
|
-
inputEvent: e,
|
|
2114
|
-
isTrusted: isTrusted,
|
|
2115
|
-
isDouble: _this.doubleFlag
|
|
2116
|
-
}, _this.getCurrentStore().getPosition()));
|
|
2117
|
-
|
|
2118
|
-
if (result === false) {
|
|
2119
|
-
_this.initDrag();
|
|
2120
|
-
}
|
|
2121
|
-
|
|
2122
|
-
_this.flag && preventDefault && e.preventDefault();
|
|
2123
|
-
}
|
|
2124
|
-
|
|
2125
|
-
if (!_this.flag) {
|
|
2126
|
-
return false;
|
|
2127
|
-
}
|
|
2128
|
-
|
|
2129
|
-
var timer = 0;
|
|
2130
|
-
|
|
2131
|
-
if (isDragStart && isTouch && pinchOutside) {
|
|
2132
|
-
timer = setTimeout(function () {
|
|
2133
|
-
addEvent(container, "touchstart", _this.onDragStart, {
|
|
2134
|
-
passive: false
|
|
2135
|
-
});
|
|
2136
|
-
});
|
|
2137
|
-
}
|
|
2138
|
-
|
|
2139
|
-
if (!isDragStart && isTouch && pinchOutside) {
|
|
2140
|
-
removeEvent(container, "touchstart", _this.onDragStart);
|
|
2141
|
-
}
|
|
2142
|
-
|
|
2143
|
-
if (_this.flag && isMultiTouch(e)) {
|
|
2144
|
-
clearTimeout(timer);
|
|
2145
|
-
|
|
2146
|
-
if (isDragStart && e.touches.length !== e.changedTouches.length) {
|
|
2147
|
-
return;
|
|
2148
|
-
}
|
|
2149
|
-
|
|
2150
|
-
if (!_this.pinchFlag) {
|
|
2151
|
-
_this.onPinchStart(e);
|
|
2152
|
-
}
|
|
2153
|
-
}
|
|
2154
|
-
};
|
|
2155
|
-
|
|
2156
|
-
_this.onDrag = function (e, isScroll) {
|
|
2157
|
-
if (!_this.flag) {
|
|
2158
|
-
return;
|
|
2159
|
-
}
|
|
2160
|
-
|
|
2161
|
-
var clients = getEventClients(e);
|
|
2162
|
-
|
|
2163
|
-
var result = _this.moveClients(clients, e, false);
|
|
2164
|
-
|
|
2165
|
-
if (_this.pinchFlag || result.deltaX || result.deltaY) {
|
|
2166
|
-
var dragResult = _this.emit("drag", __assign({}, result, {
|
|
2167
|
-
isScroll: !!isScroll,
|
|
2168
|
-
inputEvent: e
|
|
2169
|
-
}));
|
|
2170
|
-
|
|
2171
|
-
if (dragResult === false) {
|
|
2172
|
-
_this.stop();
|
|
2173
|
-
|
|
2174
|
-
return;
|
|
2175
|
-
}
|
|
2176
|
-
}
|
|
2177
|
-
|
|
2178
|
-
if (_this.pinchFlag) {
|
|
2179
|
-
_this.onPinch(e, clients);
|
|
2180
|
-
}
|
|
2181
|
-
|
|
2182
|
-
_this.getCurrentStore().addClients(clients);
|
|
2183
|
-
};
|
|
2184
|
-
|
|
2185
|
-
_this.onDragEnd = function (e) {
|
|
2186
|
-
if (!_this.flag) {
|
|
2187
|
-
return;
|
|
2188
|
-
}
|
|
2189
|
-
|
|
2190
|
-
var _a = _this.options,
|
|
2191
|
-
pinchOutside = _a.pinchOutside,
|
|
2192
|
-
container = _a.container;
|
|
2193
|
-
|
|
2194
|
-
if (_this.isTouch && pinchOutside) {
|
|
2195
|
-
removeEvent(container, "touchstart", _this.onDragStart);
|
|
2196
|
-
}
|
|
2197
|
-
|
|
2198
|
-
_this.flag = false;
|
|
2199
|
-
|
|
2200
|
-
var position = _this.getCurrentStore().getPosition();
|
|
2201
|
-
|
|
2202
|
-
var currentTime = now();
|
|
2203
|
-
var isDouble = !_this.isDrag && _this.doubleFlag;
|
|
2204
|
-
_this.prevTime = _this.isDrag || isDouble ? 0 : currentTime;
|
|
2205
|
-
|
|
2206
|
-
_this.emit("dragEnd", __assign({
|
|
2207
|
-
datas: _this.datas,
|
|
2208
|
-
isDouble: isDouble,
|
|
2209
|
-
isDrag: _this.isDrag,
|
|
2210
|
-
isClick: !_this.isDrag,
|
|
2211
|
-
inputEvent: e
|
|
2212
|
-
}, position));
|
|
2213
|
-
|
|
2214
|
-
if (_this.pinchFlag) {
|
|
2215
|
-
_this.onPinchEnd(e);
|
|
2216
|
-
}
|
|
2217
|
-
|
|
2218
|
-
_this.clientStores = [];
|
|
2219
|
-
};
|
|
2220
|
-
|
|
2221
|
-
_this.onBlur = function () {
|
|
2222
|
-
_this.onDragEnd();
|
|
2223
|
-
};
|
|
2224
|
-
|
|
2225
|
-
var elements = [].concat(targets);
|
|
2226
|
-
_this.options = __assign({
|
|
2227
|
-
checkInput: false,
|
|
2228
|
-
container: elements.length > 1 ? window : elements[0],
|
|
2229
|
-
preventRightClick: true,
|
|
2230
|
-
preventDefault: true,
|
|
2231
|
-
checkWindowBlur: false,
|
|
2232
|
-
pinchThreshold: 0,
|
|
2233
|
-
events: ["touch", "mouse"]
|
|
2234
|
-
}, options);
|
|
2235
|
-
var _a = _this.options,
|
|
2236
|
-
container = _a.container,
|
|
2237
|
-
events = _a.events,
|
|
2238
|
-
checkWindowBlur = _a.checkWindowBlur;
|
|
2239
|
-
_this.isTouch = events.indexOf("touch") > -1;
|
|
2240
|
-
_this.isMouse = events.indexOf("mouse") > -1;
|
|
2241
|
-
_this.targets = elements;
|
|
2242
|
-
|
|
2243
|
-
if (_this.isMouse) {
|
|
2244
|
-
elements.forEach(function (el) {
|
|
2245
|
-
addEvent(el, "mousedown", _this.onDragStart);
|
|
2246
|
-
});
|
|
2247
|
-
addEvent(container, "mousemove", _this.onDrag);
|
|
2248
|
-
addEvent(container, "mouseup", _this.onDragEnd);
|
|
2249
|
-
addEvent(container, "contextmenu", _this.onDragEnd);
|
|
2250
|
-
}
|
|
2251
|
-
|
|
2252
|
-
if (checkWindowBlur) {
|
|
2253
|
-
addEvent(window, "blur", _this.onBlur);
|
|
2254
|
-
}
|
|
2255
|
-
|
|
2256
|
-
if (_this.isTouch) {
|
|
2257
|
-
var passive_1 = {
|
|
2258
|
-
passive: false
|
|
2259
|
-
};
|
|
2260
|
-
elements.forEach(function (el) {
|
|
2261
|
-
addEvent(el, "touchstart", _this.onDragStart, passive_1);
|
|
2262
|
-
});
|
|
2263
|
-
addEvent(container, "touchmove", _this.onDrag, passive_1);
|
|
2264
|
-
addEvent(container, "touchend", _this.onDragEnd, passive_1);
|
|
2265
|
-
addEvent(container, "touchcancel", _this.onDragEnd, passive_1);
|
|
2266
|
-
}
|
|
2267
|
-
|
|
2268
|
-
return _this;
|
|
2269
|
-
}
|
|
2270
|
-
/**
|
|
2271
|
-
* Stop Gesto's drag events.
|
|
2272
|
-
*/
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
var __proto = Gesto.prototype;
|
|
2276
|
-
|
|
2277
|
-
__proto.stop = function () {
|
|
2278
|
-
this.isDrag = false;
|
|
2279
|
-
this.flag = false;
|
|
2280
|
-
this.clientStores = [];
|
|
2281
|
-
this.datas = {};
|
|
2282
|
-
};
|
|
2283
|
-
/**
|
|
2284
|
-
* The total moved distance
|
|
2285
|
-
*/
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
__proto.getMovement = function (clients) {
|
|
2289
|
-
return this.getCurrentStore().getMovement(clients) + this.clientStores.slice(1).reduce(function (prev, cur) {
|
|
2290
|
-
return prev + cur.movement;
|
|
2291
|
-
}, 0);
|
|
2292
|
-
};
|
|
2293
|
-
/**
|
|
2294
|
-
* Whether to drag
|
|
2295
|
-
*/
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
__proto.isDragging = function () {
|
|
2299
|
-
return this.isDrag;
|
|
2300
|
-
};
|
|
2301
|
-
/**
|
|
2302
|
-
* Whether to start drag
|
|
2303
|
-
*/
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
__proto.isFlag = function () {
|
|
2307
|
-
return this.flag;
|
|
2308
|
-
};
|
|
2309
|
-
/**
|
|
2310
|
-
* Whether to start pinch
|
|
2311
|
-
*/
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
__proto.isPinchFlag = function () {
|
|
2315
|
-
return this.pinchFlag;
|
|
2316
|
-
};
|
|
2317
|
-
/**
|
|
2318
|
-
* Whether to start double click
|
|
2319
|
-
*/
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
__proto.isDoubleFlag = function () {
|
|
2323
|
-
return this.doubleFlag;
|
|
2324
|
-
};
|
|
2325
|
-
/**
|
|
2326
|
-
* Whether to pinch
|
|
2327
|
-
*/
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
__proto.isPinching = function () {
|
|
2331
|
-
return this.isPinch;
|
|
2332
|
-
};
|
|
2333
|
-
/**
|
|
2334
|
-
* If a scroll event occurs, it is corrected by the scroll distance.
|
|
2335
|
-
*/
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
__proto.scrollBy = function (deltaX, deltaY, e, isCallDrag) {
|
|
2339
|
-
if (isCallDrag === void 0) {
|
|
2340
|
-
isCallDrag = true;
|
|
2341
|
-
}
|
|
2342
|
-
|
|
2343
|
-
if (!this.flag) {
|
|
2344
|
-
return;
|
|
2345
|
-
}
|
|
2346
|
-
|
|
2347
|
-
this.clientStores[0].move(deltaX, deltaY);
|
|
2348
|
-
isCallDrag && this.onDrag(e, true);
|
|
2349
|
-
};
|
|
2350
|
-
/**
|
|
2351
|
-
* Create a virtual drag event.
|
|
2352
|
-
*/
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
__proto.move = function (_a, inputEvent) {
|
|
2356
|
-
var deltaX = _a[0],
|
|
2357
|
-
deltaY = _a[1];
|
|
2358
|
-
var store = this.getCurrentStore();
|
|
2359
|
-
var nextClients = store.prevClients;
|
|
2360
|
-
return this.moveClients(nextClients.map(function (_a) {
|
|
2361
|
-
var clientX = _a.clientX,
|
|
2362
|
-
clientY = _a.clientY;
|
|
2363
|
-
return {
|
|
2364
|
-
clientX: clientX + deltaX,
|
|
2365
|
-
clientY: clientY + deltaY,
|
|
2366
|
-
originalClientX: clientX,
|
|
2367
|
-
originalClientY: clientY
|
|
2368
|
-
};
|
|
2369
|
-
}), inputEvent, true);
|
|
2370
|
-
};
|
|
2371
|
-
/**
|
|
2372
|
-
* The dragStart event is triggered by an external event.
|
|
2373
|
-
*/
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
__proto.triggerDragStart = function (e) {
|
|
2377
|
-
this.onDragStart(e, false);
|
|
2378
|
-
};
|
|
2379
|
-
/**
|
|
2380
|
-
* Set the event data while dragging.
|
|
2381
|
-
*/
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
__proto.setEventDatas = function (datas) {
|
|
2385
|
-
var currentDatas = this.datas;
|
|
2386
|
-
|
|
2387
|
-
for (var name in datas) {
|
|
2388
|
-
currentDatas[name] = datas[name];
|
|
2389
|
-
}
|
|
2390
|
-
|
|
2391
|
-
return this;
|
|
2392
|
-
};
|
|
2393
|
-
/**
|
|
2394
|
-
* Set the event data while dragging.
|
|
2395
|
-
*/
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
__proto.getEventDatas = function () {
|
|
2399
|
-
return this.datas;
|
|
2400
|
-
};
|
|
2401
|
-
/**
|
|
2402
|
-
* Unset Gesto
|
|
2403
|
-
*/
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
__proto.unset = function () {
|
|
2407
|
-
var _this = this;
|
|
2408
|
-
|
|
2409
|
-
var targets = this.targets;
|
|
2410
|
-
var container = this.options.container;
|
|
2411
|
-
this.off();
|
|
2412
|
-
removeEvent(window, "blur", this.onBlur);
|
|
2413
|
-
|
|
2414
|
-
if (this.isMouse) {
|
|
2415
|
-
targets.forEach(function (target) {
|
|
2416
|
-
removeEvent(target, "mousedown", _this.onDragStart);
|
|
2417
|
-
});
|
|
2418
|
-
removeEvent(container, "mousemove", this.onDrag);
|
|
2419
|
-
removeEvent(container, "mouseup", this.onDragEnd);
|
|
2420
|
-
removeEvent(container, "contextmenu", this.onDragEnd);
|
|
2421
|
-
}
|
|
2422
|
-
|
|
2423
|
-
if (this.isTouch) {
|
|
2424
|
-
targets.forEach(function (target) {
|
|
2425
|
-
removeEvent(target, "touchstart", _this.onDragStart);
|
|
2426
|
-
});
|
|
2427
|
-
removeEvent(container, "touchstart", this.onDragStart);
|
|
2428
|
-
removeEvent(container, "touchmove", this.onDrag);
|
|
2429
|
-
removeEvent(container, "touchend", this.onDragEnd);
|
|
2430
|
-
removeEvent(container, "touchcancel", this.onDragEnd);
|
|
2431
|
-
}
|
|
2432
|
-
};
|
|
2433
|
-
|
|
2434
|
-
__proto.onPinchStart = function (e) {
|
|
2435
|
-
var pinchThreshold = this.options.pinchThreshold;
|
|
2436
|
-
|
|
2437
|
-
if (this.isDrag && this.getMovement() > pinchThreshold) {
|
|
2438
|
-
return;
|
|
2439
|
-
}
|
|
2440
|
-
|
|
2441
|
-
var store = new ClientStore(getEventClients(e));
|
|
2442
|
-
this.pinchFlag = true;
|
|
2443
|
-
this.clientStores.splice(0, 0, store);
|
|
2444
|
-
var result = this.emit("pinchStart", __assign({
|
|
2445
|
-
datas: this.datas,
|
|
2446
|
-
angle: store.getAngle(),
|
|
2447
|
-
touches: this.getCurrentStore().getPositions()
|
|
2448
|
-
}, store.getPosition(), {
|
|
2449
|
-
inputEvent: e
|
|
2450
|
-
}));
|
|
2451
|
-
|
|
2452
|
-
if (result === false) {
|
|
2453
|
-
this.pinchFlag = false;
|
|
2454
|
-
}
|
|
2455
|
-
};
|
|
2456
|
-
|
|
2457
|
-
__proto.onPinch = function (e, clients) {
|
|
2458
|
-
if (!this.flag || !this.pinchFlag || clients.length < 2) {
|
|
2459
|
-
return;
|
|
2460
|
-
}
|
|
2461
|
-
|
|
2462
|
-
var store = this.getCurrentStore();
|
|
2463
|
-
this.isPinch = true;
|
|
2464
|
-
this.emit("pinch", __assign({
|
|
2465
|
-
datas: this.datas,
|
|
2466
|
-
movement: this.getMovement(clients),
|
|
2467
|
-
angle: store.getAngle(clients),
|
|
2468
|
-
rotation: store.getRotation(clients),
|
|
2469
|
-
touches: store.getPositions(clients),
|
|
2470
|
-
scale: store.getScale(clients),
|
|
2471
|
-
distance: store.getDistance(clients)
|
|
2472
|
-
}, store.getPosition(clients), {
|
|
2473
|
-
inputEvent: e
|
|
2474
|
-
}));
|
|
2475
|
-
};
|
|
2476
|
-
|
|
2477
|
-
__proto.onPinchEnd = function (e) {
|
|
2478
|
-
if (!this.pinchFlag) {
|
|
2479
|
-
return;
|
|
2480
|
-
}
|
|
2481
|
-
|
|
2482
|
-
var isPinch = this.isPinch;
|
|
2483
|
-
this.isPinch = false;
|
|
2484
|
-
this.pinchFlag = false;
|
|
2485
|
-
var store = this.getCurrentStore();
|
|
2486
|
-
this.emit("pinchEnd", __assign({
|
|
2487
|
-
datas: this.datas,
|
|
2488
|
-
isPinch: isPinch,
|
|
2489
|
-
touches: store.getPositions()
|
|
2490
|
-
}, store.getPosition(), {
|
|
2491
|
-
inputEvent: e
|
|
2492
|
-
}));
|
|
2493
|
-
this.isPinch = false;
|
|
2494
|
-
this.pinchFlag = false;
|
|
2495
|
-
};
|
|
2496
|
-
|
|
2497
|
-
__proto.initDrag = function () {
|
|
2498
|
-
this.clientStores = [];
|
|
2499
|
-
this.pinchFlag = false;
|
|
2500
|
-
this.doubleFlag = false;
|
|
2501
|
-
this.prevTime = 0;
|
|
2502
|
-
this.flag = false;
|
|
2503
|
-
};
|
|
2504
|
-
|
|
2505
|
-
__proto.getCurrentStore = function () {
|
|
2506
|
-
return this.clientStores[0];
|
|
2507
|
-
};
|
|
2508
|
-
|
|
2509
|
-
__proto.moveClients = function (clients, inputEvent, isAdd) {
|
|
2510
|
-
var store = this.getCurrentStore();
|
|
2511
|
-
var position = store[isAdd ? "addClients" : "getPosition"](clients);
|
|
2512
|
-
this.isDrag = true;
|
|
2513
|
-
return __assign({
|
|
2514
|
-
datas: this.datas
|
|
2515
|
-
}, position, {
|
|
2516
|
-
movement: this.getMovement(clients),
|
|
2517
|
-
isDrag: this.isDrag,
|
|
2518
|
-
isPinch: this.isPinch,
|
|
2519
|
-
isScroll: false,
|
|
2520
|
-
inputEvent: inputEvent
|
|
2521
|
-
});
|
|
2522
|
-
};
|
|
2523
|
-
|
|
2524
|
-
return Gesto;
|
|
2525
|
-
}(EventEmitter$1);
|
|
2526
|
-
|
|
2527
|
-
var Gesto$1 = Gesto;
|
|
2528
|
-
|
|
2529
|
-
const _sfc_main$f = defineComponent({
|
|
2530
|
-
name: "m-editor-resize",
|
|
2531
|
-
props: {
|
|
2532
|
-
type: {
|
|
2533
|
-
type: String
|
|
2534
|
-
}
|
|
2535
|
-
},
|
|
2536
|
-
setup(props) {
|
|
2537
|
-
const services = inject("services");
|
|
2538
|
-
const target = ref();
|
|
2539
|
-
let getso;
|
|
2540
|
-
onMounted(() => {
|
|
2541
|
-
if (!target.value)
|
|
2542
|
-
return;
|
|
2543
|
-
getso = new Gesto$1(target.value, {
|
|
2544
|
-
container: window,
|
|
2545
|
-
pinchOutside: true
|
|
2546
|
-
}).on("drag", (e) => {
|
|
2547
|
-
if (!target.value || !services)
|
|
2548
|
-
return;
|
|
2549
|
-
let { left, right } = {
|
|
2550
|
-
...toRaw(services.uiService.get("columnWidth"))
|
|
2551
|
-
};
|
|
2552
|
-
if (props.type === "left") {
|
|
2553
|
-
left += e.deltaX;
|
|
2554
|
-
} else if (props.type === "right") {
|
|
2555
|
-
right -= e.deltaX;
|
|
2556
|
-
}
|
|
2557
|
-
services.uiService.set("columnWidth", {
|
|
2558
|
-
left,
|
|
2559
|
-
right
|
|
2560
|
-
});
|
|
2561
|
-
});
|
|
2562
|
-
});
|
|
2563
|
-
onUnmounted(() => {
|
|
2564
|
-
getso?.unset();
|
|
2565
|
-
});
|
|
2566
|
-
return {
|
|
2567
|
-
target
|
|
2568
|
-
};
|
|
2569
|
-
}
|
|
2570
|
-
});
|
|
2571
|
-
const _hoisted_1$b = {
|
|
2572
|
-
ref: "target",
|
|
2573
|
-
class: "m-editor-resizer"
|
|
2574
|
-
};
|
|
2575
|
-
function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2576
|
-
return openBlock(), createElementBlock("span", _hoisted_1$b, [
|
|
2577
|
-
renderSlot(_ctx.$slots, "default")
|
|
2578
|
-
], 512);
|
|
2579
|
-
}
|
|
2580
|
-
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
|
|
2581
|
-
|
|
2582
|
-
const _sfc_main$e = defineComponent({
|
|
2583
|
-
components: {
|
|
2584
|
-
AddPageBox,
|
|
2585
|
-
Resizer
|
|
2586
1673
|
},
|
|
2587
1674
|
setup() {
|
|
2588
|
-
const
|
|
2589
|
-
const root = computed(() =>
|
|
1675
|
+
const { editorService, uiService } = inject("services") || {};
|
|
1676
|
+
const root = computed(() => editorService?.get("root"));
|
|
2590
1677
|
return {
|
|
2591
1678
|
root,
|
|
2592
|
-
pageLength: computed(() =>
|
|
2593
|
-
showSrc: computed(() =>
|
|
2594
|
-
columnWidth: computed(() =>
|
|
1679
|
+
pageLength: computed(() => editorService?.get("pageLength") || 0),
|
|
1680
|
+
showSrc: computed(() => uiService?.get("showSrc")),
|
|
1681
|
+
columnWidth: computed(() => uiService?.get("columnWidth")),
|
|
2595
1682
|
saveCode(value) {
|
|
2596
1683
|
try {
|
|
2597
|
-
|
|
1684
|
+
editorService?.set("root", eval(value));
|
|
2598
1685
|
} catch (e) {
|
|
2599
1686
|
console.error(e);
|
|
2600
1687
|
}
|
|
@@ -2602,24 +1689,25 @@ const _sfc_main$e = defineComponent({
|
|
|
2602
1689
|
};
|
|
2603
1690
|
}
|
|
2604
1691
|
});
|
|
2605
|
-
const _hoisted_1$
|
|
2606
|
-
const _hoisted_2$
|
|
1692
|
+
const _hoisted_1$8 = { class: "m-editor" };
|
|
1693
|
+
const _hoisted_2$3 = {
|
|
2607
1694
|
key: 1,
|
|
2608
1695
|
class: "m-editor-content"
|
|
2609
1696
|
};
|
|
2610
|
-
function _sfc_render$
|
|
1697
|
+
function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2611
1698
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
2612
1699
|
const _component_resizer = resolveComponent("resizer");
|
|
2613
1700
|
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
2614
1701
|
const _component_add_page_box = resolveComponent("add-page-box");
|
|
2615
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
1702
|
+
return openBlock(), createElementBlock("div", _hoisted_1$8, [
|
|
2616
1703
|
renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
2617
1704
|
_ctx.showSrc ? (openBlock(), createBlock(_component_magic_code_editor, {
|
|
2618
1705
|
key: 0,
|
|
2619
1706
|
class: "m-editor-content",
|
|
2620
1707
|
"init-values": _ctx.root,
|
|
1708
|
+
options: _ctx.codeOptions,
|
|
2621
1709
|
onSave: _ctx.saveCode
|
|
2622
|
-
}, null, 8, ["init-values", "onSave"])) : (openBlock(), createElementBlock("div", _hoisted_2$
|
|
1710
|
+
}, null, 8, ["init-values", "options", "onSave"])) : (openBlock(), createElementBlock("div", _hoisted_2$3, [
|
|
2623
1711
|
createElementVNode("div", {
|
|
2624
1712
|
class: "m-editor-framework-left",
|
|
2625
1713
|
style: normalizeStyle(`width: ${_ctx.columnWidth?.left}px`)
|
|
@@ -2652,9 +1740,9 @@ function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2652
1740
|
]))
|
|
2653
1741
|
]);
|
|
2654
1742
|
}
|
|
2655
|
-
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1743
|
+
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
|
|
2656
1744
|
|
|
2657
|
-
const _sfc_main$
|
|
1745
|
+
const _sfc_main$f = defineComponent({
|
|
2658
1746
|
name: "m-icon",
|
|
2659
1747
|
components: { Edit },
|
|
2660
1748
|
props: {
|
|
@@ -2668,8 +1756,8 @@ const _sfc_main$d = defineComponent({
|
|
|
2668
1756
|
};
|
|
2669
1757
|
}
|
|
2670
1758
|
});
|
|
2671
|
-
const _hoisted_1$
|
|
2672
|
-
function _sfc_render$
|
|
1759
|
+
const _hoisted_1$7 = ["src"];
|
|
1760
|
+
function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2673
1761
|
const _component_edit = resolveComponent("edit");
|
|
2674
1762
|
const _component_el_icon = resolveComponent("el-icon");
|
|
2675
1763
|
return !_ctx.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
|
|
@@ -2680,7 +1768,7 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2680
1768
|
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (openBlock(), createElementBlock("img", {
|
|
2681
1769
|
key: 1,
|
|
2682
1770
|
src: _ctx.icon
|
|
2683
|
-
}, null, 8, _hoisted_1$
|
|
1771
|
+
}, null, 8, _hoisted_1$7)) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
2684
1772
|
key: 2,
|
|
2685
1773
|
class: normalizeClass(_ctx.icon)
|
|
2686
1774
|
}, null, 2)) : (openBlock(), createBlock(_component_el_icon, { key: 3 }, {
|
|
@@ -2690,9 +1778,9 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2690
1778
|
_: 1
|
|
2691
1779
|
}));
|
|
2692
1780
|
}
|
|
2693
|
-
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1781
|
+
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
|
|
2694
1782
|
|
|
2695
|
-
const _sfc_main$
|
|
1783
|
+
const _sfc_main$e = defineComponent({
|
|
2696
1784
|
components: { MIcon, ArrowDown },
|
|
2697
1785
|
props: {
|
|
2698
1786
|
data: {
|
|
@@ -2702,16 +1790,20 @@ const _sfc_main$c = defineComponent({
|
|
|
2702
1790
|
type: "text",
|
|
2703
1791
|
display: false
|
|
2704
1792
|
})
|
|
1793
|
+
},
|
|
1794
|
+
eventType: {
|
|
1795
|
+
type: String,
|
|
1796
|
+
default: "click"
|
|
2705
1797
|
}
|
|
2706
1798
|
},
|
|
2707
1799
|
setup(props) {
|
|
2708
1800
|
const services = inject("services");
|
|
2709
1801
|
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
1802
|
const zoom = computed(() => uiService?.get("zoom") ?? 1);
|
|
2713
1803
|
const showGuides = computed(() => uiService?.get("showGuides") ?? true);
|
|
2714
1804
|
const showRule = computed(() => uiService?.get("showRule") ?? true);
|
|
1805
|
+
const zoomInHandler = () => uiService?.zoom(0.1);
|
|
1806
|
+
const zoomOutHandler = () => uiService?.zoom(-0.1);
|
|
2715
1807
|
const item = computed(() => {
|
|
2716
1808
|
if (typeof props.data !== "string") {
|
|
2717
1809
|
return props.data;
|
|
@@ -2728,7 +1820,7 @@ const _sfc_main$c = defineComponent({
|
|
|
2728
1820
|
case "delete":
|
|
2729
1821
|
return {
|
|
2730
1822
|
type: "button",
|
|
2731
|
-
icon: Delete,
|
|
1823
|
+
icon: markRaw(Delete),
|
|
2732
1824
|
tooltip: "\u522A\u9664",
|
|
2733
1825
|
disabled: () => services?.editorService.get("node")?.type === NodeType.PAGE,
|
|
2734
1826
|
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
@@ -2736,7 +1828,7 @@ const _sfc_main$c = defineComponent({
|
|
|
2736
1828
|
case "undo":
|
|
2737
1829
|
return {
|
|
2738
1830
|
type: "button",
|
|
2739
|
-
icon: Back,
|
|
1831
|
+
icon: markRaw(Back),
|
|
2740
1832
|
tooltip: "\u540E\u9000",
|
|
2741
1833
|
disabled: () => !services?.historyService.state.canUndo,
|
|
2742
1834
|
handler: () => services?.editorService.undo()
|
|
@@ -2744,7 +1836,7 @@ const _sfc_main$c = defineComponent({
|
|
|
2744
1836
|
case "redo":
|
|
2745
1837
|
return {
|
|
2746
1838
|
type: "button",
|
|
2747
|
-
icon: Right,
|
|
1839
|
+
icon: markRaw(Right),
|
|
2748
1840
|
tooltip: "\u524D\u8FDB",
|
|
2749
1841
|
disabled: () => !services?.historyService.state.canRedo,
|
|
2750
1842
|
handler: () => services?.editorService.redo()
|
|
@@ -2752,28 +1844,28 @@ const _sfc_main$c = defineComponent({
|
|
|
2752
1844
|
case "zoom-in":
|
|
2753
1845
|
return {
|
|
2754
1846
|
type: "button",
|
|
2755
|
-
icon: ZoomIn,
|
|
1847
|
+
icon: markRaw(ZoomIn),
|
|
2756
1848
|
tooltip: "\u653E\u5927",
|
|
2757
1849
|
handler: zoomInHandler
|
|
2758
1850
|
};
|
|
2759
1851
|
case "zoom-out":
|
|
2760
1852
|
return {
|
|
2761
1853
|
type: "button",
|
|
2762
|
-
icon: ZoomOut,
|
|
1854
|
+
icon: markRaw(ZoomOut),
|
|
2763
1855
|
tooltip: "\u7E2E\u5C0F",
|
|
2764
1856
|
handler: zoomOutHandler
|
|
2765
1857
|
};
|
|
2766
1858
|
case "rule":
|
|
2767
1859
|
return {
|
|
2768
1860
|
type: "button",
|
|
2769
|
-
icon: ScaleToOriginal,
|
|
1861
|
+
icon: markRaw(ScaleToOriginal),
|
|
2770
1862
|
tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
|
|
2771
1863
|
handler: () => uiService?.set("showRule", !showRule.value)
|
|
2772
1864
|
};
|
|
2773
1865
|
case "guides":
|
|
2774
1866
|
return {
|
|
2775
1867
|
type: "button",
|
|
2776
|
-
icon: Grid,
|
|
1868
|
+
icon: markRaw(Grid),
|
|
2777
1869
|
tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
|
|
2778
1870
|
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
2779
1871
|
};
|
|
@@ -2794,9 +1886,16 @@ const _sfc_main$c = defineComponent({
|
|
|
2794
1886
|
}
|
|
2795
1887
|
return item.value.disabled;
|
|
2796
1888
|
});
|
|
1889
|
+
const buttonHandler = (item2, event) => {
|
|
1890
|
+
if (disabled.value)
|
|
1891
|
+
return;
|
|
1892
|
+
if (typeof item2.handler === "function" && services) {
|
|
1893
|
+
item2.handler?.(services, event);
|
|
1894
|
+
}
|
|
1895
|
+
};
|
|
2797
1896
|
return {
|
|
2798
|
-
ZoomIn,
|
|
2799
|
-
ZoomOut,
|
|
1897
|
+
ZoomIn: markRaw(ZoomIn),
|
|
1898
|
+
ZoomOut: markRaw(ZoomOut),
|
|
2800
1899
|
item,
|
|
2801
1900
|
zoom,
|
|
2802
1901
|
disabled,
|
|
@@ -2817,31 +1916,42 @@ const _sfc_main$c = defineComponent({
|
|
|
2817
1916
|
command.item.handler(services);
|
|
2818
1917
|
}
|
|
2819
1918
|
},
|
|
2820
|
-
|
|
2821
|
-
if (
|
|
1919
|
+
clickHandler(item2, event) {
|
|
1920
|
+
if (props.eventType !== "click")
|
|
1921
|
+
return;
|
|
1922
|
+
if (item2.type === "button") {
|
|
1923
|
+
buttonHandler(item2, event);
|
|
1924
|
+
}
|
|
1925
|
+
},
|
|
1926
|
+
mousedownHandler(item2, event) {
|
|
1927
|
+
if (props.eventType !== "mousedown")
|
|
1928
|
+
return;
|
|
1929
|
+
if (item2.type === "button") {
|
|
1930
|
+
buttonHandler(item2, event);
|
|
1931
|
+
}
|
|
1932
|
+
},
|
|
1933
|
+
mouseupHandler(item2, event) {
|
|
1934
|
+
if (props.eventType !== "mouseup")
|
|
2822
1935
|
return;
|
|
2823
|
-
if (
|
|
2824
|
-
item2
|
|
1936
|
+
if (item2.type === "button") {
|
|
1937
|
+
buttonHandler(item2, event);
|
|
2825
1938
|
}
|
|
2826
1939
|
}
|
|
2827
1940
|
};
|
|
2828
1941
|
}
|
|
2829
1942
|
});
|
|
2830
|
-
const _hoisted_1$
|
|
2831
|
-
key: 0,
|
|
2832
|
-
class: "menu-item"
|
|
2833
|
-
};
|
|
2834
|
-
const _hoisted_2$4 = {
|
|
1943
|
+
const _hoisted_1$6 = {
|
|
2835
1944
|
key: 1,
|
|
2836
1945
|
class: "menu-item-text"
|
|
2837
1946
|
};
|
|
2838
|
-
const
|
|
1947
|
+
const _hoisted_2$2 = {
|
|
2839
1948
|
class: "menu-item-text",
|
|
2840
1949
|
style: { "margin": "0 5px" }
|
|
2841
1950
|
};
|
|
2842
|
-
const
|
|
2843
|
-
function _sfc_render$
|
|
1951
|
+
const _hoisted_3$1 = { class: "el-dropdown-link menubar-menu-button" };
|
|
1952
|
+
function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2844
1953
|
const _component_el_divider = resolveComponent("el-divider");
|
|
1954
|
+
const _component_tool_button = resolveComponent("tool-button", true);
|
|
2845
1955
|
const _component_m_icon = resolveComponent("m-icon");
|
|
2846
1956
|
const _component_el_button = resolveComponent("el-button");
|
|
2847
1957
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
@@ -2850,44 +1960,66 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2850
1960
|
const _component_el_dropdown_item = resolveComponent("el-dropdown-item");
|
|
2851
1961
|
const _component_el_dropdown_menu = resolveComponent("el-dropdown-menu");
|
|
2852
1962
|
const _component_el_dropdown = resolveComponent("el-dropdown");
|
|
2853
|
-
return _ctx.display ? (openBlock(), createElementBlock("div",
|
|
1963
|
+
return _ctx.display ? (openBlock(), createElementBlock("div", {
|
|
1964
|
+
key: 0,
|
|
1965
|
+
class: normalizeClass(["menu-item", _ctx.item.type]),
|
|
1966
|
+
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.clickHandler(_ctx.item, $event)),
|
|
1967
|
+
onMousedown: _cache[1] || (_cache[1] = ($event) => _ctx.mousedownHandler(_ctx.item, $event)),
|
|
1968
|
+
onMouseup: _cache[2] || (_cache[2] = ($event) => _ctx.mouseupHandler(_ctx.item, $event))
|
|
1969
|
+
}, [
|
|
2854
1970
|
_ctx.item.type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
|
|
2855
1971
|
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
|
-
|
|
1972
|
+
direction: _ctx.item.direction || "vertical"
|
|
1973
|
+
}, 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 }, [
|
|
1974
|
+
createVNode(_component_tool_button, {
|
|
1975
|
+
data: { type: "button", icon: _ctx.ZoomOut, handler: _ctx.zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
1976
|
+
"event-type": _ctx.eventType
|
|
1977
|
+
}, null, 8, ["data", "event-type"]),
|
|
1978
|
+
createElementVNode("span", _hoisted_2$2, toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
|
|
1979
|
+
createVNode(_component_tool_button, {
|
|
1980
|
+
data: { type: "button", icon: _ctx.ZoomIn, handler: _ctx.zoomInHandler, tooltip: "\u653E\u5927" },
|
|
1981
|
+
"event-type": _ctx.eventType
|
|
1982
|
+
}, null, 8, ["data", "event-type"])
|
|
1983
|
+
], 64)) : _ctx.item.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
1984
|
+
_ctx.item.tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
1985
|
+
key: 0,
|
|
1986
|
+
effect: "dark",
|
|
1987
|
+
placement: "bottom-start",
|
|
1988
|
+
content: _ctx.item.tooltip
|
|
1989
|
+
}, {
|
|
1990
|
+
default: withCtx(() => [
|
|
1991
|
+
createVNode(_component_el_button, {
|
|
1992
|
+
size: "small",
|
|
1993
|
+
text: "",
|
|
1994
|
+
disabled: _ctx.disabled
|
|
1995
|
+
}, {
|
|
1996
|
+
default: withCtx(() => [
|
|
1997
|
+
_ctx.item.icon ? (openBlock(), createBlock(_component_m_icon, {
|
|
1998
|
+
key: 0,
|
|
1999
|
+
icon: _ctx.item.icon
|
|
2000
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
2001
|
+
createElementVNode("span", null, toDisplayString(_ctx.item.text), 1)
|
|
2002
|
+
]),
|
|
2003
|
+
_: 1
|
|
2004
|
+
}, 8, ["disabled"])
|
|
2005
|
+
]),
|
|
2006
|
+
_: 1
|
|
2007
|
+
}, 8, ["content"])) : (openBlock(), createBlock(_component_el_button, {
|
|
2008
|
+
key: 1,
|
|
2009
|
+
size: "small",
|
|
2010
|
+
text: "",
|
|
2011
|
+
disabled: _ctx.disabled
|
|
2012
|
+
}, {
|
|
2013
|
+
default: withCtx(() => [
|
|
2014
|
+
_ctx.item.icon ? (openBlock(), createBlock(_component_m_icon, {
|
|
2015
|
+
key: 0,
|
|
2016
|
+
icon: _ctx.item.icon
|
|
2017
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
2018
|
+
createElementVNode("span", null, toDisplayString(_ctx.item.text), 1)
|
|
2019
|
+
]),
|
|
2020
|
+
_: 1
|
|
2021
|
+
}, 8, ["disabled"]))
|
|
2022
|
+
], 64)) : _ctx.item.type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
|
|
2891
2023
|
key: 4,
|
|
2892
2024
|
trigger: "click",
|
|
2893
2025
|
disabled: _ctx.disabled,
|
|
@@ -2912,7 +2044,7 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2912
2044
|
})) : createCommentVNode("", true)
|
|
2913
2045
|
]),
|
|
2914
2046
|
default: withCtx(() => [
|
|
2915
|
-
createElementVNode("span",
|
|
2047
|
+
createElementVNode("span", _hoisted_3$1, [
|
|
2916
2048
|
createTextVNode(toDisplayString(_ctx.item.text), 1),
|
|
2917
2049
|
createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2918
2050
|
default: withCtx(() => [
|
|
@@ -2924,11 +2056,11 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2924
2056
|
]),
|
|
2925
2057
|
_: 1
|
|
2926
2058
|
}, 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);
|
|
2059
|
+
], 34)) : createCommentVNode("", true);
|
|
2928
2060
|
}
|
|
2929
|
-
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2061
|
+
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
|
|
2930
2062
|
|
|
2931
|
-
const _sfc_main$
|
|
2063
|
+
const _sfc_main$d = defineComponent({
|
|
2932
2064
|
name: "nav-menu",
|
|
2933
2065
|
components: { ToolButton },
|
|
2934
2066
|
props: {
|
|
@@ -2948,7 +2080,7 @@ const _sfc_main$b = defineComponent({
|
|
|
2948
2080
|
};
|
|
2949
2081
|
}
|
|
2950
2082
|
});
|
|
2951
|
-
function _sfc_render$
|
|
2083
|
+
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2952
2084
|
const _component_tool_button = resolveComponent("tool-button");
|
|
2953
2085
|
return openBlock(), createElementBlock("div", {
|
|
2954
2086
|
class: "m-editor-nav-menu",
|
|
@@ -2970,9 +2102,9 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2970
2102
|
}), 128))
|
|
2971
2103
|
], 4);
|
|
2972
2104
|
}
|
|
2973
|
-
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2105
|
+
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
|
|
2974
2106
|
|
|
2975
|
-
const _sfc_main$
|
|
2107
|
+
const _sfc_main$c = defineComponent({
|
|
2976
2108
|
name: "m-editor-props-panel",
|
|
2977
2109
|
emits: ["mounted"],
|
|
2978
2110
|
setup(props, { emit }) {
|
|
@@ -2987,9 +2119,9 @@ const _sfc_main$a = defineComponent({
|
|
|
2987
2119
|
curFormConfig.value = [];
|
|
2988
2120
|
return;
|
|
2989
2121
|
}
|
|
2990
|
-
values.value = node.value;
|
|
2991
2122
|
const type = node.value.type || (node.value.items ? "container" : "text");
|
|
2992
2123
|
curFormConfig.value = await services?.propsService.getPropsConfig(type) || [];
|
|
2124
|
+
values.value = node.value;
|
|
2993
2125
|
};
|
|
2994
2126
|
watchEffect(init);
|
|
2995
2127
|
services?.propsService.on("props-configs-change", init);
|
|
@@ -3000,6 +2132,7 @@ const _sfc_main$a = defineComponent({
|
|
|
3000
2132
|
values,
|
|
3001
2133
|
configForm,
|
|
3002
2134
|
curFormConfig,
|
|
2135
|
+
propsPanelSize: computed(() => services?.uiService.get("propsPanelSize") || "small"),
|
|
3003
2136
|
async submit() {
|
|
3004
2137
|
try {
|
|
3005
2138
|
const values2 = await configForm.value?.submitForm();
|
|
@@ -3018,21 +2151,21 @@ const _sfc_main$a = defineComponent({
|
|
|
3018
2151
|
};
|
|
3019
2152
|
}
|
|
3020
2153
|
});
|
|
3021
|
-
function _sfc_render$
|
|
2154
|
+
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3022
2155
|
const _component_m_form = resolveComponent("m-form");
|
|
3023
2156
|
return openBlock(), createBlock(_component_m_form, {
|
|
3024
|
-
class:
|
|
3025
|
-
"popper-class":
|
|
2157
|
+
class: normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
|
|
2158
|
+
"popper-class": `m-editor-props-panel-popper ${_ctx.propsPanelSize}`,
|
|
3026
2159
|
ref: "configForm",
|
|
3027
|
-
size:
|
|
2160
|
+
size: _ctx.propsPanelSize,
|
|
3028
2161
|
"init-values": _ctx.values,
|
|
3029
2162
|
config: _ctx.curFormConfig,
|
|
3030
2163
|
onChange: _ctx.submit
|
|
3031
|
-
}, null, 8, ["init-values", "config", "onChange"]);
|
|
2164
|
+
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"]);
|
|
3032
2165
|
}
|
|
3033
|
-
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2166
|
+
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
|
|
3034
2167
|
|
|
3035
|
-
const _sfc_main$
|
|
2168
|
+
const _sfc_main$b = defineComponent({
|
|
3036
2169
|
name: "ui-component-panel",
|
|
3037
2170
|
components: { MIcon },
|
|
3038
2171
|
setup() {
|
|
@@ -3047,19 +2180,29 @@ const _sfc_main$9 = defineComponent({
|
|
|
3047
2180
|
searchText,
|
|
3048
2181
|
collapseValue,
|
|
3049
2182
|
list,
|
|
3050
|
-
appendComponent({ text, type,
|
|
2183
|
+
appendComponent({ text, type, data = {} }) {
|
|
3051
2184
|
services?.editorService.add({
|
|
3052
2185
|
name: text,
|
|
3053
2186
|
type,
|
|
3054
|
-
...
|
|
2187
|
+
...data
|
|
3055
2188
|
});
|
|
2189
|
+
},
|
|
2190
|
+
dragstartHandler({ text, type, data = {} }, e) {
|
|
2191
|
+
if (e.dataTransfer) {
|
|
2192
|
+
e.dataTransfer.effectAllowed = "move";
|
|
2193
|
+
e.dataTransfer.setData("data", serialize({
|
|
2194
|
+
name: text,
|
|
2195
|
+
type,
|
|
2196
|
+
...data
|
|
2197
|
+
}).replace(/"(\w+)":\s/g, "$1: "));
|
|
2198
|
+
}
|
|
3056
2199
|
}
|
|
3057
2200
|
};
|
|
3058
2201
|
}
|
|
3059
2202
|
});
|
|
3060
|
-
const _hoisted_1$
|
|
3061
|
-
const _hoisted_2$
|
|
3062
|
-
function _sfc_render$
|
|
2203
|
+
const _hoisted_1$5 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
2204
|
+
const _hoisted_2$1 = ["onClick", "onDragstart"];
|
|
2205
|
+
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3063
2206
|
const _component_el_input = resolveComponent("el-input");
|
|
3064
2207
|
const _component_m_icon = resolveComponent("m-icon");
|
|
3065
2208
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
@@ -3089,15 +2232,17 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3089
2232
|
name: index
|
|
3090
2233
|
}, {
|
|
3091
2234
|
title: withCtx(() => [
|
|
3092
|
-
_hoisted_1$
|
|
2235
|
+
_hoisted_1$5,
|
|
3093
2236
|
createTextVNode(toDisplayString(group.title), 1)
|
|
3094
2237
|
]),
|
|
3095
2238
|
default: withCtx(() => [
|
|
3096
2239
|
(openBlock(true), createElementBlock(Fragment, null, renderList(group.items, (item) => {
|
|
3097
2240
|
return openBlock(), createElementBlock("div", {
|
|
3098
2241
|
class: "component-item",
|
|
2242
|
+
draggable: "true",
|
|
3099
2243
|
key: item.type,
|
|
3100
|
-
onClick: ($event) => _ctx.appendComponent(item)
|
|
2244
|
+
onClick: ($event) => _ctx.appendComponent(item),
|
|
2245
|
+
onDragstart: ($event) => _ctx.dragstartHandler(item, $event)
|
|
3101
2246
|
}, [
|
|
3102
2247
|
createVNode(_component_m_icon, {
|
|
3103
2248
|
icon: item.icon
|
|
@@ -3112,7 +2257,7 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3112
2257
|
]),
|
|
3113
2258
|
_: 2
|
|
3114
2259
|
}, 1032, ["content"])
|
|
3115
|
-
],
|
|
2260
|
+
], 40, _hoisted_2$1);
|
|
3116
2261
|
}), 128))
|
|
3117
2262
|
]),
|
|
3118
2263
|
_: 2
|
|
@@ -3126,133 +2271,237 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3126
2271
|
_: 1
|
|
3127
2272
|
});
|
|
3128
2273
|
}
|
|
3129
|
-
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2274
|
+
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
|
|
3130
2275
|
|
|
3131
|
-
const _sfc_main$
|
|
3132
|
-
|
|
2276
|
+
const _sfc_main$a = defineComponent({
|
|
2277
|
+
components: { ToolButton },
|
|
3133
2278
|
props: {
|
|
3134
|
-
|
|
2279
|
+
menuData: {
|
|
3135
2280
|
type: Array,
|
|
3136
2281
|
default: () => []
|
|
2282
|
+
},
|
|
2283
|
+
isSubMenu: {
|
|
2284
|
+
type: Boolean,
|
|
2285
|
+
default: false
|
|
3137
2286
|
}
|
|
3138
2287
|
},
|
|
3139
|
-
|
|
2288
|
+
emits: ["hide", "show"],
|
|
2289
|
+
setup(props, { emit }) {
|
|
2290
|
+
const menu = ref();
|
|
2291
|
+
const subMenu = ref();
|
|
2292
|
+
const visible = ref(false);
|
|
2293
|
+
const subMenuData = ref([]);
|
|
2294
|
+
const menuStyle = ref({
|
|
2295
|
+
left: "0",
|
|
2296
|
+
top: "0"
|
|
2297
|
+
});
|
|
2298
|
+
const hide = () => {
|
|
2299
|
+
if (!visible.value)
|
|
2300
|
+
return;
|
|
2301
|
+
visible.value = false;
|
|
2302
|
+
subMenu.value?.hide();
|
|
2303
|
+
emit("hide");
|
|
2304
|
+
};
|
|
2305
|
+
const hideHandler = (e) => {
|
|
2306
|
+
const target = e.target;
|
|
2307
|
+
if (!visible.value || !target) {
|
|
2308
|
+
return;
|
|
2309
|
+
}
|
|
2310
|
+
if (menu.value?.contains(target) || subMenu.value?.$el?.contains(target)) {
|
|
2311
|
+
return;
|
|
2312
|
+
}
|
|
2313
|
+
hide();
|
|
2314
|
+
};
|
|
2315
|
+
onMounted(() => {
|
|
2316
|
+
if (props.isSubMenu)
|
|
2317
|
+
return;
|
|
2318
|
+
globalThis.addEventListener("mousedown", hideHandler, true);
|
|
2319
|
+
});
|
|
2320
|
+
onUnmounted(() => {
|
|
2321
|
+
if (props.isSubMenu)
|
|
2322
|
+
return;
|
|
2323
|
+
globalThis.removeEventListener("mousedown", hideHandler, true);
|
|
2324
|
+
});
|
|
2325
|
+
return {
|
|
2326
|
+
menu,
|
|
2327
|
+
subMenu,
|
|
2328
|
+
visible,
|
|
2329
|
+
menuStyle,
|
|
2330
|
+
subMenuData,
|
|
2331
|
+
hide,
|
|
2332
|
+
show(e) {
|
|
2333
|
+
setTimeout(() => {
|
|
2334
|
+
visible.value = true;
|
|
2335
|
+
nextTick(() => {
|
|
2336
|
+
const menuHeight = menu.value?.clientHeight || 0;
|
|
2337
|
+
let top = e.clientY;
|
|
2338
|
+
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
2339
|
+
top = document.body.clientHeight - menuHeight;
|
|
2340
|
+
}
|
|
2341
|
+
menuStyle.value = {
|
|
2342
|
+
top: `${top}px`,
|
|
2343
|
+
left: `${e.clientX}px`
|
|
2344
|
+
};
|
|
2345
|
+
emit("show");
|
|
2346
|
+
});
|
|
2347
|
+
}, 300);
|
|
2348
|
+
},
|
|
2349
|
+
showSubMenu(item) {
|
|
2350
|
+
const menuItem = item;
|
|
2351
|
+
if (typeof item !== "object" || !menuItem.items?.length) {
|
|
2352
|
+
return;
|
|
2353
|
+
}
|
|
2354
|
+
subMenuData.value = menuItem.items;
|
|
2355
|
+
if (menu.value) {
|
|
2356
|
+
subMenu.value.show({
|
|
2357
|
+
clientX: menu.value.offsetLeft + menu.value.clientWidth,
|
|
2358
|
+
clientY: menu.value.offsetTop
|
|
2359
|
+
});
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
};
|
|
2363
|
+
}
|
|
2364
|
+
});
|
|
2365
|
+
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2366
|
+
const _component_tool_button = resolveComponent("tool-button");
|
|
2367
|
+
const _component_content_menu = resolveComponent("content-menu", true);
|
|
2368
|
+
return _ctx.menuData.length && _ctx.visible ? (openBlock(), createElementBlock("div", {
|
|
2369
|
+
key: 0,
|
|
2370
|
+
class: "magic-editor-content-menu",
|
|
2371
|
+
ref: "menu",
|
|
2372
|
+
style: normalizeStyle(_ctx.menuStyle)
|
|
2373
|
+
}, [
|
|
2374
|
+
createElementVNode("div", null, [
|
|
2375
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menuData, (item, index) => {
|
|
2376
|
+
return openBlock(), createBlock(_component_tool_button, {
|
|
2377
|
+
"event-type": "mouseup",
|
|
2378
|
+
data: item,
|
|
2379
|
+
key: index,
|
|
2380
|
+
onMouseup: _ctx.hide,
|
|
2381
|
+
onMouseenter: ($event) => _ctx.showSubMenu(item)
|
|
2382
|
+
}, null, 8, ["data", "onMouseup", "onMouseenter"]);
|
|
2383
|
+
}), 128))
|
|
2384
|
+
]),
|
|
2385
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
2386
|
+
createVNode(_component_content_menu, {
|
|
2387
|
+
class: "sub-menu",
|
|
2388
|
+
ref: "subMenu",
|
|
2389
|
+
"menu-data": _ctx.subMenuData,
|
|
2390
|
+
"is-sub-menu": true,
|
|
2391
|
+
onHide: _ctx.hide
|
|
2392
|
+
}, null, 8, ["menu-data", "onHide"])
|
|
2393
|
+
]))
|
|
2394
|
+
], 4)) : createCommentVNode("", true);
|
|
2395
|
+
}
|
|
2396
|
+
var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
|
|
2397
|
+
|
|
2398
|
+
const _sfc_main$9 = defineComponent({
|
|
2399
|
+
components: { ContentMenu },
|
|
2400
|
+
setup() {
|
|
3140
2401
|
const services = inject("services");
|
|
3141
|
-
const
|
|
2402
|
+
const menu = ref();
|
|
3142
2403
|
const node = computed(() => services?.editorService.get("node"));
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
],
|
|
3153
|
-
component: props.componentGroupList
|
|
3154
|
-
})),
|
|
3155
|
-
append(config) {
|
|
2404
|
+
const isRoot = computed(() => node.value?.type === NodeType.ROOT);
|
|
2405
|
+
const isPage = computed(() => node.value?.type === NodeType.PAGE);
|
|
2406
|
+
const componentList = computed(() => services?.componentListService.getList() || []);
|
|
2407
|
+
const layerContentMenu = inject("layerContentMenu", []);
|
|
2408
|
+
const createMenuItems = (group) => group.items.map((component) => ({
|
|
2409
|
+
text: component.text,
|
|
2410
|
+
type: "button",
|
|
2411
|
+
icon: component.icon,
|
|
2412
|
+
handler: () => {
|
|
3156
2413
|
services?.editorService.add({
|
|
3157
|
-
name:
|
|
3158
|
-
type:
|
|
2414
|
+
name: component.text,
|
|
2415
|
+
type: component.type,
|
|
2416
|
+
...component.data || {}
|
|
3159
2417
|
});
|
|
3160
|
-
}
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
2418
|
+
}
|
|
2419
|
+
}));
|
|
2420
|
+
const getSubMenuData = computed(() => {
|
|
2421
|
+
if (node.value?.type === "tabs") {
|
|
2422
|
+
return [
|
|
2423
|
+
{
|
|
2424
|
+
text: "\u6807\u7B7E\u9875",
|
|
2425
|
+
type: "button",
|
|
2426
|
+
icon: Files,
|
|
2427
|
+
handler: () => {
|
|
2428
|
+
services?.editorService.add({
|
|
2429
|
+
type: "tab-pane"
|
|
2430
|
+
});
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
];
|
|
2434
|
+
}
|
|
2435
|
+
if (node.value?.items) {
|
|
2436
|
+
return componentList.value.reduce((subMenuData, group, index) => subMenuData.concat(createMenuItems(group), index < componentList.value.length - 1 ? [
|
|
2437
|
+
{
|
|
2438
|
+
type: "divider",
|
|
2439
|
+
direction: "horizontal"
|
|
2440
|
+
}
|
|
2441
|
+
] : []), []) || [];
|
|
2442
|
+
}
|
|
2443
|
+
return [];
|
|
2444
|
+
});
|
|
2445
|
+
return {
|
|
2446
|
+
menu,
|
|
2447
|
+
menuData: computed(() => [
|
|
2448
|
+
{
|
|
2449
|
+
type: "button",
|
|
2450
|
+
text: "\u65B0\u589E",
|
|
2451
|
+
icon: markRaw(Plus),
|
|
2452
|
+
display: () => node.value?.items,
|
|
2453
|
+
items: getSubMenuData.value
|
|
2454
|
+
},
|
|
2455
|
+
{
|
|
2456
|
+
type: "button",
|
|
2457
|
+
text: "\u590D\u5236",
|
|
2458
|
+
icon: markRaw(DocumentCopy),
|
|
2459
|
+
display: () => !isRoot.value,
|
|
2460
|
+
handler: () => {
|
|
2461
|
+
node.value && services?.editorService.copy(node.value);
|
|
2462
|
+
}
|
|
2463
|
+
},
|
|
2464
|
+
{
|
|
2465
|
+
type: "button",
|
|
2466
|
+
text: "\u5220\u9664",
|
|
2467
|
+
icon: markRaw(Delete),
|
|
2468
|
+
display: () => !isRoot.value && !isPage.value,
|
|
2469
|
+
handler: () => {
|
|
2470
|
+
node.value && services?.editorService.remove(node.value);
|
|
2471
|
+
}
|
|
2472
|
+
},
|
|
2473
|
+
...layerContentMenu
|
|
2474
|
+
]),
|
|
2475
|
+
show(e) {
|
|
2476
|
+
menu.value?.show(e);
|
|
3169
2477
|
}
|
|
3170
2478
|
};
|
|
3171
2479
|
}
|
|
3172
2480
|
});
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3181
|
-
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
3182
|
-
return _ctx.node ? (openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
3183
|
-
_ctx.node.items ? (openBlock(), createElementBlock("div", {
|
|
3184
|
-
key: 0,
|
|
3185
|
-
class: "magic-editor-content-menu-item",
|
|
3186
|
-
onMouseenter: _cache[0] || (_cache[0] = ($event) => _ctx.setSubVisiable(true)),
|
|
3187
|
-
onMouseleave: _cache[1] || (_cache[1] = ($event) => _ctx.setSubVisiable(false))
|
|
3188
|
-
}, " \u65B0\u589E ", 32)) : createCommentVNode("", true),
|
|
3189
|
-
_ctx.node.type !== "app" ? (openBlock(), createElementBlock("div", {
|
|
3190
|
-
key: 1,
|
|
3191
|
-
class: "magic-editor-content-menu-item",
|
|
3192
|
-
onClick: _cache[2] || (_cache[2] = () => _ctx.copy(_ctx.node))
|
|
3193
|
-
}, "\u590D\u5236")) : createCommentVNode("", true),
|
|
3194
|
-
_ctx.node.type !== "app" && _ctx.node.type !== "page" ? (openBlock(), createElementBlock("div", {
|
|
3195
|
-
key: 2,
|
|
3196
|
-
class: "magic-editor-content-menu-item",
|
|
3197
|
-
onClick: _cache[3] || (_cache[3] = () => _ctx.remove())
|
|
3198
|
-
}, " \u5220\u9664 ")) : createCommentVNode("", true),
|
|
3199
|
-
withDirectives(createElementVNode("div", {
|
|
3200
|
-
class: "subMenu",
|
|
3201
|
-
onMouseenter: _cache[5] || (_cache[5] = ($event) => _ctx.setSubVisiable(true)),
|
|
3202
|
-
onMouseleave: _cache[6] || (_cache[6] = ($event) => _ctx.setSubVisiable(false))
|
|
3203
|
-
}, [
|
|
3204
|
-
createVNode(_component_el_scrollbar, null, {
|
|
3205
|
-
default: withCtx(() => [
|
|
3206
|
-
_ctx.node.type === "tabs" ? (openBlock(), createElementBlock("div", {
|
|
3207
|
-
key: 0,
|
|
3208
|
-
class: "magic-editor-content-menu-item",
|
|
3209
|
-
onClick: _cache[4] || (_cache[4] = () => _ctx.append({
|
|
3210
|
-
type: "tab-pane"
|
|
3211
|
-
}))
|
|
3212
|
-
}, " \u6807\u7B7E ")) : _ctx.node.type === "app" ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(_ctx.menu.app, (item) => {
|
|
3213
|
-
return openBlock(), createElementBlock("div", {
|
|
3214
|
-
class: "magic-editor-content-menu-item",
|
|
3215
|
-
key: item.type,
|
|
3216
|
-
onClick: () => _ctx.append(item)
|
|
3217
|
-
}, toDisplayString(item.text), 9, _hoisted_2$2);
|
|
3218
|
-
}), 128)) : _ctx.node.items ? (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(_ctx.menu.component, (list) => {
|
|
3219
|
-
return openBlock(), createElementBlock("div", {
|
|
3220
|
-
key: list.title
|
|
3221
|
-
}, [
|
|
3222
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(list.items, (item) => {
|
|
3223
|
-
return openBlock(), createElementBlock(Fragment, null, [
|
|
3224
|
-
item ? (openBlock(), createElementBlock("div", {
|
|
3225
|
-
class: "magic-editor-content-menu-item",
|
|
3226
|
-
key: item.type,
|
|
3227
|
-
onClick: () => _ctx.append(item)
|
|
3228
|
-
}, toDisplayString(item.text), 9, _hoisted_3$2)) : createCommentVNode("", true)
|
|
3229
|
-
], 64);
|
|
3230
|
-
}), 256)),
|
|
3231
|
-
_hoisted_4$2
|
|
3232
|
-
]);
|
|
3233
|
-
}), 128)) : createCommentVNode("", true)
|
|
3234
|
-
]),
|
|
3235
|
-
_: 1
|
|
3236
|
-
})
|
|
3237
|
-
], 544), [
|
|
3238
|
-
[vShow, _ctx.subVisible]
|
|
3239
|
-
])
|
|
3240
|
-
])) : createCommentVNode("", true);
|
|
2481
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2482
|
+
const _component_content_menu = resolveComponent("content-menu");
|
|
2483
|
+
return openBlock(), createBlock(_component_content_menu, {
|
|
2484
|
+
"menu-data": _ctx.menuData,
|
|
2485
|
+
ref: "menu",
|
|
2486
|
+
style: { "overflow": "initial" }
|
|
2487
|
+
}, null, 8, ["menu-data"]);
|
|
3241
2488
|
}
|
|
3242
|
-
var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2489
|
+
var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
|
|
3243
2490
|
|
|
3244
2491
|
const throttleTime = 150;
|
|
3245
|
-
const select = (data, editorService) => {
|
|
2492
|
+
const select = async (data, editorService) => {
|
|
3246
2493
|
if (!data.id) {
|
|
3247
2494
|
throw new Error("\u6CA1\u6709id");
|
|
3248
2495
|
}
|
|
3249
|
-
editorService?.select(data);
|
|
2496
|
+
await editorService?.select(data);
|
|
2497
|
+
editorService?.get("stage")?.select(data.id);
|
|
3250
2498
|
};
|
|
3251
2499
|
const highlight = (data, editorService) => {
|
|
3252
2500
|
if (!data?.id) {
|
|
3253
2501
|
throw new Error("\u6CA1\u6709id");
|
|
3254
2502
|
}
|
|
3255
2503
|
editorService?.highlight(data);
|
|
2504
|
+
editorService?.get("stage")?.highlight(data.id);
|
|
3256
2505
|
};
|
|
3257
2506
|
const useDrop = (tree, editorService) => ({
|
|
3258
2507
|
allowDrop: (draggingNode, dropNode, type) => {
|
|
@@ -3307,7 +2556,8 @@ const useStatus = (tree, editorService) => {
|
|
|
3307
2556
|
resolve([]);
|
|
3308
2557
|
},
|
|
3309
2558
|
highlightNode,
|
|
3310
|
-
clickNode: node
|
|
2559
|
+
clickNode: node,
|
|
2560
|
+
expandedKeys: computed(() => node.value ? [node.value.id] : [])
|
|
3311
2561
|
};
|
|
3312
2562
|
};
|
|
3313
2563
|
const useFilter = (tree) => ({
|
|
@@ -3319,67 +2569,46 @@ const useFilter = (tree) => ({
|
|
|
3319
2569
|
let name = "";
|
|
3320
2570
|
if (data.name) {
|
|
3321
2571
|
name = data.name;
|
|
3322
|
-
} else if (data.type) {
|
|
3323
|
-
name = data.type;
|
|
3324
2572
|
} else if (data.items) {
|
|
3325
2573
|
name = "container";
|
|
3326
2574
|
}
|
|
3327
|
-
return name.indexOf(value) !== -1;
|
|
2575
|
+
return `${data.id}${name}${data.type}`.indexOf(value) !== -1;
|
|
3328
2576
|
},
|
|
3329
2577
|
filterTextChangeHandler(val) {
|
|
3330
2578
|
tree.value?.filter(val);
|
|
3331
2579
|
}
|
|
3332
2580
|
});
|
|
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({
|
|
2581
|
+
const _sfc_main$8 = defineComponent({
|
|
3362
2582
|
name: "magic-editor-layer-panel",
|
|
3363
2583
|
components: { LayerMenu },
|
|
3364
2584
|
setup() {
|
|
3365
2585
|
const services = inject("services");
|
|
3366
2586
|
const tree = ref();
|
|
2587
|
+
const menu = ref();
|
|
3367
2588
|
const clicked = ref(false);
|
|
3368
2589
|
const editorService = services?.editorService;
|
|
3369
2590
|
const highlightHandler = throttle((data) => {
|
|
3370
2591
|
highlight(data, editorService);
|
|
3371
2592
|
}, throttleTime);
|
|
3372
|
-
const
|
|
2593
|
+
const toggleClickFlag = () => {
|
|
3373
2594
|
clicked.value = !clicked.value;
|
|
3374
2595
|
};
|
|
3375
2596
|
const statusData = useStatus(tree, editorService);
|
|
3376
2597
|
const canHighlight = computed(() => statusData.highlightNode.value?.id !== statusData.clickNode.value?.id && !clicked.value);
|
|
2598
|
+
editorService?.on("remove", () => {
|
|
2599
|
+
setTimeout(() => {
|
|
2600
|
+
tree.value?.getNode(editorService.get("node").id)?.updateChildren();
|
|
2601
|
+
}, 0);
|
|
2602
|
+
});
|
|
3377
2603
|
return {
|
|
3378
2604
|
tree,
|
|
2605
|
+
menu,
|
|
3379
2606
|
...statusData,
|
|
3380
2607
|
...useDrop(tree, editorService),
|
|
3381
2608
|
...useFilter(tree),
|
|
3382
|
-
|
|
2609
|
+
highlightHandler,
|
|
2610
|
+
toggleClickFlag,
|
|
2611
|
+
canHighlight,
|
|
3383
2612
|
clickHandler(data) {
|
|
3384
2613
|
if (services?.uiService.get("uiSelectMode")) {
|
|
3385
2614
|
document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
|
|
@@ -3388,14 +2617,16 @@ const _sfc_main$7 = defineComponent({
|
|
|
3388
2617
|
tree.value?.setCurrentKey(data.id);
|
|
3389
2618
|
select(data, editorService);
|
|
3390
2619
|
},
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
2620
|
+
async contextmenu(event, data) {
|
|
2621
|
+
event.preventDefault();
|
|
2622
|
+
await select(data, editorService);
|
|
2623
|
+
menu.value?.show(event);
|
|
2624
|
+
}
|
|
3394
2625
|
};
|
|
3395
2626
|
}
|
|
3396
2627
|
});
|
|
3397
|
-
const _hoisted_1$
|
|
3398
|
-
function _sfc_render$
|
|
2628
|
+
const _hoisted_1$4 = ["id", "onMouseenter"];
|
|
2629
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3399
2630
|
const _component_el_input = resolveComponent("el-input");
|
|
3400
2631
|
const _component_el_tree = resolveComponent("el-tree");
|
|
3401
2632
|
const _component_layer_menu = resolveComponent("layer-menu");
|
|
@@ -3416,6 +2647,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3416
2647
|
ref: "tree",
|
|
3417
2648
|
"node-key": "id",
|
|
3418
2649
|
draggable: "",
|
|
2650
|
+
"default-expanded-keys": _ctx.expandedKeys,
|
|
3419
2651
|
load: _ctx.loadItems,
|
|
3420
2652
|
data: _ctx.values,
|
|
3421
2653
|
"expand-on-click-node": false,
|
|
@@ -3434,8 +2666,8 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3434
2666
|
createElementVNode("div", {
|
|
3435
2667
|
id: data.id,
|
|
3436
2668
|
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.
|
|
2669
|
+
onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
|
|
2670
|
+
onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
|
|
3439
2671
|
onMouseenter: ($event) => _ctx.highlightHandler(data)
|
|
3440
2672
|
}, [
|
|
3441
2673
|
renderSlot(_ctx.$slots, "layer-node-content", {
|
|
@@ -3444,42 +2676,33 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3444
2676
|
}, () => [
|
|
3445
2677
|
createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
|
|
3446
2678
|
])
|
|
3447
|
-
], 42, _hoisted_1$
|
|
2679
|
+
], 42, _hoisted_1$4)
|
|
3448
2680
|
]),
|
|
3449
2681
|
_: 3
|
|
3450
|
-
}, 8, ["load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : createCommentVNode("", true),
|
|
2682
|
+
}, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : createCommentVNode("", true),
|
|
3451
2683
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
3452
|
-
createVNode(_component_layer_menu, {
|
|
3453
|
-
style: normalizeStyle(_ctx.menuStyle)
|
|
3454
|
-
}, null, 8, ["style"])
|
|
2684
|
+
createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
|
|
3455
2685
|
]))
|
|
3456
2686
|
]),
|
|
3457
2687
|
_: 3
|
|
3458
2688
|
});
|
|
3459
2689
|
}
|
|
3460
|
-
var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2690
|
+
var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
|
|
3461
2691
|
|
|
3462
|
-
const _sfc_main$
|
|
3463
|
-
name: "m-sidebar",
|
|
2692
|
+
const _sfc_main$7 = defineComponent({
|
|
3464
2693
|
components: { MIcon },
|
|
3465
2694
|
props: {
|
|
3466
2695
|
data: {
|
|
3467
|
-
type: Object,
|
|
3468
|
-
default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer"] })
|
|
2696
|
+
type: [Object, String]
|
|
3469
2697
|
}
|
|
3470
2698
|
},
|
|
3471
2699
|
setup(props) {
|
|
3472
|
-
const activeTabName = ref(props.data?.status);
|
|
3473
|
-
watch(() => props.data?.status, (status) => {
|
|
3474
|
-
activeTabName.value = status || "0";
|
|
3475
|
-
});
|
|
3476
2700
|
return {
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
return item;
|
|
2701
|
+
config: computed(() => {
|
|
2702
|
+
if (typeof props.data !== "string") {
|
|
2703
|
+
return props.data;
|
|
3481
2704
|
}
|
|
3482
|
-
switch (
|
|
2705
|
+
switch (props.data) {
|
|
3483
2706
|
case "component-list":
|
|
3484
2707
|
return {
|
|
3485
2708
|
type: "component",
|
|
@@ -3497,21 +2720,75 @@ const _sfc_main$6 = defineComponent({
|
|
|
3497
2720
|
slots: {}
|
|
3498
2721
|
};
|
|
3499
2722
|
default:
|
|
3500
|
-
return
|
|
2723
|
+
return void 0;
|
|
3501
2724
|
}
|
|
3502
|
-
})
|
|
2725
|
+
})
|
|
3503
2726
|
};
|
|
3504
2727
|
}
|
|
3505
2728
|
});
|
|
3506
|
-
const _hoisted_1$
|
|
2729
|
+
const _hoisted_1$3 = {
|
|
3507
2730
|
key: 1,
|
|
3508
2731
|
class: "magic-editor-tab-panel-title"
|
|
3509
2732
|
};
|
|
3510
|
-
function _sfc_render$
|
|
2733
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3511
2734
|
const _component_m_icon = resolveComponent("m-icon");
|
|
3512
2735
|
const _component_el_tab_pane = resolveComponent("el-tab-pane");
|
|
2736
|
+
return _ctx.config ? (openBlock(), createBlock(_component_el_tab_pane, {
|
|
2737
|
+
key: 0,
|
|
2738
|
+
name: _ctx.config.text
|
|
2739
|
+
}, {
|
|
2740
|
+
label: withCtx(() => [
|
|
2741
|
+
(openBlock(), createElementBlock("div", {
|
|
2742
|
+
key: _ctx.config.text
|
|
2743
|
+
}, [
|
|
2744
|
+
_ctx.config.icon ? (openBlock(), createBlock(_component_m_icon, {
|
|
2745
|
+
key: 0,
|
|
2746
|
+
icon: _ctx.config.icon
|
|
2747
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
2748
|
+
_ctx.config.text ? (openBlock(), createElementBlock("div", _hoisted_1$3, toDisplayString(_ctx.config.text), 1)) : createCommentVNode("", true)
|
|
2749
|
+
]))
|
|
2750
|
+
]),
|
|
2751
|
+
default: withCtx(() => [
|
|
2752
|
+
(openBlock(), createBlock(resolveDynamicComponent(_ctx.config.component), mergeProps(_ctx.config.props || {}, toHandlers(_ctx.config?.listeners || {})), createSlots({ _: 2 }, [
|
|
2753
|
+
_ctx.config.slots?.layerNodeContent ? {
|
|
2754
|
+
name: "layer-node-content",
|
|
2755
|
+
fn: withCtx(({ data, node }) => [
|
|
2756
|
+
(openBlock(), createBlock(resolveDynamicComponent(_ctx.config.slots?.layerNodeContent), {
|
|
2757
|
+
data,
|
|
2758
|
+
node
|
|
2759
|
+
}, null, 8, ["data", "node"]))
|
|
2760
|
+
])
|
|
2761
|
+
} : void 0
|
|
2762
|
+
]), 1040))
|
|
2763
|
+
]),
|
|
2764
|
+
_: 1
|
|
2765
|
+
}, 8, ["name"])) : createCommentVNode("", true);
|
|
2766
|
+
}
|
|
2767
|
+
var TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7]]);
|
|
2768
|
+
|
|
2769
|
+
const _sfc_main$6 = defineComponent({
|
|
2770
|
+
components: { TabPane },
|
|
2771
|
+
name: "m-sidebar",
|
|
2772
|
+
props: {
|
|
2773
|
+
data: {
|
|
2774
|
+
type: Object,
|
|
2775
|
+
default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer"] })
|
|
2776
|
+
}
|
|
2777
|
+
},
|
|
2778
|
+
setup(props) {
|
|
2779
|
+
const activeTabName = ref(props.data?.status);
|
|
2780
|
+
watch(() => props.data?.status, (status) => {
|
|
2781
|
+
activeTabName.value = status || "0";
|
|
2782
|
+
});
|
|
2783
|
+
return {
|
|
2784
|
+
activeTabName
|
|
2785
|
+
};
|
|
2786
|
+
}
|
|
2787
|
+
});
|
|
2788
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2789
|
+
const _component_tab_pane = resolveComponent("tab-pane");
|
|
3513
2790
|
const _component_el_tabs = resolveComponent("el-tabs");
|
|
3514
|
-
return _ctx.data.type === "tabs" ? (openBlock(), createBlock(_component_el_tabs, {
|
|
2791
|
+
return _ctx.data.type === "tabs" && _ctx.data.items.length ? (openBlock(), createBlock(_component_el_tabs, {
|
|
3515
2792
|
key: 0,
|
|
3516
2793
|
class: "m-editor-sidebar",
|
|
3517
2794
|
modelValue: _ctx.activeTabName,
|
|
@@ -3520,35 +2797,11 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3520
2797
|
"tab-position": "left"
|
|
3521
2798
|
}, {
|
|
3522
2799
|
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"]);
|
|
2800
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data.items, (item, index) => {
|
|
2801
|
+
return openBlock(), createBlock(_component_tab_pane, {
|
|
2802
|
+
key: index,
|
|
2803
|
+
data: item
|
|
2804
|
+
}, null, 8, ["data"]);
|
|
3552
2805
|
}), 128))
|
|
3553
2806
|
]),
|
|
3554
2807
|
_: 1
|
|
@@ -3556,13 +2809,81 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3556
2809
|
}
|
|
3557
2810
|
var Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6]]);
|
|
3558
2811
|
|
|
2812
|
+
const useScroll = (root) => {
|
|
2813
|
+
const pageBar = ref();
|
|
2814
|
+
const itemsContainer = ref();
|
|
2815
|
+
const pageBarWidth = ref(0);
|
|
2816
|
+
const canScroll = ref(false);
|
|
2817
|
+
const itemsContainerWidth = computed(() => pageBarWidth.value - 105);
|
|
2818
|
+
let translateLeft = 0;
|
|
2819
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
2820
|
+
for (const { contentRect } of entries) {
|
|
2821
|
+
const { width } = contentRect;
|
|
2822
|
+
pageBarWidth.value = width || 0;
|
|
2823
|
+
setCanScroll();
|
|
2824
|
+
}
|
|
2825
|
+
});
|
|
2826
|
+
const setCanScroll = () => {
|
|
2827
|
+
if (itemsContainer.value) {
|
|
2828
|
+
canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
|
|
2829
|
+
}
|
|
2830
|
+
};
|
|
2831
|
+
const scroll = (type) => {
|
|
2832
|
+
if (!itemsContainer.value)
|
|
2833
|
+
return;
|
|
2834
|
+
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
2835
|
+
if (type === "left") {
|
|
2836
|
+
translateLeft += 100;
|
|
2837
|
+
if (translateLeft > 0) {
|
|
2838
|
+
translateLeft = 0;
|
|
2839
|
+
}
|
|
2840
|
+
} else if (type === "right") {
|
|
2841
|
+
translateLeft -= 100;
|
|
2842
|
+
if (-translateLeft > maxScrollLeft) {
|
|
2843
|
+
translateLeft = -maxScrollLeft;
|
|
2844
|
+
}
|
|
2845
|
+
} else if (type === "start") {
|
|
2846
|
+
translateLeft = 0;
|
|
2847
|
+
} else if (type === "end") {
|
|
2848
|
+
translateLeft = -maxScrollLeft;
|
|
2849
|
+
}
|
|
2850
|
+
itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
|
|
2851
|
+
};
|
|
2852
|
+
onMounted(() => {
|
|
2853
|
+
pageBar.value && resizeObserver.observe(pageBar.value);
|
|
2854
|
+
});
|
|
2855
|
+
onUnmounted(() => {
|
|
2856
|
+
resizeObserver.disconnect();
|
|
2857
|
+
});
|
|
2858
|
+
watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
|
|
2859
|
+
setTimeout(() => {
|
|
2860
|
+
setCanScroll();
|
|
2861
|
+
if (length < preLength) {
|
|
2862
|
+
scroll("start");
|
|
2863
|
+
} else {
|
|
2864
|
+
scroll("end");
|
|
2865
|
+
}
|
|
2866
|
+
});
|
|
2867
|
+
});
|
|
2868
|
+
return {
|
|
2869
|
+
pageBar,
|
|
2870
|
+
itemsContainer,
|
|
2871
|
+
canScroll,
|
|
2872
|
+
itemsContainerWidth,
|
|
2873
|
+
scroll
|
|
2874
|
+
};
|
|
2875
|
+
};
|
|
3559
2876
|
const _sfc_main$5 = defineComponent({
|
|
3560
|
-
components: { CaretBottom, Plus },
|
|
2877
|
+
components: { ArrowLeftBold, ArrowRightBold, CaretBottom, Plus, ToolButton },
|
|
3561
2878
|
setup() {
|
|
3562
2879
|
const services = inject("services");
|
|
3563
2880
|
const editorService = services?.editorService;
|
|
2881
|
+
const root = computed(() => editorService?.get("root"));
|
|
3564
2882
|
return {
|
|
3565
|
-
|
|
2883
|
+
Delete: markRaw(Delete),
|
|
2884
|
+
DocumentCopy: markRaw(DocumentCopy),
|
|
2885
|
+
...useScroll(root),
|
|
2886
|
+
root,
|
|
3566
2887
|
page: computed(() => editorService?.get("page")),
|
|
3567
2888
|
switchPage(page) {
|
|
3568
2889
|
editorService?.select(page);
|
|
@@ -3589,112 +2910,228 @@ const _sfc_main$5 = defineComponent({
|
|
|
3589
2910
|
};
|
|
3590
2911
|
}
|
|
3591
2912
|
});
|
|
3592
|
-
const _hoisted_1$
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
const
|
|
2913
|
+
const _hoisted_1$2 = {
|
|
2914
|
+
class: "m-editor-page-bar",
|
|
2915
|
+
ref: "pageBar"
|
|
2916
|
+
};
|
|
2917
|
+
const _hoisted_2 = ["onClick"];
|
|
2918
|
+
const _hoisted_3 = { class: "m-editor-page-bar-title" };
|
|
3597
2919
|
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3598
2920
|
const _component_plus = resolveComponent("plus");
|
|
3599
2921
|
const _component_el_icon = resolveComponent("el-icon");
|
|
2922
|
+
const _component_arrow_left_bold = resolveComponent("arrow-left-bold");
|
|
3600
2923
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
2924
|
+
const _component_tool_button = resolveComponent("tool-button");
|
|
3601
2925
|
const _component_caret_bottom = resolveComponent("caret-bottom");
|
|
3602
2926
|
const _component_el_popover = resolveComponent("el-popover");
|
|
3603
|
-
|
|
2927
|
+
const _component_arrow_right_bold = resolveComponent("arrow-right-bold");
|
|
2928
|
+
return openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
3604
2929
|
createElementVNode("div", {
|
|
3605
|
-
|
|
2930
|
+
id: "m-editor-page-bar-add-icon",
|
|
2931
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3606
2932
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.addPage && _ctx.addPage(...args))
|
|
3607
2933
|
}, [
|
|
3608
|
-
createVNode(_component_el_icon,
|
|
2934
|
+
createVNode(_component_el_icon, null, {
|
|
2935
|
+
default: withCtx(() => [
|
|
2936
|
+
createVNode(_component_plus)
|
|
2937
|
+
]),
|
|
2938
|
+
_: 1
|
|
2939
|
+
})
|
|
2940
|
+
]),
|
|
2941
|
+
_ctx.canScroll ? (openBlock(), createElementBlock("div", {
|
|
2942
|
+
key: 0,
|
|
2943
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
2944
|
+
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.scroll("left"))
|
|
2945
|
+
}, [
|
|
2946
|
+
createVNode(_component_el_icon, null, {
|
|
3609
2947
|
default: withCtx(() => [
|
|
3610
|
-
createVNode(
|
|
2948
|
+
createVNode(_component_arrow_left_bold)
|
|
3611
2949
|
]),
|
|
3612
2950
|
_: 1
|
|
3613
2951
|
})
|
|
3614
|
-
]),
|
|
3615
|
-
_ctx.root ? (openBlock(
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
}, {
|
|
3640
|
-
reference: withCtx(() => [
|
|
3641
|
-
createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
|
|
3642
|
-
default: withCtx(() => [
|
|
3643
|
-
createVNode(_component_caret_bottom)
|
|
3644
|
-
]),
|
|
3645
|
-
_: 1
|
|
3646
|
-
})
|
|
3647
|
-
]),
|
|
3648
|
-
default: withCtx(() => [
|
|
3649
|
-
createElementVNode("div", null, [
|
|
3650
|
-
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3651
|
-
createElementVNode("div", {
|
|
3652
|
-
class: "magic-editor-content-menu-item",
|
|
3653
|
-
onClick: () => _ctx.copy(item)
|
|
3654
|
-
}, "\u590D\u5236", 8, _hoisted_4$1),
|
|
3655
|
-
createElementVNode("div", {
|
|
3656
|
-
class: "magic-editor-content-menu-item",
|
|
3657
|
-
onClick: () => _ctx.remove(item)
|
|
3658
|
-
}, "\u5220\u9664", 8, _hoisted_5)
|
|
3659
|
-
])
|
|
2952
|
+
])) : createCommentVNode("", true),
|
|
2953
|
+
_ctx.root ? (openBlock(), createElementBlock("div", {
|
|
2954
|
+
key: 1,
|
|
2955
|
+
class: "m-editor-page-bar-items",
|
|
2956
|
+
ref: "itemsContainer",
|
|
2957
|
+
style: normalizeStyle(`width: ${_ctx.itemsContainerWidth}px`)
|
|
2958
|
+
}, [
|
|
2959
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.root.items, (item) => {
|
|
2960
|
+
return openBlock(), createElementBlock("div", {
|
|
2961
|
+
key: item.key,
|
|
2962
|
+
class: normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
|
|
2963
|
+
onClick: ($event) => _ctx.switchPage(item)
|
|
2964
|
+
}, [
|
|
2965
|
+
createElementVNode("div", _hoisted_3, [
|
|
2966
|
+
renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
|
|
2967
|
+
createVNode(_component_el_tooltip, {
|
|
2968
|
+
effect: "dark",
|
|
2969
|
+
placement: "top-start",
|
|
2970
|
+
content: item.name
|
|
2971
|
+
}, {
|
|
2972
|
+
default: withCtx(() => [
|
|
2973
|
+
createElementVNode("span", null, toDisplayString(item.name), 1)
|
|
2974
|
+
]),
|
|
2975
|
+
_: 2
|
|
2976
|
+
}, 1032, ["content"])
|
|
3660
2977
|
])
|
|
3661
2978
|
]),
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
2979
|
+
createVNode(_component_el_popover, {
|
|
2980
|
+
"popper-class": "page-bar-popover",
|
|
2981
|
+
placement: "top",
|
|
2982
|
+
width: 160,
|
|
2983
|
+
trigger: "hover"
|
|
2984
|
+
}, {
|
|
2985
|
+
reference: withCtx(() => [
|
|
2986
|
+
createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
|
|
2987
|
+
default: withCtx(() => [
|
|
2988
|
+
createVNode(_component_caret_bottom)
|
|
2989
|
+
]),
|
|
2990
|
+
_: 1
|
|
2991
|
+
})
|
|
2992
|
+
]),
|
|
2993
|
+
default: withCtx(() => [
|
|
2994
|
+
createElementVNode("div", null, [
|
|
2995
|
+
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
2996
|
+
createVNode(_component_tool_button, {
|
|
2997
|
+
data: {
|
|
2998
|
+
type: "button",
|
|
2999
|
+
text: "\u590D\u5236",
|
|
3000
|
+
icon: _ctx.DocumentCopy,
|
|
3001
|
+
handler: () => _ctx.copy(item)
|
|
3002
|
+
}
|
|
3003
|
+
}, null, 8, ["data"]),
|
|
3004
|
+
createVNode(_component_tool_button, {
|
|
3005
|
+
data: {
|
|
3006
|
+
type: "button",
|
|
3007
|
+
text: "\u5220\u9664",
|
|
3008
|
+
icon: _ctx.Delete,
|
|
3009
|
+
handler: () => _ctx.remove(item)
|
|
3010
|
+
}
|
|
3011
|
+
}, null, 8, ["data"])
|
|
3012
|
+
])
|
|
3013
|
+
])
|
|
3014
|
+
]),
|
|
3015
|
+
_: 2
|
|
3016
|
+
}, 1024)
|
|
3017
|
+
], 10, _hoisted_2);
|
|
3018
|
+
}), 128))
|
|
3019
|
+
], 4)) : createCommentVNode("", true),
|
|
3020
|
+
_ctx.canScroll ? (openBlock(), createElementBlock("div", {
|
|
3021
|
+
key: 2,
|
|
3022
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3023
|
+
onClick: _cache[2] || (_cache[2] = ($event) => _ctx.scroll("right"))
|
|
3024
|
+
}, [
|
|
3025
|
+
createVNode(_component_el_icon, null, {
|
|
3026
|
+
default: withCtx(() => [
|
|
3027
|
+
createVNode(_component_arrow_right_bold)
|
|
3028
|
+
]),
|
|
3029
|
+
_: 1
|
|
3030
|
+
})
|
|
3031
|
+
])) : createCommentVNode("", true)
|
|
3032
|
+
], 512);
|
|
3667
3033
|
}
|
|
3668
3034
|
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
|
|
3669
3035
|
|
|
3670
3036
|
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
|
-
|
|
3037
|
+
constructor(options) {
|
|
3038
|
+
this.enter = false;
|
|
3039
|
+
this.targetEnter = false;
|
|
3040
|
+
this.keydown = false;
|
|
3041
|
+
this.zoom = 1;
|
|
3042
|
+
this.scrollLeft = 0;
|
|
3043
|
+
this.scrollTop = 0;
|
|
3044
|
+
this.x = 0;
|
|
3045
|
+
this.y = 0;
|
|
3046
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
3047
|
+
for (const { contentRect } of entries) {
|
|
3048
|
+
const { width, height } = contentRect;
|
|
3049
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3050
|
+
const targetWidth = targetRect.width * this.zoom;
|
|
3051
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3052
|
+
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
3053
|
+
if (targetWidth < width) {
|
|
3054
|
+
this.target._left = 0;
|
|
3055
|
+
}
|
|
3056
|
+
if (targetHeight < height) {
|
|
3057
|
+
this.target._top = 0;
|
|
3058
|
+
}
|
|
3059
|
+
this.scroll();
|
|
3693
3060
|
}
|
|
3061
|
+
});
|
|
3062
|
+
this.wheelHandler = (event) => {
|
|
3063
|
+
if (this.targetEnter)
|
|
3064
|
+
return;
|
|
3065
|
+
const { deltaX, deltaY, currentTarget } = event;
|
|
3066
|
+
if (currentTarget !== this.container)
|
|
3067
|
+
return;
|
|
3068
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3694
3069
|
this.scroll();
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3070
|
+
this.scrollLeft = this.target._left;
|
|
3071
|
+
this.scrollTop = this.target._top;
|
|
3072
|
+
};
|
|
3073
|
+
this.mouseEnterHandler = () => {
|
|
3074
|
+
this.enter = true;
|
|
3075
|
+
};
|
|
3076
|
+
this.mouseLeaveHandler = () => {
|
|
3077
|
+
this.enter = false;
|
|
3078
|
+
};
|
|
3079
|
+
this.targetMouseEnterHandler = () => {
|
|
3080
|
+
this.targetEnter = true;
|
|
3081
|
+
};
|
|
3082
|
+
this.targetMouseLeaveHandler = () => {
|
|
3083
|
+
this.targetEnter = false;
|
|
3084
|
+
};
|
|
3085
|
+
this.mousedownHandler = (event) => {
|
|
3086
|
+
if (!this.keydown)
|
|
3087
|
+
return;
|
|
3088
|
+
event.stopImmediatePropagation();
|
|
3089
|
+
event.stopPropagation();
|
|
3090
|
+
this.target.style.cursor = "grabbing";
|
|
3091
|
+
this.x = event.clientX;
|
|
3092
|
+
this.y = event.clientY;
|
|
3093
|
+
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3094
|
+
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3095
|
+
};
|
|
3096
|
+
this.mouseupHandler = () => {
|
|
3097
|
+
this.x = 0;
|
|
3098
|
+
this.y = 0;
|
|
3099
|
+
this.scrollLeft = this.target._left;
|
|
3100
|
+
this.scrollTop = this.target._top;
|
|
3101
|
+
this.removeHandler();
|
|
3102
|
+
};
|
|
3103
|
+
this.mousemoveHandler = (event) => {
|
|
3104
|
+
event.stopImmediatePropagation();
|
|
3105
|
+
event.stopPropagation();
|
|
3106
|
+
const deltaX = event.clientX - this.x;
|
|
3107
|
+
const deltaY = event.clientY - this.y;
|
|
3108
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3109
|
+
this.scroll();
|
|
3110
|
+
};
|
|
3111
|
+
this.keydownHandler = (event) => {
|
|
3112
|
+
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3113
|
+
event.preventDefault();
|
|
3114
|
+
event.stopImmediatePropagation();
|
|
3115
|
+
event.stopPropagation();
|
|
3116
|
+
}
|
|
3117
|
+
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3118
|
+
return;
|
|
3119
|
+
}
|
|
3120
|
+
this.keydown = true;
|
|
3121
|
+
this.target.style.cursor = "grab";
|
|
3122
|
+
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3123
|
+
};
|
|
3124
|
+
this.keyupHandler = (event) => {
|
|
3125
|
+
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3126
|
+
return;
|
|
3127
|
+
}
|
|
3128
|
+
event.preventDefault();
|
|
3129
|
+
event.stopImmediatePropagation();
|
|
3130
|
+
event.stopPropagation();
|
|
3131
|
+
this.keydown = false;
|
|
3132
|
+
event.preventDefault();
|
|
3133
|
+
this.removeHandler();
|
|
3134
|
+
};
|
|
3698
3135
|
this.container = options.container;
|
|
3699
3136
|
this.target = options.target;
|
|
3700
3137
|
this.zoom = options.zoom;
|
|
@@ -3730,79 +3167,6 @@ class ScrollViewer$1 {
|
|
|
3730
3167
|
document.removeEventListener("mousemove", this.mousemoveHandler);
|
|
3731
3168
|
document.removeEventListener("mouseup", this.mouseupHandler);
|
|
3732
3169
|
}
|
|
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
3170
|
setScrollOffset(deltaX, deltaY) {
|
|
3807
3171
|
const { width, height } = this.container.getBoundingClientRect();
|
|
3808
3172
|
const targetRect = this.target.getBoundingClientRect();
|
|
@@ -3863,19 +3227,19 @@ const _sfc_main$4 = defineComponent({
|
|
|
3863
3227
|
el,
|
|
3864
3228
|
style: computed(() => `
|
|
3865
3229
|
width: ${props.width}px;
|
|
3866
|
-
height: ${props.height}px;
|
|
3230
|
+
height: ${(props.height || 0) - 40}px;
|
|
3867
3231
|
position: absolute;
|
|
3868
3232
|
margin-top: 30px;
|
|
3869
3233
|
`)
|
|
3870
3234
|
};
|
|
3871
3235
|
}
|
|
3872
3236
|
});
|
|
3873
|
-
const _hoisted_1$
|
|
3237
|
+
const _hoisted_1$1 = {
|
|
3874
3238
|
class: "m-editor-scroll-viewer-container",
|
|
3875
3239
|
ref: "container"
|
|
3876
3240
|
};
|
|
3877
3241
|
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3878
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
3242
|
+
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
3879
3243
|
createElementVNode("div", {
|
|
3880
3244
|
ref: "el",
|
|
3881
3245
|
style: normalizeStyle(_ctx.style)
|
|
@@ -3887,7 +3251,7 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3887
3251
|
var ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]);
|
|
3888
3252
|
|
|
3889
3253
|
const _sfc_main$3 = defineComponent({
|
|
3890
|
-
|
|
3254
|
+
components: { ContentMenu },
|
|
3891
3255
|
setup() {
|
|
3892
3256
|
const services = inject("services");
|
|
3893
3257
|
const editorService = services?.editorService;
|
|
@@ -3896,6 +3260,8 @@ const _sfc_main$3 = defineComponent({
|
|
|
3896
3260
|
const canCenter = ref(false);
|
|
3897
3261
|
const node = computed(() => editorService?.get("node"));
|
|
3898
3262
|
const parent = computed(() => editorService?.get("parent"));
|
|
3263
|
+
const isPage = computed(() => node.value?.type === NodeType.PAGE);
|
|
3264
|
+
const stageContentMenu = inject("stageContentMenu", []);
|
|
3899
3265
|
onMounted(() => {
|
|
3900
3266
|
const data = globalThis.localStorage.getItem(COPY_STORAGE_KEY);
|
|
3901
3267
|
canPaste.value = data !== "undefined" && !!data;
|
|
@@ -3908,167 +3274,142 @@ const _sfc_main$3 = defineComponent({
|
|
|
3908
3274
|
}, { immediate: true });
|
|
3909
3275
|
return {
|
|
3910
3276
|
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
|
-
|
|
3277
|
+
menuData: reactive([
|
|
3278
|
+
{
|
|
3279
|
+
type: "button",
|
|
3280
|
+
text: "\u6C34\u5E73\u5C45\u4E2D",
|
|
3281
|
+
display: () => canCenter.value,
|
|
3282
|
+
handler: () => {
|
|
3283
|
+
node.value && editorService?.alignCenter(node.value);
|
|
3284
|
+
}
|
|
3285
|
+
},
|
|
3286
|
+
{
|
|
3287
|
+
type: "button",
|
|
3288
|
+
text: "\u590D\u5236",
|
|
3289
|
+
icon: markRaw(DocumentCopy),
|
|
3290
|
+
handler: () => {
|
|
3291
|
+
node.value && editorService?.copy(node.value);
|
|
3292
|
+
canPaste.value = true;
|
|
3293
|
+
}
|
|
3294
|
+
},
|
|
3295
|
+
{
|
|
3296
|
+
type: "button",
|
|
3297
|
+
text: "\u7C98\u8D34",
|
|
3298
|
+
display: () => canPaste.value,
|
|
3299
|
+
handler: () => {
|
|
3300
|
+
const stage = editorService?.get("stage");
|
|
3301
|
+
const rect = menu.value?.$el.getBoundingClientRect();
|
|
3302
|
+
const parentRect = stage?.container?.getBoundingClientRect();
|
|
3303
|
+
let left = (rect?.left || 0) - (parentRect?.left || 0);
|
|
3304
|
+
let top = (rect?.top || 0) - (parentRect?.top || 0);
|
|
3305
|
+
if (node.value?.items && stage) {
|
|
3306
|
+
const parentEl = stage.renderer.contentWindow?.document.getElementById(`${node.value.id}`);
|
|
3307
|
+
const parentElRect = parentEl?.getBoundingClientRect();
|
|
3308
|
+
left = left - (parentElRect?.left || 0);
|
|
3309
|
+
top = top - (parentElRect?.top || 0);
|
|
3310
|
+
}
|
|
3311
|
+
editorService?.paste({ left, top });
|
|
3312
|
+
}
|
|
3313
|
+
},
|
|
3314
|
+
{
|
|
3315
|
+
type: "divider",
|
|
3316
|
+
direction: "horizontal",
|
|
3317
|
+
display: () => !isPage.value
|
|
3318
|
+
},
|
|
3319
|
+
{
|
|
3320
|
+
type: "button",
|
|
3321
|
+
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
3322
|
+
icon: markRaw(Top),
|
|
3323
|
+
display: () => !isPage.value,
|
|
3324
|
+
handler: () => {
|
|
3325
|
+
editorService?.moveLayer(1);
|
|
3326
|
+
}
|
|
3327
|
+
},
|
|
3328
|
+
{
|
|
3329
|
+
type: "button",
|
|
3330
|
+
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
3331
|
+
icon: markRaw(Bottom),
|
|
3332
|
+
display: () => !isPage.value,
|
|
3333
|
+
handler: () => {
|
|
3334
|
+
editorService?.moveLayer(-1);
|
|
3335
|
+
}
|
|
3336
|
+
},
|
|
3337
|
+
{
|
|
3338
|
+
type: "button",
|
|
3339
|
+
text: "\u7F6E\u9876",
|
|
3340
|
+
display: () => !isPage.value,
|
|
3341
|
+
handler: () => {
|
|
3342
|
+
editorService?.moveLayer(LayerOffset.TOP);
|
|
3343
|
+
}
|
|
3344
|
+
},
|
|
3345
|
+
{
|
|
3346
|
+
type: "button",
|
|
3347
|
+
text: "\u7F6E\u5E95",
|
|
3348
|
+
display: () => !isPage.value,
|
|
3349
|
+
handler: () => {
|
|
3350
|
+
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
3351
|
+
}
|
|
3352
|
+
},
|
|
3353
|
+
{
|
|
3354
|
+
type: "divider",
|
|
3355
|
+
direction: "horizontal",
|
|
3356
|
+
display: () => !isPage.value
|
|
3357
|
+
},
|
|
3358
|
+
{
|
|
3359
|
+
type: "button",
|
|
3360
|
+
text: "\u5220\u9664",
|
|
3361
|
+
icon: Delete,
|
|
3362
|
+
display: () => !isPage.value,
|
|
3363
|
+
handler: () => {
|
|
3364
|
+
node.value && editorService?.remove(node.value);
|
|
3365
|
+
}
|
|
3366
|
+
},
|
|
3367
|
+
{
|
|
3368
|
+
type: "divider",
|
|
3369
|
+
direction: "horizontal"
|
|
3370
|
+
},
|
|
3371
|
+
{
|
|
3372
|
+
type: "button",
|
|
3373
|
+
text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
|
|
3374
|
+
handler: () => {
|
|
3375
|
+
editorService?.get("stage").clearGuides();
|
|
3376
|
+
}
|
|
3377
|
+
},
|
|
3378
|
+
...stageContentMenu
|
|
3379
|
+
]),
|
|
3380
|
+
show(e) {
|
|
3381
|
+
menu.value?.show(e);
|
|
3944
3382
|
}
|
|
3945
3383
|
};
|
|
3946
3384
|
}
|
|
3947
3385
|
});
|
|
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
3386
|
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);
|
|
3387
|
+
const _component_content_menu = resolveComponent("content-menu");
|
|
3388
|
+
return openBlock(), createBlock(_component_content_menu, {
|
|
3389
|
+
"menu-data": _ctx.menuData,
|
|
3390
|
+
ref: "menu"
|
|
3391
|
+
}, null, 8, ["menu-data"]);
|
|
4005
3392
|
}
|
|
4006
3393
|
var ViewerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
|
|
4007
3394
|
|
|
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
3395
|
const _sfc_main$2 = defineComponent({
|
|
4039
3396
|
name: "magic-stage",
|
|
4040
3397
|
components: {
|
|
4041
3398
|
ViewerMenu,
|
|
4042
3399
|
ScrollViewer
|
|
4043
3400
|
},
|
|
4044
|
-
|
|
4045
|
-
render: {
|
|
4046
|
-
type: Function
|
|
4047
|
-
},
|
|
4048
|
-
runtimeUrl: String,
|
|
4049
|
-
canSelect: {
|
|
4050
|
-
type: Function,
|
|
4051
|
-
default: (el) => Boolean(el.id)
|
|
4052
|
-
},
|
|
4053
|
-
moveableOptions: {
|
|
4054
|
-
type: [Object, Function],
|
|
4055
|
-
default: () => (core) => ({
|
|
4056
|
-
container: core?.renderer?.contentWindow?.document.getElementById("app")
|
|
4057
|
-
})
|
|
4058
|
-
}
|
|
4059
|
-
},
|
|
4060
|
-
emits: ["select", "update", "sort", "highlight"],
|
|
4061
|
-
setup(props, { emit }) {
|
|
3401
|
+
setup() {
|
|
4062
3402
|
const services = inject("services");
|
|
3403
|
+
const stageOptions = inject("stageOptions");
|
|
4063
3404
|
const stageWrap = ref();
|
|
4064
3405
|
const stageContainer = ref();
|
|
3406
|
+
const menu = ref();
|
|
4065
3407
|
const stageRect = computed(() => services?.uiService.get("stageRect"));
|
|
4066
3408
|
const uiSelectMode = computed(() => services?.uiService.get("uiSelectMode"));
|
|
4067
3409
|
const root = computed(() => services?.editorService.get("root"));
|
|
4068
3410
|
const page = computed(() => services?.editorService.get("page"));
|
|
4069
|
-
const zoom = computed(() => services?.uiService.get("zoom"));
|
|
3411
|
+
const zoom = computed(() => services?.uiService.get("zoom") || 1);
|
|
4070
3412
|
const node = computed(() => services?.editorService.get("node"));
|
|
4071
|
-
const highlightNode = computed(() => services?.editorService.get("highlightNode"));
|
|
4072
3413
|
let stage = null;
|
|
4073
3414
|
let runtime = null;
|
|
4074
3415
|
watchEffect(() => {
|
|
@@ -4076,35 +3417,37 @@ const _sfc_main$2 = defineComponent({
|
|
|
4076
3417
|
return;
|
|
4077
3418
|
if (!stageContainer.value)
|
|
4078
3419
|
return;
|
|
4079
|
-
if (!(
|
|
3420
|
+
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
|
|
4080
3421
|
return;
|
|
4081
3422
|
stage = new StageCore({
|
|
4082
|
-
render:
|
|
4083
|
-
runtimeUrl:
|
|
3423
|
+
render: stageOptions.render,
|
|
3424
|
+
runtimeUrl: stageOptions.runtimeUrl,
|
|
4084
3425
|
zoom: zoom.value,
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
3426
|
+
autoScrollIntoView: stageOptions.autoScrollIntoView,
|
|
3427
|
+
canSelect: (el, event, stop) => {
|
|
3428
|
+
const elCanSelect = stageOptions.canSelect(el);
|
|
3429
|
+
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
4088
3430
|
document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
|
|
4089
3431
|
return stop();
|
|
4090
3432
|
}
|
|
4091
3433
|
return elCanSelect;
|
|
4092
3434
|
},
|
|
4093
|
-
moveableOptions:
|
|
3435
|
+
moveableOptions: stageOptions.moveableOptions,
|
|
3436
|
+
updateDragEl: stageOptions.updateDragEl
|
|
4094
3437
|
});
|
|
4095
|
-
services?.editorService.set("stage", stage);
|
|
3438
|
+
services?.editorService.set("stage", markRaw(stage));
|
|
4096
3439
|
stage?.mount(stageContainer.value);
|
|
4097
3440
|
stage?.on("select", (el) => {
|
|
4098
|
-
|
|
3441
|
+
services?.editorService.select(el.id);
|
|
4099
3442
|
});
|
|
4100
3443
|
stage?.on("highlight", (el) => {
|
|
4101
|
-
|
|
3444
|
+
services?.editorService.highlight(el.id);
|
|
4102
3445
|
});
|
|
4103
3446
|
stage?.on("update", (ev) => {
|
|
4104
|
-
|
|
3447
|
+
services?.editorService.update({ id: ev.el.id, style: ev.style });
|
|
4105
3448
|
});
|
|
4106
3449
|
stage?.on("sort", (ev) => {
|
|
4107
|
-
|
|
3450
|
+
services?.editorService.sort(ev.src, ev.dist);
|
|
4108
3451
|
});
|
|
4109
3452
|
stage?.on("changeGuides", () => {
|
|
4110
3453
|
services?.uiService.set("showGuides", true);
|
|
@@ -4113,7 +3456,7 @@ const _sfc_main$2 = defineComponent({
|
|
|
4113
3456
|
return;
|
|
4114
3457
|
stage?.on("runtime-ready", (rt) => {
|
|
4115
3458
|
runtime = rt;
|
|
4116
|
-
root.value && runtime?.updateRootConfig(cloneDeep(toRaw(root.value)));
|
|
3459
|
+
root.value && runtime?.updateRootConfig?.(cloneDeep(toRaw(root.value)));
|
|
4117
3460
|
page.value?.id && runtime?.updatePageId?.(page.value.id);
|
|
4118
3461
|
setTimeout(() => {
|
|
4119
3462
|
node.value && stage?.select(toRaw(node.value.id));
|
|
@@ -4127,19 +3470,9 @@ const _sfc_main$2 = defineComponent({
|
|
|
4127
3470
|
});
|
|
4128
3471
|
watch(root, (root2) => {
|
|
4129
3472
|
if (runtime && root2) {
|
|
4130
|
-
runtime.updateRootConfig(cloneDeep(toRaw(root2)));
|
|
3473
|
+
runtime.updateRootConfig?.(cloneDeep(toRaw(root2)));
|
|
4131
3474
|
}
|
|
4132
3475
|
});
|
|
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
3476
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
4144
3477
|
for (const { contentRect } of entries) {
|
|
4145
3478
|
services?.uiService.set("stageContainerRect", {
|
|
@@ -4159,9 +3492,37 @@ const _sfc_main$2 = defineComponent({
|
|
|
4159
3492
|
return {
|
|
4160
3493
|
stageWrap,
|
|
4161
3494
|
stageContainer,
|
|
3495
|
+
menu,
|
|
4162
3496
|
stageRect,
|
|
4163
3497
|
zoom,
|
|
4164
|
-
|
|
3498
|
+
contextmenuHandler(e2) {
|
|
3499
|
+
e2.preventDefault();
|
|
3500
|
+
menu.value?.show(e2);
|
|
3501
|
+
},
|
|
3502
|
+
dragoverHandler(e2) {
|
|
3503
|
+
e2.preventDefault();
|
|
3504
|
+
if (e2.dataTransfer) {
|
|
3505
|
+
e2.dataTransfer.dropEffect = "move";
|
|
3506
|
+
}
|
|
3507
|
+
},
|
|
3508
|
+
async dropHandler(e) {
|
|
3509
|
+
e.preventDefault();
|
|
3510
|
+
if (e.dataTransfer && page.value && stageContainer.value && stage) {
|
|
3511
|
+
const config = eval(`(${e.dataTransfer.getData("data")})`);
|
|
3512
|
+
const layout = await services?.editorService.getLayout(page.value);
|
|
3513
|
+
const containerRect = stageContainer.value.getBoundingClientRect();
|
|
3514
|
+
const { scrollTop, scrollLeft } = stage.mask;
|
|
3515
|
+
if (layout === Layout.ABSOLUTE) {
|
|
3516
|
+
config.style = {
|
|
3517
|
+
...config.style || {},
|
|
3518
|
+
position: "absolute",
|
|
3519
|
+
top: e.clientY - containerRect.top + scrollTop,
|
|
3520
|
+
left: e.clientX - containerRect.left + scrollLeft
|
|
3521
|
+
};
|
|
3522
|
+
}
|
|
3523
|
+
services?.editorService.add(config, page.value);
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
4165
3526
|
};
|
|
4166
3527
|
}
|
|
4167
3528
|
});
|
|
@@ -4179,14 +3540,13 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4179
3540
|
createElementVNode("div", {
|
|
4180
3541
|
class: "m-editor-stage-container",
|
|
4181
3542
|
ref: "stageContainer",
|
|
3543
|
+
style: normalizeStyle(`transform: scale(${_ctx.zoom})`),
|
|
4182
3544
|
onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
|
|
4183
|
-
|
|
3545
|
+
onDrop: _cache[1] || (_cache[1] = (...args) => _ctx.dropHandler && _ctx.dropHandler(...args)),
|
|
3546
|
+
onDragover: _cache[2] || (_cache[2] = (...args) => _ctx.dragoverHandler && _ctx.dragoverHandler(...args))
|
|
4184
3547
|
}, null, 36),
|
|
4185
3548
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
4186
|
-
createVNode(_component_viewer_menu, {
|
|
4187
|
-
ref: "menu",
|
|
4188
|
-
style: normalizeStyle(_ctx.menuStyle)
|
|
4189
|
-
}, null, 8, ["style"])
|
|
3549
|
+
createVNode(_component_viewer_menu, { ref: "menu" }, null, 512)
|
|
4190
3550
|
]))
|
|
4191
3551
|
]),
|
|
4192
3552
|
_: 1
|
|
@@ -4200,53 +3560,118 @@ const _sfc_main$1 = defineComponent({
|
|
|
4200
3560
|
PageBar,
|
|
4201
3561
|
MagicStage
|
|
4202
3562
|
},
|
|
4203
|
-
props: {
|
|
4204
|
-
runtimeUrl: String,
|
|
4205
|
-
render: {
|
|
4206
|
-
type: Function
|
|
4207
|
-
},
|
|
4208
|
-
moveableOptions: {
|
|
4209
|
-
type: [Object, Function]
|
|
4210
|
-
},
|
|
4211
|
-
canSelect: {
|
|
4212
|
-
type: Function
|
|
4213
|
-
}
|
|
4214
|
-
},
|
|
4215
3563
|
setup() {
|
|
4216
3564
|
const services = inject("services");
|
|
3565
|
+
const workspace = ref();
|
|
3566
|
+
const node = computed(() => services?.editorService.get("node"));
|
|
3567
|
+
let keycon;
|
|
3568
|
+
const mouseenterHandler = () => {
|
|
3569
|
+
workspace.value?.focus();
|
|
3570
|
+
};
|
|
3571
|
+
const mouseleaveHandler = () => {
|
|
3572
|
+
workspace.value?.blur();
|
|
3573
|
+
};
|
|
3574
|
+
onMounted(() => {
|
|
3575
|
+
workspace.value?.addEventListener("mouseenter", mouseenterHandler);
|
|
3576
|
+
workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
|
|
3577
|
+
keycon = new KeyController(workspace.value);
|
|
3578
|
+
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
3579
|
+
const ctrl = isMac ? "meta" : "ctrl";
|
|
3580
|
+
keycon.keyup("delete", (e) => {
|
|
3581
|
+
e.inputEvent.preventDefault();
|
|
3582
|
+
if (!node.value || isPage(node.value))
|
|
3583
|
+
return;
|
|
3584
|
+
services?.editorService.remove(node.value);
|
|
3585
|
+
}).keyup("backspace", (e) => {
|
|
3586
|
+
e.inputEvent.preventDefault();
|
|
3587
|
+
if (!node.value || isPage(node.value))
|
|
3588
|
+
return;
|
|
3589
|
+
services?.editorService.remove(node.value);
|
|
3590
|
+
}).keydown([ctrl, "c"], (e) => {
|
|
3591
|
+
e.inputEvent.preventDefault();
|
|
3592
|
+
node.value && services?.editorService.copy(node.value);
|
|
3593
|
+
}).keydown([ctrl, "v"], (e) => {
|
|
3594
|
+
e.inputEvent.preventDefault();
|
|
3595
|
+
node.value && services?.editorService.paste();
|
|
3596
|
+
}).keydown([ctrl, "x"], (e) => {
|
|
3597
|
+
e.inputEvent.preventDefault();
|
|
3598
|
+
if (!node.value || isPage(node.value))
|
|
3599
|
+
return;
|
|
3600
|
+
services?.editorService.copy(node.value);
|
|
3601
|
+
services?.editorService.remove(node.value);
|
|
3602
|
+
}).keydown([ctrl, "z"], (e) => {
|
|
3603
|
+
e.inputEvent.preventDefault();
|
|
3604
|
+
services?.editorService.undo();
|
|
3605
|
+
}).keydown([ctrl, "shift", "z"], (e) => {
|
|
3606
|
+
e.inputEvent.preventDefault();
|
|
3607
|
+
services?.editorService.redo();
|
|
3608
|
+
}).keydown("up", (e) => {
|
|
3609
|
+
e.inputEvent.preventDefault();
|
|
3610
|
+
services?.editorService.move(0, -1);
|
|
3611
|
+
}).keydown("down", (e) => {
|
|
3612
|
+
e.inputEvent.preventDefault();
|
|
3613
|
+
services?.editorService.move(0, 1);
|
|
3614
|
+
}).keydown("left", (e) => {
|
|
3615
|
+
e.inputEvent.preventDefault();
|
|
3616
|
+
services?.editorService.move(-1, 0);
|
|
3617
|
+
}).keydown("right", (e) => {
|
|
3618
|
+
e.inputEvent.preventDefault();
|
|
3619
|
+
services?.editorService.move(1, 0);
|
|
3620
|
+
}).keydown([ctrl, "up"], (e) => {
|
|
3621
|
+
e.inputEvent.preventDefault();
|
|
3622
|
+
services?.editorService.move(0, -10);
|
|
3623
|
+
}).keydown([ctrl, "down"], (e) => {
|
|
3624
|
+
e.inputEvent.preventDefault();
|
|
3625
|
+
services?.editorService.move(0, 10);
|
|
3626
|
+
}).keydown([ctrl, "left"], (e) => {
|
|
3627
|
+
e.inputEvent.preventDefault();
|
|
3628
|
+
services?.editorService.move(-10, 0);
|
|
3629
|
+
}).keydown([ctrl, "right"], (e) => {
|
|
3630
|
+
e.inputEvent.preventDefault();
|
|
3631
|
+
services?.editorService.move(10, 0);
|
|
3632
|
+
}).keydown("tab", (e) => {
|
|
3633
|
+
e.inputEvent.preventDefault();
|
|
3634
|
+
services?.editorService.selectNextNode();
|
|
3635
|
+
}).keydown([ctrl, "tab"], (e) => {
|
|
3636
|
+
e.inputEvent.preventDefault();
|
|
3637
|
+
services?.editorService.selectNextPage();
|
|
3638
|
+
}).keydown([ctrl, "="], (e) => {
|
|
3639
|
+
e.inputEvent.preventDefault();
|
|
3640
|
+
services?.uiService.zoom(0.1);
|
|
3641
|
+
}).keydown([ctrl, "numpadplus"], (e) => {
|
|
3642
|
+
e.inputEvent.preventDefault();
|
|
3643
|
+
services?.uiService.zoom(0.1);
|
|
3644
|
+
}).keydown([ctrl, "-"], (e) => {
|
|
3645
|
+
e.inputEvent.preventDefault();
|
|
3646
|
+
services?.uiService.zoom(-0.1);
|
|
3647
|
+
}).keydown([ctrl, "numpad-"], (e) => {
|
|
3648
|
+
e.inputEvent.preventDefault();
|
|
3649
|
+
services?.uiService.zoom(-0.1);
|
|
3650
|
+
});
|
|
3651
|
+
});
|
|
3652
|
+
onUnmounted(() => {
|
|
3653
|
+
workspace.value?.removeEventListener("mouseenter", mouseenterHandler);
|
|
3654
|
+
workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
|
|
3655
|
+
keycon.destroy();
|
|
3656
|
+
});
|
|
4217
3657
|
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
|
-
}
|
|
3658
|
+
workspace,
|
|
3659
|
+
page: computed(() => services?.editorService.get("page"))
|
|
4231
3660
|
};
|
|
4232
3661
|
}
|
|
4233
3662
|
});
|
|
4234
|
-
const _hoisted_1 = {
|
|
3663
|
+
const _hoisted_1 = {
|
|
3664
|
+
class: "m-editor-workspace",
|
|
3665
|
+
tabindex: "1",
|
|
3666
|
+
ref: "workspace"
|
|
3667
|
+
};
|
|
4235
3668
|
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4236
3669
|
const _component_magic_stage = resolveComponent("magic-stage");
|
|
4237
3670
|
const _component_page_bar = resolveComponent("page-bar");
|
|
4238
3671
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
4239
3672
|
(openBlock(), createBlock(_component_magic_stage, {
|
|
4240
|
-
key: _ctx.page?.id
|
|
4241
|
-
|
|
4242
|
-
render: _ctx.render,
|
|
4243
|
-
"moveable-options": _ctx.moveableOptions,
|
|
4244
|
-
"can-select": _ctx.canSelect,
|
|
4245
|
-
onSelect: _ctx.selectHandler,
|
|
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"])),
|
|
3673
|
+
key: _ctx.page?.id
|
|
3674
|
+
})),
|
|
4250
3675
|
renderSlot(_ctx.$slots, "workspace-content"),
|
|
4251
3676
|
createVNode(_component_page_bar, null, {
|
|
4252
3677
|
"page-bar-title": withCtx(({ page }) => [
|
|
@@ -4257,16 +3682,16 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4257
3682
|
]),
|
|
4258
3683
|
_: 3
|
|
4259
3684
|
})
|
|
4260
|
-
]);
|
|
3685
|
+
], 512);
|
|
4261
3686
|
}
|
|
4262
3687
|
var Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
4263
3688
|
|
|
4264
3689
|
class ComponentList extends BaseService {
|
|
4265
|
-
state = reactive({
|
|
4266
|
-
list: []
|
|
4267
|
-
});
|
|
4268
3690
|
constructor() {
|
|
4269
3691
|
super([]);
|
|
3692
|
+
this.state = reactive({
|
|
3693
|
+
list: []
|
|
3694
|
+
});
|
|
4270
3695
|
}
|
|
4271
3696
|
setList(componentGroupList) {
|
|
4272
3697
|
this.state.list = componentGroupList;
|
|
@@ -4277,6 +3702,14 @@ class ComponentList extends BaseService {
|
|
|
4277
3702
|
}
|
|
4278
3703
|
var componentListService = new ComponentList();
|
|
4279
3704
|
|
|
3705
|
+
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
3706
|
+
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
3707
|
+
const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
|
|
3708
|
+
const defaultColumnWidth = {
|
|
3709
|
+
left: DEFAULT_LEFT_COLUMN_WIDTH,
|
|
3710
|
+
center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
|
|
3711
|
+
right: DEFAULT_RIGHT_COLUMN_WIDTH
|
|
3712
|
+
};
|
|
4280
3713
|
const state = reactive({
|
|
4281
3714
|
uiSelectMode: false,
|
|
4282
3715
|
showSrc: false,
|
|
@@ -4289,13 +3722,10 @@ const state = reactive({
|
|
|
4289
3722
|
width: 375,
|
|
4290
3723
|
height: 817
|
|
4291
3724
|
},
|
|
4292
|
-
columnWidth:
|
|
4293
|
-
left: 310,
|
|
4294
|
-
center: globalThis.document.body.clientWidth - 310 - 400,
|
|
4295
|
-
right: 400
|
|
4296
|
-
},
|
|
3725
|
+
columnWidth: defaultColumnWidth,
|
|
4297
3726
|
showGuides: true,
|
|
4298
|
-
showRule: true
|
|
3727
|
+
showRule: true,
|
|
3728
|
+
propsPanelSize: "small"
|
|
4299
3729
|
});
|
|
4300
3730
|
class Ui extends BaseService {
|
|
4301
3731
|
constructor() {
|
|
@@ -4305,6 +3735,15 @@ class Ui extends BaseService {
|
|
|
4305
3735
|
center: "auto"
|
|
4306
3736
|
});
|
|
4307
3737
|
});
|
|
3738
|
+
const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
|
|
3739
|
+
if (columnWidthCacheData) {
|
|
3740
|
+
try {
|
|
3741
|
+
const columnWidthCache = JSON.parse(columnWidthCacheData);
|
|
3742
|
+
this.setColumnWidth(columnWidthCache);
|
|
3743
|
+
} catch (e) {
|
|
3744
|
+
console.error(e);
|
|
3745
|
+
}
|
|
3746
|
+
}
|
|
4308
3747
|
}
|
|
4309
3748
|
set(name, value) {
|
|
4310
3749
|
const mask = editorService.get("stage")?.mask;
|
|
@@ -4330,6 +3769,11 @@ class Ui extends BaseService {
|
|
|
4330
3769
|
get(name) {
|
|
4331
3770
|
return state[name];
|
|
4332
3771
|
}
|
|
3772
|
+
zoom(zoom) {
|
|
3773
|
+
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
3774
|
+
if (this.get("zoom") < 0.1)
|
|
3775
|
+
this.set("zoom", 0.1);
|
|
3776
|
+
}
|
|
4333
3777
|
setColumnWidth({ left, center, right }) {
|
|
4334
3778
|
const columnWidth = {
|
|
4335
3779
|
...toRaw(this.get("columnWidth"))
|
|
@@ -4343,9 +3787,15 @@ class Ui extends BaseService {
|
|
|
4343
3787
|
if (!center || center === "auto") {
|
|
4344
3788
|
const bodyWidth = globalThis.document.body.clientWidth;
|
|
4345
3789
|
columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
|
|
3790
|
+
if (columnWidth.center <= 0) {
|
|
3791
|
+
columnWidth.left = defaultColumnWidth.left;
|
|
3792
|
+
columnWidth.center = defaultColumnWidth.center;
|
|
3793
|
+
columnWidth.right = defaultColumnWidth.right;
|
|
3794
|
+
}
|
|
4346
3795
|
} else {
|
|
4347
3796
|
columnWidth.center = center;
|
|
4348
3797
|
}
|
|
3798
|
+
globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
|
|
4349
3799
|
state.columnWidth = columnWidth;
|
|
4350
3800
|
}
|
|
4351
3801
|
setStageRect(value) {
|
|
@@ -4390,6 +3840,14 @@ const _sfc_main = defineComponent({
|
|
|
4390
3840
|
sidebar: {
|
|
4391
3841
|
type: Object
|
|
4392
3842
|
},
|
|
3843
|
+
layerContentMenu: {
|
|
3844
|
+
type: Array,
|
|
3845
|
+
default: () => []
|
|
3846
|
+
},
|
|
3847
|
+
stageContentMenu: {
|
|
3848
|
+
type: Array,
|
|
3849
|
+
default: () => []
|
|
3850
|
+
},
|
|
4393
3851
|
menu: {
|
|
4394
3852
|
type: Object,
|
|
4395
3853
|
default: () => ({ left: [], right: [] })
|
|
@@ -4398,6 +3856,7 @@ const _sfc_main = defineComponent({
|
|
|
4398
3856
|
type: Function
|
|
4399
3857
|
},
|
|
4400
3858
|
runtimeUrl: String,
|
|
3859
|
+
autoScrollIntoView: Boolean,
|
|
4401
3860
|
propsConfigs: {
|
|
4402
3861
|
type: Object,
|
|
4403
3862
|
default: () => ({})
|
|
@@ -4411,16 +3870,27 @@ const _sfc_main = defineComponent({
|
|
|
4411
3870
|
default: () => ({})
|
|
4412
3871
|
},
|
|
4413
3872
|
moveableOptions: {
|
|
4414
|
-
type: [Object, Function]
|
|
3873
|
+
type: [Object, Function],
|
|
3874
|
+
default: () => (core) => ({
|
|
3875
|
+
container: core?.renderer?.contentWindow?.document.getElementById("app")
|
|
3876
|
+
})
|
|
4415
3877
|
},
|
|
4416
3878
|
defaultSelected: {
|
|
4417
3879
|
type: [Number, String]
|
|
4418
3880
|
},
|
|
4419
3881
|
canSelect: {
|
|
4420
|
-
type: Function
|
|
3882
|
+
type: Function,
|
|
3883
|
+
default: (el) => Boolean(el.id)
|
|
4421
3884
|
},
|
|
4422
3885
|
stageRect: {
|
|
4423
3886
|
type: [String, Object]
|
|
3887
|
+
},
|
|
3888
|
+
codeOptions: {
|
|
3889
|
+
type: Object,
|
|
3890
|
+
default: () => ({})
|
|
3891
|
+
},
|
|
3892
|
+
updateDragEl: {
|
|
3893
|
+
type: Function
|
|
4424
3894
|
}
|
|
4425
3895
|
},
|
|
4426
3896
|
emits: ["props-panel-mounted", "update:modelValue"],
|
|
@@ -4470,6 +3940,16 @@ const _sfc_main = defineComponent({
|
|
|
4470
3940
|
uiService
|
|
4471
3941
|
};
|
|
4472
3942
|
provide("services", services);
|
|
3943
|
+
provide("layerContentMenu", props.layerContentMenu);
|
|
3944
|
+
provide("stageContentMenu", props.stageContentMenu);
|
|
3945
|
+
provide("stageOptions", reactive({
|
|
3946
|
+
runtimeUrl: props.runtimeUrl,
|
|
3947
|
+
autoScrollIntoView: props.autoScrollIntoView,
|
|
3948
|
+
render: props.render,
|
|
3949
|
+
moveableOptions: props.moveableOptions,
|
|
3950
|
+
canSelect: props.canSelect,
|
|
3951
|
+
updateDragEl: props.updateDragEl
|
|
3952
|
+
}));
|
|
4473
3953
|
return services;
|
|
4474
3954
|
}
|
|
4475
3955
|
});
|
|
@@ -4479,7 +3959,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4479
3959
|
const _component_workspace = resolveComponent("workspace");
|
|
4480
3960
|
const _component_props_panel = resolveComponent("props-panel");
|
|
4481
3961
|
const _component_framework = resolveComponent("framework");
|
|
4482
|
-
return openBlock(), createBlock(_component_framework,
|
|
3962
|
+
return openBlock(), createBlock(_component_framework, { "code-options": _ctx.codeOptions }, {
|
|
4483
3963
|
nav: withCtx(() => [
|
|
4484
3964
|
renderSlot(_ctx.$slots, "nav", { editorService: _ctx.editorService }, () => [
|
|
4485
3965
|
createVNode(_component_nav_menu, { data: _ctx.menu }, null, 8, ["data"])
|
|
@@ -4492,12 +3972,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4492
3972
|
]),
|
|
4493
3973
|
workspace: withCtx(() => [
|
|
4494
3974
|
renderSlot(_ctx.$slots, "workspace", {}, () => [
|
|
4495
|
-
createVNode(_component_workspace, {
|
|
4496
|
-
"runtime-url": _ctx.runtimeUrl,
|
|
4497
|
-
render: _ctx.render,
|
|
4498
|
-
"moveable-options": _ctx.moveableOptions,
|
|
4499
|
-
"can-select": _ctx.canSelect
|
|
4500
|
-
}, {
|
|
3975
|
+
createVNode(_component_workspace, null, {
|
|
4501
3976
|
"workspace-content": withCtx(() => [
|
|
4502
3977
|
renderSlot(_ctx.$slots, "workspace-content", { editorService: _ctx.editorService })
|
|
4503
3978
|
]),
|
|
@@ -4508,7 +3983,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4508
3983
|
renderSlot(_ctx.$slots, "page-bar-popover", { page })
|
|
4509
3984
|
]),
|
|
4510
3985
|
_: 3
|
|
4511
|
-
}
|
|
3986
|
+
})
|
|
4512
3987
|
])
|
|
4513
3988
|
]),
|
|
4514
3989
|
propsPanel: withCtx(() => [
|
|
@@ -4523,11 +3998,11 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4523
3998
|
renderSlot(_ctx.$slots, "empty", { editorService: _ctx.editorService })
|
|
4524
3999
|
]),
|
|
4525
4000
|
_: 3
|
|
4526
|
-
});
|
|
4001
|
+
}, 8, ["code-options"]);
|
|
4527
4002
|
}
|
|
4528
4003
|
var Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
4529
4004
|
|
|
4530
|
-
var index$1 = '';
|
|
4005
|
+
var index$1 = /* #__PURE__ */ (() => ".m-editor-nav-menu {\n display: flex;\n z-index: 5;\n -webkit-box-pack: justify;\n justify-content: space-between;\n -webkit-box-align: center;\n align-items: center;\n background-color: #ffffff;\n font-size: 19.2px;\n color: #070303;\n font-weight: 400;\n box-sizing: border-box;\n margin: 0px;\n flex: 0 0 35px;\n border-bottom: 1px solid #d8dee8;\n}\n.m-editor-nav-menu > div {\n display: flex;\n height: 100%;\n z-index: 1;\n align-items: center;\n}\n.m-editor-nav-menu .menu-center {\n justify-content: center;\n}\n.m-editor-nav-menu .menu-right {\n justify-content: flex-end;\n}\n.m-editor-nav-menu .menu-item {\n flex-direction: row;\n -webkit-box-align: center;\n align-items: center;\n vertical-align: middle;\n font-size: 14px;\n line-height: 1;\n height: 100%;\n color: rgba(255, 255, 255, 0.7);\n box-sizing: inherit;\n z-index: 1;\n display: flex !important;\n transition: all 0.3s ease 0s;\n border-bottom: 2px solid transparent;\n margin: 0;\n}\n.m-editor-nav-menu .menu-item .is-disabled {\n opacity: 0.5;\n}\n.m-editor-nav-menu .menu-item .is-text {\n padding: 5px;\n}\n.m-editor-nav-menu .menu-item .is-text,\n.m-editor-nav-menu .menu-item i {\n color: #070303;\n}\n.m-editor-nav-menu .menu-item .icon {\n display: flex;\n -webkit-box-align: center;\n align-items: center;\n height: 100%;\n padding: 0px 8px;\n}\n.m-editor-nav-menu .menu-item .menu-item-text {\n color: #070303;\n}\n.m-editor {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n.m-editor-content {\n width: 100%;\n height: calc(100% - 35px);\n display: flex;\n justify-self: space-between;\n}\n.m-editor-framework-center {\n position: relative;\n transform: translateZ(0);\n flex: 1;\n}\n.m-editor-framework-left {\n background-color: #ffffff;\n}\n.m-editor-framework-center .el-scrollbar__view {\n height: 100%;\n min-height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.m-editor-empty-panel {\n display: flex;\n flex: 1;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n height: calc(100% - 32px);\n}\n.m-editor-empty-content {\n display: flex;\n justify-content: space-evenly;\n flex-direction: row;\n width: 100%;\n}\n.m-editor-empty-button {\n border: 3px solid rgba(0, 0, 0, 0.2);\n padding: 10px 40px;\n color: rgba(0, 0, 0, 0.6);\n cursor: pointer;\n}\n.m-editor-empty-button i {\n height: 180px;\n line-height: 180px;\n font-size: 100px;\n}\n.m-editor-empty-button p {\n text-align: center;\n font-size: 20px;\n margin-top: 5px;\n}\n.m-editor-empty-button:hover {\n border-color: #2882e0;\n color: #2882e0;\n}\n.m-editor-sidebar {\n height: 100%;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header {\n background: #2882e0;\n border: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header.is-left {\n width: 40px;\n margin-right: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__nav-wrap {\n margin: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__nav {\n border: 0;\n border-radius: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .tab-label {\n margin-left: 2px;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left {\n line-height: 15px;\n border: 0;\n height: auto;\n padding: 8px;\n color: rgb(255, 255, 255);\n box-sizing: border-box;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active {\n background: #ffffff;\n border: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active i {\n color: #353140;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active .magic-editor-tab-panel-title {\n color: #353140;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left:first-child {\n border-right: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header i {\n font-size: 25px;\n color: rgba(255, 255, 255, 0.6);\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header i:hover {\n color: rgb(255, 255, 255);\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .magic-editor-tab-panel-title {\n font-size: 12px;\n white-space: normal;\n}\n.m-editor-sidebar .el-scrollbar {\n height: 100%;\n}\n.m-editor-sidebar .el-tree {\n min-height: 100%;\n}\n.m-editor-sidebar .fold-icon {\n position: absolute;\n bottom: 8px;\n left: 0px;\n width: 45px;\n padding-left: 8px;\n color: #fff;\n font-size: 32px;\n opacity: 0.8;\n cursor: pointer;\n}\n.m-editor-sidebar .fold-icon:hover {\n background: rgba(0, 0, 0, 0.2);\n}\n.m-editor-sidebar .el-tabs__content,\n.m-editor-sidebar .el-tab-pane {\n height: 100%;\n}\n.magic-editor-layer-panel {\n background: #ffffff;\n}\n.magic-editor-layer-panel .search-input {\n background: #ffffff;\n color: #bbbbbb;\n padding: 10px;\n position: absolute;\n top: 0;\n left: 0;\n z-index: 1;\n}\n.magic-editor-layer-panel .search-input .el-input__suffix {\n padding: 10px 5px;\n}\n.magic-editor-layer-panel .node-content {\n flex: 1;\n display: flex;\n width: 100%;\n}\n.magic-editor-layer-panel .node-content > div {\n width: 8px;\n}\n.magic-editor-layer-panel .node-content > span {\n width: calc(100% - 68px);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.magic-editor-layer-panel .node-content > i {\n margin-right: 10px;\n font-size: 20px;\n}\n.magic-editor-layer-panel .node-content > i.lock {\n color: #bbb;\n}\n.magic-editor-layer-panel,\n.magic-editor-layer-panel .el-tree {\n background-color: #ffffff;\n color: #313a40;\n}\n.magic-editor-layer-panel .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {\n background-color: #2882e0;\n color: #fff;\n}\n.magic-editor-layer-panel .cus-tree-node {\n width: 100%;\n overflow: hidden;\n}\n.magic-editor-layer-panel .cus-tree-node-hover {\n background-color: #f3f5f9;\n width: 100%;\n}\n.magic-editor-layer-panel .el-tree-node:focus > .el-tree-node__content {\n background-color: #2882e0;\n color: #fff;\n}\n.ui-tree-tip {\n width: 100%;\n height: 25px;\n margin-left: 10px;\n background: #ffffff;\n font-style: italic;\n color: #555554;\n position: absolute;\n top: 40px;\n left: 0;\n z-index: 1;\n}\n.ui-component-panel {\n height: 100%;\n border-top: 0 !important;\n margin-top: 50px;\n background-color: #ffffff;\n}\n.ui-component-panel .search-input {\n background: #f8fbff;\n color: #bbbbbb;\n padding: 10px;\n position: absolute;\n top: 0;\n left: 0;\n box-sizing: border-box;\n z-index: 1;\n}\n.ui-component-panel .search-input .el-input__prefix {\n padding: 10px;\n}\n.ui-component-panel .search-input .el-input__suffix {\n padding: 10px 5px;\n}\n.ui-component-panel .el-collapse-item > div:first-of-type {\n border-bottom: 1px solid #d9dbdd;\n margin-bottom: 10px;\n}\n.ui-component-panel .el-collapse-item__header {\n background: #ffffff;\n color: #070303;\n height: 25px;\n line-height: 25px;\n padding-left: 10px;\n font-size: 12px;\n}\n.ui-component-panel .el-collapse-item__header i {\n margin-right: 5px;\n font-size: 14px;\n}\n.ui-component-panel .el-collapse-item__wrap {\n background: #ffffff;\n border-bottom: 0;\n}\n.ui-component-panel .el-collapse-item__wrap .el-collapse-item__content {\n padding: 10px;\n display: flex;\n flex-wrap: wrap;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item {\n display: flex;\n overflow: hidden;\n text-overflow: ellipsis;\n margin: 5px 10px;\n box-sizing: border-box;\n color: #070303;\n flex-direction: column;\n width: 42px;\n cursor: pointer;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item i {\n font-size: 20px;\n background: #fff;\n height: 40px;\n width: 40px;\n line-height: 40px;\n border-radius: 5px;\n color: #909090;\n border: 1px solid #d9dbdd;\n display: flex;\n justify-content: space-evenly;\n align-items: center;\n margin-bottom: 5px;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item i:hover {\n background: #2882e0;\n color: #fff;\n border-color: #4e8be1;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item span {\n font-size: 12px;\n text-align: center;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item .el-tooltip {\n width: 50px;\n height: 30px;\n line-height: 15px;\n display: block;\n white-space: normal;\n margin: 0;\n}\n.m-editor-resizer {\n border-left: 1px solid transparent;\n border-right: 1px solid transparent;\n width: 8px;\n margin: 0 -5px;\n height: 100%;\n opacity: 0.9;\n background: padding-box #d8dee8;\n box-sizing: border-box;\n cursor: col-resize;\n z-index: 1;\n}\n.m-editor-resizer:hover {\n border-color: #d8dee8;\n}\n.m-editor-resizer .icon-container {\n visibility: hidden;\n opacity: 0;\n transition: opacity 0.4s;\n width: 20px;\n height: 120px;\n line-height: 120px;\n text-align: center;\n background: #d8dee8;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n cursor: pointer;\n}\n.m-editor-resizer .icon-container.position-left {\n transform: translate(calc(-100% - 4px), -50%);\n}\n.m-editor-resizer .icon-container.position-right {\n transform: translate(calc(100% + 4px), -50%);\n}\n.m-editor-resizer .icon {\n color: #fff;\n font-size: 18px;\n}\n.magic-editor-resizer:hover .icon-container {\n visibility: visible;\n opacity: 1;\n}\n.m-editor-workspace {\n height: 100%;\n width: 100%;\n user-select: none;\n}\n.m-editor-workspace:focus-visible {\n outline: 0;\n}\n.m-editor-page-bar {\n position: fixed;\n bottom: 0;\n left: 0;\n display: flex;\n width: 100%;\n height: 32px;\n line-height: 32px;\n color: #070303;\n background-color: #f3f3f3;\n border-top: 1px solid #d9dbdd;\n z-index: 2;\n overflow: hidden;\n}\n.m-editor-page-bar-items {\n display: flex;\n transition: transform 0.3s;\n}\n.m-editor-page-bar-item {\n padding: 0 10px;\n cursor: pointer;\n border-right: 1px solid #d9dbdd;\n display: flex;\n justify-items: center;\n align-items: center;\n background-color: #f3f3f3;\n white-space: nowrap;\n}\n.m-editor-page-bar-item.active {\n background-color: #fff;\n cursor: text;\n}\n.m-editor-page-bar-item.active .m-editor-page-bar-menu-icon {\n cursor: pointer;\n}\n.m-editor-page-bar-item-icon {\n position: relative;\n z-index: 1;\n}\n.m-editor-page-bar-item-title {\n max-width: 150px;\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n}\n.page-bar-popover.el-popper.el-popover {\n padding: 10px 0;\n}\n.page-bar-popover .menu-item {\n cursor: pointer;\n transition: all 0.2s ease 0s;\n padding: 5px 14px;\n}\n.page-bar-popover .menu-item .el-button--text,\n.page-bar-popover .menu-item i {\n color: #070303;\n}\n.page-bar-popover .menu-item:hover {\n background-color: #f3f5f9;\n}\n.m-editor-props-panel {\n padding: 0 10px;\n}\n.m-editor-props-panel.small .el-form-item__label {\n font-size: 12px;\n}\n.m-editor-props-panel.small .m-fieldset legend {\n font-size: 12px;\n}\n.m-editor-props-panel.small .el-tabs__item {\n font-size: 12px;\n}\n.m-editor-props-panel .el-input__wrapper {\n border-radius: 0;\n}\n.m-editor-props-panel-popper.small span,\n.m-editor-props-panel-popper.small a,\n.m-editor-props-panel-popper.small p {\n font-size: 12px;\n}\n.magic-editor-content-menu {\n position: fixed;\n font-size: 12px;\n background: #fff;\n box-shadow: 0 2px 8px 2px rgba(68, 73, 77, 0.16);\n z-index: 9999;\n transform-origin: 0% 0%;\n font-weight: 600;\n padding: 4px 0px;\n overflow: auto;\n max-height: 100%;\n}\n.magic-editor-content-menu .menu-item {\n color: #333;\n display: flex;\n -webkit-box-align: center;\n align-items: center;\n cursor: pointer;\n min-width: 140px;\n transition: all 0.2s ease 0s;\n padding: 5px 14px;\n border-left: 2px solid transparent;\n}\n.magic-editor-content-menu .menu-item .el-button {\n width: 100%;\n justify-content: flex-start;\n}\n.magic-editor-content-menu .menu-item .el-button--text,\n.magic-editor-content-menu .menu-item i {\n color: #070303;\n}\n.magic-editor-content-menu .menu-item.divider {\n padding: 0 14px;\n}\n.magic-editor-content-menu .menu-item.divider .el-divider {\n margin: 0;\n}\n.magic-editor-content-menu .menu-item:hover {\n background-color: #f3f5f9;\n}\n.m-editor-stage {\n position: relative;\n width: 100%;\n height: calc(100% - 32px);\n overflow: hidden;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.m-editor-stage-container {\n width: 100%;\n height: 100%;\n z-index: 0;\n position: relative;\n border: 1px solid #d9dbdd;\n transition: transform 0.3s;\n box-sizing: content-box;\n}\n.m-editor-stage-container::-webkit-scrollbar {\n width: 0 !important;\n}\n.magic-code-editor {\n width: 100%;\n}\n.magic-code-editor .margin {\n margin: 0;\n}")();
|
|
4531
4006
|
|
|
4532
4007
|
const defaultInstallOpt = {};
|
|
4533
4008
|
var index = {
|
|
@@ -4543,5 +4018,5 @@ var index = {
|
|
|
4543
4018
|
}
|
|
4544
4019
|
};
|
|
4545
4020
|
|
|
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,
|
|
4021
|
+
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, generatePageName, generatePageNameByApp, getConfig, getDefaultPropsValue, getNodeIndex, getPageList, getPageNameList, historyService, info, initPosition, isFixed, log, propsService, setConfig, setLayout, toRelative, uiService, warn };
|
|
4547
4022
|
//# sourceMappingURL=tmagic-editor.es.js.map
|