@tmagic/editor 1.0.0-beta.8 → 1.0.0-rc.2
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/README.md +1 -0
- package/coverage/clover.xml +1556 -0
- package/coverage/coverage-final.json +36 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +206 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/Editor.vue.html +802 -0
- package/coverage/lcov-report/src/components/ContentMenu.vue.html +406 -0
- package/coverage/lcov-report/src/components/Icon.vue.html +172 -0
- package/coverage/lcov-report/src/components/ScrollViewer.vue.html +283 -0
- package/coverage/lcov-report/src/components/ToolButton.vue.html +772 -0
- package/coverage/lcov-report/src/components/index.html +161 -0
- package/coverage/lcov-report/src/index.html +131 -0
- package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +214 -0
- package/coverage/lcov-report/src/layouts/Framework.vue.html +343 -0
- package/coverage/lcov-report/src/layouts/NavMenu.vue.html +208 -0
- package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +319 -0
- package/coverage/lcov-report/src/layouts/Resizer.vue.html +268 -0
- package/coverage/lcov-report/src/layouts/index.html +176 -0
- package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +358 -0
- package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +421 -0
- package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +775 -0
- package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +226 -0
- package/coverage/lcov-report/src/layouts/sidebar/TabPane.vue.html +289 -0
- package/coverage/lcov-report/src/layouts/sidebar/index.html +176 -0
- package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +718 -0
- package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +760 -0
- package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +532 -0
- package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +598 -0
- package/coverage/lcov-report/src/layouts/workspace/index.html +161 -0
- package/coverage/lcov-report/src/services/BaseService.ts.html +643 -0
- package/coverage/lcov-report/src/services/componentList.ts.html +229 -0
- package/coverage/lcov-report/src/services/editor.ts.html +2077 -0
- package/coverage/lcov-report/src/services/events.ts.html +331 -0
- package/coverage/lcov-report/src/services/history.ts.html +478 -0
- package/coverage/lcov-report/src/services/index.html +206 -0
- package/coverage/lcov-report/src/services/props.ts.html +415 -0
- package/coverage/lcov-report/src/services/ui.ts.html +580 -0
- package/coverage/lcov-report/src/type.ts.html +850 -0
- package/coverage/lcov-report/src/utils/compose.ts.html +184 -0
- package/coverage/lcov-report/src/utils/config.ts.html +172 -0
- package/coverage/lcov-report/src/utils/editor.ts.html +838 -0
- package/coverage/lcov-report/src/utils/index.html +221 -0
- package/coverage/lcov-report/src/utils/index.ts.html +151 -0
- package/coverage/lcov-report/src/utils/logger.ts.html +226 -0
- package/coverage/lcov-report/src/utils/props.ts.html +796 -0
- package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +733 -0
- package/coverage/lcov-report/src/utils/undo-redo.ts.html +313 -0
- package/coverage/lcov.info +3747 -0
- package/dist/style.css +91 -45
- package/dist/tmagic-editor.es.js +1462 -2003
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +1461 -2003
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/Editor.vue.d.ts +10 -1
- package/dist/types/src/components/ToolButton.vue.d.ts +12 -1
- package/dist/types/src/fields/UISelect.vue.d.ts +4 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/layouts/CodeEditor.vue.d.ts +13 -4
- package/dist/types/src/layouts/Framework.vue.d.ts +15 -3
- package/dist/types/src/layouts/PropsPanel.vue.d.ts +2 -1
- package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +2 -1
- package/dist/types/src/layouts/sidebar/Sidebar.vue.d.ts +2 -3
- package/dist/types/src/layouts/sidebar/TabPane.vue.d.ts +14 -0
- package/dist/types/src/layouts/workspace/PageBar.vue.d.ts +10 -3
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +4 -6
- package/dist/types/src/services/BaseService.d.ts +4 -1
- package/dist/types/src/services/editor.d.ts +16 -6
- package/dist/types/src/services/history.d.ts +1 -0
- package/dist/types/src/services/props.d.ts +2 -2
- package/dist/types/src/services/ui.d.ts +2 -0
- package/dist/types/src/type.d.ts +16 -9
- package/dist/types/src/utils/editor.d.ts +5 -4
- package/dist/types/src/utils/polyfills.d.ts +0 -0
- package/package.json +44 -12
- package/src/Editor.vue +6 -1
- package/src/components/ContentMenu.vue +107 -0
- package/src/components/ScrollViewer.vue +1 -1
- package/src/components/ToolButton.vue +72 -31
- package/src/fields/UISelect.vue +14 -6
- package/src/index.ts +2 -0
- package/src/layouts/AddPageBox.vue +3 -1
- package/src/layouts/CodeEditor.vue +20 -13
- package/src/layouts/Framework.vue +20 -7
- package/src/layouts/PropsPanel.vue +5 -4
- package/src/layouts/sidebar/ComponentListPanel.vue +25 -3
- package/src/layouts/sidebar/LayerMenu.vue +91 -96
- package/src/layouts/sidebar/LayerPanel.vue +80 -59
- package/src/layouts/sidebar/Sidebar.vue +13 -52
- package/src/layouts/sidebar/TabPane.vue +68 -0
- package/src/layouts/workspace/PageBar.vue +145 -17
- package/src/layouts/workspace/Stage.vue +56 -64
- package/src/layouts/workspace/ViewerMenu.vue +107 -68
- package/src/layouts/workspace/Workspace.vue +110 -18
- package/src/services/BaseService.ts +70 -22
- package/src/services/editor.ts +197 -64
- package/src/services/history.ts +7 -0
- package/src/services/props.ts +3 -3
- package/src/services/ui.ts +35 -5
- package/src/theme/common/var.scss +3 -2
- package/src/theme/component-list-panel.scss +2 -0
- package/src/theme/content-menu.scss +33 -26
- package/src/theme/layer-panel.scss +10 -0
- package/src/theme/nav-menu.scss +6 -2
- package/src/theme/page-bar.scss +42 -2
- package/src/theme/props-panel.scss +19 -17
- package/src/type.ts +17 -9
- package/src/utils/editor.ts +35 -9
- package/src/utils/polyfills.ts +8 -0
- package/src/utils/props.ts +20 -1
- package/dist/types/src/layouts/sidebar/LayerMenu.vue.d.ts +0 -31
- package/dist/types/src/layouts/sidebar/LayerPanel.vue.d.ts +0 -973
- package/dist/types/src/layouts/workspace/Stage.vue.d.ts +0 -192
- package/dist/types/src/layouts/workspace/ViewerMenu.vue.d.ts +0 -18
- package/tsconfig.json +0 -9
- package/vite.config.ts +0 -30
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', '
|
|
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'), require('lodash-es'), require('monaco-editor'), require('@tmagic/schema'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('gesto'), require('element-plus'), require('keycon'), require('@tmagic/stage')) :
|
|
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', '@tmagic/stage'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.vue, global.serialize, global.icons, global.lodashEs, global.monaco, global.schema, global.utils, global.events, global.core, global.Gesto, global.elementPlus, global.KeyController, global.StageCore));
|
|
5
|
+
})(this, (function (exports, vue, serialize, icons, lodashEs, monaco, schema, utils, events, core, Gesto, elementPlus, KeyController, StageCore) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return 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
|
-
var n =
|
|
11
|
+
var n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
|
|
12
12
|
if (e) {
|
|
13
13
|
Object.keys(e).forEach(function (k) {
|
|
14
14
|
if (k !== 'default') {
|
|
@@ -26,8 +26,17 @@
|
|
|
26
26
|
|
|
27
27
|
var serialize__default = /*#__PURE__*/_interopDefaultLegacy(serialize);
|
|
28
28
|
var monaco__namespace = /*#__PURE__*/_interopNamespace(monaco);
|
|
29
|
+
var Gesto__default = /*#__PURE__*/_interopDefaultLegacy(Gesto);
|
|
30
|
+
var KeyController__default = /*#__PURE__*/_interopDefaultLegacy(KeyController);
|
|
29
31
|
var StageCore__default = /*#__PURE__*/_interopDefaultLegacy(StageCore);
|
|
30
32
|
|
|
33
|
+
if (typeof global === "undefined") {
|
|
34
|
+
window.global = window;
|
|
35
|
+
}
|
|
36
|
+
if (typeof globalThis === "undefined") {
|
|
37
|
+
window.globalThis = window;
|
|
38
|
+
}
|
|
39
|
+
|
|
31
40
|
var _export_sfc = (sfc, props) => {
|
|
32
41
|
const target = sfc.__vccOpts || sfc;
|
|
33
42
|
for (const [key, val] of props) {
|
|
@@ -36,7 +45,7 @@
|
|
|
36
45
|
return target;
|
|
37
46
|
};
|
|
38
47
|
|
|
39
|
-
const _sfc_main$
|
|
48
|
+
const _sfc_main$m = vue.defineComponent({
|
|
40
49
|
name: "m-fields-vs-code",
|
|
41
50
|
props: ["model", "name", "config", "prop"],
|
|
42
51
|
emits: ["change"],
|
|
@@ -53,7 +62,7 @@
|
|
|
53
62
|
};
|
|
54
63
|
}
|
|
55
64
|
});
|
|
56
|
-
function _sfc_render$
|
|
65
|
+
function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) {
|
|
57
66
|
const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
|
|
58
67
|
return vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
|
|
59
68
|
style: vue.normalizeStyle(`height: ${_ctx.height}`),
|
|
@@ -62,9 +71,9 @@
|
|
|
62
71
|
onSave: _ctx.save
|
|
63
72
|
}, null, 8, ["style", "init-values", "language", "onSave"]);
|
|
64
73
|
}
|
|
65
|
-
var Code = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
74
|
+
var Code = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$m]]);
|
|
66
75
|
|
|
67
|
-
const _sfc_main$
|
|
76
|
+
const _sfc_main$l = vue.defineComponent({
|
|
68
77
|
name: "m-fields-code-link",
|
|
69
78
|
props: {
|
|
70
79
|
config: {
|
|
@@ -119,7 +128,7 @@
|
|
|
119
128
|
};
|
|
120
129
|
}
|
|
121
130
|
});
|
|
122
|
-
function _sfc_render$
|
|
131
|
+
function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) {
|
|
123
132
|
const _component_m_fields_link = vue.resolveComponent("m-fields-link");
|
|
124
133
|
return vue.openBlock(), vue.createBlock(_component_m_fields_link, {
|
|
125
134
|
config: _ctx.formConfig,
|
|
@@ -128,11 +137,11 @@
|
|
|
128
137
|
onChange: _ctx.changeHandler
|
|
129
138
|
}, null, 8, ["config", "model", "onChange"]);
|
|
130
139
|
}
|
|
131
|
-
var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
140
|
+
var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$l]]);
|
|
132
141
|
|
|
133
142
|
var UISelect_vue_vue_type_style_index_0_lang = '';
|
|
134
143
|
|
|
135
|
-
const _sfc_main$
|
|
144
|
+
const _sfc_main$k = vue.defineComponent({
|
|
136
145
|
name: "m-fields-ui-select",
|
|
137
146
|
props: {
|
|
138
147
|
labelWidth: String,
|
|
@@ -170,6 +179,9 @@
|
|
|
170
179
|
}
|
|
171
180
|
};
|
|
172
181
|
return {
|
|
182
|
+
Delete: vue.markRaw(icons.Delete),
|
|
183
|
+
Pointer: vue.markRaw(icons.Pointer),
|
|
184
|
+
Close: vue.markRaw(icons.Close),
|
|
173
185
|
val,
|
|
174
186
|
uiSelectMode,
|
|
175
187
|
toName: vue.computed(() => {
|
|
@@ -194,34 +206,64 @@
|
|
|
194
206
|
};
|
|
195
207
|
}
|
|
196
208
|
});
|
|
197
|
-
const _hoisted_1$
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const _hoisted_2$7 = [
|
|
202
|
-
_hoisted_1$d
|
|
203
|
-
];
|
|
204
|
-
const _hoisted_3$5 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-thumb" }, null, -1);
|
|
205
|
-
function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
209
|
+
const _hoisted_1$c = /* @__PURE__ */ vue.createTextVNode("\u53D6\u6D88");
|
|
210
|
+
function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
|
|
211
|
+
const _component_el_button = vue.resolveComponent("el-button");
|
|
212
|
+
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
206
213
|
return _ctx.uiSelectMode ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
207
214
|
key: 0,
|
|
208
215
|
class: "m-fields-ui-select",
|
|
209
216
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.cancelHandler && _ctx.cancelHandler(...args))
|
|
210
|
-
},
|
|
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$c
|
|
226
|
+
]),
|
|
227
|
+
_: 1
|
|
228
|
+
}, 8, ["icon"])
|
|
229
|
+
])) : (vue.openBlock(), vue.createElementBlock("div", {
|
|
211
230
|
key: 1,
|
|
212
231
|
class: "m-fields-ui-select",
|
|
213
|
-
onClick: _cache[
|
|
232
|
+
onClick: _cache[1] || (_cache[1] = (...args) => _ctx.startSelect && _ctx.startSelect(...args)),
|
|
233
|
+
style: { "display": "flex" }
|
|
214
234
|
}, [
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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(() => [
|
|
252
|
+
vue.createVNode(_component_el_button, {
|
|
253
|
+
text: "",
|
|
254
|
+
style: { "padding": "0", "margin": "0" }
|
|
255
|
+
}, {
|
|
256
|
+
default: vue.withCtx(() => [
|
|
257
|
+
vue.createTextVNode(vue.toDisplayString(_ctx.val ? _ctx.toName + "_" + _ctx.val : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1)
|
|
258
|
+
]),
|
|
259
|
+
_: 1
|
|
260
|
+
})
|
|
261
|
+
]),
|
|
262
|
+
_: 1
|
|
263
|
+
}, 8, ["content"])
|
|
222
264
|
]));
|
|
223
265
|
}
|
|
224
|
-
var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
266
|
+
var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$k]]);
|
|
225
267
|
|
|
226
268
|
const toString = (v, language) => {
|
|
227
269
|
let value = "";
|
|
@@ -238,7 +280,7 @@
|
|
|
238
280
|
}
|
|
239
281
|
return value;
|
|
240
282
|
};
|
|
241
|
-
const _sfc_main$
|
|
283
|
+
const _sfc_main$j = vue.defineComponent({
|
|
242
284
|
name: "magic-code-editor",
|
|
243
285
|
props: {
|
|
244
286
|
initValues: {
|
|
@@ -248,12 +290,16 @@
|
|
|
248
290
|
type: [String, Object]
|
|
249
291
|
},
|
|
250
292
|
type: {
|
|
251
|
-
type:
|
|
293
|
+
type: String,
|
|
252
294
|
default: () => ""
|
|
253
295
|
},
|
|
254
296
|
language: {
|
|
255
|
-
type:
|
|
297
|
+
type: String,
|
|
256
298
|
default: () => "javascript"
|
|
299
|
+
},
|
|
300
|
+
options: {
|
|
301
|
+
type: Object,
|
|
302
|
+
default: () => ({})
|
|
257
303
|
}
|
|
258
304
|
},
|
|
259
305
|
emits: ["initd", "save"],
|
|
@@ -263,6 +309,10 @@
|
|
|
263
309
|
const values = vue.ref("");
|
|
264
310
|
const loading = vue.ref(false);
|
|
265
311
|
const codeEditor = vue.ref();
|
|
312
|
+
const resizeObserver = new globalThis.ResizeObserver(lodashEs.throttle(() => {
|
|
313
|
+
vsEditor?.layout();
|
|
314
|
+
vsDiffEditor?.layout();
|
|
315
|
+
}, 300));
|
|
266
316
|
const setEditorValue = (v, m) => {
|
|
267
317
|
values.value = toString(v, props.language);
|
|
268
318
|
if (props.type === "diff") {
|
|
@@ -275,10 +325,6 @@
|
|
|
275
325
|
}
|
|
276
326
|
return vsEditor?.setValue(values.value);
|
|
277
327
|
};
|
|
278
|
-
const resizeHandler = () => {
|
|
279
|
-
vsEditor?.layout();
|
|
280
|
-
vsDiffEditor?.layout();
|
|
281
|
-
};
|
|
282
328
|
const getEditorValue = () => props.type === "diff" ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue();
|
|
283
329
|
const init = async () => {
|
|
284
330
|
if (!codeEditor.value)
|
|
@@ -286,11 +332,8 @@
|
|
|
286
332
|
const options = {
|
|
287
333
|
value: values.value,
|
|
288
334
|
language: props.language,
|
|
289
|
-
tabSize: 2,
|
|
290
335
|
theme: "vs-dark",
|
|
291
|
-
|
|
292
|
-
fontSize: 15,
|
|
293
|
-
formatOnPaste: true
|
|
336
|
+
...props.options
|
|
294
337
|
};
|
|
295
338
|
if (props.type === "diff") {
|
|
296
339
|
vsDiffEditor = monaco__namespace.editor.createDiffEditor(codeEditor.value, options);
|
|
@@ -303,6 +346,7 @@
|
|
|
303
346
|
codeEditor.value.addEventListener("keydown", (e) => {
|
|
304
347
|
if (e.keyCode === 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
|
|
305
348
|
e.preventDefault();
|
|
349
|
+
e.stopPropagation();
|
|
306
350
|
emit("save", getEditorValue());
|
|
307
351
|
}
|
|
308
352
|
});
|
|
@@ -311,7 +355,7 @@
|
|
|
311
355
|
emit("save", getEditorValue());
|
|
312
356
|
});
|
|
313
357
|
}
|
|
314
|
-
|
|
358
|
+
resizeObserver.observe(codeEditor.value);
|
|
315
359
|
};
|
|
316
360
|
vue.watch(() => props.initValues, (v, preV) => {
|
|
317
361
|
if (v !== preV) {
|
|
@@ -326,7 +370,7 @@
|
|
|
326
370
|
init();
|
|
327
371
|
});
|
|
328
372
|
vue.onUnmounted(() => {
|
|
329
|
-
|
|
373
|
+
resizeObserver.disconnect();
|
|
330
374
|
});
|
|
331
375
|
return {
|
|
332
376
|
values,
|
|
@@ -343,14 +387,14 @@
|
|
|
343
387
|
};
|
|
344
388
|
}
|
|
345
389
|
});
|
|
346
|
-
const _hoisted_1$
|
|
390
|
+
const _hoisted_1$b = {
|
|
347
391
|
ref: "codeEditor",
|
|
348
392
|
class: "magic-code-editor"
|
|
349
393
|
};
|
|
350
|
-
function _sfc_render$
|
|
351
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
394
|
+
function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
|
|
395
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, null, 512);
|
|
352
396
|
}
|
|
353
|
-
var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
397
|
+
var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$j]]);
|
|
354
398
|
|
|
355
399
|
let $TMAGIC_EDITOR = {};
|
|
356
400
|
const setConfig = (option) => {
|
|
@@ -359,9 +403,6 @@
|
|
|
359
403
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
360
404
|
|
|
361
405
|
class UndoRedo {
|
|
362
|
-
elementList;
|
|
363
|
-
listCursor;
|
|
364
|
-
listMaxSize;
|
|
365
406
|
constructor(listMaxSize = 200) {
|
|
366
407
|
const minListMaxSize = 2;
|
|
367
408
|
this.elementList = [];
|
|
@@ -434,11 +475,40 @@
|
|
|
434
475
|
|
|
435
476
|
const methodName = (prefix, name) => `${prefix}${name[0].toUpperCase()}${name.substring(1)}`;
|
|
436
477
|
const isError = (error) => Object.prototype.toString.call(error) === "[object Error]";
|
|
478
|
+
const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethodName, fn) => {
|
|
479
|
+
try {
|
|
480
|
+
let beforeArgs = args;
|
|
481
|
+
for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
|
|
482
|
+
let beforeReturnValue = await beforeMethod(...beforeArgs) || [];
|
|
483
|
+
if (isError(beforeReturnValue))
|
|
484
|
+
throw beforeReturnValue;
|
|
485
|
+
if (!Array.isArray(beforeReturnValue)) {
|
|
486
|
+
beforeReturnValue = [beforeReturnValue];
|
|
487
|
+
}
|
|
488
|
+
beforeArgs = beforeArgs.map((v, index) => {
|
|
489
|
+
if (typeof beforeReturnValue[index] === "undefined")
|
|
490
|
+
return v;
|
|
491
|
+
return beforeReturnValue[index];
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
|
|
495
|
+
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
496
|
+
returnValue = await afterMethod(returnValue, ...beforeArgs);
|
|
497
|
+
if (isError(returnValue))
|
|
498
|
+
throw returnValue;
|
|
499
|
+
}
|
|
500
|
+
return returnValue;
|
|
501
|
+
} catch (error) {
|
|
502
|
+
throw error;
|
|
503
|
+
}
|
|
504
|
+
};
|
|
437
505
|
class BaseService extends events.EventEmitter {
|
|
438
|
-
|
|
439
|
-
middleware = {};
|
|
440
|
-
constructor(methods) {
|
|
506
|
+
constructor(methods = [], serialMethods = []) {
|
|
441
507
|
super();
|
|
508
|
+
this.pluginOptionsList = {};
|
|
509
|
+
this.middleware = {};
|
|
510
|
+
this.taskList = [];
|
|
511
|
+
this.doingTask = false;
|
|
442
512
|
methods.forEach((propertyName) => {
|
|
443
513
|
const scope = this;
|
|
444
514
|
const sourceMethod = scope[propertyName];
|
|
@@ -450,27 +520,23 @@
|
|
|
450
520
|
const fn = compose(this.middleware[propertyName]);
|
|
451
521
|
Object.defineProperty(scope, propertyName, {
|
|
452
522
|
value: async (...args) => {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
let beforeReturnValue = await beforeMethod(...beforeArgs) || [];
|
|
456
|
-
if (isError(beforeReturnValue))
|
|
457
|
-
throw beforeReturnValue;
|
|
458
|
-
if (!Array.isArray(beforeReturnValue)) {
|
|
459
|
-
beforeReturnValue = [beforeReturnValue];
|
|
460
|
-
}
|
|
461
|
-
beforeArgs = beforeArgs.map((v, index) => {
|
|
462
|
-
if (typeof beforeReturnValue[index] === "undefined")
|
|
463
|
-
return v;
|
|
464
|
-
return beforeReturnValue[index];
|
|
465
|
-
});
|
|
523
|
+
if (!serialMethods.includes(propertyName)) {
|
|
524
|
+
return doAction(args, scope, sourceMethod, beforeMethodName, afterMethodName, fn);
|
|
466
525
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
526
|
+
const promise = new Promise((resolve, reject) => {
|
|
527
|
+
this.taskList.push(async () => {
|
|
528
|
+
try {
|
|
529
|
+
const value = await doAction(args, scope, sourceMethod, beforeMethodName, afterMethodName, fn);
|
|
530
|
+
resolve(value);
|
|
531
|
+
} catch (e) {
|
|
532
|
+
reject(e);
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
});
|
|
536
|
+
if (!this.doingTask) {
|
|
537
|
+
this.doTask();
|
|
472
538
|
}
|
|
473
|
-
return
|
|
539
|
+
return promise;
|
|
474
540
|
}
|
|
475
541
|
});
|
|
476
542
|
});
|
|
@@ -487,19 +553,34 @@
|
|
|
487
553
|
this.pluginOptionsList[methodName2].push(method);
|
|
488
554
|
});
|
|
489
555
|
}
|
|
556
|
+
async doTask() {
|
|
557
|
+
this.doingTask = true;
|
|
558
|
+
let task = this.taskList.shift();
|
|
559
|
+
while (task) {
|
|
560
|
+
await task();
|
|
561
|
+
task = this.taskList.shift();
|
|
562
|
+
}
|
|
563
|
+
this.doingTask = false;
|
|
564
|
+
}
|
|
490
565
|
}
|
|
491
566
|
|
|
492
567
|
class History extends BaseService {
|
|
493
|
-
state = vue.reactive({
|
|
494
|
-
pageSteps: {},
|
|
495
|
-
pageId: void 0,
|
|
496
|
-
canRedo: false,
|
|
497
|
-
canUndo: false
|
|
498
|
-
});
|
|
499
568
|
constructor() {
|
|
500
569
|
super([]);
|
|
570
|
+
this.state = vue.reactive({
|
|
571
|
+
pageSteps: {},
|
|
572
|
+
pageId: void 0,
|
|
573
|
+
canRedo: false,
|
|
574
|
+
canUndo: false
|
|
575
|
+
});
|
|
501
576
|
this.on("change", this.setCanUndoRedo);
|
|
502
577
|
}
|
|
578
|
+
reset() {
|
|
579
|
+
this.state.pageSteps = {};
|
|
580
|
+
this.state.pageId = void 0;
|
|
581
|
+
this.state.canRedo = false;
|
|
582
|
+
this.state.canUndo = false;
|
|
583
|
+
}
|
|
503
584
|
changePage(page) {
|
|
504
585
|
if (!page)
|
|
505
586
|
return;
|
|
@@ -563,12 +644,12 @@
|
|
|
563
644
|
var historyService = new History();
|
|
564
645
|
|
|
565
646
|
class Props extends BaseService {
|
|
566
|
-
state = vue.reactive({
|
|
567
|
-
propsConfigMap: {},
|
|
568
|
-
propsValueMap: {}
|
|
569
|
-
});
|
|
570
647
|
constructor() {
|
|
571
648
|
super(["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue"]);
|
|
649
|
+
this.state = vue.reactive({
|
|
650
|
+
propsConfigMap: {},
|
|
651
|
+
propsValueMap: {}
|
|
652
|
+
});
|
|
572
653
|
}
|
|
573
654
|
setPropsConfigs(configs) {
|
|
574
655
|
Object.keys(configs).forEach((type) => {
|
|
@@ -593,7 +674,7 @@
|
|
|
593
674
|
setPropsValue(type, value) {
|
|
594
675
|
this.state.propsValueMap[type] = value;
|
|
595
676
|
}
|
|
596
|
-
async getPropsValue(type) {
|
|
677
|
+
async getPropsValue(type, defaultValue = {}) {
|
|
597
678
|
if (type === "area") {
|
|
598
679
|
const value = await this.getPropsValue("button");
|
|
599
680
|
value.className = "action-area";
|
|
@@ -605,7 +686,7 @@
|
|
|
605
686
|
}
|
|
606
687
|
return lodashEs.cloneDeep({
|
|
607
688
|
...getDefaultPropsValue(type),
|
|
608
|
-
...this.state.propsValueMap[type] || {}
|
|
689
|
+
...lodashEs.mergeWith(this.state.propsValueMap[type] || {}, defaultValue)
|
|
609
690
|
});
|
|
610
691
|
}
|
|
611
692
|
}
|
|
@@ -632,7 +713,7 @@
|
|
|
632
713
|
const generateId = (type) => `${type}_${lodashEs.random(1e4, false)}`;
|
|
633
714
|
const getPageList = (app) => {
|
|
634
715
|
if (app.items && Array.isArray(app.items)) {
|
|
635
|
-
return app.items.filter((item) => item.type ===
|
|
716
|
+
return app.items.filter((item) => item.type === schema.NodeType.PAGE);
|
|
636
717
|
}
|
|
637
718
|
return [];
|
|
638
719
|
};
|
|
@@ -666,9 +747,9 @@
|
|
|
666
747
|
};
|
|
667
748
|
const setNewItemId = (config, parent) => {
|
|
668
749
|
const oldId = config.id;
|
|
669
|
-
config.id = generateId(config.type);
|
|
750
|
+
config.id = generateId(config.type || "component");
|
|
670
751
|
config.name = `${config.name?.replace(/_(\d+)$/, "")}_${config.id}`;
|
|
671
|
-
if (utils.isPop(config) && parent?.type ===
|
|
752
|
+
if (utils.isPop(config) && parent?.type === schema.NodeType.PAGE) {
|
|
672
753
|
updatePopId(oldId, config.id, parent);
|
|
673
754
|
}
|
|
674
755
|
if (config.items && Array.isArray(config.items)) {
|
|
@@ -689,11 +770,25 @@
|
|
|
689
770
|
};
|
|
690
771
|
return node;
|
|
691
772
|
};
|
|
692
|
-
const
|
|
773
|
+
const setTop2Middle = (node, parentNode, stage) => {
|
|
774
|
+
const style = node.style || {};
|
|
775
|
+
const height = style.height || 0;
|
|
776
|
+
if (!stage || typeof style.top !== "undefined" || !parentNode.style || !utils.isNumber(height))
|
|
777
|
+
return style;
|
|
778
|
+
const { height: parentHeight } = parentNode.style;
|
|
779
|
+
if (utils.isPage(parentNode)) {
|
|
780
|
+
const { scrollTop = 0, wrapperHeight } = stage.mask;
|
|
781
|
+
style.top = (wrapperHeight - height) / 2 + scrollTop;
|
|
782
|
+
} else {
|
|
783
|
+
style.top = (parentHeight - height) / 2;
|
|
784
|
+
}
|
|
785
|
+
return style;
|
|
786
|
+
};
|
|
787
|
+
const initPosition = (node, layout, parentNode, stage) => {
|
|
693
788
|
if (layout === Layout.ABSOLUTE) {
|
|
694
789
|
node.style = {
|
|
695
790
|
position: "absolute",
|
|
696
|
-
...node
|
|
791
|
+
...setTop2Middle(node, parentNode, stage)
|
|
697
792
|
};
|
|
698
793
|
return node;
|
|
699
794
|
}
|
|
@@ -740,7 +835,9 @@
|
|
|
740
835
|
const cur = path.pop();
|
|
741
836
|
const offset = {
|
|
742
837
|
left: cur?.style?.left || 0,
|
|
743
|
-
top: cur?.style?.top || 0
|
|
838
|
+
top: cur?.style?.top || 0,
|
|
839
|
+
right: "",
|
|
840
|
+
bottom: ""
|
|
744
841
|
};
|
|
745
842
|
path.forEach((value) => {
|
|
746
843
|
offset.left = offset.left - globalThis.parseFloat(value.style?.left || 0);
|
|
@@ -774,15 +871,6 @@
|
|
|
774
871
|
};
|
|
775
872
|
|
|
776
873
|
class Editor$1 extends BaseService {
|
|
777
|
-
isHistoryStateChange = false;
|
|
778
|
-
state = vue.reactive({
|
|
779
|
-
root: null,
|
|
780
|
-
page: null,
|
|
781
|
-
parent: null,
|
|
782
|
-
node: null,
|
|
783
|
-
stage: null,
|
|
784
|
-
modifiedNodeIds: /* @__PURE__ */ new Map()
|
|
785
|
-
});
|
|
786
874
|
constructor() {
|
|
787
875
|
super([
|
|
788
876
|
"getLayout",
|
|
@@ -795,13 +883,27 @@
|
|
|
795
883
|
"paste",
|
|
796
884
|
"alignCenter",
|
|
797
885
|
"moveLayer",
|
|
886
|
+
"move",
|
|
798
887
|
"undo",
|
|
799
|
-
"redo"
|
|
800
|
-
|
|
888
|
+
"redo",
|
|
889
|
+
"highlight"
|
|
890
|
+
], ["select", "update", "moveLayer"]);
|
|
891
|
+
this.isHistoryStateChange = false;
|
|
892
|
+
this.state = vue.reactive({
|
|
893
|
+
root: null,
|
|
894
|
+
page: null,
|
|
895
|
+
parent: null,
|
|
896
|
+
node: null,
|
|
897
|
+
stage: null,
|
|
898
|
+
highlightNode: null,
|
|
899
|
+
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
900
|
+
pageLength: 0
|
|
901
|
+
});
|
|
801
902
|
}
|
|
802
903
|
set(name, value) {
|
|
803
904
|
this.state[name] = value;
|
|
804
905
|
if (name === "root") {
|
|
906
|
+
this.state.pageLength = value?.items?.length || 0;
|
|
805
907
|
this.emit("root-change", value);
|
|
806
908
|
}
|
|
807
909
|
}
|
|
@@ -809,7 +911,7 @@
|
|
|
809
911
|
return this.state[name];
|
|
810
912
|
}
|
|
811
913
|
getNodeInfo(id) {
|
|
812
|
-
const root = this.get("root");
|
|
914
|
+
const root = vue.toRaw(this.get("root"));
|
|
813
915
|
if (!root)
|
|
814
916
|
return {};
|
|
815
917
|
if (id === root.id) {
|
|
@@ -823,7 +925,7 @@
|
|
|
823
925
|
info.node = path[path.length - 1];
|
|
824
926
|
info.parent = path[path.length - 2];
|
|
825
927
|
path.forEach((item) => {
|
|
826
|
-
if (item.type ===
|
|
928
|
+
if (item.type === schema.NodeType.PAGE) {
|
|
827
929
|
info.page = item;
|
|
828
930
|
return;
|
|
829
931
|
}
|
|
@@ -840,31 +942,19 @@
|
|
|
840
942
|
const { parent } = this.getNodeInfo(id);
|
|
841
943
|
return parent;
|
|
842
944
|
}
|
|
843
|
-
async getLayout(node) {
|
|
844
|
-
if (node
|
|
845
|
-
return
|
|
945
|
+
async getLayout(parent, node) {
|
|
946
|
+
if (node && typeof node !== "function" && isFixed(node))
|
|
947
|
+
return Layout.FIXED;
|
|
948
|
+
if (parent.layout) {
|
|
949
|
+
return parent.layout;
|
|
846
950
|
}
|
|
847
|
-
if (!
|
|
951
|
+
if (!parent.style?.position) {
|
|
848
952
|
return Layout.RELATIVE;
|
|
849
953
|
}
|
|
850
954
|
return Layout.ABSOLUTE;
|
|
851
955
|
}
|
|
852
956
|
async select(config2) {
|
|
853
|
-
|
|
854
|
-
if (typeof config2 === "string" || typeof config2 === "number") {
|
|
855
|
-
id = config2;
|
|
856
|
-
} else {
|
|
857
|
-
id = config2.id;
|
|
858
|
-
}
|
|
859
|
-
if (!id) {
|
|
860
|
-
throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
|
|
861
|
-
}
|
|
862
|
-
const { node, parent, page } = this.getNodeInfo(id);
|
|
863
|
-
if (!node)
|
|
864
|
-
throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
|
|
865
|
-
if (node.id === this.state.root?.id) {
|
|
866
|
-
throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
|
|
867
|
-
}
|
|
957
|
+
const { node, page, parent } = this.selectedConfigExceptionHandler(config2);
|
|
868
958
|
this.set("node", node);
|
|
869
959
|
this.set("page", page || null);
|
|
870
960
|
this.set("parent", parent || null);
|
|
@@ -873,12 +963,44 @@
|
|
|
873
963
|
} else {
|
|
874
964
|
historyService.empty();
|
|
875
965
|
}
|
|
966
|
+
this.emit("select", node);
|
|
876
967
|
return node;
|
|
877
968
|
}
|
|
878
|
-
async
|
|
969
|
+
async selectNextNode() {
|
|
970
|
+
const node = vue.toRaw(this.get("node"));
|
|
971
|
+
if (!node || utils.isPage(node) || node.type === schema.NodeType.ROOT)
|
|
972
|
+
return node;
|
|
973
|
+
const parent = vue.toRaw(this.getParentById(node.id));
|
|
974
|
+
if (!parent)
|
|
975
|
+
return node;
|
|
976
|
+
const index = getNodeIndex(node, parent);
|
|
977
|
+
const nextNode = parent.items[index + 1] || parent.items[0];
|
|
978
|
+
await this.select(nextNode);
|
|
979
|
+
this.get("stage")?.select(nextNode.id);
|
|
980
|
+
return nextNode;
|
|
981
|
+
}
|
|
982
|
+
async selectNextPage() {
|
|
983
|
+
const root = vue.toRaw(this.get("root"));
|
|
984
|
+
const page = vue.toRaw(this.get("page"));
|
|
985
|
+
const index = getNodeIndex(page, root);
|
|
986
|
+
const nextPage = root.items[index + 1] || root.items[0];
|
|
987
|
+
await this.select(nextPage);
|
|
988
|
+
this.get("stage")?.select(nextPage.id);
|
|
989
|
+
return nextPage;
|
|
990
|
+
}
|
|
991
|
+
highlight(config2) {
|
|
992
|
+
const { node } = this.selectedConfigExceptionHandler(config2);
|
|
993
|
+
const currentHighlightNode = this.get("highlightNode");
|
|
994
|
+
if (currentHighlightNode === node)
|
|
995
|
+
return;
|
|
996
|
+
this.set("highlightNode", node);
|
|
997
|
+
}
|
|
998
|
+
async add(addNode, parent) {
|
|
999
|
+
const { type, ...config2 } = addNode;
|
|
879
1000
|
const curNode = this.get("node");
|
|
880
1001
|
let parentNode;
|
|
881
|
-
|
|
1002
|
+
const isPage2 = type === schema.NodeType.PAGE;
|
|
1003
|
+
if (isPage2) {
|
|
882
1004
|
parentNode = this.get("root");
|
|
883
1005
|
} else if (parent && typeof parent !== "function") {
|
|
884
1006
|
parentNode = parent;
|
|
@@ -889,16 +1011,24 @@
|
|
|
889
1011
|
}
|
|
890
1012
|
if (!parentNode)
|
|
891
1013
|
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
892
|
-
const layout = await this.getLayout(parentNode);
|
|
893
|
-
const newNode = initPosition({ ...vue.toRaw(await propsService.getPropsValue(type
|
|
894
|
-
if ((parentNode?.type ===
|
|
1014
|
+
const layout = await this.getLayout(vue.toRaw(parentNode), addNode);
|
|
1015
|
+
const newNode = initPosition({ ...vue.toRaw(await propsService.getPropsValue(type, config2)) }, layout, parentNode, this.get("stage"));
|
|
1016
|
+
if ((parentNode?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && newNode.type !== schema.NodeType.PAGE) {
|
|
895
1017
|
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
896
1018
|
}
|
|
897
1019
|
parentNode?.items?.push(newNode);
|
|
898
|
-
|
|
1020
|
+
const stage = this.get("stage");
|
|
1021
|
+
await stage?.add({ config: lodashEs.cloneDeep(newNode), root: lodashEs.cloneDeep(this.get("root")) });
|
|
899
1022
|
await this.select(newNode);
|
|
900
1023
|
this.addModifiedNodeId(newNode.id);
|
|
901
|
-
|
|
1024
|
+
if (!isPage2) {
|
|
1025
|
+
this.pushHistoryState();
|
|
1026
|
+
}
|
|
1027
|
+
stage?.select(newNode.id);
|
|
1028
|
+
if (isPage2) {
|
|
1029
|
+
this.state.pageLength += 1;
|
|
1030
|
+
}
|
|
1031
|
+
this.emit("add", newNode);
|
|
902
1032
|
return newNode;
|
|
903
1033
|
}
|
|
904
1034
|
async remove(node) {
|
|
@@ -914,14 +1044,31 @@
|
|
|
914
1044
|
if (typeof index !== "number" || index === -1)
|
|
915
1045
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
916
1046
|
parent.items?.splice(index, 1);
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
1047
|
+
const stage = this.get("stage");
|
|
1048
|
+
stage?.remove({ id: node.id, root: this.get("root") });
|
|
1049
|
+
if (node.type === schema.NodeType.PAGE) {
|
|
1050
|
+
this.state.pageLength -= 1;
|
|
1051
|
+
if (root.items[0]) {
|
|
1052
|
+
await this.select(root.items[0]);
|
|
1053
|
+
stage?.select(root.items[0].id);
|
|
1054
|
+
} else {
|
|
1055
|
+
this.set("node", null);
|
|
1056
|
+
this.set("parent", null);
|
|
1057
|
+
this.set("page", null);
|
|
1058
|
+
this.set("stage", null);
|
|
1059
|
+
this.set("highlightNode", null);
|
|
1060
|
+
this.resetModifiedNodeId();
|
|
1061
|
+
historyService.reset();
|
|
1062
|
+
this.emit("remove", node);
|
|
1063
|
+
return node;
|
|
1064
|
+
}
|
|
920
1065
|
} else {
|
|
921
1066
|
await this.select(parent);
|
|
1067
|
+
stage?.select(parent.id);
|
|
922
1068
|
}
|
|
923
1069
|
this.addModifiedNodeId(parent.id);
|
|
924
1070
|
this.pushHistoryState();
|
|
1071
|
+
this.emit("remove", node);
|
|
925
1072
|
return node;
|
|
926
1073
|
}
|
|
927
1074
|
async update(config2) {
|
|
@@ -939,7 +1086,7 @@
|
|
|
939
1086
|
});
|
|
940
1087
|
if (!newConfig.type)
|
|
941
1088
|
throw new Error("\u914D\u7F6E\u7F3A\u5C11type\u503C");
|
|
942
|
-
if (newConfig.type ===
|
|
1089
|
+
if (newConfig.type === schema.NodeType.ROOT) {
|
|
943
1090
|
this.set("root", newConfig);
|
|
944
1091
|
return newConfig;
|
|
945
1092
|
}
|
|
@@ -956,15 +1103,16 @@
|
|
|
956
1103
|
newConfig = setLayout(newConfig, newLayout);
|
|
957
1104
|
}
|
|
958
1105
|
parentNodeItems[index] = newConfig;
|
|
959
|
-
if (newConfig.id === this.get("node").id) {
|
|
1106
|
+
if (`${newConfig.id}` === `${this.get("node").id}`) {
|
|
960
1107
|
this.set("node", newConfig);
|
|
961
1108
|
}
|
|
962
1109
|
this.get("stage")?.update({ config: lodashEs.cloneDeep(newConfig), root: this.get("root") });
|
|
963
|
-
if (newConfig.type ===
|
|
1110
|
+
if (newConfig.type === schema.NodeType.PAGE) {
|
|
964
1111
|
this.set("page", newConfig);
|
|
965
1112
|
}
|
|
966
1113
|
this.addModifiedNodeId(newConfig.id);
|
|
967
1114
|
this.pushHistoryState();
|
|
1115
|
+
this.emit("update", newConfig);
|
|
968
1116
|
return newConfig;
|
|
969
1117
|
}
|
|
970
1118
|
async sort(id1, id2) {
|
|
@@ -1008,7 +1156,7 @@
|
|
|
1008
1156
|
async alignCenter(config2) {
|
|
1009
1157
|
const parent = this.get("parent");
|
|
1010
1158
|
const node = this.get("node");
|
|
1011
|
-
const layout = await this.getLayout(parent);
|
|
1159
|
+
const layout = await this.getLayout(vue.toRaw(parent), vue.toRaw(node));
|
|
1012
1160
|
if (layout === Layout.RELATIVE) {
|
|
1013
1161
|
return;
|
|
1014
1162
|
}
|
|
@@ -1045,6 +1193,26 @@
|
|
|
1045
1193
|
await this.changeHistoryState(value);
|
|
1046
1194
|
return value;
|
|
1047
1195
|
}
|
|
1196
|
+
async move(left, top) {
|
|
1197
|
+
const node = vue.toRaw(this.get("node"));
|
|
1198
|
+
if (!node || utils.isPage(node))
|
|
1199
|
+
return;
|
|
1200
|
+
const { style, id } = node;
|
|
1201
|
+
if (!style || style.position !== "absolute")
|
|
1202
|
+
return;
|
|
1203
|
+
if (top && !utils.isNumber(style.top))
|
|
1204
|
+
return;
|
|
1205
|
+
if (left && !utils.isNumber(style.left))
|
|
1206
|
+
return;
|
|
1207
|
+
this.update({
|
|
1208
|
+
id,
|
|
1209
|
+
style: {
|
|
1210
|
+
...style,
|
|
1211
|
+
left: Number(style.left) + left,
|
|
1212
|
+
top: Number(style.top) + top
|
|
1213
|
+
}
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1048
1216
|
destroy() {
|
|
1049
1217
|
this.removeAllListeners();
|
|
1050
1218
|
this.set("root", null);
|
|
@@ -1077,7 +1245,12 @@
|
|
|
1077
1245
|
this.isHistoryStateChange = true;
|
|
1078
1246
|
await this.update(value.data);
|
|
1079
1247
|
this.set("modifiedNodeIds", value.modifiedNodeIds);
|
|
1080
|
-
setTimeout(() =>
|
|
1248
|
+
setTimeout(async () => {
|
|
1249
|
+
if (!value.nodeId)
|
|
1250
|
+
return;
|
|
1251
|
+
await this.select(value.nodeId);
|
|
1252
|
+
this.get("stage")?.select(value.nodeId);
|
|
1253
|
+
}, 0);
|
|
1081
1254
|
}
|
|
1082
1255
|
async toggleFixedPosition(dist, src, root) {
|
|
1083
1256
|
let newConfig = lodashEs.cloneDeep(dist);
|
|
@@ -1090,6 +1263,28 @@
|
|
|
1090
1263
|
}
|
|
1091
1264
|
return newConfig;
|
|
1092
1265
|
}
|
|
1266
|
+
selectedConfigExceptionHandler(config2) {
|
|
1267
|
+
let id;
|
|
1268
|
+
if (typeof config2 === "string" || typeof config2 === "number") {
|
|
1269
|
+
id = config2;
|
|
1270
|
+
} else {
|
|
1271
|
+
id = config2.id;
|
|
1272
|
+
}
|
|
1273
|
+
if (!id) {
|
|
1274
|
+
throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
|
|
1275
|
+
}
|
|
1276
|
+
const { node, parent, page } = this.getNodeInfo(id);
|
|
1277
|
+
if (!node)
|
|
1278
|
+
throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
|
|
1279
|
+
if (node.id === this.state.root?.id) {
|
|
1280
|
+
throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
|
|
1281
|
+
}
|
|
1282
|
+
return {
|
|
1283
|
+
node,
|
|
1284
|
+
parent,
|
|
1285
|
+
page
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1093
1288
|
}
|
|
1094
1289
|
var editorService = new Editor$1();
|
|
1095
1290
|
|
|
@@ -1247,6 +1442,25 @@
|
|
|
1247
1442
|
defaultValue: "100% 100%"
|
|
1248
1443
|
}
|
|
1249
1444
|
]
|
|
1445
|
+
},
|
|
1446
|
+
{
|
|
1447
|
+
type: "fieldset",
|
|
1448
|
+
legend: "\u5B57\u4F53",
|
|
1449
|
+
items: [
|
|
1450
|
+
{
|
|
1451
|
+
name: "color",
|
|
1452
|
+
text: "\u989C\u8272",
|
|
1453
|
+
type: "colorPicker"
|
|
1454
|
+
},
|
|
1455
|
+
{
|
|
1456
|
+
name: "fontSize",
|
|
1457
|
+
text: "\u5927\u5C0F"
|
|
1458
|
+
},
|
|
1459
|
+
{
|
|
1460
|
+
name: "fontWeight",
|
|
1461
|
+
text: "\u7C97\u7EC6"
|
|
1462
|
+
}
|
|
1463
|
+
]
|
|
1250
1464
|
}
|
|
1251
1465
|
]
|
|
1252
1466
|
}
|
|
@@ -1279,7 +1493,7 @@
|
|
|
1279
1493
|
type: "select",
|
|
1280
1494
|
options: (mForm, { model }) => {
|
|
1281
1495
|
const node = editorService.getNodeById(model.to);
|
|
1282
|
-
if (!node)
|
|
1496
|
+
if (!node?.type)
|
|
1283
1497
|
return [];
|
|
1284
1498
|
return eventsService.getMethod(node.type).map((option) => ({
|
|
1285
1499
|
text: option.label,
|
|
@@ -1314,7 +1528,7 @@
|
|
|
1314
1528
|
name: type
|
|
1315
1529
|
});
|
|
1316
1530
|
|
|
1317
|
-
const _sfc_main$
|
|
1531
|
+
const _sfc_main$i = vue.defineComponent({
|
|
1318
1532
|
components: { Plus: icons.Plus },
|
|
1319
1533
|
setup() {
|
|
1320
1534
|
const services = vue.inject("services");
|
|
@@ -1324,21 +1538,21 @@
|
|
|
1324
1538
|
if (!editorService)
|
|
1325
1539
|
return;
|
|
1326
1540
|
editorService.add({
|
|
1327
|
-
type:
|
|
1541
|
+
type: schema.NodeType.PAGE,
|
|
1328
1542
|
name: generatePageNameByApp(vue.toRaw(editorService.get("root")))
|
|
1329
1543
|
});
|
|
1330
1544
|
}
|
|
1331
1545
|
};
|
|
1332
1546
|
}
|
|
1333
1547
|
});
|
|
1334
|
-
const _hoisted_1$
|
|
1335
|
-
const _hoisted_2$
|
|
1336
|
-
const _hoisted_3$
|
|
1337
|
-
function _sfc_render$
|
|
1548
|
+
const _hoisted_1$a = { class: "m-editor-empty-panel" };
|
|
1549
|
+
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
1550
|
+
const _hoisted_3$2 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
1551
|
+
function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1338
1552
|
const _component_plus = vue.resolveComponent("plus");
|
|
1339
1553
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
1340
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
1341
|
-
vue.createElementVNode("div", _hoisted_2$
|
|
1554
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
|
|
1555
|
+
vue.createElementVNode("div", _hoisted_2$4, [
|
|
1342
1556
|
vue.createElementVNode("div", {
|
|
1343
1557
|
class: "m-editor-empty-button",
|
|
1344
1558
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
|
|
@@ -1351,1274 +1565,114 @@
|
|
|
1351
1565
|
_: 1
|
|
1352
1566
|
})
|
|
1353
1567
|
]),
|
|
1354
|
-
_hoisted_3$
|
|
1568
|
+
_hoisted_3$2
|
|
1355
1569
|
])
|
|
1356
1570
|
])
|
|
1357
1571
|
]);
|
|
1358
1572
|
}
|
|
1359
|
-
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1360
|
-
|
|
1361
|
-
/*
|
|
1362
|
-
Copyright (c) 2018 Daybrush
|
|
1363
|
-
@name: @daybrush/utils
|
|
1364
|
-
license: MIT
|
|
1365
|
-
author: Daybrush
|
|
1366
|
-
repository: https://github.com/daybrush/utils
|
|
1367
|
-
@version 1.6.0
|
|
1368
|
-
*/
|
|
1369
|
-
/**
|
|
1370
|
-
* get string "object"
|
|
1371
|
-
* @memberof Consts
|
|
1372
|
-
* @example
|
|
1373
|
-
import {OBJECT} from "@daybrush/utils";
|
|
1374
|
-
|
|
1375
|
-
console.log(OBJECT); // "object"
|
|
1376
|
-
*/
|
|
1377
|
-
|
|
1378
|
-
var OBJECT = "object";
|
|
1379
|
-
/**
|
|
1380
|
-
* Check the type that the value is object.
|
|
1381
|
-
* @memberof Utils
|
|
1382
|
-
* @param {string} value - Value to check the type
|
|
1383
|
-
* @return {} true if the type is correct, false otherwise
|
|
1384
|
-
* @example
|
|
1385
|
-
import {isObject} from "@daybrush/utils";
|
|
1386
|
-
|
|
1387
|
-
console.log(isObject({})); // true
|
|
1388
|
-
console.log(isObject(undefined)); // false
|
|
1389
|
-
console.log(isObject("")); // false
|
|
1390
|
-
console.log(isObject(null)); // false
|
|
1391
|
-
*/
|
|
1392
|
-
|
|
1393
|
-
function isObject(value) {
|
|
1394
|
-
return value && typeof value === OBJECT;
|
|
1395
|
-
}
|
|
1396
|
-
/**
|
|
1397
|
-
* Date.now() method
|
|
1398
|
-
* @memberof CrossBrowser
|
|
1399
|
-
* @return {number} milliseconds
|
|
1400
|
-
* @example
|
|
1401
|
-
import {now} from "@daybrush/utils";
|
|
1402
|
-
|
|
1403
|
-
console.log(now()); // 12121324241(milliseconds)
|
|
1404
|
-
*/
|
|
1405
|
-
|
|
1406
|
-
function now() {
|
|
1407
|
-
return Date.now ? Date.now() : new Date().getTime();
|
|
1408
|
-
}
|
|
1409
|
-
/**
|
|
1410
|
-
* Returns the index of the first element in the array that satisfies the provided testing function.
|
|
1411
|
-
* @function
|
|
1412
|
-
* @memberof CrossBrowser
|
|
1413
|
-
* @param - The array `findIndex` was called upon.
|
|
1414
|
-
* @param - A function to execute on each value in the array until the function returns true, indicating that the satisfying element was found.
|
|
1415
|
-
* @param - Returns defaultIndex if not found by the function.
|
|
1416
|
-
* @example
|
|
1417
|
-
import { findIndex } from "@daybrush/utils";
|
|
1573
|
+
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
|
|
1418
1574
|
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
defaultIndex = -1;
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
var length = arr.length;
|
|
1428
|
-
|
|
1429
|
-
for (var i = 0; i < length; ++i) {
|
|
1430
|
-
if (callback(arr[i], i, arr)) {
|
|
1431
|
-
return i;
|
|
1575
|
+
const _sfc_main$h = vue.defineComponent({
|
|
1576
|
+
name: "m-editor-resize",
|
|
1577
|
+
props: {
|
|
1578
|
+
type: {
|
|
1579
|
+
type: String
|
|
1432
1580
|
}
|
|
1581
|
+
},
|
|
1582
|
+
setup(props) {
|
|
1583
|
+
const services = vue.inject("services");
|
|
1584
|
+
const target = vue.ref();
|
|
1585
|
+
let getso;
|
|
1586
|
+
vue.onMounted(() => {
|
|
1587
|
+
if (!target.value)
|
|
1588
|
+
return;
|
|
1589
|
+
getso = new Gesto__default["default"](target.value, {
|
|
1590
|
+
container: window,
|
|
1591
|
+
pinchOutside: true
|
|
1592
|
+
}).on("drag", (e) => {
|
|
1593
|
+
if (!target.value || !services)
|
|
1594
|
+
return;
|
|
1595
|
+
let { left, right } = {
|
|
1596
|
+
...vue.toRaw(services.uiService.get("columnWidth"))
|
|
1597
|
+
};
|
|
1598
|
+
if (props.type === "left") {
|
|
1599
|
+
left += e.deltaX;
|
|
1600
|
+
} else if (props.type === "right") {
|
|
1601
|
+
right -= e.deltaX;
|
|
1602
|
+
}
|
|
1603
|
+
services.uiService.set("columnWidth", {
|
|
1604
|
+
left,
|
|
1605
|
+
right
|
|
1606
|
+
});
|
|
1607
|
+
});
|
|
1608
|
+
});
|
|
1609
|
+
vue.onUnmounted(() => {
|
|
1610
|
+
getso?.unset();
|
|
1611
|
+
});
|
|
1612
|
+
return {
|
|
1613
|
+
target
|
|
1614
|
+
};
|
|
1433
1615
|
}
|
|
1434
|
-
|
|
1435
|
-
return defaultIndex;
|
|
1436
|
-
}
|
|
1437
|
-
/**
|
|
1438
|
-
* Sets up a function that will be called whenever the specified event is delivered to the target
|
|
1439
|
-
* @memberof DOM
|
|
1440
|
-
* @param - event target
|
|
1441
|
-
* @param - A case-sensitive string representing the event type to listen for.
|
|
1442
|
-
* @param - The object which receives a notification (an object that implements the Event interface) when an event of the specified type occurs
|
|
1443
|
-
* @param - An options object that specifies characteristics about the event listener.
|
|
1444
|
-
* @example
|
|
1445
|
-
import {addEvent} from "@daybrush/utils";
|
|
1446
|
-
|
|
1447
|
-
addEvent(el, "click", e => {
|
|
1448
|
-
console.log(e);
|
|
1449
1616
|
});
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
el.addEventListener(type, listener, options);
|
|
1454
|
-
}
|
|
1455
|
-
/**
|
|
1456
|
-
* removes from the EventTarget an event listener previously registered with EventTarget.addEventListener()
|
|
1457
|
-
* @memberof DOM
|
|
1458
|
-
* @param - event target
|
|
1459
|
-
* @param - A case-sensitive string representing the event type to listen for.
|
|
1460
|
-
* @param - The EventListener function of the event handler to remove from the event target.
|
|
1461
|
-
* @param - An options object that specifies characteristics about the event listener.
|
|
1462
|
-
* @example
|
|
1463
|
-
import {addEvent, removeEvent} from "@daybrush/utils";
|
|
1464
|
-
const listener = e => {
|
|
1465
|
-
console.log(e);
|
|
1466
|
-
};
|
|
1467
|
-
addEvent(el, "click", listener);
|
|
1468
|
-
removeEvent(el, "click", listener);
|
|
1469
|
-
*/
|
|
1470
|
-
|
|
1471
|
-
function removeEvent(el, type, listener, options) {
|
|
1472
|
-
el.removeEventListener(type, listener, options);
|
|
1473
|
-
}
|
|
1474
|
-
|
|
1475
|
-
/*
|
|
1476
|
-
Copyright (c) 2019 Daybrush
|
|
1477
|
-
name: @scena/event-emitter
|
|
1478
|
-
license: MIT
|
|
1479
|
-
author: Daybrush
|
|
1480
|
-
repository: git+https://github.com/daybrush/gesture.git
|
|
1481
|
-
version: 1.0.5
|
|
1482
|
-
*/
|
|
1483
|
-
|
|
1484
|
-
/*! *****************************************************************************
|
|
1485
|
-
Copyright (c) Microsoft Corporation.
|
|
1486
|
-
|
|
1487
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
1488
|
-
purpose with or without fee is hereby granted.
|
|
1489
|
-
|
|
1490
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1491
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1492
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1493
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1494
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1495
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1496
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
1497
|
-
***************************************************************************** */
|
|
1498
|
-
var __assign$1 = function () {
|
|
1499
|
-
__assign$1 = Object.assign || function __assign(t) {
|
|
1500
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1501
|
-
s = arguments[i];
|
|
1502
|
-
|
|
1503
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
1504
|
-
}
|
|
1505
|
-
|
|
1506
|
-
return t;
|
|
1507
|
-
};
|
|
1508
|
-
|
|
1509
|
-
return __assign$1.apply(this, arguments);
|
|
1617
|
+
const _hoisted_1$9 = {
|
|
1618
|
+
ref: "target",
|
|
1619
|
+
class: "m-editor-resizer"
|
|
1510
1620
|
};
|
|
1511
|
-
function
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
return r;
|
|
1621
|
+
function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1622
|
+
return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$9, [
|
|
1623
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
1624
|
+
], 512);
|
|
1517
1625
|
}
|
|
1626
|
+
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
|
|
1518
1627
|
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
}
|
|
1529
|
-
/**
|
|
1530
|
-
* Add a listener to the registered event.
|
|
1531
|
-
* @param - Name of the event to be added
|
|
1532
|
-
* @param - listener function of the event to be added
|
|
1533
|
-
* @example
|
|
1534
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1535
|
-
* cosnt emitter = new EventEmitter();
|
|
1536
|
-
*
|
|
1537
|
-
* // Add listener in "a" event
|
|
1538
|
-
* emitter.on("a", () => {
|
|
1539
|
-
* });
|
|
1540
|
-
* // Add listeners
|
|
1541
|
-
* emitter.on({
|
|
1542
|
-
* a: () => {},
|
|
1543
|
-
* b: () => {},
|
|
1544
|
-
* });
|
|
1545
|
-
*/
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
var __proto = EventEmitter.prototype;
|
|
1549
|
-
|
|
1550
|
-
__proto.on = function (eventName, listener) {
|
|
1551
|
-
if (isObject(eventName)) {
|
|
1552
|
-
for (var name in eventName) {
|
|
1553
|
-
this.on(name, eventName[name]);
|
|
1554
|
-
}
|
|
1555
|
-
} else {
|
|
1556
|
-
this._addEvent(eventName, listener, {});
|
|
1628
|
+
const _sfc_main$g = vue.defineComponent({
|
|
1629
|
+
components: {
|
|
1630
|
+
AddPageBox,
|
|
1631
|
+
Resizer
|
|
1632
|
+
},
|
|
1633
|
+
props: {
|
|
1634
|
+
codeOptions: {
|
|
1635
|
+
type: Object,
|
|
1636
|
+
default: () => ({})
|
|
1557
1637
|
}
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
* // Remove all listeners in "A" event.
|
|
1573
|
-
* emitter.off("a");
|
|
1574
|
-
*
|
|
1575
|
-
*
|
|
1576
|
-
* // Remove "listener" listener in "a" event.
|
|
1577
|
-
* emitter.off("a", listener);
|
|
1578
|
-
*/
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
__proto.off = function (eventName, listener) {
|
|
1582
|
-
if (!eventName) {
|
|
1583
|
-
this._events = {};
|
|
1584
|
-
} else if (isObject(eventName)) {
|
|
1585
|
-
for (var name in eventName) {
|
|
1586
|
-
this.off(name);
|
|
1587
|
-
}
|
|
1588
|
-
} else if (!listener) {
|
|
1589
|
-
this._events[eventName] = [];
|
|
1590
|
-
} else {
|
|
1591
|
-
var events = this._events[eventName];
|
|
1592
|
-
|
|
1593
|
-
if (events) {
|
|
1594
|
-
var index = findIndex(events, function (e) {
|
|
1595
|
-
return e.listener === listener;
|
|
1596
|
-
});
|
|
1597
|
-
|
|
1598
|
-
if (index > -1) {
|
|
1599
|
-
events.splice(index, 1);
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
}
|
|
1603
|
-
|
|
1604
|
-
return this;
|
|
1605
|
-
};
|
|
1606
|
-
/**
|
|
1607
|
-
* Add a disposable listener and Use promise to the registered event.
|
|
1608
|
-
* @param - Name of the event to be added
|
|
1609
|
-
* @param - disposable listener function of the event to be added
|
|
1610
|
-
* @example
|
|
1611
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1612
|
-
* cosnt emitter = new EventEmitter();
|
|
1613
|
-
*
|
|
1614
|
-
* // Add a disposable listener in "a" event
|
|
1615
|
-
* emitter.once("a", () => {
|
|
1616
|
-
* });
|
|
1617
|
-
*
|
|
1618
|
-
* // Use Promise
|
|
1619
|
-
* emitter.once("a").then(e => {
|
|
1620
|
-
* });
|
|
1621
|
-
*/
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
__proto.once = function (eventName, listener) {
|
|
1625
|
-
var _this = this;
|
|
1626
|
-
|
|
1627
|
-
if (listener) {
|
|
1628
|
-
this._addEvent(eventName, listener, {
|
|
1629
|
-
once: true
|
|
1630
|
-
});
|
|
1631
|
-
}
|
|
1632
|
-
|
|
1633
|
-
return new Promise(function (resolve) {
|
|
1634
|
-
_this._addEvent(eventName, resolve, {
|
|
1635
|
-
once: true
|
|
1636
|
-
});
|
|
1637
|
-
});
|
|
1638
|
-
};
|
|
1639
|
-
/**
|
|
1640
|
-
* Fires an event to call listeners.
|
|
1641
|
-
* @param - Event name
|
|
1642
|
-
* @param - Event parameter
|
|
1643
|
-
* @return If false, stop the event.
|
|
1644
|
-
* @example
|
|
1645
|
-
*
|
|
1646
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1647
|
-
*
|
|
1648
|
-
*
|
|
1649
|
-
* const emitter = new EventEmitter();
|
|
1650
|
-
*
|
|
1651
|
-
* emitter.on("a", e => {
|
|
1652
|
-
* });
|
|
1653
|
-
*
|
|
1654
|
-
*
|
|
1655
|
-
* emitter.emit("a", {
|
|
1656
|
-
* a: 1,
|
|
1657
|
-
* });
|
|
1658
|
-
*/
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
__proto.emit = function (eventName, param) {
|
|
1662
|
-
var _this = this;
|
|
1663
|
-
|
|
1664
|
-
if (param === void 0) {
|
|
1665
|
-
param = {};
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
var events = this._events[eventName];
|
|
1669
|
-
|
|
1670
|
-
if (!eventName || !events) {
|
|
1671
|
-
return true;
|
|
1672
|
-
}
|
|
1673
|
-
|
|
1674
|
-
var isStop = false;
|
|
1675
|
-
param.eventType = eventName;
|
|
1676
|
-
|
|
1677
|
-
param.stop = function () {
|
|
1678
|
-
isStop = true;
|
|
1679
|
-
};
|
|
1680
|
-
|
|
1681
|
-
param.currentTarget = this;
|
|
1682
|
-
|
|
1683
|
-
__spreadArrays(events).forEach(function (info) {
|
|
1684
|
-
info.listener(param);
|
|
1685
|
-
|
|
1686
|
-
if (info.once) {
|
|
1687
|
-
_this.off(eventName, info.listener);
|
|
1688
|
-
}
|
|
1689
|
-
});
|
|
1690
|
-
|
|
1691
|
-
return !isStop;
|
|
1692
|
-
};
|
|
1693
|
-
/**
|
|
1694
|
-
* Fires an event to call listeners.
|
|
1695
|
-
* @param - Event name
|
|
1696
|
-
* @param - Event parameter
|
|
1697
|
-
* @return If false, stop the event.
|
|
1698
|
-
* @example
|
|
1699
|
-
*
|
|
1700
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1701
|
-
*
|
|
1702
|
-
*
|
|
1703
|
-
* const emitter = new EventEmitter();
|
|
1704
|
-
*
|
|
1705
|
-
* emitter.on("a", e => {
|
|
1706
|
-
* });
|
|
1707
|
-
*
|
|
1708
|
-
*
|
|
1709
|
-
* emitter.emit("a", {
|
|
1710
|
-
* a: 1,
|
|
1711
|
-
* });
|
|
1712
|
-
*/
|
|
1713
|
-
|
|
1714
|
-
/**
|
|
1715
|
-
* Fires an event to call listeners.
|
|
1716
|
-
* @param - Event name
|
|
1717
|
-
* @param - Event parameter
|
|
1718
|
-
* @return If false, stop the event.
|
|
1719
|
-
* @example
|
|
1720
|
-
*
|
|
1721
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1722
|
-
*
|
|
1723
|
-
*
|
|
1724
|
-
* const emitter = new EventEmitter();
|
|
1725
|
-
*
|
|
1726
|
-
* emitter.on("a", e => {
|
|
1727
|
-
* });
|
|
1728
|
-
*
|
|
1729
|
-
* // emit
|
|
1730
|
-
* emitter.trigger("a", {
|
|
1731
|
-
* a: 1,
|
|
1732
|
-
* });
|
|
1733
|
-
*/
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
__proto.trigger = function (eventName, param) {
|
|
1737
|
-
if (param === void 0) {
|
|
1738
|
-
param = {};
|
|
1739
|
-
}
|
|
1740
|
-
|
|
1741
|
-
return this.emit(eventName, param);
|
|
1742
|
-
};
|
|
1743
|
-
|
|
1744
|
-
__proto._addEvent = function (eventName, listener, options) {
|
|
1745
|
-
var events = this._events;
|
|
1746
|
-
events[eventName] = events[eventName] || [];
|
|
1747
|
-
var listeners = events[eventName];
|
|
1748
|
-
listeners.push(__assign$1({
|
|
1749
|
-
listener: listener
|
|
1750
|
-
}, options));
|
|
1751
|
-
};
|
|
1752
|
-
|
|
1753
|
-
return EventEmitter;
|
|
1754
|
-
}();
|
|
1755
|
-
|
|
1756
|
-
var EventEmitter$1 = EventEmitter;
|
|
1757
|
-
|
|
1758
|
-
/*
|
|
1759
|
-
Copyright (c) 2019 Daybrush
|
|
1760
|
-
name: gesto
|
|
1761
|
-
license: MIT
|
|
1762
|
-
author: Daybrush
|
|
1763
|
-
repository: git+https://github.com/daybrush/gesture.git
|
|
1764
|
-
version: 1.5.0
|
|
1765
|
-
*/
|
|
1766
|
-
|
|
1767
|
-
/*! *****************************************************************************
|
|
1768
|
-
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1769
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
1770
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
1771
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1772
|
-
|
|
1773
|
-
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
1774
|
-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
1775
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
1776
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
1777
|
-
|
|
1778
|
-
See the Apache Version 2.0 License for specific language governing permissions
|
|
1779
|
-
and limitations under the License.
|
|
1780
|
-
***************************************************************************** */
|
|
1781
|
-
|
|
1782
|
-
/* global Reflect, Promise */
|
|
1783
|
-
var extendStatics = function (d, b) {
|
|
1784
|
-
extendStatics = Object.setPrototypeOf || {
|
|
1785
|
-
__proto__: []
|
|
1786
|
-
} instanceof Array && function (d, b) {
|
|
1787
|
-
d.__proto__ = b;
|
|
1788
|
-
} || function (d, b) {
|
|
1789
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
1790
|
-
};
|
|
1791
|
-
|
|
1792
|
-
return extendStatics(d, b);
|
|
1793
|
-
};
|
|
1794
|
-
|
|
1795
|
-
function __extends(d, b) {
|
|
1796
|
-
extendStatics(d, b);
|
|
1797
|
-
|
|
1798
|
-
function __() {
|
|
1799
|
-
this.constructor = d;
|
|
1800
|
-
}
|
|
1801
|
-
|
|
1802
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1803
|
-
}
|
|
1804
|
-
var __assign = function () {
|
|
1805
|
-
__assign = Object.assign || function __assign(t) {
|
|
1806
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1807
|
-
s = arguments[i];
|
|
1808
|
-
|
|
1809
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
1810
|
-
}
|
|
1811
|
-
|
|
1812
|
-
return t;
|
|
1813
|
-
};
|
|
1814
|
-
|
|
1815
|
-
return __assign.apply(this, arguments);
|
|
1816
|
-
};
|
|
1817
|
-
|
|
1818
|
-
function getRad(pos1, pos2) {
|
|
1819
|
-
var distX = pos2[0] - pos1[0];
|
|
1820
|
-
var distY = pos2[1] - pos1[1];
|
|
1821
|
-
var rad = Math.atan2(distY, distX);
|
|
1822
|
-
return rad >= 0 ? rad : rad + Math.PI * 2;
|
|
1823
|
-
}
|
|
1824
|
-
function getRotatiion(touches) {
|
|
1825
|
-
return getRad([touches[0].clientX, touches[0].clientY], [touches[1].clientX, touches[1].clientY]) / Math.PI * 180;
|
|
1826
|
-
}
|
|
1827
|
-
function isMultiTouch(e) {
|
|
1828
|
-
return e.touches && e.touches.length >= 2;
|
|
1829
|
-
}
|
|
1830
|
-
function getEventClients(e) {
|
|
1831
|
-
if (e.touches) {
|
|
1832
|
-
return getClients(e.touches);
|
|
1833
|
-
} else {
|
|
1834
|
-
return [getClient(e)];
|
|
1835
|
-
}
|
|
1836
|
-
}
|
|
1837
|
-
function getPosition(clients, prevClients, startClients) {
|
|
1838
|
-
var length = startClients.length;
|
|
1839
|
-
|
|
1840
|
-
var _a = getAverageClient(clients, length),
|
|
1841
|
-
clientX = _a.clientX,
|
|
1842
|
-
clientY = _a.clientY,
|
|
1843
|
-
originalClientX = _a.originalClientX,
|
|
1844
|
-
originalClientY = _a.originalClientY;
|
|
1845
|
-
|
|
1846
|
-
var _b = getAverageClient(prevClients, length),
|
|
1847
|
-
prevX = _b.clientX,
|
|
1848
|
-
prevY = _b.clientY;
|
|
1849
|
-
|
|
1850
|
-
var _c = getAverageClient(startClients, length),
|
|
1851
|
-
startX = _c.clientX,
|
|
1852
|
-
startY = _c.clientY;
|
|
1853
|
-
|
|
1854
|
-
var deltaX = clientX - prevX;
|
|
1855
|
-
var deltaY = clientY - prevY;
|
|
1856
|
-
var distX = clientX - startX;
|
|
1857
|
-
var distY = clientY - startY;
|
|
1858
|
-
return {
|
|
1859
|
-
clientX: originalClientX,
|
|
1860
|
-
clientY: originalClientY,
|
|
1861
|
-
deltaX: deltaX,
|
|
1862
|
-
deltaY: deltaY,
|
|
1863
|
-
distX: distX,
|
|
1864
|
-
distY: distY
|
|
1865
|
-
};
|
|
1866
|
-
}
|
|
1867
|
-
function getDist(clients) {
|
|
1868
|
-
return Math.sqrt(Math.pow(clients[0].clientX - clients[1].clientX, 2) + Math.pow(clients[0].clientY - clients[1].clientY, 2));
|
|
1869
|
-
}
|
|
1870
|
-
function getClients(touches) {
|
|
1871
|
-
var length = Math.min(touches.length, 2);
|
|
1872
|
-
var clients = [];
|
|
1873
|
-
|
|
1874
|
-
for (var i = 0; i < length; ++i) {
|
|
1875
|
-
clients.push(getClient(touches[i]));
|
|
1876
|
-
}
|
|
1877
|
-
|
|
1878
|
-
return clients;
|
|
1879
|
-
}
|
|
1880
|
-
function getClient(e) {
|
|
1881
|
-
return {
|
|
1882
|
-
clientX: e.clientX,
|
|
1883
|
-
clientY: e.clientY
|
|
1884
|
-
};
|
|
1885
|
-
}
|
|
1886
|
-
function getAverageClient(clients, length) {
|
|
1887
|
-
if (length === void 0) {
|
|
1888
|
-
length = clients.length;
|
|
1889
|
-
}
|
|
1890
|
-
|
|
1891
|
-
var sumClient = {
|
|
1892
|
-
clientX: 0,
|
|
1893
|
-
clientY: 0,
|
|
1894
|
-
originalClientX: 0,
|
|
1895
|
-
originalClientY: 0
|
|
1896
|
-
};
|
|
1897
|
-
|
|
1898
|
-
for (var i = 0; i < length; ++i) {
|
|
1899
|
-
var client = clients[i];
|
|
1900
|
-
sumClient.originalClientX += "originalClientX" in client ? client.originalClientX : client.clientX;
|
|
1901
|
-
sumClient.originalClientY += "originalClientY" in client ? client.originalClientY : client.clientY;
|
|
1902
|
-
sumClient.clientX += client.clientX;
|
|
1903
|
-
sumClient.clientY += client.clientY;
|
|
1904
|
-
}
|
|
1905
|
-
|
|
1906
|
-
if (!length) {
|
|
1907
|
-
return sumClient;
|
|
1908
|
-
}
|
|
1909
|
-
|
|
1910
|
-
return {
|
|
1911
|
-
clientX: sumClient.clientX / length,
|
|
1912
|
-
clientY: sumClient.clientY / length,
|
|
1913
|
-
originalClientX: sumClient.originalClientX / length,
|
|
1914
|
-
originalClientY: sumClient.originalClientY / length
|
|
1915
|
-
};
|
|
1916
|
-
}
|
|
1917
|
-
|
|
1918
|
-
var ClientStore =
|
|
1919
|
-
/*#__PURE__*/
|
|
1920
|
-
function () {
|
|
1921
|
-
function ClientStore(clients) {
|
|
1922
|
-
this.prevClients = [];
|
|
1923
|
-
this.startClients = [];
|
|
1924
|
-
this.movement = 0;
|
|
1925
|
-
this.length = 0;
|
|
1926
|
-
this.startClients = clients;
|
|
1927
|
-
this.prevClients = clients;
|
|
1928
|
-
this.length = clients.length;
|
|
1929
|
-
}
|
|
1930
|
-
|
|
1931
|
-
var __proto = ClientStore.prototype;
|
|
1932
|
-
|
|
1933
|
-
__proto.addClients = function (clients) {
|
|
1934
|
-
if (clients === void 0) {
|
|
1935
|
-
clients = this.prevClients;
|
|
1936
|
-
}
|
|
1937
|
-
|
|
1938
|
-
var position = this.getPosition(clients);
|
|
1939
|
-
var deltaX = position.deltaX,
|
|
1940
|
-
deltaY = position.deltaY;
|
|
1941
|
-
this.movement += Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
1942
|
-
this.prevClients = clients;
|
|
1943
|
-
return position;
|
|
1944
|
-
};
|
|
1945
|
-
|
|
1946
|
-
__proto.getAngle = function (clients) {
|
|
1947
|
-
if (clients === void 0) {
|
|
1948
|
-
clients = this.prevClients;
|
|
1949
|
-
}
|
|
1950
|
-
|
|
1951
|
-
return getRotatiion(clients);
|
|
1952
|
-
};
|
|
1953
|
-
|
|
1954
|
-
__proto.getRotation = function (clients) {
|
|
1955
|
-
if (clients === void 0) {
|
|
1956
|
-
clients = this.prevClients;
|
|
1957
|
-
}
|
|
1958
|
-
|
|
1959
|
-
return getRotatiion(clients) - getRotatiion(this.startClients);
|
|
1960
|
-
};
|
|
1961
|
-
|
|
1962
|
-
__proto.getPosition = function (clients) {
|
|
1963
|
-
return getPosition(clients || this.prevClients, this.prevClients, this.startClients);
|
|
1964
|
-
};
|
|
1965
|
-
|
|
1966
|
-
__proto.getPositions = function (clients) {
|
|
1967
|
-
if (clients === void 0) {
|
|
1968
|
-
clients = this.prevClients;
|
|
1969
|
-
}
|
|
1970
|
-
|
|
1971
|
-
var prevClients = this.prevClients;
|
|
1972
|
-
return this.startClients.map(function (startClient, i) {
|
|
1973
|
-
return getPosition([clients[i]], [prevClients[i]], [startClient]);
|
|
1974
|
-
});
|
|
1975
|
-
};
|
|
1976
|
-
|
|
1977
|
-
__proto.getMovement = function (clients) {
|
|
1978
|
-
var movement = this.movement;
|
|
1979
|
-
|
|
1980
|
-
if (!clients) {
|
|
1981
|
-
return movement;
|
|
1982
|
-
}
|
|
1983
|
-
|
|
1984
|
-
var currentClient = getAverageClient(clients, this.length);
|
|
1985
|
-
var prevClient = getAverageClient(this.prevClients, this.length);
|
|
1986
|
-
var deltaX = currentClient.clientX - prevClient.clientX;
|
|
1987
|
-
var deltaY = currentClient.clientY - prevClient.clientY;
|
|
1988
|
-
return Math.sqrt(deltaX * deltaX + deltaY * deltaY) + movement;
|
|
1989
|
-
};
|
|
1990
|
-
|
|
1991
|
-
__proto.getDistance = function (clients) {
|
|
1992
|
-
if (clients === void 0) {
|
|
1993
|
-
clients = this.prevClients;
|
|
1994
|
-
}
|
|
1995
|
-
|
|
1996
|
-
return getDist(clients);
|
|
1997
|
-
};
|
|
1998
|
-
|
|
1999
|
-
__proto.getScale = function (clients) {
|
|
2000
|
-
if (clients === void 0) {
|
|
2001
|
-
clients = this.prevClients;
|
|
2002
|
-
}
|
|
2003
|
-
|
|
2004
|
-
return getDist(clients) / getDist(this.startClients);
|
|
2005
|
-
};
|
|
2006
|
-
|
|
2007
|
-
__proto.move = function (deltaX, deltaY) {
|
|
2008
|
-
this.startClients.forEach(function (client) {
|
|
2009
|
-
client.clientX -= deltaX;
|
|
2010
|
-
client.clientY -= deltaY;
|
|
2011
|
-
});
|
|
2012
|
-
this.prevClients.forEach(function (client) {
|
|
2013
|
-
client.clientX -= deltaX;
|
|
2014
|
-
client.clientY -= deltaY;
|
|
2015
|
-
});
|
|
2016
|
-
};
|
|
2017
|
-
|
|
2018
|
-
return ClientStore;
|
|
2019
|
-
}();
|
|
2020
|
-
|
|
2021
|
-
var INPUT_TAGNAMES = ["textarea", "input"];
|
|
2022
|
-
/**
|
|
2023
|
-
* You can set up drag, pinch events in any browser.
|
|
2024
|
-
*/
|
|
2025
|
-
|
|
2026
|
-
var Gesto =
|
|
2027
|
-
/*#__PURE__*/
|
|
2028
|
-
function (_super) {
|
|
2029
|
-
__extends(Gesto, _super);
|
|
2030
|
-
/**
|
|
2031
|
-
*
|
|
2032
|
-
*/
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
function Gesto(targets, options) {
|
|
2036
|
-
if (options === void 0) {
|
|
2037
|
-
options = {};
|
|
2038
|
-
}
|
|
2039
|
-
|
|
2040
|
-
var _this = _super.call(this) || this;
|
|
2041
|
-
|
|
2042
|
-
_this.options = {};
|
|
2043
|
-
_this.flag = false;
|
|
2044
|
-
_this.pinchFlag = false;
|
|
2045
|
-
_this.datas = {};
|
|
2046
|
-
_this.isDrag = false;
|
|
2047
|
-
_this.isPinch = false;
|
|
2048
|
-
_this.isMouse = false;
|
|
2049
|
-
_this.isTouch = false;
|
|
2050
|
-
_this.clientStores = [];
|
|
2051
|
-
_this.targets = [];
|
|
2052
|
-
_this.prevTime = 0;
|
|
2053
|
-
_this.doubleFlag = false;
|
|
2054
|
-
|
|
2055
|
-
_this.onDragStart = function (e, isTrusted) {
|
|
2056
|
-
if (isTrusted === void 0) {
|
|
2057
|
-
isTrusted = true;
|
|
2058
|
-
}
|
|
2059
|
-
|
|
2060
|
-
if (!_this.flag && e.cancelable === false) {
|
|
2061
|
-
return;
|
|
2062
|
-
}
|
|
2063
|
-
|
|
2064
|
-
var _a = _this.options,
|
|
2065
|
-
container = _a.container,
|
|
2066
|
-
pinchOutside = _a.pinchOutside,
|
|
2067
|
-
preventRightClick = _a.preventRightClick,
|
|
2068
|
-
preventDefault = _a.preventDefault,
|
|
2069
|
-
checkInput = _a.checkInput;
|
|
2070
|
-
var isTouch = _this.isTouch;
|
|
2071
|
-
var isDragStart = !_this.flag;
|
|
2072
|
-
|
|
2073
|
-
if (isDragStart) {
|
|
2074
|
-
var activeElement = document.activeElement;
|
|
2075
|
-
var target = e.target;
|
|
2076
|
-
var tagName = target.tagName.toLowerCase();
|
|
2077
|
-
var hasInput = INPUT_TAGNAMES.indexOf(tagName) > -1;
|
|
2078
|
-
var hasContentEditable = target.isContentEditable;
|
|
2079
|
-
|
|
2080
|
-
if (hasInput || hasContentEditable) {
|
|
2081
|
-
if (checkInput || activeElement === target) {
|
|
2082
|
-
// force false or already focused.
|
|
2083
|
-
return false;
|
|
2084
|
-
}
|
|
2085
|
-
|
|
2086
|
-
if (activeElement && hasContentEditable && activeElement.isContentEditable && activeElement.contains(target)) {
|
|
2087
|
-
return false;
|
|
2088
|
-
}
|
|
2089
|
-
} else if ((preventDefault || e.type === "touchstart") && activeElement) {
|
|
2090
|
-
var activeTagName = activeElement.tagName;
|
|
2091
|
-
|
|
2092
|
-
if (activeElement.isContentEditable || INPUT_TAGNAMES.indexOf(activeTagName) > -1) {
|
|
2093
|
-
activeElement.blur();
|
|
2094
|
-
}
|
|
2095
|
-
}
|
|
2096
|
-
|
|
2097
|
-
_this.clientStores = [new ClientStore(getEventClients(e))];
|
|
2098
|
-
_this.flag = true;
|
|
2099
|
-
_this.isDrag = false;
|
|
2100
|
-
_this.datas = {};
|
|
2101
|
-
|
|
2102
|
-
if (preventRightClick && (e.which === 3 || e.button === 2)) {
|
|
2103
|
-
_this.initDrag();
|
|
2104
|
-
|
|
2105
|
-
return false;
|
|
2106
|
-
}
|
|
2107
|
-
|
|
2108
|
-
_this.doubleFlag = now() - _this.prevTime < 200;
|
|
2109
|
-
|
|
2110
|
-
var result = _this.emit("dragStart", __assign({
|
|
2111
|
-
datas: _this.datas,
|
|
2112
|
-
inputEvent: e,
|
|
2113
|
-
isTrusted: isTrusted,
|
|
2114
|
-
isDouble: _this.doubleFlag
|
|
2115
|
-
}, _this.getCurrentStore().getPosition()));
|
|
2116
|
-
|
|
2117
|
-
if (result === false) {
|
|
2118
|
-
_this.initDrag();
|
|
2119
|
-
}
|
|
2120
|
-
|
|
2121
|
-
_this.flag && preventDefault && e.preventDefault();
|
|
2122
|
-
}
|
|
2123
|
-
|
|
2124
|
-
if (!_this.flag) {
|
|
2125
|
-
return false;
|
|
2126
|
-
}
|
|
2127
|
-
|
|
2128
|
-
var timer = 0;
|
|
2129
|
-
|
|
2130
|
-
if (isDragStart && isTouch && pinchOutside) {
|
|
2131
|
-
timer = setTimeout(function () {
|
|
2132
|
-
addEvent(container, "touchstart", _this.onDragStart, {
|
|
2133
|
-
passive: false
|
|
2134
|
-
});
|
|
2135
|
-
});
|
|
2136
|
-
}
|
|
2137
|
-
|
|
2138
|
-
if (!isDragStart && isTouch && pinchOutside) {
|
|
2139
|
-
removeEvent(container, "touchstart", _this.onDragStart);
|
|
2140
|
-
}
|
|
2141
|
-
|
|
2142
|
-
if (_this.flag && isMultiTouch(e)) {
|
|
2143
|
-
clearTimeout(timer);
|
|
2144
|
-
|
|
2145
|
-
if (isDragStart && e.touches.length !== e.changedTouches.length) {
|
|
2146
|
-
return;
|
|
2147
|
-
}
|
|
2148
|
-
|
|
2149
|
-
if (!_this.pinchFlag) {
|
|
2150
|
-
_this.onPinchStart(e);
|
|
2151
|
-
}
|
|
2152
|
-
}
|
|
2153
|
-
};
|
|
2154
|
-
|
|
2155
|
-
_this.onDrag = function (e, isScroll) {
|
|
2156
|
-
if (!_this.flag) {
|
|
2157
|
-
return;
|
|
2158
|
-
}
|
|
2159
|
-
|
|
2160
|
-
var clients = getEventClients(e);
|
|
2161
|
-
|
|
2162
|
-
var result = _this.moveClients(clients, e, false);
|
|
2163
|
-
|
|
2164
|
-
if (_this.pinchFlag || result.deltaX || result.deltaY) {
|
|
2165
|
-
var dragResult = _this.emit("drag", __assign({}, result, {
|
|
2166
|
-
isScroll: !!isScroll,
|
|
2167
|
-
inputEvent: e
|
|
2168
|
-
}));
|
|
2169
|
-
|
|
2170
|
-
if (dragResult === false) {
|
|
2171
|
-
_this.stop();
|
|
2172
|
-
|
|
2173
|
-
return;
|
|
2174
|
-
}
|
|
2175
|
-
}
|
|
2176
|
-
|
|
2177
|
-
if (_this.pinchFlag) {
|
|
2178
|
-
_this.onPinch(e, clients);
|
|
2179
|
-
}
|
|
2180
|
-
|
|
2181
|
-
_this.getCurrentStore().addClients(clients);
|
|
2182
|
-
};
|
|
2183
|
-
|
|
2184
|
-
_this.onDragEnd = function (e) {
|
|
2185
|
-
if (!_this.flag) {
|
|
2186
|
-
return;
|
|
2187
|
-
}
|
|
2188
|
-
|
|
2189
|
-
var _a = _this.options,
|
|
2190
|
-
pinchOutside = _a.pinchOutside,
|
|
2191
|
-
container = _a.container;
|
|
2192
|
-
|
|
2193
|
-
if (_this.isTouch && pinchOutside) {
|
|
2194
|
-
removeEvent(container, "touchstart", _this.onDragStart);
|
|
2195
|
-
}
|
|
2196
|
-
|
|
2197
|
-
_this.flag = false;
|
|
2198
|
-
|
|
2199
|
-
var position = _this.getCurrentStore().getPosition();
|
|
2200
|
-
|
|
2201
|
-
var currentTime = now();
|
|
2202
|
-
var isDouble = !_this.isDrag && _this.doubleFlag;
|
|
2203
|
-
_this.prevTime = _this.isDrag || isDouble ? 0 : currentTime;
|
|
2204
|
-
|
|
2205
|
-
_this.emit("dragEnd", __assign({
|
|
2206
|
-
datas: _this.datas,
|
|
2207
|
-
isDouble: isDouble,
|
|
2208
|
-
isDrag: _this.isDrag,
|
|
2209
|
-
isClick: !_this.isDrag,
|
|
2210
|
-
inputEvent: e
|
|
2211
|
-
}, position));
|
|
2212
|
-
|
|
2213
|
-
if (_this.pinchFlag) {
|
|
2214
|
-
_this.onPinchEnd(e);
|
|
2215
|
-
}
|
|
2216
|
-
|
|
2217
|
-
_this.clientStores = [];
|
|
2218
|
-
};
|
|
2219
|
-
|
|
2220
|
-
_this.onBlur = function () {
|
|
2221
|
-
_this.onDragEnd();
|
|
2222
|
-
};
|
|
2223
|
-
|
|
2224
|
-
var elements = [].concat(targets);
|
|
2225
|
-
_this.options = __assign({
|
|
2226
|
-
checkInput: false,
|
|
2227
|
-
container: elements.length > 1 ? window : elements[0],
|
|
2228
|
-
preventRightClick: true,
|
|
2229
|
-
preventDefault: true,
|
|
2230
|
-
checkWindowBlur: false,
|
|
2231
|
-
pinchThreshold: 0,
|
|
2232
|
-
events: ["touch", "mouse"]
|
|
2233
|
-
}, options);
|
|
2234
|
-
var _a = _this.options,
|
|
2235
|
-
container = _a.container,
|
|
2236
|
-
events = _a.events,
|
|
2237
|
-
checkWindowBlur = _a.checkWindowBlur;
|
|
2238
|
-
_this.isTouch = events.indexOf("touch") > -1;
|
|
2239
|
-
_this.isMouse = events.indexOf("mouse") > -1;
|
|
2240
|
-
_this.targets = elements;
|
|
2241
|
-
|
|
2242
|
-
if (_this.isMouse) {
|
|
2243
|
-
elements.forEach(function (el) {
|
|
2244
|
-
addEvent(el, "mousedown", _this.onDragStart);
|
|
2245
|
-
});
|
|
2246
|
-
addEvent(container, "mousemove", _this.onDrag);
|
|
2247
|
-
addEvent(container, "mouseup", _this.onDragEnd);
|
|
2248
|
-
addEvent(container, "contextmenu", _this.onDragEnd);
|
|
2249
|
-
}
|
|
2250
|
-
|
|
2251
|
-
if (checkWindowBlur) {
|
|
2252
|
-
addEvent(window, "blur", _this.onBlur);
|
|
2253
|
-
}
|
|
2254
|
-
|
|
2255
|
-
if (_this.isTouch) {
|
|
2256
|
-
var passive_1 = {
|
|
2257
|
-
passive: false
|
|
2258
|
-
};
|
|
2259
|
-
elements.forEach(function (el) {
|
|
2260
|
-
addEvent(el, "touchstart", _this.onDragStart, passive_1);
|
|
2261
|
-
});
|
|
2262
|
-
addEvent(container, "touchmove", _this.onDrag, passive_1);
|
|
2263
|
-
addEvent(container, "touchend", _this.onDragEnd, passive_1);
|
|
2264
|
-
addEvent(container, "touchcancel", _this.onDragEnd, passive_1);
|
|
2265
|
-
}
|
|
2266
|
-
|
|
2267
|
-
return _this;
|
|
2268
|
-
}
|
|
2269
|
-
/**
|
|
2270
|
-
* Stop Gesto's drag events.
|
|
2271
|
-
*/
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
var __proto = Gesto.prototype;
|
|
2275
|
-
|
|
2276
|
-
__proto.stop = function () {
|
|
2277
|
-
this.isDrag = false;
|
|
2278
|
-
this.flag = false;
|
|
2279
|
-
this.clientStores = [];
|
|
2280
|
-
this.datas = {};
|
|
2281
|
-
};
|
|
2282
|
-
/**
|
|
2283
|
-
* The total moved distance
|
|
2284
|
-
*/
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
__proto.getMovement = function (clients) {
|
|
2288
|
-
return this.getCurrentStore().getMovement(clients) + this.clientStores.slice(1).reduce(function (prev, cur) {
|
|
2289
|
-
return prev + cur.movement;
|
|
2290
|
-
}, 0);
|
|
2291
|
-
};
|
|
2292
|
-
/**
|
|
2293
|
-
* Whether to drag
|
|
2294
|
-
*/
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
__proto.isDragging = function () {
|
|
2298
|
-
return this.isDrag;
|
|
2299
|
-
};
|
|
2300
|
-
/**
|
|
2301
|
-
* Whether to start drag
|
|
2302
|
-
*/
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
__proto.isFlag = function () {
|
|
2306
|
-
return this.flag;
|
|
2307
|
-
};
|
|
2308
|
-
/**
|
|
2309
|
-
* Whether to start pinch
|
|
2310
|
-
*/
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
__proto.isPinchFlag = function () {
|
|
2314
|
-
return this.pinchFlag;
|
|
2315
|
-
};
|
|
2316
|
-
/**
|
|
2317
|
-
* Whether to start double click
|
|
2318
|
-
*/
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
__proto.isDoubleFlag = function () {
|
|
2322
|
-
return this.doubleFlag;
|
|
2323
|
-
};
|
|
2324
|
-
/**
|
|
2325
|
-
* Whether to pinch
|
|
2326
|
-
*/
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
__proto.isPinching = function () {
|
|
2330
|
-
return this.isPinch;
|
|
2331
|
-
};
|
|
2332
|
-
/**
|
|
2333
|
-
* If a scroll event occurs, it is corrected by the scroll distance.
|
|
2334
|
-
*/
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
__proto.scrollBy = function (deltaX, deltaY, e, isCallDrag) {
|
|
2338
|
-
if (isCallDrag === void 0) {
|
|
2339
|
-
isCallDrag = true;
|
|
2340
|
-
}
|
|
2341
|
-
|
|
2342
|
-
if (!this.flag) {
|
|
2343
|
-
return;
|
|
2344
|
-
}
|
|
2345
|
-
|
|
2346
|
-
this.clientStores[0].move(deltaX, deltaY);
|
|
2347
|
-
isCallDrag && this.onDrag(e, true);
|
|
2348
|
-
};
|
|
2349
|
-
/**
|
|
2350
|
-
* Create a virtual drag event.
|
|
2351
|
-
*/
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
__proto.move = function (_a, inputEvent) {
|
|
2355
|
-
var deltaX = _a[0],
|
|
2356
|
-
deltaY = _a[1];
|
|
2357
|
-
var store = this.getCurrentStore();
|
|
2358
|
-
var nextClients = store.prevClients;
|
|
2359
|
-
return this.moveClients(nextClients.map(function (_a) {
|
|
2360
|
-
var clientX = _a.clientX,
|
|
2361
|
-
clientY = _a.clientY;
|
|
2362
|
-
return {
|
|
2363
|
-
clientX: clientX + deltaX,
|
|
2364
|
-
clientY: clientY + deltaY,
|
|
2365
|
-
originalClientX: clientX,
|
|
2366
|
-
originalClientY: clientY
|
|
2367
|
-
};
|
|
2368
|
-
}), inputEvent, true);
|
|
2369
|
-
};
|
|
2370
|
-
/**
|
|
2371
|
-
* The dragStart event is triggered by an external event.
|
|
2372
|
-
*/
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
__proto.triggerDragStart = function (e) {
|
|
2376
|
-
this.onDragStart(e, false);
|
|
2377
|
-
};
|
|
2378
|
-
/**
|
|
2379
|
-
* Set the event data while dragging.
|
|
2380
|
-
*/
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
__proto.setEventDatas = function (datas) {
|
|
2384
|
-
var currentDatas = this.datas;
|
|
2385
|
-
|
|
2386
|
-
for (var name in datas) {
|
|
2387
|
-
currentDatas[name] = datas[name];
|
|
2388
|
-
}
|
|
2389
|
-
|
|
2390
|
-
return this;
|
|
2391
|
-
};
|
|
2392
|
-
/**
|
|
2393
|
-
* Set the event data while dragging.
|
|
2394
|
-
*/
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
__proto.getEventDatas = function () {
|
|
2398
|
-
return this.datas;
|
|
2399
|
-
};
|
|
2400
|
-
/**
|
|
2401
|
-
* Unset Gesto
|
|
2402
|
-
*/
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
__proto.unset = function () {
|
|
2406
|
-
var _this = this;
|
|
2407
|
-
|
|
2408
|
-
var targets = this.targets;
|
|
2409
|
-
var container = this.options.container;
|
|
2410
|
-
this.off();
|
|
2411
|
-
removeEvent(window, "blur", this.onBlur);
|
|
2412
|
-
|
|
2413
|
-
if (this.isMouse) {
|
|
2414
|
-
targets.forEach(function (target) {
|
|
2415
|
-
removeEvent(target, "mousedown", _this.onDragStart);
|
|
2416
|
-
});
|
|
2417
|
-
removeEvent(container, "mousemove", this.onDrag);
|
|
2418
|
-
removeEvent(container, "mouseup", this.onDragEnd);
|
|
2419
|
-
removeEvent(container, "contextmenu", this.onDragEnd);
|
|
2420
|
-
}
|
|
2421
|
-
|
|
2422
|
-
if (this.isTouch) {
|
|
2423
|
-
targets.forEach(function (target) {
|
|
2424
|
-
removeEvent(target, "touchstart", _this.onDragStart);
|
|
2425
|
-
});
|
|
2426
|
-
removeEvent(container, "touchstart", this.onDragStart);
|
|
2427
|
-
removeEvent(container, "touchmove", this.onDrag);
|
|
2428
|
-
removeEvent(container, "touchend", this.onDragEnd);
|
|
2429
|
-
removeEvent(container, "touchcancel", this.onDragEnd);
|
|
2430
|
-
}
|
|
2431
|
-
};
|
|
2432
|
-
|
|
2433
|
-
__proto.onPinchStart = function (e) {
|
|
2434
|
-
var pinchThreshold = this.options.pinchThreshold;
|
|
2435
|
-
|
|
2436
|
-
if (this.isDrag && this.getMovement() > pinchThreshold) {
|
|
2437
|
-
return;
|
|
2438
|
-
}
|
|
2439
|
-
|
|
2440
|
-
var store = new ClientStore(getEventClients(e));
|
|
2441
|
-
this.pinchFlag = true;
|
|
2442
|
-
this.clientStores.splice(0, 0, store);
|
|
2443
|
-
var result = this.emit("pinchStart", __assign({
|
|
2444
|
-
datas: this.datas,
|
|
2445
|
-
angle: store.getAngle(),
|
|
2446
|
-
touches: this.getCurrentStore().getPositions()
|
|
2447
|
-
}, store.getPosition(), {
|
|
2448
|
-
inputEvent: e
|
|
2449
|
-
}));
|
|
2450
|
-
|
|
2451
|
-
if (result === false) {
|
|
2452
|
-
this.pinchFlag = false;
|
|
2453
|
-
}
|
|
2454
|
-
};
|
|
2455
|
-
|
|
2456
|
-
__proto.onPinch = function (e, clients) {
|
|
2457
|
-
if (!this.flag || !this.pinchFlag || clients.length < 2) {
|
|
2458
|
-
return;
|
|
2459
|
-
}
|
|
2460
|
-
|
|
2461
|
-
var store = this.getCurrentStore();
|
|
2462
|
-
this.isPinch = true;
|
|
2463
|
-
this.emit("pinch", __assign({
|
|
2464
|
-
datas: this.datas,
|
|
2465
|
-
movement: this.getMovement(clients),
|
|
2466
|
-
angle: store.getAngle(clients),
|
|
2467
|
-
rotation: store.getRotation(clients),
|
|
2468
|
-
touches: store.getPositions(clients),
|
|
2469
|
-
scale: store.getScale(clients),
|
|
2470
|
-
distance: store.getDistance(clients)
|
|
2471
|
-
}, store.getPosition(clients), {
|
|
2472
|
-
inputEvent: e
|
|
2473
|
-
}));
|
|
2474
|
-
};
|
|
2475
|
-
|
|
2476
|
-
__proto.onPinchEnd = function (e) {
|
|
2477
|
-
if (!this.pinchFlag) {
|
|
2478
|
-
return;
|
|
2479
|
-
}
|
|
2480
|
-
|
|
2481
|
-
var isPinch = this.isPinch;
|
|
2482
|
-
this.isPinch = false;
|
|
2483
|
-
this.pinchFlag = false;
|
|
2484
|
-
var store = this.getCurrentStore();
|
|
2485
|
-
this.emit("pinchEnd", __assign({
|
|
2486
|
-
datas: this.datas,
|
|
2487
|
-
isPinch: isPinch,
|
|
2488
|
-
touches: store.getPositions()
|
|
2489
|
-
}, store.getPosition(), {
|
|
2490
|
-
inputEvent: e
|
|
2491
|
-
}));
|
|
2492
|
-
this.isPinch = false;
|
|
2493
|
-
this.pinchFlag = false;
|
|
2494
|
-
};
|
|
2495
|
-
|
|
2496
|
-
__proto.initDrag = function () {
|
|
2497
|
-
this.clientStores = [];
|
|
2498
|
-
this.pinchFlag = false;
|
|
2499
|
-
this.doubleFlag = false;
|
|
2500
|
-
this.prevTime = 0;
|
|
2501
|
-
this.flag = false;
|
|
2502
|
-
};
|
|
2503
|
-
|
|
2504
|
-
__proto.getCurrentStore = function () {
|
|
2505
|
-
return this.clientStores[0];
|
|
2506
|
-
};
|
|
2507
|
-
|
|
2508
|
-
__proto.moveClients = function (clients, inputEvent, isAdd) {
|
|
2509
|
-
var store = this.getCurrentStore();
|
|
2510
|
-
var position = store[isAdd ? "addClients" : "getPosition"](clients);
|
|
2511
|
-
this.isDrag = true;
|
|
2512
|
-
return __assign({
|
|
2513
|
-
datas: this.datas
|
|
2514
|
-
}, position, {
|
|
2515
|
-
movement: this.getMovement(clients),
|
|
2516
|
-
isDrag: this.isDrag,
|
|
2517
|
-
isPinch: this.isPinch,
|
|
2518
|
-
isScroll: false,
|
|
2519
|
-
inputEvent: inputEvent
|
|
2520
|
-
});
|
|
2521
|
-
};
|
|
2522
|
-
|
|
2523
|
-
return Gesto;
|
|
2524
|
-
}(EventEmitter$1);
|
|
2525
|
-
|
|
2526
|
-
var Gesto$1 = Gesto;
|
|
2527
|
-
|
|
2528
|
-
const _sfc_main$f = vue.defineComponent({
|
|
2529
|
-
name: "m-editor-resize",
|
|
2530
|
-
props: {
|
|
2531
|
-
type: {
|
|
2532
|
-
type: String
|
|
2533
|
-
}
|
|
2534
|
-
},
|
|
2535
|
-
setup(props) {
|
|
2536
|
-
const services = vue.inject("services");
|
|
2537
|
-
const target = vue.ref();
|
|
2538
|
-
let getso;
|
|
2539
|
-
vue.onMounted(() => {
|
|
2540
|
-
if (!target.value)
|
|
2541
|
-
return;
|
|
2542
|
-
getso = new Gesto$1(target.value, {
|
|
2543
|
-
container: window,
|
|
2544
|
-
pinchOutside: true
|
|
2545
|
-
}).on("drag", (e) => {
|
|
2546
|
-
if (!target.value || !services)
|
|
2547
|
-
return;
|
|
2548
|
-
let { left, right } = {
|
|
2549
|
-
...vue.toRaw(services.uiService.get("columnWidth"))
|
|
2550
|
-
};
|
|
2551
|
-
if (props.type === "left") {
|
|
2552
|
-
left += e.deltaX;
|
|
2553
|
-
} else if (props.type === "right") {
|
|
2554
|
-
right -= e.deltaX;
|
|
2555
|
-
}
|
|
2556
|
-
services.uiService.set("columnWidth", {
|
|
2557
|
-
left,
|
|
2558
|
-
right
|
|
2559
|
-
});
|
|
2560
|
-
});
|
|
2561
|
-
});
|
|
2562
|
-
vue.onUnmounted(() => {
|
|
2563
|
-
getso?.unset();
|
|
2564
|
-
});
|
|
2565
|
-
return {
|
|
2566
|
-
target
|
|
2567
|
-
};
|
|
2568
|
-
}
|
|
2569
|
-
});
|
|
2570
|
-
const _hoisted_1$a = {
|
|
2571
|
-
ref: "target",
|
|
2572
|
-
class: "m-editor-resizer"
|
|
2573
|
-
};
|
|
2574
|
-
function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2575
|
-
return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$a, [
|
|
2576
|
-
vue.renderSlot(_ctx.$slots, "default")
|
|
2577
|
-
], 512);
|
|
2578
|
-
}
|
|
2579
|
-
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
|
|
2580
|
-
|
|
2581
|
-
const _sfc_main$e = vue.defineComponent({
|
|
2582
|
-
components: {
|
|
2583
|
-
AddPageBox,
|
|
2584
|
-
Resizer
|
|
2585
|
-
},
|
|
2586
|
-
setup() {
|
|
2587
|
-
const services = vue.inject("services");
|
|
2588
|
-
const root = vue.computed(() => services?.editorService.get("root"));
|
|
2589
|
-
return {
|
|
2590
|
-
root,
|
|
2591
|
-
pageLength: vue.computed(() => root.value?.items?.length || 0),
|
|
2592
|
-
showSrc: vue.computed(() => services?.uiService.get("showSrc")),
|
|
2593
|
-
columnWidth: vue.computed(() => services?.uiService.get("columnWidth")),
|
|
2594
|
-
saveCode(value) {
|
|
2595
|
-
try {
|
|
2596
|
-
services?.editorService.set("root", eval(value));
|
|
2597
|
-
} catch (e) {
|
|
2598
|
-
console.error(e);
|
|
1638
|
+
},
|
|
1639
|
+
setup() {
|
|
1640
|
+
const { editorService, uiService } = vue.inject("services") || {};
|
|
1641
|
+
const root = vue.computed(() => editorService?.get("root"));
|
|
1642
|
+
return {
|
|
1643
|
+
root,
|
|
1644
|
+
pageLength: vue.computed(() => editorService?.get("pageLength") || 0),
|
|
1645
|
+
showSrc: vue.computed(() => uiService?.get("showSrc")),
|
|
1646
|
+
columnWidth: vue.computed(() => uiService?.get("columnWidth")),
|
|
1647
|
+
saveCode(value) {
|
|
1648
|
+
try {
|
|
1649
|
+
editorService?.set("root", eval(value));
|
|
1650
|
+
} catch (e) {
|
|
1651
|
+
console.error(e);
|
|
2599
1652
|
}
|
|
2600
1653
|
}
|
|
2601
1654
|
};
|
|
2602
1655
|
}
|
|
2603
1656
|
});
|
|
2604
|
-
const _hoisted_1$
|
|
2605
|
-
const _hoisted_2$
|
|
1657
|
+
const _hoisted_1$8 = { class: "m-editor" };
|
|
1658
|
+
const _hoisted_2$3 = {
|
|
2606
1659
|
key: 1,
|
|
2607
1660
|
class: "m-editor-content"
|
|
2608
1661
|
};
|
|
2609
|
-
function _sfc_render$
|
|
1662
|
+
function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2610
1663
|
const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
|
|
2611
1664
|
const _component_resizer = vue.resolveComponent("resizer");
|
|
2612
1665
|
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
|
|
2613
1666
|
const _component_add_page_box = vue.resolveComponent("add-page-box");
|
|
2614
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
1667
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
|
|
2615
1668
|
vue.renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
2616
1669
|
_ctx.showSrc ? (vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
|
|
2617
1670
|
key: 0,
|
|
2618
1671
|
class: "m-editor-content",
|
|
2619
1672
|
"init-values": _ctx.root,
|
|
1673
|
+
options: _ctx.codeOptions,
|
|
2620
1674
|
onSave: _ctx.saveCode
|
|
2621
|
-
}, null, 8, ["init-values", "onSave"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$
|
|
1675
|
+
}, null, 8, ["init-values", "options", "onSave"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$3, [
|
|
2622
1676
|
vue.createElementVNode("div", {
|
|
2623
1677
|
class: "m-editor-framework-left",
|
|
2624
1678
|
style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.left}px`)
|
|
@@ -2651,9 +1705,9 @@
|
|
|
2651
1705
|
]))
|
|
2652
1706
|
]);
|
|
2653
1707
|
}
|
|
2654
|
-
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1708
|
+
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
|
|
2655
1709
|
|
|
2656
|
-
const _sfc_main$
|
|
1710
|
+
const _sfc_main$f = vue.defineComponent({
|
|
2657
1711
|
name: "m-icon",
|
|
2658
1712
|
components: { Edit: icons.Edit },
|
|
2659
1713
|
props: {
|
|
@@ -2667,8 +1721,8 @@
|
|
|
2667
1721
|
};
|
|
2668
1722
|
}
|
|
2669
1723
|
});
|
|
2670
|
-
const _hoisted_1$
|
|
2671
|
-
function _sfc_render$
|
|
1724
|
+
const _hoisted_1$7 = ["src"];
|
|
1725
|
+
function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2672
1726
|
const _component_edit = vue.resolveComponent("edit");
|
|
2673
1727
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
2674
1728
|
return !_ctx.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
|
|
@@ -2679,7 +1733,7 @@
|
|
|
2679
1733
|
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.createElementBlock("img", {
|
|
2680
1734
|
key: 1,
|
|
2681
1735
|
src: _ctx.icon
|
|
2682
|
-
}, null, 8, _hoisted_1$
|
|
1736
|
+
}, null, 8, _hoisted_1$7)) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
|
|
2683
1737
|
key: 2,
|
|
2684
1738
|
class: vue.normalizeClass(_ctx.icon)
|
|
2685
1739
|
}, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
|
|
@@ -2689,9 +1743,9 @@
|
|
|
2689
1743
|
_: 1
|
|
2690
1744
|
}));
|
|
2691
1745
|
}
|
|
2692
|
-
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1746
|
+
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
|
|
2693
1747
|
|
|
2694
|
-
const _sfc_main$
|
|
1748
|
+
const _sfc_main$e = vue.defineComponent({
|
|
2695
1749
|
components: { MIcon, ArrowDown: icons.ArrowDown },
|
|
2696
1750
|
props: {
|
|
2697
1751
|
data: {
|
|
@@ -2701,16 +1755,20 @@
|
|
|
2701
1755
|
type: "text",
|
|
2702
1756
|
display: false
|
|
2703
1757
|
})
|
|
1758
|
+
},
|
|
1759
|
+
eventType: {
|
|
1760
|
+
type: String,
|
|
1761
|
+
default: "click"
|
|
2704
1762
|
}
|
|
2705
1763
|
},
|
|
2706
1764
|
setup(props) {
|
|
2707
1765
|
const services = vue.inject("services");
|
|
2708
1766
|
const uiService = services?.uiService;
|
|
2709
|
-
const zoomInHandler = () => uiService?.set("zoom", zoom.value + 0.1);
|
|
2710
|
-
const zoomOutHandler = () => uiService?.set("zoom", zoom.value - 0.1);
|
|
2711
1767
|
const zoom = vue.computed(() => uiService?.get("zoom") ?? 1);
|
|
2712
1768
|
const showGuides = vue.computed(() => uiService?.get("showGuides") ?? true);
|
|
2713
1769
|
const showRule = vue.computed(() => uiService?.get("showRule") ?? true);
|
|
1770
|
+
const zoomInHandler = () => uiService?.zoom(0.1);
|
|
1771
|
+
const zoomOutHandler = () => uiService?.zoom(-0.1);
|
|
2714
1772
|
const item = vue.computed(() => {
|
|
2715
1773
|
if (typeof props.data !== "string") {
|
|
2716
1774
|
return props.data;
|
|
@@ -2727,15 +1785,15 @@
|
|
|
2727
1785
|
case "delete":
|
|
2728
1786
|
return {
|
|
2729
1787
|
type: "button",
|
|
2730
|
-
icon: icons.Delete,
|
|
1788
|
+
icon: vue.markRaw(icons.Delete),
|
|
2731
1789
|
tooltip: "\u522A\u9664",
|
|
2732
|
-
disabled: () => services?.editorService.get("node")?.type ===
|
|
1790
|
+
disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
|
|
2733
1791
|
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
2734
1792
|
};
|
|
2735
1793
|
case "undo":
|
|
2736
1794
|
return {
|
|
2737
1795
|
type: "button",
|
|
2738
|
-
icon: icons.Back,
|
|
1796
|
+
icon: vue.markRaw(icons.Back),
|
|
2739
1797
|
tooltip: "\u540E\u9000",
|
|
2740
1798
|
disabled: () => !services?.historyService.state.canUndo,
|
|
2741
1799
|
handler: () => services?.editorService.undo()
|
|
@@ -2743,7 +1801,7 @@
|
|
|
2743
1801
|
case "redo":
|
|
2744
1802
|
return {
|
|
2745
1803
|
type: "button",
|
|
2746
|
-
icon: icons.Right,
|
|
1804
|
+
icon: vue.markRaw(icons.Right),
|
|
2747
1805
|
tooltip: "\u524D\u8FDB",
|
|
2748
1806
|
disabled: () => !services?.historyService.state.canRedo,
|
|
2749
1807
|
handler: () => services?.editorService.redo()
|
|
@@ -2751,28 +1809,28 @@
|
|
|
2751
1809
|
case "zoom-in":
|
|
2752
1810
|
return {
|
|
2753
1811
|
type: "button",
|
|
2754
|
-
icon: icons.ZoomIn,
|
|
1812
|
+
icon: vue.markRaw(icons.ZoomIn),
|
|
2755
1813
|
tooltip: "\u653E\u5927",
|
|
2756
1814
|
handler: zoomInHandler
|
|
2757
1815
|
};
|
|
2758
1816
|
case "zoom-out":
|
|
2759
1817
|
return {
|
|
2760
1818
|
type: "button",
|
|
2761
|
-
icon: icons.ZoomOut,
|
|
1819
|
+
icon: vue.markRaw(icons.ZoomOut),
|
|
2762
1820
|
tooltip: "\u7E2E\u5C0F",
|
|
2763
1821
|
handler: zoomOutHandler
|
|
2764
1822
|
};
|
|
2765
1823
|
case "rule":
|
|
2766
1824
|
return {
|
|
2767
1825
|
type: "button",
|
|
2768
|
-
icon: icons.ScaleToOriginal,
|
|
1826
|
+
icon: vue.markRaw(icons.ScaleToOriginal),
|
|
2769
1827
|
tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
|
|
2770
1828
|
handler: () => uiService?.set("showRule", !showRule.value)
|
|
2771
1829
|
};
|
|
2772
1830
|
case "guides":
|
|
2773
1831
|
return {
|
|
2774
1832
|
type: "button",
|
|
2775
|
-
icon: icons.Grid,
|
|
1833
|
+
icon: vue.markRaw(icons.Grid),
|
|
2776
1834
|
tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
|
|
2777
1835
|
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
2778
1836
|
};
|
|
@@ -2793,9 +1851,16 @@
|
|
|
2793
1851
|
}
|
|
2794
1852
|
return item.value.disabled;
|
|
2795
1853
|
});
|
|
1854
|
+
const buttonHandler = (item2, event) => {
|
|
1855
|
+
if (disabled.value)
|
|
1856
|
+
return;
|
|
1857
|
+
if (typeof item2.handler === "function" && services) {
|
|
1858
|
+
item2.handler?.(services, event);
|
|
1859
|
+
}
|
|
1860
|
+
};
|
|
2796
1861
|
return {
|
|
2797
|
-
ZoomIn: icons.ZoomIn,
|
|
2798
|
-
ZoomOut: icons.ZoomOut,
|
|
1862
|
+
ZoomIn: vue.markRaw(icons.ZoomIn),
|
|
1863
|
+
ZoomOut: vue.markRaw(icons.ZoomOut),
|
|
2799
1864
|
item,
|
|
2800
1865
|
zoom,
|
|
2801
1866
|
disabled,
|
|
@@ -2816,31 +1881,42 @@
|
|
|
2816
1881
|
command.item.handler(services);
|
|
2817
1882
|
}
|
|
2818
1883
|
},
|
|
2819
|
-
|
|
2820
|
-
if (
|
|
1884
|
+
clickHandler(item2, event) {
|
|
1885
|
+
if (props.eventType !== "click")
|
|
1886
|
+
return;
|
|
1887
|
+
if (item2.type === "button") {
|
|
1888
|
+
buttonHandler(item2, event);
|
|
1889
|
+
}
|
|
1890
|
+
},
|
|
1891
|
+
mousedownHandler(item2, event) {
|
|
1892
|
+
if (props.eventType !== "mousedown")
|
|
1893
|
+
return;
|
|
1894
|
+
if (item2.type === "button") {
|
|
1895
|
+
buttonHandler(item2, event);
|
|
1896
|
+
}
|
|
1897
|
+
},
|
|
1898
|
+
mouseupHandler(item2, event) {
|
|
1899
|
+
if (props.eventType !== "mouseup")
|
|
2821
1900
|
return;
|
|
2822
|
-
if (
|
|
2823
|
-
item2
|
|
1901
|
+
if (item2.type === "button") {
|
|
1902
|
+
buttonHandler(item2, event);
|
|
2824
1903
|
}
|
|
2825
1904
|
}
|
|
2826
1905
|
};
|
|
2827
1906
|
}
|
|
2828
1907
|
});
|
|
2829
|
-
const _hoisted_1$
|
|
2830
|
-
key: 0,
|
|
2831
|
-
class: "menu-item"
|
|
2832
|
-
};
|
|
2833
|
-
const _hoisted_2$4 = {
|
|
1908
|
+
const _hoisted_1$6 = {
|
|
2834
1909
|
key: 1,
|
|
2835
1910
|
class: "menu-item-text"
|
|
2836
1911
|
};
|
|
2837
|
-
const
|
|
1912
|
+
const _hoisted_2$2 = {
|
|
2838
1913
|
class: "menu-item-text",
|
|
2839
1914
|
style: { "margin": "0 5px" }
|
|
2840
1915
|
};
|
|
2841
|
-
const
|
|
2842
|
-
function _sfc_render$
|
|
1916
|
+
const _hoisted_3$1 = { class: "el-dropdown-link menubar-menu-button" };
|
|
1917
|
+
function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2843
1918
|
const _component_el_divider = vue.resolveComponent("el-divider");
|
|
1919
|
+
const _component_tool_button = vue.resolveComponent("tool-button", true);
|
|
2844
1920
|
const _component_m_icon = vue.resolveComponent("m-icon");
|
|
2845
1921
|
const _component_el_button = vue.resolveComponent("el-button");
|
|
2846
1922
|
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
@@ -2849,44 +1925,66 @@
|
|
|
2849
1925
|
const _component_el_dropdown_item = vue.resolveComponent("el-dropdown-item");
|
|
2850
1926
|
const _component_el_dropdown_menu = vue.resolveComponent("el-dropdown-menu");
|
|
2851
1927
|
const _component_el_dropdown = vue.resolveComponent("el-dropdown");
|
|
2852
|
-
return _ctx.display ? (vue.openBlock(), vue.createElementBlock("div",
|
|
1928
|
+
return _ctx.display ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
1929
|
+
key: 0,
|
|
1930
|
+
class: vue.normalizeClass(["menu-item", _ctx.item.type]),
|
|
1931
|
+
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.clickHandler(_ctx.item, $event)),
|
|
1932
|
+
onMousedown: _cache[1] || (_cache[1] = ($event) => _ctx.mousedownHandler(_ctx.item, $event)),
|
|
1933
|
+
onMouseup: _cache[2] || (_cache[2] = ($event) => _ctx.mouseupHandler(_ctx.item, $event))
|
|
1934
|
+
}, [
|
|
2853
1935
|
_ctx.item.type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
|
|
2854
1936
|
key: 0,
|
|
2855
|
-
direction: "vertical"
|
|
2856
|
-
})) : _ctx.item.type === "text" ? (vue.openBlock(), vue.createElementBlock("div",
|
|
2857
|
-
vue.createVNode(
|
|
2858
|
-
icon: _ctx.
|
|
2859
|
-
|
|
2860
|
-
}, null, 8, ["
|
|
2861
|
-
vue.createElementVNode("span",
|
|
2862
|
-
vue.createVNode(
|
|
2863
|
-
icon: _ctx.
|
|
2864
|
-
|
|
2865
|
-
}, null, 8, ["
|
|
2866
|
-
], 64)) : _ctx.item.type === "button" ? (vue.openBlock(), vue.
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
vue.
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
1937
|
+
direction: _ctx.item.direction || "vertical"
|
|
1938
|
+
}, null, 8, ["direction"])) : _ctx.item.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, vue.toDisplayString(_ctx.item.text), 1)) : _ctx.item.type === "zoom" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
|
|
1939
|
+
vue.createVNode(_component_tool_button, {
|
|
1940
|
+
data: { type: "button", icon: _ctx.ZoomOut, handler: _ctx.zoomOutHandler, tooltip: "\u7F29\u5C0F" },
|
|
1941
|
+
"event-type": _ctx.eventType
|
|
1942
|
+
}, null, 8, ["data", "event-type"]),
|
|
1943
|
+
vue.createElementVNode("span", _hoisted_2$2, vue.toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
|
|
1944
|
+
vue.createVNode(_component_tool_button, {
|
|
1945
|
+
data: { type: "button", icon: _ctx.ZoomIn, handler: _ctx.zoomInHandler, tooltip: "\u653E\u5927" },
|
|
1946
|
+
"event-type": _ctx.eventType
|
|
1947
|
+
}, null, 8, ["data", "event-type"])
|
|
1948
|
+
], 64)) : _ctx.item.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
|
|
1949
|
+
_ctx.item.tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
|
|
1950
|
+
key: 0,
|
|
1951
|
+
effect: "dark",
|
|
1952
|
+
placement: "bottom-start",
|
|
1953
|
+
content: _ctx.item.tooltip
|
|
1954
|
+
}, {
|
|
1955
|
+
default: vue.withCtx(() => [
|
|
1956
|
+
vue.createVNode(_component_el_button, {
|
|
1957
|
+
size: "small",
|
|
1958
|
+
text: "",
|
|
1959
|
+
disabled: _ctx.disabled
|
|
1960
|
+
}, {
|
|
1961
|
+
default: vue.withCtx(() => [
|
|
1962
|
+
_ctx.item.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
|
|
1963
|
+
key: 0,
|
|
1964
|
+
icon: _ctx.item.icon
|
|
1965
|
+
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
1966
|
+
vue.createElementVNode("span", null, vue.toDisplayString(_ctx.item.text), 1)
|
|
1967
|
+
]),
|
|
1968
|
+
_: 1
|
|
1969
|
+
}, 8, ["disabled"])
|
|
1970
|
+
]),
|
|
1971
|
+
_: 1
|
|
1972
|
+
}, 8, ["content"])) : (vue.openBlock(), vue.createBlock(_component_el_button, {
|
|
1973
|
+
key: 1,
|
|
1974
|
+
size: "small",
|
|
1975
|
+
text: "",
|
|
1976
|
+
disabled: _ctx.disabled
|
|
1977
|
+
}, {
|
|
1978
|
+
default: vue.withCtx(() => [
|
|
1979
|
+
_ctx.item.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
|
|
1980
|
+
key: 0,
|
|
1981
|
+
icon: _ctx.item.icon
|
|
1982
|
+
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
1983
|
+
vue.createElementVNode("span", null, vue.toDisplayString(_ctx.item.text), 1)
|
|
1984
|
+
]),
|
|
1985
|
+
_: 1
|
|
1986
|
+
}, 8, ["disabled"]))
|
|
1987
|
+
], 64)) : _ctx.item.type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
|
|
2890
1988
|
key: 4,
|
|
2891
1989
|
trigger: "click",
|
|
2892
1990
|
disabled: _ctx.disabled,
|
|
@@ -2911,7 +2009,7 @@
|
|
|
2911
2009
|
})) : vue.createCommentVNode("", true)
|
|
2912
2010
|
]),
|
|
2913
2011
|
default: vue.withCtx(() => [
|
|
2914
|
-
vue.createElementVNode("span",
|
|
2012
|
+
vue.createElementVNode("span", _hoisted_3$1, [
|
|
2915
2013
|
vue.createTextVNode(vue.toDisplayString(_ctx.item.text), 1),
|
|
2916
2014
|
vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2917
2015
|
default: vue.withCtx(() => [
|
|
@@ -2923,11 +2021,11 @@
|
|
|
2923
2021
|
]),
|
|
2924
2022
|
_: 1
|
|
2925
2023
|
}, 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)
|
|
2926
|
-
])) : vue.createCommentVNode("", true);
|
|
2024
|
+
], 34)) : vue.createCommentVNode("", true);
|
|
2927
2025
|
}
|
|
2928
|
-
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2026
|
+
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
|
|
2929
2027
|
|
|
2930
|
-
const _sfc_main$
|
|
2028
|
+
const _sfc_main$d = vue.defineComponent({
|
|
2931
2029
|
name: "nav-menu",
|
|
2932
2030
|
components: { ToolButton },
|
|
2933
2031
|
props: {
|
|
@@ -2947,7 +2045,7 @@
|
|
|
2947
2045
|
};
|
|
2948
2046
|
}
|
|
2949
2047
|
});
|
|
2950
|
-
function _sfc_render$
|
|
2048
|
+
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2951
2049
|
const _component_tool_button = vue.resolveComponent("tool-button");
|
|
2952
2050
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
2953
2051
|
class: "m-editor-nav-menu",
|
|
@@ -2969,9 +2067,9 @@
|
|
|
2969
2067
|
}), 128))
|
|
2970
2068
|
], 4);
|
|
2971
2069
|
}
|
|
2972
|
-
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2070
|
+
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
|
|
2973
2071
|
|
|
2974
|
-
const _sfc_main$
|
|
2072
|
+
const _sfc_main$c = vue.defineComponent({
|
|
2975
2073
|
name: "m-editor-props-panel",
|
|
2976
2074
|
emits: ["mounted"],
|
|
2977
2075
|
setup(props, { emit }) {
|
|
@@ -2986,9 +2084,9 @@
|
|
|
2986
2084
|
curFormConfig.value = [];
|
|
2987
2085
|
return;
|
|
2988
2086
|
}
|
|
2989
|
-
values.value = node.value;
|
|
2990
2087
|
const type = node.value.type || (node.value.items ? "container" : "text");
|
|
2991
2088
|
curFormConfig.value = await services?.propsService.getPropsConfig(type) || [];
|
|
2089
|
+
values.value = node.value;
|
|
2992
2090
|
};
|
|
2993
2091
|
vue.watchEffect(init);
|
|
2994
2092
|
services?.propsService.on("props-configs-change", init);
|
|
@@ -2999,6 +2097,7 @@
|
|
|
2999
2097
|
values,
|
|
3000
2098
|
configForm,
|
|
3001
2099
|
curFormConfig,
|
|
2100
|
+
propsPanelSize: vue.computed(() => services?.uiService.get("propsPanelSize") || "small"),
|
|
3002
2101
|
async submit() {
|
|
3003
2102
|
try {
|
|
3004
2103
|
const values2 = await configForm.value?.submitForm();
|
|
@@ -3017,21 +2116,21 @@
|
|
|
3017
2116
|
};
|
|
3018
2117
|
}
|
|
3019
2118
|
});
|
|
3020
|
-
function _sfc_render$
|
|
2119
|
+
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3021
2120
|
const _component_m_form = vue.resolveComponent("m-form");
|
|
3022
2121
|
return vue.openBlock(), vue.createBlock(_component_m_form, {
|
|
3023
|
-
class:
|
|
3024
|
-
"popper-class":
|
|
2122
|
+
class: vue.normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
|
|
2123
|
+
"popper-class": `m-editor-props-panel-popper ${_ctx.propsPanelSize}`,
|
|
3025
2124
|
ref: "configForm",
|
|
3026
|
-
size:
|
|
2125
|
+
size: _ctx.propsPanelSize,
|
|
3027
2126
|
"init-values": _ctx.values,
|
|
3028
2127
|
config: _ctx.curFormConfig,
|
|
3029
2128
|
onChange: _ctx.submit
|
|
3030
|
-
}, null, 8, ["init-values", "config", "onChange"]);
|
|
2129
|
+
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"]);
|
|
3031
2130
|
}
|
|
3032
|
-
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2131
|
+
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
|
|
3033
2132
|
|
|
3034
|
-
const _sfc_main$
|
|
2133
|
+
const _sfc_main$b = vue.defineComponent({
|
|
3035
2134
|
name: "ui-component-panel",
|
|
3036
2135
|
components: { MIcon },
|
|
3037
2136
|
setup() {
|
|
@@ -3046,19 +2145,29 @@
|
|
|
3046
2145
|
searchText,
|
|
3047
2146
|
collapseValue,
|
|
3048
2147
|
list,
|
|
3049
|
-
appendComponent({ text, type,
|
|
2148
|
+
appendComponent({ text, type, data = {} }) {
|
|
3050
2149
|
services?.editorService.add({
|
|
3051
2150
|
name: text,
|
|
3052
2151
|
type,
|
|
3053
|
-
...
|
|
2152
|
+
...data
|
|
3054
2153
|
});
|
|
2154
|
+
},
|
|
2155
|
+
dragstartHandler({ text, type, data = {} }, e) {
|
|
2156
|
+
if (e.dataTransfer) {
|
|
2157
|
+
e.dataTransfer.effectAllowed = "move";
|
|
2158
|
+
e.dataTransfer.setData("data", serialize__default["default"]({
|
|
2159
|
+
name: text,
|
|
2160
|
+
type,
|
|
2161
|
+
...data
|
|
2162
|
+
}).replace(/"(\w+)":\s/g, "$1: "));
|
|
2163
|
+
}
|
|
3055
2164
|
}
|
|
3056
2165
|
};
|
|
3057
2166
|
}
|
|
3058
2167
|
});
|
|
3059
|
-
const _hoisted_1$
|
|
3060
|
-
const _hoisted_2$
|
|
3061
|
-
function _sfc_render$
|
|
2168
|
+
const _hoisted_1$5 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
2169
|
+
const _hoisted_2$1 = ["onClick", "onDragstart"];
|
|
2170
|
+
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3062
2171
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
3063
2172
|
const _component_m_icon = vue.resolveComponent("m-icon");
|
|
3064
2173
|
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
@@ -3088,15 +2197,17 @@
|
|
|
3088
2197
|
name: index
|
|
3089
2198
|
}, {
|
|
3090
2199
|
title: vue.withCtx(() => [
|
|
3091
|
-
_hoisted_1$
|
|
2200
|
+
_hoisted_1$5,
|
|
3092
2201
|
vue.createTextVNode(vue.toDisplayString(group.title), 1)
|
|
3093
2202
|
]),
|
|
3094
2203
|
default: vue.withCtx(() => [
|
|
3095
2204
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(group.items, (item) => {
|
|
3096
2205
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
3097
2206
|
class: "component-item",
|
|
2207
|
+
draggable: "true",
|
|
3098
2208
|
key: item.type,
|
|
3099
|
-
onClick: ($event) => _ctx.appendComponent(item)
|
|
2209
|
+
onClick: ($event) => _ctx.appendComponent(item),
|
|
2210
|
+
onDragstart: ($event) => _ctx.dragstartHandler(item, $event)
|
|
3100
2211
|
}, [
|
|
3101
2212
|
vue.createVNode(_component_m_icon, {
|
|
3102
2213
|
icon: item.icon
|
|
@@ -3111,7 +2222,7 @@
|
|
|
3111
2222
|
]),
|
|
3112
2223
|
_: 2
|
|
3113
2224
|
}, 1032, ["content"])
|
|
3114
|
-
],
|
|
2225
|
+
], 40, _hoisted_2$1);
|
|
3115
2226
|
}), 128))
|
|
3116
2227
|
]),
|
|
3117
2228
|
_: 2
|
|
@@ -3125,135 +2236,220 @@
|
|
|
3125
2236
|
_: 1
|
|
3126
2237
|
});
|
|
3127
2238
|
}
|
|
3128
|
-
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2239
|
+
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
|
|
3129
2240
|
|
|
3130
|
-
const _sfc_main$
|
|
3131
|
-
|
|
2241
|
+
const _sfc_main$a = vue.defineComponent({
|
|
2242
|
+
components: { ToolButton },
|
|
3132
2243
|
props: {
|
|
3133
|
-
|
|
2244
|
+
menuData: {
|
|
3134
2245
|
type: Array,
|
|
3135
2246
|
default: () => []
|
|
3136
2247
|
}
|
|
3137
2248
|
},
|
|
3138
|
-
setup(
|
|
3139
|
-
const
|
|
3140
|
-
const
|
|
3141
|
-
const
|
|
2249
|
+
setup() {
|
|
2250
|
+
const menu = vue.ref();
|
|
2251
|
+
const subMenu = vue.ref();
|
|
2252
|
+
const visible = vue.ref(false);
|
|
2253
|
+
const subMenuData = vue.ref([]);
|
|
2254
|
+
const menuStyle = vue.ref({
|
|
2255
|
+
left: "0",
|
|
2256
|
+
top: "0"
|
|
2257
|
+
});
|
|
2258
|
+
const hide = () => {
|
|
2259
|
+
visible.value = false;
|
|
2260
|
+
};
|
|
2261
|
+
vue.onMounted(() => {
|
|
2262
|
+
globalThis.addEventListener("mousedown", (e) => {
|
|
2263
|
+
if (!visible.value || e.target && menu.value?.contains(e.target)) {
|
|
2264
|
+
return;
|
|
2265
|
+
}
|
|
2266
|
+
hide();
|
|
2267
|
+
}, true);
|
|
2268
|
+
});
|
|
3142
2269
|
return {
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
2270
|
+
menu,
|
|
2271
|
+
subMenu,
|
|
2272
|
+
visible,
|
|
2273
|
+
menuStyle,
|
|
2274
|
+
subMenuData,
|
|
2275
|
+
hide,
|
|
2276
|
+
show(e) {
|
|
2277
|
+
visible.value = true;
|
|
2278
|
+
vue.nextTick(() => {
|
|
2279
|
+
const menuHeight = menu.value?.clientHeight || 0;
|
|
2280
|
+
let top = e.clientY;
|
|
2281
|
+
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
2282
|
+
top = document.body.clientHeight - menuHeight;
|
|
3150
2283
|
}
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
services?.editorService.add({
|
|
3156
|
-
name: config.text,
|
|
3157
|
-
type: config.type
|
|
2284
|
+
menuStyle.value = {
|
|
2285
|
+
top: `${top}px`,
|
|
2286
|
+
left: `${e.clientX}px`
|
|
2287
|
+
};
|
|
3158
2288
|
});
|
|
3159
2289
|
},
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
2290
|
+
showSubMenu(item) {
|
|
2291
|
+
const menuItem = item;
|
|
2292
|
+
if (typeof item !== "object" || !menuItem.items?.length) {
|
|
2293
|
+
return;
|
|
2294
|
+
}
|
|
2295
|
+
subMenuData.value = menuItem.items;
|
|
2296
|
+
if (menu.value) {
|
|
2297
|
+
subMenu.value.show({
|
|
2298
|
+
clientX: menu.value.offsetLeft + menu.value.clientWidth,
|
|
2299
|
+
clientY: menu.value.offsetTop
|
|
2300
|
+
});
|
|
2301
|
+
}
|
|
3168
2302
|
}
|
|
3169
2303
|
};
|
|
3170
2304
|
}
|
|
3171
2305
|
});
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
2306
|
+
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2307
|
+
const _component_tool_button = vue.resolveComponent("tool-button");
|
|
2308
|
+
const _component_content_menu = vue.resolveComponent("content-menu", true);
|
|
2309
|
+
return _ctx.menuData.length ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
|
|
2310
|
+
key: 0,
|
|
2311
|
+
class: "magic-editor-content-menu",
|
|
2312
|
+
ref: "menu",
|
|
2313
|
+
style: vue.normalizeStyle(_ctx.menuStyle)
|
|
2314
|
+
}, [
|
|
2315
|
+
vue.createElementVNode("div", null, [
|
|
2316
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.menuData, (item, index) => {
|
|
2317
|
+
return vue.openBlock(), vue.createBlock(_component_tool_button, {
|
|
2318
|
+
"event-type": "mouseup",
|
|
2319
|
+
data: item,
|
|
2320
|
+
key: index,
|
|
2321
|
+
onMouseup: _ctx.hide,
|
|
2322
|
+
onMouseenter: ($event) => _ctx.showSubMenu(item)
|
|
2323
|
+
}, null, 8, ["data", "onMouseup", "onMouseenter"]);
|
|
2324
|
+
}), 128))
|
|
2325
|
+
]),
|
|
2326
|
+
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
2327
|
+
vue.createVNode(_component_content_menu, {
|
|
2328
|
+
class: "sub-menu",
|
|
2329
|
+
ref: "subMenu",
|
|
2330
|
+
"menu-data": _ctx.subMenuData
|
|
2331
|
+
}, null, 8, ["menu-data"])
|
|
2332
|
+
]))
|
|
2333
|
+
], 4)), [
|
|
2334
|
+
[vue.vShow, _ctx.visible]
|
|
2335
|
+
]) : vue.createCommentVNode("", true);
|
|
2336
|
+
}
|
|
2337
|
+
var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
|
|
2338
|
+
|
|
2339
|
+
const _sfc_main$9 = vue.defineComponent({
|
|
2340
|
+
components: { ContentMenu },
|
|
2341
|
+
setup() {
|
|
2342
|
+
const services = vue.inject("services");
|
|
2343
|
+
const menu = vue.ref();
|
|
2344
|
+
const node = vue.computed(() => services?.editorService.get("node"));
|
|
2345
|
+
const isRoot = vue.computed(() => node.value?.type === schema.NodeType.ROOT);
|
|
2346
|
+
const isPage = vue.computed(() => node.value?.type === schema.NodeType.PAGE);
|
|
2347
|
+
const componentList = vue.computed(() => services?.componentListService.getList() || []);
|
|
2348
|
+
const createMenuItems = (group) => group.items.map((component) => ({
|
|
2349
|
+
text: component.text,
|
|
2350
|
+
type: "button",
|
|
2351
|
+
icon: component.icon,
|
|
2352
|
+
handler: () => {
|
|
2353
|
+
services?.editorService.add({
|
|
2354
|
+
name: component.text,
|
|
2355
|
+
type: component.type,
|
|
2356
|
+
...component.data || {}
|
|
2357
|
+
});
|
|
2358
|
+
}
|
|
2359
|
+
}));
|
|
2360
|
+
const getSubMenuData = vue.computed(() => {
|
|
2361
|
+
if (node.value?.type === "tabs") {
|
|
2362
|
+
return [
|
|
2363
|
+
{
|
|
2364
|
+
text: "\u6807\u7B7E\u9875",
|
|
2365
|
+
type: "button",
|
|
2366
|
+
icon: icons.Files,
|
|
2367
|
+
handler: () => {
|
|
2368
|
+
services?.editorService.add({
|
|
2369
|
+
type: "tab-pane"
|
|
2370
|
+
});
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
];
|
|
2374
|
+
}
|
|
2375
|
+
if (node.value?.items) {
|
|
2376
|
+
return componentList.value.reduce((subMenuData, group, index) => subMenuData.concat(createMenuItems(group), index < componentList.value.length - 1 ? [
|
|
2377
|
+
{
|
|
2378
|
+
type: "divider",
|
|
2379
|
+
direction: "horizontal"
|
|
2380
|
+
}
|
|
2381
|
+
] : []), []) || [];
|
|
2382
|
+
}
|
|
2383
|
+
return [];
|
|
2384
|
+
});
|
|
2385
|
+
return {
|
|
2386
|
+
menu,
|
|
2387
|
+
menuData: vue.computed(() => [
|
|
2388
|
+
{
|
|
2389
|
+
type: "button",
|
|
2390
|
+
text: "\u65B0\u589E",
|
|
2391
|
+
icon: vue.markRaw(icons.Plus),
|
|
2392
|
+
display: () => node.value?.items,
|
|
2393
|
+
items: getSubMenuData.value
|
|
2394
|
+
},
|
|
2395
|
+
{
|
|
2396
|
+
type: "button",
|
|
2397
|
+
text: "\u590D\u5236",
|
|
2398
|
+
icon: vue.markRaw(icons.DocumentCopy),
|
|
2399
|
+
display: () => !isRoot.value,
|
|
2400
|
+
handler: () => {
|
|
2401
|
+
node.value && services?.editorService.copy(node.value);
|
|
2402
|
+
}
|
|
2403
|
+
},
|
|
2404
|
+
{
|
|
2405
|
+
type: "button",
|
|
2406
|
+
text: "\u5220\u9664",
|
|
2407
|
+
icon: vue.markRaw(icons.Delete),
|
|
2408
|
+
display: () => !isRoot.value && !isPage.value,
|
|
2409
|
+
handler: () => {
|
|
2410
|
+
node.value && services?.editorService.remove(node.value);
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
]),
|
|
2414
|
+
show(e) {
|
|
2415
|
+
menu.value?.show(e);
|
|
2416
|
+
}
|
|
2417
|
+
};
|
|
2418
|
+
}
|
|
2419
|
+
});
|
|
2420
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2421
|
+
const _component_content_menu = vue.resolveComponent("content-menu");
|
|
2422
|
+
return vue.openBlock(), vue.createBlock(_component_content_menu, {
|
|
2423
|
+
"menu-data": _ctx.menuData,
|
|
2424
|
+
ref: "menu",
|
|
2425
|
+
style: { "overflow": "initial" }
|
|
2426
|
+
}, null, 8, ["menu-data"]);
|
|
3240
2427
|
}
|
|
3241
|
-
var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2428
|
+
var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
|
|
3242
2429
|
|
|
3243
|
-
const
|
|
2430
|
+
const throttleTime = 150;
|
|
2431
|
+
const select = async (data, editorService) => {
|
|
3244
2432
|
if (!data.id) {
|
|
3245
2433
|
throw new Error("\u6CA1\u6709id");
|
|
3246
2434
|
}
|
|
3247
|
-
editorService?.select(data);
|
|
2435
|
+
await editorService?.select(data);
|
|
2436
|
+
editorService?.get("stage")?.select(data.id);
|
|
2437
|
+
};
|
|
2438
|
+
const highlight = (data, editorService) => {
|
|
2439
|
+
if (!data?.id) {
|
|
2440
|
+
throw new Error("\u6CA1\u6709id");
|
|
2441
|
+
}
|
|
2442
|
+
editorService?.highlight(data);
|
|
2443
|
+
editorService?.get("stage")?.highlight(data.id);
|
|
3248
2444
|
};
|
|
3249
2445
|
const useDrop = (tree, editorService) => ({
|
|
3250
2446
|
allowDrop: (draggingNode, dropNode, type) => {
|
|
3251
2447
|
const { data } = dropNode || {};
|
|
3252
2448
|
const { data: ingData } = draggingNode;
|
|
3253
2449
|
const { type: ingType } = ingData;
|
|
3254
|
-
if (ingType !==
|
|
2450
|
+
if (ingType !== schema.NodeType.PAGE && data.type === schema.NodeType.PAGE)
|
|
3255
2451
|
return false;
|
|
3256
|
-
if (ingType ===
|
|
2452
|
+
if (ingType === schema.NodeType.PAGE && data.type !== schema.NodeType.PAGE)
|
|
3257
2453
|
return false;
|
|
3258
2454
|
if (!data || !data.type)
|
|
3259
2455
|
return false;
|
|
@@ -3272,29 +2468,35 @@
|
|
|
3272
2468
|
}
|
|
3273
2469
|
});
|
|
3274
2470
|
const useStatus = (tree, editorService) => {
|
|
2471
|
+
const highlightNode = vue.ref();
|
|
2472
|
+
const node = vue.ref();
|
|
3275
2473
|
const page = vue.computed(() => editorService?.get("page"));
|
|
3276
2474
|
vue.watchEffect(() => {
|
|
3277
2475
|
if (!tree.value)
|
|
3278
2476
|
return;
|
|
3279
|
-
|
|
3280
|
-
node && tree.value.setCurrentKey(node.id, true);
|
|
2477
|
+
node.value = editorService?.get("node");
|
|
2478
|
+
node.value && tree.value.setCurrentKey(node.value.id, true);
|
|
3281
2479
|
const parent = editorService?.get("parent");
|
|
3282
2480
|
if (!parent?.id)
|
|
3283
2481
|
return;
|
|
3284
2482
|
const treeNode = tree.value.getNode(parent.id);
|
|
3285
2483
|
treeNode?.updateChildren();
|
|
2484
|
+
highlightNode.value = editorService?.get("highlightNode");
|
|
3286
2485
|
});
|
|
3287
2486
|
return {
|
|
3288
2487
|
values: vue.computed(() => page.value ? [page.value] : []),
|
|
3289
|
-
loadItems: (
|
|
3290
|
-
if (Array.isArray(
|
|
3291
|
-
return resolve(
|
|
2488
|
+
loadItems: (node2, resolve) => {
|
|
2489
|
+
if (Array.isArray(node2.data)) {
|
|
2490
|
+
return resolve(node2.data);
|
|
3292
2491
|
}
|
|
3293
|
-
if (Array.isArray(
|
|
3294
|
-
return resolve(
|
|
2492
|
+
if (Array.isArray(node2.data?.items)) {
|
|
2493
|
+
return resolve(node2.data?.items);
|
|
3295
2494
|
}
|
|
3296
2495
|
resolve([]);
|
|
3297
|
-
}
|
|
2496
|
+
},
|
|
2497
|
+
highlightNode,
|
|
2498
|
+
clickNode: node,
|
|
2499
|
+
expandedKeys: vue.computed(() => node.value ? [node.value.id] : [])
|
|
3298
2500
|
};
|
|
3299
2501
|
};
|
|
3300
2502
|
const useFilter = (tree) => ({
|
|
@@ -3306,69 +2508,64 @@
|
|
|
3306
2508
|
let name = "";
|
|
3307
2509
|
if (data.name) {
|
|
3308
2510
|
name = data.name;
|
|
3309
|
-
} else if (data.type) {
|
|
3310
|
-
name = data.type;
|
|
3311
2511
|
} else if (data.items) {
|
|
3312
2512
|
name = "container";
|
|
3313
2513
|
}
|
|
3314
|
-
return name.indexOf(value) !== -1;
|
|
2514
|
+
return `${data.id}${name}${data.type}`.indexOf(value) !== -1;
|
|
3315
2515
|
},
|
|
3316
2516
|
filterTextChangeHandler(val) {
|
|
3317
2517
|
tree.value?.filter(val);
|
|
3318
2518
|
}
|
|
3319
2519
|
});
|
|
3320
|
-
const
|
|
3321
|
-
const menuStyle = vue.ref({
|
|
3322
|
-
position: "absolute",
|
|
3323
|
-
left: "0",
|
|
3324
|
-
top: "0",
|
|
3325
|
-
display: "none"
|
|
3326
|
-
});
|
|
3327
|
-
vue.onMounted(() => {
|
|
3328
|
-
document.addEventListener("click", () => {
|
|
3329
|
-
menuStyle.value.display = "none";
|
|
3330
|
-
}, true);
|
|
3331
|
-
});
|
|
3332
|
-
return {
|
|
3333
|
-
menuStyle,
|
|
3334
|
-
contextmenu(event, data) {
|
|
3335
|
-
const bodyHeight = globalThis.document.body.clientHeight;
|
|
3336
|
-
const left = `${event.clientX + 20}px`;
|
|
3337
|
-
let top = `${event.clientY - 10}px`;
|
|
3338
|
-
if (event.clientY + 300 > bodyHeight) {
|
|
3339
|
-
top = `${bodyHeight - 300}px`;
|
|
3340
|
-
}
|
|
3341
|
-
menuStyle.value.left = left;
|
|
3342
|
-
menuStyle.value.top = top;
|
|
3343
|
-
menuStyle.value.display = "";
|
|
3344
|
-
select(data, editorService);
|
|
3345
|
-
}
|
|
3346
|
-
};
|
|
3347
|
-
};
|
|
3348
|
-
const _sfc_main$7 = vue.defineComponent({
|
|
2520
|
+
const _sfc_main$8 = vue.defineComponent({
|
|
3349
2521
|
name: "magic-editor-layer-panel",
|
|
3350
2522
|
components: { LayerMenu },
|
|
3351
2523
|
setup() {
|
|
3352
2524
|
const services = vue.inject("services");
|
|
3353
2525
|
const tree = vue.ref();
|
|
2526
|
+
const menu = vue.ref();
|
|
2527
|
+
const clicked = vue.ref(false);
|
|
3354
2528
|
const editorService = services?.editorService;
|
|
2529
|
+
const highlightHandler = lodashEs.throttle((data) => {
|
|
2530
|
+
highlight(data, editorService);
|
|
2531
|
+
}, throttleTime);
|
|
2532
|
+
const toggleClickFlag = () => {
|
|
2533
|
+
clicked.value = !clicked.value;
|
|
2534
|
+
};
|
|
2535
|
+
const statusData = useStatus(tree, editorService);
|
|
2536
|
+
const canHighlight = vue.computed(() => statusData.highlightNode.value?.id !== statusData.clickNode.value?.id && !clicked.value);
|
|
2537
|
+
editorService?.on("remove", () => {
|
|
2538
|
+
setTimeout(() => {
|
|
2539
|
+
tree.value?.getNode(editorService.get("node").id)?.updateChildren();
|
|
2540
|
+
}, 0);
|
|
2541
|
+
});
|
|
3355
2542
|
return {
|
|
3356
2543
|
tree,
|
|
2544
|
+
menu,
|
|
2545
|
+
...statusData,
|
|
3357
2546
|
...useDrop(tree, editorService),
|
|
3358
|
-
...useStatus(tree, editorService),
|
|
3359
2547
|
...useFilter(tree),
|
|
3360
|
-
|
|
2548
|
+
highlightHandler,
|
|
2549
|
+
toggleClickFlag,
|
|
2550
|
+
canHighlight,
|
|
3361
2551
|
clickHandler(data) {
|
|
3362
2552
|
if (services?.uiService.get("uiSelectMode")) {
|
|
3363
2553
|
document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
|
|
3364
2554
|
return;
|
|
3365
2555
|
}
|
|
2556
|
+
tree.value?.setCurrentKey(data.id);
|
|
3366
2557
|
select(data, editorService);
|
|
2558
|
+
},
|
|
2559
|
+
async contextmenu(event, data) {
|
|
2560
|
+
event.preventDefault();
|
|
2561
|
+
await select(data, editorService);
|
|
2562
|
+
menu.value?.show(event);
|
|
3367
2563
|
}
|
|
3368
2564
|
};
|
|
3369
2565
|
}
|
|
3370
2566
|
});
|
|
3371
|
-
|
|
2567
|
+
const _hoisted_1$4 = ["id", "onMouseenter"];
|
|
2568
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3372
2569
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
3373
2570
|
const _component_el_tree = vue.resolveComponent("el-tree");
|
|
3374
2571
|
const _component_layer_menu = vue.resolveComponent("layer-menu");
|
|
@@ -3389,6 +2586,7 @@
|
|
|
3389
2586
|
ref: "tree",
|
|
3390
2587
|
"node-key": "id",
|
|
3391
2588
|
draggable: "",
|
|
2589
|
+
"default-expanded-keys": _ctx.expandedKeys,
|
|
3392
2590
|
load: _ctx.loadItems,
|
|
3393
2591
|
data: _ctx.values,
|
|
3394
2592
|
"expand-on-click-node": false,
|
|
@@ -3404,47 +2602,46 @@
|
|
|
3404
2602
|
"empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684"
|
|
3405
2603
|
}, {
|
|
3406
2604
|
default: vue.withCtx(({ node, data }) => [
|
|
3407
|
-
vue.
|
|
3408
|
-
|
|
3409
|
-
data
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
2605
|
+
vue.createElementVNode("div", {
|
|
2606
|
+
id: data.id,
|
|
2607
|
+
class: vue.normalizeClass(["cus-tree-node", { "cus-tree-node-hover": _ctx.canHighlight && data.id === _ctx.highlightNode?.id }]),
|
|
2608
|
+
onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
|
|
2609
|
+
onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
|
|
2610
|
+
onMouseenter: ($event) => _ctx.highlightHandler(data)
|
|
2611
|
+
}, [
|
|
2612
|
+
vue.renderSlot(_ctx.$slots, "layer-node-content", {
|
|
2613
|
+
node,
|
|
2614
|
+
data
|
|
2615
|
+
}, () => [
|
|
2616
|
+
vue.createElementVNode("span", null, vue.toDisplayString(`${data.name} (${data.id})`), 1)
|
|
2617
|
+
])
|
|
2618
|
+
], 42, _hoisted_1$4)
|
|
3413
2619
|
]),
|
|
3414
2620
|
_: 3
|
|
3415
|
-
}, 8, ["load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : vue.createCommentVNode("", true),
|
|
2621
|
+
}, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : vue.createCommentVNode("", true),
|
|
3416
2622
|
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
3417
|
-
vue.createVNode(_component_layer_menu, {
|
|
3418
|
-
style: vue.normalizeStyle(_ctx.menuStyle)
|
|
3419
|
-
}, null, 8, ["style"])
|
|
2623
|
+
vue.createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
|
|
3420
2624
|
]))
|
|
3421
2625
|
]),
|
|
3422
2626
|
_: 3
|
|
3423
2627
|
});
|
|
3424
2628
|
}
|
|
3425
|
-
var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2629
|
+
var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
|
|
3426
2630
|
|
|
3427
|
-
const _sfc_main$
|
|
3428
|
-
name: "m-sidebar",
|
|
2631
|
+
const _sfc_main$7 = vue.defineComponent({
|
|
3429
2632
|
components: { MIcon },
|
|
3430
2633
|
props: {
|
|
3431
2634
|
data: {
|
|
3432
|
-
type: Object
|
|
3433
|
-
default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer"] })
|
|
2635
|
+
type: Object
|
|
3434
2636
|
}
|
|
3435
2637
|
},
|
|
3436
2638
|
setup(props) {
|
|
3437
|
-
const activeTabName = vue.ref(props.data?.status);
|
|
3438
|
-
vue.watch(() => props.data?.status, (status) => {
|
|
3439
|
-
activeTabName.value = status || "0";
|
|
3440
|
-
});
|
|
3441
2639
|
return {
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
return item;
|
|
2640
|
+
config: vue.computed(() => {
|
|
2641
|
+
if (typeof props.data !== "string") {
|
|
2642
|
+
return props.data;
|
|
3446
2643
|
}
|
|
3447
|
-
switch (
|
|
2644
|
+
switch (props.data) {
|
|
3448
2645
|
case "component-list":
|
|
3449
2646
|
return {
|
|
3450
2647
|
type: "component",
|
|
@@ -3462,21 +2659,75 @@
|
|
|
3462
2659
|
slots: {}
|
|
3463
2660
|
};
|
|
3464
2661
|
default:
|
|
3465
|
-
return
|
|
2662
|
+
return void 0;
|
|
3466
2663
|
}
|
|
3467
|
-
})
|
|
2664
|
+
})
|
|
2665
|
+
};
|
|
2666
|
+
}
|
|
2667
|
+
});
|
|
2668
|
+
const _hoisted_1$3 = {
|
|
2669
|
+
key: 1,
|
|
2670
|
+
class: "magic-editor-tab-panel-title"
|
|
2671
|
+
};
|
|
2672
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2673
|
+
const _component_m_icon = vue.resolveComponent("m-icon");
|
|
2674
|
+
const _component_el_tab_pane = vue.resolveComponent("el-tab-pane");
|
|
2675
|
+
return _ctx.config ? (vue.openBlock(), vue.createBlock(_component_el_tab_pane, {
|
|
2676
|
+
key: 0,
|
|
2677
|
+
name: _ctx.config.text
|
|
2678
|
+
}, {
|
|
2679
|
+
label: vue.withCtx(() => [
|
|
2680
|
+
(vue.openBlock(), vue.createElementBlock("div", {
|
|
2681
|
+
key: _ctx.config.text
|
|
2682
|
+
}, [
|
|
2683
|
+
_ctx.config.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
|
|
2684
|
+
key: 0,
|
|
2685
|
+
icon: _ctx.config.icon
|
|
2686
|
+
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
2687
|
+
_ctx.config.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, vue.toDisplayString(_ctx.config.text), 1)) : vue.createCommentVNode("", true)
|
|
2688
|
+
]))
|
|
2689
|
+
]),
|
|
2690
|
+
default: vue.withCtx(() => [
|
|
2691
|
+
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.component), vue.mergeProps(_ctx.config.props || {}, vue.toHandlers(_ctx.config?.listeners || {})), vue.createSlots({ _: 2 }, [
|
|
2692
|
+
_ctx.config.slots?.layerNodeContent ? {
|
|
2693
|
+
name: "layer-node-content",
|
|
2694
|
+
fn: vue.withCtx(({ data, node }) => [
|
|
2695
|
+
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.slots?.layerNodeContent), {
|
|
2696
|
+
data,
|
|
2697
|
+
node
|
|
2698
|
+
}, null, 8, ["data", "node"]))
|
|
2699
|
+
])
|
|
2700
|
+
} : void 0
|
|
2701
|
+
]), 1040))
|
|
2702
|
+
]),
|
|
2703
|
+
_: 1
|
|
2704
|
+
}, 8, ["name"])) : vue.createCommentVNode("", true);
|
|
2705
|
+
}
|
|
2706
|
+
var TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7]]);
|
|
2707
|
+
|
|
2708
|
+
const _sfc_main$6 = vue.defineComponent({
|
|
2709
|
+
components: { TabPane },
|
|
2710
|
+
name: "m-sidebar",
|
|
2711
|
+
props: {
|
|
2712
|
+
data: {
|
|
2713
|
+
type: Object,
|
|
2714
|
+
default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer"] })
|
|
2715
|
+
}
|
|
2716
|
+
},
|
|
2717
|
+
setup(props) {
|
|
2718
|
+
const activeTabName = vue.ref(props.data?.status);
|
|
2719
|
+
vue.watch(() => props.data?.status, (status) => {
|
|
2720
|
+
activeTabName.value = status || "0";
|
|
2721
|
+
});
|
|
2722
|
+
return {
|
|
2723
|
+
activeTabName
|
|
3468
2724
|
};
|
|
3469
2725
|
}
|
|
3470
2726
|
});
|
|
3471
|
-
const _hoisted_1$4 = {
|
|
3472
|
-
key: 1,
|
|
3473
|
-
class: "magic-editor-tab-panel-title"
|
|
3474
|
-
};
|
|
3475
2727
|
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3476
|
-
const
|
|
3477
|
-
const _component_el_tab_pane = vue.resolveComponent("el-tab-pane");
|
|
2728
|
+
const _component_tab_pane = vue.resolveComponent("tab-pane");
|
|
3478
2729
|
const _component_el_tabs = vue.resolveComponent("el-tabs");
|
|
3479
|
-
return _ctx.data.type === "tabs" ? (vue.openBlock(), vue.createBlock(_component_el_tabs, {
|
|
2730
|
+
return _ctx.data.type === "tabs" && _ctx.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_tabs, {
|
|
3480
2731
|
key: 0,
|
|
3481
2732
|
class: "m-editor-sidebar",
|
|
3482
2733
|
modelValue: _ctx.activeTabName,
|
|
@@ -3485,35 +2736,11 @@
|
|
|
3485
2736
|
"tab-position": "left"
|
|
3486
2737
|
}, {
|
|
3487
2738
|
default: vue.withCtx(() => [
|
|
3488
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.items, (item) => {
|
|
3489
|
-
return vue.openBlock(), vue.createBlock(
|
|
3490
|
-
key:
|
|
3491
|
-
|
|
3492
|
-
},
|
|
3493
|
-
label: vue.withCtx(() => [
|
|
3494
|
-
vue.createElementVNode("span", null, [
|
|
3495
|
-
item.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
|
|
3496
|
-
key: 0,
|
|
3497
|
-
icon: item.icon
|
|
3498
|
-
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
3499
|
-
item.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, vue.toDisplayString(item.text), 1)) : vue.createCommentVNode("", true)
|
|
3500
|
-
])
|
|
3501
|
-
]),
|
|
3502
|
-
default: vue.withCtx(() => [
|
|
3503
|
-
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(item.component), vue.mergeProps(item.props || {}, vue.toHandlers(item.listeners || {})), vue.createSlots({ _: 2 }, [
|
|
3504
|
-
item.slots?.layerNodeContent ? {
|
|
3505
|
-
name: "layer-node-content",
|
|
3506
|
-
fn: vue.withCtx(({ data, node }) => [
|
|
3507
|
-
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(item.slots.layerNodeContent), {
|
|
3508
|
-
data,
|
|
3509
|
-
node
|
|
3510
|
-
}, null, 8, ["data", "node"]))
|
|
3511
|
-
])
|
|
3512
|
-
} : void 0
|
|
3513
|
-
]), 1040))
|
|
3514
|
-
]),
|
|
3515
|
-
_: 2
|
|
3516
|
-
}, 1032, ["name"]);
|
|
2739
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.data.items, (item, index) => {
|
|
2740
|
+
return vue.openBlock(), vue.createBlock(_component_tab_pane, {
|
|
2741
|
+
key: index,
|
|
2742
|
+
data: item
|
|
2743
|
+
}, null, 8, ["data"]);
|
|
3517
2744
|
}), 128))
|
|
3518
2745
|
]),
|
|
3519
2746
|
_: 1
|
|
@@ -3521,13 +2748,81 @@
|
|
|
3521
2748
|
}
|
|
3522
2749
|
var Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6]]);
|
|
3523
2750
|
|
|
2751
|
+
const useScroll = (root) => {
|
|
2752
|
+
const pageBar = vue.ref();
|
|
2753
|
+
const itemsContainer = vue.ref();
|
|
2754
|
+
const pageBarWidth = vue.ref(0);
|
|
2755
|
+
const canScroll = vue.ref(false);
|
|
2756
|
+
const itemsContainerWidth = vue.computed(() => pageBarWidth.value - 105);
|
|
2757
|
+
let translateLeft = 0;
|
|
2758
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
2759
|
+
for (const { contentRect } of entries) {
|
|
2760
|
+
const { width } = contentRect;
|
|
2761
|
+
pageBarWidth.value = width || 0;
|
|
2762
|
+
setCanScroll();
|
|
2763
|
+
}
|
|
2764
|
+
});
|
|
2765
|
+
const setCanScroll = () => {
|
|
2766
|
+
if (itemsContainer.value) {
|
|
2767
|
+
canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
|
|
2768
|
+
}
|
|
2769
|
+
};
|
|
2770
|
+
const scroll = (type) => {
|
|
2771
|
+
if (!itemsContainer.value)
|
|
2772
|
+
return;
|
|
2773
|
+
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
2774
|
+
if (type === "left") {
|
|
2775
|
+
translateLeft += 100;
|
|
2776
|
+
if (translateLeft > 0) {
|
|
2777
|
+
translateLeft = 0;
|
|
2778
|
+
}
|
|
2779
|
+
} else if (type === "right") {
|
|
2780
|
+
translateLeft -= 100;
|
|
2781
|
+
if (-translateLeft > maxScrollLeft) {
|
|
2782
|
+
translateLeft = -maxScrollLeft;
|
|
2783
|
+
}
|
|
2784
|
+
} else if (type === "start") {
|
|
2785
|
+
translateLeft = 0;
|
|
2786
|
+
} else if (type === "end") {
|
|
2787
|
+
translateLeft = -maxScrollLeft;
|
|
2788
|
+
}
|
|
2789
|
+
itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
|
|
2790
|
+
};
|
|
2791
|
+
vue.onMounted(() => {
|
|
2792
|
+
pageBar.value && resizeObserver.observe(pageBar.value);
|
|
2793
|
+
});
|
|
2794
|
+
vue.onUnmounted(() => {
|
|
2795
|
+
resizeObserver.disconnect();
|
|
2796
|
+
});
|
|
2797
|
+
vue.watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
|
|
2798
|
+
setTimeout(() => {
|
|
2799
|
+
setCanScroll();
|
|
2800
|
+
if (length < preLength) {
|
|
2801
|
+
scroll("start");
|
|
2802
|
+
} else {
|
|
2803
|
+
scroll("end");
|
|
2804
|
+
}
|
|
2805
|
+
});
|
|
2806
|
+
});
|
|
2807
|
+
return {
|
|
2808
|
+
pageBar,
|
|
2809
|
+
itemsContainer,
|
|
2810
|
+
canScroll,
|
|
2811
|
+
itemsContainerWidth,
|
|
2812
|
+
scroll
|
|
2813
|
+
};
|
|
2814
|
+
};
|
|
3524
2815
|
const _sfc_main$5 = vue.defineComponent({
|
|
3525
|
-
components: { CaretBottom: icons.CaretBottom, Plus: icons.Plus },
|
|
2816
|
+
components: { ArrowLeftBold: icons.ArrowLeftBold, ArrowRightBold: icons.ArrowRightBold, CaretBottom: icons.CaretBottom, Plus: icons.Plus, ToolButton },
|
|
3526
2817
|
setup() {
|
|
3527
2818
|
const services = vue.inject("services");
|
|
3528
2819
|
const editorService = services?.editorService;
|
|
2820
|
+
const root = vue.computed(() => editorService?.get("root"));
|
|
3529
2821
|
return {
|
|
3530
|
-
|
|
2822
|
+
Delete: vue.markRaw(icons.Delete),
|
|
2823
|
+
DocumentCopy: vue.markRaw(icons.DocumentCopy),
|
|
2824
|
+
...useScroll(root),
|
|
2825
|
+
root,
|
|
3531
2826
|
page: vue.computed(() => editorService?.get("page")),
|
|
3532
2827
|
switchPage(page) {
|
|
3533
2828
|
editorService?.select(page);
|
|
@@ -3536,7 +2831,7 @@
|
|
|
3536
2831
|
if (!editorService)
|
|
3537
2832
|
return;
|
|
3538
2833
|
const pageConfig = {
|
|
3539
|
-
type:
|
|
2834
|
+
type: schema.NodeType.PAGE,
|
|
3540
2835
|
name: generatePageNameByApp(vue.toRaw(editorService.get("root")))
|
|
3541
2836
|
};
|
|
3542
2837
|
editorService.add(pageConfig);
|
|
@@ -3554,99 +2849,228 @@
|
|
|
3554
2849
|
};
|
|
3555
2850
|
}
|
|
3556
2851
|
});
|
|
3557
|
-
const _hoisted_1$
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
2852
|
+
const _hoisted_1$2 = {
|
|
2853
|
+
class: "m-editor-page-bar",
|
|
2854
|
+
ref: "pageBar"
|
|
2855
|
+
};
|
|
2856
|
+
const _hoisted_2 = ["onClick"];
|
|
2857
|
+
const _hoisted_3 = { class: "m-editor-page-bar-title" };
|
|
3561
2858
|
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3562
2859
|
const _component_plus = vue.resolveComponent("plus");
|
|
3563
2860
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
2861
|
+
const _component_arrow_left_bold = vue.resolveComponent("arrow-left-bold");
|
|
2862
|
+
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
2863
|
+
const _component_tool_button = vue.resolveComponent("tool-button");
|
|
3564
2864
|
const _component_caret_bottom = vue.resolveComponent("caret-bottom");
|
|
3565
2865
|
const _component_el_popover = vue.resolveComponent("el-popover");
|
|
3566
|
-
|
|
2866
|
+
const _component_arrow_right_bold = vue.resolveComponent("arrow-right-bold");
|
|
2867
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
|
|
3567
2868
|
vue.createElementVNode("div", {
|
|
3568
|
-
|
|
2869
|
+
id: "m-editor-page-bar-add-icon",
|
|
2870
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3569
2871
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.addPage && _ctx.addPage(...args))
|
|
3570
2872
|
}, [
|
|
3571
|
-
vue.createVNode(_component_el_icon,
|
|
2873
|
+
vue.createVNode(_component_el_icon, null, {
|
|
3572
2874
|
default: vue.withCtx(() => [
|
|
3573
2875
|
vue.createVNode(_component_plus)
|
|
3574
2876
|
]),
|
|
3575
2877
|
_: 1
|
|
3576
2878
|
})
|
|
3577
2879
|
]),
|
|
3578
|
-
_ctx.
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
vue.
|
|
3585
|
-
vue.
|
|
2880
|
+
_ctx.canScroll ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
2881
|
+
key: 0,
|
|
2882
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
2883
|
+
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.scroll("left"))
|
|
2884
|
+
}, [
|
|
2885
|
+
vue.createVNode(_component_el_icon, null, {
|
|
2886
|
+
default: vue.withCtx(() => [
|
|
2887
|
+
vue.createVNode(_component_arrow_left_bold)
|
|
3586
2888
|
]),
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
]),
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
2889
|
+
_: 1
|
|
2890
|
+
})
|
|
2891
|
+
])) : vue.createCommentVNode("", true),
|
|
2892
|
+
_ctx.root ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
2893
|
+
key: 1,
|
|
2894
|
+
class: "m-editor-page-bar-items",
|
|
2895
|
+
ref: "itemsContainer",
|
|
2896
|
+
style: vue.normalizeStyle(`width: ${_ctx.itemsContainerWidth}px`)
|
|
2897
|
+
}, [
|
|
2898
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.root.items, (item) => {
|
|
2899
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
2900
|
+
key: item.key,
|
|
2901
|
+
class: vue.normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
|
|
2902
|
+
onClick: ($event) => _ctx.switchPage(item)
|
|
2903
|
+
}, [
|
|
2904
|
+
vue.createElementVNode("div", _hoisted_3, [
|
|
2905
|
+
vue.renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
|
|
2906
|
+
vue.createVNode(_component_el_tooltip, {
|
|
2907
|
+
effect: "dark",
|
|
2908
|
+
placement: "top-start",
|
|
2909
|
+
content: item.name
|
|
2910
|
+
}, {
|
|
2911
|
+
default: vue.withCtx(() => [
|
|
2912
|
+
vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
|
|
2913
|
+
]),
|
|
2914
|
+
_: 2
|
|
2915
|
+
}, 1032, ["content"])
|
|
3612
2916
|
])
|
|
3613
2917
|
]),
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
2918
|
+
vue.createVNode(_component_el_popover, {
|
|
2919
|
+
"popper-class": "page-bar-popover",
|
|
2920
|
+
placement: "top",
|
|
2921
|
+
width: 160,
|
|
2922
|
+
trigger: "hover"
|
|
2923
|
+
}, {
|
|
2924
|
+
reference: vue.withCtx(() => [
|
|
2925
|
+
vue.createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
|
|
2926
|
+
default: vue.withCtx(() => [
|
|
2927
|
+
vue.createVNode(_component_caret_bottom)
|
|
2928
|
+
]),
|
|
2929
|
+
_: 1
|
|
2930
|
+
})
|
|
2931
|
+
]),
|
|
2932
|
+
default: vue.withCtx(() => [
|
|
2933
|
+
vue.createElementVNode("div", null, [
|
|
2934
|
+
vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
2935
|
+
vue.createVNode(_component_tool_button, {
|
|
2936
|
+
data: {
|
|
2937
|
+
type: "button",
|
|
2938
|
+
text: "\u590D\u5236",
|
|
2939
|
+
icon: _ctx.DocumentCopy,
|
|
2940
|
+
handler: () => _ctx.copy(item)
|
|
2941
|
+
}
|
|
2942
|
+
}, null, 8, ["data"]),
|
|
2943
|
+
vue.createVNode(_component_tool_button, {
|
|
2944
|
+
data: {
|
|
2945
|
+
type: "button",
|
|
2946
|
+
text: "\u5220\u9664",
|
|
2947
|
+
icon: _ctx.Delete,
|
|
2948
|
+
handler: () => _ctx.remove(item)
|
|
2949
|
+
}
|
|
2950
|
+
}, null, 8, ["data"])
|
|
2951
|
+
])
|
|
2952
|
+
])
|
|
2953
|
+
]),
|
|
2954
|
+
_: 2
|
|
2955
|
+
}, 1024)
|
|
2956
|
+
], 10, _hoisted_2);
|
|
2957
|
+
}), 128))
|
|
2958
|
+
], 4)) : vue.createCommentVNode("", true),
|
|
2959
|
+
_ctx.canScroll ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
2960
|
+
key: 2,
|
|
2961
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
2962
|
+
onClick: _cache[2] || (_cache[2] = ($event) => _ctx.scroll("right"))
|
|
2963
|
+
}, [
|
|
2964
|
+
vue.createVNode(_component_el_icon, null, {
|
|
2965
|
+
default: vue.withCtx(() => [
|
|
2966
|
+
vue.createVNode(_component_arrow_right_bold)
|
|
2967
|
+
]),
|
|
2968
|
+
_: 1
|
|
2969
|
+
})
|
|
2970
|
+
])) : vue.createCommentVNode("", true)
|
|
2971
|
+
], 512);
|
|
3619
2972
|
}
|
|
3620
2973
|
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
|
|
3621
2974
|
|
|
3622
2975
|
class ScrollViewer$1 {
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
2976
|
+
constructor(options) {
|
|
2977
|
+
this.enter = false;
|
|
2978
|
+
this.targetEnter = false;
|
|
2979
|
+
this.keydown = false;
|
|
2980
|
+
this.zoom = 1;
|
|
2981
|
+
this.scrollLeft = 0;
|
|
2982
|
+
this.scrollTop = 0;
|
|
2983
|
+
this.x = 0;
|
|
2984
|
+
this.y = 0;
|
|
2985
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
2986
|
+
for (const { contentRect } of entries) {
|
|
2987
|
+
const { width, height } = contentRect;
|
|
2988
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
2989
|
+
const targetWidth = targetRect.width * this.zoom;
|
|
2990
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
2991
|
+
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
2992
|
+
if (targetWidth < width) {
|
|
2993
|
+
this.target._left = 0;
|
|
2994
|
+
}
|
|
2995
|
+
if (targetHeight < height) {
|
|
2996
|
+
this.target._top = 0;
|
|
2997
|
+
}
|
|
2998
|
+
this.scroll();
|
|
3645
2999
|
}
|
|
3000
|
+
});
|
|
3001
|
+
this.wheelHandler = (event) => {
|
|
3002
|
+
if (this.targetEnter)
|
|
3003
|
+
return;
|
|
3004
|
+
const { deltaX, deltaY, currentTarget } = event;
|
|
3005
|
+
if (currentTarget !== this.container)
|
|
3006
|
+
return;
|
|
3007
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3646
3008
|
this.scroll();
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3009
|
+
this.scrollLeft = this.target._left;
|
|
3010
|
+
this.scrollTop = this.target._top;
|
|
3011
|
+
};
|
|
3012
|
+
this.mouseEnterHandler = () => {
|
|
3013
|
+
this.enter = true;
|
|
3014
|
+
};
|
|
3015
|
+
this.mouseLeaveHandler = () => {
|
|
3016
|
+
this.enter = false;
|
|
3017
|
+
};
|
|
3018
|
+
this.targetMouseEnterHandler = () => {
|
|
3019
|
+
this.targetEnter = true;
|
|
3020
|
+
};
|
|
3021
|
+
this.targetMouseLeaveHandler = () => {
|
|
3022
|
+
this.targetEnter = false;
|
|
3023
|
+
};
|
|
3024
|
+
this.mousedownHandler = (event) => {
|
|
3025
|
+
if (!this.keydown)
|
|
3026
|
+
return;
|
|
3027
|
+
event.stopImmediatePropagation();
|
|
3028
|
+
event.stopPropagation();
|
|
3029
|
+
this.target.style.cursor = "grabbing";
|
|
3030
|
+
this.x = event.clientX;
|
|
3031
|
+
this.y = event.clientY;
|
|
3032
|
+
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3033
|
+
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3034
|
+
};
|
|
3035
|
+
this.mouseupHandler = () => {
|
|
3036
|
+
this.x = 0;
|
|
3037
|
+
this.y = 0;
|
|
3038
|
+
this.scrollLeft = this.target._left;
|
|
3039
|
+
this.scrollTop = this.target._top;
|
|
3040
|
+
this.removeHandler();
|
|
3041
|
+
};
|
|
3042
|
+
this.mousemoveHandler = (event) => {
|
|
3043
|
+
event.stopImmediatePropagation();
|
|
3044
|
+
event.stopPropagation();
|
|
3045
|
+
const deltaX = event.clientX - this.x;
|
|
3046
|
+
const deltaY = event.clientY - this.y;
|
|
3047
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3048
|
+
this.scroll();
|
|
3049
|
+
};
|
|
3050
|
+
this.keydownHandler = (event) => {
|
|
3051
|
+
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3052
|
+
event.preventDefault();
|
|
3053
|
+
event.stopImmediatePropagation();
|
|
3054
|
+
event.stopPropagation();
|
|
3055
|
+
}
|
|
3056
|
+
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3057
|
+
return;
|
|
3058
|
+
}
|
|
3059
|
+
this.keydown = true;
|
|
3060
|
+
this.target.style.cursor = "grab";
|
|
3061
|
+
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3062
|
+
};
|
|
3063
|
+
this.keyupHandler = (event) => {
|
|
3064
|
+
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3065
|
+
return;
|
|
3066
|
+
}
|
|
3067
|
+
event.preventDefault();
|
|
3068
|
+
event.stopImmediatePropagation();
|
|
3069
|
+
event.stopPropagation();
|
|
3070
|
+
this.keydown = false;
|
|
3071
|
+
event.preventDefault();
|
|
3072
|
+
this.removeHandler();
|
|
3073
|
+
};
|
|
3650
3074
|
this.container = options.container;
|
|
3651
3075
|
this.target = options.target;
|
|
3652
3076
|
this.zoom = options.zoom;
|
|
@@ -3682,79 +3106,6 @@
|
|
|
3682
3106
|
document.removeEventListener("mousemove", this.mousemoveHandler);
|
|
3683
3107
|
document.removeEventListener("mouseup", this.mouseupHandler);
|
|
3684
3108
|
}
|
|
3685
|
-
wheelHandler = (event) => {
|
|
3686
|
-
if (this.targetEnter)
|
|
3687
|
-
return;
|
|
3688
|
-
const { deltaX, deltaY, currentTarget } = event;
|
|
3689
|
-
if (currentTarget !== this.container)
|
|
3690
|
-
return;
|
|
3691
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3692
|
-
this.scroll();
|
|
3693
|
-
this.scrollLeft = this.target._left;
|
|
3694
|
-
this.scrollTop = this.target._top;
|
|
3695
|
-
};
|
|
3696
|
-
mouseEnterHandler = () => {
|
|
3697
|
-
this.enter = true;
|
|
3698
|
-
};
|
|
3699
|
-
mouseLeaveHandler = () => {
|
|
3700
|
-
this.enter = false;
|
|
3701
|
-
};
|
|
3702
|
-
targetMouseEnterHandler = () => {
|
|
3703
|
-
this.targetEnter = true;
|
|
3704
|
-
};
|
|
3705
|
-
targetMouseLeaveHandler = () => {
|
|
3706
|
-
this.targetEnter = false;
|
|
3707
|
-
};
|
|
3708
|
-
mousedownHandler = (event) => {
|
|
3709
|
-
if (!this.keydown)
|
|
3710
|
-
return;
|
|
3711
|
-
event.stopImmediatePropagation();
|
|
3712
|
-
event.stopPropagation();
|
|
3713
|
-
this.target.style.cursor = "grabbing";
|
|
3714
|
-
this.x = event.clientX;
|
|
3715
|
-
this.y = event.clientY;
|
|
3716
|
-
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3717
|
-
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3718
|
-
};
|
|
3719
|
-
mouseupHandler = () => {
|
|
3720
|
-
this.x = 0;
|
|
3721
|
-
this.y = 0;
|
|
3722
|
-
this.scrollLeft = this.target._left;
|
|
3723
|
-
this.scrollTop = this.target._top;
|
|
3724
|
-
this.removeHandler();
|
|
3725
|
-
};
|
|
3726
|
-
mousemoveHandler = (event) => {
|
|
3727
|
-
event.stopImmediatePropagation();
|
|
3728
|
-
event.stopPropagation();
|
|
3729
|
-
const deltaX = event.clientX - this.x;
|
|
3730
|
-
const deltaY = event.clientY - this.y;
|
|
3731
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3732
|
-
this.scroll();
|
|
3733
|
-
};
|
|
3734
|
-
keydownHandler = (event) => {
|
|
3735
|
-
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3736
|
-
event.preventDefault();
|
|
3737
|
-
event.stopImmediatePropagation();
|
|
3738
|
-
event.stopPropagation();
|
|
3739
|
-
}
|
|
3740
|
-
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3741
|
-
return;
|
|
3742
|
-
}
|
|
3743
|
-
this.keydown = true;
|
|
3744
|
-
this.target.style.cursor = "grab";
|
|
3745
|
-
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3746
|
-
};
|
|
3747
|
-
keyupHandler = (event) => {
|
|
3748
|
-
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3749
|
-
return;
|
|
3750
|
-
}
|
|
3751
|
-
event.preventDefault();
|
|
3752
|
-
event.stopImmediatePropagation();
|
|
3753
|
-
event.stopPropagation();
|
|
3754
|
-
this.keydown = false;
|
|
3755
|
-
event.preventDefault();
|
|
3756
|
-
this.removeHandler();
|
|
3757
|
-
};
|
|
3758
3109
|
setScrollOffset(deltaX, deltaY) {
|
|
3759
3110
|
const { width, height } = this.container.getBoundingClientRect();
|
|
3760
3111
|
const targetRect = this.target.getBoundingClientRect();
|
|
@@ -3815,19 +3166,19 @@
|
|
|
3815
3166
|
el,
|
|
3816
3167
|
style: vue.computed(() => `
|
|
3817
3168
|
width: ${props.width}px;
|
|
3818
|
-
height: ${props.height}px;
|
|
3169
|
+
height: ${(props.height || 0) - 40}px;
|
|
3819
3170
|
position: absolute;
|
|
3820
3171
|
margin-top: 30px;
|
|
3821
3172
|
`)
|
|
3822
3173
|
};
|
|
3823
3174
|
}
|
|
3824
3175
|
});
|
|
3825
|
-
const _hoisted_1$
|
|
3176
|
+
const _hoisted_1$1 = {
|
|
3826
3177
|
class: "m-editor-scroll-viewer-container",
|
|
3827
3178
|
ref: "container"
|
|
3828
3179
|
};
|
|
3829
3180
|
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3830
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
3181
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
|
|
3831
3182
|
vue.createElementVNode("div", {
|
|
3832
3183
|
ref: "el",
|
|
3833
3184
|
style: vue.normalizeStyle(_ctx.style)
|
|
@@ -3839,7 +3190,7 @@
|
|
|
3839
3190
|
var ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]);
|
|
3840
3191
|
|
|
3841
3192
|
const _sfc_main$3 = vue.defineComponent({
|
|
3842
|
-
|
|
3193
|
+
components: { ContentMenu },
|
|
3843
3194
|
setup() {
|
|
3844
3195
|
const services = vue.inject("services");
|
|
3845
3196
|
const editorService = services?.editorService;
|
|
@@ -3848,6 +3199,7 @@
|
|
|
3848
3199
|
const canCenter = vue.ref(false);
|
|
3849
3200
|
const node = vue.computed(() => editorService?.get("node"));
|
|
3850
3201
|
const parent = vue.computed(() => editorService?.get("parent"));
|
|
3202
|
+
const isPage = vue.computed(() => node.value?.type === schema.NodeType.PAGE);
|
|
3851
3203
|
vue.onMounted(() => {
|
|
3852
3204
|
const data = globalThis.localStorage.getItem(COPY_STORAGE_KEY);
|
|
3853
3205
|
canPaste.value = data !== "undefined" && !!data;
|
|
@@ -3856,137 +3208,118 @@
|
|
|
3856
3208
|
if (!parent.value || !editorService)
|
|
3857
3209
|
return canCenter.value = false;
|
|
3858
3210
|
const layout = await editorService.getLayout(parent.value);
|
|
3859
|
-
canCenter.value = [Layout.ABSOLUTE, Layout.FIXED].includes(layout) && ![
|
|
3211
|
+
canCenter.value = [Layout.ABSOLUTE, Layout.FIXED].includes(layout) && ![schema.NodeType.ROOT, schema.NodeType.PAGE, "pop"].includes(`${node.value?.type}`);
|
|
3860
3212
|
}, { immediate: true });
|
|
3861
3213
|
return {
|
|
3862
3214
|
menu,
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3215
|
+
menuData: vue.reactive([
|
|
3216
|
+
{
|
|
3217
|
+
type: "button",
|
|
3218
|
+
text: "\u6C34\u5E73\u5C45\u4E2D",
|
|
3219
|
+
display: () => canCenter.value,
|
|
3220
|
+
handler: () => {
|
|
3221
|
+
node.value && editorService?.alignCenter(node.value);
|
|
3222
|
+
}
|
|
3223
|
+
},
|
|
3224
|
+
{
|
|
3225
|
+
type: "button",
|
|
3226
|
+
text: "\u590D\u5236",
|
|
3227
|
+
icon: vue.markRaw(icons.DocumentCopy),
|
|
3228
|
+
handler: () => {
|
|
3229
|
+
node.value && editorService?.copy(node.value);
|
|
3230
|
+
canPaste.value = true;
|
|
3231
|
+
}
|
|
3232
|
+
},
|
|
3233
|
+
{
|
|
3234
|
+
type: "button",
|
|
3235
|
+
text: "\u7C98\u8D34",
|
|
3236
|
+
display: () => canPaste.value,
|
|
3237
|
+
handler: () => {
|
|
3238
|
+
const top = menu.value?.$el.offsetTop || 0;
|
|
3239
|
+
const left = menu.value?.$el.offsetLeft || 0;
|
|
3240
|
+
editorService?.paste({ left, top });
|
|
3241
|
+
}
|
|
3242
|
+
},
|
|
3243
|
+
{
|
|
3244
|
+
type: "divider",
|
|
3245
|
+
direction: "horizontal",
|
|
3246
|
+
display: () => !isPage.value
|
|
3247
|
+
},
|
|
3248
|
+
{
|
|
3249
|
+
type: "button",
|
|
3250
|
+
text: "\u4E0A\u79FB\u4E00\u5C42",
|
|
3251
|
+
icon: vue.markRaw(icons.Top),
|
|
3252
|
+
display: () => !isPage.value,
|
|
3253
|
+
handler: () => {
|
|
3254
|
+
editorService?.moveLayer(1);
|
|
3255
|
+
}
|
|
3256
|
+
},
|
|
3257
|
+
{
|
|
3258
|
+
type: "button",
|
|
3259
|
+
text: "\u4E0B\u79FB\u4E00\u5C42",
|
|
3260
|
+
icon: vue.markRaw(icons.Bottom),
|
|
3261
|
+
display: () => !isPage.value,
|
|
3262
|
+
handler: () => {
|
|
3263
|
+
editorService?.moveLayer(-1);
|
|
3264
|
+
}
|
|
3265
|
+
},
|
|
3266
|
+
{
|
|
3267
|
+
type: "button",
|
|
3268
|
+
text: "\u7F6E\u9876",
|
|
3269
|
+
display: () => !isPage.value,
|
|
3270
|
+
handler: () => {
|
|
3271
|
+
editorService?.moveLayer(LayerOffset.TOP);
|
|
3272
|
+
}
|
|
3273
|
+
},
|
|
3274
|
+
{
|
|
3275
|
+
type: "button",
|
|
3276
|
+
text: "\u7F6E\u5E95",
|
|
3277
|
+
display: () => !isPage.value,
|
|
3278
|
+
handler: () => {
|
|
3279
|
+
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
3280
|
+
}
|
|
3281
|
+
},
|
|
3282
|
+
{
|
|
3283
|
+
type: "divider",
|
|
3284
|
+
direction: "horizontal",
|
|
3285
|
+
display: () => !isPage.value
|
|
3286
|
+
},
|
|
3287
|
+
{
|
|
3288
|
+
type: "button",
|
|
3289
|
+
text: "\u5220\u9664",
|
|
3290
|
+
icon: icons.Delete,
|
|
3291
|
+
display: () => !isPage.value,
|
|
3292
|
+
handler: () => {
|
|
3293
|
+
node.value && editorService?.remove(node.value);
|
|
3294
|
+
}
|
|
3295
|
+
},
|
|
3296
|
+
{
|
|
3297
|
+
type: "divider",
|
|
3298
|
+
direction: "horizontal"
|
|
3299
|
+
},
|
|
3300
|
+
{
|
|
3301
|
+
type: "button",
|
|
3302
|
+
text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
|
|
3303
|
+
handler: () => {
|
|
3304
|
+
editorService?.get("stage").clearGuides();
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
]),
|
|
3308
|
+
show(e) {
|
|
3309
|
+
menu.value?.show(e);
|
|
3896
3310
|
}
|
|
3897
3311
|
};
|
|
3898
3312
|
}
|
|
3899
3313
|
});
|
|
3900
|
-
const _hoisted_1$1 = {
|
|
3901
|
-
class: "magic-editor-content-menu",
|
|
3902
|
-
ref: "menu"
|
|
3903
|
-
};
|
|
3904
|
-
const _hoisted_2 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
|
|
3905
|
-
const _hoisted_3 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
|
|
3906
|
-
const _hoisted_4 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
|
|
3907
3314
|
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
onClick: _cache[0] || (_cache[0] = () => _ctx.center())
|
|
3914
|
-
}, "\u6C34\u5E73\u5C45\u4E2D")) : vue.createCommentVNode("", true),
|
|
3915
|
-
vue.createElementVNode("div", {
|
|
3916
|
-
class: "magic-editor-content-menu-item",
|
|
3917
|
-
onClick: _cache[1] || (_cache[1] = () => _ctx.copy())
|
|
3918
|
-
}, "\u590D\u5236"),
|
|
3919
|
-
_ctx.canPaste ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3920
|
-
key: 1,
|
|
3921
|
-
class: "magic-editor-content-menu-item",
|
|
3922
|
-
onClick: _cache[2] || (_cache[2] = (...args) => _ctx.paste && _ctx.paste(...args))
|
|
3923
|
-
}, "\u7C98\u8D34")) : vue.createCommentVNode("", true),
|
|
3924
|
-
_ctx.canMoveZPos ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
|
|
3925
|
-
_hoisted_2,
|
|
3926
|
-
vue.createElementVNode("div", {
|
|
3927
|
-
class: "magic-editor-content-menu-item",
|
|
3928
|
-
onClick: _cache[3] || (_cache[3] = (...args) => _ctx.topItem && _ctx.topItem(...args))
|
|
3929
|
-
}, "\u4E0A\u79FB\u4E00\u5C42"),
|
|
3930
|
-
vue.createElementVNode("div", {
|
|
3931
|
-
class: "magic-editor-content-menu-item",
|
|
3932
|
-
onClick: _cache[4] || (_cache[4] = (...args) => _ctx.bottomItem && _ctx.bottomItem(...args))
|
|
3933
|
-
}, "\u4E0B\u79FB\u4E00\u5C42"),
|
|
3934
|
-
vue.createElementVNode("div", {
|
|
3935
|
-
class: "magic-editor-content-menu-item",
|
|
3936
|
-
onClick: _cache[5] || (_cache[5] = (...args) => _ctx.top && _ctx.top(...args))
|
|
3937
|
-
}, "\u7F6E\u9876"),
|
|
3938
|
-
vue.createElementVNode("div", {
|
|
3939
|
-
class: "magic-editor-content-menu-item",
|
|
3940
|
-
onClick: _cache[6] || (_cache[6] = (...args) => _ctx.bottom && _ctx.bottom(...args))
|
|
3941
|
-
}, "\u7F6E\u5E95")
|
|
3942
|
-
], 64)) : vue.createCommentVNode("", true),
|
|
3943
|
-
_ctx.canDelete ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
|
|
3944
|
-
_hoisted_3,
|
|
3945
|
-
vue.createElementVNode("div", {
|
|
3946
|
-
class: "magic-editor-content-menu-item",
|
|
3947
|
-
onClick: _cache[7] || (_cache[7] = () => _ctx.remove())
|
|
3948
|
-
}, "\u5220\u9664")
|
|
3949
|
-
], 64)) : vue.createCommentVNode("", true),
|
|
3950
|
-
_hoisted_4,
|
|
3951
|
-
vue.createElementVNode("div", {
|
|
3952
|
-
class: "magic-editor-content-menu-item",
|
|
3953
|
-
onClick: _cache[8] || (_cache[8] = (...args) => _ctx.clearGuides && _ctx.clearGuides(...args))
|
|
3954
|
-
}, "\u6E05\u7A7A\u53C2\u8003\u7EBF")
|
|
3955
|
-
])
|
|
3956
|
-
], 512);
|
|
3315
|
+
const _component_content_menu = vue.resolveComponent("content-menu");
|
|
3316
|
+
return vue.openBlock(), vue.createBlock(_component_content_menu, {
|
|
3317
|
+
"menu-data": _ctx.menuData,
|
|
3318
|
+
ref: "menu"
|
|
3319
|
+
}, null, 8, ["menu-data"]);
|
|
3957
3320
|
}
|
|
3958
3321
|
var ViewerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
|
|
3959
3322
|
|
|
3960
|
-
const useMenu = () => {
|
|
3961
|
-
const menu = vue.ref();
|
|
3962
|
-
const menuStyle = vue.ref({
|
|
3963
|
-
display: "none",
|
|
3964
|
-
left: "0",
|
|
3965
|
-
top: "0"
|
|
3966
|
-
});
|
|
3967
|
-
vue.onMounted(() => {
|
|
3968
|
-
document.addEventListener("click", () => {
|
|
3969
|
-
menuStyle.value.display = "none";
|
|
3970
|
-
}, true);
|
|
3971
|
-
});
|
|
3972
|
-
return {
|
|
3973
|
-
menu,
|
|
3974
|
-
menuStyle,
|
|
3975
|
-
contextmenuHandler(e) {
|
|
3976
|
-
e.preventDefault();
|
|
3977
|
-
const menuHeight = menu.value?.$el.clientHeight;
|
|
3978
|
-
let top = e.clientY;
|
|
3979
|
-
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
3980
|
-
top = document.body.clientHeight - menuHeight;
|
|
3981
|
-
}
|
|
3982
|
-
menuStyle.value = {
|
|
3983
|
-
display: "block",
|
|
3984
|
-
top: `${top}px`,
|
|
3985
|
-
left: `${e.clientX}px`
|
|
3986
|
-
};
|
|
3987
|
-
}
|
|
3988
|
-
};
|
|
3989
|
-
};
|
|
3990
3323
|
const _sfc_main$2 = vue.defineComponent({
|
|
3991
3324
|
name: "magic-stage",
|
|
3992
3325
|
components: {
|
|
@@ -4009,16 +3342,16 @@
|
|
|
4009
3342
|
})
|
|
4010
3343
|
}
|
|
4011
3344
|
},
|
|
4012
|
-
|
|
4013
|
-
setup(props, { emit }) {
|
|
3345
|
+
setup(props) {
|
|
4014
3346
|
const services = vue.inject("services");
|
|
4015
3347
|
const stageWrap = vue.ref();
|
|
4016
3348
|
const stageContainer = vue.ref();
|
|
3349
|
+
const menu = vue.ref();
|
|
4017
3350
|
const stageRect = vue.computed(() => services?.uiService.get("stageRect"));
|
|
4018
3351
|
const uiSelectMode = vue.computed(() => services?.uiService.get("uiSelectMode"));
|
|
4019
3352
|
const root = vue.computed(() => services?.editorService.get("root"));
|
|
4020
3353
|
const page = vue.computed(() => services?.editorService.get("page"));
|
|
4021
|
-
const zoom = vue.computed(() => services?.uiService.get("zoom"));
|
|
3354
|
+
const zoom = vue.computed(() => services?.uiService.get("zoom") || 1);
|
|
4022
3355
|
const node = vue.computed(() => services?.editorService.get("node"));
|
|
4023
3356
|
let stage = null;
|
|
4024
3357
|
let runtime = null;
|
|
@@ -4033,9 +3366,9 @@
|
|
|
4033
3366
|
render: props.render,
|
|
4034
3367
|
runtimeUrl: props.runtimeUrl,
|
|
4035
3368
|
zoom: zoom.value,
|
|
4036
|
-
canSelect: (el, stop) => {
|
|
3369
|
+
canSelect: (el, event, stop) => {
|
|
4037
3370
|
const elCanSelect = props.canSelect(el);
|
|
4038
|
-
if (uiSelectMode.value && elCanSelect) {
|
|
3371
|
+
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
4039
3372
|
document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
|
|
4040
3373
|
return stop();
|
|
4041
3374
|
}
|
|
@@ -4043,14 +3376,19 @@
|
|
|
4043
3376
|
},
|
|
4044
3377
|
moveableOptions: props.moveableOptions
|
|
4045
3378
|
});
|
|
4046
|
-
services?.editorService.set("stage", stage);
|
|
3379
|
+
services?.editorService.set("stage", vue.markRaw(stage));
|
|
4047
3380
|
stage?.mount(stageContainer.value);
|
|
4048
|
-
stage?.on("select", (el) =>
|
|
3381
|
+
stage?.on("select", (el) => {
|
|
3382
|
+
services?.editorService.select(el.id);
|
|
3383
|
+
});
|
|
3384
|
+
stage?.on("highlight", (el) => {
|
|
3385
|
+
services?.editorService.highlight(el.id);
|
|
3386
|
+
});
|
|
4049
3387
|
stage?.on("update", (ev) => {
|
|
4050
|
-
|
|
3388
|
+
services?.editorService.update({ id: ev.el.id, style: ev.style });
|
|
4051
3389
|
});
|
|
4052
3390
|
stage?.on("sort", (ev) => {
|
|
4053
|
-
|
|
3391
|
+
services?.editorService.sort(ev.src, ev.dist);
|
|
4054
3392
|
});
|
|
4055
3393
|
stage?.on("changeGuides", () => {
|
|
4056
3394
|
services?.uiService.set("showGuides", true);
|
|
@@ -4076,11 +3414,6 @@
|
|
|
4076
3414
|
runtime.updateRootConfig(lodashEs.cloneDeep(vue.toRaw(root2)));
|
|
4077
3415
|
}
|
|
4078
3416
|
});
|
|
4079
|
-
vue.watch(() => node.value?.id, (id) => {
|
|
4080
|
-
vue.nextTick(() => {
|
|
4081
|
-
id && stage?.select(id);
|
|
4082
|
-
});
|
|
4083
|
-
});
|
|
4084
3417
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
4085
3418
|
for (const { contentRect } of entries) {
|
|
4086
3419
|
services?.uiService.set("stageContainerRect", {
|
|
@@ -4100,9 +3433,37 @@
|
|
|
4100
3433
|
return {
|
|
4101
3434
|
stageWrap,
|
|
4102
3435
|
stageContainer,
|
|
3436
|
+
menu,
|
|
4103
3437
|
stageRect,
|
|
4104
3438
|
zoom,
|
|
4105
|
-
|
|
3439
|
+
contextmenuHandler(e2) {
|
|
3440
|
+
e2.preventDefault();
|
|
3441
|
+
menu.value?.show(e2);
|
|
3442
|
+
},
|
|
3443
|
+
dragoverHandler(e2) {
|
|
3444
|
+
e2.preventDefault();
|
|
3445
|
+
if (e2.dataTransfer) {
|
|
3446
|
+
e2.dataTransfer.dropEffect = "move";
|
|
3447
|
+
}
|
|
3448
|
+
},
|
|
3449
|
+
async dropHandler(e) {
|
|
3450
|
+
e.preventDefault();
|
|
3451
|
+
if (e.dataTransfer && page.value && stageContainer.value && stage) {
|
|
3452
|
+
const config = eval(`(${e.dataTransfer.getData("data")})`);
|
|
3453
|
+
const layout = await services?.editorService.getLayout(page.value);
|
|
3454
|
+
const containerRect = stageContainer.value.getBoundingClientRect();
|
|
3455
|
+
const { scrollTop, scrollLeft } = stage.mask;
|
|
3456
|
+
if (layout === Layout.ABSOLUTE) {
|
|
3457
|
+
config.style = {
|
|
3458
|
+
...config.style || {},
|
|
3459
|
+
position: "absolute",
|
|
3460
|
+
top: e.clientY - containerRect.top + scrollTop,
|
|
3461
|
+
left: e.clientX - containerRect.left + scrollLeft
|
|
3462
|
+
};
|
|
3463
|
+
}
|
|
3464
|
+
services?.editorService.add(config, page.value);
|
|
3465
|
+
}
|
|
3466
|
+
}
|
|
4106
3467
|
};
|
|
4107
3468
|
}
|
|
4108
3469
|
});
|
|
@@ -4120,14 +3481,13 @@
|
|
|
4120
3481
|
vue.createElementVNode("div", {
|
|
4121
3482
|
class: "m-editor-stage-container",
|
|
4122
3483
|
ref: "stageContainer",
|
|
3484
|
+
style: vue.normalizeStyle(`transform: scale(${_ctx.zoom})`),
|
|
4123
3485
|
onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
|
|
4124
|
-
|
|
3486
|
+
onDrop: _cache[1] || (_cache[1] = (...args) => _ctx.dropHandler && _ctx.dropHandler(...args)),
|
|
3487
|
+
onDragover: _cache[2] || (_cache[2] = (...args) => _ctx.dragoverHandler && _ctx.dragoverHandler(...args))
|
|
4125
3488
|
}, null, 36),
|
|
4126
3489
|
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
4127
|
-
vue.createVNode(_component_viewer_menu, {
|
|
4128
|
-
ref: "menu",
|
|
4129
|
-
style: vue.normalizeStyle(_ctx.menuStyle)
|
|
4130
|
-
}, null, 8, ["style"])
|
|
3490
|
+
vue.createVNode(_component_viewer_menu, { ref: "menu" }, null, 512)
|
|
4131
3491
|
]))
|
|
4132
3492
|
]),
|
|
4133
3493
|
_: 1
|
|
@@ -4155,21 +3515,93 @@
|
|
|
4155
3515
|
},
|
|
4156
3516
|
setup() {
|
|
4157
3517
|
const services = vue.inject("services");
|
|
3518
|
+
const workspace = vue.ref();
|
|
3519
|
+
const node = vue.computed(() => services?.editorService.get("node"));
|
|
3520
|
+
let keycon;
|
|
3521
|
+
const mouseenterHandler = () => {
|
|
3522
|
+
workspace.value?.focus();
|
|
3523
|
+
};
|
|
3524
|
+
const mouseleaveHandler = () => {
|
|
3525
|
+
workspace.value?.blur();
|
|
3526
|
+
};
|
|
3527
|
+
vue.onMounted(() => {
|
|
3528
|
+
workspace.value?.addEventListener("mouseenter", mouseenterHandler);
|
|
3529
|
+
workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
|
|
3530
|
+
keycon = new KeyController__default["default"](workspace.value);
|
|
3531
|
+
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
3532
|
+
const ctrl = isMac ? "meta" : "ctrl";
|
|
3533
|
+
keycon.keydown((e) => {
|
|
3534
|
+
console.log(e);
|
|
3535
|
+
e.inputEvent.preventDefault();
|
|
3536
|
+
}).keyup("delete", (e) => {
|
|
3537
|
+
e.inputEvent.preventDefault();
|
|
3538
|
+
if (!node.value || utils.isPage(node.value))
|
|
3539
|
+
return;
|
|
3540
|
+
services?.editorService.remove(node.value);
|
|
3541
|
+
}).keyup("backspace", (e) => {
|
|
3542
|
+
e.inputEvent.preventDefault();
|
|
3543
|
+
if (!node.value || utils.isPage(node.value))
|
|
3544
|
+
return;
|
|
3545
|
+
services?.editorService.remove(node.value);
|
|
3546
|
+
}).keydown([ctrl, "c"], () => {
|
|
3547
|
+
node.value && services?.editorService.copy(node.value);
|
|
3548
|
+
}).keydown([ctrl, "v"], () => {
|
|
3549
|
+
node.value && services?.editorService.paste();
|
|
3550
|
+
}).keydown([ctrl, "x"], () => {
|
|
3551
|
+
if (!node.value || utils.isPage(node.value))
|
|
3552
|
+
return;
|
|
3553
|
+
services?.editorService.copy(node.value);
|
|
3554
|
+
services?.editorService.remove(node.value);
|
|
3555
|
+
}).keydown([ctrl, "z"], () => {
|
|
3556
|
+
services?.editorService.undo();
|
|
3557
|
+
}).keydown([ctrl, "shift", "z"], () => {
|
|
3558
|
+
services?.editorService.redo();
|
|
3559
|
+
}).keydown("up", () => {
|
|
3560
|
+
services?.editorService.move(0, -1);
|
|
3561
|
+
}).keydown("down", () => {
|
|
3562
|
+
services?.editorService.move(0, 1);
|
|
3563
|
+
}).keydown("left", () => {
|
|
3564
|
+
services?.editorService.move(-1, 0);
|
|
3565
|
+
}).keydown("right", () => {
|
|
3566
|
+
services?.editorService.move(1, 0);
|
|
3567
|
+
}).keydown([ctrl, "up"], () => {
|
|
3568
|
+
services?.editorService.move(0, -10);
|
|
3569
|
+
}).keydown([ctrl, "down"], () => {
|
|
3570
|
+
services?.editorService.move(0, 10);
|
|
3571
|
+
}).keydown([ctrl, "left"], () => {
|
|
3572
|
+
services?.editorService.move(-10, 0);
|
|
3573
|
+
}).keydown([ctrl, "right"], () => {
|
|
3574
|
+
services?.editorService.move(10, 0);
|
|
3575
|
+
}).keydown("tab", () => {
|
|
3576
|
+
services?.editorService.selectNextNode();
|
|
3577
|
+
}).keydown([ctrl, "tab"], () => {
|
|
3578
|
+
services?.editorService.selectNextPage();
|
|
3579
|
+
}).keydown([ctrl, "="], () => {
|
|
3580
|
+
services?.uiService.zoom(0.1);
|
|
3581
|
+
}).keydown([ctrl, "numpadplus"], () => {
|
|
3582
|
+
services?.uiService.zoom(0.1);
|
|
3583
|
+
}).keydown([ctrl, "-"], () => {
|
|
3584
|
+
services?.uiService.zoom(-0.1);
|
|
3585
|
+
}).keydown([ctrl, "numpad-"], () => {
|
|
3586
|
+
services?.uiService.zoom(-0.1);
|
|
3587
|
+
});
|
|
3588
|
+
});
|
|
3589
|
+
vue.onUnmounted(() => {
|
|
3590
|
+
workspace.value?.removeEventListener("mouseenter", mouseenterHandler);
|
|
3591
|
+
workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
|
|
3592
|
+
keycon.destroy();
|
|
3593
|
+
});
|
|
4158
3594
|
return {
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
services?.editorService.select(el.id);
|
|
4162
|
-
},
|
|
4163
|
-
updateNodeHandler(node) {
|
|
4164
|
-
services?.editorService.update(node);
|
|
4165
|
-
},
|
|
4166
|
-
sortNodeHandler(ev) {
|
|
4167
|
-
services?.editorService.sort(ev.src, ev.dist);
|
|
4168
|
-
}
|
|
3595
|
+
workspace,
|
|
3596
|
+
page: vue.computed(() => services?.editorService.get("page"))
|
|
4169
3597
|
};
|
|
4170
3598
|
}
|
|
4171
3599
|
});
|
|
4172
|
-
const _hoisted_1 = {
|
|
3600
|
+
const _hoisted_1 = {
|
|
3601
|
+
class: "m-editor-workspace",
|
|
3602
|
+
tabindex: "1",
|
|
3603
|
+
ref: "workspace"
|
|
3604
|
+
};
|
|
4173
3605
|
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4174
3606
|
const _component_magic_stage = vue.resolveComponent("magic-stage");
|
|
4175
3607
|
const _component_page_bar = vue.resolveComponent("page-bar");
|
|
@@ -4179,11 +3611,8 @@
|
|
|
4179
3611
|
"runtime-url": _ctx.runtimeUrl,
|
|
4180
3612
|
render: _ctx.render,
|
|
4181
3613
|
"moveable-options": _ctx.moveableOptions,
|
|
4182
|
-
"can-select": _ctx.canSelect
|
|
4183
|
-
|
|
4184
|
-
onUpdate: _ctx.updateNodeHandler,
|
|
4185
|
-
onSort: _ctx.sortNodeHandler
|
|
4186
|
-
}, null, 8, ["runtime-url", "render", "moveable-options", "can-select", "onSelect", "onUpdate", "onSort"])),
|
|
3614
|
+
"can-select": _ctx.canSelect
|
|
3615
|
+
}, null, 8, ["runtime-url", "render", "moveable-options", "can-select"])),
|
|
4187
3616
|
vue.renderSlot(_ctx.$slots, "workspace-content"),
|
|
4188
3617
|
vue.createVNode(_component_page_bar, null, {
|
|
4189
3618
|
"page-bar-title": vue.withCtx(({ page }) => [
|
|
@@ -4194,16 +3623,16 @@
|
|
|
4194
3623
|
]),
|
|
4195
3624
|
_: 3
|
|
4196
3625
|
})
|
|
4197
|
-
]);
|
|
3626
|
+
], 512);
|
|
4198
3627
|
}
|
|
4199
3628
|
var Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
4200
3629
|
|
|
4201
3630
|
class ComponentList extends BaseService {
|
|
4202
|
-
state = vue.reactive({
|
|
4203
|
-
list: []
|
|
4204
|
-
});
|
|
4205
3631
|
constructor() {
|
|
4206
3632
|
super([]);
|
|
3633
|
+
this.state = vue.reactive({
|
|
3634
|
+
list: []
|
|
3635
|
+
});
|
|
4207
3636
|
}
|
|
4208
3637
|
setList(componentGroupList) {
|
|
4209
3638
|
this.state.list = componentGroupList;
|
|
@@ -4214,6 +3643,14 @@
|
|
|
4214
3643
|
}
|
|
4215
3644
|
var componentListService = new ComponentList();
|
|
4216
3645
|
|
|
3646
|
+
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
3647
|
+
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
3648
|
+
const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
|
|
3649
|
+
const defaultColumnWidth = {
|
|
3650
|
+
left: DEFAULT_LEFT_COLUMN_WIDTH,
|
|
3651
|
+
center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
|
|
3652
|
+
right: DEFAULT_RIGHT_COLUMN_WIDTH
|
|
3653
|
+
};
|
|
4217
3654
|
const state = vue.reactive({
|
|
4218
3655
|
uiSelectMode: false,
|
|
4219
3656
|
showSrc: false,
|
|
@@ -4226,13 +3663,10 @@
|
|
|
4226
3663
|
width: 375,
|
|
4227
3664
|
height: 817
|
|
4228
3665
|
},
|
|
4229
|
-
columnWidth:
|
|
4230
|
-
left: 310,
|
|
4231
|
-
center: globalThis.document.body.clientWidth - 310 - 400,
|
|
4232
|
-
right: 400
|
|
4233
|
-
},
|
|
3666
|
+
columnWidth: defaultColumnWidth,
|
|
4234
3667
|
showGuides: true,
|
|
4235
|
-
showRule: true
|
|
3668
|
+
showRule: true,
|
|
3669
|
+
propsPanelSize: "small"
|
|
4236
3670
|
});
|
|
4237
3671
|
class Ui extends BaseService {
|
|
4238
3672
|
constructor() {
|
|
@@ -4242,6 +3676,15 @@
|
|
|
4242
3676
|
center: "auto"
|
|
4243
3677
|
});
|
|
4244
3678
|
});
|
|
3679
|
+
const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
|
|
3680
|
+
if (columnWidthCacheData) {
|
|
3681
|
+
try {
|
|
3682
|
+
const columnWidthCache = JSON.parse(columnWidthCacheData);
|
|
3683
|
+
this.setColumnWidth(columnWidthCache);
|
|
3684
|
+
} catch (e) {
|
|
3685
|
+
console.error(e);
|
|
3686
|
+
}
|
|
3687
|
+
}
|
|
4245
3688
|
}
|
|
4246
3689
|
set(name, value) {
|
|
4247
3690
|
const mask = editorService.get("stage")?.mask;
|
|
@@ -4267,6 +3710,11 @@
|
|
|
4267
3710
|
get(name) {
|
|
4268
3711
|
return state[name];
|
|
4269
3712
|
}
|
|
3713
|
+
zoom(zoom) {
|
|
3714
|
+
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
3715
|
+
if (this.get("zoom") < 0.1)
|
|
3716
|
+
this.set("zoom", 0.1);
|
|
3717
|
+
}
|
|
4270
3718
|
setColumnWidth({ left, center, right }) {
|
|
4271
3719
|
const columnWidth = {
|
|
4272
3720
|
...vue.toRaw(this.get("columnWidth"))
|
|
@@ -4280,9 +3728,15 @@
|
|
|
4280
3728
|
if (!center || center === "auto") {
|
|
4281
3729
|
const bodyWidth = globalThis.document.body.clientWidth;
|
|
4282
3730
|
columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
|
|
3731
|
+
if (columnWidth.center <= 0) {
|
|
3732
|
+
columnWidth.left = defaultColumnWidth.left;
|
|
3733
|
+
columnWidth.center = defaultColumnWidth.center;
|
|
3734
|
+
columnWidth.right = defaultColumnWidth.right;
|
|
3735
|
+
}
|
|
4283
3736
|
} else {
|
|
4284
3737
|
columnWidth.center = center;
|
|
4285
3738
|
}
|
|
3739
|
+
globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
|
|
4286
3740
|
state.columnWidth = columnWidth;
|
|
4287
3741
|
}
|
|
4288
3742
|
setStageRect(value) {
|
|
@@ -4358,6 +3812,10 @@
|
|
|
4358
3812
|
},
|
|
4359
3813
|
stageRect: {
|
|
4360
3814
|
type: [String, Object]
|
|
3815
|
+
},
|
|
3816
|
+
codeOptions: {
|
|
3817
|
+
type: Object,
|
|
3818
|
+
default: () => ({})
|
|
4361
3819
|
}
|
|
4362
3820
|
},
|
|
4363
3821
|
emits: ["props-panel-mounted", "update:modelValue"],
|
|
@@ -4416,7 +3874,7 @@
|
|
|
4416
3874
|
const _component_workspace = vue.resolveComponent("workspace");
|
|
4417
3875
|
const _component_props_panel = vue.resolveComponent("props-panel");
|
|
4418
3876
|
const _component_framework = vue.resolveComponent("framework");
|
|
4419
|
-
return vue.openBlock(), vue.createBlock(_component_framework,
|
|
3877
|
+
return vue.openBlock(), vue.createBlock(_component_framework, { "code-options": _ctx.codeOptions }, {
|
|
4420
3878
|
nav: vue.withCtx(() => [
|
|
4421
3879
|
vue.renderSlot(_ctx.$slots, "nav", { editorService: _ctx.editorService }, () => [
|
|
4422
3880
|
vue.createVNode(_component_nav_menu, { data: _ctx.menu }, null, 8, ["data"])
|
|
@@ -4460,7 +3918,7 @@
|
|
|
4460
3918
|
vue.renderSlot(_ctx.$slots, "empty", { editorService: _ctx.editorService })
|
|
4461
3919
|
]),
|
|
4462
3920
|
_: 3
|
|
4463
|
-
});
|
|
3921
|
+
}, 8, ["code-options"]);
|
|
4464
3922
|
}
|
|
4465
3923
|
var Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
4466
3924
|
|
|
@@ -4491,6 +3949,7 @@
|
|
|
4491
3949
|
exports.PropsPanel = PropsPanel;
|
|
4492
3950
|
exports.TMagicCodeEditor = CodeEditor;
|
|
4493
3951
|
exports.TMagicEditor = Editor;
|
|
3952
|
+
exports.ToolButton = ToolButton;
|
|
4494
3953
|
exports.change2Fixed = change2Fixed;
|
|
4495
3954
|
exports.debug = debug;
|
|
4496
3955
|
exports["default"] = index;
|
|
@@ -4519,8 +3978,7 @@
|
|
|
4519
3978
|
exports.uiService = uiService;
|
|
4520
3979
|
exports.warn = warn;
|
|
4521
3980
|
|
|
4522
|
-
Object.
|
|
4523
|
-
exports[Symbol.toStringTag] = 'Module';
|
|
3981
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4524
3982
|
|
|
4525
3983
|
}));
|
|
4526
3984
|
//# sourceMappingURL=tmagic-editor.umd.js.map
|