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