@tmagic/editor 1.1.0-beta.5 → 1.1.0-beta.8
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 +4 -0
- package/dist/{tmagic-editor.es.js → tmagic-editor.mjs} +1417 -1228
- package/dist/tmagic-editor.mjs.map +1 -0
- package/dist/tmagic-editor.umd.js +1433 -1242
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +21 -19
- package/src/Editor.vue +14 -12
- package/src/components/ContentMenu.vue +87 -99
- package/src/components/Icon.vue +1 -1
- package/src/components/ScrollViewer.vue +1 -1
- package/src/components/ToolButton.vue +150 -167
- package/src/fields/UISelect.vue +49 -70
- package/src/index.ts +2 -1
- package/src/layouts/AddPageBox.vue +2 -2
- package/src/layouts/Framework.vue +1 -1
- package/src/layouts/NavMenu.vue +2 -2
- package/src/layouts/PropsPanel.vue +1 -1
- package/src/layouts/Resizer.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +2 -2
- package/src/layouts/sidebar/LayerMenu.vue +2 -2
- package/src/layouts/sidebar/LayerPanel.vue +3 -3
- 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 +195 -222
- package/src/layouts/workspace/ViewerMenu.vue +140 -147
- package/src/layouts/workspace/Workspace.vue +11 -11
- package/src/services/BaseService.ts +1 -1
- package/src/services/componentList.ts +3 -3
- package/src/services/editor.ts +137 -139
- package/src/services/events.ts +1 -1
- package/src/services/history.ts +1 -1
- package/src/services/props.ts +18 -5
- package/src/services/storage.ts +133 -0
- package/src/services/ui.ts +2 -2
- package/src/theme/component-list-panel.scss +5 -0
- package/src/type.ts +22 -6
- package/src/utils/config.ts +1 -1
- package/src/utils/editor.ts +18 -11
- package/src/utils/operator.ts +163 -0
- package/src/utils/props.ts +2 -2
- package/src/utils/scroll-viewer.ts +1 -1
- package/tsconfig.build.json +13 -0
- package/{dist/types/src → types}/Editor.vue.d.ts +7 -8
- package/types/components/ContentMenu.vue.d.ts +116 -0
- package/types/components/Icon.vue.d.ts +13 -0
- package/types/components/ScrollViewer.vue.d.ts +22 -0
- package/types/components/ToolButton.vue.d.ts +109 -0
- package/types/fields/Code.vue.d.ts +23 -0
- package/{dist/types/src → types}/fields/CodeLink.vue.d.ts +4 -6
- package/types/fields/UISelect.vue.d.ts +83 -0
- package/{dist/types/src → types}/index.d.ts +4 -1
- package/types/layouts/AddPageBox.vue.d.ts +4 -0
- package/{dist/types/src → types}/layouts/CodeEditor.vue.d.ts +11 -13
- package/types/layouts/Framework.vue.d.ts +22 -0
- package/types/layouts/NavMenu.vue.d.ts +25 -0
- package/types/layouts/PropsPanel.vue.d.ts +245 -0
- package/types/layouts/Resizer.vue.d.ts +12 -0
- package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +14 -0
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +100 -0
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +1099 -0
- package/{dist/types/src → types}/layouts/sidebar/Sidebar.vue.d.ts +3 -5
- package/types/layouts/sidebar/TabPane.vue.d.ts +14 -0
- package/types/layouts/workspace/PageBar.vue.d.ts +54 -0
- package/types/layouts/workspace/PageBarScrollContainer.vue.d.ts +48 -0
- package/types/layouts/workspace/Stage.vue.d.ts +46 -0
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +88 -0
- package/types/layouts/workspace/Workspace.vue.d.ts +6 -0
- package/{dist/types/src → types}/services/BaseService.d.ts +0 -0
- package/types/services/componentList.d.ts +14 -0
- package/{dist/types/src → types}/services/editor.d.ts +22 -12
- package/{dist/types/src → types}/services/events.d.ts +0 -0
- package/{dist/types/src → types}/services/history.d.ts +0 -0
- package/{dist/types/src → types}/services/props.d.ts +6 -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 +15 -0
- 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 +27 -0
- package/{dist/types/src → types}/utils/polyfills.d.ts +0 -0
- package/{dist/types/src → types}/utils/props.d.ts +2 -2
- package/{dist/types/src → types}/utils/scroll-viewer.d.ts +0 -0
- package/{dist/types/src → types}/utils/undo-redo.d.ts +0 -0
- package/dist/tmagic-editor.es.js.map +0 -1
- package/dist/types/src/components/Icon.vue.d.ts +0 -14
- package/dist/types/src/components/ScrollViewer.vue.d.ts +0 -24
- package/dist/types/src/fields/Code.vue.d.ts +0 -25
- package/dist/types/src/layouts/AddPageBox.vue.d.ts +0 -5
- package/dist/types/src/layouts/Framework.vue.d.ts +0 -24
- package/dist/types/src/layouts/NavMenu.vue.d.ts +0 -27
- package/dist/types/src/layouts/PropsPanel.vue.d.ts +0 -13
- package/dist/types/src/layouts/Resizer.vue.d.ts +0 -14
- package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +0 -16
- package/dist/types/src/layouts/sidebar/TabPane.vue.d.ts +0 -16
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +0 -8
- package/dist/types/src/shims-vue.d.ts +0 -6
- package/dist/types/src/vite-env.d.ts +0 -1
- package/src/vite-env.d.ts +0 -1
|
@@ -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,89 @@
|
|
|
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.createVNode(_component_el_tooltip, { content: "\u6E05\u9664" }, {
|
|
221
|
+
default: vue.withCtx(() => [
|
|
222
|
+
vue.unref(val) ? (vue.openBlock(), vue.createBlock(_component_el_button, {
|
|
223
|
+
key: 0,
|
|
224
|
+
style: { "padding": "0" },
|
|
225
|
+
type: "danger",
|
|
226
|
+
icon: vue.unref(iconsVue.Close),
|
|
227
|
+
text: "",
|
|
228
|
+
onClick: vue.withModifiers(deleteHandler, ["stop"])
|
|
229
|
+
}, null, 8, ["icon", "onClick"])) : vue.createCommentVNode("", true)
|
|
230
|
+
]),
|
|
231
|
+
_: 1
|
|
232
|
+
}),
|
|
233
|
+
vue.createVNode(_component_el_tooltip, {
|
|
234
|
+
content: vue.unref(val) ? vue.unref(toName) + "_" + vue.unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
|
|
235
|
+
}, {
|
|
236
|
+
default: vue.withCtx(() => [
|
|
237
|
+
vue.createVNode(_component_el_button, {
|
|
238
|
+
text: "",
|
|
239
|
+
style: { "padding": "0", "margin": "0" }
|
|
240
|
+
}, {
|
|
241
|
+
default: vue.withCtx(() => [
|
|
242
|
+
vue.createTextVNode(vue.toDisplayString(vue.unref(val) ? vue.unref(toName) + "_" + vue.unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1)
|
|
243
|
+
]),
|
|
244
|
+
_: 1
|
|
245
|
+
})
|
|
246
|
+
]),
|
|
247
|
+
_: 1
|
|
248
|
+
}, 8, ["content"])
|
|
249
|
+
]));
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
const UISelect_vue_vue_type_style_index_0_lang = '';
|
|
267
255
|
|
|
268
256
|
const toString = (v, language) => {
|
|
269
257
|
let value = "";
|
|
270
258
|
if (typeof v !== "string") {
|
|
271
|
-
value = serialize__default
|
|
259
|
+
value = serialize__default.default(v, {
|
|
272
260
|
space: 2,
|
|
273
261
|
unsafe: true
|
|
274
262
|
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
@@ -280,7 +268,7 @@
|
|
|
280
268
|
}
|
|
281
269
|
return value;
|
|
282
270
|
};
|
|
283
|
-
const _sfc_main$
|
|
271
|
+
const _sfc_main$k = vue.defineComponent({
|
|
284
272
|
name: "magic-code-editor",
|
|
285
273
|
props: {
|
|
286
274
|
initValues: {
|
|
@@ -387,14 +375,15 @@
|
|
|
387
375
|
};
|
|
388
376
|
}
|
|
389
377
|
});
|
|
378
|
+
|
|
390
379
|
const _hoisted_1$c = {
|
|
391
380
|
ref: "codeEditor",
|
|
392
381
|
class: "magic-code-editor"
|
|
393
382
|
};
|
|
394
|
-
function _sfc_render$
|
|
383
|
+
function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
395
384
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, null, 512);
|
|
396
385
|
}
|
|
397
|
-
|
|
386
|
+
const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$e]]);
|
|
398
387
|
|
|
399
388
|
let $TMAGIC_EDITOR = {};
|
|
400
389
|
const setConfig = (option) => {
|
|
@@ -403,6 +392,9 @@
|
|
|
403
392
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
404
393
|
|
|
405
394
|
class UndoRedo {
|
|
395
|
+
elementList;
|
|
396
|
+
listCursor;
|
|
397
|
+
listMaxSize;
|
|
406
398
|
constructor(listMaxSize = 200) {
|
|
407
399
|
const minListMaxSize = 2;
|
|
408
400
|
this.elementList = [];
|
|
@@ -498,12 +490,12 @@
|
|
|
498
490
|
}
|
|
499
491
|
};
|
|
500
492
|
class BaseService extends events.EventEmitter {
|
|
493
|
+
pluginOptionsList = {};
|
|
494
|
+
middleware = {};
|
|
495
|
+
taskList = [];
|
|
496
|
+
doingTask = false;
|
|
501
497
|
constructor(methods = [], serialMethods = []) {
|
|
502
498
|
super();
|
|
503
|
-
this.pluginOptionsList = {};
|
|
504
|
-
this.middleware = {};
|
|
505
|
-
this.taskList = [];
|
|
506
|
-
this.doingTask = false;
|
|
507
499
|
methods.forEach((propertyName) => {
|
|
508
500
|
const scope = this;
|
|
509
501
|
const sourceMethod = scope[propertyName];
|
|
@@ -560,14 +552,14 @@
|
|
|
560
552
|
}
|
|
561
553
|
|
|
562
554
|
class History extends BaseService {
|
|
555
|
+
state = vue.reactive({
|
|
556
|
+
pageSteps: {},
|
|
557
|
+
pageId: void 0,
|
|
558
|
+
canRedo: false,
|
|
559
|
+
canUndo: false
|
|
560
|
+
});
|
|
563
561
|
constructor() {
|
|
564
562
|
super([]);
|
|
565
|
-
this.state = vue.reactive({
|
|
566
|
-
pageSteps: {},
|
|
567
|
-
pageId: void 0,
|
|
568
|
-
canRedo: false,
|
|
569
|
-
canUndo: false
|
|
570
|
-
});
|
|
571
563
|
this.on("change", this.setCanUndoRedo);
|
|
572
564
|
}
|
|
573
565
|
reset() {
|
|
@@ -636,117 +628,88 @@
|
|
|
636
628
|
this.state.canUndo = undoRedo?.canUndo() || false;
|
|
637
629
|
}
|
|
638
630
|
}
|
|
639
|
-
|
|
631
|
+
const historyService = new History();
|
|
640
632
|
|
|
641
|
-
|
|
633
|
+
var Protocol = /* @__PURE__ */ ((Protocol2) => {
|
|
634
|
+
Protocol2["OBJECT"] = "object";
|
|
635
|
+
Protocol2["JSON"] = "json";
|
|
636
|
+
Protocol2["STRING"] = "string";
|
|
637
|
+
Protocol2["NUMBER"] = "number";
|
|
638
|
+
Protocol2["BOOLEAN"] = "boolean";
|
|
639
|
+
return Protocol2;
|
|
640
|
+
})(Protocol || {});
|
|
641
|
+
class WebStorage extends BaseService {
|
|
642
|
+
storage = globalThis.localStorage;
|
|
643
|
+
namespace = "tmagic";
|
|
642
644
|
constructor() {
|
|
643
|
-
super([
|
|
644
|
-
"setPropsConfig",
|
|
645
|
-
"getPropsConfig",
|
|
646
|
-
"setPropsValue",
|
|
647
|
-
"getPropsValue",
|
|
648
|
-
"createId",
|
|
649
|
-
"setNewItemId",
|
|
650
|
-
"getDefaultPropsValue"
|
|
651
|
-
]);
|
|
652
|
-
this.state = vue.reactive({
|
|
653
|
-
propsConfigMap: {},
|
|
654
|
-
propsValueMap: {}
|
|
655
|
-
});
|
|
656
|
-
}
|
|
657
|
-
setPropsConfigs(configs) {
|
|
658
|
-
Object.keys(configs).forEach((type) => {
|
|
659
|
-
this.setPropsConfig(utils.toLine(type), configs[type]);
|
|
660
|
-
});
|
|
661
|
-
this.emit("props-configs-change");
|
|
662
|
-
}
|
|
663
|
-
setPropsConfig(type, config) {
|
|
664
|
-
this.state.propsConfigMap[type] = fillConfig(Array.isArray(config) ? config : [config]);
|
|
645
|
+
super(["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"]);
|
|
665
646
|
}
|
|
666
|
-
async
|
|
667
|
-
|
|
668
|
-
return await this.getPropsConfig("button");
|
|
669
|
-
}
|
|
670
|
-
return lodashEs.cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
|
|
647
|
+
async getStorage() {
|
|
648
|
+
return this.storage;
|
|
671
649
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
this.setPropsValue(utils.toLine(type), values[type]);
|
|
675
|
-
});
|
|
650
|
+
async getNamespace() {
|
|
651
|
+
return this.namespace;
|
|
676
652
|
}
|
|
677
|
-
|
|
678
|
-
|
|
653
|
+
async clear() {
|
|
654
|
+
const storage2 = await this.getStorage();
|
|
655
|
+
storage2.clear();
|
|
679
656
|
}
|
|
680
|
-
async
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
657
|
+
async getItem(key, options = {}) {
|
|
658
|
+
const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
659
|
+
const { protocol = options.protocol, item } = this.getValueAndProtocol(storage.getItem(`${options.namespace || namespace}:${key}`));
|
|
660
|
+
if (item === null)
|
|
661
|
+
return null;
|
|
662
|
+
switch (protocol) {
|
|
663
|
+
case "object" /* OBJECT */:
|
|
664
|
+
return eval(`(${item})`);
|
|
665
|
+
case "json" /* JSON */:
|
|
666
|
+
return JSON.parse(item);
|
|
667
|
+
case "number" /* NUMBER */:
|
|
668
|
+
return Number(item);
|
|
669
|
+
case "boolean" /* BOOLEAN */:
|
|
670
|
+
return Boolean(item);
|
|
671
|
+
default:
|
|
672
|
+
return item;
|
|
689
673
|
}
|
|
690
|
-
const [id, defaultPropsValue, data] = await Promise.all([
|
|
691
|
-
this.createId(type),
|
|
692
|
-
this.getDefaultPropsValue(type),
|
|
693
|
-
this.setNewItemId(lodashEs.cloneDeep({
|
|
694
|
-
type,
|
|
695
|
-
...defaultValue
|
|
696
|
-
}))
|
|
697
|
-
]);
|
|
698
|
-
return {
|
|
699
|
-
id,
|
|
700
|
-
...defaultPropsValue,
|
|
701
|
-
...lodashEs.mergeWith(lodashEs.cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
702
|
-
};
|
|
703
674
|
}
|
|
704
|
-
async
|
|
705
|
-
|
|
675
|
+
async key(index) {
|
|
676
|
+
const storage2 = await this.getStorage();
|
|
677
|
+
return storage2.key(index);
|
|
706
678
|
}
|
|
707
|
-
async
|
|
708
|
-
const
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
679
|
+
async removeItem(key2, options2 = {}) {
|
|
680
|
+
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
681
|
+
storage2.removeItem(`${options2.namespace || namespace2}:${key2}`);
|
|
682
|
+
}
|
|
683
|
+
async setItem(key2, value, options2 = {}) {
|
|
684
|
+
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
685
|
+
let item2 = value;
|
|
686
|
+
const protocol2 = options2.protocol ? `${options2.protocol}:` : "";
|
|
687
|
+
if (typeof value === "string" /* STRING */ || typeof value === "number" /* NUMBER */) {
|
|
688
|
+
item2 = `${protocol2}${value}`;
|
|
689
|
+
} else {
|
|
690
|
+
item2 = `${protocol2}${serialize__default.default(value)}`;
|
|
712
691
|
}
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
692
|
+
storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
|
|
693
|
+
}
|
|
694
|
+
getValueAndProtocol(value) {
|
|
695
|
+
let protocol2 = "";
|
|
696
|
+
if (value === null) {
|
|
697
|
+
return {
|
|
698
|
+
item: value,
|
|
699
|
+
protocol: protocol2
|
|
700
|
+
};
|
|
717
701
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
name: type,
|
|
726
|
-
items: []
|
|
727
|
-
} : {
|
|
728
|
-
type,
|
|
729
|
-
style: {},
|
|
730
|
-
name: type
|
|
702
|
+
const item2 = value.replace(new RegExp(`^(${Object.values(Protocol).join("|")})(:)(.+)`), (_$0, $1, _$2, $3) => {
|
|
703
|
+
protocol2 = $1;
|
|
704
|
+
return $3;
|
|
705
|
+
});
|
|
706
|
+
return {
|
|
707
|
+
protocol: protocol2,
|
|
708
|
+
item: item2
|
|
731
709
|
};
|
|
732
710
|
}
|
|
733
711
|
}
|
|
734
|
-
const
|
|
735
|
-
pageConfig.items?.forEach((config) => {
|
|
736
|
-
if (config.pop === oldId) {
|
|
737
|
-
config.pop = popId;
|
|
738
|
-
return;
|
|
739
|
-
}
|
|
740
|
-
if (config.popId === oldId) {
|
|
741
|
-
config.popId = popId;
|
|
742
|
-
return;
|
|
743
|
-
}
|
|
744
|
-
if (Array.isArray(config.items)) {
|
|
745
|
-
updatePopId(oldId, popId, config);
|
|
746
|
-
}
|
|
747
|
-
});
|
|
748
|
-
};
|
|
749
|
-
var propsService = new Props();
|
|
712
|
+
const storageService = new WebStorage();
|
|
750
713
|
|
|
751
714
|
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
752
715
|
LayerOffset2["TOP"] = "top";
|
|
@@ -798,10 +761,10 @@
|
|
|
798
761
|
top: 0,
|
|
799
762
|
left: 0
|
|
800
763
|
});
|
|
801
|
-
const getMiddleTop = (
|
|
802
|
-
let height = style
|
|
803
|
-
if (!stage || typeof style
|
|
804
|
-
return style
|
|
764
|
+
const getMiddleTop = (node, parentNode, stage) => {
|
|
765
|
+
let height = node.style?.height || 0;
|
|
766
|
+
if (!stage || typeof node.style?.top !== "undefined" || !parentNode.style)
|
|
767
|
+
return node.style?.top;
|
|
805
768
|
if (!utils.isNumber(height)) {
|
|
806
769
|
height = 0;
|
|
807
770
|
}
|
|
@@ -812,12 +775,11 @@
|
|
|
812
775
|
}
|
|
813
776
|
return (parentHeight - height) / 2;
|
|
814
777
|
};
|
|
815
|
-
const getInitPositionStyle = (style = {}, layout
|
|
778
|
+
const getInitPositionStyle = (style = {}, layout) => {
|
|
816
779
|
if (layout === Layout.ABSOLUTE) {
|
|
817
780
|
return {
|
|
818
781
|
...style,
|
|
819
|
-
position: "absolute"
|
|
820
|
-
top: getMiddleTop(style, parentNode, stage)
|
|
782
|
+
position: "absolute"
|
|
821
783
|
};
|
|
822
784
|
}
|
|
823
785
|
if (layout === Layout.RELATIVE) {
|
|
@@ -909,76 +871,308 @@
|
|
|
909
871
|
}
|
|
910
872
|
return config.style.left;
|
|
911
873
|
};
|
|
874
|
+
const fixNodePosition = (config, parent, stage) => {
|
|
875
|
+
if (config.style?.position !== "absolute") {
|
|
876
|
+
return config.style;
|
|
877
|
+
}
|
|
878
|
+
return {
|
|
879
|
+
...config.style || {},
|
|
880
|
+
top: getMiddleTop(config, parent, stage),
|
|
881
|
+
left: fixNodeLeft(config, parent, stage?.renderer.contentWindow?.document)
|
|
882
|
+
};
|
|
883
|
+
};
|
|
912
884
|
|
|
913
|
-
class
|
|
885
|
+
class Props extends BaseService {
|
|
886
|
+
state = vue.reactive({
|
|
887
|
+
propsConfigMap: {},
|
|
888
|
+
propsValueMap: {}
|
|
889
|
+
});
|
|
914
890
|
constructor() {
|
|
915
891
|
super([
|
|
916
|
-
"
|
|
917
|
-
"
|
|
918
|
-
"
|
|
919
|
-
"
|
|
920
|
-
"
|
|
921
|
-
"
|
|
922
|
-
"
|
|
923
|
-
|
|
924
|
-
"alignCenter",
|
|
925
|
-
"moveLayer",
|
|
926
|
-
"moveToContainer",
|
|
927
|
-
"move",
|
|
928
|
-
"undo",
|
|
929
|
-
"redo",
|
|
930
|
-
"highlight"
|
|
931
|
-
], ["select", "update", "moveLayer"]);
|
|
932
|
-
this.isHistoryStateChange = false;
|
|
933
|
-
this.state = vue.reactive({
|
|
934
|
-
root: null,
|
|
935
|
-
page: null,
|
|
936
|
-
parent: null,
|
|
937
|
-
node: null,
|
|
938
|
-
stage: null,
|
|
939
|
-
highlightNode: null,
|
|
940
|
-
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
941
|
-
pageLength: 0
|
|
942
|
-
});
|
|
892
|
+
"setPropsConfig",
|
|
893
|
+
"getPropsConfig",
|
|
894
|
+
"setPropsValue",
|
|
895
|
+
"getPropsValue",
|
|
896
|
+
"createId",
|
|
897
|
+
"setNewItemId",
|
|
898
|
+
"getDefaultPropsValue"
|
|
899
|
+
]);
|
|
943
900
|
}
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
}
|
|
901
|
+
setPropsConfigs(configs) {
|
|
902
|
+
Object.keys(configs).forEach((type) => {
|
|
903
|
+
this.setPropsConfig(utils.toLine(type), configs[type]);
|
|
904
|
+
});
|
|
905
|
+
this.emit("props-configs-change");
|
|
950
906
|
}
|
|
951
|
-
|
|
952
|
-
|
|
907
|
+
setPropsConfig(type, config) {
|
|
908
|
+
this.state.propsConfigMap[type] = fillConfig(Array.isArray(config) ? config : [config]);
|
|
953
909
|
}
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
root = vue.toRaw(root);
|
|
958
|
-
}
|
|
959
|
-
if (!root)
|
|
960
|
-
return {};
|
|
961
|
-
if (id === root.id) {
|
|
962
|
-
return { node: root };
|
|
910
|
+
async getPropsConfig(type) {
|
|
911
|
+
if (type === "area") {
|
|
912
|
+
return await this.getPropsConfig("button");
|
|
963
913
|
}
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
info.node = path[path.length - 1];
|
|
970
|
-
info.parent = path[path.length - 2];
|
|
971
|
-
path.forEach((item) => {
|
|
972
|
-
if (item.type === schema.NodeType.PAGE) {
|
|
973
|
-
info.page = item;
|
|
974
|
-
return;
|
|
975
|
-
}
|
|
914
|
+
return lodashEs.cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
|
|
915
|
+
}
|
|
916
|
+
setPropsValues(values) {
|
|
917
|
+
Object.keys(values).forEach((type) => {
|
|
918
|
+
this.setPropsValue(utils.toLine(type), values[type]);
|
|
976
919
|
});
|
|
977
|
-
return info;
|
|
978
920
|
}
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
921
|
+
setPropsValue(type, value) {
|
|
922
|
+
this.state.propsValueMap[type] = value;
|
|
923
|
+
}
|
|
924
|
+
async getPropsValue(type, { inputEvent, ...defaultValue } = {}) {
|
|
925
|
+
if (type === "area") {
|
|
926
|
+
const value = await this.getPropsValue("button");
|
|
927
|
+
value.className = "action-area";
|
|
928
|
+
value.text = "";
|
|
929
|
+
if (value.style) {
|
|
930
|
+
value.style.backgroundColor = "rgba(255, 255, 255, 0)";
|
|
931
|
+
}
|
|
932
|
+
return value;
|
|
933
|
+
}
|
|
934
|
+
const [id, defaultPropsValue, data] = await Promise.all([
|
|
935
|
+
this.createId(type),
|
|
936
|
+
this.getDefaultPropsValue(type),
|
|
937
|
+
this.setNewItemId(lodashEs.cloneDeep({
|
|
938
|
+
type,
|
|
939
|
+
...defaultValue
|
|
940
|
+
}))
|
|
941
|
+
]);
|
|
942
|
+
return {
|
|
943
|
+
id,
|
|
944
|
+
...defaultPropsValue,
|
|
945
|
+
...lodashEs.mergeWith({}, lodashEs.cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
guid(digit = 8) {
|
|
949
|
+
return "x".repeat(digit).replace(/[xy]/g, (c) => {
|
|
950
|
+
const r = Math.random() * 16 | 0;
|
|
951
|
+
const v = c == "x" ? r : r & 3 | 8;
|
|
952
|
+
return v.toString(16);
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
async createId(type) {
|
|
956
|
+
return `${type}_${this.guid()}`;
|
|
957
|
+
}
|
|
958
|
+
async setNewItemId(config, parent) {
|
|
959
|
+
const oldId = config.id;
|
|
960
|
+
config.id = await this.createId(config.type || "component");
|
|
961
|
+
if (utils.isPop(config) && parent?.type === schema.NodeType.PAGE) {
|
|
962
|
+
updatePopId(oldId, config.id, parent);
|
|
963
|
+
}
|
|
964
|
+
if (config.items && Array.isArray(config.items)) {
|
|
965
|
+
for (const item of config.items) {
|
|
966
|
+
await this.setNewItemId(item, config);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
return config;
|
|
970
|
+
}
|
|
971
|
+
async getDefaultPropsValue(type) {
|
|
972
|
+
return ["page", "container"].includes(type) ? {
|
|
973
|
+
type,
|
|
974
|
+
layout: "absolute",
|
|
975
|
+
style: {},
|
|
976
|
+
name: type,
|
|
977
|
+
items: []
|
|
978
|
+
} : {
|
|
979
|
+
type,
|
|
980
|
+
style: {},
|
|
981
|
+
name: type
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
const updatePopId = (oldId, popId, pageConfig) => {
|
|
986
|
+
pageConfig.items?.forEach((config) => {
|
|
987
|
+
if (config.pop === oldId) {
|
|
988
|
+
config.pop = popId;
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
if (config.popId === oldId) {
|
|
992
|
+
config.popId = popId;
|
|
993
|
+
return;
|
|
994
|
+
}
|
|
995
|
+
if (Array.isArray(config.items)) {
|
|
996
|
+
updatePopId(oldId, popId, config);
|
|
997
|
+
}
|
|
998
|
+
});
|
|
999
|
+
};
|
|
1000
|
+
const propsService = new Props();
|
|
1001
|
+
|
|
1002
|
+
const beforePaste = async (position, config) => {
|
|
1003
|
+
if (!config[0]?.style)
|
|
1004
|
+
return config;
|
|
1005
|
+
const curNode = editorService.get("node");
|
|
1006
|
+
const { left: referenceLeft, top: referenceTop } = config[0].style;
|
|
1007
|
+
const pasteConfigs = await Promise.all(config.map(async (configItem) => {
|
|
1008
|
+
const { offsetX = 0, offsetY = 0, ...positionClone } = position;
|
|
1009
|
+
let pastePosition = positionClone;
|
|
1010
|
+
if (!lodashEs.isEmpty(pastePosition) && curNode.items) {
|
|
1011
|
+
pastePosition = getPositionInContainer(pastePosition, curNode.id);
|
|
1012
|
+
}
|
|
1013
|
+
if (pastePosition.left && configItem.style?.left) {
|
|
1014
|
+
pastePosition.left = configItem.style.left - referenceLeft + pastePosition.left;
|
|
1015
|
+
}
|
|
1016
|
+
if (pastePosition.top && configItem.style?.top) {
|
|
1017
|
+
pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
|
|
1018
|
+
}
|
|
1019
|
+
const pasteConfig = await propsService.setNewItemId(configItem, editorService.get("root"));
|
|
1020
|
+
if (pasteConfig.style) {
|
|
1021
|
+
const { left, top } = pasteConfig.style;
|
|
1022
|
+
if (typeof left === "number" || !!left && !isNaN(Number(left))) {
|
|
1023
|
+
pasteConfig.style.left = Number(left) + offsetX;
|
|
1024
|
+
}
|
|
1025
|
+
if (typeof top === "number" || !!top && !isNaN(Number(top))) {
|
|
1026
|
+
pasteConfig.style.top = Number(top) + offsetY;
|
|
1027
|
+
}
|
|
1028
|
+
pasteConfig.style = {
|
|
1029
|
+
...pasteConfig.style,
|
|
1030
|
+
...pastePosition
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
if (utils.isPage(pasteConfig)) {
|
|
1034
|
+
pasteConfig.name = generatePageNameByApp(editorService.get("root"));
|
|
1035
|
+
}
|
|
1036
|
+
return pasteConfig;
|
|
1037
|
+
}));
|
|
1038
|
+
return pasteConfigs;
|
|
1039
|
+
};
|
|
1040
|
+
const getPositionInContainer = (position = {}, id) => {
|
|
1041
|
+
let { left = 0, top = 0 } = position;
|
|
1042
|
+
const parentEl = editorService.get("stage")?.renderer?.contentWindow?.document.getElementById(`${id}`);
|
|
1043
|
+
const parentElRect = parentEl?.getBoundingClientRect();
|
|
1044
|
+
left = left - (parentElRect?.left || 0);
|
|
1045
|
+
top = top - (parentElRect?.top || 0);
|
|
1046
|
+
return {
|
|
1047
|
+
left,
|
|
1048
|
+
top
|
|
1049
|
+
};
|
|
1050
|
+
};
|
|
1051
|
+
const beforeRemove = async (node) => {
|
|
1052
|
+
if (!node?.id)
|
|
1053
|
+
return;
|
|
1054
|
+
const stage = editorService.get("stage");
|
|
1055
|
+
const root = editorService.get("root");
|
|
1056
|
+
if (!root)
|
|
1057
|
+
throw new Error("\u6CA1\u6709root");
|
|
1058
|
+
const { parent, node: curNode } = editorService.getNodeInfo(node.id, false);
|
|
1059
|
+
if (!parent || !curNode)
|
|
1060
|
+
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1061
|
+
const index = getNodeIndex(curNode, parent);
|
|
1062
|
+
if (typeof index !== "number" || index === -1)
|
|
1063
|
+
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1064
|
+
parent.items?.splice(index, 1);
|
|
1065
|
+
stage?.remove({ id: node.id, root: lodashEs.cloneDeep(root) });
|
|
1066
|
+
if (node.type === schema.NodeType.PAGE) {
|
|
1067
|
+
editorService.state.pageLength -= 1;
|
|
1068
|
+
if (root.items[0]) {
|
|
1069
|
+
await editorService.select(root.items[0]);
|
|
1070
|
+
stage?.select(root.items[0].id);
|
|
1071
|
+
} else {
|
|
1072
|
+
editorService.set("node", null);
|
|
1073
|
+
editorService.set("nodes", []);
|
|
1074
|
+
editorService.set("parent", null);
|
|
1075
|
+
editorService.set("page", null);
|
|
1076
|
+
editorService.set("stage", null);
|
|
1077
|
+
editorService.set("highlightNode", null);
|
|
1078
|
+
editorService.resetModifiedNodeId();
|
|
1079
|
+
historyService.reset();
|
|
1080
|
+
editorService.emit("remove", node);
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1083
|
+
} else {
|
|
1084
|
+
await editorService.select(parent);
|
|
1085
|
+
stage?.select(parent.id);
|
|
1086
|
+
}
|
|
1087
|
+
return parent;
|
|
1088
|
+
};
|
|
1089
|
+
const getAddParent = (addNode) => {
|
|
1090
|
+
const curNode = editorService.get("node");
|
|
1091
|
+
let parentNode;
|
|
1092
|
+
if (!Array.isArray(addNode) && utils.isPage(addNode)) {
|
|
1093
|
+
parentNode = editorService.get("root");
|
|
1094
|
+
} else if (curNode.items) {
|
|
1095
|
+
parentNode = curNode;
|
|
1096
|
+
} else {
|
|
1097
|
+
parentNode = editorService.getParentById(curNode.id, false);
|
|
1098
|
+
}
|
|
1099
|
+
return parentNode;
|
|
1100
|
+
};
|
|
1101
|
+
|
|
1102
|
+
class Editor$1 extends BaseService {
|
|
1103
|
+
state = vue.reactive({
|
|
1104
|
+
root: null,
|
|
1105
|
+
page: null,
|
|
1106
|
+
parent: null,
|
|
1107
|
+
node: null,
|
|
1108
|
+
nodes: [],
|
|
1109
|
+
stage: null,
|
|
1110
|
+
highlightNode: null,
|
|
1111
|
+
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
1112
|
+
pageLength: 0
|
|
1113
|
+
});
|
|
1114
|
+
isHistoryStateChange = false;
|
|
1115
|
+
constructor() {
|
|
1116
|
+
super([
|
|
1117
|
+
"getLayout",
|
|
1118
|
+
"select",
|
|
1119
|
+
"doAdd",
|
|
1120
|
+
"add",
|
|
1121
|
+
"remove",
|
|
1122
|
+
"update",
|
|
1123
|
+
"sort",
|
|
1124
|
+
"copy",
|
|
1125
|
+
"paste",
|
|
1126
|
+
"alignCenter",
|
|
1127
|
+
"moveLayer",
|
|
1128
|
+
"moveToContainer",
|
|
1129
|
+
"move",
|
|
1130
|
+
"undo",
|
|
1131
|
+
"redo",
|
|
1132
|
+
"highlight"
|
|
1133
|
+
], ["select", "update", "moveLayer"]);
|
|
1134
|
+
}
|
|
1135
|
+
set(name, value) {
|
|
1136
|
+
this.state[name] = value;
|
|
1137
|
+
if (name === "nodes") {
|
|
1138
|
+
this.set("node", value[0]);
|
|
1139
|
+
}
|
|
1140
|
+
if (name === "root") {
|
|
1141
|
+
this.state.pageLength = value?.items?.length || 0;
|
|
1142
|
+
this.emit("root-change", value);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
get(name) {
|
|
1146
|
+
return this.state[name];
|
|
1147
|
+
}
|
|
1148
|
+
getNodeInfo(id, raw = true) {
|
|
1149
|
+
let root = this.get("root");
|
|
1150
|
+
if (raw) {
|
|
1151
|
+
root = vue.toRaw(root);
|
|
1152
|
+
}
|
|
1153
|
+
if (!root)
|
|
1154
|
+
return {};
|
|
1155
|
+
if (id === root.id) {
|
|
1156
|
+
return { node: root };
|
|
1157
|
+
}
|
|
1158
|
+
const path = utils.getNodePath(id, root.items);
|
|
1159
|
+
if (!path.length)
|
|
1160
|
+
return {};
|
|
1161
|
+
path.unshift(root);
|
|
1162
|
+
const info = {};
|
|
1163
|
+
info.node = path[path.length - 1];
|
|
1164
|
+
info.parent = path[path.length - 2];
|
|
1165
|
+
path.forEach((item) => {
|
|
1166
|
+
if (item.type === schema.NodeType.PAGE) {
|
|
1167
|
+
info.page = item;
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
});
|
|
1171
|
+
return info;
|
|
1172
|
+
}
|
|
1173
|
+
getNodeById(id, raw = true) {
|
|
1174
|
+
const { node } = this.getNodeInfo(id, raw);
|
|
1175
|
+
return node;
|
|
982
1176
|
}
|
|
983
1177
|
getParentById(id, raw = true) {
|
|
984
1178
|
if (!this.get("root"))
|
|
@@ -997,9 +1191,9 @@
|
|
|
997
1191
|
}
|
|
998
1192
|
return Layout.ABSOLUTE;
|
|
999
1193
|
}
|
|
1000
|
-
async select(
|
|
1001
|
-
const { node, page, parent } = this.selectedConfigExceptionHandler(
|
|
1002
|
-
this.set("
|
|
1194
|
+
async select(config) {
|
|
1195
|
+
const { node, page, parent } = this.selectedConfigExceptionHandler(config);
|
|
1196
|
+
this.set("nodes", [node]);
|
|
1003
1197
|
this.set("page", page || null);
|
|
1004
1198
|
this.set("parent", parent || null);
|
|
1005
1199
|
if (page) {
|
|
@@ -1039,107 +1233,103 @@
|
|
|
1039
1233
|
this.get("stage")?.select(nextPage.id);
|
|
1040
1234
|
return nextPage;
|
|
1041
1235
|
}
|
|
1042
|
-
highlight(
|
|
1043
|
-
const { node } = this.selectedConfigExceptionHandler(
|
|
1236
|
+
highlight(config) {
|
|
1237
|
+
const { node } = this.selectedConfigExceptionHandler(config);
|
|
1044
1238
|
const currentHighlightNode = this.get("highlightNode");
|
|
1045
1239
|
if (currentHighlightNode === node)
|
|
1046
1240
|
return;
|
|
1047
1241
|
this.set("highlightNode", node);
|
|
1048
1242
|
}
|
|
1049
|
-
|
|
1050
|
-
const
|
|
1243
|
+
multiSelect(ids) {
|
|
1244
|
+
const nodes = [];
|
|
1245
|
+
const idsUnique = lodashEs.uniq(ids);
|
|
1246
|
+
idsUnique.forEach((id) => {
|
|
1247
|
+
const { node } = this.getNodeInfo(id);
|
|
1248
|
+
if (!node)
|
|
1249
|
+
return;
|
|
1250
|
+
nodes.push(node);
|
|
1251
|
+
});
|
|
1252
|
+
this.set("nodes", nodes);
|
|
1253
|
+
}
|
|
1254
|
+
async doAdd(node, parent) {
|
|
1255
|
+
const root = this.get("root");
|
|
1051
1256
|
const curNode = this.get("node");
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
if (isPage2) {
|
|
1055
|
-
parentNode = this.get("root");
|
|
1056
|
-
} else if (parent && typeof parent !== "function") {
|
|
1057
|
-
parentNode = parent;
|
|
1058
|
-
} else if (curNode.items) {
|
|
1059
|
-
parentNode = curNode;
|
|
1060
|
-
} else {
|
|
1061
|
-
parentNode = this.getParentById(curNode.id, false);
|
|
1062
|
-
}
|
|
1063
|
-
if (!parentNode)
|
|
1064
|
-
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1065
|
-
const layout = await this.getLayout(vue.toRaw(parentNode), addNode);
|
|
1066
|
-
const newNode = { ...vue.toRaw(await propsService.getPropsValue(type, config2)) };
|
|
1067
|
-
newNode.style = getInitPositionStyle(newNode.style, layout, parentNode, this.get("stage"));
|
|
1068
|
-
if ((parentNode?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && newNode.type !== schema.NodeType.PAGE) {
|
|
1257
|
+
const stage = this.get("stage");
|
|
1258
|
+
if ((parent?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && node.type !== schema.NodeType.PAGE) {
|
|
1069
1259
|
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
1070
1260
|
}
|
|
1071
|
-
|
|
1261
|
+
const layout = await this.getLayout(vue.toRaw(parent), node);
|
|
1262
|
+
node.style = getInitPositionStyle(node.style, layout);
|
|
1263
|
+
await stage?.add({ config: lodashEs.cloneDeep(node), parent: lodashEs.cloneDeep(parent), root: lodashEs.cloneDeep(root) });
|
|
1264
|
+
node.style = fixNodePosition(node, parent, stage);
|
|
1265
|
+
await stage?.update({ config: lodashEs.cloneDeep(node), root: lodashEs.cloneDeep(root) });
|
|
1266
|
+
parent?.items?.push(node);
|
|
1267
|
+
this.addModifiedNodeId(node.id);
|
|
1268
|
+
return node;
|
|
1269
|
+
}
|
|
1270
|
+
async add(addNode, parent) {
|
|
1072
1271
|
const stage = this.get("stage");
|
|
1073
|
-
const
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
await this.select(newNode);
|
|
1083
|
-
this.addModifiedNodeId(newNode.id);
|
|
1084
|
-
if (!isPage2) {
|
|
1085
|
-
this.pushHistoryState();
|
|
1086
|
-
}
|
|
1087
|
-
if (isPage2) {
|
|
1088
|
-
this.state.pageLength += 1;
|
|
1272
|
+
const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(addNode);
|
|
1273
|
+
if (!parentNode)
|
|
1274
|
+
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1275
|
+
const addNodes = [];
|
|
1276
|
+
if (!Array.isArray(addNode)) {
|
|
1277
|
+
const { type, inputEvent, ...config } = addNode;
|
|
1278
|
+
if (!type)
|
|
1279
|
+
throw new Error("\u7EC4\u4EF6\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A");
|
|
1280
|
+
addNodes.push({ ...vue.toRaw(await propsService.getPropsValue(type, config)) });
|
|
1089
1281
|
} else {
|
|
1090
|
-
|
|
1282
|
+
addNodes.push(...addNode);
|
|
1091
1283
|
}
|
|
1092
|
-
this.
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
const { parent, node: curNode } = this.getNodeInfo(node.id, false);
|
|
1102
|
-
if (!parent || !curNode)
|
|
1103
|
-
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1104
|
-
const index = getNodeIndex(curNode, parent);
|
|
1105
|
-
if (typeof index !== "number" || index === -1)
|
|
1106
|
-
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1107
|
-
parent.items?.splice(index, 1);
|
|
1108
|
-
const stage = this.get("stage");
|
|
1109
|
-
stage?.remove({ id: node.id, root: lodashEs.cloneDeep(this.get("root")) });
|
|
1110
|
-
if (node.type === schema.NodeType.PAGE) {
|
|
1111
|
-
this.state.pageLength -= 1;
|
|
1112
|
-
if (root.items[0]) {
|
|
1113
|
-
await this.select(root.items[0]);
|
|
1114
|
-
stage?.select(root.items[0].id);
|
|
1284
|
+
const newNodes = await Promise.all(addNodes.map((node) => this.doAdd(node, parentNode)));
|
|
1285
|
+
if (newNodes.length > 1) {
|
|
1286
|
+
const newNodeIds = newNodes.map((node) => node.id);
|
|
1287
|
+
stage?.multiSelect(newNodeIds);
|
|
1288
|
+
await this.multiSelect(newNodeIds);
|
|
1289
|
+
} else {
|
|
1290
|
+
await this.select(newNodes[0]);
|
|
1291
|
+
if (utils.isPage(newNodes[0])) {
|
|
1292
|
+
this.state.pageLength += 1;
|
|
1115
1293
|
} else {
|
|
1116
|
-
|
|
1117
|
-
this.set("parent", null);
|
|
1118
|
-
this.set("page", null);
|
|
1119
|
-
this.set("stage", null);
|
|
1120
|
-
this.set("highlightNode", null);
|
|
1121
|
-
this.resetModifiedNodeId();
|
|
1122
|
-
historyService.reset();
|
|
1123
|
-
this.emit("remove", node);
|
|
1124
|
-
return node;
|
|
1294
|
+
stage?.select(newNodes[0].id);
|
|
1125
1295
|
}
|
|
1126
|
-
} else {
|
|
1127
|
-
await this.select(parent);
|
|
1128
|
-
stage?.select(parent.id);
|
|
1129
1296
|
}
|
|
1130
|
-
this.
|
|
1297
|
+
this.pushHistoryState();
|
|
1298
|
+
this.emit("add", newNodes);
|
|
1299
|
+
return newNodes.length > 1 ? newNodes[0] : newNodes;
|
|
1300
|
+
}
|
|
1301
|
+
async remove(nodeOrNodeList) {
|
|
1302
|
+
if (Array.isArray(nodeOrNodeList)) {
|
|
1303
|
+
const nodes = nodeOrNodeList;
|
|
1304
|
+
return this.multiRemove(nodes);
|
|
1305
|
+
}
|
|
1306
|
+
const node = nodeOrNodeList;
|
|
1307
|
+
const removeParent = await beforeRemove(node);
|
|
1308
|
+
if (!removeParent)
|
|
1309
|
+
return node;
|
|
1310
|
+
this.addModifiedNodeId(removeParent.id);
|
|
1131
1311
|
this.pushHistoryState();
|
|
1132
1312
|
this.emit("remove", node);
|
|
1133
1313
|
return node;
|
|
1134
1314
|
}
|
|
1135
|
-
async
|
|
1136
|
-
|
|
1315
|
+
async multiRemove(nodes) {
|
|
1316
|
+
await Promise.all(nodes.map(async (removeNode) => {
|
|
1317
|
+
await beforeRemove(removeNode);
|
|
1318
|
+
}));
|
|
1319
|
+
const nodeIds = nodes.map((node) => node.id);
|
|
1320
|
+
this.addModifiedNodeId(nodeIds.join("-"));
|
|
1321
|
+
this.pushHistoryState();
|
|
1322
|
+
this.emit("multiRemove", nodes);
|
|
1323
|
+
return nodes;
|
|
1324
|
+
}
|
|
1325
|
+
async update(config) {
|
|
1326
|
+
if (!config?.id)
|
|
1137
1327
|
throw new Error("\u6CA1\u6709\u914D\u7F6E\u6216\u8005\u914D\u7F6E\u7F3A\u5C11id\u503C");
|
|
1138
|
-
const info = this.getNodeInfo(
|
|
1328
|
+
const info = this.getNodeInfo(config.id, false);
|
|
1139
1329
|
if (!info.node)
|
|
1140
|
-
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${
|
|
1330
|
+
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config.id}\u7684\u8282\u70B9`);
|
|
1141
1331
|
const node = lodashEs.cloneDeep(vue.toRaw(info.node));
|
|
1142
|
-
let newConfig = await this.toggleFixedPosition(vue.toRaw(
|
|
1332
|
+
let newConfig = await this.toggleFixedPosition(vue.toRaw(config), node, this.get("root"));
|
|
1143
1333
|
newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), newConfig, (objValue, srcValue) => {
|
|
1144
1334
|
if (Array.isArray(srcValue)) {
|
|
1145
1335
|
return srcValue;
|
|
@@ -1164,9 +1354,10 @@
|
|
|
1164
1354
|
newConfig = setLayout(newConfig, newLayout);
|
|
1165
1355
|
}
|
|
1166
1356
|
parentNodeItems[index] = newConfig;
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1357
|
+
const nodes = this.get("nodes");
|
|
1358
|
+
const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
|
|
1359
|
+
nodes.splice(targetIndex, 1, newConfig);
|
|
1360
|
+
this.set("nodes", nodes);
|
|
1170
1361
|
this.get("stage")?.update({ config: lodashEs.cloneDeep(newConfig), root: lodashEs.cloneDeep(this.get("root")) });
|
|
1171
1362
|
if (newConfig.type === schema.NodeType.PAGE) {
|
|
1172
1363
|
this.set("page", newConfig);
|
|
@@ -1190,34 +1381,19 @@
|
|
|
1190
1381
|
this.addModifiedNodeId(parent.id);
|
|
1191
1382
|
this.pushHistoryState();
|
|
1192
1383
|
}
|
|
1193
|
-
async copy(
|
|
1194
|
-
|
|
1384
|
+
async copy(config) {
|
|
1385
|
+
await storageService.setItem(COPY_STORAGE_KEY, Array.isArray(config) ? config : [config], {
|
|
1386
|
+
protocol: Protocol.OBJECT
|
|
1387
|
+
});
|
|
1195
1388
|
}
|
|
1196
1389
|
async paste(position = {}) {
|
|
1197
|
-
const
|
|
1198
|
-
|
|
1199
|
-
if (!configStr) {
|
|
1200
|
-
return;
|
|
1201
|
-
}
|
|
1202
|
-
try {
|
|
1203
|
-
eval(`config = ${configStr}`);
|
|
1204
|
-
} catch (e) {
|
|
1205
|
-
console.error(e);
|
|
1390
|
+
const config = await storageService.getItem(COPY_STORAGE_KEY);
|
|
1391
|
+
if (!Array.isArray(config))
|
|
1206
1392
|
return;
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
if (config.style) {
|
|
1210
|
-
config.style = {
|
|
1211
|
-
...config.style,
|
|
1212
|
-
...position
|
|
1213
|
-
};
|
|
1214
|
-
}
|
|
1215
|
-
if (utils.isPage(config)) {
|
|
1216
|
-
config.name = generatePageNameByApp(this.get("root"));
|
|
1217
|
-
}
|
|
1218
|
-
return await this.add(config);
|
|
1393
|
+
const pasteConfigs = await beforePaste(position, config);
|
|
1394
|
+
return this.add(pasteConfigs);
|
|
1219
1395
|
}
|
|
1220
|
-
async alignCenter(
|
|
1396
|
+
async alignCenter(config) {
|
|
1221
1397
|
const parent = this.get("parent");
|
|
1222
1398
|
const node = this.get("node");
|
|
1223
1399
|
const layout = await this.getLayout(vue.toRaw(parent), vue.toRaw(node));
|
|
@@ -1242,9 +1418,9 @@
|
|
|
1242
1418
|
config: lodashEs.cloneDeep(vue.toRaw(node)),
|
|
1243
1419
|
root: lodashEs.cloneDeep(this.get("root"))
|
|
1244
1420
|
});
|
|
1245
|
-
this.addModifiedNodeId(
|
|
1421
|
+
this.addModifiedNodeId(config.id);
|
|
1246
1422
|
this.pushHistoryState();
|
|
1247
|
-
return
|
|
1423
|
+
return config;
|
|
1248
1424
|
}
|
|
1249
1425
|
async moveLayer(offset) {
|
|
1250
1426
|
const parent = this.get("parent");
|
|
@@ -1263,8 +1439,8 @@
|
|
|
1263
1439
|
root: lodashEs.cloneDeep(this.get("root"))
|
|
1264
1440
|
});
|
|
1265
1441
|
}
|
|
1266
|
-
async moveToContainer(
|
|
1267
|
-
const { node, parent } = this.getNodeInfo(
|
|
1442
|
+
async moveToContainer(config, targetId) {
|
|
1443
|
+
const { node, parent } = this.getNodeInfo(config.id, false);
|
|
1268
1444
|
const target = this.getNodeById(targetId, false);
|
|
1269
1445
|
const stage = this.get("stage");
|
|
1270
1446
|
if (node && parent && stage) {
|
|
@@ -1273,12 +1449,12 @@
|
|
|
1273
1449
|
parent.items?.splice(index, 1);
|
|
1274
1450
|
await stage.remove({ id: node.id, root });
|
|
1275
1451
|
const layout = await this.getLayout(target);
|
|
1276
|
-
const newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node),
|
|
1452
|
+
const newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), config, (objValue, srcValue) => {
|
|
1277
1453
|
if (Array.isArray(srcValue)) {
|
|
1278
1454
|
return srcValue;
|
|
1279
1455
|
}
|
|
1280
1456
|
});
|
|
1281
|
-
newConfig.style = getInitPositionStyle(newConfig.style, layout
|
|
1457
|
+
newConfig.style = getInitPositionStyle(newConfig.style, layout);
|
|
1282
1458
|
target.items.push(newConfig);
|
|
1283
1459
|
await stage.select(targetId);
|
|
1284
1460
|
await stage.update({ config: lodashEs.cloneDeep(target), root });
|
|
@@ -1304,7 +1480,7 @@
|
|
|
1304
1480
|
const node = vue.toRaw(this.get("node"));
|
|
1305
1481
|
if (!node || utils.isPage(node))
|
|
1306
1482
|
return;
|
|
1307
|
-
const { style, id } = node;
|
|
1483
|
+
const { style, id, type } = node;
|
|
1308
1484
|
if (!style || style.position !== "absolute")
|
|
1309
1485
|
return;
|
|
1310
1486
|
if (top && !utils.isNumber(style.top))
|
|
@@ -1313,6 +1489,7 @@
|
|
|
1313
1489
|
return;
|
|
1314
1490
|
this.update({
|
|
1315
1491
|
id,
|
|
1492
|
+
type,
|
|
1316
1493
|
style: {
|
|
1317
1494
|
...style,
|
|
1318
1495
|
left: Number(style.left) + left,
|
|
@@ -1324,6 +1501,7 @@
|
|
|
1324
1501
|
this.removeAllListeners();
|
|
1325
1502
|
this.set("root", null);
|
|
1326
1503
|
this.set("node", null);
|
|
1504
|
+
this.set("nodes", []);
|
|
1327
1505
|
this.set("page", null);
|
|
1328
1506
|
this.set("parent", null);
|
|
1329
1507
|
}
|
|
@@ -1370,12 +1548,12 @@
|
|
|
1370
1548
|
}
|
|
1371
1549
|
return newConfig;
|
|
1372
1550
|
}
|
|
1373
|
-
selectedConfigExceptionHandler(
|
|
1551
|
+
selectedConfigExceptionHandler(config) {
|
|
1374
1552
|
let id;
|
|
1375
|
-
if (typeof
|
|
1376
|
-
id =
|
|
1553
|
+
if (typeof config === "string" || typeof config === "number") {
|
|
1554
|
+
id = config;
|
|
1377
1555
|
} else {
|
|
1378
|
-
id =
|
|
1556
|
+
id = config.id;
|
|
1379
1557
|
}
|
|
1380
1558
|
if (!id) {
|
|
1381
1559
|
throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
|
|
@@ -1393,7 +1571,7 @@
|
|
|
1393
1571
|
};
|
|
1394
1572
|
}
|
|
1395
1573
|
}
|
|
1396
|
-
|
|
1574
|
+
const editorService = new Editor$1();
|
|
1397
1575
|
|
|
1398
1576
|
const eventMap = vue.reactive({});
|
|
1399
1577
|
const methodMap = vue.reactive({});
|
|
@@ -1437,7 +1615,7 @@
|
|
|
1437
1615
|
return lodashEs.cloneDeep(methodMap[type] || core.DEFAULT_METHODS);
|
|
1438
1616
|
}
|
|
1439
1617
|
}
|
|
1440
|
-
|
|
1618
|
+
const eventsService = new Events();
|
|
1441
1619
|
|
|
1442
1620
|
const fillConfig = (config = []) => [
|
|
1443
1621
|
{
|
|
@@ -1645,17 +1823,32 @@
|
|
|
1645
1823
|
const DEFAULT_CONFIG = fillConfig([]);
|
|
1646
1824
|
|
|
1647
1825
|
const log = (...args) => {
|
|
1826
|
+
if (process.env.NODE_ENV === "development") {
|
|
1827
|
+
console.log("magic editor: ", ...args);
|
|
1828
|
+
}
|
|
1648
1829
|
};
|
|
1649
1830
|
const info = (...args) => {
|
|
1831
|
+
if (process.env.NODE_ENV === "development") {
|
|
1832
|
+
console.info("magic editor: ", ...args);
|
|
1833
|
+
}
|
|
1650
1834
|
};
|
|
1651
1835
|
const warn = (...args) => {
|
|
1836
|
+
if (process.env.NODE_ENV === "development") {
|
|
1837
|
+
console.warn("magic editor: ", ...args);
|
|
1838
|
+
}
|
|
1652
1839
|
};
|
|
1653
1840
|
const debug = (...args) => {
|
|
1841
|
+
if (process.env.NODE_ENV === "development") {
|
|
1842
|
+
console.debug("magic editor: ", ...args);
|
|
1843
|
+
}
|
|
1654
1844
|
};
|
|
1655
1845
|
const error = (...args) => {
|
|
1846
|
+
if (process.env.NODE_ENV === "development") {
|
|
1847
|
+
console.error("magic editor: ", ...args);
|
|
1848
|
+
}
|
|
1656
1849
|
};
|
|
1657
1850
|
|
|
1658
|
-
const _sfc_main$
|
|
1851
|
+
const _sfc_main$j = vue.defineComponent({
|
|
1659
1852
|
components: { Plus: iconsVue.Plus },
|
|
1660
1853
|
setup() {
|
|
1661
1854
|
const services = vue.inject("services");
|
|
@@ -1672,10 +1865,11 @@
|
|
|
1672
1865
|
};
|
|
1673
1866
|
}
|
|
1674
1867
|
});
|
|
1868
|
+
|
|
1675
1869
|
const _hoisted_1$b = { class: "m-editor-empty-panel" };
|
|
1676
1870
|
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
1677
|
-
const _hoisted_3$
|
|
1678
|
-
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) {
|
|
1679
1873
|
const _component_plus = vue.resolveComponent("plus");
|
|
1680
1874
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
1681
1875
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
|
|
@@ -1692,14 +1886,14 @@
|
|
|
1692
1886
|
_: 1
|
|
1693
1887
|
})
|
|
1694
1888
|
]),
|
|
1695
|
-
_hoisted_3$
|
|
1889
|
+
_hoisted_3$1
|
|
1696
1890
|
])
|
|
1697
1891
|
])
|
|
1698
1892
|
]);
|
|
1699
1893
|
}
|
|
1700
|
-
|
|
1894
|
+
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$d]]);
|
|
1701
1895
|
|
|
1702
|
-
const _sfc_main$
|
|
1896
|
+
const _sfc_main$i = vue.defineComponent({
|
|
1703
1897
|
name: "m-editor-resize",
|
|
1704
1898
|
props: {
|
|
1705
1899
|
type: {
|
|
@@ -1713,7 +1907,7 @@
|
|
|
1713
1907
|
vue.onMounted(() => {
|
|
1714
1908
|
if (!target.value)
|
|
1715
1909
|
return;
|
|
1716
|
-
getso = new Gesto__default
|
|
1910
|
+
getso = new Gesto__default.default(target.value, {
|
|
1717
1911
|
container: window,
|
|
1718
1912
|
pinchOutside: true
|
|
1719
1913
|
}).on("drag", (e) => {
|
|
@@ -1741,18 +1935,19 @@
|
|
|
1741
1935
|
};
|
|
1742
1936
|
}
|
|
1743
1937
|
});
|
|
1938
|
+
|
|
1744
1939
|
const _hoisted_1$a = {
|
|
1745
1940
|
ref: "target",
|
|
1746
1941
|
class: "m-editor-resizer"
|
|
1747
1942
|
};
|
|
1748
|
-
function _sfc_render$
|
|
1943
|
+
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1749
1944
|
return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$a, [
|
|
1750
1945
|
vue.renderSlot(_ctx.$slots, "default")
|
|
1751
1946
|
], 512);
|
|
1752
1947
|
}
|
|
1753
|
-
|
|
1948
|
+
const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$c]]);
|
|
1754
1949
|
|
|
1755
|
-
const _sfc_main$
|
|
1950
|
+
const _sfc_main$h = vue.defineComponent({
|
|
1756
1951
|
components: {
|
|
1757
1952
|
AddPageBox,
|
|
1758
1953
|
Resizer
|
|
@@ -1781,12 +1976,13 @@
|
|
|
1781
1976
|
};
|
|
1782
1977
|
}
|
|
1783
1978
|
});
|
|
1979
|
+
|
|
1784
1980
|
const _hoisted_1$9 = { class: "m-editor" };
|
|
1785
1981
|
const _hoisted_2$3 = {
|
|
1786
1982
|
key: 1,
|
|
1787
1983
|
class: "m-editor-content"
|
|
1788
1984
|
};
|
|
1789
|
-
function _sfc_render$
|
|
1985
|
+
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1790
1986
|
const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
|
|
1791
1987
|
const _component_resizer = vue.resolveComponent("resizer");
|
|
1792
1988
|
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
|
|
@@ -1832,9 +2028,9 @@
|
|
|
1832
2028
|
]))
|
|
1833
2029
|
]);
|
|
1834
2030
|
}
|
|
1835
|
-
|
|
2031
|
+
const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$b]]);
|
|
1836
2032
|
|
|
1837
|
-
const _sfc_main$
|
|
2033
|
+
const _sfc_main$g = vue.defineComponent({
|
|
1838
2034
|
name: "m-icon",
|
|
1839
2035
|
components: { Edit: iconsVue.Edit },
|
|
1840
2036
|
props: {
|
|
@@ -1848,8 +2044,9 @@
|
|
|
1848
2044
|
};
|
|
1849
2045
|
}
|
|
1850
2046
|
});
|
|
2047
|
+
|
|
1851
2048
|
const _hoisted_1$8 = ["src"];
|
|
1852
|
-
function _sfc_render$
|
|
2049
|
+
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1853
2050
|
const _component_edit = vue.resolveComponent("edit");
|
|
1854
2051
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
1855
2052
|
return !_ctx.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
|
|
@@ -1857,10 +2054,12 @@
|
|
|
1857
2054
|
vue.createVNode(_component_edit)
|
|
1858
2055
|
]),
|
|
1859
2056
|
_: 1
|
|
1860
|
-
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
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", {
|
|
1864
2063
|
key: 2,
|
|
1865
2064
|
class: vue.normalizeClass(_ctx.icon)
|
|
1866
2065
|
}, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
|
|
@@ -1870,10 +2069,19 @@
|
|
|
1870
2069
|
_: 1
|
|
1871
2070
|
}));
|
|
1872
2071
|
}
|
|
1873
|
-
|
|
2072
|
+
const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
|
|
1874
2073
|
|
|
1875
|
-
const
|
|
1876
|
-
|
|
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",
|
|
1877
2085
|
props: {
|
|
1878
2086
|
data: {
|
|
1879
2087
|
type: [Object, String],
|
|
@@ -1888,7 +2096,8 @@
|
|
|
1888
2096
|
default: "click"
|
|
1889
2097
|
}
|
|
1890
2098
|
},
|
|
1891
|
-
setup(
|
|
2099
|
+
setup(__props) {
|
|
2100
|
+
const props = __props;
|
|
1892
2101
|
const services = vue.inject("services");
|
|
1893
2102
|
const uiService = services?.uiService;
|
|
1894
2103
|
const zoom = vue.computed(() => uiService?.get("zoom") ?? 1);
|
|
@@ -1985,176 +2194,155 @@
|
|
|
1985
2194
|
item2.handler?.(services, event);
|
|
1986
2195
|
}
|
|
1987
2196
|
};
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
item
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
}
|
|
2002
|
-
return item.value.display ?? true;
|
|
2003
|
-
}),
|
|
2004
|
-
zoomInHandler,
|
|
2005
|
-
zoomOutHandler,
|
|
2006
|
-
dropdownHandler(command) {
|
|
2007
|
-
if (command.item.handler) {
|
|
2008
|
-
command.item.handler(services);
|
|
2009
|
-
}
|
|
2010
|
-
},
|
|
2011
|
-
clickHandler(item2, event) {
|
|
2012
|
-
if (props.eventType !== "click")
|
|
2013
|
-
return;
|
|
2014
|
-
if (item2.type === "button") {
|
|
2015
|
-
buttonHandler(item2, event);
|
|
2016
|
-
}
|
|
2017
|
-
},
|
|
2018
|
-
mousedownHandler(item2, event) {
|
|
2019
|
-
if (props.eventType !== "mousedown")
|
|
2020
|
-
return;
|
|
2021
|
-
if (item2.type === "button") {
|
|
2022
|
-
buttonHandler(item2, event);
|
|
2023
|
-
}
|
|
2024
|
-
},
|
|
2025
|
-
mouseupHandler(item2, event) {
|
|
2026
|
-
if (props.eventType !== "mouseup")
|
|
2027
|
-
return;
|
|
2028
|
-
if (item2.type === "button") {
|
|
2029
|
-
buttonHandler(item2, event);
|
|
2030
|
-
}
|
|
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);
|
|
2031
2210
|
}
|
|
2032
2211
|
};
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
direction: _ctx.item.direction || "vertical"
|
|
2065
|
-
}, 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 }, [
|
|
2066
|
-
vue.createVNode(_component_tool_button, {
|
|
2067
|
-
data: { type: "button", icon: _ctx.ZoomOut, handler: _ctx.zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
2068
|
-
"event-type": _ctx.eventType
|
|
2069
|
-
}, null, 8, ["data", "event-type"]),
|
|
2070
|
-
vue.createElementVNode("span", _hoisted_2$2, vue.toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
|
|
2071
|
-
vue.createVNode(_component_tool_button, {
|
|
2072
|
-
data: { type: "button", icon: _ctx.ZoomIn, handler: _ctx.zoomInHandler, tooltip: "\u653E\u5927" },
|
|
2073
|
-
"event-type": _ctx.eventType
|
|
2074
|
-
}, null, 8, ["data", "event-type"])
|
|
2075
|
-
], 64)) : _ctx.item.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
|
|
2076
|
-
_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", {
|
|
2077
2243
|
key: 0,
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
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,
|
|
2084
2288
|
size: "small",
|
|
2085
2289
|
text: "",
|
|
2086
|
-
disabled:
|
|
2290
|
+
disabled: vue.unref(disabled)
|
|
2087
2291
|
}, {
|
|
2088
2292
|
default: vue.withCtx(() => [
|
|
2089
|
-
|
|
2293
|
+
vue.unref(item).icon ? (vue.openBlock(), vue.createBlock(MIcon, {
|
|
2090
2294
|
key: 0,
|
|
2091
|
-
icon:
|
|
2295
|
+
icon: vue.unref(item).icon
|
|
2092
2296
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
2093
|
-
vue.createElementVNode("span", null, vue.toDisplayString(
|
|
2297
|
+
vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(item).text), 1)
|
|
2094
2298
|
]),
|
|
2095
2299
|
_: 1
|
|
2096
|
-
}, 8, ["disabled"])
|
|
2097
|
-
]),
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
_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
|
+
]),
|
|
2122
2325
|
default: vue.withCtx(() => [
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
command: { item: _ctx.item, subItem }
|
|
2127
|
-
}, {
|
|
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" }, {
|
|
2128
2329
|
default: vue.withCtx(() => [
|
|
2129
|
-
vue.
|
|
2330
|
+
vue.createVNode(vue.unref(iconsVue.ArrowDown))
|
|
2130
2331
|
]),
|
|
2131
|
-
_:
|
|
2132
|
-
}
|
|
2133
|
-
|
|
2332
|
+
_: 1
|
|
2333
|
+
})
|
|
2334
|
+
])
|
|
2134
2335
|
]),
|
|
2135
2336
|
_: 1
|
|
2136
|
-
})) : vue.createCommentVNode("", true)
|
|
2137
|
-
]),
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2142
|
-
default: vue.withCtx(() => [
|
|
2143
|
-
vue.createVNode(_component_arrow_down)
|
|
2144
|
-
]),
|
|
2145
|
-
_: 1
|
|
2146
|
-
})
|
|
2147
|
-
])
|
|
2148
|
-
]),
|
|
2149
|
-
_: 1
|
|
2150
|
-
}, 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)
|
|
2151
|
-
], 34)) : vue.createCommentVNode("", true);
|
|
2152
|
-
}
|
|
2153
|
-
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
|
+
});
|
|
2154
2342
|
|
|
2155
|
-
const _sfc_main$
|
|
2343
|
+
const _sfc_main$e = vue.defineComponent({
|
|
2156
2344
|
name: "nav-menu",
|
|
2157
|
-
components: { ToolButton },
|
|
2345
|
+
components: { ToolButton: _sfc_main$f },
|
|
2158
2346
|
props: {
|
|
2159
2347
|
data: {
|
|
2160
2348
|
type: Object,
|
|
@@ -2172,7 +2360,8 @@
|
|
|
2172
2360
|
};
|
|
2173
2361
|
}
|
|
2174
2362
|
});
|
|
2175
|
-
|
|
2363
|
+
|
|
2364
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2176
2365
|
const _component_tool_button = vue.resolveComponent("tool-button");
|
|
2177
2366
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
2178
2367
|
class: "m-editor-nav-menu",
|
|
@@ -2194,9 +2383,9 @@
|
|
|
2194
2383
|
}), 128))
|
|
2195
2384
|
], 4);
|
|
2196
2385
|
}
|
|
2197
|
-
|
|
2386
|
+
const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
|
|
2198
2387
|
|
|
2199
|
-
const _sfc_main$
|
|
2388
|
+
const _sfc_main$d = vue.defineComponent({
|
|
2200
2389
|
name: "m-editor-props-panel",
|
|
2201
2390
|
emits: ["mounted"],
|
|
2202
2391
|
setup(props, { emit }) {
|
|
@@ -2243,8 +2432,9 @@
|
|
|
2243
2432
|
};
|
|
2244
2433
|
}
|
|
2245
2434
|
});
|
|
2435
|
+
|
|
2246
2436
|
const _hoisted_1$6 = { class: "`m-editor-props-panel" };
|
|
2247
|
-
function _sfc_render$
|
|
2437
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2248
2438
|
const _component_m_form = vue.resolveComponent("m-form");
|
|
2249
2439
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
|
|
2250
2440
|
vue.renderSlot(_ctx.$slots, "props-panel-header"),
|
|
@@ -2259,9 +2449,9 @@
|
|
|
2259
2449
|
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
|
|
2260
2450
|
]);
|
|
2261
2451
|
}
|
|
2262
|
-
|
|
2452
|
+
const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
|
|
2263
2453
|
|
|
2264
|
-
const _sfc_main$
|
|
2454
|
+
const _sfc_main$c = vue.defineComponent({
|
|
2265
2455
|
name: "ui-component-panel",
|
|
2266
2456
|
components: { MIcon },
|
|
2267
2457
|
setup() {
|
|
@@ -2291,7 +2481,7 @@
|
|
|
2291
2481
|
dragstartHandler({ text, type, data = {} }, e) {
|
|
2292
2482
|
if (e.dataTransfer) {
|
|
2293
2483
|
e.dataTransfer.effectAllowed = "move";
|
|
2294
|
-
e.dataTransfer.setData("data", serialize__default
|
|
2484
|
+
e.dataTransfer.setData("data", serialize__default.default({
|
|
2295
2485
|
name: text,
|
|
2296
2486
|
type,
|
|
2297
2487
|
...data
|
|
@@ -2327,9 +2517,10 @@
|
|
|
2327
2517
|
};
|
|
2328
2518
|
}
|
|
2329
2519
|
});
|
|
2520
|
+
|
|
2330
2521
|
const _hoisted_1$5 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
2331
2522
|
const _hoisted_2$1 = ["onClick", "onDragstart"];
|
|
2332
|
-
function _sfc_render$
|
|
2523
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2333
2524
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
2334
2525
|
const _component_m_icon = vue.resolveComponent("m-icon");
|
|
2335
2526
|
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
@@ -2401,22 +2592,17 @@
|
|
|
2401
2592
|
_: 3
|
|
2402
2593
|
});
|
|
2403
2594
|
}
|
|
2404
|
-
|
|
2595
|
+
const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
|
|
2405
2596
|
|
|
2406
|
-
const _sfc_main$
|
|
2407
|
-
|
|
2597
|
+
const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
|
|
2598
|
+
__name: "ContentMenu",
|
|
2408
2599
|
props: {
|
|
2409
|
-
menuData: {
|
|
2410
|
-
|
|
2411
|
-
default: () => []
|
|
2412
|
-
},
|
|
2413
|
-
isSubMenu: {
|
|
2414
|
-
type: Boolean,
|
|
2415
|
-
default: false
|
|
2416
|
-
}
|
|
2600
|
+
menuData: { default: () => [] },
|
|
2601
|
+
isSubMenu: { type: Boolean, default: false }
|
|
2417
2602
|
},
|
|
2418
2603
|
emits: ["hide", "show"],
|
|
2419
|
-
setup(
|
|
2604
|
+
setup(__props, { expose, emit }) {
|
|
2605
|
+
const props = __props;
|
|
2420
2606
|
const menu = vue.ref();
|
|
2421
2607
|
const subMenu = vue.ref();
|
|
2422
2608
|
const visible = vue.ref(false);
|
|
@@ -2442,6 +2628,36 @@
|
|
|
2442
2628
|
}
|
|
2443
2629
|
hide();
|
|
2444
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
|
+
};
|
|
2445
2661
|
vue.onMounted(() => {
|
|
2446
2662
|
if (props.isSubMenu)
|
|
2447
2663
|
return;
|
|
@@ -2452,81 +2668,47 @@
|
|
|
2452
2668
|
return;
|
|
2453
2669
|
globalThis.removeEventListener("mousedown", hideHandler, true);
|
|
2454
2670
|
});
|
|
2455
|
-
|
|
2456
|
-
menu,
|
|
2457
|
-
subMenu,
|
|
2458
|
-
visible,
|
|
2459
|
-
menuStyle,
|
|
2460
|
-
subMenuData,
|
|
2671
|
+
expose({
|
|
2461
2672
|
hide,
|
|
2462
|
-
show
|
|
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
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
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);
|
|
2492
2706
|
};
|
|
2493
2707
|
}
|
|
2494
2708
|
});
|
|
2495
|
-
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2496
|
-
const _component_tool_button = vue.resolveComponent("tool-button");
|
|
2497
|
-
const _component_content_menu = vue.resolveComponent("content-menu", true);
|
|
2498
|
-
return _ctx.menuData.length && _ctx.visible ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
2499
|
-
key: 0,
|
|
2500
|
-
class: "magic-editor-content-menu",
|
|
2501
|
-
ref: "menu",
|
|
2502
|
-
style: vue.normalizeStyle(_ctx.menuStyle)
|
|
2503
|
-
}, [
|
|
2504
|
-
vue.createElementVNode("div", null, [
|
|
2505
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.menuData, (item, index) => {
|
|
2506
|
-
return vue.openBlock(), vue.createBlock(_component_tool_button, {
|
|
2507
|
-
"event-type": "mouseup",
|
|
2508
|
-
data: item,
|
|
2509
|
-
key: index,
|
|
2510
|
-
onMouseup: _ctx.hide,
|
|
2511
|
-
onMouseenter: ($event) => _ctx.showSubMenu(item)
|
|
2512
|
-
}, null, 8, ["data", "onMouseup", "onMouseenter"]);
|
|
2513
|
-
}), 128))
|
|
2514
|
-
]),
|
|
2515
|
-
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
2516
|
-
vue.createVNode(_component_content_menu, {
|
|
2517
|
-
class: "sub-menu",
|
|
2518
|
-
ref: "subMenu",
|
|
2519
|
-
"menu-data": _ctx.subMenuData,
|
|
2520
|
-
"is-sub-menu": true,
|
|
2521
|
-
onHide: _ctx.hide
|
|
2522
|
-
}, null, 8, ["menu-data", "onHide"])
|
|
2523
|
-
]))
|
|
2524
|
-
], 4)) : vue.createCommentVNode("", true);
|
|
2525
|
-
}
|
|
2526
|
-
var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
|
|
2527
2709
|
|
|
2528
|
-
const _sfc_main$
|
|
2529
|
-
components: { ContentMenu },
|
|
2710
|
+
const _sfc_main$a = vue.defineComponent({
|
|
2711
|
+
components: { ContentMenu: _sfc_main$b },
|
|
2530
2712
|
setup() {
|
|
2531
2713
|
const services = vue.inject("services");
|
|
2532
2714
|
const menu = vue.ref();
|
|
@@ -2608,7 +2790,8 @@
|
|
|
2608
2790
|
};
|
|
2609
2791
|
}
|
|
2610
2792
|
});
|
|
2611
|
-
|
|
2793
|
+
|
|
2794
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2612
2795
|
const _component_content_menu = vue.resolveComponent("content-menu");
|
|
2613
2796
|
return vue.openBlock(), vue.createBlock(_component_content_menu, {
|
|
2614
2797
|
"menu-data": _ctx.menuData,
|
|
@@ -2616,7 +2799,7 @@
|
|
|
2616
2799
|
style: { "overflow": "initial" }
|
|
2617
2800
|
}, null, 8, ["menu-data"]);
|
|
2618
2801
|
}
|
|
2619
|
-
|
|
2802
|
+
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$6]]);
|
|
2620
2803
|
|
|
2621
2804
|
const throttleTime = 150;
|
|
2622
2805
|
const select = async (data, editorService) => {
|
|
@@ -2716,7 +2899,7 @@
|
|
|
2716
2899
|
tree.value?.filter(val);
|
|
2717
2900
|
}
|
|
2718
2901
|
});
|
|
2719
|
-
const _sfc_main$
|
|
2902
|
+
const _sfc_main$9 = vue.defineComponent({
|
|
2720
2903
|
name: "magic-editor-layer-panel",
|
|
2721
2904
|
components: { LayerMenu },
|
|
2722
2905
|
setup() {
|
|
@@ -2763,8 +2946,9 @@
|
|
|
2763
2946
|
};
|
|
2764
2947
|
}
|
|
2765
2948
|
});
|
|
2949
|
+
|
|
2766
2950
|
const _hoisted_1$4 = ["id", "onMouseenter"];
|
|
2767
|
-
function _sfc_render$
|
|
2951
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2768
2952
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
2769
2953
|
const _component_el_tree = vue.resolveComponent("el-tree");
|
|
2770
2954
|
const _component_layer_menu = vue.resolveComponent("layer-menu");
|
|
@@ -2826,9 +3010,9 @@
|
|
|
2826
3010
|
_: 3
|
|
2827
3011
|
});
|
|
2828
3012
|
}
|
|
2829
|
-
|
|
3013
|
+
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$5]]);
|
|
2830
3014
|
|
|
2831
|
-
const _sfc_main$
|
|
3015
|
+
const _sfc_main$8 = vue.defineComponent({
|
|
2832
3016
|
components: { MIcon },
|
|
2833
3017
|
props: {
|
|
2834
3018
|
data: {
|
|
@@ -2865,11 +3049,12 @@
|
|
|
2865
3049
|
};
|
|
2866
3050
|
}
|
|
2867
3051
|
});
|
|
3052
|
+
|
|
2868
3053
|
const _hoisted_1$3 = {
|
|
2869
3054
|
key: 1,
|
|
2870
3055
|
class: "magic-editor-tab-panel-title"
|
|
2871
3056
|
};
|
|
2872
|
-
function _sfc_render$
|
|
3057
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2873
3058
|
const _component_m_icon = vue.resolveComponent("m-icon");
|
|
2874
3059
|
const _component_el_tab_pane = vue.resolveComponent("el-tab-pane");
|
|
2875
3060
|
return _ctx.config ? (vue.openBlock(), vue.createBlock(_component_el_tab_pane, {
|
|
@@ -2915,9 +3100,9 @@
|
|
|
2915
3100
|
_: 3
|
|
2916
3101
|
}, 8, ["name"])) : vue.createCommentVNode("", true);
|
|
2917
3102
|
}
|
|
2918
|
-
|
|
3103
|
+
const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$4]]);
|
|
2919
3104
|
|
|
2920
|
-
const _sfc_main$
|
|
3105
|
+
const _sfc_main$7 = vue.defineComponent({
|
|
2921
3106
|
components: { TabPane },
|
|
2922
3107
|
name: "m-sidebar",
|
|
2923
3108
|
props: {
|
|
@@ -2936,7 +3121,8 @@
|
|
|
2936
3121
|
};
|
|
2937
3122
|
}
|
|
2938
3123
|
});
|
|
2939
|
-
|
|
3124
|
+
|
|
3125
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2940
3126
|
const _component_tab_pane = vue.resolveComponent("tab-pane");
|
|
2941
3127
|
const _component_el_tabs = vue.resolveComponent("el-tabs");
|
|
2942
3128
|
return _ctx.data.type === "tabs" && _ctx.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_tabs, {
|
|
@@ -2971,331 +3157,258 @@
|
|
|
2971
3157
|
_: 3
|
|
2972
3158
|
}, 8, ["modelValue"])) : vue.createCommentVNode("", true);
|
|
2973
3159
|
}
|
|
2974
|
-
|
|
3160
|
+
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$3]]);
|
|
2975
3161
|
|
|
2976
|
-
const
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
|
|
2993
|
-
}
|
|
2994
|
-
};
|
|
2995
|
-
const scroll = (type) => {
|
|
2996
|
-
if (!itemsContainer.value)
|
|
2997
|
-
return;
|
|
2998
|
-
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
2999
|
-
if (type === "left") {
|
|
3000
|
-
translateLeft += 100;
|
|
3001
|
-
if (translateLeft > 0) {
|
|
3002
|
-
translateLeft = 0;
|
|
3162
|
+
const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
|
|
3163
|
+
__name: "PageBarScrollContainer",
|
|
3164
|
+
setup(__props) {
|
|
3165
|
+
const services = vue.inject("services");
|
|
3166
|
+
const editorService = services?.editorService;
|
|
3167
|
+
const pageBar = vue.ref();
|
|
3168
|
+
const itemsContainer = vue.ref();
|
|
3169
|
+
const pageBarWidth = vue.ref(0);
|
|
3170
|
+
const canScroll = vue.ref(false);
|
|
3171
|
+
const itemsContainerWidth = vue.computed(() => pageBarWidth.value - 105);
|
|
3172
|
+
let translateLeft = 0;
|
|
3173
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
3174
|
+
for (const { contentRect } of entries) {
|
|
3175
|
+
const { width } = contentRect;
|
|
3176
|
+
pageBarWidth.value = width || 0;
|
|
3177
|
+
setCanScroll();
|
|
3003
3178
|
}
|
|
3004
|
-
}
|
|
3005
|
-
|
|
3006
|
-
if (
|
|
3007
|
-
|
|
3179
|
+
});
|
|
3180
|
+
const setCanScroll = () => {
|
|
3181
|
+
if (itemsContainer.value) {
|
|
3182
|
+
canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
|
|
3008
3183
|
}
|
|
3009
|
-
}
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
scroll("end");
|
|
3184
|
+
};
|
|
3185
|
+
const scroll = (type) => {
|
|
3186
|
+
if (!itemsContainer.value)
|
|
3187
|
+
return;
|
|
3188
|
+
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
3189
|
+
if (type === "left") {
|
|
3190
|
+
translateLeft += 100;
|
|
3191
|
+
if (translateLeft > 0) {
|
|
3192
|
+
translateLeft = 0;
|
|
3193
|
+
}
|
|
3194
|
+
} else if (type === "right") {
|
|
3195
|
+
translateLeft -= 100;
|
|
3196
|
+
if (-translateLeft > maxScrollLeft) {
|
|
3197
|
+
translateLeft = -maxScrollLeft;
|
|
3198
|
+
}
|
|
3199
|
+
} else if (type === "start") {
|
|
3200
|
+
translateLeft = 0;
|
|
3201
|
+
} else if (type === "end") {
|
|
3202
|
+
translateLeft = -maxScrollLeft;
|
|
3029
3203
|
}
|
|
3204
|
+
itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
|
|
3205
|
+
};
|
|
3206
|
+
vue.onMounted(() => {
|
|
3207
|
+
pageBar.value && resizeObserver.observe(pageBar.value);
|
|
3208
|
+
});
|
|
3209
|
+
vue.onUnmounted(() => {
|
|
3210
|
+
resizeObserver.disconnect();
|
|
3030
3211
|
});
|
|
3031
|
-
});
|
|
3032
|
-
return {
|
|
3033
|
-
pageBar,
|
|
3034
|
-
itemsContainer,
|
|
3035
|
-
canScroll,
|
|
3036
|
-
itemsContainerWidth,
|
|
3037
|
-
scroll
|
|
3038
|
-
};
|
|
3039
|
-
};
|
|
3040
|
-
const _sfc_main$5 = vue.defineComponent({
|
|
3041
|
-
components: { ArrowLeftBold: iconsVue.ArrowLeftBold, ArrowRightBold: iconsVue.ArrowRightBold, CaretBottom: iconsVue.CaretBottom, Plus: iconsVue.Plus, ToolButton },
|
|
3042
|
-
setup() {
|
|
3043
|
-
const services = vue.inject("services");
|
|
3044
|
-
const editorService = services?.editorService;
|
|
3045
3212
|
const root = vue.computed(() => editorService?.get("root"));
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
}
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
copy(node) {
|
|
3065
|
-
node && editorService?.copy(node);
|
|
3066
|
-
editorService?.paste({
|
|
3067
|
-
left: 0,
|
|
3068
|
-
top: 0
|
|
3069
|
-
});
|
|
3070
|
-
},
|
|
3071
|
-
remove(node) {
|
|
3072
|
-
editorService?.remove(node);
|
|
3073
|
-
}
|
|
3213
|
+
vue.watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
|
|
3214
|
+
setTimeout(() => {
|
|
3215
|
+
setCanScroll();
|
|
3216
|
+
if (length < preLength) {
|
|
3217
|
+
scroll("start");
|
|
3218
|
+
} else {
|
|
3219
|
+
scroll("end");
|
|
3220
|
+
}
|
|
3221
|
+
});
|
|
3222
|
+
});
|
|
3223
|
+
const addPage = () => {
|
|
3224
|
+
if (!editorService)
|
|
3225
|
+
return;
|
|
3226
|
+
const pageConfig = {
|
|
3227
|
+
type: schema.NodeType.PAGE,
|
|
3228
|
+
name: generatePageNameByApp(vue.toRaw(editorService.get("root")))
|
|
3229
|
+
};
|
|
3230
|
+
editorService.add(pageConfig);
|
|
3074
3231
|
};
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
vue.createElementVNode("div", {
|
|
3094
|
-
id: "m-editor-page-bar-add-icon",
|
|
3095
|
-
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3096
|
-
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.addPage && _ctx.addPage(...args))
|
|
3097
|
-
}, [
|
|
3098
|
-
vue.createVNode(_component_el_icon, null, {
|
|
3099
|
-
default: vue.withCtx(() => [
|
|
3100
|
-
vue.createVNode(_component_plus)
|
|
3101
|
-
]),
|
|
3102
|
-
_: 1
|
|
3103
|
-
})
|
|
3104
|
-
]),
|
|
3105
|
-
_ctx.canScroll ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3106
|
-
key: 0,
|
|
3107
|
-
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3108
|
-
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.scroll("left"))
|
|
3109
|
-
}, [
|
|
3110
|
-
vue.createVNode(_component_el_icon, null, {
|
|
3111
|
-
default: vue.withCtx(() => [
|
|
3112
|
-
vue.createVNode(_component_arrow_left_bold)
|
|
3232
|
+
return (_ctx, _cache) => {
|
|
3233
|
+
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
3234
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
3235
|
+
class: "m-editor-page-bar",
|
|
3236
|
+
ref_key: "pageBar",
|
|
3237
|
+
ref: pageBar
|
|
3238
|
+
}, [
|
|
3239
|
+
vue.createElementVNode("div", {
|
|
3240
|
+
id: "m-editor-page-bar-add-icon",
|
|
3241
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3242
|
+
onClick: addPage
|
|
3243
|
+
}, [
|
|
3244
|
+
vue.createVNode(_component_el_icon, null, {
|
|
3245
|
+
default: vue.withCtx(() => [
|
|
3246
|
+
vue.createVNode(vue.unref(iconsVue.Plus))
|
|
3247
|
+
]),
|
|
3248
|
+
_: 1
|
|
3249
|
+
})
|
|
3113
3250
|
]),
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
key: 1,
|
|
3119
|
-
class: "m-editor-page-bar-items",
|
|
3120
|
-
ref: "itemsContainer",
|
|
3121
|
-
style: vue.normalizeStyle(`width: ${_ctx.itemsContainerWidth}px`)
|
|
3122
|
-
}, [
|
|
3123
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.root.items, (item) => {
|
|
3124
|
-
return vue.openBlock(), vue.createElementBlock("div", {
|
|
3125
|
-
key: item.key,
|
|
3126
|
-
class: vue.normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
|
|
3127
|
-
onClick: ($event) => _ctx.switchPage(item)
|
|
3251
|
+
canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3252
|
+
key: 0,
|
|
3253
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3254
|
+
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
3128
3255
|
}, [
|
|
3129
|
-
vue.
|
|
3130
|
-
vue.
|
|
3131
|
-
vue.createVNode(
|
|
3132
|
-
effect: "dark",
|
|
3133
|
-
placement: "top-start",
|
|
3134
|
-
content: item.name
|
|
3135
|
-
}, {
|
|
3136
|
-
default: vue.withCtx(() => [
|
|
3137
|
-
vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
|
|
3138
|
-
]),
|
|
3139
|
-
_: 2
|
|
3140
|
-
}, 1032, ["content"])
|
|
3141
|
-
])
|
|
3142
|
-
]),
|
|
3143
|
-
vue.createVNode(_component_el_popover, {
|
|
3144
|
-
"popper-class": "page-bar-popover",
|
|
3145
|
-
placement: "top",
|
|
3146
|
-
width: 160,
|
|
3147
|
-
trigger: "hover"
|
|
3148
|
-
}, {
|
|
3149
|
-
reference: vue.withCtx(() => [
|
|
3150
|
-
vue.createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
|
|
3151
|
-
default: vue.withCtx(() => [
|
|
3152
|
-
vue.createVNode(_component_caret_bottom)
|
|
3153
|
-
]),
|
|
3154
|
-
_: 1
|
|
3155
|
-
})
|
|
3256
|
+
vue.createVNode(_component_el_icon, null, {
|
|
3257
|
+
default: vue.withCtx(() => [
|
|
3258
|
+
vue.createVNode(vue.unref(iconsVue.ArrowLeftBold))
|
|
3156
3259
|
]),
|
|
3260
|
+
_: 1
|
|
3261
|
+
})
|
|
3262
|
+
])) : vue.createCommentVNode("", true),
|
|
3263
|
+
vue.unref(root) ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3264
|
+
key: 1,
|
|
3265
|
+
class: "m-editor-page-bar-items",
|
|
3266
|
+
ref_key: "itemsContainer",
|
|
3267
|
+
ref: itemsContainer,
|
|
3268
|
+
style: vue.normalizeStyle(`width: ${vue.unref(itemsContainerWidth)}px`)
|
|
3269
|
+
}, [
|
|
3270
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
3271
|
+
], 4)) : vue.createCommentVNode("", true),
|
|
3272
|
+
canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3273
|
+
key: 2,
|
|
3274
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3275
|
+
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
3276
|
+
}, [
|
|
3277
|
+
vue.createVNode(_component_el_icon, null, {
|
|
3157
3278
|
default: vue.withCtx(() => [
|
|
3158
|
-
vue.
|
|
3159
|
-
vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3160
|
-
vue.createVNode(_component_tool_button, {
|
|
3161
|
-
data: {
|
|
3162
|
-
type: "button",
|
|
3163
|
-
text: "\u590D\u5236",
|
|
3164
|
-
icon: _ctx.DocumentCopy,
|
|
3165
|
-
handler: () => _ctx.copy(item)
|
|
3166
|
-
}
|
|
3167
|
-
}, null, 8, ["data"]),
|
|
3168
|
-
vue.createVNode(_component_tool_button, {
|
|
3169
|
-
data: {
|
|
3170
|
-
type: "button",
|
|
3171
|
-
text: "\u5220\u9664",
|
|
3172
|
-
icon: _ctx.Delete,
|
|
3173
|
-
handler: () => _ctx.remove(item)
|
|
3174
|
-
}
|
|
3175
|
-
}, null, 8, ["data"])
|
|
3176
|
-
])
|
|
3177
|
-
])
|
|
3279
|
+
vue.createVNode(vue.unref(iconsVue.ArrowRightBold))
|
|
3178
3280
|
]),
|
|
3179
|
-
_:
|
|
3180
|
-
}
|
|
3181
|
-
]
|
|
3182
|
-
|
|
3183
|
-
], 4)) : vue.createCommentVNode("", true),
|
|
3184
|
-
_ctx.canScroll ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3185
|
-
key: 2,
|
|
3186
|
-
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3187
|
-
onClick: _cache[2] || (_cache[2] = ($event) => _ctx.scroll("right"))
|
|
3188
|
-
}, [
|
|
3189
|
-
vue.createVNode(_component_el_icon, null, {
|
|
3190
|
-
default: vue.withCtx(() => [
|
|
3191
|
-
vue.createVNode(_component_arrow_right_bold)
|
|
3192
|
-
]),
|
|
3193
|
-
_: 1
|
|
3194
|
-
})
|
|
3195
|
-
])) : vue.createCommentVNode("", true)
|
|
3196
|
-
], 512);
|
|
3197
|
-
}
|
|
3198
|
-
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
|
|
3199
|
-
|
|
3200
|
-
class ScrollViewer$1 {
|
|
3201
|
-
constructor(options) {
|
|
3202
|
-
this.enter = false;
|
|
3203
|
-
this.targetEnter = false;
|
|
3204
|
-
this.keydown = false;
|
|
3205
|
-
this.zoom = 1;
|
|
3206
|
-
this.scrollLeft = 0;
|
|
3207
|
-
this.scrollTop = 0;
|
|
3208
|
-
this.x = 0;
|
|
3209
|
-
this.y = 0;
|
|
3210
|
-
this.resizeObserver = new ResizeObserver((entries) => {
|
|
3211
|
-
for (const { contentRect } of entries) {
|
|
3212
|
-
const { width, height } = contentRect;
|
|
3213
|
-
const targetRect = this.target.getBoundingClientRect();
|
|
3214
|
-
const targetWidth = targetRect.width * this.zoom;
|
|
3215
|
-
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3216
|
-
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
3217
|
-
if (targetWidth < width) {
|
|
3218
|
-
this.target._left = 0;
|
|
3219
|
-
}
|
|
3220
|
-
if (targetHeight < height) {
|
|
3221
|
-
this.target._top = 0;
|
|
3222
|
-
}
|
|
3223
|
-
this.scroll();
|
|
3224
|
-
}
|
|
3225
|
-
});
|
|
3226
|
-
this.wheelHandler = (event) => {
|
|
3227
|
-
if (this.targetEnter)
|
|
3228
|
-
return;
|
|
3229
|
-
const { deltaX, deltaY, currentTarget } = event;
|
|
3230
|
-
if (currentTarget !== this.container)
|
|
3231
|
-
return;
|
|
3232
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3233
|
-
this.scroll();
|
|
3234
|
-
this.scrollLeft = this.target._left;
|
|
3235
|
-
this.scrollTop = this.target._top;
|
|
3236
|
-
};
|
|
3237
|
-
this.mouseEnterHandler = () => {
|
|
3238
|
-
this.enter = true;
|
|
3239
|
-
};
|
|
3240
|
-
this.mouseLeaveHandler = () => {
|
|
3241
|
-
this.enter = false;
|
|
3242
|
-
};
|
|
3243
|
-
this.targetMouseEnterHandler = () => {
|
|
3244
|
-
this.targetEnter = true;
|
|
3281
|
+
_: 1
|
|
3282
|
+
})
|
|
3283
|
+
])) : vue.createCommentVNode("", true)
|
|
3284
|
+
], 512);
|
|
3245
3285
|
};
|
|
3246
|
-
|
|
3247
|
-
|
|
3286
|
+
}
|
|
3287
|
+
});
|
|
3288
|
+
|
|
3289
|
+
const _hoisted_1$2 = ["onClick"];
|
|
3290
|
+
const _hoisted_2 = { class: "m-editor-page-bar-title" };
|
|
3291
|
+
const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
|
|
3292
|
+
__name: "PageBar",
|
|
3293
|
+
setup(__props) {
|
|
3294
|
+
const services = vue.inject("services");
|
|
3295
|
+
const editorService = services?.editorService;
|
|
3296
|
+
const root = vue.computed(() => editorService?.get("root"));
|
|
3297
|
+
const page = vue.computed(() => editorService?.get("page"));
|
|
3298
|
+
const switchPage = (page2) => {
|
|
3299
|
+
editorService?.select(page2);
|
|
3248
3300
|
};
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
this.x = event.clientX;
|
|
3256
|
-
this.y = event.clientY;
|
|
3257
|
-
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3258
|
-
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3301
|
+
const copy = (node) => {
|
|
3302
|
+
node && editorService?.copy(node);
|
|
3303
|
+
editorService?.paste({
|
|
3304
|
+
left: 0,
|
|
3305
|
+
top: 0
|
|
3306
|
+
});
|
|
3259
3307
|
};
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
this.y = 0;
|
|
3263
|
-
this.scrollLeft = this.target._left;
|
|
3264
|
-
this.scrollTop = this.target._top;
|
|
3265
|
-
this.removeHandler();
|
|
3308
|
+
const remove = (node) => {
|
|
3309
|
+
editorService?.remove(node);
|
|
3266
3310
|
};
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
const
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3311
|
+
return (_ctx, _cache) => {
|
|
3312
|
+
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
3313
|
+
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
3314
|
+
const _component_el_popover = vue.resolveComponent("el-popover");
|
|
3315
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$6, null, {
|
|
3316
|
+
default: vue.withCtx(() => [
|
|
3317
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(root) && vue.unref(root).items || [], (item) => {
|
|
3318
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
3319
|
+
class: vue.normalizeClass(["m-editor-page-bar-item", { active: vue.unref(page)?.id === item.id }]),
|
|
3320
|
+
key: item.key,
|
|
3321
|
+
onClick: ($event) => switchPage(item)
|
|
3322
|
+
}, [
|
|
3323
|
+
vue.createElementVNode("div", _hoisted_2, [
|
|
3324
|
+
vue.renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
|
|
3325
|
+
vue.createVNode(_component_el_tooltip, {
|
|
3326
|
+
effect: "dark",
|
|
3327
|
+
placement: "top-start",
|
|
3328
|
+
content: item.name
|
|
3329
|
+
}, {
|
|
3330
|
+
default: vue.withCtx(() => [
|
|
3331
|
+
vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
|
|
3332
|
+
]),
|
|
3333
|
+
_: 2
|
|
3334
|
+
}, 1032, ["content"])
|
|
3335
|
+
])
|
|
3336
|
+
]),
|
|
3337
|
+
vue.createVNode(_component_el_popover, {
|
|
3338
|
+
"popper-class": "page-bar-popover",
|
|
3339
|
+
placement: "top",
|
|
3340
|
+
width: 160,
|
|
3341
|
+
trigger: "hover"
|
|
3342
|
+
}, {
|
|
3343
|
+
reference: vue.withCtx(() => [
|
|
3344
|
+
vue.createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
|
|
3345
|
+
default: vue.withCtx(() => [
|
|
3346
|
+
vue.createVNode(vue.unref(iconsVue.CaretBottom))
|
|
3347
|
+
]),
|
|
3348
|
+
_: 1
|
|
3349
|
+
})
|
|
3350
|
+
]),
|
|
3351
|
+
default: vue.withCtx(() => [
|
|
3352
|
+
vue.createElementVNode("div", null, [
|
|
3353
|
+
vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3354
|
+
vue.createVNode(_sfc_main$f, {
|
|
3355
|
+
data: {
|
|
3356
|
+
type: "button",
|
|
3357
|
+
text: "\u590D\u5236",
|
|
3358
|
+
icon: vue.unref(iconsVue.DocumentCopy),
|
|
3359
|
+
handler: () => copy(item)
|
|
3360
|
+
}
|
|
3361
|
+
}, null, 8, ["data"]),
|
|
3362
|
+
vue.createVNode(_sfc_main$f, {
|
|
3363
|
+
data: {
|
|
3364
|
+
type: "button",
|
|
3365
|
+
text: "\u5220\u9664",
|
|
3366
|
+
icon: vue.unref(iconsVue.Delete),
|
|
3367
|
+
handler: () => remove(item)
|
|
3368
|
+
}
|
|
3369
|
+
}, null, 8, ["data"])
|
|
3370
|
+
])
|
|
3371
|
+
])
|
|
3372
|
+
]),
|
|
3373
|
+
_: 2
|
|
3374
|
+
}, 1024)
|
|
3375
|
+
], 10, _hoisted_1$2);
|
|
3376
|
+
}), 128))
|
|
3377
|
+
]),
|
|
3378
|
+
_: 3
|
|
3379
|
+
});
|
|
3274
3380
|
};
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3381
|
+
}
|
|
3382
|
+
});
|
|
3383
|
+
|
|
3384
|
+
class ScrollViewer$1 {
|
|
3385
|
+
enter = false;
|
|
3386
|
+
targetEnter = false;
|
|
3387
|
+
keydown = false;
|
|
3388
|
+
container;
|
|
3389
|
+
target;
|
|
3390
|
+
zoom = 1;
|
|
3391
|
+
scrollLeft = 0;
|
|
3392
|
+
scrollTop = 0;
|
|
3393
|
+
x = 0;
|
|
3394
|
+
y = 0;
|
|
3395
|
+
resizeObserver = new ResizeObserver((entries) => {
|
|
3396
|
+
for (const { contentRect } of entries) {
|
|
3397
|
+
const { width, height } = contentRect;
|
|
3398
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3399
|
+
const targetWidth = targetRect.width * this.zoom;
|
|
3400
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3401
|
+
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
3402
|
+
if (targetWidth < width) {
|
|
3403
|
+
this.target._left = 0;
|
|
3283
3404
|
}
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3287
|
-
};
|
|
3288
|
-
this.keyupHandler = (event) => {
|
|
3289
|
-
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3290
|
-
return;
|
|
3405
|
+
if (targetHeight < height) {
|
|
3406
|
+
this.target._top = 0;
|
|
3291
3407
|
}
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
event.preventDefault();
|
|
3297
|
-
this.removeHandler();
|
|
3298
|
-
};
|
|
3408
|
+
this.scroll();
|
|
3409
|
+
}
|
|
3410
|
+
});
|
|
3411
|
+
constructor(options) {
|
|
3299
3412
|
this.container = options.container;
|
|
3300
3413
|
this.target = options.target;
|
|
3301
3414
|
this.zoom = options.zoom;
|
|
@@ -3331,6 +3444,79 @@
|
|
|
3331
3444
|
document.removeEventListener("mousemove", this.mousemoveHandler);
|
|
3332
3445
|
document.removeEventListener("mouseup", this.mouseupHandler);
|
|
3333
3446
|
}
|
|
3447
|
+
wheelHandler = (event) => {
|
|
3448
|
+
if (this.targetEnter)
|
|
3449
|
+
return;
|
|
3450
|
+
const { deltaX, deltaY, currentTarget } = event;
|
|
3451
|
+
if (currentTarget !== this.container)
|
|
3452
|
+
return;
|
|
3453
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3454
|
+
this.scroll();
|
|
3455
|
+
this.scrollLeft = this.target._left;
|
|
3456
|
+
this.scrollTop = this.target._top;
|
|
3457
|
+
};
|
|
3458
|
+
mouseEnterHandler = () => {
|
|
3459
|
+
this.enter = true;
|
|
3460
|
+
};
|
|
3461
|
+
mouseLeaveHandler = () => {
|
|
3462
|
+
this.enter = false;
|
|
3463
|
+
};
|
|
3464
|
+
targetMouseEnterHandler = () => {
|
|
3465
|
+
this.targetEnter = true;
|
|
3466
|
+
};
|
|
3467
|
+
targetMouseLeaveHandler = () => {
|
|
3468
|
+
this.targetEnter = false;
|
|
3469
|
+
};
|
|
3470
|
+
mousedownHandler = (event) => {
|
|
3471
|
+
if (!this.keydown)
|
|
3472
|
+
return;
|
|
3473
|
+
event.stopImmediatePropagation();
|
|
3474
|
+
event.stopPropagation();
|
|
3475
|
+
this.target.style.cursor = "grabbing";
|
|
3476
|
+
this.x = event.clientX;
|
|
3477
|
+
this.y = event.clientY;
|
|
3478
|
+
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3479
|
+
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3480
|
+
};
|
|
3481
|
+
mouseupHandler = () => {
|
|
3482
|
+
this.x = 0;
|
|
3483
|
+
this.y = 0;
|
|
3484
|
+
this.scrollLeft = this.target._left;
|
|
3485
|
+
this.scrollTop = this.target._top;
|
|
3486
|
+
this.removeHandler();
|
|
3487
|
+
};
|
|
3488
|
+
mousemoveHandler = (event) => {
|
|
3489
|
+
event.stopImmediatePropagation();
|
|
3490
|
+
event.stopPropagation();
|
|
3491
|
+
const deltaX = event.clientX - this.x;
|
|
3492
|
+
const deltaY = event.clientY - this.y;
|
|
3493
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3494
|
+
this.scroll();
|
|
3495
|
+
};
|
|
3496
|
+
keydownHandler = (event) => {
|
|
3497
|
+
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3498
|
+
event.preventDefault();
|
|
3499
|
+
event.stopImmediatePropagation();
|
|
3500
|
+
event.stopPropagation();
|
|
3501
|
+
}
|
|
3502
|
+
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3503
|
+
return;
|
|
3504
|
+
}
|
|
3505
|
+
this.keydown = true;
|
|
3506
|
+
this.target.style.cursor = "grab";
|
|
3507
|
+
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3508
|
+
};
|
|
3509
|
+
keyupHandler = (event) => {
|
|
3510
|
+
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3511
|
+
return;
|
|
3512
|
+
}
|
|
3513
|
+
event.preventDefault();
|
|
3514
|
+
event.stopImmediatePropagation();
|
|
3515
|
+
event.stopPropagation();
|
|
3516
|
+
this.keydown = false;
|
|
3517
|
+
event.preventDefault();
|
|
3518
|
+
this.removeHandler();
|
|
3519
|
+
};
|
|
3334
3520
|
setScrollOffset(deltaX, deltaY) {
|
|
3335
3521
|
const { width, height } = this.container.getBoundingClientRect();
|
|
3336
3522
|
const targetRect = this.target.getBoundingClientRect();
|
|
@@ -3398,11 +3584,12 @@
|
|
|
3398
3584
|
};
|
|
3399
3585
|
}
|
|
3400
3586
|
});
|
|
3587
|
+
|
|
3401
3588
|
const _hoisted_1$1 = {
|
|
3402
3589
|
class: "m-editor-scroll-viewer-container",
|
|
3403
3590
|
ref: "container"
|
|
3404
3591
|
};
|
|
3405
|
-
function _sfc_render$
|
|
3592
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3406
3593
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
|
|
3407
3594
|
vue.createElementVNode("div", {
|
|
3408
3595
|
ref: "el",
|
|
@@ -3412,170 +3599,170 @@
|
|
|
3412
3599
|
], 4)
|
|
3413
3600
|
], 512);
|
|
3414
3601
|
}
|
|
3415
|
-
|
|
3602
|
+
const ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$2]]);
|
|
3416
3603
|
|
|
3417
|
-
const _sfc_main$3 = vue.defineComponent({
|
|
3418
|
-
|
|
3419
|
-
|
|
3604
|
+
const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
3605
|
+
__name: "ViewerMenu",
|
|
3606
|
+
props: {
|
|
3607
|
+
isMultiSelect: { type: Boolean, default: false }
|
|
3608
|
+
},
|
|
3609
|
+
setup(__props, { expose }) {
|
|
3610
|
+
const props = __props;
|
|
3420
3611
|
const services = vue.inject("services");
|
|
3421
3612
|
const editorService = services?.editorService;
|
|
3422
3613
|
const menu = vue.ref();
|
|
3423
3614
|
const canPaste = vue.ref(false);
|
|
3424
3615
|
const canCenter = vue.ref(false);
|
|
3425
3616
|
const node = vue.computed(() => editorService?.get("node"));
|
|
3617
|
+
const nodes = vue.computed(() => editorService?.get("nodes"));
|
|
3426
3618
|
const parent = vue.computed(() => editorService?.get("parent"));
|
|
3427
|
-
const
|
|
3619
|
+
const stage = vue.computed(() => editorService?.get("stage"));
|
|
3428
3620
|
const stageContentMenu = vue.inject("stageContentMenu", []);
|
|
3429
|
-
vue.
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3621
|
+
const menuData = vue.reactive([
|
|
3622
|
+
{
|
|
3623
|
+
type: "button",
|
|
3624
|
+
text: "\u6C34\u5E73\u5C45\u4E2D",
|
|
3625
|
+
display: () => canCenter.value && !props.isMultiSelect,
|
|
3626
|
+
handler: () => {
|
|
3627
|
+
if (!node.value)
|
|
3628
|
+
return;
|
|
3629
|
+
editorService?.alignCenter(node.value);
|
|
3630
|
+
}
|
|
3631
|
+
},
|
|
3632
|
+
{
|
|
3633
|
+
type: "button",
|
|
3634
|
+
text: "\u590D\u5236",
|
|
3635
|
+
icon: vue.markRaw(iconsVue.DocumentCopy),
|
|
3636
|
+
handler: () => {
|
|
3637
|
+
nodes.value && editorService?.copy(nodes.value);
|
|
3638
|
+
canPaste.value = true;
|
|
3639
|
+
}
|
|
3640
|
+
},
|
|
3641
|
+
{
|
|
3642
|
+
type: "button",
|
|
3643
|
+
text: "\u7C98\u8D34",
|
|
3644
|
+
display: () => canPaste.value,
|
|
3645
|
+
handler: () => {
|
|
3646
|
+
const rect = menu.value?.$el.getBoundingClientRect();
|
|
3647
|
+
const parentRect = stage.value?.container?.getBoundingClientRect();
|
|
3648
|
+
const initialLeft = (rect?.left || 0) - (parentRect?.left || 0);
|
|
3649
|
+
const initialTop = (rect?.top || 0) - (parentRect?.top || 0);
|
|
3650
|
+
if (!nodes.value || nodes.value.length === 0)
|
|
3651
|
+
return;
|
|
3652
|
+
editorService?.paste({ left: initialLeft, top: initialTop });
|
|
3653
|
+
}
|
|
3654
|
+
},
|
|
3655
|
+
{
|
|
3656
|
+
type: "divider",
|
|
3657
|
+
direction: "horizontal",
|
|
3658
|
+
display: () => {
|
|
3659
|
+
if (!node.value)
|
|
3660
|
+
return false;
|
|
3661
|
+
return !utils.isPage(node.value);
|
|
3662
|
+
}
|
|
3663
|
+
},
|
|
3664
|
+
{
|
|
3665
|
+
type: "button",
|
|
3666
|
+
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
3667
|
+
icon: vue.markRaw(iconsVue.Top),
|
|
3668
|
+
display: () => !utils.isPage(node.value) && !props.isMultiSelect,
|
|
3669
|
+
handler: () => {
|
|
3670
|
+
editorService?.moveLayer(1);
|
|
3671
|
+
}
|
|
3672
|
+
},
|
|
3673
|
+
{
|
|
3674
|
+
type: "button",
|
|
3675
|
+
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
3676
|
+
icon: vue.markRaw(iconsVue.Bottom),
|
|
3677
|
+
display: () => !utils.isPage(node.value) && !props.isMultiSelect,
|
|
3678
|
+
handler: () => {
|
|
3679
|
+
editorService?.moveLayer(-1);
|
|
3680
|
+
}
|
|
3681
|
+
},
|
|
3682
|
+
{
|
|
3683
|
+
type: "button",
|
|
3684
|
+
text: "\u7F6E\u9876",
|
|
3685
|
+
display: () => !utils.isPage(node.value) && !props.isMultiSelect,
|
|
3686
|
+
handler: () => {
|
|
3687
|
+
editorService?.moveLayer(LayerOffset.TOP);
|
|
3688
|
+
}
|
|
3689
|
+
},
|
|
3690
|
+
{
|
|
3691
|
+
type: "button",
|
|
3692
|
+
text: "\u7F6E\u5E95",
|
|
3693
|
+
display: () => !utils.isPage(node.value) && !props.isMultiSelect,
|
|
3694
|
+
handler: () => {
|
|
3695
|
+
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
3696
|
+
}
|
|
3697
|
+
},
|
|
3698
|
+
{
|
|
3699
|
+
type: "divider",
|
|
3700
|
+
direction: "horizontal",
|
|
3701
|
+
display: () => !utils.isPage(node.value) && !props.isMultiSelect
|
|
3702
|
+
},
|
|
3703
|
+
{
|
|
3704
|
+
type: "button",
|
|
3705
|
+
text: "\u5220\u9664",
|
|
3706
|
+
icon: iconsVue.Delete,
|
|
3707
|
+
display: () => !utils.isPage(node.value),
|
|
3708
|
+
handler: () => {
|
|
3709
|
+
nodes.value && editorService?.remove(nodes.value);
|
|
3710
|
+
}
|
|
3711
|
+
},
|
|
3712
|
+
{
|
|
3713
|
+
type: "divider",
|
|
3714
|
+
direction: "horizontal"
|
|
3715
|
+
},
|
|
3716
|
+
{
|
|
3717
|
+
type: "button",
|
|
3718
|
+
text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
|
|
3719
|
+
handler: () => {
|
|
3720
|
+
editorService?.get("stage").clearGuides();
|
|
3721
|
+
}
|
|
3722
|
+
},
|
|
3723
|
+
...stageContentMenu
|
|
3724
|
+
]);
|
|
3433
3725
|
vue.watch(parent, async () => {
|
|
3434
3726
|
if (!parent.value || !editorService)
|
|
3435
3727
|
return canCenter.value = false;
|
|
3436
3728
|
const layout = await editorService.getLayout(parent.value);
|
|
3437
|
-
|
|
3729
|
+
const isLayoutConform = [Layout.ABSOLUTE, Layout.FIXED].includes(layout);
|
|
3730
|
+
const isTypeConform = nodes.value?.every((selectedNode) => ![schema.NodeType.ROOT, schema.NodeType.PAGE, "pop"].includes(`${selectedNode?.type}`));
|
|
3731
|
+
canCenter.value = isLayoutConform && !!isTypeConform;
|
|
3438
3732
|
}, { immediate: true });
|
|
3439
|
-
|
|
3440
|
-
menu
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
type: "button",
|
|
3452
|
-
text: "\u590D\u5236",
|
|
3453
|
-
icon: vue.markRaw(iconsVue.DocumentCopy),
|
|
3454
|
-
handler: () => {
|
|
3455
|
-
node.value && editorService?.copy(node.value);
|
|
3456
|
-
canPaste.value = true;
|
|
3457
|
-
}
|
|
3458
|
-
},
|
|
3459
|
-
{
|
|
3460
|
-
type: "button",
|
|
3461
|
-
text: "\u7C98\u8D34",
|
|
3462
|
-
display: () => canPaste.value,
|
|
3463
|
-
handler: () => {
|
|
3464
|
-
const stage = editorService?.get("stage");
|
|
3465
|
-
const rect = menu.value?.$el.getBoundingClientRect();
|
|
3466
|
-
const parentRect = stage?.container?.getBoundingClientRect();
|
|
3467
|
-
let left = (rect?.left || 0) - (parentRect?.left || 0);
|
|
3468
|
-
let top = (rect?.top || 0) - (parentRect?.top || 0);
|
|
3469
|
-
if (node.value?.items && stage) {
|
|
3470
|
-
const parentEl = stage.renderer.contentWindow?.document.getElementById(`${node.value.id}`);
|
|
3471
|
-
const parentElRect = parentEl?.getBoundingClientRect();
|
|
3472
|
-
left = left - (parentElRect?.left || 0);
|
|
3473
|
-
top = top - (parentElRect?.top || 0);
|
|
3474
|
-
}
|
|
3475
|
-
editorService?.paste({ left, top });
|
|
3476
|
-
}
|
|
3477
|
-
},
|
|
3478
|
-
{
|
|
3479
|
-
type: "divider",
|
|
3480
|
-
direction: "horizontal",
|
|
3481
|
-
display: () => !isPage.value
|
|
3482
|
-
},
|
|
3483
|
-
{
|
|
3484
|
-
type: "button",
|
|
3485
|
-
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
3486
|
-
icon: vue.markRaw(iconsVue.Top),
|
|
3487
|
-
display: () => !isPage.value,
|
|
3488
|
-
handler: () => {
|
|
3489
|
-
editorService?.moveLayer(1);
|
|
3490
|
-
}
|
|
3491
|
-
},
|
|
3492
|
-
{
|
|
3493
|
-
type: "button",
|
|
3494
|
-
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
3495
|
-
icon: vue.markRaw(iconsVue.Bottom),
|
|
3496
|
-
display: () => !isPage.value,
|
|
3497
|
-
handler: () => {
|
|
3498
|
-
editorService?.moveLayer(-1);
|
|
3499
|
-
}
|
|
3500
|
-
},
|
|
3501
|
-
{
|
|
3502
|
-
type: "button",
|
|
3503
|
-
text: "\u7F6E\u9876",
|
|
3504
|
-
display: () => !isPage.value,
|
|
3505
|
-
handler: () => {
|
|
3506
|
-
editorService?.moveLayer(LayerOffset.TOP);
|
|
3507
|
-
}
|
|
3508
|
-
},
|
|
3509
|
-
{
|
|
3510
|
-
type: "button",
|
|
3511
|
-
text: "\u7F6E\u5E95",
|
|
3512
|
-
display: () => !isPage.value,
|
|
3513
|
-
handler: () => {
|
|
3514
|
-
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
3515
|
-
}
|
|
3516
|
-
},
|
|
3517
|
-
{
|
|
3518
|
-
type: "divider",
|
|
3519
|
-
direction: "horizontal",
|
|
3520
|
-
display: () => !isPage.value
|
|
3521
|
-
},
|
|
3522
|
-
{
|
|
3523
|
-
type: "button",
|
|
3524
|
-
text: "\u5220\u9664",
|
|
3525
|
-
icon: iconsVue.Delete,
|
|
3526
|
-
display: () => !isPage.value,
|
|
3527
|
-
handler: () => {
|
|
3528
|
-
node.value && editorService?.remove(node.value);
|
|
3529
|
-
}
|
|
3530
|
-
},
|
|
3531
|
-
{
|
|
3532
|
-
type: "divider",
|
|
3533
|
-
direction: "horizontal"
|
|
3534
|
-
},
|
|
3535
|
-
{
|
|
3536
|
-
type: "button",
|
|
3537
|
-
text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
|
|
3538
|
-
handler: () => {
|
|
3539
|
-
editorService?.get("stage").clearGuides();
|
|
3540
|
-
}
|
|
3541
|
-
},
|
|
3542
|
-
...stageContentMenu
|
|
3543
|
-
]),
|
|
3544
|
-
show(e) {
|
|
3545
|
-
menu.value?.show(e);
|
|
3546
|
-
}
|
|
3733
|
+
const show = async (e) => {
|
|
3734
|
+
menu.value?.show(e);
|
|
3735
|
+
const data = await storageService.getItem(COPY_STORAGE_KEY);
|
|
3736
|
+
canPaste.value = data !== "undefined" && !!data;
|
|
3737
|
+
};
|
|
3738
|
+
expose({ show });
|
|
3739
|
+
return (_ctx, _cache) => {
|
|
3740
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$b, {
|
|
3741
|
+
"menu-data": menuData,
|
|
3742
|
+
ref_key: "menu",
|
|
3743
|
+
ref: menu
|
|
3744
|
+
}, null, 8, ["menu-data"]);
|
|
3547
3745
|
};
|
|
3548
3746
|
}
|
|
3549
3747
|
});
|
|
3550
|
-
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3551
|
-
const _component_content_menu = vue.resolveComponent("content-menu");
|
|
3552
|
-
return vue.openBlock(), vue.createBlock(_component_content_menu, {
|
|
3553
|
-
"menu-data": _ctx.menuData,
|
|
3554
|
-
ref: "menu"
|
|
3555
|
-
}, null, 8, ["menu-data"]);
|
|
3556
|
-
}
|
|
3557
|
-
var ViewerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
|
|
3558
3748
|
|
|
3559
|
-
const _sfc_main$2 = vue.defineComponent({
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
},
|
|
3565
|
-
setup() {
|
|
3749
|
+
const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
3750
|
+
__name: "Stage",
|
|
3751
|
+
setup(__props) {
|
|
3752
|
+
let stage = null;
|
|
3753
|
+
let runtime = null;
|
|
3566
3754
|
const services = vue.inject("services");
|
|
3567
3755
|
const stageOptions = vue.inject("stageOptions");
|
|
3568
3756
|
const stageWrap = vue.ref();
|
|
3569
3757
|
const stageContainer = vue.ref();
|
|
3570
3758
|
const menu = vue.ref();
|
|
3759
|
+
const isMultiSelect = vue.computed(() => services?.editorService.get("nodes")?.length > 1);
|
|
3571
3760
|
const stageRect = vue.computed(() => services?.uiService.get("stageRect"));
|
|
3572
3761
|
const uiSelectMode = vue.computed(() => services?.uiService.get("uiSelectMode"));
|
|
3573
3762
|
const root = vue.computed(() => services?.editorService.get("root"));
|
|
3574
3763
|
const page = vue.computed(() => services?.editorService.get("page"));
|
|
3575
3764
|
const zoom = vue.computed(() => services?.uiService.get("zoom") || 1);
|
|
3576
3765
|
const node = vue.computed(() => services?.editorService.get("node"));
|
|
3577
|
-
let stage = null;
|
|
3578
|
-
let runtime = null;
|
|
3579
3766
|
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
3580
3767
|
vue.watchEffect(() => {
|
|
3581
3768
|
if (stage)
|
|
@@ -3584,7 +3771,7 @@
|
|
|
3584
3771
|
return;
|
|
3585
3772
|
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
|
|
3586
3773
|
return;
|
|
3587
|
-
stage = new StageCore__default
|
|
3774
|
+
stage = new StageCore__default.default({
|
|
3588
3775
|
render: stageOptions.render,
|
|
3589
3776
|
runtimeUrl: stageOptions.runtimeUrl,
|
|
3590
3777
|
zoom: zoom.value,
|
|
@@ -3615,6 +3802,9 @@
|
|
|
3615
3802
|
stage?.on("highlight", (el) => {
|
|
3616
3803
|
services?.editorService.highlight(el.id);
|
|
3617
3804
|
});
|
|
3805
|
+
stage?.on("multiSelect", (els) => {
|
|
3806
|
+
services?.editorService.multiSelect(els.map((el) => el.id));
|
|
3807
|
+
});
|
|
3618
3808
|
stage?.on("update", (ev) => {
|
|
3619
3809
|
if (ev.parentEl) {
|
|
3620
3810
|
services?.editorService.moveToContainer({ id: ev.el.id, style: ev.style }, ev.parentEl.id);
|
|
@@ -3673,100 +3863,96 @@
|
|
|
3673
3863
|
resizeObserver.disconnect();
|
|
3674
3864
|
services?.editorService.set("stage", null);
|
|
3675
3865
|
});
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
e2.
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
const
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
}
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
top = e.clientY - containerRect.top + scrollTop;
|
|
3712
|
-
left = e.clientX - containerRect.left + scrollLeft;
|
|
3713
|
-
if (parentEl && doc) {
|
|
3714
|
-
const { left: parentLeft, top: parentTop } = StageCore.getOffset(parentEl);
|
|
3715
|
-
left = left - StageCore.calcValueByFontsize(doc, parentLeft);
|
|
3716
|
-
top = top - StageCore.calcValueByFontsize(doc, parentTop);
|
|
3717
|
-
}
|
|
3866
|
+
const contextmenuHandler = (e2) => {
|
|
3867
|
+
e2.preventDefault();
|
|
3868
|
+
menu.value?.show(e2);
|
|
3869
|
+
};
|
|
3870
|
+
const dragoverHandler = (e2) => {
|
|
3871
|
+
e2.preventDefault();
|
|
3872
|
+
if (e2.dataTransfer) {
|
|
3873
|
+
e2.dataTransfer.dropEffect = "move";
|
|
3874
|
+
}
|
|
3875
|
+
};
|
|
3876
|
+
const dropHandler = async (e) => {
|
|
3877
|
+
e.preventDefault();
|
|
3878
|
+
const doc = stage?.renderer.contentWindow?.document;
|
|
3879
|
+
const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
|
|
3880
|
+
let parent = page.value;
|
|
3881
|
+
if (parentEl) {
|
|
3882
|
+
parent = services?.editorService.getNodeById(parentEl.id, false);
|
|
3883
|
+
}
|
|
3884
|
+
if (e.dataTransfer && parent && stageContainer.value && stage) {
|
|
3885
|
+
const config = eval(`(${e.dataTransfer.getData("data")})`);
|
|
3886
|
+
const layout = await services?.editorService.getLayout(parent);
|
|
3887
|
+
const containerRect = stageContainer.value.getBoundingClientRect();
|
|
3888
|
+
const { scrollTop, scrollLeft } = stage.mask;
|
|
3889
|
+
const { style = {} } = config;
|
|
3890
|
+
let top = 0;
|
|
3891
|
+
let left = 0;
|
|
3892
|
+
let position = "relative";
|
|
3893
|
+
if (layout === Layout.ABSOLUTE) {
|
|
3894
|
+
position = "absolute";
|
|
3895
|
+
top = e.clientY - containerRect.top + scrollTop;
|
|
3896
|
+
left = e.clientX - containerRect.left + scrollLeft;
|
|
3897
|
+
if (parentEl && doc) {
|
|
3898
|
+
const { left: parentLeft, top: parentTop } = StageCore.getOffset(parentEl);
|
|
3899
|
+
left = left - StageCore.calcValueByFontsize(doc, parentLeft);
|
|
3900
|
+
top = top - StageCore.calcValueByFontsize(doc, parentTop);
|
|
3718
3901
|
}
|
|
3719
|
-
config.style = {
|
|
3720
|
-
...style,
|
|
3721
|
-
position,
|
|
3722
|
-
top,
|
|
3723
|
-
left
|
|
3724
|
-
};
|
|
3725
|
-
config.inputEvent = e;
|
|
3726
|
-
services?.editorService.add(config, parent);
|
|
3727
3902
|
}
|
|
3903
|
+
config.style = {
|
|
3904
|
+
...style,
|
|
3905
|
+
position,
|
|
3906
|
+
top,
|
|
3907
|
+
left
|
|
3908
|
+
};
|
|
3909
|
+
config.inputEvent = e;
|
|
3910
|
+
services?.editorService.add(config, parent);
|
|
3728
3911
|
}
|
|
3729
3912
|
};
|
|
3913
|
+
return (_ctx, _cache) => {
|
|
3914
|
+
return vue.openBlock(), vue.createBlock(ScrollViewer, {
|
|
3915
|
+
class: "m-editor-stage",
|
|
3916
|
+
ref_key: "stageWrap",
|
|
3917
|
+
ref: stageWrap,
|
|
3918
|
+
width: vue.unref(stageRect)?.width,
|
|
3919
|
+
height: vue.unref(stageRect)?.height,
|
|
3920
|
+
zoom: vue.unref(zoom)
|
|
3921
|
+
}, {
|
|
3922
|
+
default: vue.withCtx(() => [
|
|
3923
|
+
vue.createElementVNode("div", {
|
|
3924
|
+
class: "m-editor-stage-container",
|
|
3925
|
+
ref_key: "stageContainer",
|
|
3926
|
+
ref: stageContainer,
|
|
3927
|
+
style: vue.normalizeStyle(`transform: scale(${vue.unref(zoom)})`),
|
|
3928
|
+
onContextmenu: contextmenuHandler,
|
|
3929
|
+
onDrop: dropHandler,
|
|
3930
|
+
onDragover: dragoverHandler
|
|
3931
|
+
}, null, 36),
|
|
3932
|
+
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
3933
|
+
vue.createVNode(_sfc_main$3, {
|
|
3934
|
+
ref_key: "menu",
|
|
3935
|
+
ref: menu,
|
|
3936
|
+
"is-multi-select": vue.unref(isMultiSelect)
|
|
3937
|
+
}, null, 8, ["is-multi-select"])
|
|
3938
|
+
]))
|
|
3939
|
+
]),
|
|
3940
|
+
_: 1
|
|
3941
|
+
}, 8, ["width", "height", "zoom"]);
|
|
3942
|
+
};
|
|
3730
3943
|
}
|
|
3731
3944
|
});
|
|
3732
|
-
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3733
|
-
const _component_viewer_menu = vue.resolveComponent("viewer-menu");
|
|
3734
|
-
const _component_scroll_viewer = vue.resolveComponent("scroll-viewer");
|
|
3735
|
-
return vue.openBlock(), vue.createBlock(_component_scroll_viewer, {
|
|
3736
|
-
class: "m-editor-stage",
|
|
3737
|
-
ref: "stageWrap",
|
|
3738
|
-
width: _ctx.stageRect?.width,
|
|
3739
|
-
height: _ctx.stageRect?.height,
|
|
3740
|
-
zoom: _ctx.zoom
|
|
3741
|
-
}, {
|
|
3742
|
-
default: vue.withCtx(() => [
|
|
3743
|
-
vue.createElementVNode("div", {
|
|
3744
|
-
class: "m-editor-stage-container",
|
|
3745
|
-
ref: "stageContainer",
|
|
3746
|
-
style: vue.normalizeStyle(`transform: scale(${_ctx.zoom})`),
|
|
3747
|
-
onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
|
|
3748
|
-
onDrop: _cache[1] || (_cache[1] = (...args) => _ctx.dropHandler && _ctx.dropHandler(...args)),
|
|
3749
|
-
onDragover: _cache[2] || (_cache[2] = (...args) => _ctx.dragoverHandler && _ctx.dragoverHandler(...args))
|
|
3750
|
-
}, null, 36),
|
|
3751
|
-
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
3752
|
-
vue.createVNode(_component_viewer_menu, { ref: "menu" }, null, 512)
|
|
3753
|
-
]))
|
|
3754
|
-
]),
|
|
3755
|
-
_: 1
|
|
3756
|
-
}, 8, ["width", "height", "zoom"]);
|
|
3757
|
-
}
|
|
3758
|
-
var MagicStage = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
|
|
3759
3945
|
|
|
3760
3946
|
const _sfc_main$1 = vue.defineComponent({
|
|
3761
3947
|
name: "m-editor-workspace",
|
|
3762
3948
|
components: {
|
|
3763
|
-
PageBar,
|
|
3764
|
-
MagicStage
|
|
3949
|
+
PageBar: _sfc_main$5,
|
|
3950
|
+
MagicStage: _sfc_main$2
|
|
3765
3951
|
},
|
|
3766
3952
|
setup() {
|
|
3767
3953
|
const services = vue.inject("services");
|
|
3768
3954
|
const workspace = vue.ref();
|
|
3769
|
-
const
|
|
3955
|
+
const nodes = vue.computed(() => services?.editorService.get("nodes"));
|
|
3770
3956
|
let keycon;
|
|
3771
3957
|
const mouseenterHandler = () => {
|
|
3772
3958
|
workspace.value?.focus();
|
|
@@ -3777,31 +3963,31 @@
|
|
|
3777
3963
|
vue.onMounted(() => {
|
|
3778
3964
|
workspace.value?.addEventListener("mouseenter", mouseenterHandler);
|
|
3779
3965
|
workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
|
|
3780
|
-
keycon = new KeyController__default
|
|
3966
|
+
keycon = new KeyController__default.default(workspace.value);
|
|
3781
3967
|
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
3782
3968
|
const ctrl = isMac ? "meta" : "ctrl";
|
|
3783
3969
|
keycon.keyup("delete", (e) => {
|
|
3784
3970
|
e.inputEvent.preventDefault();
|
|
3785
|
-
if (!
|
|
3971
|
+
if (!nodes.value || utils.isPage(nodes.value[0]))
|
|
3786
3972
|
return;
|
|
3787
|
-
services?.editorService.remove(
|
|
3973
|
+
services?.editorService.remove(nodes.value);
|
|
3788
3974
|
}).keyup("backspace", (e) => {
|
|
3789
3975
|
e.inputEvent.preventDefault();
|
|
3790
|
-
if (!
|
|
3976
|
+
if (!nodes.value || utils.isPage(nodes.value[0]))
|
|
3791
3977
|
return;
|
|
3792
|
-
services?.editorService.remove(
|
|
3978
|
+
services?.editorService.remove(nodes.value);
|
|
3793
3979
|
}).keydown([ctrl, "c"], (e) => {
|
|
3794
3980
|
e.inputEvent.preventDefault();
|
|
3795
|
-
|
|
3981
|
+
nodes.value && services?.editorService.copy(nodes.value);
|
|
3796
3982
|
}).keydown([ctrl, "v"], (e) => {
|
|
3797
3983
|
e.inputEvent.preventDefault();
|
|
3798
|
-
|
|
3984
|
+
nodes.value && services?.editorService.paste({ offsetX: 10, offsetY: 10 });
|
|
3799
3985
|
}).keydown([ctrl, "x"], (e) => {
|
|
3800
3986
|
e.inputEvent.preventDefault();
|
|
3801
|
-
if (!
|
|
3987
|
+
if (!nodes.value || utils.isPage(nodes.value[0]))
|
|
3802
3988
|
return;
|
|
3803
|
-
services?.editorService.copy(
|
|
3804
|
-
services?.editorService.remove(
|
|
3989
|
+
services?.editorService.copy(nodes.value);
|
|
3990
|
+
services?.editorService.remove(nodes.value);
|
|
3805
3991
|
}).keydown([ctrl, "z"], (e) => {
|
|
3806
3992
|
e.inputEvent.preventDefault();
|
|
3807
3993
|
services?.editorService.undo();
|
|
@@ -3863,6 +4049,7 @@
|
|
|
3863
4049
|
};
|
|
3864
4050
|
}
|
|
3865
4051
|
});
|
|
4052
|
+
|
|
3866
4053
|
const _hoisted_1 = {
|
|
3867
4054
|
class: "m-editor-workspace",
|
|
3868
4055
|
tabindex: "1",
|
|
@@ -3887,14 +4074,14 @@
|
|
|
3887
4074
|
})
|
|
3888
4075
|
], 512);
|
|
3889
4076
|
}
|
|
3890
|
-
|
|
4077
|
+
const Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
3891
4078
|
|
|
3892
4079
|
class ComponentList extends BaseService {
|
|
4080
|
+
state = vue.reactive({
|
|
4081
|
+
list: []
|
|
4082
|
+
});
|
|
3893
4083
|
constructor() {
|
|
3894
4084
|
super([]);
|
|
3895
|
-
this.state = vue.reactive({
|
|
3896
|
-
list: []
|
|
3897
|
-
});
|
|
3898
4085
|
}
|
|
3899
4086
|
setList(componentGroupList) {
|
|
3900
4087
|
this.state.list = componentGroupList;
|
|
@@ -3903,7 +4090,7 @@
|
|
|
3903
4090
|
return this.state.list;
|
|
3904
4091
|
}
|
|
3905
4092
|
}
|
|
3906
|
-
|
|
4093
|
+
const componentListService = new ComponentList();
|
|
3907
4094
|
|
|
3908
4095
|
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
3909
4096
|
const MIN_LEFT_COLUMN_WIDTH = 45;
|
|
@@ -4023,7 +4210,7 @@
|
|
|
4023
4210
|
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
4024
4211
|
}
|
|
4025
4212
|
}
|
|
4026
|
-
|
|
4213
|
+
const uiService = new Ui();
|
|
4027
4214
|
|
|
4028
4215
|
const _sfc_main = vue.defineComponent({
|
|
4029
4216
|
name: "m-editor",
|
|
@@ -4153,7 +4340,8 @@
|
|
|
4153
4340
|
historyService,
|
|
4154
4341
|
propsService,
|
|
4155
4342
|
editorService,
|
|
4156
|
-
uiService
|
|
4343
|
+
uiService,
|
|
4344
|
+
storageService
|
|
4157
4345
|
};
|
|
4158
4346
|
vue.provide("services", services);
|
|
4159
4347
|
vue.provide("layerContentMenu", props.layerContentMenu);
|
|
@@ -4172,6 +4360,7 @@
|
|
|
4172
4360
|
return services;
|
|
4173
4361
|
}
|
|
4174
4362
|
});
|
|
4363
|
+
|
|
4175
4364
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4176
4365
|
const _component_nav_menu = vue.resolveComponent("nav-menu");
|
|
4177
4366
|
const _component_sidebar = vue.resolveComponent("sidebar");
|
|
@@ -4232,18 +4421,18 @@
|
|
|
4232
4421
|
_: 3
|
|
4233
4422
|
}, 8, ["code-options"]);
|
|
4234
4423
|
}
|
|
4235
|
-
|
|
4424
|
+
const Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
4236
4425
|
|
|
4237
|
-
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 transition: transform 0.3s;\n box-sizing: content-box;\n box-shadow: rgba(0, 0, 0, 0.04) 0px 3px 5px;\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}")();
|
|
4426
|
+
const index$1 = '';
|
|
4238
4427
|
|
|
4239
4428
|
const defaultInstallOpt = {};
|
|
4240
|
-
|
|
4429
|
+
const index = {
|
|
4241
4430
|
install: (app, opt) => {
|
|
4242
4431
|
const option = Object.assign(defaultInstallOpt, opt || {});
|
|
4243
4432
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
4244
4433
|
setConfig(option);
|
|
4245
4434
|
app.component(Editor.name, Editor);
|
|
4246
|
-
app.component(
|
|
4435
|
+
app.component("m-fields-ui-select", _sfc_main$l);
|
|
4247
4436
|
app.component(CodeLink.name, CodeLink);
|
|
4248
4437
|
app.component(Code.name, Code);
|
|
4249
4438
|
app.component(CodeEditor.name, CodeEditor);
|
|
@@ -4262,16 +4451,17 @@
|
|
|
4262
4451
|
exports.PropsPanel = PropsPanel;
|
|
4263
4452
|
exports.TMagicCodeEditor = CodeEditor;
|
|
4264
4453
|
exports.TMagicEditor = Editor;
|
|
4265
|
-
exports.ToolButton =
|
|
4454
|
+
exports.ToolButton = _sfc_main$f;
|
|
4266
4455
|
exports.V_GUIDE_LINE_STORAGE_KEY = V_GUIDE_LINE_STORAGE_KEY;
|
|
4267
4456
|
exports.change2Fixed = change2Fixed;
|
|
4268
4457
|
exports.debug = debug;
|
|
4269
|
-
exports
|
|
4458
|
+
exports.default = index;
|
|
4270
4459
|
exports.editorService = editorService;
|
|
4271
4460
|
exports.error = error;
|
|
4272
4461
|
exports.eventsService = eventsService;
|
|
4273
4462
|
exports.fillConfig = fillConfig;
|
|
4274
4463
|
exports.fixNodeLeft = fixNodeLeft;
|
|
4464
|
+
exports.fixNodePosition = fixNodePosition;
|
|
4275
4465
|
exports.generatePageName = generatePageName;
|
|
4276
4466
|
exports.generatePageNameByApp = generatePageNameByApp;
|
|
4277
4467
|
exports.getConfig = getConfig;
|
|
@@ -4288,6 +4478,7 @@
|
|
|
4288
4478
|
exports.propsService = propsService;
|
|
4289
4479
|
exports.setConfig = setConfig;
|
|
4290
4480
|
exports.setLayout = setLayout;
|
|
4481
|
+
exports.storageService = storageService;
|
|
4291
4482
|
exports.uiService = uiService;
|
|
4292
4483
|
exports.warn = warn;
|
|
4293
4484
|
|