@tmagic/editor 1.1.0-beta.1 → 1.1.0-beta.12
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 +5 -1
- package/dist/{tmagic-editor.es.js → tmagic-editor.mjs} +1449 -1205
- package/dist/tmagic-editor.mjs.map +1 -0
- package/dist/tmagic-editor.umd.js +1463 -1219
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +23 -21
- package/src/Editor.vue +24 -15
- package/src/components/ContentMenu.vue +87 -99
- package/src/components/Icon.vue +1 -1
- package/src/components/ScrollViewer.vue +2 -2
- package/src/components/ToolButton.vue +150 -167
- package/src/fields/UISelect.vue +51 -72
- package/src/index.ts +2 -1
- 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 +6 -17
- package/src/layouts/sidebar/LayerMenu.vue +2 -2
- package/src/layouts/sidebar/LayerPanel.vue +52 -12
- package/src/layouts/sidebar/Sidebar.vue +1 -1
- package/src/layouts/sidebar/TabPane.vue +2 -2
- package/src/layouts/workspace/PageBar.vue +63 -192
- package/src/layouts/workspace/PageBarScrollContainer.vue +111 -0
- package/src/layouts/workspace/Stage.vue +198 -219
- package/src/layouts/workspace/ViewerMenu.vue +140 -147
- package/src/layouts/workspace/Workspace.vue +14 -12
- package/src/services/BaseService.ts +5 -10
- package/src/services/componentList.ts +3 -3
- package/src/services/editor.ts +208 -147
- package/src/services/events.ts +1 -1
- package/src/services/history.ts +1 -1
- package/src/services/props.ts +74 -49
- package/src/services/storage.ts +133 -0
- package/src/services/ui.ts +10 -4
- package/src/theme/component-list-panel.scss +5 -0
- package/src/theme/framework.scss +1 -1
- package/src/theme/stage.scss +2 -2
- package/src/type.ts +25 -7
- package/src/utils/config.ts +1 -1
- package/src/utils/editor.ts +20 -12
- package/src/utils/operator.ts +109 -0
- package/src/utils/props.ts +2 -27
- package/src/utils/scroll-viewer.ts +1 -1
- package/tsconfig.build.json +13 -0
- package/{dist/types/src → types}/Editor.vue.d.ts +17 -9
- 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 +83 -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 +1101 -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/PageBarScrollContainer.vue.d.ts +48 -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 +22 -14
- package/{dist/types/src → types}/services/events.d.ts +0 -0
- package/{dist/types/src → types}/services/history.d.ts +0 -0
- package/types/services/props.d.ts +97 -0
- 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 +18 -1
- 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 +6 -3
- 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 +21 -0
- package/{dist/types/src → types}/utils/polyfills.d.ts +0 -0
- package/{dist/types/src → types}/utils/props.d.ts +2 -23
- 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/services/props.d.ts +0 -42
- 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, ArrowRightBold, CaretBottom, 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
|
-
import StageCore, {
|
|
6
|
+
import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS, ContainerHighlightType } 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,15 +19,7 @@ if (typeof globalThis === "undefined") {
|
|
|
19
19
|
window.globalThis = window;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
const target = sfc.__vccOpts || sfc;
|
|
24
|
-
for (const [key, val] of props) {
|
|
25
|
-
target[key] = val;
|
|
26
|
-
}
|
|
27
|
-
return target;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const _sfc_main$m = defineComponent({
|
|
22
|
+
const _sfc_main$n = defineComponent({
|
|
31
23
|
name: "m-fields-vs-code",
|
|
32
24
|
props: ["model", "name", "config", "prop"],
|
|
33
25
|
emits: ["change"],
|
|
@@ -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,9 +54,9 @@ 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$n, [["render", _sfc_render$g]]);
|
|
57
58
|
|
|
58
|
-
const _sfc_main$
|
|
59
|
+
const _sfc_main$m = defineComponent({
|
|
59
60
|
name: "m-fields-code-link",
|
|
60
61
|
props: {
|
|
61
62
|
config: {
|
|
@@ -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,20 @@ 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$m, [["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$l = /* @__PURE__ */ defineComponent({
|
|
128
|
+
__name: "UISelect",
|
|
128
129
|
props: {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
type: String,
|
|
134
|
-
default() {
|
|
135
|
-
return "";
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
name: String
|
|
130
|
+
config: null,
|
|
131
|
+
model: null,
|
|
132
|
+
prop: null,
|
|
133
|
+
name: null
|
|
139
134
|
},
|
|
140
135
|
emits: ["change"],
|
|
141
|
-
setup(
|
|
136
|
+
setup(__props, { emit }) {
|
|
137
|
+
const props = __props;
|
|
142
138
|
const services = inject("services");
|
|
143
139
|
const mForm = inject("mForm");
|
|
144
140
|
const val = computed(() => props.model[props.name]);
|
|
@@ -160,92 +156,86 @@ const _sfc_main$k = defineComponent({
|
|
|
160
156
|
cancelHandler();
|
|
161
157
|
}
|
|
162
158
|
};
|
|
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
|
-
}
|
|
159
|
+
const toName = computed(() => {
|
|
160
|
+
const config = services?.editorService.getNodeById(val.value);
|
|
161
|
+
return config?.name || "";
|
|
162
|
+
});
|
|
163
|
+
const startSelect = () => {
|
|
164
|
+
if (!services?.uiService)
|
|
165
|
+
return;
|
|
166
|
+
services.uiService.set("uiSelectMode", true);
|
|
167
|
+
uiSelectMode.value = true;
|
|
168
|
+
globalThis.document.addEventListener("ui-select", clickHandler);
|
|
169
|
+
};
|
|
170
|
+
const deleteHandler = () => {
|
|
171
|
+
if (props.model) {
|
|
172
|
+
props.model[props.name] = "";
|
|
173
|
+
emit("change", "");
|
|
174
|
+
mForm?.$emit("field-change", props.prop, "");
|
|
187
175
|
}
|
|
188
176
|
};
|
|
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(() => [
|
|
177
|
+
return (_ctx, _cache) => {
|
|
178
|
+
const _component_el_button = resolveComponent("el-button");
|
|
179
|
+
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
180
|
+
return uiSelectMode.value ? (openBlock(), createElementBlock("div", {
|
|
181
|
+
key: 0,
|
|
182
|
+
class: "m-fields-ui-select",
|
|
183
|
+
onClick: cancelHandler
|
|
184
|
+
}, [
|
|
234
185
|
createVNode(_component_el_button, {
|
|
186
|
+
type: "danger",
|
|
187
|
+
icon: unref(Delete),
|
|
235
188
|
text: "",
|
|
236
|
-
style: { "padding": "0"
|
|
189
|
+
style: { "padding": "0" }
|
|
237
190
|
}, {
|
|
238
191
|
default: withCtx(() => [
|
|
239
|
-
|
|
192
|
+
_hoisted_1$d
|
|
240
193
|
]),
|
|
241
194
|
_: 1
|
|
242
|
-
})
|
|
243
|
-
]),
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
|
|
195
|
+
}, 8, ["icon"])
|
|
196
|
+
])) : (openBlock(), createElementBlock("div", {
|
|
197
|
+
key: 1,
|
|
198
|
+
class: "m-fields-ui-select",
|
|
199
|
+
onClick: startSelect,
|
|
200
|
+
style: { "display": "flex" }
|
|
201
|
+
}, [
|
|
202
|
+
unref(val) ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
203
|
+
key: 0,
|
|
204
|
+
content: "\u6E05\u9664"
|
|
205
|
+
}, {
|
|
206
|
+
default: withCtx(() => [
|
|
207
|
+
createVNode(_component_el_button, {
|
|
208
|
+
style: { "padding": "0" },
|
|
209
|
+
type: "danger",
|
|
210
|
+
icon: unref(Close),
|
|
211
|
+
text: "",
|
|
212
|
+
onClick: withModifiers(deleteHandler, ["stop"])
|
|
213
|
+
}, null, 8, ["icon", "onClick"])
|
|
214
|
+
]),
|
|
215
|
+
_: 1
|
|
216
|
+
})) : createCommentVNode("", true),
|
|
217
|
+
createVNode(_component_el_tooltip, {
|
|
218
|
+
content: unref(val) ? unref(toName) + "_" + unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
|
|
219
|
+
}, {
|
|
220
|
+
default: withCtx(() => [
|
|
221
|
+
createVNode(_component_el_button, {
|
|
222
|
+
text: "",
|
|
223
|
+
style: { "padding": "0", "margin": "0" }
|
|
224
|
+
}, {
|
|
225
|
+
default: withCtx(() => [
|
|
226
|
+
createTextVNode(toDisplayString(unref(val) ? unref(toName) + "_" + unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1)
|
|
227
|
+
]),
|
|
228
|
+
_: 1
|
|
229
|
+
})
|
|
230
|
+
]),
|
|
231
|
+
_: 1
|
|
232
|
+
}, 8, ["content"])
|
|
233
|
+
]));
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
const UISelect_vue_vue_type_style_index_0_lang = '';
|
|
249
239
|
|
|
250
240
|
const toString = (v, language) => {
|
|
251
241
|
let value = "";
|
|
@@ -262,7 +252,7 @@ const toString = (v, language) => {
|
|
|
262
252
|
}
|
|
263
253
|
return value;
|
|
264
254
|
};
|
|
265
|
-
const _sfc_main$
|
|
255
|
+
const _sfc_main$k = defineComponent({
|
|
266
256
|
name: "magic-code-editor",
|
|
267
257
|
props: {
|
|
268
258
|
initValues: {
|
|
@@ -369,14 +359,15 @@ const _sfc_main$j = defineComponent({
|
|
|
369
359
|
};
|
|
370
360
|
}
|
|
371
361
|
});
|
|
362
|
+
|
|
372
363
|
const _hoisted_1$c = {
|
|
373
364
|
ref: "codeEditor",
|
|
374
365
|
class: "magic-code-editor"
|
|
375
366
|
};
|
|
376
|
-
function _sfc_render$
|
|
367
|
+
function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
377
368
|
return openBlock(), createElementBlock("div", _hoisted_1$c, null, 512);
|
|
378
369
|
}
|
|
379
|
-
|
|
370
|
+
const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$e]]);
|
|
380
371
|
|
|
381
372
|
let $TMAGIC_EDITOR = {};
|
|
382
373
|
const setConfig = (option) => {
|
|
@@ -385,6 +376,9 @@ const setConfig = (option) => {
|
|
|
385
376
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
386
377
|
|
|
387
378
|
class UndoRedo {
|
|
379
|
+
elementList;
|
|
380
|
+
listCursor;
|
|
381
|
+
listMaxSize;
|
|
388
382
|
constructor(listMaxSize = 200) {
|
|
389
383
|
const minListMaxSize = 2;
|
|
390
384
|
this.elementList = [];
|
|
@@ -461,17 +455,12 @@ const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethod
|
|
|
461
455
|
try {
|
|
462
456
|
let beforeArgs = args;
|
|
463
457
|
for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
|
|
464
|
-
|
|
465
|
-
if (isError(
|
|
466
|
-
throw
|
|
467
|
-
if (!Array.isArray(
|
|
468
|
-
|
|
458
|
+
beforeArgs = await beforeMethod(...beforeArgs) || [];
|
|
459
|
+
if (isError(beforeArgs))
|
|
460
|
+
throw beforeArgs;
|
|
461
|
+
if (!Array.isArray(beforeArgs)) {
|
|
462
|
+
beforeArgs = [beforeArgs];
|
|
469
463
|
}
|
|
470
|
-
beforeArgs = beforeArgs.map((v, index) => {
|
|
471
|
-
if (typeof beforeReturnValue[index] === "undefined")
|
|
472
|
-
return v;
|
|
473
|
-
return beforeReturnValue[index];
|
|
474
|
-
});
|
|
475
464
|
}
|
|
476
465
|
let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
|
|
477
466
|
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
@@ -485,12 +474,12 @@ const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethod
|
|
|
485
474
|
}
|
|
486
475
|
};
|
|
487
476
|
class BaseService extends EventEmitter {
|
|
477
|
+
pluginOptionsList = {};
|
|
478
|
+
middleware = {};
|
|
479
|
+
taskList = [];
|
|
480
|
+
doingTask = false;
|
|
488
481
|
constructor(methods = [], serialMethods = []) {
|
|
489
482
|
super();
|
|
490
|
-
this.pluginOptionsList = {};
|
|
491
|
-
this.middleware = {};
|
|
492
|
-
this.taskList = [];
|
|
493
|
-
this.doingTask = false;
|
|
494
483
|
methods.forEach((propertyName) => {
|
|
495
484
|
const scope = this;
|
|
496
485
|
const sourceMethod = scope[propertyName];
|
|
@@ -547,14 +536,14 @@ class BaseService extends EventEmitter {
|
|
|
547
536
|
}
|
|
548
537
|
|
|
549
538
|
class History extends BaseService {
|
|
539
|
+
state = reactive({
|
|
540
|
+
pageSteps: {},
|
|
541
|
+
pageId: void 0,
|
|
542
|
+
canRedo: false,
|
|
543
|
+
canUndo: false
|
|
544
|
+
});
|
|
550
545
|
constructor() {
|
|
551
546
|
super([]);
|
|
552
|
-
this.state = reactive({
|
|
553
|
-
pageSteps: {},
|
|
554
|
-
pageId: void 0,
|
|
555
|
-
canRedo: false,
|
|
556
|
-
canUndo: false
|
|
557
|
-
});
|
|
558
547
|
this.on("change", this.setCanUndoRedo);
|
|
559
548
|
}
|
|
560
549
|
reset() {
|
|
@@ -623,88 +612,88 @@ class History extends BaseService {
|
|
|
623
612
|
this.state.canUndo = undoRedo?.canUndo() || false;
|
|
624
613
|
}
|
|
625
614
|
}
|
|
626
|
-
|
|
615
|
+
const historyService = new History();
|
|
627
616
|
|
|
628
|
-
|
|
617
|
+
var Protocol = /* @__PURE__ */ ((Protocol2) => {
|
|
618
|
+
Protocol2["OBJECT"] = "object";
|
|
619
|
+
Protocol2["JSON"] = "json";
|
|
620
|
+
Protocol2["STRING"] = "string";
|
|
621
|
+
Protocol2["NUMBER"] = "number";
|
|
622
|
+
Protocol2["BOOLEAN"] = "boolean";
|
|
623
|
+
return Protocol2;
|
|
624
|
+
})(Protocol || {});
|
|
625
|
+
class WebStorage extends BaseService {
|
|
626
|
+
storage = globalThis.localStorage;
|
|
627
|
+
namespace = "tmagic";
|
|
629
628
|
constructor() {
|
|
630
|
-
super(["
|
|
631
|
-
this.state = reactive({
|
|
632
|
-
propsConfigMap: {},
|
|
633
|
-
propsValueMap: {}
|
|
634
|
-
});
|
|
629
|
+
super(["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"]);
|
|
635
630
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
this.setPropsConfig(toLine(type), configs[type]);
|
|
639
|
-
});
|
|
640
|
-
this.emit("props-configs-change");
|
|
631
|
+
async getStorage() {
|
|
632
|
+
return this.storage;
|
|
641
633
|
}
|
|
642
|
-
|
|
643
|
-
this.
|
|
634
|
+
async getNamespace() {
|
|
635
|
+
return this.namespace;
|
|
644
636
|
}
|
|
645
|
-
async
|
|
646
|
-
|
|
647
|
-
|
|
637
|
+
async clear() {
|
|
638
|
+
const storage2 = await this.getStorage();
|
|
639
|
+
storage2.clear();
|
|
640
|
+
}
|
|
641
|
+
async getItem(key, options = {}) {
|
|
642
|
+
const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
643
|
+
const { protocol = options.protocol, item } = this.getValueAndProtocol(storage.getItem(`${options.namespace || namespace}:${key}`));
|
|
644
|
+
if (item === null)
|
|
645
|
+
return null;
|
|
646
|
+
switch (protocol) {
|
|
647
|
+
case "object" /* OBJECT */:
|
|
648
|
+
return eval(`(${item})`);
|
|
649
|
+
case "json" /* JSON */:
|
|
650
|
+
return JSON.parse(item);
|
|
651
|
+
case "number" /* NUMBER */:
|
|
652
|
+
return Number(item);
|
|
653
|
+
case "boolean" /* BOOLEAN */:
|
|
654
|
+
return Boolean(item);
|
|
655
|
+
default:
|
|
656
|
+
return item;
|
|
648
657
|
}
|
|
649
|
-
return cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
|
|
650
658
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
});
|
|
659
|
+
async key(index) {
|
|
660
|
+
const storage2 = await this.getStorage();
|
|
661
|
+
return storage2.key(index);
|
|
655
662
|
}
|
|
656
|
-
|
|
657
|
-
|
|
663
|
+
async removeItem(key2, options2 = {}) {
|
|
664
|
+
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
665
|
+
storage2.removeItem(`${options2.namespace || namespace2}:${key2}`);
|
|
658
666
|
}
|
|
659
|
-
async
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
}
|
|
667
|
-
|
|
667
|
+
async setItem(key2, value, options2 = {}) {
|
|
668
|
+
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
669
|
+
let item2 = value;
|
|
670
|
+
const protocol2 = options2.protocol ? `${options2.protocol}:` : "";
|
|
671
|
+
if (typeof value === "string" /* STRING */ || typeof value === "number" /* NUMBER */) {
|
|
672
|
+
item2 = `${protocol2}${value}`;
|
|
673
|
+
} else {
|
|
674
|
+
item2 = `${protocol2}${serialize(value)}`;
|
|
675
|
+
}
|
|
676
|
+
storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
|
|
677
|
+
}
|
|
678
|
+
getValueAndProtocol(value) {
|
|
679
|
+
let protocol2 = "";
|
|
680
|
+
if (value === null) {
|
|
681
|
+
return {
|
|
682
|
+
item: value,
|
|
683
|
+
protocol: protocol2
|
|
684
|
+
};
|
|
668
685
|
}
|
|
669
|
-
const
|
|
670
|
-
|
|
686
|
+
const item2 = value.replace(new RegExp(`^(${Object.values(Protocol).join("|")})(:)(.+)`), (_$0, $1, _$2, $3) => {
|
|
687
|
+
protocol2 = $1;
|
|
688
|
+
return $3;
|
|
689
|
+
});
|
|
671
690
|
return {
|
|
672
|
-
|
|
673
|
-
|
|
691
|
+
protocol: protocol2,
|
|
692
|
+
item: item2
|
|
674
693
|
};
|
|
675
694
|
}
|
|
676
|
-
async createId(type) {
|
|
677
|
-
return `${type}_${random(1e4, false)}`;
|
|
678
|
-
}
|
|
679
|
-
async setNewItemId(config, parent) {
|
|
680
|
-
const oldId = config.id;
|
|
681
|
-
config.id = await this.createId(config.type || "component");
|
|
682
|
-
if (isPop(config) && parent?.type === NodeType.PAGE) {
|
|
683
|
-
updatePopId(oldId, config.id, parent);
|
|
684
|
-
}
|
|
685
|
-
if (config.items && Array.isArray(config.items)) {
|
|
686
|
-
for (const item of config.items) {
|
|
687
|
-
await this.setNewItemId(item, config);
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
695
|
}
|
|
692
|
-
const
|
|
693
|
-
pageConfig.items?.forEach((config) => {
|
|
694
|
-
if (config.pop === oldId) {
|
|
695
|
-
config.pop = popId;
|
|
696
|
-
return;
|
|
697
|
-
}
|
|
698
|
-
if (config.popId === oldId) {
|
|
699
|
-
config.popId = popId;
|
|
700
|
-
return;
|
|
701
|
-
}
|
|
702
|
-
if (Array.isArray(config.items)) {
|
|
703
|
-
updatePopId(oldId, popId, config);
|
|
704
|
-
}
|
|
705
|
-
});
|
|
706
|
-
};
|
|
707
|
-
var propsService = new Props();
|
|
696
|
+
const storageService = new WebStorage();
|
|
708
697
|
|
|
709
698
|
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
710
699
|
LayerOffset2["TOP"] = "top";
|
|
@@ -756,10 +745,10 @@ const getRelativeStyle = (style = {}) => ({
|
|
|
756
745
|
top: 0,
|
|
757
746
|
left: 0
|
|
758
747
|
});
|
|
759
|
-
const getMiddleTop = (
|
|
760
|
-
let height = style
|
|
761
|
-
if (!stage || typeof style
|
|
762
|
-
return style
|
|
748
|
+
const getMiddleTop = (node, parentNode, stage) => {
|
|
749
|
+
let height = node.style?.height || 0;
|
|
750
|
+
if (!stage || typeof node.style?.top !== "undefined" || !parentNode.style)
|
|
751
|
+
return node.style?.top;
|
|
763
752
|
if (!isNumber(height)) {
|
|
764
753
|
height = 0;
|
|
765
754
|
}
|
|
@@ -770,12 +759,11 @@ const getMiddleTop = (style = {}, parentNode, stage) => {
|
|
|
770
759
|
}
|
|
771
760
|
return (parentHeight - height) / 2;
|
|
772
761
|
};
|
|
773
|
-
const getInitPositionStyle = (style = {}, layout
|
|
762
|
+
const getInitPositionStyle = (style = {}, layout) => {
|
|
774
763
|
if (layout === Layout.ABSOLUTE) {
|
|
775
764
|
return {
|
|
776
765
|
...style,
|
|
777
|
-
position: "absolute"
|
|
778
|
-
top: getMiddleTop(style, parentNode, stage)
|
|
766
|
+
position: "absolute"
|
|
779
767
|
};
|
|
780
768
|
}
|
|
781
769
|
if (layout === Layout.RELATIVE) {
|
|
@@ -861,34 +849,215 @@ const fixNodeLeft = (config, parent, doc) => {
|
|
|
861
849
|
return config.style?.left;
|
|
862
850
|
const el = doc.getElementById(`${config.id}`);
|
|
863
851
|
const parentEl = doc.getElementById(`${parent.id}`);
|
|
864
|
-
|
|
852
|
+
const left = Number(config.style?.left) || 0;
|
|
853
|
+
if (el && parentEl && el.offsetWidth + left > parentEl.offsetWidth) {
|
|
865
854
|
return parentEl.offsetWidth - el.offsetWidth;
|
|
866
855
|
}
|
|
867
856
|
return config.style.left;
|
|
868
857
|
};
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
858
|
+
const fixNodePosition = (config, parent, stage) => {
|
|
859
|
+
if (config.style?.position !== "absolute") {
|
|
860
|
+
return config.style;
|
|
861
|
+
}
|
|
862
|
+
return {
|
|
863
|
+
...config.style || {},
|
|
864
|
+
top: getMiddleTop(config, parent, stage),
|
|
865
|
+
left: fixNodeLeft(config, parent, stage?.renderer.contentWindow?.document)
|
|
866
|
+
};
|
|
873
867
|
};
|
|
874
|
-
|
|
868
|
+
|
|
869
|
+
class Props extends BaseService {
|
|
870
|
+
state = reactive({
|
|
871
|
+
propsConfigMap: {},
|
|
872
|
+
propsValueMap: {}
|
|
873
|
+
});
|
|
874
|
+
constructor() {
|
|
875
|
+
super([
|
|
876
|
+
"setPropsConfig",
|
|
877
|
+
"getPropsConfig",
|
|
878
|
+
"setPropsValue",
|
|
879
|
+
"getPropsValue",
|
|
880
|
+
"createId",
|
|
881
|
+
"setNewItemId",
|
|
882
|
+
"fillConfig",
|
|
883
|
+
"getDefaultPropsValue"
|
|
884
|
+
]);
|
|
885
|
+
}
|
|
886
|
+
setPropsConfigs(configs) {
|
|
887
|
+
Object.keys(configs).forEach((type) => {
|
|
888
|
+
this.setPropsConfig(toLine(type), configs[type]);
|
|
889
|
+
});
|
|
890
|
+
this.emit("props-configs-change");
|
|
891
|
+
}
|
|
892
|
+
async fillConfig(config) {
|
|
893
|
+
return fillConfig(config);
|
|
894
|
+
}
|
|
895
|
+
async setPropsConfig(type, config) {
|
|
896
|
+
this.state.propsConfigMap[type] = await this.fillConfig(Array.isArray(config) ? config : [config]);
|
|
897
|
+
}
|
|
898
|
+
async getPropsConfig(type) {
|
|
899
|
+
if (type === "area") {
|
|
900
|
+
return await this.getPropsConfig("button");
|
|
901
|
+
}
|
|
902
|
+
return cloneDeep(this.state.propsConfigMap[type] || await this.fillConfig([]));
|
|
903
|
+
}
|
|
904
|
+
setPropsValues(values) {
|
|
905
|
+
Object.keys(values).forEach((type) => {
|
|
906
|
+
this.setPropsValue(toLine(type), values[type]);
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
setPropsValue(type, value) {
|
|
910
|
+
this.state.propsValueMap[type] = value;
|
|
911
|
+
}
|
|
912
|
+
async getPropsValue(type, { inputEvent, ...defaultValue } = {}) {
|
|
913
|
+
if (type === "area") {
|
|
914
|
+
const value = await this.getPropsValue("button");
|
|
915
|
+
value.className = "action-area";
|
|
916
|
+
value.text = "";
|
|
917
|
+
if (value.style) {
|
|
918
|
+
value.style.backgroundColor = "rgba(255, 255, 255, 0)";
|
|
919
|
+
}
|
|
920
|
+
return value;
|
|
921
|
+
}
|
|
922
|
+
const [id, defaultPropsValue, data] = await Promise.all([
|
|
923
|
+
this.createId(type),
|
|
924
|
+
this.getDefaultPropsValue(type),
|
|
925
|
+
this.setNewItemId(cloneDeep({
|
|
926
|
+
type,
|
|
927
|
+
...defaultValue
|
|
928
|
+
}))
|
|
929
|
+
]);
|
|
930
|
+
return {
|
|
931
|
+
id,
|
|
932
|
+
...defaultPropsValue,
|
|
933
|
+
...mergeWith({}, cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
async createId(type) {
|
|
937
|
+
return `${type}_${this.guid()}`;
|
|
938
|
+
}
|
|
939
|
+
async setNewItemId(config) {
|
|
940
|
+
config.id = await this.createId(config.type || "component");
|
|
941
|
+
if (config.items && Array.isArray(config.items)) {
|
|
942
|
+
for (const item of config.items) {
|
|
943
|
+
await this.setNewItemId(item);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
return config;
|
|
947
|
+
}
|
|
948
|
+
async getDefaultPropsValue(type) {
|
|
949
|
+
return ["page", "container"].includes(type) ? {
|
|
950
|
+
type,
|
|
951
|
+
layout: "absolute",
|
|
952
|
+
style: {},
|
|
953
|
+
name: type,
|
|
954
|
+
items: []
|
|
955
|
+
} : {
|
|
956
|
+
type,
|
|
957
|
+
style: {},
|
|
958
|
+
name: type
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
guid(digit = 8) {
|
|
962
|
+
return "x".repeat(digit).replace(/[xy]/g, (c) => {
|
|
963
|
+
const r = Math.random() * 16 | 0;
|
|
964
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
965
|
+
return v.toString(16);
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
const propsService = new Props();
|
|
970
|
+
|
|
971
|
+
const beforePaste = async (position, config) => {
|
|
972
|
+
if (!config[0]?.style)
|
|
973
|
+
return config;
|
|
974
|
+
const curNode = editorService.get("node");
|
|
975
|
+
const { left: referenceLeft, top: referenceTop } = config[0].style;
|
|
976
|
+
const pasteConfigs = await Promise.all(config.map(async (configItem) => {
|
|
977
|
+
const { offsetX = 0, offsetY = 0, ...positionClone } = position;
|
|
978
|
+
let pastePosition = positionClone;
|
|
979
|
+
if (!isEmpty(pastePosition) && curNode.items) {
|
|
980
|
+
pastePosition = getPositionInContainer(pastePosition, curNode.id);
|
|
981
|
+
}
|
|
982
|
+
if (pastePosition.left && configItem.style?.left) {
|
|
983
|
+
pastePosition.left = configItem.style.left - referenceLeft + pastePosition.left;
|
|
984
|
+
}
|
|
985
|
+
if (pastePosition.top && configItem.style?.top) {
|
|
986
|
+
pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
|
|
987
|
+
}
|
|
988
|
+
const pasteConfig = await propsService.setNewItemId(configItem);
|
|
989
|
+
if (pasteConfig.style) {
|
|
990
|
+
const { left, top } = pasteConfig.style;
|
|
991
|
+
if (typeof left === "number" || !!left && !isNaN(Number(left))) {
|
|
992
|
+
pasteConfig.style.left = Number(left) + offsetX;
|
|
993
|
+
}
|
|
994
|
+
if (typeof top === "number" || !!top && !isNaN(Number(top))) {
|
|
995
|
+
pasteConfig.style.top = Number(top) + offsetY;
|
|
996
|
+
}
|
|
997
|
+
pasteConfig.style = {
|
|
998
|
+
...pasteConfig.style,
|
|
999
|
+
...pastePosition
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
if (isPage(pasteConfig)) {
|
|
1003
|
+
pasteConfig.name = generatePageNameByApp(editorService.get("root"));
|
|
1004
|
+
}
|
|
1005
|
+
return pasteConfig;
|
|
1006
|
+
}));
|
|
1007
|
+
return pasteConfigs;
|
|
875
1008
|
};
|
|
876
|
-
const
|
|
1009
|
+
const getPositionInContainer = (position = {}, id) => {
|
|
1010
|
+
let { left = 0, top = 0 } = position;
|
|
1011
|
+
const parentEl = editorService.get("stage")?.renderer?.contentWindow?.document.getElementById(`${id}`);
|
|
1012
|
+
const parentElRect = parentEl?.getBoundingClientRect();
|
|
1013
|
+
left = left - (parentElRect?.left || 0);
|
|
1014
|
+
top = top - (parentElRect?.top || 0);
|
|
1015
|
+
return {
|
|
1016
|
+
left,
|
|
1017
|
+
top
|
|
1018
|
+
};
|
|
877
1019
|
};
|
|
878
|
-
const
|
|
1020
|
+
const getAddParent = (node) => {
|
|
1021
|
+
const curNode = editorService.get("node");
|
|
1022
|
+
let parentNode;
|
|
1023
|
+
if (isPage(node)) {
|
|
1024
|
+
parentNode = editorService.get("root");
|
|
1025
|
+
} else if (curNode.items) {
|
|
1026
|
+
parentNode = curNode;
|
|
1027
|
+
} else {
|
|
1028
|
+
parentNode = editorService.getParentById(curNode.id, false);
|
|
1029
|
+
}
|
|
1030
|
+
return parentNode;
|
|
879
1031
|
};
|
|
880
1032
|
|
|
881
1033
|
class Editor$1 extends BaseService {
|
|
1034
|
+
state = reactive({
|
|
1035
|
+
root: null,
|
|
1036
|
+
page: null,
|
|
1037
|
+
parent: null,
|
|
1038
|
+
node: null,
|
|
1039
|
+
nodes: [],
|
|
1040
|
+
stage: null,
|
|
1041
|
+
highlightNode: null,
|
|
1042
|
+
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
1043
|
+
pageLength: 0
|
|
1044
|
+
});
|
|
1045
|
+
isHistoryStateChange = false;
|
|
882
1046
|
constructor() {
|
|
883
1047
|
super([
|
|
884
1048
|
"getLayout",
|
|
885
1049
|
"select",
|
|
1050
|
+
"doAdd",
|
|
886
1051
|
"add",
|
|
1052
|
+
"doRemove",
|
|
887
1053
|
"remove",
|
|
1054
|
+
"doUpdate",
|
|
888
1055
|
"update",
|
|
889
1056
|
"sort",
|
|
890
1057
|
"copy",
|
|
891
1058
|
"paste",
|
|
1059
|
+
"doPaste",
|
|
1060
|
+
"duAlignCenter",
|
|
892
1061
|
"alignCenter",
|
|
893
1062
|
"moveLayer",
|
|
894
1063
|
"moveToContainer",
|
|
@@ -897,20 +1066,12 @@ class Editor$1 extends BaseService {
|
|
|
897
1066
|
"redo",
|
|
898
1067
|
"highlight"
|
|
899
1068
|
], ["select", "update", "moveLayer"]);
|
|
900
|
-
this.isHistoryStateChange = false;
|
|
901
|
-
this.state = reactive({
|
|
902
|
-
root: null,
|
|
903
|
-
page: null,
|
|
904
|
-
parent: null,
|
|
905
|
-
node: null,
|
|
906
|
-
stage: null,
|
|
907
|
-
highlightNode: null,
|
|
908
|
-
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
909
|
-
pageLength: 0
|
|
910
|
-
});
|
|
911
1069
|
}
|
|
912
1070
|
set(name, value) {
|
|
913
1071
|
this.state[name] = value;
|
|
1072
|
+
if (name === "nodes") {
|
|
1073
|
+
this.set("node", value[0]);
|
|
1074
|
+
}
|
|
914
1075
|
if (name === "root") {
|
|
915
1076
|
this.state.pageLength = value?.items?.length || 0;
|
|
916
1077
|
this.emit("root-change", value);
|
|
@@ -965,9 +1126,9 @@ class Editor$1 extends BaseService {
|
|
|
965
1126
|
}
|
|
966
1127
|
return Layout.ABSOLUTE;
|
|
967
1128
|
}
|
|
968
|
-
async select(
|
|
969
|
-
const { node, page, parent } = this.selectedConfigExceptionHandler(
|
|
970
|
-
this.set("
|
|
1129
|
+
async select(config) {
|
|
1130
|
+
const { node, page, parent } = this.selectedConfigExceptionHandler(config);
|
|
1131
|
+
this.set("nodes", [node]);
|
|
971
1132
|
this.set("page", page || null);
|
|
972
1133
|
this.set("parent", parent || null);
|
|
973
1134
|
if (page) {
|
|
@@ -1007,65 +1168,83 @@ class Editor$1 extends BaseService {
|
|
|
1007
1168
|
this.get("stage")?.select(nextPage.id);
|
|
1008
1169
|
return nextPage;
|
|
1009
1170
|
}
|
|
1010
|
-
highlight(
|
|
1011
|
-
const { node } = this.selectedConfigExceptionHandler(
|
|
1171
|
+
highlight(config) {
|
|
1172
|
+
const { node } = this.selectedConfigExceptionHandler(config);
|
|
1012
1173
|
const currentHighlightNode = this.get("highlightNode");
|
|
1013
1174
|
if (currentHighlightNode === node)
|
|
1014
1175
|
return;
|
|
1015
1176
|
this.set("highlightNode", node);
|
|
1016
1177
|
}
|
|
1017
|
-
|
|
1018
|
-
const
|
|
1178
|
+
multiSelect(ids) {
|
|
1179
|
+
const nodes = [];
|
|
1180
|
+
const idsUnique = uniq(ids);
|
|
1181
|
+
idsUnique.forEach((id) => {
|
|
1182
|
+
const { node } = this.getNodeInfo(id);
|
|
1183
|
+
if (!node)
|
|
1184
|
+
return;
|
|
1185
|
+
nodes.push(node);
|
|
1186
|
+
});
|
|
1187
|
+
this.set("nodes", nodes);
|
|
1188
|
+
}
|
|
1189
|
+
async doAdd(node, parent) {
|
|
1190
|
+
const root = this.get("root");
|
|
1019
1191
|
const curNode = this.get("node");
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
if (isPage2) {
|
|
1023
|
-
parentNode = this.get("root");
|
|
1024
|
-
} else if (parent && typeof parent !== "function") {
|
|
1025
|
-
parentNode = parent;
|
|
1026
|
-
} else if (curNode.items) {
|
|
1027
|
-
parentNode = curNode;
|
|
1028
|
-
} else {
|
|
1029
|
-
parentNode = this.getParentById(curNode.id, false);
|
|
1030
|
-
}
|
|
1031
|
-
if (!parentNode)
|
|
1032
|
-
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1033
|
-
const layout = await this.getLayout(toRaw(parentNode), addNode);
|
|
1034
|
-
const newNode = { ...toRaw(await propsService.getPropsValue(type, config2)) };
|
|
1035
|
-
newNode.style = getInitPositionStyle(newNode.style, layout, parentNode, this.get("stage"));
|
|
1036
|
-
if ((parentNode?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && newNode.type !== NodeType.PAGE) {
|
|
1192
|
+
const stage = this.get("stage");
|
|
1193
|
+
if ((parent?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && node.type !== NodeType.PAGE) {
|
|
1037
1194
|
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
1038
1195
|
}
|
|
1039
|
-
|
|
1196
|
+
parent?.items?.push(node);
|
|
1197
|
+
const layout = await this.getLayout(toRaw(parent), node);
|
|
1198
|
+
node.style = getInitPositionStyle(node.style, layout);
|
|
1199
|
+
await stage?.add({
|
|
1200
|
+
config: cloneDeep(node),
|
|
1201
|
+
parent: cloneDeep(parent),
|
|
1202
|
+
parentId: parent.id,
|
|
1203
|
+
root: cloneDeep(root)
|
|
1204
|
+
});
|
|
1205
|
+
node.style = fixNodePosition(node, parent, stage);
|
|
1206
|
+
await stage?.update({ config: cloneDeep(node), parentId: parent.id, root: cloneDeep(root) });
|
|
1207
|
+
this.addModifiedNodeId(node.id);
|
|
1208
|
+
return node;
|
|
1209
|
+
}
|
|
1210
|
+
async add(addNode, parent) {
|
|
1040
1211
|
const stage = this.get("stage");
|
|
1041
|
-
const
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
}
|
|
1050
|
-
await this.select(newNode);
|
|
1051
|
-
this.addModifiedNodeId(newNode.id);
|
|
1052
|
-
if (!isPage2) {
|
|
1053
|
-
this.pushHistoryState();
|
|
1212
|
+
const addNodes = [];
|
|
1213
|
+
if (!Array.isArray(addNode)) {
|
|
1214
|
+
const { type, inputEvent, ...config } = addNode;
|
|
1215
|
+
if (!type)
|
|
1216
|
+
throw new Error("\u7EC4\u4EF6\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A");
|
|
1217
|
+
addNodes.push({ ...toRaw(await propsService.getPropsValue(type, config)) });
|
|
1218
|
+
} else {
|
|
1219
|
+
addNodes.push(...addNode);
|
|
1054
1220
|
}
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1221
|
+
const newNodes = await Promise.all(addNodes.map((node) => {
|
|
1222
|
+
const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
|
|
1223
|
+
if (!parentNode)
|
|
1224
|
+
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1225
|
+
return this.doAdd(node, parentNode);
|
|
1226
|
+
}));
|
|
1227
|
+
if (newNodes.length > 1) {
|
|
1228
|
+
const newNodeIds = newNodes.map((node) => node.id);
|
|
1229
|
+
stage?.multiSelect(newNodeIds);
|
|
1230
|
+
await this.multiSelect(newNodeIds);
|
|
1231
|
+
} else {
|
|
1232
|
+
await this.select(newNodes[0]);
|
|
1233
|
+
if (isPage(newNodes[0])) {
|
|
1234
|
+
this.state.pageLength += 1;
|
|
1235
|
+
} else {
|
|
1236
|
+
stage?.select(newNodes[0].id);
|
|
1237
|
+
}
|
|
1058
1238
|
}
|
|
1059
|
-
this.
|
|
1060
|
-
|
|
1239
|
+
this.pushHistoryState();
|
|
1240
|
+
this.emit("add", newNodes);
|
|
1241
|
+
return Array.isArray(addNode) ? newNodes : newNodes[0];
|
|
1061
1242
|
}
|
|
1062
|
-
async
|
|
1063
|
-
if (!node?.id)
|
|
1064
|
-
return;
|
|
1243
|
+
async doRemove(node) {
|
|
1065
1244
|
const root = this.get("root");
|
|
1066
1245
|
if (!root)
|
|
1067
1246
|
throw new Error("\u6CA1\u6709root");
|
|
1068
|
-
const { parent, node: curNode } = this.getNodeInfo(node.id
|
|
1247
|
+
const { parent, node: curNode } = this.getNodeInfo(node.id);
|
|
1069
1248
|
if (!parent || !curNode)
|
|
1070
1249
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1071
1250
|
const index = getNodeIndex(curNode, parent);
|
|
@@ -1073,7 +1252,7 @@ class Editor$1 extends BaseService {
|
|
|
1073
1252
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1074
1253
|
parent.items?.splice(index, 1);
|
|
1075
1254
|
const stage = this.get("stage");
|
|
1076
|
-
stage?.remove({ id: node.id, root: cloneDeep(
|
|
1255
|
+
stage?.remove({ id: node.id, parentId: parent.id, root: cloneDeep(root) });
|
|
1077
1256
|
if (node.type === NodeType.PAGE) {
|
|
1078
1257
|
this.state.pageLength -= 1;
|
|
1079
1258
|
if (root.items[0]) {
|
|
@@ -1087,26 +1266,28 @@ class Editor$1 extends BaseService {
|
|
|
1087
1266
|
this.set("highlightNode", null);
|
|
1088
1267
|
this.resetModifiedNodeId();
|
|
1089
1268
|
historyService.reset();
|
|
1090
|
-
|
|
1091
|
-
return node;
|
|
1269
|
+
return;
|
|
1092
1270
|
}
|
|
1093
1271
|
} else {
|
|
1094
1272
|
await this.select(parent);
|
|
1095
1273
|
stage?.select(parent.id);
|
|
1096
1274
|
}
|
|
1097
1275
|
this.addModifiedNodeId(parent.id);
|
|
1276
|
+
}
|
|
1277
|
+
async remove(nodeOrNodeList) {
|
|
1278
|
+
const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
|
|
1279
|
+
await Promise.all(nodes.map((node) => this.doRemove(node)));
|
|
1098
1280
|
this.pushHistoryState();
|
|
1099
|
-
this.emit("remove"
|
|
1100
|
-
return node;
|
|
1281
|
+
this.emit("remove");
|
|
1101
1282
|
}
|
|
1102
|
-
async
|
|
1103
|
-
if (!
|
|
1283
|
+
async doUpdate(config) {
|
|
1284
|
+
if (!config?.id)
|
|
1104
1285
|
throw new Error("\u6CA1\u6709\u914D\u7F6E\u6216\u8005\u914D\u7F6E\u7F3A\u5C11id\u503C");
|
|
1105
|
-
const info = this.getNodeInfo(
|
|
1286
|
+
const info = this.getNodeInfo(config.id, false);
|
|
1106
1287
|
if (!info.node)
|
|
1107
|
-
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${
|
|
1288
|
+
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config.id}\u7684\u8282\u70B9`);
|
|
1108
1289
|
const node = cloneDeep(toRaw(info.node));
|
|
1109
|
-
let newConfig = await this.toggleFixedPosition(toRaw(
|
|
1290
|
+
let newConfig = await this.toggleFixedPosition(toRaw(config), node, this.get("root"));
|
|
1110
1291
|
newConfig = mergeWith(cloneDeep(node), newConfig, (objValue, srcValue) => {
|
|
1111
1292
|
if (Array.isArray(srcValue)) {
|
|
1112
1293
|
return srcValue;
|
|
@@ -1131,18 +1312,28 @@ class Editor$1 extends BaseService {
|
|
|
1131
1312
|
newConfig = setLayout(newConfig, newLayout);
|
|
1132
1313
|
}
|
|
1133
1314
|
parentNodeItems[index] = newConfig;
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
this.
|
|
1315
|
+
const nodes = this.get("nodes");
|
|
1316
|
+
const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
|
|
1317
|
+
nodes.splice(targetIndex, 1, newConfig);
|
|
1318
|
+
this.set("nodes", nodes);
|
|
1319
|
+
this.get("stage")?.update({
|
|
1320
|
+
config: cloneDeep(newConfig),
|
|
1321
|
+
parentId: parent.id,
|
|
1322
|
+
root: cloneDeep(this.get("root"))
|
|
1323
|
+
});
|
|
1138
1324
|
if (newConfig.type === NodeType.PAGE) {
|
|
1139
1325
|
this.set("page", newConfig);
|
|
1140
1326
|
}
|
|
1141
1327
|
this.addModifiedNodeId(newConfig.id);
|
|
1142
|
-
this.pushHistoryState();
|
|
1143
|
-
this.emit("update", newConfig);
|
|
1144
1328
|
return newConfig;
|
|
1145
1329
|
}
|
|
1330
|
+
async update(config) {
|
|
1331
|
+
const nodes = Array.isArray(config) ? config : [config];
|
|
1332
|
+
const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
|
|
1333
|
+
this.pushHistoryState();
|
|
1334
|
+
this.emit("update", newNodes);
|
|
1335
|
+
return Array.isArray(config) ? newNodes : newNodes[0];
|
|
1336
|
+
}
|
|
1146
1337
|
async sort(id1, id2) {
|
|
1147
1338
|
const node = this.get("node");
|
|
1148
1339
|
const parent = cloneDeep(toRaw(this.get("parent")));
|
|
@@ -1153,65 +1344,61 @@ class Editor$1 extends BaseService {
|
|
|
1153
1344
|
parent.items.splice(index2, 0, ...parent.items.splice(index1, 1));
|
|
1154
1345
|
await this.update(parent);
|
|
1155
1346
|
await this.select(node);
|
|
1156
|
-
this.get("stage")?.update({
|
|
1347
|
+
this.get("stage")?.update({
|
|
1348
|
+
config: cloneDeep(node),
|
|
1349
|
+
parentId: parent.id,
|
|
1350
|
+
root: cloneDeep(this.get("root"))
|
|
1351
|
+
});
|
|
1157
1352
|
this.addModifiedNodeId(parent.id);
|
|
1158
1353
|
this.pushHistoryState();
|
|
1159
1354
|
}
|
|
1160
|
-
async copy(
|
|
1161
|
-
|
|
1355
|
+
async copy(config) {
|
|
1356
|
+
await storageService.setItem(COPY_STORAGE_KEY, Array.isArray(config) ? config : [config], {
|
|
1357
|
+
protocol: Protocol.OBJECT
|
|
1358
|
+
});
|
|
1162
1359
|
}
|
|
1163
1360
|
async paste(position = {}) {
|
|
1164
|
-
const
|
|
1165
|
-
|
|
1166
|
-
if (!configStr) {
|
|
1167
|
-
return;
|
|
1168
|
-
}
|
|
1169
|
-
try {
|
|
1170
|
-
eval(`config = ${configStr}`);
|
|
1171
|
-
} catch (e) {
|
|
1172
|
-
console.error(e);
|
|
1361
|
+
const config = await storageService.getItem(COPY_STORAGE_KEY);
|
|
1362
|
+
if (!Array.isArray(config))
|
|
1173
1363
|
return;
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
if (config.style) {
|
|
1177
|
-
config.style = {
|
|
1178
|
-
...config.style,
|
|
1179
|
-
...position
|
|
1180
|
-
};
|
|
1181
|
-
}
|
|
1182
|
-
if (isPage(config)) {
|
|
1183
|
-
config.name = generatePageNameByApp(this.get("root"));
|
|
1184
|
-
}
|
|
1185
|
-
return await this.add(config);
|
|
1364
|
+
const pasteConfigs = await this.doPaste(config, position);
|
|
1365
|
+
return this.add(pasteConfigs);
|
|
1186
1366
|
}
|
|
1187
|
-
async
|
|
1188
|
-
const
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1367
|
+
async doPaste(config, position = {}) {
|
|
1368
|
+
const pasteConfigs = await beforePaste(position, cloneDeep(config));
|
|
1369
|
+
return pasteConfigs;
|
|
1370
|
+
}
|
|
1371
|
+
async doAlignCenter(config) {
|
|
1372
|
+
const parent = this.getParentById(config.id);
|
|
1373
|
+
if (!parent)
|
|
1374
|
+
throw new Error("\u627E\u4E0D\u5230\u7236\u8282\u70B9");
|
|
1375
|
+
const node = cloneDeep(toRaw(config));
|
|
1376
|
+
const layout = await this.getLayout(parent, node);
|
|
1377
|
+
if (layout === Layout.RELATIVE) {
|
|
1378
|
+
return config;
|
|
1193
1379
|
}
|
|
1194
1380
|
if (!node.style)
|
|
1195
|
-
return;
|
|
1381
|
+
return config;
|
|
1196
1382
|
const stage = this.get("stage");
|
|
1197
1383
|
const doc = stage?.renderer.contentWindow?.document;
|
|
1198
1384
|
if (doc) {
|
|
1199
|
-
const parentEl = doc.getElementById(`${parent.id}`);
|
|
1200
1385
|
const el = doc.getElementById(`${node.id}`);
|
|
1386
|
+
const parentEl = el?.offsetParent;
|
|
1201
1387
|
if (parentEl && el) {
|
|
1202
1388
|
node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
|
|
1203
1389
|
}
|
|
1204
1390
|
} else if (parent.style && isNumber(parent.style?.width) && isNumber(node.style?.width)) {
|
|
1205
1391
|
node.style.left = (parent.style.width - node.style.width) / 2;
|
|
1206
1392
|
}
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
this.
|
|
1214
|
-
|
|
1393
|
+
return node;
|
|
1394
|
+
}
|
|
1395
|
+
async alignCenter(config) {
|
|
1396
|
+
const nodes = Array.isArray(config) ? config : [config];
|
|
1397
|
+
const stage = this.get("stage");
|
|
1398
|
+
const newNodes = await Promise.all(nodes.map((node) => this.doAlignCenter(node)));
|
|
1399
|
+
const newNode = await this.update(newNodes);
|
|
1400
|
+
await stage?.multiSelect(newNodes.map((node) => node.id));
|
|
1401
|
+
return newNode;
|
|
1215
1402
|
}
|
|
1216
1403
|
async moveLayer(offset) {
|
|
1217
1404
|
const parent = this.get("parent");
|
|
@@ -1225,30 +1412,35 @@ class Editor$1 extends BaseService {
|
|
|
1225
1412
|
} else {
|
|
1226
1413
|
brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
|
|
1227
1414
|
}
|
|
1415
|
+
const grandparent = this.getParentById(parent.id);
|
|
1228
1416
|
this.get("stage")?.update({
|
|
1229
1417
|
config: cloneDeep(toRaw(parent)),
|
|
1418
|
+
parentId: grandparent?.id,
|
|
1230
1419
|
root: cloneDeep(this.get("root"))
|
|
1231
1420
|
});
|
|
1421
|
+
this.addModifiedNodeId(parent.id);
|
|
1422
|
+
this.pushHistoryState();
|
|
1232
1423
|
}
|
|
1233
|
-
async moveToContainer(
|
|
1234
|
-
const { node, parent } = this.getNodeInfo(
|
|
1424
|
+
async moveToContainer(config, targetId) {
|
|
1425
|
+
const { node, parent } = this.getNodeInfo(config.id, false);
|
|
1235
1426
|
const target = this.getNodeById(targetId, false);
|
|
1236
1427
|
const stage = this.get("stage");
|
|
1237
1428
|
if (node && parent && stage) {
|
|
1238
1429
|
const root = cloneDeep(this.get("root"));
|
|
1239
1430
|
const index = getNodeIndex(node, parent);
|
|
1240
1431
|
parent.items?.splice(index, 1);
|
|
1241
|
-
await stage.remove({ id: node.id, root });
|
|
1432
|
+
await stage.remove({ id: node.id, parentId: parent.id, root });
|
|
1242
1433
|
const layout = await this.getLayout(target);
|
|
1243
|
-
const newConfig = mergeWith(cloneDeep(node),
|
|
1434
|
+
const newConfig = mergeWith(cloneDeep(node), config, (objValue, srcValue) => {
|
|
1244
1435
|
if (Array.isArray(srcValue)) {
|
|
1245
1436
|
return srcValue;
|
|
1246
1437
|
}
|
|
1247
1438
|
});
|
|
1248
|
-
newConfig.style = getInitPositionStyle(newConfig.style, layout
|
|
1439
|
+
newConfig.style = getInitPositionStyle(newConfig.style, layout);
|
|
1249
1440
|
target.items.push(newConfig);
|
|
1250
1441
|
await stage.select(targetId);
|
|
1251
|
-
|
|
1442
|
+
const targetParent = this.getParentById(target.id);
|
|
1443
|
+
await stage.update({ config: cloneDeep(target), parentId: targetParent?.id, root });
|
|
1252
1444
|
await this.select(newConfig);
|
|
1253
1445
|
stage.select(newConfig.id);
|
|
1254
1446
|
this.addModifiedNodeId(target.id);
|
|
@@ -1271,7 +1463,7 @@ class Editor$1 extends BaseService {
|
|
|
1271
1463
|
const node = toRaw(this.get("node"));
|
|
1272
1464
|
if (!node || isPage(node))
|
|
1273
1465
|
return;
|
|
1274
|
-
const { style, id } = node;
|
|
1466
|
+
const { style, id, type } = node;
|
|
1275
1467
|
if (!style || style.position !== "absolute")
|
|
1276
1468
|
return;
|
|
1277
1469
|
if (top && !isNumber(style.top))
|
|
@@ -1280,6 +1472,7 @@ class Editor$1 extends BaseService {
|
|
|
1280
1472
|
return;
|
|
1281
1473
|
this.update({
|
|
1282
1474
|
id,
|
|
1475
|
+
type,
|
|
1283
1476
|
style: {
|
|
1284
1477
|
...style,
|
|
1285
1478
|
left: Number(style.left) + left,
|
|
@@ -1291,6 +1484,7 @@ class Editor$1 extends BaseService {
|
|
|
1291
1484
|
this.removeAllListeners();
|
|
1292
1485
|
this.set("root", null);
|
|
1293
1486
|
this.set("node", null);
|
|
1487
|
+
this.set("nodes", []);
|
|
1294
1488
|
this.set("page", null);
|
|
1295
1489
|
this.set("parent", null);
|
|
1296
1490
|
}
|
|
@@ -1337,12 +1531,12 @@ class Editor$1 extends BaseService {
|
|
|
1337
1531
|
}
|
|
1338
1532
|
return newConfig;
|
|
1339
1533
|
}
|
|
1340
|
-
selectedConfigExceptionHandler(
|
|
1534
|
+
selectedConfigExceptionHandler(config) {
|
|
1341
1535
|
let id;
|
|
1342
|
-
if (typeof
|
|
1343
|
-
id =
|
|
1536
|
+
if (typeof config === "string" || typeof config === "number") {
|
|
1537
|
+
id = config;
|
|
1344
1538
|
} else {
|
|
1345
|
-
id =
|
|
1539
|
+
id = config.id;
|
|
1346
1540
|
}
|
|
1347
1541
|
if (!id) {
|
|
1348
1542
|
throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
|
|
@@ -1360,7 +1554,7 @@ class Editor$1 extends BaseService {
|
|
|
1360
1554
|
};
|
|
1361
1555
|
}
|
|
1362
1556
|
}
|
|
1363
|
-
|
|
1557
|
+
const editorService = new Editor$1();
|
|
1364
1558
|
|
|
1365
1559
|
const eventMap = reactive({});
|
|
1366
1560
|
const methodMap = reactive({});
|
|
@@ -1404,7 +1598,7 @@ class Events extends BaseService {
|
|
|
1404
1598
|
return cloneDeep(methodMap[type] || DEFAULT_METHODS);
|
|
1405
1599
|
}
|
|
1406
1600
|
}
|
|
1407
|
-
|
|
1601
|
+
const eventsService = new Events();
|
|
1408
1602
|
|
|
1409
1603
|
const fillConfig = (config = []) => [
|
|
1410
1604
|
{
|
|
@@ -1609,22 +1803,34 @@ const fillConfig = (config = []) => [
|
|
|
1609
1803
|
]
|
|
1610
1804
|
}
|
|
1611
1805
|
];
|
|
1612
|
-
|
|
1613
|
-
const
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1806
|
+
|
|
1807
|
+
const log = (...args) => {
|
|
1808
|
+
if (process.env.NODE_ENV === "development") {
|
|
1809
|
+
console.log("magic editor: ", ...args);
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
const info = (...args) => {
|
|
1813
|
+
if (process.env.NODE_ENV === "development") {
|
|
1814
|
+
console.info("magic editor: ", ...args);
|
|
1815
|
+
}
|
|
1816
|
+
};
|
|
1817
|
+
const warn = (...args) => {
|
|
1818
|
+
if (process.env.NODE_ENV === "development") {
|
|
1819
|
+
console.warn("magic editor: ", ...args);
|
|
1820
|
+
}
|
|
1821
|
+
};
|
|
1822
|
+
const debug = (...args) => {
|
|
1823
|
+
if (process.env.NODE_ENV === "development") {
|
|
1824
|
+
console.debug("magic editor: ", ...args);
|
|
1825
|
+
}
|
|
1826
|
+
};
|
|
1827
|
+
const error = (...args) => {
|
|
1828
|
+
if (process.env.NODE_ENV === "development") {
|
|
1829
|
+
console.error("magic editor: ", ...args);
|
|
1830
|
+
}
|
|
1625
1831
|
};
|
|
1626
1832
|
|
|
1627
|
-
const _sfc_main$
|
|
1833
|
+
const _sfc_main$j = defineComponent({
|
|
1628
1834
|
components: { Plus },
|
|
1629
1835
|
setup() {
|
|
1630
1836
|
const services = inject("services");
|
|
@@ -1641,10 +1847,11 @@ const _sfc_main$i = defineComponent({
|
|
|
1641
1847
|
};
|
|
1642
1848
|
}
|
|
1643
1849
|
});
|
|
1850
|
+
|
|
1644
1851
|
const _hoisted_1$b = { class: "m-editor-empty-panel" };
|
|
1645
1852
|
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
1646
|
-
const _hoisted_3$
|
|
1647
|
-
function _sfc_render$
|
|
1853
|
+
const _hoisted_3$1 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
1854
|
+
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1648
1855
|
const _component_plus = resolveComponent("plus");
|
|
1649
1856
|
const _component_el_icon = resolveComponent("el-icon");
|
|
1650
1857
|
return openBlock(), createElementBlock("div", _hoisted_1$b, [
|
|
@@ -1661,14 +1868,14 @@ function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1661
1868
|
_: 1
|
|
1662
1869
|
})
|
|
1663
1870
|
]),
|
|
1664
|
-
_hoisted_3$
|
|
1871
|
+
_hoisted_3$1
|
|
1665
1872
|
])
|
|
1666
1873
|
])
|
|
1667
1874
|
]);
|
|
1668
1875
|
}
|
|
1669
|
-
|
|
1876
|
+
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$d]]);
|
|
1670
1877
|
|
|
1671
|
-
const _sfc_main$
|
|
1878
|
+
const _sfc_main$i = defineComponent({
|
|
1672
1879
|
name: "m-editor-resize",
|
|
1673
1880
|
props: {
|
|
1674
1881
|
type: {
|
|
@@ -1710,18 +1917,19 @@ const _sfc_main$h = defineComponent({
|
|
|
1710
1917
|
};
|
|
1711
1918
|
}
|
|
1712
1919
|
});
|
|
1920
|
+
|
|
1713
1921
|
const _hoisted_1$a = {
|
|
1714
1922
|
ref: "target",
|
|
1715
1923
|
class: "m-editor-resizer"
|
|
1716
1924
|
};
|
|
1717
|
-
function _sfc_render$
|
|
1925
|
+
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1718
1926
|
return openBlock(), createElementBlock("span", _hoisted_1$a, [
|
|
1719
1927
|
renderSlot(_ctx.$slots, "default")
|
|
1720
1928
|
], 512);
|
|
1721
1929
|
}
|
|
1722
|
-
|
|
1930
|
+
const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$c]]);
|
|
1723
1931
|
|
|
1724
|
-
const _sfc_main$
|
|
1932
|
+
const _sfc_main$h = defineComponent({
|
|
1725
1933
|
components: {
|
|
1726
1934
|
AddPageBox,
|
|
1727
1935
|
Resizer
|
|
@@ -1750,12 +1958,13 @@ const _sfc_main$g = defineComponent({
|
|
|
1750
1958
|
};
|
|
1751
1959
|
}
|
|
1752
1960
|
});
|
|
1961
|
+
|
|
1753
1962
|
const _hoisted_1$9 = { class: "m-editor" };
|
|
1754
1963
|
const _hoisted_2$3 = {
|
|
1755
1964
|
key: 1,
|
|
1756
1965
|
class: "m-editor-content"
|
|
1757
1966
|
};
|
|
1758
|
-
function _sfc_render$
|
|
1967
|
+
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1759
1968
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
1760
1969
|
const _component_resizer = resolveComponent("resizer");
|
|
1761
1970
|
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
@@ -1801,9 +2010,9 @@ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1801
2010
|
]))
|
|
1802
2011
|
]);
|
|
1803
2012
|
}
|
|
1804
|
-
|
|
2013
|
+
const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$b]]);
|
|
1805
2014
|
|
|
1806
|
-
const _sfc_main$
|
|
2015
|
+
const _sfc_main$g = defineComponent({
|
|
1807
2016
|
name: "m-icon",
|
|
1808
2017
|
components: { Edit },
|
|
1809
2018
|
props: {
|
|
@@ -1817,8 +2026,9 @@ const _sfc_main$f = defineComponent({
|
|
|
1817
2026
|
};
|
|
1818
2027
|
}
|
|
1819
2028
|
});
|
|
2029
|
+
|
|
1820
2030
|
const _hoisted_1$8 = ["src"];
|
|
1821
|
-
function _sfc_render$
|
|
2031
|
+
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1822
2032
|
const _component_edit = resolveComponent("edit");
|
|
1823
2033
|
const _component_el_icon = resolveComponent("el-icon");
|
|
1824
2034
|
return !_ctx.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
|
|
@@ -1826,10 +2036,12 @@ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1826
2036
|
createVNode(_component_edit)
|
|
1827
2037
|
]),
|
|
1828
2038
|
_: 1
|
|
1829
|
-
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (openBlock(),
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
2039
|
+
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (openBlock(), createBlock(_component_el_icon, { key: 1 }, {
|
|
2040
|
+
default: withCtx(() => [
|
|
2041
|
+
createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$8)
|
|
2042
|
+
]),
|
|
2043
|
+
_: 1
|
|
2044
|
+
})) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
1833
2045
|
key: 2,
|
|
1834
2046
|
class: normalizeClass(_ctx.icon)
|
|
1835
2047
|
}, null, 2)) : (openBlock(), createBlock(_component_el_icon, { key: 3 }, {
|
|
@@ -1839,10 +2051,19 @@ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1839
2051
|
_: 1
|
|
1840
2052
|
}));
|
|
1841
2053
|
}
|
|
1842
|
-
|
|
2054
|
+
const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
|
|
1843
2055
|
|
|
1844
|
-
const
|
|
1845
|
-
|
|
2056
|
+
const _hoisted_1$7 = {
|
|
2057
|
+
key: 1,
|
|
2058
|
+
class: "menu-item-text"
|
|
2059
|
+
};
|
|
2060
|
+
const _hoisted_2$2 = {
|
|
2061
|
+
class: "menu-item-text",
|
|
2062
|
+
style: { "margin": "0 5px" }
|
|
2063
|
+
};
|
|
2064
|
+
const _hoisted_3 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2065
|
+
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
2066
|
+
__name: "ToolButton",
|
|
1846
2067
|
props: {
|
|
1847
2068
|
data: {
|
|
1848
2069
|
type: [Object, String],
|
|
@@ -1857,7 +2078,8 @@ const _sfc_main$e = defineComponent({
|
|
|
1857
2078
|
default: "click"
|
|
1858
2079
|
}
|
|
1859
2080
|
},
|
|
1860
|
-
setup(
|
|
2081
|
+
setup(__props) {
|
|
2082
|
+
const props = __props;
|
|
1861
2083
|
const services = inject("services");
|
|
1862
2084
|
const uiService = services?.uiService;
|
|
1863
2085
|
const zoom = computed(() => uiService?.get("zoom") ?? 1);
|
|
@@ -1954,176 +2176,155 @@ const _sfc_main$e = defineComponent({
|
|
|
1954
2176
|
item2.handler?.(services, event);
|
|
1955
2177
|
}
|
|
1956
2178
|
};
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
item
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
}
|
|
1971
|
-
return item.value.display ?? true;
|
|
1972
|
-
}),
|
|
1973
|
-
zoomInHandler,
|
|
1974
|
-
zoomOutHandler,
|
|
1975
|
-
dropdownHandler(command) {
|
|
1976
|
-
if (command.item.handler) {
|
|
1977
|
-
command.item.handler(services);
|
|
1978
|
-
}
|
|
1979
|
-
},
|
|
1980
|
-
clickHandler(item2, event) {
|
|
1981
|
-
if (props.eventType !== "click")
|
|
1982
|
-
return;
|
|
1983
|
-
if (item2.type === "button") {
|
|
1984
|
-
buttonHandler(item2, event);
|
|
1985
|
-
}
|
|
1986
|
-
},
|
|
1987
|
-
mousedownHandler(item2, event) {
|
|
1988
|
-
if (props.eventType !== "mousedown")
|
|
1989
|
-
return;
|
|
1990
|
-
if (item2.type === "button") {
|
|
1991
|
-
buttonHandler(item2, event);
|
|
1992
|
-
}
|
|
1993
|
-
},
|
|
1994
|
-
mouseupHandler(item2, event) {
|
|
1995
|
-
if (props.eventType !== "mouseup")
|
|
1996
|
-
return;
|
|
1997
|
-
if (item2.type === "button") {
|
|
1998
|
-
buttonHandler(item2, event);
|
|
1999
|
-
}
|
|
2179
|
+
const display = computed(() => {
|
|
2180
|
+
if (!item.value)
|
|
2181
|
+
return false;
|
|
2182
|
+
if (typeof item.value === "string")
|
|
2183
|
+
return true;
|
|
2184
|
+
if (typeof item.value.display === "function") {
|
|
2185
|
+
return item.value.display(services);
|
|
2186
|
+
}
|
|
2187
|
+
return item.value.display ?? true;
|
|
2188
|
+
});
|
|
2189
|
+
const dropdownHandler = (command) => {
|
|
2190
|
+
if (command.item.handler) {
|
|
2191
|
+
command.item.handler(services);
|
|
2000
2192
|
}
|
|
2001
2193
|
};
|
|
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
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
direction: _ctx.item.direction || "vertical"
|
|
2034
|
-
}, 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 }, [
|
|
2035
|
-
createVNode(_component_tool_button, {
|
|
2036
|
-
data: { type: "button", icon: _ctx.ZoomOut, handler: _ctx.zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
2037
|
-
"event-type": _ctx.eventType
|
|
2038
|
-
}, null, 8, ["data", "event-type"]),
|
|
2039
|
-
createElementVNode("span", _hoisted_2$2, toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
|
|
2040
|
-
createVNode(_component_tool_button, {
|
|
2041
|
-
data: { type: "button", icon: _ctx.ZoomIn, handler: _ctx.zoomInHandler, tooltip: "\u653E\u5927" },
|
|
2042
|
-
"event-type": _ctx.eventType
|
|
2043
|
-
}, null, 8, ["data", "event-type"])
|
|
2044
|
-
], 64)) : _ctx.item.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
2045
|
-
_ctx.item.tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
2194
|
+
const clickHandler = (item2, event) => {
|
|
2195
|
+
if (props.eventType !== "click")
|
|
2196
|
+
return;
|
|
2197
|
+
if (item2.type === "button") {
|
|
2198
|
+
buttonHandler(item2, event);
|
|
2199
|
+
}
|
|
2200
|
+
};
|
|
2201
|
+
const mousedownHandler = (item2, event) => {
|
|
2202
|
+
if (props.eventType !== "mousedown")
|
|
2203
|
+
return;
|
|
2204
|
+
if (item2.type === "button") {
|
|
2205
|
+
buttonHandler(item2, event);
|
|
2206
|
+
}
|
|
2207
|
+
};
|
|
2208
|
+
const mouseupHandler = (item2, event) => {
|
|
2209
|
+
if (props.eventType !== "mouseup")
|
|
2210
|
+
return;
|
|
2211
|
+
if (item2.type === "button") {
|
|
2212
|
+
buttonHandler(item2, event);
|
|
2213
|
+
}
|
|
2214
|
+
};
|
|
2215
|
+
return (_ctx, _cache) => {
|
|
2216
|
+
const _component_el_divider = resolveComponent("el-divider");
|
|
2217
|
+
const _component_tool_button = resolveComponent("tool-button", true);
|
|
2218
|
+
const _component_el_button = resolveComponent("el-button");
|
|
2219
|
+
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
2220
|
+
const _component_el_icon = resolveComponent("el-icon");
|
|
2221
|
+
const _component_el_dropdown_item = resolveComponent("el-dropdown-item");
|
|
2222
|
+
const _component_el_dropdown_menu = resolveComponent("el-dropdown-menu");
|
|
2223
|
+
const _component_el_dropdown = resolveComponent("el-dropdown");
|
|
2224
|
+
return unref(display) ? (openBlock(), createElementBlock("div", {
|
|
2046
2225
|
key: 0,
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2226
|
+
class: normalizeClass(["menu-item", unref(item).type]),
|
|
2227
|
+
onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(unref(item), $event)),
|
|
2228
|
+
onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(unref(item), $event)),
|
|
2229
|
+
onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(unref(item), $event))
|
|
2230
|
+
}, [
|
|
2231
|
+
unref(item).type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
|
|
2232
|
+
key: 0,
|
|
2233
|
+
direction: unref(item).direction || "vertical"
|
|
2234
|
+
}, 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 }, [
|
|
2235
|
+
createVNode(_component_tool_button, {
|
|
2236
|
+
data: { type: "button", icon: unref(ZoomOut), handler: zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
2237
|
+
"event-type": __props.eventType
|
|
2238
|
+
}, null, 8, ["data", "event-type"]),
|
|
2239
|
+
createElementVNode("span", _hoisted_2$2, toDisplayString(parseInt(`${unref(zoom) * 100}`, 10)) + "%", 1),
|
|
2240
|
+
createVNode(_component_tool_button, {
|
|
2241
|
+
data: { type: "button", icon: unref(ZoomIn), handler: zoomInHandler, tooltip: "\u653E\u5927" },
|
|
2242
|
+
"event-type": __props.eventType
|
|
2243
|
+
}, null, 8, ["data", "event-type"])
|
|
2244
|
+
], 64)) : unref(item).type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
2245
|
+
unref(item).tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
2246
|
+
key: 0,
|
|
2247
|
+
effect: "dark",
|
|
2248
|
+
placement: "bottom-start",
|
|
2249
|
+
content: unref(item).tooltip
|
|
2250
|
+
}, {
|
|
2251
|
+
default: withCtx(() => [
|
|
2252
|
+
createVNode(_component_el_button, {
|
|
2253
|
+
size: "small",
|
|
2254
|
+
text: "",
|
|
2255
|
+
disabled: unref(disabled)
|
|
2256
|
+
}, {
|
|
2257
|
+
default: withCtx(() => [
|
|
2258
|
+
unref(item).icon ? (openBlock(), createBlock(MIcon, {
|
|
2259
|
+
key: 0,
|
|
2260
|
+
icon: unref(item).icon
|
|
2261
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
2262
|
+
createElementVNode("span", null, toDisplayString(unref(item).text), 1)
|
|
2263
|
+
]),
|
|
2264
|
+
_: 1
|
|
2265
|
+
}, 8, ["disabled"])
|
|
2266
|
+
]),
|
|
2267
|
+
_: 1
|
|
2268
|
+
}, 8, ["content"])) : (openBlock(), createBlock(_component_el_button, {
|
|
2269
|
+
key: 1,
|
|
2053
2270
|
size: "small",
|
|
2054
2271
|
text: "",
|
|
2055
|
-
disabled:
|
|
2272
|
+
disabled: unref(disabled)
|
|
2056
2273
|
}, {
|
|
2057
2274
|
default: withCtx(() => [
|
|
2058
|
-
|
|
2275
|
+
unref(item).icon ? (openBlock(), createBlock(MIcon, {
|
|
2059
2276
|
key: 0,
|
|
2060
|
-
icon:
|
|
2277
|
+
icon: unref(item).icon
|
|
2061
2278
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
2062
|
-
createElementVNode("span", null, toDisplayString(
|
|
2279
|
+
createElementVNode("span", null, toDisplayString(unref(item).text), 1)
|
|
2063
2280
|
]),
|
|
2064
2281
|
_: 1
|
|
2065
|
-
}, 8, ["disabled"])
|
|
2066
|
-
]),
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
_ctx.item.items && _ctx.item.items.length ? (openBlock(), createBlock(_component_el_dropdown_menu, { key: 0 }, {
|
|
2282
|
+
}, 8, ["disabled"]))
|
|
2283
|
+
], 64)) : unref(item).type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
|
|
2284
|
+
key: 4,
|
|
2285
|
+
trigger: "click",
|
|
2286
|
+
disabled: unref(disabled),
|
|
2287
|
+
onCommand: dropdownHandler
|
|
2288
|
+
}, {
|
|
2289
|
+
dropdown: withCtx(() => [
|
|
2290
|
+
unref(item).items && unref(item).items.length ? (openBlock(), createBlock(_component_el_dropdown_menu, { key: 0 }, {
|
|
2291
|
+
default: withCtx(() => [
|
|
2292
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(item).items, (subItem, index) => {
|
|
2293
|
+
return openBlock(), createBlock(_component_el_dropdown_item, {
|
|
2294
|
+
key: index,
|
|
2295
|
+
command: { item: unref(item), subItem }
|
|
2296
|
+
}, {
|
|
2297
|
+
default: withCtx(() => [
|
|
2298
|
+
createTextVNode(toDisplayString(subItem.text), 1)
|
|
2299
|
+
]),
|
|
2300
|
+
_: 2
|
|
2301
|
+
}, 1032, ["command"]);
|
|
2302
|
+
}), 128))
|
|
2303
|
+
]),
|
|
2304
|
+
_: 1
|
|
2305
|
+
})) : createCommentVNode("", true)
|
|
2306
|
+
]),
|
|
2091
2307
|
default: withCtx(() => [
|
|
2092
|
-
(
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
command: { item: _ctx.item, subItem }
|
|
2096
|
-
}, {
|
|
2308
|
+
createElementVNode("span", _hoisted_3, [
|
|
2309
|
+
createTextVNode(toDisplayString(unref(item).text), 1),
|
|
2310
|
+
createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2097
2311
|
default: withCtx(() => [
|
|
2098
|
-
|
|
2312
|
+
createVNode(unref(ArrowDown))
|
|
2099
2313
|
]),
|
|
2100
|
-
_:
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2314
|
+
_: 1
|
|
2315
|
+
})
|
|
2316
|
+
])
|
|
2103
2317
|
]),
|
|
2104
2318
|
_: 1
|
|
2105
|
-
})) : createCommentVNode("", true)
|
|
2106
|
-
]),
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2111
|
-
default: withCtx(() => [
|
|
2112
|
-
createVNode(_component_arrow_down)
|
|
2113
|
-
]),
|
|
2114
|
-
_: 1
|
|
2115
|
-
})
|
|
2116
|
-
])
|
|
2117
|
-
]),
|
|
2118
|
-
_: 1
|
|
2119
|
-
}, 8, ["disabled", "onCommand"])) : _ctx.item.type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.item.component), normalizeProps(mergeProps({ key: 5 }, _ctx.item.props || {})), null, 16)) : createCommentVNode("", true)
|
|
2120
|
-
], 34)) : createCommentVNode("", true);
|
|
2121
|
-
}
|
|
2122
|
-
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
|
|
2319
|
+
}, 8, ["disabled"])) : unref(item).type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(unref(item).component), normalizeProps(mergeProps({ key: 5 }, unref(item).props || {})), null, 16)) : createCommentVNode("", true)
|
|
2320
|
+
], 34)) : createCommentVNode("", true);
|
|
2321
|
+
};
|
|
2322
|
+
}
|
|
2323
|
+
});
|
|
2123
2324
|
|
|
2124
|
-
const _sfc_main$
|
|
2325
|
+
const _sfc_main$e = defineComponent({
|
|
2125
2326
|
name: "nav-menu",
|
|
2126
|
-
components: { ToolButton },
|
|
2327
|
+
components: { ToolButton: _sfc_main$f },
|
|
2127
2328
|
props: {
|
|
2128
2329
|
data: {
|
|
2129
2330
|
type: Object,
|
|
@@ -2141,7 +2342,8 @@ const _sfc_main$d = defineComponent({
|
|
|
2141
2342
|
};
|
|
2142
2343
|
}
|
|
2143
2344
|
});
|
|
2144
|
-
|
|
2345
|
+
|
|
2346
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2145
2347
|
const _component_tool_button = resolveComponent("tool-button");
|
|
2146
2348
|
return openBlock(), createElementBlock("div", {
|
|
2147
2349
|
class: "m-editor-nav-menu",
|
|
@@ -2163,9 +2365,9 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2163
2365
|
}), 128))
|
|
2164
2366
|
], 4);
|
|
2165
2367
|
}
|
|
2166
|
-
|
|
2368
|
+
const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
|
|
2167
2369
|
|
|
2168
|
-
const _sfc_main$
|
|
2370
|
+
const _sfc_main$d = defineComponent({
|
|
2169
2371
|
name: "m-editor-props-panel",
|
|
2170
2372
|
emits: ["mounted"],
|
|
2171
2373
|
setup(props, { emit }) {
|
|
@@ -2212,8 +2414,9 @@ const _sfc_main$c = defineComponent({
|
|
|
2212
2414
|
};
|
|
2213
2415
|
}
|
|
2214
2416
|
});
|
|
2417
|
+
|
|
2215
2418
|
const _hoisted_1$6 = { class: "`m-editor-props-panel" };
|
|
2216
|
-
function _sfc_render$
|
|
2419
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2217
2420
|
const _component_m_form = resolveComponent("m-form");
|
|
2218
2421
|
return openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
2219
2422
|
renderSlot(_ctx.$slots, "props-panel-header"),
|
|
@@ -2228,9 +2431,9 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2228
2431
|
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
|
|
2229
2432
|
]);
|
|
2230
2433
|
}
|
|
2231
|
-
|
|
2434
|
+
const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
|
|
2232
2435
|
|
|
2233
|
-
const _sfc_main$
|
|
2436
|
+
const _sfc_main$c = defineComponent({
|
|
2234
2437
|
name: "ui-component-panel",
|
|
2235
2438
|
components: { MIcon },
|
|
2236
2439
|
setup() {
|
|
@@ -2289,27 +2492,17 @@ const _sfc_main$b = defineComponent({
|
|
|
2289
2492
|
}
|
|
2290
2493
|
return;
|
|
2291
2494
|
}
|
|
2292
|
-
if (timeout)
|
|
2495
|
+
if (timeout || !stage.value)
|
|
2293
2496
|
return;
|
|
2294
|
-
timeout =
|
|
2295
|
-
if (!stageOptions || !stage.value)
|
|
2296
|
-
return;
|
|
2297
|
-
const doc = stage.value.renderer.contentWindow?.document;
|
|
2298
|
-
const els = stage.value.getElementsFromPoint(e);
|
|
2299
|
-
for (const el of els) {
|
|
2300
|
-
if (doc && !el.id.startsWith(GHOST_EL_ID_PREFIX) && await stageOptions.isContainer(el)) {
|
|
2301
|
-
addClassName(el, doc, stageOptions?.containerHighlightClassName);
|
|
2302
|
-
break;
|
|
2303
|
-
}
|
|
2304
|
-
}
|
|
2305
|
-
}, stageOptions?.containerHighlightDuration);
|
|
2497
|
+
timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
|
|
2306
2498
|
}
|
|
2307
2499
|
};
|
|
2308
2500
|
}
|
|
2309
2501
|
});
|
|
2502
|
+
|
|
2310
2503
|
const _hoisted_1$5 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
2311
2504
|
const _hoisted_2$1 = ["onClick", "onDragstart"];
|
|
2312
|
-
function _sfc_render$
|
|
2505
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2313
2506
|
const _component_el_input = resolveComponent("el-input");
|
|
2314
2507
|
const _component_m_icon = resolveComponent("m-icon");
|
|
2315
2508
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
@@ -2381,22 +2574,17 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2381
2574
|
_: 3
|
|
2382
2575
|
});
|
|
2383
2576
|
}
|
|
2384
|
-
|
|
2577
|
+
const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
|
|
2385
2578
|
|
|
2386
|
-
const _sfc_main$
|
|
2387
|
-
|
|
2579
|
+
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
2580
|
+
__name: "ContentMenu",
|
|
2388
2581
|
props: {
|
|
2389
|
-
menuData: {
|
|
2390
|
-
|
|
2391
|
-
default: () => []
|
|
2392
|
-
},
|
|
2393
|
-
isSubMenu: {
|
|
2394
|
-
type: Boolean,
|
|
2395
|
-
default: false
|
|
2396
|
-
}
|
|
2582
|
+
menuData: { default: () => [] },
|
|
2583
|
+
isSubMenu: { type: Boolean, default: false }
|
|
2397
2584
|
},
|
|
2398
2585
|
emits: ["hide", "show"],
|
|
2399
|
-
setup(
|
|
2586
|
+
setup(__props, { expose, emit }) {
|
|
2587
|
+
const props = __props;
|
|
2400
2588
|
const menu = ref();
|
|
2401
2589
|
const subMenu = ref();
|
|
2402
2590
|
const visible = ref(false);
|
|
@@ -2422,6 +2610,36 @@ const _sfc_main$a = defineComponent({
|
|
|
2422
2610
|
}
|
|
2423
2611
|
hide();
|
|
2424
2612
|
};
|
|
2613
|
+
const show = (e) => {
|
|
2614
|
+
setTimeout(() => {
|
|
2615
|
+
visible.value = true;
|
|
2616
|
+
nextTick(() => {
|
|
2617
|
+
const menuHeight = menu.value?.clientHeight || 0;
|
|
2618
|
+
let top = e.clientY;
|
|
2619
|
+
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
2620
|
+
top = document.body.clientHeight - menuHeight;
|
|
2621
|
+
}
|
|
2622
|
+
menuStyle.value = {
|
|
2623
|
+
top: `${top}px`,
|
|
2624
|
+
left: `${e.clientX}px`
|
|
2625
|
+
};
|
|
2626
|
+
emit("show");
|
|
2627
|
+
});
|
|
2628
|
+
}, 300);
|
|
2629
|
+
};
|
|
2630
|
+
const showSubMenu = (item) => {
|
|
2631
|
+
const menuItem = item;
|
|
2632
|
+
if (typeof item !== "object" || !menuItem.items?.length) {
|
|
2633
|
+
return;
|
|
2634
|
+
}
|
|
2635
|
+
subMenuData.value = menuItem.items;
|
|
2636
|
+
if (menu.value) {
|
|
2637
|
+
subMenu.value.show({
|
|
2638
|
+
clientX: menu.value.offsetLeft + menu.value.clientWidth,
|
|
2639
|
+
clientY: menu.value.offsetTop
|
|
2640
|
+
});
|
|
2641
|
+
}
|
|
2642
|
+
};
|
|
2425
2643
|
onMounted(() => {
|
|
2426
2644
|
if (props.isSubMenu)
|
|
2427
2645
|
return;
|
|
@@ -2432,81 +2650,47 @@ const _sfc_main$a = defineComponent({
|
|
|
2432
2650
|
return;
|
|
2433
2651
|
globalThis.removeEventListener("mousedown", hideHandler, true);
|
|
2434
2652
|
});
|
|
2435
|
-
|
|
2436
|
-
menu,
|
|
2437
|
-
subMenu,
|
|
2438
|
-
visible,
|
|
2439
|
-
menuStyle,
|
|
2440
|
-
subMenuData,
|
|
2653
|
+
expose({
|
|
2441
2654
|
hide,
|
|
2442
|
-
show
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2655
|
+
show
|
|
2656
|
+
});
|
|
2657
|
+
return (_ctx, _cache) => {
|
|
2658
|
+
const _component_content_menu = resolveComponent("content-menu", true);
|
|
2659
|
+
return __props.menuData.length && visible.value ? (openBlock(), createElementBlock("div", {
|
|
2660
|
+
key: 0,
|
|
2661
|
+
class: "magic-editor-content-menu",
|
|
2662
|
+
ref_key: "menu",
|
|
2663
|
+
ref: menu,
|
|
2664
|
+
style: normalizeStyle(menuStyle.value)
|
|
2665
|
+
}, [
|
|
2666
|
+
createElementVNode("div", null, [
|
|
2667
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.menuData, (item, index) => {
|
|
2668
|
+
return openBlock(), createBlock(_sfc_main$f, {
|
|
2669
|
+
"event-type": "mouseup",
|
|
2670
|
+
data: item,
|
|
2671
|
+
key: index,
|
|
2672
|
+
onMouseup: hide,
|
|
2673
|
+
onMouseenter: ($event) => showSubMenu(item)
|
|
2674
|
+
}, null, 8, ["data", "onMouseenter"]);
|
|
2675
|
+
}), 128))
|
|
2676
|
+
]),
|
|
2677
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
2678
|
+
createVNode(_component_content_menu, {
|
|
2679
|
+
class: "sub-menu",
|
|
2680
|
+
ref_key: "subMenu",
|
|
2681
|
+
ref: subMenu,
|
|
2682
|
+
"menu-data": subMenuData.value,
|
|
2683
|
+
"is-sub-menu": true,
|
|
2684
|
+
onHide: hide
|
|
2685
|
+
}, null, 8, ["menu-data"])
|
|
2686
|
+
]))
|
|
2687
|
+
], 4)) : createCommentVNode("", true);
|
|
2472
2688
|
};
|
|
2473
2689
|
}
|
|
2474
2690
|
});
|
|
2475
|
-
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2476
|
-
const _component_tool_button = resolveComponent("tool-button");
|
|
2477
|
-
const _component_content_menu = resolveComponent("content-menu", true);
|
|
2478
|
-
return _ctx.menuData.length && _ctx.visible ? (openBlock(), createElementBlock("div", {
|
|
2479
|
-
key: 0,
|
|
2480
|
-
class: "magic-editor-content-menu",
|
|
2481
|
-
ref: "menu",
|
|
2482
|
-
style: normalizeStyle(_ctx.menuStyle)
|
|
2483
|
-
}, [
|
|
2484
|
-
createElementVNode("div", null, [
|
|
2485
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menuData, (item, index) => {
|
|
2486
|
-
return openBlock(), createBlock(_component_tool_button, {
|
|
2487
|
-
"event-type": "mouseup",
|
|
2488
|
-
data: item,
|
|
2489
|
-
key: index,
|
|
2490
|
-
onMouseup: _ctx.hide,
|
|
2491
|
-
onMouseenter: ($event) => _ctx.showSubMenu(item)
|
|
2492
|
-
}, null, 8, ["data", "onMouseup", "onMouseenter"]);
|
|
2493
|
-
}), 128))
|
|
2494
|
-
]),
|
|
2495
|
-
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
2496
|
-
createVNode(_component_content_menu, {
|
|
2497
|
-
class: "sub-menu",
|
|
2498
|
-
ref: "subMenu",
|
|
2499
|
-
"menu-data": _ctx.subMenuData,
|
|
2500
|
-
"is-sub-menu": true,
|
|
2501
|
-
onHide: _ctx.hide
|
|
2502
|
-
}, null, 8, ["menu-data", "onHide"])
|
|
2503
|
-
]))
|
|
2504
|
-
], 4)) : createCommentVNode("", true);
|
|
2505
|
-
}
|
|
2506
|
-
var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
|
|
2507
2691
|
|
|
2508
|
-
const _sfc_main$
|
|
2509
|
-
components: { ContentMenu },
|
|
2692
|
+
const _sfc_main$a = defineComponent({
|
|
2693
|
+
components: { ContentMenu: _sfc_main$b },
|
|
2510
2694
|
setup() {
|
|
2511
2695
|
const services = inject("services");
|
|
2512
2696
|
const menu = ref();
|
|
@@ -2588,7 +2772,8 @@ const _sfc_main$9 = defineComponent({
|
|
|
2588
2772
|
};
|
|
2589
2773
|
}
|
|
2590
2774
|
});
|
|
2591
|
-
|
|
2775
|
+
|
|
2776
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2592
2777
|
const _component_content_menu = resolveComponent("content-menu");
|
|
2593
2778
|
return openBlock(), createBlock(_component_content_menu, {
|
|
2594
2779
|
"menu-data": _ctx.menuData,
|
|
@@ -2596,7 +2781,7 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2596
2781
|
style: { "overflow": "initial" }
|
|
2597
2782
|
}, null, 8, ["menu-data"]);
|
|
2598
2783
|
}
|
|
2599
|
-
|
|
2784
|
+
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$6]]);
|
|
2600
2785
|
|
|
2601
2786
|
const throttleTime = 150;
|
|
2602
2787
|
const select = async (data, editorService) => {
|
|
@@ -2630,29 +2815,55 @@ const useDrop = (tree, editorService) => ({
|
|
|
2630
2815
|
return true;
|
|
2631
2816
|
return false;
|
|
2632
2817
|
},
|
|
2633
|
-
handleDragEnd() {
|
|
2818
|
+
async handleDragEnd(e) {
|
|
2634
2819
|
if (!tree.value)
|
|
2635
2820
|
return;
|
|
2821
|
+
const { data: node } = e;
|
|
2822
|
+
const parent = editorService?.getParentById(node.id, false);
|
|
2823
|
+
const layout = await editorService?.getLayout(parent);
|
|
2824
|
+
node.style.position = layout;
|
|
2825
|
+
if (layout === Layout.RELATIVE) {
|
|
2826
|
+
node.style.top = 0;
|
|
2827
|
+
node.style.left = 0;
|
|
2828
|
+
}
|
|
2636
2829
|
const { data } = tree.value;
|
|
2637
2830
|
const [page] = data;
|
|
2638
2831
|
editorService?.update(page);
|
|
2639
2832
|
}
|
|
2640
2833
|
});
|
|
2641
2834
|
const useStatus = (tree, editorService) => {
|
|
2642
|
-
const highlightNode = ref();
|
|
2643
2835
|
const node = ref();
|
|
2644
2836
|
const page = computed(() => editorService?.get("page"));
|
|
2837
|
+
const expandedKeys = /* @__PURE__ */ new Map();
|
|
2838
|
+
const expandNodes = () => {
|
|
2839
|
+
expandedKeys.forEach((key) => {
|
|
2840
|
+
if (!tree.value)
|
|
2841
|
+
return;
|
|
2842
|
+
tree.value.getNode(key)?.expand();
|
|
2843
|
+
});
|
|
2844
|
+
};
|
|
2645
2845
|
watchEffect(() => {
|
|
2646
2846
|
if (!tree.value)
|
|
2647
2847
|
return;
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2848
|
+
if (!editorService)
|
|
2849
|
+
return;
|
|
2850
|
+
node.value = editorService.get("node");
|
|
2851
|
+
if (!node.value)
|
|
2852
|
+
return;
|
|
2853
|
+
tree.value.setCurrentKey(node.value.id, true);
|
|
2854
|
+
const parent = editorService.get("parent");
|
|
2651
2855
|
if (!parent?.id)
|
|
2652
2856
|
return;
|
|
2653
2857
|
const treeNode = tree.value.getNode(parent.id);
|
|
2654
2858
|
treeNode?.updateChildren();
|
|
2655
|
-
|
|
2859
|
+
setTimeout(() => {
|
|
2860
|
+
tree.value && Object.entries(tree.value.store.nodesMap).forEach(([id, node2]) => {
|
|
2861
|
+
if (node2.expanded && node2.data.items) {
|
|
2862
|
+
expandedKeys.set(id, id);
|
|
2863
|
+
}
|
|
2864
|
+
});
|
|
2865
|
+
expandNodes();
|
|
2866
|
+
});
|
|
2656
2867
|
});
|
|
2657
2868
|
return {
|
|
2658
2869
|
values: computed(() => page.value ? [page.value] : []),
|
|
@@ -2665,9 +2876,18 @@ const useStatus = (tree, editorService) => {
|
|
|
2665
2876
|
}
|
|
2666
2877
|
resolve([]);
|
|
2667
2878
|
},
|
|
2668
|
-
highlightNode,
|
|
2879
|
+
highlightNode: computed(() => editorService?.get("highlightNode")),
|
|
2669
2880
|
clickNode: node,
|
|
2670
|
-
expandedKeys: computed(() => node.value ? [node.value.id] : [])
|
|
2881
|
+
expandedKeys: computed(() => node.value ? [node.value.id] : []),
|
|
2882
|
+
handleCollapse: (data) => {
|
|
2883
|
+
expandedKeys.delete(data.id);
|
|
2884
|
+
},
|
|
2885
|
+
handleExpand: (data) => {
|
|
2886
|
+
const parent = editorService?.getParentById(data.id);
|
|
2887
|
+
if (!parent?.id)
|
|
2888
|
+
return;
|
|
2889
|
+
expandedKeys.set(parent.id, parent.id);
|
|
2890
|
+
}
|
|
2671
2891
|
};
|
|
2672
2892
|
};
|
|
2673
2893
|
const useFilter = (tree) => ({
|
|
@@ -2688,7 +2908,7 @@ const useFilter = (tree) => ({
|
|
|
2688
2908
|
tree.value?.filter(val);
|
|
2689
2909
|
}
|
|
2690
2910
|
});
|
|
2691
|
-
const _sfc_main$
|
|
2911
|
+
const _sfc_main$9 = defineComponent({
|
|
2692
2912
|
name: "magic-editor-layer-panel",
|
|
2693
2913
|
components: { LayerMenu },
|
|
2694
2914
|
setup() {
|
|
@@ -2735,8 +2955,9 @@ const _sfc_main$8 = defineComponent({
|
|
|
2735
2955
|
};
|
|
2736
2956
|
}
|
|
2737
2957
|
});
|
|
2958
|
+
|
|
2738
2959
|
const _hoisted_1$4 = ["id", "onMouseenter"];
|
|
2739
|
-
function _sfc_render$
|
|
2960
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2740
2961
|
const _component_el_input = resolveComponent("el-input");
|
|
2741
2962
|
const _component_el_tree = resolveComponent("el-tree");
|
|
2742
2963
|
const _component_layer_menu = resolveComponent("layer-menu");
|
|
@@ -2757,6 +2978,7 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2757
2978
|
key: 0,
|
|
2758
2979
|
ref: "tree",
|
|
2759
2980
|
"node-key": "id",
|
|
2981
|
+
"empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
|
|
2760
2982
|
draggable: "",
|
|
2761
2983
|
"default-expanded-keys": _ctx.expandedKeys,
|
|
2762
2984
|
load: _ctx.loadItems,
|
|
@@ -2771,7 +2993,8 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2771
2993
|
onNodeClick: _ctx.clickHandler,
|
|
2772
2994
|
onNodeContextmenu: _ctx.contextmenu,
|
|
2773
2995
|
onNodeDragEnd: _ctx.handleDragEnd,
|
|
2774
|
-
|
|
2996
|
+
onNodeCollapse: _ctx.handleCollapse,
|
|
2997
|
+
onNodeExpand: _ctx.handleExpand
|
|
2775
2998
|
}, {
|
|
2776
2999
|
default: withCtx(({ node, data }) => [
|
|
2777
3000
|
createElementVNode("div", {
|
|
@@ -2790,7 +3013,7 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2790
3013
|
], 42, _hoisted_1$4)
|
|
2791
3014
|
]),
|
|
2792
3015
|
_: 3
|
|
2793
|
-
}, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : createCommentVNode("", true),
|
|
3016
|
+
}, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd", "onNodeCollapse", "onNodeExpand"])) : createCommentVNode("", true),
|
|
2794
3017
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
2795
3018
|
createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
|
|
2796
3019
|
]))
|
|
@@ -2798,9 +3021,9 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2798
3021
|
_: 3
|
|
2799
3022
|
});
|
|
2800
3023
|
}
|
|
2801
|
-
|
|
3024
|
+
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$5]]);
|
|
2802
3025
|
|
|
2803
|
-
const _sfc_main$
|
|
3026
|
+
const _sfc_main$8 = defineComponent({
|
|
2804
3027
|
components: { MIcon },
|
|
2805
3028
|
props: {
|
|
2806
3029
|
data: {
|
|
@@ -2837,11 +3060,12 @@ const _sfc_main$7 = defineComponent({
|
|
|
2837
3060
|
};
|
|
2838
3061
|
}
|
|
2839
3062
|
});
|
|
3063
|
+
|
|
2840
3064
|
const _hoisted_1$3 = {
|
|
2841
3065
|
key: 1,
|
|
2842
3066
|
class: "magic-editor-tab-panel-title"
|
|
2843
3067
|
};
|
|
2844
|
-
function _sfc_render$
|
|
3068
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2845
3069
|
const _component_m_icon = resolveComponent("m-icon");
|
|
2846
3070
|
const _component_el_tab_pane = resolveComponent("el-tab-pane");
|
|
2847
3071
|
return _ctx.config ? (openBlock(), createBlock(_component_el_tab_pane, {
|
|
@@ -2887,9 +3111,9 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2887
3111
|
_: 3
|
|
2888
3112
|
}, 8, ["name"])) : createCommentVNode("", true);
|
|
2889
3113
|
}
|
|
2890
|
-
|
|
3114
|
+
const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$4]]);
|
|
2891
3115
|
|
|
2892
|
-
const _sfc_main$
|
|
3116
|
+
const _sfc_main$7 = defineComponent({
|
|
2893
3117
|
components: { TabPane },
|
|
2894
3118
|
name: "m-sidebar",
|
|
2895
3119
|
props: {
|
|
@@ -2908,7 +3132,8 @@ const _sfc_main$6 = defineComponent({
|
|
|
2908
3132
|
};
|
|
2909
3133
|
}
|
|
2910
3134
|
});
|
|
2911
|
-
|
|
3135
|
+
|
|
3136
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2912
3137
|
const _component_tab_pane = resolveComponent("tab-pane");
|
|
2913
3138
|
const _component_el_tabs = resolveComponent("el-tabs");
|
|
2914
3139
|
return _ctx.data.type === "tabs" && _ctx.data.items.length ? (openBlock(), createBlock(_component_el_tabs, {
|
|
@@ -2943,331 +3168,258 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2943
3168
|
_: 3
|
|
2944
3169
|
}, 8, ["modelValue"])) : createCommentVNode("", true);
|
|
2945
3170
|
}
|
|
2946
|
-
|
|
3171
|
+
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$3]]);
|
|
2947
3172
|
|
|
2948
|
-
const
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
}
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
return;
|
|
2970
|
-
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
2971
|
-
if (type === "left") {
|
|
2972
|
-
translateLeft += 100;
|
|
2973
|
-
if (translateLeft > 0) {
|
|
2974
|
-
translateLeft = 0;
|
|
3173
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
3174
|
+
__name: "PageBarScrollContainer",
|
|
3175
|
+
setup(__props) {
|
|
3176
|
+
const services = inject("services");
|
|
3177
|
+
const editorService = services?.editorService;
|
|
3178
|
+
const pageBar = ref();
|
|
3179
|
+
const itemsContainer = ref();
|
|
3180
|
+
const pageBarWidth = ref(0);
|
|
3181
|
+
const canScroll = ref(false);
|
|
3182
|
+
const itemsContainerWidth = computed(() => pageBarWidth.value - 105);
|
|
3183
|
+
let translateLeft = 0;
|
|
3184
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
3185
|
+
for (const { contentRect } of entries) {
|
|
3186
|
+
const { width } = contentRect;
|
|
3187
|
+
pageBarWidth.value = width || 0;
|
|
3188
|
+
setCanScroll();
|
|
3189
|
+
}
|
|
3190
|
+
});
|
|
3191
|
+
const setCanScroll = () => {
|
|
3192
|
+
if (itemsContainer.value) {
|
|
3193
|
+
canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
|
|
2975
3194
|
}
|
|
2976
|
-
}
|
|
2977
|
-
|
|
2978
|
-
if (
|
|
3195
|
+
};
|
|
3196
|
+
const scroll = (type) => {
|
|
3197
|
+
if (!itemsContainer.value)
|
|
3198
|
+
return;
|
|
3199
|
+
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
3200
|
+
if (type === "left") {
|
|
3201
|
+
translateLeft += 100;
|
|
3202
|
+
if (translateLeft > 0) {
|
|
3203
|
+
translateLeft = 0;
|
|
3204
|
+
}
|
|
3205
|
+
} else if (type === "right") {
|
|
3206
|
+
translateLeft -= 100;
|
|
3207
|
+
if (-translateLeft > maxScrollLeft) {
|
|
3208
|
+
translateLeft = -maxScrollLeft;
|
|
3209
|
+
}
|
|
3210
|
+
} else if (type === "start") {
|
|
3211
|
+
translateLeft = 0;
|
|
3212
|
+
} else if (type === "end") {
|
|
2979
3213
|
translateLeft = -maxScrollLeft;
|
|
2980
3214
|
}
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
}
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
onMounted(() => {
|
|
2989
|
-
pageBar.value && resizeObserver.observe(pageBar.value);
|
|
2990
|
-
});
|
|
2991
|
-
onUnmounted(() => {
|
|
2992
|
-
resizeObserver.disconnect();
|
|
2993
|
-
});
|
|
2994
|
-
watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
|
|
2995
|
-
setTimeout(() => {
|
|
2996
|
-
setCanScroll();
|
|
2997
|
-
if (length < preLength) {
|
|
2998
|
-
scroll("start");
|
|
2999
|
-
} else {
|
|
3000
|
-
scroll("end");
|
|
3001
|
-
}
|
|
3215
|
+
itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
|
|
3216
|
+
};
|
|
3217
|
+
onMounted(() => {
|
|
3218
|
+
pageBar.value && resizeObserver.observe(pageBar.value);
|
|
3219
|
+
});
|
|
3220
|
+
onUnmounted(() => {
|
|
3221
|
+
resizeObserver.disconnect();
|
|
3002
3222
|
});
|
|
3003
|
-
});
|
|
3004
|
-
return {
|
|
3005
|
-
pageBar,
|
|
3006
|
-
itemsContainer,
|
|
3007
|
-
canScroll,
|
|
3008
|
-
itemsContainerWidth,
|
|
3009
|
-
scroll
|
|
3010
|
-
};
|
|
3011
|
-
};
|
|
3012
|
-
const _sfc_main$5 = defineComponent({
|
|
3013
|
-
components: { ArrowLeftBold, ArrowRightBold, CaretBottom, Plus, ToolButton },
|
|
3014
|
-
setup() {
|
|
3015
|
-
const services = inject("services");
|
|
3016
|
-
const editorService = services?.editorService;
|
|
3017
3223
|
const root = computed(() => editorService?.get("root"));
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
}
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
copy(node) {
|
|
3037
|
-
node && editorService?.copy(node);
|
|
3038
|
-
editorService?.paste({
|
|
3039
|
-
left: 0,
|
|
3040
|
-
top: 0
|
|
3041
|
-
});
|
|
3042
|
-
},
|
|
3043
|
-
remove(node) {
|
|
3044
|
-
editorService?.remove(node);
|
|
3045
|
-
}
|
|
3224
|
+
watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
|
|
3225
|
+
setTimeout(() => {
|
|
3226
|
+
setCanScroll();
|
|
3227
|
+
if (length < preLength) {
|
|
3228
|
+
scroll("start");
|
|
3229
|
+
} else {
|
|
3230
|
+
scroll("end");
|
|
3231
|
+
}
|
|
3232
|
+
});
|
|
3233
|
+
});
|
|
3234
|
+
const addPage = () => {
|
|
3235
|
+
if (!editorService)
|
|
3236
|
+
return;
|
|
3237
|
+
const pageConfig = {
|
|
3238
|
+
type: NodeType.PAGE,
|
|
3239
|
+
name: generatePageNameByApp(toRaw(editorService.get("root")))
|
|
3240
|
+
};
|
|
3241
|
+
editorService.add(pageConfig);
|
|
3046
3242
|
};
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
createElementVNode("div", {
|
|
3066
|
-
id: "m-editor-page-bar-add-icon",
|
|
3067
|
-
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3068
|
-
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.addPage && _ctx.addPage(...args))
|
|
3069
|
-
}, [
|
|
3070
|
-
createVNode(_component_el_icon, null, {
|
|
3071
|
-
default: withCtx(() => [
|
|
3072
|
-
createVNode(_component_plus)
|
|
3073
|
-
]),
|
|
3074
|
-
_: 1
|
|
3075
|
-
})
|
|
3076
|
-
]),
|
|
3077
|
-
_ctx.canScroll ? (openBlock(), createElementBlock("div", {
|
|
3078
|
-
key: 0,
|
|
3079
|
-
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3080
|
-
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.scroll("left"))
|
|
3081
|
-
}, [
|
|
3082
|
-
createVNode(_component_el_icon, null, {
|
|
3083
|
-
default: withCtx(() => [
|
|
3084
|
-
createVNode(_component_arrow_left_bold)
|
|
3243
|
+
return (_ctx, _cache) => {
|
|
3244
|
+
const _component_el_icon = resolveComponent("el-icon");
|
|
3245
|
+
return openBlock(), createElementBlock("div", {
|
|
3246
|
+
class: "m-editor-page-bar",
|
|
3247
|
+
ref_key: "pageBar",
|
|
3248
|
+
ref: pageBar
|
|
3249
|
+
}, [
|
|
3250
|
+
createElementVNode("div", {
|
|
3251
|
+
id: "m-editor-page-bar-add-icon",
|
|
3252
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3253
|
+
onClick: addPage
|
|
3254
|
+
}, [
|
|
3255
|
+
createVNode(_component_el_icon, null, {
|
|
3256
|
+
default: withCtx(() => [
|
|
3257
|
+
createVNode(unref(Plus))
|
|
3258
|
+
]),
|
|
3259
|
+
_: 1
|
|
3260
|
+
})
|
|
3085
3261
|
]),
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
key: 1,
|
|
3091
|
-
class: "m-editor-page-bar-items",
|
|
3092
|
-
ref: "itemsContainer",
|
|
3093
|
-
style: normalizeStyle(`width: ${_ctx.itemsContainerWidth}px`)
|
|
3094
|
-
}, [
|
|
3095
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.root.items, (item) => {
|
|
3096
|
-
return openBlock(), createElementBlock("div", {
|
|
3097
|
-
key: item.key,
|
|
3098
|
-
class: normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
|
|
3099
|
-
onClick: ($event) => _ctx.switchPage(item)
|
|
3262
|
+
canScroll.value ? (openBlock(), createElementBlock("div", {
|
|
3263
|
+
key: 0,
|
|
3264
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3265
|
+
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
3100
3266
|
}, [
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
createVNode(
|
|
3104
|
-
effect: "dark",
|
|
3105
|
-
placement: "top-start",
|
|
3106
|
-
content: item.name
|
|
3107
|
-
}, {
|
|
3108
|
-
default: withCtx(() => [
|
|
3109
|
-
createElementVNode("span", null, toDisplayString(item.name), 1)
|
|
3110
|
-
]),
|
|
3111
|
-
_: 2
|
|
3112
|
-
}, 1032, ["content"])
|
|
3113
|
-
])
|
|
3114
|
-
]),
|
|
3115
|
-
createVNode(_component_el_popover, {
|
|
3116
|
-
"popper-class": "page-bar-popover",
|
|
3117
|
-
placement: "top",
|
|
3118
|
-
width: 160,
|
|
3119
|
-
trigger: "hover"
|
|
3120
|
-
}, {
|
|
3121
|
-
reference: withCtx(() => [
|
|
3122
|
-
createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
|
|
3123
|
-
default: withCtx(() => [
|
|
3124
|
-
createVNode(_component_caret_bottom)
|
|
3125
|
-
]),
|
|
3126
|
-
_: 1
|
|
3127
|
-
})
|
|
3267
|
+
createVNode(_component_el_icon, null, {
|
|
3268
|
+
default: withCtx(() => [
|
|
3269
|
+
createVNode(unref(ArrowLeftBold))
|
|
3128
3270
|
]),
|
|
3271
|
+
_: 1
|
|
3272
|
+
})
|
|
3273
|
+
])) : createCommentVNode("", true),
|
|
3274
|
+
unref(root) ? (openBlock(), createElementBlock("div", {
|
|
3275
|
+
key: 1,
|
|
3276
|
+
class: "m-editor-page-bar-items",
|
|
3277
|
+
ref_key: "itemsContainer",
|
|
3278
|
+
ref: itemsContainer,
|
|
3279
|
+
style: normalizeStyle(`width: ${unref(itemsContainerWidth)}px`)
|
|
3280
|
+
}, [
|
|
3281
|
+
renderSlot(_ctx.$slots, "default")
|
|
3282
|
+
], 4)) : createCommentVNode("", true),
|
|
3283
|
+
canScroll.value ? (openBlock(), createElementBlock("div", {
|
|
3284
|
+
key: 2,
|
|
3285
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3286
|
+
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
3287
|
+
}, [
|
|
3288
|
+
createVNode(_component_el_icon, null, {
|
|
3129
3289
|
default: withCtx(() => [
|
|
3130
|
-
|
|
3131
|
-
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3132
|
-
createVNode(_component_tool_button, {
|
|
3133
|
-
data: {
|
|
3134
|
-
type: "button",
|
|
3135
|
-
text: "\u590D\u5236",
|
|
3136
|
-
icon: _ctx.DocumentCopy,
|
|
3137
|
-
handler: () => _ctx.copy(item)
|
|
3138
|
-
}
|
|
3139
|
-
}, null, 8, ["data"]),
|
|
3140
|
-
createVNode(_component_tool_button, {
|
|
3141
|
-
data: {
|
|
3142
|
-
type: "button",
|
|
3143
|
-
text: "\u5220\u9664",
|
|
3144
|
-
icon: _ctx.Delete,
|
|
3145
|
-
handler: () => _ctx.remove(item)
|
|
3146
|
-
}
|
|
3147
|
-
}, null, 8, ["data"])
|
|
3148
|
-
])
|
|
3149
|
-
])
|
|
3290
|
+
createVNode(unref(ArrowRightBold))
|
|
3150
3291
|
]),
|
|
3151
|
-
_:
|
|
3152
|
-
}
|
|
3153
|
-
]
|
|
3154
|
-
|
|
3155
|
-
], 4)) : createCommentVNode("", true),
|
|
3156
|
-
_ctx.canScroll ? (openBlock(), createElementBlock("div", {
|
|
3157
|
-
key: 2,
|
|
3158
|
-
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3159
|
-
onClick: _cache[2] || (_cache[2] = ($event) => _ctx.scroll("right"))
|
|
3160
|
-
}, [
|
|
3161
|
-
createVNode(_component_el_icon, null, {
|
|
3162
|
-
default: withCtx(() => [
|
|
3163
|
-
createVNode(_component_arrow_right_bold)
|
|
3164
|
-
]),
|
|
3165
|
-
_: 1
|
|
3166
|
-
})
|
|
3167
|
-
])) : createCommentVNode("", true)
|
|
3168
|
-
], 512);
|
|
3169
|
-
}
|
|
3170
|
-
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
|
|
3171
|
-
|
|
3172
|
-
class ScrollViewer$1 {
|
|
3173
|
-
constructor(options) {
|
|
3174
|
-
this.enter = false;
|
|
3175
|
-
this.targetEnter = false;
|
|
3176
|
-
this.keydown = false;
|
|
3177
|
-
this.zoom = 1;
|
|
3178
|
-
this.scrollLeft = 0;
|
|
3179
|
-
this.scrollTop = 0;
|
|
3180
|
-
this.x = 0;
|
|
3181
|
-
this.y = 0;
|
|
3182
|
-
this.resizeObserver = new ResizeObserver((entries) => {
|
|
3183
|
-
for (const { contentRect } of entries) {
|
|
3184
|
-
const { width, height } = contentRect;
|
|
3185
|
-
const targetRect = this.target.getBoundingClientRect();
|
|
3186
|
-
const targetWidth = targetRect.width * this.zoom;
|
|
3187
|
-
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3188
|
-
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
3189
|
-
if (targetWidth < width) {
|
|
3190
|
-
this.target._left = 0;
|
|
3191
|
-
}
|
|
3192
|
-
if (targetHeight < height) {
|
|
3193
|
-
this.target._top = 0;
|
|
3194
|
-
}
|
|
3195
|
-
this.scroll();
|
|
3196
|
-
}
|
|
3197
|
-
});
|
|
3198
|
-
this.wheelHandler = (event) => {
|
|
3199
|
-
if (this.targetEnter)
|
|
3200
|
-
return;
|
|
3201
|
-
const { deltaX, deltaY, currentTarget } = event;
|
|
3202
|
-
if (currentTarget !== this.container)
|
|
3203
|
-
return;
|
|
3204
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3205
|
-
this.scroll();
|
|
3206
|
-
this.scrollLeft = this.target._left;
|
|
3207
|
-
this.scrollTop = this.target._top;
|
|
3208
|
-
};
|
|
3209
|
-
this.mouseEnterHandler = () => {
|
|
3210
|
-
this.enter = true;
|
|
3211
|
-
};
|
|
3212
|
-
this.mouseLeaveHandler = () => {
|
|
3213
|
-
this.enter = false;
|
|
3214
|
-
};
|
|
3215
|
-
this.targetMouseEnterHandler = () => {
|
|
3216
|
-
this.targetEnter = true;
|
|
3292
|
+
_: 1
|
|
3293
|
+
})
|
|
3294
|
+
])) : createCommentVNode("", true)
|
|
3295
|
+
], 512);
|
|
3217
3296
|
};
|
|
3218
|
-
|
|
3219
|
-
|
|
3297
|
+
}
|
|
3298
|
+
});
|
|
3299
|
+
|
|
3300
|
+
const _hoisted_1$2 = ["onClick"];
|
|
3301
|
+
const _hoisted_2 = { class: "m-editor-page-bar-title" };
|
|
3302
|
+
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
3303
|
+
__name: "PageBar",
|
|
3304
|
+
setup(__props) {
|
|
3305
|
+
const services = inject("services");
|
|
3306
|
+
const editorService = services?.editorService;
|
|
3307
|
+
const root = computed(() => editorService?.get("root"));
|
|
3308
|
+
const page = computed(() => editorService?.get("page"));
|
|
3309
|
+
const switchPage = (page2) => {
|
|
3310
|
+
editorService?.select(page2);
|
|
3220
3311
|
};
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
this.x = event.clientX;
|
|
3228
|
-
this.y = event.clientY;
|
|
3229
|
-
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3230
|
-
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3312
|
+
const copy = (node) => {
|
|
3313
|
+
node && editorService?.copy(node);
|
|
3314
|
+
editorService?.paste({
|
|
3315
|
+
left: 0,
|
|
3316
|
+
top: 0
|
|
3317
|
+
});
|
|
3231
3318
|
};
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
this.y = 0;
|
|
3235
|
-
this.scrollLeft = this.target._left;
|
|
3236
|
-
this.scrollTop = this.target._top;
|
|
3237
|
-
this.removeHandler();
|
|
3319
|
+
const remove = (node) => {
|
|
3320
|
+
editorService?.remove(node);
|
|
3238
3321
|
};
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
const
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3322
|
+
return (_ctx, _cache) => {
|
|
3323
|
+
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
3324
|
+
const _component_el_icon = resolveComponent("el-icon");
|
|
3325
|
+
const _component_el_popover = resolveComponent("el-popover");
|
|
3326
|
+
return openBlock(), createBlock(_sfc_main$6, null, {
|
|
3327
|
+
default: withCtx(() => [
|
|
3328
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(root) && unref(root).items || [], (item) => {
|
|
3329
|
+
return openBlock(), createElementBlock("div", {
|
|
3330
|
+
class: normalizeClass(["m-editor-page-bar-item", { active: unref(page)?.id === item.id }]),
|
|
3331
|
+
key: item.key,
|
|
3332
|
+
onClick: ($event) => switchPage(item)
|
|
3333
|
+
}, [
|
|
3334
|
+
createElementVNode("div", _hoisted_2, [
|
|
3335
|
+
renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
|
|
3336
|
+
createVNode(_component_el_tooltip, {
|
|
3337
|
+
effect: "dark",
|
|
3338
|
+
placement: "top-start",
|
|
3339
|
+
content: item.name
|
|
3340
|
+
}, {
|
|
3341
|
+
default: withCtx(() => [
|
|
3342
|
+
createElementVNode("span", null, toDisplayString(item.name || item.id), 1)
|
|
3343
|
+
]),
|
|
3344
|
+
_: 2
|
|
3345
|
+
}, 1032, ["content"])
|
|
3346
|
+
])
|
|
3347
|
+
]),
|
|
3348
|
+
createVNode(_component_el_popover, {
|
|
3349
|
+
"popper-class": "page-bar-popover",
|
|
3350
|
+
placement: "top",
|
|
3351
|
+
width: 160,
|
|
3352
|
+
trigger: "hover"
|
|
3353
|
+
}, {
|
|
3354
|
+
reference: withCtx(() => [
|
|
3355
|
+
createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
|
|
3356
|
+
default: withCtx(() => [
|
|
3357
|
+
createVNode(unref(CaretBottom))
|
|
3358
|
+
]),
|
|
3359
|
+
_: 1
|
|
3360
|
+
})
|
|
3361
|
+
]),
|
|
3362
|
+
default: withCtx(() => [
|
|
3363
|
+
createElementVNode("div", null, [
|
|
3364
|
+
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3365
|
+
createVNode(_sfc_main$f, {
|
|
3366
|
+
data: {
|
|
3367
|
+
type: "button",
|
|
3368
|
+
text: "\u590D\u5236",
|
|
3369
|
+
icon: unref(DocumentCopy),
|
|
3370
|
+
handler: () => copy(item)
|
|
3371
|
+
}
|
|
3372
|
+
}, null, 8, ["data"]),
|
|
3373
|
+
createVNode(_sfc_main$f, {
|
|
3374
|
+
data: {
|
|
3375
|
+
type: "button",
|
|
3376
|
+
text: "\u5220\u9664",
|
|
3377
|
+
icon: unref(Delete),
|
|
3378
|
+
handler: () => remove(item)
|
|
3379
|
+
}
|
|
3380
|
+
}, null, 8, ["data"])
|
|
3381
|
+
])
|
|
3382
|
+
])
|
|
3383
|
+
]),
|
|
3384
|
+
_: 2
|
|
3385
|
+
}, 1024)
|
|
3386
|
+
], 10, _hoisted_1$2);
|
|
3387
|
+
}), 128))
|
|
3388
|
+
]),
|
|
3389
|
+
_: 3
|
|
3390
|
+
});
|
|
3246
3391
|
};
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3392
|
+
}
|
|
3393
|
+
});
|
|
3394
|
+
|
|
3395
|
+
class ScrollViewer$1 {
|
|
3396
|
+
enter = false;
|
|
3397
|
+
targetEnter = false;
|
|
3398
|
+
keydown = false;
|
|
3399
|
+
container;
|
|
3400
|
+
target;
|
|
3401
|
+
zoom = 1;
|
|
3402
|
+
scrollLeft = 0;
|
|
3403
|
+
scrollTop = 0;
|
|
3404
|
+
x = 0;
|
|
3405
|
+
y = 0;
|
|
3406
|
+
resizeObserver = new ResizeObserver((entries) => {
|
|
3407
|
+
for (const { contentRect } of entries) {
|
|
3408
|
+
const { width, height } = contentRect;
|
|
3409
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3410
|
+
const targetWidth = targetRect.width * this.zoom;
|
|
3411
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3412
|
+
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
3413
|
+
if (targetWidth < width) {
|
|
3414
|
+
this.target._left = 0;
|
|
3255
3415
|
}
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3259
|
-
};
|
|
3260
|
-
this.keyupHandler = (event) => {
|
|
3261
|
-
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3262
|
-
return;
|
|
3416
|
+
if (targetHeight < height) {
|
|
3417
|
+
this.target._top = 0;
|
|
3263
3418
|
}
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
event.preventDefault();
|
|
3269
|
-
this.removeHandler();
|
|
3270
|
-
};
|
|
3419
|
+
this.scroll();
|
|
3420
|
+
}
|
|
3421
|
+
});
|
|
3422
|
+
constructor(options) {
|
|
3271
3423
|
this.container = options.container;
|
|
3272
3424
|
this.target = options.target;
|
|
3273
3425
|
this.zoom = options.zoom;
|
|
@@ -3303,6 +3455,79 @@ class ScrollViewer$1 {
|
|
|
3303
3455
|
document.removeEventListener("mousemove", this.mousemoveHandler);
|
|
3304
3456
|
document.removeEventListener("mouseup", this.mouseupHandler);
|
|
3305
3457
|
}
|
|
3458
|
+
wheelHandler = (event) => {
|
|
3459
|
+
if (this.targetEnter)
|
|
3460
|
+
return;
|
|
3461
|
+
const { deltaX, deltaY, currentTarget } = event;
|
|
3462
|
+
if (currentTarget !== this.container)
|
|
3463
|
+
return;
|
|
3464
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3465
|
+
this.scroll();
|
|
3466
|
+
this.scrollLeft = this.target._left;
|
|
3467
|
+
this.scrollTop = this.target._top;
|
|
3468
|
+
};
|
|
3469
|
+
mouseEnterHandler = () => {
|
|
3470
|
+
this.enter = true;
|
|
3471
|
+
};
|
|
3472
|
+
mouseLeaveHandler = () => {
|
|
3473
|
+
this.enter = false;
|
|
3474
|
+
};
|
|
3475
|
+
targetMouseEnterHandler = () => {
|
|
3476
|
+
this.targetEnter = true;
|
|
3477
|
+
};
|
|
3478
|
+
targetMouseLeaveHandler = () => {
|
|
3479
|
+
this.targetEnter = false;
|
|
3480
|
+
};
|
|
3481
|
+
mousedownHandler = (event) => {
|
|
3482
|
+
if (!this.keydown)
|
|
3483
|
+
return;
|
|
3484
|
+
event.stopImmediatePropagation();
|
|
3485
|
+
event.stopPropagation();
|
|
3486
|
+
this.target.style.cursor = "grabbing";
|
|
3487
|
+
this.x = event.clientX;
|
|
3488
|
+
this.y = event.clientY;
|
|
3489
|
+
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3490
|
+
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3491
|
+
};
|
|
3492
|
+
mouseupHandler = () => {
|
|
3493
|
+
this.x = 0;
|
|
3494
|
+
this.y = 0;
|
|
3495
|
+
this.scrollLeft = this.target._left;
|
|
3496
|
+
this.scrollTop = this.target._top;
|
|
3497
|
+
this.removeHandler();
|
|
3498
|
+
};
|
|
3499
|
+
mousemoveHandler = (event) => {
|
|
3500
|
+
event.stopImmediatePropagation();
|
|
3501
|
+
event.stopPropagation();
|
|
3502
|
+
const deltaX = event.clientX - this.x;
|
|
3503
|
+
const deltaY = event.clientY - this.y;
|
|
3504
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3505
|
+
this.scroll();
|
|
3506
|
+
};
|
|
3507
|
+
keydownHandler = (event) => {
|
|
3508
|
+
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3509
|
+
event.preventDefault();
|
|
3510
|
+
event.stopImmediatePropagation();
|
|
3511
|
+
event.stopPropagation();
|
|
3512
|
+
}
|
|
3513
|
+
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3514
|
+
return;
|
|
3515
|
+
}
|
|
3516
|
+
this.keydown = true;
|
|
3517
|
+
this.target.style.cursor = "grab";
|
|
3518
|
+
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3519
|
+
};
|
|
3520
|
+
keyupHandler = (event) => {
|
|
3521
|
+
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3522
|
+
return;
|
|
3523
|
+
}
|
|
3524
|
+
event.preventDefault();
|
|
3525
|
+
event.stopImmediatePropagation();
|
|
3526
|
+
event.stopPropagation();
|
|
3527
|
+
this.keydown = false;
|
|
3528
|
+
event.preventDefault();
|
|
3529
|
+
this.removeHandler();
|
|
3530
|
+
};
|
|
3306
3531
|
setScrollOffset(deltaX, deltaY) {
|
|
3307
3532
|
const { width, height } = this.container.getBoundingClientRect();
|
|
3308
3533
|
const targetRect = this.target.getBoundingClientRect();
|
|
@@ -3363,18 +3588,19 @@ const _sfc_main$4 = defineComponent({
|
|
|
3363
3588
|
el,
|
|
3364
3589
|
style: computed(() => `
|
|
3365
3590
|
width: ${props.width}px;
|
|
3366
|
-
height: ${
|
|
3591
|
+
height: ${props.height}px;
|
|
3367
3592
|
position: absolute;
|
|
3368
3593
|
margin-top: 30px;
|
|
3369
3594
|
`)
|
|
3370
3595
|
};
|
|
3371
3596
|
}
|
|
3372
3597
|
});
|
|
3598
|
+
|
|
3373
3599
|
const _hoisted_1$1 = {
|
|
3374
3600
|
class: "m-editor-scroll-viewer-container",
|
|
3375
3601
|
ref: "container"
|
|
3376
3602
|
};
|
|
3377
|
-
function _sfc_render$
|
|
3603
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3378
3604
|
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
3379
3605
|
createElementVNode("div", {
|
|
3380
3606
|
ref: "el",
|
|
@@ -3384,170 +3610,170 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3384
3610
|
], 4)
|
|
3385
3611
|
], 512);
|
|
3386
3612
|
}
|
|
3387
|
-
|
|
3613
|
+
const ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$2]]);
|
|
3388
3614
|
|
|
3389
|
-
const _sfc_main$3 = defineComponent({
|
|
3390
|
-
|
|
3391
|
-
|
|
3615
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
3616
|
+
__name: "ViewerMenu",
|
|
3617
|
+
props: {
|
|
3618
|
+
isMultiSelect: { type: Boolean, default: false }
|
|
3619
|
+
},
|
|
3620
|
+
setup(__props, { expose }) {
|
|
3621
|
+
const props = __props;
|
|
3392
3622
|
const services = inject("services");
|
|
3393
3623
|
const editorService = services?.editorService;
|
|
3394
3624
|
const menu = ref();
|
|
3395
3625
|
const canPaste = ref(false);
|
|
3396
3626
|
const canCenter = ref(false);
|
|
3397
3627
|
const node = computed(() => editorService?.get("node"));
|
|
3628
|
+
const nodes = computed(() => editorService?.get("nodes"));
|
|
3398
3629
|
const parent = computed(() => editorService?.get("parent"));
|
|
3399
|
-
const
|
|
3630
|
+
const stage = computed(() => editorService?.get("stage"));
|
|
3400
3631
|
const stageContentMenu = inject("stageContentMenu", []);
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3632
|
+
const menuData = reactive([
|
|
3633
|
+
{
|
|
3634
|
+
type: "button",
|
|
3635
|
+
text: "\u6C34\u5E73\u5C45\u4E2D",
|
|
3636
|
+
display: () => canCenter.value,
|
|
3637
|
+
handler: () => {
|
|
3638
|
+
if (!nodes.value)
|
|
3639
|
+
return;
|
|
3640
|
+
editorService?.alignCenter(nodes.value);
|
|
3641
|
+
}
|
|
3642
|
+
},
|
|
3643
|
+
{
|
|
3644
|
+
type: "button",
|
|
3645
|
+
text: "\u590D\u5236",
|
|
3646
|
+
icon: markRaw(DocumentCopy),
|
|
3647
|
+
handler: () => {
|
|
3648
|
+
nodes.value && editorService?.copy(nodes.value);
|
|
3649
|
+
canPaste.value = true;
|
|
3650
|
+
}
|
|
3651
|
+
},
|
|
3652
|
+
{
|
|
3653
|
+
type: "button",
|
|
3654
|
+
text: "\u7C98\u8D34",
|
|
3655
|
+
display: () => canPaste.value,
|
|
3656
|
+
handler: () => {
|
|
3657
|
+
const rect = menu.value?.$el.getBoundingClientRect();
|
|
3658
|
+
const parentRect = stage.value?.container?.getBoundingClientRect();
|
|
3659
|
+
const initialLeft = (rect?.left || 0) - (parentRect?.left || 0);
|
|
3660
|
+
const initialTop = (rect?.top || 0) - (parentRect?.top || 0);
|
|
3661
|
+
if (!nodes.value || nodes.value.length === 0)
|
|
3662
|
+
return;
|
|
3663
|
+
editorService?.paste({ left: initialLeft, top: initialTop });
|
|
3664
|
+
}
|
|
3665
|
+
},
|
|
3666
|
+
{
|
|
3667
|
+
type: "divider",
|
|
3668
|
+
direction: "horizontal",
|
|
3669
|
+
display: () => {
|
|
3670
|
+
if (!node.value)
|
|
3671
|
+
return false;
|
|
3672
|
+
return !isPage(node.value);
|
|
3673
|
+
}
|
|
3674
|
+
},
|
|
3675
|
+
{
|
|
3676
|
+
type: "button",
|
|
3677
|
+
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
3678
|
+
icon: markRaw(Top),
|
|
3679
|
+
display: () => !isPage(node.value) && !props.isMultiSelect,
|
|
3680
|
+
handler: () => {
|
|
3681
|
+
editorService?.moveLayer(1);
|
|
3682
|
+
}
|
|
3683
|
+
},
|
|
3684
|
+
{
|
|
3685
|
+
type: "button",
|
|
3686
|
+
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
3687
|
+
icon: markRaw(Bottom),
|
|
3688
|
+
display: () => !isPage(node.value) && !props.isMultiSelect,
|
|
3689
|
+
handler: () => {
|
|
3690
|
+
editorService?.moveLayer(-1);
|
|
3691
|
+
}
|
|
3692
|
+
},
|
|
3693
|
+
{
|
|
3694
|
+
type: "button",
|
|
3695
|
+
text: "\u7F6E\u9876",
|
|
3696
|
+
display: () => !isPage(node.value) && !props.isMultiSelect,
|
|
3697
|
+
handler: () => {
|
|
3698
|
+
editorService?.moveLayer(LayerOffset.TOP);
|
|
3699
|
+
}
|
|
3700
|
+
},
|
|
3701
|
+
{
|
|
3702
|
+
type: "button",
|
|
3703
|
+
text: "\u7F6E\u5E95",
|
|
3704
|
+
display: () => !isPage(node.value) && !props.isMultiSelect,
|
|
3705
|
+
handler: () => {
|
|
3706
|
+
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
3707
|
+
}
|
|
3708
|
+
},
|
|
3709
|
+
{
|
|
3710
|
+
type: "divider",
|
|
3711
|
+
direction: "horizontal",
|
|
3712
|
+
display: () => !isPage(node.value) && !props.isMultiSelect
|
|
3713
|
+
},
|
|
3714
|
+
{
|
|
3715
|
+
type: "button",
|
|
3716
|
+
text: "\u5220\u9664",
|
|
3717
|
+
icon: Delete,
|
|
3718
|
+
display: () => !isPage(node.value),
|
|
3719
|
+
handler: () => {
|
|
3720
|
+
nodes.value && editorService?.remove(nodes.value);
|
|
3721
|
+
}
|
|
3722
|
+
},
|
|
3723
|
+
{
|
|
3724
|
+
type: "divider",
|
|
3725
|
+
direction: "horizontal"
|
|
3726
|
+
},
|
|
3727
|
+
{
|
|
3728
|
+
type: "button",
|
|
3729
|
+
text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
|
|
3730
|
+
handler: () => {
|
|
3731
|
+
editorService?.get("stage").clearGuides();
|
|
3732
|
+
}
|
|
3733
|
+
},
|
|
3734
|
+
...stageContentMenu
|
|
3735
|
+
]);
|
|
3405
3736
|
watch(parent, async () => {
|
|
3406
3737
|
if (!parent.value || !editorService)
|
|
3407
3738
|
return canCenter.value = false;
|
|
3408
3739
|
const layout = await editorService.getLayout(parent.value);
|
|
3409
|
-
|
|
3740
|
+
const isLayoutConform = [Layout.ABSOLUTE, Layout.FIXED].includes(layout);
|
|
3741
|
+
const isTypeConform = nodes.value?.every((selectedNode) => ![NodeType.ROOT, NodeType.PAGE, "pop"].includes(`${selectedNode?.type}`));
|
|
3742
|
+
canCenter.value = isLayoutConform && !!isTypeConform;
|
|
3410
3743
|
}, { immediate: true });
|
|
3411
|
-
|
|
3412
|
-
menu
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
type: "button",
|
|
3424
|
-
text: "\u590D\u5236",
|
|
3425
|
-
icon: markRaw(DocumentCopy),
|
|
3426
|
-
handler: () => {
|
|
3427
|
-
node.value && editorService?.copy(node.value);
|
|
3428
|
-
canPaste.value = true;
|
|
3429
|
-
}
|
|
3430
|
-
},
|
|
3431
|
-
{
|
|
3432
|
-
type: "button",
|
|
3433
|
-
text: "\u7C98\u8D34",
|
|
3434
|
-
display: () => canPaste.value,
|
|
3435
|
-
handler: () => {
|
|
3436
|
-
const stage = editorService?.get("stage");
|
|
3437
|
-
const rect = menu.value?.$el.getBoundingClientRect();
|
|
3438
|
-
const parentRect = stage?.container?.getBoundingClientRect();
|
|
3439
|
-
let left = (rect?.left || 0) - (parentRect?.left || 0);
|
|
3440
|
-
let top = (rect?.top || 0) - (parentRect?.top || 0);
|
|
3441
|
-
if (node.value?.items && stage) {
|
|
3442
|
-
const parentEl = stage.renderer.contentWindow?.document.getElementById(`${node.value.id}`);
|
|
3443
|
-
const parentElRect = parentEl?.getBoundingClientRect();
|
|
3444
|
-
left = left - (parentElRect?.left || 0);
|
|
3445
|
-
top = top - (parentElRect?.top || 0);
|
|
3446
|
-
}
|
|
3447
|
-
editorService?.paste({ left, top });
|
|
3448
|
-
}
|
|
3449
|
-
},
|
|
3450
|
-
{
|
|
3451
|
-
type: "divider",
|
|
3452
|
-
direction: "horizontal",
|
|
3453
|
-
display: () => !isPage.value
|
|
3454
|
-
},
|
|
3455
|
-
{
|
|
3456
|
-
type: "button",
|
|
3457
|
-
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
3458
|
-
icon: markRaw(Top),
|
|
3459
|
-
display: () => !isPage.value,
|
|
3460
|
-
handler: () => {
|
|
3461
|
-
editorService?.moveLayer(1);
|
|
3462
|
-
}
|
|
3463
|
-
},
|
|
3464
|
-
{
|
|
3465
|
-
type: "button",
|
|
3466
|
-
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
3467
|
-
icon: markRaw(Bottom),
|
|
3468
|
-
display: () => !isPage.value,
|
|
3469
|
-
handler: () => {
|
|
3470
|
-
editorService?.moveLayer(-1);
|
|
3471
|
-
}
|
|
3472
|
-
},
|
|
3473
|
-
{
|
|
3474
|
-
type: "button",
|
|
3475
|
-
text: "\u7F6E\u9876",
|
|
3476
|
-
display: () => !isPage.value,
|
|
3477
|
-
handler: () => {
|
|
3478
|
-
editorService?.moveLayer(LayerOffset.TOP);
|
|
3479
|
-
}
|
|
3480
|
-
},
|
|
3481
|
-
{
|
|
3482
|
-
type: "button",
|
|
3483
|
-
text: "\u7F6E\u5E95",
|
|
3484
|
-
display: () => !isPage.value,
|
|
3485
|
-
handler: () => {
|
|
3486
|
-
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
3487
|
-
}
|
|
3488
|
-
},
|
|
3489
|
-
{
|
|
3490
|
-
type: "divider",
|
|
3491
|
-
direction: "horizontal",
|
|
3492
|
-
display: () => !isPage.value
|
|
3493
|
-
},
|
|
3494
|
-
{
|
|
3495
|
-
type: "button",
|
|
3496
|
-
text: "\u5220\u9664",
|
|
3497
|
-
icon: Delete,
|
|
3498
|
-
display: () => !isPage.value,
|
|
3499
|
-
handler: () => {
|
|
3500
|
-
node.value && editorService?.remove(node.value);
|
|
3501
|
-
}
|
|
3502
|
-
},
|
|
3503
|
-
{
|
|
3504
|
-
type: "divider",
|
|
3505
|
-
direction: "horizontal"
|
|
3506
|
-
},
|
|
3507
|
-
{
|
|
3508
|
-
type: "button",
|
|
3509
|
-
text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
|
|
3510
|
-
handler: () => {
|
|
3511
|
-
editorService?.get("stage").clearGuides();
|
|
3512
|
-
}
|
|
3513
|
-
},
|
|
3514
|
-
...stageContentMenu
|
|
3515
|
-
]),
|
|
3516
|
-
show(e) {
|
|
3517
|
-
menu.value?.show(e);
|
|
3518
|
-
}
|
|
3744
|
+
const show = async (e) => {
|
|
3745
|
+
menu.value?.show(e);
|
|
3746
|
+
const data = await storageService.getItem(COPY_STORAGE_KEY);
|
|
3747
|
+
canPaste.value = data !== "undefined" && !!data;
|
|
3748
|
+
};
|
|
3749
|
+
expose({ show });
|
|
3750
|
+
return (_ctx, _cache) => {
|
|
3751
|
+
return openBlock(), createBlock(_sfc_main$b, {
|
|
3752
|
+
"menu-data": menuData,
|
|
3753
|
+
ref_key: "menu",
|
|
3754
|
+
ref: menu
|
|
3755
|
+
}, null, 8, ["menu-data"]);
|
|
3519
3756
|
};
|
|
3520
3757
|
}
|
|
3521
3758
|
});
|
|
3522
|
-
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3523
|
-
const _component_content_menu = resolveComponent("content-menu");
|
|
3524
|
-
return openBlock(), createBlock(_component_content_menu, {
|
|
3525
|
-
"menu-data": _ctx.menuData,
|
|
3526
|
-
ref: "menu"
|
|
3527
|
-
}, null, 8, ["menu-data"]);
|
|
3528
|
-
}
|
|
3529
|
-
var ViewerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
|
|
3530
3759
|
|
|
3531
|
-
const _sfc_main$2 = defineComponent({
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
},
|
|
3537
|
-
setup() {
|
|
3760
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
3761
|
+
__name: "Stage",
|
|
3762
|
+
setup(__props) {
|
|
3763
|
+
let stage = null;
|
|
3764
|
+
let runtime = null;
|
|
3538
3765
|
const services = inject("services");
|
|
3539
3766
|
const stageOptions = inject("stageOptions");
|
|
3540
3767
|
const stageWrap = ref();
|
|
3541
3768
|
const stageContainer = ref();
|
|
3542
3769
|
const menu = ref();
|
|
3770
|
+
const isMultiSelect = computed(() => services?.editorService.get("nodes")?.length > 1);
|
|
3543
3771
|
const stageRect = computed(() => services?.uiService.get("stageRect"));
|
|
3544
3772
|
const uiSelectMode = computed(() => services?.uiService.get("uiSelectMode"));
|
|
3545
3773
|
const root = computed(() => services?.editorService.get("root"));
|
|
3546
3774
|
const page = computed(() => services?.editorService.get("page"));
|
|
3547
3775
|
const zoom = computed(() => services?.uiService.get("zoom") || 1);
|
|
3548
3776
|
const node = computed(() => services?.editorService.get("node"));
|
|
3549
|
-
let stage = null;
|
|
3550
|
-
let runtime = null;
|
|
3551
3777
|
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
3552
3778
|
watchEffect(() => {
|
|
3553
3779
|
if (stage)
|
|
@@ -3564,6 +3790,7 @@ const _sfc_main$2 = defineComponent({
|
|
|
3564
3790
|
isContainer: stageOptions.isContainer,
|
|
3565
3791
|
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
3566
3792
|
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
3793
|
+
containerHighlightType: stageOptions.containerHighlightType,
|
|
3567
3794
|
canSelect: (el, event, stop) => {
|
|
3568
3795
|
const elCanSelect = stageOptions.canSelect(el);
|
|
3569
3796
|
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
@@ -3587,12 +3814,17 @@ const _sfc_main$2 = defineComponent({
|
|
|
3587
3814
|
stage?.on("highlight", (el) => {
|
|
3588
3815
|
services?.editorService.highlight(el.id);
|
|
3589
3816
|
});
|
|
3817
|
+
stage?.on("multiSelect", (els) => {
|
|
3818
|
+
services?.editorService.multiSelect(els.map((el) => el.id));
|
|
3819
|
+
});
|
|
3590
3820
|
stage?.on("update", (ev) => {
|
|
3591
3821
|
if (ev.parentEl) {
|
|
3592
|
-
|
|
3822
|
+
for (const data of ev.data) {
|
|
3823
|
+
services?.editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
3824
|
+
}
|
|
3593
3825
|
return;
|
|
3594
3826
|
}
|
|
3595
|
-
services?.editorService.update({ id:
|
|
3827
|
+
services?.editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
3596
3828
|
});
|
|
3597
3829
|
stage?.on("sort", (ev) => {
|
|
3598
3830
|
services?.editorService.sort(ev.src, ev.dist);
|
|
@@ -3645,99 +3877,96 @@ const _sfc_main$2 = defineComponent({
|
|
|
3645
3877
|
resizeObserver.disconnect();
|
|
3646
3878
|
services?.editorService.set("stage", null);
|
|
3647
3879
|
});
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
e2.
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
const
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
}
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
top = e.clientY - containerRect.top + scrollTop;
|
|
3684
|
-
left = e.clientX - containerRect.left + scrollLeft;
|
|
3685
|
-
if (parentEl && doc) {
|
|
3686
|
-
const { left: parentLeft, top: parentTop } = getOffset(parentEl);
|
|
3687
|
-
left = left - calcValueByFontsize(doc, parentLeft);
|
|
3688
|
-
top = top - calcValueByFontsize(doc, parentTop);
|
|
3689
|
-
}
|
|
3880
|
+
const contextmenuHandler = (e2) => {
|
|
3881
|
+
e2.preventDefault();
|
|
3882
|
+
menu.value?.show(e2);
|
|
3883
|
+
};
|
|
3884
|
+
const dragoverHandler = (e2) => {
|
|
3885
|
+
e2.preventDefault();
|
|
3886
|
+
if (e2.dataTransfer) {
|
|
3887
|
+
e2.dataTransfer.dropEffect = "move";
|
|
3888
|
+
}
|
|
3889
|
+
};
|
|
3890
|
+
const dropHandler = async (e) => {
|
|
3891
|
+
e.preventDefault();
|
|
3892
|
+
const doc = stage?.renderer.contentWindow?.document;
|
|
3893
|
+
const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
|
|
3894
|
+
let parent = page.value;
|
|
3895
|
+
if (parentEl) {
|
|
3896
|
+
parent = services?.editorService.getNodeById(parentEl.id, false);
|
|
3897
|
+
}
|
|
3898
|
+
if (e.dataTransfer && parent && stageContainer.value && stage) {
|
|
3899
|
+
const config = eval(`(${e.dataTransfer.getData("data")})`);
|
|
3900
|
+
const layout = await services?.editorService.getLayout(parent);
|
|
3901
|
+
const containerRect = stageContainer.value.getBoundingClientRect();
|
|
3902
|
+
const { scrollTop, scrollLeft } = stage.mask;
|
|
3903
|
+
const { style = {} } = config;
|
|
3904
|
+
let top = 0;
|
|
3905
|
+
let left = 0;
|
|
3906
|
+
let position = "relative";
|
|
3907
|
+
if (layout === Layout.ABSOLUTE) {
|
|
3908
|
+
position = "absolute";
|
|
3909
|
+
top = e.clientY - containerRect.top + scrollTop;
|
|
3910
|
+
left = e.clientX - containerRect.left + scrollLeft;
|
|
3911
|
+
if (parentEl && doc) {
|
|
3912
|
+
const { left: parentLeft, top: parentTop } = getOffset(parentEl);
|
|
3913
|
+
left = left - calcValueByFontsize(doc, parentLeft);
|
|
3914
|
+
top = top - calcValueByFontsize(doc, parentTop);
|
|
3690
3915
|
}
|
|
3691
|
-
config.style = {
|
|
3692
|
-
...style,
|
|
3693
|
-
position,
|
|
3694
|
-
top,
|
|
3695
|
-
left
|
|
3696
|
-
};
|
|
3697
|
-
services?.editorService.add(config, parent);
|
|
3698
3916
|
}
|
|
3917
|
+
config.style = {
|
|
3918
|
+
...style,
|
|
3919
|
+
position,
|
|
3920
|
+
top,
|
|
3921
|
+
left
|
|
3922
|
+
};
|
|
3923
|
+
config.inputEvent = e;
|
|
3924
|
+
services?.editorService.add(config, parent);
|
|
3699
3925
|
}
|
|
3700
3926
|
};
|
|
3927
|
+
return (_ctx, _cache) => {
|
|
3928
|
+
return openBlock(), createBlock(ScrollViewer, {
|
|
3929
|
+
class: "m-editor-stage",
|
|
3930
|
+
ref_key: "stageWrap",
|
|
3931
|
+
ref: stageWrap,
|
|
3932
|
+
width: unref(stageRect)?.width,
|
|
3933
|
+
height: unref(stageRect)?.height,
|
|
3934
|
+
zoom: unref(zoom)
|
|
3935
|
+
}, {
|
|
3936
|
+
default: withCtx(() => [
|
|
3937
|
+
createElementVNode("div", {
|
|
3938
|
+
class: "m-editor-stage-container",
|
|
3939
|
+
ref_key: "stageContainer",
|
|
3940
|
+
ref: stageContainer,
|
|
3941
|
+
style: normalizeStyle(`transform: scale(${unref(zoom)})`),
|
|
3942
|
+
onContextmenu: contextmenuHandler,
|
|
3943
|
+
onDrop: dropHandler,
|
|
3944
|
+
onDragover: dragoverHandler
|
|
3945
|
+
}, null, 36),
|
|
3946
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
3947
|
+
createVNode(_sfc_main$3, {
|
|
3948
|
+
ref_key: "menu",
|
|
3949
|
+
ref: menu,
|
|
3950
|
+
"is-multi-select": unref(isMultiSelect)
|
|
3951
|
+
}, null, 8, ["is-multi-select"])
|
|
3952
|
+
]))
|
|
3953
|
+
]),
|
|
3954
|
+
_: 1
|
|
3955
|
+
}, 8, ["width", "height", "zoom"]);
|
|
3956
|
+
};
|
|
3701
3957
|
}
|
|
3702
3958
|
});
|
|
3703
|
-
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3704
|
-
const _component_viewer_menu = resolveComponent("viewer-menu");
|
|
3705
|
-
const _component_scroll_viewer = resolveComponent("scroll-viewer");
|
|
3706
|
-
return openBlock(), createBlock(_component_scroll_viewer, {
|
|
3707
|
-
class: "m-editor-stage",
|
|
3708
|
-
ref: "stageWrap",
|
|
3709
|
-
width: _ctx.stageRect?.width,
|
|
3710
|
-
height: _ctx.stageRect?.height,
|
|
3711
|
-
zoom: _ctx.zoom
|
|
3712
|
-
}, {
|
|
3713
|
-
default: withCtx(() => [
|
|
3714
|
-
createElementVNode("div", {
|
|
3715
|
-
class: "m-editor-stage-container",
|
|
3716
|
-
ref: "stageContainer",
|
|
3717
|
-
style: normalizeStyle(`transform: scale(${_ctx.zoom})`),
|
|
3718
|
-
onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
|
|
3719
|
-
onDrop: _cache[1] || (_cache[1] = (...args) => _ctx.dropHandler && _ctx.dropHandler(...args)),
|
|
3720
|
-
onDragover: _cache[2] || (_cache[2] = (...args) => _ctx.dragoverHandler && _ctx.dragoverHandler(...args))
|
|
3721
|
-
}, null, 36),
|
|
3722
|
-
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
3723
|
-
createVNode(_component_viewer_menu, { ref: "menu" }, null, 512)
|
|
3724
|
-
]))
|
|
3725
|
-
]),
|
|
3726
|
-
_: 1
|
|
3727
|
-
}, 8, ["width", "height", "zoom"]);
|
|
3728
|
-
}
|
|
3729
|
-
var MagicStage = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
|
|
3730
3959
|
|
|
3731
3960
|
const _sfc_main$1 = defineComponent({
|
|
3732
3961
|
name: "m-editor-workspace",
|
|
3733
3962
|
components: {
|
|
3734
|
-
PageBar,
|
|
3735
|
-
MagicStage
|
|
3963
|
+
PageBar: _sfc_main$5,
|
|
3964
|
+
MagicStage: _sfc_main$2
|
|
3736
3965
|
},
|
|
3737
3966
|
setup() {
|
|
3738
3967
|
const services = inject("services");
|
|
3739
3968
|
const workspace = ref();
|
|
3740
|
-
const
|
|
3969
|
+
const nodes = computed(() => services?.editorService.get("nodes"));
|
|
3741
3970
|
let keycon;
|
|
3742
3971
|
const mouseenterHandler = () => {
|
|
3743
3972
|
workspace.value?.focus();
|
|
@@ -3753,26 +3982,26 @@ const _sfc_main$1 = defineComponent({
|
|
|
3753
3982
|
const ctrl = isMac ? "meta" : "ctrl";
|
|
3754
3983
|
keycon.keyup("delete", (e) => {
|
|
3755
3984
|
e.inputEvent.preventDefault();
|
|
3756
|
-
if (!
|
|
3985
|
+
if (!nodes.value || isPage(nodes.value[0]))
|
|
3757
3986
|
return;
|
|
3758
|
-
services?.editorService.remove(
|
|
3987
|
+
services?.editorService.remove(nodes.value);
|
|
3759
3988
|
}).keyup("backspace", (e) => {
|
|
3760
3989
|
e.inputEvent.preventDefault();
|
|
3761
|
-
if (!
|
|
3990
|
+
if (!nodes.value || isPage(nodes.value[0]))
|
|
3762
3991
|
return;
|
|
3763
|
-
services?.editorService.remove(
|
|
3992
|
+
services?.editorService.remove(nodes.value);
|
|
3764
3993
|
}).keydown([ctrl, "c"], (e) => {
|
|
3765
3994
|
e.inputEvent.preventDefault();
|
|
3766
|
-
|
|
3995
|
+
nodes.value && services?.editorService.copy(nodes.value);
|
|
3767
3996
|
}).keydown([ctrl, "v"], (e) => {
|
|
3768
3997
|
e.inputEvent.preventDefault();
|
|
3769
|
-
|
|
3998
|
+
nodes.value && services?.editorService.paste({ offsetX: 10, offsetY: 10 });
|
|
3770
3999
|
}).keydown([ctrl, "x"], (e) => {
|
|
3771
4000
|
e.inputEvent.preventDefault();
|
|
3772
|
-
if (!
|
|
4001
|
+
if (!nodes.value || isPage(nodes.value[0]))
|
|
3773
4002
|
return;
|
|
3774
|
-
services?.editorService.copy(
|
|
3775
|
-
services?.editorService.remove(
|
|
4003
|
+
services?.editorService.copy(nodes.value);
|
|
4004
|
+
services?.editorService.remove(nodes.value);
|
|
3776
4005
|
}).keydown([ctrl, "z"], (e) => {
|
|
3777
4006
|
e.inputEvent.preventDefault();
|
|
3778
4007
|
services?.editorService.undo();
|
|
@@ -3834,6 +4063,7 @@ const _sfc_main$1 = defineComponent({
|
|
|
3834
4063
|
};
|
|
3835
4064
|
}
|
|
3836
4065
|
});
|
|
4066
|
+
|
|
3837
4067
|
const _hoisted_1 = {
|
|
3838
4068
|
class: "m-editor-workspace",
|
|
3839
4069
|
tabindex: "1",
|
|
@@ -3843,9 +4073,11 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3843
4073
|
const _component_magic_stage = resolveComponent("magic-stage");
|
|
3844
4074
|
const _component_page_bar = resolveComponent("page-bar");
|
|
3845
4075
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
3846
|
-
(
|
|
3847
|
-
|
|
3848
|
-
|
|
4076
|
+
renderSlot(_ctx.$slots, "stage", {}, () => [
|
|
4077
|
+
(openBlock(), createBlock(_component_magic_stage, {
|
|
4078
|
+
key: _ctx.page?.id
|
|
4079
|
+
}))
|
|
4080
|
+
]),
|
|
3849
4081
|
renderSlot(_ctx.$slots, "workspace-content"),
|
|
3850
4082
|
createVNode(_component_page_bar, null, {
|
|
3851
4083
|
"page-bar-title": withCtx(({ page }) => [
|
|
@@ -3858,14 +4090,14 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3858
4090
|
})
|
|
3859
4091
|
], 512);
|
|
3860
4092
|
}
|
|
3861
|
-
|
|
4093
|
+
const Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
3862
4094
|
|
|
3863
4095
|
class ComponentList extends BaseService {
|
|
4096
|
+
state = reactive({
|
|
4097
|
+
list: []
|
|
4098
|
+
});
|
|
3864
4099
|
constructor() {
|
|
3865
4100
|
super([]);
|
|
3866
|
-
this.state = reactive({
|
|
3867
|
-
list: []
|
|
3868
|
-
});
|
|
3869
4101
|
}
|
|
3870
4102
|
setList(componentGroupList) {
|
|
3871
4103
|
this.state.list = componentGroupList;
|
|
@@ -3874,7 +4106,7 @@ class ComponentList extends BaseService {
|
|
|
3874
4106
|
return this.state.list;
|
|
3875
4107
|
}
|
|
3876
4108
|
}
|
|
3877
|
-
|
|
4109
|
+
const componentListService = new ComponentList();
|
|
3878
4110
|
|
|
3879
4111
|
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
3880
4112
|
const MIN_LEFT_COLUMN_WIDTH = 45;
|
|
@@ -3986,13 +4218,15 @@ class Ui extends BaseService {
|
|
|
3986
4218
|
const { height, width } = stageContainerRect;
|
|
3987
4219
|
if (!width || !height)
|
|
3988
4220
|
return 1;
|
|
3989
|
-
|
|
4221
|
+
const stageWidth = stageRect.width + 30;
|
|
4222
|
+
const stageHeight = stageRect.height + 30;
|
|
4223
|
+
if (width > stageWidth && height > stageHeight) {
|
|
3990
4224
|
return 1;
|
|
3991
4225
|
}
|
|
3992
|
-
return Math.min((width -
|
|
4226
|
+
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
3993
4227
|
}
|
|
3994
4228
|
}
|
|
3995
|
-
|
|
4229
|
+
const uiService = new Ui();
|
|
3996
4230
|
|
|
3997
4231
|
const _sfc_main = defineComponent({
|
|
3998
4232
|
name: "m-editor",
|
|
@@ -4067,6 +4301,10 @@ const _sfc_main = defineComponent({
|
|
|
4067
4301
|
type: Number,
|
|
4068
4302
|
default: 800
|
|
4069
4303
|
},
|
|
4304
|
+
containerHighlightType: {
|
|
4305
|
+
type: String,
|
|
4306
|
+
default: ContainerHighlightType.DEFAULT
|
|
4307
|
+
},
|
|
4070
4308
|
stageRect: {
|
|
4071
4309
|
type: [String, Object]
|
|
4072
4310
|
},
|
|
@@ -4122,7 +4360,8 @@ const _sfc_main = defineComponent({
|
|
|
4122
4360
|
historyService,
|
|
4123
4361
|
propsService,
|
|
4124
4362
|
editorService,
|
|
4125
|
-
uiService
|
|
4363
|
+
uiService,
|
|
4364
|
+
storageService
|
|
4126
4365
|
};
|
|
4127
4366
|
provide("services", services);
|
|
4128
4367
|
provide("layerContentMenu", props.layerContentMenu);
|
|
@@ -4136,11 +4375,13 @@ const _sfc_main = defineComponent({
|
|
|
4136
4375
|
updateDragEl: props.updateDragEl,
|
|
4137
4376
|
isContainer: props.isContainer,
|
|
4138
4377
|
containerHighlightClassName: props.containerHighlightClassName,
|
|
4139
|
-
containerHighlightDuration: props.containerHighlightDuration
|
|
4378
|
+
containerHighlightDuration: props.containerHighlightDuration,
|
|
4379
|
+
containerHighlightType: props.containerHighlightType
|
|
4140
4380
|
}));
|
|
4141
4381
|
return services;
|
|
4142
4382
|
}
|
|
4143
4383
|
});
|
|
4384
|
+
|
|
4144
4385
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4145
4386
|
const _component_nav_menu = resolveComponent("nav-menu");
|
|
4146
4387
|
const _component_sidebar = resolveComponent("sidebar");
|
|
@@ -4169,6 +4410,9 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4169
4410
|
workspace: withCtx(() => [
|
|
4170
4411
|
renderSlot(_ctx.$slots, "workspace", { editorService: _ctx.editorService }, () => [
|
|
4171
4412
|
createVNode(_component_workspace, null, {
|
|
4413
|
+
stage: withCtx(() => [
|
|
4414
|
+
renderSlot(_ctx.$slots, "stage")
|
|
4415
|
+
]),
|
|
4172
4416
|
"workspace-content": withCtx(() => [
|
|
4173
4417
|
renderSlot(_ctx.$slots, "workspace-content", { editorService: _ctx.editorService })
|
|
4174
4418
|
]),
|
|
@@ -4201,23 +4445,23 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4201
4445
|
_: 3
|
|
4202
4446
|
}, 8, ["code-options"]);
|
|
4203
4447
|
}
|
|
4204
|
-
|
|
4448
|
+
const Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
4205
4449
|
|
|
4206
|
-
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}")();
|
|
4450
|
+
const index$1 = '';
|
|
4207
4451
|
|
|
4208
4452
|
const defaultInstallOpt = {};
|
|
4209
|
-
|
|
4453
|
+
const index = {
|
|
4210
4454
|
install: (app, opt) => {
|
|
4211
4455
|
const option = Object.assign(defaultInstallOpt, opt || {});
|
|
4212
4456
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
4213
4457
|
setConfig(option);
|
|
4214
4458
|
app.component(Editor.name, Editor);
|
|
4215
|
-
app.component(
|
|
4459
|
+
app.component("m-fields-ui-select", _sfc_main$l);
|
|
4216
4460
|
app.component(CodeLink.name, CodeLink);
|
|
4217
4461
|
app.component(Code.name, Code);
|
|
4218
4462
|
app.component(CodeEditor.name, CodeEditor);
|
|
4219
4463
|
}
|
|
4220
4464
|
};
|
|
4221
4465
|
|
|
4222
|
-
export { COPY_STORAGE_KEY, ComponentListPanel,
|
|
4223
|
-
//# sourceMappingURL=tmagic-editor.
|
|
4466
|
+
export { COPY_STORAGE_KEY, ComponentListPanel, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$f as ToolButton, V_GUIDE_LINE_STORAGE_KEY, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getRelativeStyle, historyService, info, isFixed, log, propsService, setConfig, setLayout, storageService, uiService, warn };
|
|
4467
|
+
//# sourceMappingURL=tmagic-editor.mjs.map
|