@tmagic/editor 1.0.6 → 1.1.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/style.css +5 -1
- package/dist/{tmagic-editor.es.js → tmagic-editor.mjs} +1522 -1177
- package/dist/tmagic-editor.mjs.map +1 -0
- package/dist/tmagic-editor.umd.js +1606 -1259
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +22 -20
- package/src/Editor.vue +41 -15
- package/src/components/ContentMenu.vue +87 -99
- package/src/components/Icon.vue +2 -2
- package/src/components/ScrollViewer.vue +2 -2
- package/src/components/ToolButton.vue +151 -168
- package/src/fields/UISelect.vue +49 -70
- package/src/index.ts +2 -1
- package/src/layouts/AddPageBox.vue +3 -3
- package/src/layouts/Framework.vue +1 -1
- package/src/layouts/NavMenu.vue +2 -2
- package/src/layouts/PropsPanel.vue +1 -1
- package/src/layouts/Resizer.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +43 -2
- package/src/layouts/sidebar/LayerMenu.vue +3 -3
- package/src/layouts/sidebar/LayerPanel.vue +13 -4
- package/src/layouts/sidebar/Sidebar.vue +1 -1
- package/src/layouts/sidebar/TabPane.vue +3 -3
- package/src/layouts/workspace/PageBar.vue +63 -192
- package/src/layouts/workspace/PageBarScrollContainer.vue +111 -0
- package/src/layouts/workspace/Stage.vue +208 -188
- package/src/layouts/workspace/ViewerMenu.vue +141 -148
- package/src/layouts/workspace/Workspace.vue +11 -11
- package/src/services/BaseService.ts +5 -10
- package/src/services/componentList.ts +3 -3
- package/src/services/editor.ts +247 -140
- package/src/services/events.ts +1 -1
- package/src/services/history.ts +1 -1
- package/src/services/props.ts +63 -11
- package/src/services/storage.ts +133 -0
- package/src/services/ui.ts +10 -4
- package/src/theme/component-list-panel.scss +5 -0
- package/src/theme/framework.scss +1 -1
- package/src/theme/stage.scss +2 -2
- package/src/type.ts +28 -7
- package/src/utils/config.ts +1 -1
- package/src/utils/editor.ts +53 -35
- package/src/utils/operator.ts +109 -0
- package/src/utils/props.ts +2 -24
- package/src/utils/scroll-viewer.ts +1 -1
- package/tsconfig.build.json +13 -0
- package/{dist/types/src → types}/Editor.vue.d.ts +44 -9
- package/types/components/ContentMenu.vue.d.ts +116 -0
- package/types/components/Icon.vue.d.ts +13 -0
- package/types/components/ScrollViewer.vue.d.ts +22 -0
- package/types/components/ToolButton.vue.d.ts +109 -0
- package/types/fields/Code.vue.d.ts +23 -0
- package/{dist/types/src → types}/fields/CodeLink.vue.d.ts +4 -6
- package/types/fields/UISelect.vue.d.ts +83 -0
- package/{dist/types/src → types}/index.d.ts +4 -1
- package/types/layouts/AddPageBox.vue.d.ts +4 -0
- package/{dist/types/src → types}/layouts/CodeEditor.vue.d.ts +11 -13
- package/types/layouts/Framework.vue.d.ts +22 -0
- package/types/layouts/NavMenu.vue.d.ts +25 -0
- package/types/layouts/PropsPanel.vue.d.ts +245 -0
- package/types/layouts/Resizer.vue.d.ts +12 -0
- package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +14 -0
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +100 -0
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +1099 -0
- package/{dist/types/src → types}/layouts/sidebar/Sidebar.vue.d.ts +3 -5
- package/types/layouts/sidebar/TabPane.vue.d.ts +14 -0
- package/types/layouts/workspace/PageBar.vue.d.ts +54 -0
- package/types/layouts/workspace/PageBarScrollContainer.vue.d.ts +48 -0
- package/types/layouts/workspace/Stage.vue.d.ts +46 -0
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +88 -0
- package/types/layouts/workspace/Workspace.vue.d.ts +6 -0
- package/{dist/types/src → types}/services/BaseService.d.ts +0 -0
- package/types/services/componentList.d.ts +14 -0
- package/{dist/types/src → types}/services/editor.d.ts +27 -14
- package/{dist/types/src → types}/services/events.d.ts +0 -0
- package/{dist/types/src → types}/services/history.d.ts +0 -0
- package/{dist/types/src → types}/services/props.d.ts +26 -2
- package/types/services/storage.d.ts +56 -0
- package/{dist/types/src → types}/services/ui.d.ts +1 -1
- package/{dist/types/src → types}/type.d.ts +21 -1
- package/{dist/types/src → types}/utils/compose.d.ts +1 -1
- package/{dist/types/src → types}/utils/config.d.ts +0 -0
- package/{dist/types/src → types}/utils/editor.d.ts +11 -4
- package/{dist/types/src → types}/utils/index.d.ts +0 -0
- package/{dist/types/src → types}/utils/logger.d.ts +0 -0
- package/types/utils/operator.d.ts +21 -0
- package/{dist/types/src → types}/utils/polyfills.d.ts +0 -0
- package/{dist/types/src → types}/utils/props.d.ts +2 -22
- package/{dist/types/src → types}/utils/scroll-viewer.d.ts +0 -0
- package/{dist/types/src → types}/utils/undo-redo.d.ts +0 -0
- package/dist/tmagic-editor.es.js.map +0 -1
- package/dist/types/src/components/Icon.vue.d.ts +0 -14
- package/dist/types/src/components/ScrollViewer.vue.d.ts +0 -24
- package/dist/types/src/fields/Code.vue.d.ts +0 -25
- package/dist/types/src/layouts/AddPageBox.vue.d.ts +0 -5
- package/dist/types/src/layouts/Framework.vue.d.ts +0 -24
- package/dist/types/src/layouts/NavMenu.vue.d.ts +0 -27
- package/dist/types/src/layouts/PropsPanel.vue.d.ts +0 -13
- package/dist/types/src/layouts/Resizer.vue.d.ts +0 -14
- package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +0 -14
- package/dist/types/src/layouts/sidebar/TabPane.vue.d.ts +0 -16
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +0 -8
- package/dist/types/src/shims-vue.d.ts +0 -6
- package/dist/types/src/vite-env.d.ts +0 -1
- package/src/vite-env.d.ts +0 -1
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('@element-plus/icons'), require('lodash-es'), require('monaco-editor'), require('@tmagic/schema'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('gesto'), require('element-plus'), require('keycon')
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', '@element-plus/icons', 'lodash-es', 'monaco-editor', '@tmagic/schema', '@tmagic/utils', 'events', '@tmagic/core', 'gesto', 'element-plus', 'keycon'
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.serialize, global.
|
|
5
|
-
})(this, (function (exports, vue, serialize,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('@element-plus/icons-vue'), require('lodash-es'), require('monaco-editor'), require('@tmagic/stage'), require('@tmagic/schema'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('gesto'), require('element-plus'), require('keycon')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', '@element-plus/icons-vue', 'lodash-es', 'monaco-editor', '@tmagic/stage', '@tmagic/schema', '@tmagic/utils', 'events', '@tmagic/core', 'gesto', 'element-plus', 'keycon'], factory) :
|
|
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
|
+
})(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 = [];
|
|
@@ -479,17 +471,12 @@
|
|
|
479
471
|
try {
|
|
480
472
|
let beforeArgs = args;
|
|
481
473
|
for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
|
|
482
|
-
|
|
483
|
-
if (isError(
|
|
484
|
-
throw
|
|
485
|
-
if (!Array.isArray(
|
|
486
|
-
|
|
474
|
+
beforeArgs = await beforeMethod(...beforeArgs) || [];
|
|
475
|
+
if (isError(beforeArgs))
|
|
476
|
+
throw beforeArgs;
|
|
477
|
+
if (!Array.isArray(beforeArgs)) {
|
|
478
|
+
beforeArgs = [beforeArgs];
|
|
487
479
|
}
|
|
488
|
-
beforeArgs = beforeArgs.map((v, index) => {
|
|
489
|
-
if (typeof beforeReturnValue[index] === "undefined")
|
|
490
|
-
return v;
|
|
491
|
-
return beforeReturnValue[index];
|
|
492
|
-
});
|
|
493
480
|
}
|
|
494
481
|
let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
|
|
495
482
|
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
@@ -503,12 +490,12 @@
|
|
|
503
490
|
}
|
|
504
491
|
};
|
|
505
492
|
class BaseService extends events.EventEmitter {
|
|
493
|
+
pluginOptionsList = {};
|
|
494
|
+
middleware = {};
|
|
495
|
+
taskList = [];
|
|
496
|
+
doingTask = false;
|
|
506
497
|
constructor(methods = [], serialMethods = []) {
|
|
507
498
|
super();
|
|
508
|
-
this.pluginOptionsList = {};
|
|
509
|
-
this.middleware = {};
|
|
510
|
-
this.taskList = [];
|
|
511
|
-
this.doingTask = false;
|
|
512
499
|
methods.forEach((propertyName) => {
|
|
513
500
|
const scope = this;
|
|
514
501
|
const sourceMethod = scope[propertyName];
|
|
@@ -565,14 +552,14 @@
|
|
|
565
552
|
}
|
|
566
553
|
|
|
567
554
|
class History extends BaseService {
|
|
555
|
+
state = vue.reactive({
|
|
556
|
+
pageSteps: {},
|
|
557
|
+
pageId: void 0,
|
|
558
|
+
canRedo: false,
|
|
559
|
+
canUndo: false
|
|
560
|
+
});
|
|
568
561
|
constructor() {
|
|
569
562
|
super([]);
|
|
570
|
-
this.state = vue.reactive({
|
|
571
|
-
pageSteps: {},
|
|
572
|
-
pageId: void 0,
|
|
573
|
-
canRedo: false,
|
|
574
|
-
canUndo: false
|
|
575
|
-
});
|
|
576
563
|
this.on("change", this.setCanUndoRedo);
|
|
577
564
|
}
|
|
578
565
|
reset() {
|
|
@@ -641,88 +628,88 @@
|
|
|
641
628
|
this.state.canUndo = undoRedo?.canUndo() || false;
|
|
642
629
|
}
|
|
643
630
|
}
|
|
644
|
-
|
|
631
|
+
const historyService = new History();
|
|
645
632
|
|
|
646
|
-
|
|
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";
|
|
647
644
|
constructor() {
|
|
648
|
-
super(["
|
|
649
|
-
this.state = vue.reactive({
|
|
650
|
-
propsConfigMap: {},
|
|
651
|
-
propsValueMap: {}
|
|
652
|
-
});
|
|
645
|
+
super(["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"]);
|
|
653
646
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
this.setPropsConfig(utils.toLine(type), configs[type]);
|
|
657
|
-
});
|
|
658
|
-
this.emit("props-configs-change");
|
|
647
|
+
async getStorage() {
|
|
648
|
+
return this.storage;
|
|
659
649
|
}
|
|
660
|
-
|
|
661
|
-
this.
|
|
650
|
+
async getNamespace() {
|
|
651
|
+
return this.namespace;
|
|
662
652
|
}
|
|
663
|
-
async
|
|
664
|
-
|
|
665
|
-
|
|
653
|
+
async clear() {
|
|
654
|
+
const storage2 = await this.getStorage();
|
|
655
|
+
storage2.clear();
|
|
656
|
+
}
|
|
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;
|
|
666
673
|
}
|
|
667
|
-
return lodashEs.cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
|
|
668
674
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
});
|
|
675
|
+
async key(index) {
|
|
676
|
+
const storage2 = await this.getStorage();
|
|
677
|
+
return storage2.key(index);
|
|
673
678
|
}
|
|
674
|
-
|
|
675
|
-
|
|
679
|
+
async removeItem(key2, options2 = {}) {
|
|
680
|
+
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
681
|
+
storage2.removeItem(`${options2.namespace || namespace2}:${key2}`);
|
|
676
682
|
}
|
|
677
|
-
async
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
}
|
|
685
|
-
return value;
|
|
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)}`;
|
|
686
691
|
}
|
|
687
|
-
|
|
688
|
-
await this.setNewItemId(data);
|
|
689
|
-
return {
|
|
690
|
-
...getDefaultPropsValue(type, await this.createId(type)),
|
|
691
|
-
...lodashEs.mergeWith(lodashEs.cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
692
|
-
};
|
|
693
|
-
}
|
|
694
|
-
async createId(type) {
|
|
695
|
-
return `${type}_${lodashEs.random(1e4, false)}`;
|
|
692
|
+
storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
|
|
696
693
|
}
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
for (const item of config.items) {
|
|
705
|
-
await this.setNewItemId(item, config);
|
|
706
|
-
}
|
|
694
|
+
getValueAndProtocol(value) {
|
|
695
|
+
let protocol2 = "";
|
|
696
|
+
if (value === null) {
|
|
697
|
+
return {
|
|
698
|
+
item: value,
|
|
699
|
+
protocol: protocol2
|
|
700
|
+
};
|
|
707
701
|
}
|
|
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
|
|
709
|
+
};
|
|
708
710
|
}
|
|
709
711
|
}
|
|
710
|
-
const
|
|
711
|
-
pageConfig.items?.forEach((config) => {
|
|
712
|
-
if (config.pop === oldId) {
|
|
713
|
-
config.pop = popId;
|
|
714
|
-
return;
|
|
715
|
-
}
|
|
716
|
-
if (config.popId === oldId) {
|
|
717
|
-
config.popId = popId;
|
|
718
|
-
return;
|
|
719
|
-
}
|
|
720
|
-
if (Array.isArray(config.items)) {
|
|
721
|
-
updatePopId(oldId, popId, config);
|
|
722
|
-
}
|
|
723
|
-
});
|
|
724
|
-
};
|
|
725
|
-
var propsService = new Props();
|
|
712
|
+
const storageService = new WebStorage();
|
|
726
713
|
|
|
727
714
|
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
728
715
|
LayerOffset2["TOP"] = "top";
|
|
@@ -768,56 +755,49 @@
|
|
|
768
755
|
const items = parent?.items || [];
|
|
769
756
|
return items.findIndex((item) => `${item.id}` === `${node.id}`);
|
|
770
757
|
};
|
|
771
|
-
const
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
const style = node.style || {};
|
|
782
|
-
let height = style.height || 0;
|
|
783
|
-
if (!stage || typeof style.top !== "undefined" || !parentNode.style)
|
|
784
|
-
return style;
|
|
758
|
+
const getRelativeStyle = (style = {}) => ({
|
|
759
|
+
...style,
|
|
760
|
+
position: "relative",
|
|
761
|
+
top: 0,
|
|
762
|
+
left: 0
|
|
763
|
+
});
|
|
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;
|
|
785
768
|
if (!utils.isNumber(height)) {
|
|
786
769
|
height = 0;
|
|
787
770
|
}
|
|
788
771
|
const { height: parentHeight } = parentNode.style;
|
|
789
772
|
if (utils.isPage(parentNode)) {
|
|
790
773
|
const { scrollTop = 0, wrapperHeight } = stage.mask;
|
|
791
|
-
|
|
792
|
-
} else {
|
|
793
|
-
style.top = (parentHeight - height) / 2;
|
|
774
|
+
return (wrapperHeight - height) / 2 + scrollTop;
|
|
794
775
|
}
|
|
795
|
-
return
|
|
776
|
+
return (parentHeight - height) / 2;
|
|
796
777
|
};
|
|
797
|
-
const
|
|
778
|
+
const getInitPositionStyle = (style = {}, layout) => {
|
|
798
779
|
if (layout === Layout.ABSOLUTE) {
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
780
|
+
return {
|
|
781
|
+
...style,
|
|
782
|
+
position: "absolute"
|
|
802
783
|
};
|
|
803
|
-
return node;
|
|
804
784
|
}
|
|
805
785
|
if (layout === Layout.RELATIVE) {
|
|
806
|
-
return
|
|
786
|
+
return getRelativeStyle(style);
|
|
807
787
|
}
|
|
808
|
-
return
|
|
788
|
+
return style;
|
|
809
789
|
};
|
|
810
790
|
const setLayout = (node, layout) => {
|
|
811
791
|
node.items?.forEach((child) => {
|
|
812
792
|
if (utils.isPop(child))
|
|
813
793
|
return;
|
|
814
|
-
|
|
815
|
-
if (
|
|
794
|
+
const style = child.style || {};
|
|
795
|
+
if (style.position === "fixed")
|
|
816
796
|
return;
|
|
817
797
|
if (layout !== Layout.RELATIVE) {
|
|
818
|
-
|
|
798
|
+
style.position = "absolute";
|
|
819
799
|
} else {
|
|
820
|
-
|
|
800
|
+
child.style = getRelativeStyle(style);
|
|
821
801
|
child.style.right = "auto";
|
|
822
802
|
child.style.bottom = "auto";
|
|
823
803
|
}
|
|
@@ -834,11 +814,10 @@
|
|
|
834
814
|
offset.left = offset.left + globalThis.parseFloat(value.style?.left || 0);
|
|
835
815
|
offset.top = offset.top + globalThis.parseFloat(value.style?.top || 0);
|
|
836
816
|
});
|
|
837
|
-
|
|
817
|
+
return {
|
|
838
818
|
...node.style || {},
|
|
839
819
|
...offset
|
|
840
820
|
};
|
|
841
|
-
return node;
|
|
842
821
|
};
|
|
843
822
|
const Fixed2Other = async (node, root, getLayout) => {
|
|
844
823
|
const path = utils.getNodePath(node.id, root.items);
|
|
@@ -853,20 +832,20 @@
|
|
|
853
832
|
offset.left = offset.left - globalThis.parseFloat(value.style?.left || 0);
|
|
854
833
|
offset.top = offset.top - globalThis.parseFloat(value.style?.top || 0);
|
|
855
834
|
});
|
|
835
|
+
const style = node.style || {};
|
|
856
836
|
const parent = path.pop();
|
|
857
837
|
if (!parent) {
|
|
858
|
-
return
|
|
838
|
+
return getRelativeStyle(style);
|
|
859
839
|
}
|
|
860
840
|
const layout = await getLayout(parent);
|
|
861
841
|
if (layout !== Layout.RELATIVE) {
|
|
862
|
-
|
|
863
|
-
...
|
|
842
|
+
return {
|
|
843
|
+
...style,
|
|
864
844
|
...offset,
|
|
865
845
|
position: "absolute"
|
|
866
846
|
};
|
|
867
|
-
return node;
|
|
868
847
|
}
|
|
869
|
-
return
|
|
848
|
+
return getRelativeStyle(style);
|
|
870
849
|
};
|
|
871
850
|
const getGuideLineFromCache = (key) => {
|
|
872
851
|
if (!key)
|
|
@@ -881,86 +860,284 @@
|
|
|
881
860
|
}
|
|
882
861
|
return [];
|
|
883
862
|
};
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
863
|
+
const fixNodeLeft = (config, parent, doc) => {
|
|
864
|
+
if (!doc || !config.style || !utils.isNumber(config.style.left))
|
|
865
|
+
return config.style?.left;
|
|
866
|
+
const el = doc.getElementById(`${config.id}`);
|
|
867
|
+
const parentEl = doc.getElementById(`${parent.id}`);
|
|
868
|
+
const left = Number(config.style?.left) || 0;
|
|
869
|
+
if (el && parentEl && el.offsetWidth + left > parentEl.offsetWidth) {
|
|
870
|
+
return parentEl.offsetWidth - el.offsetWidth;
|
|
871
|
+
}
|
|
872
|
+
return config.style.left;
|
|
892
873
|
};
|
|
893
|
-
const
|
|
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
|
+
};
|
|
894
883
|
};
|
|
895
884
|
|
|
896
|
-
class
|
|
885
|
+
class Props extends BaseService {
|
|
886
|
+
state = vue.reactive({
|
|
887
|
+
propsConfigMap: {},
|
|
888
|
+
propsValueMap: {}
|
|
889
|
+
});
|
|
897
890
|
constructor() {
|
|
898
891
|
super([
|
|
899
|
-
"
|
|
900
|
-
"
|
|
901
|
-
"
|
|
902
|
-
"
|
|
903
|
-
"
|
|
904
|
-
"
|
|
905
|
-
"
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
"redo",
|
|
912
|
-
"highlight"
|
|
913
|
-
], ["select", "update", "moveLayer"]);
|
|
914
|
-
this.isHistoryStateChange = false;
|
|
915
|
-
this.state = vue.reactive({
|
|
916
|
-
root: null,
|
|
917
|
-
page: null,
|
|
918
|
-
parent: null,
|
|
919
|
-
node: null,
|
|
920
|
-
stage: null,
|
|
921
|
-
highlightNode: null,
|
|
922
|
-
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
923
|
-
pageLength: 0
|
|
892
|
+
"setPropsConfig",
|
|
893
|
+
"getPropsConfig",
|
|
894
|
+
"setPropsValue",
|
|
895
|
+
"getPropsValue",
|
|
896
|
+
"createId",
|
|
897
|
+
"setNewItemId",
|
|
898
|
+
"getDefaultPropsValue"
|
|
899
|
+
]);
|
|
900
|
+
}
|
|
901
|
+
setPropsConfigs(configs) {
|
|
902
|
+
Object.keys(configs).forEach((type) => {
|
|
903
|
+
this.setPropsConfig(utils.toLine(type), configs[type]);
|
|
924
904
|
});
|
|
905
|
+
this.emit("props-configs-change");
|
|
925
906
|
}
|
|
926
|
-
|
|
927
|
-
this.state[
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
907
|
+
setPropsConfig(type, config) {
|
|
908
|
+
this.state.propsConfigMap[type] = fillConfig(Array.isArray(config) ? config : [config]);
|
|
909
|
+
}
|
|
910
|
+
async getPropsConfig(type) {
|
|
911
|
+
if (type === "area") {
|
|
912
|
+
return await this.getPropsConfig("button");
|
|
931
913
|
}
|
|
914
|
+
return lodashEs.cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
|
|
932
915
|
}
|
|
933
|
-
|
|
934
|
-
|
|
916
|
+
setPropsValues(values) {
|
|
917
|
+
Object.keys(values).forEach((type) => {
|
|
918
|
+
this.setPropsValue(utils.toLine(type), values[type]);
|
|
919
|
+
});
|
|
935
920
|
}
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
const path = utils.getNodePath(id, root.items);
|
|
947
|
-
if (!path.length)
|
|
948
|
-
return {};
|
|
949
|
-
path.unshift(root);
|
|
950
|
-
const info = {};
|
|
951
|
-
info.node = path[path.length - 1];
|
|
952
|
-
info.parent = path[path.length - 2];
|
|
953
|
-
path.forEach((item) => {
|
|
954
|
-
if (item.type === schema.NodeType.PAGE) {
|
|
955
|
-
info.page = item;
|
|
956
|
-
return;
|
|
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)";
|
|
957
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);
|
|
958
953
|
});
|
|
959
|
-
return info;
|
|
960
954
|
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
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 getAddParent = (node) => {
|
|
1052
|
+
const curNode = editorService.get("node");
|
|
1053
|
+
let parentNode;
|
|
1054
|
+
if (utils.isPage(node)) {
|
|
1055
|
+
parentNode = editorService.get("root");
|
|
1056
|
+
} else if (curNode.items) {
|
|
1057
|
+
parentNode = curNode;
|
|
1058
|
+
} else {
|
|
1059
|
+
parentNode = editorService.getParentById(curNode.id, false);
|
|
1060
|
+
}
|
|
1061
|
+
return parentNode;
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
class Editor$1 extends BaseService {
|
|
1065
|
+
state = vue.reactive({
|
|
1066
|
+
root: null,
|
|
1067
|
+
page: null,
|
|
1068
|
+
parent: null,
|
|
1069
|
+
node: null,
|
|
1070
|
+
nodes: [],
|
|
1071
|
+
stage: null,
|
|
1072
|
+
highlightNode: null,
|
|
1073
|
+
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
1074
|
+
pageLength: 0
|
|
1075
|
+
});
|
|
1076
|
+
isHistoryStateChange = false;
|
|
1077
|
+
constructor() {
|
|
1078
|
+
super([
|
|
1079
|
+
"getLayout",
|
|
1080
|
+
"select",
|
|
1081
|
+
"doAdd",
|
|
1082
|
+
"add",
|
|
1083
|
+
"doRemove",
|
|
1084
|
+
"remove",
|
|
1085
|
+
"doUpdate",
|
|
1086
|
+
"update",
|
|
1087
|
+
"sort",
|
|
1088
|
+
"copy",
|
|
1089
|
+
"paste",
|
|
1090
|
+
"duAlignCenter",
|
|
1091
|
+
"alignCenter",
|
|
1092
|
+
"moveLayer",
|
|
1093
|
+
"moveToContainer",
|
|
1094
|
+
"move",
|
|
1095
|
+
"undo",
|
|
1096
|
+
"redo",
|
|
1097
|
+
"highlight"
|
|
1098
|
+
], ["select", "update", "moveLayer"]);
|
|
1099
|
+
}
|
|
1100
|
+
set(name, value) {
|
|
1101
|
+
this.state[name] = value;
|
|
1102
|
+
if (name === "nodes") {
|
|
1103
|
+
this.set("node", value[0]);
|
|
1104
|
+
}
|
|
1105
|
+
if (name === "root") {
|
|
1106
|
+
this.state.pageLength = value?.items?.length || 0;
|
|
1107
|
+
this.emit("root-change", value);
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
get(name) {
|
|
1111
|
+
return this.state[name];
|
|
1112
|
+
}
|
|
1113
|
+
getNodeInfo(id, raw = true) {
|
|
1114
|
+
let root = this.get("root");
|
|
1115
|
+
if (raw) {
|
|
1116
|
+
root = vue.toRaw(root);
|
|
1117
|
+
}
|
|
1118
|
+
if (!root)
|
|
1119
|
+
return {};
|
|
1120
|
+
if (id === root.id) {
|
|
1121
|
+
return { node: root };
|
|
1122
|
+
}
|
|
1123
|
+
const path = utils.getNodePath(id, root.items);
|
|
1124
|
+
if (!path.length)
|
|
1125
|
+
return {};
|
|
1126
|
+
path.unshift(root);
|
|
1127
|
+
const info = {};
|
|
1128
|
+
info.node = path[path.length - 1];
|
|
1129
|
+
info.parent = path[path.length - 2];
|
|
1130
|
+
path.forEach((item) => {
|
|
1131
|
+
if (item.type === schema.NodeType.PAGE) {
|
|
1132
|
+
info.page = item;
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1135
|
+
});
|
|
1136
|
+
return info;
|
|
1137
|
+
}
|
|
1138
|
+
getNodeById(id, raw = true) {
|
|
1139
|
+
const { node } = this.getNodeInfo(id, raw);
|
|
1140
|
+
return node;
|
|
964
1141
|
}
|
|
965
1142
|
getParentById(id, raw = true) {
|
|
966
1143
|
if (!this.get("root"))
|
|
@@ -979,9 +1156,9 @@
|
|
|
979
1156
|
}
|
|
980
1157
|
return Layout.ABSOLUTE;
|
|
981
1158
|
}
|
|
982
|
-
async select(
|
|
983
|
-
const { node, page, parent } = this.selectedConfigExceptionHandler(
|
|
984
|
-
this.set("
|
|
1159
|
+
async select(config) {
|
|
1160
|
+
const { node, page, parent } = this.selectedConfigExceptionHandler(config);
|
|
1161
|
+
this.set("nodes", [node]);
|
|
985
1162
|
this.set("page", page || null);
|
|
986
1163
|
this.set("parent", parent || null);
|
|
987
1164
|
if (page) {
|
|
@@ -1021,56 +1198,83 @@
|
|
|
1021
1198
|
this.get("stage")?.select(nextPage.id);
|
|
1022
1199
|
return nextPage;
|
|
1023
1200
|
}
|
|
1024
|
-
highlight(
|
|
1025
|
-
const { node } = this.selectedConfigExceptionHandler(
|
|
1201
|
+
highlight(config) {
|
|
1202
|
+
const { node } = this.selectedConfigExceptionHandler(config);
|
|
1026
1203
|
const currentHighlightNode = this.get("highlightNode");
|
|
1027
1204
|
if (currentHighlightNode === node)
|
|
1028
1205
|
return;
|
|
1029
1206
|
this.set("highlightNode", node);
|
|
1030
1207
|
}
|
|
1031
|
-
|
|
1032
|
-
const
|
|
1208
|
+
multiSelect(ids) {
|
|
1209
|
+
const nodes = [];
|
|
1210
|
+
const idsUnique = lodashEs.uniq(ids);
|
|
1211
|
+
idsUnique.forEach((id) => {
|
|
1212
|
+
const { node } = this.getNodeInfo(id);
|
|
1213
|
+
if (!node)
|
|
1214
|
+
return;
|
|
1215
|
+
nodes.push(node);
|
|
1216
|
+
});
|
|
1217
|
+
this.set("nodes", nodes);
|
|
1218
|
+
}
|
|
1219
|
+
async doAdd(node, parent) {
|
|
1220
|
+
const root = this.get("root");
|
|
1033
1221
|
const curNode = this.get("node");
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
if (isPage2) {
|
|
1037
|
-
parentNode = this.get("root");
|
|
1038
|
-
} else if (parent && typeof parent !== "function") {
|
|
1039
|
-
parentNode = parent;
|
|
1040
|
-
} else if (curNode.items) {
|
|
1041
|
-
parentNode = curNode;
|
|
1042
|
-
} else {
|
|
1043
|
-
parentNode = this.getParentById(curNode.id, false);
|
|
1044
|
-
}
|
|
1045
|
-
if (!parentNode)
|
|
1046
|
-
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1047
|
-
const layout = await this.getLayout(vue.toRaw(parentNode), addNode);
|
|
1048
|
-
const newNode = initPosition({ ...vue.toRaw(await propsService.getPropsValue(type, config2)) }, layout, parentNode, this.get("stage"));
|
|
1049
|
-
if ((parentNode?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && newNode.type !== schema.NodeType.PAGE) {
|
|
1222
|
+
const stage = this.get("stage");
|
|
1223
|
+
if ((parent?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && node.type !== schema.NodeType.PAGE) {
|
|
1050
1224
|
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
1051
1225
|
}
|
|
1052
|
-
|
|
1226
|
+
parent?.items?.push(node);
|
|
1227
|
+
const layout = await this.getLayout(vue.toRaw(parent), node);
|
|
1228
|
+
node.style = getInitPositionStyle(node.style, layout);
|
|
1229
|
+
await stage?.add({
|
|
1230
|
+
config: lodashEs.cloneDeep(node),
|
|
1231
|
+
parent: lodashEs.cloneDeep(parent),
|
|
1232
|
+
parentId: parent.id,
|
|
1233
|
+
root: lodashEs.cloneDeep(root)
|
|
1234
|
+
});
|
|
1235
|
+
node.style = fixNodePosition(node, parent, stage);
|
|
1236
|
+
await stage?.update({ config: lodashEs.cloneDeep(node), parentId: parent.id, root: lodashEs.cloneDeep(root) });
|
|
1237
|
+
this.addModifiedNodeId(node.id);
|
|
1238
|
+
return node;
|
|
1239
|
+
}
|
|
1240
|
+
async add(addNode, parent) {
|
|
1053
1241
|
const stage = this.get("stage");
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1242
|
+
const addNodes = [];
|
|
1243
|
+
if (!Array.isArray(addNode)) {
|
|
1244
|
+
const { type, inputEvent, ...config } = addNode;
|
|
1245
|
+
if (!type)
|
|
1246
|
+
throw new Error("\u7EC4\u4EF6\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A");
|
|
1247
|
+
addNodes.push({ ...vue.toRaw(await propsService.getPropsValue(type, config)) });
|
|
1248
|
+
} else {
|
|
1249
|
+
addNodes.push(...addNode);
|
|
1059
1250
|
}
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1251
|
+
const newNodes = await Promise.all(addNodes.map((node) => {
|
|
1252
|
+
const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
|
|
1253
|
+
if (!parentNode)
|
|
1254
|
+
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1255
|
+
return this.doAdd(node, parentNode);
|
|
1256
|
+
}));
|
|
1257
|
+
if (newNodes.length > 1) {
|
|
1258
|
+
const newNodeIds = newNodes.map((node) => node.id);
|
|
1259
|
+
stage?.multiSelect(newNodeIds);
|
|
1260
|
+
await this.multiSelect(newNodeIds);
|
|
1261
|
+
} else {
|
|
1262
|
+
await this.select(newNodes[0]);
|
|
1263
|
+
if (utils.isPage(newNodes[0])) {
|
|
1264
|
+
this.state.pageLength += 1;
|
|
1265
|
+
} else {
|
|
1266
|
+
stage?.select(newNodes[0].id);
|
|
1267
|
+
}
|
|
1063
1268
|
}
|
|
1064
|
-
this.
|
|
1065
|
-
|
|
1269
|
+
this.pushHistoryState();
|
|
1270
|
+
this.emit("add", newNodes);
|
|
1271
|
+
return newNodes.length > 1 ? newNodes[0] : newNodes;
|
|
1066
1272
|
}
|
|
1067
|
-
async
|
|
1068
|
-
if (!node?.id)
|
|
1069
|
-
return;
|
|
1273
|
+
async doRemove(node) {
|
|
1070
1274
|
const root = this.get("root");
|
|
1071
1275
|
if (!root)
|
|
1072
1276
|
throw new Error("\u6CA1\u6709root");
|
|
1073
|
-
const { parent, node: curNode } = this.getNodeInfo(node.id
|
|
1277
|
+
const { parent, node: curNode } = this.getNodeInfo(node.id);
|
|
1074
1278
|
if (!parent || !curNode)
|
|
1075
1279
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1076
1280
|
const index = getNodeIndex(curNode, parent);
|
|
@@ -1078,7 +1282,7 @@
|
|
|
1078
1282
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1079
1283
|
parent.items?.splice(index, 1);
|
|
1080
1284
|
const stage = this.get("stage");
|
|
1081
|
-
stage?.remove({ id: node.id, root:
|
|
1285
|
+
stage?.remove({ id: node.id, parentId: parent.id, root: lodashEs.cloneDeep(root) });
|
|
1082
1286
|
if (node.type === schema.NodeType.PAGE) {
|
|
1083
1287
|
this.state.pageLength -= 1;
|
|
1084
1288
|
if (root.items[0]) {
|
|
@@ -1092,26 +1296,28 @@
|
|
|
1092
1296
|
this.set("highlightNode", null);
|
|
1093
1297
|
this.resetModifiedNodeId();
|
|
1094
1298
|
historyService.reset();
|
|
1095
|
-
|
|
1096
|
-
return node;
|
|
1299
|
+
return;
|
|
1097
1300
|
}
|
|
1098
1301
|
} else {
|
|
1099
1302
|
await this.select(parent);
|
|
1100
1303
|
stage?.select(parent.id);
|
|
1101
1304
|
}
|
|
1102
1305
|
this.addModifiedNodeId(parent.id);
|
|
1306
|
+
}
|
|
1307
|
+
async remove(nodeOrNodeList) {
|
|
1308
|
+
const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
|
|
1309
|
+
await Promise.all(nodes.map((node) => this.doRemove(node)));
|
|
1103
1310
|
this.pushHistoryState();
|
|
1104
|
-
this.emit("remove"
|
|
1105
|
-
return node;
|
|
1311
|
+
this.emit("remove");
|
|
1106
1312
|
}
|
|
1107
|
-
async
|
|
1108
|
-
if (!
|
|
1313
|
+
async doUpdate(config) {
|
|
1314
|
+
if (!config?.id)
|
|
1109
1315
|
throw new Error("\u6CA1\u6709\u914D\u7F6E\u6216\u8005\u914D\u7F6E\u7F3A\u5C11id\u503C");
|
|
1110
|
-
const info = this.getNodeInfo(
|
|
1316
|
+
const info = this.getNodeInfo(config.id, false);
|
|
1111
1317
|
if (!info.node)
|
|
1112
|
-
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${
|
|
1318
|
+
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config.id}\u7684\u8282\u70B9`);
|
|
1113
1319
|
const node = lodashEs.cloneDeep(vue.toRaw(info.node));
|
|
1114
|
-
let newConfig = await this.toggleFixedPosition(vue.toRaw(
|
|
1320
|
+
let newConfig = await this.toggleFixedPosition(vue.toRaw(config), node, this.get("root"));
|
|
1115
1321
|
newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), newConfig, (objValue, srcValue) => {
|
|
1116
1322
|
if (Array.isArray(srcValue)) {
|
|
1117
1323
|
return srcValue;
|
|
@@ -1136,18 +1342,28 @@
|
|
|
1136
1342
|
newConfig = setLayout(newConfig, newLayout);
|
|
1137
1343
|
}
|
|
1138
1344
|
parentNodeItems[index] = newConfig;
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
this.
|
|
1345
|
+
const nodes = this.get("nodes");
|
|
1346
|
+
const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
|
|
1347
|
+
nodes.splice(targetIndex, 1, newConfig);
|
|
1348
|
+
this.set("nodes", nodes);
|
|
1349
|
+
this.get("stage")?.update({
|
|
1350
|
+
config: lodashEs.cloneDeep(newConfig),
|
|
1351
|
+
parentId: parent.id,
|
|
1352
|
+
root: lodashEs.cloneDeep(this.get("root"))
|
|
1353
|
+
});
|
|
1143
1354
|
if (newConfig.type === schema.NodeType.PAGE) {
|
|
1144
1355
|
this.set("page", newConfig);
|
|
1145
1356
|
}
|
|
1146
1357
|
this.addModifiedNodeId(newConfig.id);
|
|
1147
|
-
this.pushHistoryState();
|
|
1148
|
-
this.emit("update", newConfig);
|
|
1149
1358
|
return newConfig;
|
|
1150
1359
|
}
|
|
1360
|
+
async update(config) {
|
|
1361
|
+
const nodes = Array.isArray(config) ? config : [config];
|
|
1362
|
+
const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
|
|
1363
|
+
this.pushHistoryState();
|
|
1364
|
+
this.emit("update", newNodes);
|
|
1365
|
+
return newNodes.length > 1 ? newNodes[0] : newNodes;
|
|
1366
|
+
}
|
|
1151
1367
|
async sort(id1, id2) {
|
|
1152
1368
|
const node = this.get("node");
|
|
1153
1369
|
const parent = lodashEs.cloneDeep(vue.toRaw(this.get("parent")));
|
|
@@ -1158,62 +1374,57 @@
|
|
|
1158
1374
|
parent.items.splice(index2, 0, ...parent.items.splice(index1, 1));
|
|
1159
1375
|
await this.update(parent);
|
|
1160
1376
|
await this.select(node);
|
|
1161
|
-
this.get("stage")?.update({
|
|
1377
|
+
this.get("stage")?.update({
|
|
1378
|
+
config: lodashEs.cloneDeep(node),
|
|
1379
|
+
parentId: parent.id,
|
|
1380
|
+
root: lodashEs.cloneDeep(this.get("root"))
|
|
1381
|
+
});
|
|
1162
1382
|
this.addModifiedNodeId(parent.id);
|
|
1163
1383
|
this.pushHistoryState();
|
|
1164
1384
|
}
|
|
1165
|
-
async copy(
|
|
1166
|
-
|
|
1385
|
+
async copy(config) {
|
|
1386
|
+
await storageService.setItem(COPY_STORAGE_KEY, Array.isArray(config) ? config : [config], {
|
|
1387
|
+
protocol: Protocol.OBJECT
|
|
1388
|
+
});
|
|
1167
1389
|
}
|
|
1168
1390
|
async paste(position = {}) {
|
|
1169
|
-
const
|
|
1170
|
-
|
|
1171
|
-
if (!configStr) {
|
|
1172
|
-
return;
|
|
1173
|
-
}
|
|
1174
|
-
try {
|
|
1175
|
-
eval(`config = ${configStr}`);
|
|
1176
|
-
} catch (e) {
|
|
1177
|
-
console.error(e);
|
|
1391
|
+
const config = await storageService.getItem(COPY_STORAGE_KEY);
|
|
1392
|
+
if (!Array.isArray(config))
|
|
1178
1393
|
return;
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
if (config.style) {
|
|
1182
|
-
config.style = {
|
|
1183
|
-
...config.style,
|
|
1184
|
-
...position
|
|
1185
|
-
};
|
|
1186
|
-
}
|
|
1187
|
-
if (utils.isPage(config)) {
|
|
1188
|
-
config.name = generatePageNameByApp(this.get("root"));
|
|
1189
|
-
}
|
|
1190
|
-
return await this.add(config);
|
|
1394
|
+
const pasteConfigs = await beforePaste(position, config);
|
|
1395
|
+
return this.add(pasteConfigs);
|
|
1191
1396
|
}
|
|
1192
|
-
async
|
|
1193
|
-
const parent = this.
|
|
1194
|
-
|
|
1195
|
-
|
|
1397
|
+
async doAlignCenter(config) {
|
|
1398
|
+
const parent = this.getParentById(config.id);
|
|
1399
|
+
if (!parent)
|
|
1400
|
+
throw new Error("\u627E\u4E0D\u5230\u7236\u8282\u70B9");
|
|
1401
|
+
const node = lodashEs.cloneDeep(vue.toRaw(config));
|
|
1402
|
+
const layout = await this.getLayout(parent, node);
|
|
1196
1403
|
if (layout === Layout.RELATIVE) {
|
|
1197
|
-
return;
|
|
1404
|
+
return config;
|
|
1198
1405
|
}
|
|
1199
1406
|
if (!node.style)
|
|
1200
|
-
return;
|
|
1407
|
+
return config;
|
|
1201
1408
|
const stage = this.get("stage");
|
|
1202
1409
|
const doc = stage?.renderer.contentWindow?.document;
|
|
1203
1410
|
if (doc) {
|
|
1204
|
-
const parentEl = doc.getElementById(`${parent.id}`);
|
|
1205
1411
|
const el = doc.getElementById(`${node.id}`);
|
|
1412
|
+
const parentEl = el?.offsetParent;
|
|
1206
1413
|
if (parentEl && el) {
|
|
1207
1414
|
node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
|
|
1208
1415
|
}
|
|
1209
1416
|
} else if (parent.style && utils.isNumber(parent.style?.width) && utils.isNumber(node.style?.width)) {
|
|
1210
1417
|
node.style.left = (parent.style.width - node.style.width) / 2;
|
|
1211
1418
|
}
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1419
|
+
return node;
|
|
1420
|
+
}
|
|
1421
|
+
async alignCenter(config) {
|
|
1422
|
+
const nodes = Array.isArray(config) ? config : [config];
|
|
1423
|
+
const stage = this.get("stage");
|
|
1424
|
+
const newNodes = await Promise.all(nodes.map((node) => this.doAlignCenter(node)));
|
|
1425
|
+
const newNode = await this.update(newNodes);
|
|
1426
|
+
await stage?.multiSelect(newNodes.map((node) => node.id));
|
|
1427
|
+
return newNode;
|
|
1217
1428
|
}
|
|
1218
1429
|
async moveLayer(offset) {
|
|
1219
1430
|
const parent = this.get("parent");
|
|
@@ -1227,7 +1438,38 @@
|
|
|
1227
1438
|
} else {
|
|
1228
1439
|
brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
|
|
1229
1440
|
}
|
|
1230
|
-
this.get("stage")?.update({
|
|
1441
|
+
this.get("stage")?.update({
|
|
1442
|
+
config: lodashEs.cloneDeep(vue.toRaw(parent)),
|
|
1443
|
+
parentId: parent.id,
|
|
1444
|
+
root: lodashEs.cloneDeep(this.get("root"))
|
|
1445
|
+
});
|
|
1446
|
+
}
|
|
1447
|
+
async moveToContainer(config, targetId) {
|
|
1448
|
+
const { node, parent } = this.getNodeInfo(config.id, false);
|
|
1449
|
+
const target = this.getNodeById(targetId, false);
|
|
1450
|
+
const stage = this.get("stage");
|
|
1451
|
+
if (node && parent && stage) {
|
|
1452
|
+
const root = lodashEs.cloneDeep(this.get("root"));
|
|
1453
|
+
const index = getNodeIndex(node, parent);
|
|
1454
|
+
parent.items?.splice(index, 1);
|
|
1455
|
+
await stage.remove({ id: node.id, parentId: parent.id, root });
|
|
1456
|
+
const layout = await this.getLayout(target);
|
|
1457
|
+
const newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), config, (objValue, srcValue) => {
|
|
1458
|
+
if (Array.isArray(srcValue)) {
|
|
1459
|
+
return srcValue;
|
|
1460
|
+
}
|
|
1461
|
+
});
|
|
1462
|
+
newConfig.style = getInitPositionStyle(newConfig.style, layout);
|
|
1463
|
+
target.items.push(newConfig);
|
|
1464
|
+
await stage.select(targetId);
|
|
1465
|
+
await stage.update({ config: lodashEs.cloneDeep(target), parentId: parent.id, root });
|
|
1466
|
+
await this.select(newConfig);
|
|
1467
|
+
stage.select(newConfig.id);
|
|
1468
|
+
this.addModifiedNodeId(target.id);
|
|
1469
|
+
this.addModifiedNodeId(parent.id);
|
|
1470
|
+
this.pushHistoryState();
|
|
1471
|
+
return newConfig;
|
|
1472
|
+
}
|
|
1231
1473
|
}
|
|
1232
1474
|
async undo() {
|
|
1233
1475
|
const value = historyService.undo();
|
|
@@ -1243,7 +1485,7 @@
|
|
|
1243
1485
|
const node = vue.toRaw(this.get("node"));
|
|
1244
1486
|
if (!node || utils.isPage(node))
|
|
1245
1487
|
return;
|
|
1246
|
-
const { style, id } = node;
|
|
1488
|
+
const { style, id, type } = node;
|
|
1247
1489
|
if (!style || style.position !== "absolute")
|
|
1248
1490
|
return;
|
|
1249
1491
|
if (top && !utils.isNumber(style.top))
|
|
@@ -1252,6 +1494,7 @@
|
|
|
1252
1494
|
return;
|
|
1253
1495
|
this.update({
|
|
1254
1496
|
id,
|
|
1497
|
+
type,
|
|
1255
1498
|
style: {
|
|
1256
1499
|
...style,
|
|
1257
1500
|
left: Number(style.left) + left,
|
|
@@ -1263,6 +1506,7 @@
|
|
|
1263
1506
|
this.removeAllListeners();
|
|
1264
1507
|
this.set("root", null);
|
|
1265
1508
|
this.set("node", null);
|
|
1509
|
+
this.set("nodes", []);
|
|
1266
1510
|
this.set("page", null);
|
|
1267
1511
|
this.set("parent", null);
|
|
1268
1512
|
}
|
|
@@ -1299,22 +1543,22 @@
|
|
|
1299
1543
|
}, 0);
|
|
1300
1544
|
}
|
|
1301
1545
|
async toggleFixedPosition(dist, src, root) {
|
|
1302
|
-
|
|
1546
|
+
const newConfig = lodashEs.cloneDeep(dist);
|
|
1303
1547
|
if (!utils.isPop(src) && newConfig.style?.position) {
|
|
1304
1548
|
if (isFixed(newConfig) && !isFixed(src)) {
|
|
1305
|
-
newConfig = change2Fixed(newConfig, root);
|
|
1549
|
+
newConfig.style = change2Fixed(newConfig, root);
|
|
1306
1550
|
} else if (!isFixed(newConfig) && isFixed(src)) {
|
|
1307
|
-
newConfig = await Fixed2Other(newConfig, root, this.getLayout);
|
|
1551
|
+
newConfig.style = await Fixed2Other(newConfig, root, this.getLayout);
|
|
1308
1552
|
}
|
|
1309
1553
|
}
|
|
1310
1554
|
return newConfig;
|
|
1311
1555
|
}
|
|
1312
|
-
selectedConfigExceptionHandler(
|
|
1556
|
+
selectedConfigExceptionHandler(config) {
|
|
1313
1557
|
let id;
|
|
1314
|
-
if (typeof
|
|
1315
|
-
id =
|
|
1558
|
+
if (typeof config === "string" || typeof config === "number") {
|
|
1559
|
+
id = config;
|
|
1316
1560
|
} else {
|
|
1317
|
-
id =
|
|
1561
|
+
id = config.id;
|
|
1318
1562
|
}
|
|
1319
1563
|
if (!id) {
|
|
1320
1564
|
throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
|
|
@@ -1332,7 +1576,7 @@
|
|
|
1332
1576
|
};
|
|
1333
1577
|
}
|
|
1334
1578
|
}
|
|
1335
|
-
|
|
1579
|
+
const editorService = new Editor$1();
|
|
1336
1580
|
|
|
1337
1581
|
const eventMap = vue.reactive({});
|
|
1338
1582
|
const methodMap = vue.reactive({});
|
|
@@ -1376,7 +1620,7 @@
|
|
|
1376
1620
|
return lodashEs.cloneDeep(methodMap[type] || core.DEFAULT_METHODS);
|
|
1377
1621
|
}
|
|
1378
1622
|
}
|
|
1379
|
-
|
|
1623
|
+
const eventsService = new Events();
|
|
1380
1624
|
|
|
1381
1625
|
const fillConfig = (config = []) => [
|
|
1382
1626
|
{
|
|
@@ -1582,22 +1826,35 @@
|
|
|
1582
1826
|
}
|
|
1583
1827
|
];
|
|
1584
1828
|
const DEFAULT_CONFIG = fillConfig([]);
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1829
|
+
|
|
1830
|
+
const log = (...args) => {
|
|
1831
|
+
if (process.env.NODE_ENV === "development") {
|
|
1832
|
+
console.log("magic editor: ", ...args);
|
|
1833
|
+
}
|
|
1834
|
+
};
|
|
1835
|
+
const info = (...args) => {
|
|
1836
|
+
if (process.env.NODE_ENV === "development") {
|
|
1837
|
+
console.info("magic editor: ", ...args);
|
|
1838
|
+
}
|
|
1839
|
+
};
|
|
1840
|
+
const warn = (...args) => {
|
|
1841
|
+
if (process.env.NODE_ENV === "development") {
|
|
1842
|
+
console.warn("magic editor: ", ...args);
|
|
1843
|
+
}
|
|
1844
|
+
};
|
|
1845
|
+
const debug = (...args) => {
|
|
1846
|
+
if (process.env.NODE_ENV === "development") {
|
|
1847
|
+
console.debug("magic editor: ", ...args);
|
|
1848
|
+
}
|
|
1849
|
+
};
|
|
1850
|
+
const error = (...args) => {
|
|
1851
|
+
if (process.env.NODE_ENV === "development") {
|
|
1852
|
+
console.error("magic editor: ", ...args);
|
|
1853
|
+
}
|
|
1597
1854
|
};
|
|
1598
1855
|
|
|
1599
|
-
const _sfc_main$
|
|
1600
|
-
components: { Plus:
|
|
1856
|
+
const _sfc_main$j = vue.defineComponent({
|
|
1857
|
+
components: { Plus: iconsVue.Plus },
|
|
1601
1858
|
setup() {
|
|
1602
1859
|
const services = vue.inject("services");
|
|
1603
1860
|
return {
|
|
@@ -1613,10 +1870,11 @@
|
|
|
1613
1870
|
};
|
|
1614
1871
|
}
|
|
1615
1872
|
});
|
|
1873
|
+
|
|
1616
1874
|
const _hoisted_1$b = { class: "m-editor-empty-panel" };
|
|
1617
1875
|
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
1618
|
-
const _hoisted_3$
|
|
1619
|
-
function _sfc_render$
|
|
1876
|
+
const _hoisted_3$1 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
1877
|
+
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1620
1878
|
const _component_plus = vue.resolveComponent("plus");
|
|
1621
1879
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
1622
1880
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
|
|
@@ -1633,14 +1891,14 @@
|
|
|
1633
1891
|
_: 1
|
|
1634
1892
|
})
|
|
1635
1893
|
]),
|
|
1636
|
-
_hoisted_3$
|
|
1894
|
+
_hoisted_3$1
|
|
1637
1895
|
])
|
|
1638
1896
|
])
|
|
1639
1897
|
]);
|
|
1640
1898
|
}
|
|
1641
|
-
|
|
1899
|
+
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$d]]);
|
|
1642
1900
|
|
|
1643
|
-
const _sfc_main$
|
|
1901
|
+
const _sfc_main$i = vue.defineComponent({
|
|
1644
1902
|
name: "m-editor-resize",
|
|
1645
1903
|
props: {
|
|
1646
1904
|
type: {
|
|
@@ -1654,7 +1912,7 @@
|
|
|
1654
1912
|
vue.onMounted(() => {
|
|
1655
1913
|
if (!target.value)
|
|
1656
1914
|
return;
|
|
1657
|
-
getso = new Gesto__default
|
|
1915
|
+
getso = new Gesto__default.default(target.value, {
|
|
1658
1916
|
container: window,
|
|
1659
1917
|
pinchOutside: true
|
|
1660
1918
|
}).on("drag", (e) => {
|
|
@@ -1682,18 +1940,19 @@
|
|
|
1682
1940
|
};
|
|
1683
1941
|
}
|
|
1684
1942
|
});
|
|
1943
|
+
|
|
1685
1944
|
const _hoisted_1$a = {
|
|
1686
1945
|
ref: "target",
|
|
1687
1946
|
class: "m-editor-resizer"
|
|
1688
1947
|
};
|
|
1689
|
-
function _sfc_render$
|
|
1948
|
+
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1690
1949
|
return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$a, [
|
|
1691
1950
|
vue.renderSlot(_ctx.$slots, "default")
|
|
1692
1951
|
], 512);
|
|
1693
1952
|
}
|
|
1694
|
-
|
|
1953
|
+
const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$c]]);
|
|
1695
1954
|
|
|
1696
|
-
const _sfc_main$
|
|
1955
|
+
const _sfc_main$h = vue.defineComponent({
|
|
1697
1956
|
components: {
|
|
1698
1957
|
AddPageBox,
|
|
1699
1958
|
Resizer
|
|
@@ -1722,12 +1981,13 @@
|
|
|
1722
1981
|
};
|
|
1723
1982
|
}
|
|
1724
1983
|
});
|
|
1984
|
+
|
|
1725
1985
|
const _hoisted_1$9 = { class: "m-editor" };
|
|
1726
1986
|
const _hoisted_2$3 = {
|
|
1727
1987
|
key: 1,
|
|
1728
1988
|
class: "m-editor-content"
|
|
1729
1989
|
};
|
|
1730
|
-
function _sfc_render$
|
|
1990
|
+
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1731
1991
|
const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
|
|
1732
1992
|
const _component_resizer = vue.resolveComponent("resizer");
|
|
1733
1993
|
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
|
|
@@ -1773,11 +2033,11 @@
|
|
|
1773
2033
|
]))
|
|
1774
2034
|
]);
|
|
1775
2035
|
}
|
|
1776
|
-
|
|
2036
|
+
const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$b]]);
|
|
1777
2037
|
|
|
1778
|
-
const _sfc_main$
|
|
2038
|
+
const _sfc_main$g = vue.defineComponent({
|
|
1779
2039
|
name: "m-icon",
|
|
1780
|
-
components: { Edit:
|
|
2040
|
+
components: { Edit: iconsVue.Edit },
|
|
1781
2041
|
props: {
|
|
1782
2042
|
icon: {
|
|
1783
2043
|
type: [String, Object]
|
|
@@ -1789,8 +2049,9 @@
|
|
|
1789
2049
|
};
|
|
1790
2050
|
}
|
|
1791
2051
|
});
|
|
2052
|
+
|
|
1792
2053
|
const _hoisted_1$8 = ["src"];
|
|
1793
|
-
function _sfc_render$
|
|
2054
|
+
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1794
2055
|
const _component_edit = vue.resolveComponent("edit");
|
|
1795
2056
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
1796
2057
|
return !_ctx.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
|
|
@@ -1798,10 +2059,12 @@
|
|
|
1798
2059
|
vue.createVNode(_component_edit)
|
|
1799
2060
|
]),
|
|
1800
2061
|
_: 1
|
|
1801
|
-
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
2062
|
+
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 1 }, {
|
|
2063
|
+
default: vue.withCtx(() => [
|
|
2064
|
+
vue.createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$8)
|
|
2065
|
+
]),
|
|
2066
|
+
_: 1
|
|
2067
|
+
})) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
|
|
1805
2068
|
key: 2,
|
|
1806
2069
|
class: vue.normalizeClass(_ctx.icon)
|
|
1807
2070
|
}, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
|
|
@@ -1811,10 +2074,19 @@
|
|
|
1811
2074
|
_: 1
|
|
1812
2075
|
}));
|
|
1813
2076
|
}
|
|
1814
|
-
|
|
2077
|
+
const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
|
|
1815
2078
|
|
|
1816
|
-
const
|
|
1817
|
-
|
|
2079
|
+
const _hoisted_1$7 = {
|
|
2080
|
+
key: 1,
|
|
2081
|
+
class: "menu-item-text"
|
|
2082
|
+
};
|
|
2083
|
+
const _hoisted_2$2 = {
|
|
2084
|
+
class: "menu-item-text",
|
|
2085
|
+
style: { "margin": "0 5px" }
|
|
2086
|
+
};
|
|
2087
|
+
const _hoisted_3 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2088
|
+
const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
2089
|
+
__name: "ToolButton",
|
|
1818
2090
|
props: {
|
|
1819
2091
|
data: {
|
|
1820
2092
|
type: [Object, String],
|
|
@@ -1829,7 +2101,8 @@
|
|
|
1829
2101
|
default: "click"
|
|
1830
2102
|
}
|
|
1831
2103
|
},
|
|
1832
|
-
setup(
|
|
2104
|
+
setup(__props) {
|
|
2105
|
+
const props = __props;
|
|
1833
2106
|
const services = vue.inject("services");
|
|
1834
2107
|
const uiService = services?.uiService;
|
|
1835
2108
|
const zoom = vue.computed(() => uiService?.get("zoom") ?? 1);
|
|
@@ -1853,7 +2126,7 @@
|
|
|
1853
2126
|
case "delete":
|
|
1854
2127
|
return {
|
|
1855
2128
|
type: "button",
|
|
1856
|
-
icon: vue.markRaw(
|
|
2129
|
+
icon: vue.markRaw(iconsVue.Delete),
|
|
1857
2130
|
tooltip: "\u522A\u9664",
|
|
1858
2131
|
disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
|
|
1859
2132
|
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
@@ -1861,7 +2134,7 @@
|
|
|
1861
2134
|
case "undo":
|
|
1862
2135
|
return {
|
|
1863
2136
|
type: "button",
|
|
1864
|
-
icon: vue.markRaw(
|
|
2137
|
+
icon: vue.markRaw(iconsVue.Back),
|
|
1865
2138
|
tooltip: "\u540E\u9000",
|
|
1866
2139
|
disabled: () => !services?.historyService.state.canUndo,
|
|
1867
2140
|
handler: () => services?.editorService.undo()
|
|
@@ -1869,7 +2142,7 @@
|
|
|
1869
2142
|
case "redo":
|
|
1870
2143
|
return {
|
|
1871
2144
|
type: "button",
|
|
1872
|
-
icon: vue.markRaw(
|
|
2145
|
+
icon: vue.markRaw(iconsVue.Right),
|
|
1873
2146
|
tooltip: "\u524D\u8FDB",
|
|
1874
2147
|
disabled: () => !services?.historyService.state.canRedo,
|
|
1875
2148
|
handler: () => services?.editorService.redo()
|
|
@@ -1877,28 +2150,28 @@
|
|
|
1877
2150
|
case "zoom-in":
|
|
1878
2151
|
return {
|
|
1879
2152
|
type: "button",
|
|
1880
|
-
icon: vue.markRaw(
|
|
2153
|
+
icon: vue.markRaw(iconsVue.ZoomIn),
|
|
1881
2154
|
tooltip: "\u653E\u5927",
|
|
1882
2155
|
handler: zoomInHandler
|
|
1883
2156
|
};
|
|
1884
2157
|
case "zoom-out":
|
|
1885
2158
|
return {
|
|
1886
2159
|
type: "button",
|
|
1887
|
-
icon: vue.markRaw(
|
|
2160
|
+
icon: vue.markRaw(iconsVue.ZoomOut),
|
|
1888
2161
|
tooltip: "\u7E2E\u5C0F",
|
|
1889
2162
|
handler: zoomOutHandler
|
|
1890
2163
|
};
|
|
1891
2164
|
case "rule":
|
|
1892
2165
|
return {
|
|
1893
2166
|
type: "button",
|
|
1894
|
-
icon: vue.markRaw(
|
|
2167
|
+
icon: vue.markRaw(iconsVue.ScaleToOriginal),
|
|
1895
2168
|
tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
|
|
1896
2169
|
handler: () => uiService?.set("showRule", !showRule.value)
|
|
1897
2170
|
};
|
|
1898
2171
|
case "guides":
|
|
1899
2172
|
return {
|
|
1900
2173
|
type: "button",
|
|
1901
|
-
icon: vue.markRaw(
|
|
2174
|
+
icon: vue.markRaw(iconsVue.Grid),
|
|
1902
2175
|
tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
|
|
1903
2176
|
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
1904
2177
|
};
|
|
@@ -1926,176 +2199,155 @@
|
|
|
1926
2199
|
item2.handler?.(services, event);
|
|
1927
2200
|
}
|
|
1928
2201
|
};
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
item
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
}
|
|
1943
|
-
return item.value.display ?? true;
|
|
1944
|
-
}),
|
|
1945
|
-
zoomInHandler,
|
|
1946
|
-
zoomOutHandler,
|
|
1947
|
-
dropdownHandler(command) {
|
|
1948
|
-
if (command.item.handler) {
|
|
1949
|
-
command.item.handler(services);
|
|
1950
|
-
}
|
|
1951
|
-
},
|
|
1952
|
-
clickHandler(item2, event) {
|
|
1953
|
-
if (props.eventType !== "click")
|
|
1954
|
-
return;
|
|
1955
|
-
if (item2.type === "button") {
|
|
1956
|
-
buttonHandler(item2, event);
|
|
1957
|
-
}
|
|
1958
|
-
},
|
|
1959
|
-
mousedownHandler(item2, event) {
|
|
1960
|
-
if (props.eventType !== "mousedown")
|
|
1961
|
-
return;
|
|
1962
|
-
if (item2.type === "button") {
|
|
1963
|
-
buttonHandler(item2, event);
|
|
1964
|
-
}
|
|
1965
|
-
},
|
|
1966
|
-
mouseupHandler(item2, event) {
|
|
1967
|
-
if (props.eventType !== "mouseup")
|
|
1968
|
-
return;
|
|
1969
|
-
if (item2.type === "button") {
|
|
1970
|
-
buttonHandler(item2, event);
|
|
1971
|
-
}
|
|
2202
|
+
const display = vue.computed(() => {
|
|
2203
|
+
if (!item.value)
|
|
2204
|
+
return false;
|
|
2205
|
+
if (typeof item.value === "string")
|
|
2206
|
+
return true;
|
|
2207
|
+
if (typeof item.value.display === "function") {
|
|
2208
|
+
return item.value.display(services);
|
|
2209
|
+
}
|
|
2210
|
+
return item.value.display ?? true;
|
|
2211
|
+
});
|
|
2212
|
+
const dropdownHandler = (command) => {
|
|
2213
|
+
if (command.item.handler) {
|
|
2214
|
+
command.item.handler(services);
|
|
1972
2215
|
}
|
|
1973
2216
|
};
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
direction: _ctx.item.direction || "vertical"
|
|
2006
|
-
}, 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 }, [
|
|
2007
|
-
vue.createVNode(_component_tool_button, {
|
|
2008
|
-
data: { type: "button", icon: _ctx.ZoomOut, handler: _ctx.zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
2009
|
-
"event-type": _ctx.eventType
|
|
2010
|
-
}, null, 8, ["data", "event-type"]),
|
|
2011
|
-
vue.createElementVNode("span", _hoisted_2$2, vue.toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
|
|
2012
|
-
vue.createVNode(_component_tool_button, {
|
|
2013
|
-
data: { type: "button", icon: _ctx.ZoomIn, handler: _ctx.zoomInHandler, tooltip: "\u653E\u5927" },
|
|
2014
|
-
"event-type": _ctx.eventType
|
|
2015
|
-
}, null, 8, ["data", "event-type"])
|
|
2016
|
-
], 64)) : _ctx.item.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
|
|
2017
|
-
_ctx.item.tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
|
|
2217
|
+
const clickHandler = (item2, event) => {
|
|
2218
|
+
if (props.eventType !== "click")
|
|
2219
|
+
return;
|
|
2220
|
+
if (item2.type === "button") {
|
|
2221
|
+
buttonHandler(item2, event);
|
|
2222
|
+
}
|
|
2223
|
+
};
|
|
2224
|
+
const mousedownHandler = (item2, event) => {
|
|
2225
|
+
if (props.eventType !== "mousedown")
|
|
2226
|
+
return;
|
|
2227
|
+
if (item2.type === "button") {
|
|
2228
|
+
buttonHandler(item2, event);
|
|
2229
|
+
}
|
|
2230
|
+
};
|
|
2231
|
+
const mouseupHandler = (item2, event) => {
|
|
2232
|
+
if (props.eventType !== "mouseup")
|
|
2233
|
+
return;
|
|
2234
|
+
if (item2.type === "button") {
|
|
2235
|
+
buttonHandler(item2, event);
|
|
2236
|
+
}
|
|
2237
|
+
};
|
|
2238
|
+
return (_ctx, _cache) => {
|
|
2239
|
+
const _component_el_divider = vue.resolveComponent("el-divider");
|
|
2240
|
+
const _component_tool_button = vue.resolveComponent("tool-button", true);
|
|
2241
|
+
const _component_el_button = vue.resolveComponent("el-button");
|
|
2242
|
+
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
2243
|
+
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
2244
|
+
const _component_el_dropdown_item = vue.resolveComponent("el-dropdown-item");
|
|
2245
|
+
const _component_el_dropdown_menu = vue.resolveComponent("el-dropdown-menu");
|
|
2246
|
+
const _component_el_dropdown = vue.resolveComponent("el-dropdown");
|
|
2247
|
+
return vue.unref(display) ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
2018
2248
|
key: 0,
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2249
|
+
class: vue.normalizeClass(["menu-item", vue.unref(item).type]),
|
|
2250
|
+
onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(vue.unref(item), $event)),
|
|
2251
|
+
onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(vue.unref(item), $event)),
|
|
2252
|
+
onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(vue.unref(item), $event))
|
|
2253
|
+
}, [
|
|
2254
|
+
vue.unref(item).type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
|
|
2255
|
+
key: 0,
|
|
2256
|
+
direction: vue.unref(item).direction || "vertical"
|
|
2257
|
+
}, 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 }, [
|
|
2258
|
+
vue.createVNode(_component_tool_button, {
|
|
2259
|
+
data: { type: "button", icon: vue.unref(iconsVue.ZoomOut), handler: zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
2260
|
+
"event-type": __props.eventType
|
|
2261
|
+
}, null, 8, ["data", "event-type"]),
|
|
2262
|
+
vue.createElementVNode("span", _hoisted_2$2, vue.toDisplayString(parseInt(`${vue.unref(zoom) * 100}`, 10)) + "%", 1),
|
|
2263
|
+
vue.createVNode(_component_tool_button, {
|
|
2264
|
+
data: { type: "button", icon: vue.unref(iconsVue.ZoomIn), handler: zoomInHandler, tooltip: "\u653E\u5927" },
|
|
2265
|
+
"event-type": __props.eventType
|
|
2266
|
+
}, null, 8, ["data", "event-type"])
|
|
2267
|
+
], 64)) : vue.unref(item).type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
|
|
2268
|
+
vue.unref(item).tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
|
|
2269
|
+
key: 0,
|
|
2270
|
+
effect: "dark",
|
|
2271
|
+
placement: "bottom-start",
|
|
2272
|
+
content: vue.unref(item).tooltip
|
|
2273
|
+
}, {
|
|
2274
|
+
default: vue.withCtx(() => [
|
|
2275
|
+
vue.createVNode(_component_el_button, {
|
|
2276
|
+
size: "small",
|
|
2277
|
+
text: "",
|
|
2278
|
+
disabled: vue.unref(disabled)
|
|
2279
|
+
}, {
|
|
2280
|
+
default: vue.withCtx(() => [
|
|
2281
|
+
vue.unref(item).icon ? (vue.openBlock(), vue.createBlock(MIcon, {
|
|
2282
|
+
key: 0,
|
|
2283
|
+
icon: vue.unref(item).icon
|
|
2284
|
+
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
2285
|
+
vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(item).text), 1)
|
|
2286
|
+
]),
|
|
2287
|
+
_: 1
|
|
2288
|
+
}, 8, ["disabled"])
|
|
2289
|
+
]),
|
|
2290
|
+
_: 1
|
|
2291
|
+
}, 8, ["content"])) : (vue.openBlock(), vue.createBlock(_component_el_button, {
|
|
2292
|
+
key: 1,
|
|
2293
|
+
size: "small",
|
|
2026
2294
|
text: "",
|
|
2027
|
-
disabled:
|
|
2295
|
+
disabled: vue.unref(disabled)
|
|
2028
2296
|
}, {
|
|
2029
2297
|
default: vue.withCtx(() => [
|
|
2030
|
-
|
|
2298
|
+
vue.unref(item).icon ? (vue.openBlock(), vue.createBlock(MIcon, {
|
|
2031
2299
|
key: 0,
|
|
2032
|
-
icon:
|
|
2300
|
+
icon: vue.unref(item).icon
|
|
2033
2301
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
2034
|
-
vue.createElementVNode("span", null, vue.toDisplayString(
|
|
2302
|
+
vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(item).text), 1)
|
|
2035
2303
|
]),
|
|
2036
2304
|
_: 1
|
|
2037
|
-
}, 8, ["disabled"])
|
|
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
|
-
_ctx.item.items && _ctx.item.items.length ? (vue.openBlock(), vue.createBlock(_component_el_dropdown_menu, { key: 0 }, {
|
|
2305
|
+
}, 8, ["disabled"]))
|
|
2306
|
+
], 64)) : vue.unref(item).type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
|
|
2307
|
+
key: 4,
|
|
2308
|
+
trigger: "click",
|
|
2309
|
+
disabled: vue.unref(disabled),
|
|
2310
|
+
onCommand: dropdownHandler
|
|
2311
|
+
}, {
|
|
2312
|
+
dropdown: vue.withCtx(() => [
|
|
2313
|
+
vue.unref(item).items && vue.unref(item).items.length ? (vue.openBlock(), vue.createBlock(_component_el_dropdown_menu, { key: 0 }, {
|
|
2314
|
+
default: vue.withCtx(() => [
|
|
2315
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(item).items, (subItem, index) => {
|
|
2316
|
+
return vue.openBlock(), vue.createBlock(_component_el_dropdown_item, {
|
|
2317
|
+
key: index,
|
|
2318
|
+
command: { item: vue.unref(item), subItem }
|
|
2319
|
+
}, {
|
|
2320
|
+
default: vue.withCtx(() => [
|
|
2321
|
+
vue.createTextVNode(vue.toDisplayString(subItem.text), 1)
|
|
2322
|
+
]),
|
|
2323
|
+
_: 2
|
|
2324
|
+
}, 1032, ["command"]);
|
|
2325
|
+
}), 128))
|
|
2326
|
+
]),
|
|
2327
|
+
_: 1
|
|
2328
|
+
})) : vue.createCommentVNode("", true)
|
|
2329
|
+
]),
|
|
2063
2330
|
default: vue.withCtx(() => [
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
command: { item: _ctx.item, subItem }
|
|
2068
|
-
}, {
|
|
2331
|
+
vue.createElementVNode("span", _hoisted_3, [
|
|
2332
|
+
vue.createTextVNode(vue.toDisplayString(vue.unref(item).text), 1),
|
|
2333
|
+
vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2069
2334
|
default: vue.withCtx(() => [
|
|
2070
|
-
vue.
|
|
2335
|
+
vue.createVNode(vue.unref(iconsVue.ArrowDown))
|
|
2071
2336
|
]),
|
|
2072
|
-
_:
|
|
2073
|
-
}
|
|
2074
|
-
|
|
2337
|
+
_: 1
|
|
2338
|
+
})
|
|
2339
|
+
])
|
|
2075
2340
|
]),
|
|
2076
2341
|
_: 1
|
|
2077
|
-
})) : vue.createCommentVNode("", true)
|
|
2078
|
-
]),
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2083
|
-
default: vue.withCtx(() => [
|
|
2084
|
-
vue.createVNode(_component_arrow_down)
|
|
2085
|
-
]),
|
|
2086
|
-
_: 1
|
|
2087
|
-
})
|
|
2088
|
-
])
|
|
2089
|
-
]),
|
|
2090
|
-
_: 1
|
|
2091
|
-
}, 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)
|
|
2092
|
-
], 34)) : vue.createCommentVNode("", true);
|
|
2093
|
-
}
|
|
2094
|
-
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
|
|
2342
|
+
}, 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)
|
|
2343
|
+
], 34)) : vue.createCommentVNode("", true);
|
|
2344
|
+
};
|
|
2345
|
+
}
|
|
2346
|
+
});
|
|
2095
2347
|
|
|
2096
|
-
const _sfc_main$
|
|
2348
|
+
const _sfc_main$e = vue.defineComponent({
|
|
2097
2349
|
name: "nav-menu",
|
|
2098
|
-
components: { ToolButton },
|
|
2350
|
+
components: { ToolButton: _sfc_main$f },
|
|
2099
2351
|
props: {
|
|
2100
2352
|
data: {
|
|
2101
2353
|
type: Object,
|
|
@@ -2113,7 +2365,8 @@
|
|
|
2113
2365
|
};
|
|
2114
2366
|
}
|
|
2115
2367
|
});
|
|
2116
|
-
|
|
2368
|
+
|
|
2369
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2117
2370
|
const _component_tool_button = vue.resolveComponent("tool-button");
|
|
2118
2371
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
2119
2372
|
class: "m-editor-nav-menu",
|
|
@@ -2135,9 +2388,9 @@
|
|
|
2135
2388
|
}), 128))
|
|
2136
2389
|
], 4);
|
|
2137
2390
|
}
|
|
2138
|
-
|
|
2391
|
+
const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
|
|
2139
2392
|
|
|
2140
|
-
const _sfc_main$
|
|
2393
|
+
const _sfc_main$d = vue.defineComponent({
|
|
2141
2394
|
name: "m-editor-props-panel",
|
|
2142
2395
|
emits: ["mounted"],
|
|
2143
2396
|
setup(props, { emit }) {
|
|
@@ -2184,8 +2437,9 @@
|
|
|
2184
2437
|
};
|
|
2185
2438
|
}
|
|
2186
2439
|
});
|
|
2440
|
+
|
|
2187
2441
|
const _hoisted_1$6 = { class: "`m-editor-props-panel" };
|
|
2188
|
-
function _sfc_render$
|
|
2442
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2189
2443
|
const _component_m_form = vue.resolveComponent("m-form");
|
|
2190
2444
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
|
|
2191
2445
|
vue.renderSlot(_ctx.$slots, "props-panel-header"),
|
|
@@ -2200,19 +2454,24 @@
|
|
|
2200
2454
|
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
|
|
2201
2455
|
]);
|
|
2202
2456
|
}
|
|
2203
|
-
|
|
2457
|
+
const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
|
|
2204
2458
|
|
|
2205
|
-
const _sfc_main$
|
|
2459
|
+
const _sfc_main$c = vue.defineComponent({
|
|
2206
2460
|
name: "ui-component-panel",
|
|
2207
2461
|
components: { MIcon },
|
|
2208
2462
|
setup() {
|
|
2209
2463
|
const searchText = vue.ref("");
|
|
2210
2464
|
const services = vue.inject("services");
|
|
2465
|
+
const stageOptions = vue.inject("stageOptions");
|
|
2466
|
+
const stage = vue.computed(() => services?.editorService.get("stage"));
|
|
2211
2467
|
const list = vue.computed(() => services?.componentListService.getList().map((group) => ({
|
|
2212
2468
|
...group,
|
|
2213
2469
|
items: group.items.filter((item) => item.text.includes(searchText.value))
|
|
2214
2470
|
})));
|
|
2215
2471
|
const collapseValue = vue.computed(() => Array(list.value?.length).fill(1).map((x, i) => i));
|
|
2472
|
+
let timeout;
|
|
2473
|
+
let clientX;
|
|
2474
|
+
let clientY;
|
|
2216
2475
|
return {
|
|
2217
2476
|
searchText,
|
|
2218
2477
|
collapseValue,
|
|
@@ -2227,19 +2486,46 @@
|
|
|
2227
2486
|
dragstartHandler({ text, type, data = {} }, e) {
|
|
2228
2487
|
if (e.dataTransfer) {
|
|
2229
2488
|
e.dataTransfer.effectAllowed = "move";
|
|
2230
|
-
e.dataTransfer.setData("data", serialize__default
|
|
2489
|
+
e.dataTransfer.setData("data", serialize__default.default({
|
|
2231
2490
|
name: text,
|
|
2232
2491
|
type,
|
|
2233
2492
|
...data
|
|
2234
2493
|
}).replace(/"(\w+)":\s/g, "$1: "));
|
|
2235
2494
|
}
|
|
2495
|
+
},
|
|
2496
|
+
dragendHandler() {
|
|
2497
|
+
if (timeout) {
|
|
2498
|
+
globalThis.clearTimeout(timeout);
|
|
2499
|
+
timeout = void 0;
|
|
2500
|
+
}
|
|
2501
|
+
const doc = stage.value?.renderer.contentWindow?.document;
|
|
2502
|
+
if (doc && stageOptions) {
|
|
2503
|
+
utils.removeClassNameByClassName(doc, stageOptions.containerHighlightClassName);
|
|
2504
|
+
}
|
|
2505
|
+
clientX = 0;
|
|
2506
|
+
clientY = 0;
|
|
2507
|
+
},
|
|
2508
|
+
dragHandler(e) {
|
|
2509
|
+
if (e.clientX !== clientX || e.clientY !== clientY) {
|
|
2510
|
+
clientX = e.clientX;
|
|
2511
|
+
clientY = e.clientY;
|
|
2512
|
+
if (timeout) {
|
|
2513
|
+
globalThis.clearTimeout(timeout);
|
|
2514
|
+
timeout = void 0;
|
|
2515
|
+
}
|
|
2516
|
+
return;
|
|
2517
|
+
}
|
|
2518
|
+
if (timeout || !stage.value)
|
|
2519
|
+
return;
|
|
2520
|
+
timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
|
|
2236
2521
|
}
|
|
2237
2522
|
};
|
|
2238
2523
|
}
|
|
2239
2524
|
});
|
|
2525
|
+
|
|
2240
2526
|
const _hoisted_1$5 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
2241
2527
|
const _hoisted_2$1 = ["onClick", "onDragstart"];
|
|
2242
|
-
function _sfc_render$
|
|
2528
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2243
2529
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
2244
2530
|
const _component_m_icon = vue.resolveComponent("m-icon");
|
|
2245
2531
|
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
@@ -2280,7 +2566,9 @@
|
|
|
2280
2566
|
draggable: "true",
|
|
2281
2567
|
key: item.type,
|
|
2282
2568
|
onClick: ($event) => _ctx.appendComponent(item),
|
|
2283
|
-
onDragstart: ($event) => _ctx.dragstartHandler(item, $event)
|
|
2569
|
+
onDragstart: ($event) => _ctx.dragstartHandler(item, $event),
|
|
2570
|
+
onDragend: _cache[1] || (_cache[1] = (...args) => _ctx.dragendHandler && _ctx.dragendHandler(...args)),
|
|
2571
|
+
onDrag: _cache[2] || (_cache[2] = (...args) => _ctx.dragHandler && _ctx.dragHandler(...args))
|
|
2284
2572
|
}, [
|
|
2285
2573
|
vue.createVNode(_component_m_icon, {
|
|
2286
2574
|
icon: item.icon
|
|
@@ -2309,22 +2597,17 @@
|
|
|
2309
2597
|
_: 3
|
|
2310
2598
|
});
|
|
2311
2599
|
}
|
|
2312
|
-
|
|
2600
|
+
const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
|
|
2313
2601
|
|
|
2314
|
-
const _sfc_main$
|
|
2315
|
-
|
|
2602
|
+
const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
|
|
2603
|
+
__name: "ContentMenu",
|
|
2316
2604
|
props: {
|
|
2317
|
-
menuData: {
|
|
2318
|
-
|
|
2319
|
-
default: () => []
|
|
2320
|
-
},
|
|
2321
|
-
isSubMenu: {
|
|
2322
|
-
type: Boolean,
|
|
2323
|
-
default: false
|
|
2324
|
-
}
|
|
2605
|
+
menuData: { default: () => [] },
|
|
2606
|
+
isSubMenu: { type: Boolean, default: false }
|
|
2325
2607
|
},
|
|
2326
2608
|
emits: ["hide", "show"],
|
|
2327
|
-
setup(
|
|
2609
|
+
setup(__props, { expose, emit }) {
|
|
2610
|
+
const props = __props;
|
|
2328
2611
|
const menu = vue.ref();
|
|
2329
2612
|
const subMenu = vue.ref();
|
|
2330
2613
|
const visible = vue.ref(false);
|
|
@@ -2350,6 +2633,36 @@
|
|
|
2350
2633
|
}
|
|
2351
2634
|
hide();
|
|
2352
2635
|
};
|
|
2636
|
+
const show = (e) => {
|
|
2637
|
+
setTimeout(() => {
|
|
2638
|
+
visible.value = true;
|
|
2639
|
+
vue.nextTick(() => {
|
|
2640
|
+
const menuHeight = menu.value?.clientHeight || 0;
|
|
2641
|
+
let top = e.clientY;
|
|
2642
|
+
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
2643
|
+
top = document.body.clientHeight - menuHeight;
|
|
2644
|
+
}
|
|
2645
|
+
menuStyle.value = {
|
|
2646
|
+
top: `${top}px`,
|
|
2647
|
+
left: `${e.clientX}px`
|
|
2648
|
+
};
|
|
2649
|
+
emit("show");
|
|
2650
|
+
});
|
|
2651
|
+
}, 300);
|
|
2652
|
+
};
|
|
2653
|
+
const showSubMenu = (item) => {
|
|
2654
|
+
const menuItem = item;
|
|
2655
|
+
if (typeof item !== "object" || !menuItem.items?.length) {
|
|
2656
|
+
return;
|
|
2657
|
+
}
|
|
2658
|
+
subMenuData.value = menuItem.items;
|
|
2659
|
+
if (menu.value) {
|
|
2660
|
+
subMenu.value.show({
|
|
2661
|
+
clientX: menu.value.offsetLeft + menu.value.clientWidth,
|
|
2662
|
+
clientY: menu.value.offsetTop
|
|
2663
|
+
});
|
|
2664
|
+
}
|
|
2665
|
+
};
|
|
2353
2666
|
vue.onMounted(() => {
|
|
2354
2667
|
if (props.isSubMenu)
|
|
2355
2668
|
return;
|
|
@@ -2360,81 +2673,47 @@
|
|
|
2360
2673
|
return;
|
|
2361
2674
|
globalThis.removeEventListener("mousedown", hideHandler, true);
|
|
2362
2675
|
});
|
|
2363
|
-
|
|
2364
|
-
menu,
|
|
2365
|
-
subMenu,
|
|
2366
|
-
visible,
|
|
2367
|
-
menuStyle,
|
|
2368
|
-
subMenuData,
|
|
2676
|
+
expose({
|
|
2369
2677
|
hide,
|
|
2370
|
-
show
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2678
|
+
show
|
|
2679
|
+
});
|
|
2680
|
+
return (_ctx, _cache) => {
|
|
2681
|
+
const _component_content_menu = vue.resolveComponent("content-menu", true);
|
|
2682
|
+
return __props.menuData.length && visible.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
2683
|
+
key: 0,
|
|
2684
|
+
class: "magic-editor-content-menu",
|
|
2685
|
+
ref_key: "menu",
|
|
2686
|
+
ref: menu,
|
|
2687
|
+
style: vue.normalizeStyle(menuStyle.value)
|
|
2688
|
+
}, [
|
|
2689
|
+
vue.createElementVNode("div", null, [
|
|
2690
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.menuData, (item, index) => {
|
|
2691
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$f, {
|
|
2692
|
+
"event-type": "mouseup",
|
|
2693
|
+
data: item,
|
|
2694
|
+
key: index,
|
|
2695
|
+
onMouseup: hide,
|
|
2696
|
+
onMouseenter: ($event) => showSubMenu(item)
|
|
2697
|
+
}, null, 8, ["data", "onMouseenter"]);
|
|
2698
|
+
}), 128))
|
|
2699
|
+
]),
|
|
2700
|
+
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
2701
|
+
vue.createVNode(_component_content_menu, {
|
|
2702
|
+
class: "sub-menu",
|
|
2703
|
+
ref_key: "subMenu",
|
|
2704
|
+
ref: subMenu,
|
|
2705
|
+
"menu-data": subMenuData.value,
|
|
2706
|
+
"is-sub-menu": true,
|
|
2707
|
+
onHide: hide
|
|
2708
|
+
}, null, 8, ["menu-data"])
|
|
2709
|
+
]))
|
|
2710
|
+
], 4)) : vue.createCommentVNode("", true);
|
|
2400
2711
|
};
|
|
2401
2712
|
}
|
|
2402
2713
|
});
|
|
2403
|
-
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2404
|
-
const _component_tool_button = vue.resolveComponent("tool-button");
|
|
2405
|
-
const _component_content_menu = vue.resolveComponent("content-menu", true);
|
|
2406
|
-
return _ctx.menuData.length && _ctx.visible ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
2407
|
-
key: 0,
|
|
2408
|
-
class: "magic-editor-content-menu",
|
|
2409
|
-
ref: "menu",
|
|
2410
|
-
style: vue.normalizeStyle(_ctx.menuStyle)
|
|
2411
|
-
}, [
|
|
2412
|
-
vue.createElementVNode("div", null, [
|
|
2413
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.menuData, (item, index) => {
|
|
2414
|
-
return vue.openBlock(), vue.createBlock(_component_tool_button, {
|
|
2415
|
-
"event-type": "mouseup",
|
|
2416
|
-
data: item,
|
|
2417
|
-
key: index,
|
|
2418
|
-
onMouseup: _ctx.hide,
|
|
2419
|
-
onMouseenter: ($event) => _ctx.showSubMenu(item)
|
|
2420
|
-
}, null, 8, ["data", "onMouseup", "onMouseenter"]);
|
|
2421
|
-
}), 128))
|
|
2422
|
-
]),
|
|
2423
|
-
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
2424
|
-
vue.createVNode(_component_content_menu, {
|
|
2425
|
-
class: "sub-menu",
|
|
2426
|
-
ref: "subMenu",
|
|
2427
|
-
"menu-data": _ctx.subMenuData,
|
|
2428
|
-
"is-sub-menu": true,
|
|
2429
|
-
onHide: _ctx.hide
|
|
2430
|
-
}, null, 8, ["menu-data", "onHide"])
|
|
2431
|
-
]))
|
|
2432
|
-
], 4)) : vue.createCommentVNode("", true);
|
|
2433
|
-
}
|
|
2434
|
-
var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
|
|
2435
2714
|
|
|
2436
|
-
const _sfc_main$
|
|
2437
|
-
components: { ContentMenu },
|
|
2715
|
+
const _sfc_main$a = vue.defineComponent({
|
|
2716
|
+
components: { ContentMenu: _sfc_main$b },
|
|
2438
2717
|
setup() {
|
|
2439
2718
|
const services = vue.inject("services");
|
|
2440
2719
|
const menu = vue.ref();
|
|
@@ -2461,7 +2740,7 @@
|
|
|
2461
2740
|
{
|
|
2462
2741
|
text: "\u6807\u7B7E\u9875",
|
|
2463
2742
|
type: "button",
|
|
2464
|
-
icon:
|
|
2743
|
+
icon: iconsVue.Files,
|
|
2465
2744
|
handler: () => {
|
|
2466
2745
|
services?.editorService.add({
|
|
2467
2746
|
type: "tab-pane"
|
|
@@ -2486,14 +2765,14 @@
|
|
|
2486
2765
|
{
|
|
2487
2766
|
type: "button",
|
|
2488
2767
|
text: "\u65B0\u589E",
|
|
2489
|
-
icon: vue.markRaw(
|
|
2768
|
+
icon: vue.markRaw(iconsVue.Plus),
|
|
2490
2769
|
display: () => node.value?.items,
|
|
2491
2770
|
items: getSubMenuData.value
|
|
2492
2771
|
},
|
|
2493
2772
|
{
|
|
2494
2773
|
type: "button",
|
|
2495
2774
|
text: "\u590D\u5236",
|
|
2496
|
-
icon: vue.markRaw(
|
|
2775
|
+
icon: vue.markRaw(iconsVue.DocumentCopy),
|
|
2497
2776
|
display: () => !isRoot.value,
|
|
2498
2777
|
handler: () => {
|
|
2499
2778
|
node.value && services?.editorService.copy(node.value);
|
|
@@ -2502,7 +2781,7 @@
|
|
|
2502
2781
|
{
|
|
2503
2782
|
type: "button",
|
|
2504
2783
|
text: "\u5220\u9664",
|
|
2505
|
-
icon: vue.markRaw(
|
|
2784
|
+
icon: vue.markRaw(iconsVue.Delete),
|
|
2506
2785
|
display: () => !isRoot.value && !isPage.value,
|
|
2507
2786
|
handler: () => {
|
|
2508
2787
|
node.value && services?.editorService.remove(node.value);
|
|
@@ -2516,7 +2795,8 @@
|
|
|
2516
2795
|
};
|
|
2517
2796
|
}
|
|
2518
2797
|
});
|
|
2519
|
-
|
|
2798
|
+
|
|
2799
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2520
2800
|
const _component_content_menu = vue.resolveComponent("content-menu");
|
|
2521
2801
|
return vue.openBlock(), vue.createBlock(_component_content_menu, {
|
|
2522
2802
|
"menu-data": _ctx.menuData,
|
|
@@ -2524,7 +2804,7 @@
|
|
|
2524
2804
|
style: { "overflow": "initial" }
|
|
2525
2805
|
}, null, 8, ["menu-data"]);
|
|
2526
2806
|
}
|
|
2527
|
-
|
|
2807
|
+
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$6]]);
|
|
2528
2808
|
|
|
2529
2809
|
const throttleTime = 150;
|
|
2530
2810
|
const select = async (data, editorService) => {
|
|
@@ -2558,9 +2838,17 @@
|
|
|
2558
2838
|
return true;
|
|
2559
2839
|
return false;
|
|
2560
2840
|
},
|
|
2561
|
-
handleDragEnd() {
|
|
2841
|
+
async handleDragEnd(e) {
|
|
2562
2842
|
if (!tree.value)
|
|
2563
2843
|
return;
|
|
2844
|
+
const { data: node } = e;
|
|
2845
|
+
const parent = editorService?.getParentById(node.id, false);
|
|
2846
|
+
const layout = await editorService?.getLayout(parent);
|
|
2847
|
+
node.style.position = layout;
|
|
2848
|
+
if (layout === Layout.RELATIVE) {
|
|
2849
|
+
node.style.top = 0;
|
|
2850
|
+
node.style.left = 0;
|
|
2851
|
+
}
|
|
2564
2852
|
const { data } = tree.value;
|
|
2565
2853
|
const [page] = data;
|
|
2566
2854
|
editorService?.update(page);
|
|
@@ -2616,7 +2904,7 @@
|
|
|
2616
2904
|
tree.value?.filter(val);
|
|
2617
2905
|
}
|
|
2618
2906
|
});
|
|
2619
|
-
const _sfc_main$
|
|
2907
|
+
const _sfc_main$9 = vue.defineComponent({
|
|
2620
2908
|
name: "magic-editor-layer-panel",
|
|
2621
2909
|
components: { LayerMenu },
|
|
2622
2910
|
setup() {
|
|
@@ -2663,8 +2951,9 @@
|
|
|
2663
2951
|
};
|
|
2664
2952
|
}
|
|
2665
2953
|
});
|
|
2954
|
+
|
|
2666
2955
|
const _hoisted_1$4 = ["id", "onMouseenter"];
|
|
2667
|
-
function _sfc_render$
|
|
2956
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2668
2957
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
2669
2958
|
const _component_el_tree = vue.resolveComponent("el-tree");
|
|
2670
2959
|
const _component_layer_menu = vue.resolveComponent("layer-menu");
|
|
@@ -2726,9 +3015,9 @@
|
|
|
2726
3015
|
_: 3
|
|
2727
3016
|
});
|
|
2728
3017
|
}
|
|
2729
|
-
|
|
3018
|
+
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$5]]);
|
|
2730
3019
|
|
|
2731
|
-
const _sfc_main$
|
|
3020
|
+
const _sfc_main$8 = vue.defineComponent({
|
|
2732
3021
|
components: { MIcon },
|
|
2733
3022
|
props: {
|
|
2734
3023
|
data: {
|
|
@@ -2745,7 +3034,7 @@
|
|
|
2745
3034
|
case "component-list":
|
|
2746
3035
|
return {
|
|
2747
3036
|
type: "component",
|
|
2748
|
-
icon:
|
|
3037
|
+
icon: iconsVue.Coin,
|
|
2749
3038
|
text: "\u7EC4\u4EF6",
|
|
2750
3039
|
component: ComponentListPanel,
|
|
2751
3040
|
slots: {}
|
|
@@ -2753,7 +3042,7 @@
|
|
|
2753
3042
|
case "layer":
|
|
2754
3043
|
return {
|
|
2755
3044
|
type: "component",
|
|
2756
|
-
icon:
|
|
3045
|
+
icon: iconsVue.Files,
|
|
2757
3046
|
text: "\u5DF2\u9009\u7EC4\u4EF6",
|
|
2758
3047
|
component: LayerPanel,
|
|
2759
3048
|
slots: {}
|
|
@@ -2765,11 +3054,12 @@
|
|
|
2765
3054
|
};
|
|
2766
3055
|
}
|
|
2767
3056
|
});
|
|
3057
|
+
|
|
2768
3058
|
const _hoisted_1$3 = {
|
|
2769
3059
|
key: 1,
|
|
2770
3060
|
class: "magic-editor-tab-panel-title"
|
|
2771
3061
|
};
|
|
2772
|
-
function _sfc_render$
|
|
3062
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2773
3063
|
const _component_m_icon = vue.resolveComponent("m-icon");
|
|
2774
3064
|
const _component_el_tab_pane = vue.resolveComponent("el-tab-pane");
|
|
2775
3065
|
return _ctx.config ? (vue.openBlock(), vue.createBlock(_component_el_tab_pane, {
|
|
@@ -2815,9 +3105,9 @@
|
|
|
2815
3105
|
_: 3
|
|
2816
3106
|
}, 8, ["name"])) : vue.createCommentVNode("", true);
|
|
2817
3107
|
}
|
|
2818
|
-
|
|
3108
|
+
const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$4]]);
|
|
2819
3109
|
|
|
2820
|
-
const _sfc_main$
|
|
3110
|
+
const _sfc_main$7 = vue.defineComponent({
|
|
2821
3111
|
components: { TabPane },
|
|
2822
3112
|
name: "m-sidebar",
|
|
2823
3113
|
props: {
|
|
@@ -2836,7 +3126,8 @@
|
|
|
2836
3126
|
};
|
|
2837
3127
|
}
|
|
2838
3128
|
});
|
|
2839
|
-
|
|
3129
|
+
|
|
3130
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2840
3131
|
const _component_tab_pane = vue.resolveComponent("tab-pane");
|
|
2841
3132
|
const _component_el_tabs = vue.resolveComponent("el-tabs");
|
|
2842
3133
|
return _ctx.data.type === "tabs" && _ctx.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_tabs, {
|
|
@@ -2871,331 +3162,258 @@
|
|
|
2871
3162
|
_: 3
|
|
2872
3163
|
}, 8, ["modelValue"])) : vue.createCommentVNode("", true);
|
|
2873
3164
|
}
|
|
2874
|
-
|
|
3165
|
+
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$3]]);
|
|
2875
3166
|
|
|
2876
|
-
const
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
|
|
2893
|
-
}
|
|
2894
|
-
};
|
|
2895
|
-
const scroll = (type) => {
|
|
2896
|
-
if (!itemsContainer.value)
|
|
2897
|
-
return;
|
|
2898
|
-
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
2899
|
-
if (type === "left") {
|
|
2900
|
-
translateLeft += 100;
|
|
2901
|
-
if (translateLeft > 0) {
|
|
2902
|
-
translateLeft = 0;
|
|
3167
|
+
const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
|
|
3168
|
+
__name: "PageBarScrollContainer",
|
|
3169
|
+
setup(__props) {
|
|
3170
|
+
const services = vue.inject("services");
|
|
3171
|
+
const editorService = services?.editorService;
|
|
3172
|
+
const pageBar = vue.ref();
|
|
3173
|
+
const itemsContainer = vue.ref();
|
|
3174
|
+
const pageBarWidth = vue.ref(0);
|
|
3175
|
+
const canScroll = vue.ref(false);
|
|
3176
|
+
const itemsContainerWidth = vue.computed(() => pageBarWidth.value - 105);
|
|
3177
|
+
let translateLeft = 0;
|
|
3178
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
3179
|
+
for (const { contentRect } of entries) {
|
|
3180
|
+
const { width } = contentRect;
|
|
3181
|
+
pageBarWidth.value = width || 0;
|
|
3182
|
+
setCanScroll();
|
|
2903
3183
|
}
|
|
2904
|
-
}
|
|
2905
|
-
|
|
2906
|
-
if (
|
|
2907
|
-
|
|
3184
|
+
});
|
|
3185
|
+
const setCanScroll = () => {
|
|
3186
|
+
if (itemsContainer.value) {
|
|
3187
|
+
canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
|
|
2908
3188
|
}
|
|
2909
|
-
}
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
scroll("end");
|
|
3189
|
+
};
|
|
3190
|
+
const scroll = (type) => {
|
|
3191
|
+
if (!itemsContainer.value)
|
|
3192
|
+
return;
|
|
3193
|
+
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
3194
|
+
if (type === "left") {
|
|
3195
|
+
translateLeft += 100;
|
|
3196
|
+
if (translateLeft > 0) {
|
|
3197
|
+
translateLeft = 0;
|
|
3198
|
+
}
|
|
3199
|
+
} else if (type === "right") {
|
|
3200
|
+
translateLeft -= 100;
|
|
3201
|
+
if (-translateLeft > maxScrollLeft) {
|
|
3202
|
+
translateLeft = -maxScrollLeft;
|
|
3203
|
+
}
|
|
3204
|
+
} else if (type === "start") {
|
|
3205
|
+
translateLeft = 0;
|
|
3206
|
+
} else if (type === "end") {
|
|
3207
|
+
translateLeft = -maxScrollLeft;
|
|
2929
3208
|
}
|
|
3209
|
+
itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
|
|
3210
|
+
};
|
|
3211
|
+
vue.onMounted(() => {
|
|
3212
|
+
pageBar.value && resizeObserver.observe(pageBar.value);
|
|
3213
|
+
});
|
|
3214
|
+
vue.onUnmounted(() => {
|
|
3215
|
+
resizeObserver.disconnect();
|
|
2930
3216
|
});
|
|
2931
|
-
});
|
|
2932
|
-
return {
|
|
2933
|
-
pageBar,
|
|
2934
|
-
itemsContainer,
|
|
2935
|
-
canScroll,
|
|
2936
|
-
itemsContainerWidth,
|
|
2937
|
-
scroll
|
|
2938
|
-
};
|
|
2939
|
-
};
|
|
2940
|
-
const _sfc_main$5 = vue.defineComponent({
|
|
2941
|
-
components: { ArrowLeftBold: icons.ArrowLeftBold, ArrowRightBold: icons.ArrowRightBold, CaretBottom: icons.CaretBottom, Plus: icons.Plus, ToolButton },
|
|
2942
|
-
setup() {
|
|
2943
|
-
const services = vue.inject("services");
|
|
2944
|
-
const editorService = services?.editorService;
|
|
2945
3217
|
const root = vue.computed(() => editorService?.get("root"));
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
}
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
copy(node) {
|
|
2965
|
-
node && editorService?.copy(node);
|
|
2966
|
-
editorService?.paste({
|
|
2967
|
-
left: 0,
|
|
2968
|
-
top: 0
|
|
2969
|
-
});
|
|
2970
|
-
},
|
|
2971
|
-
remove(node) {
|
|
2972
|
-
editorService?.remove(node);
|
|
2973
|
-
}
|
|
3218
|
+
vue.watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
|
|
3219
|
+
setTimeout(() => {
|
|
3220
|
+
setCanScroll();
|
|
3221
|
+
if (length < preLength) {
|
|
3222
|
+
scroll("start");
|
|
3223
|
+
} else {
|
|
3224
|
+
scroll("end");
|
|
3225
|
+
}
|
|
3226
|
+
});
|
|
3227
|
+
});
|
|
3228
|
+
const addPage = () => {
|
|
3229
|
+
if (!editorService)
|
|
3230
|
+
return;
|
|
3231
|
+
const pageConfig = {
|
|
3232
|
+
type: schema.NodeType.PAGE,
|
|
3233
|
+
name: generatePageNameByApp(vue.toRaw(editorService.get("root")))
|
|
3234
|
+
};
|
|
3235
|
+
editorService.add(pageConfig);
|
|
2974
3236
|
};
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
vue.createElementVNode("div", {
|
|
2994
|
-
id: "m-editor-page-bar-add-icon",
|
|
2995
|
-
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
2996
|
-
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.addPage && _ctx.addPage(...args))
|
|
2997
|
-
}, [
|
|
2998
|
-
vue.createVNode(_component_el_icon, null, {
|
|
2999
|
-
default: vue.withCtx(() => [
|
|
3000
|
-
vue.createVNode(_component_plus)
|
|
3001
|
-
]),
|
|
3002
|
-
_: 1
|
|
3003
|
-
})
|
|
3004
|
-
]),
|
|
3005
|
-
_ctx.canScroll ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3006
|
-
key: 0,
|
|
3007
|
-
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3008
|
-
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.scroll("left"))
|
|
3009
|
-
}, [
|
|
3010
|
-
vue.createVNode(_component_el_icon, null, {
|
|
3011
|
-
default: vue.withCtx(() => [
|
|
3012
|
-
vue.createVNode(_component_arrow_left_bold)
|
|
3237
|
+
return (_ctx, _cache) => {
|
|
3238
|
+
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
3239
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
3240
|
+
class: "m-editor-page-bar",
|
|
3241
|
+
ref_key: "pageBar",
|
|
3242
|
+
ref: pageBar
|
|
3243
|
+
}, [
|
|
3244
|
+
vue.createElementVNode("div", {
|
|
3245
|
+
id: "m-editor-page-bar-add-icon",
|
|
3246
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3247
|
+
onClick: addPage
|
|
3248
|
+
}, [
|
|
3249
|
+
vue.createVNode(_component_el_icon, null, {
|
|
3250
|
+
default: vue.withCtx(() => [
|
|
3251
|
+
vue.createVNode(vue.unref(iconsVue.Plus))
|
|
3252
|
+
]),
|
|
3253
|
+
_: 1
|
|
3254
|
+
})
|
|
3013
3255
|
]),
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
key: 1,
|
|
3019
|
-
class: "m-editor-page-bar-items",
|
|
3020
|
-
ref: "itemsContainer",
|
|
3021
|
-
style: vue.normalizeStyle(`width: ${_ctx.itemsContainerWidth}px`)
|
|
3022
|
-
}, [
|
|
3023
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.root.items, (item) => {
|
|
3024
|
-
return vue.openBlock(), vue.createElementBlock("div", {
|
|
3025
|
-
key: item.key,
|
|
3026
|
-
class: vue.normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
|
|
3027
|
-
onClick: ($event) => _ctx.switchPage(item)
|
|
3256
|
+
canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3257
|
+
key: 0,
|
|
3258
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3259
|
+
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
3028
3260
|
}, [
|
|
3029
|
-
vue.
|
|
3030
|
-
vue.
|
|
3031
|
-
vue.createVNode(
|
|
3032
|
-
effect: "dark",
|
|
3033
|
-
placement: "top-start",
|
|
3034
|
-
content: item.name
|
|
3035
|
-
}, {
|
|
3036
|
-
default: vue.withCtx(() => [
|
|
3037
|
-
vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
|
|
3038
|
-
]),
|
|
3039
|
-
_: 2
|
|
3040
|
-
}, 1032, ["content"])
|
|
3041
|
-
])
|
|
3042
|
-
]),
|
|
3043
|
-
vue.createVNode(_component_el_popover, {
|
|
3044
|
-
"popper-class": "page-bar-popover",
|
|
3045
|
-
placement: "top",
|
|
3046
|
-
width: 160,
|
|
3047
|
-
trigger: "hover"
|
|
3048
|
-
}, {
|
|
3049
|
-
reference: vue.withCtx(() => [
|
|
3050
|
-
vue.createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
|
|
3051
|
-
default: vue.withCtx(() => [
|
|
3052
|
-
vue.createVNode(_component_caret_bottom)
|
|
3053
|
-
]),
|
|
3054
|
-
_: 1
|
|
3055
|
-
})
|
|
3261
|
+
vue.createVNode(_component_el_icon, null, {
|
|
3262
|
+
default: vue.withCtx(() => [
|
|
3263
|
+
vue.createVNode(vue.unref(iconsVue.ArrowLeftBold))
|
|
3056
3264
|
]),
|
|
3265
|
+
_: 1
|
|
3266
|
+
})
|
|
3267
|
+
])) : vue.createCommentVNode("", true),
|
|
3268
|
+
vue.unref(root) ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3269
|
+
key: 1,
|
|
3270
|
+
class: "m-editor-page-bar-items",
|
|
3271
|
+
ref_key: "itemsContainer",
|
|
3272
|
+
ref: itemsContainer,
|
|
3273
|
+
style: vue.normalizeStyle(`width: ${vue.unref(itemsContainerWidth)}px`)
|
|
3274
|
+
}, [
|
|
3275
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
3276
|
+
], 4)) : vue.createCommentVNode("", true),
|
|
3277
|
+
canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3278
|
+
key: 2,
|
|
3279
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3280
|
+
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
3281
|
+
}, [
|
|
3282
|
+
vue.createVNode(_component_el_icon, null, {
|
|
3057
3283
|
default: vue.withCtx(() => [
|
|
3058
|
-
vue.
|
|
3059
|
-
vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3060
|
-
vue.createVNode(_component_tool_button, {
|
|
3061
|
-
data: {
|
|
3062
|
-
type: "button",
|
|
3063
|
-
text: "\u590D\u5236",
|
|
3064
|
-
icon: _ctx.DocumentCopy,
|
|
3065
|
-
handler: () => _ctx.copy(item)
|
|
3066
|
-
}
|
|
3067
|
-
}, null, 8, ["data"]),
|
|
3068
|
-
vue.createVNode(_component_tool_button, {
|
|
3069
|
-
data: {
|
|
3070
|
-
type: "button",
|
|
3071
|
-
text: "\u5220\u9664",
|
|
3072
|
-
icon: _ctx.Delete,
|
|
3073
|
-
handler: () => _ctx.remove(item)
|
|
3074
|
-
}
|
|
3075
|
-
}, null, 8, ["data"])
|
|
3076
|
-
])
|
|
3077
|
-
])
|
|
3284
|
+
vue.createVNode(vue.unref(iconsVue.ArrowRightBold))
|
|
3078
3285
|
]),
|
|
3079
|
-
_:
|
|
3080
|
-
}
|
|
3081
|
-
]
|
|
3082
|
-
|
|
3083
|
-
], 4)) : vue.createCommentVNode("", true),
|
|
3084
|
-
_ctx.canScroll ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3085
|
-
key: 2,
|
|
3086
|
-
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3087
|
-
onClick: _cache[2] || (_cache[2] = ($event) => _ctx.scroll("right"))
|
|
3088
|
-
}, [
|
|
3089
|
-
vue.createVNode(_component_el_icon, null, {
|
|
3090
|
-
default: vue.withCtx(() => [
|
|
3091
|
-
vue.createVNode(_component_arrow_right_bold)
|
|
3092
|
-
]),
|
|
3093
|
-
_: 1
|
|
3094
|
-
})
|
|
3095
|
-
])) : vue.createCommentVNode("", true)
|
|
3096
|
-
], 512);
|
|
3097
|
-
}
|
|
3098
|
-
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
|
|
3099
|
-
|
|
3100
|
-
class ScrollViewer$1 {
|
|
3101
|
-
constructor(options) {
|
|
3102
|
-
this.enter = false;
|
|
3103
|
-
this.targetEnter = false;
|
|
3104
|
-
this.keydown = false;
|
|
3105
|
-
this.zoom = 1;
|
|
3106
|
-
this.scrollLeft = 0;
|
|
3107
|
-
this.scrollTop = 0;
|
|
3108
|
-
this.x = 0;
|
|
3109
|
-
this.y = 0;
|
|
3110
|
-
this.resizeObserver = new ResizeObserver((entries) => {
|
|
3111
|
-
for (const { contentRect } of entries) {
|
|
3112
|
-
const { width, height } = contentRect;
|
|
3113
|
-
const targetRect = this.target.getBoundingClientRect();
|
|
3114
|
-
const targetWidth = targetRect.width * this.zoom;
|
|
3115
|
-
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3116
|
-
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
3117
|
-
if (targetWidth < width) {
|
|
3118
|
-
this.target._left = 0;
|
|
3119
|
-
}
|
|
3120
|
-
if (targetHeight < height) {
|
|
3121
|
-
this.target._top = 0;
|
|
3122
|
-
}
|
|
3123
|
-
this.scroll();
|
|
3124
|
-
}
|
|
3125
|
-
});
|
|
3126
|
-
this.wheelHandler = (event) => {
|
|
3127
|
-
if (this.targetEnter)
|
|
3128
|
-
return;
|
|
3129
|
-
const { deltaX, deltaY, currentTarget } = event;
|
|
3130
|
-
if (currentTarget !== this.container)
|
|
3131
|
-
return;
|
|
3132
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3133
|
-
this.scroll();
|
|
3134
|
-
this.scrollLeft = this.target._left;
|
|
3135
|
-
this.scrollTop = this.target._top;
|
|
3136
|
-
};
|
|
3137
|
-
this.mouseEnterHandler = () => {
|
|
3138
|
-
this.enter = true;
|
|
3139
|
-
};
|
|
3140
|
-
this.mouseLeaveHandler = () => {
|
|
3141
|
-
this.enter = false;
|
|
3142
|
-
};
|
|
3143
|
-
this.targetMouseEnterHandler = () => {
|
|
3144
|
-
this.targetEnter = true;
|
|
3286
|
+
_: 1
|
|
3287
|
+
})
|
|
3288
|
+
])) : vue.createCommentVNode("", true)
|
|
3289
|
+
], 512);
|
|
3145
3290
|
};
|
|
3146
|
-
|
|
3147
|
-
|
|
3291
|
+
}
|
|
3292
|
+
});
|
|
3293
|
+
|
|
3294
|
+
const _hoisted_1$2 = ["onClick"];
|
|
3295
|
+
const _hoisted_2 = { class: "m-editor-page-bar-title" };
|
|
3296
|
+
const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
|
|
3297
|
+
__name: "PageBar",
|
|
3298
|
+
setup(__props) {
|
|
3299
|
+
const services = vue.inject("services");
|
|
3300
|
+
const editorService = services?.editorService;
|
|
3301
|
+
const root = vue.computed(() => editorService?.get("root"));
|
|
3302
|
+
const page = vue.computed(() => editorService?.get("page"));
|
|
3303
|
+
const switchPage = (page2) => {
|
|
3304
|
+
editorService?.select(page2);
|
|
3148
3305
|
};
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
this.x = event.clientX;
|
|
3156
|
-
this.y = event.clientY;
|
|
3157
|
-
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3158
|
-
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3306
|
+
const copy = (node) => {
|
|
3307
|
+
node && editorService?.copy(node);
|
|
3308
|
+
editorService?.paste({
|
|
3309
|
+
left: 0,
|
|
3310
|
+
top: 0
|
|
3311
|
+
});
|
|
3159
3312
|
};
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
this.y = 0;
|
|
3163
|
-
this.scrollLeft = this.target._left;
|
|
3164
|
-
this.scrollTop = this.target._top;
|
|
3165
|
-
this.removeHandler();
|
|
3313
|
+
const remove = (node) => {
|
|
3314
|
+
editorService?.remove(node);
|
|
3166
3315
|
};
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
const
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3316
|
+
return (_ctx, _cache) => {
|
|
3317
|
+
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
3318
|
+
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
3319
|
+
const _component_el_popover = vue.resolveComponent("el-popover");
|
|
3320
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$6, null, {
|
|
3321
|
+
default: vue.withCtx(() => [
|
|
3322
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(root) && vue.unref(root).items || [], (item) => {
|
|
3323
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
3324
|
+
class: vue.normalizeClass(["m-editor-page-bar-item", { active: vue.unref(page)?.id === item.id }]),
|
|
3325
|
+
key: item.key,
|
|
3326
|
+
onClick: ($event) => switchPage(item)
|
|
3327
|
+
}, [
|
|
3328
|
+
vue.createElementVNode("div", _hoisted_2, [
|
|
3329
|
+
vue.renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
|
|
3330
|
+
vue.createVNode(_component_el_tooltip, {
|
|
3331
|
+
effect: "dark",
|
|
3332
|
+
placement: "top-start",
|
|
3333
|
+
content: item.name
|
|
3334
|
+
}, {
|
|
3335
|
+
default: vue.withCtx(() => [
|
|
3336
|
+
vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
|
|
3337
|
+
]),
|
|
3338
|
+
_: 2
|
|
3339
|
+
}, 1032, ["content"])
|
|
3340
|
+
])
|
|
3341
|
+
]),
|
|
3342
|
+
vue.createVNode(_component_el_popover, {
|
|
3343
|
+
"popper-class": "page-bar-popover",
|
|
3344
|
+
placement: "top",
|
|
3345
|
+
width: 160,
|
|
3346
|
+
trigger: "hover"
|
|
3347
|
+
}, {
|
|
3348
|
+
reference: vue.withCtx(() => [
|
|
3349
|
+
vue.createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
|
|
3350
|
+
default: vue.withCtx(() => [
|
|
3351
|
+
vue.createVNode(vue.unref(iconsVue.CaretBottom))
|
|
3352
|
+
]),
|
|
3353
|
+
_: 1
|
|
3354
|
+
})
|
|
3355
|
+
]),
|
|
3356
|
+
default: vue.withCtx(() => [
|
|
3357
|
+
vue.createElementVNode("div", null, [
|
|
3358
|
+
vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3359
|
+
vue.createVNode(_sfc_main$f, {
|
|
3360
|
+
data: {
|
|
3361
|
+
type: "button",
|
|
3362
|
+
text: "\u590D\u5236",
|
|
3363
|
+
icon: vue.unref(iconsVue.DocumentCopy),
|
|
3364
|
+
handler: () => copy(item)
|
|
3365
|
+
}
|
|
3366
|
+
}, null, 8, ["data"]),
|
|
3367
|
+
vue.createVNode(_sfc_main$f, {
|
|
3368
|
+
data: {
|
|
3369
|
+
type: "button",
|
|
3370
|
+
text: "\u5220\u9664",
|
|
3371
|
+
icon: vue.unref(iconsVue.Delete),
|
|
3372
|
+
handler: () => remove(item)
|
|
3373
|
+
}
|
|
3374
|
+
}, null, 8, ["data"])
|
|
3375
|
+
])
|
|
3376
|
+
])
|
|
3377
|
+
]),
|
|
3378
|
+
_: 2
|
|
3379
|
+
}, 1024)
|
|
3380
|
+
], 10, _hoisted_1$2);
|
|
3381
|
+
}), 128))
|
|
3382
|
+
]),
|
|
3383
|
+
_: 3
|
|
3384
|
+
});
|
|
3174
3385
|
};
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3386
|
+
}
|
|
3387
|
+
});
|
|
3388
|
+
|
|
3389
|
+
class ScrollViewer$1 {
|
|
3390
|
+
enter = false;
|
|
3391
|
+
targetEnter = false;
|
|
3392
|
+
keydown = false;
|
|
3393
|
+
container;
|
|
3394
|
+
target;
|
|
3395
|
+
zoom = 1;
|
|
3396
|
+
scrollLeft = 0;
|
|
3397
|
+
scrollTop = 0;
|
|
3398
|
+
x = 0;
|
|
3399
|
+
y = 0;
|
|
3400
|
+
resizeObserver = new ResizeObserver((entries) => {
|
|
3401
|
+
for (const { contentRect } of entries) {
|
|
3402
|
+
const { width, height } = contentRect;
|
|
3403
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3404
|
+
const targetWidth = targetRect.width * this.zoom;
|
|
3405
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3406
|
+
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
3407
|
+
if (targetWidth < width) {
|
|
3408
|
+
this.target._left = 0;
|
|
3180
3409
|
}
|
|
3181
|
-
if (
|
|
3182
|
-
|
|
3410
|
+
if (targetHeight < height) {
|
|
3411
|
+
this.target._top = 0;
|
|
3183
3412
|
}
|
|
3184
|
-
this.
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
this.keyupHandler = (event) => {
|
|
3189
|
-
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3190
|
-
return;
|
|
3191
|
-
}
|
|
3192
|
-
event.preventDefault();
|
|
3193
|
-
event.stopImmediatePropagation();
|
|
3194
|
-
event.stopPropagation();
|
|
3195
|
-
this.keydown = false;
|
|
3196
|
-
event.preventDefault();
|
|
3197
|
-
this.removeHandler();
|
|
3198
|
-
};
|
|
3413
|
+
this.scroll();
|
|
3414
|
+
}
|
|
3415
|
+
});
|
|
3416
|
+
constructor(options) {
|
|
3199
3417
|
this.container = options.container;
|
|
3200
3418
|
this.target = options.target;
|
|
3201
3419
|
this.zoom = options.zoom;
|
|
@@ -3231,6 +3449,79 @@
|
|
|
3231
3449
|
document.removeEventListener("mousemove", this.mousemoveHandler);
|
|
3232
3450
|
document.removeEventListener("mouseup", this.mouseupHandler);
|
|
3233
3451
|
}
|
|
3452
|
+
wheelHandler = (event) => {
|
|
3453
|
+
if (this.targetEnter)
|
|
3454
|
+
return;
|
|
3455
|
+
const { deltaX, deltaY, currentTarget } = event;
|
|
3456
|
+
if (currentTarget !== this.container)
|
|
3457
|
+
return;
|
|
3458
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3459
|
+
this.scroll();
|
|
3460
|
+
this.scrollLeft = this.target._left;
|
|
3461
|
+
this.scrollTop = this.target._top;
|
|
3462
|
+
};
|
|
3463
|
+
mouseEnterHandler = () => {
|
|
3464
|
+
this.enter = true;
|
|
3465
|
+
};
|
|
3466
|
+
mouseLeaveHandler = () => {
|
|
3467
|
+
this.enter = false;
|
|
3468
|
+
};
|
|
3469
|
+
targetMouseEnterHandler = () => {
|
|
3470
|
+
this.targetEnter = true;
|
|
3471
|
+
};
|
|
3472
|
+
targetMouseLeaveHandler = () => {
|
|
3473
|
+
this.targetEnter = false;
|
|
3474
|
+
};
|
|
3475
|
+
mousedownHandler = (event) => {
|
|
3476
|
+
if (!this.keydown)
|
|
3477
|
+
return;
|
|
3478
|
+
event.stopImmediatePropagation();
|
|
3479
|
+
event.stopPropagation();
|
|
3480
|
+
this.target.style.cursor = "grabbing";
|
|
3481
|
+
this.x = event.clientX;
|
|
3482
|
+
this.y = event.clientY;
|
|
3483
|
+
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3484
|
+
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3485
|
+
};
|
|
3486
|
+
mouseupHandler = () => {
|
|
3487
|
+
this.x = 0;
|
|
3488
|
+
this.y = 0;
|
|
3489
|
+
this.scrollLeft = this.target._left;
|
|
3490
|
+
this.scrollTop = this.target._top;
|
|
3491
|
+
this.removeHandler();
|
|
3492
|
+
};
|
|
3493
|
+
mousemoveHandler = (event) => {
|
|
3494
|
+
event.stopImmediatePropagation();
|
|
3495
|
+
event.stopPropagation();
|
|
3496
|
+
const deltaX = event.clientX - this.x;
|
|
3497
|
+
const deltaY = event.clientY - this.y;
|
|
3498
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3499
|
+
this.scroll();
|
|
3500
|
+
};
|
|
3501
|
+
keydownHandler = (event) => {
|
|
3502
|
+
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3503
|
+
event.preventDefault();
|
|
3504
|
+
event.stopImmediatePropagation();
|
|
3505
|
+
event.stopPropagation();
|
|
3506
|
+
}
|
|
3507
|
+
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3508
|
+
return;
|
|
3509
|
+
}
|
|
3510
|
+
this.keydown = true;
|
|
3511
|
+
this.target.style.cursor = "grab";
|
|
3512
|
+
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3513
|
+
};
|
|
3514
|
+
keyupHandler = (event) => {
|
|
3515
|
+
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3516
|
+
return;
|
|
3517
|
+
}
|
|
3518
|
+
event.preventDefault();
|
|
3519
|
+
event.stopImmediatePropagation();
|
|
3520
|
+
event.stopPropagation();
|
|
3521
|
+
this.keydown = false;
|
|
3522
|
+
event.preventDefault();
|
|
3523
|
+
this.removeHandler();
|
|
3524
|
+
};
|
|
3234
3525
|
setScrollOffset(deltaX, deltaY) {
|
|
3235
3526
|
const { width, height } = this.container.getBoundingClientRect();
|
|
3236
3527
|
const targetRect = this.target.getBoundingClientRect();
|
|
@@ -3291,18 +3582,19 @@
|
|
|
3291
3582
|
el,
|
|
3292
3583
|
style: vue.computed(() => `
|
|
3293
3584
|
width: ${props.width}px;
|
|
3294
|
-
height: ${
|
|
3585
|
+
height: ${props.height}px;
|
|
3295
3586
|
position: absolute;
|
|
3296
3587
|
margin-top: 30px;
|
|
3297
3588
|
`)
|
|
3298
3589
|
};
|
|
3299
3590
|
}
|
|
3300
3591
|
});
|
|
3592
|
+
|
|
3301
3593
|
const _hoisted_1$1 = {
|
|
3302
3594
|
class: "m-editor-scroll-viewer-container",
|
|
3303
3595
|
ref: "container"
|
|
3304
3596
|
};
|
|
3305
|
-
function _sfc_render$
|
|
3597
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3306
3598
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
|
|
3307
3599
|
vue.createElementVNode("div", {
|
|
3308
3600
|
ref: "el",
|
|
@@ -3312,170 +3604,170 @@
|
|
|
3312
3604
|
], 4)
|
|
3313
3605
|
], 512);
|
|
3314
3606
|
}
|
|
3315
|
-
|
|
3607
|
+
const ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$2]]);
|
|
3316
3608
|
|
|
3317
|
-
const _sfc_main$3 = vue.defineComponent({
|
|
3318
|
-
|
|
3319
|
-
|
|
3609
|
+
const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
3610
|
+
__name: "ViewerMenu",
|
|
3611
|
+
props: {
|
|
3612
|
+
isMultiSelect: { type: Boolean, default: false }
|
|
3613
|
+
},
|
|
3614
|
+
setup(__props, { expose }) {
|
|
3615
|
+
const props = __props;
|
|
3320
3616
|
const services = vue.inject("services");
|
|
3321
3617
|
const editorService = services?.editorService;
|
|
3322
3618
|
const menu = vue.ref();
|
|
3323
3619
|
const canPaste = vue.ref(false);
|
|
3324
3620
|
const canCenter = vue.ref(false);
|
|
3325
3621
|
const node = vue.computed(() => editorService?.get("node"));
|
|
3622
|
+
const nodes = vue.computed(() => editorService?.get("nodes"));
|
|
3326
3623
|
const parent = vue.computed(() => editorService?.get("parent"));
|
|
3327
|
-
const
|
|
3624
|
+
const stage = vue.computed(() => editorService?.get("stage"));
|
|
3328
3625
|
const stageContentMenu = vue.inject("stageContentMenu", []);
|
|
3329
|
-
vue.
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3626
|
+
const menuData = vue.reactive([
|
|
3627
|
+
{
|
|
3628
|
+
type: "button",
|
|
3629
|
+
text: "\u6C34\u5E73\u5C45\u4E2D",
|
|
3630
|
+
display: () => canCenter.value,
|
|
3631
|
+
handler: () => {
|
|
3632
|
+
if (!nodes.value)
|
|
3633
|
+
return;
|
|
3634
|
+
editorService?.alignCenter(nodes.value);
|
|
3635
|
+
}
|
|
3636
|
+
},
|
|
3637
|
+
{
|
|
3638
|
+
type: "button",
|
|
3639
|
+
text: "\u590D\u5236",
|
|
3640
|
+
icon: vue.markRaw(iconsVue.DocumentCopy),
|
|
3641
|
+
handler: () => {
|
|
3642
|
+
nodes.value && editorService?.copy(nodes.value);
|
|
3643
|
+
canPaste.value = true;
|
|
3644
|
+
}
|
|
3645
|
+
},
|
|
3646
|
+
{
|
|
3647
|
+
type: "button",
|
|
3648
|
+
text: "\u7C98\u8D34",
|
|
3649
|
+
display: () => canPaste.value,
|
|
3650
|
+
handler: () => {
|
|
3651
|
+
const rect = menu.value?.$el.getBoundingClientRect();
|
|
3652
|
+
const parentRect = stage.value?.container?.getBoundingClientRect();
|
|
3653
|
+
const initialLeft = (rect?.left || 0) - (parentRect?.left || 0);
|
|
3654
|
+
const initialTop = (rect?.top || 0) - (parentRect?.top || 0);
|
|
3655
|
+
if (!nodes.value || nodes.value.length === 0)
|
|
3656
|
+
return;
|
|
3657
|
+
editorService?.paste({ left: initialLeft, top: initialTop });
|
|
3658
|
+
}
|
|
3659
|
+
},
|
|
3660
|
+
{
|
|
3661
|
+
type: "divider",
|
|
3662
|
+
direction: "horizontal",
|
|
3663
|
+
display: () => {
|
|
3664
|
+
if (!node.value)
|
|
3665
|
+
return false;
|
|
3666
|
+
return !utils.isPage(node.value);
|
|
3667
|
+
}
|
|
3668
|
+
},
|
|
3669
|
+
{
|
|
3670
|
+
type: "button",
|
|
3671
|
+
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
3672
|
+
icon: vue.markRaw(iconsVue.Top),
|
|
3673
|
+
display: () => !utils.isPage(node.value) && !props.isMultiSelect,
|
|
3674
|
+
handler: () => {
|
|
3675
|
+
editorService?.moveLayer(1);
|
|
3676
|
+
}
|
|
3677
|
+
},
|
|
3678
|
+
{
|
|
3679
|
+
type: "button",
|
|
3680
|
+
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
3681
|
+
icon: vue.markRaw(iconsVue.Bottom),
|
|
3682
|
+
display: () => !utils.isPage(node.value) && !props.isMultiSelect,
|
|
3683
|
+
handler: () => {
|
|
3684
|
+
editorService?.moveLayer(-1);
|
|
3685
|
+
}
|
|
3686
|
+
},
|
|
3687
|
+
{
|
|
3688
|
+
type: "button",
|
|
3689
|
+
text: "\u7F6E\u9876",
|
|
3690
|
+
display: () => !utils.isPage(node.value) && !props.isMultiSelect,
|
|
3691
|
+
handler: () => {
|
|
3692
|
+
editorService?.moveLayer(LayerOffset.TOP);
|
|
3693
|
+
}
|
|
3694
|
+
},
|
|
3695
|
+
{
|
|
3696
|
+
type: "button",
|
|
3697
|
+
text: "\u7F6E\u5E95",
|
|
3698
|
+
display: () => !utils.isPage(node.value) && !props.isMultiSelect,
|
|
3699
|
+
handler: () => {
|
|
3700
|
+
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
3701
|
+
}
|
|
3702
|
+
},
|
|
3703
|
+
{
|
|
3704
|
+
type: "divider",
|
|
3705
|
+
direction: "horizontal",
|
|
3706
|
+
display: () => !utils.isPage(node.value) && !props.isMultiSelect
|
|
3707
|
+
},
|
|
3708
|
+
{
|
|
3709
|
+
type: "button",
|
|
3710
|
+
text: "\u5220\u9664",
|
|
3711
|
+
icon: iconsVue.Delete,
|
|
3712
|
+
display: () => !utils.isPage(node.value),
|
|
3713
|
+
handler: () => {
|
|
3714
|
+
nodes.value && editorService?.remove(nodes.value);
|
|
3715
|
+
}
|
|
3716
|
+
},
|
|
3717
|
+
{
|
|
3718
|
+
type: "divider",
|
|
3719
|
+
direction: "horizontal"
|
|
3720
|
+
},
|
|
3721
|
+
{
|
|
3722
|
+
type: "button",
|
|
3723
|
+
text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
|
|
3724
|
+
handler: () => {
|
|
3725
|
+
editorService?.get("stage").clearGuides();
|
|
3726
|
+
}
|
|
3727
|
+
},
|
|
3728
|
+
...stageContentMenu
|
|
3729
|
+
]);
|
|
3333
3730
|
vue.watch(parent, async () => {
|
|
3334
3731
|
if (!parent.value || !editorService)
|
|
3335
3732
|
return canCenter.value = false;
|
|
3336
3733
|
const layout = await editorService.getLayout(parent.value);
|
|
3337
|
-
|
|
3734
|
+
const isLayoutConform = [Layout.ABSOLUTE, Layout.FIXED].includes(layout);
|
|
3735
|
+
const isTypeConform = nodes.value?.every((selectedNode) => ![schema.NodeType.ROOT, schema.NodeType.PAGE, "pop"].includes(`${selectedNode?.type}`));
|
|
3736
|
+
canCenter.value = isLayoutConform && !!isTypeConform;
|
|
3338
3737
|
}, { immediate: true });
|
|
3339
|
-
|
|
3340
|
-
menu
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
type: "button",
|
|
3352
|
-
text: "\u590D\u5236",
|
|
3353
|
-
icon: vue.markRaw(icons.DocumentCopy),
|
|
3354
|
-
handler: () => {
|
|
3355
|
-
node.value && editorService?.copy(node.value);
|
|
3356
|
-
canPaste.value = true;
|
|
3357
|
-
}
|
|
3358
|
-
},
|
|
3359
|
-
{
|
|
3360
|
-
type: "button",
|
|
3361
|
-
text: "\u7C98\u8D34",
|
|
3362
|
-
display: () => canPaste.value,
|
|
3363
|
-
handler: () => {
|
|
3364
|
-
const stage = editorService?.get("stage");
|
|
3365
|
-
const rect = menu.value?.$el.getBoundingClientRect();
|
|
3366
|
-
const parentRect = stage?.container?.getBoundingClientRect();
|
|
3367
|
-
let left = (rect?.left || 0) - (parentRect?.left || 0);
|
|
3368
|
-
let top = (rect?.top || 0) - (parentRect?.top || 0);
|
|
3369
|
-
if (node.value?.items && stage) {
|
|
3370
|
-
const parentEl = stage.renderer.contentWindow?.document.getElementById(`${node.value.id}`);
|
|
3371
|
-
const parentElRect = parentEl?.getBoundingClientRect();
|
|
3372
|
-
left = left - (parentElRect?.left || 0);
|
|
3373
|
-
top = top - (parentElRect?.top || 0);
|
|
3374
|
-
}
|
|
3375
|
-
editorService?.paste({ left, top });
|
|
3376
|
-
}
|
|
3377
|
-
},
|
|
3378
|
-
{
|
|
3379
|
-
type: "divider",
|
|
3380
|
-
direction: "horizontal",
|
|
3381
|
-
display: () => !isPage.value
|
|
3382
|
-
},
|
|
3383
|
-
{
|
|
3384
|
-
type: "button",
|
|
3385
|
-
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
3386
|
-
icon: vue.markRaw(icons.Top),
|
|
3387
|
-
display: () => !isPage.value,
|
|
3388
|
-
handler: () => {
|
|
3389
|
-
editorService?.moveLayer(1);
|
|
3390
|
-
}
|
|
3391
|
-
},
|
|
3392
|
-
{
|
|
3393
|
-
type: "button",
|
|
3394
|
-
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
3395
|
-
icon: vue.markRaw(icons.Bottom),
|
|
3396
|
-
display: () => !isPage.value,
|
|
3397
|
-
handler: () => {
|
|
3398
|
-
editorService?.moveLayer(-1);
|
|
3399
|
-
}
|
|
3400
|
-
},
|
|
3401
|
-
{
|
|
3402
|
-
type: "button",
|
|
3403
|
-
text: "\u7F6E\u9876",
|
|
3404
|
-
display: () => !isPage.value,
|
|
3405
|
-
handler: () => {
|
|
3406
|
-
editorService?.moveLayer(LayerOffset.TOP);
|
|
3407
|
-
}
|
|
3408
|
-
},
|
|
3409
|
-
{
|
|
3410
|
-
type: "button",
|
|
3411
|
-
text: "\u7F6E\u5E95",
|
|
3412
|
-
display: () => !isPage.value,
|
|
3413
|
-
handler: () => {
|
|
3414
|
-
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
3415
|
-
}
|
|
3416
|
-
},
|
|
3417
|
-
{
|
|
3418
|
-
type: "divider",
|
|
3419
|
-
direction: "horizontal",
|
|
3420
|
-
display: () => !isPage.value
|
|
3421
|
-
},
|
|
3422
|
-
{
|
|
3423
|
-
type: "button",
|
|
3424
|
-
text: "\u5220\u9664",
|
|
3425
|
-
icon: icons.Delete,
|
|
3426
|
-
display: () => !isPage.value,
|
|
3427
|
-
handler: () => {
|
|
3428
|
-
node.value && editorService?.remove(node.value);
|
|
3429
|
-
}
|
|
3430
|
-
},
|
|
3431
|
-
{
|
|
3432
|
-
type: "divider",
|
|
3433
|
-
direction: "horizontal"
|
|
3434
|
-
},
|
|
3435
|
-
{
|
|
3436
|
-
type: "button",
|
|
3437
|
-
text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
|
|
3438
|
-
handler: () => {
|
|
3439
|
-
editorService?.get("stage").clearGuides();
|
|
3440
|
-
}
|
|
3441
|
-
},
|
|
3442
|
-
...stageContentMenu
|
|
3443
|
-
]),
|
|
3444
|
-
show(e) {
|
|
3445
|
-
menu.value?.show(e);
|
|
3446
|
-
}
|
|
3738
|
+
const show = async (e) => {
|
|
3739
|
+
menu.value?.show(e);
|
|
3740
|
+
const data = await storageService.getItem(COPY_STORAGE_KEY);
|
|
3741
|
+
canPaste.value = data !== "undefined" && !!data;
|
|
3742
|
+
};
|
|
3743
|
+
expose({ show });
|
|
3744
|
+
return (_ctx, _cache) => {
|
|
3745
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$b, {
|
|
3746
|
+
"menu-data": menuData,
|
|
3747
|
+
ref_key: "menu",
|
|
3748
|
+
ref: menu
|
|
3749
|
+
}, null, 8, ["menu-data"]);
|
|
3447
3750
|
};
|
|
3448
3751
|
}
|
|
3449
3752
|
});
|
|
3450
|
-
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3451
|
-
const _component_content_menu = vue.resolveComponent("content-menu");
|
|
3452
|
-
return vue.openBlock(), vue.createBlock(_component_content_menu, {
|
|
3453
|
-
"menu-data": _ctx.menuData,
|
|
3454
|
-
ref: "menu"
|
|
3455
|
-
}, null, 8, ["menu-data"]);
|
|
3456
|
-
}
|
|
3457
|
-
var ViewerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
|
|
3458
3753
|
|
|
3459
|
-
const _sfc_main$2 = vue.defineComponent({
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
},
|
|
3465
|
-
setup() {
|
|
3754
|
+
const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
3755
|
+
__name: "Stage",
|
|
3756
|
+
setup(__props) {
|
|
3757
|
+
let stage = null;
|
|
3758
|
+
let runtime = null;
|
|
3466
3759
|
const services = vue.inject("services");
|
|
3467
3760
|
const stageOptions = vue.inject("stageOptions");
|
|
3468
3761
|
const stageWrap = vue.ref();
|
|
3469
3762
|
const stageContainer = vue.ref();
|
|
3470
3763
|
const menu = vue.ref();
|
|
3764
|
+
const isMultiSelect = vue.computed(() => services?.editorService.get("nodes")?.length > 1);
|
|
3471
3765
|
const stageRect = vue.computed(() => services?.uiService.get("stageRect"));
|
|
3472
3766
|
const uiSelectMode = vue.computed(() => services?.uiService.get("uiSelectMode"));
|
|
3473
3767
|
const root = vue.computed(() => services?.editorService.get("root"));
|
|
3474
3768
|
const page = vue.computed(() => services?.editorService.get("page"));
|
|
3475
3769
|
const zoom = vue.computed(() => services?.uiService.get("zoom") || 1);
|
|
3476
3770
|
const node = vue.computed(() => services?.editorService.get("node"));
|
|
3477
|
-
let stage = null;
|
|
3478
|
-
let runtime = null;
|
|
3479
3771
|
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
3480
3772
|
vue.watchEffect(() => {
|
|
3481
3773
|
if (stage)
|
|
@@ -3484,11 +3776,15 @@
|
|
|
3484
3776
|
return;
|
|
3485
3777
|
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
|
|
3486
3778
|
return;
|
|
3487
|
-
stage = new StageCore__default
|
|
3779
|
+
stage = new StageCore__default.default({
|
|
3488
3780
|
render: stageOptions.render,
|
|
3489
3781
|
runtimeUrl: stageOptions.runtimeUrl,
|
|
3490
3782
|
zoom: zoom.value,
|
|
3491
3783
|
autoScrollIntoView: stageOptions.autoScrollIntoView,
|
|
3784
|
+
isContainer: stageOptions.isContainer,
|
|
3785
|
+
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
3786
|
+
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
3787
|
+
containerHighlightType: stageOptions.containerHighlightType,
|
|
3492
3788
|
canSelect: (el, event, stop) => {
|
|
3493
3789
|
const elCanSelect = stageOptions.canSelect(el);
|
|
3494
3790
|
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
@@ -3512,8 +3808,17 @@
|
|
|
3512
3808
|
stage?.on("highlight", (el) => {
|
|
3513
3809
|
services?.editorService.highlight(el.id);
|
|
3514
3810
|
});
|
|
3811
|
+
stage?.on("multiSelect", (els) => {
|
|
3812
|
+
services?.editorService.multiSelect(els.map((el) => el.id));
|
|
3813
|
+
});
|
|
3515
3814
|
stage?.on("update", (ev) => {
|
|
3516
|
-
|
|
3815
|
+
if (ev.parentEl) {
|
|
3816
|
+
for (const data of ev.data) {
|
|
3817
|
+
services?.editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
3818
|
+
}
|
|
3819
|
+
return;
|
|
3820
|
+
}
|
|
3821
|
+
services?.editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
3517
3822
|
});
|
|
3518
3823
|
stage?.on("sort", (ev) => {
|
|
3519
3824
|
services?.editorService.sort(ev.src, ev.dist);
|
|
@@ -3566,81 +3871,96 @@
|
|
|
3566
3871
|
resizeObserver.disconnect();
|
|
3567
3872
|
services?.editorService.set("stage", null);
|
|
3568
3873
|
});
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
e2.
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3874
|
+
const contextmenuHandler = (e2) => {
|
|
3875
|
+
e2.preventDefault();
|
|
3876
|
+
menu.value?.show(e2);
|
|
3877
|
+
};
|
|
3878
|
+
const dragoverHandler = (e2) => {
|
|
3879
|
+
e2.preventDefault();
|
|
3880
|
+
if (e2.dataTransfer) {
|
|
3881
|
+
e2.dataTransfer.dropEffect = "move";
|
|
3882
|
+
}
|
|
3883
|
+
};
|
|
3884
|
+
const dropHandler = async (e) => {
|
|
3885
|
+
e.preventDefault();
|
|
3886
|
+
const doc = stage?.renderer.contentWindow?.document;
|
|
3887
|
+
const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
|
|
3888
|
+
let parent = page.value;
|
|
3889
|
+
if (parentEl) {
|
|
3890
|
+
parent = services?.editorService.getNodeById(parentEl.id, false);
|
|
3891
|
+
}
|
|
3892
|
+
if (e.dataTransfer && parent && stageContainer.value && stage) {
|
|
3893
|
+
const config = eval(`(${e.dataTransfer.getData("data")})`);
|
|
3894
|
+
const layout = await services?.editorService.getLayout(parent);
|
|
3895
|
+
const containerRect = stageContainer.value.getBoundingClientRect();
|
|
3896
|
+
const { scrollTop, scrollLeft } = stage.mask;
|
|
3897
|
+
const { style = {} } = config;
|
|
3898
|
+
let top = 0;
|
|
3899
|
+
let left = 0;
|
|
3900
|
+
let position = "relative";
|
|
3901
|
+
if (layout === Layout.ABSOLUTE) {
|
|
3902
|
+
position = "absolute";
|
|
3903
|
+
top = e.clientY - containerRect.top + scrollTop;
|
|
3904
|
+
left = e.clientX - containerRect.left + scrollLeft;
|
|
3905
|
+
if (parentEl && doc) {
|
|
3906
|
+
const { left: parentLeft, top: parentTop } = StageCore.getOffset(parentEl);
|
|
3907
|
+
left = left - StageCore.calcValueByFontsize(doc, parentLeft);
|
|
3908
|
+
top = top - StageCore.calcValueByFontsize(doc, parentTop);
|
|
3599
3909
|
}
|
|
3600
|
-
services?.editorService.add(config, page.value);
|
|
3601
3910
|
}
|
|
3911
|
+
config.style = {
|
|
3912
|
+
...style,
|
|
3913
|
+
position,
|
|
3914
|
+
top,
|
|
3915
|
+
left
|
|
3916
|
+
};
|
|
3917
|
+
config.inputEvent = e;
|
|
3918
|
+
services?.editorService.add(config, parent);
|
|
3602
3919
|
}
|
|
3603
3920
|
};
|
|
3921
|
+
return (_ctx, _cache) => {
|
|
3922
|
+
return vue.openBlock(), vue.createBlock(ScrollViewer, {
|
|
3923
|
+
class: "m-editor-stage",
|
|
3924
|
+
ref_key: "stageWrap",
|
|
3925
|
+
ref: stageWrap,
|
|
3926
|
+
width: vue.unref(stageRect)?.width,
|
|
3927
|
+
height: vue.unref(stageRect)?.height,
|
|
3928
|
+
zoom: vue.unref(zoom)
|
|
3929
|
+
}, {
|
|
3930
|
+
default: vue.withCtx(() => [
|
|
3931
|
+
vue.createElementVNode("div", {
|
|
3932
|
+
class: "m-editor-stage-container",
|
|
3933
|
+
ref_key: "stageContainer",
|
|
3934
|
+
ref: stageContainer,
|
|
3935
|
+
style: vue.normalizeStyle(`transform: scale(${vue.unref(zoom)})`),
|
|
3936
|
+
onContextmenu: contextmenuHandler,
|
|
3937
|
+
onDrop: dropHandler,
|
|
3938
|
+
onDragover: dragoverHandler
|
|
3939
|
+
}, null, 36),
|
|
3940
|
+
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
3941
|
+
vue.createVNode(_sfc_main$3, {
|
|
3942
|
+
ref_key: "menu",
|
|
3943
|
+
ref: menu,
|
|
3944
|
+
"is-multi-select": vue.unref(isMultiSelect)
|
|
3945
|
+
}, null, 8, ["is-multi-select"])
|
|
3946
|
+
]))
|
|
3947
|
+
]),
|
|
3948
|
+
_: 1
|
|
3949
|
+
}, 8, ["width", "height", "zoom"]);
|
|
3950
|
+
};
|
|
3604
3951
|
}
|
|
3605
3952
|
});
|
|
3606
|
-
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3607
|
-
const _component_viewer_menu = vue.resolveComponent("viewer-menu");
|
|
3608
|
-
const _component_scroll_viewer = vue.resolveComponent("scroll-viewer");
|
|
3609
|
-
return vue.openBlock(), vue.createBlock(_component_scroll_viewer, {
|
|
3610
|
-
class: "m-editor-stage",
|
|
3611
|
-
ref: "stageWrap",
|
|
3612
|
-
width: _ctx.stageRect?.width,
|
|
3613
|
-
height: _ctx.stageRect?.height,
|
|
3614
|
-
zoom: _ctx.zoom
|
|
3615
|
-
}, {
|
|
3616
|
-
default: vue.withCtx(() => [
|
|
3617
|
-
vue.createElementVNode("div", {
|
|
3618
|
-
class: "m-editor-stage-container",
|
|
3619
|
-
ref: "stageContainer",
|
|
3620
|
-
style: vue.normalizeStyle(`transform: scale(${_ctx.zoom})`),
|
|
3621
|
-
onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
|
|
3622
|
-
onDrop: _cache[1] || (_cache[1] = (...args) => _ctx.dropHandler && _ctx.dropHandler(...args)),
|
|
3623
|
-
onDragover: _cache[2] || (_cache[2] = (...args) => _ctx.dragoverHandler && _ctx.dragoverHandler(...args))
|
|
3624
|
-
}, null, 36),
|
|
3625
|
-
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
3626
|
-
vue.createVNode(_component_viewer_menu, { ref: "menu" }, null, 512)
|
|
3627
|
-
]))
|
|
3628
|
-
]),
|
|
3629
|
-
_: 1
|
|
3630
|
-
}, 8, ["width", "height", "zoom"]);
|
|
3631
|
-
}
|
|
3632
|
-
var MagicStage = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
|
|
3633
3953
|
|
|
3634
3954
|
const _sfc_main$1 = vue.defineComponent({
|
|
3635
3955
|
name: "m-editor-workspace",
|
|
3636
3956
|
components: {
|
|
3637
|
-
PageBar,
|
|
3638
|
-
MagicStage
|
|
3957
|
+
PageBar: _sfc_main$5,
|
|
3958
|
+
MagicStage: _sfc_main$2
|
|
3639
3959
|
},
|
|
3640
3960
|
setup() {
|
|
3641
3961
|
const services = vue.inject("services");
|
|
3642
3962
|
const workspace = vue.ref();
|
|
3643
|
-
const
|
|
3963
|
+
const nodes = vue.computed(() => services?.editorService.get("nodes"));
|
|
3644
3964
|
let keycon;
|
|
3645
3965
|
const mouseenterHandler = () => {
|
|
3646
3966
|
workspace.value?.focus();
|
|
@@ -3651,31 +3971,31 @@
|
|
|
3651
3971
|
vue.onMounted(() => {
|
|
3652
3972
|
workspace.value?.addEventListener("mouseenter", mouseenterHandler);
|
|
3653
3973
|
workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
|
|
3654
|
-
keycon = new KeyController__default
|
|
3974
|
+
keycon = new KeyController__default.default(workspace.value);
|
|
3655
3975
|
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
3656
3976
|
const ctrl = isMac ? "meta" : "ctrl";
|
|
3657
3977
|
keycon.keyup("delete", (e) => {
|
|
3658
3978
|
e.inputEvent.preventDefault();
|
|
3659
|
-
if (!
|
|
3979
|
+
if (!nodes.value || utils.isPage(nodes.value[0]))
|
|
3660
3980
|
return;
|
|
3661
|
-
services?.editorService.remove(
|
|
3981
|
+
services?.editorService.remove(nodes.value);
|
|
3662
3982
|
}).keyup("backspace", (e) => {
|
|
3663
3983
|
e.inputEvent.preventDefault();
|
|
3664
|
-
if (!
|
|
3984
|
+
if (!nodes.value || utils.isPage(nodes.value[0]))
|
|
3665
3985
|
return;
|
|
3666
|
-
services?.editorService.remove(
|
|
3986
|
+
services?.editorService.remove(nodes.value);
|
|
3667
3987
|
}).keydown([ctrl, "c"], (e) => {
|
|
3668
3988
|
e.inputEvent.preventDefault();
|
|
3669
|
-
|
|
3989
|
+
nodes.value && services?.editorService.copy(nodes.value);
|
|
3670
3990
|
}).keydown([ctrl, "v"], (e) => {
|
|
3671
3991
|
e.inputEvent.preventDefault();
|
|
3672
|
-
|
|
3992
|
+
nodes.value && services?.editorService.paste({ offsetX: 10, offsetY: 10 });
|
|
3673
3993
|
}).keydown([ctrl, "x"], (e) => {
|
|
3674
3994
|
e.inputEvent.preventDefault();
|
|
3675
|
-
if (!
|
|
3995
|
+
if (!nodes.value || utils.isPage(nodes.value[0]))
|
|
3676
3996
|
return;
|
|
3677
|
-
services?.editorService.copy(
|
|
3678
|
-
services?.editorService.remove(
|
|
3997
|
+
services?.editorService.copy(nodes.value);
|
|
3998
|
+
services?.editorService.remove(nodes.value);
|
|
3679
3999
|
}).keydown([ctrl, "z"], (e) => {
|
|
3680
4000
|
e.inputEvent.preventDefault();
|
|
3681
4001
|
services?.editorService.undo();
|
|
@@ -3737,6 +4057,7 @@
|
|
|
3737
4057
|
};
|
|
3738
4058
|
}
|
|
3739
4059
|
});
|
|
4060
|
+
|
|
3740
4061
|
const _hoisted_1 = {
|
|
3741
4062
|
class: "m-editor-workspace",
|
|
3742
4063
|
tabindex: "1",
|
|
@@ -3761,14 +4082,14 @@
|
|
|
3761
4082
|
})
|
|
3762
4083
|
], 512);
|
|
3763
4084
|
}
|
|
3764
|
-
|
|
4085
|
+
const Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
3765
4086
|
|
|
3766
4087
|
class ComponentList extends BaseService {
|
|
4088
|
+
state = vue.reactive({
|
|
4089
|
+
list: []
|
|
4090
|
+
});
|
|
3767
4091
|
constructor() {
|
|
3768
4092
|
super([]);
|
|
3769
|
-
this.state = vue.reactive({
|
|
3770
|
-
list: []
|
|
3771
|
-
});
|
|
3772
4093
|
}
|
|
3773
4094
|
setList(componentGroupList) {
|
|
3774
4095
|
this.state.list = componentGroupList;
|
|
@@ -3777,7 +4098,7 @@
|
|
|
3777
4098
|
return this.state.list;
|
|
3778
4099
|
}
|
|
3779
4100
|
}
|
|
3780
|
-
|
|
4101
|
+
const componentListService = new ComponentList();
|
|
3781
4102
|
|
|
3782
4103
|
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
3783
4104
|
const MIN_LEFT_COLUMN_WIDTH = 45;
|
|
@@ -3889,13 +4210,15 @@
|
|
|
3889
4210
|
const { height, width } = stageContainerRect;
|
|
3890
4211
|
if (!width || !height)
|
|
3891
4212
|
return 1;
|
|
3892
|
-
|
|
4213
|
+
const stageWidth = stageRect.width + 30;
|
|
4214
|
+
const stageHeight = stageRect.height + 30;
|
|
4215
|
+
if (width > stageWidth && height > stageHeight) {
|
|
3893
4216
|
return 1;
|
|
3894
4217
|
}
|
|
3895
|
-
return Math.min((width -
|
|
4218
|
+
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
3896
4219
|
}
|
|
3897
4220
|
}
|
|
3898
|
-
|
|
4221
|
+
const uiService = new Ui();
|
|
3899
4222
|
|
|
3900
4223
|
const _sfc_main = vue.defineComponent({
|
|
3901
4224
|
name: "m-editor",
|
|
@@ -3958,6 +4281,22 @@
|
|
|
3958
4281
|
type: Function,
|
|
3959
4282
|
default: (el) => Boolean(el.id)
|
|
3960
4283
|
},
|
|
4284
|
+
isContainer: {
|
|
4285
|
+
type: Function,
|
|
4286
|
+
default: (el) => el.classList.contains("magic-ui-container")
|
|
4287
|
+
},
|
|
4288
|
+
containerHighlightClassName: {
|
|
4289
|
+
type: String,
|
|
4290
|
+
default: StageCore.CONTAINER_HIGHLIGHT_CLASS
|
|
4291
|
+
},
|
|
4292
|
+
containerHighlightDuration: {
|
|
4293
|
+
type: Number,
|
|
4294
|
+
default: 800
|
|
4295
|
+
},
|
|
4296
|
+
containerHighlightType: {
|
|
4297
|
+
type: String,
|
|
4298
|
+
default: StageCore.ContainerHighlightType.DEFAULT
|
|
4299
|
+
},
|
|
3961
4300
|
stageRect: {
|
|
3962
4301
|
type: [String, Object]
|
|
3963
4302
|
},
|
|
@@ -4013,7 +4352,8 @@
|
|
|
4013
4352
|
historyService,
|
|
4014
4353
|
propsService,
|
|
4015
4354
|
editorService,
|
|
4016
|
-
uiService
|
|
4355
|
+
uiService,
|
|
4356
|
+
storageService
|
|
4017
4357
|
};
|
|
4018
4358
|
vue.provide("services", services);
|
|
4019
4359
|
vue.provide("layerContentMenu", props.layerContentMenu);
|
|
@@ -4024,11 +4364,16 @@
|
|
|
4024
4364
|
render: props.render,
|
|
4025
4365
|
moveableOptions: props.moveableOptions,
|
|
4026
4366
|
canSelect: props.canSelect,
|
|
4027
|
-
updateDragEl: props.updateDragEl
|
|
4367
|
+
updateDragEl: props.updateDragEl,
|
|
4368
|
+
isContainer: props.isContainer,
|
|
4369
|
+
containerHighlightClassName: props.containerHighlightClassName,
|
|
4370
|
+
containerHighlightDuration: props.containerHighlightDuration,
|
|
4371
|
+
containerHighlightType: props.containerHighlightType
|
|
4028
4372
|
}));
|
|
4029
4373
|
return services;
|
|
4030
4374
|
}
|
|
4031
4375
|
});
|
|
4376
|
+
|
|
4032
4377
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4033
4378
|
const _component_nav_menu = vue.resolveComponent("nav-menu");
|
|
4034
4379
|
const _component_sidebar = vue.resolveComponent("sidebar");
|
|
@@ -4089,18 +4434,18 @@
|
|
|
4089
4434
|
_: 3
|
|
4090
4435
|
}, 8, ["code-options"]);
|
|
4091
4436
|
}
|
|
4092
|
-
|
|
4437
|
+
const Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
4093
4438
|
|
|
4094
|
-
var index$1 = /* #__PURE__ */ (() => ".m-editor-nav-menu {\n display: flex;\n z-index: 5;\n -webkit-box-pack: justify;\n justify-content: space-between;\n -webkit-box-align: center;\n align-items: center;\n background-color: #ffffff;\n font-size: 19.2px;\n color: #070303;\n font-weight: 400;\n box-sizing: border-box;\n margin: 0px;\n flex: 0 0 35px;\n border-bottom: 1px solid #d8dee8;\n}\n.m-editor-nav-menu > div {\n display: flex;\n height: 100%;\n z-index: 1;\n align-items: center;\n}\n.m-editor-nav-menu .menu-center {\n justify-content: center;\n}\n.m-editor-nav-menu .menu-right {\n justify-content: flex-end;\n}\n.m-editor-nav-menu .menu-item {\n flex-direction: row;\n -webkit-box-align: center;\n align-items: center;\n vertical-align: middle;\n font-size: 14px;\n line-height: 1;\n height: 100%;\n color: rgba(255, 255, 255, 0.7);\n box-sizing: inherit;\n z-index: 1;\n display: flex !important;\n transition: all 0.3s ease 0s;\n border-bottom: 2px solid transparent;\n margin: 0;\n}\n.m-editor-nav-menu .menu-item .is-disabled {\n opacity: 0.5;\n}\n.m-editor-nav-menu .menu-item .is-text {\n padding: 5px;\n}\n.m-editor-nav-menu .menu-item .is-text,\n.m-editor-nav-menu .menu-item i {\n color: #070303;\n}\n.m-editor-nav-menu .menu-item .icon {\n display: flex;\n -webkit-box-align: center;\n align-items: center;\n height: 100%;\n padding: 0px 8px;\n}\n.m-editor-nav-menu .menu-item .menu-item-text {\n color: #070303;\n}\n.m-editor {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n.m-editor-content {\n width: 100%;\n height: calc(100% - 35px);\n display: flex;\n justify-self: space-between;\n}\n.m-editor-framework-center {\n position: relative;\n transform: translateZ(0);\n flex: 1;\n}\n.m-editor-framework-left {\n background-color: #ffffff;\n}\n.m-editor-framework-center .el-scrollbar__view {\n height: 100%;\n min-height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.m-editor-empty-panel {\n display: flex;\n flex: 1;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n height: calc(100% - 32px);\n}\n.m-editor-empty-content {\n display: flex;\n justify-content: space-evenly;\n flex-direction: row;\n width: 100%;\n}\n.m-editor-empty-button {\n border: 3px solid rgba(0, 0, 0, 0.2);\n padding: 10px 40px;\n color: rgba(0, 0, 0, 0.6);\n cursor: pointer;\n}\n.m-editor-empty-button i {\n height: 180px;\n line-height: 180px;\n font-size: 100px;\n}\n.m-editor-empty-button p {\n text-align: center;\n font-size: 20px;\n margin-top: 5px;\n}\n.m-editor-empty-button:hover {\n border-color: #2882e0;\n color: #2882e0;\n}\n.m-editor-sidebar {\n height: 100%;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header {\n background: #2882e0;\n border: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header.is-left {\n width: 40px;\n margin-right: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__nav-wrap {\n margin: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__nav {\n border: 0;\n border-radius: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .tab-label {\n margin-left: 2px;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left {\n line-height: 15px;\n border: 0;\n height: auto;\n padding: 8px;\n color: rgb(255, 255, 255);\n box-sizing: border-box;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active {\n background: #ffffff;\n border: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active i {\n color: #353140;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active .magic-editor-tab-panel-title {\n color: #353140;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left:first-child {\n border-right: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header i {\n font-size: 25px;\n color: rgba(255, 255, 255, 0.6);\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header i:hover {\n color: rgb(255, 255, 255);\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .magic-editor-tab-panel-title {\n font-size: 12px;\n white-space: normal;\n}\n.m-editor-sidebar .el-scrollbar {\n height: 100%;\n}\n.m-editor-sidebar .el-tree {\n min-height: 100%;\n}\n.m-editor-sidebar .fold-icon {\n position: absolute;\n bottom: 8px;\n left: 0px;\n width: 45px;\n padding-left: 8px;\n color: #fff;\n font-size: 32px;\n opacity: 0.8;\n cursor: pointer;\n}\n.m-editor-sidebar .fold-icon:hover {\n background: rgba(0, 0, 0, 0.2);\n}\n.m-editor-sidebar .el-tabs__content,\n.m-editor-sidebar .el-tab-pane {\n height: 100%;\n}\n.magic-editor-layer-panel {\n background: #ffffff;\n}\n.magic-editor-layer-panel .search-input {\n background: #ffffff;\n color: #bbbbbb;\n padding: 10px;\n position: absolute;\n top: 0;\n left: 0;\n z-index: 1;\n}\n.magic-editor-layer-panel .search-input .el-input__suffix {\n padding: 10px 5px;\n}\n.magic-editor-layer-panel .node-content {\n flex: 1;\n display: flex;\n width: 100%;\n}\n.magic-editor-layer-panel .node-content > div {\n width: 8px;\n}\n.magic-editor-layer-panel .node-content > span {\n width: calc(100% - 68px);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.magic-editor-layer-panel .node-content > i {\n margin-right: 10px;\n font-size: 20px;\n}\n.magic-editor-layer-panel .node-content > i.lock {\n color: #bbb;\n}\n.magic-editor-layer-panel,\n.magic-editor-layer-panel .el-tree {\n background-color: #ffffff;\n color: #313a40;\n}\n.magic-editor-layer-panel .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {\n background-color: #2882e0;\n color: #fff;\n}\n.magic-editor-layer-panel .cus-tree-node {\n width: 100%;\n overflow: hidden;\n}\n.magic-editor-layer-panel .cus-tree-node-hover {\n background-color: #f3f5f9;\n width: 100%;\n}\n.magic-editor-layer-panel .el-tree-node:focus > .el-tree-node__content {\n background-color: #2882e0;\n color: #fff;\n}\n.ui-tree-tip {\n width: 100%;\n height: 25px;\n margin-left: 10px;\n background: #ffffff;\n font-style: italic;\n color: #555554;\n position: absolute;\n top: 40px;\n left: 0;\n z-index: 1;\n}\n.ui-component-panel {\n height: 100%;\n border-top: 0 !important;\n margin-top: 50px;\n background-color: #ffffff;\n}\n.ui-component-panel .search-input {\n background: #f8fbff;\n color: #bbbbbb;\n padding: 10px;\n position: absolute;\n top: 0;\n left: 0;\n box-sizing: border-box;\n z-index: 1;\n}\n.ui-component-panel .search-input .el-input__prefix {\n padding: 10px;\n}\n.ui-component-panel .search-input .el-input__suffix {\n padding: 10px 5px;\n}\n.ui-component-panel .el-collapse-item > div:first-of-type {\n border-bottom: 1px solid #d9dbdd;\n margin-bottom: 10px;\n}\n.ui-component-panel .el-collapse-item__header {\n background: #ffffff;\n color: #070303;\n height: 25px;\n line-height: 25px;\n padding-left: 10px;\n font-size: 12px;\n}\n.ui-component-panel .el-collapse-item__header i {\n margin-right: 5px;\n font-size: 14px;\n}\n.ui-component-panel .el-collapse-item__wrap {\n background: #ffffff;\n border-bottom: 0;\n}\n.ui-component-panel .el-collapse-item__wrap .el-collapse-item__content {\n padding: 10px;\n display: flex;\n flex-wrap: wrap;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item {\n display: flex;\n overflow: hidden;\n text-overflow: ellipsis;\n margin: 5px 10px;\n box-sizing: border-box;\n color: #070303;\n flex-direction: column;\n width: 42px;\n cursor: pointer;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item i {\n font-size: 20px;\n background: #fff;\n height: 40px;\n width: 40px;\n line-height: 40px;\n border-radius: 5px;\n color: #909090;\n border: 1px solid #d9dbdd;\n display: flex;\n justify-content: space-evenly;\n align-items: center;\n margin-bottom: 5px;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item i:hover {\n background: #2882e0;\n color: #fff;\n border-color: #4e8be1;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item span {\n font-size: 12px;\n text-align: center;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item .el-tooltip {\n width: 50px;\n height: 30px;\n line-height: 15px;\n display: block;\n white-space: normal;\n margin: 0;\n}\n.m-editor-resizer {\n border-left: 1px solid transparent;\n border-right: 1px solid transparent;\n width: 8px;\n margin: 0 -5px;\n height: 100%;\n opacity: 0.9;\n background: padding-box #d8dee8;\n box-sizing: border-box;\n cursor: col-resize;\n z-index: 1;\n}\n.m-editor-resizer:hover {\n border-color: #d8dee8;\n}\n.m-editor-resizer .icon-container {\n visibility: hidden;\n opacity: 0;\n transition: opacity 0.4s;\n width: 20px;\n height: 120px;\n line-height: 120px;\n text-align: center;\n background: #d8dee8;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n cursor: pointer;\n}\n.m-editor-resizer .icon-container.position-left {\n transform: translate(calc(-100% - 4px), -50%);\n}\n.m-editor-resizer .icon-container.position-right {\n transform: translate(calc(100% + 4px), -50%);\n}\n.m-editor-resizer .icon {\n color: #fff;\n font-size: 18px;\n}\n.magic-editor-resizer:hover .icon-container {\n visibility: visible;\n opacity: 1;\n}\n.m-editor-workspace {\n height: 100%;\n width: 100%;\n user-select: none;\n}\n.m-editor-workspace:focus-visible {\n outline: 0;\n}\n.m-editor-page-bar {\n position: fixed;\n bottom: 0;\n left: 0;\n display: flex;\n width: 100%;\n height: 32px;\n line-height: 32px;\n color: #070303;\n background-color: #f3f3f3;\n border-top: 1px solid #d9dbdd;\n z-index: 2;\n overflow: hidden;\n}\n.m-editor-page-bar-items {\n display: flex;\n transition: transform 0.3s;\n}\n.m-editor-page-bar-item {\n padding: 0 10px;\n cursor: pointer;\n border-right: 1px solid #d9dbdd;\n display: flex;\n justify-items: center;\n align-items: center;\n background-color: #f3f3f3;\n white-space: nowrap;\n}\n.m-editor-page-bar-item.active {\n background-color: #fff;\n cursor: text;\n}\n.m-editor-page-bar-item.active .m-editor-page-bar-menu-icon {\n cursor: pointer;\n}\n.m-editor-page-bar-item-icon {\n position: relative;\n z-index: 1;\n}\n.m-editor-page-bar-item-title {\n max-width: 150px;\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n}\n.page-bar-popover.el-popper.el-popover {\n padding: 10px 0;\n}\n.page-bar-popover .menu-item {\n cursor: pointer;\n transition: all 0.2s ease 0s;\n padding: 5px 14px;\n}\n.page-bar-popover .menu-item .el-button--text,\n.page-bar-popover .menu-item i {\n color: #070303;\n}\n.page-bar-popover .menu-item:hover {\n background-color: #f3f5f9;\n}\n.m-editor-props-panel {\n padding: 0 10px;\n}\n.m-editor-props-panel.small .el-form-item__label {\n font-size: 12px;\n}\n.m-editor-props-panel.small .m-fieldset legend {\n font-size: 12px;\n}\n.m-editor-props-panel.small .el-tabs__item {\n font-size: 12px;\n}\n.m-editor-props-panel .el-input__wrapper {\n border-radius: 0;\n}\n.m-editor-props-panel-popper.small span,\n.m-editor-props-panel-popper.small a,\n.m-editor-props-panel-popper.small p {\n font-size: 12px;\n}\n.magic-editor-content-menu {\n position: fixed;\n font-size: 12px;\n background: #fff;\n box-shadow: 0 2px 8px 2px rgba(68, 73, 77, 0.16);\n z-index: 9999;\n transform-origin: 0% 0%;\n font-weight: 600;\n padding: 4px 0px;\n overflow: auto;\n max-height: 100%;\n}\n.magic-editor-content-menu .menu-item {\n color: #333;\n display: flex;\n -webkit-box-align: center;\n align-items: center;\n cursor: pointer;\n min-width: 140px;\n transition: all 0.2s ease 0s;\n padding: 5px 14px;\n border-left: 2px solid transparent;\n}\n.magic-editor-content-menu .menu-item .el-button {\n width: 100%;\n justify-content: flex-start;\n}\n.magic-editor-content-menu .menu-item .el-button--text,\n.magic-editor-content-menu .menu-item i {\n color: #070303;\n}\n.magic-editor-content-menu .menu-item.divider {\n padding: 0 14px;\n}\n.magic-editor-content-menu .menu-item.divider .el-divider {\n margin: 0;\n}\n.magic-editor-content-menu .menu-item:hover {\n background-color: #f3f5f9;\n}\n.m-editor-stage {\n position: relative;\n width: 100%;\n height: calc(100% - 32px);\n overflow: hidden;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.m-editor-stage-container {\n width: 100%;\n height: 100%;\n z-index: 0;\n position: relative;\n border: 1px solid #d9dbdd;\n transition: transform 0.3s;\n box-sizing: content-box;\n}\n.m-editor-stage-container::-webkit-scrollbar {\n width: 0 !important;\n}\n.magic-code-editor {\n width: 100%;\n}\n.magic-code-editor .margin {\n margin: 0;\n}")();
|
|
4439
|
+
const index$1 = '';
|
|
4095
4440
|
|
|
4096
4441
|
const defaultInstallOpt = {};
|
|
4097
|
-
|
|
4442
|
+
const index = {
|
|
4098
4443
|
install: (app, opt) => {
|
|
4099
4444
|
const option = Object.assign(defaultInstallOpt, opt || {});
|
|
4100
4445
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
4101
4446
|
setConfig(option);
|
|
4102
4447
|
app.component(Editor.name, Editor);
|
|
4103
|
-
app.component(
|
|
4448
|
+
app.component("m-fields-ui-select", _sfc_main$l);
|
|
4104
4449
|
app.component(CodeLink.name, CodeLink);
|
|
4105
4450
|
app.component(Code.name, Code);
|
|
4106
4451
|
app.component(CodeEditor.name, CodeEditor);
|
|
@@ -4119,32 +4464,34 @@
|
|
|
4119
4464
|
exports.PropsPanel = PropsPanel;
|
|
4120
4465
|
exports.TMagicCodeEditor = CodeEditor;
|
|
4121
4466
|
exports.TMagicEditor = Editor;
|
|
4122
|
-
exports.ToolButton =
|
|
4467
|
+
exports.ToolButton = _sfc_main$f;
|
|
4123
4468
|
exports.V_GUIDE_LINE_STORAGE_KEY = V_GUIDE_LINE_STORAGE_KEY;
|
|
4124
4469
|
exports.change2Fixed = change2Fixed;
|
|
4125
4470
|
exports.debug = debug;
|
|
4126
|
-
exports
|
|
4471
|
+
exports.default = index;
|
|
4127
4472
|
exports.editorService = editorService;
|
|
4128
4473
|
exports.error = error;
|
|
4129
4474
|
exports.eventsService = eventsService;
|
|
4130
4475
|
exports.fillConfig = fillConfig;
|
|
4476
|
+
exports.fixNodeLeft = fixNodeLeft;
|
|
4477
|
+
exports.fixNodePosition = fixNodePosition;
|
|
4131
4478
|
exports.generatePageName = generatePageName;
|
|
4132
4479
|
exports.generatePageNameByApp = generatePageNameByApp;
|
|
4133
4480
|
exports.getConfig = getConfig;
|
|
4134
|
-
exports.getDefaultPropsValue = getDefaultPropsValue;
|
|
4135
4481
|
exports.getGuideLineFromCache = getGuideLineFromCache;
|
|
4482
|
+
exports.getInitPositionStyle = getInitPositionStyle;
|
|
4136
4483
|
exports.getNodeIndex = getNodeIndex;
|
|
4137
4484
|
exports.getPageList = getPageList;
|
|
4138
4485
|
exports.getPageNameList = getPageNameList;
|
|
4486
|
+
exports.getRelativeStyle = getRelativeStyle;
|
|
4139
4487
|
exports.historyService = historyService;
|
|
4140
4488
|
exports.info = info;
|
|
4141
|
-
exports.initPosition = initPosition;
|
|
4142
4489
|
exports.isFixed = isFixed;
|
|
4143
4490
|
exports.log = log;
|
|
4144
4491
|
exports.propsService = propsService;
|
|
4145
4492
|
exports.setConfig = setConfig;
|
|
4146
4493
|
exports.setLayout = setLayout;
|
|
4147
|
-
exports.
|
|
4494
|
+
exports.storageService = storageService;
|
|
4148
4495
|
exports.uiService = uiService;
|
|
4149
4496
|
exports.warn = warn;
|
|
4150
4497
|
|