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