@tmagic/editor 1.0.6 → 1.1.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/style.css +5 -1
- package/dist/{tmagic-editor.es.js → tmagic-editor.mjs} +1522 -1177
- package/dist/tmagic-editor.mjs.map +1 -0
- package/dist/tmagic-editor.umd.js +1606 -1259
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +22 -20
- package/src/Editor.vue +41 -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 +49 -70
- 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 +43 -2
- package/src/layouts/sidebar/LayerMenu.vue +3 -3
- package/src/layouts/sidebar/LayerPanel.vue +13 -4
- 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 +208 -188
- 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 +247 -140
- 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 +28 -7
- package/src/utils/config.ts +1 -1
- package/src/utils/editor.ts +53 -35
- 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 +44 -9
- package/types/components/ContentMenu.vue.d.ts +116 -0
- package/types/components/Icon.vue.d.ts +13 -0
- package/types/components/ScrollViewer.vue.d.ts +22 -0
- package/types/components/ToolButton.vue.d.ts +109 -0
- package/types/fields/Code.vue.d.ts +23 -0
- package/{dist/types/src → types}/fields/CodeLink.vue.d.ts +4 -6
- package/types/fields/UISelect.vue.d.ts +83 -0
- package/{dist/types/src → types}/index.d.ts +4 -1
- package/types/layouts/AddPageBox.vue.d.ts +4 -0
- package/{dist/types/src → types}/layouts/CodeEditor.vue.d.ts +11 -13
- package/types/layouts/Framework.vue.d.ts +22 -0
- package/types/layouts/NavMenu.vue.d.ts +25 -0
- package/types/layouts/PropsPanel.vue.d.ts +245 -0
- package/types/layouts/Resizer.vue.d.ts +12 -0
- package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +14 -0
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +100 -0
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +1099 -0
- package/{dist/types/src → types}/layouts/sidebar/Sidebar.vue.d.ts +3 -5
- package/types/layouts/sidebar/TabPane.vue.d.ts +14 -0
- package/types/layouts/workspace/PageBar.vue.d.ts +54 -0
- package/types/layouts/workspace/PageBarScrollContainer.vue.d.ts +48 -0
- package/types/layouts/workspace/Stage.vue.d.ts +46 -0
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +88 -0
- package/types/layouts/workspace/Workspace.vue.d.ts +6 -0
- package/{dist/types/src → types}/services/BaseService.d.ts +0 -0
- package/types/services/componentList.d.ts +14 -0
- package/{dist/types/src → types}/services/editor.d.ts +27 -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 +21 -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 +11 -4
- 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 -14
- 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,16 +1,16 @@
|
|
|
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, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS, ContainerHighlightType } from '@tmagic/stage';
|
|
6
7
|
import { NodeType } from '@tmagic/schema';
|
|
7
|
-
import {
|
|
8
|
+
import { isPop, getNodePath, isNumber, isPage, toLine, removeClassNameByClassName } from '@tmagic/utils';
|
|
8
9
|
import { EventEmitter } from 'events';
|
|
9
10
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
10
11
|
import Gesto from 'gesto';
|
|
11
12
|
import { ElMessage } from 'element-plus';
|
|
12
13
|
import KeyController from 'keycon';
|
|
13
|
-
import StageCore, { GuidesType } from '@tmagic/stage';
|
|
14
14
|
|
|
15
15
|
if (typeof global === "undefined") {
|
|
16
16
|
window.global = window;
|
|
@@ -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
|
-
|
|
123
|
-
|
|
124
|
-
var UISelect_vue_vue_type_style_index_0_lang = /* #__PURE__ */ (() => ".m-fields-ui-select {\n cursor: pointer;\n}\n.m-fields-ui-select i {\n margin-right: 3px;\n}\n.m-fields-ui-select span {\n color: #2882e0;\n}")();
|
|
124
|
+
const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$f]]);
|
|
125
125
|
|
|
126
|
-
const
|
|
127
|
-
|
|
126
|
+
const _hoisted_1$d = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
|
|
127
|
+
const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
128
|
+
__name: "UISelect",
|
|
128
129
|
props: {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
type: String,
|
|
134
|
-
default() {
|
|
135
|
-
return "";
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
name: String
|
|
130
|
+
config: null,
|
|
131
|
+
model: null,
|
|
132
|
+
prop: null,
|
|
133
|
+
name: null
|
|
139
134
|
},
|
|
140
135
|
emits: ["change"],
|
|
141
|
-
setup(
|
|
136
|
+
setup(__props, { emit }) {
|
|
137
|
+
const props = __props;
|
|
142
138
|
const services = inject("services");
|
|
143
139
|
const mForm = inject("mForm");
|
|
144
140
|
const val = computed(() => props.model[props.name]);
|
|
@@ -160,92 +156,84 @@ const _sfc_main$k = defineComponent({
|
|
|
160
156
|
cancelHandler();
|
|
161
157
|
}
|
|
162
158
|
};
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
},
|
|
180
|
-
cancelHandler,
|
|
181
|
-
deleteHandler() {
|
|
182
|
-
if (props.model) {
|
|
183
|
-
props.model[props.name] = "";
|
|
184
|
-
emit("change", "");
|
|
185
|
-
mForm?.$emit("field-change", props.prop, "");
|
|
186
|
-
}
|
|
159
|
+
const toName = computed(() => {
|
|
160
|
+
const config = services?.editorService.getNodeById(val.value);
|
|
161
|
+
return config?.name || "";
|
|
162
|
+
});
|
|
163
|
+
const startSelect = () => {
|
|
164
|
+
if (!services?.uiService)
|
|
165
|
+
return;
|
|
166
|
+
services.uiService.set("uiSelectMode", true);
|
|
167
|
+
uiSelectMode.value = true;
|
|
168
|
+
globalThis.document.addEventListener("ui-select", clickHandler);
|
|
169
|
+
};
|
|
170
|
+
const deleteHandler = () => {
|
|
171
|
+
if (props.model) {
|
|
172
|
+
props.model[props.name] = "";
|
|
173
|
+
emit("change", "");
|
|
174
|
+
mForm?.$emit("field-change", props.prop, "");
|
|
187
175
|
}
|
|
188
176
|
};
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
class: "m-fields-ui-select",
|
|
198
|
-
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.cancelHandler && _ctx.cancelHandler(...args))
|
|
199
|
-
}, [
|
|
200
|
-
createVNode(_component_el_button, {
|
|
201
|
-
type: "danger",
|
|
202
|
-
icon: _ctx.Delete,
|
|
203
|
-
text: "",
|
|
204
|
-
style: { "padding": "0" }
|
|
205
|
-
}, {
|
|
206
|
-
default: withCtx(() => [
|
|
207
|
-
_hoisted_1$d
|
|
208
|
-
]),
|
|
209
|
-
_: 1
|
|
210
|
-
}, 8, ["icon"])
|
|
211
|
-
])) : (openBlock(), createElementBlock("div", {
|
|
212
|
-
key: 1,
|
|
213
|
-
class: "m-fields-ui-select",
|
|
214
|
-
onClick: _cache[1] || (_cache[1] = (...args) => _ctx.startSelect && _ctx.startSelect(...args)),
|
|
215
|
-
style: { "display": "flex" }
|
|
216
|
-
}, [
|
|
217
|
-
createVNode(_component_el_tooltip, { content: "\u6E05\u9664" }, {
|
|
218
|
-
default: withCtx(() => [
|
|
219
|
-
_ctx.val ? (openBlock(), createBlock(_component_el_button, {
|
|
220
|
-
key: 0,
|
|
221
|
-
style: { "padding": "0" },
|
|
222
|
-
type: "danger",
|
|
223
|
-
icon: _ctx.Close,
|
|
224
|
-
text: "",
|
|
225
|
-
onClick: withModifiers(_ctx.deleteHandler, ["stop"])
|
|
226
|
-
}, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
|
|
227
|
-
]),
|
|
228
|
-
_: 1
|
|
229
|
-
}),
|
|
230
|
-
createVNode(_component_el_tooltip, {
|
|
231
|
-
content: _ctx.val ? _ctx.toName + "_" + _ctx.val : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
|
|
232
|
-
}, {
|
|
233
|
-
default: withCtx(() => [
|
|
177
|
+
return (_ctx, _cache) => {
|
|
178
|
+
const _component_el_button = resolveComponent("el-button");
|
|
179
|
+
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
180
|
+
return uiSelectMode.value ? (openBlock(), createElementBlock("div", {
|
|
181
|
+
key: 0,
|
|
182
|
+
class: "m-fields-ui-select",
|
|
183
|
+
onClick: cancelHandler
|
|
184
|
+
}, [
|
|
234
185
|
createVNode(_component_el_button, {
|
|
186
|
+
type: "danger",
|
|
187
|
+
icon: unref(Delete),
|
|
235
188
|
text: "",
|
|
236
|
-
style: { "padding": "0"
|
|
189
|
+
style: { "padding": "0" }
|
|
237
190
|
}, {
|
|
238
191
|
default: withCtx(() => [
|
|
239
|
-
|
|
192
|
+
_hoisted_1$d
|
|
240
193
|
]),
|
|
241
194
|
_: 1
|
|
242
|
-
})
|
|
243
|
-
]),
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
|
|
195
|
+
}, 8, ["icon"])
|
|
196
|
+
])) : (openBlock(), createElementBlock("div", {
|
|
197
|
+
key: 1,
|
|
198
|
+
class: "m-fields-ui-select",
|
|
199
|
+
onClick: startSelect,
|
|
200
|
+
style: { "display": "flex" }
|
|
201
|
+
}, [
|
|
202
|
+
createVNode(_component_el_tooltip, { content: "\u6E05\u9664" }, {
|
|
203
|
+
default: withCtx(() => [
|
|
204
|
+
unref(val) ? (openBlock(), createBlock(_component_el_button, {
|
|
205
|
+
key: 0,
|
|
206
|
+
style: { "padding": "0" },
|
|
207
|
+
type: "danger",
|
|
208
|
+
icon: unref(Close),
|
|
209
|
+
text: "",
|
|
210
|
+
onClick: withModifiers(deleteHandler, ["stop"])
|
|
211
|
+
}, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
|
|
212
|
+
]),
|
|
213
|
+
_: 1
|
|
214
|
+
}),
|
|
215
|
+
createVNode(_component_el_tooltip, {
|
|
216
|
+
content: unref(val) ? unref(toName) + "_" + unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
|
|
217
|
+
}, {
|
|
218
|
+
default: withCtx(() => [
|
|
219
|
+
createVNode(_component_el_button, {
|
|
220
|
+
text: "",
|
|
221
|
+
style: { "padding": "0", "margin": "0" }
|
|
222
|
+
}, {
|
|
223
|
+
default: withCtx(() => [
|
|
224
|
+
createTextVNode(toDisplayString(unref(val) ? unref(toName) + "_" + unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1)
|
|
225
|
+
]),
|
|
226
|
+
_: 1
|
|
227
|
+
})
|
|
228
|
+
]),
|
|
229
|
+
_: 1
|
|
230
|
+
}, 8, ["content"])
|
|
231
|
+
]));
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
const UISelect_vue_vue_type_style_index_0_lang = '';
|
|
249
237
|
|
|
250
238
|
const toString = (v, language) => {
|
|
251
239
|
let value = "";
|
|
@@ -262,7 +250,7 @@ const toString = (v, language) => {
|
|
|
262
250
|
}
|
|
263
251
|
return value;
|
|
264
252
|
};
|
|
265
|
-
const _sfc_main$
|
|
253
|
+
const _sfc_main$k = defineComponent({
|
|
266
254
|
name: "magic-code-editor",
|
|
267
255
|
props: {
|
|
268
256
|
initValues: {
|
|
@@ -369,14 +357,15 @@ const _sfc_main$j = defineComponent({
|
|
|
369
357
|
};
|
|
370
358
|
}
|
|
371
359
|
});
|
|
360
|
+
|
|
372
361
|
const _hoisted_1$c = {
|
|
373
362
|
ref: "codeEditor",
|
|
374
363
|
class: "magic-code-editor"
|
|
375
364
|
};
|
|
376
|
-
function _sfc_render$
|
|
365
|
+
function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
377
366
|
return openBlock(), createElementBlock("div", _hoisted_1$c, null, 512);
|
|
378
367
|
}
|
|
379
|
-
|
|
368
|
+
const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$e]]);
|
|
380
369
|
|
|
381
370
|
let $TMAGIC_EDITOR = {};
|
|
382
371
|
const setConfig = (option) => {
|
|
@@ -385,6 +374,9 @@ const setConfig = (option) => {
|
|
|
385
374
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
386
375
|
|
|
387
376
|
class UndoRedo {
|
|
377
|
+
elementList;
|
|
378
|
+
listCursor;
|
|
379
|
+
listMaxSize;
|
|
388
380
|
constructor(listMaxSize = 200) {
|
|
389
381
|
const minListMaxSize = 2;
|
|
390
382
|
this.elementList = [];
|
|
@@ -461,17 +453,12 @@ const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethod
|
|
|
461
453
|
try {
|
|
462
454
|
let beforeArgs = args;
|
|
463
455
|
for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
|
|
464
|
-
|
|
465
|
-
if (isError(
|
|
466
|
-
throw
|
|
467
|
-
if (!Array.isArray(
|
|
468
|
-
|
|
456
|
+
beforeArgs = await beforeMethod(...beforeArgs) || [];
|
|
457
|
+
if (isError(beforeArgs))
|
|
458
|
+
throw beforeArgs;
|
|
459
|
+
if (!Array.isArray(beforeArgs)) {
|
|
460
|
+
beforeArgs = [beforeArgs];
|
|
469
461
|
}
|
|
470
|
-
beforeArgs = beforeArgs.map((v, index) => {
|
|
471
|
-
if (typeof beforeReturnValue[index] === "undefined")
|
|
472
|
-
return v;
|
|
473
|
-
return beforeReturnValue[index];
|
|
474
|
-
});
|
|
475
462
|
}
|
|
476
463
|
let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
|
|
477
464
|
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
@@ -485,12 +472,12 @@ const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethod
|
|
|
485
472
|
}
|
|
486
473
|
};
|
|
487
474
|
class BaseService extends EventEmitter {
|
|
475
|
+
pluginOptionsList = {};
|
|
476
|
+
middleware = {};
|
|
477
|
+
taskList = [];
|
|
478
|
+
doingTask = false;
|
|
488
479
|
constructor(methods = [], serialMethods = []) {
|
|
489
480
|
super();
|
|
490
|
-
this.pluginOptionsList = {};
|
|
491
|
-
this.middleware = {};
|
|
492
|
-
this.taskList = [];
|
|
493
|
-
this.doingTask = false;
|
|
494
481
|
methods.forEach((propertyName) => {
|
|
495
482
|
const scope = this;
|
|
496
483
|
const sourceMethod = scope[propertyName];
|
|
@@ -547,14 +534,14 @@ class BaseService extends EventEmitter {
|
|
|
547
534
|
}
|
|
548
535
|
|
|
549
536
|
class History extends BaseService {
|
|
537
|
+
state = reactive({
|
|
538
|
+
pageSteps: {},
|
|
539
|
+
pageId: void 0,
|
|
540
|
+
canRedo: false,
|
|
541
|
+
canUndo: false
|
|
542
|
+
});
|
|
550
543
|
constructor() {
|
|
551
544
|
super([]);
|
|
552
|
-
this.state = reactive({
|
|
553
|
-
pageSteps: {},
|
|
554
|
-
pageId: void 0,
|
|
555
|
-
canRedo: false,
|
|
556
|
-
canUndo: false
|
|
557
|
-
});
|
|
558
545
|
this.on("change", this.setCanUndoRedo);
|
|
559
546
|
}
|
|
560
547
|
reset() {
|
|
@@ -623,88 +610,88 @@ class History extends BaseService {
|
|
|
623
610
|
this.state.canUndo = undoRedo?.canUndo() || false;
|
|
624
611
|
}
|
|
625
612
|
}
|
|
626
|
-
|
|
613
|
+
const historyService = new History();
|
|
627
614
|
|
|
628
|
-
|
|
615
|
+
var Protocol = /* @__PURE__ */ ((Protocol2) => {
|
|
616
|
+
Protocol2["OBJECT"] = "object";
|
|
617
|
+
Protocol2["JSON"] = "json";
|
|
618
|
+
Protocol2["STRING"] = "string";
|
|
619
|
+
Protocol2["NUMBER"] = "number";
|
|
620
|
+
Protocol2["BOOLEAN"] = "boolean";
|
|
621
|
+
return Protocol2;
|
|
622
|
+
})(Protocol || {});
|
|
623
|
+
class WebStorage extends BaseService {
|
|
624
|
+
storage = globalThis.localStorage;
|
|
625
|
+
namespace = "tmagic";
|
|
629
626
|
constructor() {
|
|
630
|
-
super(["
|
|
631
|
-
this.state = reactive({
|
|
632
|
-
propsConfigMap: {},
|
|
633
|
-
propsValueMap: {}
|
|
634
|
-
});
|
|
627
|
+
super(["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"]);
|
|
635
628
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
this.setPropsConfig(toLine(type), configs[type]);
|
|
639
|
-
});
|
|
640
|
-
this.emit("props-configs-change");
|
|
629
|
+
async getStorage() {
|
|
630
|
+
return this.storage;
|
|
641
631
|
}
|
|
642
|
-
|
|
643
|
-
this.
|
|
632
|
+
async getNamespace() {
|
|
633
|
+
return this.namespace;
|
|
644
634
|
}
|
|
645
|
-
async
|
|
646
|
-
|
|
647
|
-
|
|
635
|
+
async clear() {
|
|
636
|
+
const storage2 = await this.getStorage();
|
|
637
|
+
storage2.clear();
|
|
638
|
+
}
|
|
639
|
+
async getItem(key, options = {}) {
|
|
640
|
+
const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
641
|
+
const { protocol = options.protocol, item } = this.getValueAndProtocol(storage.getItem(`${options.namespace || namespace}:${key}`));
|
|
642
|
+
if (item === null)
|
|
643
|
+
return null;
|
|
644
|
+
switch (protocol) {
|
|
645
|
+
case "object" /* OBJECT */:
|
|
646
|
+
return eval(`(${item})`);
|
|
647
|
+
case "json" /* JSON */:
|
|
648
|
+
return JSON.parse(item);
|
|
649
|
+
case "number" /* NUMBER */:
|
|
650
|
+
return Number(item);
|
|
651
|
+
case "boolean" /* BOOLEAN */:
|
|
652
|
+
return Boolean(item);
|
|
653
|
+
default:
|
|
654
|
+
return item;
|
|
648
655
|
}
|
|
649
|
-
return cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
|
|
650
656
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
});
|
|
657
|
+
async key(index) {
|
|
658
|
+
const storage2 = await this.getStorage();
|
|
659
|
+
return storage2.key(index);
|
|
655
660
|
}
|
|
656
|
-
|
|
657
|
-
|
|
661
|
+
async removeItem(key2, options2 = {}) {
|
|
662
|
+
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
663
|
+
storage2.removeItem(`${options2.namespace || namespace2}:${key2}`);
|
|
658
664
|
}
|
|
659
|
-
async
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
}
|
|
667
|
-
return value;
|
|
665
|
+
async setItem(key2, value, options2 = {}) {
|
|
666
|
+
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
667
|
+
let item2 = value;
|
|
668
|
+
const protocol2 = options2.protocol ? `${options2.protocol}:` : "";
|
|
669
|
+
if (typeof value === "string" /* STRING */ || typeof value === "number" /* NUMBER */) {
|
|
670
|
+
item2 = `${protocol2}${value}`;
|
|
671
|
+
} else {
|
|
672
|
+
item2 = `${protocol2}${serialize(value)}`;
|
|
668
673
|
}
|
|
669
|
-
|
|
670
|
-
await this.setNewItemId(data);
|
|
671
|
-
return {
|
|
672
|
-
...getDefaultPropsValue(type, await this.createId(type)),
|
|
673
|
-
...mergeWith(cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
674
|
-
};
|
|
675
|
-
}
|
|
676
|
-
async createId(type) {
|
|
677
|
-
return `${type}_${random(1e4, false)}`;
|
|
674
|
+
storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
|
|
678
675
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
for (const item of config.items) {
|
|
687
|
-
await this.setNewItemId(item, config);
|
|
688
|
-
}
|
|
676
|
+
getValueAndProtocol(value) {
|
|
677
|
+
let protocol2 = "";
|
|
678
|
+
if (value === null) {
|
|
679
|
+
return {
|
|
680
|
+
item: value,
|
|
681
|
+
protocol: protocol2
|
|
682
|
+
};
|
|
689
683
|
}
|
|
684
|
+
const item2 = value.replace(new RegExp(`^(${Object.values(Protocol).join("|")})(:)(.+)`), (_$0, $1, _$2, $3) => {
|
|
685
|
+
protocol2 = $1;
|
|
686
|
+
return $3;
|
|
687
|
+
});
|
|
688
|
+
return {
|
|
689
|
+
protocol: protocol2,
|
|
690
|
+
item: item2
|
|
691
|
+
};
|
|
690
692
|
}
|
|
691
693
|
}
|
|
692
|
-
const
|
|
693
|
-
pageConfig.items?.forEach((config) => {
|
|
694
|
-
if (config.pop === oldId) {
|
|
695
|
-
config.pop = popId;
|
|
696
|
-
return;
|
|
697
|
-
}
|
|
698
|
-
if (config.popId === oldId) {
|
|
699
|
-
config.popId = popId;
|
|
700
|
-
return;
|
|
701
|
-
}
|
|
702
|
-
if (Array.isArray(config.items)) {
|
|
703
|
-
updatePopId(oldId, popId, config);
|
|
704
|
-
}
|
|
705
|
-
});
|
|
706
|
-
};
|
|
707
|
-
var propsService = new Props();
|
|
694
|
+
const storageService = new WebStorage();
|
|
708
695
|
|
|
709
696
|
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
710
697
|
LayerOffset2["TOP"] = "top";
|
|
@@ -750,56 +737,49 @@ const getNodeIndex = (node, parent) => {
|
|
|
750
737
|
const items = parent?.items || [];
|
|
751
738
|
return items.findIndex((item) => `${item.id}` === `${node.id}`);
|
|
752
739
|
};
|
|
753
|
-
const
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
const style = node.style || {};
|
|
764
|
-
let height = style.height || 0;
|
|
765
|
-
if (!stage || typeof style.top !== "undefined" || !parentNode.style)
|
|
766
|
-
return style;
|
|
740
|
+
const getRelativeStyle = (style = {}) => ({
|
|
741
|
+
...style,
|
|
742
|
+
position: "relative",
|
|
743
|
+
top: 0,
|
|
744
|
+
left: 0
|
|
745
|
+
});
|
|
746
|
+
const getMiddleTop = (node, parentNode, stage) => {
|
|
747
|
+
let height = node.style?.height || 0;
|
|
748
|
+
if (!stage || typeof node.style?.top !== "undefined" || !parentNode.style)
|
|
749
|
+
return node.style?.top;
|
|
767
750
|
if (!isNumber(height)) {
|
|
768
751
|
height = 0;
|
|
769
752
|
}
|
|
770
753
|
const { height: parentHeight } = parentNode.style;
|
|
771
754
|
if (isPage(parentNode)) {
|
|
772
755
|
const { scrollTop = 0, wrapperHeight } = stage.mask;
|
|
773
|
-
|
|
774
|
-
} else {
|
|
775
|
-
style.top = (parentHeight - height) / 2;
|
|
756
|
+
return (wrapperHeight - height) / 2 + scrollTop;
|
|
776
757
|
}
|
|
777
|
-
return
|
|
758
|
+
return (parentHeight - height) / 2;
|
|
778
759
|
};
|
|
779
|
-
const
|
|
760
|
+
const getInitPositionStyle = (style = {}, layout) => {
|
|
780
761
|
if (layout === Layout.ABSOLUTE) {
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
762
|
+
return {
|
|
763
|
+
...style,
|
|
764
|
+
position: "absolute"
|
|
784
765
|
};
|
|
785
|
-
return node;
|
|
786
766
|
}
|
|
787
767
|
if (layout === Layout.RELATIVE) {
|
|
788
|
-
return
|
|
768
|
+
return getRelativeStyle(style);
|
|
789
769
|
}
|
|
790
|
-
return
|
|
770
|
+
return style;
|
|
791
771
|
};
|
|
792
772
|
const setLayout = (node, layout) => {
|
|
793
773
|
node.items?.forEach((child) => {
|
|
794
774
|
if (isPop(child))
|
|
795
775
|
return;
|
|
796
|
-
|
|
797
|
-
if (
|
|
776
|
+
const style = child.style || {};
|
|
777
|
+
if (style.position === "fixed")
|
|
798
778
|
return;
|
|
799
779
|
if (layout !== Layout.RELATIVE) {
|
|
800
|
-
|
|
780
|
+
style.position = "absolute";
|
|
801
781
|
} else {
|
|
802
|
-
|
|
782
|
+
child.style = getRelativeStyle(style);
|
|
803
783
|
child.style.right = "auto";
|
|
804
784
|
child.style.bottom = "auto";
|
|
805
785
|
}
|
|
@@ -816,11 +796,10 @@ const change2Fixed = (node, root) => {
|
|
|
816
796
|
offset.left = offset.left + globalThis.parseFloat(value.style?.left || 0);
|
|
817
797
|
offset.top = offset.top + globalThis.parseFloat(value.style?.top || 0);
|
|
818
798
|
});
|
|
819
|
-
|
|
799
|
+
return {
|
|
820
800
|
...node.style || {},
|
|
821
801
|
...offset
|
|
822
802
|
};
|
|
823
|
-
return node;
|
|
824
803
|
};
|
|
825
804
|
const Fixed2Other = async (node, root, getLayout) => {
|
|
826
805
|
const path = getNodePath(node.id, root.items);
|
|
@@ -835,20 +814,20 @@ const Fixed2Other = async (node, root, getLayout) => {
|
|
|
835
814
|
offset.left = offset.left - globalThis.parseFloat(value.style?.left || 0);
|
|
836
815
|
offset.top = offset.top - globalThis.parseFloat(value.style?.top || 0);
|
|
837
816
|
});
|
|
817
|
+
const style = node.style || {};
|
|
838
818
|
const parent = path.pop();
|
|
839
819
|
if (!parent) {
|
|
840
|
-
return
|
|
820
|
+
return getRelativeStyle(style);
|
|
841
821
|
}
|
|
842
822
|
const layout = await getLayout(parent);
|
|
843
823
|
if (layout !== Layout.RELATIVE) {
|
|
844
|
-
|
|
845
|
-
...
|
|
824
|
+
return {
|
|
825
|
+
...style,
|
|
846
826
|
...offset,
|
|
847
827
|
position: "absolute"
|
|
848
828
|
};
|
|
849
|
-
return node;
|
|
850
829
|
}
|
|
851
|
-
return
|
|
830
|
+
return getRelativeStyle(style);
|
|
852
831
|
};
|
|
853
832
|
const getGuideLineFromCache = (key) => {
|
|
854
833
|
if (!key)
|
|
@@ -863,50 +842,248 @@ const getGuideLineFromCache = (key) => {
|
|
|
863
842
|
}
|
|
864
843
|
return [];
|
|
865
844
|
};
|
|
866
|
-
|
|
867
|
-
|
|
845
|
+
const fixNodeLeft = (config, parent, doc) => {
|
|
846
|
+
if (!doc || !config.style || !isNumber(config.style.left))
|
|
847
|
+
return config.style?.left;
|
|
848
|
+
const el = doc.getElementById(`${config.id}`);
|
|
849
|
+
const parentEl = doc.getElementById(`${parent.id}`);
|
|
850
|
+
const left = Number(config.style?.left) || 0;
|
|
851
|
+
if (el && parentEl && el.offsetWidth + left > parentEl.offsetWidth) {
|
|
852
|
+
return parentEl.offsetWidth - el.offsetWidth;
|
|
853
|
+
}
|
|
854
|
+
return config.style.left;
|
|
868
855
|
};
|
|
869
|
-
const
|
|
856
|
+
const fixNodePosition = (config, parent, stage) => {
|
|
857
|
+
if (config.style?.position !== "absolute") {
|
|
858
|
+
return config.style;
|
|
859
|
+
}
|
|
860
|
+
return {
|
|
861
|
+
...config.style || {},
|
|
862
|
+
top: getMiddleTop(config, parent, stage),
|
|
863
|
+
left: fixNodeLeft(config, parent, stage?.renderer.contentWindow?.document)
|
|
864
|
+
};
|
|
870
865
|
};
|
|
871
|
-
|
|
866
|
+
|
|
867
|
+
class Props extends BaseService {
|
|
868
|
+
state = reactive({
|
|
869
|
+
propsConfigMap: {},
|
|
870
|
+
propsValueMap: {}
|
|
871
|
+
});
|
|
872
|
+
constructor() {
|
|
873
|
+
super([
|
|
874
|
+
"setPropsConfig",
|
|
875
|
+
"getPropsConfig",
|
|
876
|
+
"setPropsValue",
|
|
877
|
+
"getPropsValue",
|
|
878
|
+
"createId",
|
|
879
|
+
"setNewItemId",
|
|
880
|
+
"getDefaultPropsValue"
|
|
881
|
+
]);
|
|
882
|
+
}
|
|
883
|
+
setPropsConfigs(configs) {
|
|
884
|
+
Object.keys(configs).forEach((type) => {
|
|
885
|
+
this.setPropsConfig(toLine(type), configs[type]);
|
|
886
|
+
});
|
|
887
|
+
this.emit("props-configs-change");
|
|
888
|
+
}
|
|
889
|
+
setPropsConfig(type, config) {
|
|
890
|
+
this.state.propsConfigMap[type] = fillConfig(Array.isArray(config) ? config : [config]);
|
|
891
|
+
}
|
|
892
|
+
async getPropsConfig(type) {
|
|
893
|
+
if (type === "area") {
|
|
894
|
+
return await this.getPropsConfig("button");
|
|
895
|
+
}
|
|
896
|
+
return cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
|
|
897
|
+
}
|
|
898
|
+
setPropsValues(values) {
|
|
899
|
+
Object.keys(values).forEach((type) => {
|
|
900
|
+
this.setPropsValue(toLine(type), values[type]);
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
setPropsValue(type, value) {
|
|
904
|
+
this.state.propsValueMap[type] = value;
|
|
905
|
+
}
|
|
906
|
+
async getPropsValue(type, { inputEvent, ...defaultValue } = {}) {
|
|
907
|
+
if (type === "area") {
|
|
908
|
+
const value = await this.getPropsValue("button");
|
|
909
|
+
value.className = "action-area";
|
|
910
|
+
value.text = "";
|
|
911
|
+
if (value.style) {
|
|
912
|
+
value.style.backgroundColor = "rgba(255, 255, 255, 0)";
|
|
913
|
+
}
|
|
914
|
+
return value;
|
|
915
|
+
}
|
|
916
|
+
const [id, defaultPropsValue, data] = await Promise.all([
|
|
917
|
+
this.createId(type),
|
|
918
|
+
this.getDefaultPropsValue(type),
|
|
919
|
+
this.setNewItemId(cloneDeep({
|
|
920
|
+
type,
|
|
921
|
+
...defaultValue
|
|
922
|
+
}))
|
|
923
|
+
]);
|
|
924
|
+
return {
|
|
925
|
+
id,
|
|
926
|
+
...defaultPropsValue,
|
|
927
|
+
...mergeWith({}, cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
guid(digit = 8) {
|
|
931
|
+
return "x".repeat(digit).replace(/[xy]/g, (c) => {
|
|
932
|
+
const r = Math.random() * 16 | 0;
|
|
933
|
+
const v = c == "x" ? r : r & 3 | 8;
|
|
934
|
+
return v.toString(16);
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
async createId(type) {
|
|
938
|
+
return `${type}_${this.guid()}`;
|
|
939
|
+
}
|
|
940
|
+
async setNewItemId(config, parent) {
|
|
941
|
+
const oldId = config.id;
|
|
942
|
+
config.id = await this.createId(config.type || "component");
|
|
943
|
+
if (isPop(config) && parent?.type === NodeType.PAGE) {
|
|
944
|
+
updatePopId(oldId, config.id, parent);
|
|
945
|
+
}
|
|
946
|
+
if (config.items && Array.isArray(config.items)) {
|
|
947
|
+
for (const item of config.items) {
|
|
948
|
+
await this.setNewItemId(item, config);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
return config;
|
|
952
|
+
}
|
|
953
|
+
async getDefaultPropsValue(type) {
|
|
954
|
+
return ["page", "container"].includes(type) ? {
|
|
955
|
+
type,
|
|
956
|
+
layout: "absolute",
|
|
957
|
+
style: {},
|
|
958
|
+
name: type,
|
|
959
|
+
items: []
|
|
960
|
+
} : {
|
|
961
|
+
type,
|
|
962
|
+
style: {},
|
|
963
|
+
name: type
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
const updatePopId = (oldId, popId, pageConfig) => {
|
|
968
|
+
pageConfig.items?.forEach((config) => {
|
|
969
|
+
if (config.pop === oldId) {
|
|
970
|
+
config.pop = popId;
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
if (config.popId === oldId) {
|
|
974
|
+
config.popId = popId;
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
if (Array.isArray(config.items)) {
|
|
978
|
+
updatePopId(oldId, popId, config);
|
|
979
|
+
}
|
|
980
|
+
});
|
|
872
981
|
};
|
|
873
|
-
const
|
|
982
|
+
const propsService = new Props();
|
|
983
|
+
|
|
984
|
+
const beforePaste = async (position, config) => {
|
|
985
|
+
if (!config[0]?.style)
|
|
986
|
+
return config;
|
|
987
|
+
const curNode = editorService.get("node");
|
|
988
|
+
const { left: referenceLeft, top: referenceTop } = config[0].style;
|
|
989
|
+
const pasteConfigs = await Promise.all(config.map(async (configItem) => {
|
|
990
|
+
const { offsetX = 0, offsetY = 0, ...positionClone } = position;
|
|
991
|
+
let pastePosition = positionClone;
|
|
992
|
+
if (!isEmpty(pastePosition) && curNode.items) {
|
|
993
|
+
pastePosition = getPositionInContainer(pastePosition, curNode.id);
|
|
994
|
+
}
|
|
995
|
+
if (pastePosition.left && configItem.style?.left) {
|
|
996
|
+
pastePosition.left = configItem.style.left - referenceLeft + pastePosition.left;
|
|
997
|
+
}
|
|
998
|
+
if (pastePosition.top && configItem.style?.top) {
|
|
999
|
+
pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
|
|
1000
|
+
}
|
|
1001
|
+
const pasteConfig = await propsService.setNewItemId(configItem, editorService.get("root"));
|
|
1002
|
+
if (pasteConfig.style) {
|
|
1003
|
+
const { left, top } = pasteConfig.style;
|
|
1004
|
+
if (typeof left === "number" || !!left && !isNaN(Number(left))) {
|
|
1005
|
+
pasteConfig.style.left = Number(left) + offsetX;
|
|
1006
|
+
}
|
|
1007
|
+
if (typeof top === "number" || !!top && !isNaN(Number(top))) {
|
|
1008
|
+
pasteConfig.style.top = Number(top) + offsetY;
|
|
1009
|
+
}
|
|
1010
|
+
pasteConfig.style = {
|
|
1011
|
+
...pasteConfig.style,
|
|
1012
|
+
...pastePosition
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
if (isPage(pasteConfig)) {
|
|
1016
|
+
pasteConfig.name = generatePageNameByApp(editorService.get("root"));
|
|
1017
|
+
}
|
|
1018
|
+
return pasteConfig;
|
|
1019
|
+
}));
|
|
1020
|
+
return pasteConfigs;
|
|
874
1021
|
};
|
|
875
|
-
const
|
|
1022
|
+
const getPositionInContainer = (position = {}, id) => {
|
|
1023
|
+
let { left = 0, top = 0 } = position;
|
|
1024
|
+
const parentEl = editorService.get("stage")?.renderer?.contentWindow?.document.getElementById(`${id}`);
|
|
1025
|
+
const parentElRect = parentEl?.getBoundingClientRect();
|
|
1026
|
+
left = left - (parentElRect?.left || 0);
|
|
1027
|
+
top = top - (parentElRect?.top || 0);
|
|
1028
|
+
return {
|
|
1029
|
+
left,
|
|
1030
|
+
top
|
|
1031
|
+
};
|
|
1032
|
+
};
|
|
1033
|
+
const getAddParent = (node) => {
|
|
1034
|
+
const curNode = editorService.get("node");
|
|
1035
|
+
let parentNode;
|
|
1036
|
+
if (isPage(node)) {
|
|
1037
|
+
parentNode = editorService.get("root");
|
|
1038
|
+
} else if (curNode.items) {
|
|
1039
|
+
parentNode = curNode;
|
|
1040
|
+
} else {
|
|
1041
|
+
parentNode = editorService.getParentById(curNode.id, false);
|
|
1042
|
+
}
|
|
1043
|
+
return parentNode;
|
|
876
1044
|
};
|
|
877
1045
|
|
|
878
1046
|
class Editor$1 extends BaseService {
|
|
1047
|
+
state = reactive({
|
|
1048
|
+
root: null,
|
|
1049
|
+
page: null,
|
|
1050
|
+
parent: null,
|
|
1051
|
+
node: null,
|
|
1052
|
+
nodes: [],
|
|
1053
|
+
stage: null,
|
|
1054
|
+
highlightNode: null,
|
|
1055
|
+
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
1056
|
+
pageLength: 0
|
|
1057
|
+
});
|
|
1058
|
+
isHistoryStateChange = false;
|
|
879
1059
|
constructor() {
|
|
880
1060
|
super([
|
|
881
1061
|
"getLayout",
|
|
882
1062
|
"select",
|
|
1063
|
+
"doAdd",
|
|
883
1064
|
"add",
|
|
1065
|
+
"doRemove",
|
|
884
1066
|
"remove",
|
|
1067
|
+
"doUpdate",
|
|
885
1068
|
"update",
|
|
886
1069
|
"sort",
|
|
887
1070
|
"copy",
|
|
888
1071
|
"paste",
|
|
1072
|
+
"duAlignCenter",
|
|
889
1073
|
"alignCenter",
|
|
890
1074
|
"moveLayer",
|
|
1075
|
+
"moveToContainer",
|
|
891
1076
|
"move",
|
|
892
1077
|
"undo",
|
|
893
1078
|
"redo",
|
|
894
1079
|
"highlight"
|
|
895
1080
|
], ["select", "update", "moveLayer"]);
|
|
896
|
-
this.isHistoryStateChange = false;
|
|
897
|
-
this.state = reactive({
|
|
898
|
-
root: null,
|
|
899
|
-
page: null,
|
|
900
|
-
parent: null,
|
|
901
|
-
node: null,
|
|
902
|
-
stage: null,
|
|
903
|
-
highlightNode: null,
|
|
904
|
-
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
905
|
-
pageLength: 0
|
|
906
|
-
});
|
|
907
1081
|
}
|
|
908
1082
|
set(name, value) {
|
|
909
1083
|
this.state[name] = value;
|
|
1084
|
+
if (name === "nodes") {
|
|
1085
|
+
this.set("node", value[0]);
|
|
1086
|
+
}
|
|
910
1087
|
if (name === "root") {
|
|
911
1088
|
this.state.pageLength = value?.items?.length || 0;
|
|
912
1089
|
this.emit("root-change", value);
|
|
@@ -961,9 +1138,9 @@ class Editor$1 extends BaseService {
|
|
|
961
1138
|
}
|
|
962
1139
|
return Layout.ABSOLUTE;
|
|
963
1140
|
}
|
|
964
|
-
async select(
|
|
965
|
-
const { node, page, parent } = this.selectedConfigExceptionHandler(
|
|
966
|
-
this.set("
|
|
1141
|
+
async select(config) {
|
|
1142
|
+
const { node, page, parent } = this.selectedConfigExceptionHandler(config);
|
|
1143
|
+
this.set("nodes", [node]);
|
|
967
1144
|
this.set("page", page || null);
|
|
968
1145
|
this.set("parent", parent || null);
|
|
969
1146
|
if (page) {
|
|
@@ -1003,56 +1180,83 @@ class Editor$1 extends BaseService {
|
|
|
1003
1180
|
this.get("stage")?.select(nextPage.id);
|
|
1004
1181
|
return nextPage;
|
|
1005
1182
|
}
|
|
1006
|
-
highlight(
|
|
1007
|
-
const { node } = this.selectedConfigExceptionHandler(
|
|
1183
|
+
highlight(config) {
|
|
1184
|
+
const { node } = this.selectedConfigExceptionHandler(config);
|
|
1008
1185
|
const currentHighlightNode = this.get("highlightNode");
|
|
1009
1186
|
if (currentHighlightNode === node)
|
|
1010
1187
|
return;
|
|
1011
1188
|
this.set("highlightNode", node);
|
|
1012
1189
|
}
|
|
1013
|
-
|
|
1014
|
-
const
|
|
1190
|
+
multiSelect(ids) {
|
|
1191
|
+
const nodes = [];
|
|
1192
|
+
const idsUnique = uniq(ids);
|
|
1193
|
+
idsUnique.forEach((id) => {
|
|
1194
|
+
const { node } = this.getNodeInfo(id);
|
|
1195
|
+
if (!node)
|
|
1196
|
+
return;
|
|
1197
|
+
nodes.push(node);
|
|
1198
|
+
});
|
|
1199
|
+
this.set("nodes", nodes);
|
|
1200
|
+
}
|
|
1201
|
+
async doAdd(node, parent) {
|
|
1202
|
+
const root = this.get("root");
|
|
1015
1203
|
const curNode = this.get("node");
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
if (isPage2) {
|
|
1019
|
-
parentNode = this.get("root");
|
|
1020
|
-
} else if (parent && typeof parent !== "function") {
|
|
1021
|
-
parentNode = parent;
|
|
1022
|
-
} else if (curNode.items) {
|
|
1023
|
-
parentNode = curNode;
|
|
1024
|
-
} else {
|
|
1025
|
-
parentNode = this.getParentById(curNode.id, false);
|
|
1026
|
-
}
|
|
1027
|
-
if (!parentNode)
|
|
1028
|
-
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1029
|
-
const layout = await this.getLayout(toRaw(parentNode), addNode);
|
|
1030
|
-
const newNode = initPosition({ ...toRaw(await propsService.getPropsValue(type, config2)) }, layout, parentNode, this.get("stage"));
|
|
1031
|
-
if ((parentNode?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && newNode.type !== NodeType.PAGE) {
|
|
1204
|
+
const stage = this.get("stage");
|
|
1205
|
+
if ((parent?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && node.type !== NodeType.PAGE) {
|
|
1032
1206
|
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
1033
1207
|
}
|
|
1034
|
-
|
|
1208
|
+
parent?.items?.push(node);
|
|
1209
|
+
const layout = await this.getLayout(toRaw(parent), node);
|
|
1210
|
+
node.style = getInitPositionStyle(node.style, layout);
|
|
1211
|
+
await stage?.add({
|
|
1212
|
+
config: cloneDeep(node),
|
|
1213
|
+
parent: cloneDeep(parent),
|
|
1214
|
+
parentId: parent.id,
|
|
1215
|
+
root: cloneDeep(root)
|
|
1216
|
+
});
|
|
1217
|
+
node.style = fixNodePosition(node, parent, stage);
|
|
1218
|
+
await stage?.update({ config: cloneDeep(node), parentId: parent.id, root: cloneDeep(root) });
|
|
1219
|
+
this.addModifiedNodeId(node.id);
|
|
1220
|
+
return node;
|
|
1221
|
+
}
|
|
1222
|
+
async add(addNode, parent) {
|
|
1035
1223
|
const stage = this.get("stage");
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1224
|
+
const addNodes = [];
|
|
1225
|
+
if (!Array.isArray(addNode)) {
|
|
1226
|
+
const { type, inputEvent, ...config } = addNode;
|
|
1227
|
+
if (!type)
|
|
1228
|
+
throw new Error("\u7EC4\u4EF6\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A");
|
|
1229
|
+
addNodes.push({ ...toRaw(await propsService.getPropsValue(type, config)) });
|
|
1230
|
+
} else {
|
|
1231
|
+
addNodes.push(...addNode);
|
|
1041
1232
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1233
|
+
const newNodes = await Promise.all(addNodes.map((node) => {
|
|
1234
|
+
const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
|
|
1235
|
+
if (!parentNode)
|
|
1236
|
+
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1237
|
+
return this.doAdd(node, parentNode);
|
|
1238
|
+
}));
|
|
1239
|
+
if (newNodes.length > 1) {
|
|
1240
|
+
const newNodeIds = newNodes.map((node) => node.id);
|
|
1241
|
+
stage?.multiSelect(newNodeIds);
|
|
1242
|
+
await this.multiSelect(newNodeIds);
|
|
1243
|
+
} else {
|
|
1244
|
+
await this.select(newNodes[0]);
|
|
1245
|
+
if (isPage(newNodes[0])) {
|
|
1246
|
+
this.state.pageLength += 1;
|
|
1247
|
+
} else {
|
|
1248
|
+
stage?.select(newNodes[0].id);
|
|
1249
|
+
}
|
|
1045
1250
|
}
|
|
1046
|
-
this.
|
|
1047
|
-
|
|
1251
|
+
this.pushHistoryState();
|
|
1252
|
+
this.emit("add", newNodes);
|
|
1253
|
+
return newNodes.length > 1 ? newNodes[0] : newNodes;
|
|
1048
1254
|
}
|
|
1049
|
-
async
|
|
1050
|
-
if (!node?.id)
|
|
1051
|
-
return;
|
|
1255
|
+
async doRemove(node) {
|
|
1052
1256
|
const root = this.get("root");
|
|
1053
1257
|
if (!root)
|
|
1054
1258
|
throw new Error("\u6CA1\u6709root");
|
|
1055
|
-
const { parent, node: curNode } = this.getNodeInfo(node.id
|
|
1259
|
+
const { parent, node: curNode } = this.getNodeInfo(node.id);
|
|
1056
1260
|
if (!parent || !curNode)
|
|
1057
1261
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1058
1262
|
const index = getNodeIndex(curNode, parent);
|
|
@@ -1060,7 +1264,7 @@ class Editor$1 extends BaseService {
|
|
|
1060
1264
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1061
1265
|
parent.items?.splice(index, 1);
|
|
1062
1266
|
const stage = this.get("stage");
|
|
1063
|
-
stage?.remove({ id: node.id, root:
|
|
1267
|
+
stage?.remove({ id: node.id, parentId: parent.id, root: cloneDeep(root) });
|
|
1064
1268
|
if (node.type === NodeType.PAGE) {
|
|
1065
1269
|
this.state.pageLength -= 1;
|
|
1066
1270
|
if (root.items[0]) {
|
|
@@ -1074,26 +1278,28 @@ class Editor$1 extends BaseService {
|
|
|
1074
1278
|
this.set("highlightNode", null);
|
|
1075
1279
|
this.resetModifiedNodeId();
|
|
1076
1280
|
historyService.reset();
|
|
1077
|
-
|
|
1078
|
-
return node;
|
|
1281
|
+
return;
|
|
1079
1282
|
}
|
|
1080
1283
|
} else {
|
|
1081
1284
|
await this.select(parent);
|
|
1082
1285
|
stage?.select(parent.id);
|
|
1083
1286
|
}
|
|
1084
1287
|
this.addModifiedNodeId(parent.id);
|
|
1288
|
+
}
|
|
1289
|
+
async remove(nodeOrNodeList) {
|
|
1290
|
+
const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
|
|
1291
|
+
await Promise.all(nodes.map((node) => this.doRemove(node)));
|
|
1085
1292
|
this.pushHistoryState();
|
|
1086
|
-
this.emit("remove"
|
|
1087
|
-
return node;
|
|
1293
|
+
this.emit("remove");
|
|
1088
1294
|
}
|
|
1089
|
-
async
|
|
1090
|
-
if (!
|
|
1295
|
+
async doUpdate(config) {
|
|
1296
|
+
if (!config?.id)
|
|
1091
1297
|
throw new Error("\u6CA1\u6709\u914D\u7F6E\u6216\u8005\u914D\u7F6E\u7F3A\u5C11id\u503C");
|
|
1092
|
-
const info = this.getNodeInfo(
|
|
1298
|
+
const info = this.getNodeInfo(config.id, false);
|
|
1093
1299
|
if (!info.node)
|
|
1094
|
-
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${
|
|
1300
|
+
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config.id}\u7684\u8282\u70B9`);
|
|
1095
1301
|
const node = cloneDeep(toRaw(info.node));
|
|
1096
|
-
let newConfig = await this.toggleFixedPosition(toRaw(
|
|
1302
|
+
let newConfig = await this.toggleFixedPosition(toRaw(config), node, this.get("root"));
|
|
1097
1303
|
newConfig = mergeWith(cloneDeep(node), newConfig, (objValue, srcValue) => {
|
|
1098
1304
|
if (Array.isArray(srcValue)) {
|
|
1099
1305
|
return srcValue;
|
|
@@ -1118,18 +1324,28 @@ class Editor$1 extends BaseService {
|
|
|
1118
1324
|
newConfig = setLayout(newConfig, newLayout);
|
|
1119
1325
|
}
|
|
1120
1326
|
parentNodeItems[index] = newConfig;
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
this.
|
|
1327
|
+
const nodes = this.get("nodes");
|
|
1328
|
+
const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
|
|
1329
|
+
nodes.splice(targetIndex, 1, newConfig);
|
|
1330
|
+
this.set("nodes", nodes);
|
|
1331
|
+
this.get("stage")?.update({
|
|
1332
|
+
config: cloneDeep(newConfig),
|
|
1333
|
+
parentId: parent.id,
|
|
1334
|
+
root: cloneDeep(this.get("root"))
|
|
1335
|
+
});
|
|
1125
1336
|
if (newConfig.type === NodeType.PAGE) {
|
|
1126
1337
|
this.set("page", newConfig);
|
|
1127
1338
|
}
|
|
1128
1339
|
this.addModifiedNodeId(newConfig.id);
|
|
1129
|
-
this.pushHistoryState();
|
|
1130
|
-
this.emit("update", newConfig);
|
|
1131
1340
|
return newConfig;
|
|
1132
1341
|
}
|
|
1342
|
+
async update(config) {
|
|
1343
|
+
const nodes = Array.isArray(config) ? config : [config];
|
|
1344
|
+
const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
|
|
1345
|
+
this.pushHistoryState();
|
|
1346
|
+
this.emit("update", newNodes);
|
|
1347
|
+
return newNodes.length > 1 ? newNodes[0] : newNodes;
|
|
1348
|
+
}
|
|
1133
1349
|
async sort(id1, id2) {
|
|
1134
1350
|
const node = this.get("node");
|
|
1135
1351
|
const parent = cloneDeep(toRaw(this.get("parent")));
|
|
@@ -1140,62 +1356,57 @@ class Editor$1 extends BaseService {
|
|
|
1140
1356
|
parent.items.splice(index2, 0, ...parent.items.splice(index1, 1));
|
|
1141
1357
|
await this.update(parent);
|
|
1142
1358
|
await this.select(node);
|
|
1143
|
-
this.get("stage")?.update({
|
|
1359
|
+
this.get("stage")?.update({
|
|
1360
|
+
config: cloneDeep(node),
|
|
1361
|
+
parentId: parent.id,
|
|
1362
|
+
root: cloneDeep(this.get("root"))
|
|
1363
|
+
});
|
|
1144
1364
|
this.addModifiedNodeId(parent.id);
|
|
1145
1365
|
this.pushHistoryState();
|
|
1146
1366
|
}
|
|
1147
|
-
async copy(
|
|
1148
|
-
|
|
1367
|
+
async copy(config) {
|
|
1368
|
+
await storageService.setItem(COPY_STORAGE_KEY, Array.isArray(config) ? config : [config], {
|
|
1369
|
+
protocol: Protocol.OBJECT
|
|
1370
|
+
});
|
|
1149
1371
|
}
|
|
1150
1372
|
async paste(position = {}) {
|
|
1151
|
-
const
|
|
1152
|
-
|
|
1153
|
-
if (!configStr) {
|
|
1154
|
-
return;
|
|
1155
|
-
}
|
|
1156
|
-
try {
|
|
1157
|
-
eval(`config = ${configStr}`);
|
|
1158
|
-
} catch (e) {
|
|
1159
|
-
console.error(e);
|
|
1373
|
+
const config = await storageService.getItem(COPY_STORAGE_KEY);
|
|
1374
|
+
if (!Array.isArray(config))
|
|
1160
1375
|
return;
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
if (config.style) {
|
|
1164
|
-
config.style = {
|
|
1165
|
-
...config.style,
|
|
1166
|
-
...position
|
|
1167
|
-
};
|
|
1168
|
-
}
|
|
1169
|
-
if (isPage(config)) {
|
|
1170
|
-
config.name = generatePageNameByApp(this.get("root"));
|
|
1171
|
-
}
|
|
1172
|
-
return await this.add(config);
|
|
1376
|
+
const pasteConfigs = await beforePaste(position, config);
|
|
1377
|
+
return this.add(pasteConfigs);
|
|
1173
1378
|
}
|
|
1174
|
-
async
|
|
1175
|
-
const parent = this.
|
|
1176
|
-
|
|
1177
|
-
|
|
1379
|
+
async doAlignCenter(config) {
|
|
1380
|
+
const parent = this.getParentById(config.id);
|
|
1381
|
+
if (!parent)
|
|
1382
|
+
throw new Error("\u627E\u4E0D\u5230\u7236\u8282\u70B9");
|
|
1383
|
+
const node = cloneDeep(toRaw(config));
|
|
1384
|
+
const layout = await this.getLayout(parent, node);
|
|
1178
1385
|
if (layout === Layout.RELATIVE) {
|
|
1179
|
-
return;
|
|
1386
|
+
return config;
|
|
1180
1387
|
}
|
|
1181
1388
|
if (!node.style)
|
|
1182
|
-
return;
|
|
1389
|
+
return config;
|
|
1183
1390
|
const stage = this.get("stage");
|
|
1184
1391
|
const doc = stage?.renderer.contentWindow?.document;
|
|
1185
1392
|
if (doc) {
|
|
1186
|
-
const parentEl = doc.getElementById(`${parent.id}`);
|
|
1187
1393
|
const el = doc.getElementById(`${node.id}`);
|
|
1394
|
+
const parentEl = el?.offsetParent;
|
|
1188
1395
|
if (parentEl && el) {
|
|
1189
1396
|
node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
|
|
1190
1397
|
}
|
|
1191
1398
|
} else if (parent.style && isNumber(parent.style?.width) && isNumber(node.style?.width)) {
|
|
1192
1399
|
node.style.left = (parent.style.width - node.style.width) / 2;
|
|
1193
1400
|
}
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1401
|
+
return node;
|
|
1402
|
+
}
|
|
1403
|
+
async alignCenter(config) {
|
|
1404
|
+
const nodes = Array.isArray(config) ? config : [config];
|
|
1405
|
+
const stage = this.get("stage");
|
|
1406
|
+
const newNodes = await Promise.all(nodes.map((node) => this.doAlignCenter(node)));
|
|
1407
|
+
const newNode = await this.update(newNodes);
|
|
1408
|
+
await stage?.multiSelect(newNodes.map((node) => node.id));
|
|
1409
|
+
return newNode;
|
|
1199
1410
|
}
|
|
1200
1411
|
async moveLayer(offset) {
|
|
1201
1412
|
const parent = this.get("parent");
|
|
@@ -1209,7 +1420,38 @@ class Editor$1 extends BaseService {
|
|
|
1209
1420
|
} else {
|
|
1210
1421
|
brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
|
|
1211
1422
|
}
|
|
1212
|
-
this.get("stage")?.update({
|
|
1423
|
+
this.get("stage")?.update({
|
|
1424
|
+
config: cloneDeep(toRaw(parent)),
|
|
1425
|
+
parentId: parent.id,
|
|
1426
|
+
root: cloneDeep(this.get("root"))
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1429
|
+
async moveToContainer(config, targetId) {
|
|
1430
|
+
const { node, parent } = this.getNodeInfo(config.id, false);
|
|
1431
|
+
const target = this.getNodeById(targetId, false);
|
|
1432
|
+
const stage = this.get("stage");
|
|
1433
|
+
if (node && parent && stage) {
|
|
1434
|
+
const root = cloneDeep(this.get("root"));
|
|
1435
|
+
const index = getNodeIndex(node, parent);
|
|
1436
|
+
parent.items?.splice(index, 1);
|
|
1437
|
+
await stage.remove({ id: node.id, parentId: parent.id, root });
|
|
1438
|
+
const layout = await this.getLayout(target);
|
|
1439
|
+
const newConfig = mergeWith(cloneDeep(node), config, (objValue, srcValue) => {
|
|
1440
|
+
if (Array.isArray(srcValue)) {
|
|
1441
|
+
return srcValue;
|
|
1442
|
+
}
|
|
1443
|
+
});
|
|
1444
|
+
newConfig.style = getInitPositionStyle(newConfig.style, layout);
|
|
1445
|
+
target.items.push(newConfig);
|
|
1446
|
+
await stage.select(targetId);
|
|
1447
|
+
await stage.update({ config: cloneDeep(target), parentId: parent.id, root });
|
|
1448
|
+
await this.select(newConfig);
|
|
1449
|
+
stage.select(newConfig.id);
|
|
1450
|
+
this.addModifiedNodeId(target.id);
|
|
1451
|
+
this.addModifiedNodeId(parent.id);
|
|
1452
|
+
this.pushHistoryState();
|
|
1453
|
+
return newConfig;
|
|
1454
|
+
}
|
|
1213
1455
|
}
|
|
1214
1456
|
async undo() {
|
|
1215
1457
|
const value = historyService.undo();
|
|
@@ -1225,7 +1467,7 @@ class Editor$1 extends BaseService {
|
|
|
1225
1467
|
const node = toRaw(this.get("node"));
|
|
1226
1468
|
if (!node || isPage(node))
|
|
1227
1469
|
return;
|
|
1228
|
-
const { style, id } = node;
|
|
1470
|
+
const { style, id, type } = node;
|
|
1229
1471
|
if (!style || style.position !== "absolute")
|
|
1230
1472
|
return;
|
|
1231
1473
|
if (top && !isNumber(style.top))
|
|
@@ -1234,6 +1476,7 @@ class Editor$1 extends BaseService {
|
|
|
1234
1476
|
return;
|
|
1235
1477
|
this.update({
|
|
1236
1478
|
id,
|
|
1479
|
+
type,
|
|
1237
1480
|
style: {
|
|
1238
1481
|
...style,
|
|
1239
1482
|
left: Number(style.left) + left,
|
|
@@ -1245,6 +1488,7 @@ class Editor$1 extends BaseService {
|
|
|
1245
1488
|
this.removeAllListeners();
|
|
1246
1489
|
this.set("root", null);
|
|
1247
1490
|
this.set("node", null);
|
|
1491
|
+
this.set("nodes", []);
|
|
1248
1492
|
this.set("page", null);
|
|
1249
1493
|
this.set("parent", null);
|
|
1250
1494
|
}
|
|
@@ -1281,22 +1525,22 @@ class Editor$1 extends BaseService {
|
|
|
1281
1525
|
}, 0);
|
|
1282
1526
|
}
|
|
1283
1527
|
async toggleFixedPosition(dist, src, root) {
|
|
1284
|
-
|
|
1528
|
+
const newConfig = cloneDeep(dist);
|
|
1285
1529
|
if (!isPop(src) && newConfig.style?.position) {
|
|
1286
1530
|
if (isFixed(newConfig) && !isFixed(src)) {
|
|
1287
|
-
newConfig = change2Fixed(newConfig, root);
|
|
1531
|
+
newConfig.style = change2Fixed(newConfig, root);
|
|
1288
1532
|
} else if (!isFixed(newConfig) && isFixed(src)) {
|
|
1289
|
-
newConfig = await Fixed2Other(newConfig, root, this.getLayout);
|
|
1533
|
+
newConfig.style = await Fixed2Other(newConfig, root, this.getLayout);
|
|
1290
1534
|
}
|
|
1291
1535
|
}
|
|
1292
1536
|
return newConfig;
|
|
1293
1537
|
}
|
|
1294
|
-
selectedConfigExceptionHandler(
|
|
1538
|
+
selectedConfigExceptionHandler(config) {
|
|
1295
1539
|
let id;
|
|
1296
|
-
if (typeof
|
|
1297
|
-
id =
|
|
1540
|
+
if (typeof config === "string" || typeof config === "number") {
|
|
1541
|
+
id = config;
|
|
1298
1542
|
} else {
|
|
1299
|
-
id =
|
|
1543
|
+
id = config.id;
|
|
1300
1544
|
}
|
|
1301
1545
|
if (!id) {
|
|
1302
1546
|
throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
|
|
@@ -1314,7 +1558,7 @@ class Editor$1 extends BaseService {
|
|
|
1314
1558
|
};
|
|
1315
1559
|
}
|
|
1316
1560
|
}
|
|
1317
|
-
|
|
1561
|
+
const editorService = new Editor$1();
|
|
1318
1562
|
|
|
1319
1563
|
const eventMap = reactive({});
|
|
1320
1564
|
const methodMap = reactive({});
|
|
@@ -1358,7 +1602,7 @@ class Events extends BaseService {
|
|
|
1358
1602
|
return cloneDeep(methodMap[type] || DEFAULT_METHODS);
|
|
1359
1603
|
}
|
|
1360
1604
|
}
|
|
1361
|
-
|
|
1605
|
+
const eventsService = new Events();
|
|
1362
1606
|
|
|
1363
1607
|
const fillConfig = (config = []) => [
|
|
1364
1608
|
{
|
|
@@ -1564,21 +1808,34 @@ const fillConfig = (config = []) => [
|
|
|
1564
1808
|
}
|
|
1565
1809
|
];
|
|
1566
1810
|
const DEFAULT_CONFIG = fillConfig([]);
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1811
|
+
|
|
1812
|
+
const log = (...args) => {
|
|
1813
|
+
if (process.env.NODE_ENV === "development") {
|
|
1814
|
+
console.log("magic editor: ", ...args);
|
|
1815
|
+
}
|
|
1816
|
+
};
|
|
1817
|
+
const info = (...args) => {
|
|
1818
|
+
if (process.env.NODE_ENV === "development") {
|
|
1819
|
+
console.info("magic editor: ", ...args);
|
|
1820
|
+
}
|
|
1821
|
+
};
|
|
1822
|
+
const warn = (...args) => {
|
|
1823
|
+
if (process.env.NODE_ENV === "development") {
|
|
1824
|
+
console.warn("magic editor: ", ...args);
|
|
1825
|
+
}
|
|
1826
|
+
};
|
|
1827
|
+
const debug = (...args) => {
|
|
1828
|
+
if (process.env.NODE_ENV === "development") {
|
|
1829
|
+
console.debug("magic editor: ", ...args);
|
|
1830
|
+
}
|
|
1831
|
+
};
|
|
1832
|
+
const error = (...args) => {
|
|
1833
|
+
if (process.env.NODE_ENV === "development") {
|
|
1834
|
+
console.error("magic editor: ", ...args);
|
|
1835
|
+
}
|
|
1579
1836
|
};
|
|
1580
1837
|
|
|
1581
|
-
const _sfc_main$
|
|
1838
|
+
const _sfc_main$j = defineComponent({
|
|
1582
1839
|
components: { Plus },
|
|
1583
1840
|
setup() {
|
|
1584
1841
|
const services = inject("services");
|
|
@@ -1595,10 +1852,11 @@ const _sfc_main$i = defineComponent({
|
|
|
1595
1852
|
};
|
|
1596
1853
|
}
|
|
1597
1854
|
});
|
|
1855
|
+
|
|
1598
1856
|
const _hoisted_1$b = { class: "m-editor-empty-panel" };
|
|
1599
1857
|
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
1600
|
-
const _hoisted_3$
|
|
1601
|
-
function _sfc_render$
|
|
1858
|
+
const _hoisted_3$1 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
1859
|
+
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1602
1860
|
const _component_plus = resolveComponent("plus");
|
|
1603
1861
|
const _component_el_icon = resolveComponent("el-icon");
|
|
1604
1862
|
return openBlock(), createElementBlock("div", _hoisted_1$b, [
|
|
@@ -1615,14 +1873,14 @@ function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1615
1873
|
_: 1
|
|
1616
1874
|
})
|
|
1617
1875
|
]),
|
|
1618
|
-
_hoisted_3$
|
|
1876
|
+
_hoisted_3$1
|
|
1619
1877
|
])
|
|
1620
1878
|
])
|
|
1621
1879
|
]);
|
|
1622
1880
|
}
|
|
1623
|
-
|
|
1881
|
+
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$d]]);
|
|
1624
1882
|
|
|
1625
|
-
const _sfc_main$
|
|
1883
|
+
const _sfc_main$i = defineComponent({
|
|
1626
1884
|
name: "m-editor-resize",
|
|
1627
1885
|
props: {
|
|
1628
1886
|
type: {
|
|
@@ -1664,18 +1922,19 @@ const _sfc_main$h = defineComponent({
|
|
|
1664
1922
|
};
|
|
1665
1923
|
}
|
|
1666
1924
|
});
|
|
1925
|
+
|
|
1667
1926
|
const _hoisted_1$a = {
|
|
1668
1927
|
ref: "target",
|
|
1669
1928
|
class: "m-editor-resizer"
|
|
1670
1929
|
};
|
|
1671
|
-
function _sfc_render$
|
|
1930
|
+
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1672
1931
|
return openBlock(), createElementBlock("span", _hoisted_1$a, [
|
|
1673
1932
|
renderSlot(_ctx.$slots, "default")
|
|
1674
1933
|
], 512);
|
|
1675
1934
|
}
|
|
1676
|
-
|
|
1935
|
+
const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$c]]);
|
|
1677
1936
|
|
|
1678
|
-
const _sfc_main$
|
|
1937
|
+
const _sfc_main$h = defineComponent({
|
|
1679
1938
|
components: {
|
|
1680
1939
|
AddPageBox,
|
|
1681
1940
|
Resizer
|
|
@@ -1704,12 +1963,13 @@ const _sfc_main$g = defineComponent({
|
|
|
1704
1963
|
};
|
|
1705
1964
|
}
|
|
1706
1965
|
});
|
|
1966
|
+
|
|
1707
1967
|
const _hoisted_1$9 = { class: "m-editor" };
|
|
1708
1968
|
const _hoisted_2$3 = {
|
|
1709
1969
|
key: 1,
|
|
1710
1970
|
class: "m-editor-content"
|
|
1711
1971
|
};
|
|
1712
|
-
function _sfc_render$
|
|
1972
|
+
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1713
1973
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
1714
1974
|
const _component_resizer = resolveComponent("resizer");
|
|
1715
1975
|
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
@@ -1755,9 +2015,9 @@ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1755
2015
|
]))
|
|
1756
2016
|
]);
|
|
1757
2017
|
}
|
|
1758
|
-
|
|
2018
|
+
const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$b]]);
|
|
1759
2019
|
|
|
1760
|
-
const _sfc_main$
|
|
2020
|
+
const _sfc_main$g = defineComponent({
|
|
1761
2021
|
name: "m-icon",
|
|
1762
2022
|
components: { Edit },
|
|
1763
2023
|
props: {
|
|
@@ -1771,8 +2031,9 @@ const _sfc_main$f = defineComponent({
|
|
|
1771
2031
|
};
|
|
1772
2032
|
}
|
|
1773
2033
|
});
|
|
2034
|
+
|
|
1774
2035
|
const _hoisted_1$8 = ["src"];
|
|
1775
|
-
function _sfc_render$
|
|
2036
|
+
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1776
2037
|
const _component_edit = resolveComponent("edit");
|
|
1777
2038
|
const _component_el_icon = resolveComponent("el-icon");
|
|
1778
2039
|
return !_ctx.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
|
|
@@ -1780,10 +2041,12 @@ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1780
2041
|
createVNode(_component_edit)
|
|
1781
2042
|
]),
|
|
1782
2043
|
_: 1
|
|
1783
|
-
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (openBlock(),
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
2044
|
+
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (openBlock(), createBlock(_component_el_icon, { key: 1 }, {
|
|
2045
|
+
default: withCtx(() => [
|
|
2046
|
+
createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$8)
|
|
2047
|
+
]),
|
|
2048
|
+
_: 1
|
|
2049
|
+
})) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
1787
2050
|
key: 2,
|
|
1788
2051
|
class: normalizeClass(_ctx.icon)
|
|
1789
2052
|
}, null, 2)) : (openBlock(), createBlock(_component_el_icon, { key: 3 }, {
|
|
@@ -1793,10 +2056,19 @@ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1793
2056
|
_: 1
|
|
1794
2057
|
}));
|
|
1795
2058
|
}
|
|
1796
|
-
|
|
2059
|
+
const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
|
|
1797
2060
|
|
|
1798
|
-
const
|
|
1799
|
-
|
|
2061
|
+
const _hoisted_1$7 = {
|
|
2062
|
+
key: 1,
|
|
2063
|
+
class: "menu-item-text"
|
|
2064
|
+
};
|
|
2065
|
+
const _hoisted_2$2 = {
|
|
2066
|
+
class: "menu-item-text",
|
|
2067
|
+
style: { "margin": "0 5px" }
|
|
2068
|
+
};
|
|
2069
|
+
const _hoisted_3 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2070
|
+
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
2071
|
+
__name: "ToolButton",
|
|
1800
2072
|
props: {
|
|
1801
2073
|
data: {
|
|
1802
2074
|
type: [Object, String],
|
|
@@ -1811,7 +2083,8 @@ const _sfc_main$e = defineComponent({
|
|
|
1811
2083
|
default: "click"
|
|
1812
2084
|
}
|
|
1813
2085
|
},
|
|
1814
|
-
setup(
|
|
2086
|
+
setup(__props) {
|
|
2087
|
+
const props = __props;
|
|
1815
2088
|
const services = inject("services");
|
|
1816
2089
|
const uiService = services?.uiService;
|
|
1817
2090
|
const zoom = computed(() => uiService?.get("zoom") ?? 1);
|
|
@@ -1907,177 +2180,156 @@ const _sfc_main$e = defineComponent({
|
|
|
1907
2180
|
if (typeof item2.handler === "function" && services) {
|
|
1908
2181
|
item2.handler?.(services, event);
|
|
1909
2182
|
}
|
|
1910
|
-
};
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
item
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
});
|
|
1958
|
-
const _hoisted_1$7 = {
|
|
1959
|
-
key: 1,
|
|
1960
|
-
class: "menu-item-text"
|
|
1961
|
-
};
|
|
1962
|
-
const _hoisted_2$2 = {
|
|
1963
|
-
class: "menu-item-text",
|
|
1964
|
-
style: { "margin": "0 5px" }
|
|
1965
|
-
};
|
|
1966
|
-
const _hoisted_3$1 = { class: "el-dropdown-link menubar-menu-button" };
|
|
1967
|
-
function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1968
|
-
const _component_el_divider = resolveComponent("el-divider");
|
|
1969
|
-
const _component_tool_button = resolveComponent("tool-button", true);
|
|
1970
|
-
const _component_m_icon = resolveComponent("m-icon");
|
|
1971
|
-
const _component_el_button = resolveComponent("el-button");
|
|
1972
|
-
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
1973
|
-
const _component_arrow_down = resolveComponent("arrow-down");
|
|
1974
|
-
const _component_el_icon = resolveComponent("el-icon");
|
|
1975
|
-
const _component_el_dropdown_item = resolveComponent("el-dropdown-item");
|
|
1976
|
-
const _component_el_dropdown_menu = resolveComponent("el-dropdown-menu");
|
|
1977
|
-
const _component_el_dropdown = resolveComponent("el-dropdown");
|
|
1978
|
-
return _ctx.display ? (openBlock(), createElementBlock("div", {
|
|
1979
|
-
key: 0,
|
|
1980
|
-
class: normalizeClass(["menu-item", _ctx.item.type]),
|
|
1981
|
-
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.clickHandler(_ctx.item, $event)),
|
|
1982
|
-
onMousedown: _cache[1] || (_cache[1] = ($event) => _ctx.mousedownHandler(_ctx.item, $event)),
|
|
1983
|
-
onMouseup: _cache[2] || (_cache[2] = ($event) => _ctx.mouseupHandler(_ctx.item, $event))
|
|
1984
|
-
}, [
|
|
1985
|
-
_ctx.item.type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
|
|
1986
|
-
key: 0,
|
|
1987
|
-
direction: _ctx.item.direction || "vertical"
|
|
1988
|
-
}, 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 }, [
|
|
1989
|
-
createVNode(_component_tool_button, {
|
|
1990
|
-
data: { type: "button", icon: _ctx.ZoomOut, handler: _ctx.zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
1991
|
-
"event-type": _ctx.eventType
|
|
1992
|
-
}, null, 8, ["data", "event-type"]),
|
|
1993
|
-
createElementVNode("span", _hoisted_2$2, toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
|
|
1994
|
-
createVNode(_component_tool_button, {
|
|
1995
|
-
data: { type: "button", icon: _ctx.ZoomIn, handler: _ctx.zoomInHandler, tooltip: "\u653E\u5927" },
|
|
1996
|
-
"event-type": _ctx.eventType
|
|
1997
|
-
}, null, 8, ["data", "event-type"])
|
|
1998
|
-
], 64)) : _ctx.item.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
1999
|
-
_ctx.item.tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
2183
|
+
};
|
|
2184
|
+
const display = computed(() => {
|
|
2185
|
+
if (!item.value)
|
|
2186
|
+
return false;
|
|
2187
|
+
if (typeof item.value === "string")
|
|
2188
|
+
return true;
|
|
2189
|
+
if (typeof item.value.display === "function") {
|
|
2190
|
+
return item.value.display(services);
|
|
2191
|
+
}
|
|
2192
|
+
return item.value.display ?? true;
|
|
2193
|
+
});
|
|
2194
|
+
const dropdownHandler = (command) => {
|
|
2195
|
+
if (command.item.handler) {
|
|
2196
|
+
command.item.handler(services);
|
|
2197
|
+
}
|
|
2198
|
+
};
|
|
2199
|
+
const clickHandler = (item2, event) => {
|
|
2200
|
+
if (props.eventType !== "click")
|
|
2201
|
+
return;
|
|
2202
|
+
if (item2.type === "button") {
|
|
2203
|
+
buttonHandler(item2, event);
|
|
2204
|
+
}
|
|
2205
|
+
};
|
|
2206
|
+
const mousedownHandler = (item2, event) => {
|
|
2207
|
+
if (props.eventType !== "mousedown")
|
|
2208
|
+
return;
|
|
2209
|
+
if (item2.type === "button") {
|
|
2210
|
+
buttonHandler(item2, event);
|
|
2211
|
+
}
|
|
2212
|
+
};
|
|
2213
|
+
const mouseupHandler = (item2, event) => {
|
|
2214
|
+
if (props.eventType !== "mouseup")
|
|
2215
|
+
return;
|
|
2216
|
+
if (item2.type === "button") {
|
|
2217
|
+
buttonHandler(item2, event);
|
|
2218
|
+
}
|
|
2219
|
+
};
|
|
2220
|
+
return (_ctx, _cache) => {
|
|
2221
|
+
const _component_el_divider = resolveComponent("el-divider");
|
|
2222
|
+
const _component_tool_button = resolveComponent("tool-button", true);
|
|
2223
|
+
const _component_el_button = resolveComponent("el-button");
|
|
2224
|
+
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
2225
|
+
const _component_el_icon = resolveComponent("el-icon");
|
|
2226
|
+
const _component_el_dropdown_item = resolveComponent("el-dropdown-item");
|
|
2227
|
+
const _component_el_dropdown_menu = resolveComponent("el-dropdown-menu");
|
|
2228
|
+
const _component_el_dropdown = resolveComponent("el-dropdown");
|
|
2229
|
+
return unref(display) ? (openBlock(), createElementBlock("div", {
|
|
2000
2230
|
key: 0,
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2231
|
+
class: normalizeClass(["menu-item", unref(item).type]),
|
|
2232
|
+
onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(unref(item), $event)),
|
|
2233
|
+
onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(unref(item), $event)),
|
|
2234
|
+
onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(unref(item), $event))
|
|
2235
|
+
}, [
|
|
2236
|
+
unref(item).type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
|
|
2237
|
+
key: 0,
|
|
2238
|
+
direction: unref(item).direction || "vertical"
|
|
2239
|
+
}, null, 8, ["direction"])) : unref(item).type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$7, toDisplayString(unref(item).text), 1)) : unref(item).type === "zoom" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
2240
|
+
createVNode(_component_tool_button, {
|
|
2241
|
+
data: { type: "button", icon: unref(ZoomOut), handler: zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
2242
|
+
"event-type": __props.eventType
|
|
2243
|
+
}, null, 8, ["data", "event-type"]),
|
|
2244
|
+
createElementVNode("span", _hoisted_2$2, toDisplayString(parseInt(`${unref(zoom) * 100}`, 10)) + "%", 1),
|
|
2245
|
+
createVNode(_component_tool_button, {
|
|
2246
|
+
data: { type: "button", icon: unref(ZoomIn), handler: zoomInHandler, tooltip: "\u653E\u5927" },
|
|
2247
|
+
"event-type": __props.eventType
|
|
2248
|
+
}, null, 8, ["data", "event-type"])
|
|
2249
|
+
], 64)) : unref(item).type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
2250
|
+
unref(item).tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
2251
|
+
key: 0,
|
|
2252
|
+
effect: "dark",
|
|
2253
|
+
placement: "bottom-start",
|
|
2254
|
+
content: unref(item).tooltip
|
|
2255
|
+
}, {
|
|
2256
|
+
default: withCtx(() => [
|
|
2257
|
+
createVNode(_component_el_button, {
|
|
2258
|
+
size: "small",
|
|
2259
|
+
text: "",
|
|
2260
|
+
disabled: unref(disabled)
|
|
2261
|
+
}, {
|
|
2262
|
+
default: withCtx(() => [
|
|
2263
|
+
unref(item).icon ? (openBlock(), createBlock(MIcon, {
|
|
2264
|
+
key: 0,
|
|
2265
|
+
icon: unref(item).icon
|
|
2266
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
2267
|
+
createElementVNode("span", null, toDisplayString(unref(item).text), 1)
|
|
2268
|
+
]),
|
|
2269
|
+
_: 1
|
|
2270
|
+
}, 8, ["disabled"])
|
|
2271
|
+
]),
|
|
2272
|
+
_: 1
|
|
2273
|
+
}, 8, ["content"])) : (openBlock(), createBlock(_component_el_button, {
|
|
2274
|
+
key: 1,
|
|
2007
2275
|
size: "small",
|
|
2008
2276
|
text: "",
|
|
2009
|
-
disabled:
|
|
2277
|
+
disabled: unref(disabled)
|
|
2010
2278
|
}, {
|
|
2011
2279
|
default: withCtx(() => [
|
|
2012
|
-
|
|
2280
|
+
unref(item).icon ? (openBlock(), createBlock(MIcon, {
|
|
2013
2281
|
key: 0,
|
|
2014
|
-
icon:
|
|
2282
|
+
icon: unref(item).icon
|
|
2015
2283
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
2016
|
-
createElementVNode("span", null, toDisplayString(
|
|
2284
|
+
createElementVNode("span", null, toDisplayString(unref(item).text), 1)
|
|
2017
2285
|
]),
|
|
2018
2286
|
_: 1
|
|
2019
|
-
}, 8, ["disabled"])
|
|
2020
|
-
]),
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
_ctx.item.items && _ctx.item.items.length ? (openBlock(), createBlock(_component_el_dropdown_menu, { key: 0 }, {
|
|
2287
|
+
}, 8, ["disabled"]))
|
|
2288
|
+
], 64)) : unref(item).type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
|
|
2289
|
+
key: 4,
|
|
2290
|
+
trigger: "click",
|
|
2291
|
+
disabled: unref(disabled),
|
|
2292
|
+
onCommand: dropdownHandler
|
|
2293
|
+
}, {
|
|
2294
|
+
dropdown: withCtx(() => [
|
|
2295
|
+
unref(item).items && unref(item).items.length ? (openBlock(), createBlock(_component_el_dropdown_menu, { key: 0 }, {
|
|
2296
|
+
default: withCtx(() => [
|
|
2297
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(item).items, (subItem, index) => {
|
|
2298
|
+
return openBlock(), createBlock(_component_el_dropdown_item, {
|
|
2299
|
+
key: index,
|
|
2300
|
+
command: { item: unref(item), subItem }
|
|
2301
|
+
}, {
|
|
2302
|
+
default: withCtx(() => [
|
|
2303
|
+
createTextVNode(toDisplayString(subItem.text), 1)
|
|
2304
|
+
]),
|
|
2305
|
+
_: 2
|
|
2306
|
+
}, 1032, ["command"]);
|
|
2307
|
+
}), 128))
|
|
2308
|
+
]),
|
|
2309
|
+
_: 1
|
|
2310
|
+
})) : createCommentVNode("", true)
|
|
2311
|
+
]),
|
|
2045
2312
|
default: withCtx(() => [
|
|
2046
|
-
(
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
command: { item: _ctx.item, subItem }
|
|
2050
|
-
}, {
|
|
2313
|
+
createElementVNode("span", _hoisted_3, [
|
|
2314
|
+
createTextVNode(toDisplayString(unref(item).text), 1),
|
|
2315
|
+
createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2051
2316
|
default: withCtx(() => [
|
|
2052
|
-
|
|
2317
|
+
createVNode(unref(ArrowDown))
|
|
2053
2318
|
]),
|
|
2054
|
-
_:
|
|
2055
|
-
}
|
|
2056
|
-
|
|
2319
|
+
_: 1
|
|
2320
|
+
})
|
|
2321
|
+
])
|
|
2057
2322
|
]),
|
|
2058
2323
|
_: 1
|
|
2059
|
-
})) : createCommentVNode("", true)
|
|
2060
|
-
]),
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2065
|
-
default: withCtx(() => [
|
|
2066
|
-
createVNode(_component_arrow_down)
|
|
2067
|
-
]),
|
|
2068
|
-
_: 1
|
|
2069
|
-
})
|
|
2070
|
-
])
|
|
2071
|
-
]),
|
|
2072
|
-
_: 1
|
|
2073
|
-
}, 8, ["disabled", "onCommand"])) : _ctx.item.type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.item.component), normalizeProps(mergeProps({ key: 5 }, _ctx.item.props || {})), null, 16)) : createCommentVNode("", true)
|
|
2074
|
-
], 34)) : createCommentVNode("", true);
|
|
2075
|
-
}
|
|
2076
|
-
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
|
|
2324
|
+
}, 8, ["disabled"])) : unref(item).type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(unref(item).component), normalizeProps(mergeProps({ key: 5 }, unref(item).props || {})), null, 16)) : createCommentVNode("", true)
|
|
2325
|
+
], 34)) : createCommentVNode("", true);
|
|
2326
|
+
};
|
|
2327
|
+
}
|
|
2328
|
+
});
|
|
2077
2329
|
|
|
2078
|
-
const _sfc_main$
|
|
2330
|
+
const _sfc_main$e = defineComponent({
|
|
2079
2331
|
name: "nav-menu",
|
|
2080
|
-
components: { ToolButton },
|
|
2332
|
+
components: { ToolButton: _sfc_main$f },
|
|
2081
2333
|
props: {
|
|
2082
2334
|
data: {
|
|
2083
2335
|
type: Object,
|
|
@@ -2095,7 +2347,8 @@ const _sfc_main$d = defineComponent({
|
|
|
2095
2347
|
};
|
|
2096
2348
|
}
|
|
2097
2349
|
});
|
|
2098
|
-
|
|
2350
|
+
|
|
2351
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2099
2352
|
const _component_tool_button = resolveComponent("tool-button");
|
|
2100
2353
|
return openBlock(), createElementBlock("div", {
|
|
2101
2354
|
class: "m-editor-nav-menu",
|
|
@@ -2117,9 +2370,9 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2117
2370
|
}), 128))
|
|
2118
2371
|
], 4);
|
|
2119
2372
|
}
|
|
2120
|
-
|
|
2373
|
+
const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
|
|
2121
2374
|
|
|
2122
|
-
const _sfc_main$
|
|
2375
|
+
const _sfc_main$d = defineComponent({
|
|
2123
2376
|
name: "m-editor-props-panel",
|
|
2124
2377
|
emits: ["mounted"],
|
|
2125
2378
|
setup(props, { emit }) {
|
|
@@ -2166,8 +2419,9 @@ const _sfc_main$c = defineComponent({
|
|
|
2166
2419
|
};
|
|
2167
2420
|
}
|
|
2168
2421
|
});
|
|
2422
|
+
|
|
2169
2423
|
const _hoisted_1$6 = { class: "`m-editor-props-panel" };
|
|
2170
|
-
function _sfc_render$
|
|
2424
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2171
2425
|
const _component_m_form = resolveComponent("m-form");
|
|
2172
2426
|
return openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
2173
2427
|
renderSlot(_ctx.$slots, "props-panel-header"),
|
|
@@ -2182,19 +2436,24 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2182
2436
|
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
|
|
2183
2437
|
]);
|
|
2184
2438
|
}
|
|
2185
|
-
|
|
2439
|
+
const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
|
|
2186
2440
|
|
|
2187
|
-
const _sfc_main$
|
|
2441
|
+
const _sfc_main$c = defineComponent({
|
|
2188
2442
|
name: "ui-component-panel",
|
|
2189
2443
|
components: { MIcon },
|
|
2190
2444
|
setup() {
|
|
2191
2445
|
const searchText = ref("");
|
|
2192
2446
|
const services = inject("services");
|
|
2447
|
+
const stageOptions = inject("stageOptions");
|
|
2448
|
+
const stage = computed(() => services?.editorService.get("stage"));
|
|
2193
2449
|
const list = computed(() => services?.componentListService.getList().map((group) => ({
|
|
2194
2450
|
...group,
|
|
2195
2451
|
items: group.items.filter((item) => item.text.includes(searchText.value))
|
|
2196
2452
|
})));
|
|
2197
2453
|
const collapseValue = computed(() => Array(list.value?.length).fill(1).map((x, i) => i));
|
|
2454
|
+
let timeout;
|
|
2455
|
+
let clientX;
|
|
2456
|
+
let clientY;
|
|
2198
2457
|
return {
|
|
2199
2458
|
searchText,
|
|
2200
2459
|
collapseValue,
|
|
@@ -2215,13 +2474,40 @@ const _sfc_main$b = defineComponent({
|
|
|
2215
2474
|
...data
|
|
2216
2475
|
}).replace(/"(\w+)":\s/g, "$1: "));
|
|
2217
2476
|
}
|
|
2477
|
+
},
|
|
2478
|
+
dragendHandler() {
|
|
2479
|
+
if (timeout) {
|
|
2480
|
+
globalThis.clearTimeout(timeout);
|
|
2481
|
+
timeout = void 0;
|
|
2482
|
+
}
|
|
2483
|
+
const doc = stage.value?.renderer.contentWindow?.document;
|
|
2484
|
+
if (doc && stageOptions) {
|
|
2485
|
+
removeClassNameByClassName(doc, stageOptions.containerHighlightClassName);
|
|
2486
|
+
}
|
|
2487
|
+
clientX = 0;
|
|
2488
|
+
clientY = 0;
|
|
2489
|
+
},
|
|
2490
|
+
dragHandler(e) {
|
|
2491
|
+
if (e.clientX !== clientX || e.clientY !== clientY) {
|
|
2492
|
+
clientX = e.clientX;
|
|
2493
|
+
clientY = e.clientY;
|
|
2494
|
+
if (timeout) {
|
|
2495
|
+
globalThis.clearTimeout(timeout);
|
|
2496
|
+
timeout = void 0;
|
|
2497
|
+
}
|
|
2498
|
+
return;
|
|
2499
|
+
}
|
|
2500
|
+
if (timeout || !stage.value)
|
|
2501
|
+
return;
|
|
2502
|
+
timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
|
|
2218
2503
|
}
|
|
2219
2504
|
};
|
|
2220
2505
|
}
|
|
2221
2506
|
});
|
|
2507
|
+
|
|
2222
2508
|
const _hoisted_1$5 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
2223
2509
|
const _hoisted_2$1 = ["onClick", "onDragstart"];
|
|
2224
|
-
function _sfc_render$
|
|
2510
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2225
2511
|
const _component_el_input = resolveComponent("el-input");
|
|
2226
2512
|
const _component_m_icon = resolveComponent("m-icon");
|
|
2227
2513
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
@@ -2262,7 +2548,9 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2262
2548
|
draggable: "true",
|
|
2263
2549
|
key: item.type,
|
|
2264
2550
|
onClick: ($event) => _ctx.appendComponent(item),
|
|
2265
|
-
onDragstart: ($event) => _ctx.dragstartHandler(item, $event)
|
|
2551
|
+
onDragstart: ($event) => _ctx.dragstartHandler(item, $event),
|
|
2552
|
+
onDragend: _cache[1] || (_cache[1] = (...args) => _ctx.dragendHandler && _ctx.dragendHandler(...args)),
|
|
2553
|
+
onDrag: _cache[2] || (_cache[2] = (...args) => _ctx.dragHandler && _ctx.dragHandler(...args))
|
|
2266
2554
|
}, [
|
|
2267
2555
|
createVNode(_component_m_icon, {
|
|
2268
2556
|
icon: item.icon
|
|
@@ -2291,22 +2579,17 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2291
2579
|
_: 3
|
|
2292
2580
|
});
|
|
2293
2581
|
}
|
|
2294
|
-
|
|
2582
|
+
const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
|
|
2295
2583
|
|
|
2296
|
-
const _sfc_main$
|
|
2297
|
-
|
|
2584
|
+
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
2585
|
+
__name: "ContentMenu",
|
|
2298
2586
|
props: {
|
|
2299
|
-
menuData: {
|
|
2300
|
-
|
|
2301
|
-
default: () => []
|
|
2302
|
-
},
|
|
2303
|
-
isSubMenu: {
|
|
2304
|
-
type: Boolean,
|
|
2305
|
-
default: false
|
|
2306
|
-
}
|
|
2587
|
+
menuData: { default: () => [] },
|
|
2588
|
+
isSubMenu: { type: Boolean, default: false }
|
|
2307
2589
|
},
|
|
2308
2590
|
emits: ["hide", "show"],
|
|
2309
|
-
setup(
|
|
2591
|
+
setup(__props, { expose, emit }) {
|
|
2592
|
+
const props = __props;
|
|
2310
2593
|
const menu = ref();
|
|
2311
2594
|
const subMenu = ref();
|
|
2312
2595
|
const visible = ref(false);
|
|
@@ -2332,6 +2615,36 @@ const _sfc_main$a = defineComponent({
|
|
|
2332
2615
|
}
|
|
2333
2616
|
hide();
|
|
2334
2617
|
};
|
|
2618
|
+
const show = (e) => {
|
|
2619
|
+
setTimeout(() => {
|
|
2620
|
+
visible.value = true;
|
|
2621
|
+
nextTick(() => {
|
|
2622
|
+
const menuHeight = menu.value?.clientHeight || 0;
|
|
2623
|
+
let top = e.clientY;
|
|
2624
|
+
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
2625
|
+
top = document.body.clientHeight - menuHeight;
|
|
2626
|
+
}
|
|
2627
|
+
menuStyle.value = {
|
|
2628
|
+
top: `${top}px`,
|
|
2629
|
+
left: `${e.clientX}px`
|
|
2630
|
+
};
|
|
2631
|
+
emit("show");
|
|
2632
|
+
});
|
|
2633
|
+
}, 300);
|
|
2634
|
+
};
|
|
2635
|
+
const showSubMenu = (item) => {
|
|
2636
|
+
const menuItem = item;
|
|
2637
|
+
if (typeof item !== "object" || !menuItem.items?.length) {
|
|
2638
|
+
return;
|
|
2639
|
+
}
|
|
2640
|
+
subMenuData.value = menuItem.items;
|
|
2641
|
+
if (menu.value) {
|
|
2642
|
+
subMenu.value.show({
|
|
2643
|
+
clientX: menu.value.offsetLeft + menu.value.clientWidth,
|
|
2644
|
+
clientY: menu.value.offsetTop
|
|
2645
|
+
});
|
|
2646
|
+
}
|
|
2647
|
+
};
|
|
2335
2648
|
onMounted(() => {
|
|
2336
2649
|
if (props.isSubMenu)
|
|
2337
2650
|
return;
|
|
@@ -2342,81 +2655,47 @@ const _sfc_main$a = defineComponent({
|
|
|
2342
2655
|
return;
|
|
2343
2656
|
globalThis.removeEventListener("mousedown", hideHandler, true);
|
|
2344
2657
|
});
|
|
2345
|
-
|
|
2346
|
-
menu,
|
|
2347
|
-
subMenu,
|
|
2348
|
-
visible,
|
|
2349
|
-
menuStyle,
|
|
2350
|
-
subMenuData,
|
|
2658
|
+
expose({
|
|
2351
2659
|
hide,
|
|
2352
|
-
show
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2660
|
+
show
|
|
2661
|
+
});
|
|
2662
|
+
return (_ctx, _cache) => {
|
|
2663
|
+
const _component_content_menu = resolveComponent("content-menu", true);
|
|
2664
|
+
return __props.menuData.length && visible.value ? (openBlock(), createElementBlock("div", {
|
|
2665
|
+
key: 0,
|
|
2666
|
+
class: "magic-editor-content-menu",
|
|
2667
|
+
ref_key: "menu",
|
|
2668
|
+
ref: menu,
|
|
2669
|
+
style: normalizeStyle(menuStyle.value)
|
|
2670
|
+
}, [
|
|
2671
|
+
createElementVNode("div", null, [
|
|
2672
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.menuData, (item, index) => {
|
|
2673
|
+
return openBlock(), createBlock(_sfc_main$f, {
|
|
2674
|
+
"event-type": "mouseup",
|
|
2675
|
+
data: item,
|
|
2676
|
+
key: index,
|
|
2677
|
+
onMouseup: hide,
|
|
2678
|
+
onMouseenter: ($event) => showSubMenu(item)
|
|
2679
|
+
}, null, 8, ["data", "onMouseenter"]);
|
|
2680
|
+
}), 128))
|
|
2681
|
+
]),
|
|
2682
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
2683
|
+
createVNode(_component_content_menu, {
|
|
2684
|
+
class: "sub-menu",
|
|
2685
|
+
ref_key: "subMenu",
|
|
2686
|
+
ref: subMenu,
|
|
2687
|
+
"menu-data": subMenuData.value,
|
|
2688
|
+
"is-sub-menu": true,
|
|
2689
|
+
onHide: hide
|
|
2690
|
+
}, null, 8, ["menu-data"])
|
|
2691
|
+
]))
|
|
2692
|
+
], 4)) : createCommentVNode("", true);
|
|
2382
2693
|
};
|
|
2383
2694
|
}
|
|
2384
2695
|
});
|
|
2385
|
-
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2386
|
-
const _component_tool_button = resolveComponent("tool-button");
|
|
2387
|
-
const _component_content_menu = resolveComponent("content-menu", true);
|
|
2388
|
-
return _ctx.menuData.length && _ctx.visible ? (openBlock(), createElementBlock("div", {
|
|
2389
|
-
key: 0,
|
|
2390
|
-
class: "magic-editor-content-menu",
|
|
2391
|
-
ref: "menu",
|
|
2392
|
-
style: normalizeStyle(_ctx.menuStyle)
|
|
2393
|
-
}, [
|
|
2394
|
-
createElementVNode("div", null, [
|
|
2395
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menuData, (item, index) => {
|
|
2396
|
-
return openBlock(), createBlock(_component_tool_button, {
|
|
2397
|
-
"event-type": "mouseup",
|
|
2398
|
-
data: item,
|
|
2399
|
-
key: index,
|
|
2400
|
-
onMouseup: _ctx.hide,
|
|
2401
|
-
onMouseenter: ($event) => _ctx.showSubMenu(item)
|
|
2402
|
-
}, null, 8, ["data", "onMouseup", "onMouseenter"]);
|
|
2403
|
-
}), 128))
|
|
2404
|
-
]),
|
|
2405
|
-
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
2406
|
-
createVNode(_component_content_menu, {
|
|
2407
|
-
class: "sub-menu",
|
|
2408
|
-
ref: "subMenu",
|
|
2409
|
-
"menu-data": _ctx.subMenuData,
|
|
2410
|
-
"is-sub-menu": true,
|
|
2411
|
-
onHide: _ctx.hide
|
|
2412
|
-
}, null, 8, ["menu-data", "onHide"])
|
|
2413
|
-
]))
|
|
2414
|
-
], 4)) : createCommentVNode("", true);
|
|
2415
|
-
}
|
|
2416
|
-
var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
|
|
2417
2696
|
|
|
2418
|
-
const _sfc_main$
|
|
2419
|
-
components: { ContentMenu },
|
|
2697
|
+
const _sfc_main$a = defineComponent({
|
|
2698
|
+
components: { ContentMenu: _sfc_main$b },
|
|
2420
2699
|
setup() {
|
|
2421
2700
|
const services = inject("services");
|
|
2422
2701
|
const menu = ref();
|
|
@@ -2498,7 +2777,8 @@ const _sfc_main$9 = defineComponent({
|
|
|
2498
2777
|
};
|
|
2499
2778
|
}
|
|
2500
2779
|
});
|
|
2501
|
-
|
|
2780
|
+
|
|
2781
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2502
2782
|
const _component_content_menu = resolveComponent("content-menu");
|
|
2503
2783
|
return openBlock(), createBlock(_component_content_menu, {
|
|
2504
2784
|
"menu-data": _ctx.menuData,
|
|
@@ -2506,7 +2786,7 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2506
2786
|
style: { "overflow": "initial" }
|
|
2507
2787
|
}, null, 8, ["menu-data"]);
|
|
2508
2788
|
}
|
|
2509
|
-
|
|
2789
|
+
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$6]]);
|
|
2510
2790
|
|
|
2511
2791
|
const throttleTime = 150;
|
|
2512
2792
|
const select = async (data, editorService) => {
|
|
@@ -2540,9 +2820,17 @@ const useDrop = (tree, editorService) => ({
|
|
|
2540
2820
|
return true;
|
|
2541
2821
|
return false;
|
|
2542
2822
|
},
|
|
2543
|
-
handleDragEnd() {
|
|
2823
|
+
async handleDragEnd(e) {
|
|
2544
2824
|
if (!tree.value)
|
|
2545
2825
|
return;
|
|
2826
|
+
const { data: node } = e;
|
|
2827
|
+
const parent = editorService?.getParentById(node.id, false);
|
|
2828
|
+
const layout = await editorService?.getLayout(parent);
|
|
2829
|
+
node.style.position = layout;
|
|
2830
|
+
if (layout === Layout.RELATIVE) {
|
|
2831
|
+
node.style.top = 0;
|
|
2832
|
+
node.style.left = 0;
|
|
2833
|
+
}
|
|
2546
2834
|
const { data } = tree.value;
|
|
2547
2835
|
const [page] = data;
|
|
2548
2836
|
editorService?.update(page);
|
|
@@ -2598,7 +2886,7 @@ const useFilter = (tree) => ({
|
|
|
2598
2886
|
tree.value?.filter(val);
|
|
2599
2887
|
}
|
|
2600
2888
|
});
|
|
2601
|
-
const _sfc_main$
|
|
2889
|
+
const _sfc_main$9 = defineComponent({
|
|
2602
2890
|
name: "magic-editor-layer-panel",
|
|
2603
2891
|
components: { LayerMenu },
|
|
2604
2892
|
setup() {
|
|
@@ -2645,8 +2933,9 @@ const _sfc_main$8 = defineComponent({
|
|
|
2645
2933
|
};
|
|
2646
2934
|
}
|
|
2647
2935
|
});
|
|
2936
|
+
|
|
2648
2937
|
const _hoisted_1$4 = ["id", "onMouseenter"];
|
|
2649
|
-
function _sfc_render$
|
|
2938
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2650
2939
|
const _component_el_input = resolveComponent("el-input");
|
|
2651
2940
|
const _component_el_tree = resolveComponent("el-tree");
|
|
2652
2941
|
const _component_layer_menu = resolveComponent("layer-menu");
|
|
@@ -2708,9 +2997,9 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2708
2997
|
_: 3
|
|
2709
2998
|
});
|
|
2710
2999
|
}
|
|
2711
|
-
|
|
3000
|
+
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$5]]);
|
|
2712
3001
|
|
|
2713
|
-
const _sfc_main$
|
|
3002
|
+
const _sfc_main$8 = defineComponent({
|
|
2714
3003
|
components: { MIcon },
|
|
2715
3004
|
props: {
|
|
2716
3005
|
data: {
|
|
@@ -2747,11 +3036,12 @@ const _sfc_main$7 = defineComponent({
|
|
|
2747
3036
|
};
|
|
2748
3037
|
}
|
|
2749
3038
|
});
|
|
3039
|
+
|
|
2750
3040
|
const _hoisted_1$3 = {
|
|
2751
3041
|
key: 1,
|
|
2752
3042
|
class: "magic-editor-tab-panel-title"
|
|
2753
3043
|
};
|
|
2754
|
-
function _sfc_render$
|
|
3044
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2755
3045
|
const _component_m_icon = resolveComponent("m-icon");
|
|
2756
3046
|
const _component_el_tab_pane = resolveComponent("el-tab-pane");
|
|
2757
3047
|
return _ctx.config ? (openBlock(), createBlock(_component_el_tab_pane, {
|
|
@@ -2797,9 +3087,9 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2797
3087
|
_: 3
|
|
2798
3088
|
}, 8, ["name"])) : createCommentVNode("", true);
|
|
2799
3089
|
}
|
|
2800
|
-
|
|
3090
|
+
const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$4]]);
|
|
2801
3091
|
|
|
2802
|
-
const _sfc_main$
|
|
3092
|
+
const _sfc_main$7 = defineComponent({
|
|
2803
3093
|
components: { TabPane },
|
|
2804
3094
|
name: "m-sidebar",
|
|
2805
3095
|
props: {
|
|
@@ -2818,7 +3108,8 @@ const _sfc_main$6 = defineComponent({
|
|
|
2818
3108
|
};
|
|
2819
3109
|
}
|
|
2820
3110
|
});
|
|
2821
|
-
|
|
3111
|
+
|
|
3112
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2822
3113
|
const _component_tab_pane = resolveComponent("tab-pane");
|
|
2823
3114
|
const _component_el_tabs = resolveComponent("el-tabs");
|
|
2824
3115
|
return _ctx.data.type === "tabs" && _ctx.data.items.length ? (openBlock(), createBlock(_component_el_tabs, {
|
|
@@ -2853,331 +3144,258 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2853
3144
|
_: 3
|
|
2854
3145
|
}, 8, ["modelValue"])) : createCommentVNode("", true);
|
|
2855
3146
|
}
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
const
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
|
|
2875
|
-
}
|
|
2876
|
-
};
|
|
2877
|
-
const scroll = (type) => {
|
|
2878
|
-
if (!itemsContainer.value)
|
|
2879
|
-
return;
|
|
2880
|
-
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
2881
|
-
if (type === "left") {
|
|
2882
|
-
translateLeft += 100;
|
|
2883
|
-
if (translateLeft > 0) {
|
|
2884
|
-
translateLeft = 0;
|
|
3147
|
+
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$3]]);
|
|
3148
|
+
|
|
3149
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
3150
|
+
__name: "PageBarScrollContainer",
|
|
3151
|
+
setup(__props) {
|
|
3152
|
+
const services = inject("services");
|
|
3153
|
+
const editorService = services?.editorService;
|
|
3154
|
+
const pageBar = ref();
|
|
3155
|
+
const itemsContainer = ref();
|
|
3156
|
+
const pageBarWidth = ref(0);
|
|
3157
|
+
const canScroll = ref(false);
|
|
3158
|
+
const itemsContainerWidth = computed(() => pageBarWidth.value - 105);
|
|
3159
|
+
let translateLeft = 0;
|
|
3160
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
3161
|
+
for (const { contentRect } of entries) {
|
|
3162
|
+
const { width } = contentRect;
|
|
3163
|
+
pageBarWidth.value = width || 0;
|
|
3164
|
+
setCanScroll();
|
|
2885
3165
|
}
|
|
2886
|
-
}
|
|
2887
|
-
|
|
2888
|
-
if (
|
|
2889
|
-
|
|
3166
|
+
});
|
|
3167
|
+
const setCanScroll = () => {
|
|
3168
|
+
if (itemsContainer.value) {
|
|
3169
|
+
canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
|
|
2890
3170
|
}
|
|
2891
|
-
}
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
scroll("end");
|
|
3171
|
+
};
|
|
3172
|
+
const scroll = (type) => {
|
|
3173
|
+
if (!itemsContainer.value)
|
|
3174
|
+
return;
|
|
3175
|
+
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
3176
|
+
if (type === "left") {
|
|
3177
|
+
translateLeft += 100;
|
|
3178
|
+
if (translateLeft > 0) {
|
|
3179
|
+
translateLeft = 0;
|
|
3180
|
+
}
|
|
3181
|
+
} else if (type === "right") {
|
|
3182
|
+
translateLeft -= 100;
|
|
3183
|
+
if (-translateLeft > maxScrollLeft) {
|
|
3184
|
+
translateLeft = -maxScrollLeft;
|
|
3185
|
+
}
|
|
3186
|
+
} else if (type === "start") {
|
|
3187
|
+
translateLeft = 0;
|
|
3188
|
+
} else if (type === "end") {
|
|
3189
|
+
translateLeft = -maxScrollLeft;
|
|
2911
3190
|
}
|
|
3191
|
+
itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
|
|
3192
|
+
};
|
|
3193
|
+
onMounted(() => {
|
|
3194
|
+
pageBar.value && resizeObserver.observe(pageBar.value);
|
|
3195
|
+
});
|
|
3196
|
+
onUnmounted(() => {
|
|
3197
|
+
resizeObserver.disconnect();
|
|
2912
3198
|
});
|
|
2913
|
-
});
|
|
2914
|
-
return {
|
|
2915
|
-
pageBar,
|
|
2916
|
-
itemsContainer,
|
|
2917
|
-
canScroll,
|
|
2918
|
-
itemsContainerWidth,
|
|
2919
|
-
scroll
|
|
2920
|
-
};
|
|
2921
|
-
};
|
|
2922
|
-
const _sfc_main$5 = defineComponent({
|
|
2923
|
-
components: { ArrowLeftBold, ArrowRightBold, CaretBottom, Plus, ToolButton },
|
|
2924
|
-
setup() {
|
|
2925
|
-
const services = inject("services");
|
|
2926
|
-
const editorService = services?.editorService;
|
|
2927
3199
|
const root = computed(() => editorService?.get("root"));
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
}
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
3200
|
+
watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
|
|
3201
|
+
setTimeout(() => {
|
|
3202
|
+
setCanScroll();
|
|
3203
|
+
if (length < preLength) {
|
|
3204
|
+
scroll("start");
|
|
3205
|
+
} else {
|
|
3206
|
+
scroll("end");
|
|
3207
|
+
}
|
|
3208
|
+
});
|
|
3209
|
+
});
|
|
3210
|
+
const addPage = () => {
|
|
3211
|
+
if (!editorService)
|
|
3212
|
+
return;
|
|
3213
|
+
const pageConfig = {
|
|
3214
|
+
type: NodeType.PAGE,
|
|
3215
|
+
name: generatePageNameByApp(toRaw(editorService.get("root")))
|
|
3216
|
+
};
|
|
3217
|
+
editorService.add(pageConfig);
|
|
3218
|
+
};
|
|
3219
|
+
return (_ctx, _cache) => {
|
|
3220
|
+
const _component_el_icon = resolveComponent("el-icon");
|
|
3221
|
+
return openBlock(), createElementBlock("div", {
|
|
3222
|
+
class: "m-editor-page-bar",
|
|
3223
|
+
ref_key: "pageBar",
|
|
3224
|
+
ref: pageBar
|
|
3225
|
+
}, [
|
|
3226
|
+
createElementVNode("div", {
|
|
3227
|
+
id: "m-editor-page-bar-add-icon",
|
|
3228
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3229
|
+
onClick: addPage
|
|
3230
|
+
}, [
|
|
3231
|
+
createVNode(_component_el_icon, null, {
|
|
3232
|
+
default: withCtx(() => [
|
|
3233
|
+
createVNode(unref(Plus))
|
|
3234
|
+
]),
|
|
3235
|
+
_: 1
|
|
3236
|
+
})
|
|
3237
|
+
]),
|
|
3238
|
+
canScroll.value ? (openBlock(), createElementBlock("div", {
|
|
3239
|
+
key: 0,
|
|
3240
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3241
|
+
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
3242
|
+
}, [
|
|
3243
|
+
createVNode(_component_el_icon, null, {
|
|
3244
|
+
default: withCtx(() => [
|
|
3245
|
+
createVNode(unref(ArrowLeftBold))
|
|
3246
|
+
]),
|
|
3247
|
+
_: 1
|
|
3248
|
+
})
|
|
3249
|
+
])) : createCommentVNode("", true),
|
|
3250
|
+
unref(root) ? (openBlock(), createElementBlock("div", {
|
|
3251
|
+
key: 1,
|
|
3252
|
+
class: "m-editor-page-bar-items",
|
|
3253
|
+
ref_key: "itemsContainer",
|
|
3254
|
+
ref: itemsContainer,
|
|
3255
|
+
style: normalizeStyle(`width: ${unref(itemsContainerWidth)}px`)
|
|
3256
|
+
}, [
|
|
3257
|
+
renderSlot(_ctx.$slots, "default")
|
|
3258
|
+
], 4)) : createCommentVNode("", true),
|
|
3259
|
+
canScroll.value ? (openBlock(), createElementBlock("div", {
|
|
3260
|
+
key: 2,
|
|
3261
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3262
|
+
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
3263
|
+
}, [
|
|
3264
|
+
createVNode(_component_el_icon, null, {
|
|
3265
|
+
default: withCtx(() => [
|
|
3266
|
+
createVNode(unref(ArrowRightBold))
|
|
3267
|
+
]),
|
|
3268
|
+
_: 1
|
|
3269
|
+
})
|
|
3270
|
+
])) : createCommentVNode("", true)
|
|
3271
|
+
], 512);
|
|
2956
3272
|
};
|
|
2957
3273
|
}
|
|
2958
3274
|
});
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
_ctx.canScroll ? (openBlock(), createElementBlock("div", {
|
|
2988
|
-
key: 0,
|
|
2989
|
-
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
2990
|
-
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.scroll("left"))
|
|
2991
|
-
}, [
|
|
2992
|
-
createVNode(_component_el_icon, null, {
|
|
3275
|
+
|
|
3276
|
+
const _hoisted_1$2 = ["onClick"];
|
|
3277
|
+
const _hoisted_2 = { class: "m-editor-page-bar-title" };
|
|
3278
|
+
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
3279
|
+
__name: "PageBar",
|
|
3280
|
+
setup(__props) {
|
|
3281
|
+
const services = inject("services");
|
|
3282
|
+
const editorService = services?.editorService;
|
|
3283
|
+
const root = computed(() => editorService?.get("root"));
|
|
3284
|
+
const page = computed(() => editorService?.get("page"));
|
|
3285
|
+
const switchPage = (page2) => {
|
|
3286
|
+
editorService?.select(page2);
|
|
3287
|
+
};
|
|
3288
|
+
const copy = (node) => {
|
|
3289
|
+
node && editorService?.copy(node);
|
|
3290
|
+
editorService?.paste({
|
|
3291
|
+
left: 0,
|
|
3292
|
+
top: 0
|
|
3293
|
+
});
|
|
3294
|
+
};
|
|
3295
|
+
const remove = (node) => {
|
|
3296
|
+
editorService?.remove(node);
|
|
3297
|
+
};
|
|
3298
|
+
return (_ctx, _cache) => {
|
|
3299
|
+
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
3300
|
+
const _component_el_icon = resolveComponent("el-icon");
|
|
3301
|
+
const _component_el_popover = resolveComponent("el-popover");
|
|
3302
|
+
return openBlock(), createBlock(_sfc_main$6, null, {
|
|
2993
3303
|
default: withCtx(() => [
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3304
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(root) && unref(root).items || [], (item) => {
|
|
3305
|
+
return openBlock(), createElementBlock("div", {
|
|
3306
|
+
class: normalizeClass(["m-editor-page-bar-item", { active: unref(page)?.id === item.id }]),
|
|
3307
|
+
key: item.key,
|
|
3308
|
+
onClick: ($event) => switchPage(item)
|
|
3309
|
+
}, [
|
|
3310
|
+
createElementVNode("div", _hoisted_2, [
|
|
3311
|
+
renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
|
|
3312
|
+
createVNode(_component_el_tooltip, {
|
|
3313
|
+
effect: "dark",
|
|
3314
|
+
placement: "top-start",
|
|
3315
|
+
content: item.name
|
|
3316
|
+
}, {
|
|
3317
|
+
default: withCtx(() => [
|
|
3318
|
+
createElementVNode("span", null, toDisplayString(item.name), 1)
|
|
3319
|
+
]),
|
|
3320
|
+
_: 2
|
|
3321
|
+
}, 1032, ["content"])
|
|
3322
|
+
])
|
|
3323
|
+
]),
|
|
3324
|
+
createVNode(_component_el_popover, {
|
|
3325
|
+
"popper-class": "page-bar-popover",
|
|
3326
|
+
placement: "top",
|
|
3327
|
+
width: 160,
|
|
3328
|
+
trigger: "hover"
|
|
3017
3329
|
}, {
|
|
3018
|
-
|
|
3019
|
-
|
|
3330
|
+
reference: withCtx(() => [
|
|
3331
|
+
createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
|
|
3332
|
+
default: withCtx(() => [
|
|
3333
|
+
createVNode(unref(CaretBottom))
|
|
3334
|
+
]),
|
|
3335
|
+
_: 1
|
|
3336
|
+
})
|
|
3020
3337
|
]),
|
|
3021
|
-
_: 2
|
|
3022
|
-
}, 1032, ["content"])
|
|
3023
|
-
])
|
|
3024
|
-
]),
|
|
3025
|
-
createVNode(_component_el_popover, {
|
|
3026
|
-
"popper-class": "page-bar-popover",
|
|
3027
|
-
placement: "top",
|
|
3028
|
-
width: 160,
|
|
3029
|
-
trigger: "hover"
|
|
3030
|
-
}, {
|
|
3031
|
-
reference: withCtx(() => [
|
|
3032
|
-
createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
|
|
3033
3338
|
default: withCtx(() => [
|
|
3034
|
-
|
|
3339
|
+
createElementVNode("div", null, [
|
|
3340
|
+
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3341
|
+
createVNode(_sfc_main$f, {
|
|
3342
|
+
data: {
|
|
3343
|
+
type: "button",
|
|
3344
|
+
text: "\u590D\u5236",
|
|
3345
|
+
icon: unref(DocumentCopy),
|
|
3346
|
+
handler: () => copy(item)
|
|
3347
|
+
}
|
|
3348
|
+
}, null, 8, ["data"]),
|
|
3349
|
+
createVNode(_sfc_main$f, {
|
|
3350
|
+
data: {
|
|
3351
|
+
type: "button",
|
|
3352
|
+
text: "\u5220\u9664",
|
|
3353
|
+
icon: unref(Delete),
|
|
3354
|
+
handler: () => remove(item)
|
|
3355
|
+
}
|
|
3356
|
+
}, null, 8, ["data"])
|
|
3357
|
+
])
|
|
3358
|
+
])
|
|
3035
3359
|
]),
|
|
3036
|
-
_:
|
|
3037
|
-
})
|
|
3038
|
-
])
|
|
3039
|
-
|
|
3040
|
-
createElementVNode("div", null, [
|
|
3041
|
-
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3042
|
-
createVNode(_component_tool_button, {
|
|
3043
|
-
data: {
|
|
3044
|
-
type: "button",
|
|
3045
|
-
text: "\u590D\u5236",
|
|
3046
|
-
icon: _ctx.DocumentCopy,
|
|
3047
|
-
handler: () => _ctx.copy(item)
|
|
3048
|
-
}
|
|
3049
|
-
}, null, 8, ["data"]),
|
|
3050
|
-
createVNode(_component_tool_button, {
|
|
3051
|
-
data: {
|
|
3052
|
-
type: "button",
|
|
3053
|
-
text: "\u5220\u9664",
|
|
3054
|
-
icon: _ctx.Delete,
|
|
3055
|
-
handler: () => _ctx.remove(item)
|
|
3056
|
-
}
|
|
3057
|
-
}, null, 8, ["data"])
|
|
3058
|
-
])
|
|
3059
|
-
])
|
|
3060
|
-
]),
|
|
3061
|
-
_: 2
|
|
3062
|
-
}, 1024)
|
|
3063
|
-
], 10, _hoisted_2);
|
|
3064
|
-
}), 128))
|
|
3065
|
-
], 4)) : createCommentVNode("", true),
|
|
3066
|
-
_ctx.canScroll ? (openBlock(), createElementBlock("div", {
|
|
3067
|
-
key: 2,
|
|
3068
|
-
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3069
|
-
onClick: _cache[2] || (_cache[2] = ($event) => _ctx.scroll("right"))
|
|
3070
|
-
}, [
|
|
3071
|
-
createVNode(_component_el_icon, null, {
|
|
3072
|
-
default: withCtx(() => [
|
|
3073
|
-
createVNode(_component_arrow_right_bold)
|
|
3360
|
+
_: 2
|
|
3361
|
+
}, 1024)
|
|
3362
|
+
], 10, _hoisted_1$2);
|
|
3363
|
+
}), 128))
|
|
3074
3364
|
]),
|
|
3075
|
-
_:
|
|
3076
|
-
})
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
}
|
|
3080
|
-
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
|
|
3365
|
+
_: 3
|
|
3366
|
+
});
|
|
3367
|
+
};
|
|
3368
|
+
}
|
|
3369
|
+
});
|
|
3081
3370
|
|
|
3082
3371
|
class ScrollViewer$1 {
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
if (targetHeight < height) {
|
|
3103
|
-
this.target._top = 0;
|
|
3104
|
-
}
|
|
3105
|
-
this.scroll();
|
|
3106
|
-
}
|
|
3107
|
-
});
|
|
3108
|
-
this.wheelHandler = (event) => {
|
|
3109
|
-
if (this.targetEnter)
|
|
3110
|
-
return;
|
|
3111
|
-
const { deltaX, deltaY, currentTarget } = event;
|
|
3112
|
-
if (currentTarget !== this.container)
|
|
3113
|
-
return;
|
|
3114
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3115
|
-
this.scroll();
|
|
3116
|
-
this.scrollLeft = this.target._left;
|
|
3117
|
-
this.scrollTop = this.target._top;
|
|
3118
|
-
};
|
|
3119
|
-
this.mouseEnterHandler = () => {
|
|
3120
|
-
this.enter = true;
|
|
3121
|
-
};
|
|
3122
|
-
this.mouseLeaveHandler = () => {
|
|
3123
|
-
this.enter = false;
|
|
3124
|
-
};
|
|
3125
|
-
this.targetMouseEnterHandler = () => {
|
|
3126
|
-
this.targetEnter = true;
|
|
3127
|
-
};
|
|
3128
|
-
this.targetMouseLeaveHandler = () => {
|
|
3129
|
-
this.targetEnter = false;
|
|
3130
|
-
};
|
|
3131
|
-
this.mousedownHandler = (event) => {
|
|
3132
|
-
if (!this.keydown)
|
|
3133
|
-
return;
|
|
3134
|
-
event.stopImmediatePropagation();
|
|
3135
|
-
event.stopPropagation();
|
|
3136
|
-
this.target.style.cursor = "grabbing";
|
|
3137
|
-
this.x = event.clientX;
|
|
3138
|
-
this.y = event.clientY;
|
|
3139
|
-
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3140
|
-
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3141
|
-
};
|
|
3142
|
-
this.mouseupHandler = () => {
|
|
3143
|
-
this.x = 0;
|
|
3144
|
-
this.y = 0;
|
|
3145
|
-
this.scrollLeft = this.target._left;
|
|
3146
|
-
this.scrollTop = this.target._top;
|
|
3147
|
-
this.removeHandler();
|
|
3148
|
-
};
|
|
3149
|
-
this.mousemoveHandler = (event) => {
|
|
3150
|
-
event.stopImmediatePropagation();
|
|
3151
|
-
event.stopPropagation();
|
|
3152
|
-
const deltaX = event.clientX - this.x;
|
|
3153
|
-
const deltaY = event.clientY - this.y;
|
|
3154
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3155
|
-
this.scroll();
|
|
3156
|
-
};
|
|
3157
|
-
this.keydownHandler = (event) => {
|
|
3158
|
-
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3159
|
-
event.preventDefault();
|
|
3160
|
-
event.stopImmediatePropagation();
|
|
3161
|
-
event.stopPropagation();
|
|
3162
|
-
}
|
|
3163
|
-
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3164
|
-
return;
|
|
3372
|
+
enter = false;
|
|
3373
|
+
targetEnter = false;
|
|
3374
|
+
keydown = false;
|
|
3375
|
+
container;
|
|
3376
|
+
target;
|
|
3377
|
+
zoom = 1;
|
|
3378
|
+
scrollLeft = 0;
|
|
3379
|
+
scrollTop = 0;
|
|
3380
|
+
x = 0;
|
|
3381
|
+
y = 0;
|
|
3382
|
+
resizeObserver = new ResizeObserver((entries) => {
|
|
3383
|
+
for (const { contentRect } of entries) {
|
|
3384
|
+
const { width, height } = contentRect;
|
|
3385
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3386
|
+
const targetWidth = targetRect.width * this.zoom;
|
|
3387
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3388
|
+
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
3389
|
+
if (targetWidth < width) {
|
|
3390
|
+
this.target._left = 0;
|
|
3165
3391
|
}
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3169
|
-
};
|
|
3170
|
-
this.keyupHandler = (event) => {
|
|
3171
|
-
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3172
|
-
return;
|
|
3392
|
+
if (targetHeight < height) {
|
|
3393
|
+
this.target._top = 0;
|
|
3173
3394
|
}
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
event.preventDefault();
|
|
3179
|
-
this.removeHandler();
|
|
3180
|
-
};
|
|
3395
|
+
this.scroll();
|
|
3396
|
+
}
|
|
3397
|
+
});
|
|
3398
|
+
constructor(options) {
|
|
3181
3399
|
this.container = options.container;
|
|
3182
3400
|
this.target = options.target;
|
|
3183
3401
|
this.zoom = options.zoom;
|
|
@@ -3213,6 +3431,79 @@ class ScrollViewer$1 {
|
|
|
3213
3431
|
document.removeEventListener("mousemove", this.mousemoveHandler);
|
|
3214
3432
|
document.removeEventListener("mouseup", this.mouseupHandler);
|
|
3215
3433
|
}
|
|
3434
|
+
wheelHandler = (event) => {
|
|
3435
|
+
if (this.targetEnter)
|
|
3436
|
+
return;
|
|
3437
|
+
const { deltaX, deltaY, currentTarget } = event;
|
|
3438
|
+
if (currentTarget !== this.container)
|
|
3439
|
+
return;
|
|
3440
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3441
|
+
this.scroll();
|
|
3442
|
+
this.scrollLeft = this.target._left;
|
|
3443
|
+
this.scrollTop = this.target._top;
|
|
3444
|
+
};
|
|
3445
|
+
mouseEnterHandler = () => {
|
|
3446
|
+
this.enter = true;
|
|
3447
|
+
};
|
|
3448
|
+
mouseLeaveHandler = () => {
|
|
3449
|
+
this.enter = false;
|
|
3450
|
+
};
|
|
3451
|
+
targetMouseEnterHandler = () => {
|
|
3452
|
+
this.targetEnter = true;
|
|
3453
|
+
};
|
|
3454
|
+
targetMouseLeaveHandler = () => {
|
|
3455
|
+
this.targetEnter = false;
|
|
3456
|
+
};
|
|
3457
|
+
mousedownHandler = (event) => {
|
|
3458
|
+
if (!this.keydown)
|
|
3459
|
+
return;
|
|
3460
|
+
event.stopImmediatePropagation();
|
|
3461
|
+
event.stopPropagation();
|
|
3462
|
+
this.target.style.cursor = "grabbing";
|
|
3463
|
+
this.x = event.clientX;
|
|
3464
|
+
this.y = event.clientY;
|
|
3465
|
+
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3466
|
+
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3467
|
+
};
|
|
3468
|
+
mouseupHandler = () => {
|
|
3469
|
+
this.x = 0;
|
|
3470
|
+
this.y = 0;
|
|
3471
|
+
this.scrollLeft = this.target._left;
|
|
3472
|
+
this.scrollTop = this.target._top;
|
|
3473
|
+
this.removeHandler();
|
|
3474
|
+
};
|
|
3475
|
+
mousemoveHandler = (event) => {
|
|
3476
|
+
event.stopImmediatePropagation();
|
|
3477
|
+
event.stopPropagation();
|
|
3478
|
+
const deltaX = event.clientX - this.x;
|
|
3479
|
+
const deltaY = event.clientY - this.y;
|
|
3480
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3481
|
+
this.scroll();
|
|
3482
|
+
};
|
|
3483
|
+
keydownHandler = (event) => {
|
|
3484
|
+
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3485
|
+
event.preventDefault();
|
|
3486
|
+
event.stopImmediatePropagation();
|
|
3487
|
+
event.stopPropagation();
|
|
3488
|
+
}
|
|
3489
|
+
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3490
|
+
return;
|
|
3491
|
+
}
|
|
3492
|
+
this.keydown = true;
|
|
3493
|
+
this.target.style.cursor = "grab";
|
|
3494
|
+
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3495
|
+
};
|
|
3496
|
+
keyupHandler = (event) => {
|
|
3497
|
+
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3498
|
+
return;
|
|
3499
|
+
}
|
|
3500
|
+
event.preventDefault();
|
|
3501
|
+
event.stopImmediatePropagation();
|
|
3502
|
+
event.stopPropagation();
|
|
3503
|
+
this.keydown = false;
|
|
3504
|
+
event.preventDefault();
|
|
3505
|
+
this.removeHandler();
|
|
3506
|
+
};
|
|
3216
3507
|
setScrollOffset(deltaX, deltaY) {
|
|
3217
3508
|
const { width, height } = this.container.getBoundingClientRect();
|
|
3218
3509
|
const targetRect = this.target.getBoundingClientRect();
|
|
@@ -3273,18 +3564,19 @@ const _sfc_main$4 = defineComponent({
|
|
|
3273
3564
|
el,
|
|
3274
3565
|
style: computed(() => `
|
|
3275
3566
|
width: ${props.width}px;
|
|
3276
|
-
height: ${
|
|
3567
|
+
height: ${props.height}px;
|
|
3277
3568
|
position: absolute;
|
|
3278
3569
|
margin-top: 30px;
|
|
3279
3570
|
`)
|
|
3280
3571
|
};
|
|
3281
3572
|
}
|
|
3282
3573
|
});
|
|
3574
|
+
|
|
3283
3575
|
const _hoisted_1$1 = {
|
|
3284
3576
|
class: "m-editor-scroll-viewer-container",
|
|
3285
3577
|
ref: "container"
|
|
3286
3578
|
};
|
|
3287
|
-
function _sfc_render$
|
|
3579
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3288
3580
|
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
3289
3581
|
createElementVNode("div", {
|
|
3290
3582
|
ref: "el",
|
|
@@ -3294,170 +3586,170 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3294
3586
|
], 4)
|
|
3295
3587
|
], 512);
|
|
3296
3588
|
}
|
|
3297
|
-
|
|
3589
|
+
const ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$2]]);
|
|
3298
3590
|
|
|
3299
|
-
const _sfc_main$3 = defineComponent({
|
|
3300
|
-
|
|
3301
|
-
|
|
3591
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
3592
|
+
__name: "ViewerMenu",
|
|
3593
|
+
props: {
|
|
3594
|
+
isMultiSelect: { type: Boolean, default: false }
|
|
3595
|
+
},
|
|
3596
|
+
setup(__props, { expose }) {
|
|
3597
|
+
const props = __props;
|
|
3302
3598
|
const services = inject("services");
|
|
3303
3599
|
const editorService = services?.editorService;
|
|
3304
3600
|
const menu = ref();
|
|
3305
3601
|
const canPaste = ref(false);
|
|
3306
3602
|
const canCenter = ref(false);
|
|
3307
3603
|
const node = computed(() => editorService?.get("node"));
|
|
3604
|
+
const nodes = computed(() => editorService?.get("nodes"));
|
|
3308
3605
|
const parent = computed(() => editorService?.get("parent"));
|
|
3309
|
-
const
|
|
3606
|
+
const stage = computed(() => editorService?.get("stage"));
|
|
3310
3607
|
const stageContentMenu = inject("stageContentMenu", []);
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3608
|
+
const menuData = reactive([
|
|
3609
|
+
{
|
|
3610
|
+
type: "button",
|
|
3611
|
+
text: "\u6C34\u5E73\u5C45\u4E2D",
|
|
3612
|
+
display: () => canCenter.value,
|
|
3613
|
+
handler: () => {
|
|
3614
|
+
if (!nodes.value)
|
|
3615
|
+
return;
|
|
3616
|
+
editorService?.alignCenter(nodes.value);
|
|
3617
|
+
}
|
|
3618
|
+
},
|
|
3619
|
+
{
|
|
3620
|
+
type: "button",
|
|
3621
|
+
text: "\u590D\u5236",
|
|
3622
|
+
icon: markRaw(DocumentCopy),
|
|
3623
|
+
handler: () => {
|
|
3624
|
+
nodes.value && editorService?.copy(nodes.value);
|
|
3625
|
+
canPaste.value = true;
|
|
3626
|
+
}
|
|
3627
|
+
},
|
|
3628
|
+
{
|
|
3629
|
+
type: "button",
|
|
3630
|
+
text: "\u7C98\u8D34",
|
|
3631
|
+
display: () => canPaste.value,
|
|
3632
|
+
handler: () => {
|
|
3633
|
+
const rect = menu.value?.$el.getBoundingClientRect();
|
|
3634
|
+
const parentRect = stage.value?.container?.getBoundingClientRect();
|
|
3635
|
+
const initialLeft = (rect?.left || 0) - (parentRect?.left || 0);
|
|
3636
|
+
const initialTop = (rect?.top || 0) - (parentRect?.top || 0);
|
|
3637
|
+
if (!nodes.value || nodes.value.length === 0)
|
|
3638
|
+
return;
|
|
3639
|
+
editorService?.paste({ left: initialLeft, top: initialTop });
|
|
3640
|
+
}
|
|
3641
|
+
},
|
|
3642
|
+
{
|
|
3643
|
+
type: "divider",
|
|
3644
|
+
direction: "horizontal",
|
|
3645
|
+
display: () => {
|
|
3646
|
+
if (!node.value)
|
|
3647
|
+
return false;
|
|
3648
|
+
return !isPage(node.value);
|
|
3649
|
+
}
|
|
3650
|
+
},
|
|
3651
|
+
{
|
|
3652
|
+
type: "button",
|
|
3653
|
+
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
3654
|
+
icon: markRaw(Top),
|
|
3655
|
+
display: () => !isPage(node.value) && !props.isMultiSelect,
|
|
3656
|
+
handler: () => {
|
|
3657
|
+
editorService?.moveLayer(1);
|
|
3658
|
+
}
|
|
3659
|
+
},
|
|
3660
|
+
{
|
|
3661
|
+
type: "button",
|
|
3662
|
+
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
3663
|
+
icon: markRaw(Bottom),
|
|
3664
|
+
display: () => !isPage(node.value) && !props.isMultiSelect,
|
|
3665
|
+
handler: () => {
|
|
3666
|
+
editorService?.moveLayer(-1);
|
|
3667
|
+
}
|
|
3668
|
+
},
|
|
3669
|
+
{
|
|
3670
|
+
type: "button",
|
|
3671
|
+
text: "\u7F6E\u9876",
|
|
3672
|
+
display: () => !isPage(node.value) && !props.isMultiSelect,
|
|
3673
|
+
handler: () => {
|
|
3674
|
+
editorService?.moveLayer(LayerOffset.TOP);
|
|
3675
|
+
}
|
|
3676
|
+
},
|
|
3677
|
+
{
|
|
3678
|
+
type: "button",
|
|
3679
|
+
text: "\u7F6E\u5E95",
|
|
3680
|
+
display: () => !isPage(node.value) && !props.isMultiSelect,
|
|
3681
|
+
handler: () => {
|
|
3682
|
+
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
3683
|
+
}
|
|
3684
|
+
},
|
|
3685
|
+
{
|
|
3686
|
+
type: "divider",
|
|
3687
|
+
direction: "horizontal",
|
|
3688
|
+
display: () => !isPage(node.value) && !props.isMultiSelect
|
|
3689
|
+
},
|
|
3690
|
+
{
|
|
3691
|
+
type: "button",
|
|
3692
|
+
text: "\u5220\u9664",
|
|
3693
|
+
icon: Delete,
|
|
3694
|
+
display: () => !isPage(node.value),
|
|
3695
|
+
handler: () => {
|
|
3696
|
+
nodes.value && editorService?.remove(nodes.value);
|
|
3697
|
+
}
|
|
3698
|
+
},
|
|
3699
|
+
{
|
|
3700
|
+
type: "divider",
|
|
3701
|
+
direction: "horizontal"
|
|
3702
|
+
},
|
|
3703
|
+
{
|
|
3704
|
+
type: "button",
|
|
3705
|
+
text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
|
|
3706
|
+
handler: () => {
|
|
3707
|
+
editorService?.get("stage").clearGuides();
|
|
3708
|
+
}
|
|
3709
|
+
},
|
|
3710
|
+
...stageContentMenu
|
|
3711
|
+
]);
|
|
3315
3712
|
watch(parent, async () => {
|
|
3316
3713
|
if (!parent.value || !editorService)
|
|
3317
3714
|
return canCenter.value = false;
|
|
3318
3715
|
const layout = await editorService.getLayout(parent.value);
|
|
3319
|
-
|
|
3716
|
+
const isLayoutConform = [Layout.ABSOLUTE, Layout.FIXED].includes(layout);
|
|
3717
|
+
const isTypeConform = nodes.value?.every((selectedNode) => ![NodeType.ROOT, NodeType.PAGE, "pop"].includes(`${selectedNode?.type}`));
|
|
3718
|
+
canCenter.value = isLayoutConform && !!isTypeConform;
|
|
3320
3719
|
}, { immediate: true });
|
|
3321
|
-
|
|
3322
|
-
menu
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
type: "button",
|
|
3334
|
-
text: "\u590D\u5236",
|
|
3335
|
-
icon: markRaw(DocumentCopy),
|
|
3336
|
-
handler: () => {
|
|
3337
|
-
node.value && editorService?.copy(node.value);
|
|
3338
|
-
canPaste.value = true;
|
|
3339
|
-
}
|
|
3340
|
-
},
|
|
3341
|
-
{
|
|
3342
|
-
type: "button",
|
|
3343
|
-
text: "\u7C98\u8D34",
|
|
3344
|
-
display: () => canPaste.value,
|
|
3345
|
-
handler: () => {
|
|
3346
|
-
const stage = editorService?.get("stage");
|
|
3347
|
-
const rect = menu.value?.$el.getBoundingClientRect();
|
|
3348
|
-
const parentRect = stage?.container?.getBoundingClientRect();
|
|
3349
|
-
let left = (rect?.left || 0) - (parentRect?.left || 0);
|
|
3350
|
-
let top = (rect?.top || 0) - (parentRect?.top || 0);
|
|
3351
|
-
if (node.value?.items && stage) {
|
|
3352
|
-
const parentEl = stage.renderer.contentWindow?.document.getElementById(`${node.value.id}`);
|
|
3353
|
-
const parentElRect = parentEl?.getBoundingClientRect();
|
|
3354
|
-
left = left - (parentElRect?.left || 0);
|
|
3355
|
-
top = top - (parentElRect?.top || 0);
|
|
3356
|
-
}
|
|
3357
|
-
editorService?.paste({ left, top });
|
|
3358
|
-
}
|
|
3359
|
-
},
|
|
3360
|
-
{
|
|
3361
|
-
type: "divider",
|
|
3362
|
-
direction: "horizontal",
|
|
3363
|
-
display: () => !isPage.value
|
|
3364
|
-
},
|
|
3365
|
-
{
|
|
3366
|
-
type: "button",
|
|
3367
|
-
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
3368
|
-
icon: markRaw(Top),
|
|
3369
|
-
display: () => !isPage.value,
|
|
3370
|
-
handler: () => {
|
|
3371
|
-
editorService?.moveLayer(1);
|
|
3372
|
-
}
|
|
3373
|
-
},
|
|
3374
|
-
{
|
|
3375
|
-
type: "button",
|
|
3376
|
-
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
3377
|
-
icon: markRaw(Bottom),
|
|
3378
|
-
display: () => !isPage.value,
|
|
3379
|
-
handler: () => {
|
|
3380
|
-
editorService?.moveLayer(-1);
|
|
3381
|
-
}
|
|
3382
|
-
},
|
|
3383
|
-
{
|
|
3384
|
-
type: "button",
|
|
3385
|
-
text: "\u7F6E\u9876",
|
|
3386
|
-
display: () => !isPage.value,
|
|
3387
|
-
handler: () => {
|
|
3388
|
-
editorService?.moveLayer(LayerOffset.TOP);
|
|
3389
|
-
}
|
|
3390
|
-
},
|
|
3391
|
-
{
|
|
3392
|
-
type: "button",
|
|
3393
|
-
text: "\u7F6E\u5E95",
|
|
3394
|
-
display: () => !isPage.value,
|
|
3395
|
-
handler: () => {
|
|
3396
|
-
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
3397
|
-
}
|
|
3398
|
-
},
|
|
3399
|
-
{
|
|
3400
|
-
type: "divider",
|
|
3401
|
-
direction: "horizontal",
|
|
3402
|
-
display: () => !isPage.value
|
|
3403
|
-
},
|
|
3404
|
-
{
|
|
3405
|
-
type: "button",
|
|
3406
|
-
text: "\u5220\u9664",
|
|
3407
|
-
icon: Delete,
|
|
3408
|
-
display: () => !isPage.value,
|
|
3409
|
-
handler: () => {
|
|
3410
|
-
node.value && editorService?.remove(node.value);
|
|
3411
|
-
}
|
|
3412
|
-
},
|
|
3413
|
-
{
|
|
3414
|
-
type: "divider",
|
|
3415
|
-
direction: "horizontal"
|
|
3416
|
-
},
|
|
3417
|
-
{
|
|
3418
|
-
type: "button",
|
|
3419
|
-
text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
|
|
3420
|
-
handler: () => {
|
|
3421
|
-
editorService?.get("stage").clearGuides();
|
|
3422
|
-
}
|
|
3423
|
-
},
|
|
3424
|
-
...stageContentMenu
|
|
3425
|
-
]),
|
|
3426
|
-
show(e) {
|
|
3427
|
-
menu.value?.show(e);
|
|
3428
|
-
}
|
|
3720
|
+
const show = async (e) => {
|
|
3721
|
+
menu.value?.show(e);
|
|
3722
|
+
const data = await storageService.getItem(COPY_STORAGE_KEY);
|
|
3723
|
+
canPaste.value = data !== "undefined" && !!data;
|
|
3724
|
+
};
|
|
3725
|
+
expose({ show });
|
|
3726
|
+
return (_ctx, _cache) => {
|
|
3727
|
+
return openBlock(), createBlock(_sfc_main$b, {
|
|
3728
|
+
"menu-data": menuData,
|
|
3729
|
+
ref_key: "menu",
|
|
3730
|
+
ref: menu
|
|
3731
|
+
}, null, 8, ["menu-data"]);
|
|
3429
3732
|
};
|
|
3430
3733
|
}
|
|
3431
3734
|
});
|
|
3432
|
-
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3433
|
-
const _component_content_menu = resolveComponent("content-menu");
|
|
3434
|
-
return openBlock(), createBlock(_component_content_menu, {
|
|
3435
|
-
"menu-data": _ctx.menuData,
|
|
3436
|
-
ref: "menu"
|
|
3437
|
-
}, null, 8, ["menu-data"]);
|
|
3438
|
-
}
|
|
3439
|
-
var ViewerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
|
|
3440
3735
|
|
|
3441
|
-
const _sfc_main$2 = defineComponent({
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
},
|
|
3447
|
-
setup() {
|
|
3736
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
3737
|
+
__name: "Stage",
|
|
3738
|
+
setup(__props) {
|
|
3739
|
+
let stage = null;
|
|
3740
|
+
let runtime = null;
|
|
3448
3741
|
const services = inject("services");
|
|
3449
3742
|
const stageOptions = inject("stageOptions");
|
|
3450
3743
|
const stageWrap = ref();
|
|
3451
3744
|
const stageContainer = ref();
|
|
3452
3745
|
const menu = ref();
|
|
3746
|
+
const isMultiSelect = computed(() => services?.editorService.get("nodes")?.length > 1);
|
|
3453
3747
|
const stageRect = computed(() => services?.uiService.get("stageRect"));
|
|
3454
3748
|
const uiSelectMode = computed(() => services?.uiService.get("uiSelectMode"));
|
|
3455
3749
|
const root = computed(() => services?.editorService.get("root"));
|
|
3456
3750
|
const page = computed(() => services?.editorService.get("page"));
|
|
3457
3751
|
const zoom = computed(() => services?.uiService.get("zoom") || 1);
|
|
3458
3752
|
const node = computed(() => services?.editorService.get("node"));
|
|
3459
|
-
let stage = null;
|
|
3460
|
-
let runtime = null;
|
|
3461
3753
|
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
3462
3754
|
watchEffect(() => {
|
|
3463
3755
|
if (stage)
|
|
@@ -3471,6 +3763,10 @@ const _sfc_main$2 = defineComponent({
|
|
|
3471
3763
|
runtimeUrl: stageOptions.runtimeUrl,
|
|
3472
3764
|
zoom: zoom.value,
|
|
3473
3765
|
autoScrollIntoView: stageOptions.autoScrollIntoView,
|
|
3766
|
+
isContainer: stageOptions.isContainer,
|
|
3767
|
+
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
3768
|
+
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
3769
|
+
containerHighlightType: stageOptions.containerHighlightType,
|
|
3474
3770
|
canSelect: (el, event, stop) => {
|
|
3475
3771
|
const elCanSelect = stageOptions.canSelect(el);
|
|
3476
3772
|
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
@@ -3494,8 +3790,17 @@ const _sfc_main$2 = defineComponent({
|
|
|
3494
3790
|
stage?.on("highlight", (el) => {
|
|
3495
3791
|
services?.editorService.highlight(el.id);
|
|
3496
3792
|
});
|
|
3793
|
+
stage?.on("multiSelect", (els) => {
|
|
3794
|
+
services?.editorService.multiSelect(els.map((el) => el.id));
|
|
3795
|
+
});
|
|
3497
3796
|
stage?.on("update", (ev) => {
|
|
3498
|
-
|
|
3797
|
+
if (ev.parentEl) {
|
|
3798
|
+
for (const data of ev.data) {
|
|
3799
|
+
services?.editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
3800
|
+
}
|
|
3801
|
+
return;
|
|
3802
|
+
}
|
|
3803
|
+
services?.editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
3499
3804
|
});
|
|
3500
3805
|
stage?.on("sort", (ev) => {
|
|
3501
3806
|
services?.editorService.sort(ev.src, ev.dist);
|
|
@@ -3548,81 +3853,96 @@ const _sfc_main$2 = defineComponent({
|
|
|
3548
3853
|
resizeObserver.disconnect();
|
|
3549
3854
|
services?.editorService.set("stage", null);
|
|
3550
3855
|
});
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
e2.
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3856
|
+
const contextmenuHandler = (e2) => {
|
|
3857
|
+
e2.preventDefault();
|
|
3858
|
+
menu.value?.show(e2);
|
|
3859
|
+
};
|
|
3860
|
+
const dragoverHandler = (e2) => {
|
|
3861
|
+
e2.preventDefault();
|
|
3862
|
+
if (e2.dataTransfer) {
|
|
3863
|
+
e2.dataTransfer.dropEffect = "move";
|
|
3864
|
+
}
|
|
3865
|
+
};
|
|
3866
|
+
const dropHandler = async (e) => {
|
|
3867
|
+
e.preventDefault();
|
|
3868
|
+
const doc = stage?.renderer.contentWindow?.document;
|
|
3869
|
+
const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
|
|
3870
|
+
let parent = page.value;
|
|
3871
|
+
if (parentEl) {
|
|
3872
|
+
parent = services?.editorService.getNodeById(parentEl.id, false);
|
|
3873
|
+
}
|
|
3874
|
+
if (e.dataTransfer && parent && stageContainer.value && stage) {
|
|
3875
|
+
const config = eval(`(${e.dataTransfer.getData("data")})`);
|
|
3876
|
+
const layout = await services?.editorService.getLayout(parent);
|
|
3877
|
+
const containerRect = stageContainer.value.getBoundingClientRect();
|
|
3878
|
+
const { scrollTop, scrollLeft } = stage.mask;
|
|
3879
|
+
const { style = {} } = config;
|
|
3880
|
+
let top = 0;
|
|
3881
|
+
let left = 0;
|
|
3882
|
+
let position = "relative";
|
|
3883
|
+
if (layout === Layout.ABSOLUTE) {
|
|
3884
|
+
position = "absolute";
|
|
3885
|
+
top = e.clientY - containerRect.top + scrollTop;
|
|
3886
|
+
left = e.clientX - containerRect.left + scrollLeft;
|
|
3887
|
+
if (parentEl && doc) {
|
|
3888
|
+
const { left: parentLeft, top: parentTop } = getOffset(parentEl);
|
|
3889
|
+
left = left - calcValueByFontsize(doc, parentLeft);
|
|
3890
|
+
top = top - calcValueByFontsize(doc, parentTop);
|
|
3581
3891
|
}
|
|
3582
|
-
services?.editorService.add(config, page.value);
|
|
3583
3892
|
}
|
|
3893
|
+
config.style = {
|
|
3894
|
+
...style,
|
|
3895
|
+
position,
|
|
3896
|
+
top,
|
|
3897
|
+
left
|
|
3898
|
+
};
|
|
3899
|
+
config.inputEvent = e;
|
|
3900
|
+
services?.editorService.add(config, parent);
|
|
3584
3901
|
}
|
|
3585
3902
|
};
|
|
3903
|
+
return (_ctx, _cache) => {
|
|
3904
|
+
return openBlock(), createBlock(ScrollViewer, {
|
|
3905
|
+
class: "m-editor-stage",
|
|
3906
|
+
ref_key: "stageWrap",
|
|
3907
|
+
ref: stageWrap,
|
|
3908
|
+
width: unref(stageRect)?.width,
|
|
3909
|
+
height: unref(stageRect)?.height,
|
|
3910
|
+
zoom: unref(zoom)
|
|
3911
|
+
}, {
|
|
3912
|
+
default: withCtx(() => [
|
|
3913
|
+
createElementVNode("div", {
|
|
3914
|
+
class: "m-editor-stage-container",
|
|
3915
|
+
ref_key: "stageContainer",
|
|
3916
|
+
ref: stageContainer,
|
|
3917
|
+
style: normalizeStyle(`transform: scale(${unref(zoom)})`),
|
|
3918
|
+
onContextmenu: contextmenuHandler,
|
|
3919
|
+
onDrop: dropHandler,
|
|
3920
|
+
onDragover: dragoverHandler
|
|
3921
|
+
}, null, 36),
|
|
3922
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
3923
|
+
createVNode(_sfc_main$3, {
|
|
3924
|
+
ref_key: "menu",
|
|
3925
|
+
ref: menu,
|
|
3926
|
+
"is-multi-select": unref(isMultiSelect)
|
|
3927
|
+
}, null, 8, ["is-multi-select"])
|
|
3928
|
+
]))
|
|
3929
|
+
]),
|
|
3930
|
+
_: 1
|
|
3931
|
+
}, 8, ["width", "height", "zoom"]);
|
|
3932
|
+
};
|
|
3586
3933
|
}
|
|
3587
3934
|
});
|
|
3588
|
-
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3589
|
-
const _component_viewer_menu = resolveComponent("viewer-menu");
|
|
3590
|
-
const _component_scroll_viewer = resolveComponent("scroll-viewer");
|
|
3591
|
-
return openBlock(), createBlock(_component_scroll_viewer, {
|
|
3592
|
-
class: "m-editor-stage",
|
|
3593
|
-
ref: "stageWrap",
|
|
3594
|
-
width: _ctx.stageRect?.width,
|
|
3595
|
-
height: _ctx.stageRect?.height,
|
|
3596
|
-
zoom: _ctx.zoom
|
|
3597
|
-
}, {
|
|
3598
|
-
default: withCtx(() => [
|
|
3599
|
-
createElementVNode("div", {
|
|
3600
|
-
class: "m-editor-stage-container",
|
|
3601
|
-
ref: "stageContainer",
|
|
3602
|
-
style: normalizeStyle(`transform: scale(${_ctx.zoom})`),
|
|
3603
|
-
onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
|
|
3604
|
-
onDrop: _cache[1] || (_cache[1] = (...args) => _ctx.dropHandler && _ctx.dropHandler(...args)),
|
|
3605
|
-
onDragover: _cache[2] || (_cache[2] = (...args) => _ctx.dragoverHandler && _ctx.dragoverHandler(...args))
|
|
3606
|
-
}, null, 36),
|
|
3607
|
-
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
3608
|
-
createVNode(_component_viewer_menu, { ref: "menu" }, null, 512)
|
|
3609
|
-
]))
|
|
3610
|
-
]),
|
|
3611
|
-
_: 1
|
|
3612
|
-
}, 8, ["width", "height", "zoom"]);
|
|
3613
|
-
}
|
|
3614
|
-
var MagicStage = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
|
|
3615
3935
|
|
|
3616
3936
|
const _sfc_main$1 = defineComponent({
|
|
3617
3937
|
name: "m-editor-workspace",
|
|
3618
3938
|
components: {
|
|
3619
|
-
PageBar,
|
|
3620
|
-
MagicStage
|
|
3939
|
+
PageBar: _sfc_main$5,
|
|
3940
|
+
MagicStage: _sfc_main$2
|
|
3621
3941
|
},
|
|
3622
3942
|
setup() {
|
|
3623
3943
|
const services = inject("services");
|
|
3624
3944
|
const workspace = ref();
|
|
3625
|
-
const
|
|
3945
|
+
const nodes = computed(() => services?.editorService.get("nodes"));
|
|
3626
3946
|
let keycon;
|
|
3627
3947
|
const mouseenterHandler = () => {
|
|
3628
3948
|
workspace.value?.focus();
|
|
@@ -3638,26 +3958,26 @@ const _sfc_main$1 = defineComponent({
|
|
|
3638
3958
|
const ctrl = isMac ? "meta" : "ctrl";
|
|
3639
3959
|
keycon.keyup("delete", (e) => {
|
|
3640
3960
|
e.inputEvent.preventDefault();
|
|
3641
|
-
if (!
|
|
3961
|
+
if (!nodes.value || isPage(nodes.value[0]))
|
|
3642
3962
|
return;
|
|
3643
|
-
services?.editorService.remove(
|
|
3963
|
+
services?.editorService.remove(nodes.value);
|
|
3644
3964
|
}).keyup("backspace", (e) => {
|
|
3645
3965
|
e.inputEvent.preventDefault();
|
|
3646
|
-
if (!
|
|
3966
|
+
if (!nodes.value || isPage(nodes.value[0]))
|
|
3647
3967
|
return;
|
|
3648
|
-
services?.editorService.remove(
|
|
3968
|
+
services?.editorService.remove(nodes.value);
|
|
3649
3969
|
}).keydown([ctrl, "c"], (e) => {
|
|
3650
3970
|
e.inputEvent.preventDefault();
|
|
3651
|
-
|
|
3971
|
+
nodes.value && services?.editorService.copy(nodes.value);
|
|
3652
3972
|
}).keydown([ctrl, "v"], (e) => {
|
|
3653
3973
|
e.inputEvent.preventDefault();
|
|
3654
|
-
|
|
3974
|
+
nodes.value && services?.editorService.paste({ offsetX: 10, offsetY: 10 });
|
|
3655
3975
|
}).keydown([ctrl, "x"], (e) => {
|
|
3656
3976
|
e.inputEvent.preventDefault();
|
|
3657
|
-
if (!
|
|
3977
|
+
if (!nodes.value || isPage(nodes.value[0]))
|
|
3658
3978
|
return;
|
|
3659
|
-
services?.editorService.copy(
|
|
3660
|
-
services?.editorService.remove(
|
|
3979
|
+
services?.editorService.copy(nodes.value);
|
|
3980
|
+
services?.editorService.remove(nodes.value);
|
|
3661
3981
|
}).keydown([ctrl, "z"], (e) => {
|
|
3662
3982
|
e.inputEvent.preventDefault();
|
|
3663
3983
|
services?.editorService.undo();
|
|
@@ -3719,6 +4039,7 @@ const _sfc_main$1 = defineComponent({
|
|
|
3719
4039
|
};
|
|
3720
4040
|
}
|
|
3721
4041
|
});
|
|
4042
|
+
|
|
3722
4043
|
const _hoisted_1 = {
|
|
3723
4044
|
class: "m-editor-workspace",
|
|
3724
4045
|
tabindex: "1",
|
|
@@ -3743,14 +4064,14 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3743
4064
|
})
|
|
3744
4065
|
], 512);
|
|
3745
4066
|
}
|
|
3746
|
-
|
|
4067
|
+
const Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
3747
4068
|
|
|
3748
4069
|
class ComponentList extends BaseService {
|
|
4070
|
+
state = reactive({
|
|
4071
|
+
list: []
|
|
4072
|
+
});
|
|
3749
4073
|
constructor() {
|
|
3750
4074
|
super([]);
|
|
3751
|
-
this.state = reactive({
|
|
3752
|
-
list: []
|
|
3753
|
-
});
|
|
3754
4075
|
}
|
|
3755
4076
|
setList(componentGroupList) {
|
|
3756
4077
|
this.state.list = componentGroupList;
|
|
@@ -3759,7 +4080,7 @@ class ComponentList extends BaseService {
|
|
|
3759
4080
|
return this.state.list;
|
|
3760
4081
|
}
|
|
3761
4082
|
}
|
|
3762
|
-
|
|
4083
|
+
const componentListService = new ComponentList();
|
|
3763
4084
|
|
|
3764
4085
|
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
3765
4086
|
const MIN_LEFT_COLUMN_WIDTH = 45;
|
|
@@ -3871,13 +4192,15 @@ class Ui extends BaseService {
|
|
|
3871
4192
|
const { height, width } = stageContainerRect;
|
|
3872
4193
|
if (!width || !height)
|
|
3873
4194
|
return 1;
|
|
3874
|
-
|
|
4195
|
+
const stageWidth = stageRect.width + 30;
|
|
4196
|
+
const stageHeight = stageRect.height + 30;
|
|
4197
|
+
if (width > stageWidth && height > stageHeight) {
|
|
3875
4198
|
return 1;
|
|
3876
4199
|
}
|
|
3877
|
-
return Math.min((width -
|
|
4200
|
+
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
3878
4201
|
}
|
|
3879
4202
|
}
|
|
3880
|
-
|
|
4203
|
+
const uiService = new Ui();
|
|
3881
4204
|
|
|
3882
4205
|
const _sfc_main = defineComponent({
|
|
3883
4206
|
name: "m-editor",
|
|
@@ -3940,6 +4263,22 @@ const _sfc_main = defineComponent({
|
|
|
3940
4263
|
type: Function,
|
|
3941
4264
|
default: (el) => Boolean(el.id)
|
|
3942
4265
|
},
|
|
4266
|
+
isContainer: {
|
|
4267
|
+
type: Function,
|
|
4268
|
+
default: (el) => el.classList.contains("magic-ui-container")
|
|
4269
|
+
},
|
|
4270
|
+
containerHighlightClassName: {
|
|
4271
|
+
type: String,
|
|
4272
|
+
default: CONTAINER_HIGHLIGHT_CLASS
|
|
4273
|
+
},
|
|
4274
|
+
containerHighlightDuration: {
|
|
4275
|
+
type: Number,
|
|
4276
|
+
default: 800
|
|
4277
|
+
},
|
|
4278
|
+
containerHighlightType: {
|
|
4279
|
+
type: String,
|
|
4280
|
+
default: ContainerHighlightType.DEFAULT
|
|
4281
|
+
},
|
|
3943
4282
|
stageRect: {
|
|
3944
4283
|
type: [String, Object]
|
|
3945
4284
|
},
|
|
@@ -3995,7 +4334,8 @@ const _sfc_main = defineComponent({
|
|
|
3995
4334
|
historyService,
|
|
3996
4335
|
propsService,
|
|
3997
4336
|
editorService,
|
|
3998
|
-
uiService
|
|
4337
|
+
uiService,
|
|
4338
|
+
storageService
|
|
3999
4339
|
};
|
|
4000
4340
|
provide("services", services);
|
|
4001
4341
|
provide("layerContentMenu", props.layerContentMenu);
|
|
@@ -4006,11 +4346,16 @@ const _sfc_main = defineComponent({
|
|
|
4006
4346
|
render: props.render,
|
|
4007
4347
|
moveableOptions: props.moveableOptions,
|
|
4008
4348
|
canSelect: props.canSelect,
|
|
4009
|
-
updateDragEl: props.updateDragEl
|
|
4349
|
+
updateDragEl: props.updateDragEl,
|
|
4350
|
+
isContainer: props.isContainer,
|
|
4351
|
+
containerHighlightClassName: props.containerHighlightClassName,
|
|
4352
|
+
containerHighlightDuration: props.containerHighlightDuration,
|
|
4353
|
+
containerHighlightType: props.containerHighlightType
|
|
4010
4354
|
}));
|
|
4011
4355
|
return services;
|
|
4012
4356
|
}
|
|
4013
4357
|
});
|
|
4358
|
+
|
|
4014
4359
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4015
4360
|
const _component_nav_menu = resolveComponent("nav-menu");
|
|
4016
4361
|
const _component_sidebar = resolveComponent("sidebar");
|
|
@@ -4071,23 +4416,23 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4071
4416
|
_: 3
|
|
4072
4417
|
}, 8, ["code-options"]);
|
|
4073
4418
|
}
|
|
4074
|
-
|
|
4419
|
+
const Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
4075
4420
|
|
|
4076
|
-
var index$1 = /* #__PURE__ */ (() => ".m-editor-nav-menu {\n display: flex;\n z-index: 5;\n -webkit-box-pack: justify;\n justify-content: space-between;\n -webkit-box-align: center;\n align-items: center;\n background-color: #ffffff;\n font-size: 19.2px;\n color: #070303;\n font-weight: 400;\n box-sizing: border-box;\n margin: 0px;\n flex: 0 0 35px;\n border-bottom: 1px solid #d8dee8;\n}\n.m-editor-nav-menu > div {\n display: flex;\n height: 100%;\n z-index: 1;\n align-items: center;\n}\n.m-editor-nav-menu .menu-center {\n justify-content: center;\n}\n.m-editor-nav-menu .menu-right {\n justify-content: flex-end;\n}\n.m-editor-nav-menu .menu-item {\n flex-direction: row;\n -webkit-box-align: center;\n align-items: center;\n vertical-align: middle;\n font-size: 14px;\n line-height: 1;\n height: 100%;\n color: rgba(255, 255, 255, 0.7);\n box-sizing: inherit;\n z-index: 1;\n display: flex !important;\n transition: all 0.3s ease 0s;\n border-bottom: 2px solid transparent;\n margin: 0;\n}\n.m-editor-nav-menu .menu-item .is-disabled {\n opacity: 0.5;\n}\n.m-editor-nav-menu .menu-item .is-text {\n padding: 5px;\n}\n.m-editor-nav-menu .menu-item .is-text,\n.m-editor-nav-menu .menu-item i {\n color: #070303;\n}\n.m-editor-nav-menu .menu-item .icon {\n display: flex;\n -webkit-box-align: center;\n align-items: center;\n height: 100%;\n padding: 0px 8px;\n}\n.m-editor-nav-menu .menu-item .menu-item-text {\n color: #070303;\n}\n.m-editor {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n.m-editor-content {\n width: 100%;\n height: calc(100% - 35px);\n display: flex;\n justify-self: space-between;\n}\n.m-editor-framework-center {\n position: relative;\n transform: translateZ(0);\n flex: 1;\n}\n.m-editor-framework-left {\n background-color: #ffffff;\n}\n.m-editor-framework-center .el-scrollbar__view {\n height: 100%;\n min-height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.m-editor-empty-panel {\n display: flex;\n flex: 1;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n height: calc(100% - 32px);\n}\n.m-editor-empty-content {\n display: flex;\n justify-content: space-evenly;\n flex-direction: row;\n width: 100%;\n}\n.m-editor-empty-button {\n border: 3px solid rgba(0, 0, 0, 0.2);\n padding: 10px 40px;\n color: rgba(0, 0, 0, 0.6);\n cursor: pointer;\n}\n.m-editor-empty-button i {\n height: 180px;\n line-height: 180px;\n font-size: 100px;\n}\n.m-editor-empty-button p {\n text-align: center;\n font-size: 20px;\n margin-top: 5px;\n}\n.m-editor-empty-button:hover {\n border-color: #2882e0;\n color: #2882e0;\n}\n.m-editor-sidebar {\n height: 100%;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header {\n background: #2882e0;\n border: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header.is-left {\n width: 40px;\n margin-right: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__nav-wrap {\n margin: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__nav {\n border: 0;\n border-radius: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .tab-label {\n margin-left: 2px;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left {\n line-height: 15px;\n border: 0;\n height: auto;\n padding: 8px;\n color: rgb(255, 255, 255);\n box-sizing: border-box;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active {\n background: #ffffff;\n border: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active i {\n color: #353140;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active .magic-editor-tab-panel-title {\n color: #353140;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left:first-child {\n border-right: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header i {\n font-size: 25px;\n color: rgba(255, 255, 255, 0.6);\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header i:hover {\n color: rgb(255, 255, 255);\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .magic-editor-tab-panel-title {\n font-size: 12px;\n white-space: normal;\n}\n.m-editor-sidebar .el-scrollbar {\n height: 100%;\n}\n.m-editor-sidebar .el-tree {\n min-height: 100%;\n}\n.m-editor-sidebar .fold-icon {\n position: absolute;\n bottom: 8px;\n left: 0px;\n width: 45px;\n padding-left: 8px;\n color: #fff;\n font-size: 32px;\n opacity: 0.8;\n cursor: pointer;\n}\n.m-editor-sidebar .fold-icon:hover {\n background: rgba(0, 0, 0, 0.2);\n}\n.m-editor-sidebar .el-tabs__content,\n.m-editor-sidebar .el-tab-pane {\n height: 100%;\n}\n.magic-editor-layer-panel {\n background: #ffffff;\n}\n.magic-editor-layer-panel .search-input {\n background: #ffffff;\n color: #bbbbbb;\n padding: 10px;\n position: absolute;\n top: 0;\n left: 0;\n z-index: 1;\n}\n.magic-editor-layer-panel .search-input .el-input__suffix {\n padding: 10px 5px;\n}\n.magic-editor-layer-panel .node-content {\n flex: 1;\n display: flex;\n width: 100%;\n}\n.magic-editor-layer-panel .node-content > div {\n width: 8px;\n}\n.magic-editor-layer-panel .node-content > span {\n width: calc(100% - 68px);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.magic-editor-layer-panel .node-content > i {\n margin-right: 10px;\n font-size: 20px;\n}\n.magic-editor-layer-panel .node-content > i.lock {\n color: #bbb;\n}\n.magic-editor-layer-panel,\n.magic-editor-layer-panel .el-tree {\n background-color: #ffffff;\n color: #313a40;\n}\n.magic-editor-layer-panel .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {\n background-color: #2882e0;\n color: #fff;\n}\n.magic-editor-layer-panel .cus-tree-node {\n width: 100%;\n overflow: hidden;\n}\n.magic-editor-layer-panel .cus-tree-node-hover {\n background-color: #f3f5f9;\n width: 100%;\n}\n.magic-editor-layer-panel .el-tree-node:focus > .el-tree-node__content {\n background-color: #2882e0;\n color: #fff;\n}\n.ui-tree-tip {\n width: 100%;\n height: 25px;\n margin-left: 10px;\n background: #ffffff;\n font-style: italic;\n color: #555554;\n position: absolute;\n top: 40px;\n left: 0;\n z-index: 1;\n}\n.ui-component-panel {\n height: 100%;\n border-top: 0 !important;\n margin-top: 50px;\n background-color: #ffffff;\n}\n.ui-component-panel .search-input {\n background: #f8fbff;\n color: #bbbbbb;\n padding: 10px;\n position: absolute;\n top: 0;\n left: 0;\n box-sizing: border-box;\n z-index: 1;\n}\n.ui-component-panel .search-input .el-input__prefix {\n padding: 10px;\n}\n.ui-component-panel .search-input .el-input__suffix {\n padding: 10px 5px;\n}\n.ui-component-panel .el-collapse-item > div:first-of-type {\n border-bottom: 1px solid #d9dbdd;\n margin-bottom: 10px;\n}\n.ui-component-panel .el-collapse-item__header {\n background: #ffffff;\n color: #070303;\n height: 25px;\n line-height: 25px;\n padding-left: 10px;\n font-size: 12px;\n}\n.ui-component-panel .el-collapse-item__header i {\n margin-right: 5px;\n font-size: 14px;\n}\n.ui-component-panel .el-collapse-item__wrap {\n background: #ffffff;\n border-bottom: 0;\n}\n.ui-component-panel .el-collapse-item__wrap .el-collapse-item__content {\n padding: 10px;\n display: flex;\n flex-wrap: wrap;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item {\n display: flex;\n overflow: hidden;\n text-overflow: ellipsis;\n margin: 5px 10px;\n box-sizing: border-box;\n color: #070303;\n flex-direction: column;\n width: 42px;\n cursor: pointer;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item i {\n font-size: 20px;\n background: #fff;\n height: 40px;\n width: 40px;\n line-height: 40px;\n border-radius: 5px;\n color: #909090;\n border: 1px solid #d9dbdd;\n display: flex;\n justify-content: space-evenly;\n align-items: center;\n margin-bottom: 5px;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item i:hover {\n background: #2882e0;\n color: #fff;\n border-color: #4e8be1;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item span {\n font-size: 12px;\n text-align: center;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item .el-tooltip {\n width: 50px;\n height: 30px;\n line-height: 15px;\n display: block;\n white-space: normal;\n margin: 0;\n}\n.m-editor-resizer {\n border-left: 1px solid transparent;\n border-right: 1px solid transparent;\n width: 8px;\n margin: 0 -5px;\n height: 100%;\n opacity: 0.9;\n background: padding-box #d8dee8;\n box-sizing: border-box;\n cursor: col-resize;\n z-index: 1;\n}\n.m-editor-resizer:hover {\n border-color: #d8dee8;\n}\n.m-editor-resizer .icon-container {\n visibility: hidden;\n opacity: 0;\n transition: opacity 0.4s;\n width: 20px;\n height: 120px;\n line-height: 120px;\n text-align: center;\n background: #d8dee8;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n cursor: pointer;\n}\n.m-editor-resizer .icon-container.position-left {\n transform: translate(calc(-100% - 4px), -50%);\n}\n.m-editor-resizer .icon-container.position-right {\n transform: translate(calc(100% + 4px), -50%);\n}\n.m-editor-resizer .icon {\n color: #fff;\n font-size: 18px;\n}\n.magic-editor-resizer:hover .icon-container {\n visibility: visible;\n opacity: 1;\n}\n.m-editor-workspace {\n height: 100%;\n width: 100%;\n user-select: none;\n}\n.m-editor-workspace:focus-visible {\n outline: 0;\n}\n.m-editor-page-bar {\n position: fixed;\n bottom: 0;\n left: 0;\n display: flex;\n width: 100%;\n height: 32px;\n line-height: 32px;\n color: #070303;\n background-color: #f3f3f3;\n border-top: 1px solid #d9dbdd;\n z-index: 2;\n overflow: hidden;\n}\n.m-editor-page-bar-items {\n display: flex;\n transition: transform 0.3s;\n}\n.m-editor-page-bar-item {\n padding: 0 10px;\n cursor: pointer;\n border-right: 1px solid #d9dbdd;\n display: flex;\n justify-items: center;\n align-items: center;\n background-color: #f3f3f3;\n white-space: nowrap;\n}\n.m-editor-page-bar-item.active {\n background-color: #fff;\n cursor: text;\n}\n.m-editor-page-bar-item.active .m-editor-page-bar-menu-icon {\n cursor: pointer;\n}\n.m-editor-page-bar-item-icon {\n position: relative;\n z-index: 1;\n}\n.m-editor-page-bar-item-title {\n max-width: 150px;\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n}\n.page-bar-popover.el-popper.el-popover {\n padding: 10px 0;\n}\n.page-bar-popover .menu-item {\n cursor: pointer;\n transition: all 0.2s ease 0s;\n padding: 5px 14px;\n}\n.page-bar-popover .menu-item .el-button--text,\n.page-bar-popover .menu-item i {\n color: #070303;\n}\n.page-bar-popover .menu-item:hover {\n background-color: #f3f5f9;\n}\n.m-editor-props-panel {\n padding: 0 10px;\n}\n.m-editor-props-panel.small .el-form-item__label {\n font-size: 12px;\n}\n.m-editor-props-panel.small .m-fieldset legend {\n font-size: 12px;\n}\n.m-editor-props-panel.small .el-tabs__item {\n font-size: 12px;\n}\n.m-editor-props-panel .el-input__wrapper {\n border-radius: 0;\n}\n.m-editor-props-panel-popper.small span,\n.m-editor-props-panel-popper.small a,\n.m-editor-props-panel-popper.small p {\n font-size: 12px;\n}\n.magic-editor-content-menu {\n position: fixed;\n font-size: 12px;\n background: #fff;\n box-shadow: 0 2px 8px 2px rgba(68, 73, 77, 0.16);\n z-index: 9999;\n transform-origin: 0% 0%;\n font-weight: 600;\n padding: 4px 0px;\n overflow: auto;\n max-height: 100%;\n}\n.magic-editor-content-menu .menu-item {\n color: #333;\n display: flex;\n -webkit-box-align: center;\n align-items: center;\n cursor: pointer;\n min-width: 140px;\n transition: all 0.2s ease 0s;\n padding: 5px 14px;\n border-left: 2px solid transparent;\n}\n.magic-editor-content-menu .menu-item .el-button {\n width: 100%;\n justify-content: flex-start;\n}\n.magic-editor-content-menu .menu-item .el-button--text,\n.magic-editor-content-menu .menu-item i {\n color: #070303;\n}\n.magic-editor-content-menu .menu-item.divider {\n padding: 0 14px;\n}\n.magic-editor-content-menu .menu-item.divider .el-divider {\n margin: 0;\n}\n.magic-editor-content-menu .menu-item:hover {\n background-color: #f3f5f9;\n}\n.m-editor-stage {\n position: relative;\n width: 100%;\n height: calc(100% - 32px);\n overflow: hidden;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.m-editor-stage-container {\n width: 100%;\n height: 100%;\n z-index: 0;\n position: relative;\n border: 1px solid #d9dbdd;\n transition: transform 0.3s;\n box-sizing: content-box;\n}\n.m-editor-stage-container::-webkit-scrollbar {\n width: 0 !important;\n}\n.magic-code-editor {\n width: 100%;\n}\n.magic-code-editor .margin {\n margin: 0;\n}")();
|
|
4421
|
+
const index$1 = '';
|
|
4077
4422
|
|
|
4078
4423
|
const defaultInstallOpt = {};
|
|
4079
|
-
|
|
4424
|
+
const index = {
|
|
4080
4425
|
install: (app, opt) => {
|
|
4081
4426
|
const option = Object.assign(defaultInstallOpt, opt || {});
|
|
4082
4427
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
4083
4428
|
setConfig(option);
|
|
4084
4429
|
app.component(Editor.name, Editor);
|
|
4085
|
-
app.component(
|
|
4430
|
+
app.component("m-fields-ui-select", _sfc_main$l);
|
|
4086
4431
|
app.component(CodeLink.name, CodeLink);
|
|
4087
4432
|
app.component(Code.name, Code);
|
|
4088
4433
|
app.component(CodeEditor.name, CodeEditor);
|
|
4089
4434
|
}
|
|
4090
4435
|
};
|
|
4091
4436
|
|
|
4092
|
-
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, generatePageName, generatePageNameByApp, getConfig,
|
|
4093
|
-
//# sourceMappingURL=tmagic-editor.
|
|
4437
|
+
export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$f as ToolButton, V_GUIDE_LINE_STORAGE_KEY, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getRelativeStyle, historyService, info, isFixed, log, propsService, setConfig, setLayout, storageService, uiService, warn };
|
|
4438
|
+
//# sourceMappingURL=tmagic-editor.mjs.map
|