@tmagic/editor 1.1.0-beta.1 → 1.1.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/style.css +5 -1
- package/dist/{tmagic-editor.es.js → tmagic-editor.mjs} +1405 -1190
- package/dist/tmagic-editor.mjs.map +1 -0
- package/dist/tmagic-editor.umd.js +1420 -1204
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +21 -19
- package/src/Editor.vue +23 -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 +49 -70
- 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 +13 -4
- 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 +11 -11
- package/src/services/BaseService.ts +5 -10
- package/src/services/componentList.ts +3 -3
- package/src/services/editor.ts +197 -147
- package/src/services/events.ts +1 -1
- package/src/services/history.ts +1 -1
- package/src/services/props.ts +63 -11
- package/src/services/storage.ts +133 -0
- package/src/services/ui.ts +10 -4
- package/src/theme/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 -24
- 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 +1099 -0
- package/{dist/types/src → types}/layouts/sidebar/Sidebar.vue.d.ts +3 -5
- package/types/layouts/sidebar/TabPane.vue.d.ts +14 -0
- package/types/layouts/workspace/PageBar.vue.d.ts +54 -0
- package/types/layouts/workspace/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 +21 -14
- package/{dist/types/src → types}/services/events.d.ts +0 -0
- package/{dist/types/src → types}/services/history.d.ts +0 -0
- package/{dist/types/src → types}/services/props.d.ts +26 -2
- package/types/services/storage.d.ts +56 -0
- package/{dist/types/src → types}/services/ui.d.ts +1 -1
- package/{dist/types/src → types}/type.d.ts +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 -22
- package/{dist/types/src → types}/utils/scroll-viewer.d.ts +0 -0
- package/{dist/types/src → types}/utils/undo-redo.d.ts +0 -0
- package/dist/tmagic-editor.es.js.map +0 -1
- package/dist/types/src/components/Icon.vue.d.ts +0 -14
- package/dist/types/src/components/ScrollViewer.vue.d.ts +0 -24
- package/dist/types/src/fields/Code.vue.d.ts +0 -25
- package/dist/types/src/layouts/AddPageBox.vue.d.ts +0 -5
- package/dist/types/src/layouts/Framework.vue.d.ts +0 -24
- package/dist/types/src/layouts/NavMenu.vue.d.ts +0 -27
- package/dist/types/src/layouts/PropsPanel.vue.d.ts +0 -13
- package/dist/types/src/layouts/Resizer.vue.d.ts +0 -14
- package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +0 -16
- package/dist/types/src/layouts/sidebar/TabPane.vue.d.ts +0 -16
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +0 -8
- package/dist/types/src/shims-vue.d.ts +0 -6
- package/dist/types/src/vite-env.d.ts +0 -1
- package/src/vite-env.d.ts +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject,
|
|
1
|
+
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, createElementBlock, createVNode, unref, withCtx, withModifiers, createCommentVNode, createTextVNode, toDisplayString, watch, onMounted, onUnmounted, reactive, toRaw, createElementVNode, renderSlot, Fragment, normalizeClass, resolveDynamicComponent, markRaw, renderList, normalizeProps, mergeProps, getCurrentInstance, Teleport, nextTick, toHandlers, createSlots, provide } from 'vue';
|
|
2
2
|
import serialize from 'serialize-javascript';
|
|
3
|
-
import { Delete,
|
|
4
|
-
import { throttle, cloneDeep, mergeWith,
|
|
3
|
+
import { Delete, Close, Plus, Edit, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, ArrowDown, Files, DocumentCopy, Coin, ArrowLeftBold, 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,84 @@ 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
|
+
createVNode(_component_el_tooltip, { content: "\u6E05\u9664" }, {
|
|
203
|
+
default: withCtx(() => [
|
|
204
|
+
unref(val) ? (openBlock(), createBlock(_component_el_button, {
|
|
205
|
+
key: 0,
|
|
206
|
+
style: { "padding": "0" },
|
|
207
|
+
type: "danger",
|
|
208
|
+
icon: unref(Close),
|
|
209
|
+
text: "",
|
|
210
|
+
onClick: withModifiers(deleteHandler, ["stop"])
|
|
211
|
+
}, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
|
|
212
|
+
]),
|
|
213
|
+
_: 1
|
|
214
|
+
}),
|
|
215
|
+
createVNode(_component_el_tooltip, {
|
|
216
|
+
content: unref(val) ? unref(toName) + "_" + unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
|
|
217
|
+
}, {
|
|
218
|
+
default: withCtx(() => [
|
|
219
|
+
createVNode(_component_el_button, {
|
|
220
|
+
text: "",
|
|
221
|
+
style: { "padding": "0", "margin": "0" }
|
|
222
|
+
}, {
|
|
223
|
+
default: withCtx(() => [
|
|
224
|
+
createTextVNode(toDisplayString(unref(val) ? unref(toName) + "_" + unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1)
|
|
225
|
+
]),
|
|
226
|
+
_: 1
|
|
227
|
+
})
|
|
228
|
+
]),
|
|
229
|
+
_: 1
|
|
230
|
+
}, 8, ["content"])
|
|
231
|
+
]));
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
const UISelect_vue_vue_type_style_index_0_lang = '';
|
|
249
237
|
|
|
250
238
|
const toString = (v, language) => {
|
|
251
239
|
let value = "";
|
|
@@ -262,7 +250,7 @@ const toString = (v, language) => {
|
|
|
262
250
|
}
|
|
263
251
|
return value;
|
|
264
252
|
};
|
|
265
|
-
const _sfc_main$
|
|
253
|
+
const _sfc_main$k = defineComponent({
|
|
266
254
|
name: "magic-code-editor",
|
|
267
255
|
props: {
|
|
268
256
|
initValues: {
|
|
@@ -369,14 +357,15 @@ const _sfc_main$j = defineComponent({
|
|
|
369
357
|
};
|
|
370
358
|
}
|
|
371
359
|
});
|
|
360
|
+
|
|
372
361
|
const _hoisted_1$c = {
|
|
373
362
|
ref: "codeEditor",
|
|
374
363
|
class: "magic-code-editor"
|
|
375
364
|
};
|
|
376
|
-
function _sfc_render$
|
|
365
|
+
function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
377
366
|
return openBlock(), createElementBlock("div", _hoisted_1$c, null, 512);
|
|
378
367
|
}
|
|
379
|
-
|
|
368
|
+
const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$e]]);
|
|
380
369
|
|
|
381
370
|
let $TMAGIC_EDITOR = {};
|
|
382
371
|
const setConfig = (option) => {
|
|
@@ -385,6 +374,9 @@ const setConfig = (option) => {
|
|
|
385
374
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
386
375
|
|
|
387
376
|
class UndoRedo {
|
|
377
|
+
elementList;
|
|
378
|
+
listCursor;
|
|
379
|
+
listMaxSize;
|
|
388
380
|
constructor(listMaxSize = 200) {
|
|
389
381
|
const minListMaxSize = 2;
|
|
390
382
|
this.elementList = [];
|
|
@@ -461,17 +453,12 @@ const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethod
|
|
|
461
453
|
try {
|
|
462
454
|
let beforeArgs = args;
|
|
463
455
|
for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
|
|
464
|
-
|
|
465
|
-
if (isError(
|
|
466
|
-
throw
|
|
467
|
-
if (!Array.isArray(
|
|
468
|
-
|
|
456
|
+
beforeArgs = await beforeMethod(...beforeArgs) || [];
|
|
457
|
+
if (isError(beforeArgs))
|
|
458
|
+
throw beforeArgs;
|
|
459
|
+
if (!Array.isArray(beforeArgs)) {
|
|
460
|
+
beforeArgs = [beforeArgs];
|
|
469
461
|
}
|
|
470
|
-
beforeArgs = beforeArgs.map((v, index) => {
|
|
471
|
-
if (typeof beforeReturnValue[index] === "undefined")
|
|
472
|
-
return v;
|
|
473
|
-
return beforeReturnValue[index];
|
|
474
|
-
});
|
|
475
462
|
}
|
|
476
463
|
let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
|
|
477
464
|
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
@@ -485,12 +472,12 @@ const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethod
|
|
|
485
472
|
}
|
|
486
473
|
};
|
|
487
474
|
class BaseService extends EventEmitter {
|
|
475
|
+
pluginOptionsList = {};
|
|
476
|
+
middleware = {};
|
|
477
|
+
taskList = [];
|
|
478
|
+
doingTask = false;
|
|
488
479
|
constructor(methods = [], serialMethods = []) {
|
|
489
480
|
super();
|
|
490
|
-
this.pluginOptionsList = {};
|
|
491
|
-
this.middleware = {};
|
|
492
|
-
this.taskList = [];
|
|
493
|
-
this.doingTask = false;
|
|
494
481
|
methods.forEach((propertyName) => {
|
|
495
482
|
const scope = this;
|
|
496
483
|
const sourceMethod = scope[propertyName];
|
|
@@ -547,14 +534,14 @@ class BaseService extends EventEmitter {
|
|
|
547
534
|
}
|
|
548
535
|
|
|
549
536
|
class History extends BaseService {
|
|
537
|
+
state = reactive({
|
|
538
|
+
pageSteps: {},
|
|
539
|
+
pageId: void 0,
|
|
540
|
+
canRedo: false,
|
|
541
|
+
canUndo: false
|
|
542
|
+
});
|
|
550
543
|
constructor() {
|
|
551
544
|
super([]);
|
|
552
|
-
this.state = reactive({
|
|
553
|
-
pageSteps: {},
|
|
554
|
-
pageId: void 0,
|
|
555
|
-
canRedo: false,
|
|
556
|
-
canUndo: false
|
|
557
|
-
});
|
|
558
545
|
this.on("change", this.setCanUndoRedo);
|
|
559
546
|
}
|
|
560
547
|
reset() {
|
|
@@ -623,88 +610,88 @@ class History extends BaseService {
|
|
|
623
610
|
this.state.canUndo = undoRedo?.canUndo() || false;
|
|
624
611
|
}
|
|
625
612
|
}
|
|
626
|
-
|
|
613
|
+
const historyService = new History();
|
|
627
614
|
|
|
628
|
-
|
|
615
|
+
var Protocol = /* @__PURE__ */ ((Protocol2) => {
|
|
616
|
+
Protocol2["OBJECT"] = "object";
|
|
617
|
+
Protocol2["JSON"] = "json";
|
|
618
|
+
Protocol2["STRING"] = "string";
|
|
619
|
+
Protocol2["NUMBER"] = "number";
|
|
620
|
+
Protocol2["BOOLEAN"] = "boolean";
|
|
621
|
+
return Protocol2;
|
|
622
|
+
})(Protocol || {});
|
|
623
|
+
class WebStorage extends BaseService {
|
|
624
|
+
storage = globalThis.localStorage;
|
|
625
|
+
namespace = "tmagic";
|
|
629
626
|
constructor() {
|
|
630
|
-
super(["
|
|
631
|
-
this.state = reactive({
|
|
632
|
-
propsConfigMap: {},
|
|
633
|
-
propsValueMap: {}
|
|
634
|
-
});
|
|
627
|
+
super(["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"]);
|
|
635
628
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
this.setPropsConfig(toLine(type), configs[type]);
|
|
639
|
-
});
|
|
640
|
-
this.emit("props-configs-change");
|
|
629
|
+
async getStorage() {
|
|
630
|
+
return this.storage;
|
|
641
631
|
}
|
|
642
|
-
|
|
643
|
-
this.
|
|
632
|
+
async getNamespace() {
|
|
633
|
+
return this.namespace;
|
|
644
634
|
}
|
|
645
|
-
async
|
|
646
|
-
|
|
647
|
-
|
|
635
|
+
async clear() {
|
|
636
|
+
const storage2 = await this.getStorage();
|
|
637
|
+
storage2.clear();
|
|
638
|
+
}
|
|
639
|
+
async getItem(key, options = {}) {
|
|
640
|
+
const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
641
|
+
const { protocol = options.protocol, item } = this.getValueAndProtocol(storage.getItem(`${options.namespace || namespace}:${key}`));
|
|
642
|
+
if (item === null)
|
|
643
|
+
return null;
|
|
644
|
+
switch (protocol) {
|
|
645
|
+
case "object" /* OBJECT */:
|
|
646
|
+
return eval(`(${item})`);
|
|
647
|
+
case "json" /* JSON */:
|
|
648
|
+
return JSON.parse(item);
|
|
649
|
+
case "number" /* NUMBER */:
|
|
650
|
+
return Number(item);
|
|
651
|
+
case "boolean" /* BOOLEAN */:
|
|
652
|
+
return Boolean(item);
|
|
653
|
+
default:
|
|
654
|
+
return item;
|
|
648
655
|
}
|
|
649
|
-
return cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
|
|
650
656
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
});
|
|
657
|
+
async key(index) {
|
|
658
|
+
const storage2 = await this.getStorage();
|
|
659
|
+
return storage2.key(index);
|
|
655
660
|
}
|
|
656
|
-
|
|
657
|
-
|
|
661
|
+
async removeItem(key2, options2 = {}) {
|
|
662
|
+
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
663
|
+
storage2.removeItem(`${options2.namespace || namespace2}:${key2}`);
|
|
658
664
|
}
|
|
659
|
-
async
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
}
|
|
667
|
-
|
|
665
|
+
async setItem(key2, value, options2 = {}) {
|
|
666
|
+
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
667
|
+
let item2 = value;
|
|
668
|
+
const protocol2 = options2.protocol ? `${options2.protocol}:` : "";
|
|
669
|
+
if (typeof value === "string" /* STRING */ || typeof value === "number" /* NUMBER */) {
|
|
670
|
+
item2 = `${protocol2}${value}`;
|
|
671
|
+
} else {
|
|
672
|
+
item2 = `${protocol2}${serialize(value)}`;
|
|
673
|
+
}
|
|
674
|
+
storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
|
|
675
|
+
}
|
|
676
|
+
getValueAndProtocol(value) {
|
|
677
|
+
let protocol2 = "";
|
|
678
|
+
if (value === null) {
|
|
679
|
+
return {
|
|
680
|
+
item: value,
|
|
681
|
+
protocol: protocol2
|
|
682
|
+
};
|
|
668
683
|
}
|
|
669
|
-
const
|
|
670
|
-
|
|
684
|
+
const item2 = value.replace(new RegExp(`^(${Object.values(Protocol).join("|")})(:)(.+)`), (_$0, $1, _$2, $3) => {
|
|
685
|
+
protocol2 = $1;
|
|
686
|
+
return $3;
|
|
687
|
+
});
|
|
671
688
|
return {
|
|
672
|
-
|
|
673
|
-
|
|
689
|
+
protocol: protocol2,
|
|
690
|
+
item: item2
|
|
674
691
|
};
|
|
675
692
|
}
|
|
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
693
|
}
|
|
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();
|
|
694
|
+
const storageService = new WebStorage();
|
|
708
695
|
|
|
709
696
|
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
710
697
|
LayerOffset2["TOP"] = "top";
|
|
@@ -756,10 +743,10 @@ const getRelativeStyle = (style = {}) => ({
|
|
|
756
743
|
top: 0,
|
|
757
744
|
left: 0
|
|
758
745
|
});
|
|
759
|
-
const getMiddleTop = (
|
|
760
|
-
let height = style
|
|
761
|
-
if (!stage || typeof style
|
|
762
|
-
return style
|
|
746
|
+
const getMiddleTop = (node, parentNode, stage) => {
|
|
747
|
+
let height = node.style?.height || 0;
|
|
748
|
+
if (!stage || typeof node.style?.top !== "undefined" || !parentNode.style)
|
|
749
|
+
return node.style?.top;
|
|
763
750
|
if (!isNumber(height)) {
|
|
764
751
|
height = 0;
|
|
765
752
|
}
|
|
@@ -770,12 +757,11 @@ const getMiddleTop = (style = {}, parentNode, stage) => {
|
|
|
770
757
|
}
|
|
771
758
|
return (parentHeight - height) / 2;
|
|
772
759
|
};
|
|
773
|
-
const getInitPositionStyle = (style = {}, layout
|
|
760
|
+
const getInitPositionStyle = (style = {}, layout) => {
|
|
774
761
|
if (layout === Layout.ABSOLUTE) {
|
|
775
762
|
return {
|
|
776
763
|
...style,
|
|
777
|
-
position: "absolute"
|
|
778
|
-
top: getMiddleTop(style, parentNode, stage)
|
|
764
|
+
position: "absolute"
|
|
779
765
|
};
|
|
780
766
|
}
|
|
781
767
|
if (layout === Layout.RELATIVE) {
|
|
@@ -861,34 +847,229 @@ const fixNodeLeft = (config, parent, doc) => {
|
|
|
861
847
|
return config.style?.left;
|
|
862
848
|
const el = doc.getElementById(`${config.id}`);
|
|
863
849
|
const parentEl = doc.getElementById(`${parent.id}`);
|
|
864
|
-
|
|
850
|
+
const left = Number(config.style?.left) || 0;
|
|
851
|
+
if (el && parentEl && el.offsetWidth + left > parentEl.offsetWidth) {
|
|
865
852
|
return parentEl.offsetWidth - el.offsetWidth;
|
|
866
853
|
}
|
|
867
854
|
return config.style.left;
|
|
868
855
|
};
|
|
869
|
-
|
|
870
|
-
|
|
856
|
+
const fixNodePosition = (config, parent, stage) => {
|
|
857
|
+
if (config.style?.position !== "absolute") {
|
|
858
|
+
return config.style;
|
|
859
|
+
}
|
|
860
|
+
return {
|
|
861
|
+
...config.style || {},
|
|
862
|
+
top: getMiddleTop(config, parent, stage),
|
|
863
|
+
left: fixNodeLeft(config, parent, stage?.renderer.contentWindow?.document)
|
|
864
|
+
};
|
|
871
865
|
};
|
|
872
|
-
|
|
866
|
+
|
|
867
|
+
class Props extends BaseService {
|
|
868
|
+
state = reactive({
|
|
869
|
+
propsConfigMap: {},
|
|
870
|
+
propsValueMap: {}
|
|
871
|
+
});
|
|
872
|
+
constructor() {
|
|
873
|
+
super([
|
|
874
|
+
"setPropsConfig",
|
|
875
|
+
"getPropsConfig",
|
|
876
|
+
"setPropsValue",
|
|
877
|
+
"getPropsValue",
|
|
878
|
+
"createId",
|
|
879
|
+
"setNewItemId",
|
|
880
|
+
"getDefaultPropsValue"
|
|
881
|
+
]);
|
|
882
|
+
}
|
|
883
|
+
setPropsConfigs(configs) {
|
|
884
|
+
Object.keys(configs).forEach((type) => {
|
|
885
|
+
this.setPropsConfig(toLine(type), configs[type]);
|
|
886
|
+
});
|
|
887
|
+
this.emit("props-configs-change");
|
|
888
|
+
}
|
|
889
|
+
setPropsConfig(type, config) {
|
|
890
|
+
this.state.propsConfigMap[type] = fillConfig(Array.isArray(config) ? config : [config]);
|
|
891
|
+
}
|
|
892
|
+
async getPropsConfig(type) {
|
|
893
|
+
if (type === "area") {
|
|
894
|
+
return await this.getPropsConfig("button");
|
|
895
|
+
}
|
|
896
|
+
return cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
|
|
897
|
+
}
|
|
898
|
+
setPropsValues(values) {
|
|
899
|
+
Object.keys(values).forEach((type) => {
|
|
900
|
+
this.setPropsValue(toLine(type), values[type]);
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
setPropsValue(type, value) {
|
|
904
|
+
this.state.propsValueMap[type] = value;
|
|
905
|
+
}
|
|
906
|
+
async getPropsValue(type, { inputEvent, ...defaultValue } = {}) {
|
|
907
|
+
if (type === "area") {
|
|
908
|
+
const value = await this.getPropsValue("button");
|
|
909
|
+
value.className = "action-area";
|
|
910
|
+
value.text = "";
|
|
911
|
+
if (value.style) {
|
|
912
|
+
value.style.backgroundColor = "rgba(255, 255, 255, 0)";
|
|
913
|
+
}
|
|
914
|
+
return value;
|
|
915
|
+
}
|
|
916
|
+
const [id, defaultPropsValue, data] = await Promise.all([
|
|
917
|
+
this.createId(type),
|
|
918
|
+
this.getDefaultPropsValue(type),
|
|
919
|
+
this.setNewItemId(cloneDeep({
|
|
920
|
+
type,
|
|
921
|
+
...defaultValue
|
|
922
|
+
}))
|
|
923
|
+
]);
|
|
924
|
+
return {
|
|
925
|
+
id,
|
|
926
|
+
...defaultPropsValue,
|
|
927
|
+
...mergeWith({}, cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
guid(digit = 8) {
|
|
931
|
+
return "x".repeat(digit).replace(/[xy]/g, (c) => {
|
|
932
|
+
const r = Math.random() * 16 | 0;
|
|
933
|
+
const v = c == "x" ? r : r & 3 | 8;
|
|
934
|
+
return v.toString(16);
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
async createId(type) {
|
|
938
|
+
return `${type}_${this.guid()}`;
|
|
939
|
+
}
|
|
940
|
+
async setNewItemId(config, parent) {
|
|
941
|
+
const oldId = config.id;
|
|
942
|
+
config.id = await this.createId(config.type || "component");
|
|
943
|
+
if (isPop(config) && parent?.type === NodeType.PAGE) {
|
|
944
|
+
updatePopId(oldId, config.id, parent);
|
|
945
|
+
}
|
|
946
|
+
if (config.items && Array.isArray(config.items)) {
|
|
947
|
+
for (const item of config.items) {
|
|
948
|
+
await this.setNewItemId(item, config);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
return config;
|
|
952
|
+
}
|
|
953
|
+
async getDefaultPropsValue(type) {
|
|
954
|
+
return ["page", "container"].includes(type) ? {
|
|
955
|
+
type,
|
|
956
|
+
layout: "absolute",
|
|
957
|
+
style: {},
|
|
958
|
+
name: type,
|
|
959
|
+
items: []
|
|
960
|
+
} : {
|
|
961
|
+
type,
|
|
962
|
+
style: {},
|
|
963
|
+
name: type
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
const updatePopId = (oldId, popId, pageConfig) => {
|
|
968
|
+
pageConfig.items?.forEach((config) => {
|
|
969
|
+
if (config.pop === oldId) {
|
|
970
|
+
config.pop = popId;
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
if (config.popId === oldId) {
|
|
974
|
+
config.popId = popId;
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
if (Array.isArray(config.items)) {
|
|
978
|
+
updatePopId(oldId, popId, config);
|
|
979
|
+
}
|
|
980
|
+
});
|
|
873
981
|
};
|
|
874
|
-
const
|
|
982
|
+
const propsService = new Props();
|
|
983
|
+
|
|
984
|
+
const beforePaste = async (position, config) => {
|
|
985
|
+
if (!config[0]?.style)
|
|
986
|
+
return config;
|
|
987
|
+
const curNode = editorService.get("node");
|
|
988
|
+
const { left: referenceLeft, top: referenceTop } = config[0].style;
|
|
989
|
+
const pasteConfigs = await Promise.all(config.map(async (configItem) => {
|
|
990
|
+
const { offsetX = 0, offsetY = 0, ...positionClone } = position;
|
|
991
|
+
let pastePosition = positionClone;
|
|
992
|
+
if (!isEmpty(pastePosition) && curNode.items) {
|
|
993
|
+
pastePosition = getPositionInContainer(pastePosition, curNode.id);
|
|
994
|
+
}
|
|
995
|
+
if (pastePosition.left && configItem.style?.left) {
|
|
996
|
+
pastePosition.left = configItem.style.left - referenceLeft + pastePosition.left;
|
|
997
|
+
}
|
|
998
|
+
if (pastePosition.top && configItem.style?.top) {
|
|
999
|
+
pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
|
|
1000
|
+
}
|
|
1001
|
+
const pasteConfig = await propsService.setNewItemId(configItem, editorService.get("root"));
|
|
1002
|
+
if (pasteConfig.style) {
|
|
1003
|
+
const { left, top } = pasteConfig.style;
|
|
1004
|
+
if (typeof left === "number" || !!left && !isNaN(Number(left))) {
|
|
1005
|
+
pasteConfig.style.left = Number(left) + offsetX;
|
|
1006
|
+
}
|
|
1007
|
+
if (typeof top === "number" || !!top && !isNaN(Number(top))) {
|
|
1008
|
+
pasteConfig.style.top = Number(top) + offsetY;
|
|
1009
|
+
}
|
|
1010
|
+
pasteConfig.style = {
|
|
1011
|
+
...pasteConfig.style,
|
|
1012
|
+
...pastePosition
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
if (isPage(pasteConfig)) {
|
|
1016
|
+
pasteConfig.name = generatePageNameByApp(editorService.get("root"));
|
|
1017
|
+
}
|
|
1018
|
+
return pasteConfig;
|
|
1019
|
+
}));
|
|
1020
|
+
return pasteConfigs;
|
|
875
1021
|
};
|
|
876
|
-
const
|
|
1022
|
+
const getPositionInContainer = (position = {}, id) => {
|
|
1023
|
+
let { left = 0, top = 0 } = position;
|
|
1024
|
+
const parentEl = editorService.get("stage")?.renderer?.contentWindow?.document.getElementById(`${id}`);
|
|
1025
|
+
const parentElRect = parentEl?.getBoundingClientRect();
|
|
1026
|
+
left = left - (parentElRect?.left || 0);
|
|
1027
|
+
top = top - (parentElRect?.top || 0);
|
|
1028
|
+
return {
|
|
1029
|
+
left,
|
|
1030
|
+
top
|
|
1031
|
+
};
|
|
877
1032
|
};
|
|
878
|
-
const
|
|
1033
|
+
const getAddParent = (node) => {
|
|
1034
|
+
const curNode = editorService.get("node");
|
|
1035
|
+
let parentNode;
|
|
1036
|
+
if (isPage(node)) {
|
|
1037
|
+
parentNode = editorService.get("root");
|
|
1038
|
+
} else if (curNode.items) {
|
|
1039
|
+
parentNode = curNode;
|
|
1040
|
+
} else {
|
|
1041
|
+
parentNode = editorService.getParentById(curNode.id, false);
|
|
1042
|
+
}
|
|
1043
|
+
return parentNode;
|
|
879
1044
|
};
|
|
880
1045
|
|
|
881
1046
|
class Editor$1 extends BaseService {
|
|
1047
|
+
state = reactive({
|
|
1048
|
+
root: null,
|
|
1049
|
+
page: null,
|
|
1050
|
+
parent: null,
|
|
1051
|
+
node: null,
|
|
1052
|
+
nodes: [],
|
|
1053
|
+
stage: null,
|
|
1054
|
+
highlightNode: null,
|
|
1055
|
+
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
1056
|
+
pageLength: 0
|
|
1057
|
+
});
|
|
1058
|
+
isHistoryStateChange = false;
|
|
882
1059
|
constructor() {
|
|
883
1060
|
super([
|
|
884
1061
|
"getLayout",
|
|
885
1062
|
"select",
|
|
1063
|
+
"doAdd",
|
|
886
1064
|
"add",
|
|
1065
|
+
"doRemove",
|
|
887
1066
|
"remove",
|
|
1067
|
+
"doUpdate",
|
|
888
1068
|
"update",
|
|
889
1069
|
"sort",
|
|
890
1070
|
"copy",
|
|
891
1071
|
"paste",
|
|
1072
|
+
"duAlignCenter",
|
|
892
1073
|
"alignCenter",
|
|
893
1074
|
"moveLayer",
|
|
894
1075
|
"moveToContainer",
|
|
@@ -897,20 +1078,12 @@ class Editor$1 extends BaseService {
|
|
|
897
1078
|
"redo",
|
|
898
1079
|
"highlight"
|
|
899
1080
|
], ["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
1081
|
}
|
|
912
1082
|
set(name, value) {
|
|
913
1083
|
this.state[name] = value;
|
|
1084
|
+
if (name === "nodes") {
|
|
1085
|
+
this.set("node", value[0]);
|
|
1086
|
+
}
|
|
914
1087
|
if (name === "root") {
|
|
915
1088
|
this.state.pageLength = value?.items?.length || 0;
|
|
916
1089
|
this.emit("root-change", value);
|
|
@@ -965,9 +1138,9 @@ class Editor$1 extends BaseService {
|
|
|
965
1138
|
}
|
|
966
1139
|
return Layout.ABSOLUTE;
|
|
967
1140
|
}
|
|
968
|
-
async select(
|
|
969
|
-
const { node, page, parent } = this.selectedConfigExceptionHandler(
|
|
970
|
-
this.set("
|
|
1141
|
+
async select(config) {
|
|
1142
|
+
const { node, page, parent } = this.selectedConfigExceptionHandler(config);
|
|
1143
|
+
this.set("nodes", [node]);
|
|
971
1144
|
this.set("page", page || null);
|
|
972
1145
|
this.set("parent", parent || null);
|
|
973
1146
|
if (page) {
|
|
@@ -1007,65 +1180,83 @@ class Editor$1 extends BaseService {
|
|
|
1007
1180
|
this.get("stage")?.select(nextPage.id);
|
|
1008
1181
|
return nextPage;
|
|
1009
1182
|
}
|
|
1010
|
-
highlight(
|
|
1011
|
-
const { node } = this.selectedConfigExceptionHandler(
|
|
1183
|
+
highlight(config) {
|
|
1184
|
+
const { node } = this.selectedConfigExceptionHandler(config);
|
|
1012
1185
|
const currentHighlightNode = this.get("highlightNode");
|
|
1013
1186
|
if (currentHighlightNode === node)
|
|
1014
1187
|
return;
|
|
1015
1188
|
this.set("highlightNode", node);
|
|
1016
1189
|
}
|
|
1017
|
-
|
|
1018
|
-
const
|
|
1190
|
+
multiSelect(ids) {
|
|
1191
|
+
const nodes = [];
|
|
1192
|
+
const idsUnique = uniq(ids);
|
|
1193
|
+
idsUnique.forEach((id) => {
|
|
1194
|
+
const { node } = this.getNodeInfo(id);
|
|
1195
|
+
if (!node)
|
|
1196
|
+
return;
|
|
1197
|
+
nodes.push(node);
|
|
1198
|
+
});
|
|
1199
|
+
this.set("nodes", nodes);
|
|
1200
|
+
}
|
|
1201
|
+
async doAdd(node, parent) {
|
|
1202
|
+
const root = this.get("root");
|
|
1019
1203
|
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) {
|
|
1204
|
+
const stage = this.get("stage");
|
|
1205
|
+
if ((parent?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && node.type !== NodeType.PAGE) {
|
|
1037
1206
|
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
1038
1207
|
}
|
|
1039
|
-
|
|
1208
|
+
parent?.items?.push(node);
|
|
1209
|
+
const layout = await this.getLayout(toRaw(parent), node);
|
|
1210
|
+
node.style = getInitPositionStyle(node.style, layout);
|
|
1211
|
+
await stage?.add({
|
|
1212
|
+
config: cloneDeep(node),
|
|
1213
|
+
parent: cloneDeep(parent),
|
|
1214
|
+
parentId: parent.id,
|
|
1215
|
+
root: cloneDeep(root)
|
|
1216
|
+
});
|
|
1217
|
+
node.style = fixNodePosition(node, parent, stage);
|
|
1218
|
+
await stage?.update({ config: cloneDeep(node), parentId: parent.id, root: cloneDeep(root) });
|
|
1219
|
+
this.addModifiedNodeId(node.id);
|
|
1220
|
+
return node;
|
|
1221
|
+
}
|
|
1222
|
+
async add(addNode, parent) {
|
|
1040
1223
|
const stage = this.get("stage");
|
|
1041
|
-
const
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1224
|
+
const addNodes = [];
|
|
1225
|
+
if (!Array.isArray(addNode)) {
|
|
1226
|
+
const { type, inputEvent, ...config } = addNode;
|
|
1227
|
+
if (!type)
|
|
1228
|
+
throw new Error("\u7EC4\u4EF6\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A");
|
|
1229
|
+
addNodes.push({ ...toRaw(await propsService.getPropsValue(type, config)) });
|
|
1230
|
+
} else {
|
|
1231
|
+
addNodes.push(...addNode);
|
|
1049
1232
|
}
|
|
1050
|
-
await
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
if (
|
|
1057
|
-
|
|
1233
|
+
const newNodes = await Promise.all(addNodes.map((node) => {
|
|
1234
|
+
const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
|
|
1235
|
+
if (!parentNode)
|
|
1236
|
+
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1237
|
+
return this.doAdd(node, parentNode);
|
|
1238
|
+
}));
|
|
1239
|
+
if (newNodes.length > 1) {
|
|
1240
|
+
const newNodeIds = newNodes.map((node) => node.id);
|
|
1241
|
+
stage?.multiSelect(newNodeIds);
|
|
1242
|
+
await this.multiSelect(newNodeIds);
|
|
1243
|
+
} else {
|
|
1244
|
+
await this.select(newNodes[0]);
|
|
1245
|
+
if (isPage(newNodes[0])) {
|
|
1246
|
+
this.state.pageLength += 1;
|
|
1247
|
+
} else {
|
|
1248
|
+
stage?.select(newNodes[0].id);
|
|
1249
|
+
}
|
|
1058
1250
|
}
|
|
1059
|
-
this.
|
|
1060
|
-
|
|
1251
|
+
this.pushHistoryState();
|
|
1252
|
+
this.emit("add", newNodes);
|
|
1253
|
+
return newNodes.length > 1 ? newNodes[0] : newNodes;
|
|
1061
1254
|
}
|
|
1062
|
-
async
|
|
1063
|
-
if (!node?.id)
|
|
1064
|
-
return;
|
|
1255
|
+
async doRemove(node) {
|
|
1065
1256
|
const root = this.get("root");
|
|
1066
1257
|
if (!root)
|
|
1067
1258
|
throw new Error("\u6CA1\u6709root");
|
|
1068
|
-
const { parent, node: curNode } = this.getNodeInfo(node.id
|
|
1259
|
+
const { parent, node: curNode } = this.getNodeInfo(node.id);
|
|
1069
1260
|
if (!parent || !curNode)
|
|
1070
1261
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1071
1262
|
const index = getNodeIndex(curNode, parent);
|
|
@@ -1073,7 +1264,7 @@ class Editor$1 extends BaseService {
|
|
|
1073
1264
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1074
1265
|
parent.items?.splice(index, 1);
|
|
1075
1266
|
const stage = this.get("stage");
|
|
1076
|
-
stage?.remove({ id: node.id, root: cloneDeep(
|
|
1267
|
+
stage?.remove({ id: node.id, parentId: parent.id, root: cloneDeep(root) });
|
|
1077
1268
|
if (node.type === NodeType.PAGE) {
|
|
1078
1269
|
this.state.pageLength -= 1;
|
|
1079
1270
|
if (root.items[0]) {
|
|
@@ -1087,26 +1278,28 @@ class Editor$1 extends BaseService {
|
|
|
1087
1278
|
this.set("highlightNode", null);
|
|
1088
1279
|
this.resetModifiedNodeId();
|
|
1089
1280
|
historyService.reset();
|
|
1090
|
-
|
|
1091
|
-
return node;
|
|
1281
|
+
return;
|
|
1092
1282
|
}
|
|
1093
1283
|
} else {
|
|
1094
1284
|
await this.select(parent);
|
|
1095
1285
|
stage?.select(parent.id);
|
|
1096
1286
|
}
|
|
1097
1287
|
this.addModifiedNodeId(parent.id);
|
|
1288
|
+
}
|
|
1289
|
+
async remove(nodeOrNodeList) {
|
|
1290
|
+
const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
|
|
1291
|
+
await Promise.all(nodes.map((node) => this.doRemove(node)));
|
|
1098
1292
|
this.pushHistoryState();
|
|
1099
|
-
this.emit("remove"
|
|
1100
|
-
return node;
|
|
1293
|
+
this.emit("remove");
|
|
1101
1294
|
}
|
|
1102
|
-
async
|
|
1103
|
-
if (!
|
|
1295
|
+
async doUpdate(config) {
|
|
1296
|
+
if (!config?.id)
|
|
1104
1297
|
throw new Error("\u6CA1\u6709\u914D\u7F6E\u6216\u8005\u914D\u7F6E\u7F3A\u5C11id\u503C");
|
|
1105
|
-
const info = this.getNodeInfo(
|
|
1298
|
+
const info = this.getNodeInfo(config.id, false);
|
|
1106
1299
|
if (!info.node)
|
|
1107
|
-
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${
|
|
1300
|
+
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config.id}\u7684\u8282\u70B9`);
|
|
1108
1301
|
const node = cloneDeep(toRaw(info.node));
|
|
1109
|
-
let newConfig = await this.toggleFixedPosition(toRaw(
|
|
1302
|
+
let newConfig = await this.toggleFixedPosition(toRaw(config), node, this.get("root"));
|
|
1110
1303
|
newConfig = mergeWith(cloneDeep(node), newConfig, (objValue, srcValue) => {
|
|
1111
1304
|
if (Array.isArray(srcValue)) {
|
|
1112
1305
|
return srcValue;
|
|
@@ -1131,18 +1324,28 @@ class Editor$1 extends BaseService {
|
|
|
1131
1324
|
newConfig = setLayout(newConfig, newLayout);
|
|
1132
1325
|
}
|
|
1133
1326
|
parentNodeItems[index] = newConfig;
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
this.
|
|
1327
|
+
const nodes = this.get("nodes");
|
|
1328
|
+
const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
|
|
1329
|
+
nodes.splice(targetIndex, 1, newConfig);
|
|
1330
|
+
this.set("nodes", nodes);
|
|
1331
|
+
this.get("stage")?.update({
|
|
1332
|
+
config: cloneDeep(newConfig),
|
|
1333
|
+
parentId: parent.id,
|
|
1334
|
+
root: cloneDeep(this.get("root"))
|
|
1335
|
+
});
|
|
1138
1336
|
if (newConfig.type === NodeType.PAGE) {
|
|
1139
1337
|
this.set("page", newConfig);
|
|
1140
1338
|
}
|
|
1141
1339
|
this.addModifiedNodeId(newConfig.id);
|
|
1142
|
-
this.pushHistoryState();
|
|
1143
|
-
this.emit("update", newConfig);
|
|
1144
1340
|
return newConfig;
|
|
1145
1341
|
}
|
|
1342
|
+
async update(config) {
|
|
1343
|
+
const nodes = Array.isArray(config) ? config : [config];
|
|
1344
|
+
const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
|
|
1345
|
+
this.pushHistoryState();
|
|
1346
|
+
this.emit("update", newNodes);
|
|
1347
|
+
return newNodes.length > 1 ? newNodes[0] : newNodes;
|
|
1348
|
+
}
|
|
1146
1349
|
async sort(id1, id2) {
|
|
1147
1350
|
const node = this.get("node");
|
|
1148
1351
|
const parent = cloneDeep(toRaw(this.get("parent")));
|
|
@@ -1153,65 +1356,57 @@ class Editor$1 extends BaseService {
|
|
|
1153
1356
|
parent.items.splice(index2, 0, ...parent.items.splice(index1, 1));
|
|
1154
1357
|
await this.update(parent);
|
|
1155
1358
|
await this.select(node);
|
|
1156
|
-
this.get("stage")?.update({
|
|
1359
|
+
this.get("stage")?.update({
|
|
1360
|
+
config: cloneDeep(node),
|
|
1361
|
+
parentId: parent.id,
|
|
1362
|
+
root: cloneDeep(this.get("root"))
|
|
1363
|
+
});
|
|
1157
1364
|
this.addModifiedNodeId(parent.id);
|
|
1158
1365
|
this.pushHistoryState();
|
|
1159
1366
|
}
|
|
1160
|
-
async copy(
|
|
1161
|
-
|
|
1367
|
+
async copy(config) {
|
|
1368
|
+
await storageService.setItem(COPY_STORAGE_KEY, Array.isArray(config) ? config : [config], {
|
|
1369
|
+
protocol: Protocol.OBJECT
|
|
1370
|
+
});
|
|
1162
1371
|
}
|
|
1163
1372
|
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);
|
|
1373
|
+
const config = await storageService.getItem(COPY_STORAGE_KEY);
|
|
1374
|
+
if (!Array.isArray(config))
|
|
1173
1375
|
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);
|
|
1376
|
+
const pasteConfigs = await beforePaste(position, config);
|
|
1377
|
+
return this.add(pasteConfigs);
|
|
1186
1378
|
}
|
|
1187
|
-
async
|
|
1188
|
-
const parent = this.
|
|
1189
|
-
|
|
1190
|
-
|
|
1379
|
+
async doAlignCenter(config) {
|
|
1380
|
+
const parent = this.getParentById(config.id);
|
|
1381
|
+
if (!parent)
|
|
1382
|
+
throw new Error("\u627E\u4E0D\u5230\u7236\u8282\u70B9");
|
|
1383
|
+
const node = cloneDeep(toRaw(config));
|
|
1384
|
+
const layout = await this.getLayout(parent, node);
|
|
1191
1385
|
if (layout === Layout.RELATIVE) {
|
|
1192
|
-
return;
|
|
1386
|
+
return config;
|
|
1193
1387
|
}
|
|
1194
1388
|
if (!node.style)
|
|
1195
|
-
return;
|
|
1389
|
+
return config;
|
|
1196
1390
|
const stage = this.get("stage");
|
|
1197
1391
|
const doc = stage?.renderer.contentWindow?.document;
|
|
1198
1392
|
if (doc) {
|
|
1199
|
-
const parentEl = doc.getElementById(`${parent.id}`);
|
|
1200
1393
|
const el = doc.getElementById(`${node.id}`);
|
|
1394
|
+
const parentEl = el?.offsetParent;
|
|
1201
1395
|
if (parentEl && el) {
|
|
1202
1396
|
node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
|
|
1203
1397
|
}
|
|
1204
1398
|
} else if (parent.style && isNumber(parent.style?.width) && isNumber(node.style?.width)) {
|
|
1205
1399
|
node.style.left = (parent.style.width - node.style.width) / 2;
|
|
1206
1400
|
}
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
this.
|
|
1214
|
-
|
|
1401
|
+
return node;
|
|
1402
|
+
}
|
|
1403
|
+
async alignCenter(config) {
|
|
1404
|
+
const nodes = Array.isArray(config) ? config : [config];
|
|
1405
|
+
const stage = this.get("stage");
|
|
1406
|
+
const newNodes = await Promise.all(nodes.map((node) => this.doAlignCenter(node)));
|
|
1407
|
+
const newNode = await this.update(newNodes);
|
|
1408
|
+
await stage?.multiSelect(newNodes.map((node) => node.id));
|
|
1409
|
+
return newNode;
|
|
1215
1410
|
}
|
|
1216
1411
|
async moveLayer(offset) {
|
|
1217
1412
|
const parent = this.get("parent");
|
|
@@ -1227,28 +1422,29 @@ class Editor$1 extends BaseService {
|
|
|
1227
1422
|
}
|
|
1228
1423
|
this.get("stage")?.update({
|
|
1229
1424
|
config: cloneDeep(toRaw(parent)),
|
|
1425
|
+
parentId: parent.id,
|
|
1230
1426
|
root: cloneDeep(this.get("root"))
|
|
1231
1427
|
});
|
|
1232
1428
|
}
|
|
1233
|
-
async moveToContainer(
|
|
1234
|
-
const { node, parent } = this.getNodeInfo(
|
|
1429
|
+
async moveToContainer(config, targetId) {
|
|
1430
|
+
const { node, parent } = this.getNodeInfo(config.id, false);
|
|
1235
1431
|
const target = this.getNodeById(targetId, false);
|
|
1236
1432
|
const stage = this.get("stage");
|
|
1237
1433
|
if (node && parent && stage) {
|
|
1238
1434
|
const root = cloneDeep(this.get("root"));
|
|
1239
1435
|
const index = getNodeIndex(node, parent);
|
|
1240
1436
|
parent.items?.splice(index, 1);
|
|
1241
|
-
await stage.remove({ id: node.id, root });
|
|
1437
|
+
await stage.remove({ id: node.id, parentId: parent.id, root });
|
|
1242
1438
|
const layout = await this.getLayout(target);
|
|
1243
|
-
const newConfig = mergeWith(cloneDeep(node),
|
|
1439
|
+
const newConfig = mergeWith(cloneDeep(node), config, (objValue, srcValue) => {
|
|
1244
1440
|
if (Array.isArray(srcValue)) {
|
|
1245
1441
|
return srcValue;
|
|
1246
1442
|
}
|
|
1247
1443
|
});
|
|
1248
|
-
newConfig.style = getInitPositionStyle(newConfig.style, layout
|
|
1444
|
+
newConfig.style = getInitPositionStyle(newConfig.style, layout);
|
|
1249
1445
|
target.items.push(newConfig);
|
|
1250
1446
|
await stage.select(targetId);
|
|
1251
|
-
await stage.update({ config: cloneDeep(target), root });
|
|
1447
|
+
await stage.update({ config: cloneDeep(target), parentId: parent.id, root });
|
|
1252
1448
|
await this.select(newConfig);
|
|
1253
1449
|
stage.select(newConfig.id);
|
|
1254
1450
|
this.addModifiedNodeId(target.id);
|
|
@@ -1271,7 +1467,7 @@ class Editor$1 extends BaseService {
|
|
|
1271
1467
|
const node = toRaw(this.get("node"));
|
|
1272
1468
|
if (!node || isPage(node))
|
|
1273
1469
|
return;
|
|
1274
|
-
const { style, id } = node;
|
|
1470
|
+
const { style, id, type } = node;
|
|
1275
1471
|
if (!style || style.position !== "absolute")
|
|
1276
1472
|
return;
|
|
1277
1473
|
if (top && !isNumber(style.top))
|
|
@@ -1280,6 +1476,7 @@ class Editor$1 extends BaseService {
|
|
|
1280
1476
|
return;
|
|
1281
1477
|
this.update({
|
|
1282
1478
|
id,
|
|
1479
|
+
type,
|
|
1283
1480
|
style: {
|
|
1284
1481
|
...style,
|
|
1285
1482
|
left: Number(style.left) + left,
|
|
@@ -1291,6 +1488,7 @@ class Editor$1 extends BaseService {
|
|
|
1291
1488
|
this.removeAllListeners();
|
|
1292
1489
|
this.set("root", null);
|
|
1293
1490
|
this.set("node", null);
|
|
1491
|
+
this.set("nodes", []);
|
|
1294
1492
|
this.set("page", null);
|
|
1295
1493
|
this.set("parent", null);
|
|
1296
1494
|
}
|
|
@@ -1337,12 +1535,12 @@ class Editor$1 extends BaseService {
|
|
|
1337
1535
|
}
|
|
1338
1536
|
return newConfig;
|
|
1339
1537
|
}
|
|
1340
|
-
selectedConfigExceptionHandler(
|
|
1538
|
+
selectedConfigExceptionHandler(config) {
|
|
1341
1539
|
let id;
|
|
1342
|
-
if (typeof
|
|
1343
|
-
id =
|
|
1540
|
+
if (typeof config === "string" || typeof config === "number") {
|
|
1541
|
+
id = config;
|
|
1344
1542
|
} else {
|
|
1345
|
-
id =
|
|
1543
|
+
id = config.id;
|
|
1346
1544
|
}
|
|
1347
1545
|
if (!id) {
|
|
1348
1546
|
throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
|
|
@@ -1360,7 +1558,7 @@ class Editor$1 extends BaseService {
|
|
|
1360
1558
|
};
|
|
1361
1559
|
}
|
|
1362
1560
|
}
|
|
1363
|
-
|
|
1561
|
+
const editorService = new Editor$1();
|
|
1364
1562
|
|
|
1365
1563
|
const eventMap = reactive({});
|
|
1366
1564
|
const methodMap = reactive({});
|
|
@@ -1404,7 +1602,7 @@ class Events extends BaseService {
|
|
|
1404
1602
|
return cloneDeep(methodMap[type] || DEFAULT_METHODS);
|
|
1405
1603
|
}
|
|
1406
1604
|
}
|
|
1407
|
-
|
|
1605
|
+
const eventsService = new Events();
|
|
1408
1606
|
|
|
1409
1607
|
const fillConfig = (config = []) => [
|
|
1410
1608
|
{
|
|
@@ -1610,21 +1808,34 @@ const fillConfig = (config = []) => [
|
|
|
1610
1808
|
}
|
|
1611
1809
|
];
|
|
1612
1810
|
const DEFAULT_CONFIG = fillConfig([]);
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1811
|
+
|
|
1812
|
+
const log = (...args) => {
|
|
1813
|
+
if (process.env.NODE_ENV === "development") {
|
|
1814
|
+
console.log("magic editor: ", ...args);
|
|
1815
|
+
}
|
|
1816
|
+
};
|
|
1817
|
+
const info = (...args) => {
|
|
1818
|
+
if (process.env.NODE_ENV === "development") {
|
|
1819
|
+
console.info("magic editor: ", ...args);
|
|
1820
|
+
}
|
|
1821
|
+
};
|
|
1822
|
+
const warn = (...args) => {
|
|
1823
|
+
if (process.env.NODE_ENV === "development") {
|
|
1824
|
+
console.warn("magic editor: ", ...args);
|
|
1825
|
+
}
|
|
1826
|
+
};
|
|
1827
|
+
const debug = (...args) => {
|
|
1828
|
+
if (process.env.NODE_ENV === "development") {
|
|
1829
|
+
console.debug("magic editor: ", ...args);
|
|
1830
|
+
}
|
|
1831
|
+
};
|
|
1832
|
+
const error = (...args) => {
|
|
1833
|
+
if (process.env.NODE_ENV === "development") {
|
|
1834
|
+
console.error("magic editor: ", ...args);
|
|
1835
|
+
}
|
|
1625
1836
|
};
|
|
1626
1837
|
|
|
1627
|
-
const _sfc_main$
|
|
1838
|
+
const _sfc_main$j = defineComponent({
|
|
1628
1839
|
components: { Plus },
|
|
1629
1840
|
setup() {
|
|
1630
1841
|
const services = inject("services");
|
|
@@ -1641,10 +1852,11 @@ const _sfc_main$i = defineComponent({
|
|
|
1641
1852
|
};
|
|
1642
1853
|
}
|
|
1643
1854
|
});
|
|
1855
|
+
|
|
1644
1856
|
const _hoisted_1$b = { class: "m-editor-empty-panel" };
|
|
1645
1857
|
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
1646
|
-
const _hoisted_3$
|
|
1647
|
-
function _sfc_render$
|
|
1858
|
+
const _hoisted_3$1 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
1859
|
+
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1648
1860
|
const _component_plus = resolveComponent("plus");
|
|
1649
1861
|
const _component_el_icon = resolveComponent("el-icon");
|
|
1650
1862
|
return openBlock(), createElementBlock("div", _hoisted_1$b, [
|
|
@@ -1661,14 +1873,14 @@ function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1661
1873
|
_: 1
|
|
1662
1874
|
})
|
|
1663
1875
|
]),
|
|
1664
|
-
_hoisted_3$
|
|
1876
|
+
_hoisted_3$1
|
|
1665
1877
|
])
|
|
1666
1878
|
])
|
|
1667
1879
|
]);
|
|
1668
1880
|
}
|
|
1669
|
-
|
|
1881
|
+
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$d]]);
|
|
1670
1882
|
|
|
1671
|
-
const _sfc_main$
|
|
1883
|
+
const _sfc_main$i = defineComponent({
|
|
1672
1884
|
name: "m-editor-resize",
|
|
1673
1885
|
props: {
|
|
1674
1886
|
type: {
|
|
@@ -1710,18 +1922,19 @@ const _sfc_main$h = defineComponent({
|
|
|
1710
1922
|
};
|
|
1711
1923
|
}
|
|
1712
1924
|
});
|
|
1925
|
+
|
|
1713
1926
|
const _hoisted_1$a = {
|
|
1714
1927
|
ref: "target",
|
|
1715
1928
|
class: "m-editor-resizer"
|
|
1716
1929
|
};
|
|
1717
|
-
function _sfc_render$
|
|
1930
|
+
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1718
1931
|
return openBlock(), createElementBlock("span", _hoisted_1$a, [
|
|
1719
1932
|
renderSlot(_ctx.$slots, "default")
|
|
1720
1933
|
], 512);
|
|
1721
1934
|
}
|
|
1722
|
-
|
|
1935
|
+
const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$c]]);
|
|
1723
1936
|
|
|
1724
|
-
const _sfc_main$
|
|
1937
|
+
const _sfc_main$h = defineComponent({
|
|
1725
1938
|
components: {
|
|
1726
1939
|
AddPageBox,
|
|
1727
1940
|
Resizer
|
|
@@ -1750,12 +1963,13 @@ const _sfc_main$g = defineComponent({
|
|
|
1750
1963
|
};
|
|
1751
1964
|
}
|
|
1752
1965
|
});
|
|
1966
|
+
|
|
1753
1967
|
const _hoisted_1$9 = { class: "m-editor" };
|
|
1754
1968
|
const _hoisted_2$3 = {
|
|
1755
1969
|
key: 1,
|
|
1756
1970
|
class: "m-editor-content"
|
|
1757
1971
|
};
|
|
1758
|
-
function _sfc_render$
|
|
1972
|
+
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1759
1973
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
1760
1974
|
const _component_resizer = resolveComponent("resizer");
|
|
1761
1975
|
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
@@ -1801,9 +2015,9 @@ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1801
2015
|
]))
|
|
1802
2016
|
]);
|
|
1803
2017
|
}
|
|
1804
|
-
|
|
2018
|
+
const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$b]]);
|
|
1805
2019
|
|
|
1806
|
-
const _sfc_main$
|
|
2020
|
+
const _sfc_main$g = defineComponent({
|
|
1807
2021
|
name: "m-icon",
|
|
1808
2022
|
components: { Edit },
|
|
1809
2023
|
props: {
|
|
@@ -1817,8 +2031,9 @@ const _sfc_main$f = defineComponent({
|
|
|
1817
2031
|
};
|
|
1818
2032
|
}
|
|
1819
2033
|
});
|
|
2034
|
+
|
|
1820
2035
|
const _hoisted_1$8 = ["src"];
|
|
1821
|
-
function _sfc_render$
|
|
2036
|
+
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1822
2037
|
const _component_edit = resolveComponent("edit");
|
|
1823
2038
|
const _component_el_icon = resolveComponent("el-icon");
|
|
1824
2039
|
return !_ctx.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
|
|
@@ -1826,10 +2041,12 @@ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1826
2041
|
createVNode(_component_edit)
|
|
1827
2042
|
]),
|
|
1828
2043
|
_: 1
|
|
1829
|
-
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (openBlock(),
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
2044
|
+
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (openBlock(), createBlock(_component_el_icon, { key: 1 }, {
|
|
2045
|
+
default: withCtx(() => [
|
|
2046
|
+
createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$8)
|
|
2047
|
+
]),
|
|
2048
|
+
_: 1
|
|
2049
|
+
})) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
1833
2050
|
key: 2,
|
|
1834
2051
|
class: normalizeClass(_ctx.icon)
|
|
1835
2052
|
}, null, 2)) : (openBlock(), createBlock(_component_el_icon, { key: 3 }, {
|
|
@@ -1839,10 +2056,19 @@ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1839
2056
|
_: 1
|
|
1840
2057
|
}));
|
|
1841
2058
|
}
|
|
1842
|
-
|
|
2059
|
+
const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
|
|
1843
2060
|
|
|
1844
|
-
const
|
|
1845
|
-
|
|
2061
|
+
const _hoisted_1$7 = {
|
|
2062
|
+
key: 1,
|
|
2063
|
+
class: "menu-item-text"
|
|
2064
|
+
};
|
|
2065
|
+
const _hoisted_2$2 = {
|
|
2066
|
+
class: "menu-item-text",
|
|
2067
|
+
style: { "margin": "0 5px" }
|
|
2068
|
+
};
|
|
2069
|
+
const _hoisted_3 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2070
|
+
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
2071
|
+
__name: "ToolButton",
|
|
1846
2072
|
props: {
|
|
1847
2073
|
data: {
|
|
1848
2074
|
type: [Object, String],
|
|
@@ -1857,7 +2083,8 @@ const _sfc_main$e = defineComponent({
|
|
|
1857
2083
|
default: "click"
|
|
1858
2084
|
}
|
|
1859
2085
|
},
|
|
1860
|
-
setup(
|
|
2086
|
+
setup(__props) {
|
|
2087
|
+
const props = __props;
|
|
1861
2088
|
const services = inject("services");
|
|
1862
2089
|
const uiService = services?.uiService;
|
|
1863
2090
|
const zoom = computed(() => uiService?.get("zoom") ?? 1);
|
|
@@ -1954,176 +2181,155 @@ const _sfc_main$e = defineComponent({
|
|
|
1954
2181
|
item2.handler?.(services, event);
|
|
1955
2182
|
}
|
|
1956
2183
|
};
|
|
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
|
-
}
|
|
2184
|
+
const display = computed(() => {
|
|
2185
|
+
if (!item.value)
|
|
2186
|
+
return false;
|
|
2187
|
+
if (typeof item.value === "string")
|
|
2188
|
+
return true;
|
|
2189
|
+
if (typeof item.value.display === "function") {
|
|
2190
|
+
return item.value.display(services);
|
|
2191
|
+
}
|
|
2192
|
+
return item.value.display ?? true;
|
|
2193
|
+
});
|
|
2194
|
+
const dropdownHandler = (command) => {
|
|
2195
|
+
if (command.item.handler) {
|
|
2196
|
+
command.item.handler(services);
|
|
2000
2197
|
}
|
|
2001
2198
|
};
|
|
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, {
|
|
2199
|
+
const clickHandler = (item2, event) => {
|
|
2200
|
+
if (props.eventType !== "click")
|
|
2201
|
+
return;
|
|
2202
|
+
if (item2.type === "button") {
|
|
2203
|
+
buttonHandler(item2, event);
|
|
2204
|
+
}
|
|
2205
|
+
};
|
|
2206
|
+
const mousedownHandler = (item2, event) => {
|
|
2207
|
+
if (props.eventType !== "mousedown")
|
|
2208
|
+
return;
|
|
2209
|
+
if (item2.type === "button") {
|
|
2210
|
+
buttonHandler(item2, event);
|
|
2211
|
+
}
|
|
2212
|
+
};
|
|
2213
|
+
const mouseupHandler = (item2, event) => {
|
|
2214
|
+
if (props.eventType !== "mouseup")
|
|
2215
|
+
return;
|
|
2216
|
+
if (item2.type === "button") {
|
|
2217
|
+
buttonHandler(item2, event);
|
|
2218
|
+
}
|
|
2219
|
+
};
|
|
2220
|
+
return (_ctx, _cache) => {
|
|
2221
|
+
const _component_el_divider = resolveComponent("el-divider");
|
|
2222
|
+
const _component_tool_button = resolveComponent("tool-button", true);
|
|
2223
|
+
const _component_el_button = resolveComponent("el-button");
|
|
2224
|
+
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
2225
|
+
const _component_el_icon = resolveComponent("el-icon");
|
|
2226
|
+
const _component_el_dropdown_item = resolveComponent("el-dropdown-item");
|
|
2227
|
+
const _component_el_dropdown_menu = resolveComponent("el-dropdown-menu");
|
|
2228
|
+
const _component_el_dropdown = resolveComponent("el-dropdown");
|
|
2229
|
+
return unref(display) ? (openBlock(), createElementBlock("div", {
|
|
2046
2230
|
key: 0,
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2231
|
+
class: normalizeClass(["menu-item", unref(item).type]),
|
|
2232
|
+
onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(unref(item), $event)),
|
|
2233
|
+
onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(unref(item), $event)),
|
|
2234
|
+
onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(unref(item), $event))
|
|
2235
|
+
}, [
|
|
2236
|
+
unref(item).type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
|
|
2237
|
+
key: 0,
|
|
2238
|
+
direction: unref(item).direction || "vertical"
|
|
2239
|
+
}, 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 }, [
|
|
2240
|
+
createVNode(_component_tool_button, {
|
|
2241
|
+
data: { type: "button", icon: unref(ZoomOut), handler: zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
2242
|
+
"event-type": __props.eventType
|
|
2243
|
+
}, null, 8, ["data", "event-type"]),
|
|
2244
|
+
createElementVNode("span", _hoisted_2$2, toDisplayString(parseInt(`${unref(zoom) * 100}`, 10)) + "%", 1),
|
|
2245
|
+
createVNode(_component_tool_button, {
|
|
2246
|
+
data: { type: "button", icon: unref(ZoomIn), handler: zoomInHandler, tooltip: "\u653E\u5927" },
|
|
2247
|
+
"event-type": __props.eventType
|
|
2248
|
+
}, null, 8, ["data", "event-type"])
|
|
2249
|
+
], 64)) : unref(item).type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
2250
|
+
unref(item).tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
2251
|
+
key: 0,
|
|
2252
|
+
effect: "dark",
|
|
2253
|
+
placement: "bottom-start",
|
|
2254
|
+
content: unref(item).tooltip
|
|
2255
|
+
}, {
|
|
2256
|
+
default: withCtx(() => [
|
|
2257
|
+
createVNode(_component_el_button, {
|
|
2258
|
+
size: "small",
|
|
2259
|
+
text: "",
|
|
2260
|
+
disabled: unref(disabled)
|
|
2261
|
+
}, {
|
|
2262
|
+
default: withCtx(() => [
|
|
2263
|
+
unref(item).icon ? (openBlock(), createBlock(MIcon, {
|
|
2264
|
+
key: 0,
|
|
2265
|
+
icon: unref(item).icon
|
|
2266
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
2267
|
+
createElementVNode("span", null, toDisplayString(unref(item).text), 1)
|
|
2268
|
+
]),
|
|
2269
|
+
_: 1
|
|
2270
|
+
}, 8, ["disabled"])
|
|
2271
|
+
]),
|
|
2272
|
+
_: 1
|
|
2273
|
+
}, 8, ["content"])) : (openBlock(), createBlock(_component_el_button, {
|
|
2274
|
+
key: 1,
|
|
2053
2275
|
size: "small",
|
|
2054
2276
|
text: "",
|
|
2055
|
-
disabled:
|
|
2277
|
+
disabled: unref(disabled)
|
|
2056
2278
|
}, {
|
|
2057
2279
|
default: withCtx(() => [
|
|
2058
|
-
|
|
2280
|
+
unref(item).icon ? (openBlock(), createBlock(MIcon, {
|
|
2059
2281
|
key: 0,
|
|
2060
|
-
icon:
|
|
2282
|
+
icon: unref(item).icon
|
|
2061
2283
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
2062
|
-
createElementVNode("span", null, toDisplayString(
|
|
2284
|
+
createElementVNode("span", null, toDisplayString(unref(item).text), 1)
|
|
2063
2285
|
]),
|
|
2064
2286
|
_: 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 }, {
|
|
2287
|
+
}, 8, ["disabled"]))
|
|
2288
|
+
], 64)) : unref(item).type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
|
|
2289
|
+
key: 4,
|
|
2290
|
+
trigger: "click",
|
|
2291
|
+
disabled: unref(disabled),
|
|
2292
|
+
onCommand: dropdownHandler
|
|
2293
|
+
}, {
|
|
2294
|
+
dropdown: withCtx(() => [
|
|
2295
|
+
unref(item).items && unref(item).items.length ? (openBlock(), createBlock(_component_el_dropdown_menu, { key: 0 }, {
|
|
2296
|
+
default: withCtx(() => [
|
|
2297
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(item).items, (subItem, index) => {
|
|
2298
|
+
return openBlock(), createBlock(_component_el_dropdown_item, {
|
|
2299
|
+
key: index,
|
|
2300
|
+
command: { item: unref(item), subItem }
|
|
2301
|
+
}, {
|
|
2302
|
+
default: withCtx(() => [
|
|
2303
|
+
createTextVNode(toDisplayString(subItem.text), 1)
|
|
2304
|
+
]),
|
|
2305
|
+
_: 2
|
|
2306
|
+
}, 1032, ["command"]);
|
|
2307
|
+
}), 128))
|
|
2308
|
+
]),
|
|
2309
|
+
_: 1
|
|
2310
|
+
})) : createCommentVNode("", true)
|
|
2311
|
+
]),
|
|
2091
2312
|
default: withCtx(() => [
|
|
2092
|
-
(
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
command: { item: _ctx.item, subItem }
|
|
2096
|
-
}, {
|
|
2313
|
+
createElementVNode("span", _hoisted_3, [
|
|
2314
|
+
createTextVNode(toDisplayString(unref(item).text), 1),
|
|
2315
|
+
createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2097
2316
|
default: withCtx(() => [
|
|
2098
|
-
|
|
2317
|
+
createVNode(unref(ArrowDown))
|
|
2099
2318
|
]),
|
|
2100
|
-
_:
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2319
|
+
_: 1
|
|
2320
|
+
})
|
|
2321
|
+
])
|
|
2103
2322
|
]),
|
|
2104
2323
|
_: 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]]);
|
|
2324
|
+
}, 8, ["disabled"])) : unref(item).type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(unref(item).component), normalizeProps(mergeProps({ key: 5 }, unref(item).props || {})), null, 16)) : createCommentVNode("", true)
|
|
2325
|
+
], 34)) : createCommentVNode("", true);
|
|
2326
|
+
};
|
|
2327
|
+
}
|
|
2328
|
+
});
|
|
2123
2329
|
|
|
2124
|
-
const _sfc_main$
|
|
2330
|
+
const _sfc_main$e = defineComponent({
|
|
2125
2331
|
name: "nav-menu",
|
|
2126
|
-
components: { ToolButton },
|
|
2332
|
+
components: { ToolButton: _sfc_main$f },
|
|
2127
2333
|
props: {
|
|
2128
2334
|
data: {
|
|
2129
2335
|
type: Object,
|
|
@@ -2141,7 +2347,8 @@ const _sfc_main$d = defineComponent({
|
|
|
2141
2347
|
};
|
|
2142
2348
|
}
|
|
2143
2349
|
});
|
|
2144
|
-
|
|
2350
|
+
|
|
2351
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2145
2352
|
const _component_tool_button = resolveComponent("tool-button");
|
|
2146
2353
|
return openBlock(), createElementBlock("div", {
|
|
2147
2354
|
class: "m-editor-nav-menu",
|
|
@@ -2163,9 +2370,9 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2163
2370
|
}), 128))
|
|
2164
2371
|
], 4);
|
|
2165
2372
|
}
|
|
2166
|
-
|
|
2373
|
+
const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
|
|
2167
2374
|
|
|
2168
|
-
const _sfc_main$
|
|
2375
|
+
const _sfc_main$d = defineComponent({
|
|
2169
2376
|
name: "m-editor-props-panel",
|
|
2170
2377
|
emits: ["mounted"],
|
|
2171
2378
|
setup(props, { emit }) {
|
|
@@ -2212,8 +2419,9 @@ const _sfc_main$c = defineComponent({
|
|
|
2212
2419
|
};
|
|
2213
2420
|
}
|
|
2214
2421
|
});
|
|
2422
|
+
|
|
2215
2423
|
const _hoisted_1$6 = { class: "`m-editor-props-panel" };
|
|
2216
|
-
function _sfc_render$
|
|
2424
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2217
2425
|
const _component_m_form = resolveComponent("m-form");
|
|
2218
2426
|
return openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
2219
2427
|
renderSlot(_ctx.$slots, "props-panel-header"),
|
|
@@ -2228,9 +2436,9 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2228
2436
|
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
|
|
2229
2437
|
]);
|
|
2230
2438
|
}
|
|
2231
|
-
|
|
2439
|
+
const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
|
|
2232
2440
|
|
|
2233
|
-
const _sfc_main$
|
|
2441
|
+
const _sfc_main$c = defineComponent({
|
|
2234
2442
|
name: "ui-component-panel",
|
|
2235
2443
|
components: { MIcon },
|
|
2236
2444
|
setup() {
|
|
@@ -2289,27 +2497,17 @@ const _sfc_main$b = defineComponent({
|
|
|
2289
2497
|
}
|
|
2290
2498
|
return;
|
|
2291
2499
|
}
|
|
2292
|
-
if (timeout)
|
|
2500
|
+
if (timeout || !stage.value)
|
|
2293
2501
|
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);
|
|
2502
|
+
timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
|
|
2306
2503
|
}
|
|
2307
2504
|
};
|
|
2308
2505
|
}
|
|
2309
2506
|
});
|
|
2507
|
+
|
|
2310
2508
|
const _hoisted_1$5 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
2311
2509
|
const _hoisted_2$1 = ["onClick", "onDragstart"];
|
|
2312
|
-
function _sfc_render$
|
|
2510
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2313
2511
|
const _component_el_input = resolveComponent("el-input");
|
|
2314
2512
|
const _component_m_icon = resolveComponent("m-icon");
|
|
2315
2513
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
@@ -2381,22 +2579,17 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2381
2579
|
_: 3
|
|
2382
2580
|
});
|
|
2383
2581
|
}
|
|
2384
|
-
|
|
2582
|
+
const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
|
|
2385
2583
|
|
|
2386
|
-
const _sfc_main$
|
|
2387
|
-
|
|
2584
|
+
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
2585
|
+
__name: "ContentMenu",
|
|
2388
2586
|
props: {
|
|
2389
|
-
menuData: {
|
|
2390
|
-
|
|
2391
|
-
default: () => []
|
|
2392
|
-
},
|
|
2393
|
-
isSubMenu: {
|
|
2394
|
-
type: Boolean,
|
|
2395
|
-
default: false
|
|
2396
|
-
}
|
|
2587
|
+
menuData: { default: () => [] },
|
|
2588
|
+
isSubMenu: { type: Boolean, default: false }
|
|
2397
2589
|
},
|
|
2398
2590
|
emits: ["hide", "show"],
|
|
2399
|
-
setup(
|
|
2591
|
+
setup(__props, { expose, emit }) {
|
|
2592
|
+
const props = __props;
|
|
2400
2593
|
const menu = ref();
|
|
2401
2594
|
const subMenu = ref();
|
|
2402
2595
|
const visible = ref(false);
|
|
@@ -2422,6 +2615,36 @@ const _sfc_main$a = defineComponent({
|
|
|
2422
2615
|
}
|
|
2423
2616
|
hide();
|
|
2424
2617
|
};
|
|
2618
|
+
const show = (e) => {
|
|
2619
|
+
setTimeout(() => {
|
|
2620
|
+
visible.value = true;
|
|
2621
|
+
nextTick(() => {
|
|
2622
|
+
const menuHeight = menu.value?.clientHeight || 0;
|
|
2623
|
+
let top = e.clientY;
|
|
2624
|
+
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
2625
|
+
top = document.body.clientHeight - menuHeight;
|
|
2626
|
+
}
|
|
2627
|
+
menuStyle.value = {
|
|
2628
|
+
top: `${top}px`,
|
|
2629
|
+
left: `${e.clientX}px`
|
|
2630
|
+
};
|
|
2631
|
+
emit("show");
|
|
2632
|
+
});
|
|
2633
|
+
}, 300);
|
|
2634
|
+
};
|
|
2635
|
+
const showSubMenu = (item) => {
|
|
2636
|
+
const menuItem = item;
|
|
2637
|
+
if (typeof item !== "object" || !menuItem.items?.length) {
|
|
2638
|
+
return;
|
|
2639
|
+
}
|
|
2640
|
+
subMenuData.value = menuItem.items;
|
|
2641
|
+
if (menu.value) {
|
|
2642
|
+
subMenu.value.show({
|
|
2643
|
+
clientX: menu.value.offsetLeft + menu.value.clientWidth,
|
|
2644
|
+
clientY: menu.value.offsetTop
|
|
2645
|
+
});
|
|
2646
|
+
}
|
|
2647
|
+
};
|
|
2425
2648
|
onMounted(() => {
|
|
2426
2649
|
if (props.isSubMenu)
|
|
2427
2650
|
return;
|
|
@@ -2432,81 +2655,47 @@ const _sfc_main$a = defineComponent({
|
|
|
2432
2655
|
return;
|
|
2433
2656
|
globalThis.removeEventListener("mousedown", hideHandler, true);
|
|
2434
2657
|
});
|
|
2435
|
-
|
|
2436
|
-
menu,
|
|
2437
|
-
subMenu,
|
|
2438
|
-
visible,
|
|
2439
|
-
menuStyle,
|
|
2440
|
-
subMenuData,
|
|
2658
|
+
expose({
|
|
2441
2659
|
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
|
-
|
|
2660
|
+
show
|
|
2661
|
+
});
|
|
2662
|
+
return (_ctx, _cache) => {
|
|
2663
|
+
const _component_content_menu = resolveComponent("content-menu", true);
|
|
2664
|
+
return __props.menuData.length && visible.value ? (openBlock(), createElementBlock("div", {
|
|
2665
|
+
key: 0,
|
|
2666
|
+
class: "magic-editor-content-menu",
|
|
2667
|
+
ref_key: "menu",
|
|
2668
|
+
ref: menu,
|
|
2669
|
+
style: normalizeStyle(menuStyle.value)
|
|
2670
|
+
}, [
|
|
2671
|
+
createElementVNode("div", null, [
|
|
2672
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.menuData, (item, index) => {
|
|
2673
|
+
return openBlock(), createBlock(_sfc_main$f, {
|
|
2674
|
+
"event-type": "mouseup",
|
|
2675
|
+
data: item,
|
|
2676
|
+
key: index,
|
|
2677
|
+
onMouseup: hide,
|
|
2678
|
+
onMouseenter: ($event) => showSubMenu(item)
|
|
2679
|
+
}, null, 8, ["data", "onMouseenter"]);
|
|
2680
|
+
}), 128))
|
|
2681
|
+
]),
|
|
2682
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
2683
|
+
createVNode(_component_content_menu, {
|
|
2684
|
+
class: "sub-menu",
|
|
2685
|
+
ref_key: "subMenu",
|
|
2686
|
+
ref: subMenu,
|
|
2687
|
+
"menu-data": subMenuData.value,
|
|
2688
|
+
"is-sub-menu": true,
|
|
2689
|
+
onHide: hide
|
|
2690
|
+
}, null, 8, ["menu-data"])
|
|
2691
|
+
]))
|
|
2692
|
+
], 4)) : createCommentVNode("", true);
|
|
2472
2693
|
};
|
|
2473
2694
|
}
|
|
2474
2695
|
});
|
|
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
2696
|
|
|
2508
|
-
const _sfc_main$
|
|
2509
|
-
components: { ContentMenu },
|
|
2697
|
+
const _sfc_main$a = defineComponent({
|
|
2698
|
+
components: { ContentMenu: _sfc_main$b },
|
|
2510
2699
|
setup() {
|
|
2511
2700
|
const services = inject("services");
|
|
2512
2701
|
const menu = ref();
|
|
@@ -2588,7 +2777,8 @@ const _sfc_main$9 = defineComponent({
|
|
|
2588
2777
|
};
|
|
2589
2778
|
}
|
|
2590
2779
|
});
|
|
2591
|
-
|
|
2780
|
+
|
|
2781
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2592
2782
|
const _component_content_menu = resolveComponent("content-menu");
|
|
2593
2783
|
return openBlock(), createBlock(_component_content_menu, {
|
|
2594
2784
|
"menu-data": _ctx.menuData,
|
|
@@ -2596,7 +2786,7 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2596
2786
|
style: { "overflow": "initial" }
|
|
2597
2787
|
}, null, 8, ["menu-data"]);
|
|
2598
2788
|
}
|
|
2599
|
-
|
|
2789
|
+
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$6]]);
|
|
2600
2790
|
|
|
2601
2791
|
const throttleTime = 150;
|
|
2602
2792
|
const select = async (data, editorService) => {
|
|
@@ -2630,9 +2820,17 @@ const useDrop = (tree, editorService) => ({
|
|
|
2630
2820
|
return true;
|
|
2631
2821
|
return false;
|
|
2632
2822
|
},
|
|
2633
|
-
handleDragEnd() {
|
|
2823
|
+
async handleDragEnd(e) {
|
|
2634
2824
|
if (!tree.value)
|
|
2635
2825
|
return;
|
|
2826
|
+
const { data: node } = e;
|
|
2827
|
+
const parent = editorService?.getParentById(node.id, false);
|
|
2828
|
+
const layout = await editorService?.getLayout(parent);
|
|
2829
|
+
node.style.position = layout;
|
|
2830
|
+
if (layout === Layout.RELATIVE) {
|
|
2831
|
+
node.style.top = 0;
|
|
2832
|
+
node.style.left = 0;
|
|
2833
|
+
}
|
|
2636
2834
|
const { data } = tree.value;
|
|
2637
2835
|
const [page] = data;
|
|
2638
2836
|
editorService?.update(page);
|
|
@@ -2688,7 +2886,7 @@ const useFilter = (tree) => ({
|
|
|
2688
2886
|
tree.value?.filter(val);
|
|
2689
2887
|
}
|
|
2690
2888
|
});
|
|
2691
|
-
const _sfc_main$
|
|
2889
|
+
const _sfc_main$9 = defineComponent({
|
|
2692
2890
|
name: "magic-editor-layer-panel",
|
|
2693
2891
|
components: { LayerMenu },
|
|
2694
2892
|
setup() {
|
|
@@ -2735,8 +2933,9 @@ const _sfc_main$8 = defineComponent({
|
|
|
2735
2933
|
};
|
|
2736
2934
|
}
|
|
2737
2935
|
});
|
|
2936
|
+
|
|
2738
2937
|
const _hoisted_1$4 = ["id", "onMouseenter"];
|
|
2739
|
-
function _sfc_render$
|
|
2938
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2740
2939
|
const _component_el_input = resolveComponent("el-input");
|
|
2741
2940
|
const _component_el_tree = resolveComponent("el-tree");
|
|
2742
2941
|
const _component_layer_menu = resolveComponent("layer-menu");
|
|
@@ -2798,9 +2997,9 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2798
2997
|
_: 3
|
|
2799
2998
|
});
|
|
2800
2999
|
}
|
|
2801
|
-
|
|
3000
|
+
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$5]]);
|
|
2802
3001
|
|
|
2803
|
-
const _sfc_main$
|
|
3002
|
+
const _sfc_main$8 = defineComponent({
|
|
2804
3003
|
components: { MIcon },
|
|
2805
3004
|
props: {
|
|
2806
3005
|
data: {
|
|
@@ -2837,11 +3036,12 @@ const _sfc_main$7 = defineComponent({
|
|
|
2837
3036
|
};
|
|
2838
3037
|
}
|
|
2839
3038
|
});
|
|
3039
|
+
|
|
2840
3040
|
const _hoisted_1$3 = {
|
|
2841
3041
|
key: 1,
|
|
2842
3042
|
class: "magic-editor-tab-panel-title"
|
|
2843
3043
|
};
|
|
2844
|
-
function _sfc_render$
|
|
3044
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2845
3045
|
const _component_m_icon = resolveComponent("m-icon");
|
|
2846
3046
|
const _component_el_tab_pane = resolveComponent("el-tab-pane");
|
|
2847
3047
|
return _ctx.config ? (openBlock(), createBlock(_component_el_tab_pane, {
|
|
@@ -2887,9 +3087,9 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2887
3087
|
_: 3
|
|
2888
3088
|
}, 8, ["name"])) : createCommentVNode("", true);
|
|
2889
3089
|
}
|
|
2890
|
-
|
|
3090
|
+
const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$4]]);
|
|
2891
3091
|
|
|
2892
|
-
const _sfc_main$
|
|
3092
|
+
const _sfc_main$7 = defineComponent({
|
|
2893
3093
|
components: { TabPane },
|
|
2894
3094
|
name: "m-sidebar",
|
|
2895
3095
|
props: {
|
|
@@ -2908,7 +3108,8 @@ const _sfc_main$6 = defineComponent({
|
|
|
2908
3108
|
};
|
|
2909
3109
|
}
|
|
2910
3110
|
});
|
|
2911
|
-
|
|
3111
|
+
|
|
3112
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2912
3113
|
const _component_tab_pane = resolveComponent("tab-pane");
|
|
2913
3114
|
const _component_el_tabs = resolveComponent("el-tabs");
|
|
2914
3115
|
return _ctx.data.type === "tabs" && _ctx.data.items.length ? (openBlock(), createBlock(_component_el_tabs, {
|
|
@@ -2943,331 +3144,258 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2943
3144
|
_: 3
|
|
2944
3145
|
}, 8, ["modelValue"])) : createCommentVNode("", true);
|
|
2945
3146
|
}
|
|
2946
|
-
|
|
3147
|
+
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$3]]);
|
|
2947
3148
|
|
|
2948
|
-
const
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
|
|
2965
|
-
}
|
|
2966
|
-
};
|
|
2967
|
-
const scroll = (type) => {
|
|
2968
|
-
if (!itemsContainer.value)
|
|
2969
|
-
return;
|
|
2970
|
-
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
2971
|
-
if (type === "left") {
|
|
2972
|
-
translateLeft += 100;
|
|
2973
|
-
if (translateLeft > 0) {
|
|
2974
|
-
translateLeft = 0;
|
|
3149
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
3150
|
+
__name: "PageBarScrollContainer",
|
|
3151
|
+
setup(__props) {
|
|
3152
|
+
const services = inject("services");
|
|
3153
|
+
const editorService = services?.editorService;
|
|
3154
|
+
const pageBar = ref();
|
|
3155
|
+
const itemsContainer = ref();
|
|
3156
|
+
const pageBarWidth = ref(0);
|
|
3157
|
+
const canScroll = ref(false);
|
|
3158
|
+
const itemsContainerWidth = computed(() => pageBarWidth.value - 105);
|
|
3159
|
+
let translateLeft = 0;
|
|
3160
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
3161
|
+
for (const { contentRect } of entries) {
|
|
3162
|
+
const { width } = contentRect;
|
|
3163
|
+
pageBarWidth.value = width || 0;
|
|
3164
|
+
setCanScroll();
|
|
2975
3165
|
}
|
|
2976
|
-
}
|
|
2977
|
-
|
|
2978
|
-
if (
|
|
2979
|
-
|
|
3166
|
+
});
|
|
3167
|
+
const setCanScroll = () => {
|
|
3168
|
+
if (itemsContainer.value) {
|
|
3169
|
+
canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
|
|
2980
3170
|
}
|
|
2981
|
-
}
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
scroll("end");
|
|
3171
|
+
};
|
|
3172
|
+
const scroll = (type) => {
|
|
3173
|
+
if (!itemsContainer.value)
|
|
3174
|
+
return;
|
|
3175
|
+
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
3176
|
+
if (type === "left") {
|
|
3177
|
+
translateLeft += 100;
|
|
3178
|
+
if (translateLeft > 0) {
|
|
3179
|
+
translateLeft = 0;
|
|
3180
|
+
}
|
|
3181
|
+
} else if (type === "right") {
|
|
3182
|
+
translateLeft -= 100;
|
|
3183
|
+
if (-translateLeft > maxScrollLeft) {
|
|
3184
|
+
translateLeft = -maxScrollLeft;
|
|
3185
|
+
}
|
|
3186
|
+
} else if (type === "start") {
|
|
3187
|
+
translateLeft = 0;
|
|
3188
|
+
} else if (type === "end") {
|
|
3189
|
+
translateLeft = -maxScrollLeft;
|
|
3001
3190
|
}
|
|
3191
|
+
itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
|
|
3192
|
+
};
|
|
3193
|
+
onMounted(() => {
|
|
3194
|
+
pageBar.value && resizeObserver.observe(pageBar.value);
|
|
3195
|
+
});
|
|
3196
|
+
onUnmounted(() => {
|
|
3197
|
+
resizeObserver.disconnect();
|
|
3002
3198
|
});
|
|
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
3199
|
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
|
-
}
|
|
3200
|
+
watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
|
|
3201
|
+
setTimeout(() => {
|
|
3202
|
+
setCanScroll();
|
|
3203
|
+
if (length < preLength) {
|
|
3204
|
+
scroll("start");
|
|
3205
|
+
} else {
|
|
3206
|
+
scroll("end");
|
|
3207
|
+
}
|
|
3208
|
+
});
|
|
3209
|
+
});
|
|
3210
|
+
const addPage = () => {
|
|
3211
|
+
if (!editorService)
|
|
3212
|
+
return;
|
|
3213
|
+
const pageConfig = {
|
|
3214
|
+
type: NodeType.PAGE,
|
|
3215
|
+
name: generatePageNameByApp(toRaw(editorService.get("root")))
|
|
3216
|
+
};
|
|
3217
|
+
editorService.add(pageConfig);
|
|
3046
3218
|
};
|
|
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)
|
|
3219
|
+
return (_ctx, _cache) => {
|
|
3220
|
+
const _component_el_icon = resolveComponent("el-icon");
|
|
3221
|
+
return openBlock(), createElementBlock("div", {
|
|
3222
|
+
class: "m-editor-page-bar",
|
|
3223
|
+
ref_key: "pageBar",
|
|
3224
|
+
ref: pageBar
|
|
3225
|
+
}, [
|
|
3226
|
+
createElementVNode("div", {
|
|
3227
|
+
id: "m-editor-page-bar-add-icon",
|
|
3228
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3229
|
+
onClick: addPage
|
|
3230
|
+
}, [
|
|
3231
|
+
createVNode(_component_el_icon, null, {
|
|
3232
|
+
default: withCtx(() => [
|
|
3233
|
+
createVNode(unref(Plus))
|
|
3234
|
+
]),
|
|
3235
|
+
_: 1
|
|
3236
|
+
})
|
|
3085
3237
|
]),
|
|
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)
|
|
3238
|
+
canScroll.value ? (openBlock(), createElementBlock("div", {
|
|
3239
|
+
key: 0,
|
|
3240
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3241
|
+
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
3100
3242
|
}, [
|
|
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
|
-
})
|
|
3243
|
+
createVNode(_component_el_icon, null, {
|
|
3244
|
+
default: withCtx(() => [
|
|
3245
|
+
createVNode(unref(ArrowLeftBold))
|
|
3128
3246
|
]),
|
|
3247
|
+
_: 1
|
|
3248
|
+
})
|
|
3249
|
+
])) : createCommentVNode("", true),
|
|
3250
|
+
unref(root) ? (openBlock(), createElementBlock("div", {
|
|
3251
|
+
key: 1,
|
|
3252
|
+
class: "m-editor-page-bar-items",
|
|
3253
|
+
ref_key: "itemsContainer",
|
|
3254
|
+
ref: itemsContainer,
|
|
3255
|
+
style: normalizeStyle(`width: ${unref(itemsContainerWidth)}px`)
|
|
3256
|
+
}, [
|
|
3257
|
+
renderSlot(_ctx.$slots, "default")
|
|
3258
|
+
], 4)) : createCommentVNode("", true),
|
|
3259
|
+
canScroll.value ? (openBlock(), createElementBlock("div", {
|
|
3260
|
+
key: 2,
|
|
3261
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3262
|
+
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
3263
|
+
}, [
|
|
3264
|
+
createVNode(_component_el_icon, null, {
|
|
3129
3265
|
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
|
-
])
|
|
3266
|
+
createVNode(unref(ArrowRightBold))
|
|
3150
3267
|
]),
|
|
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;
|
|
3268
|
+
_: 1
|
|
3269
|
+
})
|
|
3270
|
+
])) : createCommentVNode("", true)
|
|
3271
|
+
], 512);
|
|
3217
3272
|
};
|
|
3218
|
-
|
|
3219
|
-
|
|
3273
|
+
}
|
|
3274
|
+
});
|
|
3275
|
+
|
|
3276
|
+
const _hoisted_1$2 = ["onClick"];
|
|
3277
|
+
const _hoisted_2 = { class: "m-editor-page-bar-title" };
|
|
3278
|
+
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
3279
|
+
__name: "PageBar",
|
|
3280
|
+
setup(__props) {
|
|
3281
|
+
const services = inject("services");
|
|
3282
|
+
const editorService = services?.editorService;
|
|
3283
|
+
const root = computed(() => editorService?.get("root"));
|
|
3284
|
+
const page = computed(() => editorService?.get("page"));
|
|
3285
|
+
const switchPage = (page2) => {
|
|
3286
|
+
editorService?.select(page2);
|
|
3220
3287
|
};
|
|
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);
|
|
3288
|
+
const copy = (node) => {
|
|
3289
|
+
node && editorService?.copy(node);
|
|
3290
|
+
editorService?.paste({
|
|
3291
|
+
left: 0,
|
|
3292
|
+
top: 0
|
|
3293
|
+
});
|
|
3231
3294
|
};
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
this.y = 0;
|
|
3235
|
-
this.scrollLeft = this.target._left;
|
|
3236
|
-
this.scrollTop = this.target._top;
|
|
3237
|
-
this.removeHandler();
|
|
3295
|
+
const remove = (node) => {
|
|
3296
|
+
editorService?.remove(node);
|
|
3238
3297
|
};
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
const
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3298
|
+
return (_ctx, _cache) => {
|
|
3299
|
+
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
3300
|
+
const _component_el_icon = resolveComponent("el-icon");
|
|
3301
|
+
const _component_el_popover = resolveComponent("el-popover");
|
|
3302
|
+
return openBlock(), createBlock(_sfc_main$6, null, {
|
|
3303
|
+
default: withCtx(() => [
|
|
3304
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(root) && unref(root).items || [], (item) => {
|
|
3305
|
+
return openBlock(), createElementBlock("div", {
|
|
3306
|
+
class: normalizeClass(["m-editor-page-bar-item", { active: unref(page)?.id === item.id }]),
|
|
3307
|
+
key: item.key,
|
|
3308
|
+
onClick: ($event) => switchPage(item)
|
|
3309
|
+
}, [
|
|
3310
|
+
createElementVNode("div", _hoisted_2, [
|
|
3311
|
+
renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
|
|
3312
|
+
createVNode(_component_el_tooltip, {
|
|
3313
|
+
effect: "dark",
|
|
3314
|
+
placement: "top-start",
|
|
3315
|
+
content: item.name
|
|
3316
|
+
}, {
|
|
3317
|
+
default: withCtx(() => [
|
|
3318
|
+
createElementVNode("span", null, toDisplayString(item.name), 1)
|
|
3319
|
+
]),
|
|
3320
|
+
_: 2
|
|
3321
|
+
}, 1032, ["content"])
|
|
3322
|
+
])
|
|
3323
|
+
]),
|
|
3324
|
+
createVNode(_component_el_popover, {
|
|
3325
|
+
"popper-class": "page-bar-popover",
|
|
3326
|
+
placement: "top",
|
|
3327
|
+
width: 160,
|
|
3328
|
+
trigger: "hover"
|
|
3329
|
+
}, {
|
|
3330
|
+
reference: withCtx(() => [
|
|
3331
|
+
createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
|
|
3332
|
+
default: withCtx(() => [
|
|
3333
|
+
createVNode(unref(CaretBottom))
|
|
3334
|
+
]),
|
|
3335
|
+
_: 1
|
|
3336
|
+
})
|
|
3337
|
+
]),
|
|
3338
|
+
default: withCtx(() => [
|
|
3339
|
+
createElementVNode("div", null, [
|
|
3340
|
+
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3341
|
+
createVNode(_sfc_main$f, {
|
|
3342
|
+
data: {
|
|
3343
|
+
type: "button",
|
|
3344
|
+
text: "\u590D\u5236",
|
|
3345
|
+
icon: unref(DocumentCopy),
|
|
3346
|
+
handler: () => copy(item)
|
|
3347
|
+
}
|
|
3348
|
+
}, null, 8, ["data"]),
|
|
3349
|
+
createVNode(_sfc_main$f, {
|
|
3350
|
+
data: {
|
|
3351
|
+
type: "button",
|
|
3352
|
+
text: "\u5220\u9664",
|
|
3353
|
+
icon: unref(Delete),
|
|
3354
|
+
handler: () => remove(item)
|
|
3355
|
+
}
|
|
3356
|
+
}, null, 8, ["data"])
|
|
3357
|
+
])
|
|
3358
|
+
])
|
|
3359
|
+
]),
|
|
3360
|
+
_: 2
|
|
3361
|
+
}, 1024)
|
|
3362
|
+
], 10, _hoisted_1$2);
|
|
3363
|
+
}), 128))
|
|
3364
|
+
]),
|
|
3365
|
+
_: 3
|
|
3366
|
+
});
|
|
3246
3367
|
};
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3368
|
+
}
|
|
3369
|
+
});
|
|
3370
|
+
|
|
3371
|
+
class ScrollViewer$1 {
|
|
3372
|
+
enter = false;
|
|
3373
|
+
targetEnter = false;
|
|
3374
|
+
keydown = false;
|
|
3375
|
+
container;
|
|
3376
|
+
target;
|
|
3377
|
+
zoom = 1;
|
|
3378
|
+
scrollLeft = 0;
|
|
3379
|
+
scrollTop = 0;
|
|
3380
|
+
x = 0;
|
|
3381
|
+
y = 0;
|
|
3382
|
+
resizeObserver = new ResizeObserver((entries) => {
|
|
3383
|
+
for (const { contentRect } of entries) {
|
|
3384
|
+
const { width, height } = contentRect;
|
|
3385
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3386
|
+
const targetWidth = targetRect.width * this.zoom;
|
|
3387
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3388
|
+
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
3389
|
+
if (targetWidth < width) {
|
|
3390
|
+
this.target._left = 0;
|
|
3255
3391
|
}
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3259
|
-
};
|
|
3260
|
-
this.keyupHandler = (event) => {
|
|
3261
|
-
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3262
|
-
return;
|
|
3392
|
+
if (targetHeight < height) {
|
|
3393
|
+
this.target._top = 0;
|
|
3263
3394
|
}
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
event.preventDefault();
|
|
3269
|
-
this.removeHandler();
|
|
3270
|
-
};
|
|
3395
|
+
this.scroll();
|
|
3396
|
+
}
|
|
3397
|
+
});
|
|
3398
|
+
constructor(options) {
|
|
3271
3399
|
this.container = options.container;
|
|
3272
3400
|
this.target = options.target;
|
|
3273
3401
|
this.zoom = options.zoom;
|
|
@@ -3303,6 +3431,79 @@ class ScrollViewer$1 {
|
|
|
3303
3431
|
document.removeEventListener("mousemove", this.mousemoveHandler);
|
|
3304
3432
|
document.removeEventListener("mouseup", this.mouseupHandler);
|
|
3305
3433
|
}
|
|
3434
|
+
wheelHandler = (event) => {
|
|
3435
|
+
if (this.targetEnter)
|
|
3436
|
+
return;
|
|
3437
|
+
const { deltaX, deltaY, currentTarget } = event;
|
|
3438
|
+
if (currentTarget !== this.container)
|
|
3439
|
+
return;
|
|
3440
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3441
|
+
this.scroll();
|
|
3442
|
+
this.scrollLeft = this.target._left;
|
|
3443
|
+
this.scrollTop = this.target._top;
|
|
3444
|
+
};
|
|
3445
|
+
mouseEnterHandler = () => {
|
|
3446
|
+
this.enter = true;
|
|
3447
|
+
};
|
|
3448
|
+
mouseLeaveHandler = () => {
|
|
3449
|
+
this.enter = false;
|
|
3450
|
+
};
|
|
3451
|
+
targetMouseEnterHandler = () => {
|
|
3452
|
+
this.targetEnter = true;
|
|
3453
|
+
};
|
|
3454
|
+
targetMouseLeaveHandler = () => {
|
|
3455
|
+
this.targetEnter = false;
|
|
3456
|
+
};
|
|
3457
|
+
mousedownHandler = (event) => {
|
|
3458
|
+
if (!this.keydown)
|
|
3459
|
+
return;
|
|
3460
|
+
event.stopImmediatePropagation();
|
|
3461
|
+
event.stopPropagation();
|
|
3462
|
+
this.target.style.cursor = "grabbing";
|
|
3463
|
+
this.x = event.clientX;
|
|
3464
|
+
this.y = event.clientY;
|
|
3465
|
+
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3466
|
+
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3467
|
+
};
|
|
3468
|
+
mouseupHandler = () => {
|
|
3469
|
+
this.x = 0;
|
|
3470
|
+
this.y = 0;
|
|
3471
|
+
this.scrollLeft = this.target._left;
|
|
3472
|
+
this.scrollTop = this.target._top;
|
|
3473
|
+
this.removeHandler();
|
|
3474
|
+
};
|
|
3475
|
+
mousemoveHandler = (event) => {
|
|
3476
|
+
event.stopImmediatePropagation();
|
|
3477
|
+
event.stopPropagation();
|
|
3478
|
+
const deltaX = event.clientX - this.x;
|
|
3479
|
+
const deltaY = event.clientY - this.y;
|
|
3480
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3481
|
+
this.scroll();
|
|
3482
|
+
};
|
|
3483
|
+
keydownHandler = (event) => {
|
|
3484
|
+
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3485
|
+
event.preventDefault();
|
|
3486
|
+
event.stopImmediatePropagation();
|
|
3487
|
+
event.stopPropagation();
|
|
3488
|
+
}
|
|
3489
|
+
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3490
|
+
return;
|
|
3491
|
+
}
|
|
3492
|
+
this.keydown = true;
|
|
3493
|
+
this.target.style.cursor = "grab";
|
|
3494
|
+
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3495
|
+
};
|
|
3496
|
+
keyupHandler = (event) => {
|
|
3497
|
+
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3498
|
+
return;
|
|
3499
|
+
}
|
|
3500
|
+
event.preventDefault();
|
|
3501
|
+
event.stopImmediatePropagation();
|
|
3502
|
+
event.stopPropagation();
|
|
3503
|
+
this.keydown = false;
|
|
3504
|
+
event.preventDefault();
|
|
3505
|
+
this.removeHandler();
|
|
3506
|
+
};
|
|
3306
3507
|
setScrollOffset(deltaX, deltaY) {
|
|
3307
3508
|
const { width, height } = this.container.getBoundingClientRect();
|
|
3308
3509
|
const targetRect = this.target.getBoundingClientRect();
|
|
@@ -3363,18 +3564,19 @@ const _sfc_main$4 = defineComponent({
|
|
|
3363
3564
|
el,
|
|
3364
3565
|
style: computed(() => `
|
|
3365
3566
|
width: ${props.width}px;
|
|
3366
|
-
height: ${
|
|
3567
|
+
height: ${props.height}px;
|
|
3367
3568
|
position: absolute;
|
|
3368
3569
|
margin-top: 30px;
|
|
3369
3570
|
`)
|
|
3370
3571
|
};
|
|
3371
3572
|
}
|
|
3372
3573
|
});
|
|
3574
|
+
|
|
3373
3575
|
const _hoisted_1$1 = {
|
|
3374
3576
|
class: "m-editor-scroll-viewer-container",
|
|
3375
3577
|
ref: "container"
|
|
3376
3578
|
};
|
|
3377
|
-
function _sfc_render$
|
|
3579
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3378
3580
|
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
3379
3581
|
createElementVNode("div", {
|
|
3380
3582
|
ref: "el",
|
|
@@ -3384,170 +3586,170 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3384
3586
|
], 4)
|
|
3385
3587
|
], 512);
|
|
3386
3588
|
}
|
|
3387
|
-
|
|
3589
|
+
const ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$2]]);
|
|
3388
3590
|
|
|
3389
|
-
const _sfc_main$3 = defineComponent({
|
|
3390
|
-
|
|
3391
|
-
|
|
3591
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
3592
|
+
__name: "ViewerMenu",
|
|
3593
|
+
props: {
|
|
3594
|
+
isMultiSelect: { type: Boolean, default: false }
|
|
3595
|
+
},
|
|
3596
|
+
setup(__props, { expose }) {
|
|
3597
|
+
const props = __props;
|
|
3392
3598
|
const services = inject("services");
|
|
3393
3599
|
const editorService = services?.editorService;
|
|
3394
3600
|
const menu = ref();
|
|
3395
3601
|
const canPaste = ref(false);
|
|
3396
3602
|
const canCenter = ref(false);
|
|
3397
3603
|
const node = computed(() => editorService?.get("node"));
|
|
3604
|
+
const nodes = computed(() => editorService?.get("nodes"));
|
|
3398
3605
|
const parent = computed(() => editorService?.get("parent"));
|
|
3399
|
-
const
|
|
3606
|
+
const stage = computed(() => editorService?.get("stage"));
|
|
3400
3607
|
const stageContentMenu = inject("stageContentMenu", []);
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3608
|
+
const menuData = reactive([
|
|
3609
|
+
{
|
|
3610
|
+
type: "button",
|
|
3611
|
+
text: "\u6C34\u5E73\u5C45\u4E2D",
|
|
3612
|
+
display: () => canCenter.value,
|
|
3613
|
+
handler: () => {
|
|
3614
|
+
if (!nodes.value)
|
|
3615
|
+
return;
|
|
3616
|
+
editorService?.alignCenter(nodes.value);
|
|
3617
|
+
}
|
|
3618
|
+
},
|
|
3619
|
+
{
|
|
3620
|
+
type: "button",
|
|
3621
|
+
text: "\u590D\u5236",
|
|
3622
|
+
icon: markRaw(DocumentCopy),
|
|
3623
|
+
handler: () => {
|
|
3624
|
+
nodes.value && editorService?.copy(nodes.value);
|
|
3625
|
+
canPaste.value = true;
|
|
3626
|
+
}
|
|
3627
|
+
},
|
|
3628
|
+
{
|
|
3629
|
+
type: "button",
|
|
3630
|
+
text: "\u7C98\u8D34",
|
|
3631
|
+
display: () => canPaste.value,
|
|
3632
|
+
handler: () => {
|
|
3633
|
+
const rect = menu.value?.$el.getBoundingClientRect();
|
|
3634
|
+
const parentRect = stage.value?.container?.getBoundingClientRect();
|
|
3635
|
+
const initialLeft = (rect?.left || 0) - (parentRect?.left || 0);
|
|
3636
|
+
const initialTop = (rect?.top || 0) - (parentRect?.top || 0);
|
|
3637
|
+
if (!nodes.value || nodes.value.length === 0)
|
|
3638
|
+
return;
|
|
3639
|
+
editorService?.paste({ left: initialLeft, top: initialTop });
|
|
3640
|
+
}
|
|
3641
|
+
},
|
|
3642
|
+
{
|
|
3643
|
+
type: "divider",
|
|
3644
|
+
direction: "horizontal",
|
|
3645
|
+
display: () => {
|
|
3646
|
+
if (!node.value)
|
|
3647
|
+
return false;
|
|
3648
|
+
return !isPage(node.value);
|
|
3649
|
+
}
|
|
3650
|
+
},
|
|
3651
|
+
{
|
|
3652
|
+
type: "button",
|
|
3653
|
+
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
3654
|
+
icon: markRaw(Top),
|
|
3655
|
+
display: () => !isPage(node.value) && !props.isMultiSelect,
|
|
3656
|
+
handler: () => {
|
|
3657
|
+
editorService?.moveLayer(1);
|
|
3658
|
+
}
|
|
3659
|
+
},
|
|
3660
|
+
{
|
|
3661
|
+
type: "button",
|
|
3662
|
+
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
3663
|
+
icon: markRaw(Bottom),
|
|
3664
|
+
display: () => !isPage(node.value) && !props.isMultiSelect,
|
|
3665
|
+
handler: () => {
|
|
3666
|
+
editorService?.moveLayer(-1);
|
|
3667
|
+
}
|
|
3668
|
+
},
|
|
3669
|
+
{
|
|
3670
|
+
type: "button",
|
|
3671
|
+
text: "\u7F6E\u9876",
|
|
3672
|
+
display: () => !isPage(node.value) && !props.isMultiSelect,
|
|
3673
|
+
handler: () => {
|
|
3674
|
+
editorService?.moveLayer(LayerOffset.TOP);
|
|
3675
|
+
}
|
|
3676
|
+
},
|
|
3677
|
+
{
|
|
3678
|
+
type: "button",
|
|
3679
|
+
text: "\u7F6E\u5E95",
|
|
3680
|
+
display: () => !isPage(node.value) && !props.isMultiSelect,
|
|
3681
|
+
handler: () => {
|
|
3682
|
+
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
3683
|
+
}
|
|
3684
|
+
},
|
|
3685
|
+
{
|
|
3686
|
+
type: "divider",
|
|
3687
|
+
direction: "horizontal",
|
|
3688
|
+
display: () => !isPage(node.value) && !props.isMultiSelect
|
|
3689
|
+
},
|
|
3690
|
+
{
|
|
3691
|
+
type: "button",
|
|
3692
|
+
text: "\u5220\u9664",
|
|
3693
|
+
icon: Delete,
|
|
3694
|
+
display: () => !isPage(node.value),
|
|
3695
|
+
handler: () => {
|
|
3696
|
+
nodes.value && editorService?.remove(nodes.value);
|
|
3697
|
+
}
|
|
3698
|
+
},
|
|
3699
|
+
{
|
|
3700
|
+
type: "divider",
|
|
3701
|
+
direction: "horizontal"
|
|
3702
|
+
},
|
|
3703
|
+
{
|
|
3704
|
+
type: "button",
|
|
3705
|
+
text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
|
|
3706
|
+
handler: () => {
|
|
3707
|
+
editorService?.get("stage").clearGuides();
|
|
3708
|
+
}
|
|
3709
|
+
},
|
|
3710
|
+
...stageContentMenu
|
|
3711
|
+
]);
|
|
3405
3712
|
watch(parent, async () => {
|
|
3406
3713
|
if (!parent.value || !editorService)
|
|
3407
3714
|
return canCenter.value = false;
|
|
3408
3715
|
const layout = await editorService.getLayout(parent.value);
|
|
3409
|
-
|
|
3716
|
+
const isLayoutConform = [Layout.ABSOLUTE, Layout.FIXED].includes(layout);
|
|
3717
|
+
const isTypeConform = nodes.value?.every((selectedNode) => ![NodeType.ROOT, NodeType.PAGE, "pop"].includes(`${selectedNode?.type}`));
|
|
3718
|
+
canCenter.value = isLayoutConform && !!isTypeConform;
|
|
3410
3719
|
}, { 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
|
-
}
|
|
3720
|
+
const show = async (e) => {
|
|
3721
|
+
menu.value?.show(e);
|
|
3722
|
+
const data = await storageService.getItem(COPY_STORAGE_KEY);
|
|
3723
|
+
canPaste.value = data !== "undefined" && !!data;
|
|
3724
|
+
};
|
|
3725
|
+
expose({ show });
|
|
3726
|
+
return (_ctx, _cache) => {
|
|
3727
|
+
return openBlock(), createBlock(_sfc_main$b, {
|
|
3728
|
+
"menu-data": menuData,
|
|
3729
|
+
ref_key: "menu",
|
|
3730
|
+
ref: menu
|
|
3731
|
+
}, null, 8, ["menu-data"]);
|
|
3519
3732
|
};
|
|
3520
3733
|
}
|
|
3521
3734
|
});
|
|
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
3735
|
|
|
3531
|
-
const _sfc_main$2 = defineComponent({
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
},
|
|
3537
|
-
setup() {
|
|
3736
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
3737
|
+
__name: "Stage",
|
|
3738
|
+
setup(__props) {
|
|
3739
|
+
let stage = null;
|
|
3740
|
+
let runtime = null;
|
|
3538
3741
|
const services = inject("services");
|
|
3539
3742
|
const stageOptions = inject("stageOptions");
|
|
3540
3743
|
const stageWrap = ref();
|
|
3541
3744
|
const stageContainer = ref();
|
|
3542
3745
|
const menu = ref();
|
|
3746
|
+
const isMultiSelect = computed(() => services?.editorService.get("nodes")?.length > 1);
|
|
3543
3747
|
const stageRect = computed(() => services?.uiService.get("stageRect"));
|
|
3544
3748
|
const uiSelectMode = computed(() => services?.uiService.get("uiSelectMode"));
|
|
3545
3749
|
const root = computed(() => services?.editorService.get("root"));
|
|
3546
3750
|
const page = computed(() => services?.editorService.get("page"));
|
|
3547
3751
|
const zoom = computed(() => services?.uiService.get("zoom") || 1);
|
|
3548
3752
|
const node = computed(() => services?.editorService.get("node"));
|
|
3549
|
-
let stage = null;
|
|
3550
|
-
let runtime = null;
|
|
3551
3753
|
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
3552
3754
|
watchEffect(() => {
|
|
3553
3755
|
if (stage)
|
|
@@ -3564,6 +3766,7 @@ const _sfc_main$2 = defineComponent({
|
|
|
3564
3766
|
isContainer: stageOptions.isContainer,
|
|
3565
3767
|
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
3566
3768
|
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
3769
|
+
containerHighlightType: stageOptions.containerHighlightType,
|
|
3567
3770
|
canSelect: (el, event, stop) => {
|
|
3568
3771
|
const elCanSelect = stageOptions.canSelect(el);
|
|
3569
3772
|
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
@@ -3587,12 +3790,17 @@ const _sfc_main$2 = defineComponent({
|
|
|
3587
3790
|
stage?.on("highlight", (el) => {
|
|
3588
3791
|
services?.editorService.highlight(el.id);
|
|
3589
3792
|
});
|
|
3793
|
+
stage?.on("multiSelect", (els) => {
|
|
3794
|
+
services?.editorService.multiSelect(els.map((el) => el.id));
|
|
3795
|
+
});
|
|
3590
3796
|
stage?.on("update", (ev) => {
|
|
3591
3797
|
if (ev.parentEl) {
|
|
3592
|
-
|
|
3798
|
+
for (const data of ev.data) {
|
|
3799
|
+
services?.editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
3800
|
+
}
|
|
3593
3801
|
return;
|
|
3594
3802
|
}
|
|
3595
|
-
services?.editorService.update({ id:
|
|
3803
|
+
services?.editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
3596
3804
|
});
|
|
3597
3805
|
stage?.on("sort", (ev) => {
|
|
3598
3806
|
services?.editorService.sort(ev.src, ev.dist);
|
|
@@ -3645,99 +3853,96 @@ const _sfc_main$2 = defineComponent({
|
|
|
3645
3853
|
resizeObserver.disconnect();
|
|
3646
3854
|
services?.editorService.set("stage", null);
|
|
3647
3855
|
});
|
|
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
|
-
}
|
|
3856
|
+
const contextmenuHandler = (e2) => {
|
|
3857
|
+
e2.preventDefault();
|
|
3858
|
+
menu.value?.show(e2);
|
|
3859
|
+
};
|
|
3860
|
+
const dragoverHandler = (e2) => {
|
|
3861
|
+
e2.preventDefault();
|
|
3862
|
+
if (e2.dataTransfer) {
|
|
3863
|
+
e2.dataTransfer.dropEffect = "move";
|
|
3864
|
+
}
|
|
3865
|
+
};
|
|
3866
|
+
const dropHandler = async (e) => {
|
|
3867
|
+
e.preventDefault();
|
|
3868
|
+
const doc = stage?.renderer.contentWindow?.document;
|
|
3869
|
+
const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
|
|
3870
|
+
let parent = page.value;
|
|
3871
|
+
if (parentEl) {
|
|
3872
|
+
parent = services?.editorService.getNodeById(parentEl.id, false);
|
|
3873
|
+
}
|
|
3874
|
+
if (e.dataTransfer && parent && stageContainer.value && stage) {
|
|
3875
|
+
const config = eval(`(${e.dataTransfer.getData("data")})`);
|
|
3876
|
+
const layout = await services?.editorService.getLayout(parent);
|
|
3877
|
+
const containerRect = stageContainer.value.getBoundingClientRect();
|
|
3878
|
+
const { scrollTop, scrollLeft } = stage.mask;
|
|
3879
|
+
const { style = {} } = config;
|
|
3880
|
+
let top = 0;
|
|
3881
|
+
let left = 0;
|
|
3882
|
+
let position = "relative";
|
|
3883
|
+
if (layout === Layout.ABSOLUTE) {
|
|
3884
|
+
position = "absolute";
|
|
3885
|
+
top = e.clientY - containerRect.top + scrollTop;
|
|
3886
|
+
left = e.clientX - containerRect.left + scrollLeft;
|
|
3887
|
+
if (parentEl && doc) {
|
|
3888
|
+
const { left: parentLeft, top: parentTop } = getOffset(parentEl);
|
|
3889
|
+
left = left - calcValueByFontsize(doc, parentLeft);
|
|
3890
|
+
top = top - calcValueByFontsize(doc, parentTop);
|
|
3690
3891
|
}
|
|
3691
|
-
config.style = {
|
|
3692
|
-
...style,
|
|
3693
|
-
position,
|
|
3694
|
-
top,
|
|
3695
|
-
left
|
|
3696
|
-
};
|
|
3697
|
-
services?.editorService.add(config, parent);
|
|
3698
3892
|
}
|
|
3893
|
+
config.style = {
|
|
3894
|
+
...style,
|
|
3895
|
+
position,
|
|
3896
|
+
top,
|
|
3897
|
+
left
|
|
3898
|
+
};
|
|
3899
|
+
config.inputEvent = e;
|
|
3900
|
+
services?.editorService.add(config, parent);
|
|
3699
3901
|
}
|
|
3700
3902
|
};
|
|
3903
|
+
return (_ctx, _cache) => {
|
|
3904
|
+
return openBlock(), createBlock(ScrollViewer, {
|
|
3905
|
+
class: "m-editor-stage",
|
|
3906
|
+
ref_key: "stageWrap",
|
|
3907
|
+
ref: stageWrap,
|
|
3908
|
+
width: unref(stageRect)?.width,
|
|
3909
|
+
height: unref(stageRect)?.height,
|
|
3910
|
+
zoom: unref(zoom)
|
|
3911
|
+
}, {
|
|
3912
|
+
default: withCtx(() => [
|
|
3913
|
+
createElementVNode("div", {
|
|
3914
|
+
class: "m-editor-stage-container",
|
|
3915
|
+
ref_key: "stageContainer",
|
|
3916
|
+
ref: stageContainer,
|
|
3917
|
+
style: normalizeStyle(`transform: scale(${unref(zoom)})`),
|
|
3918
|
+
onContextmenu: contextmenuHandler,
|
|
3919
|
+
onDrop: dropHandler,
|
|
3920
|
+
onDragover: dragoverHandler
|
|
3921
|
+
}, null, 36),
|
|
3922
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
3923
|
+
createVNode(_sfc_main$3, {
|
|
3924
|
+
ref_key: "menu",
|
|
3925
|
+
ref: menu,
|
|
3926
|
+
"is-multi-select": unref(isMultiSelect)
|
|
3927
|
+
}, null, 8, ["is-multi-select"])
|
|
3928
|
+
]))
|
|
3929
|
+
]),
|
|
3930
|
+
_: 1
|
|
3931
|
+
}, 8, ["width", "height", "zoom"]);
|
|
3932
|
+
};
|
|
3701
3933
|
}
|
|
3702
3934
|
});
|
|
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
3935
|
|
|
3731
3936
|
const _sfc_main$1 = defineComponent({
|
|
3732
3937
|
name: "m-editor-workspace",
|
|
3733
3938
|
components: {
|
|
3734
|
-
PageBar,
|
|
3735
|
-
MagicStage
|
|
3939
|
+
PageBar: _sfc_main$5,
|
|
3940
|
+
MagicStage: _sfc_main$2
|
|
3736
3941
|
},
|
|
3737
3942
|
setup() {
|
|
3738
3943
|
const services = inject("services");
|
|
3739
3944
|
const workspace = ref();
|
|
3740
|
-
const
|
|
3945
|
+
const nodes = computed(() => services?.editorService.get("nodes"));
|
|
3741
3946
|
let keycon;
|
|
3742
3947
|
const mouseenterHandler = () => {
|
|
3743
3948
|
workspace.value?.focus();
|
|
@@ -3753,26 +3958,26 @@ const _sfc_main$1 = defineComponent({
|
|
|
3753
3958
|
const ctrl = isMac ? "meta" : "ctrl";
|
|
3754
3959
|
keycon.keyup("delete", (e) => {
|
|
3755
3960
|
e.inputEvent.preventDefault();
|
|
3756
|
-
if (!
|
|
3961
|
+
if (!nodes.value || isPage(nodes.value[0]))
|
|
3757
3962
|
return;
|
|
3758
|
-
services?.editorService.remove(
|
|
3963
|
+
services?.editorService.remove(nodes.value);
|
|
3759
3964
|
}).keyup("backspace", (e) => {
|
|
3760
3965
|
e.inputEvent.preventDefault();
|
|
3761
|
-
if (!
|
|
3966
|
+
if (!nodes.value || isPage(nodes.value[0]))
|
|
3762
3967
|
return;
|
|
3763
|
-
services?.editorService.remove(
|
|
3968
|
+
services?.editorService.remove(nodes.value);
|
|
3764
3969
|
}).keydown([ctrl, "c"], (e) => {
|
|
3765
3970
|
e.inputEvent.preventDefault();
|
|
3766
|
-
|
|
3971
|
+
nodes.value && services?.editorService.copy(nodes.value);
|
|
3767
3972
|
}).keydown([ctrl, "v"], (e) => {
|
|
3768
3973
|
e.inputEvent.preventDefault();
|
|
3769
|
-
|
|
3974
|
+
nodes.value && services?.editorService.paste({ offsetX: 10, offsetY: 10 });
|
|
3770
3975
|
}).keydown([ctrl, "x"], (e) => {
|
|
3771
3976
|
e.inputEvent.preventDefault();
|
|
3772
|
-
if (!
|
|
3977
|
+
if (!nodes.value || isPage(nodes.value[0]))
|
|
3773
3978
|
return;
|
|
3774
|
-
services?.editorService.copy(
|
|
3775
|
-
services?.editorService.remove(
|
|
3979
|
+
services?.editorService.copy(nodes.value);
|
|
3980
|
+
services?.editorService.remove(nodes.value);
|
|
3776
3981
|
}).keydown([ctrl, "z"], (e) => {
|
|
3777
3982
|
e.inputEvent.preventDefault();
|
|
3778
3983
|
services?.editorService.undo();
|
|
@@ -3834,6 +4039,7 @@ const _sfc_main$1 = defineComponent({
|
|
|
3834
4039
|
};
|
|
3835
4040
|
}
|
|
3836
4041
|
});
|
|
4042
|
+
|
|
3837
4043
|
const _hoisted_1 = {
|
|
3838
4044
|
class: "m-editor-workspace",
|
|
3839
4045
|
tabindex: "1",
|
|
@@ -3858,14 +4064,14 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3858
4064
|
})
|
|
3859
4065
|
], 512);
|
|
3860
4066
|
}
|
|
3861
|
-
|
|
4067
|
+
const Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
3862
4068
|
|
|
3863
4069
|
class ComponentList extends BaseService {
|
|
4070
|
+
state = reactive({
|
|
4071
|
+
list: []
|
|
4072
|
+
});
|
|
3864
4073
|
constructor() {
|
|
3865
4074
|
super([]);
|
|
3866
|
-
this.state = reactive({
|
|
3867
|
-
list: []
|
|
3868
|
-
});
|
|
3869
4075
|
}
|
|
3870
4076
|
setList(componentGroupList) {
|
|
3871
4077
|
this.state.list = componentGroupList;
|
|
@@ -3874,7 +4080,7 @@ class ComponentList extends BaseService {
|
|
|
3874
4080
|
return this.state.list;
|
|
3875
4081
|
}
|
|
3876
4082
|
}
|
|
3877
|
-
|
|
4083
|
+
const componentListService = new ComponentList();
|
|
3878
4084
|
|
|
3879
4085
|
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
3880
4086
|
const MIN_LEFT_COLUMN_WIDTH = 45;
|
|
@@ -3986,13 +4192,15 @@ class Ui extends BaseService {
|
|
|
3986
4192
|
const { height, width } = stageContainerRect;
|
|
3987
4193
|
if (!width || !height)
|
|
3988
4194
|
return 1;
|
|
3989
|
-
|
|
4195
|
+
const stageWidth = stageRect.width + 30;
|
|
4196
|
+
const stageHeight = stageRect.height + 30;
|
|
4197
|
+
if (width > stageWidth && height > stageHeight) {
|
|
3990
4198
|
return 1;
|
|
3991
4199
|
}
|
|
3992
|
-
return Math.min((width -
|
|
4200
|
+
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
3993
4201
|
}
|
|
3994
4202
|
}
|
|
3995
|
-
|
|
4203
|
+
const uiService = new Ui();
|
|
3996
4204
|
|
|
3997
4205
|
const _sfc_main = defineComponent({
|
|
3998
4206
|
name: "m-editor",
|
|
@@ -4067,6 +4275,10 @@ const _sfc_main = defineComponent({
|
|
|
4067
4275
|
type: Number,
|
|
4068
4276
|
default: 800
|
|
4069
4277
|
},
|
|
4278
|
+
containerHighlightType: {
|
|
4279
|
+
type: String,
|
|
4280
|
+
default: ContainerHighlightType.DEFAULT
|
|
4281
|
+
},
|
|
4070
4282
|
stageRect: {
|
|
4071
4283
|
type: [String, Object]
|
|
4072
4284
|
},
|
|
@@ -4122,7 +4334,8 @@ const _sfc_main = defineComponent({
|
|
|
4122
4334
|
historyService,
|
|
4123
4335
|
propsService,
|
|
4124
4336
|
editorService,
|
|
4125
|
-
uiService
|
|
4337
|
+
uiService,
|
|
4338
|
+
storageService
|
|
4126
4339
|
};
|
|
4127
4340
|
provide("services", services);
|
|
4128
4341
|
provide("layerContentMenu", props.layerContentMenu);
|
|
@@ -4136,11 +4349,13 @@ const _sfc_main = defineComponent({
|
|
|
4136
4349
|
updateDragEl: props.updateDragEl,
|
|
4137
4350
|
isContainer: props.isContainer,
|
|
4138
4351
|
containerHighlightClassName: props.containerHighlightClassName,
|
|
4139
|
-
containerHighlightDuration: props.containerHighlightDuration
|
|
4352
|
+
containerHighlightDuration: props.containerHighlightDuration,
|
|
4353
|
+
containerHighlightType: props.containerHighlightType
|
|
4140
4354
|
}));
|
|
4141
4355
|
return services;
|
|
4142
4356
|
}
|
|
4143
4357
|
});
|
|
4358
|
+
|
|
4144
4359
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4145
4360
|
const _component_nav_menu = resolveComponent("nav-menu");
|
|
4146
4361
|
const _component_sidebar = resolveComponent("sidebar");
|
|
@@ -4201,23 +4416,23 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4201
4416
|
_: 3
|
|
4202
4417
|
}, 8, ["code-options"]);
|
|
4203
4418
|
}
|
|
4204
|
-
|
|
4419
|
+
const Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
4205
4420
|
|
|
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}")();
|
|
4421
|
+
const index$1 = '';
|
|
4207
4422
|
|
|
4208
4423
|
const defaultInstallOpt = {};
|
|
4209
|
-
|
|
4424
|
+
const index = {
|
|
4210
4425
|
install: (app, opt) => {
|
|
4211
4426
|
const option = Object.assign(defaultInstallOpt, opt || {});
|
|
4212
4427
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
4213
4428
|
setConfig(option);
|
|
4214
4429
|
app.component(Editor.name, Editor);
|
|
4215
|
-
app.component(
|
|
4430
|
+
app.component("m-fields-ui-select", _sfc_main$l);
|
|
4216
4431
|
app.component(CodeLink.name, CodeLink);
|
|
4217
4432
|
app.component(Code.name, Code);
|
|
4218
4433
|
app.component(CodeEditor.name, CodeEditor);
|
|
4219
4434
|
}
|
|
4220
4435
|
};
|
|
4221
4436
|
|
|
4222
|
-
export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, ToolButton, V_GUIDE_LINE_STORAGE_KEY, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, fixNodeLeft, generatePageName, generatePageNameByApp, getConfig,
|
|
4223
|
-
//# sourceMappingURL=tmagic-editor.
|
|
4437
|
+
export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$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 };
|
|
4438
|
+
//# sourceMappingURL=tmagic-editor.mjs.map
|