@tmagic/editor 1.1.0-beta.1 → 1.1.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/style.css +5 -1
- package/dist/{tmagic-editor.es.js → tmagic-editor.mjs} +1449 -1205
- package/dist/tmagic-editor.mjs.map +1 -0
- package/dist/tmagic-editor.umd.js +1463 -1219
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +23 -21
- package/src/Editor.vue +24 -15
- package/src/components/ContentMenu.vue +87 -99
- package/src/components/Icon.vue +1 -1
- package/src/components/ScrollViewer.vue +2 -2
- package/src/components/ToolButton.vue +150 -167
- package/src/fields/UISelect.vue +51 -72
- package/src/index.ts +2 -1
- package/src/layouts/AddPageBox.vue +2 -2
- package/src/layouts/Framework.vue +1 -1
- package/src/layouts/NavMenu.vue +2 -2
- package/src/layouts/PropsPanel.vue +1 -1
- package/src/layouts/Resizer.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +6 -17
- package/src/layouts/sidebar/LayerMenu.vue +2 -2
- package/src/layouts/sidebar/LayerPanel.vue +52 -12
- package/src/layouts/sidebar/Sidebar.vue +1 -1
- package/src/layouts/sidebar/TabPane.vue +2 -2
- package/src/layouts/workspace/PageBar.vue +63 -192
- package/src/layouts/workspace/PageBarScrollContainer.vue +111 -0
- package/src/layouts/workspace/Stage.vue +198 -219
- package/src/layouts/workspace/ViewerMenu.vue +140 -147
- package/src/layouts/workspace/Workspace.vue +14 -12
- package/src/services/BaseService.ts +5 -10
- package/src/services/componentList.ts +3 -3
- package/src/services/editor.ts +208 -147
- package/src/services/events.ts +1 -1
- package/src/services/history.ts +1 -1
- package/src/services/props.ts +74 -49
- package/src/services/storage.ts +133 -0
- package/src/services/ui.ts +10 -4
- package/src/theme/component-list-panel.scss +5 -0
- package/src/theme/framework.scss +1 -1
- package/src/theme/stage.scss +2 -2
- package/src/type.ts +25 -7
- package/src/utils/config.ts +1 -1
- package/src/utils/editor.ts +20 -12
- package/src/utils/operator.ts +109 -0
- package/src/utils/props.ts +2 -27
- package/src/utils/scroll-viewer.ts +1 -1
- package/tsconfig.build.json +13 -0
- package/{dist/types/src → types}/Editor.vue.d.ts +17 -9
- package/types/components/ContentMenu.vue.d.ts +116 -0
- package/types/components/Icon.vue.d.ts +13 -0
- package/types/components/ScrollViewer.vue.d.ts +22 -0
- package/types/components/ToolButton.vue.d.ts +109 -0
- package/types/fields/Code.vue.d.ts +23 -0
- package/{dist/types/src → types}/fields/CodeLink.vue.d.ts +4 -6
- package/types/fields/UISelect.vue.d.ts +83 -0
- package/{dist/types/src → types}/index.d.ts +4 -1
- package/types/layouts/AddPageBox.vue.d.ts +4 -0
- package/{dist/types/src → types}/layouts/CodeEditor.vue.d.ts +11 -13
- package/types/layouts/Framework.vue.d.ts +22 -0
- package/types/layouts/NavMenu.vue.d.ts +25 -0
- package/types/layouts/PropsPanel.vue.d.ts +245 -0
- package/types/layouts/Resizer.vue.d.ts +12 -0
- package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +14 -0
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +100 -0
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +1101 -0
- package/{dist/types/src → types}/layouts/sidebar/Sidebar.vue.d.ts +3 -5
- package/types/layouts/sidebar/TabPane.vue.d.ts +14 -0
- package/types/layouts/workspace/PageBar.vue.d.ts +54 -0
- package/types/layouts/workspace/PageBarScrollContainer.vue.d.ts +48 -0
- package/types/layouts/workspace/Stage.vue.d.ts +46 -0
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +88 -0
- package/types/layouts/workspace/Workspace.vue.d.ts +6 -0
- package/{dist/types/src → types}/services/BaseService.d.ts +0 -0
- package/types/services/componentList.d.ts +14 -0
- package/{dist/types/src → types}/services/editor.d.ts +22 -14
- package/{dist/types/src → types}/services/events.d.ts +0 -0
- package/{dist/types/src → types}/services/history.d.ts +0 -0
- package/types/services/props.d.ts +97 -0
- package/types/services/storage.d.ts +56 -0
- package/{dist/types/src → types}/services/ui.d.ts +1 -1
- package/{dist/types/src → types}/type.d.ts +18 -1
- package/{dist/types/src → types}/utils/compose.d.ts +1 -1
- package/{dist/types/src → types}/utils/config.d.ts +0 -0
- package/{dist/types/src → types}/utils/editor.d.ts +6 -3
- package/{dist/types/src → types}/utils/index.d.ts +0 -0
- package/{dist/types/src → types}/utils/logger.d.ts +0 -0
- package/types/utils/operator.d.ts +21 -0
- package/{dist/types/src → types}/utils/polyfills.d.ts +0 -0
- package/{dist/types/src → types}/utils/props.d.ts +2 -23
- package/{dist/types/src → types}/utils/scroll-viewer.d.ts +0 -0
- package/{dist/types/src → types}/utils/undo-redo.d.ts +0 -0
- package/dist/tmagic-editor.es.js.map +0 -1
- package/dist/types/src/components/Icon.vue.d.ts +0 -14
- package/dist/types/src/components/ScrollViewer.vue.d.ts +0 -24
- package/dist/types/src/fields/Code.vue.d.ts +0 -25
- package/dist/types/src/layouts/AddPageBox.vue.d.ts +0 -5
- package/dist/types/src/layouts/Framework.vue.d.ts +0 -24
- package/dist/types/src/layouts/NavMenu.vue.d.ts +0 -27
- package/dist/types/src/layouts/PropsPanel.vue.d.ts +0 -13
- package/dist/types/src/layouts/Resizer.vue.d.ts +0 -14
- package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +0 -16
- package/dist/types/src/layouts/sidebar/TabPane.vue.d.ts +0 -16
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +0 -8
- package/dist/types/src/services/props.d.ts +0 -42
- package/dist/types/src/shims-vue.d.ts +0 -6
- package/dist/types/src/vite-env.d.ts +0 -1
- package/src/vite-env.d.ts +0 -1
|
@@ -4,31 +4,31 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.serialize, global.iconsVue, global.lodashEs, global.monaco, global.StageCore, global.schema, global.utils, global.events, global.core, global.Gesto, global.ElementPlus, global.KeyController));
|
|
5
5
|
})(this, (function (exports, vue, serialize, iconsVue, lodashEs, monaco, StageCore, schema, utils, events, core, Gesto, elementPlus, KeyController) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
|
|
8
8
|
|
|
9
9
|
function _interopNamespace(e) {
|
|
10
10
|
if (e && e.__esModule) return e;
|
|
11
|
-
|
|
11
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
|
|
12
12
|
if (e) {
|
|
13
|
-
|
|
13
|
+
for (const k in e) {
|
|
14
14
|
if (k !== 'default') {
|
|
15
|
-
|
|
15
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
16
|
Object.defineProperty(n, k, d.get ? d : {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get:
|
|
18
|
+
get: () => e[k]
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
}
|
|
21
|
+
}
|
|
22
22
|
}
|
|
23
|
-
n
|
|
23
|
+
n.default = e;
|
|
24
24
|
return Object.freeze(n);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
const serialize__default = /*#__PURE__*/_interopDefaultLegacy(serialize);
|
|
28
|
+
const monaco__namespace = /*#__PURE__*/_interopNamespace(monaco);
|
|
29
|
+
const StageCore__default = /*#__PURE__*/_interopDefaultLegacy(StageCore);
|
|
30
|
+
const Gesto__default = /*#__PURE__*/_interopDefaultLegacy(Gesto);
|
|
31
|
+
const KeyController__default = /*#__PURE__*/_interopDefaultLegacy(KeyController);
|
|
32
32
|
|
|
33
33
|
if (typeof global === "undefined") {
|
|
34
34
|
window.global = window;
|
|
@@ -37,15 +37,7 @@
|
|
|
37
37
|
window.globalThis = window;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
const target = sfc.__vccOpts || sfc;
|
|
42
|
-
for (const [key, val] of props) {
|
|
43
|
-
target[key] = val;
|
|
44
|
-
}
|
|
45
|
-
return target;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const _sfc_main$m = vue.defineComponent({
|
|
40
|
+
const _sfc_main$n = vue.defineComponent({
|
|
49
41
|
name: "m-fields-vs-code",
|
|
50
42
|
props: ["model", "name", "config", "prop"],
|
|
51
43
|
emits: ["change"],
|
|
@@ -62,7 +54,16 @@
|
|
|
62
54
|
};
|
|
63
55
|
}
|
|
64
56
|
});
|
|
65
|
-
|
|
57
|
+
|
|
58
|
+
const _export_sfc = (sfc, props) => {
|
|
59
|
+
const target = sfc.__vccOpts || sfc;
|
|
60
|
+
for (const [key, val] of props) {
|
|
61
|
+
target[key] = val;
|
|
62
|
+
}
|
|
63
|
+
return target;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
66
67
|
const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
|
|
67
68
|
return vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
|
|
68
69
|
style: vue.normalizeStyle(`height: ${_ctx.height}`),
|
|
@@ -71,9 +72,9 @@
|
|
|
71
72
|
onSave: _ctx.save
|
|
72
73
|
}, null, 8, ["style", "init-values", "language", "onSave"]);
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
+
const Code = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$g]]);
|
|
75
76
|
|
|
76
|
-
const _sfc_main$
|
|
77
|
+
const _sfc_main$m = vue.defineComponent({
|
|
77
78
|
name: "m-fields-code-link",
|
|
78
79
|
props: {
|
|
79
80
|
config: {
|
|
@@ -97,7 +98,7 @@
|
|
|
97
98
|
vue.watchEffect(() => {
|
|
98
99
|
if (!props.model || !props.name)
|
|
99
100
|
return;
|
|
100
|
-
modelValue.value.form[props.name] = serialize__default
|
|
101
|
+
modelValue.value.form[props.name] = serialize__default.default(props.model[props.name], {
|
|
101
102
|
space: 2,
|
|
102
103
|
unsafe: true
|
|
103
104
|
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
@@ -128,7 +129,8 @@
|
|
|
128
129
|
};
|
|
129
130
|
}
|
|
130
131
|
});
|
|
131
|
-
|
|
132
|
+
|
|
133
|
+
function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
132
134
|
const _component_m_fields_link = vue.resolveComponent("m-fields-link");
|
|
133
135
|
return vue.openBlock(), vue.createBlock(_component_m_fields_link, {
|
|
134
136
|
config: _ctx.formConfig,
|
|
@@ -137,26 +139,20 @@
|
|
|
137
139
|
onChange: _ctx.changeHandler
|
|
138
140
|
}, null, 8, ["config", "model", "onChange"]);
|
|
139
141
|
}
|
|
140
|
-
|
|
142
|
+
const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$f]]);
|
|
141
143
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
name: "m-fields-ui-select",
|
|
144
|
+
const _hoisted_1$d = /* @__PURE__ */ vue.createTextVNode("\u53D6\u6D88");
|
|
145
|
+
const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
|
|
146
|
+
__name: "UISelect",
|
|
146
147
|
props: {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
type: String,
|
|
152
|
-
default() {
|
|
153
|
-
return "";
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
name: String
|
|
148
|
+
config: null,
|
|
149
|
+
model: null,
|
|
150
|
+
prop: null,
|
|
151
|
+
name: null
|
|
157
152
|
},
|
|
158
153
|
emits: ["change"],
|
|
159
|
-
setup(
|
|
154
|
+
setup(__props, { emit }) {
|
|
155
|
+
const props = __props;
|
|
160
156
|
const services = vue.inject("services");
|
|
161
157
|
const mForm = vue.inject("mForm");
|
|
162
158
|
const val = vue.computed(() => props.model[props.name]);
|
|
@@ -178,97 +174,91 @@
|
|
|
178
174
|
cancelHandler();
|
|
179
175
|
}
|
|
180
176
|
};
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
},
|
|
198
|
-
cancelHandler,
|
|
199
|
-
deleteHandler() {
|
|
200
|
-
if (props.model) {
|
|
201
|
-
props.model[props.name] = "";
|
|
202
|
-
emit("change", "");
|
|
203
|
-
mForm?.$emit("field-change", props.prop, "");
|
|
204
|
-
}
|
|
177
|
+
const toName = vue.computed(() => {
|
|
178
|
+
const config = services?.editorService.getNodeById(val.value);
|
|
179
|
+
return config?.name || "";
|
|
180
|
+
});
|
|
181
|
+
const startSelect = () => {
|
|
182
|
+
if (!services?.uiService)
|
|
183
|
+
return;
|
|
184
|
+
services.uiService.set("uiSelectMode", true);
|
|
185
|
+
uiSelectMode.value = true;
|
|
186
|
+
globalThis.document.addEventListener("ui-select", clickHandler);
|
|
187
|
+
};
|
|
188
|
+
const deleteHandler = () => {
|
|
189
|
+
if (props.model) {
|
|
190
|
+
props.model[props.name] = "";
|
|
191
|
+
emit("change", "");
|
|
192
|
+
mForm?.$emit("field-change", props.prop, "");
|
|
205
193
|
}
|
|
206
194
|
};
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
class: "m-fields-ui-select",
|
|
216
|
-
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.cancelHandler && _ctx.cancelHandler(...args))
|
|
217
|
-
}, [
|
|
218
|
-
vue.createVNode(_component_el_button, {
|
|
219
|
-
type: "danger",
|
|
220
|
-
icon: _ctx.Delete,
|
|
221
|
-
text: "",
|
|
222
|
-
style: { "padding": "0" }
|
|
223
|
-
}, {
|
|
224
|
-
default: vue.withCtx(() => [
|
|
225
|
-
_hoisted_1$d
|
|
226
|
-
]),
|
|
227
|
-
_: 1
|
|
228
|
-
}, 8, ["icon"])
|
|
229
|
-
])) : (vue.openBlock(), vue.createElementBlock("div", {
|
|
230
|
-
key: 1,
|
|
231
|
-
class: "m-fields-ui-select",
|
|
232
|
-
onClick: _cache[1] || (_cache[1] = (...args) => _ctx.startSelect && _ctx.startSelect(...args)),
|
|
233
|
-
style: { "display": "flex" }
|
|
234
|
-
}, [
|
|
235
|
-
vue.createVNode(_component_el_tooltip, { content: "\u6E05\u9664" }, {
|
|
236
|
-
default: vue.withCtx(() => [
|
|
237
|
-
_ctx.val ? (vue.openBlock(), vue.createBlock(_component_el_button, {
|
|
238
|
-
key: 0,
|
|
239
|
-
style: { "padding": "0" },
|
|
240
|
-
type: "danger",
|
|
241
|
-
icon: _ctx.Close,
|
|
242
|
-
text: "",
|
|
243
|
-
onClick: vue.withModifiers(_ctx.deleteHandler, ["stop"])
|
|
244
|
-
}, null, 8, ["icon", "onClick"])) : vue.createCommentVNode("", true)
|
|
245
|
-
]),
|
|
246
|
-
_: 1
|
|
247
|
-
}),
|
|
248
|
-
vue.createVNode(_component_el_tooltip, {
|
|
249
|
-
content: _ctx.val ? _ctx.toName + "_" + _ctx.val : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
|
|
250
|
-
}, {
|
|
251
|
-
default: vue.withCtx(() => [
|
|
195
|
+
return (_ctx, _cache) => {
|
|
196
|
+
const _component_el_button = vue.resolveComponent("el-button");
|
|
197
|
+
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
198
|
+
return uiSelectMode.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
199
|
+
key: 0,
|
|
200
|
+
class: "m-fields-ui-select",
|
|
201
|
+
onClick: cancelHandler
|
|
202
|
+
}, [
|
|
252
203
|
vue.createVNode(_component_el_button, {
|
|
204
|
+
type: "danger",
|
|
205
|
+
icon: vue.unref(iconsVue.Delete),
|
|
253
206
|
text: "",
|
|
254
|
-
style: { "padding": "0"
|
|
207
|
+
style: { "padding": "0" }
|
|
255
208
|
}, {
|
|
256
209
|
default: vue.withCtx(() => [
|
|
257
|
-
|
|
210
|
+
_hoisted_1$d
|
|
258
211
|
]),
|
|
259
212
|
_: 1
|
|
260
|
-
})
|
|
261
|
-
]),
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
213
|
+
}, 8, ["icon"])
|
|
214
|
+
])) : (vue.openBlock(), vue.createElementBlock("div", {
|
|
215
|
+
key: 1,
|
|
216
|
+
class: "m-fields-ui-select",
|
|
217
|
+
onClick: startSelect,
|
|
218
|
+
style: { "display": "flex" }
|
|
219
|
+
}, [
|
|
220
|
+
vue.unref(val) ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
|
|
221
|
+
key: 0,
|
|
222
|
+
content: "\u6E05\u9664"
|
|
223
|
+
}, {
|
|
224
|
+
default: vue.withCtx(() => [
|
|
225
|
+
vue.createVNode(_component_el_button, {
|
|
226
|
+
style: { "padding": "0" },
|
|
227
|
+
type: "danger",
|
|
228
|
+
icon: vue.unref(iconsVue.Close),
|
|
229
|
+
text: "",
|
|
230
|
+
onClick: vue.withModifiers(deleteHandler, ["stop"])
|
|
231
|
+
}, null, 8, ["icon", "onClick"])
|
|
232
|
+
]),
|
|
233
|
+
_: 1
|
|
234
|
+
})) : vue.createCommentVNode("", true),
|
|
235
|
+
vue.createVNode(_component_el_tooltip, {
|
|
236
|
+
content: vue.unref(val) ? vue.unref(toName) + "_" + vue.unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
|
|
237
|
+
}, {
|
|
238
|
+
default: vue.withCtx(() => [
|
|
239
|
+
vue.createVNode(_component_el_button, {
|
|
240
|
+
text: "",
|
|
241
|
+
style: { "padding": "0", "margin": "0" }
|
|
242
|
+
}, {
|
|
243
|
+
default: vue.withCtx(() => [
|
|
244
|
+
vue.createTextVNode(vue.toDisplayString(vue.unref(val) ? vue.unref(toName) + "_" + vue.unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1)
|
|
245
|
+
]),
|
|
246
|
+
_: 1
|
|
247
|
+
})
|
|
248
|
+
]),
|
|
249
|
+
_: 1
|
|
250
|
+
}, 8, ["content"])
|
|
251
|
+
]));
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
const UISelect_vue_vue_type_style_index_0_lang = '';
|
|
267
257
|
|
|
268
258
|
const toString = (v, language) => {
|
|
269
259
|
let value = "";
|
|
270
260
|
if (typeof v !== "string") {
|
|
271
|
-
value = serialize__default
|
|
261
|
+
value = serialize__default.default(v, {
|
|
272
262
|
space: 2,
|
|
273
263
|
unsafe: true
|
|
274
264
|
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
@@ -280,7 +270,7 @@
|
|
|
280
270
|
}
|
|
281
271
|
return value;
|
|
282
272
|
};
|
|
283
|
-
const _sfc_main$
|
|
273
|
+
const _sfc_main$k = vue.defineComponent({
|
|
284
274
|
name: "magic-code-editor",
|
|
285
275
|
props: {
|
|
286
276
|
initValues: {
|
|
@@ -387,14 +377,15 @@
|
|
|
387
377
|
};
|
|
388
378
|
}
|
|
389
379
|
});
|
|
380
|
+
|
|
390
381
|
const _hoisted_1$c = {
|
|
391
382
|
ref: "codeEditor",
|
|
392
383
|
class: "magic-code-editor"
|
|
393
384
|
};
|
|
394
|
-
function _sfc_render$
|
|
385
|
+
function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
395
386
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, null, 512);
|
|
396
387
|
}
|
|
397
|
-
|
|
388
|
+
const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$e]]);
|
|
398
389
|
|
|
399
390
|
let $TMAGIC_EDITOR = {};
|
|
400
391
|
const setConfig = (option) => {
|
|
@@ -403,6 +394,9 @@
|
|
|
403
394
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
404
395
|
|
|
405
396
|
class UndoRedo {
|
|
397
|
+
elementList;
|
|
398
|
+
listCursor;
|
|
399
|
+
listMaxSize;
|
|
406
400
|
constructor(listMaxSize = 200) {
|
|
407
401
|
const minListMaxSize = 2;
|
|
408
402
|
this.elementList = [];
|
|
@@ -479,17 +473,12 @@
|
|
|
479
473
|
try {
|
|
480
474
|
let beforeArgs = args;
|
|
481
475
|
for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
|
|
482
|
-
|
|
483
|
-
if (isError(
|
|
484
|
-
throw
|
|
485
|
-
if (!Array.isArray(
|
|
486
|
-
|
|
476
|
+
beforeArgs = await beforeMethod(...beforeArgs) || [];
|
|
477
|
+
if (isError(beforeArgs))
|
|
478
|
+
throw beforeArgs;
|
|
479
|
+
if (!Array.isArray(beforeArgs)) {
|
|
480
|
+
beforeArgs = [beforeArgs];
|
|
487
481
|
}
|
|
488
|
-
beforeArgs = beforeArgs.map((v, index) => {
|
|
489
|
-
if (typeof beforeReturnValue[index] === "undefined")
|
|
490
|
-
return v;
|
|
491
|
-
return beforeReturnValue[index];
|
|
492
|
-
});
|
|
493
482
|
}
|
|
494
483
|
let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
|
|
495
484
|
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
@@ -503,12 +492,12 @@
|
|
|
503
492
|
}
|
|
504
493
|
};
|
|
505
494
|
class BaseService extends events.EventEmitter {
|
|
495
|
+
pluginOptionsList = {};
|
|
496
|
+
middleware = {};
|
|
497
|
+
taskList = [];
|
|
498
|
+
doingTask = false;
|
|
506
499
|
constructor(methods = [], serialMethods = []) {
|
|
507
500
|
super();
|
|
508
|
-
this.pluginOptionsList = {};
|
|
509
|
-
this.middleware = {};
|
|
510
|
-
this.taskList = [];
|
|
511
|
-
this.doingTask = false;
|
|
512
501
|
methods.forEach((propertyName) => {
|
|
513
502
|
const scope = this;
|
|
514
503
|
const sourceMethod = scope[propertyName];
|
|
@@ -565,14 +554,14 @@
|
|
|
565
554
|
}
|
|
566
555
|
|
|
567
556
|
class History extends BaseService {
|
|
557
|
+
state = vue.reactive({
|
|
558
|
+
pageSteps: {},
|
|
559
|
+
pageId: void 0,
|
|
560
|
+
canRedo: false,
|
|
561
|
+
canUndo: false
|
|
562
|
+
});
|
|
568
563
|
constructor() {
|
|
569
564
|
super([]);
|
|
570
|
-
this.state = vue.reactive({
|
|
571
|
-
pageSteps: {},
|
|
572
|
-
pageId: void 0,
|
|
573
|
-
canRedo: false,
|
|
574
|
-
canUndo: false
|
|
575
|
-
});
|
|
576
565
|
this.on("change", this.setCanUndoRedo);
|
|
577
566
|
}
|
|
578
567
|
reset() {
|
|
@@ -641,88 +630,88 @@
|
|
|
641
630
|
this.state.canUndo = undoRedo?.canUndo() || false;
|
|
642
631
|
}
|
|
643
632
|
}
|
|
644
|
-
|
|
633
|
+
const historyService = new History();
|
|
645
634
|
|
|
646
|
-
|
|
635
|
+
var Protocol = /* @__PURE__ */ ((Protocol2) => {
|
|
636
|
+
Protocol2["OBJECT"] = "object";
|
|
637
|
+
Protocol2["JSON"] = "json";
|
|
638
|
+
Protocol2["STRING"] = "string";
|
|
639
|
+
Protocol2["NUMBER"] = "number";
|
|
640
|
+
Protocol2["BOOLEAN"] = "boolean";
|
|
641
|
+
return Protocol2;
|
|
642
|
+
})(Protocol || {});
|
|
643
|
+
class WebStorage extends BaseService {
|
|
644
|
+
storage = globalThis.localStorage;
|
|
645
|
+
namespace = "tmagic";
|
|
647
646
|
constructor() {
|
|
648
|
-
super(["
|
|
649
|
-
this.state = vue.reactive({
|
|
650
|
-
propsConfigMap: {},
|
|
651
|
-
propsValueMap: {}
|
|
652
|
-
});
|
|
647
|
+
super(["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"]);
|
|
653
648
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
this.setPropsConfig(utils.toLine(type), configs[type]);
|
|
657
|
-
});
|
|
658
|
-
this.emit("props-configs-change");
|
|
649
|
+
async getStorage() {
|
|
650
|
+
return this.storage;
|
|
659
651
|
}
|
|
660
|
-
|
|
661
|
-
this.
|
|
652
|
+
async getNamespace() {
|
|
653
|
+
return this.namespace;
|
|
662
654
|
}
|
|
663
|
-
async
|
|
664
|
-
|
|
665
|
-
|
|
655
|
+
async clear() {
|
|
656
|
+
const storage2 = await this.getStorage();
|
|
657
|
+
storage2.clear();
|
|
658
|
+
}
|
|
659
|
+
async getItem(key, options = {}) {
|
|
660
|
+
const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
661
|
+
const { protocol = options.protocol, item } = this.getValueAndProtocol(storage.getItem(`${options.namespace || namespace}:${key}`));
|
|
662
|
+
if (item === null)
|
|
663
|
+
return null;
|
|
664
|
+
switch (protocol) {
|
|
665
|
+
case "object" /* OBJECT */:
|
|
666
|
+
return eval(`(${item})`);
|
|
667
|
+
case "json" /* JSON */:
|
|
668
|
+
return JSON.parse(item);
|
|
669
|
+
case "number" /* NUMBER */:
|
|
670
|
+
return Number(item);
|
|
671
|
+
case "boolean" /* BOOLEAN */:
|
|
672
|
+
return Boolean(item);
|
|
673
|
+
default:
|
|
674
|
+
return item;
|
|
666
675
|
}
|
|
667
|
-
return lodashEs.cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
|
|
668
676
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
});
|
|
677
|
+
async key(index) {
|
|
678
|
+
const storage2 = await this.getStorage();
|
|
679
|
+
return storage2.key(index);
|
|
673
680
|
}
|
|
674
|
-
|
|
675
|
-
|
|
681
|
+
async removeItem(key2, options2 = {}) {
|
|
682
|
+
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
683
|
+
storage2.removeItem(`${options2.namespace || namespace2}:${key2}`);
|
|
676
684
|
}
|
|
677
|
-
async
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
}
|
|
685
|
-
return value;
|
|
685
|
+
async setItem(key2, value, options2 = {}) {
|
|
686
|
+
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
687
|
+
let item2 = value;
|
|
688
|
+
const protocol2 = options2.protocol ? `${options2.protocol}:` : "";
|
|
689
|
+
if (typeof value === "string" /* STRING */ || typeof value === "number" /* NUMBER */) {
|
|
690
|
+
item2 = `${protocol2}${value}`;
|
|
691
|
+
} else {
|
|
692
|
+
item2 = `${protocol2}${serialize__default.default(value)}`;
|
|
686
693
|
}
|
|
687
|
-
|
|
688
|
-
|
|
694
|
+
storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
|
|
695
|
+
}
|
|
696
|
+
getValueAndProtocol(value) {
|
|
697
|
+
let protocol2 = "";
|
|
698
|
+
if (value === null) {
|
|
699
|
+
return {
|
|
700
|
+
item: value,
|
|
701
|
+
protocol: protocol2
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
const item2 = value.replace(new RegExp(`^(${Object.values(Protocol).join("|")})(:)(.+)`), (_$0, $1, _$2, $3) => {
|
|
705
|
+
protocol2 = $1;
|
|
706
|
+
return $3;
|
|
707
|
+
});
|
|
689
708
|
return {
|
|
690
|
-
|
|
691
|
-
|
|
709
|
+
protocol: protocol2,
|
|
710
|
+
item: item2
|
|
692
711
|
};
|
|
693
712
|
}
|
|
694
|
-
async createId(type) {
|
|
695
|
-
return `${type}_${lodashEs.random(1e4, false)}`;
|
|
696
|
-
}
|
|
697
|
-
async setNewItemId(config, parent) {
|
|
698
|
-
const oldId = config.id;
|
|
699
|
-
config.id = await this.createId(config.type || "component");
|
|
700
|
-
if (utils.isPop(config) && parent?.type === schema.NodeType.PAGE) {
|
|
701
|
-
updatePopId(oldId, config.id, parent);
|
|
702
|
-
}
|
|
703
|
-
if (config.items && Array.isArray(config.items)) {
|
|
704
|
-
for (const item of config.items) {
|
|
705
|
-
await this.setNewItemId(item, config);
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
713
|
}
|
|
710
|
-
const
|
|
711
|
-
pageConfig.items?.forEach((config) => {
|
|
712
|
-
if (config.pop === oldId) {
|
|
713
|
-
config.pop = popId;
|
|
714
|
-
return;
|
|
715
|
-
}
|
|
716
|
-
if (config.popId === oldId) {
|
|
717
|
-
config.popId = popId;
|
|
718
|
-
return;
|
|
719
|
-
}
|
|
720
|
-
if (Array.isArray(config.items)) {
|
|
721
|
-
updatePopId(oldId, popId, config);
|
|
722
|
-
}
|
|
723
|
-
});
|
|
724
|
-
};
|
|
725
|
-
var propsService = new Props();
|
|
714
|
+
const storageService = new WebStorage();
|
|
726
715
|
|
|
727
716
|
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
728
717
|
LayerOffset2["TOP"] = "top";
|
|
@@ -774,10 +763,10 @@
|
|
|
774
763
|
top: 0,
|
|
775
764
|
left: 0
|
|
776
765
|
});
|
|
777
|
-
const getMiddleTop = (
|
|
778
|
-
let height = style
|
|
779
|
-
if (!stage || typeof style
|
|
780
|
-
return style
|
|
766
|
+
const getMiddleTop = (node, parentNode, stage) => {
|
|
767
|
+
let height = node.style?.height || 0;
|
|
768
|
+
if (!stage || typeof node.style?.top !== "undefined" || !parentNode.style)
|
|
769
|
+
return node.style?.top;
|
|
781
770
|
if (!utils.isNumber(height)) {
|
|
782
771
|
height = 0;
|
|
783
772
|
}
|
|
@@ -788,12 +777,11 @@
|
|
|
788
777
|
}
|
|
789
778
|
return (parentHeight - height) / 2;
|
|
790
779
|
};
|
|
791
|
-
const getInitPositionStyle = (style = {}, layout
|
|
780
|
+
const getInitPositionStyle = (style = {}, layout) => {
|
|
792
781
|
if (layout === Layout.ABSOLUTE) {
|
|
793
782
|
return {
|
|
794
783
|
...style,
|
|
795
|
-
position: "absolute"
|
|
796
|
-
top: getMiddleTop(style, parentNode, stage)
|
|
784
|
+
position: "absolute"
|
|
797
785
|
};
|
|
798
786
|
}
|
|
799
787
|
if (layout === Layout.RELATIVE) {
|
|
@@ -879,34 +867,215 @@
|
|
|
879
867
|
return config.style?.left;
|
|
880
868
|
const el = doc.getElementById(`${config.id}`);
|
|
881
869
|
const parentEl = doc.getElementById(`${parent.id}`);
|
|
882
|
-
|
|
870
|
+
const left = Number(config.style?.left) || 0;
|
|
871
|
+
if (el && parentEl && el.offsetWidth + left > parentEl.offsetWidth) {
|
|
883
872
|
return parentEl.offsetWidth - el.offsetWidth;
|
|
884
873
|
}
|
|
885
874
|
return config.style.left;
|
|
886
875
|
};
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
876
|
+
const fixNodePosition = (config, parent, stage) => {
|
|
877
|
+
if (config.style?.position !== "absolute") {
|
|
878
|
+
return config.style;
|
|
879
|
+
}
|
|
880
|
+
return {
|
|
881
|
+
...config.style || {},
|
|
882
|
+
top: getMiddleTop(config, parent, stage),
|
|
883
|
+
left: fixNodeLeft(config, parent, stage?.renderer.contentWindow?.document)
|
|
884
|
+
};
|
|
891
885
|
};
|
|
892
|
-
|
|
886
|
+
|
|
887
|
+
class Props extends BaseService {
|
|
888
|
+
state = vue.reactive({
|
|
889
|
+
propsConfigMap: {},
|
|
890
|
+
propsValueMap: {}
|
|
891
|
+
});
|
|
892
|
+
constructor() {
|
|
893
|
+
super([
|
|
894
|
+
"setPropsConfig",
|
|
895
|
+
"getPropsConfig",
|
|
896
|
+
"setPropsValue",
|
|
897
|
+
"getPropsValue",
|
|
898
|
+
"createId",
|
|
899
|
+
"setNewItemId",
|
|
900
|
+
"fillConfig",
|
|
901
|
+
"getDefaultPropsValue"
|
|
902
|
+
]);
|
|
903
|
+
}
|
|
904
|
+
setPropsConfigs(configs) {
|
|
905
|
+
Object.keys(configs).forEach((type) => {
|
|
906
|
+
this.setPropsConfig(utils.toLine(type), configs[type]);
|
|
907
|
+
});
|
|
908
|
+
this.emit("props-configs-change");
|
|
909
|
+
}
|
|
910
|
+
async fillConfig(config) {
|
|
911
|
+
return fillConfig(config);
|
|
912
|
+
}
|
|
913
|
+
async setPropsConfig(type, config) {
|
|
914
|
+
this.state.propsConfigMap[type] = await this.fillConfig(Array.isArray(config) ? config : [config]);
|
|
915
|
+
}
|
|
916
|
+
async getPropsConfig(type) {
|
|
917
|
+
if (type === "area") {
|
|
918
|
+
return await this.getPropsConfig("button");
|
|
919
|
+
}
|
|
920
|
+
return lodashEs.cloneDeep(this.state.propsConfigMap[type] || await this.fillConfig([]));
|
|
921
|
+
}
|
|
922
|
+
setPropsValues(values) {
|
|
923
|
+
Object.keys(values).forEach((type) => {
|
|
924
|
+
this.setPropsValue(utils.toLine(type), values[type]);
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
setPropsValue(type, value) {
|
|
928
|
+
this.state.propsValueMap[type] = value;
|
|
929
|
+
}
|
|
930
|
+
async getPropsValue(type, { inputEvent, ...defaultValue } = {}) {
|
|
931
|
+
if (type === "area") {
|
|
932
|
+
const value = await this.getPropsValue("button");
|
|
933
|
+
value.className = "action-area";
|
|
934
|
+
value.text = "";
|
|
935
|
+
if (value.style) {
|
|
936
|
+
value.style.backgroundColor = "rgba(255, 255, 255, 0)";
|
|
937
|
+
}
|
|
938
|
+
return value;
|
|
939
|
+
}
|
|
940
|
+
const [id, defaultPropsValue, data] = await Promise.all([
|
|
941
|
+
this.createId(type),
|
|
942
|
+
this.getDefaultPropsValue(type),
|
|
943
|
+
this.setNewItemId(lodashEs.cloneDeep({
|
|
944
|
+
type,
|
|
945
|
+
...defaultValue
|
|
946
|
+
}))
|
|
947
|
+
]);
|
|
948
|
+
return {
|
|
949
|
+
id,
|
|
950
|
+
...defaultPropsValue,
|
|
951
|
+
...lodashEs.mergeWith({}, lodashEs.cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
async createId(type) {
|
|
955
|
+
return `${type}_${this.guid()}`;
|
|
956
|
+
}
|
|
957
|
+
async setNewItemId(config) {
|
|
958
|
+
config.id = await this.createId(config.type || "component");
|
|
959
|
+
if (config.items && Array.isArray(config.items)) {
|
|
960
|
+
for (const item of config.items) {
|
|
961
|
+
await this.setNewItemId(item);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
return config;
|
|
965
|
+
}
|
|
966
|
+
async getDefaultPropsValue(type) {
|
|
967
|
+
return ["page", "container"].includes(type) ? {
|
|
968
|
+
type,
|
|
969
|
+
layout: "absolute",
|
|
970
|
+
style: {},
|
|
971
|
+
name: type,
|
|
972
|
+
items: []
|
|
973
|
+
} : {
|
|
974
|
+
type,
|
|
975
|
+
style: {},
|
|
976
|
+
name: type
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
guid(digit = 8) {
|
|
980
|
+
return "x".repeat(digit).replace(/[xy]/g, (c) => {
|
|
981
|
+
const r = Math.random() * 16 | 0;
|
|
982
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
983
|
+
return v.toString(16);
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
const propsService = new Props();
|
|
988
|
+
|
|
989
|
+
const beforePaste = async (position, config) => {
|
|
990
|
+
if (!config[0]?.style)
|
|
991
|
+
return config;
|
|
992
|
+
const curNode = editorService.get("node");
|
|
993
|
+
const { left: referenceLeft, top: referenceTop } = config[0].style;
|
|
994
|
+
const pasteConfigs = await Promise.all(config.map(async (configItem) => {
|
|
995
|
+
const { offsetX = 0, offsetY = 0, ...positionClone } = position;
|
|
996
|
+
let pastePosition = positionClone;
|
|
997
|
+
if (!lodashEs.isEmpty(pastePosition) && curNode.items) {
|
|
998
|
+
pastePosition = getPositionInContainer(pastePosition, curNode.id);
|
|
999
|
+
}
|
|
1000
|
+
if (pastePosition.left && configItem.style?.left) {
|
|
1001
|
+
pastePosition.left = configItem.style.left - referenceLeft + pastePosition.left;
|
|
1002
|
+
}
|
|
1003
|
+
if (pastePosition.top && configItem.style?.top) {
|
|
1004
|
+
pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
|
|
1005
|
+
}
|
|
1006
|
+
const pasteConfig = await propsService.setNewItemId(configItem);
|
|
1007
|
+
if (pasteConfig.style) {
|
|
1008
|
+
const { left, top } = pasteConfig.style;
|
|
1009
|
+
if (typeof left === "number" || !!left && !isNaN(Number(left))) {
|
|
1010
|
+
pasteConfig.style.left = Number(left) + offsetX;
|
|
1011
|
+
}
|
|
1012
|
+
if (typeof top === "number" || !!top && !isNaN(Number(top))) {
|
|
1013
|
+
pasteConfig.style.top = Number(top) + offsetY;
|
|
1014
|
+
}
|
|
1015
|
+
pasteConfig.style = {
|
|
1016
|
+
...pasteConfig.style,
|
|
1017
|
+
...pastePosition
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
if (utils.isPage(pasteConfig)) {
|
|
1021
|
+
pasteConfig.name = generatePageNameByApp(editorService.get("root"));
|
|
1022
|
+
}
|
|
1023
|
+
return pasteConfig;
|
|
1024
|
+
}));
|
|
1025
|
+
return pasteConfigs;
|
|
893
1026
|
};
|
|
894
|
-
const
|
|
1027
|
+
const getPositionInContainer = (position = {}, id) => {
|
|
1028
|
+
let { left = 0, top = 0 } = position;
|
|
1029
|
+
const parentEl = editorService.get("stage")?.renderer?.contentWindow?.document.getElementById(`${id}`);
|
|
1030
|
+
const parentElRect = parentEl?.getBoundingClientRect();
|
|
1031
|
+
left = left - (parentElRect?.left || 0);
|
|
1032
|
+
top = top - (parentElRect?.top || 0);
|
|
1033
|
+
return {
|
|
1034
|
+
left,
|
|
1035
|
+
top
|
|
1036
|
+
};
|
|
895
1037
|
};
|
|
896
|
-
const
|
|
1038
|
+
const getAddParent = (node) => {
|
|
1039
|
+
const curNode = editorService.get("node");
|
|
1040
|
+
let parentNode;
|
|
1041
|
+
if (utils.isPage(node)) {
|
|
1042
|
+
parentNode = editorService.get("root");
|
|
1043
|
+
} else if (curNode.items) {
|
|
1044
|
+
parentNode = curNode;
|
|
1045
|
+
} else {
|
|
1046
|
+
parentNode = editorService.getParentById(curNode.id, false);
|
|
1047
|
+
}
|
|
1048
|
+
return parentNode;
|
|
897
1049
|
};
|
|
898
1050
|
|
|
899
1051
|
class Editor$1 extends BaseService {
|
|
1052
|
+
state = vue.reactive({
|
|
1053
|
+
root: null,
|
|
1054
|
+
page: null,
|
|
1055
|
+
parent: null,
|
|
1056
|
+
node: null,
|
|
1057
|
+
nodes: [],
|
|
1058
|
+
stage: null,
|
|
1059
|
+
highlightNode: null,
|
|
1060
|
+
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
1061
|
+
pageLength: 0
|
|
1062
|
+
});
|
|
1063
|
+
isHistoryStateChange = false;
|
|
900
1064
|
constructor() {
|
|
901
1065
|
super([
|
|
902
1066
|
"getLayout",
|
|
903
1067
|
"select",
|
|
1068
|
+
"doAdd",
|
|
904
1069
|
"add",
|
|
1070
|
+
"doRemove",
|
|
905
1071
|
"remove",
|
|
1072
|
+
"doUpdate",
|
|
906
1073
|
"update",
|
|
907
1074
|
"sort",
|
|
908
1075
|
"copy",
|
|
909
1076
|
"paste",
|
|
1077
|
+
"doPaste",
|
|
1078
|
+
"duAlignCenter",
|
|
910
1079
|
"alignCenter",
|
|
911
1080
|
"moveLayer",
|
|
912
1081
|
"moveToContainer",
|
|
@@ -915,20 +1084,12 @@
|
|
|
915
1084
|
"redo",
|
|
916
1085
|
"highlight"
|
|
917
1086
|
], ["select", "update", "moveLayer"]);
|
|
918
|
-
this.isHistoryStateChange = false;
|
|
919
|
-
this.state = vue.reactive({
|
|
920
|
-
root: null,
|
|
921
|
-
page: null,
|
|
922
|
-
parent: null,
|
|
923
|
-
node: null,
|
|
924
|
-
stage: null,
|
|
925
|
-
highlightNode: null,
|
|
926
|
-
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
927
|
-
pageLength: 0
|
|
928
|
-
});
|
|
929
1087
|
}
|
|
930
1088
|
set(name, value) {
|
|
931
1089
|
this.state[name] = value;
|
|
1090
|
+
if (name === "nodes") {
|
|
1091
|
+
this.set("node", value[0]);
|
|
1092
|
+
}
|
|
932
1093
|
if (name === "root") {
|
|
933
1094
|
this.state.pageLength = value?.items?.length || 0;
|
|
934
1095
|
this.emit("root-change", value);
|
|
@@ -983,9 +1144,9 @@
|
|
|
983
1144
|
}
|
|
984
1145
|
return Layout.ABSOLUTE;
|
|
985
1146
|
}
|
|
986
|
-
async select(
|
|
987
|
-
const { node, page, parent } = this.selectedConfigExceptionHandler(
|
|
988
|
-
this.set("
|
|
1147
|
+
async select(config) {
|
|
1148
|
+
const { node, page, parent } = this.selectedConfigExceptionHandler(config);
|
|
1149
|
+
this.set("nodes", [node]);
|
|
989
1150
|
this.set("page", page || null);
|
|
990
1151
|
this.set("parent", parent || null);
|
|
991
1152
|
if (page) {
|
|
@@ -1025,65 +1186,83 @@
|
|
|
1025
1186
|
this.get("stage")?.select(nextPage.id);
|
|
1026
1187
|
return nextPage;
|
|
1027
1188
|
}
|
|
1028
|
-
highlight(
|
|
1029
|
-
const { node } = this.selectedConfigExceptionHandler(
|
|
1189
|
+
highlight(config) {
|
|
1190
|
+
const { node } = this.selectedConfigExceptionHandler(config);
|
|
1030
1191
|
const currentHighlightNode = this.get("highlightNode");
|
|
1031
1192
|
if (currentHighlightNode === node)
|
|
1032
1193
|
return;
|
|
1033
1194
|
this.set("highlightNode", node);
|
|
1034
1195
|
}
|
|
1035
|
-
|
|
1036
|
-
const
|
|
1196
|
+
multiSelect(ids) {
|
|
1197
|
+
const nodes = [];
|
|
1198
|
+
const idsUnique = lodashEs.uniq(ids);
|
|
1199
|
+
idsUnique.forEach((id) => {
|
|
1200
|
+
const { node } = this.getNodeInfo(id);
|
|
1201
|
+
if (!node)
|
|
1202
|
+
return;
|
|
1203
|
+
nodes.push(node);
|
|
1204
|
+
});
|
|
1205
|
+
this.set("nodes", nodes);
|
|
1206
|
+
}
|
|
1207
|
+
async doAdd(node, parent) {
|
|
1208
|
+
const root = this.get("root");
|
|
1037
1209
|
const curNode = this.get("node");
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
if (isPage2) {
|
|
1041
|
-
parentNode = this.get("root");
|
|
1042
|
-
} else if (parent && typeof parent !== "function") {
|
|
1043
|
-
parentNode = parent;
|
|
1044
|
-
} else if (curNode.items) {
|
|
1045
|
-
parentNode = curNode;
|
|
1046
|
-
} else {
|
|
1047
|
-
parentNode = this.getParentById(curNode.id, false);
|
|
1048
|
-
}
|
|
1049
|
-
if (!parentNode)
|
|
1050
|
-
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1051
|
-
const layout = await this.getLayout(vue.toRaw(parentNode), addNode);
|
|
1052
|
-
const newNode = { ...vue.toRaw(await propsService.getPropsValue(type, config2)) };
|
|
1053
|
-
newNode.style = getInitPositionStyle(newNode.style, layout, parentNode, this.get("stage"));
|
|
1054
|
-
if ((parentNode?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && newNode.type !== schema.NodeType.PAGE) {
|
|
1210
|
+
const stage = this.get("stage");
|
|
1211
|
+
if ((parent?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && node.type !== schema.NodeType.PAGE) {
|
|
1055
1212
|
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
1056
1213
|
}
|
|
1057
|
-
|
|
1214
|
+
parent?.items?.push(node);
|
|
1215
|
+
const layout = await this.getLayout(vue.toRaw(parent), node);
|
|
1216
|
+
node.style = getInitPositionStyle(node.style, layout);
|
|
1217
|
+
await stage?.add({
|
|
1218
|
+
config: lodashEs.cloneDeep(node),
|
|
1219
|
+
parent: lodashEs.cloneDeep(parent),
|
|
1220
|
+
parentId: parent.id,
|
|
1221
|
+
root: lodashEs.cloneDeep(root)
|
|
1222
|
+
});
|
|
1223
|
+
node.style = fixNodePosition(node, parent, stage);
|
|
1224
|
+
await stage?.update({ config: lodashEs.cloneDeep(node), parentId: parent.id, root: lodashEs.cloneDeep(root) });
|
|
1225
|
+
this.addModifiedNodeId(node.id);
|
|
1226
|
+
return node;
|
|
1227
|
+
}
|
|
1228
|
+
async add(addNode, parent) {
|
|
1058
1229
|
const stage = this.get("stage");
|
|
1059
|
-
const
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
}
|
|
1068
|
-
await this.select(newNode);
|
|
1069
|
-
this.addModifiedNodeId(newNode.id);
|
|
1070
|
-
if (!isPage2) {
|
|
1071
|
-
this.pushHistoryState();
|
|
1230
|
+
const addNodes = [];
|
|
1231
|
+
if (!Array.isArray(addNode)) {
|
|
1232
|
+
const { type, inputEvent, ...config } = addNode;
|
|
1233
|
+
if (!type)
|
|
1234
|
+
throw new Error("\u7EC4\u4EF6\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A");
|
|
1235
|
+
addNodes.push({ ...vue.toRaw(await propsService.getPropsValue(type, config)) });
|
|
1236
|
+
} else {
|
|
1237
|
+
addNodes.push(...addNode);
|
|
1072
1238
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1239
|
+
const newNodes = await Promise.all(addNodes.map((node) => {
|
|
1240
|
+
const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
|
|
1241
|
+
if (!parentNode)
|
|
1242
|
+
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1243
|
+
return this.doAdd(node, parentNode);
|
|
1244
|
+
}));
|
|
1245
|
+
if (newNodes.length > 1) {
|
|
1246
|
+
const newNodeIds = newNodes.map((node) => node.id);
|
|
1247
|
+
stage?.multiSelect(newNodeIds);
|
|
1248
|
+
await this.multiSelect(newNodeIds);
|
|
1249
|
+
} else {
|
|
1250
|
+
await this.select(newNodes[0]);
|
|
1251
|
+
if (utils.isPage(newNodes[0])) {
|
|
1252
|
+
this.state.pageLength += 1;
|
|
1253
|
+
} else {
|
|
1254
|
+
stage?.select(newNodes[0].id);
|
|
1255
|
+
}
|
|
1076
1256
|
}
|
|
1077
|
-
this.
|
|
1078
|
-
|
|
1257
|
+
this.pushHistoryState();
|
|
1258
|
+
this.emit("add", newNodes);
|
|
1259
|
+
return Array.isArray(addNode) ? newNodes : newNodes[0];
|
|
1079
1260
|
}
|
|
1080
|
-
async
|
|
1081
|
-
if (!node?.id)
|
|
1082
|
-
return;
|
|
1261
|
+
async doRemove(node) {
|
|
1083
1262
|
const root = this.get("root");
|
|
1084
1263
|
if (!root)
|
|
1085
1264
|
throw new Error("\u6CA1\u6709root");
|
|
1086
|
-
const { parent, node: curNode } = this.getNodeInfo(node.id
|
|
1265
|
+
const { parent, node: curNode } = this.getNodeInfo(node.id);
|
|
1087
1266
|
if (!parent || !curNode)
|
|
1088
1267
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1089
1268
|
const index = getNodeIndex(curNode, parent);
|
|
@@ -1091,7 +1270,7 @@
|
|
|
1091
1270
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1092
1271
|
parent.items?.splice(index, 1);
|
|
1093
1272
|
const stage = this.get("stage");
|
|
1094
|
-
stage?.remove({ id: node.id, root: lodashEs.cloneDeep(
|
|
1273
|
+
stage?.remove({ id: node.id, parentId: parent.id, root: lodashEs.cloneDeep(root) });
|
|
1095
1274
|
if (node.type === schema.NodeType.PAGE) {
|
|
1096
1275
|
this.state.pageLength -= 1;
|
|
1097
1276
|
if (root.items[0]) {
|
|
@@ -1105,26 +1284,28 @@
|
|
|
1105
1284
|
this.set("highlightNode", null);
|
|
1106
1285
|
this.resetModifiedNodeId();
|
|
1107
1286
|
historyService.reset();
|
|
1108
|
-
|
|
1109
|
-
return node;
|
|
1287
|
+
return;
|
|
1110
1288
|
}
|
|
1111
1289
|
} else {
|
|
1112
1290
|
await this.select(parent);
|
|
1113
1291
|
stage?.select(parent.id);
|
|
1114
1292
|
}
|
|
1115
1293
|
this.addModifiedNodeId(parent.id);
|
|
1294
|
+
}
|
|
1295
|
+
async remove(nodeOrNodeList) {
|
|
1296
|
+
const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
|
|
1297
|
+
await Promise.all(nodes.map((node) => this.doRemove(node)));
|
|
1116
1298
|
this.pushHistoryState();
|
|
1117
|
-
this.emit("remove"
|
|
1118
|
-
return node;
|
|
1299
|
+
this.emit("remove");
|
|
1119
1300
|
}
|
|
1120
|
-
async
|
|
1121
|
-
if (!
|
|
1301
|
+
async doUpdate(config) {
|
|
1302
|
+
if (!config?.id)
|
|
1122
1303
|
throw new Error("\u6CA1\u6709\u914D\u7F6E\u6216\u8005\u914D\u7F6E\u7F3A\u5C11id\u503C");
|
|
1123
|
-
const info = this.getNodeInfo(
|
|
1304
|
+
const info = this.getNodeInfo(config.id, false);
|
|
1124
1305
|
if (!info.node)
|
|
1125
|
-
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${
|
|
1306
|
+
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config.id}\u7684\u8282\u70B9`);
|
|
1126
1307
|
const node = lodashEs.cloneDeep(vue.toRaw(info.node));
|
|
1127
|
-
let newConfig = await this.toggleFixedPosition(vue.toRaw(
|
|
1308
|
+
let newConfig = await this.toggleFixedPosition(vue.toRaw(config), node, this.get("root"));
|
|
1128
1309
|
newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), newConfig, (objValue, srcValue) => {
|
|
1129
1310
|
if (Array.isArray(srcValue)) {
|
|
1130
1311
|
return srcValue;
|
|
@@ -1149,18 +1330,28 @@
|
|
|
1149
1330
|
newConfig = setLayout(newConfig, newLayout);
|
|
1150
1331
|
}
|
|
1151
1332
|
parentNodeItems[index] = newConfig;
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
this.
|
|
1333
|
+
const nodes = this.get("nodes");
|
|
1334
|
+
const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
|
|
1335
|
+
nodes.splice(targetIndex, 1, newConfig);
|
|
1336
|
+
this.set("nodes", nodes);
|
|
1337
|
+
this.get("stage")?.update({
|
|
1338
|
+
config: lodashEs.cloneDeep(newConfig),
|
|
1339
|
+
parentId: parent.id,
|
|
1340
|
+
root: lodashEs.cloneDeep(this.get("root"))
|
|
1341
|
+
});
|
|
1156
1342
|
if (newConfig.type === schema.NodeType.PAGE) {
|
|
1157
1343
|
this.set("page", newConfig);
|
|
1158
1344
|
}
|
|
1159
1345
|
this.addModifiedNodeId(newConfig.id);
|
|
1160
|
-
this.pushHistoryState();
|
|
1161
|
-
this.emit("update", newConfig);
|
|
1162
1346
|
return newConfig;
|
|
1163
1347
|
}
|
|
1348
|
+
async update(config) {
|
|
1349
|
+
const nodes = Array.isArray(config) ? config : [config];
|
|
1350
|
+
const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
|
|
1351
|
+
this.pushHistoryState();
|
|
1352
|
+
this.emit("update", newNodes);
|
|
1353
|
+
return Array.isArray(config) ? newNodes : newNodes[0];
|
|
1354
|
+
}
|
|
1164
1355
|
async sort(id1, id2) {
|
|
1165
1356
|
const node = this.get("node");
|
|
1166
1357
|
const parent = lodashEs.cloneDeep(vue.toRaw(this.get("parent")));
|
|
@@ -1171,65 +1362,61 @@
|
|
|
1171
1362
|
parent.items.splice(index2, 0, ...parent.items.splice(index1, 1));
|
|
1172
1363
|
await this.update(parent);
|
|
1173
1364
|
await this.select(node);
|
|
1174
|
-
this.get("stage")?.update({
|
|
1365
|
+
this.get("stage")?.update({
|
|
1366
|
+
config: lodashEs.cloneDeep(node),
|
|
1367
|
+
parentId: parent.id,
|
|
1368
|
+
root: lodashEs.cloneDeep(this.get("root"))
|
|
1369
|
+
});
|
|
1175
1370
|
this.addModifiedNodeId(parent.id);
|
|
1176
1371
|
this.pushHistoryState();
|
|
1177
1372
|
}
|
|
1178
|
-
async copy(
|
|
1179
|
-
|
|
1373
|
+
async copy(config) {
|
|
1374
|
+
await storageService.setItem(COPY_STORAGE_KEY, Array.isArray(config) ? config : [config], {
|
|
1375
|
+
protocol: Protocol.OBJECT
|
|
1376
|
+
});
|
|
1180
1377
|
}
|
|
1181
1378
|
async paste(position = {}) {
|
|
1182
|
-
const
|
|
1183
|
-
|
|
1184
|
-
if (!configStr) {
|
|
1185
|
-
return;
|
|
1186
|
-
}
|
|
1187
|
-
try {
|
|
1188
|
-
eval(`config = ${configStr}`);
|
|
1189
|
-
} catch (e) {
|
|
1190
|
-
console.error(e);
|
|
1379
|
+
const config = await storageService.getItem(COPY_STORAGE_KEY);
|
|
1380
|
+
if (!Array.isArray(config))
|
|
1191
1381
|
return;
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
if (config.style) {
|
|
1195
|
-
config.style = {
|
|
1196
|
-
...config.style,
|
|
1197
|
-
...position
|
|
1198
|
-
};
|
|
1199
|
-
}
|
|
1200
|
-
if (utils.isPage(config)) {
|
|
1201
|
-
config.name = generatePageNameByApp(this.get("root"));
|
|
1202
|
-
}
|
|
1203
|
-
return await this.add(config);
|
|
1382
|
+
const pasteConfigs = await this.doPaste(config, position);
|
|
1383
|
+
return this.add(pasteConfigs);
|
|
1204
1384
|
}
|
|
1205
|
-
async
|
|
1206
|
-
const
|
|
1207
|
-
|
|
1208
|
-
|
|
1385
|
+
async doPaste(config, position = {}) {
|
|
1386
|
+
const pasteConfigs = await beforePaste(position, lodashEs.cloneDeep(config));
|
|
1387
|
+
return pasteConfigs;
|
|
1388
|
+
}
|
|
1389
|
+
async doAlignCenter(config) {
|
|
1390
|
+
const parent = this.getParentById(config.id);
|
|
1391
|
+
if (!parent)
|
|
1392
|
+
throw new Error("\u627E\u4E0D\u5230\u7236\u8282\u70B9");
|
|
1393
|
+
const node = lodashEs.cloneDeep(vue.toRaw(config));
|
|
1394
|
+
const layout = await this.getLayout(parent, node);
|
|
1209
1395
|
if (layout === Layout.RELATIVE) {
|
|
1210
|
-
return;
|
|
1396
|
+
return config;
|
|
1211
1397
|
}
|
|
1212
1398
|
if (!node.style)
|
|
1213
|
-
return;
|
|
1399
|
+
return config;
|
|
1214
1400
|
const stage = this.get("stage");
|
|
1215
1401
|
const doc = stage?.renderer.contentWindow?.document;
|
|
1216
1402
|
if (doc) {
|
|
1217
|
-
const parentEl = doc.getElementById(`${parent.id}`);
|
|
1218
1403
|
const el = doc.getElementById(`${node.id}`);
|
|
1404
|
+
const parentEl = el?.offsetParent;
|
|
1219
1405
|
if (parentEl && el) {
|
|
1220
1406
|
node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
|
|
1221
1407
|
}
|
|
1222
1408
|
} else if (parent.style && utils.isNumber(parent.style?.width) && utils.isNumber(node.style?.width)) {
|
|
1223
1409
|
node.style.left = (parent.style.width - node.style.width) / 2;
|
|
1224
1410
|
}
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
this.
|
|
1232
|
-
|
|
1411
|
+
return node;
|
|
1412
|
+
}
|
|
1413
|
+
async alignCenter(config) {
|
|
1414
|
+
const nodes = Array.isArray(config) ? config : [config];
|
|
1415
|
+
const stage = this.get("stage");
|
|
1416
|
+
const newNodes = await Promise.all(nodes.map((node) => this.doAlignCenter(node)));
|
|
1417
|
+
const newNode = await this.update(newNodes);
|
|
1418
|
+
await stage?.multiSelect(newNodes.map((node) => node.id));
|
|
1419
|
+
return newNode;
|
|
1233
1420
|
}
|
|
1234
1421
|
async moveLayer(offset) {
|
|
1235
1422
|
const parent = this.get("parent");
|
|
@@ -1243,30 +1430,35 @@
|
|
|
1243
1430
|
} else {
|
|
1244
1431
|
brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
|
|
1245
1432
|
}
|
|
1433
|
+
const grandparent = this.getParentById(parent.id);
|
|
1246
1434
|
this.get("stage")?.update({
|
|
1247
1435
|
config: lodashEs.cloneDeep(vue.toRaw(parent)),
|
|
1436
|
+
parentId: grandparent?.id,
|
|
1248
1437
|
root: lodashEs.cloneDeep(this.get("root"))
|
|
1249
1438
|
});
|
|
1439
|
+
this.addModifiedNodeId(parent.id);
|
|
1440
|
+
this.pushHistoryState();
|
|
1250
1441
|
}
|
|
1251
|
-
async moveToContainer(
|
|
1252
|
-
const { node, parent } = this.getNodeInfo(
|
|
1442
|
+
async moveToContainer(config, targetId) {
|
|
1443
|
+
const { node, parent } = this.getNodeInfo(config.id, false);
|
|
1253
1444
|
const target = this.getNodeById(targetId, false);
|
|
1254
1445
|
const stage = this.get("stage");
|
|
1255
1446
|
if (node && parent && stage) {
|
|
1256
1447
|
const root = lodashEs.cloneDeep(this.get("root"));
|
|
1257
1448
|
const index = getNodeIndex(node, parent);
|
|
1258
1449
|
parent.items?.splice(index, 1);
|
|
1259
|
-
await stage.remove({ id: node.id, root });
|
|
1450
|
+
await stage.remove({ id: node.id, parentId: parent.id, root });
|
|
1260
1451
|
const layout = await this.getLayout(target);
|
|
1261
|
-
const newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node),
|
|
1452
|
+
const newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), config, (objValue, srcValue) => {
|
|
1262
1453
|
if (Array.isArray(srcValue)) {
|
|
1263
1454
|
return srcValue;
|
|
1264
1455
|
}
|
|
1265
1456
|
});
|
|
1266
|
-
newConfig.style = getInitPositionStyle(newConfig.style, layout
|
|
1457
|
+
newConfig.style = getInitPositionStyle(newConfig.style, layout);
|
|
1267
1458
|
target.items.push(newConfig);
|
|
1268
1459
|
await stage.select(targetId);
|
|
1269
|
-
|
|
1460
|
+
const targetParent = this.getParentById(target.id);
|
|
1461
|
+
await stage.update({ config: lodashEs.cloneDeep(target), parentId: targetParent?.id, root });
|
|
1270
1462
|
await this.select(newConfig);
|
|
1271
1463
|
stage.select(newConfig.id);
|
|
1272
1464
|
this.addModifiedNodeId(target.id);
|
|
@@ -1289,7 +1481,7 @@
|
|
|
1289
1481
|
const node = vue.toRaw(this.get("node"));
|
|
1290
1482
|
if (!node || utils.isPage(node))
|
|
1291
1483
|
return;
|
|
1292
|
-
const { style, id } = node;
|
|
1484
|
+
const { style, id, type } = node;
|
|
1293
1485
|
if (!style || style.position !== "absolute")
|
|
1294
1486
|
return;
|
|
1295
1487
|
if (top && !utils.isNumber(style.top))
|
|
@@ -1298,6 +1490,7 @@
|
|
|
1298
1490
|
return;
|
|
1299
1491
|
this.update({
|
|
1300
1492
|
id,
|
|
1493
|
+
type,
|
|
1301
1494
|
style: {
|
|
1302
1495
|
...style,
|
|
1303
1496
|
left: Number(style.left) + left,
|
|
@@ -1309,6 +1502,7 @@
|
|
|
1309
1502
|
this.removeAllListeners();
|
|
1310
1503
|
this.set("root", null);
|
|
1311
1504
|
this.set("node", null);
|
|
1505
|
+
this.set("nodes", []);
|
|
1312
1506
|
this.set("page", null);
|
|
1313
1507
|
this.set("parent", null);
|
|
1314
1508
|
}
|
|
@@ -1355,12 +1549,12 @@
|
|
|
1355
1549
|
}
|
|
1356
1550
|
return newConfig;
|
|
1357
1551
|
}
|
|
1358
|
-
selectedConfigExceptionHandler(
|
|
1552
|
+
selectedConfigExceptionHandler(config) {
|
|
1359
1553
|
let id;
|
|
1360
|
-
if (typeof
|
|
1361
|
-
id =
|
|
1554
|
+
if (typeof config === "string" || typeof config === "number") {
|
|
1555
|
+
id = config;
|
|
1362
1556
|
} else {
|
|
1363
|
-
id =
|
|
1557
|
+
id = config.id;
|
|
1364
1558
|
}
|
|
1365
1559
|
if (!id) {
|
|
1366
1560
|
throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
|
|
@@ -1378,7 +1572,7 @@
|
|
|
1378
1572
|
};
|
|
1379
1573
|
}
|
|
1380
1574
|
}
|
|
1381
|
-
|
|
1575
|
+
const editorService = new Editor$1();
|
|
1382
1576
|
|
|
1383
1577
|
const eventMap = vue.reactive({});
|
|
1384
1578
|
const methodMap = vue.reactive({});
|
|
@@ -1422,7 +1616,7 @@
|
|
|
1422
1616
|
return lodashEs.cloneDeep(methodMap[type] || core.DEFAULT_METHODS);
|
|
1423
1617
|
}
|
|
1424
1618
|
}
|
|
1425
|
-
|
|
1619
|
+
const eventsService = new Events();
|
|
1426
1620
|
|
|
1427
1621
|
const fillConfig = (config = []) => [
|
|
1428
1622
|
{
|
|
@@ -1627,22 +1821,34 @@
|
|
|
1627
1821
|
]
|
|
1628
1822
|
}
|
|
1629
1823
|
];
|
|
1630
|
-
|
|
1631
|
-
const
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1824
|
+
|
|
1825
|
+
const log = (...args) => {
|
|
1826
|
+
if (process.env.NODE_ENV === "development") {
|
|
1827
|
+
console.log("magic editor: ", ...args);
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
const info = (...args) => {
|
|
1831
|
+
if (process.env.NODE_ENV === "development") {
|
|
1832
|
+
console.info("magic editor: ", ...args);
|
|
1833
|
+
}
|
|
1834
|
+
};
|
|
1835
|
+
const warn = (...args) => {
|
|
1836
|
+
if (process.env.NODE_ENV === "development") {
|
|
1837
|
+
console.warn("magic editor: ", ...args);
|
|
1838
|
+
}
|
|
1839
|
+
};
|
|
1840
|
+
const debug = (...args) => {
|
|
1841
|
+
if (process.env.NODE_ENV === "development") {
|
|
1842
|
+
console.debug("magic editor: ", ...args);
|
|
1843
|
+
}
|
|
1844
|
+
};
|
|
1845
|
+
const error = (...args) => {
|
|
1846
|
+
if (process.env.NODE_ENV === "development") {
|
|
1847
|
+
console.error("magic editor: ", ...args);
|
|
1848
|
+
}
|
|
1643
1849
|
};
|
|
1644
1850
|
|
|
1645
|
-
const _sfc_main$
|
|
1851
|
+
const _sfc_main$j = vue.defineComponent({
|
|
1646
1852
|
components: { Plus: iconsVue.Plus },
|
|
1647
1853
|
setup() {
|
|
1648
1854
|
const services = vue.inject("services");
|
|
@@ -1659,10 +1865,11 @@
|
|
|
1659
1865
|
};
|
|
1660
1866
|
}
|
|
1661
1867
|
});
|
|
1868
|
+
|
|
1662
1869
|
const _hoisted_1$b = { class: "m-editor-empty-panel" };
|
|
1663
1870
|
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
1664
|
-
const _hoisted_3$
|
|
1665
|
-
function _sfc_render$
|
|
1871
|
+
const _hoisted_3$1 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
1872
|
+
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1666
1873
|
const _component_plus = vue.resolveComponent("plus");
|
|
1667
1874
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
1668
1875
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
|
|
@@ -1679,14 +1886,14 @@
|
|
|
1679
1886
|
_: 1
|
|
1680
1887
|
})
|
|
1681
1888
|
]),
|
|
1682
|
-
_hoisted_3$
|
|
1889
|
+
_hoisted_3$1
|
|
1683
1890
|
])
|
|
1684
1891
|
])
|
|
1685
1892
|
]);
|
|
1686
1893
|
}
|
|
1687
|
-
|
|
1894
|
+
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$d]]);
|
|
1688
1895
|
|
|
1689
|
-
const _sfc_main$
|
|
1896
|
+
const _sfc_main$i = vue.defineComponent({
|
|
1690
1897
|
name: "m-editor-resize",
|
|
1691
1898
|
props: {
|
|
1692
1899
|
type: {
|
|
@@ -1700,7 +1907,7 @@
|
|
|
1700
1907
|
vue.onMounted(() => {
|
|
1701
1908
|
if (!target.value)
|
|
1702
1909
|
return;
|
|
1703
|
-
getso = new Gesto__default
|
|
1910
|
+
getso = new Gesto__default.default(target.value, {
|
|
1704
1911
|
container: window,
|
|
1705
1912
|
pinchOutside: true
|
|
1706
1913
|
}).on("drag", (e) => {
|
|
@@ -1728,18 +1935,19 @@
|
|
|
1728
1935
|
};
|
|
1729
1936
|
}
|
|
1730
1937
|
});
|
|
1938
|
+
|
|
1731
1939
|
const _hoisted_1$a = {
|
|
1732
1940
|
ref: "target",
|
|
1733
1941
|
class: "m-editor-resizer"
|
|
1734
1942
|
};
|
|
1735
|
-
function _sfc_render$
|
|
1943
|
+
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1736
1944
|
return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$a, [
|
|
1737
1945
|
vue.renderSlot(_ctx.$slots, "default")
|
|
1738
1946
|
], 512);
|
|
1739
1947
|
}
|
|
1740
|
-
|
|
1948
|
+
const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$c]]);
|
|
1741
1949
|
|
|
1742
|
-
const _sfc_main$
|
|
1950
|
+
const _sfc_main$h = vue.defineComponent({
|
|
1743
1951
|
components: {
|
|
1744
1952
|
AddPageBox,
|
|
1745
1953
|
Resizer
|
|
@@ -1768,12 +1976,13 @@
|
|
|
1768
1976
|
};
|
|
1769
1977
|
}
|
|
1770
1978
|
});
|
|
1979
|
+
|
|
1771
1980
|
const _hoisted_1$9 = { class: "m-editor" };
|
|
1772
1981
|
const _hoisted_2$3 = {
|
|
1773
1982
|
key: 1,
|
|
1774
1983
|
class: "m-editor-content"
|
|
1775
1984
|
};
|
|
1776
|
-
function _sfc_render$
|
|
1985
|
+
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1777
1986
|
const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
|
|
1778
1987
|
const _component_resizer = vue.resolveComponent("resizer");
|
|
1779
1988
|
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
|
|
@@ -1819,9 +2028,9 @@
|
|
|
1819
2028
|
]))
|
|
1820
2029
|
]);
|
|
1821
2030
|
}
|
|
1822
|
-
|
|
2031
|
+
const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$b]]);
|
|
1823
2032
|
|
|
1824
|
-
const _sfc_main$
|
|
2033
|
+
const _sfc_main$g = vue.defineComponent({
|
|
1825
2034
|
name: "m-icon",
|
|
1826
2035
|
components: { Edit: iconsVue.Edit },
|
|
1827
2036
|
props: {
|
|
@@ -1835,8 +2044,9 @@
|
|
|
1835
2044
|
};
|
|
1836
2045
|
}
|
|
1837
2046
|
});
|
|
2047
|
+
|
|
1838
2048
|
const _hoisted_1$8 = ["src"];
|
|
1839
|
-
function _sfc_render$
|
|
2049
|
+
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1840
2050
|
const _component_edit = vue.resolveComponent("edit");
|
|
1841
2051
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
1842
2052
|
return !_ctx.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
|
|
@@ -1844,10 +2054,12 @@
|
|
|
1844
2054
|
vue.createVNode(_component_edit)
|
|
1845
2055
|
]),
|
|
1846
2056
|
_: 1
|
|
1847
|
-
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
2057
|
+
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 1 }, {
|
|
2058
|
+
default: vue.withCtx(() => [
|
|
2059
|
+
vue.createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$8)
|
|
2060
|
+
]),
|
|
2061
|
+
_: 1
|
|
2062
|
+
})) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
|
|
1851
2063
|
key: 2,
|
|
1852
2064
|
class: vue.normalizeClass(_ctx.icon)
|
|
1853
2065
|
}, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
|
|
@@ -1857,10 +2069,19 @@
|
|
|
1857
2069
|
_: 1
|
|
1858
2070
|
}));
|
|
1859
2071
|
}
|
|
1860
|
-
|
|
2072
|
+
const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
|
|
1861
2073
|
|
|
1862
|
-
const
|
|
1863
|
-
|
|
2074
|
+
const _hoisted_1$7 = {
|
|
2075
|
+
key: 1,
|
|
2076
|
+
class: "menu-item-text"
|
|
2077
|
+
};
|
|
2078
|
+
const _hoisted_2$2 = {
|
|
2079
|
+
class: "menu-item-text",
|
|
2080
|
+
style: { "margin": "0 5px" }
|
|
2081
|
+
};
|
|
2082
|
+
const _hoisted_3 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2083
|
+
const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
2084
|
+
__name: "ToolButton",
|
|
1864
2085
|
props: {
|
|
1865
2086
|
data: {
|
|
1866
2087
|
type: [Object, String],
|
|
@@ -1875,7 +2096,8 @@
|
|
|
1875
2096
|
default: "click"
|
|
1876
2097
|
}
|
|
1877
2098
|
},
|
|
1878
|
-
setup(
|
|
2099
|
+
setup(__props) {
|
|
2100
|
+
const props = __props;
|
|
1879
2101
|
const services = vue.inject("services");
|
|
1880
2102
|
const uiService = services?.uiService;
|
|
1881
2103
|
const zoom = vue.computed(() => uiService?.get("zoom") ?? 1);
|
|
@@ -1972,176 +2194,155 @@
|
|
|
1972
2194
|
item2.handler?.(services, event);
|
|
1973
2195
|
}
|
|
1974
2196
|
};
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
item
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
}
|
|
1989
|
-
return item.value.display ?? true;
|
|
1990
|
-
}),
|
|
1991
|
-
zoomInHandler,
|
|
1992
|
-
zoomOutHandler,
|
|
1993
|
-
dropdownHandler(command) {
|
|
1994
|
-
if (command.item.handler) {
|
|
1995
|
-
command.item.handler(services);
|
|
1996
|
-
}
|
|
1997
|
-
},
|
|
1998
|
-
clickHandler(item2, event) {
|
|
1999
|
-
if (props.eventType !== "click")
|
|
2000
|
-
return;
|
|
2001
|
-
if (item2.type === "button") {
|
|
2002
|
-
buttonHandler(item2, event);
|
|
2003
|
-
}
|
|
2004
|
-
},
|
|
2005
|
-
mousedownHandler(item2, event) {
|
|
2006
|
-
if (props.eventType !== "mousedown")
|
|
2007
|
-
return;
|
|
2008
|
-
if (item2.type === "button") {
|
|
2009
|
-
buttonHandler(item2, event);
|
|
2010
|
-
}
|
|
2011
|
-
},
|
|
2012
|
-
mouseupHandler(item2, event) {
|
|
2013
|
-
if (props.eventType !== "mouseup")
|
|
2014
|
-
return;
|
|
2015
|
-
if (item2.type === "button") {
|
|
2016
|
-
buttonHandler(item2, event);
|
|
2017
|
-
}
|
|
2197
|
+
const display = vue.computed(() => {
|
|
2198
|
+
if (!item.value)
|
|
2199
|
+
return false;
|
|
2200
|
+
if (typeof item.value === "string")
|
|
2201
|
+
return true;
|
|
2202
|
+
if (typeof item.value.display === "function") {
|
|
2203
|
+
return item.value.display(services);
|
|
2204
|
+
}
|
|
2205
|
+
return item.value.display ?? true;
|
|
2206
|
+
});
|
|
2207
|
+
const dropdownHandler = (command) => {
|
|
2208
|
+
if (command.item.handler) {
|
|
2209
|
+
command.item.handler(services);
|
|
2018
2210
|
}
|
|
2019
2211
|
};
|
|
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
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
direction: _ctx.item.direction || "vertical"
|
|
2052
|
-
}, null, 8, ["direction"])) : _ctx.item.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, vue.toDisplayString(_ctx.item.text), 1)) : _ctx.item.type === "zoom" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
|
|
2053
|
-
vue.createVNode(_component_tool_button, {
|
|
2054
|
-
data: { type: "button", icon: _ctx.ZoomOut, handler: _ctx.zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
2055
|
-
"event-type": _ctx.eventType
|
|
2056
|
-
}, null, 8, ["data", "event-type"]),
|
|
2057
|
-
vue.createElementVNode("span", _hoisted_2$2, vue.toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
|
|
2058
|
-
vue.createVNode(_component_tool_button, {
|
|
2059
|
-
data: { type: "button", icon: _ctx.ZoomIn, handler: _ctx.zoomInHandler, tooltip: "\u653E\u5927" },
|
|
2060
|
-
"event-type": _ctx.eventType
|
|
2061
|
-
}, null, 8, ["data", "event-type"])
|
|
2062
|
-
], 64)) : _ctx.item.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
|
|
2063
|
-
_ctx.item.tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
|
|
2212
|
+
const clickHandler = (item2, event) => {
|
|
2213
|
+
if (props.eventType !== "click")
|
|
2214
|
+
return;
|
|
2215
|
+
if (item2.type === "button") {
|
|
2216
|
+
buttonHandler(item2, event);
|
|
2217
|
+
}
|
|
2218
|
+
};
|
|
2219
|
+
const mousedownHandler = (item2, event) => {
|
|
2220
|
+
if (props.eventType !== "mousedown")
|
|
2221
|
+
return;
|
|
2222
|
+
if (item2.type === "button") {
|
|
2223
|
+
buttonHandler(item2, event);
|
|
2224
|
+
}
|
|
2225
|
+
};
|
|
2226
|
+
const mouseupHandler = (item2, event) => {
|
|
2227
|
+
if (props.eventType !== "mouseup")
|
|
2228
|
+
return;
|
|
2229
|
+
if (item2.type === "button") {
|
|
2230
|
+
buttonHandler(item2, event);
|
|
2231
|
+
}
|
|
2232
|
+
};
|
|
2233
|
+
return (_ctx, _cache) => {
|
|
2234
|
+
const _component_el_divider = vue.resolveComponent("el-divider");
|
|
2235
|
+
const _component_tool_button = vue.resolveComponent("tool-button", true);
|
|
2236
|
+
const _component_el_button = vue.resolveComponent("el-button");
|
|
2237
|
+
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
2238
|
+
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
2239
|
+
const _component_el_dropdown_item = vue.resolveComponent("el-dropdown-item");
|
|
2240
|
+
const _component_el_dropdown_menu = vue.resolveComponent("el-dropdown-menu");
|
|
2241
|
+
const _component_el_dropdown = vue.resolveComponent("el-dropdown");
|
|
2242
|
+
return vue.unref(display) ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
2064
2243
|
key: 0,
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2244
|
+
class: vue.normalizeClass(["menu-item", vue.unref(item).type]),
|
|
2245
|
+
onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(vue.unref(item), $event)),
|
|
2246
|
+
onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(vue.unref(item), $event)),
|
|
2247
|
+
onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(vue.unref(item), $event))
|
|
2248
|
+
}, [
|
|
2249
|
+
vue.unref(item).type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
|
|
2250
|
+
key: 0,
|
|
2251
|
+
direction: vue.unref(item).direction || "vertical"
|
|
2252
|
+
}, null, 8, ["direction"])) : vue.unref(item).type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, vue.toDisplayString(vue.unref(item).text), 1)) : vue.unref(item).type === "zoom" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
|
|
2253
|
+
vue.createVNode(_component_tool_button, {
|
|
2254
|
+
data: { type: "button", icon: vue.unref(iconsVue.ZoomOut), handler: zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
2255
|
+
"event-type": __props.eventType
|
|
2256
|
+
}, null, 8, ["data", "event-type"]),
|
|
2257
|
+
vue.createElementVNode("span", _hoisted_2$2, vue.toDisplayString(parseInt(`${vue.unref(zoom) * 100}`, 10)) + "%", 1),
|
|
2258
|
+
vue.createVNode(_component_tool_button, {
|
|
2259
|
+
data: { type: "button", icon: vue.unref(iconsVue.ZoomIn), handler: zoomInHandler, tooltip: "\u653E\u5927" },
|
|
2260
|
+
"event-type": __props.eventType
|
|
2261
|
+
}, null, 8, ["data", "event-type"])
|
|
2262
|
+
], 64)) : vue.unref(item).type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
|
|
2263
|
+
vue.unref(item).tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
|
|
2264
|
+
key: 0,
|
|
2265
|
+
effect: "dark",
|
|
2266
|
+
placement: "bottom-start",
|
|
2267
|
+
content: vue.unref(item).tooltip
|
|
2268
|
+
}, {
|
|
2269
|
+
default: vue.withCtx(() => [
|
|
2270
|
+
vue.createVNode(_component_el_button, {
|
|
2271
|
+
size: "small",
|
|
2272
|
+
text: "",
|
|
2273
|
+
disabled: vue.unref(disabled)
|
|
2274
|
+
}, {
|
|
2275
|
+
default: vue.withCtx(() => [
|
|
2276
|
+
vue.unref(item).icon ? (vue.openBlock(), vue.createBlock(MIcon, {
|
|
2277
|
+
key: 0,
|
|
2278
|
+
icon: vue.unref(item).icon
|
|
2279
|
+
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
2280
|
+
vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(item).text), 1)
|
|
2281
|
+
]),
|
|
2282
|
+
_: 1
|
|
2283
|
+
}, 8, ["disabled"])
|
|
2284
|
+
]),
|
|
2285
|
+
_: 1
|
|
2286
|
+
}, 8, ["content"])) : (vue.openBlock(), vue.createBlock(_component_el_button, {
|
|
2287
|
+
key: 1,
|
|
2071
2288
|
size: "small",
|
|
2072
2289
|
text: "",
|
|
2073
|
-
disabled:
|
|
2290
|
+
disabled: vue.unref(disabled)
|
|
2074
2291
|
}, {
|
|
2075
2292
|
default: vue.withCtx(() => [
|
|
2076
|
-
|
|
2293
|
+
vue.unref(item).icon ? (vue.openBlock(), vue.createBlock(MIcon, {
|
|
2077
2294
|
key: 0,
|
|
2078
|
-
icon:
|
|
2295
|
+
icon: vue.unref(item).icon
|
|
2079
2296
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
2080
|
-
vue.createElementVNode("span", null, vue.toDisplayString(
|
|
2297
|
+
vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(item).text), 1)
|
|
2081
2298
|
]),
|
|
2082
2299
|
_: 1
|
|
2083
|
-
}, 8, ["disabled"])
|
|
2084
|
-
]),
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
_ctx.item.items && _ctx.item.items.length ? (vue.openBlock(), vue.createBlock(_component_el_dropdown_menu, { key: 0 }, {
|
|
2300
|
+
}, 8, ["disabled"]))
|
|
2301
|
+
], 64)) : vue.unref(item).type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
|
|
2302
|
+
key: 4,
|
|
2303
|
+
trigger: "click",
|
|
2304
|
+
disabled: vue.unref(disabled),
|
|
2305
|
+
onCommand: dropdownHandler
|
|
2306
|
+
}, {
|
|
2307
|
+
dropdown: vue.withCtx(() => [
|
|
2308
|
+
vue.unref(item).items && vue.unref(item).items.length ? (vue.openBlock(), vue.createBlock(_component_el_dropdown_menu, { key: 0 }, {
|
|
2309
|
+
default: vue.withCtx(() => [
|
|
2310
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(item).items, (subItem, index) => {
|
|
2311
|
+
return vue.openBlock(), vue.createBlock(_component_el_dropdown_item, {
|
|
2312
|
+
key: index,
|
|
2313
|
+
command: { item: vue.unref(item), subItem }
|
|
2314
|
+
}, {
|
|
2315
|
+
default: vue.withCtx(() => [
|
|
2316
|
+
vue.createTextVNode(vue.toDisplayString(subItem.text), 1)
|
|
2317
|
+
]),
|
|
2318
|
+
_: 2
|
|
2319
|
+
}, 1032, ["command"]);
|
|
2320
|
+
}), 128))
|
|
2321
|
+
]),
|
|
2322
|
+
_: 1
|
|
2323
|
+
})) : vue.createCommentVNode("", true)
|
|
2324
|
+
]),
|
|
2109
2325
|
default: vue.withCtx(() => [
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
command: { item: _ctx.item, subItem }
|
|
2114
|
-
}, {
|
|
2326
|
+
vue.createElementVNode("span", _hoisted_3, [
|
|
2327
|
+
vue.createTextVNode(vue.toDisplayString(vue.unref(item).text), 1),
|
|
2328
|
+
vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2115
2329
|
default: vue.withCtx(() => [
|
|
2116
|
-
vue.
|
|
2330
|
+
vue.createVNode(vue.unref(iconsVue.ArrowDown))
|
|
2117
2331
|
]),
|
|
2118
|
-
_:
|
|
2119
|
-
}
|
|
2120
|
-
|
|
2332
|
+
_: 1
|
|
2333
|
+
})
|
|
2334
|
+
])
|
|
2121
2335
|
]),
|
|
2122
2336
|
_: 1
|
|
2123
|
-
})) : vue.createCommentVNode("", true)
|
|
2124
|
-
]),
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2129
|
-
default: vue.withCtx(() => [
|
|
2130
|
-
vue.createVNode(_component_arrow_down)
|
|
2131
|
-
]),
|
|
2132
|
-
_: 1
|
|
2133
|
-
})
|
|
2134
|
-
])
|
|
2135
|
-
]),
|
|
2136
|
-
_: 1
|
|
2137
|
-
}, 8, ["disabled", "onCommand"])) : _ctx.item.type === "component" ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.item.component), vue.normalizeProps(vue.mergeProps({ key: 5 }, _ctx.item.props || {})), null, 16)) : vue.createCommentVNode("", true)
|
|
2138
|
-
], 34)) : vue.createCommentVNode("", true);
|
|
2139
|
-
}
|
|
2140
|
-
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
|
|
2337
|
+
}, 8, ["disabled"])) : vue.unref(item).type === "component" ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(item).component), vue.normalizeProps(vue.mergeProps({ key: 5 }, vue.unref(item).props || {})), null, 16)) : vue.createCommentVNode("", true)
|
|
2338
|
+
], 34)) : vue.createCommentVNode("", true);
|
|
2339
|
+
};
|
|
2340
|
+
}
|
|
2341
|
+
});
|
|
2141
2342
|
|
|
2142
|
-
const _sfc_main$
|
|
2343
|
+
const _sfc_main$e = vue.defineComponent({
|
|
2143
2344
|
name: "nav-menu",
|
|
2144
|
-
components: { ToolButton },
|
|
2345
|
+
components: { ToolButton: _sfc_main$f },
|
|
2145
2346
|
props: {
|
|
2146
2347
|
data: {
|
|
2147
2348
|
type: Object,
|
|
@@ -2159,7 +2360,8 @@
|
|
|
2159
2360
|
};
|
|
2160
2361
|
}
|
|
2161
2362
|
});
|
|
2162
|
-
|
|
2363
|
+
|
|
2364
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2163
2365
|
const _component_tool_button = vue.resolveComponent("tool-button");
|
|
2164
2366
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
2165
2367
|
class: "m-editor-nav-menu",
|
|
@@ -2181,9 +2383,9 @@
|
|
|
2181
2383
|
}), 128))
|
|
2182
2384
|
], 4);
|
|
2183
2385
|
}
|
|
2184
|
-
|
|
2386
|
+
const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
|
|
2185
2387
|
|
|
2186
|
-
const _sfc_main$
|
|
2388
|
+
const _sfc_main$d = vue.defineComponent({
|
|
2187
2389
|
name: "m-editor-props-panel",
|
|
2188
2390
|
emits: ["mounted"],
|
|
2189
2391
|
setup(props, { emit }) {
|
|
@@ -2230,8 +2432,9 @@
|
|
|
2230
2432
|
};
|
|
2231
2433
|
}
|
|
2232
2434
|
});
|
|
2435
|
+
|
|
2233
2436
|
const _hoisted_1$6 = { class: "`m-editor-props-panel" };
|
|
2234
|
-
function _sfc_render$
|
|
2437
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2235
2438
|
const _component_m_form = vue.resolveComponent("m-form");
|
|
2236
2439
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
|
|
2237
2440
|
vue.renderSlot(_ctx.$slots, "props-panel-header"),
|
|
@@ -2246,9 +2449,9 @@
|
|
|
2246
2449
|
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
|
|
2247
2450
|
]);
|
|
2248
2451
|
}
|
|
2249
|
-
|
|
2452
|
+
const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
|
|
2250
2453
|
|
|
2251
|
-
const _sfc_main$
|
|
2454
|
+
const _sfc_main$c = vue.defineComponent({
|
|
2252
2455
|
name: "ui-component-panel",
|
|
2253
2456
|
components: { MIcon },
|
|
2254
2457
|
setup() {
|
|
@@ -2278,7 +2481,7 @@
|
|
|
2278
2481
|
dragstartHandler({ text, type, data = {} }, e) {
|
|
2279
2482
|
if (e.dataTransfer) {
|
|
2280
2483
|
e.dataTransfer.effectAllowed = "move";
|
|
2281
|
-
e.dataTransfer.setData("data", serialize__default
|
|
2484
|
+
e.dataTransfer.setData("data", serialize__default.default({
|
|
2282
2485
|
name: text,
|
|
2283
2486
|
type,
|
|
2284
2487
|
...data
|
|
@@ -2307,27 +2510,17 @@
|
|
|
2307
2510
|
}
|
|
2308
2511
|
return;
|
|
2309
2512
|
}
|
|
2310
|
-
if (timeout)
|
|
2513
|
+
if (timeout || !stage.value)
|
|
2311
2514
|
return;
|
|
2312
|
-
timeout =
|
|
2313
|
-
if (!stageOptions || !stage.value)
|
|
2314
|
-
return;
|
|
2315
|
-
const doc = stage.value.renderer.contentWindow?.document;
|
|
2316
|
-
const els = stage.value.getElementsFromPoint(e);
|
|
2317
|
-
for (const el of els) {
|
|
2318
|
-
if (doc && !el.id.startsWith(StageCore.GHOST_EL_ID_PREFIX) && await stageOptions.isContainer(el)) {
|
|
2319
|
-
utils.addClassName(el, doc, stageOptions?.containerHighlightClassName);
|
|
2320
|
-
break;
|
|
2321
|
-
}
|
|
2322
|
-
}
|
|
2323
|
-
}, stageOptions?.containerHighlightDuration);
|
|
2515
|
+
timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
|
|
2324
2516
|
}
|
|
2325
2517
|
};
|
|
2326
2518
|
}
|
|
2327
2519
|
});
|
|
2520
|
+
|
|
2328
2521
|
const _hoisted_1$5 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
2329
2522
|
const _hoisted_2$1 = ["onClick", "onDragstart"];
|
|
2330
|
-
function _sfc_render$
|
|
2523
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2331
2524
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
2332
2525
|
const _component_m_icon = vue.resolveComponent("m-icon");
|
|
2333
2526
|
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
@@ -2399,22 +2592,17 @@
|
|
|
2399
2592
|
_: 3
|
|
2400
2593
|
});
|
|
2401
2594
|
}
|
|
2402
|
-
|
|
2595
|
+
const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
|
|
2403
2596
|
|
|
2404
|
-
const _sfc_main$
|
|
2405
|
-
|
|
2597
|
+
const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
|
|
2598
|
+
__name: "ContentMenu",
|
|
2406
2599
|
props: {
|
|
2407
|
-
menuData: {
|
|
2408
|
-
|
|
2409
|
-
default: () => []
|
|
2410
|
-
},
|
|
2411
|
-
isSubMenu: {
|
|
2412
|
-
type: Boolean,
|
|
2413
|
-
default: false
|
|
2414
|
-
}
|
|
2600
|
+
menuData: { default: () => [] },
|
|
2601
|
+
isSubMenu: { type: Boolean, default: false }
|
|
2415
2602
|
},
|
|
2416
2603
|
emits: ["hide", "show"],
|
|
2417
|
-
setup(
|
|
2604
|
+
setup(__props, { expose, emit }) {
|
|
2605
|
+
const props = __props;
|
|
2418
2606
|
const menu = vue.ref();
|
|
2419
2607
|
const subMenu = vue.ref();
|
|
2420
2608
|
const visible = vue.ref(false);
|
|
@@ -2440,6 +2628,36 @@
|
|
|
2440
2628
|
}
|
|
2441
2629
|
hide();
|
|
2442
2630
|
};
|
|
2631
|
+
const show = (e) => {
|
|
2632
|
+
setTimeout(() => {
|
|
2633
|
+
visible.value = true;
|
|
2634
|
+
vue.nextTick(() => {
|
|
2635
|
+
const menuHeight = menu.value?.clientHeight || 0;
|
|
2636
|
+
let top = e.clientY;
|
|
2637
|
+
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
2638
|
+
top = document.body.clientHeight - menuHeight;
|
|
2639
|
+
}
|
|
2640
|
+
menuStyle.value = {
|
|
2641
|
+
top: `${top}px`,
|
|
2642
|
+
left: `${e.clientX}px`
|
|
2643
|
+
};
|
|
2644
|
+
emit("show");
|
|
2645
|
+
});
|
|
2646
|
+
}, 300);
|
|
2647
|
+
};
|
|
2648
|
+
const showSubMenu = (item) => {
|
|
2649
|
+
const menuItem = item;
|
|
2650
|
+
if (typeof item !== "object" || !menuItem.items?.length) {
|
|
2651
|
+
return;
|
|
2652
|
+
}
|
|
2653
|
+
subMenuData.value = menuItem.items;
|
|
2654
|
+
if (menu.value) {
|
|
2655
|
+
subMenu.value.show({
|
|
2656
|
+
clientX: menu.value.offsetLeft + menu.value.clientWidth,
|
|
2657
|
+
clientY: menu.value.offsetTop
|
|
2658
|
+
});
|
|
2659
|
+
}
|
|
2660
|
+
};
|
|
2443
2661
|
vue.onMounted(() => {
|
|
2444
2662
|
if (props.isSubMenu)
|
|
2445
2663
|
return;
|
|
@@ -2450,81 +2668,47 @@
|
|
|
2450
2668
|
return;
|
|
2451
2669
|
globalThis.removeEventListener("mousedown", hideHandler, true);
|
|
2452
2670
|
});
|
|
2453
|
-
|
|
2454
|
-
menu,
|
|
2455
|
-
subMenu,
|
|
2456
|
-
visible,
|
|
2457
|
-
menuStyle,
|
|
2458
|
-
subMenuData,
|
|
2671
|
+
expose({
|
|
2459
2672
|
hide,
|
|
2460
|
-
show
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2673
|
+
show
|
|
2674
|
+
});
|
|
2675
|
+
return (_ctx, _cache) => {
|
|
2676
|
+
const _component_content_menu = vue.resolveComponent("content-menu", true);
|
|
2677
|
+
return __props.menuData.length && visible.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
2678
|
+
key: 0,
|
|
2679
|
+
class: "magic-editor-content-menu",
|
|
2680
|
+
ref_key: "menu",
|
|
2681
|
+
ref: menu,
|
|
2682
|
+
style: vue.normalizeStyle(menuStyle.value)
|
|
2683
|
+
}, [
|
|
2684
|
+
vue.createElementVNode("div", null, [
|
|
2685
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.menuData, (item, index) => {
|
|
2686
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$f, {
|
|
2687
|
+
"event-type": "mouseup",
|
|
2688
|
+
data: item,
|
|
2689
|
+
key: index,
|
|
2690
|
+
onMouseup: hide,
|
|
2691
|
+
onMouseenter: ($event) => showSubMenu(item)
|
|
2692
|
+
}, null, 8, ["data", "onMouseenter"]);
|
|
2693
|
+
}), 128))
|
|
2694
|
+
]),
|
|
2695
|
+
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
2696
|
+
vue.createVNode(_component_content_menu, {
|
|
2697
|
+
class: "sub-menu",
|
|
2698
|
+
ref_key: "subMenu",
|
|
2699
|
+
ref: subMenu,
|
|
2700
|
+
"menu-data": subMenuData.value,
|
|
2701
|
+
"is-sub-menu": true,
|
|
2702
|
+
onHide: hide
|
|
2703
|
+
}, null, 8, ["menu-data"])
|
|
2704
|
+
]))
|
|
2705
|
+
], 4)) : vue.createCommentVNode("", true);
|
|
2490
2706
|
};
|
|
2491
2707
|
}
|
|
2492
2708
|
});
|
|
2493
|
-
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2494
|
-
const _component_tool_button = vue.resolveComponent("tool-button");
|
|
2495
|
-
const _component_content_menu = vue.resolveComponent("content-menu", true);
|
|
2496
|
-
return _ctx.menuData.length && _ctx.visible ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
2497
|
-
key: 0,
|
|
2498
|
-
class: "magic-editor-content-menu",
|
|
2499
|
-
ref: "menu",
|
|
2500
|
-
style: vue.normalizeStyle(_ctx.menuStyle)
|
|
2501
|
-
}, [
|
|
2502
|
-
vue.createElementVNode("div", null, [
|
|
2503
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.menuData, (item, index) => {
|
|
2504
|
-
return vue.openBlock(), vue.createBlock(_component_tool_button, {
|
|
2505
|
-
"event-type": "mouseup",
|
|
2506
|
-
data: item,
|
|
2507
|
-
key: index,
|
|
2508
|
-
onMouseup: _ctx.hide,
|
|
2509
|
-
onMouseenter: ($event) => _ctx.showSubMenu(item)
|
|
2510
|
-
}, null, 8, ["data", "onMouseup", "onMouseenter"]);
|
|
2511
|
-
}), 128))
|
|
2512
|
-
]),
|
|
2513
|
-
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
2514
|
-
vue.createVNode(_component_content_menu, {
|
|
2515
|
-
class: "sub-menu",
|
|
2516
|
-
ref: "subMenu",
|
|
2517
|
-
"menu-data": _ctx.subMenuData,
|
|
2518
|
-
"is-sub-menu": true,
|
|
2519
|
-
onHide: _ctx.hide
|
|
2520
|
-
}, null, 8, ["menu-data", "onHide"])
|
|
2521
|
-
]))
|
|
2522
|
-
], 4)) : vue.createCommentVNode("", true);
|
|
2523
|
-
}
|
|
2524
|
-
var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
|
|
2525
2709
|
|
|
2526
|
-
const _sfc_main$
|
|
2527
|
-
components: { ContentMenu },
|
|
2710
|
+
const _sfc_main$a = vue.defineComponent({
|
|
2711
|
+
components: { ContentMenu: _sfc_main$b },
|
|
2528
2712
|
setup() {
|
|
2529
2713
|
const services = vue.inject("services");
|
|
2530
2714
|
const menu = vue.ref();
|
|
@@ -2606,7 +2790,8 @@
|
|
|
2606
2790
|
};
|
|
2607
2791
|
}
|
|
2608
2792
|
});
|
|
2609
|
-
|
|
2793
|
+
|
|
2794
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2610
2795
|
const _component_content_menu = vue.resolveComponent("content-menu");
|
|
2611
2796
|
return vue.openBlock(), vue.createBlock(_component_content_menu, {
|
|
2612
2797
|
"menu-data": _ctx.menuData,
|
|
@@ -2614,7 +2799,7 @@
|
|
|
2614
2799
|
style: { "overflow": "initial" }
|
|
2615
2800
|
}, null, 8, ["menu-data"]);
|
|
2616
2801
|
}
|
|
2617
|
-
|
|
2802
|
+
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$6]]);
|
|
2618
2803
|
|
|
2619
2804
|
const throttleTime = 150;
|
|
2620
2805
|
const select = async (data, editorService) => {
|
|
@@ -2648,29 +2833,55 @@
|
|
|
2648
2833
|
return true;
|
|
2649
2834
|
return false;
|
|
2650
2835
|
},
|
|
2651
|
-
handleDragEnd() {
|
|
2836
|
+
async handleDragEnd(e) {
|
|
2652
2837
|
if (!tree.value)
|
|
2653
2838
|
return;
|
|
2839
|
+
const { data: node } = e;
|
|
2840
|
+
const parent = editorService?.getParentById(node.id, false);
|
|
2841
|
+
const layout = await editorService?.getLayout(parent);
|
|
2842
|
+
node.style.position = layout;
|
|
2843
|
+
if (layout === Layout.RELATIVE) {
|
|
2844
|
+
node.style.top = 0;
|
|
2845
|
+
node.style.left = 0;
|
|
2846
|
+
}
|
|
2654
2847
|
const { data } = tree.value;
|
|
2655
2848
|
const [page] = data;
|
|
2656
2849
|
editorService?.update(page);
|
|
2657
2850
|
}
|
|
2658
2851
|
});
|
|
2659
2852
|
const useStatus = (tree, editorService) => {
|
|
2660
|
-
const highlightNode = vue.ref();
|
|
2661
2853
|
const node = vue.ref();
|
|
2662
2854
|
const page = vue.computed(() => editorService?.get("page"));
|
|
2855
|
+
const expandedKeys = /* @__PURE__ */ new Map();
|
|
2856
|
+
const expandNodes = () => {
|
|
2857
|
+
expandedKeys.forEach((key) => {
|
|
2858
|
+
if (!tree.value)
|
|
2859
|
+
return;
|
|
2860
|
+
tree.value.getNode(key)?.expand();
|
|
2861
|
+
});
|
|
2862
|
+
};
|
|
2663
2863
|
vue.watchEffect(() => {
|
|
2664
2864
|
if (!tree.value)
|
|
2665
2865
|
return;
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2866
|
+
if (!editorService)
|
|
2867
|
+
return;
|
|
2868
|
+
node.value = editorService.get("node");
|
|
2869
|
+
if (!node.value)
|
|
2870
|
+
return;
|
|
2871
|
+
tree.value.setCurrentKey(node.value.id, true);
|
|
2872
|
+
const parent = editorService.get("parent");
|
|
2669
2873
|
if (!parent?.id)
|
|
2670
2874
|
return;
|
|
2671
2875
|
const treeNode = tree.value.getNode(parent.id);
|
|
2672
2876
|
treeNode?.updateChildren();
|
|
2673
|
-
|
|
2877
|
+
setTimeout(() => {
|
|
2878
|
+
tree.value && Object.entries(tree.value.store.nodesMap).forEach(([id, node2]) => {
|
|
2879
|
+
if (node2.expanded && node2.data.items) {
|
|
2880
|
+
expandedKeys.set(id, id);
|
|
2881
|
+
}
|
|
2882
|
+
});
|
|
2883
|
+
expandNodes();
|
|
2884
|
+
});
|
|
2674
2885
|
});
|
|
2675
2886
|
return {
|
|
2676
2887
|
values: vue.computed(() => page.value ? [page.value] : []),
|
|
@@ -2683,9 +2894,18 @@
|
|
|
2683
2894
|
}
|
|
2684
2895
|
resolve([]);
|
|
2685
2896
|
},
|
|
2686
|
-
highlightNode,
|
|
2897
|
+
highlightNode: vue.computed(() => editorService?.get("highlightNode")),
|
|
2687
2898
|
clickNode: node,
|
|
2688
|
-
expandedKeys: vue.computed(() => node.value ? [node.value.id] : [])
|
|
2899
|
+
expandedKeys: vue.computed(() => node.value ? [node.value.id] : []),
|
|
2900
|
+
handleCollapse: (data) => {
|
|
2901
|
+
expandedKeys.delete(data.id);
|
|
2902
|
+
},
|
|
2903
|
+
handleExpand: (data) => {
|
|
2904
|
+
const parent = editorService?.getParentById(data.id);
|
|
2905
|
+
if (!parent?.id)
|
|
2906
|
+
return;
|
|
2907
|
+
expandedKeys.set(parent.id, parent.id);
|
|
2908
|
+
}
|
|
2689
2909
|
};
|
|
2690
2910
|
};
|
|
2691
2911
|
const useFilter = (tree) => ({
|
|
@@ -2706,7 +2926,7 @@
|
|
|
2706
2926
|
tree.value?.filter(val);
|
|
2707
2927
|
}
|
|
2708
2928
|
});
|
|
2709
|
-
const _sfc_main$
|
|
2929
|
+
const _sfc_main$9 = vue.defineComponent({
|
|
2710
2930
|
name: "magic-editor-layer-panel",
|
|
2711
2931
|
components: { LayerMenu },
|
|
2712
2932
|
setup() {
|
|
@@ -2753,8 +2973,9 @@
|
|
|
2753
2973
|
};
|
|
2754
2974
|
}
|
|
2755
2975
|
});
|
|
2976
|
+
|
|
2756
2977
|
const _hoisted_1$4 = ["id", "onMouseenter"];
|
|
2757
|
-
function _sfc_render$
|
|
2978
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2758
2979
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
2759
2980
|
const _component_el_tree = vue.resolveComponent("el-tree");
|
|
2760
2981
|
const _component_layer_menu = vue.resolveComponent("layer-menu");
|
|
@@ -2775,6 +2996,7 @@
|
|
|
2775
2996
|
key: 0,
|
|
2776
2997
|
ref: "tree",
|
|
2777
2998
|
"node-key": "id",
|
|
2999
|
+
"empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
|
|
2778
3000
|
draggable: "",
|
|
2779
3001
|
"default-expanded-keys": _ctx.expandedKeys,
|
|
2780
3002
|
load: _ctx.loadItems,
|
|
@@ -2789,7 +3011,8 @@
|
|
|
2789
3011
|
onNodeClick: _ctx.clickHandler,
|
|
2790
3012
|
onNodeContextmenu: _ctx.contextmenu,
|
|
2791
3013
|
onNodeDragEnd: _ctx.handleDragEnd,
|
|
2792
|
-
|
|
3014
|
+
onNodeCollapse: _ctx.handleCollapse,
|
|
3015
|
+
onNodeExpand: _ctx.handleExpand
|
|
2793
3016
|
}, {
|
|
2794
3017
|
default: vue.withCtx(({ node, data }) => [
|
|
2795
3018
|
vue.createElementVNode("div", {
|
|
@@ -2808,7 +3031,7 @@
|
|
|
2808
3031
|
], 42, _hoisted_1$4)
|
|
2809
3032
|
]),
|
|
2810
3033
|
_: 3
|
|
2811
|
-
}, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : vue.createCommentVNode("", true),
|
|
3034
|
+
}, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd", "onNodeCollapse", "onNodeExpand"])) : vue.createCommentVNode("", true),
|
|
2812
3035
|
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
2813
3036
|
vue.createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
|
|
2814
3037
|
]))
|
|
@@ -2816,9 +3039,9 @@
|
|
|
2816
3039
|
_: 3
|
|
2817
3040
|
});
|
|
2818
3041
|
}
|
|
2819
|
-
|
|
3042
|
+
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$5]]);
|
|
2820
3043
|
|
|
2821
|
-
const _sfc_main$
|
|
3044
|
+
const _sfc_main$8 = vue.defineComponent({
|
|
2822
3045
|
components: { MIcon },
|
|
2823
3046
|
props: {
|
|
2824
3047
|
data: {
|
|
@@ -2855,11 +3078,12 @@
|
|
|
2855
3078
|
};
|
|
2856
3079
|
}
|
|
2857
3080
|
});
|
|
3081
|
+
|
|
2858
3082
|
const _hoisted_1$3 = {
|
|
2859
3083
|
key: 1,
|
|
2860
3084
|
class: "magic-editor-tab-panel-title"
|
|
2861
3085
|
};
|
|
2862
|
-
function _sfc_render$
|
|
3086
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2863
3087
|
const _component_m_icon = vue.resolveComponent("m-icon");
|
|
2864
3088
|
const _component_el_tab_pane = vue.resolveComponent("el-tab-pane");
|
|
2865
3089
|
return _ctx.config ? (vue.openBlock(), vue.createBlock(_component_el_tab_pane, {
|
|
@@ -2905,9 +3129,9 @@
|
|
|
2905
3129
|
_: 3
|
|
2906
3130
|
}, 8, ["name"])) : vue.createCommentVNode("", true);
|
|
2907
3131
|
}
|
|
2908
|
-
|
|
3132
|
+
const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$4]]);
|
|
2909
3133
|
|
|
2910
|
-
const _sfc_main$
|
|
3134
|
+
const _sfc_main$7 = vue.defineComponent({
|
|
2911
3135
|
components: { TabPane },
|
|
2912
3136
|
name: "m-sidebar",
|
|
2913
3137
|
props: {
|
|
@@ -2926,7 +3150,8 @@
|
|
|
2926
3150
|
};
|
|
2927
3151
|
}
|
|
2928
3152
|
});
|
|
2929
|
-
|
|
3153
|
+
|
|
3154
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2930
3155
|
const _component_tab_pane = vue.resolveComponent("tab-pane");
|
|
2931
3156
|
const _component_el_tabs = vue.resolveComponent("el-tabs");
|
|
2932
3157
|
return _ctx.data.type === "tabs" && _ctx.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_tabs, {
|
|
@@ -2961,331 +3186,258 @@
|
|
|
2961
3186
|
_: 3
|
|
2962
3187
|
}, 8, ["modelValue"])) : vue.createCommentVNode("", true);
|
|
2963
3188
|
}
|
|
2964
|
-
|
|
3189
|
+
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$3]]);
|
|
2965
3190
|
|
|
2966
|
-
const
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
}
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
return;
|
|
2988
|
-
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
2989
|
-
if (type === "left") {
|
|
2990
|
-
translateLeft += 100;
|
|
2991
|
-
if (translateLeft > 0) {
|
|
2992
|
-
translateLeft = 0;
|
|
3191
|
+
const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
|
|
3192
|
+
__name: "PageBarScrollContainer",
|
|
3193
|
+
setup(__props) {
|
|
3194
|
+
const services = vue.inject("services");
|
|
3195
|
+
const editorService = services?.editorService;
|
|
3196
|
+
const pageBar = vue.ref();
|
|
3197
|
+
const itemsContainer = vue.ref();
|
|
3198
|
+
const pageBarWidth = vue.ref(0);
|
|
3199
|
+
const canScroll = vue.ref(false);
|
|
3200
|
+
const itemsContainerWidth = vue.computed(() => pageBarWidth.value - 105);
|
|
3201
|
+
let translateLeft = 0;
|
|
3202
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
3203
|
+
for (const { contentRect } of entries) {
|
|
3204
|
+
const { width } = contentRect;
|
|
3205
|
+
pageBarWidth.value = width || 0;
|
|
3206
|
+
setCanScroll();
|
|
3207
|
+
}
|
|
3208
|
+
});
|
|
3209
|
+
const setCanScroll = () => {
|
|
3210
|
+
if (itemsContainer.value) {
|
|
3211
|
+
canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
|
|
2993
3212
|
}
|
|
2994
|
-
}
|
|
2995
|
-
|
|
2996
|
-
if (
|
|
3213
|
+
};
|
|
3214
|
+
const scroll = (type) => {
|
|
3215
|
+
if (!itemsContainer.value)
|
|
3216
|
+
return;
|
|
3217
|
+
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
3218
|
+
if (type === "left") {
|
|
3219
|
+
translateLeft += 100;
|
|
3220
|
+
if (translateLeft > 0) {
|
|
3221
|
+
translateLeft = 0;
|
|
3222
|
+
}
|
|
3223
|
+
} else if (type === "right") {
|
|
3224
|
+
translateLeft -= 100;
|
|
3225
|
+
if (-translateLeft > maxScrollLeft) {
|
|
3226
|
+
translateLeft = -maxScrollLeft;
|
|
3227
|
+
}
|
|
3228
|
+
} else if (type === "start") {
|
|
3229
|
+
translateLeft = 0;
|
|
3230
|
+
} else if (type === "end") {
|
|
2997
3231
|
translateLeft = -maxScrollLeft;
|
|
2998
3232
|
}
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
}
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
vue.onMounted(() => {
|
|
3007
|
-
pageBar.value && resizeObserver.observe(pageBar.value);
|
|
3008
|
-
});
|
|
3009
|
-
vue.onUnmounted(() => {
|
|
3010
|
-
resizeObserver.disconnect();
|
|
3011
|
-
});
|
|
3012
|
-
vue.watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
|
|
3013
|
-
setTimeout(() => {
|
|
3014
|
-
setCanScroll();
|
|
3015
|
-
if (length < preLength) {
|
|
3016
|
-
scroll("start");
|
|
3017
|
-
} else {
|
|
3018
|
-
scroll("end");
|
|
3019
|
-
}
|
|
3233
|
+
itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
|
|
3234
|
+
};
|
|
3235
|
+
vue.onMounted(() => {
|
|
3236
|
+
pageBar.value && resizeObserver.observe(pageBar.value);
|
|
3237
|
+
});
|
|
3238
|
+
vue.onUnmounted(() => {
|
|
3239
|
+
resizeObserver.disconnect();
|
|
3020
3240
|
});
|
|
3021
|
-
});
|
|
3022
|
-
return {
|
|
3023
|
-
pageBar,
|
|
3024
|
-
itemsContainer,
|
|
3025
|
-
canScroll,
|
|
3026
|
-
itemsContainerWidth,
|
|
3027
|
-
scroll
|
|
3028
|
-
};
|
|
3029
|
-
};
|
|
3030
|
-
const _sfc_main$5 = vue.defineComponent({
|
|
3031
|
-
components: { ArrowLeftBold: iconsVue.ArrowLeftBold, ArrowRightBold: iconsVue.ArrowRightBold, CaretBottom: iconsVue.CaretBottom, Plus: iconsVue.Plus, ToolButton },
|
|
3032
|
-
setup() {
|
|
3033
|
-
const services = vue.inject("services");
|
|
3034
|
-
const editorService = services?.editorService;
|
|
3035
3241
|
const root = vue.computed(() => editorService?.get("root"));
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
}
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
copy(node) {
|
|
3055
|
-
node && editorService?.copy(node);
|
|
3056
|
-
editorService?.paste({
|
|
3057
|
-
left: 0,
|
|
3058
|
-
top: 0
|
|
3059
|
-
});
|
|
3060
|
-
},
|
|
3061
|
-
remove(node) {
|
|
3062
|
-
editorService?.remove(node);
|
|
3063
|
-
}
|
|
3242
|
+
vue.watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
|
|
3243
|
+
setTimeout(() => {
|
|
3244
|
+
setCanScroll();
|
|
3245
|
+
if (length < preLength) {
|
|
3246
|
+
scroll("start");
|
|
3247
|
+
} else {
|
|
3248
|
+
scroll("end");
|
|
3249
|
+
}
|
|
3250
|
+
});
|
|
3251
|
+
});
|
|
3252
|
+
const addPage = () => {
|
|
3253
|
+
if (!editorService)
|
|
3254
|
+
return;
|
|
3255
|
+
const pageConfig = {
|
|
3256
|
+
type: schema.NodeType.PAGE,
|
|
3257
|
+
name: generatePageNameByApp(vue.toRaw(editorService.get("root")))
|
|
3258
|
+
};
|
|
3259
|
+
editorService.add(pageConfig);
|
|
3064
3260
|
};
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
vue.createElementVNode("div", {
|
|
3084
|
-
id: "m-editor-page-bar-add-icon",
|
|
3085
|
-
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3086
|
-
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.addPage && _ctx.addPage(...args))
|
|
3087
|
-
}, [
|
|
3088
|
-
vue.createVNode(_component_el_icon, null, {
|
|
3089
|
-
default: vue.withCtx(() => [
|
|
3090
|
-
vue.createVNode(_component_plus)
|
|
3091
|
-
]),
|
|
3092
|
-
_: 1
|
|
3093
|
-
})
|
|
3094
|
-
]),
|
|
3095
|
-
_ctx.canScroll ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3096
|
-
key: 0,
|
|
3097
|
-
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3098
|
-
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.scroll("left"))
|
|
3099
|
-
}, [
|
|
3100
|
-
vue.createVNode(_component_el_icon, null, {
|
|
3101
|
-
default: vue.withCtx(() => [
|
|
3102
|
-
vue.createVNode(_component_arrow_left_bold)
|
|
3261
|
+
return (_ctx, _cache) => {
|
|
3262
|
+
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
3263
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
3264
|
+
class: "m-editor-page-bar",
|
|
3265
|
+
ref_key: "pageBar",
|
|
3266
|
+
ref: pageBar
|
|
3267
|
+
}, [
|
|
3268
|
+
vue.createElementVNode("div", {
|
|
3269
|
+
id: "m-editor-page-bar-add-icon",
|
|
3270
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3271
|
+
onClick: addPage
|
|
3272
|
+
}, [
|
|
3273
|
+
vue.createVNode(_component_el_icon, null, {
|
|
3274
|
+
default: vue.withCtx(() => [
|
|
3275
|
+
vue.createVNode(vue.unref(iconsVue.Plus))
|
|
3276
|
+
]),
|
|
3277
|
+
_: 1
|
|
3278
|
+
})
|
|
3103
3279
|
]),
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
key: 1,
|
|
3109
|
-
class: "m-editor-page-bar-items",
|
|
3110
|
-
ref: "itemsContainer",
|
|
3111
|
-
style: vue.normalizeStyle(`width: ${_ctx.itemsContainerWidth}px`)
|
|
3112
|
-
}, [
|
|
3113
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.root.items, (item) => {
|
|
3114
|
-
return vue.openBlock(), vue.createElementBlock("div", {
|
|
3115
|
-
key: item.key,
|
|
3116
|
-
class: vue.normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
|
|
3117
|
-
onClick: ($event) => _ctx.switchPage(item)
|
|
3280
|
+
canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3281
|
+
key: 0,
|
|
3282
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3283
|
+
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
3118
3284
|
}, [
|
|
3119
|
-
vue.
|
|
3120
|
-
vue.
|
|
3121
|
-
vue.createVNode(
|
|
3122
|
-
effect: "dark",
|
|
3123
|
-
placement: "top-start",
|
|
3124
|
-
content: item.name
|
|
3125
|
-
}, {
|
|
3126
|
-
default: vue.withCtx(() => [
|
|
3127
|
-
vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
|
|
3128
|
-
]),
|
|
3129
|
-
_: 2
|
|
3130
|
-
}, 1032, ["content"])
|
|
3131
|
-
])
|
|
3132
|
-
]),
|
|
3133
|
-
vue.createVNode(_component_el_popover, {
|
|
3134
|
-
"popper-class": "page-bar-popover",
|
|
3135
|
-
placement: "top",
|
|
3136
|
-
width: 160,
|
|
3137
|
-
trigger: "hover"
|
|
3138
|
-
}, {
|
|
3139
|
-
reference: vue.withCtx(() => [
|
|
3140
|
-
vue.createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
|
|
3141
|
-
default: vue.withCtx(() => [
|
|
3142
|
-
vue.createVNode(_component_caret_bottom)
|
|
3143
|
-
]),
|
|
3144
|
-
_: 1
|
|
3145
|
-
})
|
|
3285
|
+
vue.createVNode(_component_el_icon, null, {
|
|
3286
|
+
default: vue.withCtx(() => [
|
|
3287
|
+
vue.createVNode(vue.unref(iconsVue.ArrowLeftBold))
|
|
3146
3288
|
]),
|
|
3289
|
+
_: 1
|
|
3290
|
+
})
|
|
3291
|
+
])) : vue.createCommentVNode("", true),
|
|
3292
|
+
vue.unref(root) ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3293
|
+
key: 1,
|
|
3294
|
+
class: "m-editor-page-bar-items",
|
|
3295
|
+
ref_key: "itemsContainer",
|
|
3296
|
+
ref: itemsContainer,
|
|
3297
|
+
style: vue.normalizeStyle(`width: ${vue.unref(itemsContainerWidth)}px`)
|
|
3298
|
+
}, [
|
|
3299
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
3300
|
+
], 4)) : vue.createCommentVNode("", true),
|
|
3301
|
+
canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3302
|
+
key: 2,
|
|
3303
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3304
|
+
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
3305
|
+
}, [
|
|
3306
|
+
vue.createVNode(_component_el_icon, null, {
|
|
3147
3307
|
default: vue.withCtx(() => [
|
|
3148
|
-
vue.
|
|
3149
|
-
vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3150
|
-
vue.createVNode(_component_tool_button, {
|
|
3151
|
-
data: {
|
|
3152
|
-
type: "button",
|
|
3153
|
-
text: "\u590D\u5236",
|
|
3154
|
-
icon: _ctx.DocumentCopy,
|
|
3155
|
-
handler: () => _ctx.copy(item)
|
|
3156
|
-
}
|
|
3157
|
-
}, null, 8, ["data"]),
|
|
3158
|
-
vue.createVNode(_component_tool_button, {
|
|
3159
|
-
data: {
|
|
3160
|
-
type: "button",
|
|
3161
|
-
text: "\u5220\u9664",
|
|
3162
|
-
icon: _ctx.Delete,
|
|
3163
|
-
handler: () => _ctx.remove(item)
|
|
3164
|
-
}
|
|
3165
|
-
}, null, 8, ["data"])
|
|
3166
|
-
])
|
|
3167
|
-
])
|
|
3308
|
+
vue.createVNode(vue.unref(iconsVue.ArrowRightBold))
|
|
3168
3309
|
]),
|
|
3169
|
-
_:
|
|
3170
|
-
}
|
|
3171
|
-
]
|
|
3172
|
-
|
|
3173
|
-
], 4)) : vue.createCommentVNode("", true),
|
|
3174
|
-
_ctx.canScroll ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3175
|
-
key: 2,
|
|
3176
|
-
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3177
|
-
onClick: _cache[2] || (_cache[2] = ($event) => _ctx.scroll("right"))
|
|
3178
|
-
}, [
|
|
3179
|
-
vue.createVNode(_component_el_icon, null, {
|
|
3180
|
-
default: vue.withCtx(() => [
|
|
3181
|
-
vue.createVNode(_component_arrow_right_bold)
|
|
3182
|
-
]),
|
|
3183
|
-
_: 1
|
|
3184
|
-
})
|
|
3185
|
-
])) : vue.createCommentVNode("", true)
|
|
3186
|
-
], 512);
|
|
3187
|
-
}
|
|
3188
|
-
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
|
|
3189
|
-
|
|
3190
|
-
class ScrollViewer$1 {
|
|
3191
|
-
constructor(options) {
|
|
3192
|
-
this.enter = false;
|
|
3193
|
-
this.targetEnter = false;
|
|
3194
|
-
this.keydown = false;
|
|
3195
|
-
this.zoom = 1;
|
|
3196
|
-
this.scrollLeft = 0;
|
|
3197
|
-
this.scrollTop = 0;
|
|
3198
|
-
this.x = 0;
|
|
3199
|
-
this.y = 0;
|
|
3200
|
-
this.resizeObserver = new ResizeObserver((entries) => {
|
|
3201
|
-
for (const { contentRect } of entries) {
|
|
3202
|
-
const { width, height } = contentRect;
|
|
3203
|
-
const targetRect = this.target.getBoundingClientRect();
|
|
3204
|
-
const targetWidth = targetRect.width * this.zoom;
|
|
3205
|
-
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3206
|
-
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
3207
|
-
if (targetWidth < width) {
|
|
3208
|
-
this.target._left = 0;
|
|
3209
|
-
}
|
|
3210
|
-
if (targetHeight < height) {
|
|
3211
|
-
this.target._top = 0;
|
|
3212
|
-
}
|
|
3213
|
-
this.scroll();
|
|
3214
|
-
}
|
|
3215
|
-
});
|
|
3216
|
-
this.wheelHandler = (event) => {
|
|
3217
|
-
if (this.targetEnter)
|
|
3218
|
-
return;
|
|
3219
|
-
const { deltaX, deltaY, currentTarget } = event;
|
|
3220
|
-
if (currentTarget !== this.container)
|
|
3221
|
-
return;
|
|
3222
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3223
|
-
this.scroll();
|
|
3224
|
-
this.scrollLeft = this.target._left;
|
|
3225
|
-
this.scrollTop = this.target._top;
|
|
3226
|
-
};
|
|
3227
|
-
this.mouseEnterHandler = () => {
|
|
3228
|
-
this.enter = true;
|
|
3229
|
-
};
|
|
3230
|
-
this.mouseLeaveHandler = () => {
|
|
3231
|
-
this.enter = false;
|
|
3232
|
-
};
|
|
3233
|
-
this.targetMouseEnterHandler = () => {
|
|
3234
|
-
this.targetEnter = true;
|
|
3310
|
+
_: 1
|
|
3311
|
+
})
|
|
3312
|
+
])) : vue.createCommentVNode("", true)
|
|
3313
|
+
], 512);
|
|
3235
3314
|
};
|
|
3236
|
-
|
|
3237
|
-
|
|
3315
|
+
}
|
|
3316
|
+
});
|
|
3317
|
+
|
|
3318
|
+
const _hoisted_1$2 = ["onClick"];
|
|
3319
|
+
const _hoisted_2 = { class: "m-editor-page-bar-title" };
|
|
3320
|
+
const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
|
|
3321
|
+
__name: "PageBar",
|
|
3322
|
+
setup(__props) {
|
|
3323
|
+
const services = vue.inject("services");
|
|
3324
|
+
const editorService = services?.editorService;
|
|
3325
|
+
const root = vue.computed(() => editorService?.get("root"));
|
|
3326
|
+
const page = vue.computed(() => editorService?.get("page"));
|
|
3327
|
+
const switchPage = (page2) => {
|
|
3328
|
+
editorService?.select(page2);
|
|
3238
3329
|
};
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
this.x = event.clientX;
|
|
3246
|
-
this.y = event.clientY;
|
|
3247
|
-
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3248
|
-
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3330
|
+
const copy = (node) => {
|
|
3331
|
+
node && editorService?.copy(node);
|
|
3332
|
+
editorService?.paste({
|
|
3333
|
+
left: 0,
|
|
3334
|
+
top: 0
|
|
3335
|
+
});
|
|
3249
3336
|
};
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
this.y = 0;
|
|
3253
|
-
this.scrollLeft = this.target._left;
|
|
3254
|
-
this.scrollTop = this.target._top;
|
|
3255
|
-
this.removeHandler();
|
|
3337
|
+
const remove = (node) => {
|
|
3338
|
+
editorService?.remove(node);
|
|
3256
3339
|
};
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
const
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3340
|
+
return (_ctx, _cache) => {
|
|
3341
|
+
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
3342
|
+
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
3343
|
+
const _component_el_popover = vue.resolveComponent("el-popover");
|
|
3344
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$6, null, {
|
|
3345
|
+
default: vue.withCtx(() => [
|
|
3346
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(root) && vue.unref(root).items || [], (item) => {
|
|
3347
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
3348
|
+
class: vue.normalizeClass(["m-editor-page-bar-item", { active: vue.unref(page)?.id === item.id }]),
|
|
3349
|
+
key: item.key,
|
|
3350
|
+
onClick: ($event) => switchPage(item)
|
|
3351
|
+
}, [
|
|
3352
|
+
vue.createElementVNode("div", _hoisted_2, [
|
|
3353
|
+
vue.renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
|
|
3354
|
+
vue.createVNode(_component_el_tooltip, {
|
|
3355
|
+
effect: "dark",
|
|
3356
|
+
placement: "top-start",
|
|
3357
|
+
content: item.name
|
|
3358
|
+
}, {
|
|
3359
|
+
default: vue.withCtx(() => [
|
|
3360
|
+
vue.createElementVNode("span", null, vue.toDisplayString(item.name || item.id), 1)
|
|
3361
|
+
]),
|
|
3362
|
+
_: 2
|
|
3363
|
+
}, 1032, ["content"])
|
|
3364
|
+
])
|
|
3365
|
+
]),
|
|
3366
|
+
vue.createVNode(_component_el_popover, {
|
|
3367
|
+
"popper-class": "page-bar-popover",
|
|
3368
|
+
placement: "top",
|
|
3369
|
+
width: 160,
|
|
3370
|
+
trigger: "hover"
|
|
3371
|
+
}, {
|
|
3372
|
+
reference: vue.withCtx(() => [
|
|
3373
|
+
vue.createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
|
|
3374
|
+
default: vue.withCtx(() => [
|
|
3375
|
+
vue.createVNode(vue.unref(iconsVue.CaretBottom))
|
|
3376
|
+
]),
|
|
3377
|
+
_: 1
|
|
3378
|
+
})
|
|
3379
|
+
]),
|
|
3380
|
+
default: vue.withCtx(() => [
|
|
3381
|
+
vue.createElementVNode("div", null, [
|
|
3382
|
+
vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3383
|
+
vue.createVNode(_sfc_main$f, {
|
|
3384
|
+
data: {
|
|
3385
|
+
type: "button",
|
|
3386
|
+
text: "\u590D\u5236",
|
|
3387
|
+
icon: vue.unref(iconsVue.DocumentCopy),
|
|
3388
|
+
handler: () => copy(item)
|
|
3389
|
+
}
|
|
3390
|
+
}, null, 8, ["data"]),
|
|
3391
|
+
vue.createVNode(_sfc_main$f, {
|
|
3392
|
+
data: {
|
|
3393
|
+
type: "button",
|
|
3394
|
+
text: "\u5220\u9664",
|
|
3395
|
+
icon: vue.unref(iconsVue.Delete),
|
|
3396
|
+
handler: () => remove(item)
|
|
3397
|
+
}
|
|
3398
|
+
}, null, 8, ["data"])
|
|
3399
|
+
])
|
|
3400
|
+
])
|
|
3401
|
+
]),
|
|
3402
|
+
_: 2
|
|
3403
|
+
}, 1024)
|
|
3404
|
+
], 10, _hoisted_1$2);
|
|
3405
|
+
}), 128))
|
|
3406
|
+
]),
|
|
3407
|
+
_: 3
|
|
3408
|
+
});
|
|
3264
3409
|
};
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3410
|
+
}
|
|
3411
|
+
});
|
|
3412
|
+
|
|
3413
|
+
class ScrollViewer$1 {
|
|
3414
|
+
enter = false;
|
|
3415
|
+
targetEnter = false;
|
|
3416
|
+
keydown = false;
|
|
3417
|
+
container;
|
|
3418
|
+
target;
|
|
3419
|
+
zoom = 1;
|
|
3420
|
+
scrollLeft = 0;
|
|
3421
|
+
scrollTop = 0;
|
|
3422
|
+
x = 0;
|
|
3423
|
+
y = 0;
|
|
3424
|
+
resizeObserver = new ResizeObserver((entries) => {
|
|
3425
|
+
for (const { contentRect } of entries) {
|
|
3426
|
+
const { width, height } = contentRect;
|
|
3427
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3428
|
+
const targetWidth = targetRect.width * this.zoom;
|
|
3429
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3430
|
+
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
3431
|
+
if (targetWidth < width) {
|
|
3432
|
+
this.target._left = 0;
|
|
3273
3433
|
}
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3277
|
-
};
|
|
3278
|
-
this.keyupHandler = (event) => {
|
|
3279
|
-
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3280
|
-
return;
|
|
3434
|
+
if (targetHeight < height) {
|
|
3435
|
+
this.target._top = 0;
|
|
3281
3436
|
}
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
event.preventDefault();
|
|
3287
|
-
this.removeHandler();
|
|
3288
|
-
};
|
|
3437
|
+
this.scroll();
|
|
3438
|
+
}
|
|
3439
|
+
});
|
|
3440
|
+
constructor(options) {
|
|
3289
3441
|
this.container = options.container;
|
|
3290
3442
|
this.target = options.target;
|
|
3291
3443
|
this.zoom = options.zoom;
|
|
@@ -3321,6 +3473,79 @@
|
|
|
3321
3473
|
document.removeEventListener("mousemove", this.mousemoveHandler);
|
|
3322
3474
|
document.removeEventListener("mouseup", this.mouseupHandler);
|
|
3323
3475
|
}
|
|
3476
|
+
wheelHandler = (event) => {
|
|
3477
|
+
if (this.targetEnter)
|
|
3478
|
+
return;
|
|
3479
|
+
const { deltaX, deltaY, currentTarget } = event;
|
|
3480
|
+
if (currentTarget !== this.container)
|
|
3481
|
+
return;
|
|
3482
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3483
|
+
this.scroll();
|
|
3484
|
+
this.scrollLeft = this.target._left;
|
|
3485
|
+
this.scrollTop = this.target._top;
|
|
3486
|
+
};
|
|
3487
|
+
mouseEnterHandler = () => {
|
|
3488
|
+
this.enter = true;
|
|
3489
|
+
};
|
|
3490
|
+
mouseLeaveHandler = () => {
|
|
3491
|
+
this.enter = false;
|
|
3492
|
+
};
|
|
3493
|
+
targetMouseEnterHandler = () => {
|
|
3494
|
+
this.targetEnter = true;
|
|
3495
|
+
};
|
|
3496
|
+
targetMouseLeaveHandler = () => {
|
|
3497
|
+
this.targetEnter = false;
|
|
3498
|
+
};
|
|
3499
|
+
mousedownHandler = (event) => {
|
|
3500
|
+
if (!this.keydown)
|
|
3501
|
+
return;
|
|
3502
|
+
event.stopImmediatePropagation();
|
|
3503
|
+
event.stopPropagation();
|
|
3504
|
+
this.target.style.cursor = "grabbing";
|
|
3505
|
+
this.x = event.clientX;
|
|
3506
|
+
this.y = event.clientY;
|
|
3507
|
+
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3508
|
+
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3509
|
+
};
|
|
3510
|
+
mouseupHandler = () => {
|
|
3511
|
+
this.x = 0;
|
|
3512
|
+
this.y = 0;
|
|
3513
|
+
this.scrollLeft = this.target._left;
|
|
3514
|
+
this.scrollTop = this.target._top;
|
|
3515
|
+
this.removeHandler();
|
|
3516
|
+
};
|
|
3517
|
+
mousemoveHandler = (event) => {
|
|
3518
|
+
event.stopImmediatePropagation();
|
|
3519
|
+
event.stopPropagation();
|
|
3520
|
+
const deltaX = event.clientX - this.x;
|
|
3521
|
+
const deltaY = event.clientY - this.y;
|
|
3522
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3523
|
+
this.scroll();
|
|
3524
|
+
};
|
|
3525
|
+
keydownHandler = (event) => {
|
|
3526
|
+
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3527
|
+
event.preventDefault();
|
|
3528
|
+
event.stopImmediatePropagation();
|
|
3529
|
+
event.stopPropagation();
|
|
3530
|
+
}
|
|
3531
|
+
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3532
|
+
return;
|
|
3533
|
+
}
|
|
3534
|
+
this.keydown = true;
|
|
3535
|
+
this.target.style.cursor = "grab";
|
|
3536
|
+
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3537
|
+
};
|
|
3538
|
+
keyupHandler = (event) => {
|
|
3539
|
+
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3540
|
+
return;
|
|
3541
|
+
}
|
|
3542
|
+
event.preventDefault();
|
|
3543
|
+
event.stopImmediatePropagation();
|
|
3544
|
+
event.stopPropagation();
|
|
3545
|
+
this.keydown = false;
|
|
3546
|
+
event.preventDefault();
|
|
3547
|
+
this.removeHandler();
|
|
3548
|
+
};
|
|
3324
3549
|
setScrollOffset(deltaX, deltaY) {
|
|
3325
3550
|
const { width, height } = this.container.getBoundingClientRect();
|
|
3326
3551
|
const targetRect = this.target.getBoundingClientRect();
|
|
@@ -3381,18 +3606,19 @@
|
|
|
3381
3606
|
el,
|
|
3382
3607
|
style: vue.computed(() => `
|
|
3383
3608
|
width: ${props.width}px;
|
|
3384
|
-
height: ${
|
|
3609
|
+
height: ${props.height}px;
|
|
3385
3610
|
position: absolute;
|
|
3386
3611
|
margin-top: 30px;
|
|
3387
3612
|
`)
|
|
3388
3613
|
};
|
|
3389
3614
|
}
|
|
3390
3615
|
});
|
|
3616
|
+
|
|
3391
3617
|
const _hoisted_1$1 = {
|
|
3392
3618
|
class: "m-editor-scroll-viewer-container",
|
|
3393
3619
|
ref: "container"
|
|
3394
3620
|
};
|
|
3395
|
-
function _sfc_render$
|
|
3621
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3396
3622
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
|
|
3397
3623
|
vue.createElementVNode("div", {
|
|
3398
3624
|
ref: "el",
|
|
@@ -3402,170 +3628,170 @@
|
|
|
3402
3628
|
], 4)
|
|
3403
3629
|
], 512);
|
|
3404
3630
|
}
|
|
3405
|
-
|
|
3631
|
+
const ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$2]]);
|
|
3406
3632
|
|
|
3407
|
-
const _sfc_main$3 = vue.defineComponent({
|
|
3408
|
-
|
|
3409
|
-
|
|
3633
|
+
const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
3634
|
+
__name: "ViewerMenu",
|
|
3635
|
+
props: {
|
|
3636
|
+
isMultiSelect: { type: Boolean, default: false }
|
|
3637
|
+
},
|
|
3638
|
+
setup(__props, { expose }) {
|
|
3639
|
+
const props = __props;
|
|
3410
3640
|
const services = vue.inject("services");
|
|
3411
3641
|
const editorService = services?.editorService;
|
|
3412
3642
|
const menu = vue.ref();
|
|
3413
3643
|
const canPaste = vue.ref(false);
|
|
3414
3644
|
const canCenter = vue.ref(false);
|
|
3415
3645
|
const node = vue.computed(() => editorService?.get("node"));
|
|
3646
|
+
const nodes = vue.computed(() => editorService?.get("nodes"));
|
|
3416
3647
|
const parent = vue.computed(() => editorService?.get("parent"));
|
|
3417
|
-
const
|
|
3648
|
+
const stage = vue.computed(() => editorService?.get("stage"));
|
|
3418
3649
|
const stageContentMenu = vue.inject("stageContentMenu", []);
|
|
3419
|
-
vue.
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3650
|
+
const menuData = vue.reactive([
|
|
3651
|
+
{
|
|
3652
|
+
type: "button",
|
|
3653
|
+
text: "\u6C34\u5E73\u5C45\u4E2D",
|
|
3654
|
+
display: () => canCenter.value,
|
|
3655
|
+
handler: () => {
|
|
3656
|
+
if (!nodes.value)
|
|
3657
|
+
return;
|
|
3658
|
+
editorService?.alignCenter(nodes.value);
|
|
3659
|
+
}
|
|
3660
|
+
},
|
|
3661
|
+
{
|
|
3662
|
+
type: "button",
|
|
3663
|
+
text: "\u590D\u5236",
|
|
3664
|
+
icon: vue.markRaw(iconsVue.DocumentCopy),
|
|
3665
|
+
handler: () => {
|
|
3666
|
+
nodes.value && editorService?.copy(nodes.value);
|
|
3667
|
+
canPaste.value = true;
|
|
3668
|
+
}
|
|
3669
|
+
},
|
|
3670
|
+
{
|
|
3671
|
+
type: "button",
|
|
3672
|
+
text: "\u7C98\u8D34",
|
|
3673
|
+
display: () => canPaste.value,
|
|
3674
|
+
handler: () => {
|
|
3675
|
+
const rect = menu.value?.$el.getBoundingClientRect();
|
|
3676
|
+
const parentRect = stage.value?.container?.getBoundingClientRect();
|
|
3677
|
+
const initialLeft = (rect?.left || 0) - (parentRect?.left || 0);
|
|
3678
|
+
const initialTop = (rect?.top || 0) - (parentRect?.top || 0);
|
|
3679
|
+
if (!nodes.value || nodes.value.length === 0)
|
|
3680
|
+
return;
|
|
3681
|
+
editorService?.paste({ left: initialLeft, top: initialTop });
|
|
3682
|
+
}
|
|
3683
|
+
},
|
|
3684
|
+
{
|
|
3685
|
+
type: "divider",
|
|
3686
|
+
direction: "horizontal",
|
|
3687
|
+
display: () => {
|
|
3688
|
+
if (!node.value)
|
|
3689
|
+
return false;
|
|
3690
|
+
return !utils.isPage(node.value);
|
|
3691
|
+
}
|
|
3692
|
+
},
|
|
3693
|
+
{
|
|
3694
|
+
type: "button",
|
|
3695
|
+
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
3696
|
+
icon: vue.markRaw(iconsVue.Top),
|
|
3697
|
+
display: () => !utils.isPage(node.value) && !props.isMultiSelect,
|
|
3698
|
+
handler: () => {
|
|
3699
|
+
editorService?.moveLayer(1);
|
|
3700
|
+
}
|
|
3701
|
+
},
|
|
3702
|
+
{
|
|
3703
|
+
type: "button",
|
|
3704
|
+
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
3705
|
+
icon: vue.markRaw(iconsVue.Bottom),
|
|
3706
|
+
display: () => !utils.isPage(node.value) && !props.isMultiSelect,
|
|
3707
|
+
handler: () => {
|
|
3708
|
+
editorService?.moveLayer(-1);
|
|
3709
|
+
}
|
|
3710
|
+
},
|
|
3711
|
+
{
|
|
3712
|
+
type: "button",
|
|
3713
|
+
text: "\u7F6E\u9876",
|
|
3714
|
+
display: () => !utils.isPage(node.value) && !props.isMultiSelect,
|
|
3715
|
+
handler: () => {
|
|
3716
|
+
editorService?.moveLayer(LayerOffset.TOP);
|
|
3717
|
+
}
|
|
3718
|
+
},
|
|
3719
|
+
{
|
|
3720
|
+
type: "button",
|
|
3721
|
+
text: "\u7F6E\u5E95",
|
|
3722
|
+
display: () => !utils.isPage(node.value) && !props.isMultiSelect,
|
|
3723
|
+
handler: () => {
|
|
3724
|
+
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
3725
|
+
}
|
|
3726
|
+
},
|
|
3727
|
+
{
|
|
3728
|
+
type: "divider",
|
|
3729
|
+
direction: "horizontal",
|
|
3730
|
+
display: () => !utils.isPage(node.value) && !props.isMultiSelect
|
|
3731
|
+
},
|
|
3732
|
+
{
|
|
3733
|
+
type: "button",
|
|
3734
|
+
text: "\u5220\u9664",
|
|
3735
|
+
icon: iconsVue.Delete,
|
|
3736
|
+
display: () => !utils.isPage(node.value),
|
|
3737
|
+
handler: () => {
|
|
3738
|
+
nodes.value && editorService?.remove(nodes.value);
|
|
3739
|
+
}
|
|
3740
|
+
},
|
|
3741
|
+
{
|
|
3742
|
+
type: "divider",
|
|
3743
|
+
direction: "horizontal"
|
|
3744
|
+
},
|
|
3745
|
+
{
|
|
3746
|
+
type: "button",
|
|
3747
|
+
text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
|
|
3748
|
+
handler: () => {
|
|
3749
|
+
editorService?.get("stage").clearGuides();
|
|
3750
|
+
}
|
|
3751
|
+
},
|
|
3752
|
+
...stageContentMenu
|
|
3753
|
+
]);
|
|
3423
3754
|
vue.watch(parent, async () => {
|
|
3424
3755
|
if (!parent.value || !editorService)
|
|
3425
3756
|
return canCenter.value = false;
|
|
3426
3757
|
const layout = await editorService.getLayout(parent.value);
|
|
3427
|
-
|
|
3758
|
+
const isLayoutConform = [Layout.ABSOLUTE, Layout.FIXED].includes(layout);
|
|
3759
|
+
const isTypeConform = nodes.value?.every((selectedNode) => ![schema.NodeType.ROOT, schema.NodeType.PAGE, "pop"].includes(`${selectedNode?.type}`));
|
|
3760
|
+
canCenter.value = isLayoutConform && !!isTypeConform;
|
|
3428
3761
|
}, { immediate: true });
|
|
3429
|
-
|
|
3430
|
-
menu
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
type: "button",
|
|
3442
|
-
text: "\u590D\u5236",
|
|
3443
|
-
icon: vue.markRaw(iconsVue.DocumentCopy),
|
|
3444
|
-
handler: () => {
|
|
3445
|
-
node.value && editorService?.copy(node.value);
|
|
3446
|
-
canPaste.value = true;
|
|
3447
|
-
}
|
|
3448
|
-
},
|
|
3449
|
-
{
|
|
3450
|
-
type: "button",
|
|
3451
|
-
text: "\u7C98\u8D34",
|
|
3452
|
-
display: () => canPaste.value,
|
|
3453
|
-
handler: () => {
|
|
3454
|
-
const stage = editorService?.get("stage");
|
|
3455
|
-
const rect = menu.value?.$el.getBoundingClientRect();
|
|
3456
|
-
const parentRect = stage?.container?.getBoundingClientRect();
|
|
3457
|
-
let left = (rect?.left || 0) - (parentRect?.left || 0);
|
|
3458
|
-
let top = (rect?.top || 0) - (parentRect?.top || 0);
|
|
3459
|
-
if (node.value?.items && stage) {
|
|
3460
|
-
const parentEl = stage.renderer.contentWindow?.document.getElementById(`${node.value.id}`);
|
|
3461
|
-
const parentElRect = parentEl?.getBoundingClientRect();
|
|
3462
|
-
left = left - (parentElRect?.left || 0);
|
|
3463
|
-
top = top - (parentElRect?.top || 0);
|
|
3464
|
-
}
|
|
3465
|
-
editorService?.paste({ left, top });
|
|
3466
|
-
}
|
|
3467
|
-
},
|
|
3468
|
-
{
|
|
3469
|
-
type: "divider",
|
|
3470
|
-
direction: "horizontal",
|
|
3471
|
-
display: () => !isPage.value
|
|
3472
|
-
},
|
|
3473
|
-
{
|
|
3474
|
-
type: "button",
|
|
3475
|
-
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
3476
|
-
icon: vue.markRaw(iconsVue.Top),
|
|
3477
|
-
display: () => !isPage.value,
|
|
3478
|
-
handler: () => {
|
|
3479
|
-
editorService?.moveLayer(1);
|
|
3480
|
-
}
|
|
3481
|
-
},
|
|
3482
|
-
{
|
|
3483
|
-
type: "button",
|
|
3484
|
-
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
3485
|
-
icon: vue.markRaw(iconsVue.Bottom),
|
|
3486
|
-
display: () => !isPage.value,
|
|
3487
|
-
handler: () => {
|
|
3488
|
-
editorService?.moveLayer(-1);
|
|
3489
|
-
}
|
|
3490
|
-
},
|
|
3491
|
-
{
|
|
3492
|
-
type: "button",
|
|
3493
|
-
text: "\u7F6E\u9876",
|
|
3494
|
-
display: () => !isPage.value,
|
|
3495
|
-
handler: () => {
|
|
3496
|
-
editorService?.moveLayer(LayerOffset.TOP);
|
|
3497
|
-
}
|
|
3498
|
-
},
|
|
3499
|
-
{
|
|
3500
|
-
type: "button",
|
|
3501
|
-
text: "\u7F6E\u5E95",
|
|
3502
|
-
display: () => !isPage.value,
|
|
3503
|
-
handler: () => {
|
|
3504
|
-
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
3505
|
-
}
|
|
3506
|
-
},
|
|
3507
|
-
{
|
|
3508
|
-
type: "divider",
|
|
3509
|
-
direction: "horizontal",
|
|
3510
|
-
display: () => !isPage.value
|
|
3511
|
-
},
|
|
3512
|
-
{
|
|
3513
|
-
type: "button",
|
|
3514
|
-
text: "\u5220\u9664",
|
|
3515
|
-
icon: iconsVue.Delete,
|
|
3516
|
-
display: () => !isPage.value,
|
|
3517
|
-
handler: () => {
|
|
3518
|
-
node.value && editorService?.remove(node.value);
|
|
3519
|
-
}
|
|
3520
|
-
},
|
|
3521
|
-
{
|
|
3522
|
-
type: "divider",
|
|
3523
|
-
direction: "horizontal"
|
|
3524
|
-
},
|
|
3525
|
-
{
|
|
3526
|
-
type: "button",
|
|
3527
|
-
text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
|
|
3528
|
-
handler: () => {
|
|
3529
|
-
editorService?.get("stage").clearGuides();
|
|
3530
|
-
}
|
|
3531
|
-
},
|
|
3532
|
-
...stageContentMenu
|
|
3533
|
-
]),
|
|
3534
|
-
show(e) {
|
|
3535
|
-
menu.value?.show(e);
|
|
3536
|
-
}
|
|
3762
|
+
const show = async (e) => {
|
|
3763
|
+
menu.value?.show(e);
|
|
3764
|
+
const data = await storageService.getItem(COPY_STORAGE_KEY);
|
|
3765
|
+
canPaste.value = data !== "undefined" && !!data;
|
|
3766
|
+
};
|
|
3767
|
+
expose({ show });
|
|
3768
|
+
return (_ctx, _cache) => {
|
|
3769
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$b, {
|
|
3770
|
+
"menu-data": menuData,
|
|
3771
|
+
ref_key: "menu",
|
|
3772
|
+
ref: menu
|
|
3773
|
+
}, null, 8, ["menu-data"]);
|
|
3537
3774
|
};
|
|
3538
3775
|
}
|
|
3539
3776
|
});
|
|
3540
|
-
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3541
|
-
const _component_content_menu = vue.resolveComponent("content-menu");
|
|
3542
|
-
return vue.openBlock(), vue.createBlock(_component_content_menu, {
|
|
3543
|
-
"menu-data": _ctx.menuData,
|
|
3544
|
-
ref: "menu"
|
|
3545
|
-
}, null, 8, ["menu-data"]);
|
|
3546
|
-
}
|
|
3547
|
-
var ViewerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
|
|
3548
3777
|
|
|
3549
|
-
const _sfc_main$2 = vue.defineComponent({
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
},
|
|
3555
|
-
setup() {
|
|
3778
|
+
const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
3779
|
+
__name: "Stage",
|
|
3780
|
+
setup(__props) {
|
|
3781
|
+
let stage = null;
|
|
3782
|
+
let runtime = null;
|
|
3556
3783
|
const services = vue.inject("services");
|
|
3557
3784
|
const stageOptions = vue.inject("stageOptions");
|
|
3558
3785
|
const stageWrap = vue.ref();
|
|
3559
3786
|
const stageContainer = vue.ref();
|
|
3560
3787
|
const menu = vue.ref();
|
|
3788
|
+
const isMultiSelect = vue.computed(() => services?.editorService.get("nodes")?.length > 1);
|
|
3561
3789
|
const stageRect = vue.computed(() => services?.uiService.get("stageRect"));
|
|
3562
3790
|
const uiSelectMode = vue.computed(() => services?.uiService.get("uiSelectMode"));
|
|
3563
3791
|
const root = vue.computed(() => services?.editorService.get("root"));
|
|
3564
3792
|
const page = vue.computed(() => services?.editorService.get("page"));
|
|
3565
3793
|
const zoom = vue.computed(() => services?.uiService.get("zoom") || 1);
|
|
3566
3794
|
const node = vue.computed(() => services?.editorService.get("node"));
|
|
3567
|
-
let stage = null;
|
|
3568
|
-
let runtime = null;
|
|
3569
3795
|
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
3570
3796
|
vue.watchEffect(() => {
|
|
3571
3797
|
if (stage)
|
|
@@ -3574,7 +3800,7 @@
|
|
|
3574
3800
|
return;
|
|
3575
3801
|
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
|
|
3576
3802
|
return;
|
|
3577
|
-
stage = new StageCore__default
|
|
3803
|
+
stage = new StageCore__default.default({
|
|
3578
3804
|
render: stageOptions.render,
|
|
3579
3805
|
runtimeUrl: stageOptions.runtimeUrl,
|
|
3580
3806
|
zoom: zoom.value,
|
|
@@ -3582,6 +3808,7 @@
|
|
|
3582
3808
|
isContainer: stageOptions.isContainer,
|
|
3583
3809
|
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
3584
3810
|
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
3811
|
+
containerHighlightType: stageOptions.containerHighlightType,
|
|
3585
3812
|
canSelect: (el, event, stop) => {
|
|
3586
3813
|
const elCanSelect = stageOptions.canSelect(el);
|
|
3587
3814
|
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
@@ -3605,12 +3832,17 @@
|
|
|
3605
3832
|
stage?.on("highlight", (el) => {
|
|
3606
3833
|
services?.editorService.highlight(el.id);
|
|
3607
3834
|
});
|
|
3835
|
+
stage?.on("multiSelect", (els) => {
|
|
3836
|
+
services?.editorService.multiSelect(els.map((el) => el.id));
|
|
3837
|
+
});
|
|
3608
3838
|
stage?.on("update", (ev) => {
|
|
3609
3839
|
if (ev.parentEl) {
|
|
3610
|
-
|
|
3840
|
+
for (const data of ev.data) {
|
|
3841
|
+
services?.editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
3842
|
+
}
|
|
3611
3843
|
return;
|
|
3612
3844
|
}
|
|
3613
|
-
services?.editorService.update({ id:
|
|
3845
|
+
services?.editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
3614
3846
|
});
|
|
3615
3847
|
stage?.on("sort", (ev) => {
|
|
3616
3848
|
services?.editorService.sort(ev.src, ev.dist);
|
|
@@ -3663,99 +3895,96 @@
|
|
|
3663
3895
|
resizeObserver.disconnect();
|
|
3664
3896
|
services?.editorService.set("stage", null);
|
|
3665
3897
|
});
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
e2.
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
const
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
}
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
top = e.clientY - containerRect.top + scrollTop;
|
|
3702
|
-
left = e.clientX - containerRect.left + scrollLeft;
|
|
3703
|
-
if (parentEl && doc) {
|
|
3704
|
-
const { left: parentLeft, top: parentTop } = StageCore.getOffset(parentEl);
|
|
3705
|
-
left = left - StageCore.calcValueByFontsize(doc, parentLeft);
|
|
3706
|
-
top = top - StageCore.calcValueByFontsize(doc, parentTop);
|
|
3707
|
-
}
|
|
3898
|
+
const contextmenuHandler = (e2) => {
|
|
3899
|
+
e2.preventDefault();
|
|
3900
|
+
menu.value?.show(e2);
|
|
3901
|
+
};
|
|
3902
|
+
const dragoverHandler = (e2) => {
|
|
3903
|
+
e2.preventDefault();
|
|
3904
|
+
if (e2.dataTransfer) {
|
|
3905
|
+
e2.dataTransfer.dropEffect = "move";
|
|
3906
|
+
}
|
|
3907
|
+
};
|
|
3908
|
+
const dropHandler = async (e) => {
|
|
3909
|
+
e.preventDefault();
|
|
3910
|
+
const doc = stage?.renderer.contentWindow?.document;
|
|
3911
|
+
const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
|
|
3912
|
+
let parent = page.value;
|
|
3913
|
+
if (parentEl) {
|
|
3914
|
+
parent = services?.editorService.getNodeById(parentEl.id, false);
|
|
3915
|
+
}
|
|
3916
|
+
if (e.dataTransfer && parent && stageContainer.value && stage) {
|
|
3917
|
+
const config = eval(`(${e.dataTransfer.getData("data")})`);
|
|
3918
|
+
const layout = await services?.editorService.getLayout(parent);
|
|
3919
|
+
const containerRect = stageContainer.value.getBoundingClientRect();
|
|
3920
|
+
const { scrollTop, scrollLeft } = stage.mask;
|
|
3921
|
+
const { style = {} } = config;
|
|
3922
|
+
let top = 0;
|
|
3923
|
+
let left = 0;
|
|
3924
|
+
let position = "relative";
|
|
3925
|
+
if (layout === Layout.ABSOLUTE) {
|
|
3926
|
+
position = "absolute";
|
|
3927
|
+
top = e.clientY - containerRect.top + scrollTop;
|
|
3928
|
+
left = e.clientX - containerRect.left + scrollLeft;
|
|
3929
|
+
if (parentEl && doc) {
|
|
3930
|
+
const { left: parentLeft, top: parentTop } = StageCore.getOffset(parentEl);
|
|
3931
|
+
left = left - StageCore.calcValueByFontsize(doc, parentLeft);
|
|
3932
|
+
top = top - StageCore.calcValueByFontsize(doc, parentTop);
|
|
3708
3933
|
}
|
|
3709
|
-
config.style = {
|
|
3710
|
-
...style,
|
|
3711
|
-
position,
|
|
3712
|
-
top,
|
|
3713
|
-
left
|
|
3714
|
-
};
|
|
3715
|
-
services?.editorService.add(config, parent);
|
|
3716
3934
|
}
|
|
3935
|
+
config.style = {
|
|
3936
|
+
...style,
|
|
3937
|
+
position,
|
|
3938
|
+
top,
|
|
3939
|
+
left
|
|
3940
|
+
};
|
|
3941
|
+
config.inputEvent = e;
|
|
3942
|
+
services?.editorService.add(config, parent);
|
|
3717
3943
|
}
|
|
3718
3944
|
};
|
|
3945
|
+
return (_ctx, _cache) => {
|
|
3946
|
+
return vue.openBlock(), vue.createBlock(ScrollViewer, {
|
|
3947
|
+
class: "m-editor-stage",
|
|
3948
|
+
ref_key: "stageWrap",
|
|
3949
|
+
ref: stageWrap,
|
|
3950
|
+
width: vue.unref(stageRect)?.width,
|
|
3951
|
+
height: vue.unref(stageRect)?.height,
|
|
3952
|
+
zoom: vue.unref(zoom)
|
|
3953
|
+
}, {
|
|
3954
|
+
default: vue.withCtx(() => [
|
|
3955
|
+
vue.createElementVNode("div", {
|
|
3956
|
+
class: "m-editor-stage-container",
|
|
3957
|
+
ref_key: "stageContainer",
|
|
3958
|
+
ref: stageContainer,
|
|
3959
|
+
style: vue.normalizeStyle(`transform: scale(${vue.unref(zoom)})`),
|
|
3960
|
+
onContextmenu: contextmenuHandler,
|
|
3961
|
+
onDrop: dropHandler,
|
|
3962
|
+
onDragover: dragoverHandler
|
|
3963
|
+
}, null, 36),
|
|
3964
|
+
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
3965
|
+
vue.createVNode(_sfc_main$3, {
|
|
3966
|
+
ref_key: "menu",
|
|
3967
|
+
ref: menu,
|
|
3968
|
+
"is-multi-select": vue.unref(isMultiSelect)
|
|
3969
|
+
}, null, 8, ["is-multi-select"])
|
|
3970
|
+
]))
|
|
3971
|
+
]),
|
|
3972
|
+
_: 1
|
|
3973
|
+
}, 8, ["width", "height", "zoom"]);
|
|
3974
|
+
};
|
|
3719
3975
|
}
|
|
3720
3976
|
});
|
|
3721
|
-
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3722
|
-
const _component_viewer_menu = vue.resolveComponent("viewer-menu");
|
|
3723
|
-
const _component_scroll_viewer = vue.resolveComponent("scroll-viewer");
|
|
3724
|
-
return vue.openBlock(), vue.createBlock(_component_scroll_viewer, {
|
|
3725
|
-
class: "m-editor-stage",
|
|
3726
|
-
ref: "stageWrap",
|
|
3727
|
-
width: _ctx.stageRect?.width,
|
|
3728
|
-
height: _ctx.stageRect?.height,
|
|
3729
|
-
zoom: _ctx.zoom
|
|
3730
|
-
}, {
|
|
3731
|
-
default: vue.withCtx(() => [
|
|
3732
|
-
vue.createElementVNode("div", {
|
|
3733
|
-
class: "m-editor-stage-container",
|
|
3734
|
-
ref: "stageContainer",
|
|
3735
|
-
style: vue.normalizeStyle(`transform: scale(${_ctx.zoom})`),
|
|
3736
|
-
onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
|
|
3737
|
-
onDrop: _cache[1] || (_cache[1] = (...args) => _ctx.dropHandler && _ctx.dropHandler(...args)),
|
|
3738
|
-
onDragover: _cache[2] || (_cache[2] = (...args) => _ctx.dragoverHandler && _ctx.dragoverHandler(...args))
|
|
3739
|
-
}, null, 36),
|
|
3740
|
-
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
3741
|
-
vue.createVNode(_component_viewer_menu, { ref: "menu" }, null, 512)
|
|
3742
|
-
]))
|
|
3743
|
-
]),
|
|
3744
|
-
_: 1
|
|
3745
|
-
}, 8, ["width", "height", "zoom"]);
|
|
3746
|
-
}
|
|
3747
|
-
var MagicStage = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
|
|
3748
3977
|
|
|
3749
3978
|
const _sfc_main$1 = vue.defineComponent({
|
|
3750
3979
|
name: "m-editor-workspace",
|
|
3751
3980
|
components: {
|
|
3752
|
-
PageBar,
|
|
3753
|
-
MagicStage
|
|
3981
|
+
PageBar: _sfc_main$5,
|
|
3982
|
+
MagicStage: _sfc_main$2
|
|
3754
3983
|
},
|
|
3755
3984
|
setup() {
|
|
3756
3985
|
const services = vue.inject("services");
|
|
3757
3986
|
const workspace = vue.ref();
|
|
3758
|
-
const
|
|
3987
|
+
const nodes = vue.computed(() => services?.editorService.get("nodes"));
|
|
3759
3988
|
let keycon;
|
|
3760
3989
|
const mouseenterHandler = () => {
|
|
3761
3990
|
workspace.value?.focus();
|
|
@@ -3766,31 +3995,31 @@
|
|
|
3766
3995
|
vue.onMounted(() => {
|
|
3767
3996
|
workspace.value?.addEventListener("mouseenter", mouseenterHandler);
|
|
3768
3997
|
workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
|
|
3769
|
-
keycon = new KeyController__default
|
|
3998
|
+
keycon = new KeyController__default.default(workspace.value);
|
|
3770
3999
|
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
3771
4000
|
const ctrl = isMac ? "meta" : "ctrl";
|
|
3772
4001
|
keycon.keyup("delete", (e) => {
|
|
3773
4002
|
e.inputEvent.preventDefault();
|
|
3774
|
-
if (!
|
|
4003
|
+
if (!nodes.value || utils.isPage(nodes.value[0]))
|
|
3775
4004
|
return;
|
|
3776
|
-
services?.editorService.remove(
|
|
4005
|
+
services?.editorService.remove(nodes.value);
|
|
3777
4006
|
}).keyup("backspace", (e) => {
|
|
3778
4007
|
e.inputEvent.preventDefault();
|
|
3779
|
-
if (!
|
|
4008
|
+
if (!nodes.value || utils.isPage(nodes.value[0]))
|
|
3780
4009
|
return;
|
|
3781
|
-
services?.editorService.remove(
|
|
4010
|
+
services?.editorService.remove(nodes.value);
|
|
3782
4011
|
}).keydown([ctrl, "c"], (e) => {
|
|
3783
4012
|
e.inputEvent.preventDefault();
|
|
3784
|
-
|
|
4013
|
+
nodes.value && services?.editorService.copy(nodes.value);
|
|
3785
4014
|
}).keydown([ctrl, "v"], (e) => {
|
|
3786
4015
|
e.inputEvent.preventDefault();
|
|
3787
|
-
|
|
4016
|
+
nodes.value && services?.editorService.paste({ offsetX: 10, offsetY: 10 });
|
|
3788
4017
|
}).keydown([ctrl, "x"], (e) => {
|
|
3789
4018
|
e.inputEvent.preventDefault();
|
|
3790
|
-
if (!
|
|
4019
|
+
if (!nodes.value || utils.isPage(nodes.value[0]))
|
|
3791
4020
|
return;
|
|
3792
|
-
services?.editorService.copy(
|
|
3793
|
-
services?.editorService.remove(
|
|
4021
|
+
services?.editorService.copy(nodes.value);
|
|
4022
|
+
services?.editorService.remove(nodes.value);
|
|
3794
4023
|
}).keydown([ctrl, "z"], (e) => {
|
|
3795
4024
|
e.inputEvent.preventDefault();
|
|
3796
4025
|
services?.editorService.undo();
|
|
@@ -3852,6 +4081,7 @@
|
|
|
3852
4081
|
};
|
|
3853
4082
|
}
|
|
3854
4083
|
});
|
|
4084
|
+
|
|
3855
4085
|
const _hoisted_1 = {
|
|
3856
4086
|
class: "m-editor-workspace",
|
|
3857
4087
|
tabindex: "1",
|
|
@@ -3861,9 +4091,11 @@
|
|
|
3861
4091
|
const _component_magic_stage = vue.resolveComponent("magic-stage");
|
|
3862
4092
|
const _component_page_bar = vue.resolveComponent("page-bar");
|
|
3863
4093
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
4094
|
+
vue.renderSlot(_ctx.$slots, "stage", {}, () => [
|
|
4095
|
+
(vue.openBlock(), vue.createBlock(_component_magic_stage, {
|
|
4096
|
+
key: _ctx.page?.id
|
|
4097
|
+
}))
|
|
4098
|
+
]),
|
|
3867
4099
|
vue.renderSlot(_ctx.$slots, "workspace-content"),
|
|
3868
4100
|
vue.createVNode(_component_page_bar, null, {
|
|
3869
4101
|
"page-bar-title": vue.withCtx(({ page }) => [
|
|
@@ -3876,14 +4108,14 @@
|
|
|
3876
4108
|
})
|
|
3877
4109
|
], 512);
|
|
3878
4110
|
}
|
|
3879
|
-
|
|
4111
|
+
const Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
3880
4112
|
|
|
3881
4113
|
class ComponentList extends BaseService {
|
|
4114
|
+
state = vue.reactive({
|
|
4115
|
+
list: []
|
|
4116
|
+
});
|
|
3882
4117
|
constructor() {
|
|
3883
4118
|
super([]);
|
|
3884
|
-
this.state = vue.reactive({
|
|
3885
|
-
list: []
|
|
3886
|
-
});
|
|
3887
4119
|
}
|
|
3888
4120
|
setList(componentGroupList) {
|
|
3889
4121
|
this.state.list = componentGroupList;
|
|
@@ -3892,7 +4124,7 @@
|
|
|
3892
4124
|
return this.state.list;
|
|
3893
4125
|
}
|
|
3894
4126
|
}
|
|
3895
|
-
|
|
4127
|
+
const componentListService = new ComponentList();
|
|
3896
4128
|
|
|
3897
4129
|
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
3898
4130
|
const MIN_LEFT_COLUMN_WIDTH = 45;
|
|
@@ -4004,13 +4236,15 @@
|
|
|
4004
4236
|
const { height, width } = stageContainerRect;
|
|
4005
4237
|
if (!width || !height)
|
|
4006
4238
|
return 1;
|
|
4007
|
-
|
|
4239
|
+
const stageWidth = stageRect.width + 30;
|
|
4240
|
+
const stageHeight = stageRect.height + 30;
|
|
4241
|
+
if (width > stageWidth && height > stageHeight) {
|
|
4008
4242
|
return 1;
|
|
4009
4243
|
}
|
|
4010
|
-
return Math.min((width -
|
|
4244
|
+
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
4011
4245
|
}
|
|
4012
4246
|
}
|
|
4013
|
-
|
|
4247
|
+
const uiService = new Ui();
|
|
4014
4248
|
|
|
4015
4249
|
const _sfc_main = vue.defineComponent({
|
|
4016
4250
|
name: "m-editor",
|
|
@@ -4085,6 +4319,10 @@
|
|
|
4085
4319
|
type: Number,
|
|
4086
4320
|
default: 800
|
|
4087
4321
|
},
|
|
4322
|
+
containerHighlightType: {
|
|
4323
|
+
type: String,
|
|
4324
|
+
default: StageCore.ContainerHighlightType.DEFAULT
|
|
4325
|
+
},
|
|
4088
4326
|
stageRect: {
|
|
4089
4327
|
type: [String, Object]
|
|
4090
4328
|
},
|
|
@@ -4140,7 +4378,8 @@
|
|
|
4140
4378
|
historyService,
|
|
4141
4379
|
propsService,
|
|
4142
4380
|
editorService,
|
|
4143
|
-
uiService
|
|
4381
|
+
uiService,
|
|
4382
|
+
storageService
|
|
4144
4383
|
};
|
|
4145
4384
|
vue.provide("services", services);
|
|
4146
4385
|
vue.provide("layerContentMenu", props.layerContentMenu);
|
|
@@ -4154,11 +4393,13 @@
|
|
|
4154
4393
|
updateDragEl: props.updateDragEl,
|
|
4155
4394
|
isContainer: props.isContainer,
|
|
4156
4395
|
containerHighlightClassName: props.containerHighlightClassName,
|
|
4157
|
-
containerHighlightDuration: props.containerHighlightDuration
|
|
4396
|
+
containerHighlightDuration: props.containerHighlightDuration,
|
|
4397
|
+
containerHighlightType: props.containerHighlightType
|
|
4158
4398
|
}));
|
|
4159
4399
|
return services;
|
|
4160
4400
|
}
|
|
4161
4401
|
});
|
|
4402
|
+
|
|
4162
4403
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4163
4404
|
const _component_nav_menu = vue.resolveComponent("nav-menu");
|
|
4164
4405
|
const _component_sidebar = vue.resolveComponent("sidebar");
|
|
@@ -4187,6 +4428,9 @@
|
|
|
4187
4428
|
workspace: vue.withCtx(() => [
|
|
4188
4429
|
vue.renderSlot(_ctx.$slots, "workspace", { editorService: _ctx.editorService }, () => [
|
|
4189
4430
|
vue.createVNode(_component_workspace, null, {
|
|
4431
|
+
stage: vue.withCtx(() => [
|
|
4432
|
+
vue.renderSlot(_ctx.$slots, "stage")
|
|
4433
|
+
]),
|
|
4190
4434
|
"workspace-content": vue.withCtx(() => [
|
|
4191
4435
|
vue.renderSlot(_ctx.$slots, "workspace-content", { editorService: _ctx.editorService })
|
|
4192
4436
|
]),
|
|
@@ -4219,18 +4463,18 @@
|
|
|
4219
4463
|
_: 3
|
|
4220
4464
|
}, 8, ["code-options"]);
|
|
4221
4465
|
}
|
|
4222
|
-
|
|
4466
|
+
const Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
4223
4467
|
|
|
4224
|
-
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}")();
|
|
4468
|
+
const index$1 = '';
|
|
4225
4469
|
|
|
4226
4470
|
const defaultInstallOpt = {};
|
|
4227
|
-
|
|
4471
|
+
const index = {
|
|
4228
4472
|
install: (app, opt) => {
|
|
4229
4473
|
const option = Object.assign(defaultInstallOpt, opt || {});
|
|
4230
4474
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
4231
4475
|
setConfig(option);
|
|
4232
4476
|
app.component(Editor.name, Editor);
|
|
4233
|
-
app.component(
|
|
4477
|
+
app.component("m-fields-ui-select", _sfc_main$l);
|
|
4234
4478
|
app.component(CodeLink.name, CodeLink);
|
|
4235
4479
|
app.component(Code.name, Code);
|
|
4236
4480
|
app.component(CodeEditor.name, CodeEditor);
|
|
@@ -4239,7 +4483,6 @@
|
|
|
4239
4483
|
|
|
4240
4484
|
exports.COPY_STORAGE_KEY = COPY_STORAGE_KEY;
|
|
4241
4485
|
exports.ComponentListPanel = ComponentListPanel;
|
|
4242
|
-
exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
|
|
4243
4486
|
exports.Fixed2Other = Fixed2Other;
|
|
4244
4487
|
exports.H_GUIDE_LINE_STORAGE_KEY = H_GUIDE_LINE_STORAGE_KEY;
|
|
4245
4488
|
exports.Keys = Keys;
|
|
@@ -4249,20 +4492,20 @@
|
|
|
4249
4492
|
exports.PropsPanel = PropsPanel;
|
|
4250
4493
|
exports.TMagicCodeEditor = CodeEditor;
|
|
4251
4494
|
exports.TMagicEditor = Editor;
|
|
4252
|
-
exports.ToolButton =
|
|
4495
|
+
exports.ToolButton = _sfc_main$f;
|
|
4253
4496
|
exports.V_GUIDE_LINE_STORAGE_KEY = V_GUIDE_LINE_STORAGE_KEY;
|
|
4254
4497
|
exports.change2Fixed = change2Fixed;
|
|
4255
4498
|
exports.debug = debug;
|
|
4256
|
-
exports
|
|
4499
|
+
exports.default = index;
|
|
4257
4500
|
exports.editorService = editorService;
|
|
4258
4501
|
exports.error = error;
|
|
4259
4502
|
exports.eventsService = eventsService;
|
|
4260
4503
|
exports.fillConfig = fillConfig;
|
|
4261
4504
|
exports.fixNodeLeft = fixNodeLeft;
|
|
4505
|
+
exports.fixNodePosition = fixNodePosition;
|
|
4262
4506
|
exports.generatePageName = generatePageName;
|
|
4263
4507
|
exports.generatePageNameByApp = generatePageNameByApp;
|
|
4264
4508
|
exports.getConfig = getConfig;
|
|
4265
|
-
exports.getDefaultPropsValue = getDefaultPropsValue;
|
|
4266
4509
|
exports.getGuideLineFromCache = getGuideLineFromCache;
|
|
4267
4510
|
exports.getInitPositionStyle = getInitPositionStyle;
|
|
4268
4511
|
exports.getNodeIndex = getNodeIndex;
|
|
@@ -4276,6 +4519,7 @@
|
|
|
4276
4519
|
exports.propsService = propsService;
|
|
4277
4520
|
exports.setConfig = setConfig;
|
|
4278
4521
|
exports.setLayout = setLayout;
|
|
4522
|
+
exports.storageService = storageService;
|
|
4279
4523
|
exports.uiService = uiService;
|
|
4280
4524
|
exports.warn = warn;
|
|
4281
4525
|
|