@tmagic/editor 1.1.0-beta.3 → 1.1.0-beta.6
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/dist/style.css +1 -1
- package/dist/{tmagic-editor.es.js → tmagic-editor.mjs} +1342 -1130
- package/dist/tmagic-editor.mjs.map +1 -0
- package/dist/tmagic-editor.umd.js +1357 -1145
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +21 -19
- package/src/Editor.vue +14 -12
- package/src/components/ContentMenu.vue +87 -99
- package/src/components/ScrollViewer.vue +2 -2
- package/src/components/ToolButton.vue +150 -167
- package/src/fields/UISelect.vue +50 -70
- package/src/index.ts +1 -0
- package/src/layouts/AddPageBox.vue +2 -2
- package/src/layouts/Framework.vue +1 -1
- package/src/layouts/NavMenu.vue +2 -2
- package/src/layouts/PropsPanel.vue +1 -1
- package/src/layouts/Resizer.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +2 -2
- package/src/layouts/sidebar/LayerMenu.vue +2 -2
- package/src/layouts/sidebar/LayerPanel.vue +13 -4
- package/src/layouts/sidebar/Sidebar.vue +1 -1
- package/src/layouts/sidebar/TabPane.vue +2 -2
- package/src/layouts/workspace/PageBar.vue +53 -64
- package/src/layouts/workspace/Stage.vue +195 -220
- package/src/layouts/workspace/ViewerMenu.vue +142 -146
- package/src/layouts/workspace/Workspace.vue +11 -11
- package/src/services/BaseService.ts +1 -1
- package/src/services/componentList.ts +3 -3
- package/src/services/editor.ts +118 -135
- package/src/services/events.ts +1 -1
- package/src/services/history.ts +1 -1
- package/src/services/props.ts +63 -11
- package/src/services/storage.ts +133 -0
- package/src/services/ui.ts +10 -4
- package/src/theme/framework.scss +1 -1
- package/src/theme/stage.scss +2 -2
- package/src/type.ts +23 -6
- package/src/utils/config.ts +1 -1
- package/src/utils/editor.ts +1 -1
- package/src/utils/operator.ts +210 -0
- package/src/utils/props.ts +2 -24
- package/src/utils/scroll-viewer.ts +1 -1
- package/tsconfig.build.json +13 -0
- package/{dist/types/src → types}/Editor.vue.d.ts +7 -8
- package/types/components/ContentMenu.vue.d.ts +116 -0
- package/types/components/Icon.vue.d.ts +13 -0
- package/types/components/ScrollViewer.vue.d.ts +22 -0
- package/types/components/ToolButton.vue.d.ts +109 -0
- package/types/fields/Code.vue.d.ts +23 -0
- package/{dist/types/src → types}/fields/CodeLink.vue.d.ts +4 -6
- package/types/fields/UISelect.vue.d.ts +87 -0
- package/{dist/types/src → types}/index.d.ts +4 -1
- package/types/layouts/AddPageBox.vue.d.ts +4 -0
- package/{dist/types/src → types}/layouts/CodeEditor.vue.d.ts +11 -13
- package/types/layouts/Framework.vue.d.ts +22 -0
- package/types/layouts/NavMenu.vue.d.ts +25 -0
- package/types/layouts/PropsPanel.vue.d.ts +245 -0
- package/types/layouts/Resizer.vue.d.ts +12 -0
- package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +14 -0
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +100 -0
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +1099 -0
- package/{dist/types/src → types}/layouts/sidebar/Sidebar.vue.d.ts +3 -5
- package/types/layouts/sidebar/TabPane.vue.d.ts +14 -0
- package/types/layouts/workspace/PageBar.vue.d.ts +54 -0
- package/types/layouts/workspace/Stage.vue.d.ts +46 -0
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +88 -0
- package/types/layouts/workspace/Workspace.vue.d.ts +6 -0
- package/{dist/types/src → types}/services/BaseService.d.ts +0 -0
- package/types/services/componentList.d.ts +14 -0
- package/{dist/types/src → types}/services/editor.d.ts +26 -11
- package/{dist/types/src → types}/services/events.d.ts +0 -0
- package/{dist/types/src → types}/services/history.d.ts +0 -0
- package/{dist/types/src → types}/services/props.d.ts +26 -2
- package/types/services/storage.d.ts +56 -0
- package/{dist/types/src → types}/services/ui.d.ts +1 -1
- package/{dist/types/src → types}/type.d.ts +16 -0
- package/{dist/types/src → types}/utils/compose.d.ts +1 -1
- package/{dist/types/src → types}/utils/config.d.ts +0 -0
- package/{dist/types/src → types}/utils/editor.d.ts +2 -2
- package/{dist/types/src → types}/utils/index.d.ts +0 -0
- package/{dist/types/src → types}/utils/logger.d.ts +0 -0
- package/types/utils/operator.d.ts +44 -0
- package/{dist/types/src → types}/utils/polyfills.d.ts +0 -0
- package/{dist/types/src → types}/utils/props.d.ts +2 -22
- package/{dist/types/src → types}/utils/scroll-viewer.d.ts +0 -0
- package/{dist/types/src → types}/utils/undo-redo.d.ts +0 -0
- package/dist/tmagic-editor.es.js.map +0 -1
- package/dist/types/src/components/Icon.vue.d.ts +0 -14
- package/dist/types/src/components/ScrollViewer.vue.d.ts +0 -24
- package/dist/types/src/fields/Code.vue.d.ts +0 -25
- package/dist/types/src/layouts/AddPageBox.vue.d.ts +0 -5
- package/dist/types/src/layouts/Framework.vue.d.ts +0 -24
- package/dist/types/src/layouts/NavMenu.vue.d.ts +0 -27
- package/dist/types/src/layouts/PropsPanel.vue.d.ts +0 -13
- package/dist/types/src/layouts/Resizer.vue.d.ts +0 -14
- package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +0 -16
- package/dist/types/src/layouts/sidebar/TabPane.vue.d.ts +0 -16
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +0 -8
- package/dist/types/src/shims-vue.d.ts +0 -6
- package/dist/types/src/vite-env.d.ts +0 -1
- package/src/vite-env.d.ts +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject,
|
|
1
|
+
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, createElementBlock, createVNode, unref, withCtx, withModifiers, createCommentVNode, createTextVNode, toDisplayString, watch, onMounted, onUnmounted, reactive, toRaw, createElementVNode, renderSlot, Fragment, normalizeClass, resolveDynamicComponent, markRaw, renderList, normalizeProps, mergeProps, getCurrentInstance, Teleport, nextTick, toHandlers, createSlots, provide } from 'vue';
|
|
2
2
|
import serialize from 'serialize-javascript';
|
|
3
|
-
import { Delete,
|
|
4
|
-
import { throttle, cloneDeep, mergeWith,
|
|
3
|
+
import { Delete, Close, Plus, Edit, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, ArrowDown, Files, DocumentCopy, Coin, ArrowLeftBold, CaretBottom, ArrowRightBold, Top, Bottom } from '@element-plus/icons-vue';
|
|
4
|
+
import { throttle, cloneDeep, mergeWith, isEmpty, uniq } from 'lodash-es';
|
|
5
5
|
import * as monaco from 'monaco-editor';
|
|
6
6
|
import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS } from '@tmagic/stage';
|
|
7
7
|
import { NodeType } from '@tmagic/schema';
|
|
8
|
-
import {
|
|
8
|
+
import { isPop, getNodePath, isNumber, isPage, toLine, removeClassNameByClassName } from '@tmagic/utils';
|
|
9
9
|
import { EventEmitter } from 'events';
|
|
10
10
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
11
11
|
import Gesto from 'gesto';
|
|
@@ -19,14 +19,6 @@ if (typeof globalThis === "undefined") {
|
|
|
19
19
|
window.globalThis = window;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
var _export_sfc = (sfc, props) => {
|
|
23
|
-
const target = sfc.__vccOpts || sfc;
|
|
24
|
-
for (const [key, val] of props) {
|
|
25
|
-
target[key] = val;
|
|
26
|
-
}
|
|
27
|
-
return target;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
22
|
const _sfc_main$m = defineComponent({
|
|
31
23
|
name: "m-fields-vs-code",
|
|
32
24
|
props: ["model", "name", "config", "prop"],
|
|
@@ -44,7 +36,16 @@ const _sfc_main$m = defineComponent({
|
|
|
44
36
|
};
|
|
45
37
|
}
|
|
46
38
|
});
|
|
47
|
-
|
|
39
|
+
|
|
40
|
+
const _export_sfc = (sfc, props) => {
|
|
41
|
+
const target = sfc.__vccOpts || sfc;
|
|
42
|
+
for (const [key, val] of props) {
|
|
43
|
+
target[key] = val;
|
|
44
|
+
}
|
|
45
|
+
return target;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
48
49
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
49
50
|
return openBlock(), createBlock(_component_magic_code_editor, {
|
|
50
51
|
style: normalizeStyle(`height: ${_ctx.height}`),
|
|
@@ -53,7 +54,7 @@ function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
53
54
|
onSave: _ctx.save
|
|
54
55
|
}, null, 8, ["style", "init-values", "language", "onSave"]);
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
+
const Code = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$g]]);
|
|
57
58
|
|
|
58
59
|
const _sfc_main$l = defineComponent({
|
|
59
60
|
name: "m-fields-code-link",
|
|
@@ -110,7 +111,8 @@ const _sfc_main$l = defineComponent({
|
|
|
110
111
|
};
|
|
111
112
|
}
|
|
112
113
|
});
|
|
113
|
-
|
|
114
|
+
|
|
115
|
+
function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
114
116
|
const _component_m_fields_link = resolveComponent("m-fields-link");
|
|
115
117
|
return openBlock(), createBlock(_component_m_fields_link, {
|
|
116
118
|
config: _ctx.formConfig,
|
|
@@ -119,26 +121,21 @@ function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
119
121
|
onChange: _ctx.changeHandler
|
|
120
122
|
}, null, 8, ["config", "model", "onChange"]);
|
|
121
123
|
}
|
|
122
|
-
|
|
124
|
+
const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$f]]);
|
|
123
125
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
name: "m-fields-ui-select",
|
|
126
|
+
const _hoisted_1$d = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
|
|
127
|
+
const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
128
|
+
__name: "UISelect",
|
|
128
129
|
props: {
|
|
129
|
-
labelWidth:
|
|
130
|
-
config:
|
|
131
|
-
model:
|
|
132
|
-
prop:
|
|
133
|
-
|
|
134
|
-
default() {
|
|
135
|
-
return "";
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
name: String
|
|
130
|
+
labelWidth: null,
|
|
131
|
+
config: null,
|
|
132
|
+
model: null,
|
|
133
|
+
prop: null,
|
|
134
|
+
name: null
|
|
139
135
|
},
|
|
140
136
|
emits: ["change"],
|
|
141
|
-
setup(
|
|
137
|
+
setup(__props, { emit }) {
|
|
138
|
+
const props = __props;
|
|
142
139
|
const services = inject("services");
|
|
143
140
|
const mForm = inject("mForm");
|
|
144
141
|
const val = computed(() => props.model[props.name]);
|
|
@@ -160,92 +157,84 @@ const _sfc_main$k = defineComponent({
|
|
|
160
157
|
cancelHandler();
|
|
161
158
|
}
|
|
162
159
|
};
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
},
|
|
180
|
-
cancelHandler,
|
|
181
|
-
deleteHandler() {
|
|
182
|
-
if (props.model) {
|
|
183
|
-
props.model[props.name] = "";
|
|
184
|
-
emit("change", "");
|
|
185
|
-
mForm?.$emit("field-change", props.prop, "");
|
|
186
|
-
}
|
|
160
|
+
const toName = computed(() => {
|
|
161
|
+
const config = services?.editorService.getNodeById(val.value);
|
|
162
|
+
return config?.name || "";
|
|
163
|
+
});
|
|
164
|
+
const startSelect = () => {
|
|
165
|
+
if (!services?.uiService)
|
|
166
|
+
return;
|
|
167
|
+
services.uiService.set("uiSelectMode", true);
|
|
168
|
+
uiSelectMode.value = true;
|
|
169
|
+
globalThis.document.addEventListener("ui-select", clickHandler);
|
|
170
|
+
};
|
|
171
|
+
const deleteHandler = () => {
|
|
172
|
+
if (props.model) {
|
|
173
|
+
props.model[props.name] = "";
|
|
174
|
+
emit("change", "");
|
|
175
|
+
mForm?.$emit("field-change", props.prop, "");
|
|
187
176
|
}
|
|
188
177
|
};
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
class: "m-fields-ui-select",
|
|
198
|
-
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.cancelHandler && _ctx.cancelHandler(...args))
|
|
199
|
-
}, [
|
|
200
|
-
createVNode(_component_el_button, {
|
|
201
|
-
type: "danger",
|
|
202
|
-
icon: _ctx.Delete,
|
|
203
|
-
text: "",
|
|
204
|
-
style: { "padding": "0" }
|
|
205
|
-
}, {
|
|
206
|
-
default: withCtx(() => [
|
|
207
|
-
_hoisted_1$d
|
|
208
|
-
]),
|
|
209
|
-
_: 1
|
|
210
|
-
}, 8, ["icon"])
|
|
211
|
-
])) : (openBlock(), createElementBlock("div", {
|
|
212
|
-
key: 1,
|
|
213
|
-
class: "m-fields-ui-select",
|
|
214
|
-
onClick: _cache[1] || (_cache[1] = (...args) => _ctx.startSelect && _ctx.startSelect(...args)),
|
|
215
|
-
style: { "display": "flex" }
|
|
216
|
-
}, [
|
|
217
|
-
createVNode(_component_el_tooltip, { content: "\u6E05\u9664" }, {
|
|
218
|
-
default: withCtx(() => [
|
|
219
|
-
_ctx.val ? (openBlock(), createBlock(_component_el_button, {
|
|
220
|
-
key: 0,
|
|
221
|
-
style: { "padding": "0" },
|
|
222
|
-
type: "danger",
|
|
223
|
-
icon: _ctx.Close,
|
|
224
|
-
text: "",
|
|
225
|
-
onClick: withModifiers(_ctx.deleteHandler, ["stop"])
|
|
226
|
-
}, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
|
|
227
|
-
]),
|
|
228
|
-
_: 1
|
|
229
|
-
}),
|
|
230
|
-
createVNode(_component_el_tooltip, {
|
|
231
|
-
content: _ctx.val ? _ctx.toName + "_" + _ctx.val : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
|
|
232
|
-
}, {
|
|
233
|
-
default: withCtx(() => [
|
|
178
|
+
return (_ctx, _cache) => {
|
|
179
|
+
const _component_el_button = resolveComponent("el-button");
|
|
180
|
+
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
181
|
+
return uiSelectMode.value ? (openBlock(), createElementBlock("div", {
|
|
182
|
+
key: 0,
|
|
183
|
+
class: "m-fields-ui-select",
|
|
184
|
+
onClick: cancelHandler
|
|
185
|
+
}, [
|
|
234
186
|
createVNode(_component_el_button, {
|
|
187
|
+
type: "danger",
|
|
188
|
+
icon: unref(Delete),
|
|
235
189
|
text: "",
|
|
236
|
-
style: { "padding": "0"
|
|
190
|
+
style: { "padding": "0" }
|
|
237
191
|
}, {
|
|
238
192
|
default: withCtx(() => [
|
|
239
|
-
|
|
193
|
+
_hoisted_1$d
|
|
240
194
|
]),
|
|
241
195
|
_: 1
|
|
242
|
-
})
|
|
243
|
-
]),
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
|
|
196
|
+
}, 8, ["icon"])
|
|
197
|
+
])) : (openBlock(), createElementBlock("div", {
|
|
198
|
+
key: 1,
|
|
199
|
+
class: "m-fields-ui-select",
|
|
200
|
+
onClick: startSelect,
|
|
201
|
+
style: { "display": "flex" }
|
|
202
|
+
}, [
|
|
203
|
+
createVNode(_component_el_tooltip, { content: "\u6E05\u9664" }, {
|
|
204
|
+
default: withCtx(() => [
|
|
205
|
+
unref(val) ? (openBlock(), createBlock(_component_el_button, {
|
|
206
|
+
key: 0,
|
|
207
|
+
style: { "padding": "0" },
|
|
208
|
+
type: "danger",
|
|
209
|
+
icon: unref(Close),
|
|
210
|
+
text: "",
|
|
211
|
+
onClick: withModifiers(deleteHandler, ["stop"])
|
|
212
|
+
}, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
|
|
213
|
+
]),
|
|
214
|
+
_: 1
|
|
215
|
+
}),
|
|
216
|
+
createVNode(_component_el_tooltip, {
|
|
217
|
+
content: unref(val) ? unref(toName) + "_" + unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
|
|
218
|
+
}, {
|
|
219
|
+
default: withCtx(() => [
|
|
220
|
+
createVNode(_component_el_button, {
|
|
221
|
+
text: "",
|
|
222
|
+
style: { "padding": "0", "margin": "0" }
|
|
223
|
+
}, {
|
|
224
|
+
default: withCtx(() => [
|
|
225
|
+
createTextVNode(toDisplayString(unref(val) ? unref(toName) + "_" + unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1)
|
|
226
|
+
]),
|
|
227
|
+
_: 1
|
|
228
|
+
})
|
|
229
|
+
]),
|
|
230
|
+
_: 1
|
|
231
|
+
}, 8, ["content"])
|
|
232
|
+
]));
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
const UISelect_vue_vue_type_style_index_0_lang = '';
|
|
249
238
|
|
|
250
239
|
const toString = (v, language) => {
|
|
251
240
|
let value = "";
|
|
@@ -369,14 +358,15 @@ const _sfc_main$j = defineComponent({
|
|
|
369
358
|
};
|
|
370
359
|
}
|
|
371
360
|
});
|
|
361
|
+
|
|
372
362
|
const _hoisted_1$c = {
|
|
373
363
|
ref: "codeEditor",
|
|
374
364
|
class: "magic-code-editor"
|
|
375
365
|
};
|
|
376
|
-
function _sfc_render$
|
|
366
|
+
function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
377
367
|
return openBlock(), createElementBlock("div", _hoisted_1$c, null, 512);
|
|
378
368
|
}
|
|
379
|
-
|
|
369
|
+
const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$e]]);
|
|
380
370
|
|
|
381
371
|
let $TMAGIC_EDITOR = {};
|
|
382
372
|
const setConfig = (option) => {
|
|
@@ -385,6 +375,9 @@ const setConfig = (option) => {
|
|
|
385
375
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
386
376
|
|
|
387
377
|
class UndoRedo {
|
|
378
|
+
elementList;
|
|
379
|
+
listCursor;
|
|
380
|
+
listMaxSize;
|
|
388
381
|
constructor(listMaxSize = 200) {
|
|
389
382
|
const minListMaxSize = 2;
|
|
390
383
|
this.elementList = [];
|
|
@@ -480,12 +473,12 @@ const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethod
|
|
|
480
473
|
}
|
|
481
474
|
};
|
|
482
475
|
class BaseService extends EventEmitter {
|
|
476
|
+
pluginOptionsList = {};
|
|
477
|
+
middleware = {};
|
|
478
|
+
taskList = [];
|
|
479
|
+
doingTask = false;
|
|
483
480
|
constructor(methods = [], serialMethods = []) {
|
|
484
481
|
super();
|
|
485
|
-
this.pluginOptionsList = {};
|
|
486
|
-
this.middleware = {};
|
|
487
|
-
this.taskList = [];
|
|
488
|
-
this.doingTask = false;
|
|
489
482
|
methods.forEach((propertyName) => {
|
|
490
483
|
const scope = this;
|
|
491
484
|
const sourceMethod = scope[propertyName];
|
|
@@ -542,14 +535,14 @@ class BaseService extends EventEmitter {
|
|
|
542
535
|
}
|
|
543
536
|
|
|
544
537
|
class History extends BaseService {
|
|
538
|
+
state = reactive({
|
|
539
|
+
pageSteps: {},
|
|
540
|
+
pageId: void 0,
|
|
541
|
+
canRedo: false,
|
|
542
|
+
canUndo: false
|
|
543
|
+
});
|
|
545
544
|
constructor() {
|
|
546
545
|
super([]);
|
|
547
|
-
this.state = reactive({
|
|
548
|
-
pageSteps: {},
|
|
549
|
-
pageId: void 0,
|
|
550
|
-
canRedo: false,
|
|
551
|
-
canUndo: false
|
|
552
|
-
});
|
|
553
546
|
this.on("change", this.setCanUndoRedo);
|
|
554
547
|
}
|
|
555
548
|
reset() {
|
|
@@ -618,88 +611,88 @@ class History extends BaseService {
|
|
|
618
611
|
this.state.canUndo = undoRedo?.canUndo() || false;
|
|
619
612
|
}
|
|
620
613
|
}
|
|
621
|
-
|
|
614
|
+
const historyService = new History();
|
|
622
615
|
|
|
623
|
-
|
|
616
|
+
var Protocol = /* @__PURE__ */ ((Protocol2) => {
|
|
617
|
+
Protocol2["OBJECT"] = "object";
|
|
618
|
+
Protocol2["JSON"] = "json";
|
|
619
|
+
Protocol2["STRING"] = "string";
|
|
620
|
+
Protocol2["NUMBER"] = "number";
|
|
621
|
+
Protocol2["BOOLEAN"] = "boolean";
|
|
622
|
+
return Protocol2;
|
|
623
|
+
})(Protocol || {});
|
|
624
|
+
class WebStorage extends BaseService {
|
|
625
|
+
storage = globalThis.localStorage;
|
|
626
|
+
namespace = "tmagic";
|
|
624
627
|
constructor() {
|
|
625
|
-
super(["
|
|
626
|
-
this.state = reactive({
|
|
627
|
-
propsConfigMap: {},
|
|
628
|
-
propsValueMap: {}
|
|
629
|
-
});
|
|
628
|
+
super(["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"]);
|
|
630
629
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
this.setPropsConfig(toLine(type), configs[type]);
|
|
634
|
-
});
|
|
635
|
-
this.emit("props-configs-change");
|
|
630
|
+
async getStorage() {
|
|
631
|
+
return this.storage;
|
|
636
632
|
}
|
|
637
|
-
|
|
638
|
-
this.
|
|
633
|
+
async getNamespace() {
|
|
634
|
+
return this.namespace;
|
|
639
635
|
}
|
|
640
|
-
async
|
|
641
|
-
|
|
642
|
-
|
|
636
|
+
async clear() {
|
|
637
|
+
const storage2 = await this.getStorage();
|
|
638
|
+
storage2.clear();
|
|
639
|
+
}
|
|
640
|
+
async getItem(key, options = {}) {
|
|
641
|
+
const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
642
|
+
const { protocol = options.protocol, item } = this.getValueAndProtocol(storage.getItem(`${options.namespace || namespace}:${key}`));
|
|
643
|
+
if (item === null)
|
|
644
|
+
return null;
|
|
645
|
+
switch (protocol) {
|
|
646
|
+
case "object" /* OBJECT */:
|
|
647
|
+
return eval(`(${item})`);
|
|
648
|
+
case "json" /* JSON */:
|
|
649
|
+
return JSON.parse(item);
|
|
650
|
+
case "number" /* NUMBER */:
|
|
651
|
+
return Number(item);
|
|
652
|
+
case "boolean" /* BOOLEAN */:
|
|
653
|
+
return Boolean(item);
|
|
654
|
+
default:
|
|
655
|
+
return item;
|
|
643
656
|
}
|
|
644
|
-
return cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
|
|
645
657
|
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
});
|
|
658
|
+
async key(index) {
|
|
659
|
+
const storage2 = await this.getStorage();
|
|
660
|
+
return storage2.key(index);
|
|
650
661
|
}
|
|
651
|
-
|
|
652
|
-
|
|
662
|
+
async removeItem(key2, options2 = {}) {
|
|
663
|
+
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
664
|
+
storage2.removeItem(`${options2.namespace || namespace2}:${key2}`);
|
|
653
665
|
}
|
|
654
|
-
async
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
}
|
|
662
|
-
|
|
666
|
+
async setItem(key2, value, options2 = {}) {
|
|
667
|
+
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
668
|
+
let item2 = value;
|
|
669
|
+
const protocol2 = options2.protocol ? `${options2.protocol}:` : "";
|
|
670
|
+
if (typeof value === "string" /* STRING */ || typeof value === "number" /* NUMBER */) {
|
|
671
|
+
item2 = `${protocol2}${value}`;
|
|
672
|
+
} else {
|
|
673
|
+
item2 = `${protocol2}${serialize(value)}`;
|
|
674
|
+
}
|
|
675
|
+
storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
|
|
676
|
+
}
|
|
677
|
+
getValueAndProtocol(value) {
|
|
678
|
+
let protocol2 = "";
|
|
679
|
+
if (value === null) {
|
|
680
|
+
return {
|
|
681
|
+
item: value,
|
|
682
|
+
protocol: protocol2
|
|
683
|
+
};
|
|
663
684
|
}
|
|
664
|
-
const
|
|
665
|
-
|
|
685
|
+
const item2 = value.replace(new RegExp(`^(${Object.values(Protocol).join("|")})(:)(.+)`), (_$0, $1, _$2, $3) => {
|
|
686
|
+
protocol2 = $1;
|
|
687
|
+
return $3;
|
|
688
|
+
});
|
|
666
689
|
return {
|
|
667
|
-
|
|
668
|
-
|
|
690
|
+
protocol: protocol2,
|
|
691
|
+
item: item2
|
|
669
692
|
};
|
|
670
693
|
}
|
|
671
|
-
async createId(type) {
|
|
672
|
-
return `${type}_${random(1e4, false)}`;
|
|
673
|
-
}
|
|
674
|
-
async setNewItemId(config, parent) {
|
|
675
|
-
const oldId = config.id;
|
|
676
|
-
config.id = await this.createId(config.type || "component");
|
|
677
|
-
if (isPop(config) && parent?.type === NodeType.PAGE) {
|
|
678
|
-
updatePopId(oldId, config.id, parent);
|
|
679
|
-
}
|
|
680
|
-
if (config.items && Array.isArray(config.items)) {
|
|
681
|
-
for (const item of config.items) {
|
|
682
|
-
await this.setNewItemId(item, config);
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
694
|
}
|
|
687
|
-
const
|
|
688
|
-
pageConfig.items?.forEach((config) => {
|
|
689
|
-
if (config.pop === oldId) {
|
|
690
|
-
config.pop = popId;
|
|
691
|
-
return;
|
|
692
|
-
}
|
|
693
|
-
if (config.popId === oldId) {
|
|
694
|
-
config.popId = popId;
|
|
695
|
-
return;
|
|
696
|
-
}
|
|
697
|
-
if (Array.isArray(config.items)) {
|
|
698
|
-
updatePopId(oldId, popId, config);
|
|
699
|
-
}
|
|
700
|
-
});
|
|
701
|
-
};
|
|
702
|
-
var propsService = new Props();
|
|
695
|
+
const storageService = new WebStorage();
|
|
703
696
|
|
|
704
697
|
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
705
698
|
LayerOffset2["TOP"] = "top";
|
|
@@ -863,7 +856,266 @@ const fixNodeLeft = (config, parent, doc) => {
|
|
|
863
856
|
return config.style.left;
|
|
864
857
|
};
|
|
865
858
|
|
|
859
|
+
class Props extends BaseService {
|
|
860
|
+
state = reactive({
|
|
861
|
+
propsConfigMap: {},
|
|
862
|
+
propsValueMap: {}
|
|
863
|
+
});
|
|
864
|
+
constructor() {
|
|
865
|
+
super([
|
|
866
|
+
"setPropsConfig",
|
|
867
|
+
"getPropsConfig",
|
|
868
|
+
"setPropsValue",
|
|
869
|
+
"getPropsValue",
|
|
870
|
+
"createId",
|
|
871
|
+
"setNewItemId",
|
|
872
|
+
"getDefaultPropsValue"
|
|
873
|
+
]);
|
|
874
|
+
}
|
|
875
|
+
setPropsConfigs(configs) {
|
|
876
|
+
Object.keys(configs).forEach((type) => {
|
|
877
|
+
this.setPropsConfig(toLine(type), configs[type]);
|
|
878
|
+
});
|
|
879
|
+
this.emit("props-configs-change");
|
|
880
|
+
}
|
|
881
|
+
setPropsConfig(type, config) {
|
|
882
|
+
this.state.propsConfigMap[type] = fillConfig(Array.isArray(config) ? config : [config]);
|
|
883
|
+
}
|
|
884
|
+
async getPropsConfig(type) {
|
|
885
|
+
if (type === "area") {
|
|
886
|
+
return await this.getPropsConfig("button");
|
|
887
|
+
}
|
|
888
|
+
return cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
|
|
889
|
+
}
|
|
890
|
+
setPropsValues(values) {
|
|
891
|
+
Object.keys(values).forEach((type) => {
|
|
892
|
+
this.setPropsValue(toLine(type), values[type]);
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
setPropsValue(type, value) {
|
|
896
|
+
this.state.propsValueMap[type] = value;
|
|
897
|
+
}
|
|
898
|
+
async getPropsValue(type, { inputEvent, ...defaultValue } = {}) {
|
|
899
|
+
if (type === "area") {
|
|
900
|
+
const value = await this.getPropsValue("button");
|
|
901
|
+
value.className = "action-area";
|
|
902
|
+
value.text = "";
|
|
903
|
+
if (value.style) {
|
|
904
|
+
value.style.backgroundColor = "rgba(255, 255, 255, 0)";
|
|
905
|
+
}
|
|
906
|
+
return value;
|
|
907
|
+
}
|
|
908
|
+
const [id, defaultPropsValue, data] = await Promise.all([
|
|
909
|
+
this.createId(type),
|
|
910
|
+
this.getDefaultPropsValue(type),
|
|
911
|
+
this.setNewItemId(cloneDeep({
|
|
912
|
+
type,
|
|
913
|
+
...defaultValue
|
|
914
|
+
}))
|
|
915
|
+
]);
|
|
916
|
+
return {
|
|
917
|
+
id,
|
|
918
|
+
...defaultPropsValue,
|
|
919
|
+
...mergeWith({}, cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
guid(digit = 8) {
|
|
923
|
+
return "x".repeat(digit).replace(/[xy]/g, (c) => {
|
|
924
|
+
const r = Math.random() * 16 | 0;
|
|
925
|
+
const v = c == "x" ? r : r & 3 | 8;
|
|
926
|
+
return v.toString(16);
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
async createId(type) {
|
|
930
|
+
return `${type}_${this.guid()}`;
|
|
931
|
+
}
|
|
932
|
+
async setNewItemId(config, parent) {
|
|
933
|
+
const oldId = config.id;
|
|
934
|
+
config.id = await this.createId(config.type || "component");
|
|
935
|
+
if (isPop(config) && parent?.type === NodeType.PAGE) {
|
|
936
|
+
updatePopId(oldId, config.id, parent);
|
|
937
|
+
}
|
|
938
|
+
if (config.items && Array.isArray(config.items)) {
|
|
939
|
+
for (const item of config.items) {
|
|
940
|
+
await this.setNewItemId(item, config);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
return config;
|
|
944
|
+
}
|
|
945
|
+
async getDefaultPropsValue(type) {
|
|
946
|
+
return ["page", "container"].includes(type) ? {
|
|
947
|
+
type,
|
|
948
|
+
layout: "absolute",
|
|
949
|
+
style: {},
|
|
950
|
+
name: type,
|
|
951
|
+
items: []
|
|
952
|
+
} : {
|
|
953
|
+
type,
|
|
954
|
+
style: {},
|
|
955
|
+
name: type
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
const updatePopId = (oldId, popId, pageConfig) => {
|
|
960
|
+
pageConfig.items?.forEach((config) => {
|
|
961
|
+
if (config.pop === oldId) {
|
|
962
|
+
config.pop = popId;
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
if (config.popId === oldId) {
|
|
966
|
+
config.popId = popId;
|
|
967
|
+
return;
|
|
968
|
+
}
|
|
969
|
+
if (Array.isArray(config.items)) {
|
|
970
|
+
updatePopId(oldId, popId, config);
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
};
|
|
974
|
+
const propsService = new Props();
|
|
975
|
+
|
|
976
|
+
const beforePaste = async (position, config) => {
|
|
977
|
+
if (!config[0]?.style)
|
|
978
|
+
return config;
|
|
979
|
+
const curNode = editorService.get("node");
|
|
980
|
+
const { left: referenceLeft, top: referenceTop } = config[0].style;
|
|
981
|
+
const pasteConfigs = await Promise.all(config.map(async (configItem) => {
|
|
982
|
+
const { offsetX = 0, offsetY = 0, ...positionClone } = position;
|
|
983
|
+
let pastePosition = positionClone;
|
|
984
|
+
if (!isEmpty(pastePosition) && curNode.items) {
|
|
985
|
+
pastePosition = getPositionInContainer(pastePosition, curNode.id);
|
|
986
|
+
}
|
|
987
|
+
if (pastePosition.left && configItem.style?.left) {
|
|
988
|
+
pastePosition.left = configItem.style.left - referenceLeft + pastePosition.left;
|
|
989
|
+
}
|
|
990
|
+
if (pastePosition.top && configItem.style?.top) {
|
|
991
|
+
pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
|
|
992
|
+
}
|
|
993
|
+
const pasteConfig = await propsService.setNewItemId(configItem, editorService.get("root"));
|
|
994
|
+
if (pasteConfig.style) {
|
|
995
|
+
const { left, top } = pasteConfig.style;
|
|
996
|
+
if (typeof left === "number" || !!left && !isNaN(Number(left))) {
|
|
997
|
+
pasteConfig.style.left = Number(left) + offsetX;
|
|
998
|
+
}
|
|
999
|
+
if (typeof top === "number" || !!top && !isNaN(Number(top))) {
|
|
1000
|
+
pasteConfig.style.top = Number(top) + offsetY;
|
|
1001
|
+
}
|
|
1002
|
+
pasteConfig.style = {
|
|
1003
|
+
...pasteConfig.style,
|
|
1004
|
+
...pastePosition
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
if (isPage(pasteConfig)) {
|
|
1008
|
+
pasteConfig.name = generatePageNameByApp(editorService.get("root"));
|
|
1009
|
+
}
|
|
1010
|
+
return pasteConfig;
|
|
1011
|
+
}));
|
|
1012
|
+
return pasteConfigs;
|
|
1013
|
+
};
|
|
1014
|
+
const beforeAdd = async (addNode, parent) => {
|
|
1015
|
+
const { type, inputEvent, ...config } = addNode;
|
|
1016
|
+
const curNode = editorService.get("node");
|
|
1017
|
+
let parentNode;
|
|
1018
|
+
const isPage2 = type === NodeType.PAGE;
|
|
1019
|
+
if (isPage2) {
|
|
1020
|
+
parentNode = editorService.get("root");
|
|
1021
|
+
} else if (parent && typeof parent !== "function") {
|
|
1022
|
+
parentNode = parent;
|
|
1023
|
+
} else if (curNode.items) {
|
|
1024
|
+
parentNode = curNode;
|
|
1025
|
+
} else {
|
|
1026
|
+
parentNode = editorService.getParentById(curNode.id, false);
|
|
1027
|
+
}
|
|
1028
|
+
if (!parentNode)
|
|
1029
|
+
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1030
|
+
const layout = await editorService.getLayout(toRaw(parentNode), addNode);
|
|
1031
|
+
const newNode = { ...toRaw(await propsService.getPropsValue(type, config)) };
|
|
1032
|
+
newNode.style = getInitPositionStyle(newNode.style, layout, parentNode, editorService.get("stage"));
|
|
1033
|
+
if ((parentNode?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && newNode.type !== NodeType.PAGE) {
|
|
1034
|
+
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
1035
|
+
}
|
|
1036
|
+
parentNode?.items?.push(newNode);
|
|
1037
|
+
return {
|
|
1038
|
+
parentNode,
|
|
1039
|
+
newNode,
|
|
1040
|
+
layout,
|
|
1041
|
+
isPage: isPage2
|
|
1042
|
+
};
|
|
1043
|
+
};
|
|
1044
|
+
const getPositionInContainer = (position = {}, id) => {
|
|
1045
|
+
let { left = 0, top = 0 } = position;
|
|
1046
|
+
const parentEl = editorService.get("stage")?.renderer?.contentWindow?.document.getElementById(`${id}`);
|
|
1047
|
+
const parentElRect = parentEl?.getBoundingClientRect();
|
|
1048
|
+
left = left - (parentElRect?.left || 0);
|
|
1049
|
+
top = top - (parentElRect?.top || 0);
|
|
1050
|
+
return {
|
|
1051
|
+
left,
|
|
1052
|
+
top
|
|
1053
|
+
};
|
|
1054
|
+
};
|
|
1055
|
+
const notifyAddToStage = async (parentNode, newNode, layout) => {
|
|
1056
|
+
const stage = editorService.get("stage");
|
|
1057
|
+
const root = editorService.get("root");
|
|
1058
|
+
await stage?.add({ config: cloneDeep(newNode), parent: cloneDeep(parentNode), root: cloneDeep(root) });
|
|
1059
|
+
if (layout === Layout.ABSOLUTE) {
|
|
1060
|
+
const fixedLeft = fixNodeLeft(newNode, parentNode, stage?.renderer.contentWindow?.document);
|
|
1061
|
+
if (typeof fixedLeft !== "undefined" && newNode.style) {
|
|
1062
|
+
newNode.style.left = fixedLeft;
|
|
1063
|
+
await stage?.update({ config: cloneDeep(newNode), root: cloneDeep(root) });
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
const beforeRemove = async (node) => {
|
|
1068
|
+
if (!node?.id)
|
|
1069
|
+
return;
|
|
1070
|
+
const stage = editorService.get("stage");
|
|
1071
|
+
const root = editorService.get("root");
|
|
1072
|
+
if (!root)
|
|
1073
|
+
throw new Error("\u6CA1\u6709root");
|
|
1074
|
+
const { parent, node: curNode } = editorService.getNodeInfo(node.id, false);
|
|
1075
|
+
if (!parent || !curNode)
|
|
1076
|
+
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1077
|
+
const index = getNodeIndex(curNode, parent);
|
|
1078
|
+
if (typeof index !== "number" || index === -1)
|
|
1079
|
+
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1080
|
+
parent.items?.splice(index, 1);
|
|
1081
|
+
stage?.remove({ id: node.id, root: cloneDeep(root) });
|
|
1082
|
+
if (node.type === NodeType.PAGE) {
|
|
1083
|
+
editorService.state.pageLength -= 1;
|
|
1084
|
+
if (root.items[0]) {
|
|
1085
|
+
await editorService.select(root.items[0]);
|
|
1086
|
+
stage?.select(root.items[0].id);
|
|
1087
|
+
} else {
|
|
1088
|
+
editorService.set("node", null);
|
|
1089
|
+
editorService.set("nodes", []);
|
|
1090
|
+
editorService.set("parent", null);
|
|
1091
|
+
editorService.set("page", null);
|
|
1092
|
+
editorService.set("stage", null);
|
|
1093
|
+
editorService.set("highlightNode", null);
|
|
1094
|
+
editorService.resetModifiedNodeId();
|
|
1095
|
+
historyService.reset();
|
|
1096
|
+
editorService.emit("remove", node);
|
|
1097
|
+
return;
|
|
1098
|
+
}
|
|
1099
|
+
} else {
|
|
1100
|
+
await editorService.select(parent);
|
|
1101
|
+
stage?.select(parent.id);
|
|
1102
|
+
}
|
|
1103
|
+
return parent;
|
|
1104
|
+
};
|
|
1105
|
+
|
|
866
1106
|
class Editor$1 extends BaseService {
|
|
1107
|
+
state = reactive({
|
|
1108
|
+
root: null,
|
|
1109
|
+
page: null,
|
|
1110
|
+
parent: null,
|
|
1111
|
+
node: null,
|
|
1112
|
+
nodes: [],
|
|
1113
|
+
stage: null,
|
|
1114
|
+
highlightNode: null,
|
|
1115
|
+
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
1116
|
+
pageLength: 0
|
|
1117
|
+
});
|
|
1118
|
+
isHistoryStateChange = false;
|
|
867
1119
|
constructor() {
|
|
868
1120
|
super([
|
|
869
1121
|
"getLayout",
|
|
@@ -882,20 +1134,12 @@ class Editor$1 extends BaseService {
|
|
|
882
1134
|
"redo",
|
|
883
1135
|
"highlight"
|
|
884
1136
|
], ["select", "update", "moveLayer"]);
|
|
885
|
-
this.isHistoryStateChange = false;
|
|
886
|
-
this.state = reactive({
|
|
887
|
-
root: null,
|
|
888
|
-
page: null,
|
|
889
|
-
parent: null,
|
|
890
|
-
node: null,
|
|
891
|
-
stage: null,
|
|
892
|
-
highlightNode: null,
|
|
893
|
-
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
894
|
-
pageLength: 0
|
|
895
|
-
});
|
|
896
1137
|
}
|
|
897
1138
|
set(name, value) {
|
|
898
1139
|
this.state[name] = value;
|
|
1140
|
+
if (name === "nodes") {
|
|
1141
|
+
this.set("node", value[0]);
|
|
1142
|
+
}
|
|
899
1143
|
if (name === "root") {
|
|
900
1144
|
this.state.pageLength = value?.items?.length || 0;
|
|
901
1145
|
this.emit("root-change", value);
|
|
@@ -950,9 +1194,9 @@ class Editor$1 extends BaseService {
|
|
|
950
1194
|
}
|
|
951
1195
|
return Layout.ABSOLUTE;
|
|
952
1196
|
}
|
|
953
|
-
async select(
|
|
954
|
-
const { node, page, parent } = this.selectedConfigExceptionHandler(
|
|
955
|
-
this.set("
|
|
1197
|
+
async select(config) {
|
|
1198
|
+
const { node, page, parent } = this.selectedConfigExceptionHandler(config);
|
|
1199
|
+
this.set("nodes", [node]);
|
|
956
1200
|
this.set("page", page || null);
|
|
957
1201
|
this.set("parent", parent || null);
|
|
958
1202
|
if (page) {
|
|
@@ -992,106 +1236,87 @@ class Editor$1 extends BaseService {
|
|
|
992
1236
|
this.get("stage")?.select(nextPage.id);
|
|
993
1237
|
return nextPage;
|
|
994
1238
|
}
|
|
995
|
-
highlight(
|
|
996
|
-
const { node } = this.selectedConfigExceptionHandler(
|
|
1239
|
+
highlight(config) {
|
|
1240
|
+
const { node } = this.selectedConfigExceptionHandler(config);
|
|
997
1241
|
const currentHighlightNode = this.get("highlightNode");
|
|
998
1242
|
if (currentHighlightNode === node)
|
|
999
1243
|
return;
|
|
1000
1244
|
this.set("highlightNode", node);
|
|
1001
1245
|
}
|
|
1246
|
+
multiSelect(ids) {
|
|
1247
|
+
const nodes = [];
|
|
1248
|
+
const idsUnique = uniq(ids);
|
|
1249
|
+
idsUnique.forEach((id) => {
|
|
1250
|
+
const { node } = this.getNodeInfo(id);
|
|
1251
|
+
if (!node)
|
|
1252
|
+
return;
|
|
1253
|
+
nodes.push(node);
|
|
1254
|
+
});
|
|
1255
|
+
this.set("nodes", nodes);
|
|
1256
|
+
}
|
|
1257
|
+
async multiAdd(configs) {
|
|
1258
|
+
const stage = this.get("stage");
|
|
1259
|
+
const newNodes = await Promise.all(configs.map(async (configItem) => {
|
|
1260
|
+
const { parentNode, newNode, layout } = await beforeAdd(configItem);
|
|
1261
|
+
await notifyAddToStage(parentNode, newNode, layout);
|
|
1262
|
+
return newNode;
|
|
1263
|
+
}));
|
|
1264
|
+
const newNodeIds = newNodes.map((node) => node.id);
|
|
1265
|
+
this.addModifiedNodeId(newNodeIds.join("-"));
|
|
1266
|
+
this.pushHistoryState();
|
|
1267
|
+
stage?.multiSelect(newNodeIds);
|
|
1268
|
+
this.emit("multiAdd", newNodes);
|
|
1269
|
+
return newNodes;
|
|
1270
|
+
}
|
|
1002
1271
|
async add(addNode, parent) {
|
|
1003
|
-
const { type, ...config2 } = addNode;
|
|
1004
|
-
const curNode = this.get("node");
|
|
1005
|
-
let parentNode;
|
|
1006
|
-
const isPage2 = type === NodeType.PAGE;
|
|
1007
|
-
if (isPage2) {
|
|
1008
|
-
parentNode = this.get("root");
|
|
1009
|
-
} else if (parent && typeof parent !== "function") {
|
|
1010
|
-
parentNode = parent;
|
|
1011
|
-
} else if (curNode.items) {
|
|
1012
|
-
parentNode = curNode;
|
|
1013
|
-
} else {
|
|
1014
|
-
parentNode = this.getParentById(curNode.id, false);
|
|
1015
|
-
}
|
|
1016
|
-
if (!parentNode)
|
|
1017
|
-
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1018
|
-
const layout = await this.getLayout(toRaw(parentNode), addNode);
|
|
1019
|
-
const newNode = { ...toRaw(await propsService.getPropsValue(type, config2)) };
|
|
1020
|
-
newNode.style = getInitPositionStyle(newNode.style, layout, parentNode, this.get("stage"));
|
|
1021
|
-
if ((parentNode?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && newNode.type !== NodeType.PAGE) {
|
|
1022
|
-
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
1023
|
-
}
|
|
1024
|
-
parentNode?.items?.push(newNode);
|
|
1025
1272
|
const stage = this.get("stage");
|
|
1026
|
-
const
|
|
1027
|
-
await
|
|
1028
|
-
if (layout === Layout.ABSOLUTE) {
|
|
1029
|
-
const fixedLeft = fixNodeLeft(newNode, parentNode, stage?.renderer.contentWindow?.document);
|
|
1030
|
-
if (typeof fixedLeft !== "undefined") {
|
|
1031
|
-
newNode.style.left = fixedLeft;
|
|
1032
|
-
await stage?.update({ config: cloneDeep(newNode), root: cloneDeep(root) });
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1273
|
+
const { parentNode, newNode, layout, isPage: isPage2 } = await beforeAdd(addNode, parent);
|
|
1274
|
+
await notifyAddToStage(parentNode, newNode, layout);
|
|
1035
1275
|
await this.select(newNode);
|
|
1036
1276
|
this.addModifiedNodeId(newNode.id);
|
|
1037
1277
|
if (!isPage2) {
|
|
1038
1278
|
this.pushHistoryState();
|
|
1039
1279
|
}
|
|
1040
|
-
stage?.select(newNode.id);
|
|
1041
1280
|
if (isPage2) {
|
|
1042
1281
|
this.state.pageLength += 1;
|
|
1282
|
+
} else {
|
|
1283
|
+
stage?.select(newNode.id);
|
|
1043
1284
|
}
|
|
1044
1285
|
this.emit("add", newNode);
|
|
1045
1286
|
return newNode;
|
|
1046
1287
|
}
|
|
1047
|
-
async remove(
|
|
1048
|
-
if (
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
if (!root)
|
|
1052
|
-
throw new Error("\u6CA1\u6709root");
|
|
1053
|
-
const { parent, node: curNode } = this.getNodeInfo(node.id, false);
|
|
1054
|
-
if (!parent || !curNode)
|
|
1055
|
-
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1056
|
-
const index = getNodeIndex(curNode, parent);
|
|
1057
|
-
if (typeof index !== "number" || index === -1)
|
|
1058
|
-
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1059
|
-
parent.items?.splice(index, 1);
|
|
1060
|
-
const stage = this.get("stage");
|
|
1061
|
-
stage?.remove({ id: node.id, root: cloneDeep(this.get("root")) });
|
|
1062
|
-
if (node.type === NodeType.PAGE) {
|
|
1063
|
-
this.state.pageLength -= 1;
|
|
1064
|
-
if (root.items[0]) {
|
|
1065
|
-
await this.select(root.items[0]);
|
|
1066
|
-
stage?.select(root.items[0].id);
|
|
1067
|
-
} else {
|
|
1068
|
-
this.set("node", null);
|
|
1069
|
-
this.set("parent", null);
|
|
1070
|
-
this.set("page", null);
|
|
1071
|
-
this.set("stage", null);
|
|
1072
|
-
this.set("highlightNode", null);
|
|
1073
|
-
this.resetModifiedNodeId();
|
|
1074
|
-
historyService.reset();
|
|
1075
|
-
this.emit("remove", node);
|
|
1076
|
-
return node;
|
|
1077
|
-
}
|
|
1078
|
-
} else {
|
|
1079
|
-
await this.select(parent);
|
|
1080
|
-
stage?.select(parent.id);
|
|
1288
|
+
async remove(nodeOrNodeList) {
|
|
1289
|
+
if (Array.isArray(nodeOrNodeList)) {
|
|
1290
|
+
const nodes = nodeOrNodeList;
|
|
1291
|
+
return this.multiRemove(nodes);
|
|
1081
1292
|
}
|
|
1082
|
-
|
|
1293
|
+
const node = nodeOrNodeList;
|
|
1294
|
+
const removeParent = await beforeRemove(node);
|
|
1295
|
+
if (!removeParent)
|
|
1296
|
+
return node;
|
|
1297
|
+
this.addModifiedNodeId(removeParent.id);
|
|
1083
1298
|
this.pushHistoryState();
|
|
1084
1299
|
this.emit("remove", node);
|
|
1085
1300
|
return node;
|
|
1086
1301
|
}
|
|
1087
|
-
async
|
|
1088
|
-
|
|
1302
|
+
async multiRemove(nodes) {
|
|
1303
|
+
await Promise.all(nodes.map(async (removeNode) => {
|
|
1304
|
+
await beforeRemove(removeNode);
|
|
1305
|
+
}));
|
|
1306
|
+
const nodeIds = nodes.map((node) => node.id);
|
|
1307
|
+
this.addModifiedNodeId(nodeIds.join("-"));
|
|
1308
|
+
this.pushHistoryState();
|
|
1309
|
+
this.emit("multiRemove", nodes);
|
|
1310
|
+
return nodes;
|
|
1311
|
+
}
|
|
1312
|
+
async update(config) {
|
|
1313
|
+
if (!config?.id)
|
|
1089
1314
|
throw new Error("\u6CA1\u6709\u914D\u7F6E\u6216\u8005\u914D\u7F6E\u7F3A\u5C11id\u503C");
|
|
1090
|
-
const info = this.getNodeInfo(
|
|
1315
|
+
const info = this.getNodeInfo(config.id, false);
|
|
1091
1316
|
if (!info.node)
|
|
1092
|
-
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${
|
|
1317
|
+
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config.id}\u7684\u8282\u70B9`);
|
|
1093
1318
|
const node = cloneDeep(toRaw(info.node));
|
|
1094
|
-
let newConfig = await this.toggleFixedPosition(toRaw(
|
|
1319
|
+
let newConfig = await this.toggleFixedPosition(toRaw(config), node, this.get("root"));
|
|
1095
1320
|
newConfig = mergeWith(cloneDeep(node), newConfig, (objValue, srcValue) => {
|
|
1096
1321
|
if (Array.isArray(srcValue)) {
|
|
1097
1322
|
return srcValue;
|
|
@@ -1116,9 +1341,10 @@ class Editor$1 extends BaseService {
|
|
|
1116
1341
|
newConfig = setLayout(newConfig, newLayout);
|
|
1117
1342
|
}
|
|
1118
1343
|
parentNodeItems[index] = newConfig;
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1344
|
+
const nodes = this.get("nodes");
|
|
1345
|
+
const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
|
|
1346
|
+
nodes.splice(targetIndex, 1, newConfig);
|
|
1347
|
+
this.set("nodes", nodes);
|
|
1122
1348
|
this.get("stage")?.update({ config: cloneDeep(newConfig), root: cloneDeep(this.get("root")) });
|
|
1123
1349
|
if (newConfig.type === NodeType.PAGE) {
|
|
1124
1350
|
this.set("page", newConfig);
|
|
@@ -1142,34 +1368,19 @@ class Editor$1 extends BaseService {
|
|
|
1142
1368
|
this.addModifiedNodeId(parent.id);
|
|
1143
1369
|
this.pushHistoryState();
|
|
1144
1370
|
}
|
|
1145
|
-
async copy(
|
|
1146
|
-
|
|
1371
|
+
async copy(config) {
|
|
1372
|
+
await storageService.setItem(COPY_STORAGE_KEY, Array.isArray(config) ? config : [config], {
|
|
1373
|
+
protocol: Protocol.OBJECT
|
|
1374
|
+
});
|
|
1147
1375
|
}
|
|
1148
1376
|
async paste(position = {}) {
|
|
1149
|
-
const
|
|
1150
|
-
|
|
1151
|
-
if (!configStr) {
|
|
1152
|
-
return;
|
|
1153
|
-
}
|
|
1154
|
-
try {
|
|
1155
|
-
eval(`config = ${configStr}`);
|
|
1156
|
-
} catch (e) {
|
|
1157
|
-
console.error(e);
|
|
1377
|
+
const config = await storageService.getItem(COPY_STORAGE_KEY);
|
|
1378
|
+
if (!config)
|
|
1158
1379
|
return;
|
|
1159
|
-
|
|
1160
|
-
await
|
|
1161
|
-
if (config.style) {
|
|
1162
|
-
config.style = {
|
|
1163
|
-
...config.style,
|
|
1164
|
-
...position
|
|
1165
|
-
};
|
|
1166
|
-
}
|
|
1167
|
-
if (isPage(config)) {
|
|
1168
|
-
config.name = generatePageNameByApp(this.get("root"));
|
|
1169
|
-
}
|
|
1170
|
-
return await this.add(config);
|
|
1380
|
+
const pasteConfigs = await beforePaste(position, config);
|
|
1381
|
+
return await this.multiAdd(pasteConfigs);
|
|
1171
1382
|
}
|
|
1172
|
-
async alignCenter(
|
|
1383
|
+
async alignCenter(config) {
|
|
1173
1384
|
const parent = this.get("parent");
|
|
1174
1385
|
const node = this.get("node");
|
|
1175
1386
|
const layout = await this.getLayout(toRaw(parent), toRaw(node));
|
|
@@ -1181,8 +1392,8 @@ class Editor$1 extends BaseService {
|
|
|
1181
1392
|
const stage = this.get("stage");
|
|
1182
1393
|
const doc = stage?.renderer.contentWindow?.document;
|
|
1183
1394
|
if (doc) {
|
|
1184
|
-
const parentEl = doc.getElementById(`${parent.id}`);
|
|
1185
1395
|
const el = doc.getElementById(`${node.id}`);
|
|
1396
|
+
const parentEl = el?.offsetParent;
|
|
1186
1397
|
if (parentEl && el) {
|
|
1187
1398
|
node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
|
|
1188
1399
|
}
|
|
@@ -1194,9 +1405,9 @@ class Editor$1 extends BaseService {
|
|
|
1194
1405
|
config: cloneDeep(toRaw(node)),
|
|
1195
1406
|
root: cloneDeep(this.get("root"))
|
|
1196
1407
|
});
|
|
1197
|
-
this.addModifiedNodeId(
|
|
1408
|
+
this.addModifiedNodeId(config.id);
|
|
1198
1409
|
this.pushHistoryState();
|
|
1199
|
-
return
|
|
1410
|
+
return config;
|
|
1200
1411
|
}
|
|
1201
1412
|
async moveLayer(offset) {
|
|
1202
1413
|
const parent = this.get("parent");
|
|
@@ -1215,8 +1426,8 @@ class Editor$1 extends BaseService {
|
|
|
1215
1426
|
root: cloneDeep(this.get("root"))
|
|
1216
1427
|
});
|
|
1217
1428
|
}
|
|
1218
|
-
async moveToContainer(
|
|
1219
|
-
const { node, parent } = this.getNodeInfo(
|
|
1429
|
+
async moveToContainer(config, targetId) {
|
|
1430
|
+
const { node, parent } = this.getNodeInfo(config.id, false);
|
|
1220
1431
|
const target = this.getNodeById(targetId, false);
|
|
1221
1432
|
const stage = this.get("stage");
|
|
1222
1433
|
if (node && parent && stage) {
|
|
@@ -1225,7 +1436,7 @@ class Editor$1 extends BaseService {
|
|
|
1225
1436
|
parent.items?.splice(index, 1);
|
|
1226
1437
|
await stage.remove({ id: node.id, root });
|
|
1227
1438
|
const layout = await this.getLayout(target);
|
|
1228
|
-
const newConfig = mergeWith(cloneDeep(node),
|
|
1439
|
+
const newConfig = mergeWith(cloneDeep(node), config, (objValue, srcValue) => {
|
|
1229
1440
|
if (Array.isArray(srcValue)) {
|
|
1230
1441
|
return srcValue;
|
|
1231
1442
|
}
|
|
@@ -1276,6 +1487,7 @@ class Editor$1 extends BaseService {
|
|
|
1276
1487
|
this.removeAllListeners();
|
|
1277
1488
|
this.set("root", null);
|
|
1278
1489
|
this.set("node", null);
|
|
1490
|
+
this.set("nodes", []);
|
|
1279
1491
|
this.set("page", null);
|
|
1280
1492
|
this.set("parent", null);
|
|
1281
1493
|
}
|
|
@@ -1322,12 +1534,12 @@ class Editor$1 extends BaseService {
|
|
|
1322
1534
|
}
|
|
1323
1535
|
return newConfig;
|
|
1324
1536
|
}
|
|
1325
|
-
selectedConfigExceptionHandler(
|
|
1537
|
+
selectedConfigExceptionHandler(config) {
|
|
1326
1538
|
let id;
|
|
1327
|
-
if (typeof
|
|
1328
|
-
id =
|
|
1539
|
+
if (typeof config === "string" || typeof config === "number") {
|
|
1540
|
+
id = config;
|
|
1329
1541
|
} else {
|
|
1330
|
-
id =
|
|
1542
|
+
id = config.id;
|
|
1331
1543
|
}
|
|
1332
1544
|
if (!id) {
|
|
1333
1545
|
throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
|
|
@@ -1345,7 +1557,7 @@ class Editor$1 extends BaseService {
|
|
|
1345
1557
|
};
|
|
1346
1558
|
}
|
|
1347
1559
|
}
|
|
1348
|
-
|
|
1560
|
+
const editorService = new Editor$1();
|
|
1349
1561
|
|
|
1350
1562
|
const eventMap = reactive({});
|
|
1351
1563
|
const methodMap = reactive({});
|
|
@@ -1389,7 +1601,7 @@ class Events extends BaseService {
|
|
|
1389
1601
|
return cloneDeep(methodMap[type] || DEFAULT_METHODS);
|
|
1390
1602
|
}
|
|
1391
1603
|
}
|
|
1392
|
-
|
|
1604
|
+
const eventsService = new Events();
|
|
1393
1605
|
|
|
1394
1606
|
const fillConfig = (config = []) => [
|
|
1395
1607
|
{
|
|
@@ -1595,29 +1807,31 @@ const fillConfig = (config = []) => [
|
|
|
1595
1807
|
}
|
|
1596
1808
|
];
|
|
1597
1809
|
const DEFAULT_CONFIG = fillConfig([]);
|
|
1598
|
-
const getDefaultPropsValue = (type, id) => ["page", "container"].includes(type) ? {
|
|
1599
|
-
type,
|
|
1600
|
-
id,
|
|
1601
|
-
layout: "absolute",
|
|
1602
|
-
style: {},
|
|
1603
|
-
name: type,
|
|
1604
|
-
items: []
|
|
1605
|
-
} : {
|
|
1606
|
-
type,
|
|
1607
|
-
id,
|
|
1608
|
-
style: {},
|
|
1609
|
-
name: type
|
|
1610
|
-
};
|
|
1611
1810
|
|
|
1612
1811
|
const log = (...args) => {
|
|
1812
|
+
if (process.env.NODE_ENV === "development") {
|
|
1813
|
+
console.log("magic editor: ", ...args);
|
|
1814
|
+
}
|
|
1613
1815
|
};
|
|
1614
1816
|
const info = (...args) => {
|
|
1817
|
+
if (process.env.NODE_ENV === "development") {
|
|
1818
|
+
console.info("magic editor: ", ...args);
|
|
1819
|
+
}
|
|
1615
1820
|
};
|
|
1616
1821
|
const warn = (...args) => {
|
|
1822
|
+
if (process.env.NODE_ENV === "development") {
|
|
1823
|
+
console.warn("magic editor: ", ...args);
|
|
1824
|
+
}
|
|
1617
1825
|
};
|
|
1618
1826
|
const debug = (...args) => {
|
|
1827
|
+
if (process.env.NODE_ENV === "development") {
|
|
1828
|
+
console.debug("magic editor: ", ...args);
|
|
1829
|
+
}
|
|
1619
1830
|
};
|
|
1620
1831
|
const error = (...args) => {
|
|
1832
|
+
if (process.env.NODE_ENV === "development") {
|
|
1833
|
+
console.error("magic editor: ", ...args);
|
|
1834
|
+
}
|
|
1621
1835
|
};
|
|
1622
1836
|
|
|
1623
1837
|
const _sfc_main$i = defineComponent({
|
|
@@ -1637,10 +1851,11 @@ const _sfc_main$i = defineComponent({
|
|
|
1637
1851
|
};
|
|
1638
1852
|
}
|
|
1639
1853
|
});
|
|
1854
|
+
|
|
1640
1855
|
const _hoisted_1$b = { class: "m-editor-empty-panel" };
|
|
1641
1856
|
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
1642
1857
|
const _hoisted_3$2 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
1643
|
-
function _sfc_render$
|
|
1858
|
+
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1644
1859
|
const _component_plus = resolveComponent("plus");
|
|
1645
1860
|
const _component_el_icon = resolveComponent("el-icon");
|
|
1646
1861
|
return openBlock(), createElementBlock("div", _hoisted_1$b, [
|
|
@@ -1662,7 +1877,7 @@ function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1662
1877
|
])
|
|
1663
1878
|
]);
|
|
1664
1879
|
}
|
|
1665
|
-
|
|
1880
|
+
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$d]]);
|
|
1666
1881
|
|
|
1667
1882
|
const _sfc_main$h = defineComponent({
|
|
1668
1883
|
name: "m-editor-resize",
|
|
@@ -1706,16 +1921,17 @@ const _sfc_main$h = defineComponent({
|
|
|
1706
1921
|
};
|
|
1707
1922
|
}
|
|
1708
1923
|
});
|
|
1924
|
+
|
|
1709
1925
|
const _hoisted_1$a = {
|
|
1710
1926
|
ref: "target",
|
|
1711
1927
|
class: "m-editor-resizer"
|
|
1712
1928
|
};
|
|
1713
|
-
function _sfc_render$
|
|
1929
|
+
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1714
1930
|
return openBlock(), createElementBlock("span", _hoisted_1$a, [
|
|
1715
1931
|
renderSlot(_ctx.$slots, "default")
|
|
1716
1932
|
], 512);
|
|
1717
1933
|
}
|
|
1718
|
-
|
|
1934
|
+
const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$c]]);
|
|
1719
1935
|
|
|
1720
1936
|
const _sfc_main$g = defineComponent({
|
|
1721
1937
|
components: {
|
|
@@ -1746,12 +1962,13 @@ const _sfc_main$g = defineComponent({
|
|
|
1746
1962
|
};
|
|
1747
1963
|
}
|
|
1748
1964
|
});
|
|
1965
|
+
|
|
1749
1966
|
const _hoisted_1$9 = { class: "m-editor" };
|
|
1750
1967
|
const _hoisted_2$3 = {
|
|
1751
1968
|
key: 1,
|
|
1752
1969
|
class: "m-editor-content"
|
|
1753
1970
|
};
|
|
1754
|
-
function _sfc_render$
|
|
1971
|
+
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1755
1972
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
1756
1973
|
const _component_resizer = resolveComponent("resizer");
|
|
1757
1974
|
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
@@ -1797,7 +2014,7 @@ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1797
2014
|
]))
|
|
1798
2015
|
]);
|
|
1799
2016
|
}
|
|
1800
|
-
|
|
2017
|
+
const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$b]]);
|
|
1801
2018
|
|
|
1802
2019
|
const _sfc_main$f = defineComponent({
|
|
1803
2020
|
name: "m-icon",
|
|
@@ -1813,8 +2030,9 @@ const _sfc_main$f = defineComponent({
|
|
|
1813
2030
|
};
|
|
1814
2031
|
}
|
|
1815
2032
|
});
|
|
2033
|
+
|
|
1816
2034
|
const _hoisted_1$8 = ["src"];
|
|
1817
|
-
function _sfc_render$
|
|
2035
|
+
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1818
2036
|
const _component_edit = resolveComponent("edit");
|
|
1819
2037
|
const _component_el_icon = resolveComponent("el-icon");
|
|
1820
2038
|
return !_ctx.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
|
|
@@ -1835,10 +2053,19 @@ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1835
2053
|
_: 1
|
|
1836
2054
|
}));
|
|
1837
2055
|
}
|
|
1838
|
-
|
|
2056
|
+
const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$a]]);
|
|
1839
2057
|
|
|
1840
|
-
const
|
|
1841
|
-
|
|
2058
|
+
const _hoisted_1$7 = {
|
|
2059
|
+
key: 1,
|
|
2060
|
+
class: "menu-item-text"
|
|
2061
|
+
};
|
|
2062
|
+
const _hoisted_2$2 = {
|
|
2063
|
+
class: "menu-item-text",
|
|
2064
|
+
style: { "margin": "0 5px" }
|
|
2065
|
+
};
|
|
2066
|
+
const _hoisted_3$1 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2067
|
+
const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
2068
|
+
__name: "ToolButton",
|
|
1842
2069
|
props: {
|
|
1843
2070
|
data: {
|
|
1844
2071
|
type: [Object, String],
|
|
@@ -1853,7 +2080,8 @@ const _sfc_main$e = defineComponent({
|
|
|
1853
2080
|
default: "click"
|
|
1854
2081
|
}
|
|
1855
2082
|
},
|
|
1856
|
-
setup(
|
|
2083
|
+
setup(__props) {
|
|
2084
|
+
const props = __props;
|
|
1857
2085
|
const services = inject("services");
|
|
1858
2086
|
const uiService = services?.uiService;
|
|
1859
2087
|
const zoom = computed(() => uiService?.get("zoom") ?? 1);
|
|
@@ -1950,176 +2178,155 @@ const _sfc_main$e = defineComponent({
|
|
|
1950
2178
|
item2.handler?.(services, event);
|
|
1951
2179
|
}
|
|
1952
2180
|
};
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
item
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
}
|
|
1967
|
-
return item.value.display ?? true;
|
|
1968
|
-
}),
|
|
1969
|
-
zoomInHandler,
|
|
1970
|
-
zoomOutHandler,
|
|
1971
|
-
dropdownHandler(command) {
|
|
1972
|
-
if (command.item.handler) {
|
|
1973
|
-
command.item.handler(services);
|
|
1974
|
-
}
|
|
1975
|
-
},
|
|
1976
|
-
clickHandler(item2, event) {
|
|
1977
|
-
if (props.eventType !== "click")
|
|
1978
|
-
return;
|
|
1979
|
-
if (item2.type === "button") {
|
|
1980
|
-
buttonHandler(item2, event);
|
|
1981
|
-
}
|
|
1982
|
-
},
|
|
1983
|
-
mousedownHandler(item2, event) {
|
|
1984
|
-
if (props.eventType !== "mousedown")
|
|
1985
|
-
return;
|
|
1986
|
-
if (item2.type === "button") {
|
|
1987
|
-
buttonHandler(item2, event);
|
|
1988
|
-
}
|
|
1989
|
-
},
|
|
1990
|
-
mouseupHandler(item2, event) {
|
|
1991
|
-
if (props.eventType !== "mouseup")
|
|
1992
|
-
return;
|
|
1993
|
-
if (item2.type === "button") {
|
|
1994
|
-
buttonHandler(item2, event);
|
|
1995
|
-
}
|
|
2181
|
+
const display = computed(() => {
|
|
2182
|
+
if (!item.value)
|
|
2183
|
+
return false;
|
|
2184
|
+
if (typeof item.value === "string")
|
|
2185
|
+
return true;
|
|
2186
|
+
if (typeof item.value.display === "function") {
|
|
2187
|
+
return item.value.display(services);
|
|
2188
|
+
}
|
|
2189
|
+
return item.value.display ?? true;
|
|
2190
|
+
});
|
|
2191
|
+
const dropdownHandler = (command) => {
|
|
2192
|
+
if (command.item.handler) {
|
|
2193
|
+
command.item.handler(services);
|
|
1996
2194
|
}
|
|
1997
2195
|
};
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
}
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
direction: _ctx.item.direction || "vertical"
|
|
2030
|
-
}, null, 8, ["direction"])) : _ctx.item.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$7, toDisplayString(_ctx.item.text), 1)) : _ctx.item.type === "zoom" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
2031
|
-
createVNode(_component_tool_button, {
|
|
2032
|
-
data: { type: "button", icon: _ctx.ZoomOut, handler: _ctx.zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
2033
|
-
"event-type": _ctx.eventType
|
|
2034
|
-
}, null, 8, ["data", "event-type"]),
|
|
2035
|
-
createElementVNode("span", _hoisted_2$2, toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
|
|
2036
|
-
createVNode(_component_tool_button, {
|
|
2037
|
-
data: { type: "button", icon: _ctx.ZoomIn, handler: _ctx.zoomInHandler, tooltip: "\u653E\u5927" },
|
|
2038
|
-
"event-type": _ctx.eventType
|
|
2039
|
-
}, null, 8, ["data", "event-type"])
|
|
2040
|
-
], 64)) : _ctx.item.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
2041
|
-
_ctx.item.tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
2196
|
+
const clickHandler = (item2, event) => {
|
|
2197
|
+
if (props.eventType !== "click")
|
|
2198
|
+
return;
|
|
2199
|
+
if (item2.type === "button") {
|
|
2200
|
+
buttonHandler(item2, event);
|
|
2201
|
+
}
|
|
2202
|
+
};
|
|
2203
|
+
const mousedownHandler = (item2, event) => {
|
|
2204
|
+
if (props.eventType !== "mousedown")
|
|
2205
|
+
return;
|
|
2206
|
+
if (item2.type === "button") {
|
|
2207
|
+
buttonHandler(item2, event);
|
|
2208
|
+
}
|
|
2209
|
+
};
|
|
2210
|
+
const mouseupHandler = (item2, event) => {
|
|
2211
|
+
if (props.eventType !== "mouseup")
|
|
2212
|
+
return;
|
|
2213
|
+
if (item2.type === "button") {
|
|
2214
|
+
buttonHandler(item2, event);
|
|
2215
|
+
}
|
|
2216
|
+
};
|
|
2217
|
+
return (_ctx, _cache) => {
|
|
2218
|
+
const _component_el_divider = resolveComponent("el-divider");
|
|
2219
|
+
const _component_tool_button = resolveComponent("tool-button", true);
|
|
2220
|
+
const _component_el_button = resolveComponent("el-button");
|
|
2221
|
+
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
2222
|
+
const _component_el_icon = resolveComponent("el-icon");
|
|
2223
|
+
const _component_el_dropdown_item = resolveComponent("el-dropdown-item");
|
|
2224
|
+
const _component_el_dropdown_menu = resolveComponent("el-dropdown-menu");
|
|
2225
|
+
const _component_el_dropdown = resolveComponent("el-dropdown");
|
|
2226
|
+
return unref(display) ? (openBlock(), createElementBlock("div", {
|
|
2042
2227
|
key: 0,
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2228
|
+
class: normalizeClass(["menu-item", unref(item).type]),
|
|
2229
|
+
onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(unref(item), $event)),
|
|
2230
|
+
onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(unref(item), $event)),
|
|
2231
|
+
onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(unref(item), $event))
|
|
2232
|
+
}, [
|
|
2233
|
+
unref(item).type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
|
|
2234
|
+
key: 0,
|
|
2235
|
+
direction: unref(item).direction || "vertical"
|
|
2236
|
+
}, null, 8, ["direction"])) : unref(item).type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$7, toDisplayString(unref(item).text), 1)) : unref(item).type === "zoom" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
2237
|
+
createVNode(_component_tool_button, {
|
|
2238
|
+
data: { type: "button", icon: unref(ZoomOut), handler: zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
2239
|
+
"event-type": __props.eventType
|
|
2240
|
+
}, null, 8, ["data", "event-type"]),
|
|
2241
|
+
createElementVNode("span", _hoisted_2$2, toDisplayString(parseInt(`${unref(zoom) * 100}`, 10)) + "%", 1),
|
|
2242
|
+
createVNode(_component_tool_button, {
|
|
2243
|
+
data: { type: "button", icon: unref(ZoomIn), handler: zoomInHandler, tooltip: "\u653E\u5927" },
|
|
2244
|
+
"event-type": __props.eventType
|
|
2245
|
+
}, null, 8, ["data", "event-type"])
|
|
2246
|
+
], 64)) : unref(item).type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
2247
|
+
unref(item).tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
2248
|
+
key: 0,
|
|
2249
|
+
effect: "dark",
|
|
2250
|
+
placement: "bottom-start",
|
|
2251
|
+
content: unref(item).tooltip
|
|
2252
|
+
}, {
|
|
2253
|
+
default: withCtx(() => [
|
|
2254
|
+
createVNode(_component_el_button, {
|
|
2255
|
+
size: "small",
|
|
2256
|
+
text: "",
|
|
2257
|
+
disabled: unref(disabled)
|
|
2258
|
+
}, {
|
|
2259
|
+
default: withCtx(() => [
|
|
2260
|
+
unref(item).icon ? (openBlock(), createBlock(MIcon, {
|
|
2261
|
+
key: 0,
|
|
2262
|
+
icon: unref(item).icon
|
|
2263
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
2264
|
+
createElementVNode("span", null, toDisplayString(unref(item).text), 1)
|
|
2265
|
+
]),
|
|
2266
|
+
_: 1
|
|
2267
|
+
}, 8, ["disabled"])
|
|
2268
|
+
]),
|
|
2269
|
+
_: 1
|
|
2270
|
+
}, 8, ["content"])) : (openBlock(), createBlock(_component_el_button, {
|
|
2271
|
+
key: 1,
|
|
2049
2272
|
size: "small",
|
|
2050
2273
|
text: "",
|
|
2051
|
-
disabled:
|
|
2274
|
+
disabled: unref(disabled)
|
|
2052
2275
|
}, {
|
|
2053
2276
|
default: withCtx(() => [
|
|
2054
|
-
|
|
2277
|
+
unref(item).icon ? (openBlock(), createBlock(MIcon, {
|
|
2055
2278
|
key: 0,
|
|
2056
|
-
icon:
|
|
2279
|
+
icon: unref(item).icon
|
|
2057
2280
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
2058
|
-
createElementVNode("span", null, toDisplayString(
|
|
2281
|
+
createElementVNode("span", null, toDisplayString(unref(item).text), 1)
|
|
2059
2282
|
]),
|
|
2060
2283
|
_: 1
|
|
2061
|
-
}, 8, ["disabled"])
|
|
2062
|
-
]),
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
_ctx.item.items && _ctx.item.items.length ? (openBlock(), createBlock(_component_el_dropdown_menu, { key: 0 }, {
|
|
2284
|
+
}, 8, ["disabled"]))
|
|
2285
|
+
], 64)) : unref(item).type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
|
|
2286
|
+
key: 4,
|
|
2287
|
+
trigger: "click",
|
|
2288
|
+
disabled: unref(disabled),
|
|
2289
|
+
onCommand: dropdownHandler
|
|
2290
|
+
}, {
|
|
2291
|
+
dropdown: withCtx(() => [
|
|
2292
|
+
unref(item).items && unref(item).items.length ? (openBlock(), createBlock(_component_el_dropdown_menu, { key: 0 }, {
|
|
2293
|
+
default: withCtx(() => [
|
|
2294
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(item).items, (subItem, index) => {
|
|
2295
|
+
return openBlock(), createBlock(_component_el_dropdown_item, {
|
|
2296
|
+
key: index,
|
|
2297
|
+
command: { item: unref(item), subItem }
|
|
2298
|
+
}, {
|
|
2299
|
+
default: withCtx(() => [
|
|
2300
|
+
createTextVNode(toDisplayString(subItem.text), 1)
|
|
2301
|
+
]),
|
|
2302
|
+
_: 2
|
|
2303
|
+
}, 1032, ["command"]);
|
|
2304
|
+
}), 128))
|
|
2305
|
+
]),
|
|
2306
|
+
_: 1
|
|
2307
|
+
})) : createCommentVNode("", true)
|
|
2308
|
+
]),
|
|
2087
2309
|
default: withCtx(() => [
|
|
2088
|
-
(
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
command: { item: _ctx.item, subItem }
|
|
2092
|
-
}, {
|
|
2310
|
+
createElementVNode("span", _hoisted_3$1, [
|
|
2311
|
+
createTextVNode(toDisplayString(unref(item).text), 1),
|
|
2312
|
+
createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2093
2313
|
default: withCtx(() => [
|
|
2094
|
-
|
|
2314
|
+
createVNode(unref(ArrowDown))
|
|
2095
2315
|
]),
|
|
2096
|
-
_:
|
|
2097
|
-
}
|
|
2098
|
-
|
|
2316
|
+
_: 1
|
|
2317
|
+
})
|
|
2318
|
+
])
|
|
2099
2319
|
]),
|
|
2100
2320
|
_: 1
|
|
2101
|
-
})) : createCommentVNode("", true)
|
|
2102
|
-
]),
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2107
|
-
default: withCtx(() => [
|
|
2108
|
-
createVNode(_component_arrow_down)
|
|
2109
|
-
]),
|
|
2110
|
-
_: 1
|
|
2111
|
-
})
|
|
2112
|
-
])
|
|
2113
|
-
]),
|
|
2114
|
-
_: 1
|
|
2115
|
-
}, 8, ["disabled", "onCommand"])) : _ctx.item.type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.item.component), normalizeProps(mergeProps({ key: 5 }, _ctx.item.props || {})), null, 16)) : createCommentVNode("", true)
|
|
2116
|
-
], 34)) : createCommentVNode("", true);
|
|
2117
|
-
}
|
|
2118
|
-
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
|
|
2321
|
+
}, 8, ["disabled"])) : unref(item).type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(unref(item).component), normalizeProps(mergeProps({ key: 5 }, unref(item).props || {})), null, 16)) : createCommentVNode("", true)
|
|
2322
|
+
], 34)) : createCommentVNode("", true);
|
|
2323
|
+
};
|
|
2324
|
+
}
|
|
2325
|
+
});
|
|
2119
2326
|
|
|
2120
2327
|
const _sfc_main$d = defineComponent({
|
|
2121
2328
|
name: "nav-menu",
|
|
2122
|
-
components: { ToolButton },
|
|
2329
|
+
components: { ToolButton: _sfc_main$e },
|
|
2123
2330
|
props: {
|
|
2124
2331
|
data: {
|
|
2125
2332
|
type: Object,
|
|
@@ -2137,7 +2344,8 @@ const _sfc_main$d = defineComponent({
|
|
|
2137
2344
|
};
|
|
2138
2345
|
}
|
|
2139
2346
|
});
|
|
2140
|
-
|
|
2347
|
+
|
|
2348
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2141
2349
|
const _component_tool_button = resolveComponent("tool-button");
|
|
2142
2350
|
return openBlock(), createElementBlock("div", {
|
|
2143
2351
|
class: "m-editor-nav-menu",
|
|
@@ -2159,7 +2367,7 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2159
2367
|
}), 128))
|
|
2160
2368
|
], 4);
|
|
2161
2369
|
}
|
|
2162
|
-
|
|
2370
|
+
const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$9]]);
|
|
2163
2371
|
|
|
2164
2372
|
const _sfc_main$c = defineComponent({
|
|
2165
2373
|
name: "m-editor-props-panel",
|
|
@@ -2208,8 +2416,9 @@ const _sfc_main$c = defineComponent({
|
|
|
2208
2416
|
};
|
|
2209
2417
|
}
|
|
2210
2418
|
});
|
|
2419
|
+
|
|
2211
2420
|
const _hoisted_1$6 = { class: "`m-editor-props-panel" };
|
|
2212
|
-
function _sfc_render$
|
|
2421
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2213
2422
|
const _component_m_form = resolveComponent("m-form");
|
|
2214
2423
|
return openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
2215
2424
|
renderSlot(_ctx.$slots, "props-panel-header"),
|
|
@@ -2224,7 +2433,7 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2224
2433
|
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
|
|
2225
2434
|
]);
|
|
2226
2435
|
}
|
|
2227
|
-
|
|
2436
|
+
const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$8]]);
|
|
2228
2437
|
|
|
2229
2438
|
const _sfc_main$b = defineComponent({
|
|
2230
2439
|
name: "ui-component-panel",
|
|
@@ -2292,9 +2501,10 @@ const _sfc_main$b = defineComponent({
|
|
|
2292
2501
|
};
|
|
2293
2502
|
}
|
|
2294
2503
|
});
|
|
2504
|
+
|
|
2295
2505
|
const _hoisted_1$5 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
2296
2506
|
const _hoisted_2$1 = ["onClick", "onDragstart"];
|
|
2297
|
-
function _sfc_render$
|
|
2507
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2298
2508
|
const _component_el_input = resolveComponent("el-input");
|
|
2299
2509
|
const _component_m_icon = resolveComponent("m-icon");
|
|
2300
2510
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
@@ -2366,22 +2576,17 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2366
2576
|
_: 3
|
|
2367
2577
|
});
|
|
2368
2578
|
}
|
|
2369
|
-
|
|
2579
|
+
const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$7]]);
|
|
2370
2580
|
|
|
2371
|
-
const _sfc_main$a = defineComponent({
|
|
2372
|
-
|
|
2581
|
+
const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
2582
|
+
__name: "ContentMenu",
|
|
2373
2583
|
props: {
|
|
2374
|
-
menuData: {
|
|
2375
|
-
|
|
2376
|
-
default: () => []
|
|
2377
|
-
},
|
|
2378
|
-
isSubMenu: {
|
|
2379
|
-
type: Boolean,
|
|
2380
|
-
default: false
|
|
2381
|
-
}
|
|
2584
|
+
menuData: { default: () => [] },
|
|
2585
|
+
isSubMenu: { type: Boolean, default: false }
|
|
2382
2586
|
},
|
|
2383
2587
|
emits: ["hide", "show"],
|
|
2384
|
-
setup(
|
|
2588
|
+
setup(__props, { expose, emit }) {
|
|
2589
|
+
const props = __props;
|
|
2385
2590
|
const menu = ref();
|
|
2386
2591
|
const subMenu = ref();
|
|
2387
2592
|
const visible = ref(false);
|
|
@@ -2407,6 +2612,36 @@ const _sfc_main$a = defineComponent({
|
|
|
2407
2612
|
}
|
|
2408
2613
|
hide();
|
|
2409
2614
|
};
|
|
2615
|
+
const show = (e) => {
|
|
2616
|
+
setTimeout(() => {
|
|
2617
|
+
visible.value = true;
|
|
2618
|
+
nextTick(() => {
|
|
2619
|
+
const menuHeight = menu.value?.clientHeight || 0;
|
|
2620
|
+
let top = e.clientY;
|
|
2621
|
+
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
2622
|
+
top = document.body.clientHeight - menuHeight;
|
|
2623
|
+
}
|
|
2624
|
+
menuStyle.value = {
|
|
2625
|
+
top: `${top}px`,
|
|
2626
|
+
left: `${e.clientX}px`
|
|
2627
|
+
};
|
|
2628
|
+
emit("show");
|
|
2629
|
+
});
|
|
2630
|
+
}, 300);
|
|
2631
|
+
};
|
|
2632
|
+
const showSubMenu = (item) => {
|
|
2633
|
+
const menuItem = item;
|
|
2634
|
+
if (typeof item !== "object" || !menuItem.items?.length) {
|
|
2635
|
+
return;
|
|
2636
|
+
}
|
|
2637
|
+
subMenuData.value = menuItem.items;
|
|
2638
|
+
if (menu.value) {
|
|
2639
|
+
subMenu.value.show({
|
|
2640
|
+
clientX: menu.value.offsetLeft + menu.value.clientWidth,
|
|
2641
|
+
clientY: menu.value.offsetTop
|
|
2642
|
+
});
|
|
2643
|
+
}
|
|
2644
|
+
};
|
|
2410
2645
|
onMounted(() => {
|
|
2411
2646
|
if (props.isSubMenu)
|
|
2412
2647
|
return;
|
|
@@ -2417,81 +2652,47 @@ const _sfc_main$a = defineComponent({
|
|
|
2417
2652
|
return;
|
|
2418
2653
|
globalThis.removeEventListener("mousedown", hideHandler, true);
|
|
2419
2654
|
});
|
|
2420
|
-
|
|
2421
|
-
menu,
|
|
2422
|
-
subMenu,
|
|
2423
|
-
visible,
|
|
2424
|
-
menuStyle,
|
|
2425
|
-
subMenuData,
|
|
2655
|
+
expose({
|
|
2426
2656
|
hide,
|
|
2427
|
-
show
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2657
|
+
show
|
|
2658
|
+
});
|
|
2659
|
+
return (_ctx, _cache) => {
|
|
2660
|
+
const _component_content_menu = resolveComponent("content-menu", true);
|
|
2661
|
+
return __props.menuData.length && visible.value ? (openBlock(), createElementBlock("div", {
|
|
2662
|
+
key: 0,
|
|
2663
|
+
class: "magic-editor-content-menu",
|
|
2664
|
+
ref_key: "menu",
|
|
2665
|
+
ref: menu,
|
|
2666
|
+
style: normalizeStyle(menuStyle.value)
|
|
2667
|
+
}, [
|
|
2668
|
+
createElementVNode("div", null, [
|
|
2669
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.menuData, (item, index) => {
|
|
2670
|
+
return openBlock(), createBlock(_sfc_main$e, {
|
|
2671
|
+
"event-type": "mouseup",
|
|
2672
|
+
data: item,
|
|
2673
|
+
key: index,
|
|
2674
|
+
onMouseup: hide,
|
|
2675
|
+
onMouseenter: ($event) => showSubMenu(item)
|
|
2676
|
+
}, null, 8, ["data", "onMouseenter"]);
|
|
2677
|
+
}), 128))
|
|
2678
|
+
]),
|
|
2679
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
2680
|
+
createVNode(_component_content_menu, {
|
|
2681
|
+
class: "sub-menu",
|
|
2682
|
+
ref_key: "subMenu",
|
|
2683
|
+
ref: subMenu,
|
|
2684
|
+
"menu-data": subMenuData.value,
|
|
2685
|
+
"is-sub-menu": true,
|
|
2686
|
+
onHide: hide
|
|
2687
|
+
}, null, 8, ["menu-data"])
|
|
2688
|
+
]))
|
|
2689
|
+
], 4)) : createCommentVNode("", true);
|
|
2457
2690
|
};
|
|
2458
2691
|
}
|
|
2459
2692
|
});
|
|
2460
|
-
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2461
|
-
const _component_tool_button = resolveComponent("tool-button");
|
|
2462
|
-
const _component_content_menu = resolveComponent("content-menu", true);
|
|
2463
|
-
return _ctx.menuData.length && _ctx.visible ? (openBlock(), createElementBlock("div", {
|
|
2464
|
-
key: 0,
|
|
2465
|
-
class: "magic-editor-content-menu",
|
|
2466
|
-
ref: "menu",
|
|
2467
|
-
style: normalizeStyle(_ctx.menuStyle)
|
|
2468
|
-
}, [
|
|
2469
|
-
createElementVNode("div", null, [
|
|
2470
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menuData, (item, index) => {
|
|
2471
|
-
return openBlock(), createBlock(_component_tool_button, {
|
|
2472
|
-
"event-type": "mouseup",
|
|
2473
|
-
data: item,
|
|
2474
|
-
key: index,
|
|
2475
|
-
onMouseup: _ctx.hide,
|
|
2476
|
-
onMouseenter: ($event) => _ctx.showSubMenu(item)
|
|
2477
|
-
}, null, 8, ["data", "onMouseup", "onMouseenter"]);
|
|
2478
|
-
}), 128))
|
|
2479
|
-
]),
|
|
2480
|
-
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
2481
|
-
createVNode(_component_content_menu, {
|
|
2482
|
-
class: "sub-menu",
|
|
2483
|
-
ref: "subMenu",
|
|
2484
|
-
"menu-data": _ctx.subMenuData,
|
|
2485
|
-
"is-sub-menu": true,
|
|
2486
|
-
onHide: _ctx.hide
|
|
2487
|
-
}, null, 8, ["menu-data", "onHide"])
|
|
2488
|
-
]))
|
|
2489
|
-
], 4)) : createCommentVNode("", true);
|
|
2490
|
-
}
|
|
2491
|
-
var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
|
|
2492
2693
|
|
|
2493
2694
|
const _sfc_main$9 = defineComponent({
|
|
2494
|
-
components: { ContentMenu },
|
|
2695
|
+
components: { ContentMenu: _sfc_main$a },
|
|
2495
2696
|
setup() {
|
|
2496
2697
|
const services = inject("services");
|
|
2497
2698
|
const menu = ref();
|
|
@@ -2573,7 +2774,8 @@ const _sfc_main$9 = defineComponent({
|
|
|
2573
2774
|
};
|
|
2574
2775
|
}
|
|
2575
2776
|
});
|
|
2576
|
-
|
|
2777
|
+
|
|
2778
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2577
2779
|
const _component_content_menu = resolveComponent("content-menu");
|
|
2578
2780
|
return openBlock(), createBlock(_component_content_menu, {
|
|
2579
2781
|
"menu-data": _ctx.menuData,
|
|
@@ -2581,7 +2783,7 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2581
2783
|
style: { "overflow": "initial" }
|
|
2582
2784
|
}, null, 8, ["menu-data"]);
|
|
2583
2785
|
}
|
|
2584
|
-
|
|
2786
|
+
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$6]]);
|
|
2585
2787
|
|
|
2586
2788
|
const throttleTime = 150;
|
|
2587
2789
|
const select = async (data, editorService) => {
|
|
@@ -2615,9 +2817,17 @@ const useDrop = (tree, editorService) => ({
|
|
|
2615
2817
|
return true;
|
|
2616
2818
|
return false;
|
|
2617
2819
|
},
|
|
2618
|
-
handleDragEnd() {
|
|
2820
|
+
async handleDragEnd(e) {
|
|
2619
2821
|
if (!tree.value)
|
|
2620
2822
|
return;
|
|
2823
|
+
const { data: node } = e;
|
|
2824
|
+
const parent = editorService?.getParentById(node.id, false);
|
|
2825
|
+
const layout = await editorService?.getLayout(parent);
|
|
2826
|
+
node.style.position = layout;
|
|
2827
|
+
if (layout === Layout.RELATIVE) {
|
|
2828
|
+
node.style.top = 0;
|
|
2829
|
+
node.style.left = 0;
|
|
2830
|
+
}
|
|
2621
2831
|
const { data } = tree.value;
|
|
2622
2832
|
const [page] = data;
|
|
2623
2833
|
editorService?.update(page);
|
|
@@ -2720,8 +2930,9 @@ const _sfc_main$8 = defineComponent({
|
|
|
2720
2930
|
};
|
|
2721
2931
|
}
|
|
2722
2932
|
});
|
|
2933
|
+
|
|
2723
2934
|
const _hoisted_1$4 = ["id", "onMouseenter"];
|
|
2724
|
-
function _sfc_render$
|
|
2935
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2725
2936
|
const _component_el_input = resolveComponent("el-input");
|
|
2726
2937
|
const _component_el_tree = resolveComponent("el-tree");
|
|
2727
2938
|
const _component_layer_menu = resolveComponent("layer-menu");
|
|
@@ -2783,7 +2994,7 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2783
2994
|
_: 3
|
|
2784
2995
|
});
|
|
2785
2996
|
}
|
|
2786
|
-
|
|
2997
|
+
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$5]]);
|
|
2787
2998
|
|
|
2788
2999
|
const _sfc_main$7 = defineComponent({
|
|
2789
3000
|
components: { MIcon },
|
|
@@ -2822,11 +3033,12 @@ const _sfc_main$7 = defineComponent({
|
|
|
2822
3033
|
};
|
|
2823
3034
|
}
|
|
2824
3035
|
});
|
|
3036
|
+
|
|
2825
3037
|
const _hoisted_1$3 = {
|
|
2826
3038
|
key: 1,
|
|
2827
3039
|
class: "magic-editor-tab-panel-title"
|
|
2828
3040
|
};
|
|
2829
|
-
function _sfc_render$
|
|
3041
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2830
3042
|
const _component_m_icon = resolveComponent("m-icon");
|
|
2831
3043
|
const _component_el_tab_pane = resolveComponent("el-tab-pane");
|
|
2832
3044
|
return _ctx.config ? (openBlock(), createBlock(_component_el_tab_pane, {
|
|
@@ -2872,7 +3084,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2872
3084
|
_: 3
|
|
2873
3085
|
}, 8, ["name"])) : createCommentVNode("", true);
|
|
2874
3086
|
}
|
|
2875
|
-
|
|
3087
|
+
const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$4]]);
|
|
2876
3088
|
|
|
2877
3089
|
const _sfc_main$6 = defineComponent({
|
|
2878
3090
|
components: { TabPane },
|
|
@@ -2893,7 +3105,8 @@ const _sfc_main$6 = defineComponent({
|
|
|
2893
3105
|
};
|
|
2894
3106
|
}
|
|
2895
3107
|
});
|
|
2896
|
-
|
|
3108
|
+
|
|
3109
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2897
3110
|
const _component_tab_pane = resolveComponent("tab-pane");
|
|
2898
3111
|
const _component_el_tabs = resolveComponent("el-tabs");
|
|
2899
3112
|
return _ctx.data.type === "tabs" && _ctx.data.items.length ? (openBlock(), createBlock(_component_el_tabs, {
|
|
@@ -2928,331 +3141,249 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2928
3141
|
_: 3
|
|
2929
3142
|
}, 8, ["modelValue"])) : createCommentVNode("", true);
|
|
2930
3143
|
}
|
|
2931
|
-
|
|
3144
|
+
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$3]]);
|
|
2932
3145
|
|
|
2933
|
-
const useScroll = (root) => {
|
|
2934
|
-
const pageBar = ref();
|
|
2935
|
-
const itemsContainer = ref();
|
|
2936
|
-
const pageBarWidth = ref(0);
|
|
2937
|
-
const canScroll = ref(false);
|
|
2938
|
-
const itemsContainerWidth = computed(() => pageBarWidth.value - 105);
|
|
2939
|
-
let translateLeft = 0;
|
|
2940
|
-
const resizeObserver = new ResizeObserver((entries) => {
|
|
2941
|
-
for (const { contentRect } of entries) {
|
|
2942
|
-
const { width } = contentRect;
|
|
2943
|
-
pageBarWidth.value = width || 0;
|
|
2944
|
-
setCanScroll();
|
|
2945
|
-
}
|
|
2946
|
-
});
|
|
2947
|
-
const setCanScroll = () => {
|
|
2948
|
-
if (itemsContainer.value) {
|
|
2949
|
-
canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
|
|
2950
|
-
}
|
|
2951
|
-
};
|
|
2952
|
-
const scroll = (type) => {
|
|
2953
|
-
if (!itemsContainer.value)
|
|
2954
|
-
return;
|
|
2955
|
-
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
2956
|
-
if (type === "left") {
|
|
2957
|
-
translateLeft += 100;
|
|
2958
|
-
if (translateLeft > 0) {
|
|
2959
|
-
translateLeft = 0;
|
|
2960
|
-
}
|
|
2961
|
-
} else if (type === "right") {
|
|
2962
|
-
translateLeft -= 100;
|
|
2963
|
-
if (-translateLeft > maxScrollLeft) {
|
|
2964
|
-
translateLeft = -maxScrollLeft;
|
|
2965
|
-
}
|
|
2966
|
-
} else if (type === "start") {
|
|
2967
|
-
translateLeft = 0;
|
|
2968
|
-
} else if (type === "end") {
|
|
2969
|
-
translateLeft = -maxScrollLeft;
|
|
2970
|
-
}
|
|
2971
|
-
itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
|
|
2972
|
-
};
|
|
2973
|
-
onMounted(() => {
|
|
2974
|
-
pageBar.value && resizeObserver.observe(pageBar.value);
|
|
2975
|
-
});
|
|
2976
|
-
onUnmounted(() => {
|
|
2977
|
-
resizeObserver.disconnect();
|
|
2978
|
-
});
|
|
2979
|
-
watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
|
|
2980
|
-
setTimeout(() => {
|
|
2981
|
-
setCanScroll();
|
|
2982
|
-
if (length < preLength) {
|
|
2983
|
-
scroll("start");
|
|
2984
|
-
} else {
|
|
2985
|
-
scroll("end");
|
|
2986
|
-
}
|
|
2987
|
-
});
|
|
2988
|
-
});
|
|
2989
|
-
return {
|
|
2990
|
-
pageBar,
|
|
2991
|
-
itemsContainer,
|
|
2992
|
-
canScroll,
|
|
2993
|
-
itemsContainerWidth,
|
|
2994
|
-
scroll
|
|
2995
|
-
};
|
|
2996
|
-
};
|
|
2997
|
-
const _sfc_main$5 = defineComponent({
|
|
2998
|
-
components: { ArrowLeftBold, ArrowRightBold, CaretBottom, Plus, ToolButton },
|
|
2999
|
-
setup() {
|
|
3000
|
-
const services = inject("services");
|
|
3001
|
-
const editorService = services?.editorService;
|
|
3002
|
-
const root = computed(() => editorService?.get("root"));
|
|
3003
|
-
return {
|
|
3004
|
-
Delete: markRaw(Delete),
|
|
3005
|
-
DocumentCopy: markRaw(DocumentCopy),
|
|
3006
|
-
...useScroll(root),
|
|
3007
|
-
root,
|
|
3008
|
-
page: computed(() => editorService?.get("page")),
|
|
3009
|
-
switchPage(page) {
|
|
3010
|
-
editorService?.select(page);
|
|
3011
|
-
},
|
|
3012
|
-
addPage() {
|
|
3013
|
-
if (!editorService)
|
|
3014
|
-
return;
|
|
3015
|
-
const pageConfig = {
|
|
3016
|
-
type: NodeType.PAGE,
|
|
3017
|
-
name: generatePageNameByApp(toRaw(editorService.get("root")))
|
|
3018
|
-
};
|
|
3019
|
-
editorService.add(pageConfig);
|
|
3020
|
-
},
|
|
3021
|
-
copy(node) {
|
|
3022
|
-
node && editorService?.copy(node);
|
|
3023
|
-
editorService?.paste({
|
|
3024
|
-
left: 0,
|
|
3025
|
-
top: 0
|
|
3026
|
-
});
|
|
3027
|
-
},
|
|
3028
|
-
remove(node) {
|
|
3029
|
-
editorService?.remove(node);
|
|
3030
|
-
}
|
|
3031
|
-
};
|
|
3032
|
-
}
|
|
3033
|
-
});
|
|
3034
3146
|
const _hoisted_1$2 = {
|
|
3035
3147
|
class: "m-editor-page-bar",
|
|
3036
3148
|
ref: "pageBar"
|
|
3037
3149
|
};
|
|
3038
3150
|
const _hoisted_2 = ["onClick"];
|
|
3039
3151
|
const _hoisted_3 = { class: "m-editor-page-bar-title" };
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3152
|
+
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
3153
|
+
__name: "PageBar",
|
|
3154
|
+
setup(__props) {
|
|
3155
|
+
const useScroll = (root2) => {
|
|
3156
|
+
const pageBar = ref();
|
|
3157
|
+
const itemsContainer = ref();
|
|
3158
|
+
const pageBarWidth = ref(0);
|
|
3159
|
+
const canScroll = ref(false);
|
|
3160
|
+
const itemsContainerWidth = computed(() => pageBarWidth.value - 105);
|
|
3161
|
+
let translateLeft = 0;
|
|
3162
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
3163
|
+
for (const { contentRect } of entries) {
|
|
3164
|
+
const { width } = contentRect;
|
|
3165
|
+
pageBarWidth.value = width || 0;
|
|
3166
|
+
setCanScroll();
|
|
3167
|
+
}
|
|
3168
|
+
});
|
|
3169
|
+
const setCanScroll = () => {
|
|
3170
|
+
if (itemsContainer.value) {
|
|
3171
|
+
canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
|
|
3172
|
+
}
|
|
3173
|
+
};
|
|
3174
|
+
const scroll = (type) => {
|
|
3175
|
+
if (!itemsContainer.value)
|
|
3176
|
+
return;
|
|
3177
|
+
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
3178
|
+
if (type === "left") {
|
|
3179
|
+
translateLeft += 100;
|
|
3180
|
+
if (translateLeft > 0) {
|
|
3181
|
+
translateLeft = 0;
|
|
3182
|
+
}
|
|
3183
|
+
} else if (type === "right") {
|
|
3184
|
+
translateLeft -= 100;
|
|
3185
|
+
if (-translateLeft > maxScrollLeft) {
|
|
3186
|
+
translateLeft = -maxScrollLeft;
|
|
3187
|
+
}
|
|
3188
|
+
} else if (type === "start") {
|
|
3189
|
+
translateLeft = 0;
|
|
3190
|
+
} else if (type === "end") {
|
|
3191
|
+
translateLeft = -maxScrollLeft;
|
|
3192
|
+
}
|
|
3193
|
+
itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
|
|
3194
|
+
};
|
|
3195
|
+
onMounted(() => {
|
|
3196
|
+
pageBar.value && resizeObserver.observe(pageBar.value);
|
|
3197
|
+
});
|
|
3198
|
+
onUnmounted(() => {
|
|
3199
|
+
resizeObserver.disconnect();
|
|
3200
|
+
});
|
|
3201
|
+
watch(() => root2.value?.items.length, (length = 0, preLength = 0) => {
|
|
3202
|
+
setTimeout(() => {
|
|
3203
|
+
setCanScroll();
|
|
3204
|
+
if (length < preLength) {
|
|
3205
|
+
scroll("start");
|
|
3206
|
+
} else {
|
|
3207
|
+
scroll("end");
|
|
3208
|
+
}
|
|
3209
|
+
});
|
|
3210
|
+
});
|
|
3211
|
+
return {
|
|
3212
|
+
pageBar,
|
|
3213
|
+
itemsContainer,
|
|
3214
|
+
canScroll,
|
|
3215
|
+
itemsContainerWidth,
|
|
3216
|
+
scroll
|
|
3217
|
+
};
|
|
3218
|
+
};
|
|
3219
|
+
const services = inject("services");
|
|
3220
|
+
const editorService = services?.editorService;
|
|
3221
|
+
const root = computed(() => editorService?.get("root"));
|
|
3222
|
+
const scrollState = useScroll(root);
|
|
3223
|
+
const page = computed(() => editorService?.get("page"));
|
|
3224
|
+
const switchPage = (page2) => {
|
|
3225
|
+
editorService?.select(page2);
|
|
3226
|
+
};
|
|
3227
|
+
const addPage = () => {
|
|
3228
|
+
if (!editorService)
|
|
3229
|
+
return;
|
|
3230
|
+
const pageConfig = {
|
|
3231
|
+
type: NodeType.PAGE,
|
|
3232
|
+
name: generatePageNameByApp(toRaw(editorService.get("root")))
|
|
3233
|
+
};
|
|
3234
|
+
editorService.add(pageConfig);
|
|
3235
|
+
};
|
|
3236
|
+
const copy = (node) => {
|
|
3237
|
+
node && editorService?.copy(node);
|
|
3238
|
+
editorService?.paste({
|
|
3239
|
+
left: 0,
|
|
3240
|
+
top: 0
|
|
3241
|
+
});
|
|
3242
|
+
};
|
|
3243
|
+
const remove = (node) => {
|
|
3244
|
+
editorService?.remove(node);
|
|
3245
|
+
};
|
|
3246
|
+
return (_ctx, _cache) => {
|
|
3247
|
+
const _component_el_icon = resolveComponent("el-icon");
|
|
3248
|
+
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
3249
|
+
const _component_el_popover = resolveComponent("el-popover");
|
|
3250
|
+
return openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
3251
|
+
createElementVNode("div", {
|
|
3252
|
+
id: "m-editor-page-bar-add-icon",
|
|
3253
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3254
|
+
onClick: addPage
|
|
3255
|
+
}, [
|
|
3256
|
+
createVNode(_component_el_icon, null, {
|
|
3257
|
+
default: withCtx(() => [
|
|
3258
|
+
createVNode(unref(Plus))
|
|
3259
|
+
]),
|
|
3260
|
+
_: 1
|
|
3261
|
+
})
|
|
3262
|
+
]),
|
|
3263
|
+
unref(scrollState).canScroll ? (openBlock(), createElementBlock("div", {
|
|
3264
|
+
key: 0,
|
|
3265
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3266
|
+
onClick: _cache[0] || (_cache[0] = ($event) => unref(scrollState).scroll("left"))
|
|
3085
3267
|
}, [
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
createVNode(
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3268
|
+
createVNode(_component_el_icon, null, {
|
|
3269
|
+
default: withCtx(() => [
|
|
3270
|
+
createVNode(unref(ArrowLeftBold))
|
|
3271
|
+
]),
|
|
3272
|
+
_: 1
|
|
3273
|
+
})
|
|
3274
|
+
])) : createCommentVNode("", true),
|
|
3275
|
+
unref(root) ? (openBlock(), createElementBlock("div", {
|
|
3276
|
+
key: 1,
|
|
3277
|
+
class: "m-editor-page-bar-items",
|
|
3278
|
+
ref: "itemsContainer",
|
|
3279
|
+
style: normalizeStyle(`width: ${unref(scrollState).itemsContainerWidth}px`)
|
|
3280
|
+
}, [
|
|
3281
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(root).items, (item) => {
|
|
3282
|
+
return openBlock(), createElementBlock("div", {
|
|
3283
|
+
key: item.key,
|
|
3284
|
+
class: normalizeClass(["m-editor-page-bar-item", { active: unref(page)?.id === item.id }]),
|
|
3285
|
+
onClick: ($event) => switchPage(item)
|
|
3286
|
+
}, [
|
|
3287
|
+
createElementVNode("div", _hoisted_3, [
|
|
3288
|
+
renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
|
|
3289
|
+
createVNode(_component_el_tooltip, {
|
|
3290
|
+
effect: "dark",
|
|
3291
|
+
placement: "top-start",
|
|
3292
|
+
content: item.name
|
|
3293
|
+
}, {
|
|
3294
|
+
default: withCtx(() => [
|
|
3295
|
+
createElementVNode("span", null, toDisplayString(item.name), 1)
|
|
3296
|
+
]),
|
|
3297
|
+
_: 2
|
|
3298
|
+
}, 1032, ["content"])
|
|
3299
|
+
])
|
|
3300
|
+
]),
|
|
3301
|
+
createVNode(_component_el_popover, {
|
|
3302
|
+
"popper-class": "page-bar-popover",
|
|
3303
|
+
placement: "top",
|
|
3304
|
+
width: 160,
|
|
3305
|
+
trigger: "hover"
|
|
3092
3306
|
}, {
|
|
3093
|
-
|
|
3094
|
-
|
|
3307
|
+
reference: withCtx(() => [
|
|
3308
|
+
createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
|
|
3309
|
+
default: withCtx(() => [
|
|
3310
|
+
createVNode(unref(CaretBottom))
|
|
3311
|
+
]),
|
|
3312
|
+
_: 1
|
|
3313
|
+
})
|
|
3095
3314
|
]),
|
|
3096
|
-
_: 2
|
|
3097
|
-
}, 1032, ["content"])
|
|
3098
|
-
])
|
|
3099
|
-
]),
|
|
3100
|
-
createVNode(_component_el_popover, {
|
|
3101
|
-
"popper-class": "page-bar-popover",
|
|
3102
|
-
placement: "top",
|
|
3103
|
-
width: 160,
|
|
3104
|
-
trigger: "hover"
|
|
3105
|
-
}, {
|
|
3106
|
-
reference: withCtx(() => [
|
|
3107
|
-
createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
|
|
3108
3315
|
default: withCtx(() => [
|
|
3109
|
-
|
|
3316
|
+
createElementVNode("div", null, [
|
|
3317
|
+
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3318
|
+
createVNode(_sfc_main$e, {
|
|
3319
|
+
data: {
|
|
3320
|
+
type: "button",
|
|
3321
|
+
text: "\u590D\u5236",
|
|
3322
|
+
icon: unref(DocumentCopy),
|
|
3323
|
+
handler: () => copy(item)
|
|
3324
|
+
}
|
|
3325
|
+
}, null, 8, ["data"]),
|
|
3326
|
+
createVNode(_sfc_main$e, {
|
|
3327
|
+
data: {
|
|
3328
|
+
type: "button",
|
|
3329
|
+
text: "\u5220\u9664",
|
|
3330
|
+
icon: unref(Delete),
|
|
3331
|
+
handler: () => remove(item)
|
|
3332
|
+
}
|
|
3333
|
+
}, null, 8, ["data"])
|
|
3334
|
+
])
|
|
3335
|
+
])
|
|
3110
3336
|
]),
|
|
3111
|
-
_:
|
|
3112
|
-
})
|
|
3113
|
-
])
|
|
3337
|
+
_: 2
|
|
3338
|
+
}, 1024)
|
|
3339
|
+
], 10, _hoisted_2);
|
|
3340
|
+
}), 128))
|
|
3341
|
+
], 4)) : createCommentVNode("", true),
|
|
3342
|
+
unref(scrollState).canScroll ? (openBlock(), createElementBlock("div", {
|
|
3343
|
+
key: 2,
|
|
3344
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3345
|
+
onClick: _cache[1] || (_cache[1] = ($event) => unref(scrollState).scroll("right"))
|
|
3346
|
+
}, [
|
|
3347
|
+
createVNode(_component_el_icon, null, {
|
|
3114
3348
|
default: withCtx(() => [
|
|
3115
|
-
|
|
3116
|
-
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3117
|
-
createVNode(_component_tool_button, {
|
|
3118
|
-
data: {
|
|
3119
|
-
type: "button",
|
|
3120
|
-
text: "\u590D\u5236",
|
|
3121
|
-
icon: _ctx.DocumentCopy,
|
|
3122
|
-
handler: () => _ctx.copy(item)
|
|
3123
|
-
}
|
|
3124
|
-
}, null, 8, ["data"]),
|
|
3125
|
-
createVNode(_component_tool_button, {
|
|
3126
|
-
data: {
|
|
3127
|
-
type: "button",
|
|
3128
|
-
text: "\u5220\u9664",
|
|
3129
|
-
icon: _ctx.Delete,
|
|
3130
|
-
handler: () => _ctx.remove(item)
|
|
3131
|
-
}
|
|
3132
|
-
}, null, 8, ["data"])
|
|
3133
|
-
])
|
|
3134
|
-
])
|
|
3349
|
+
createVNode(unref(ArrowRightBold))
|
|
3135
3350
|
]),
|
|
3136
|
-
_:
|
|
3137
|
-
}
|
|
3138
|
-
]
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3144
|
-
onClick: _cache[2] || (_cache[2] = ($event) => _ctx.scroll("right"))
|
|
3145
|
-
}, [
|
|
3146
|
-
createVNode(_component_el_icon, null, {
|
|
3147
|
-
default: withCtx(() => [
|
|
3148
|
-
createVNode(_component_arrow_right_bold)
|
|
3149
|
-
]),
|
|
3150
|
-
_: 1
|
|
3151
|
-
})
|
|
3152
|
-
])) : createCommentVNode("", true)
|
|
3153
|
-
], 512);
|
|
3154
|
-
}
|
|
3155
|
-
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
|
|
3351
|
+
_: 1
|
|
3352
|
+
})
|
|
3353
|
+
])) : createCommentVNode("", true)
|
|
3354
|
+
], 512);
|
|
3355
|
+
};
|
|
3356
|
+
}
|
|
3357
|
+
});
|
|
3156
3358
|
|
|
3157
3359
|
class ScrollViewer$1 {
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
if (targetHeight < height) {
|
|
3178
|
-
this.target._top = 0;
|
|
3179
|
-
}
|
|
3180
|
-
this.scroll();
|
|
3181
|
-
}
|
|
3182
|
-
});
|
|
3183
|
-
this.wheelHandler = (event) => {
|
|
3184
|
-
if (this.targetEnter)
|
|
3185
|
-
return;
|
|
3186
|
-
const { deltaX, deltaY, currentTarget } = event;
|
|
3187
|
-
if (currentTarget !== this.container)
|
|
3188
|
-
return;
|
|
3189
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3190
|
-
this.scroll();
|
|
3191
|
-
this.scrollLeft = this.target._left;
|
|
3192
|
-
this.scrollTop = this.target._top;
|
|
3193
|
-
};
|
|
3194
|
-
this.mouseEnterHandler = () => {
|
|
3195
|
-
this.enter = true;
|
|
3196
|
-
};
|
|
3197
|
-
this.mouseLeaveHandler = () => {
|
|
3198
|
-
this.enter = false;
|
|
3199
|
-
};
|
|
3200
|
-
this.targetMouseEnterHandler = () => {
|
|
3201
|
-
this.targetEnter = true;
|
|
3202
|
-
};
|
|
3203
|
-
this.targetMouseLeaveHandler = () => {
|
|
3204
|
-
this.targetEnter = false;
|
|
3205
|
-
};
|
|
3206
|
-
this.mousedownHandler = (event) => {
|
|
3207
|
-
if (!this.keydown)
|
|
3208
|
-
return;
|
|
3209
|
-
event.stopImmediatePropagation();
|
|
3210
|
-
event.stopPropagation();
|
|
3211
|
-
this.target.style.cursor = "grabbing";
|
|
3212
|
-
this.x = event.clientX;
|
|
3213
|
-
this.y = event.clientY;
|
|
3214
|
-
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3215
|
-
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3216
|
-
};
|
|
3217
|
-
this.mouseupHandler = () => {
|
|
3218
|
-
this.x = 0;
|
|
3219
|
-
this.y = 0;
|
|
3220
|
-
this.scrollLeft = this.target._left;
|
|
3221
|
-
this.scrollTop = this.target._top;
|
|
3222
|
-
this.removeHandler();
|
|
3223
|
-
};
|
|
3224
|
-
this.mousemoveHandler = (event) => {
|
|
3225
|
-
event.stopImmediatePropagation();
|
|
3226
|
-
event.stopPropagation();
|
|
3227
|
-
const deltaX = event.clientX - this.x;
|
|
3228
|
-
const deltaY = event.clientY - this.y;
|
|
3229
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3230
|
-
this.scroll();
|
|
3231
|
-
};
|
|
3232
|
-
this.keydownHandler = (event) => {
|
|
3233
|
-
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3234
|
-
event.preventDefault();
|
|
3235
|
-
event.stopImmediatePropagation();
|
|
3236
|
-
event.stopPropagation();
|
|
3237
|
-
}
|
|
3238
|
-
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3239
|
-
return;
|
|
3360
|
+
enter = false;
|
|
3361
|
+
targetEnter = false;
|
|
3362
|
+
keydown = false;
|
|
3363
|
+
container;
|
|
3364
|
+
target;
|
|
3365
|
+
zoom = 1;
|
|
3366
|
+
scrollLeft = 0;
|
|
3367
|
+
scrollTop = 0;
|
|
3368
|
+
x = 0;
|
|
3369
|
+
y = 0;
|
|
3370
|
+
resizeObserver = new ResizeObserver((entries) => {
|
|
3371
|
+
for (const { contentRect } of entries) {
|
|
3372
|
+
const { width, height } = contentRect;
|
|
3373
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3374
|
+
const targetWidth = targetRect.width * this.zoom;
|
|
3375
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3376
|
+
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
3377
|
+
if (targetWidth < width) {
|
|
3378
|
+
this.target._left = 0;
|
|
3240
3379
|
}
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3244
|
-
};
|
|
3245
|
-
this.keyupHandler = (event) => {
|
|
3246
|
-
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3247
|
-
return;
|
|
3380
|
+
if (targetHeight < height) {
|
|
3381
|
+
this.target._top = 0;
|
|
3248
3382
|
}
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
event.preventDefault();
|
|
3254
|
-
this.removeHandler();
|
|
3255
|
-
};
|
|
3383
|
+
this.scroll();
|
|
3384
|
+
}
|
|
3385
|
+
});
|
|
3386
|
+
constructor(options) {
|
|
3256
3387
|
this.container = options.container;
|
|
3257
3388
|
this.target = options.target;
|
|
3258
3389
|
this.zoom = options.zoom;
|
|
@@ -3288,6 +3419,79 @@ class ScrollViewer$1 {
|
|
|
3288
3419
|
document.removeEventListener("mousemove", this.mousemoveHandler);
|
|
3289
3420
|
document.removeEventListener("mouseup", this.mouseupHandler);
|
|
3290
3421
|
}
|
|
3422
|
+
wheelHandler = (event) => {
|
|
3423
|
+
if (this.targetEnter)
|
|
3424
|
+
return;
|
|
3425
|
+
const { deltaX, deltaY, currentTarget } = event;
|
|
3426
|
+
if (currentTarget !== this.container)
|
|
3427
|
+
return;
|
|
3428
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3429
|
+
this.scroll();
|
|
3430
|
+
this.scrollLeft = this.target._left;
|
|
3431
|
+
this.scrollTop = this.target._top;
|
|
3432
|
+
};
|
|
3433
|
+
mouseEnterHandler = () => {
|
|
3434
|
+
this.enter = true;
|
|
3435
|
+
};
|
|
3436
|
+
mouseLeaveHandler = () => {
|
|
3437
|
+
this.enter = false;
|
|
3438
|
+
};
|
|
3439
|
+
targetMouseEnterHandler = () => {
|
|
3440
|
+
this.targetEnter = true;
|
|
3441
|
+
};
|
|
3442
|
+
targetMouseLeaveHandler = () => {
|
|
3443
|
+
this.targetEnter = false;
|
|
3444
|
+
};
|
|
3445
|
+
mousedownHandler = (event) => {
|
|
3446
|
+
if (!this.keydown)
|
|
3447
|
+
return;
|
|
3448
|
+
event.stopImmediatePropagation();
|
|
3449
|
+
event.stopPropagation();
|
|
3450
|
+
this.target.style.cursor = "grabbing";
|
|
3451
|
+
this.x = event.clientX;
|
|
3452
|
+
this.y = event.clientY;
|
|
3453
|
+
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3454
|
+
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3455
|
+
};
|
|
3456
|
+
mouseupHandler = () => {
|
|
3457
|
+
this.x = 0;
|
|
3458
|
+
this.y = 0;
|
|
3459
|
+
this.scrollLeft = this.target._left;
|
|
3460
|
+
this.scrollTop = this.target._top;
|
|
3461
|
+
this.removeHandler();
|
|
3462
|
+
};
|
|
3463
|
+
mousemoveHandler = (event) => {
|
|
3464
|
+
event.stopImmediatePropagation();
|
|
3465
|
+
event.stopPropagation();
|
|
3466
|
+
const deltaX = event.clientX - this.x;
|
|
3467
|
+
const deltaY = event.clientY - this.y;
|
|
3468
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3469
|
+
this.scroll();
|
|
3470
|
+
};
|
|
3471
|
+
keydownHandler = (event) => {
|
|
3472
|
+
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3473
|
+
event.preventDefault();
|
|
3474
|
+
event.stopImmediatePropagation();
|
|
3475
|
+
event.stopPropagation();
|
|
3476
|
+
}
|
|
3477
|
+
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3478
|
+
return;
|
|
3479
|
+
}
|
|
3480
|
+
this.keydown = true;
|
|
3481
|
+
this.target.style.cursor = "grab";
|
|
3482
|
+
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3483
|
+
};
|
|
3484
|
+
keyupHandler = (event) => {
|
|
3485
|
+
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3486
|
+
return;
|
|
3487
|
+
}
|
|
3488
|
+
event.preventDefault();
|
|
3489
|
+
event.stopImmediatePropagation();
|
|
3490
|
+
event.stopPropagation();
|
|
3491
|
+
this.keydown = false;
|
|
3492
|
+
event.preventDefault();
|
|
3493
|
+
this.removeHandler();
|
|
3494
|
+
};
|
|
3291
3495
|
setScrollOffset(deltaX, deltaY) {
|
|
3292
3496
|
const { width, height } = this.container.getBoundingClientRect();
|
|
3293
3497
|
const targetRect = this.target.getBoundingClientRect();
|
|
@@ -3348,18 +3552,19 @@ const _sfc_main$4 = defineComponent({
|
|
|
3348
3552
|
el,
|
|
3349
3553
|
style: computed(() => `
|
|
3350
3554
|
width: ${props.width}px;
|
|
3351
|
-
height: ${
|
|
3555
|
+
height: ${props.height}px;
|
|
3352
3556
|
position: absolute;
|
|
3353
3557
|
margin-top: 30px;
|
|
3354
3558
|
`)
|
|
3355
3559
|
};
|
|
3356
3560
|
}
|
|
3357
3561
|
});
|
|
3562
|
+
|
|
3358
3563
|
const _hoisted_1$1 = {
|
|
3359
3564
|
class: "m-editor-scroll-viewer-container",
|
|
3360
3565
|
ref: "container"
|
|
3361
3566
|
};
|
|
3362
|
-
function _sfc_render$
|
|
3567
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3363
3568
|
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
3364
3569
|
createElementVNode("div", {
|
|
3365
3570
|
ref: "el",
|
|
@@ -3369,170 +3574,172 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3369
3574
|
], 4)
|
|
3370
3575
|
], 512);
|
|
3371
3576
|
}
|
|
3372
|
-
|
|
3577
|
+
const ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$2]]);
|
|
3373
3578
|
|
|
3374
|
-
const _sfc_main$3 = defineComponent({
|
|
3375
|
-
|
|
3376
|
-
|
|
3579
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
3580
|
+
__name: "ViewerMenu",
|
|
3581
|
+
props: {
|
|
3582
|
+
isMultiSelect: { type: Boolean, default: false }
|
|
3583
|
+
},
|
|
3584
|
+
setup(__props, { expose }) {
|
|
3585
|
+
const props = __props;
|
|
3377
3586
|
const services = inject("services");
|
|
3378
3587
|
const editorService = services?.editorService;
|
|
3379
3588
|
const menu = ref();
|
|
3380
3589
|
const canPaste = ref(false);
|
|
3381
3590
|
const canCenter = ref(false);
|
|
3382
3591
|
const node = computed(() => editorService?.get("node"));
|
|
3592
|
+
const nodes = computed(() => editorService?.get("nodes"));
|
|
3383
3593
|
const parent = computed(() => editorService?.get("parent"));
|
|
3384
|
-
const
|
|
3594
|
+
const stage = computed(() => editorService?.get("stage"));
|
|
3385
3595
|
const stageContentMenu = inject("stageContentMenu", []);
|
|
3386
|
-
|
|
3387
|
-
|
|
3596
|
+
const menuData = reactive([
|
|
3597
|
+
{
|
|
3598
|
+
type: "button",
|
|
3599
|
+
text: "\u6C34\u5E73\u5C45\u4E2D",
|
|
3600
|
+
display: () => canCenter.value && !props.isMultiSelect,
|
|
3601
|
+
handler: () => {
|
|
3602
|
+
if (!node.value)
|
|
3603
|
+
return;
|
|
3604
|
+
editorService?.alignCenter(node.value);
|
|
3605
|
+
}
|
|
3606
|
+
},
|
|
3607
|
+
{
|
|
3608
|
+
type: "button",
|
|
3609
|
+
text: "\u590D\u5236",
|
|
3610
|
+
icon: markRaw(DocumentCopy),
|
|
3611
|
+
handler: () => {
|
|
3612
|
+
nodes.value && editorService?.copy(nodes.value);
|
|
3613
|
+
canPaste.value = true;
|
|
3614
|
+
}
|
|
3615
|
+
},
|
|
3616
|
+
{
|
|
3617
|
+
type: "button",
|
|
3618
|
+
text: "\u7C98\u8D34",
|
|
3619
|
+
display: () => canPaste.value,
|
|
3620
|
+
handler: () => {
|
|
3621
|
+
const rect = menu.value?.$el.getBoundingClientRect();
|
|
3622
|
+
const parentRect = stage.value?.container?.getBoundingClientRect();
|
|
3623
|
+
const initialLeft = (rect?.left || 0) - (parentRect?.left || 0);
|
|
3624
|
+
const initialTop = (rect?.top || 0) - (parentRect?.top || 0);
|
|
3625
|
+
if (!nodes.value || nodes.value.length === 0)
|
|
3626
|
+
return;
|
|
3627
|
+
editorService?.paste({ left: initialLeft, top: initialTop });
|
|
3628
|
+
}
|
|
3629
|
+
},
|
|
3630
|
+
{
|
|
3631
|
+
type: "divider",
|
|
3632
|
+
direction: "horizontal",
|
|
3633
|
+
display: () => {
|
|
3634
|
+
if (!node.value)
|
|
3635
|
+
return false;
|
|
3636
|
+
return !isPage(node.value);
|
|
3637
|
+
}
|
|
3638
|
+
},
|
|
3639
|
+
{
|
|
3640
|
+
type: "button",
|
|
3641
|
+
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
3642
|
+
icon: markRaw(Top),
|
|
3643
|
+
display: () => !isPage(node.value) && !props.isMultiSelect,
|
|
3644
|
+
handler: () => {
|
|
3645
|
+
editorService?.moveLayer(1);
|
|
3646
|
+
}
|
|
3647
|
+
},
|
|
3648
|
+
{
|
|
3649
|
+
type: "button",
|
|
3650
|
+
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
3651
|
+
icon: markRaw(Bottom),
|
|
3652
|
+
display: () => !isPage(node.value) && !props.isMultiSelect,
|
|
3653
|
+
handler: () => {
|
|
3654
|
+
editorService?.moveLayer(-1);
|
|
3655
|
+
}
|
|
3656
|
+
},
|
|
3657
|
+
{
|
|
3658
|
+
type: "button",
|
|
3659
|
+
text: "\u7F6E\u9876",
|
|
3660
|
+
display: () => !isPage(node.value) && !props.isMultiSelect,
|
|
3661
|
+
handler: () => {
|
|
3662
|
+
editorService?.moveLayer(LayerOffset.TOP);
|
|
3663
|
+
}
|
|
3664
|
+
},
|
|
3665
|
+
{
|
|
3666
|
+
type: "button",
|
|
3667
|
+
text: "\u7F6E\u5E95",
|
|
3668
|
+
display: () => !isPage(node.value) && !props.isMultiSelect,
|
|
3669
|
+
handler: () => {
|
|
3670
|
+
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
3671
|
+
}
|
|
3672
|
+
},
|
|
3673
|
+
{
|
|
3674
|
+
type: "divider",
|
|
3675
|
+
direction: "horizontal",
|
|
3676
|
+
display: () => !isPage(node.value) && !props.isMultiSelect
|
|
3677
|
+
},
|
|
3678
|
+
{
|
|
3679
|
+
type: "button",
|
|
3680
|
+
text: "\u5220\u9664",
|
|
3681
|
+
icon: Delete,
|
|
3682
|
+
display: () => !isPage(node.value),
|
|
3683
|
+
handler: () => {
|
|
3684
|
+
nodes.value && editorService?.remove(nodes.value);
|
|
3685
|
+
}
|
|
3686
|
+
},
|
|
3687
|
+
{
|
|
3688
|
+
type: "divider",
|
|
3689
|
+
direction: "horizontal"
|
|
3690
|
+
},
|
|
3691
|
+
{
|
|
3692
|
+
type: "button",
|
|
3693
|
+
text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
|
|
3694
|
+
handler: () => {
|
|
3695
|
+
editorService?.get("stage").clearGuides();
|
|
3696
|
+
}
|
|
3697
|
+
},
|
|
3698
|
+
...stageContentMenu
|
|
3699
|
+
]);
|
|
3700
|
+
onMounted(async () => {
|
|
3701
|
+
const data = await storageService.getItem(COPY_STORAGE_KEY);
|
|
3388
3702
|
canPaste.value = data !== "undefined" && !!data;
|
|
3389
3703
|
});
|
|
3390
3704
|
watch(parent, async () => {
|
|
3391
3705
|
if (!parent.value || !editorService)
|
|
3392
3706
|
return canCenter.value = false;
|
|
3393
3707
|
const layout = await editorService.getLayout(parent.value);
|
|
3394
|
-
|
|
3708
|
+
const isLayoutConform = [Layout.ABSOLUTE, Layout.FIXED].includes(layout);
|
|
3709
|
+
const isTypeConform = nodes.value?.every((selectedNode) => ![NodeType.ROOT, NodeType.PAGE, "pop"].includes(`${selectedNode?.type}`));
|
|
3710
|
+
canCenter.value = isLayoutConform && !!isTypeConform;
|
|
3395
3711
|
}, { immediate: true });
|
|
3396
|
-
|
|
3397
|
-
menu
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
},
|
|
3407
|
-
{
|
|
3408
|
-
type: "button",
|
|
3409
|
-
text: "\u590D\u5236",
|
|
3410
|
-
icon: markRaw(DocumentCopy),
|
|
3411
|
-
handler: () => {
|
|
3412
|
-
node.value && editorService?.copy(node.value);
|
|
3413
|
-
canPaste.value = true;
|
|
3414
|
-
}
|
|
3415
|
-
},
|
|
3416
|
-
{
|
|
3417
|
-
type: "button",
|
|
3418
|
-
text: "\u7C98\u8D34",
|
|
3419
|
-
display: () => canPaste.value,
|
|
3420
|
-
handler: () => {
|
|
3421
|
-
const stage = editorService?.get("stage");
|
|
3422
|
-
const rect = menu.value?.$el.getBoundingClientRect();
|
|
3423
|
-
const parentRect = stage?.container?.getBoundingClientRect();
|
|
3424
|
-
let left = (rect?.left || 0) - (parentRect?.left || 0);
|
|
3425
|
-
let top = (rect?.top || 0) - (parentRect?.top || 0);
|
|
3426
|
-
if (node.value?.items && stage) {
|
|
3427
|
-
const parentEl = stage.renderer.contentWindow?.document.getElementById(`${node.value.id}`);
|
|
3428
|
-
const parentElRect = parentEl?.getBoundingClientRect();
|
|
3429
|
-
left = left - (parentElRect?.left || 0);
|
|
3430
|
-
top = top - (parentElRect?.top || 0);
|
|
3431
|
-
}
|
|
3432
|
-
editorService?.paste({ left, top });
|
|
3433
|
-
}
|
|
3434
|
-
},
|
|
3435
|
-
{
|
|
3436
|
-
type: "divider",
|
|
3437
|
-
direction: "horizontal",
|
|
3438
|
-
display: () => !isPage.value
|
|
3439
|
-
},
|
|
3440
|
-
{
|
|
3441
|
-
type: "button",
|
|
3442
|
-
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
3443
|
-
icon: markRaw(Top),
|
|
3444
|
-
display: () => !isPage.value,
|
|
3445
|
-
handler: () => {
|
|
3446
|
-
editorService?.moveLayer(1);
|
|
3447
|
-
}
|
|
3448
|
-
},
|
|
3449
|
-
{
|
|
3450
|
-
type: "button",
|
|
3451
|
-
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
3452
|
-
icon: markRaw(Bottom),
|
|
3453
|
-
display: () => !isPage.value,
|
|
3454
|
-
handler: () => {
|
|
3455
|
-
editorService?.moveLayer(-1);
|
|
3456
|
-
}
|
|
3457
|
-
},
|
|
3458
|
-
{
|
|
3459
|
-
type: "button",
|
|
3460
|
-
text: "\u7F6E\u9876",
|
|
3461
|
-
display: () => !isPage.value,
|
|
3462
|
-
handler: () => {
|
|
3463
|
-
editorService?.moveLayer(LayerOffset.TOP);
|
|
3464
|
-
}
|
|
3465
|
-
},
|
|
3466
|
-
{
|
|
3467
|
-
type: "button",
|
|
3468
|
-
text: "\u7F6E\u5E95",
|
|
3469
|
-
display: () => !isPage.value,
|
|
3470
|
-
handler: () => {
|
|
3471
|
-
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
3472
|
-
}
|
|
3473
|
-
},
|
|
3474
|
-
{
|
|
3475
|
-
type: "divider",
|
|
3476
|
-
direction: "horizontal",
|
|
3477
|
-
display: () => !isPage.value
|
|
3478
|
-
},
|
|
3479
|
-
{
|
|
3480
|
-
type: "button",
|
|
3481
|
-
text: "\u5220\u9664",
|
|
3482
|
-
icon: Delete,
|
|
3483
|
-
display: () => !isPage.value,
|
|
3484
|
-
handler: () => {
|
|
3485
|
-
node.value && editorService?.remove(node.value);
|
|
3486
|
-
}
|
|
3487
|
-
},
|
|
3488
|
-
{
|
|
3489
|
-
type: "divider",
|
|
3490
|
-
direction: "horizontal"
|
|
3491
|
-
},
|
|
3492
|
-
{
|
|
3493
|
-
type: "button",
|
|
3494
|
-
text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
|
|
3495
|
-
handler: () => {
|
|
3496
|
-
editorService?.get("stage").clearGuides();
|
|
3497
|
-
}
|
|
3498
|
-
},
|
|
3499
|
-
...stageContentMenu
|
|
3500
|
-
]),
|
|
3501
|
-
show(e) {
|
|
3502
|
-
menu.value?.show(e);
|
|
3503
|
-
}
|
|
3712
|
+
const show = (e) => {
|
|
3713
|
+
menu.value?.show(e);
|
|
3714
|
+
};
|
|
3715
|
+
expose({ show });
|
|
3716
|
+
return (_ctx, _cache) => {
|
|
3717
|
+
return openBlock(), createBlock(_sfc_main$a, {
|
|
3718
|
+
"menu-data": menuData,
|
|
3719
|
+
ref_key: "menu",
|
|
3720
|
+
ref: menu
|
|
3721
|
+
}, null, 8, ["menu-data"]);
|
|
3504
3722
|
};
|
|
3505
3723
|
}
|
|
3506
3724
|
});
|
|
3507
|
-
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3508
|
-
const _component_content_menu = resolveComponent("content-menu");
|
|
3509
|
-
return openBlock(), createBlock(_component_content_menu, {
|
|
3510
|
-
"menu-data": _ctx.menuData,
|
|
3511
|
-
ref: "menu"
|
|
3512
|
-
}, null, 8, ["menu-data"]);
|
|
3513
|
-
}
|
|
3514
|
-
var ViewerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
|
|
3515
3725
|
|
|
3516
|
-
const _sfc_main$2 = defineComponent({
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
},
|
|
3522
|
-
setup() {
|
|
3726
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
3727
|
+
__name: "Stage",
|
|
3728
|
+
setup(__props) {
|
|
3729
|
+
let stage = null;
|
|
3730
|
+
let runtime = null;
|
|
3523
3731
|
const services = inject("services");
|
|
3524
3732
|
const stageOptions = inject("stageOptions");
|
|
3525
3733
|
const stageWrap = ref();
|
|
3526
3734
|
const stageContainer = ref();
|
|
3527
3735
|
const menu = ref();
|
|
3736
|
+
const isMultiSelect = computed(() => services?.editorService.get("nodes")?.length > 1);
|
|
3528
3737
|
const stageRect = computed(() => services?.uiService.get("stageRect"));
|
|
3529
3738
|
const uiSelectMode = computed(() => services?.uiService.get("uiSelectMode"));
|
|
3530
3739
|
const root = computed(() => services?.editorService.get("root"));
|
|
3531
3740
|
const page = computed(() => services?.editorService.get("page"));
|
|
3532
3741
|
const zoom = computed(() => services?.uiService.get("zoom") || 1);
|
|
3533
3742
|
const node = computed(() => services?.editorService.get("node"));
|
|
3534
|
-
let stage = null;
|
|
3535
|
-
let runtime = null;
|
|
3536
3743
|
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
3537
3744
|
watchEffect(() => {
|
|
3538
3745
|
if (stage)
|
|
@@ -3572,6 +3779,9 @@ const _sfc_main$2 = defineComponent({
|
|
|
3572
3779
|
stage?.on("highlight", (el) => {
|
|
3573
3780
|
services?.editorService.highlight(el.id);
|
|
3574
3781
|
});
|
|
3782
|
+
stage?.on("multiSelect", (els) => {
|
|
3783
|
+
services?.editorService.multiSelect(els.map((el) => el.id));
|
|
3784
|
+
});
|
|
3575
3785
|
stage?.on("update", (ev) => {
|
|
3576
3786
|
if (ev.parentEl) {
|
|
3577
3787
|
services?.editorService.moveToContainer({ id: ev.el.id, style: ev.style }, ev.parentEl.id);
|
|
@@ -3630,99 +3840,96 @@ const _sfc_main$2 = defineComponent({
|
|
|
3630
3840
|
resizeObserver.disconnect();
|
|
3631
3841
|
services?.editorService.set("stage", null);
|
|
3632
3842
|
});
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
e2.
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
const
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
}
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
top = e.clientY - containerRect.top + scrollTop;
|
|
3669
|
-
left = e.clientX - containerRect.left + scrollLeft;
|
|
3670
|
-
if (parentEl && doc) {
|
|
3671
|
-
const { left: parentLeft, top: parentTop } = getOffset(parentEl);
|
|
3672
|
-
left = left - calcValueByFontsize(doc, parentLeft);
|
|
3673
|
-
top = top - calcValueByFontsize(doc, parentTop);
|
|
3674
|
-
}
|
|
3843
|
+
const contextmenuHandler = (e2) => {
|
|
3844
|
+
e2.preventDefault();
|
|
3845
|
+
menu.value?.show(e2);
|
|
3846
|
+
};
|
|
3847
|
+
const dragoverHandler = (e2) => {
|
|
3848
|
+
e2.preventDefault();
|
|
3849
|
+
if (e2.dataTransfer) {
|
|
3850
|
+
e2.dataTransfer.dropEffect = "move";
|
|
3851
|
+
}
|
|
3852
|
+
};
|
|
3853
|
+
const dropHandler = async (e) => {
|
|
3854
|
+
e.preventDefault();
|
|
3855
|
+
const doc = stage?.renderer.contentWindow?.document;
|
|
3856
|
+
const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
|
|
3857
|
+
let parent = page.value;
|
|
3858
|
+
if (parentEl) {
|
|
3859
|
+
parent = services?.editorService.getNodeById(parentEl.id, false);
|
|
3860
|
+
}
|
|
3861
|
+
if (e.dataTransfer && parent && stageContainer.value && stage) {
|
|
3862
|
+
const config = eval(`(${e.dataTransfer.getData("data")})`);
|
|
3863
|
+
const layout = await services?.editorService.getLayout(parent);
|
|
3864
|
+
const containerRect = stageContainer.value.getBoundingClientRect();
|
|
3865
|
+
const { scrollTop, scrollLeft } = stage.mask;
|
|
3866
|
+
const { style = {} } = config;
|
|
3867
|
+
let top = 0;
|
|
3868
|
+
let left = 0;
|
|
3869
|
+
let position = "relative";
|
|
3870
|
+
if (layout === Layout.ABSOLUTE) {
|
|
3871
|
+
position = "absolute";
|
|
3872
|
+
top = e.clientY - containerRect.top + scrollTop;
|
|
3873
|
+
left = e.clientX - containerRect.left + scrollLeft;
|
|
3874
|
+
if (parentEl && doc) {
|
|
3875
|
+
const { left: parentLeft, top: parentTop } = getOffset(parentEl);
|
|
3876
|
+
left = left - calcValueByFontsize(doc, parentLeft);
|
|
3877
|
+
top = top - calcValueByFontsize(doc, parentTop);
|
|
3675
3878
|
}
|
|
3676
|
-
config.style = {
|
|
3677
|
-
...style,
|
|
3678
|
-
position,
|
|
3679
|
-
top,
|
|
3680
|
-
left
|
|
3681
|
-
};
|
|
3682
|
-
services?.editorService.add(config, parent);
|
|
3683
3879
|
}
|
|
3880
|
+
config.style = {
|
|
3881
|
+
...style,
|
|
3882
|
+
position,
|
|
3883
|
+
top,
|
|
3884
|
+
left
|
|
3885
|
+
};
|
|
3886
|
+
config.inputEvent = e;
|
|
3887
|
+
services?.editorService.add(config, parent);
|
|
3684
3888
|
}
|
|
3685
3889
|
};
|
|
3890
|
+
return (_ctx, _cache) => {
|
|
3891
|
+
return openBlock(), createBlock(ScrollViewer, {
|
|
3892
|
+
class: "m-editor-stage",
|
|
3893
|
+
ref_key: "stageWrap",
|
|
3894
|
+
ref: stageWrap,
|
|
3895
|
+
width: unref(stageRect)?.width,
|
|
3896
|
+
height: unref(stageRect)?.height,
|
|
3897
|
+
zoom: unref(zoom)
|
|
3898
|
+
}, {
|
|
3899
|
+
default: withCtx(() => [
|
|
3900
|
+
createElementVNode("div", {
|
|
3901
|
+
class: "m-editor-stage-container",
|
|
3902
|
+
ref_key: "stageContainer",
|
|
3903
|
+
ref: stageContainer,
|
|
3904
|
+
style: normalizeStyle(`transform: scale(${unref(zoom)})`),
|
|
3905
|
+
onContextmenu: contextmenuHandler,
|
|
3906
|
+
onDrop: dropHandler,
|
|
3907
|
+
onDragover: dragoverHandler
|
|
3908
|
+
}, null, 36),
|
|
3909
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
3910
|
+
createVNode(_sfc_main$3, {
|
|
3911
|
+
ref_key: "menu",
|
|
3912
|
+
ref: menu,
|
|
3913
|
+
"is-multi-select": unref(isMultiSelect)
|
|
3914
|
+
}, null, 8, ["is-multi-select"])
|
|
3915
|
+
]))
|
|
3916
|
+
]),
|
|
3917
|
+
_: 1
|
|
3918
|
+
}, 8, ["width", "height", "zoom"]);
|
|
3919
|
+
};
|
|
3686
3920
|
}
|
|
3687
3921
|
});
|
|
3688
|
-
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3689
|
-
const _component_viewer_menu = resolveComponent("viewer-menu");
|
|
3690
|
-
const _component_scroll_viewer = resolveComponent("scroll-viewer");
|
|
3691
|
-
return openBlock(), createBlock(_component_scroll_viewer, {
|
|
3692
|
-
class: "m-editor-stage",
|
|
3693
|
-
ref: "stageWrap",
|
|
3694
|
-
width: _ctx.stageRect?.width,
|
|
3695
|
-
height: _ctx.stageRect?.height,
|
|
3696
|
-
zoom: _ctx.zoom
|
|
3697
|
-
}, {
|
|
3698
|
-
default: withCtx(() => [
|
|
3699
|
-
createElementVNode("div", {
|
|
3700
|
-
class: "m-editor-stage-container",
|
|
3701
|
-
ref: "stageContainer",
|
|
3702
|
-
style: normalizeStyle(`transform: scale(${_ctx.zoom})`),
|
|
3703
|
-
onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
|
|
3704
|
-
onDrop: _cache[1] || (_cache[1] = (...args) => _ctx.dropHandler && _ctx.dropHandler(...args)),
|
|
3705
|
-
onDragover: _cache[2] || (_cache[2] = (...args) => _ctx.dragoverHandler && _ctx.dragoverHandler(...args))
|
|
3706
|
-
}, null, 36),
|
|
3707
|
-
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
3708
|
-
createVNode(_component_viewer_menu, { ref: "menu" }, null, 512)
|
|
3709
|
-
]))
|
|
3710
|
-
]),
|
|
3711
|
-
_: 1
|
|
3712
|
-
}, 8, ["width", "height", "zoom"]);
|
|
3713
|
-
}
|
|
3714
|
-
var MagicStage = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
|
|
3715
3922
|
|
|
3716
3923
|
const _sfc_main$1 = defineComponent({
|
|
3717
3924
|
name: "m-editor-workspace",
|
|
3718
3925
|
components: {
|
|
3719
|
-
PageBar,
|
|
3720
|
-
MagicStage
|
|
3926
|
+
PageBar: _sfc_main$5,
|
|
3927
|
+
MagicStage: _sfc_main$2
|
|
3721
3928
|
},
|
|
3722
3929
|
setup() {
|
|
3723
3930
|
const services = inject("services");
|
|
3724
3931
|
const workspace = ref();
|
|
3725
|
-
const
|
|
3932
|
+
const nodes = computed(() => services?.editorService.get("nodes"));
|
|
3726
3933
|
let keycon;
|
|
3727
3934
|
const mouseenterHandler = () => {
|
|
3728
3935
|
workspace.value?.focus();
|
|
@@ -3738,26 +3945,26 @@ const _sfc_main$1 = defineComponent({
|
|
|
3738
3945
|
const ctrl = isMac ? "meta" : "ctrl";
|
|
3739
3946
|
keycon.keyup("delete", (e) => {
|
|
3740
3947
|
e.inputEvent.preventDefault();
|
|
3741
|
-
if (!
|
|
3948
|
+
if (!nodes.value || isPage(nodes.value[0]))
|
|
3742
3949
|
return;
|
|
3743
|
-
services?.editorService.remove(
|
|
3950
|
+
services?.editorService.remove(nodes.value);
|
|
3744
3951
|
}).keyup("backspace", (e) => {
|
|
3745
3952
|
e.inputEvent.preventDefault();
|
|
3746
|
-
if (!
|
|
3953
|
+
if (!nodes.value || isPage(nodes.value[0]))
|
|
3747
3954
|
return;
|
|
3748
|
-
services?.editorService.remove(
|
|
3955
|
+
services?.editorService.remove(nodes.value);
|
|
3749
3956
|
}).keydown([ctrl, "c"], (e) => {
|
|
3750
3957
|
e.inputEvent.preventDefault();
|
|
3751
|
-
|
|
3958
|
+
nodes.value && services?.editorService.copy(nodes.value);
|
|
3752
3959
|
}).keydown([ctrl, "v"], (e) => {
|
|
3753
3960
|
e.inputEvent.preventDefault();
|
|
3754
|
-
|
|
3961
|
+
nodes.value && services?.editorService.paste();
|
|
3755
3962
|
}).keydown([ctrl, "x"], (e) => {
|
|
3756
3963
|
e.inputEvent.preventDefault();
|
|
3757
|
-
if (!
|
|
3964
|
+
if (!nodes.value || isPage(nodes.value[0]))
|
|
3758
3965
|
return;
|
|
3759
|
-
services?.editorService.copy(
|
|
3760
|
-
services?.editorService.remove(
|
|
3966
|
+
services?.editorService.copy(nodes.value);
|
|
3967
|
+
services?.editorService.remove(nodes.value);
|
|
3761
3968
|
}).keydown([ctrl, "z"], (e) => {
|
|
3762
3969
|
e.inputEvent.preventDefault();
|
|
3763
3970
|
services?.editorService.undo();
|
|
@@ -3819,6 +4026,7 @@ const _sfc_main$1 = defineComponent({
|
|
|
3819
4026
|
};
|
|
3820
4027
|
}
|
|
3821
4028
|
});
|
|
4029
|
+
|
|
3822
4030
|
const _hoisted_1 = {
|
|
3823
4031
|
class: "m-editor-workspace",
|
|
3824
4032
|
tabindex: "1",
|
|
@@ -3843,14 +4051,14 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3843
4051
|
})
|
|
3844
4052
|
], 512);
|
|
3845
4053
|
}
|
|
3846
|
-
|
|
4054
|
+
const Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
3847
4055
|
|
|
3848
4056
|
class ComponentList extends BaseService {
|
|
4057
|
+
state = reactive({
|
|
4058
|
+
list: []
|
|
4059
|
+
});
|
|
3849
4060
|
constructor() {
|
|
3850
4061
|
super([]);
|
|
3851
|
-
this.state = reactive({
|
|
3852
|
-
list: []
|
|
3853
|
-
});
|
|
3854
4062
|
}
|
|
3855
4063
|
setList(componentGroupList) {
|
|
3856
4064
|
this.state.list = componentGroupList;
|
|
@@ -3859,7 +4067,7 @@ class ComponentList extends BaseService {
|
|
|
3859
4067
|
return this.state.list;
|
|
3860
4068
|
}
|
|
3861
4069
|
}
|
|
3862
|
-
|
|
4070
|
+
const componentListService = new ComponentList();
|
|
3863
4071
|
|
|
3864
4072
|
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
3865
4073
|
const MIN_LEFT_COLUMN_WIDTH = 45;
|
|
@@ -3971,13 +4179,15 @@ class Ui extends BaseService {
|
|
|
3971
4179
|
const { height, width } = stageContainerRect;
|
|
3972
4180
|
if (!width || !height)
|
|
3973
4181
|
return 1;
|
|
3974
|
-
|
|
4182
|
+
const stageWidth = stageRect.width + 30;
|
|
4183
|
+
const stageHeight = stageRect.height + 30;
|
|
4184
|
+
if (width > stageWidth && height > stageHeight) {
|
|
3975
4185
|
return 1;
|
|
3976
4186
|
}
|
|
3977
|
-
return Math.min((width -
|
|
4187
|
+
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
3978
4188
|
}
|
|
3979
4189
|
}
|
|
3980
|
-
|
|
4190
|
+
const uiService = new Ui();
|
|
3981
4191
|
|
|
3982
4192
|
const _sfc_main = defineComponent({
|
|
3983
4193
|
name: "m-editor",
|
|
@@ -4107,7 +4317,8 @@ const _sfc_main = defineComponent({
|
|
|
4107
4317
|
historyService,
|
|
4108
4318
|
propsService,
|
|
4109
4319
|
editorService,
|
|
4110
|
-
uiService
|
|
4320
|
+
uiService,
|
|
4321
|
+
storageService
|
|
4111
4322
|
};
|
|
4112
4323
|
provide("services", services);
|
|
4113
4324
|
provide("layerContentMenu", props.layerContentMenu);
|
|
@@ -4126,6 +4337,7 @@ const _sfc_main = defineComponent({
|
|
|
4126
4337
|
return services;
|
|
4127
4338
|
}
|
|
4128
4339
|
});
|
|
4340
|
+
|
|
4129
4341
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4130
4342
|
const _component_nav_menu = resolveComponent("nav-menu");
|
|
4131
4343
|
const _component_sidebar = resolveComponent("sidebar");
|
|
@@ -4186,23 +4398,23 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4186
4398
|
_: 3
|
|
4187
4399
|
}, 8, ["code-options"]);
|
|
4188
4400
|
}
|
|
4189
|
-
|
|
4401
|
+
const Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
4190
4402
|
|
|
4191
|
-
var index$1 = /* #__PURE__ */ (() => ".m-editor-nav-menu {\n display: flex;\n z-index: 5;\n -webkit-box-pack: justify;\n justify-content: space-between;\n -webkit-box-align: center;\n align-items: center;\n background-color: #ffffff;\n font-size: 19.2px;\n color: #070303;\n font-weight: 400;\n box-sizing: border-box;\n margin: 0px;\n flex: 0 0 35px;\n border-bottom: 1px solid #d8dee8;\n}\n.m-editor-nav-menu > div {\n display: flex;\n height: 100%;\n z-index: 1;\n align-items: center;\n}\n.m-editor-nav-menu .menu-center {\n justify-content: center;\n}\n.m-editor-nav-menu .menu-right {\n justify-content: flex-end;\n}\n.m-editor-nav-menu .menu-item {\n flex-direction: row;\n -webkit-box-align: center;\n align-items: center;\n vertical-align: middle;\n font-size: 14px;\n line-height: 1;\n height: 100%;\n color: rgba(255, 255, 255, 0.7);\n box-sizing: inherit;\n z-index: 1;\n display: flex !important;\n transition: all 0.3s ease 0s;\n border-bottom: 2px solid transparent;\n margin: 0;\n}\n.m-editor-nav-menu .menu-item .is-disabled {\n opacity: 0.5;\n}\n.m-editor-nav-menu .menu-item .is-text {\n padding: 5px;\n}\n.m-editor-nav-menu .menu-item .is-text,\n.m-editor-nav-menu .menu-item i {\n color: #070303;\n}\n.m-editor-nav-menu .menu-item .icon {\n display: flex;\n -webkit-box-align: center;\n align-items: center;\n height: 100%;\n padding: 0px 8px;\n}\n.m-editor-nav-menu .menu-item .menu-item-text {\n color: #070303;\n}\n.m-editor {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n.m-editor-content {\n width: 100%;\n height: calc(100% - 35px);\n display: flex;\n justify-self: space-between;\n}\n.m-editor-framework-center {\n position: relative;\n transform: translateZ(0);\n flex: 1;\n}\n.m-editor-framework-left {\n background-color: #ffffff;\n}\n.m-editor-framework-center .el-scrollbar__view {\n height: 100%;\n min-height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.m-editor-empty-panel {\n display: flex;\n flex: 1;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n height: calc(100% - 32px);\n}\n.m-editor-empty-content {\n display: flex;\n justify-content: space-evenly;\n flex-direction: row;\n width: 100%;\n}\n.m-editor-empty-button {\n border: 3px solid rgba(0, 0, 0, 0.2);\n padding: 10px 40px;\n color: rgba(0, 0, 0, 0.6);\n cursor: pointer;\n}\n.m-editor-empty-button i {\n height: 180px;\n line-height: 180px;\n font-size: 100px;\n}\n.m-editor-empty-button p {\n text-align: center;\n font-size: 20px;\n margin-top: 5px;\n}\n.m-editor-empty-button:hover {\n border-color: #2882e0;\n color: #2882e0;\n}\n.m-editor-sidebar {\n height: 100%;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header {\n background: #2882e0;\n border: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header.is-left {\n width: 40px;\n margin-right: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__nav-wrap {\n margin: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__nav {\n border: 0;\n border-radius: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .tab-label {\n margin-left: 2px;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left {\n line-height: 15px;\n border: 0;\n height: auto;\n padding: 8px;\n color: rgb(255, 255, 255);\n box-sizing: border-box;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active {\n background: #ffffff;\n border: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active i {\n color: #353140;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active .magic-editor-tab-panel-title {\n color: #353140;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left:first-child {\n border-right: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header i {\n font-size: 25px;\n color: rgba(255, 255, 255, 0.6);\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header i:hover {\n color: rgb(255, 255, 255);\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .magic-editor-tab-panel-title {\n font-size: 12px;\n white-space: normal;\n}\n.m-editor-sidebar .el-scrollbar {\n height: 100%;\n}\n.m-editor-sidebar .el-tree {\n min-height: 100%;\n}\n.m-editor-sidebar .fold-icon {\n position: absolute;\n bottom: 8px;\n left: 0px;\n width: 45px;\n padding-left: 8px;\n color: #fff;\n font-size: 32px;\n opacity: 0.8;\n cursor: pointer;\n}\n.m-editor-sidebar .fold-icon:hover {\n background: rgba(0, 0, 0, 0.2);\n}\n.m-editor-sidebar .el-tabs__content,\n.m-editor-sidebar .el-tab-pane {\n height: 100%;\n}\n.magic-editor-layer-panel {\n background: #ffffff;\n}\n.magic-editor-layer-panel .search-input {\n background: #ffffff;\n color: #bbbbbb;\n padding: 10px;\n position: absolute;\n top: 0;\n left: 0;\n z-index: 1;\n}\n.magic-editor-layer-panel .search-input .el-input__suffix {\n padding: 10px 5px;\n}\n.magic-editor-layer-panel .node-content {\n flex: 1;\n display: flex;\n width: 100%;\n}\n.magic-editor-layer-panel .node-content > div {\n width: 8px;\n}\n.magic-editor-layer-panel .node-content > span {\n width: calc(100% - 68px);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.magic-editor-layer-panel .node-content > i {\n margin-right: 10px;\n font-size: 20px;\n}\n.magic-editor-layer-panel .node-content > i.lock {\n color: #bbb;\n}\n.magic-editor-layer-panel,\n.magic-editor-layer-panel .el-tree {\n background-color: #ffffff;\n color: #313a40;\n}\n.magic-editor-layer-panel .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {\n background-color: #2882e0;\n color: #fff;\n}\n.magic-editor-layer-panel .cus-tree-node {\n width: 100%;\n overflow: hidden;\n}\n.magic-editor-layer-panel .cus-tree-node-hover {\n background-color: #f3f5f9;\n width: 100%;\n}\n.magic-editor-layer-panel .el-tree-node:focus > .el-tree-node__content {\n background-color: #2882e0;\n color: #fff;\n}\n.ui-tree-tip {\n width: 100%;\n height: 25px;\n margin-left: 10px;\n background: #ffffff;\n font-style: italic;\n color: #555554;\n position: absolute;\n top: 40px;\n left: 0;\n z-index: 1;\n}\n.ui-component-panel {\n height: 100%;\n border-top: 0 !important;\n margin-top: 50px;\n background-color: #ffffff;\n}\n.ui-component-panel .search-input {\n background: #f8fbff;\n color: #bbbbbb;\n padding: 10px;\n position: absolute;\n top: 0;\n left: 0;\n box-sizing: border-box;\n z-index: 1;\n}\n.ui-component-panel .search-input .el-input__prefix {\n padding: 10px;\n}\n.ui-component-panel .search-input .el-input__suffix {\n padding: 10px 5px;\n}\n.ui-component-panel .el-collapse-item > div:first-of-type {\n border-bottom: 1px solid #d9dbdd;\n margin-bottom: 10px;\n}\n.ui-component-panel .el-collapse-item__header {\n background: #ffffff;\n color: #070303;\n height: 25px;\n line-height: 25px;\n padding-left: 10px;\n font-size: 12px;\n}\n.ui-component-panel .el-collapse-item__header i {\n margin-right: 5px;\n font-size: 14px;\n}\n.ui-component-panel .el-collapse-item__wrap {\n background: #ffffff;\n border-bottom: 0;\n}\n.ui-component-panel .el-collapse-item__wrap .el-collapse-item__content {\n padding: 10px;\n display: flex;\n flex-wrap: wrap;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item {\n display: flex;\n overflow: hidden;\n text-overflow: ellipsis;\n margin: 5px 10px;\n box-sizing: border-box;\n color: #070303;\n flex-direction: column;\n width: 42px;\n cursor: pointer;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item i {\n font-size: 20px;\n background: #fff;\n height: 40px;\n width: 40px;\n line-height: 40px;\n border-radius: 5px;\n color: #909090;\n border: 1px solid #d9dbdd;\n display: flex;\n justify-content: space-evenly;\n align-items: center;\n margin-bottom: 5px;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item i:hover {\n background: #2882e0;\n color: #fff;\n border-color: #4e8be1;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item span {\n font-size: 12px;\n text-align: center;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item .el-tooltip {\n width: 50px;\n height: 30px;\n line-height: 15px;\n display: block;\n white-space: normal;\n margin: 0;\n}\n.m-editor-resizer {\n border-left: 1px solid transparent;\n border-right: 1px solid transparent;\n width: 8px;\n margin: 0 -5px;\n height: 100%;\n opacity: 0.9;\n background: padding-box #d8dee8;\n box-sizing: border-box;\n cursor: col-resize;\n z-index: 1;\n}\n.m-editor-resizer:hover {\n border-color: #d8dee8;\n}\n.m-editor-resizer .icon-container {\n visibility: hidden;\n opacity: 0;\n transition: opacity 0.4s;\n width: 20px;\n height: 120px;\n line-height: 120px;\n text-align: center;\n background: #d8dee8;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n cursor: pointer;\n}\n.m-editor-resizer .icon-container.position-left {\n transform: translate(calc(-100% - 4px), -50%);\n}\n.m-editor-resizer .icon-container.position-right {\n transform: translate(calc(100% + 4px), -50%);\n}\n.m-editor-resizer .icon {\n color: #fff;\n font-size: 18px;\n}\n.magic-editor-resizer:hover .icon-container {\n visibility: visible;\n opacity: 1;\n}\n.m-editor-workspace {\n height: 100%;\n width: 100%;\n user-select: none;\n}\n.m-editor-workspace:focus-visible {\n outline: 0;\n}\n.m-editor-page-bar {\n position: fixed;\n bottom: 0;\n left: 0;\n display: flex;\n width: 100%;\n height: 32px;\n line-height: 32px;\n color: #070303;\n background-color: #f3f3f3;\n border-top: 1px solid #d9dbdd;\n z-index: 2;\n overflow: hidden;\n}\n.m-editor-page-bar-items {\n display: flex;\n transition: transform 0.3s;\n}\n.m-editor-page-bar-item {\n padding: 0 10px;\n cursor: pointer;\n border-right: 1px solid #d9dbdd;\n display: flex;\n justify-items: center;\n align-items: center;\n background-color: #f3f3f3;\n white-space: nowrap;\n}\n.m-editor-page-bar-item.active {\n background-color: #fff;\n cursor: text;\n}\n.m-editor-page-bar-item.active .m-editor-page-bar-menu-icon {\n cursor: pointer;\n}\n.m-editor-page-bar-item-icon {\n position: relative;\n z-index: 1;\n}\n.m-editor-page-bar-item-title {\n max-width: 150px;\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n}\n.page-bar-popover.el-popper.el-popover {\n padding: 10px 0;\n}\n.page-bar-popover .menu-item {\n cursor: pointer;\n transition: all 0.2s ease 0s;\n padding: 5px 14px;\n}\n.page-bar-popover .menu-item .el-button--text,\n.page-bar-popover .menu-item i {\n color: #070303;\n}\n.page-bar-popover .menu-item:hover {\n background-color: #f3f5f9;\n}\n.m-editor-props-panel {\n padding: 0 10px;\n}\n.m-editor-props-panel.small .el-form-item__label {\n font-size: 12px;\n}\n.m-editor-props-panel.small .m-fieldset legend {\n font-size: 12px;\n}\n.m-editor-props-panel.small .el-tabs__item {\n font-size: 12px;\n}\n.m-editor-props-panel .el-input__wrapper {\n border-radius: 0;\n}\n.m-editor-props-panel-popper.small span,\n.m-editor-props-panel-popper.small a,\n.m-editor-props-panel-popper.small p {\n font-size: 12px;\n}\n.magic-editor-content-menu {\n position: fixed;\n font-size: 12px;\n background: #fff;\n box-shadow: 0 2px 8px 2px rgba(68, 73, 77, 0.16);\n z-index: 9999;\n transform-origin: 0% 0%;\n font-weight: 600;\n padding: 4px 0px;\n overflow: auto;\n max-height: 100%;\n}\n.magic-editor-content-menu .menu-item {\n color: #333;\n display: flex;\n -webkit-box-align: center;\n align-items: center;\n cursor: pointer;\n min-width: 140px;\n transition: all 0.2s ease 0s;\n padding: 5px 14px;\n border-left: 2px solid transparent;\n}\n.magic-editor-content-menu .menu-item .el-button {\n width: 100%;\n justify-content: flex-start;\n}\n.magic-editor-content-menu .menu-item .el-button--text,\n.magic-editor-content-menu .menu-item i {\n color: #070303;\n}\n.magic-editor-content-menu .menu-item.divider {\n padding: 0 14px;\n}\n.magic-editor-content-menu .menu-item.divider .el-divider {\n margin: 0;\n}\n.magic-editor-content-menu .menu-item:hover {\n background-color: #f3f5f9;\n}\n.m-editor-stage {\n position: relative;\n width: 100%;\n height: calc(100% - 32px);\n overflow: hidden;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.m-editor-stage-container {\n width: 100%;\n height: 100%;\n z-index: 0;\n position: relative;\n border: 1px solid #d9dbdd;\n transition: transform 0.3s;\n box-sizing: content-box;\n}\n.m-editor-stage-container::-webkit-scrollbar {\n width: 0 !important;\n}\n.magic-code-editor {\n width: 100%;\n}\n.magic-code-editor .margin {\n margin: 0;\n}")();
|
|
4403
|
+
const index$1 = '';
|
|
4192
4404
|
|
|
4193
4405
|
const defaultInstallOpt = {};
|
|
4194
|
-
|
|
4406
|
+
const index = {
|
|
4195
4407
|
install: (app, opt) => {
|
|
4196
4408
|
const option = Object.assign(defaultInstallOpt, opt || {});
|
|
4197
4409
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
4198
4410
|
setConfig(option);
|
|
4199
4411
|
app.component(Editor.name, Editor);
|
|
4200
|
-
app.component(
|
|
4412
|
+
app.component(_sfc_main$k.name, _sfc_main$k);
|
|
4201
4413
|
app.component(CodeLink.name, CodeLink);
|
|
4202
4414
|
app.component(Code.name, Code);
|
|
4203
4415
|
app.component(CodeEditor.name, CodeEditor);
|
|
4204
4416
|
}
|
|
4205
4417
|
};
|
|
4206
4418
|
|
|
4207
|
-
export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, ToolButton, V_GUIDE_LINE_STORAGE_KEY, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, fixNodeLeft, generatePageName, generatePageNameByApp, getConfig,
|
|
4208
|
-
//# sourceMappingURL=tmagic-editor.
|
|
4419
|
+
export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$e as ToolButton, V_GUIDE_LINE_STORAGE_KEY, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, fixNodeLeft, generatePageName, generatePageNameByApp, getConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getRelativeStyle, historyService, info, isFixed, log, propsService, setConfig, setLayout, storageService, uiService, warn };
|
|
4420
|
+
//# sourceMappingURL=tmagic-editor.mjs.map
|