@tmagic/editor 1.0.0-beta.11 → 1.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/coverage/clover.xml +1540 -0
- package/coverage/coverage-final.json +35 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +206 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/Editor.vue.html +787 -0
- package/coverage/lcov-report/src/components/ContentMenu.vue.html +406 -0
- package/coverage/lcov-report/src/components/Icon.vue.html +172 -0
- package/coverage/lcov-report/src/components/ScrollViewer.vue.html +283 -0
- package/coverage/lcov-report/src/components/ToolButton.vue.html +772 -0
- package/coverage/lcov-report/src/components/index.html +161 -0
- package/coverage/lcov-report/src/index.html +131 -0
- package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +214 -0
- package/coverage/lcov-report/src/layouts/Framework.vue.html +304 -0
- package/coverage/lcov-report/src/layouts/NavMenu.vue.html +208 -0
- package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +316 -0
- package/coverage/lcov-report/src/layouts/Resizer.vue.html +268 -0
- package/coverage/lcov-report/src/layouts/index.html +176 -0
- package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +358 -0
- package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +421 -0
- package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +775 -0
- package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +343 -0
- package/coverage/lcov-report/src/layouts/sidebar/index.html +161 -0
- package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +718 -0
- package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +757 -0
- package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +532 -0
- package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +586 -0
- package/coverage/lcov-report/src/layouts/workspace/index.html +161 -0
- package/coverage/lcov-report/src/services/BaseService.ts.html +643 -0
- package/coverage/lcov-report/src/services/componentList.ts.html +229 -0
- package/coverage/lcov-report/src/services/editor.ts.html +2077 -0
- package/coverage/lcov-report/src/services/events.ts.html +331 -0
- package/coverage/lcov-report/src/services/history.ts.html +478 -0
- package/coverage/lcov-report/src/services/index.html +206 -0
- package/coverage/lcov-report/src/services/props.ts.html +415 -0
- package/coverage/lcov-report/src/services/ui.ts.html +514 -0
- package/coverage/lcov-report/src/type.ts.html +844 -0
- package/coverage/lcov-report/src/utils/compose.ts.html +184 -0
- package/coverage/lcov-report/src/utils/config.ts.html +172 -0
- package/coverage/lcov-report/src/utils/editor.ts.html +838 -0
- package/coverage/lcov-report/src/utils/index.html +221 -0
- package/coverage/lcov-report/src/utils/index.ts.html +151 -0
- package/coverage/lcov-report/src/utils/logger.ts.html +226 -0
- package/coverage/lcov-report/src/utils/props.ts.html +796 -0
- package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +733 -0
- package/coverage/lcov-report/src/utils/undo-redo.ts.html +313 -0
- package/coverage/lcov.info +3676 -0
- package/dist/style.css +42 -20
- package/dist/tmagic-editor.es.js +972 -599
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +974 -601
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/Editor.vue.d.ts +1 -1
- package/dist/types/src/components/ToolButton.vue.d.ts +12 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +2 -1
- package/dist/types/src/layouts/workspace/PageBar.vue.d.ts +2 -0
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +2 -1
- package/dist/types/src/services/editor.d.ts +5 -2
- package/dist/types/src/services/history.d.ts +1 -0
- package/dist/types/src/services/props.d.ts +2 -2
- package/dist/types/src/services/ui.d.ts +1 -0
- package/dist/types/src/type.d.ts +9 -9
- package/dist/types/src/utils/editor.d.ts +4 -3
- package/dist/types/src/utils/polyfills.d.ts +0 -0
- package/package.json +29 -9
- package/src/components/ContentMenu.vue +107 -0
- package/src/components/ScrollViewer.vue +1 -1
- package/src/components/ToolButton.vue +69 -30
- package/src/index.ts +2 -0
- package/src/layouts/Framework.vue +6 -6
- package/src/layouts/PropsPanel.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +25 -3
- package/src/layouts/sidebar/LayerMenu.vue +91 -71
- package/src/layouts/sidebar/LayerPanel.vue +23 -49
- package/src/layouts/workspace/PageBar.vue +35 -6
- package/src/layouts/workspace/Stage.vue +41 -44
- package/src/layouts/workspace/ViewerMenu.vue +104 -67
- package/src/layouts/workspace/Workspace.vue +106 -3
- package/src/services/BaseService.ts +1 -1
- package/src/services/editor.ts +104 -12
- package/src/services/history.ts +7 -0
- package/src/services/props.ts +3 -3
- package/src/services/ui.ts +5 -0
- package/src/theme/common/var.scss +1 -0
- package/src/theme/component-list-panel.scss +2 -0
- package/src/theme/content-menu.scss +33 -26
- package/src/theme/layer-panel.scss +2 -1
- package/src/theme/page-bar.scss +22 -1
- package/src/type.ts +9 -9
- package/src/utils/editor.ts +31 -6
- package/{vite.config.ts → src/utils/polyfills.ts} +4 -12
- package/src/utils/props.ts +20 -1
- package/dist/types/src/layouts/sidebar/LayerPanel.vue.d.ts +0 -980
- package/dist/types/src/layouts/workspace/Stage.vue.d.ts +0 -188
- package/dist/types/src/layouts/workspace/ViewerMenu.vue.d.ts +0 -18
- package/tsconfig.json +0 -9
package/dist/tmagic-editor.es.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, createElementBlock, createElementVNode, toDisplayString, withModifiers, createCommentVNode, watch, onMounted, onUnmounted, reactive, toRaw, createVNode, withCtx, renderSlot, Fragment, normalizeClass, resolveDynamicComponent, renderList, createTextVNode, normalizeProps, mergeProps, getCurrentInstance,
|
|
1
|
+
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, createElementBlock, createElementVNode, toDisplayString, withModifiers, createCommentVNode, watch, onMounted, onUnmounted, reactive, toRaw, createVNode, withCtx, renderSlot, Fragment, normalizeClass, resolveDynamicComponent, markRaw, renderList, createTextVNode, normalizeProps, mergeProps, getCurrentInstance, nextTick, withDirectives, Teleport, vShow, toHandlers, createSlots, provide } from 'vue';
|
|
2
2
|
import serialize from 'serialize-javascript';
|
|
3
3
|
import * as monaco from 'monaco-editor';
|
|
4
|
-
import { Plus, Edit, ArrowDown, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Delete, Files, Coin, ArrowLeftBold, ArrowRightBold, CaretBottom } from '@element-plus/icons';
|
|
4
|
+
import { Plus, Edit, ArrowDown, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Delete, Files, DocumentCopy, Coin, ArrowLeftBold, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons';
|
|
5
5
|
import { NodeType } from '@tmagic/schema';
|
|
6
|
-
import { cloneDeep,
|
|
7
|
-
import { toLine, isPop, getNodePath } from '@tmagic/utils';
|
|
6
|
+
import { cloneDeep, mergeWith, random, throttle } from 'lodash-es';
|
|
7
|
+
import { toLine, isPop, getNodePath, isNumber, isPage } from '@tmagic/utils';
|
|
8
8
|
import { EventEmitter as EventEmitter$2 } from 'events';
|
|
9
9
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
10
10
|
import { ElMessage } from 'element-plus';
|
|
11
|
+
import KeyController from 'keycon';
|
|
11
12
|
import StageCore from '@tmagic/stage';
|
|
12
13
|
|
|
14
|
+
if (typeof window.global === "undefined") {
|
|
15
|
+
window.global = window;
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
var _export_sfc = (sfc, props) => {
|
|
14
19
|
const target = sfc.__vccOpts || sfc;
|
|
15
20
|
for (const [key, val] of props) {
|
|
@@ -18,7 +23,7 @@ var _export_sfc = (sfc, props) => {
|
|
|
18
23
|
return target;
|
|
19
24
|
};
|
|
20
25
|
|
|
21
|
-
const _sfc_main$
|
|
26
|
+
const _sfc_main$l = defineComponent({
|
|
22
27
|
name: "m-fields-vs-code",
|
|
23
28
|
props: ["model", "name", "config", "prop"],
|
|
24
29
|
emits: ["change"],
|
|
@@ -35,7 +40,7 @@ const _sfc_main$k = defineComponent({
|
|
|
35
40
|
};
|
|
36
41
|
}
|
|
37
42
|
});
|
|
38
|
-
function _sfc_render$
|
|
43
|
+
function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) {
|
|
39
44
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
40
45
|
return openBlock(), createBlock(_component_magic_code_editor, {
|
|
41
46
|
style: normalizeStyle(`height: ${_ctx.height}`),
|
|
@@ -44,9 +49,9 @@ function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
44
49
|
onSave: _ctx.save
|
|
45
50
|
}, null, 8, ["style", "init-values", "language", "onSave"]);
|
|
46
51
|
}
|
|
47
|
-
var Code = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
52
|
+
var Code = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$l]]);
|
|
48
53
|
|
|
49
|
-
const _sfc_main$
|
|
54
|
+
const _sfc_main$k = defineComponent({
|
|
50
55
|
name: "m-fields-code-link",
|
|
51
56
|
props: {
|
|
52
57
|
config: {
|
|
@@ -101,7 +106,7 @@ const _sfc_main$j = defineComponent({
|
|
|
101
106
|
};
|
|
102
107
|
}
|
|
103
108
|
});
|
|
104
|
-
function _sfc_render$
|
|
109
|
+
function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
|
|
105
110
|
const _component_m_fields_link = resolveComponent("m-fields-link");
|
|
106
111
|
return openBlock(), createBlock(_component_m_fields_link, {
|
|
107
112
|
config: _ctx.formConfig,
|
|
@@ -110,11 +115,11 @@ function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
110
115
|
onChange: _ctx.changeHandler
|
|
111
116
|
}, null, 8, ["config", "model", "onChange"]);
|
|
112
117
|
}
|
|
113
|
-
var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
118
|
+
var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$k]]);
|
|
114
119
|
|
|
115
120
|
var UISelect_vue_vue_type_style_index_0_lang = '';
|
|
116
121
|
|
|
117
|
-
const _sfc_main$
|
|
122
|
+
const _sfc_main$j = defineComponent({
|
|
118
123
|
name: "m-fields-ui-select",
|
|
119
124
|
props: {
|
|
120
125
|
labelWidth: String,
|
|
@@ -176,25 +181,25 @@ const _sfc_main$i = defineComponent({
|
|
|
176
181
|
};
|
|
177
182
|
}
|
|
178
183
|
});
|
|
179
|
-
const _hoisted_1$
|
|
184
|
+
const _hoisted_1$c = /* @__PURE__ */ createElementVNode("i", {
|
|
180
185
|
class: "el-icon-delete",
|
|
181
186
|
style: { "color": "rgb(221, 75, 57)" }
|
|
182
187
|
}, "\u53D6\u6D88", -1);
|
|
183
|
-
const _hoisted_2$
|
|
184
|
-
_hoisted_1$
|
|
188
|
+
const _hoisted_2$5 = [
|
|
189
|
+
_hoisted_1$c
|
|
185
190
|
];
|
|
186
|
-
const _hoisted_3$
|
|
187
|
-
function _sfc_render$
|
|
191
|
+
const _hoisted_3$3 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-thumb" }, null, -1);
|
|
192
|
+
function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
|
|
188
193
|
return _ctx.uiSelectMode ? (openBlock(), createElementBlock("div", {
|
|
189
194
|
key: 0,
|
|
190
195
|
class: "m-fields-ui-select",
|
|
191
196
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.cancelHandler && _ctx.cancelHandler(...args))
|
|
192
|
-
}, _hoisted_2$
|
|
197
|
+
}, _hoisted_2$5)) : (openBlock(), createElementBlock("div", {
|
|
193
198
|
key: 1,
|
|
194
199
|
class: "m-fields-ui-select",
|
|
195
200
|
onClick: _cache[2] || (_cache[2] = (...args) => _ctx.startSelect && _ctx.startSelect(...args))
|
|
196
201
|
}, [
|
|
197
|
-
_hoisted_3$
|
|
202
|
+
_hoisted_3$3,
|
|
198
203
|
createElementVNode("span", null, toDisplayString(_ctx.val ? _ctx.toName + "_" + _ctx.val : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1),
|
|
199
204
|
_ctx.val ? (openBlock(), createElementBlock("i", {
|
|
200
205
|
key: 0,
|
|
@@ -203,7 +208,7 @@ function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
203
208
|
})) : createCommentVNode("", true)
|
|
204
209
|
]));
|
|
205
210
|
}
|
|
206
|
-
var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
211
|
+
var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$j]]);
|
|
207
212
|
|
|
208
213
|
const toString = (v, language) => {
|
|
209
214
|
let value = "";
|
|
@@ -220,7 +225,7 @@ const toString = (v, language) => {
|
|
|
220
225
|
}
|
|
221
226
|
return value;
|
|
222
227
|
};
|
|
223
|
-
const _sfc_main$
|
|
228
|
+
const _sfc_main$i = defineComponent({
|
|
224
229
|
name: "magic-code-editor",
|
|
225
230
|
props: {
|
|
226
231
|
initValues: {
|
|
@@ -325,14 +330,14 @@ const _sfc_main$h = defineComponent({
|
|
|
325
330
|
};
|
|
326
331
|
}
|
|
327
332
|
});
|
|
328
|
-
const _hoisted_1$
|
|
333
|
+
const _hoisted_1$b = {
|
|
329
334
|
ref: "codeEditor",
|
|
330
335
|
class: "magic-code-editor"
|
|
331
336
|
};
|
|
332
|
-
function _sfc_render$
|
|
333
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
337
|
+
function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
338
|
+
return openBlock(), createElementBlock("div", _hoisted_1$b, null, 512);
|
|
334
339
|
}
|
|
335
|
-
var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
340
|
+
var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
|
|
336
341
|
|
|
337
342
|
let $TMAGIC_EDITOR = {};
|
|
338
343
|
const setConfig = (option) => {
|
|
@@ -341,9 +346,6 @@ const setConfig = (option) => {
|
|
|
341
346
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
342
347
|
|
|
343
348
|
class UndoRedo {
|
|
344
|
-
elementList;
|
|
345
|
-
listCursor;
|
|
346
|
-
listMaxSize;
|
|
347
349
|
constructor(listMaxSize = 200) {
|
|
348
350
|
const minListMaxSize = 2;
|
|
349
351
|
this.elementList = [];
|
|
@@ -434,7 +436,7 @@ const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethod
|
|
|
434
436
|
}
|
|
435
437
|
let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
|
|
436
438
|
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
437
|
-
returnValue = await afterMethod(...beforeArgs
|
|
439
|
+
returnValue = await afterMethod(returnValue, ...beforeArgs);
|
|
438
440
|
if (isError(returnValue))
|
|
439
441
|
throw returnValue;
|
|
440
442
|
}
|
|
@@ -444,12 +446,12 @@ const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethod
|
|
|
444
446
|
}
|
|
445
447
|
};
|
|
446
448
|
class BaseService extends EventEmitter$2 {
|
|
447
|
-
pluginOptionsList = {};
|
|
448
|
-
middleware = {};
|
|
449
|
-
taskList = [];
|
|
450
|
-
doingTask = false;
|
|
451
449
|
constructor(methods = [], serialMethods = []) {
|
|
452
450
|
super();
|
|
451
|
+
this.pluginOptionsList = {};
|
|
452
|
+
this.middleware = {};
|
|
453
|
+
this.taskList = [];
|
|
454
|
+
this.doingTask = false;
|
|
453
455
|
methods.forEach((propertyName) => {
|
|
454
456
|
const scope = this;
|
|
455
457
|
const sourceMethod = scope[propertyName];
|
|
@@ -506,16 +508,22 @@ class BaseService extends EventEmitter$2 {
|
|
|
506
508
|
}
|
|
507
509
|
|
|
508
510
|
class History extends BaseService {
|
|
509
|
-
state = reactive({
|
|
510
|
-
pageSteps: {},
|
|
511
|
-
pageId: void 0,
|
|
512
|
-
canRedo: false,
|
|
513
|
-
canUndo: false
|
|
514
|
-
});
|
|
515
511
|
constructor() {
|
|
516
512
|
super([]);
|
|
513
|
+
this.state = reactive({
|
|
514
|
+
pageSteps: {},
|
|
515
|
+
pageId: void 0,
|
|
516
|
+
canRedo: false,
|
|
517
|
+
canUndo: false
|
|
518
|
+
});
|
|
517
519
|
this.on("change", this.setCanUndoRedo);
|
|
518
520
|
}
|
|
521
|
+
reset() {
|
|
522
|
+
this.state.pageSteps = {};
|
|
523
|
+
this.state.pageId = void 0;
|
|
524
|
+
this.state.canRedo = false;
|
|
525
|
+
this.state.canUndo = false;
|
|
526
|
+
}
|
|
519
527
|
changePage(page) {
|
|
520
528
|
if (!page)
|
|
521
529
|
return;
|
|
@@ -579,12 +587,12 @@ class History extends BaseService {
|
|
|
579
587
|
var historyService = new History();
|
|
580
588
|
|
|
581
589
|
class Props extends BaseService {
|
|
582
|
-
state = reactive({
|
|
583
|
-
propsConfigMap: {},
|
|
584
|
-
propsValueMap: {}
|
|
585
|
-
});
|
|
586
590
|
constructor() {
|
|
587
591
|
super(["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue"]);
|
|
592
|
+
this.state = reactive({
|
|
593
|
+
propsConfigMap: {},
|
|
594
|
+
propsValueMap: {}
|
|
595
|
+
});
|
|
588
596
|
}
|
|
589
597
|
setPropsConfigs(configs) {
|
|
590
598
|
Object.keys(configs).forEach((type) => {
|
|
@@ -609,7 +617,7 @@ class Props extends BaseService {
|
|
|
609
617
|
setPropsValue(type, value) {
|
|
610
618
|
this.state.propsValueMap[type] = value;
|
|
611
619
|
}
|
|
612
|
-
async getPropsValue(type) {
|
|
620
|
+
async getPropsValue(type, defaultValue = {}) {
|
|
613
621
|
if (type === "area") {
|
|
614
622
|
const value = await this.getPropsValue("button");
|
|
615
623
|
value.className = "action-area";
|
|
@@ -621,7 +629,7 @@ class Props extends BaseService {
|
|
|
621
629
|
}
|
|
622
630
|
return cloneDeep({
|
|
623
631
|
...getDefaultPropsValue(type),
|
|
624
|
-
...this.state.propsValueMap[type] || {}
|
|
632
|
+
...mergeWith(this.state.propsValueMap[type] || {}, defaultValue)
|
|
625
633
|
});
|
|
626
634
|
}
|
|
627
635
|
}
|
|
@@ -682,7 +690,7 @@ const updatePopId = (oldId, popId, pageConfig) => {
|
|
|
682
690
|
};
|
|
683
691
|
const setNewItemId = (config, parent) => {
|
|
684
692
|
const oldId = config.id;
|
|
685
|
-
config.id = generateId(config.type);
|
|
693
|
+
config.id = generateId(config.type || "component");
|
|
686
694
|
config.name = `${config.name?.replace(/_(\d+)$/, "")}_${config.id}`;
|
|
687
695
|
if (isPop(config) && parent?.type === NodeType.PAGE) {
|
|
688
696
|
updatePopId(oldId, config.id, parent);
|
|
@@ -705,11 +713,25 @@ const toRelative = (node) => {
|
|
|
705
713
|
};
|
|
706
714
|
return node;
|
|
707
715
|
};
|
|
708
|
-
const
|
|
716
|
+
const setTop2Middle = (node, parentNode, stage) => {
|
|
717
|
+
const style = node.style || {};
|
|
718
|
+
const height = style.height || 0;
|
|
719
|
+
if (!stage || typeof style.top !== "undefined" || !parentNode.style || !isNumber(height))
|
|
720
|
+
return style;
|
|
721
|
+
const { height: parentHeight } = parentNode.style;
|
|
722
|
+
if (isPage(parentNode)) {
|
|
723
|
+
const { scrollTop = 0, wrapperHeight } = stage.mask;
|
|
724
|
+
style.top = (wrapperHeight - height) / 2 + scrollTop;
|
|
725
|
+
} else {
|
|
726
|
+
style.top = (parentHeight - height) / 2;
|
|
727
|
+
}
|
|
728
|
+
return style;
|
|
729
|
+
};
|
|
730
|
+
const initPosition = (node, layout, parentNode, stage) => {
|
|
709
731
|
if (layout === Layout.ABSOLUTE) {
|
|
710
732
|
node.style = {
|
|
711
733
|
position: "absolute",
|
|
712
|
-
...node
|
|
734
|
+
...setTop2Middle(node, parentNode, stage)
|
|
713
735
|
};
|
|
714
736
|
return node;
|
|
715
737
|
}
|
|
@@ -756,7 +778,9 @@ const Fixed2Other = async (node, root, getLayout) => {
|
|
|
756
778
|
const cur = path.pop();
|
|
757
779
|
const offset = {
|
|
758
780
|
left: cur?.style?.left || 0,
|
|
759
|
-
top: cur?.style?.top || 0
|
|
781
|
+
top: cur?.style?.top || 0,
|
|
782
|
+
right: "",
|
|
783
|
+
bottom: ""
|
|
760
784
|
};
|
|
761
785
|
path.forEach((value) => {
|
|
762
786
|
offset.left = offset.left - globalThis.parseFloat(value.style?.left || 0);
|
|
@@ -790,16 +814,6 @@ const error = (...args) => {
|
|
|
790
814
|
};
|
|
791
815
|
|
|
792
816
|
class Editor$1 extends BaseService {
|
|
793
|
-
isHistoryStateChange = false;
|
|
794
|
-
state = reactive({
|
|
795
|
-
root: null,
|
|
796
|
-
page: null,
|
|
797
|
-
parent: null,
|
|
798
|
-
node: null,
|
|
799
|
-
stage: null,
|
|
800
|
-
highlightNode: null,
|
|
801
|
-
modifiedNodeIds: /* @__PURE__ */ new Map()
|
|
802
|
-
});
|
|
803
817
|
constructor() {
|
|
804
818
|
super([
|
|
805
819
|
"getLayout",
|
|
@@ -812,14 +826,27 @@ class Editor$1 extends BaseService {
|
|
|
812
826
|
"paste",
|
|
813
827
|
"alignCenter",
|
|
814
828
|
"moveLayer",
|
|
829
|
+
"move",
|
|
815
830
|
"undo",
|
|
816
831
|
"redo",
|
|
817
832
|
"highlight"
|
|
818
833
|
], ["select", "update", "moveLayer"]);
|
|
834
|
+
this.isHistoryStateChange = false;
|
|
835
|
+
this.state = reactive({
|
|
836
|
+
root: null,
|
|
837
|
+
page: null,
|
|
838
|
+
parent: null,
|
|
839
|
+
node: null,
|
|
840
|
+
stage: null,
|
|
841
|
+
highlightNode: null,
|
|
842
|
+
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
843
|
+
pageLength: 0
|
|
844
|
+
});
|
|
819
845
|
}
|
|
820
846
|
set(name, value) {
|
|
821
847
|
this.state[name] = value;
|
|
822
848
|
if (name === "root") {
|
|
849
|
+
this.state.pageLength = value?.items?.length || 0;
|
|
823
850
|
this.emit("root-change", value);
|
|
824
851
|
}
|
|
825
852
|
}
|
|
@@ -827,7 +854,7 @@ class Editor$1 extends BaseService {
|
|
|
827
854
|
return this.state[name];
|
|
828
855
|
}
|
|
829
856
|
getNodeInfo(id) {
|
|
830
|
-
const root = this.get("root");
|
|
857
|
+
const root = toRaw(this.get("root"));
|
|
831
858
|
if (!root)
|
|
832
859
|
return {};
|
|
833
860
|
if (id === root.id) {
|
|
@@ -858,11 +885,13 @@ class Editor$1 extends BaseService {
|
|
|
858
885
|
const { parent } = this.getNodeInfo(id);
|
|
859
886
|
return parent;
|
|
860
887
|
}
|
|
861
|
-
async getLayout(node) {
|
|
862
|
-
if (node
|
|
863
|
-
return
|
|
888
|
+
async getLayout(parent, node) {
|
|
889
|
+
if (node && typeof node !== "function" && isFixed(node))
|
|
890
|
+
return Layout.FIXED;
|
|
891
|
+
if (parent.layout) {
|
|
892
|
+
return parent.layout;
|
|
864
893
|
}
|
|
865
|
-
if (!
|
|
894
|
+
if (!parent.style?.position) {
|
|
866
895
|
return Layout.RELATIVE;
|
|
867
896
|
}
|
|
868
897
|
return Layout.ABSOLUTE;
|
|
@@ -877,8 +906,31 @@ class Editor$1 extends BaseService {
|
|
|
877
906
|
} else {
|
|
878
907
|
historyService.empty();
|
|
879
908
|
}
|
|
909
|
+
this.emit("select", node);
|
|
880
910
|
return node;
|
|
881
911
|
}
|
|
912
|
+
async selectNextNode() {
|
|
913
|
+
const node = toRaw(this.get("node"));
|
|
914
|
+
if (!node || isPage(node) || node.type === NodeType.ROOT)
|
|
915
|
+
return node;
|
|
916
|
+
const parent = toRaw(this.getParentById(node.id));
|
|
917
|
+
if (!parent)
|
|
918
|
+
return node;
|
|
919
|
+
const index = getNodeIndex(node, parent);
|
|
920
|
+
const nextNode = parent.items[index + 1] || parent.items[0];
|
|
921
|
+
await this.select(nextNode);
|
|
922
|
+
this.get("stage")?.select(nextNode.id);
|
|
923
|
+
return nextNode;
|
|
924
|
+
}
|
|
925
|
+
async selectNextPage() {
|
|
926
|
+
const root = toRaw(this.get("root"));
|
|
927
|
+
const page = toRaw(this.get("page"));
|
|
928
|
+
const index = getNodeIndex(page, root);
|
|
929
|
+
const nextPage = root.items[index + 1] || root.items[0];
|
|
930
|
+
await this.select(nextPage);
|
|
931
|
+
this.get("stage")?.select(nextPage.id);
|
|
932
|
+
return nextPage;
|
|
933
|
+
}
|
|
882
934
|
highlight(config2) {
|
|
883
935
|
const { node } = this.selectedConfigExceptionHandler(config2);
|
|
884
936
|
const currentHighlightNode = this.get("highlightNode");
|
|
@@ -886,10 +938,12 @@ class Editor$1 extends BaseService {
|
|
|
886
938
|
return;
|
|
887
939
|
this.set("highlightNode", node);
|
|
888
940
|
}
|
|
889
|
-
async add(
|
|
941
|
+
async add(addNode, parent) {
|
|
942
|
+
const { type, ...config2 } = addNode;
|
|
890
943
|
const curNode = this.get("node");
|
|
891
944
|
let parentNode;
|
|
892
|
-
|
|
945
|
+
const isPage2 = type === NodeType.PAGE;
|
|
946
|
+
if (isPage2) {
|
|
893
947
|
parentNode = this.get("root");
|
|
894
948
|
} else if (parent && typeof parent !== "function") {
|
|
895
949
|
parentNode = parent;
|
|
@@ -900,8 +954,8 @@ class Editor$1 extends BaseService {
|
|
|
900
954
|
}
|
|
901
955
|
if (!parentNode)
|
|
902
956
|
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
903
|
-
const layout = await this.getLayout(parentNode);
|
|
904
|
-
const newNode = initPosition({ ...toRaw(await propsService.getPropsValue(type
|
|
957
|
+
const layout = await this.getLayout(toRaw(parentNode), addNode);
|
|
958
|
+
const newNode = initPosition({ ...toRaw(await propsService.getPropsValue(type, config2)) }, layout, parentNode, this.get("stage"));
|
|
905
959
|
if ((parentNode?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && newNode.type !== NodeType.PAGE) {
|
|
906
960
|
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
907
961
|
}
|
|
@@ -914,6 +968,10 @@ class Editor$1 extends BaseService {
|
|
|
914
968
|
this.pushHistoryState();
|
|
915
969
|
}
|
|
916
970
|
stage?.select(newNode.id);
|
|
971
|
+
if (isPage2) {
|
|
972
|
+
this.state.pageLength += 1;
|
|
973
|
+
}
|
|
974
|
+
this.emit("add", newNode);
|
|
917
975
|
return newNode;
|
|
918
976
|
}
|
|
919
977
|
async remove(node) {
|
|
@@ -932,9 +990,20 @@ class Editor$1 extends BaseService {
|
|
|
932
990
|
const stage = this.get("stage");
|
|
933
991
|
stage?.remove({ id: node.id, root: this.get("root") });
|
|
934
992
|
if (node.type === NodeType.PAGE) {
|
|
993
|
+
this.state.pageLength -= 1;
|
|
935
994
|
if (root.items[0]) {
|
|
936
995
|
await this.select(root.items[0]);
|
|
937
996
|
stage?.select(root.items[0].id);
|
|
997
|
+
} else {
|
|
998
|
+
this.set("node", null);
|
|
999
|
+
this.set("parent", null);
|
|
1000
|
+
this.set("page", null);
|
|
1001
|
+
this.set("stage", null);
|
|
1002
|
+
this.set("highlightNode", null);
|
|
1003
|
+
this.resetModifiedNodeId();
|
|
1004
|
+
historyService.reset();
|
|
1005
|
+
this.emit("remove", node);
|
|
1006
|
+
return node;
|
|
938
1007
|
}
|
|
939
1008
|
} else {
|
|
940
1009
|
await this.select(parent);
|
|
@@ -942,6 +1011,7 @@ class Editor$1 extends BaseService {
|
|
|
942
1011
|
}
|
|
943
1012
|
this.addModifiedNodeId(parent.id);
|
|
944
1013
|
this.pushHistoryState();
|
|
1014
|
+
this.emit("remove", node);
|
|
945
1015
|
return node;
|
|
946
1016
|
}
|
|
947
1017
|
async update(config2) {
|
|
@@ -985,6 +1055,7 @@ class Editor$1 extends BaseService {
|
|
|
985
1055
|
}
|
|
986
1056
|
this.addModifiedNodeId(newConfig.id);
|
|
987
1057
|
this.pushHistoryState();
|
|
1058
|
+
this.emit("update", newConfig);
|
|
988
1059
|
return newConfig;
|
|
989
1060
|
}
|
|
990
1061
|
async sort(id1, id2) {
|
|
@@ -1028,7 +1099,7 @@ class Editor$1 extends BaseService {
|
|
|
1028
1099
|
async alignCenter(config2) {
|
|
1029
1100
|
const parent = this.get("parent");
|
|
1030
1101
|
const node = this.get("node");
|
|
1031
|
-
const layout = await this.getLayout(parent);
|
|
1102
|
+
const layout = await this.getLayout(toRaw(parent), toRaw(node));
|
|
1032
1103
|
if (layout === Layout.RELATIVE) {
|
|
1033
1104
|
return;
|
|
1034
1105
|
}
|
|
@@ -1065,6 +1136,26 @@ class Editor$1 extends BaseService {
|
|
|
1065
1136
|
await this.changeHistoryState(value);
|
|
1066
1137
|
return value;
|
|
1067
1138
|
}
|
|
1139
|
+
async move(left, top) {
|
|
1140
|
+
const node = toRaw(this.get("node"));
|
|
1141
|
+
if (!node || isPage(node))
|
|
1142
|
+
return;
|
|
1143
|
+
const { style, id } = node;
|
|
1144
|
+
if (!style || style.position !== "absolute")
|
|
1145
|
+
return;
|
|
1146
|
+
if (top && !isNumber(style.top))
|
|
1147
|
+
return;
|
|
1148
|
+
if (left && !isNumber(style.left))
|
|
1149
|
+
return;
|
|
1150
|
+
this.update({
|
|
1151
|
+
id,
|
|
1152
|
+
style: {
|
|
1153
|
+
...style,
|
|
1154
|
+
left: Number(style.left) + left,
|
|
1155
|
+
top: Number(style.top) + top
|
|
1156
|
+
}
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1068
1159
|
destroy() {
|
|
1069
1160
|
this.removeAllListeners();
|
|
1070
1161
|
this.set("root", null);
|
|
@@ -1294,6 +1385,25 @@ const fillConfig = (config = []) => [
|
|
|
1294
1385
|
defaultValue: "100% 100%"
|
|
1295
1386
|
}
|
|
1296
1387
|
]
|
|
1388
|
+
},
|
|
1389
|
+
{
|
|
1390
|
+
type: "fieldset",
|
|
1391
|
+
legend: "\u5B57\u4F53",
|
|
1392
|
+
items: [
|
|
1393
|
+
{
|
|
1394
|
+
name: "color",
|
|
1395
|
+
text: "\u989C\u8272",
|
|
1396
|
+
type: "colorPicker"
|
|
1397
|
+
},
|
|
1398
|
+
{
|
|
1399
|
+
name: "fontSize",
|
|
1400
|
+
text: "\u5927\u5C0F"
|
|
1401
|
+
},
|
|
1402
|
+
{
|
|
1403
|
+
name: "fontWeight",
|
|
1404
|
+
text: "\u7C97\u7EC6"
|
|
1405
|
+
}
|
|
1406
|
+
]
|
|
1297
1407
|
}
|
|
1298
1408
|
]
|
|
1299
1409
|
}
|
|
@@ -1326,7 +1436,7 @@ const fillConfig = (config = []) => [
|
|
|
1326
1436
|
type: "select",
|
|
1327
1437
|
options: (mForm, { model }) => {
|
|
1328
1438
|
const node = editorService.getNodeById(model.to);
|
|
1329
|
-
if (!node)
|
|
1439
|
+
if (!node?.type)
|
|
1330
1440
|
return [];
|
|
1331
1441
|
return eventsService.getMethod(node.type).map((option) => ({
|
|
1332
1442
|
text: option.label,
|
|
@@ -1361,7 +1471,7 @@ const getDefaultPropsValue = (type) => ({
|
|
|
1361
1471
|
name: type
|
|
1362
1472
|
});
|
|
1363
1473
|
|
|
1364
|
-
const _sfc_main$
|
|
1474
|
+
const _sfc_main$h = defineComponent({
|
|
1365
1475
|
components: { Plus },
|
|
1366
1476
|
setup() {
|
|
1367
1477
|
const services = inject("services");
|
|
@@ -1378,14 +1488,14 @@ const _sfc_main$g = defineComponent({
|
|
|
1378
1488
|
};
|
|
1379
1489
|
}
|
|
1380
1490
|
});
|
|
1381
|
-
const _hoisted_1$
|
|
1382
|
-
const _hoisted_2$
|
|
1383
|
-
const _hoisted_3$
|
|
1384
|
-
function _sfc_render$
|
|
1491
|
+
const _hoisted_1$a = { class: "m-editor-empty-panel" };
|
|
1492
|
+
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
1493
|
+
const _hoisted_3$2 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
1494
|
+
function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1385
1495
|
const _component_plus = resolveComponent("plus");
|
|
1386
1496
|
const _component_el_icon = resolveComponent("el-icon");
|
|
1387
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
1388
|
-
createElementVNode("div", _hoisted_2$
|
|
1497
|
+
return openBlock(), createElementBlock("div", _hoisted_1$a, [
|
|
1498
|
+
createElementVNode("div", _hoisted_2$4, [
|
|
1389
1499
|
createElementVNode("div", {
|
|
1390
1500
|
class: "m-editor-empty-button",
|
|
1391
1501
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
|
|
@@ -1398,12 +1508,12 @@ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1398
1508
|
_: 1
|
|
1399
1509
|
})
|
|
1400
1510
|
]),
|
|
1401
|
-
_hoisted_3$
|
|
1511
|
+
_hoisted_3$2
|
|
1402
1512
|
])
|
|
1403
1513
|
])
|
|
1404
1514
|
]);
|
|
1405
1515
|
}
|
|
1406
|
-
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1516
|
+
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
|
|
1407
1517
|
|
|
1408
1518
|
/*
|
|
1409
1519
|
Copyright (c) 2018 Daybrush
|
|
@@ -1807,8 +1917,8 @@ Copyright (c) 2019 Daybrush
|
|
|
1807
1917
|
name: gesto
|
|
1808
1918
|
license: MIT
|
|
1809
1919
|
author: Daybrush
|
|
1810
|
-
repository: git+https://github.com/daybrush/
|
|
1811
|
-
version: 1.
|
|
1920
|
+
repository: git+https://github.com/daybrush/gesto.git
|
|
1921
|
+
version: 1.7.0
|
|
1812
1922
|
*/
|
|
1813
1923
|
|
|
1814
1924
|
/*! *****************************************************************************
|
|
@@ -1977,19 +2087,6 @@ function () {
|
|
|
1977
2087
|
|
|
1978
2088
|
var __proto = ClientStore.prototype;
|
|
1979
2089
|
|
|
1980
|
-
__proto.addClients = function (clients) {
|
|
1981
|
-
if (clients === void 0) {
|
|
1982
|
-
clients = this.prevClients;
|
|
1983
|
-
}
|
|
1984
|
-
|
|
1985
|
-
var position = this.getPosition(clients);
|
|
1986
|
-
var deltaX = position.deltaX,
|
|
1987
|
-
deltaY = position.deltaY;
|
|
1988
|
-
this.movement += Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
1989
|
-
this.prevClients = clients;
|
|
1990
|
-
return position;
|
|
1991
|
-
};
|
|
1992
|
-
|
|
1993
2090
|
__proto.getAngle = function (clients) {
|
|
1994
2091
|
if (clients === void 0) {
|
|
1995
2092
|
clients = this.prevClients;
|
|
@@ -2006,8 +2103,17 @@ function () {
|
|
|
2006
2103
|
return getRotatiion(clients) - getRotatiion(this.startClients);
|
|
2007
2104
|
};
|
|
2008
2105
|
|
|
2009
|
-
__proto.getPosition = function (clients) {
|
|
2010
|
-
|
|
2106
|
+
__proto.getPosition = function (clients, isAdd) {
|
|
2107
|
+
if (clients === void 0) {
|
|
2108
|
+
clients = this.prevClients;
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
var position = getPosition(clients || this.prevClients, this.prevClients, this.startClients);
|
|
2112
|
+
var deltaX = position.deltaX,
|
|
2113
|
+
deltaY = position.deltaY;
|
|
2114
|
+
this.movement += Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
2115
|
+
this.prevClients = clients;
|
|
2116
|
+
return position;
|
|
2011
2117
|
};
|
|
2012
2118
|
|
|
2013
2119
|
__proto.getPositions = function (clients) {
|
|
@@ -2056,10 +2162,6 @@ function () {
|
|
|
2056
2162
|
client.clientX -= deltaX;
|
|
2057
2163
|
client.clientY -= deltaY;
|
|
2058
2164
|
});
|
|
2059
|
-
this.prevClients.forEach(function (client) {
|
|
2060
|
-
client.clientX -= deltaX;
|
|
2061
|
-
client.clientY -= deltaY;
|
|
2062
|
-
});
|
|
2063
2165
|
};
|
|
2064
2166
|
|
|
2065
2167
|
return ClientStore;
|
|
@@ -2098,6 +2200,7 @@ function (_super) {
|
|
|
2098
2200
|
_this.targets = [];
|
|
2099
2201
|
_this.prevTime = 0;
|
|
2100
2202
|
_this.doubleFlag = false;
|
|
2203
|
+
_this._dragFlag = false;
|
|
2101
2204
|
|
|
2102
2205
|
_this.onDragStart = function (e, isTrusted) {
|
|
2103
2206
|
if (isTrusted === void 0) {
|
|
@@ -2128,7 +2231,8 @@ function (_super) {
|
|
|
2128
2231
|
if (checkInput || activeElement === target) {
|
|
2129
2232
|
// force false or already focused.
|
|
2130
2233
|
return false;
|
|
2131
|
-
}
|
|
2234
|
+
} // no focus
|
|
2235
|
+
|
|
2132
2236
|
|
|
2133
2237
|
if (activeElement && hasContentEditable && activeElement.isContentEditable && activeElement.contains(target)) {
|
|
2134
2238
|
return false;
|
|
@@ -2144,6 +2248,7 @@ function (_super) {
|
|
|
2144
2248
|
_this.clientStores = [new ClientStore(getEventClients(e))];
|
|
2145
2249
|
_this.flag = true;
|
|
2146
2250
|
_this.isDrag = false;
|
|
2251
|
+
_this._dragFlag = true;
|
|
2147
2252
|
_this.datas = {};
|
|
2148
2253
|
|
|
2149
2254
|
if (preventRightClick && (e.which === 3 || e.button === 2)) {
|
|
@@ -2159,7 +2264,14 @@ function (_super) {
|
|
|
2159
2264
|
inputEvent: e,
|
|
2160
2265
|
isTrusted: isTrusted,
|
|
2161
2266
|
isDouble: _this.doubleFlag
|
|
2162
|
-
}, _this.getCurrentStore().getPosition()
|
|
2267
|
+
}, _this.getCurrentStore().getPosition(), {
|
|
2268
|
+
preventDefault: function () {
|
|
2269
|
+
e.preventDefault();
|
|
2270
|
+
},
|
|
2271
|
+
preventDrag: function () {
|
|
2272
|
+
_this._dragFlag = false;
|
|
2273
|
+
}
|
|
2274
|
+
}));
|
|
2163
2275
|
|
|
2164
2276
|
if (result === false) {
|
|
2165
2277
|
_this.initDrag();
|
|
@@ -2208,24 +2320,26 @@ function (_super) {
|
|
|
2208
2320
|
|
|
2209
2321
|
var result = _this.moveClients(clients, e, false);
|
|
2210
2322
|
|
|
2211
|
-
if (_this.
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2323
|
+
if (_this._dragFlag) {
|
|
2324
|
+
if (_this.pinchFlag || result.deltaX || result.deltaY) {
|
|
2325
|
+
var dragResult = _this.emit("drag", __assign({}, result, {
|
|
2326
|
+
isScroll: !!isScroll,
|
|
2327
|
+
inputEvent: e
|
|
2328
|
+
}));
|
|
2216
2329
|
|
|
2217
|
-
|
|
2218
|
-
|
|
2330
|
+
if (dragResult === false) {
|
|
2331
|
+
_this.stop();
|
|
2219
2332
|
|
|
2220
|
-
|
|
2333
|
+
return;
|
|
2334
|
+
}
|
|
2221
2335
|
}
|
|
2222
|
-
}
|
|
2223
2336
|
|
|
2224
|
-
|
|
2225
|
-
|
|
2337
|
+
if (_this.pinchFlag) {
|
|
2338
|
+
_this.onPinch(e, clients);
|
|
2339
|
+
}
|
|
2226
2340
|
}
|
|
2227
2341
|
|
|
2228
|
-
_this.getCurrentStore().
|
|
2342
|
+
_this.getCurrentStore().getPosition(clients, true);
|
|
2229
2343
|
};
|
|
2230
2344
|
|
|
2231
2345
|
_this.onDragEnd = function (e) {
|
|
@@ -2243,7 +2357,7 @@ function (_super) {
|
|
|
2243
2357
|
|
|
2244
2358
|
_this.flag = false;
|
|
2245
2359
|
|
|
2246
|
-
var position = _this.
|
|
2360
|
+
var position = _this._getPosition();
|
|
2247
2361
|
|
|
2248
2362
|
var currentTime = now();
|
|
2249
2363
|
var isDouble = !_this.isDrag && _this.doubleFlag;
|
|
@@ -2437,7 +2551,23 @@ function (_super) {
|
|
|
2437
2551
|
return this;
|
|
2438
2552
|
};
|
|
2439
2553
|
/**
|
|
2440
|
-
*
|
|
2554
|
+
* Get the current event state while dragging.
|
|
2555
|
+
*/
|
|
2556
|
+
|
|
2557
|
+
|
|
2558
|
+
__proto.getCurrentEvent = function (inputEvent) {
|
|
2559
|
+
return __assign({
|
|
2560
|
+
datas: this.datas
|
|
2561
|
+
}, this._getPosition(), {
|
|
2562
|
+
movement: this.getMovement(),
|
|
2563
|
+
isDrag: this.isDrag,
|
|
2564
|
+
isPinch: this.isPinch,
|
|
2565
|
+
isScroll: false,
|
|
2566
|
+
inputEvent: inputEvent
|
|
2567
|
+
});
|
|
2568
|
+
};
|
|
2569
|
+
/**
|
|
2570
|
+
* Get & Set the event data while dragging.
|
|
2441
2571
|
*/
|
|
2442
2572
|
|
|
2443
2573
|
|
|
@@ -2553,9 +2683,12 @@ function (_super) {
|
|
|
2553
2683
|
};
|
|
2554
2684
|
|
|
2555
2685
|
__proto.moveClients = function (clients, inputEvent, isAdd) {
|
|
2556
|
-
var
|
|
2557
|
-
|
|
2558
|
-
|
|
2686
|
+
var position = this._getPosition(clients, isAdd);
|
|
2687
|
+
|
|
2688
|
+
if (position.deltaX || position.deltaY) {
|
|
2689
|
+
this.isDrag = true;
|
|
2690
|
+
}
|
|
2691
|
+
|
|
2559
2692
|
return __assign({
|
|
2560
2693
|
datas: this.datas
|
|
2561
2694
|
}, position, {
|
|
@@ -2567,12 +2700,31 @@ function (_super) {
|
|
|
2567
2700
|
});
|
|
2568
2701
|
};
|
|
2569
2702
|
|
|
2703
|
+
__proto._getPosition = function (clients, isAdd) {
|
|
2704
|
+
var store = this.getCurrentStore();
|
|
2705
|
+
var position = store.getPosition(clients, isAdd);
|
|
2706
|
+
|
|
2707
|
+
var _a = this.clientStores.slice(1).reduce(function (prev, cur) {
|
|
2708
|
+
var storePosition = cur.getPosition();
|
|
2709
|
+
prev.distX += storePosition.distX;
|
|
2710
|
+
prev.distY += storePosition.distY;
|
|
2711
|
+
return prev;
|
|
2712
|
+
}, position),
|
|
2713
|
+
distX = _a.distX,
|
|
2714
|
+
distY = _a.distY;
|
|
2715
|
+
|
|
2716
|
+
return __assign({}, position, {
|
|
2717
|
+
distX: distX,
|
|
2718
|
+
distY: distY
|
|
2719
|
+
});
|
|
2720
|
+
};
|
|
2721
|
+
|
|
2570
2722
|
return Gesto;
|
|
2571
2723
|
}(EventEmitter$1);
|
|
2572
2724
|
|
|
2573
2725
|
var Gesto$1 = Gesto;
|
|
2574
2726
|
|
|
2575
|
-
const _sfc_main$
|
|
2727
|
+
const _sfc_main$g = defineComponent({
|
|
2576
2728
|
name: "m-editor-resize",
|
|
2577
2729
|
props: {
|
|
2578
2730
|
type: {
|
|
@@ -2614,33 +2766,33 @@ const _sfc_main$f = defineComponent({
|
|
|
2614
2766
|
};
|
|
2615
2767
|
}
|
|
2616
2768
|
});
|
|
2617
|
-
const _hoisted_1$
|
|
2769
|
+
const _hoisted_1$9 = {
|
|
2618
2770
|
ref: "target",
|
|
2619
2771
|
class: "m-editor-resizer"
|
|
2620
2772
|
};
|
|
2621
|
-
function _sfc_render$
|
|
2622
|
-
return openBlock(), createElementBlock("span", _hoisted_1$
|
|
2773
|
+
function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2774
|
+
return openBlock(), createElementBlock("span", _hoisted_1$9, [
|
|
2623
2775
|
renderSlot(_ctx.$slots, "default")
|
|
2624
2776
|
], 512);
|
|
2625
2777
|
}
|
|
2626
|
-
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2778
|
+
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
|
|
2627
2779
|
|
|
2628
|
-
const _sfc_main$
|
|
2780
|
+
const _sfc_main$f = defineComponent({
|
|
2629
2781
|
components: {
|
|
2630
2782
|
AddPageBox,
|
|
2631
2783
|
Resizer
|
|
2632
2784
|
},
|
|
2633
2785
|
setup() {
|
|
2634
|
-
const
|
|
2635
|
-
const root = computed(() =>
|
|
2786
|
+
const { editorService, uiService } = inject("services") || {};
|
|
2787
|
+
const root = computed(() => editorService?.get("root"));
|
|
2636
2788
|
return {
|
|
2637
2789
|
root,
|
|
2638
|
-
pageLength: computed(() =>
|
|
2639
|
-
showSrc: computed(() =>
|
|
2640
|
-
columnWidth: computed(() =>
|
|
2790
|
+
pageLength: computed(() => editorService?.get("pageLength") || 0),
|
|
2791
|
+
showSrc: computed(() => uiService?.get("showSrc")),
|
|
2792
|
+
columnWidth: computed(() => uiService?.get("columnWidth")),
|
|
2641
2793
|
saveCode(value) {
|
|
2642
2794
|
try {
|
|
2643
|
-
|
|
2795
|
+
editorService?.set("root", eval(value));
|
|
2644
2796
|
} catch (e) {
|
|
2645
2797
|
console.error(e);
|
|
2646
2798
|
}
|
|
@@ -2648,24 +2800,24 @@ const _sfc_main$e = defineComponent({
|
|
|
2648
2800
|
};
|
|
2649
2801
|
}
|
|
2650
2802
|
});
|
|
2651
|
-
const _hoisted_1$
|
|
2652
|
-
const _hoisted_2$
|
|
2803
|
+
const _hoisted_1$8 = { class: "m-editor" };
|
|
2804
|
+
const _hoisted_2$3 = {
|
|
2653
2805
|
key: 1,
|
|
2654
2806
|
class: "m-editor-content"
|
|
2655
2807
|
};
|
|
2656
|
-
function _sfc_render$
|
|
2808
|
+
function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2657
2809
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
2658
2810
|
const _component_resizer = resolveComponent("resizer");
|
|
2659
2811
|
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
2660
2812
|
const _component_add_page_box = resolveComponent("add-page-box");
|
|
2661
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
2813
|
+
return openBlock(), createElementBlock("div", _hoisted_1$8, [
|
|
2662
2814
|
renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
2663
2815
|
_ctx.showSrc ? (openBlock(), createBlock(_component_magic_code_editor, {
|
|
2664
2816
|
key: 0,
|
|
2665
2817
|
class: "m-editor-content",
|
|
2666
2818
|
"init-values": _ctx.root,
|
|
2667
2819
|
onSave: _ctx.saveCode
|
|
2668
|
-
}, null, 8, ["init-values", "onSave"])) : (openBlock(), createElementBlock("div", _hoisted_2$
|
|
2820
|
+
}, null, 8, ["init-values", "onSave"])) : (openBlock(), createElementBlock("div", _hoisted_2$3, [
|
|
2669
2821
|
createElementVNode("div", {
|
|
2670
2822
|
class: "m-editor-framework-left",
|
|
2671
2823
|
style: normalizeStyle(`width: ${_ctx.columnWidth?.left}px`)
|
|
@@ -2698,9 +2850,9 @@ function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2698
2850
|
]))
|
|
2699
2851
|
]);
|
|
2700
2852
|
}
|
|
2701
|
-
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2853
|
+
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
|
|
2702
2854
|
|
|
2703
|
-
const _sfc_main$
|
|
2855
|
+
const _sfc_main$e = defineComponent({
|
|
2704
2856
|
name: "m-icon",
|
|
2705
2857
|
components: { Edit },
|
|
2706
2858
|
props: {
|
|
@@ -2714,8 +2866,8 @@ const _sfc_main$d = defineComponent({
|
|
|
2714
2866
|
};
|
|
2715
2867
|
}
|
|
2716
2868
|
});
|
|
2717
|
-
const _hoisted_1$
|
|
2718
|
-
function _sfc_render$
|
|
2869
|
+
const _hoisted_1$7 = ["src"];
|
|
2870
|
+
function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2719
2871
|
const _component_edit = resolveComponent("edit");
|
|
2720
2872
|
const _component_el_icon = resolveComponent("el-icon");
|
|
2721
2873
|
return !_ctx.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
|
|
@@ -2726,7 +2878,7 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2726
2878
|
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (openBlock(), createElementBlock("img", {
|
|
2727
2879
|
key: 1,
|
|
2728
2880
|
src: _ctx.icon
|
|
2729
|
-
}, null, 8, _hoisted_1$
|
|
2881
|
+
}, null, 8, _hoisted_1$7)) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
2730
2882
|
key: 2,
|
|
2731
2883
|
class: normalizeClass(_ctx.icon)
|
|
2732
2884
|
}, null, 2)) : (openBlock(), createBlock(_component_el_icon, { key: 3 }, {
|
|
@@ -2736,9 +2888,9 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2736
2888
|
_: 1
|
|
2737
2889
|
}));
|
|
2738
2890
|
}
|
|
2739
|
-
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2891
|
+
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
|
|
2740
2892
|
|
|
2741
|
-
const _sfc_main$
|
|
2893
|
+
const _sfc_main$d = defineComponent({
|
|
2742
2894
|
components: { MIcon, ArrowDown },
|
|
2743
2895
|
props: {
|
|
2744
2896
|
data: {
|
|
@@ -2748,16 +2900,20 @@ const _sfc_main$c = defineComponent({
|
|
|
2748
2900
|
type: "text",
|
|
2749
2901
|
display: false
|
|
2750
2902
|
})
|
|
2903
|
+
},
|
|
2904
|
+
eventType: {
|
|
2905
|
+
type: String,
|
|
2906
|
+
default: "click"
|
|
2751
2907
|
}
|
|
2752
2908
|
},
|
|
2753
2909
|
setup(props) {
|
|
2754
2910
|
const services = inject("services");
|
|
2755
2911
|
const uiService = services?.uiService;
|
|
2756
|
-
const zoomInHandler = () => uiService?.set("zoom", zoom.value + 0.1);
|
|
2757
|
-
const zoomOutHandler = () => uiService?.set("zoom", zoom.value - 0.1);
|
|
2758
2912
|
const zoom = computed(() => uiService?.get("zoom") ?? 1);
|
|
2759
2913
|
const showGuides = computed(() => uiService?.get("showGuides") ?? true);
|
|
2760
2914
|
const showRule = computed(() => uiService?.get("showRule") ?? true);
|
|
2915
|
+
const zoomInHandler = () => uiService?.zoom(0.1);
|
|
2916
|
+
const zoomOutHandler = () => uiService?.zoom(-0.1);
|
|
2761
2917
|
const item = computed(() => {
|
|
2762
2918
|
if (typeof props.data !== "string") {
|
|
2763
2919
|
return props.data;
|
|
@@ -2774,7 +2930,7 @@ const _sfc_main$c = defineComponent({
|
|
|
2774
2930
|
case "delete":
|
|
2775
2931
|
return {
|
|
2776
2932
|
type: "button",
|
|
2777
|
-
icon: Delete,
|
|
2933
|
+
icon: markRaw(Delete),
|
|
2778
2934
|
tooltip: "\u522A\u9664",
|
|
2779
2935
|
disabled: () => services?.editorService.get("node")?.type === NodeType.PAGE,
|
|
2780
2936
|
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
@@ -2782,7 +2938,7 @@ const _sfc_main$c = defineComponent({
|
|
|
2782
2938
|
case "undo":
|
|
2783
2939
|
return {
|
|
2784
2940
|
type: "button",
|
|
2785
|
-
icon: Back,
|
|
2941
|
+
icon: markRaw(Back),
|
|
2786
2942
|
tooltip: "\u540E\u9000",
|
|
2787
2943
|
disabled: () => !services?.historyService.state.canUndo,
|
|
2788
2944
|
handler: () => services?.editorService.undo()
|
|
@@ -2790,7 +2946,7 @@ const _sfc_main$c = defineComponent({
|
|
|
2790
2946
|
case "redo":
|
|
2791
2947
|
return {
|
|
2792
2948
|
type: "button",
|
|
2793
|
-
icon: Right,
|
|
2949
|
+
icon: markRaw(Right),
|
|
2794
2950
|
tooltip: "\u524D\u8FDB",
|
|
2795
2951
|
disabled: () => !services?.historyService.state.canRedo,
|
|
2796
2952
|
handler: () => services?.editorService.redo()
|
|
@@ -2798,28 +2954,28 @@ const _sfc_main$c = defineComponent({
|
|
|
2798
2954
|
case "zoom-in":
|
|
2799
2955
|
return {
|
|
2800
2956
|
type: "button",
|
|
2801
|
-
icon: ZoomIn,
|
|
2957
|
+
icon: markRaw(ZoomIn),
|
|
2802
2958
|
tooltip: "\u653E\u5927",
|
|
2803
2959
|
handler: zoomInHandler
|
|
2804
2960
|
};
|
|
2805
2961
|
case "zoom-out":
|
|
2806
2962
|
return {
|
|
2807
2963
|
type: "button",
|
|
2808
|
-
icon: ZoomOut,
|
|
2964
|
+
icon: markRaw(ZoomOut),
|
|
2809
2965
|
tooltip: "\u7E2E\u5C0F",
|
|
2810
2966
|
handler: zoomOutHandler
|
|
2811
2967
|
};
|
|
2812
2968
|
case "rule":
|
|
2813
2969
|
return {
|
|
2814
2970
|
type: "button",
|
|
2815
|
-
icon: ScaleToOriginal,
|
|
2971
|
+
icon: markRaw(ScaleToOriginal),
|
|
2816
2972
|
tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
|
|
2817
2973
|
handler: () => uiService?.set("showRule", !showRule.value)
|
|
2818
2974
|
};
|
|
2819
2975
|
case "guides":
|
|
2820
2976
|
return {
|
|
2821
2977
|
type: "button",
|
|
2822
|
-
icon: Grid,
|
|
2978
|
+
icon: markRaw(Grid),
|
|
2823
2979
|
tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
|
|
2824
2980
|
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
2825
2981
|
};
|
|
@@ -2840,9 +2996,16 @@ const _sfc_main$c = defineComponent({
|
|
|
2840
2996
|
}
|
|
2841
2997
|
return item.value.disabled;
|
|
2842
2998
|
});
|
|
2999
|
+
const buttonHandler = (item2, event) => {
|
|
3000
|
+
if (disabled.value)
|
|
3001
|
+
return;
|
|
3002
|
+
if (typeof item2.handler === "function" && services) {
|
|
3003
|
+
item2.handler?.(services, event);
|
|
3004
|
+
}
|
|
3005
|
+
};
|
|
2843
3006
|
return {
|
|
2844
|
-
ZoomIn,
|
|
2845
|
-
ZoomOut,
|
|
3007
|
+
ZoomIn: markRaw(ZoomIn),
|
|
3008
|
+
ZoomOut: markRaw(ZoomOut),
|
|
2846
3009
|
item,
|
|
2847
3010
|
zoom,
|
|
2848
3011
|
disabled,
|
|
@@ -2863,31 +3026,42 @@ const _sfc_main$c = defineComponent({
|
|
|
2863
3026
|
command.item.handler(services);
|
|
2864
3027
|
}
|
|
2865
3028
|
},
|
|
2866
|
-
|
|
2867
|
-
if (
|
|
3029
|
+
clickHandler(item2, event) {
|
|
3030
|
+
if (props.eventType !== "click")
|
|
3031
|
+
return;
|
|
3032
|
+
if (item2.type === "button") {
|
|
3033
|
+
buttonHandler(item2, event);
|
|
3034
|
+
}
|
|
3035
|
+
},
|
|
3036
|
+
mousedownHandler(item2, event) {
|
|
3037
|
+
if (props.eventType !== "mousedown")
|
|
3038
|
+
return;
|
|
3039
|
+
if (item2.type === "button") {
|
|
3040
|
+
buttonHandler(item2, event);
|
|
3041
|
+
}
|
|
3042
|
+
},
|
|
3043
|
+
mouseupHandler(item2, event) {
|
|
3044
|
+
if (props.eventType !== "mouseup")
|
|
2868
3045
|
return;
|
|
2869
|
-
if (
|
|
2870
|
-
item2
|
|
3046
|
+
if (item2.type === "button") {
|
|
3047
|
+
buttonHandler(item2, event);
|
|
2871
3048
|
}
|
|
2872
3049
|
}
|
|
2873
3050
|
};
|
|
2874
3051
|
}
|
|
2875
3052
|
});
|
|
2876
|
-
const _hoisted_1$
|
|
2877
|
-
key: 0,
|
|
2878
|
-
class: "menu-item"
|
|
2879
|
-
};
|
|
2880
|
-
const _hoisted_2$4 = {
|
|
3053
|
+
const _hoisted_1$6 = {
|
|
2881
3054
|
key: 1,
|
|
2882
3055
|
class: "menu-item-text"
|
|
2883
3056
|
};
|
|
2884
|
-
const
|
|
3057
|
+
const _hoisted_2$2 = {
|
|
2885
3058
|
class: "menu-item-text",
|
|
2886
3059
|
style: { "margin": "0 5px" }
|
|
2887
3060
|
};
|
|
2888
|
-
const
|
|
2889
|
-
function _sfc_render$
|
|
3061
|
+
const _hoisted_3$1 = { class: "el-dropdown-link menubar-menu-button" };
|
|
3062
|
+
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2890
3063
|
const _component_el_divider = resolveComponent("el-divider");
|
|
3064
|
+
const _component_tool_button = resolveComponent("tool-button", true);
|
|
2891
3065
|
const _component_m_icon = resolveComponent("m-icon");
|
|
2892
3066
|
const _component_el_button = resolveComponent("el-button");
|
|
2893
3067
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
@@ -2896,60 +3070,66 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2896
3070
|
const _component_el_dropdown_item = resolveComponent("el-dropdown-item");
|
|
2897
3071
|
const _component_el_dropdown_menu = resolveComponent("el-dropdown-menu");
|
|
2898
3072
|
const _component_el_dropdown = resolveComponent("el-dropdown");
|
|
2899
|
-
return _ctx.display ? (openBlock(), createElementBlock("div",
|
|
3073
|
+
return _ctx.display ? (openBlock(), createElementBlock("div", {
|
|
3074
|
+
key: 0,
|
|
3075
|
+
class: normalizeClass(["menu-item", _ctx.item.type]),
|
|
3076
|
+
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.clickHandler(_ctx.item, $event)),
|
|
3077
|
+
onMousedown: _cache[1] || (_cache[1] = ($event) => _ctx.mousedownHandler(_ctx.item, $event)),
|
|
3078
|
+
onMouseup: _cache[2] || (_cache[2] = ($event) => _ctx.mouseupHandler(_ctx.item, $event))
|
|
3079
|
+
}, [
|
|
2900
3080
|
_ctx.item.type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
|
|
2901
3081
|
key: 0,
|
|
2902
|
-
direction: "vertical"
|
|
2903
|
-
})) : _ctx.item.type === "text" ? (openBlock(), createElementBlock("div",
|
|
2904
|
-
createVNode(
|
|
2905
|
-
|
|
2906
|
-
type:
|
|
3082
|
+
direction: _ctx.item.direction || "vertical"
|
|
3083
|
+
}, null, 8, ["direction"])) : _ctx.item.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$6, toDisplayString(_ctx.item.text), 1)) : _ctx.item.type === "zoom" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
3084
|
+
createVNode(_component_tool_button, {
|
|
3085
|
+
data: { type: "button", icon: _ctx.ZoomIn, handler: _ctx.zoomInHandler, tooltip: "\u653E\u5927" },
|
|
3086
|
+
"event-type": _ctx.eventType
|
|
3087
|
+
}, null, 8, ["data", "event-type"]),
|
|
3088
|
+
createElementVNode("span", _hoisted_2$2, toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
|
|
3089
|
+
createVNode(_component_tool_button, {
|
|
3090
|
+
data: { type: "button", icon: _ctx.ZoomOut, handler: _ctx.zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
3091
|
+
"event-type": _ctx.eventType
|
|
3092
|
+
}, null, 8, ["data", "event-type"])
|
|
3093
|
+
], 64)) : _ctx.item.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
3094
|
+
_ctx.item.tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
3095
|
+
key: 0,
|
|
3096
|
+
effect: "dark",
|
|
3097
|
+
placement: "bottom-start",
|
|
3098
|
+
content: _ctx.item.tooltip
|
|
2907
3099
|
}, {
|
|
2908
3100
|
default: withCtx(() => [
|
|
2909
|
-
createVNode(
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
3101
|
+
createVNode(_component_el_button, {
|
|
3102
|
+
size: "small",
|
|
3103
|
+
type: "text",
|
|
3104
|
+
disabled: _ctx.disabled
|
|
3105
|
+
}, {
|
|
3106
|
+
default: withCtx(() => [
|
|
3107
|
+
_ctx.item.icon ? (openBlock(), createBlock(_component_m_icon, {
|
|
3108
|
+
key: 0,
|
|
3109
|
+
icon: _ctx.item.icon
|
|
3110
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
3111
|
+
createElementVNode("span", null, toDisplayString(_ctx.item.text), 1)
|
|
3112
|
+
]),
|
|
3113
|
+
_: 1
|
|
3114
|
+
}, 8, ["disabled"])
|
|
2913
3115
|
]),
|
|
2914
3116
|
_: 1
|
|
2915
|
-
}),
|
|
2916
|
-
|
|
2917
|
-
createVNode(_component_el_button, {
|
|
3117
|
+
}, 8, ["content"])) : (openBlock(), createBlock(_component_el_button, {
|
|
3118
|
+
key: 1,
|
|
2918
3119
|
size: "small",
|
|
2919
|
-
type: "text"
|
|
3120
|
+
type: "text",
|
|
3121
|
+
disabled: _ctx.disabled
|
|
2920
3122
|
}, {
|
|
2921
3123
|
default: withCtx(() => [
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
}, null, 8, ["icon"
|
|
3124
|
+
_ctx.item.icon ? (openBlock(), createBlock(_component_m_icon, {
|
|
3125
|
+
key: 0,
|
|
3126
|
+
icon: _ctx.item.icon
|
|
3127
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
3128
|
+
createElementVNode("span", null, toDisplayString(_ctx.item.text), 1)
|
|
2926
3129
|
]),
|
|
2927
3130
|
_: 1
|
|
2928
|
-
})
|
|
2929
|
-
], 64)) : _ctx.item.type === "
|
|
2930
|
-
key: 3,
|
|
2931
|
-
effect: "dark",
|
|
2932
|
-
placement: "bottom-start",
|
|
2933
|
-
content: _ctx.item.tooltip || _ctx.item.text
|
|
2934
|
-
}, {
|
|
2935
|
-
default: withCtx(() => [
|
|
2936
|
-
createVNode(_component_el_button, {
|
|
2937
|
-
size: "small",
|
|
2938
|
-
type: "text",
|
|
2939
|
-
disabled: _ctx.disabled,
|
|
2940
|
-
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.buttonHandler(_ctx.item))
|
|
2941
|
-
}, {
|
|
2942
|
-
default: withCtx(() => [
|
|
2943
|
-
createVNode(_component_m_icon, {
|
|
2944
|
-
icon: _ctx.item.icon
|
|
2945
|
-
}, null, 8, ["icon"]),
|
|
2946
|
-
createElementVNode("span", null, toDisplayString(_ctx.item.text), 1)
|
|
2947
|
-
]),
|
|
2948
|
-
_: 1
|
|
2949
|
-
}, 8, ["disabled"])
|
|
2950
|
-
]),
|
|
2951
|
-
_: 1
|
|
2952
|
-
}, 8, ["content"])) : _ctx.item.type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
|
|
3131
|
+
}, 8, ["disabled"]))
|
|
3132
|
+
], 64)) : _ctx.item.type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
|
|
2953
3133
|
key: 4,
|
|
2954
3134
|
trigger: "click",
|
|
2955
3135
|
disabled: _ctx.disabled,
|
|
@@ -2974,7 +3154,7 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2974
3154
|
})) : createCommentVNode("", true)
|
|
2975
3155
|
]),
|
|
2976
3156
|
default: withCtx(() => [
|
|
2977
|
-
createElementVNode("span",
|
|
3157
|
+
createElementVNode("span", _hoisted_3$1, [
|
|
2978
3158
|
createTextVNode(toDisplayString(_ctx.item.text), 1),
|
|
2979
3159
|
createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2980
3160
|
default: withCtx(() => [
|
|
@@ -2986,11 +3166,11 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2986
3166
|
]),
|
|
2987
3167
|
_: 1
|
|
2988
3168
|
}, 8, ["disabled", "onCommand"])) : _ctx.item.type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.item.component), normalizeProps(mergeProps({ key: 5 }, _ctx.item.props || {})), null, 16)) : createCommentVNode("", true)
|
|
2989
|
-
])) : createCommentVNode("", true);
|
|
3169
|
+
], 34)) : createCommentVNode("", true);
|
|
2990
3170
|
}
|
|
2991
|
-
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3171
|
+
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
|
|
2992
3172
|
|
|
2993
|
-
const _sfc_main$
|
|
3173
|
+
const _sfc_main$c = defineComponent({
|
|
2994
3174
|
name: "nav-menu",
|
|
2995
3175
|
components: { ToolButton },
|
|
2996
3176
|
props: {
|
|
@@ -3010,7 +3190,7 @@ const _sfc_main$b = defineComponent({
|
|
|
3010
3190
|
};
|
|
3011
3191
|
}
|
|
3012
3192
|
});
|
|
3013
|
-
function _sfc_render$
|
|
3193
|
+
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3014
3194
|
const _component_tool_button = resolveComponent("tool-button");
|
|
3015
3195
|
return openBlock(), createElementBlock("div", {
|
|
3016
3196
|
class: "m-editor-nav-menu",
|
|
@@ -3032,9 +3212,9 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3032
3212
|
}), 128))
|
|
3033
3213
|
], 4);
|
|
3034
3214
|
}
|
|
3035
|
-
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3215
|
+
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
|
|
3036
3216
|
|
|
3037
|
-
const _sfc_main$
|
|
3217
|
+
const _sfc_main$b = defineComponent({
|
|
3038
3218
|
name: "m-editor-props-panel",
|
|
3039
3219
|
emits: ["mounted"],
|
|
3040
3220
|
setup(props, { emit }) {
|
|
@@ -3049,9 +3229,9 @@ const _sfc_main$a = defineComponent({
|
|
|
3049
3229
|
curFormConfig.value = [];
|
|
3050
3230
|
return;
|
|
3051
3231
|
}
|
|
3052
|
-
values.value = node.value;
|
|
3053
3232
|
const type = node.value.type || (node.value.items ? "container" : "text");
|
|
3054
3233
|
curFormConfig.value = await services?.propsService.getPropsConfig(type) || [];
|
|
3234
|
+
values.value = node.value;
|
|
3055
3235
|
};
|
|
3056
3236
|
watchEffect(init);
|
|
3057
3237
|
services?.propsService.on("props-configs-change", init);
|
|
@@ -3080,7 +3260,7 @@ const _sfc_main$a = defineComponent({
|
|
|
3080
3260
|
};
|
|
3081
3261
|
}
|
|
3082
3262
|
});
|
|
3083
|
-
function _sfc_render$
|
|
3263
|
+
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3084
3264
|
const _component_m_form = resolveComponent("m-form");
|
|
3085
3265
|
return openBlock(), createBlock(_component_m_form, {
|
|
3086
3266
|
class: "m-editor-props-panel",
|
|
@@ -3092,9 +3272,9 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3092
3272
|
onChange: _ctx.submit
|
|
3093
3273
|
}, null, 8, ["init-values", "config", "onChange"]);
|
|
3094
3274
|
}
|
|
3095
|
-
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3275
|
+
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
|
|
3096
3276
|
|
|
3097
|
-
const _sfc_main$
|
|
3277
|
+
const _sfc_main$a = defineComponent({
|
|
3098
3278
|
name: "ui-component-panel",
|
|
3099
3279
|
components: { MIcon },
|
|
3100
3280
|
setup() {
|
|
@@ -3109,19 +3289,29 @@ const _sfc_main$9 = defineComponent({
|
|
|
3109
3289
|
searchText,
|
|
3110
3290
|
collapseValue,
|
|
3111
3291
|
list,
|
|
3112
|
-
appendComponent({ text, type,
|
|
3292
|
+
appendComponent({ text, type, data = {} }) {
|
|
3113
3293
|
services?.editorService.add({
|
|
3114
3294
|
name: text,
|
|
3115
3295
|
type,
|
|
3116
|
-
...
|
|
3296
|
+
...data
|
|
3117
3297
|
});
|
|
3298
|
+
},
|
|
3299
|
+
dragstartHandler({ text, type, data = {} }, e) {
|
|
3300
|
+
if (e.dataTransfer) {
|
|
3301
|
+
e.dataTransfer.effectAllowed = "move";
|
|
3302
|
+
e.dataTransfer.setData("data", serialize({
|
|
3303
|
+
name: text,
|
|
3304
|
+
type,
|
|
3305
|
+
...data
|
|
3306
|
+
}).replace(/"(\w+)":\s/g, "$1: "));
|
|
3307
|
+
}
|
|
3118
3308
|
}
|
|
3119
3309
|
};
|
|
3120
3310
|
}
|
|
3121
3311
|
});
|
|
3122
|
-
const _hoisted_1$
|
|
3123
|
-
const _hoisted_2$
|
|
3124
|
-
function _sfc_render$
|
|
3312
|
+
const _hoisted_1$5 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
3313
|
+
const _hoisted_2$1 = ["onClick", "onDragstart"];
|
|
3314
|
+
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3125
3315
|
const _component_el_input = resolveComponent("el-input");
|
|
3126
3316
|
const _component_m_icon = resolveComponent("m-icon");
|
|
3127
3317
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
@@ -3151,15 +3341,17 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3151
3341
|
name: index
|
|
3152
3342
|
}, {
|
|
3153
3343
|
title: withCtx(() => [
|
|
3154
|
-
_hoisted_1$
|
|
3344
|
+
_hoisted_1$5,
|
|
3155
3345
|
createTextVNode(toDisplayString(group.title), 1)
|
|
3156
3346
|
]),
|
|
3157
3347
|
default: withCtx(() => [
|
|
3158
3348
|
(openBlock(true), createElementBlock(Fragment, null, renderList(group.items, (item) => {
|
|
3159
3349
|
return openBlock(), createElementBlock("div", {
|
|
3160
3350
|
class: "component-item",
|
|
3351
|
+
draggable: "true",
|
|
3161
3352
|
key: item.type,
|
|
3162
|
-
onClick: ($event) => _ctx.appendComponent(item)
|
|
3353
|
+
onClick: ($event) => _ctx.appendComponent(item),
|
|
3354
|
+
onDragstart: ($event) => _ctx.dragstartHandler(item, $event)
|
|
3163
3355
|
}, [
|
|
3164
3356
|
createVNode(_component_m_icon, {
|
|
3165
3357
|
icon: item.icon
|
|
@@ -3174,7 +3366,7 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3174
3366
|
]),
|
|
3175
3367
|
_: 2
|
|
3176
3368
|
}, 1032, ["content"])
|
|
3177
|
-
],
|
|
3369
|
+
], 40, _hoisted_2$1);
|
|
3178
3370
|
}), 128))
|
|
3179
3371
|
]),
|
|
3180
3372
|
_: 2
|
|
@@ -3188,97 +3380,194 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3188
3380
|
_: 1
|
|
3189
3381
|
});
|
|
3190
3382
|
}
|
|
3191
|
-
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3383
|
+
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
|
|
3384
|
+
|
|
3385
|
+
const _sfc_main$9 = defineComponent({
|
|
3386
|
+
components: { ToolButton },
|
|
3387
|
+
props: {
|
|
3388
|
+
menuData: {
|
|
3389
|
+
type: Array,
|
|
3390
|
+
default: () => []
|
|
3391
|
+
}
|
|
3392
|
+
},
|
|
3393
|
+
setup() {
|
|
3394
|
+
const menu = ref();
|
|
3395
|
+
const subMenu = ref();
|
|
3396
|
+
const visible = ref(false);
|
|
3397
|
+
const subMenuData = ref([]);
|
|
3398
|
+
const menuStyle = ref({
|
|
3399
|
+
left: "0",
|
|
3400
|
+
top: "0"
|
|
3401
|
+
});
|
|
3402
|
+
const hide = () => {
|
|
3403
|
+
visible.value = false;
|
|
3404
|
+
};
|
|
3405
|
+
onMounted(() => {
|
|
3406
|
+
globalThis.addEventListener("mousedown", (e) => {
|
|
3407
|
+
if (!visible.value || e.target && menu.value?.contains(e.target)) {
|
|
3408
|
+
return;
|
|
3409
|
+
}
|
|
3410
|
+
hide();
|
|
3411
|
+
}, true);
|
|
3412
|
+
});
|
|
3413
|
+
return {
|
|
3414
|
+
menu,
|
|
3415
|
+
subMenu,
|
|
3416
|
+
visible,
|
|
3417
|
+
menuStyle,
|
|
3418
|
+
subMenuData,
|
|
3419
|
+
hide,
|
|
3420
|
+
show(e) {
|
|
3421
|
+
visible.value = true;
|
|
3422
|
+
nextTick(() => {
|
|
3423
|
+
const menuHeight = menu.value?.clientHeight || 0;
|
|
3424
|
+
let top = e.clientY;
|
|
3425
|
+
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
3426
|
+
top = document.body.clientHeight - menuHeight;
|
|
3427
|
+
}
|
|
3428
|
+
menuStyle.value = {
|
|
3429
|
+
top: `${top}px`,
|
|
3430
|
+
left: `${e.clientX}px`
|
|
3431
|
+
};
|
|
3432
|
+
});
|
|
3433
|
+
},
|
|
3434
|
+
showSubMenu(item) {
|
|
3435
|
+
const menuItem = item;
|
|
3436
|
+
if (typeof item !== "object" || !menuItem.items?.length) {
|
|
3437
|
+
return;
|
|
3438
|
+
}
|
|
3439
|
+
subMenuData.value = menuItem.items;
|
|
3440
|
+
if (menu.value) {
|
|
3441
|
+
subMenu.value.show({
|
|
3442
|
+
clientX: menu.value.offsetLeft + menu.value.clientWidth,
|
|
3443
|
+
clientY: menu.value.offsetTop
|
|
3444
|
+
});
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
};
|
|
3448
|
+
}
|
|
3449
|
+
});
|
|
3450
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3451
|
+
const _component_tool_button = resolveComponent("tool-button");
|
|
3452
|
+
const _component_content_menu = resolveComponent("content-menu", true);
|
|
3453
|
+
return _ctx.menuData.length ? withDirectives((openBlock(), createElementBlock("div", {
|
|
3454
|
+
key: 0,
|
|
3455
|
+
class: "magic-editor-content-menu",
|
|
3456
|
+
ref: "menu",
|
|
3457
|
+
style: normalizeStyle(_ctx.menuStyle)
|
|
3458
|
+
}, [
|
|
3459
|
+
createElementVNode("div", null, [
|
|
3460
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menuData, (item, index) => {
|
|
3461
|
+
return openBlock(), createBlock(_component_tool_button, {
|
|
3462
|
+
"event-type": "mouseup",
|
|
3463
|
+
data: item,
|
|
3464
|
+
key: index,
|
|
3465
|
+
onMouseup: _ctx.hide,
|
|
3466
|
+
onMouseenter: ($event) => _ctx.showSubMenu(item)
|
|
3467
|
+
}, null, 8, ["data", "onMouseup", "onMouseenter"]);
|
|
3468
|
+
}), 128))
|
|
3469
|
+
]),
|
|
3470
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
3471
|
+
createVNode(_component_content_menu, {
|
|
3472
|
+
class: "sub-menu",
|
|
3473
|
+
ref: "subMenu",
|
|
3474
|
+
"menu-data": _ctx.subMenuData
|
|
3475
|
+
}, null, 8, ["menu-data"])
|
|
3476
|
+
]))
|
|
3477
|
+
], 4)), [
|
|
3478
|
+
[vShow, _ctx.visible]
|
|
3479
|
+
]) : createCommentVNode("", true);
|
|
3480
|
+
}
|
|
3481
|
+
var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
|
|
3192
3482
|
|
|
3193
3483
|
const _sfc_main$8 = defineComponent({
|
|
3194
|
-
|
|
3484
|
+
components: { ContentMenu },
|
|
3195
3485
|
setup() {
|
|
3196
3486
|
const services = inject("services");
|
|
3197
|
-
const
|
|
3487
|
+
const menu = ref();
|
|
3198
3488
|
const node = computed(() => services?.editorService.get("node"));
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3489
|
+
const isRoot = computed(() => node.value?.type === NodeType.ROOT);
|
|
3490
|
+
const isPage = computed(() => node.value?.type === NodeType.PAGE);
|
|
3491
|
+
const componentList = computed(() => services?.componentListService.getList() || []);
|
|
3492
|
+
const createMenuItems = (group) => group.items.map((component) => ({
|
|
3493
|
+
text: component.text,
|
|
3494
|
+
type: "button",
|
|
3495
|
+
icon: component.icon,
|
|
3496
|
+
handler: () => {
|
|
3204
3497
|
services?.editorService.add({
|
|
3205
|
-
name:
|
|
3206
|
-
type:
|
|
3498
|
+
name: component.text,
|
|
3499
|
+
type: component.type,
|
|
3500
|
+
...component.data || {}
|
|
3207
3501
|
});
|
|
3208
|
-
}
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3502
|
+
}
|
|
3503
|
+
}));
|
|
3504
|
+
const getSubMenuData = computed(() => {
|
|
3505
|
+
if (node.value?.type === "tabs") {
|
|
3506
|
+
return [
|
|
3507
|
+
{
|
|
3508
|
+
text: "\u6807\u7B7E\u9875",
|
|
3509
|
+
type: "button",
|
|
3510
|
+
icon: Files,
|
|
3511
|
+
handler: () => {
|
|
3512
|
+
services?.editorService.add({
|
|
3513
|
+
type: "tab-pane"
|
|
3514
|
+
});
|
|
3515
|
+
}
|
|
3516
|
+
}
|
|
3517
|
+
];
|
|
3518
|
+
}
|
|
3519
|
+
if (node.value?.items) {
|
|
3520
|
+
return componentList.value.reduce((subMenuData, group, index) => subMenuData.concat(createMenuItems(group), index < componentList.value.length - 1 ? [
|
|
3521
|
+
{
|
|
3522
|
+
type: "divider",
|
|
3523
|
+
direction: "horizontal"
|
|
3524
|
+
}
|
|
3525
|
+
] : []), []) || [];
|
|
3526
|
+
}
|
|
3527
|
+
return [];
|
|
3528
|
+
});
|
|
3529
|
+
return {
|
|
3530
|
+
menu,
|
|
3531
|
+
menuData: computed(() => [
|
|
3532
|
+
{
|
|
3533
|
+
type: "button",
|
|
3534
|
+
text: "\u65B0\u589E",
|
|
3535
|
+
icon: markRaw(Plus),
|
|
3536
|
+
display: () => node.value?.items,
|
|
3537
|
+
items: getSubMenuData.value
|
|
3538
|
+
},
|
|
3539
|
+
{
|
|
3540
|
+
type: "button",
|
|
3541
|
+
text: "\u590D\u5236",
|
|
3542
|
+
icon: markRaw(DocumentCopy),
|
|
3543
|
+
display: () => !isRoot.value,
|
|
3544
|
+
handler: () => {
|
|
3545
|
+
node.value && services?.editorService.copy(node.value);
|
|
3546
|
+
}
|
|
3547
|
+
},
|
|
3548
|
+
{
|
|
3549
|
+
type: "button",
|
|
3550
|
+
text: "\u5220\u9664",
|
|
3551
|
+
icon: markRaw(Delete),
|
|
3552
|
+
display: () => !isRoot.value && !isPage.value,
|
|
3553
|
+
handler: () => {
|
|
3554
|
+
node.value && services?.editorService.remove(node.value);
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
]),
|
|
3558
|
+
show(e) {
|
|
3559
|
+
menu.value?.show(e);
|
|
3217
3560
|
}
|
|
3218
3561
|
};
|
|
3219
3562
|
}
|
|
3220
3563
|
});
|
|
3221
|
-
const _hoisted_1$6 = {
|
|
3222
|
-
key: 0,
|
|
3223
|
-
class: "magic-editor-content-menu"
|
|
3224
|
-
};
|
|
3225
|
-
const _hoisted_2$2 = ["onClick"];
|
|
3226
|
-
const _hoisted_3$2 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
3227
3564
|
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3228
|
-
const
|
|
3229
|
-
return
|
|
3230
|
-
_ctx.
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
onMouseleave: _cache[1] || (_cache[1] = ($event) => _ctx.setSubVisitable(false))
|
|
3235
|
-
}, " \u65B0\u589E ", 32)) : createCommentVNode("", true),
|
|
3236
|
-
_ctx.node.type !== "app" ? (openBlock(), createElementBlock("div", {
|
|
3237
|
-
key: 1,
|
|
3238
|
-
class: "magic-editor-content-menu-item",
|
|
3239
|
-
onClick: _cache[2] || (_cache[2] = () => _ctx.copy(_ctx.node))
|
|
3240
|
-
}, "\u590D\u5236")) : createCommentVNode("", true),
|
|
3241
|
-
_ctx.node.type !== "app" && _ctx.node.type !== "page" ? (openBlock(), createElementBlock("div", {
|
|
3242
|
-
key: 2,
|
|
3243
|
-
class: "magic-editor-content-menu-item",
|
|
3244
|
-
onClick: _cache[3] || (_cache[3] = () => _ctx.remove())
|
|
3245
|
-
}, " \u5220\u9664 ")) : createCommentVNode("", true),
|
|
3246
|
-
withDirectives(createElementVNode("div", {
|
|
3247
|
-
class: "subMenu",
|
|
3248
|
-
onMouseenter: _cache[5] || (_cache[5] = ($event) => _ctx.setSubVisitable(true)),
|
|
3249
|
-
onMouseleave: _cache[6] || (_cache[6] = ($event) => _ctx.setSubVisitable(false))
|
|
3250
|
-
}, [
|
|
3251
|
-
createVNode(_component_el_scrollbar, null, {
|
|
3252
|
-
default: withCtx(() => [
|
|
3253
|
-
_ctx.node.type === "tabs" ? (openBlock(), createElementBlock("div", {
|
|
3254
|
-
key: 0,
|
|
3255
|
-
class: "magic-editor-content-menu-item",
|
|
3256
|
-
onClick: _cache[4] || (_cache[4] = () => _ctx.append({
|
|
3257
|
-
type: "tab-pane"
|
|
3258
|
-
}))
|
|
3259
|
-
}, " \u6807\u7B7E ")) : _ctx.node.items ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(_ctx.componentGroupList, (list) => {
|
|
3260
|
-
return openBlock(), createElementBlock("div", {
|
|
3261
|
-
key: list.title
|
|
3262
|
-
}, [
|
|
3263
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(list.items, (item) => {
|
|
3264
|
-
return openBlock(), createElementBlock(Fragment, null, [
|
|
3265
|
-
item ? (openBlock(), createElementBlock("div", {
|
|
3266
|
-
class: "magic-editor-content-menu-item",
|
|
3267
|
-
key: item.type,
|
|
3268
|
-
onClick: () => _ctx.append(item)
|
|
3269
|
-
}, toDisplayString(item.text), 9, _hoisted_2$2)) : createCommentVNode("", true)
|
|
3270
|
-
], 64);
|
|
3271
|
-
}), 256)),
|
|
3272
|
-
_hoisted_3$2
|
|
3273
|
-
]);
|
|
3274
|
-
}), 128)) : createCommentVNode("", true)
|
|
3275
|
-
]),
|
|
3276
|
-
_: 1
|
|
3277
|
-
})
|
|
3278
|
-
], 544), [
|
|
3279
|
-
[vShow, _ctx.subVisible]
|
|
3280
|
-
])
|
|
3281
|
-
])) : createCommentVNode("", true);
|
|
3565
|
+
const _component_content_menu = resolveComponent("content-menu");
|
|
3566
|
+
return openBlock(), createBlock(_component_content_menu, {
|
|
3567
|
+
"menu-data": _ctx.menuData,
|
|
3568
|
+
ref: "menu",
|
|
3569
|
+
style: { "overflow": "initial" }
|
|
3570
|
+
}, null, 8, ["menu-data"]);
|
|
3282
3571
|
}
|
|
3283
3572
|
var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
|
|
3284
3573
|
|
|
@@ -3372,56 +3661,37 @@ const useFilter = (tree) => ({
|
|
|
3372
3661
|
tree.value?.filter(val);
|
|
3373
3662
|
}
|
|
3374
3663
|
});
|
|
3375
|
-
const useContentMenu = (editorService) => {
|
|
3376
|
-
const menuStyle = ref({
|
|
3377
|
-
position: "absolute",
|
|
3378
|
-
left: "0",
|
|
3379
|
-
top: "0",
|
|
3380
|
-
display: "none"
|
|
3381
|
-
});
|
|
3382
|
-
onMounted(() => {
|
|
3383
|
-
document.addEventListener("click", () => {
|
|
3384
|
-
menuStyle.value.display = "none";
|
|
3385
|
-
}, true);
|
|
3386
|
-
});
|
|
3387
|
-
return {
|
|
3388
|
-
menuStyle,
|
|
3389
|
-
contextmenu(event, data) {
|
|
3390
|
-
const bodyHeight = globalThis.document.body.clientHeight;
|
|
3391
|
-
const left = `${event.clientX + 20}px`;
|
|
3392
|
-
let top = `${event.clientY - 10}px`;
|
|
3393
|
-
if (event.clientY + 300 > bodyHeight) {
|
|
3394
|
-
top = `${bodyHeight - 300}px`;
|
|
3395
|
-
}
|
|
3396
|
-
menuStyle.value.left = left;
|
|
3397
|
-
menuStyle.value.top = top;
|
|
3398
|
-
menuStyle.value.display = "";
|
|
3399
|
-
select(data, editorService);
|
|
3400
|
-
}
|
|
3401
|
-
};
|
|
3402
|
-
};
|
|
3403
3664
|
const _sfc_main$7 = defineComponent({
|
|
3404
3665
|
name: "magic-editor-layer-panel",
|
|
3405
3666
|
components: { LayerMenu },
|
|
3406
3667
|
setup() {
|
|
3407
3668
|
const services = inject("services");
|
|
3408
3669
|
const tree = ref();
|
|
3670
|
+
const menu = ref();
|
|
3409
3671
|
const clicked = ref(false);
|
|
3410
3672
|
const editorService = services?.editorService;
|
|
3411
3673
|
const highlightHandler = throttle((data) => {
|
|
3412
3674
|
highlight(data, editorService);
|
|
3413
3675
|
}, throttleTime);
|
|
3414
|
-
const
|
|
3676
|
+
const toggleClickFlag = () => {
|
|
3415
3677
|
clicked.value = !clicked.value;
|
|
3416
3678
|
};
|
|
3417
3679
|
const statusData = useStatus(tree, editorService);
|
|
3418
3680
|
const canHighlight = computed(() => statusData.highlightNode.value?.id !== statusData.clickNode.value?.id && !clicked.value);
|
|
3681
|
+
editorService?.on("remove", () => {
|
|
3682
|
+
setTimeout(() => {
|
|
3683
|
+
tree.value?.getNode(editorService.get("node").id)?.updateChildren();
|
|
3684
|
+
}, 0);
|
|
3685
|
+
});
|
|
3419
3686
|
return {
|
|
3420
3687
|
tree,
|
|
3688
|
+
menu,
|
|
3421
3689
|
...statusData,
|
|
3422
3690
|
...useDrop(tree, editorService),
|
|
3423
3691
|
...useFilter(tree),
|
|
3424
|
-
|
|
3692
|
+
highlightHandler,
|
|
3693
|
+
toggleClickFlag,
|
|
3694
|
+
canHighlight,
|
|
3425
3695
|
clickHandler(data) {
|
|
3426
3696
|
if (services?.uiService.get("uiSelectMode")) {
|
|
3427
3697
|
document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
|
|
@@ -3430,13 +3700,15 @@ const _sfc_main$7 = defineComponent({
|
|
|
3430
3700
|
tree.value?.setCurrentKey(data.id);
|
|
3431
3701
|
select(data, editorService);
|
|
3432
3702
|
},
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3703
|
+
async contextmenu(event, data) {
|
|
3704
|
+
event.preventDefault();
|
|
3705
|
+
await select(data, editorService);
|
|
3706
|
+
menu.value?.show(event);
|
|
3707
|
+
}
|
|
3436
3708
|
};
|
|
3437
3709
|
}
|
|
3438
3710
|
});
|
|
3439
|
-
const _hoisted_1$
|
|
3711
|
+
const _hoisted_1$4 = ["id", "onMouseenter"];
|
|
3440
3712
|
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3441
3713
|
const _component_el_input = resolveComponent("el-input");
|
|
3442
3714
|
const _component_el_tree = resolveComponent("el-tree");
|
|
@@ -3477,8 +3749,8 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3477
3749
|
createElementVNode("div", {
|
|
3478
3750
|
id: data.id,
|
|
3479
3751
|
class: normalizeClass(["cus-tree-node", { "cus-tree-node-hover": _ctx.canHighlight && data.id === _ctx.highlightNode?.id }]),
|
|
3480
|
-
onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.
|
|
3481
|
-
onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.
|
|
3752
|
+
onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
|
|
3753
|
+
onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
|
|
3482
3754
|
onMouseenter: ($event) => _ctx.highlightHandler(data)
|
|
3483
3755
|
}, [
|
|
3484
3756
|
renderSlot(_ctx.$slots, "layer-node-content", {
|
|
@@ -3487,14 +3759,12 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3487
3759
|
}, () => [
|
|
3488
3760
|
createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
|
|
3489
3761
|
])
|
|
3490
|
-
], 42, _hoisted_1$
|
|
3762
|
+
], 42, _hoisted_1$4)
|
|
3491
3763
|
]),
|
|
3492
3764
|
_: 3
|
|
3493
3765
|
}, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : createCommentVNode("", true),
|
|
3494
3766
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
3495
|
-
createVNode(_component_layer_menu, {
|
|
3496
|
-
style: normalizeStyle(_ctx.menuStyle)
|
|
3497
|
-
}, null, 8, ["style"])
|
|
3767
|
+
createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
|
|
3498
3768
|
]))
|
|
3499
3769
|
]),
|
|
3500
3770
|
_: 3
|
|
@@ -3546,7 +3816,7 @@ const _sfc_main$6 = defineComponent({
|
|
|
3546
3816
|
};
|
|
3547
3817
|
}
|
|
3548
3818
|
});
|
|
3549
|
-
const _hoisted_1$
|
|
3819
|
+
const _hoisted_1$3 = {
|
|
3550
3820
|
key: 1,
|
|
3551
3821
|
class: "magic-editor-tab-panel-title"
|
|
3552
3822
|
};
|
|
@@ -3574,7 +3844,7 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3574
3844
|
key: 0,
|
|
3575
3845
|
icon: item.icon
|
|
3576
3846
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
3577
|
-
item.text ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
3847
|
+
item.text ? (openBlock(), createElementBlock("div", _hoisted_1$3, toDisplayString(item.text), 1)) : createCommentVNode("", true)
|
|
3578
3848
|
])
|
|
3579
3849
|
]),
|
|
3580
3850
|
default: withCtx(() => [
|
|
@@ -3664,12 +3934,14 @@ const useScroll = (root) => {
|
|
|
3664
3934
|
};
|
|
3665
3935
|
};
|
|
3666
3936
|
const _sfc_main$5 = defineComponent({
|
|
3667
|
-
components: { ArrowLeftBold, ArrowRightBold, CaretBottom, Plus },
|
|
3937
|
+
components: { ArrowLeftBold, ArrowRightBold, CaretBottom, Plus, ToolButton },
|
|
3668
3938
|
setup() {
|
|
3669
3939
|
const services = inject("services");
|
|
3670
3940
|
const editorService = services?.editorService;
|
|
3671
3941
|
const root = computed(() => editorService?.get("root"));
|
|
3672
3942
|
return {
|
|
3943
|
+
Delete: markRaw(Delete),
|
|
3944
|
+
DocumentCopy: markRaw(DocumentCopy),
|
|
3673
3945
|
...useScroll(root),
|
|
3674
3946
|
root,
|
|
3675
3947
|
page: computed(() => editorService?.get("page")),
|
|
@@ -3698,23 +3970,22 @@ const _sfc_main$5 = defineComponent({
|
|
|
3698
3970
|
};
|
|
3699
3971
|
}
|
|
3700
3972
|
});
|
|
3701
|
-
const _hoisted_1$
|
|
3973
|
+
const _hoisted_1$2 = {
|
|
3702
3974
|
class: "m-editor-page-bar",
|
|
3703
3975
|
ref: "pageBar"
|
|
3704
3976
|
};
|
|
3705
|
-
const _hoisted_2
|
|
3706
|
-
const _hoisted_3
|
|
3707
|
-
const _hoisted_4$1 = ["onClick"];
|
|
3708
|
-
const _hoisted_5 = ["onClick"];
|
|
3977
|
+
const _hoisted_2 = ["onClick"];
|
|
3978
|
+
const _hoisted_3 = { class: "m-editor-page-bar-title" };
|
|
3709
3979
|
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3710
3980
|
const _component_plus = resolveComponent("plus");
|
|
3711
3981
|
const _component_el_icon = resolveComponent("el-icon");
|
|
3712
3982
|
const _component_arrow_left_bold = resolveComponent("arrow-left-bold");
|
|
3713
3983
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
3984
|
+
const _component_tool_button = resolveComponent("tool-button");
|
|
3714
3985
|
const _component_caret_bottom = resolveComponent("caret-bottom");
|
|
3715
3986
|
const _component_el_popover = resolveComponent("el-popover");
|
|
3716
3987
|
const _component_arrow_right_bold = resolveComponent("arrow-right-bold");
|
|
3717
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
3988
|
+
return openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
3718
3989
|
createElementVNode("div", {
|
|
3719
3990
|
id: "m-editor-page-bar-add-icon",
|
|
3720
3991
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
@@ -3751,7 +4022,7 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3751
4022
|
class: normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
|
|
3752
4023
|
onClick: ($event) => _ctx.switchPage(item)
|
|
3753
4024
|
}, [
|
|
3754
|
-
createElementVNode("div", _hoisted_3
|
|
4025
|
+
createElementVNode("div", _hoisted_3, [
|
|
3755
4026
|
renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
|
|
3756
4027
|
createVNode(_component_el_tooltip, {
|
|
3757
4028
|
effect: "dark",
|
|
@@ -3766,6 +4037,7 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3766
4037
|
])
|
|
3767
4038
|
]),
|
|
3768
4039
|
createVNode(_component_el_popover, {
|
|
4040
|
+
"popper-class": "page-bar-popover",
|
|
3769
4041
|
placement: "top",
|
|
3770
4042
|
width: 160,
|
|
3771
4043
|
trigger: "hover"
|
|
@@ -3781,20 +4053,28 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3781
4053
|
default: withCtx(() => [
|
|
3782
4054
|
createElementVNode("div", null, [
|
|
3783
4055
|
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
},
|
|
4056
|
+
createVNode(_component_tool_button, {
|
|
4057
|
+
data: {
|
|
4058
|
+
type: "button",
|
|
4059
|
+
text: "\u590D\u5236",
|
|
4060
|
+
icon: _ctx.DocumentCopy,
|
|
4061
|
+
handler: () => _ctx.copy(item)
|
|
4062
|
+
}
|
|
4063
|
+
}, null, 8, ["data"]),
|
|
4064
|
+
createVNode(_component_tool_button, {
|
|
4065
|
+
data: {
|
|
4066
|
+
type: "button",
|
|
4067
|
+
text: "\u5220\u9664",
|
|
4068
|
+
icon: _ctx.Delete,
|
|
4069
|
+
handler: () => _ctx.remove(item)
|
|
4070
|
+
}
|
|
4071
|
+
}, null, 8, ["data"])
|
|
3792
4072
|
])
|
|
3793
4073
|
])
|
|
3794
4074
|
]),
|
|
3795
4075
|
_: 2
|
|
3796
4076
|
}, 1024)
|
|
3797
|
-
], 10, _hoisted_2
|
|
4077
|
+
], 10, _hoisted_2);
|
|
3798
4078
|
}), 128))
|
|
3799
4079
|
], 4)) : createCommentVNode("", true),
|
|
3800
4080
|
_ctx.canScroll ? (openBlock(), createElementBlock("div", {
|
|
@@ -3814,33 +4094,104 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3814
4094
|
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
|
|
3815
4095
|
|
|
3816
4096
|
class ScrollViewer$1 {
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
4097
|
+
constructor(options) {
|
|
4098
|
+
this.enter = false;
|
|
4099
|
+
this.targetEnter = false;
|
|
4100
|
+
this.keydown = false;
|
|
4101
|
+
this.zoom = 1;
|
|
4102
|
+
this.scrollLeft = 0;
|
|
4103
|
+
this.scrollTop = 0;
|
|
4104
|
+
this.x = 0;
|
|
4105
|
+
this.y = 0;
|
|
4106
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
4107
|
+
for (const { contentRect } of entries) {
|
|
4108
|
+
const { width, height } = contentRect;
|
|
4109
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
4110
|
+
const targetWidth = targetRect.width * this.zoom;
|
|
4111
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
4112
|
+
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
4113
|
+
if (targetWidth < width) {
|
|
4114
|
+
this.target._left = 0;
|
|
4115
|
+
}
|
|
4116
|
+
if (targetHeight < height) {
|
|
4117
|
+
this.target._top = 0;
|
|
4118
|
+
}
|
|
4119
|
+
this.scroll();
|
|
3839
4120
|
}
|
|
4121
|
+
});
|
|
4122
|
+
this.wheelHandler = (event) => {
|
|
4123
|
+
if (this.targetEnter)
|
|
4124
|
+
return;
|
|
4125
|
+
const { deltaX, deltaY, currentTarget } = event;
|
|
4126
|
+
if (currentTarget !== this.container)
|
|
4127
|
+
return;
|
|
4128
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3840
4129
|
this.scroll();
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
4130
|
+
this.scrollLeft = this.target._left;
|
|
4131
|
+
this.scrollTop = this.target._top;
|
|
4132
|
+
};
|
|
4133
|
+
this.mouseEnterHandler = () => {
|
|
4134
|
+
this.enter = true;
|
|
4135
|
+
};
|
|
4136
|
+
this.mouseLeaveHandler = () => {
|
|
4137
|
+
this.enter = false;
|
|
4138
|
+
};
|
|
4139
|
+
this.targetMouseEnterHandler = () => {
|
|
4140
|
+
this.targetEnter = true;
|
|
4141
|
+
};
|
|
4142
|
+
this.targetMouseLeaveHandler = () => {
|
|
4143
|
+
this.targetEnter = false;
|
|
4144
|
+
};
|
|
4145
|
+
this.mousedownHandler = (event) => {
|
|
4146
|
+
if (!this.keydown)
|
|
4147
|
+
return;
|
|
4148
|
+
event.stopImmediatePropagation();
|
|
4149
|
+
event.stopPropagation();
|
|
4150
|
+
this.target.style.cursor = "grabbing";
|
|
4151
|
+
this.x = event.clientX;
|
|
4152
|
+
this.y = event.clientY;
|
|
4153
|
+
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
4154
|
+
document.addEventListener("mouseup", this.mouseupHandler);
|
|
4155
|
+
};
|
|
4156
|
+
this.mouseupHandler = () => {
|
|
4157
|
+
this.x = 0;
|
|
4158
|
+
this.y = 0;
|
|
4159
|
+
this.scrollLeft = this.target._left;
|
|
4160
|
+
this.scrollTop = this.target._top;
|
|
4161
|
+
this.removeHandler();
|
|
4162
|
+
};
|
|
4163
|
+
this.mousemoveHandler = (event) => {
|
|
4164
|
+
event.stopImmediatePropagation();
|
|
4165
|
+
event.stopPropagation();
|
|
4166
|
+
const deltaX = event.clientX - this.x;
|
|
4167
|
+
const deltaY = event.clientY - this.y;
|
|
4168
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
4169
|
+
this.scroll();
|
|
4170
|
+
};
|
|
4171
|
+
this.keydownHandler = (event) => {
|
|
4172
|
+
if (event.code === Keys.ESCAPE && this.enter) {
|
|
4173
|
+
event.preventDefault();
|
|
4174
|
+
event.stopImmediatePropagation();
|
|
4175
|
+
event.stopPropagation();
|
|
4176
|
+
}
|
|
4177
|
+
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
4178
|
+
return;
|
|
4179
|
+
}
|
|
4180
|
+
this.keydown = true;
|
|
4181
|
+
this.target.style.cursor = "grab";
|
|
4182
|
+
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
4183
|
+
};
|
|
4184
|
+
this.keyupHandler = (event) => {
|
|
4185
|
+
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
4186
|
+
return;
|
|
4187
|
+
}
|
|
4188
|
+
event.preventDefault();
|
|
4189
|
+
event.stopImmediatePropagation();
|
|
4190
|
+
event.stopPropagation();
|
|
4191
|
+
this.keydown = false;
|
|
4192
|
+
event.preventDefault();
|
|
4193
|
+
this.removeHandler();
|
|
4194
|
+
};
|
|
3844
4195
|
this.container = options.container;
|
|
3845
4196
|
this.target = options.target;
|
|
3846
4197
|
this.zoom = options.zoom;
|
|
@@ -3876,79 +4227,6 @@ class ScrollViewer$1 {
|
|
|
3876
4227
|
document.removeEventListener("mousemove", this.mousemoveHandler);
|
|
3877
4228
|
document.removeEventListener("mouseup", this.mouseupHandler);
|
|
3878
4229
|
}
|
|
3879
|
-
wheelHandler = (event) => {
|
|
3880
|
-
if (this.targetEnter)
|
|
3881
|
-
return;
|
|
3882
|
-
const { deltaX, deltaY, currentTarget } = event;
|
|
3883
|
-
if (currentTarget !== this.container)
|
|
3884
|
-
return;
|
|
3885
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3886
|
-
this.scroll();
|
|
3887
|
-
this.scrollLeft = this.target._left;
|
|
3888
|
-
this.scrollTop = this.target._top;
|
|
3889
|
-
};
|
|
3890
|
-
mouseEnterHandler = () => {
|
|
3891
|
-
this.enter = true;
|
|
3892
|
-
};
|
|
3893
|
-
mouseLeaveHandler = () => {
|
|
3894
|
-
this.enter = false;
|
|
3895
|
-
};
|
|
3896
|
-
targetMouseEnterHandler = () => {
|
|
3897
|
-
this.targetEnter = true;
|
|
3898
|
-
};
|
|
3899
|
-
targetMouseLeaveHandler = () => {
|
|
3900
|
-
this.targetEnter = false;
|
|
3901
|
-
};
|
|
3902
|
-
mousedownHandler = (event) => {
|
|
3903
|
-
if (!this.keydown)
|
|
3904
|
-
return;
|
|
3905
|
-
event.stopImmediatePropagation();
|
|
3906
|
-
event.stopPropagation();
|
|
3907
|
-
this.target.style.cursor = "grabbing";
|
|
3908
|
-
this.x = event.clientX;
|
|
3909
|
-
this.y = event.clientY;
|
|
3910
|
-
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3911
|
-
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3912
|
-
};
|
|
3913
|
-
mouseupHandler = () => {
|
|
3914
|
-
this.x = 0;
|
|
3915
|
-
this.y = 0;
|
|
3916
|
-
this.scrollLeft = this.target._left;
|
|
3917
|
-
this.scrollTop = this.target._top;
|
|
3918
|
-
this.removeHandler();
|
|
3919
|
-
};
|
|
3920
|
-
mousemoveHandler = (event) => {
|
|
3921
|
-
event.stopImmediatePropagation();
|
|
3922
|
-
event.stopPropagation();
|
|
3923
|
-
const deltaX = event.clientX - this.x;
|
|
3924
|
-
const deltaY = event.clientY - this.y;
|
|
3925
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3926
|
-
this.scroll();
|
|
3927
|
-
};
|
|
3928
|
-
keydownHandler = (event) => {
|
|
3929
|
-
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3930
|
-
event.preventDefault();
|
|
3931
|
-
event.stopImmediatePropagation();
|
|
3932
|
-
event.stopPropagation();
|
|
3933
|
-
}
|
|
3934
|
-
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3935
|
-
return;
|
|
3936
|
-
}
|
|
3937
|
-
this.keydown = true;
|
|
3938
|
-
this.target.style.cursor = "grab";
|
|
3939
|
-
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3940
|
-
};
|
|
3941
|
-
keyupHandler = (event) => {
|
|
3942
|
-
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3943
|
-
return;
|
|
3944
|
-
}
|
|
3945
|
-
event.preventDefault();
|
|
3946
|
-
event.stopImmediatePropagation();
|
|
3947
|
-
event.stopPropagation();
|
|
3948
|
-
this.keydown = false;
|
|
3949
|
-
event.preventDefault();
|
|
3950
|
-
this.removeHandler();
|
|
3951
|
-
};
|
|
3952
4230
|
setScrollOffset(deltaX, deltaY) {
|
|
3953
4231
|
const { width, height } = this.container.getBoundingClientRect();
|
|
3954
4232
|
const targetRect = this.target.getBoundingClientRect();
|
|
@@ -4009,19 +4287,19 @@ const _sfc_main$4 = defineComponent({
|
|
|
4009
4287
|
el,
|
|
4010
4288
|
style: computed(() => `
|
|
4011
4289
|
width: ${props.width}px;
|
|
4012
|
-
height: ${props.height}px;
|
|
4290
|
+
height: ${(props.height || 0) - 40}px;
|
|
4013
4291
|
position: absolute;
|
|
4014
4292
|
margin-top: 30px;
|
|
4015
4293
|
`)
|
|
4016
4294
|
};
|
|
4017
4295
|
}
|
|
4018
4296
|
});
|
|
4019
|
-
const _hoisted_1$
|
|
4297
|
+
const _hoisted_1$1 = {
|
|
4020
4298
|
class: "m-editor-scroll-viewer-container",
|
|
4021
4299
|
ref: "container"
|
|
4022
4300
|
};
|
|
4023
4301
|
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4024
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
4302
|
+
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
4025
4303
|
createElementVNode("div", {
|
|
4026
4304
|
ref: "el",
|
|
4027
4305
|
style: normalizeStyle(_ctx.style)
|
|
@@ -4033,7 +4311,7 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4033
4311
|
var ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]);
|
|
4034
4312
|
|
|
4035
4313
|
const _sfc_main$3 = defineComponent({
|
|
4036
|
-
|
|
4314
|
+
components: { ContentMenu },
|
|
4037
4315
|
setup() {
|
|
4038
4316
|
const services = inject("services");
|
|
4039
4317
|
const editorService = services?.editorService;
|
|
@@ -4042,6 +4320,7 @@ const _sfc_main$3 = defineComponent({
|
|
|
4042
4320
|
const canCenter = ref(false);
|
|
4043
4321
|
const node = computed(() => editorService?.get("node"));
|
|
4044
4322
|
const parent = computed(() => editorService?.get("parent"));
|
|
4323
|
+
const isPage = computed(() => node.value?.type === NodeType.PAGE);
|
|
4045
4324
|
onMounted(() => {
|
|
4046
4325
|
const data = globalThis.localStorage.getItem(COPY_STORAGE_KEY);
|
|
4047
4326
|
canPaste.value = data !== "undefined" && !!data;
|
|
@@ -4054,133 +4333,114 @@ const _sfc_main$3 = defineComponent({
|
|
|
4054
4333
|
}, { immediate: true });
|
|
4055
4334
|
return {
|
|
4056
4335
|
menu,
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4336
|
+
menuData: reactive([
|
|
4337
|
+
{
|
|
4338
|
+
type: "button",
|
|
4339
|
+
text: "\u6C34\u5E73\u5C45\u4E2D",
|
|
4340
|
+
display: () => canCenter.value,
|
|
4341
|
+
handler: () => {
|
|
4342
|
+
node.value && editorService?.alignCenter(node.value);
|
|
4343
|
+
}
|
|
4344
|
+
},
|
|
4345
|
+
{
|
|
4346
|
+
type: "button",
|
|
4347
|
+
text: "\u590D\u5236",
|
|
4348
|
+
icon: markRaw(DocumentCopy),
|
|
4349
|
+
handler: () => {
|
|
4350
|
+
node.value && editorService?.copy(node.value);
|
|
4351
|
+
canPaste.value = true;
|
|
4352
|
+
}
|
|
4353
|
+
},
|
|
4354
|
+
{
|
|
4355
|
+
type: "button",
|
|
4356
|
+
text: "\u7C98\u8D34",
|
|
4357
|
+
display: () => canPaste.value,
|
|
4358
|
+
handler: () => {
|
|
4359
|
+
const top = menu.value?.$el.offsetTop || 0;
|
|
4360
|
+
const left = menu.value?.$el.offsetLeft || 0;
|
|
4361
|
+
editorService?.paste({ left, top });
|
|
4362
|
+
}
|
|
4363
|
+
},
|
|
4364
|
+
{
|
|
4365
|
+
type: "divider",
|
|
4366
|
+
direction: "horizontal",
|
|
4367
|
+
display: () => !isPage.value
|
|
4368
|
+
},
|
|
4369
|
+
{
|
|
4370
|
+
type: "button",
|
|
4371
|
+
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
4372
|
+
icon: markRaw(Top),
|
|
4373
|
+
display: () => !isPage.value,
|
|
4374
|
+
handler: () => {
|
|
4375
|
+
editorService?.moveLayer(1);
|
|
4376
|
+
}
|
|
4377
|
+
},
|
|
4378
|
+
{
|
|
4379
|
+
type: "button",
|
|
4380
|
+
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
4381
|
+
icon: markRaw(Bottom),
|
|
4382
|
+
display: () => !isPage.value,
|
|
4383
|
+
handler: () => {
|
|
4384
|
+
editorService?.moveLayer(-1);
|
|
4385
|
+
}
|
|
4386
|
+
},
|
|
4387
|
+
{
|
|
4388
|
+
type: "button",
|
|
4389
|
+
text: "\u7F6E\u9876",
|
|
4390
|
+
display: () => !isPage.value,
|
|
4391
|
+
handler: () => {
|
|
4392
|
+
editorService?.moveLayer(LayerOffset.TOP);
|
|
4393
|
+
}
|
|
4394
|
+
},
|
|
4395
|
+
{
|
|
4396
|
+
type: "button",
|
|
4397
|
+
text: "\u7F6E\u5E95",
|
|
4398
|
+
display: () => !isPage.value,
|
|
4399
|
+
handler: () => {
|
|
4400
|
+
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
4401
|
+
}
|
|
4402
|
+
},
|
|
4403
|
+
{
|
|
4404
|
+
type: "divider",
|
|
4405
|
+
direction: "horizontal",
|
|
4406
|
+
display: () => !isPage.value
|
|
4407
|
+
},
|
|
4408
|
+
{
|
|
4409
|
+
type: "button",
|
|
4410
|
+
text: "\u5220\u9664",
|
|
4411
|
+
icon: Delete,
|
|
4412
|
+
display: () => !isPage.value,
|
|
4413
|
+
handler: () => {
|
|
4414
|
+
node.value && editorService?.remove(node.value);
|
|
4415
|
+
}
|
|
4416
|
+
},
|
|
4417
|
+
{
|
|
4418
|
+
type: "divider",
|
|
4419
|
+
direction: "horizontal"
|
|
4420
|
+
},
|
|
4421
|
+
{
|
|
4422
|
+
type: "button",
|
|
4423
|
+
text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
|
|
4424
|
+
handler: () => {
|
|
4425
|
+
editorService?.get("stage").clearGuides();
|
|
4426
|
+
}
|
|
4427
|
+
}
|
|
4428
|
+
]),
|
|
4429
|
+
show(e) {
|
|
4430
|
+
menu.value?.show(e);
|
|
4090
4431
|
}
|
|
4091
4432
|
};
|
|
4092
4433
|
}
|
|
4093
4434
|
});
|
|
4094
|
-
const _hoisted_1$1 = {
|
|
4095
|
-
class: "magic-editor-content-menu",
|
|
4096
|
-
ref: "menu"
|
|
4097
|
-
};
|
|
4098
|
-
const _hoisted_2 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
4099
|
-
const _hoisted_3 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
4100
|
-
const _hoisted_4 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
4101
4435
|
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
onClick: _cache[0] || (_cache[0] = () => _ctx.center())
|
|
4108
|
-
}, "\u6C34\u5E73\u5C45\u4E2D")) : createCommentVNode("", true),
|
|
4109
|
-
createElementVNode("div", {
|
|
4110
|
-
class: "magic-editor-content-menu-item",
|
|
4111
|
-
onClick: _cache[1] || (_cache[1] = () => _ctx.copy())
|
|
4112
|
-
}, "\u590D\u5236"),
|
|
4113
|
-
_ctx.canPaste ? (openBlock(), createElementBlock("div", {
|
|
4114
|
-
key: 1,
|
|
4115
|
-
class: "magic-editor-content-menu-item",
|
|
4116
|
-
onClick: _cache[2] || (_cache[2] = (...args) => _ctx.paste && _ctx.paste(...args))
|
|
4117
|
-
}, "\u7C98\u8D34")) : createCommentVNode("", true),
|
|
4118
|
-
_ctx.canMoveZPos ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
4119
|
-
_hoisted_2,
|
|
4120
|
-
createElementVNode("div", {
|
|
4121
|
-
class: "magic-editor-content-menu-item",
|
|
4122
|
-
onClick: _cache[3] || (_cache[3] = (...args) => _ctx.topItem && _ctx.topItem(...args))
|
|
4123
|
-
}, "\u4E0A\u79FB\u4E00\u5C42"),
|
|
4124
|
-
createElementVNode("div", {
|
|
4125
|
-
class: "magic-editor-content-menu-item",
|
|
4126
|
-
onClick: _cache[4] || (_cache[4] = (...args) => _ctx.bottomItem && _ctx.bottomItem(...args))
|
|
4127
|
-
}, "\u4E0B\u79FB\u4E00\u5C42"),
|
|
4128
|
-
createElementVNode("div", {
|
|
4129
|
-
class: "magic-editor-content-menu-item",
|
|
4130
|
-
onClick: _cache[5] || (_cache[5] = (...args) => _ctx.top && _ctx.top(...args))
|
|
4131
|
-
}, "\u7F6E\u9876"),
|
|
4132
|
-
createElementVNode("div", {
|
|
4133
|
-
class: "magic-editor-content-menu-item",
|
|
4134
|
-
onClick: _cache[6] || (_cache[6] = (...args) => _ctx.bottom && _ctx.bottom(...args))
|
|
4135
|
-
}, "\u7F6E\u5E95")
|
|
4136
|
-
], 64)) : createCommentVNode("", true),
|
|
4137
|
-
_ctx.canDelete ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
4138
|
-
_hoisted_3,
|
|
4139
|
-
createElementVNode("div", {
|
|
4140
|
-
class: "magic-editor-content-menu-item",
|
|
4141
|
-
onClick: _cache[7] || (_cache[7] = () => _ctx.remove())
|
|
4142
|
-
}, "\u5220\u9664")
|
|
4143
|
-
], 64)) : createCommentVNode("", true),
|
|
4144
|
-
_hoisted_4,
|
|
4145
|
-
createElementVNode("div", {
|
|
4146
|
-
class: "magic-editor-content-menu-item",
|
|
4147
|
-
onClick: _cache[8] || (_cache[8] = (...args) => _ctx.clearGuides && _ctx.clearGuides(...args))
|
|
4148
|
-
}, "\u6E05\u7A7A\u53C2\u8003\u7EBF")
|
|
4149
|
-
])
|
|
4150
|
-
], 512);
|
|
4436
|
+
const _component_content_menu = resolveComponent("content-menu");
|
|
4437
|
+
return openBlock(), createBlock(_component_content_menu, {
|
|
4438
|
+
"menu-data": _ctx.menuData,
|
|
4439
|
+
ref: "menu"
|
|
4440
|
+
}, null, 8, ["menu-data"]);
|
|
4151
4441
|
}
|
|
4152
4442
|
var ViewerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
|
|
4153
4443
|
|
|
4154
|
-
const useMenu = () => {
|
|
4155
|
-
const menu = ref();
|
|
4156
|
-
const menuStyle = ref({
|
|
4157
|
-
display: "none",
|
|
4158
|
-
left: "0",
|
|
4159
|
-
top: "0"
|
|
4160
|
-
});
|
|
4161
|
-
onMounted(() => {
|
|
4162
|
-
document.addEventListener("click", () => {
|
|
4163
|
-
menuStyle.value.display = "none";
|
|
4164
|
-
}, true);
|
|
4165
|
-
});
|
|
4166
|
-
return {
|
|
4167
|
-
menu,
|
|
4168
|
-
menuStyle,
|
|
4169
|
-
contextmenuHandler(e) {
|
|
4170
|
-
e.preventDefault();
|
|
4171
|
-
const menuHeight = menu.value?.$el.clientHeight;
|
|
4172
|
-
let top = e.clientY;
|
|
4173
|
-
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
4174
|
-
top = document.body.clientHeight - menuHeight;
|
|
4175
|
-
}
|
|
4176
|
-
menuStyle.value = {
|
|
4177
|
-
display: "block",
|
|
4178
|
-
top: `${top}px`,
|
|
4179
|
-
left: `${e.clientX}px`
|
|
4180
|
-
};
|
|
4181
|
-
}
|
|
4182
|
-
};
|
|
4183
|
-
};
|
|
4184
4444
|
const _sfc_main$2 = defineComponent({
|
|
4185
4445
|
name: "magic-stage",
|
|
4186
4446
|
components: {
|
|
@@ -4207,11 +4467,12 @@ const _sfc_main$2 = defineComponent({
|
|
|
4207
4467
|
const services = inject("services");
|
|
4208
4468
|
const stageWrap = ref();
|
|
4209
4469
|
const stageContainer = ref();
|
|
4470
|
+
const menu = ref();
|
|
4210
4471
|
const stageRect = computed(() => services?.uiService.get("stageRect"));
|
|
4211
4472
|
const uiSelectMode = computed(() => services?.uiService.get("uiSelectMode"));
|
|
4212
4473
|
const root = computed(() => services?.editorService.get("root"));
|
|
4213
4474
|
const page = computed(() => services?.editorService.get("page"));
|
|
4214
|
-
const zoom = computed(() => services?.uiService.get("zoom"));
|
|
4475
|
+
const zoom = computed(() => services?.uiService.get("zoom") || 1);
|
|
4215
4476
|
const node = computed(() => services?.editorService.get("node"));
|
|
4216
4477
|
let stage = null;
|
|
4217
4478
|
let runtime = null;
|
|
@@ -4293,9 +4554,36 @@ const _sfc_main$2 = defineComponent({
|
|
|
4293
4554
|
return {
|
|
4294
4555
|
stageWrap,
|
|
4295
4556
|
stageContainer,
|
|
4557
|
+
menu,
|
|
4296
4558
|
stageRect,
|
|
4297
4559
|
zoom,
|
|
4298
|
-
|
|
4560
|
+
contextmenuHandler(e2) {
|
|
4561
|
+
e2.preventDefault();
|
|
4562
|
+
menu.value?.show(e2);
|
|
4563
|
+
},
|
|
4564
|
+
dragoverHandler(e2) {
|
|
4565
|
+
e2.preventDefault();
|
|
4566
|
+
if (e2.dataTransfer) {
|
|
4567
|
+
e2.dataTransfer.dropEffect = "move";
|
|
4568
|
+
}
|
|
4569
|
+
},
|
|
4570
|
+
async dropHandler(e) {
|
|
4571
|
+
e.preventDefault();
|
|
4572
|
+
if (e.dataTransfer && page.value && stageContainer.value && stage) {
|
|
4573
|
+
const config = eval(`(${e.dataTransfer.getData("data")})`);
|
|
4574
|
+
const layout = await services?.editorService.getLayout(page.value);
|
|
4575
|
+
const containerRect = stageContainer.value.getBoundingClientRect();
|
|
4576
|
+
const { scrollTop, scrollLeft } = stage.mask;
|
|
4577
|
+
if (layout === Layout.ABSOLUTE) {
|
|
4578
|
+
config.style = {
|
|
4579
|
+
position: "absolute",
|
|
4580
|
+
top: e.clientY - containerRect.top + scrollTop,
|
|
4581
|
+
left: e.clientX - containerRect.left + scrollLeft
|
|
4582
|
+
};
|
|
4583
|
+
}
|
|
4584
|
+
services?.editorService.add(config, page.value);
|
|
4585
|
+
}
|
|
4586
|
+
}
|
|
4299
4587
|
};
|
|
4300
4588
|
}
|
|
4301
4589
|
});
|
|
@@ -4313,14 +4601,13 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4313
4601
|
createElementVNode("div", {
|
|
4314
4602
|
class: "m-editor-stage-container",
|
|
4315
4603
|
ref: "stageContainer",
|
|
4604
|
+
style: normalizeStyle(`transform: scale(${_ctx.zoom})`),
|
|
4316
4605
|
onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
|
|
4317
|
-
|
|
4606
|
+
onDrop: _cache[1] || (_cache[1] = (...args) => _ctx.dropHandler && _ctx.dropHandler(...args)),
|
|
4607
|
+
onDragover: _cache[2] || (_cache[2] = (...args) => _ctx.dragoverHandler && _ctx.dragoverHandler(...args))
|
|
4318
4608
|
}, null, 36),
|
|
4319
4609
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
4320
|
-
createVNode(_component_viewer_menu, {
|
|
4321
|
-
ref: "menu",
|
|
4322
|
-
style: normalizeStyle(_ctx.menuStyle)
|
|
4323
|
-
}, null, 8, ["style"])
|
|
4610
|
+
createVNode(_component_viewer_menu, { ref: "menu" }, null, 512)
|
|
4324
4611
|
]))
|
|
4325
4612
|
]),
|
|
4326
4613
|
_: 1
|
|
@@ -4348,12 +4635,93 @@ const _sfc_main$1 = defineComponent({
|
|
|
4348
4635
|
},
|
|
4349
4636
|
setup() {
|
|
4350
4637
|
const services = inject("services");
|
|
4638
|
+
const workspace = ref();
|
|
4639
|
+
const node = computed(() => services?.editorService.get("node"));
|
|
4640
|
+
let keycon;
|
|
4641
|
+
const mouseenterHandler = () => {
|
|
4642
|
+
workspace.value?.focus();
|
|
4643
|
+
};
|
|
4644
|
+
onMounted(() => {
|
|
4645
|
+
workspace.value?.addEventListener("mouseenter", mouseenterHandler);
|
|
4646
|
+
keycon = new KeyController(workspace.value);
|
|
4647
|
+
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
4648
|
+
const ctrl = isMac ? "meta" : "ctrl";
|
|
4649
|
+
keycon.keyup("delete", (e) => {
|
|
4650
|
+
e.inputEvent.preventDefault();
|
|
4651
|
+
if (!node.value || isPage(node.value))
|
|
4652
|
+
return;
|
|
4653
|
+
services?.editorService.remove(node.value);
|
|
4654
|
+
}).keydown([ctrl, "c"], (e) => {
|
|
4655
|
+
e.inputEvent.preventDefault();
|
|
4656
|
+
node.value && services?.editorService.copy(node.value);
|
|
4657
|
+
}).keydown([ctrl, "v"], (e) => {
|
|
4658
|
+
e.inputEvent.preventDefault();
|
|
4659
|
+
node.value && services?.editorService.paste();
|
|
4660
|
+
}).keydown([ctrl, "x"], (e) => {
|
|
4661
|
+
e.inputEvent.preventDefault();
|
|
4662
|
+
if (!node.value || isPage(node.value))
|
|
4663
|
+
return;
|
|
4664
|
+
services?.editorService.copy(node.value);
|
|
4665
|
+
services?.editorService.remove(node.value);
|
|
4666
|
+
}).keydown([ctrl, "z"], (e) => {
|
|
4667
|
+
e.inputEvent.preventDefault();
|
|
4668
|
+
services?.editorService.undo();
|
|
4669
|
+
}).keydown([ctrl, "shift", "z"], (e) => {
|
|
4670
|
+
e.inputEvent.preventDefault();
|
|
4671
|
+
services?.editorService.redo();
|
|
4672
|
+
}).keydown("up", (e) => {
|
|
4673
|
+
e.inputEvent.preventDefault();
|
|
4674
|
+
services?.editorService.move(0, -1);
|
|
4675
|
+
}).keydown("down", (e) => {
|
|
4676
|
+
e.inputEvent.preventDefault();
|
|
4677
|
+
services?.editorService.move(0, 1);
|
|
4678
|
+
}).keydown("left", (e) => {
|
|
4679
|
+
e.inputEvent.preventDefault();
|
|
4680
|
+
services?.editorService.move(-1, 0);
|
|
4681
|
+
}).keydown("right", (e) => {
|
|
4682
|
+
e.inputEvent.preventDefault();
|
|
4683
|
+
services?.editorService.move(1, 0);
|
|
4684
|
+
}).keydown([ctrl, "up"], (e) => {
|
|
4685
|
+
e.inputEvent.preventDefault();
|
|
4686
|
+
services?.editorService.move(0, -10);
|
|
4687
|
+
}).keydown([ctrl, "down"], (e) => {
|
|
4688
|
+
e.inputEvent.preventDefault();
|
|
4689
|
+
services?.editorService.move(0, 10);
|
|
4690
|
+
}).keydown([ctrl, "left"], (e) => {
|
|
4691
|
+
e.inputEvent.preventDefault();
|
|
4692
|
+
services?.editorService.move(-10, 0);
|
|
4693
|
+
}).keydown([ctrl, "right"], (e) => {
|
|
4694
|
+
e.inputEvent.preventDefault();
|
|
4695
|
+
services?.editorService.move(10, 0);
|
|
4696
|
+
}).keydown("tab", (e) => {
|
|
4697
|
+
e.inputEvent.preventDefault();
|
|
4698
|
+
services?.editorService.selectNextNode();
|
|
4699
|
+
}).keydown([ctrl, "tab"], (e) => {
|
|
4700
|
+
e.inputEvent.preventDefault();
|
|
4701
|
+
services?.editorService.selectNextPage();
|
|
4702
|
+
}).keydown([ctrl, "="], (e) => {
|
|
4703
|
+
e.inputEvent.preventDefault();
|
|
4704
|
+
services?.uiService.zoom(0.1);
|
|
4705
|
+
}).keydown([ctrl, "-"], (e) => {
|
|
4706
|
+
e.inputEvent.preventDefault();
|
|
4707
|
+
services?.uiService.zoom(-0.1);
|
|
4708
|
+
});
|
|
4709
|
+
});
|
|
4710
|
+
onUnmounted(() => {
|
|
4711
|
+
workspace.value?.removeEventListener("mouseenter", mouseenterHandler);
|
|
4712
|
+
keycon.destroy();
|
|
4713
|
+
});
|
|
4351
4714
|
return {
|
|
4715
|
+
workspace,
|
|
4352
4716
|
page: computed(() => services?.editorService.get("page"))
|
|
4353
4717
|
};
|
|
4354
4718
|
}
|
|
4355
4719
|
});
|
|
4356
|
-
const _hoisted_1 = {
|
|
4720
|
+
const _hoisted_1 = {
|
|
4721
|
+
class: "m-editor-workspace",
|
|
4722
|
+
tabindex: "1",
|
|
4723
|
+
ref: "workspace"
|
|
4724
|
+
};
|
|
4357
4725
|
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4358
4726
|
const _component_magic_stage = resolveComponent("magic-stage");
|
|
4359
4727
|
const _component_page_bar = resolveComponent("page-bar");
|
|
@@ -4375,16 +4743,16 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4375
4743
|
]),
|
|
4376
4744
|
_: 3
|
|
4377
4745
|
})
|
|
4378
|
-
]);
|
|
4746
|
+
], 512);
|
|
4379
4747
|
}
|
|
4380
4748
|
var Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
4381
4749
|
|
|
4382
4750
|
class ComponentList extends BaseService {
|
|
4383
|
-
state = reactive({
|
|
4384
|
-
list: []
|
|
4385
|
-
});
|
|
4386
4751
|
constructor() {
|
|
4387
4752
|
super([]);
|
|
4753
|
+
this.state = reactive({
|
|
4754
|
+
list: []
|
|
4755
|
+
});
|
|
4388
4756
|
}
|
|
4389
4757
|
setList(componentGroupList) {
|
|
4390
4758
|
this.state.list = componentGroupList;
|
|
@@ -4450,6 +4818,11 @@ class Ui extends BaseService {
|
|
|
4450
4818
|
get(name) {
|
|
4451
4819
|
return state[name];
|
|
4452
4820
|
}
|
|
4821
|
+
zoom(zoom) {
|
|
4822
|
+
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
4823
|
+
if (this.get("zoom") < 0.1)
|
|
4824
|
+
this.set("zoom", 0.1);
|
|
4825
|
+
}
|
|
4453
4826
|
setColumnWidth({ left, center, right }) {
|
|
4454
4827
|
const columnWidth = {
|
|
4455
4828
|
...toRaw(this.get("columnWidth"))
|
|
@@ -4663,5 +5036,5 @@ var index = {
|
|
|
4663
5036
|
}
|
|
4664
5037
|
};
|
|
4665
5038
|
|
|
4666
|
-
export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, generateId, generatePageName, generatePageNameByApp, getConfig, getDefaultPropsValue, getNodeIndex, getPageList, getPageNameList, historyService, info, initPosition, isFixed, log, propsService, setConfig, setLayout, setNewItemId, toRelative, uiService, warn };
|
|
5039
|
+
export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, ToolButton, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, generateId, generatePageName, generatePageNameByApp, getConfig, getDefaultPropsValue, getNodeIndex, getPageList, getPageNameList, historyService, info, initPosition, isFixed, log, propsService, setConfig, setLayout, setNewItemId, toRelative, uiService, warn };
|
|
4667
5040
|
//# sourceMappingURL=tmagic-editor.es.js.map
|