@tmagic/editor 1.0.0-beta.9 → 1.0.0-rc.3
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 +814 -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 +766 -0
- package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +532 -0
- package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +604 -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 +68 -36
- package/dist/tmagic-editor.es.js +1431 -2048
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +1431 -2048
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/Editor.vue.d.ts +15 -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 +9 -8
- package/dist/types/src/services/BaseService.d.ts +4 -1
- package/dist/types/src/services/editor.d.ts +5 -2
- 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 +15 -9
- package/dist/types/src/utils/editor.d.ts +4 -3
- package/dist/types/src/utils/polyfills.d.ts +0 -0
- package/package.json +44 -12
- package/src/Editor.vue +10 -1
- package/src/components/ContentMenu.vue +107 -0
- package/src/components/ScrollViewer.vue +1 -1
- package/src/components/ToolButton.vue +69 -30
- package/src/fields/UISelect.vue +14 -6
- package/src/index.ts +2 -0
- 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 +31 -54
- package/src/layouts/sidebar/Sidebar.vue +13 -52
- package/src/layouts/sidebar/TabPane.vue +68 -0
- package/src/layouts/workspace/PageBar.vue +136 -13
- package/src/layouts/workspace/Stage.vue +53 -75
- package/src/layouts/workspace/ViewerMenu.vue +104 -67
- package/src/layouts/workspace/Workspace.vue +111 -22
- package/src/services/BaseService.ts +70 -22
- package/src/services/editor.ts +148 -39
- 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 +1 -0
- package/src/theme/component-list-panel.scss +2 -0
- package/src/theme/content-menu.scss +33 -26
- package/src/theme/layer-panel.scss +2 -1
- package/src/theme/nav-menu.scss +6 -2
- package/src/theme/page-bar.scss +35 -3
- package/src/theme/props-panel.scss +19 -17
- package/src/type.ts +16 -9
- package/src/utils/editor.ts +31 -6
- 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 -979
- package/dist/types/src/layouts/workspace/Stage.vue.d.ts +0 -193
- 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$e
|
|
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
|
}
|
|
@@ -666,7 +747,7 @@
|
|
|
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
752
|
if (utils.isPop(config) && parent?.type === schema.NodeType.PAGE) {
|
|
672
753
|
updatePopId(oldId, config.id, parent);
|
|
@@ -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,16 +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
|
-
highlightNode: null,
|
|
785
|
-
modifiedNodeIds: /* @__PURE__ */ new Map()
|
|
786
|
-
});
|
|
787
874
|
constructor() {
|
|
788
875
|
super([
|
|
789
876
|
"getLayout",
|
|
@@ -796,14 +883,27 @@
|
|
|
796
883
|
"paste",
|
|
797
884
|
"alignCenter",
|
|
798
885
|
"moveLayer",
|
|
886
|
+
"move",
|
|
799
887
|
"undo",
|
|
800
888
|
"redo",
|
|
801
889
|
"highlight"
|
|
802
|
-
]);
|
|
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
|
+
});
|
|
803
902
|
}
|
|
804
903
|
set(name, value) {
|
|
805
904
|
this.state[name] = value;
|
|
806
905
|
if (name === "root") {
|
|
906
|
+
this.state.pageLength = value?.items?.length || 0;
|
|
807
907
|
this.emit("root-change", value);
|
|
808
908
|
}
|
|
809
909
|
}
|
|
@@ -811,7 +911,7 @@
|
|
|
811
911
|
return this.state[name];
|
|
812
912
|
}
|
|
813
913
|
getNodeInfo(id) {
|
|
814
|
-
const root = this.get("root");
|
|
914
|
+
const root = vue.toRaw(this.get("root"));
|
|
815
915
|
if (!root)
|
|
816
916
|
return {};
|
|
817
917
|
if (id === root.id) {
|
|
@@ -842,11 +942,13 @@
|
|
|
842
942
|
const { parent } = this.getNodeInfo(id);
|
|
843
943
|
return parent;
|
|
844
944
|
}
|
|
845
|
-
async getLayout(node) {
|
|
846
|
-
if (node
|
|
847
|
-
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;
|
|
848
950
|
}
|
|
849
|
-
if (!
|
|
951
|
+
if (!parent.style?.position) {
|
|
850
952
|
return Layout.RELATIVE;
|
|
851
953
|
}
|
|
852
954
|
return Layout.ABSOLUTE;
|
|
@@ -861,19 +963,44 @@
|
|
|
861
963
|
} else {
|
|
862
964
|
historyService.empty();
|
|
863
965
|
}
|
|
966
|
+
this.emit("select", node);
|
|
864
967
|
return node;
|
|
865
968
|
}
|
|
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
|
+
}
|
|
866
991
|
highlight(config2) {
|
|
867
992
|
const { node } = this.selectedConfigExceptionHandler(config2);
|
|
868
|
-
const
|
|
869
|
-
if (
|
|
993
|
+
const currentHighlightNode = this.get("highlightNode");
|
|
994
|
+
if (currentHighlightNode === node)
|
|
870
995
|
return;
|
|
871
996
|
this.set("highlightNode", node);
|
|
872
997
|
}
|
|
873
|
-
async add(
|
|
998
|
+
async add(addNode, parent) {
|
|
999
|
+
const { type, ...config2 } = addNode;
|
|
874
1000
|
const curNode = this.get("node");
|
|
875
1001
|
let parentNode;
|
|
876
|
-
|
|
1002
|
+
const isPage2 = type === schema.NodeType.PAGE;
|
|
1003
|
+
if (isPage2) {
|
|
877
1004
|
parentNode = this.get("root");
|
|
878
1005
|
} else if (parent && typeof parent !== "function") {
|
|
879
1006
|
parentNode = parent;
|
|
@@ -884,18 +1011,24 @@
|
|
|
884
1011
|
}
|
|
885
1012
|
if (!parentNode)
|
|
886
1013
|
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
887
|
-
const layout = await this.getLayout(parentNode);
|
|
888
|
-
const newNode = initPosition({ ...vue.toRaw(await propsService.getPropsValue(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"));
|
|
889
1016
|
if ((parentNode?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && newNode.type !== schema.NodeType.PAGE) {
|
|
890
1017
|
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
891
1018
|
}
|
|
892
1019
|
parentNode?.items?.push(newNode);
|
|
893
|
-
|
|
1020
|
+
const stage = this.get("stage");
|
|
1021
|
+
await stage?.add({ config: lodashEs.cloneDeep(newNode), root: lodashEs.cloneDeep(this.get("root")) });
|
|
894
1022
|
await this.select(newNode);
|
|
895
1023
|
this.addModifiedNodeId(newNode.id);
|
|
896
|
-
if (
|
|
1024
|
+
if (!isPage2) {
|
|
897
1025
|
this.pushHistoryState();
|
|
898
1026
|
}
|
|
1027
|
+
stage?.select(newNode.id);
|
|
1028
|
+
if (isPage2) {
|
|
1029
|
+
this.state.pageLength += 1;
|
|
1030
|
+
}
|
|
1031
|
+
this.emit("add", newNode);
|
|
899
1032
|
return newNode;
|
|
900
1033
|
}
|
|
901
1034
|
async remove(node) {
|
|
@@ -911,14 +1044,31 @@
|
|
|
911
1044
|
if (typeof index !== "number" || index === -1)
|
|
912
1045
|
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
913
1046
|
parent.items?.splice(index, 1);
|
|
914
|
-
|
|
1047
|
+
const stage = this.get("stage");
|
|
1048
|
+
stage?.remove({ id: node.id, root: this.get("root") });
|
|
915
1049
|
if (node.type === schema.NodeType.PAGE) {
|
|
916
|
-
|
|
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
|
+
}
|
|
917
1065
|
} else {
|
|
918
1066
|
await this.select(parent);
|
|
1067
|
+
stage?.select(parent.id);
|
|
919
1068
|
}
|
|
920
1069
|
this.addModifiedNodeId(parent.id);
|
|
921
1070
|
this.pushHistoryState();
|
|
1071
|
+
this.emit("remove", node);
|
|
922
1072
|
return node;
|
|
923
1073
|
}
|
|
924
1074
|
async update(config2) {
|
|
@@ -953,7 +1103,7 @@
|
|
|
953
1103
|
newConfig = setLayout(newConfig, newLayout);
|
|
954
1104
|
}
|
|
955
1105
|
parentNodeItems[index] = newConfig;
|
|
956
|
-
if (newConfig.id === this.get("node").id) {
|
|
1106
|
+
if (`${newConfig.id}` === `${this.get("node").id}`) {
|
|
957
1107
|
this.set("node", newConfig);
|
|
958
1108
|
}
|
|
959
1109
|
this.get("stage")?.update({ config: lodashEs.cloneDeep(newConfig), root: this.get("root") });
|
|
@@ -962,6 +1112,7 @@
|
|
|
962
1112
|
}
|
|
963
1113
|
this.addModifiedNodeId(newConfig.id);
|
|
964
1114
|
this.pushHistoryState();
|
|
1115
|
+
this.emit("update", newConfig);
|
|
965
1116
|
return newConfig;
|
|
966
1117
|
}
|
|
967
1118
|
async sort(id1, id2) {
|
|
@@ -1005,7 +1156,7 @@
|
|
|
1005
1156
|
async alignCenter(config2) {
|
|
1006
1157
|
const parent = this.get("parent");
|
|
1007
1158
|
const node = this.get("node");
|
|
1008
|
-
const layout = await this.getLayout(parent);
|
|
1159
|
+
const layout = await this.getLayout(vue.toRaw(parent), vue.toRaw(node));
|
|
1009
1160
|
if (layout === Layout.RELATIVE) {
|
|
1010
1161
|
return;
|
|
1011
1162
|
}
|
|
@@ -1042,6 +1193,26 @@
|
|
|
1042
1193
|
await this.changeHistoryState(value);
|
|
1043
1194
|
return value;
|
|
1044
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
|
+
}
|
|
1045
1216
|
destroy() {
|
|
1046
1217
|
this.removeAllListeners();
|
|
1047
1218
|
this.set("root", null);
|
|
@@ -1074,7 +1245,12 @@
|
|
|
1074
1245
|
this.isHistoryStateChange = true;
|
|
1075
1246
|
await this.update(value.data);
|
|
1076
1247
|
this.set("modifiedNodeIds", value.modifiedNodeIds);
|
|
1077
|
-
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);
|
|
1078
1254
|
}
|
|
1079
1255
|
async toggleFixedPosition(dist, src, root) {
|
|
1080
1256
|
let newConfig = lodashEs.cloneDeep(dist);
|
|
@@ -1266,6 +1442,25 @@
|
|
|
1266
1442
|
defaultValue: "100% 100%"
|
|
1267
1443
|
}
|
|
1268
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
|
+
]
|
|
1269
1464
|
}
|
|
1270
1465
|
]
|
|
1271
1466
|
}
|
|
@@ -1298,7 +1493,7 @@
|
|
|
1298
1493
|
type: "select",
|
|
1299
1494
|
options: (mForm, { model }) => {
|
|
1300
1495
|
const node = editorService.getNodeById(model.to);
|
|
1301
|
-
if (!node)
|
|
1496
|
+
if (!node?.type)
|
|
1302
1497
|
return [];
|
|
1303
1498
|
return eventsService.getMethod(node.type).map((option) => ({
|
|
1304
1499
|
text: option.label,
|
|
@@ -1333,7 +1528,7 @@
|
|
|
1333
1528
|
name: type
|
|
1334
1529
|
});
|
|
1335
1530
|
|
|
1336
|
-
const _sfc_main$
|
|
1531
|
+
const _sfc_main$i = vue.defineComponent({
|
|
1337
1532
|
components: { Plus: icons.Plus },
|
|
1338
1533
|
setup() {
|
|
1339
1534
|
const services = vue.inject("services");
|
|
@@ -1350,14 +1545,14 @@
|
|
|
1350
1545
|
};
|
|
1351
1546
|
}
|
|
1352
1547
|
});
|
|
1353
|
-
const _hoisted_1$
|
|
1354
|
-
const _hoisted_2$
|
|
1355
|
-
const _hoisted_3$
|
|
1356
|
-
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) {
|
|
1357
1552
|
const _component_plus = vue.resolveComponent("plus");
|
|
1358
1553
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
1359
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
1360
|
-
vue.createElementVNode("div", _hoisted_2$
|
|
1554
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
|
|
1555
|
+
vue.createElementVNode("div", _hoisted_2$4, [
|
|
1361
1556
|
vue.createElementVNode("div", {
|
|
1362
1557
|
class: "m-editor-empty-button",
|
|
1363
1558
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
|
|
@@ -1370,1314 +1565,154 @@
|
|
|
1370
1565
|
_: 1
|
|
1371
1566
|
})
|
|
1372
1567
|
]),
|
|
1373
|
-
_hoisted_3$
|
|
1568
|
+
_hoisted_3$2
|
|
1374
1569
|
])
|
|
1375
1570
|
])
|
|
1376
1571
|
]);
|
|
1377
1572
|
}
|
|
1378
|
-
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1379
|
-
|
|
1380
|
-
/*
|
|
1381
|
-
Copyright (c) 2018 Daybrush
|
|
1382
|
-
@name: @daybrush/utils
|
|
1383
|
-
license: MIT
|
|
1384
|
-
author: Daybrush
|
|
1385
|
-
repository: https://github.com/daybrush/utils
|
|
1386
|
-
@version 1.6.0
|
|
1387
|
-
*/
|
|
1388
|
-
/**
|
|
1389
|
-
* get string "object"
|
|
1390
|
-
* @memberof Consts
|
|
1391
|
-
* @example
|
|
1392
|
-
import {OBJECT} from "@daybrush/utils";
|
|
1393
|
-
|
|
1394
|
-
console.log(OBJECT); // "object"
|
|
1395
|
-
*/
|
|
1396
|
-
|
|
1397
|
-
var OBJECT = "object";
|
|
1398
|
-
/**
|
|
1399
|
-
* Check the type that the value is object.
|
|
1400
|
-
* @memberof Utils
|
|
1401
|
-
* @param {string} value - Value to check the type
|
|
1402
|
-
* @return {} true if the type is correct, false otherwise
|
|
1403
|
-
* @example
|
|
1404
|
-
import {isObject} from "@daybrush/utils";
|
|
1405
|
-
|
|
1406
|
-
console.log(isObject({})); // true
|
|
1407
|
-
console.log(isObject(undefined)); // false
|
|
1408
|
-
console.log(isObject("")); // false
|
|
1409
|
-
console.log(isObject(null)); // false
|
|
1410
|
-
*/
|
|
1411
|
-
|
|
1412
|
-
function isObject(value) {
|
|
1413
|
-
return value && typeof value === OBJECT;
|
|
1414
|
-
}
|
|
1415
|
-
/**
|
|
1416
|
-
* Date.now() method
|
|
1417
|
-
* @memberof CrossBrowser
|
|
1418
|
-
* @return {number} milliseconds
|
|
1419
|
-
* @example
|
|
1420
|
-
import {now} from "@daybrush/utils";
|
|
1421
|
-
|
|
1422
|
-
console.log(now()); // 12121324241(milliseconds)
|
|
1423
|
-
*/
|
|
1424
|
-
|
|
1425
|
-
function now() {
|
|
1426
|
-
return Date.now ? Date.now() : new Date().getTime();
|
|
1427
|
-
}
|
|
1428
|
-
/**
|
|
1429
|
-
* Returns the index of the first element in the array that satisfies the provided testing function.
|
|
1430
|
-
* @function
|
|
1431
|
-
* @memberof CrossBrowser
|
|
1432
|
-
* @param - The array `findIndex` was called upon.
|
|
1433
|
-
* @param - A function to execute on each value in the array until the function returns true, indicating that the satisfying element was found.
|
|
1434
|
-
* @param - Returns defaultIndex if not found by the function.
|
|
1435
|
-
* @example
|
|
1436
|
-
import { findIndex } from "@daybrush/utils";
|
|
1437
|
-
|
|
1438
|
-
findIndex([{a: 1}, {a: 2}, {a: 3}, {a: 4}], ({ a }) => a === 2); // 1
|
|
1439
|
-
*/
|
|
1440
|
-
|
|
1441
|
-
function findIndex(arr, callback, defaultIndex) {
|
|
1442
|
-
if (defaultIndex === void 0) {
|
|
1443
|
-
defaultIndex = -1;
|
|
1444
|
-
}
|
|
1573
|
+
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
|
|
1445
1574
|
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1575
|
+
const _sfc_main$h = vue.defineComponent({
|
|
1576
|
+
name: "m-editor-resize",
|
|
1577
|
+
props: {
|
|
1578
|
+
type: {
|
|
1579
|
+
type: String
|
|
1451
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
|
+
};
|
|
1452
1615
|
}
|
|
1453
|
-
|
|
1454
|
-
return defaultIndex;
|
|
1455
|
-
}
|
|
1456
|
-
/**
|
|
1457
|
-
* Sets up a function that will be called whenever the specified event is delivered to the target
|
|
1458
|
-
* @memberof DOM
|
|
1459
|
-
* @param - event target
|
|
1460
|
-
* @param - A case-sensitive string representing the event type to listen for.
|
|
1461
|
-
* @param - The object which receives a notification (an object that implements the Event interface) when an event of the specified type occurs
|
|
1462
|
-
* @param - An options object that specifies characteristics about the event listener.
|
|
1463
|
-
* @example
|
|
1464
|
-
import {addEvent} from "@daybrush/utils";
|
|
1465
|
-
|
|
1466
|
-
addEvent(el, "click", e => {
|
|
1467
|
-
console.log(e);
|
|
1468
1616
|
});
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
el.addEventListener(type, listener, options);
|
|
1473
|
-
}
|
|
1474
|
-
/**
|
|
1475
|
-
* removes from the EventTarget an event listener previously registered with EventTarget.addEventListener()
|
|
1476
|
-
* @memberof DOM
|
|
1477
|
-
* @param - event target
|
|
1478
|
-
* @param - A case-sensitive string representing the event type to listen for.
|
|
1479
|
-
* @param - The EventListener function of the event handler to remove from the event target.
|
|
1480
|
-
* @param - An options object that specifies characteristics about the event listener.
|
|
1481
|
-
* @example
|
|
1482
|
-
import {addEvent, removeEvent} from "@daybrush/utils";
|
|
1483
|
-
const listener = e => {
|
|
1484
|
-
console.log(e);
|
|
1617
|
+
const _hoisted_1$9 = {
|
|
1618
|
+
ref: "target",
|
|
1619
|
+
class: "m-editor-resizer"
|
|
1485
1620
|
};
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
function removeEvent(el, type, listener, options) {
|
|
1491
|
-
el.removeEventListener(type, listener, options);
|
|
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);
|
|
1492
1625
|
}
|
|
1626
|
+
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
|
|
1493
1627
|
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
/*! *****************************************************************************
|
|
1504
|
-
Copyright (c) Microsoft Corporation.
|
|
1505
|
-
|
|
1506
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
1507
|
-
purpose with or without fee is hereby granted.
|
|
1508
|
-
|
|
1509
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1510
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1511
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1512
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1513
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1514
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1515
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
1516
|
-
***************************************************************************** */
|
|
1517
|
-
var __assign$1 = function () {
|
|
1518
|
-
__assign$1 = Object.assign || function __assign(t) {
|
|
1519
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1520
|
-
s = arguments[i];
|
|
1521
|
-
|
|
1522
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
1628
|
+
const _sfc_main$g = vue.defineComponent({
|
|
1629
|
+
components: {
|
|
1630
|
+
AddPageBox,
|
|
1631
|
+
Resizer
|
|
1632
|
+
},
|
|
1633
|
+
props: {
|
|
1634
|
+
codeOptions: {
|
|
1635
|
+
type: Object,
|
|
1636
|
+
default: () => ({})
|
|
1523
1637
|
}
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
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);
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
};
|
|
1655
|
+
}
|
|
1656
|
+
});
|
|
1657
|
+
const _hoisted_1$8 = { class: "m-editor" };
|
|
1658
|
+
const _hoisted_2$3 = {
|
|
1659
|
+
key: 1,
|
|
1660
|
+
class: "m-editor-content"
|
|
1529
1661
|
};
|
|
1530
|
-
function
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
return
|
|
1662
|
+
function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1663
|
+
const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
|
|
1664
|
+
const _component_resizer = vue.resolveComponent("resizer");
|
|
1665
|
+
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
|
|
1666
|
+
const _component_add_page_box = vue.resolveComponent("add-page-box");
|
|
1667
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
|
|
1668
|
+
vue.renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
1669
|
+
_ctx.showSrc ? (vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
|
|
1670
|
+
key: 0,
|
|
1671
|
+
class: "m-editor-content",
|
|
1672
|
+
"init-values": _ctx.root,
|
|
1673
|
+
options: _ctx.codeOptions,
|
|
1674
|
+
onSave: _ctx.saveCode
|
|
1675
|
+
}, null, 8, ["init-values", "options", "onSave"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$3, [
|
|
1676
|
+
vue.createElementVNode("div", {
|
|
1677
|
+
class: "m-editor-framework-left",
|
|
1678
|
+
style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.left}px`)
|
|
1679
|
+
}, [
|
|
1680
|
+
vue.renderSlot(_ctx.$slots, "sidebar")
|
|
1681
|
+
], 4),
|
|
1682
|
+
vue.createVNode(_component_resizer, { type: "left" }),
|
|
1683
|
+
_ctx.pageLength > 0 ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
|
|
1684
|
+
vue.createElementVNode("div", {
|
|
1685
|
+
class: "m-editor-framework-center",
|
|
1686
|
+
style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.center}px`)
|
|
1687
|
+
}, [
|
|
1688
|
+
vue.renderSlot(_ctx.$slots, "workspace")
|
|
1689
|
+
], 4),
|
|
1690
|
+
vue.createVNode(_component_resizer, { type: "right" }),
|
|
1691
|
+
vue.createElementVNode("div", {
|
|
1692
|
+
class: "m-editor-framework-right",
|
|
1693
|
+
style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.right}px`)
|
|
1694
|
+
}, [
|
|
1695
|
+
vue.createVNode(_component_el_scrollbar, null, {
|
|
1696
|
+
default: vue.withCtx(() => [
|
|
1697
|
+
vue.renderSlot(_ctx.$slots, "propsPanel")
|
|
1698
|
+
]),
|
|
1699
|
+
_: 3
|
|
1700
|
+
})
|
|
1701
|
+
], 4)
|
|
1702
|
+
], 64)) : vue.renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
|
|
1703
|
+
vue.createVNode(_component_add_page_box)
|
|
1704
|
+
])
|
|
1705
|
+
]))
|
|
1706
|
+
]);
|
|
1536
1707
|
}
|
|
1708
|
+
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
|
|
1537
1709
|
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
function () {
|
|
1545
|
-
function EventEmitter() {
|
|
1546
|
-
this._events = {};
|
|
1547
|
-
}
|
|
1548
|
-
/**
|
|
1549
|
-
* Add a listener to the registered event.
|
|
1550
|
-
* @param - Name of the event to be added
|
|
1551
|
-
* @param - listener function of the event to be added
|
|
1552
|
-
* @example
|
|
1553
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1554
|
-
* cosnt emitter = new EventEmitter();
|
|
1555
|
-
*
|
|
1556
|
-
* // Add listener in "a" event
|
|
1557
|
-
* emitter.on("a", () => {
|
|
1558
|
-
* });
|
|
1559
|
-
* // Add listeners
|
|
1560
|
-
* emitter.on({
|
|
1561
|
-
* a: () => {},
|
|
1562
|
-
* b: () => {},
|
|
1563
|
-
* });
|
|
1564
|
-
*/
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
var __proto = EventEmitter.prototype;
|
|
1568
|
-
|
|
1569
|
-
__proto.on = function (eventName, listener) {
|
|
1570
|
-
if (isObject(eventName)) {
|
|
1571
|
-
for (var name in eventName) {
|
|
1572
|
-
this.on(name, eventName[name]);
|
|
1573
|
-
}
|
|
1574
|
-
} else {
|
|
1575
|
-
this._addEvent(eventName, listener, {});
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1578
|
-
return this;
|
|
1579
|
-
};
|
|
1580
|
-
/**
|
|
1581
|
-
* Remove listeners registered in the event target.
|
|
1582
|
-
* @param - Name of the event to be removed
|
|
1583
|
-
* @param - listener function of the event to be removed
|
|
1584
|
-
* @example
|
|
1585
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1586
|
-
* cosnt emitter = new EventEmitter();
|
|
1587
|
-
*
|
|
1588
|
-
* // Remove all listeners.
|
|
1589
|
-
* emitter.off();
|
|
1590
|
-
*
|
|
1591
|
-
* // Remove all listeners in "A" event.
|
|
1592
|
-
* emitter.off("a");
|
|
1593
|
-
*
|
|
1594
|
-
*
|
|
1595
|
-
* // Remove "listener" listener in "a" event.
|
|
1596
|
-
* emitter.off("a", listener);
|
|
1597
|
-
*/
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
__proto.off = function (eventName, listener) {
|
|
1601
|
-
if (!eventName) {
|
|
1602
|
-
this._events = {};
|
|
1603
|
-
} else if (isObject(eventName)) {
|
|
1604
|
-
for (var name in eventName) {
|
|
1605
|
-
this.off(name);
|
|
1606
|
-
}
|
|
1607
|
-
} else if (!listener) {
|
|
1608
|
-
this._events[eventName] = [];
|
|
1609
|
-
} else {
|
|
1610
|
-
var events = this._events[eventName];
|
|
1611
|
-
|
|
1612
|
-
if (events) {
|
|
1613
|
-
var index = findIndex(events, function (e) {
|
|
1614
|
-
return e.listener === listener;
|
|
1615
|
-
});
|
|
1616
|
-
|
|
1617
|
-
if (index > -1) {
|
|
1618
|
-
events.splice(index, 1);
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1623
|
-
return this;
|
|
1624
|
-
};
|
|
1625
|
-
/**
|
|
1626
|
-
* Add a disposable listener and Use promise to the registered event.
|
|
1627
|
-
* @param - Name of the event to be added
|
|
1628
|
-
* @param - disposable listener function of the event to be added
|
|
1629
|
-
* @example
|
|
1630
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1631
|
-
* cosnt emitter = new EventEmitter();
|
|
1632
|
-
*
|
|
1633
|
-
* // Add a disposable listener in "a" event
|
|
1634
|
-
* emitter.once("a", () => {
|
|
1635
|
-
* });
|
|
1636
|
-
*
|
|
1637
|
-
* // Use Promise
|
|
1638
|
-
* emitter.once("a").then(e => {
|
|
1639
|
-
* });
|
|
1640
|
-
*/
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
__proto.once = function (eventName, listener) {
|
|
1644
|
-
var _this = this;
|
|
1645
|
-
|
|
1646
|
-
if (listener) {
|
|
1647
|
-
this._addEvent(eventName, listener, {
|
|
1648
|
-
once: true
|
|
1649
|
-
});
|
|
1650
|
-
}
|
|
1651
|
-
|
|
1652
|
-
return new Promise(function (resolve) {
|
|
1653
|
-
_this._addEvent(eventName, resolve, {
|
|
1654
|
-
once: true
|
|
1655
|
-
});
|
|
1656
|
-
});
|
|
1657
|
-
};
|
|
1658
|
-
/**
|
|
1659
|
-
* Fires an event to call listeners.
|
|
1660
|
-
* @param - Event name
|
|
1661
|
-
* @param - Event parameter
|
|
1662
|
-
* @return If false, stop the event.
|
|
1663
|
-
* @example
|
|
1664
|
-
*
|
|
1665
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1666
|
-
*
|
|
1667
|
-
*
|
|
1668
|
-
* const emitter = new EventEmitter();
|
|
1669
|
-
*
|
|
1670
|
-
* emitter.on("a", e => {
|
|
1671
|
-
* });
|
|
1672
|
-
*
|
|
1673
|
-
*
|
|
1674
|
-
* emitter.emit("a", {
|
|
1675
|
-
* a: 1,
|
|
1676
|
-
* });
|
|
1677
|
-
*/
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
__proto.emit = function (eventName, param) {
|
|
1681
|
-
var _this = this;
|
|
1682
|
-
|
|
1683
|
-
if (param === void 0) {
|
|
1684
|
-
param = {};
|
|
1685
|
-
}
|
|
1686
|
-
|
|
1687
|
-
var events = this._events[eventName];
|
|
1688
|
-
|
|
1689
|
-
if (!eventName || !events) {
|
|
1690
|
-
return true;
|
|
1691
|
-
}
|
|
1692
|
-
|
|
1693
|
-
var isStop = false;
|
|
1694
|
-
param.eventType = eventName;
|
|
1695
|
-
|
|
1696
|
-
param.stop = function () {
|
|
1697
|
-
isStop = true;
|
|
1698
|
-
};
|
|
1699
|
-
|
|
1700
|
-
param.currentTarget = this;
|
|
1701
|
-
|
|
1702
|
-
__spreadArrays(events).forEach(function (info) {
|
|
1703
|
-
info.listener(param);
|
|
1704
|
-
|
|
1705
|
-
if (info.once) {
|
|
1706
|
-
_this.off(eventName, info.listener);
|
|
1707
|
-
}
|
|
1708
|
-
});
|
|
1709
|
-
|
|
1710
|
-
return !isStop;
|
|
1711
|
-
};
|
|
1712
|
-
/**
|
|
1713
|
-
* Fires an event to call listeners.
|
|
1714
|
-
* @param - Event name
|
|
1715
|
-
* @param - Event parameter
|
|
1716
|
-
* @return If false, stop the event.
|
|
1717
|
-
* @example
|
|
1718
|
-
*
|
|
1719
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1720
|
-
*
|
|
1721
|
-
*
|
|
1722
|
-
* const emitter = new EventEmitter();
|
|
1723
|
-
*
|
|
1724
|
-
* emitter.on("a", e => {
|
|
1725
|
-
* });
|
|
1726
|
-
*
|
|
1727
|
-
*
|
|
1728
|
-
* emitter.emit("a", {
|
|
1729
|
-
* a: 1,
|
|
1730
|
-
* });
|
|
1731
|
-
*/
|
|
1732
|
-
|
|
1733
|
-
/**
|
|
1734
|
-
* Fires an event to call listeners.
|
|
1735
|
-
* @param - Event name
|
|
1736
|
-
* @param - Event parameter
|
|
1737
|
-
* @return If false, stop the event.
|
|
1738
|
-
* @example
|
|
1739
|
-
*
|
|
1740
|
-
* import EventEmitter from "@scena/event-emitter";
|
|
1741
|
-
*
|
|
1742
|
-
*
|
|
1743
|
-
* const emitter = new EventEmitter();
|
|
1744
|
-
*
|
|
1745
|
-
* emitter.on("a", e => {
|
|
1746
|
-
* });
|
|
1747
|
-
*
|
|
1748
|
-
* // emit
|
|
1749
|
-
* emitter.trigger("a", {
|
|
1750
|
-
* a: 1,
|
|
1751
|
-
* });
|
|
1752
|
-
*/
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
__proto.trigger = function (eventName, param) {
|
|
1756
|
-
if (param === void 0) {
|
|
1757
|
-
param = {};
|
|
1758
|
-
}
|
|
1759
|
-
|
|
1760
|
-
return this.emit(eventName, param);
|
|
1761
|
-
};
|
|
1762
|
-
|
|
1763
|
-
__proto._addEvent = function (eventName, listener, options) {
|
|
1764
|
-
var events = this._events;
|
|
1765
|
-
events[eventName] = events[eventName] || [];
|
|
1766
|
-
var listeners = events[eventName];
|
|
1767
|
-
listeners.push(__assign$1({
|
|
1768
|
-
listener: listener
|
|
1769
|
-
}, options));
|
|
1770
|
-
};
|
|
1771
|
-
|
|
1772
|
-
return EventEmitter;
|
|
1773
|
-
}();
|
|
1774
|
-
|
|
1775
|
-
var EventEmitter$1 = EventEmitter;
|
|
1776
|
-
|
|
1777
|
-
/*
|
|
1778
|
-
Copyright (c) 2019 Daybrush
|
|
1779
|
-
name: gesto
|
|
1780
|
-
license: MIT
|
|
1781
|
-
author: Daybrush
|
|
1782
|
-
repository: git+https://github.com/daybrush/gesture.git
|
|
1783
|
-
version: 1.5.0
|
|
1784
|
-
*/
|
|
1785
|
-
|
|
1786
|
-
/*! *****************************************************************************
|
|
1787
|
-
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1788
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
1789
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
1790
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1791
|
-
|
|
1792
|
-
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
1793
|
-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
1794
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
1795
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
1796
|
-
|
|
1797
|
-
See the Apache Version 2.0 License for specific language governing permissions
|
|
1798
|
-
and limitations under the License.
|
|
1799
|
-
***************************************************************************** */
|
|
1800
|
-
|
|
1801
|
-
/* global Reflect, Promise */
|
|
1802
|
-
var extendStatics = function (d, b) {
|
|
1803
|
-
extendStatics = Object.setPrototypeOf || {
|
|
1804
|
-
__proto__: []
|
|
1805
|
-
} instanceof Array && function (d, b) {
|
|
1806
|
-
d.__proto__ = b;
|
|
1807
|
-
} || function (d, b) {
|
|
1808
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
1809
|
-
};
|
|
1810
|
-
|
|
1811
|
-
return extendStatics(d, b);
|
|
1812
|
-
};
|
|
1813
|
-
|
|
1814
|
-
function __extends(d, b) {
|
|
1815
|
-
extendStatics(d, b);
|
|
1816
|
-
|
|
1817
|
-
function __() {
|
|
1818
|
-
this.constructor = d;
|
|
1819
|
-
}
|
|
1820
|
-
|
|
1821
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1822
|
-
}
|
|
1823
|
-
var __assign = function () {
|
|
1824
|
-
__assign = Object.assign || function __assign(t) {
|
|
1825
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1826
|
-
s = arguments[i];
|
|
1827
|
-
|
|
1828
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
1829
|
-
}
|
|
1830
|
-
|
|
1831
|
-
return t;
|
|
1832
|
-
};
|
|
1833
|
-
|
|
1834
|
-
return __assign.apply(this, arguments);
|
|
1835
|
-
};
|
|
1836
|
-
|
|
1837
|
-
function getRad(pos1, pos2) {
|
|
1838
|
-
var distX = pos2[0] - pos1[0];
|
|
1839
|
-
var distY = pos2[1] - pos1[1];
|
|
1840
|
-
var rad = Math.atan2(distY, distX);
|
|
1841
|
-
return rad >= 0 ? rad : rad + Math.PI * 2;
|
|
1842
|
-
}
|
|
1843
|
-
function getRotatiion(touches) {
|
|
1844
|
-
return getRad([touches[0].clientX, touches[0].clientY], [touches[1].clientX, touches[1].clientY]) / Math.PI * 180;
|
|
1845
|
-
}
|
|
1846
|
-
function isMultiTouch(e) {
|
|
1847
|
-
return e.touches && e.touches.length >= 2;
|
|
1848
|
-
}
|
|
1849
|
-
function getEventClients(e) {
|
|
1850
|
-
if (e.touches) {
|
|
1851
|
-
return getClients(e.touches);
|
|
1852
|
-
} else {
|
|
1853
|
-
return [getClient(e)];
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
function getPosition(clients, prevClients, startClients) {
|
|
1857
|
-
var length = startClients.length;
|
|
1858
|
-
|
|
1859
|
-
var _a = getAverageClient(clients, length),
|
|
1860
|
-
clientX = _a.clientX,
|
|
1861
|
-
clientY = _a.clientY,
|
|
1862
|
-
originalClientX = _a.originalClientX,
|
|
1863
|
-
originalClientY = _a.originalClientY;
|
|
1864
|
-
|
|
1865
|
-
var _b = getAverageClient(prevClients, length),
|
|
1866
|
-
prevX = _b.clientX,
|
|
1867
|
-
prevY = _b.clientY;
|
|
1868
|
-
|
|
1869
|
-
var _c = getAverageClient(startClients, length),
|
|
1870
|
-
startX = _c.clientX,
|
|
1871
|
-
startY = _c.clientY;
|
|
1872
|
-
|
|
1873
|
-
var deltaX = clientX - prevX;
|
|
1874
|
-
var deltaY = clientY - prevY;
|
|
1875
|
-
var distX = clientX - startX;
|
|
1876
|
-
var distY = clientY - startY;
|
|
1877
|
-
return {
|
|
1878
|
-
clientX: originalClientX,
|
|
1879
|
-
clientY: originalClientY,
|
|
1880
|
-
deltaX: deltaX,
|
|
1881
|
-
deltaY: deltaY,
|
|
1882
|
-
distX: distX,
|
|
1883
|
-
distY: distY
|
|
1884
|
-
};
|
|
1885
|
-
}
|
|
1886
|
-
function getDist(clients) {
|
|
1887
|
-
return Math.sqrt(Math.pow(clients[0].clientX - clients[1].clientX, 2) + Math.pow(clients[0].clientY - clients[1].clientY, 2));
|
|
1888
|
-
}
|
|
1889
|
-
function getClients(touches) {
|
|
1890
|
-
var length = Math.min(touches.length, 2);
|
|
1891
|
-
var clients = [];
|
|
1892
|
-
|
|
1893
|
-
for (var i = 0; i < length; ++i) {
|
|
1894
|
-
clients.push(getClient(touches[i]));
|
|
1895
|
-
}
|
|
1896
|
-
|
|
1897
|
-
return clients;
|
|
1898
|
-
}
|
|
1899
|
-
function getClient(e) {
|
|
1900
|
-
return {
|
|
1901
|
-
clientX: e.clientX,
|
|
1902
|
-
clientY: e.clientY
|
|
1903
|
-
};
|
|
1904
|
-
}
|
|
1905
|
-
function getAverageClient(clients, length) {
|
|
1906
|
-
if (length === void 0) {
|
|
1907
|
-
length = clients.length;
|
|
1908
|
-
}
|
|
1909
|
-
|
|
1910
|
-
var sumClient = {
|
|
1911
|
-
clientX: 0,
|
|
1912
|
-
clientY: 0,
|
|
1913
|
-
originalClientX: 0,
|
|
1914
|
-
originalClientY: 0
|
|
1915
|
-
};
|
|
1916
|
-
|
|
1917
|
-
for (var i = 0; i < length; ++i) {
|
|
1918
|
-
var client = clients[i];
|
|
1919
|
-
sumClient.originalClientX += "originalClientX" in client ? client.originalClientX : client.clientX;
|
|
1920
|
-
sumClient.originalClientY += "originalClientY" in client ? client.originalClientY : client.clientY;
|
|
1921
|
-
sumClient.clientX += client.clientX;
|
|
1922
|
-
sumClient.clientY += client.clientY;
|
|
1923
|
-
}
|
|
1924
|
-
|
|
1925
|
-
if (!length) {
|
|
1926
|
-
return sumClient;
|
|
1927
|
-
}
|
|
1928
|
-
|
|
1929
|
-
return {
|
|
1930
|
-
clientX: sumClient.clientX / length,
|
|
1931
|
-
clientY: sumClient.clientY / length,
|
|
1932
|
-
originalClientX: sumClient.originalClientX / length,
|
|
1933
|
-
originalClientY: sumClient.originalClientY / length
|
|
1934
|
-
};
|
|
1935
|
-
}
|
|
1936
|
-
|
|
1937
|
-
var ClientStore =
|
|
1938
|
-
/*#__PURE__*/
|
|
1939
|
-
function () {
|
|
1940
|
-
function ClientStore(clients) {
|
|
1941
|
-
this.prevClients = [];
|
|
1942
|
-
this.startClients = [];
|
|
1943
|
-
this.movement = 0;
|
|
1944
|
-
this.length = 0;
|
|
1945
|
-
this.startClients = clients;
|
|
1946
|
-
this.prevClients = clients;
|
|
1947
|
-
this.length = clients.length;
|
|
1948
|
-
}
|
|
1949
|
-
|
|
1950
|
-
var __proto = ClientStore.prototype;
|
|
1951
|
-
|
|
1952
|
-
__proto.addClients = function (clients) {
|
|
1953
|
-
if (clients === void 0) {
|
|
1954
|
-
clients = this.prevClients;
|
|
1955
|
-
}
|
|
1956
|
-
|
|
1957
|
-
var position = this.getPosition(clients);
|
|
1958
|
-
var deltaX = position.deltaX,
|
|
1959
|
-
deltaY = position.deltaY;
|
|
1960
|
-
this.movement += Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
1961
|
-
this.prevClients = clients;
|
|
1962
|
-
return position;
|
|
1963
|
-
};
|
|
1964
|
-
|
|
1965
|
-
__proto.getAngle = function (clients) {
|
|
1966
|
-
if (clients === void 0) {
|
|
1967
|
-
clients = this.prevClients;
|
|
1968
|
-
}
|
|
1969
|
-
|
|
1970
|
-
return getRotatiion(clients);
|
|
1971
|
-
};
|
|
1972
|
-
|
|
1973
|
-
__proto.getRotation = function (clients) {
|
|
1974
|
-
if (clients === void 0) {
|
|
1975
|
-
clients = this.prevClients;
|
|
1976
|
-
}
|
|
1977
|
-
|
|
1978
|
-
return getRotatiion(clients) - getRotatiion(this.startClients);
|
|
1979
|
-
};
|
|
1980
|
-
|
|
1981
|
-
__proto.getPosition = function (clients) {
|
|
1982
|
-
return getPosition(clients || this.prevClients, this.prevClients, this.startClients);
|
|
1983
|
-
};
|
|
1984
|
-
|
|
1985
|
-
__proto.getPositions = function (clients) {
|
|
1986
|
-
if (clients === void 0) {
|
|
1987
|
-
clients = this.prevClients;
|
|
1988
|
-
}
|
|
1989
|
-
|
|
1990
|
-
var prevClients = this.prevClients;
|
|
1991
|
-
return this.startClients.map(function (startClient, i) {
|
|
1992
|
-
return getPosition([clients[i]], [prevClients[i]], [startClient]);
|
|
1993
|
-
});
|
|
1994
|
-
};
|
|
1995
|
-
|
|
1996
|
-
__proto.getMovement = function (clients) {
|
|
1997
|
-
var movement = this.movement;
|
|
1998
|
-
|
|
1999
|
-
if (!clients) {
|
|
2000
|
-
return movement;
|
|
2001
|
-
}
|
|
2002
|
-
|
|
2003
|
-
var currentClient = getAverageClient(clients, this.length);
|
|
2004
|
-
var prevClient = getAverageClient(this.prevClients, this.length);
|
|
2005
|
-
var deltaX = currentClient.clientX - prevClient.clientX;
|
|
2006
|
-
var deltaY = currentClient.clientY - prevClient.clientY;
|
|
2007
|
-
return Math.sqrt(deltaX * deltaX + deltaY * deltaY) + movement;
|
|
2008
|
-
};
|
|
2009
|
-
|
|
2010
|
-
__proto.getDistance = function (clients) {
|
|
2011
|
-
if (clients === void 0) {
|
|
2012
|
-
clients = this.prevClients;
|
|
2013
|
-
}
|
|
2014
|
-
|
|
2015
|
-
return getDist(clients);
|
|
2016
|
-
};
|
|
2017
|
-
|
|
2018
|
-
__proto.getScale = function (clients) {
|
|
2019
|
-
if (clients === void 0) {
|
|
2020
|
-
clients = this.prevClients;
|
|
2021
|
-
}
|
|
2022
|
-
|
|
2023
|
-
return getDist(clients) / getDist(this.startClients);
|
|
2024
|
-
};
|
|
2025
|
-
|
|
2026
|
-
__proto.move = function (deltaX, deltaY) {
|
|
2027
|
-
this.startClients.forEach(function (client) {
|
|
2028
|
-
client.clientX -= deltaX;
|
|
2029
|
-
client.clientY -= deltaY;
|
|
2030
|
-
});
|
|
2031
|
-
this.prevClients.forEach(function (client) {
|
|
2032
|
-
client.clientX -= deltaX;
|
|
2033
|
-
client.clientY -= deltaY;
|
|
2034
|
-
});
|
|
2035
|
-
};
|
|
2036
|
-
|
|
2037
|
-
return ClientStore;
|
|
2038
|
-
}();
|
|
2039
|
-
|
|
2040
|
-
var INPUT_TAGNAMES = ["textarea", "input"];
|
|
2041
|
-
/**
|
|
2042
|
-
* You can set up drag, pinch events in any browser.
|
|
2043
|
-
*/
|
|
2044
|
-
|
|
2045
|
-
var Gesto =
|
|
2046
|
-
/*#__PURE__*/
|
|
2047
|
-
function (_super) {
|
|
2048
|
-
__extends(Gesto, _super);
|
|
2049
|
-
/**
|
|
2050
|
-
*
|
|
2051
|
-
*/
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
function Gesto(targets, options) {
|
|
2055
|
-
if (options === void 0) {
|
|
2056
|
-
options = {};
|
|
2057
|
-
}
|
|
2058
|
-
|
|
2059
|
-
var _this = _super.call(this) || this;
|
|
2060
|
-
|
|
2061
|
-
_this.options = {};
|
|
2062
|
-
_this.flag = false;
|
|
2063
|
-
_this.pinchFlag = false;
|
|
2064
|
-
_this.datas = {};
|
|
2065
|
-
_this.isDrag = false;
|
|
2066
|
-
_this.isPinch = false;
|
|
2067
|
-
_this.isMouse = false;
|
|
2068
|
-
_this.isTouch = false;
|
|
2069
|
-
_this.clientStores = [];
|
|
2070
|
-
_this.targets = [];
|
|
2071
|
-
_this.prevTime = 0;
|
|
2072
|
-
_this.doubleFlag = false;
|
|
2073
|
-
|
|
2074
|
-
_this.onDragStart = function (e, isTrusted) {
|
|
2075
|
-
if (isTrusted === void 0) {
|
|
2076
|
-
isTrusted = true;
|
|
2077
|
-
}
|
|
2078
|
-
|
|
2079
|
-
if (!_this.flag && e.cancelable === false) {
|
|
2080
|
-
return;
|
|
2081
|
-
}
|
|
2082
|
-
|
|
2083
|
-
var _a = _this.options,
|
|
2084
|
-
container = _a.container,
|
|
2085
|
-
pinchOutside = _a.pinchOutside,
|
|
2086
|
-
preventRightClick = _a.preventRightClick,
|
|
2087
|
-
preventDefault = _a.preventDefault,
|
|
2088
|
-
checkInput = _a.checkInput;
|
|
2089
|
-
var isTouch = _this.isTouch;
|
|
2090
|
-
var isDragStart = !_this.flag;
|
|
2091
|
-
|
|
2092
|
-
if (isDragStart) {
|
|
2093
|
-
var activeElement = document.activeElement;
|
|
2094
|
-
var target = e.target;
|
|
2095
|
-
var tagName = target.tagName.toLowerCase();
|
|
2096
|
-
var hasInput = INPUT_TAGNAMES.indexOf(tagName) > -1;
|
|
2097
|
-
var hasContentEditable = target.isContentEditable;
|
|
2098
|
-
|
|
2099
|
-
if (hasInput || hasContentEditable) {
|
|
2100
|
-
if (checkInput || activeElement === target) {
|
|
2101
|
-
// force false or already focused.
|
|
2102
|
-
return false;
|
|
2103
|
-
}
|
|
2104
|
-
|
|
2105
|
-
if (activeElement && hasContentEditable && activeElement.isContentEditable && activeElement.contains(target)) {
|
|
2106
|
-
return false;
|
|
2107
|
-
}
|
|
2108
|
-
} else if ((preventDefault || e.type === "touchstart") && activeElement) {
|
|
2109
|
-
var activeTagName = activeElement.tagName;
|
|
2110
|
-
|
|
2111
|
-
if (activeElement.isContentEditable || INPUT_TAGNAMES.indexOf(activeTagName) > -1) {
|
|
2112
|
-
activeElement.blur();
|
|
2113
|
-
}
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
|
-
_this.clientStores = [new ClientStore(getEventClients(e))];
|
|
2117
|
-
_this.flag = true;
|
|
2118
|
-
_this.isDrag = false;
|
|
2119
|
-
_this.datas = {};
|
|
2120
|
-
|
|
2121
|
-
if (preventRightClick && (e.which === 3 || e.button === 2)) {
|
|
2122
|
-
_this.initDrag();
|
|
2123
|
-
|
|
2124
|
-
return false;
|
|
2125
|
-
}
|
|
2126
|
-
|
|
2127
|
-
_this.doubleFlag = now() - _this.prevTime < 200;
|
|
2128
|
-
|
|
2129
|
-
var result = _this.emit("dragStart", __assign({
|
|
2130
|
-
datas: _this.datas,
|
|
2131
|
-
inputEvent: e,
|
|
2132
|
-
isTrusted: isTrusted,
|
|
2133
|
-
isDouble: _this.doubleFlag
|
|
2134
|
-
}, _this.getCurrentStore().getPosition()));
|
|
2135
|
-
|
|
2136
|
-
if (result === false) {
|
|
2137
|
-
_this.initDrag();
|
|
2138
|
-
}
|
|
2139
|
-
|
|
2140
|
-
_this.flag && preventDefault && e.preventDefault();
|
|
2141
|
-
}
|
|
2142
|
-
|
|
2143
|
-
if (!_this.flag) {
|
|
2144
|
-
return false;
|
|
2145
|
-
}
|
|
2146
|
-
|
|
2147
|
-
var timer = 0;
|
|
2148
|
-
|
|
2149
|
-
if (isDragStart && isTouch && pinchOutside) {
|
|
2150
|
-
timer = setTimeout(function () {
|
|
2151
|
-
addEvent(container, "touchstart", _this.onDragStart, {
|
|
2152
|
-
passive: false
|
|
2153
|
-
});
|
|
2154
|
-
});
|
|
2155
|
-
}
|
|
2156
|
-
|
|
2157
|
-
if (!isDragStart && isTouch && pinchOutside) {
|
|
2158
|
-
removeEvent(container, "touchstart", _this.onDragStart);
|
|
2159
|
-
}
|
|
2160
|
-
|
|
2161
|
-
if (_this.flag && isMultiTouch(e)) {
|
|
2162
|
-
clearTimeout(timer);
|
|
2163
|
-
|
|
2164
|
-
if (isDragStart && e.touches.length !== e.changedTouches.length) {
|
|
2165
|
-
return;
|
|
2166
|
-
}
|
|
2167
|
-
|
|
2168
|
-
if (!_this.pinchFlag) {
|
|
2169
|
-
_this.onPinchStart(e);
|
|
2170
|
-
}
|
|
2171
|
-
}
|
|
2172
|
-
};
|
|
2173
|
-
|
|
2174
|
-
_this.onDrag = function (e, isScroll) {
|
|
2175
|
-
if (!_this.flag) {
|
|
2176
|
-
return;
|
|
2177
|
-
}
|
|
2178
|
-
|
|
2179
|
-
var clients = getEventClients(e);
|
|
2180
|
-
|
|
2181
|
-
var result = _this.moveClients(clients, e, false);
|
|
2182
|
-
|
|
2183
|
-
if (_this.pinchFlag || result.deltaX || result.deltaY) {
|
|
2184
|
-
var dragResult = _this.emit("drag", __assign({}, result, {
|
|
2185
|
-
isScroll: !!isScroll,
|
|
2186
|
-
inputEvent: e
|
|
2187
|
-
}));
|
|
2188
|
-
|
|
2189
|
-
if (dragResult === false) {
|
|
2190
|
-
_this.stop();
|
|
2191
|
-
|
|
2192
|
-
return;
|
|
2193
|
-
}
|
|
2194
|
-
}
|
|
2195
|
-
|
|
2196
|
-
if (_this.pinchFlag) {
|
|
2197
|
-
_this.onPinch(e, clients);
|
|
2198
|
-
}
|
|
2199
|
-
|
|
2200
|
-
_this.getCurrentStore().addClients(clients);
|
|
2201
|
-
};
|
|
2202
|
-
|
|
2203
|
-
_this.onDragEnd = function (e) {
|
|
2204
|
-
if (!_this.flag) {
|
|
2205
|
-
return;
|
|
2206
|
-
}
|
|
2207
|
-
|
|
2208
|
-
var _a = _this.options,
|
|
2209
|
-
pinchOutside = _a.pinchOutside,
|
|
2210
|
-
container = _a.container;
|
|
2211
|
-
|
|
2212
|
-
if (_this.isTouch && pinchOutside) {
|
|
2213
|
-
removeEvent(container, "touchstart", _this.onDragStart);
|
|
2214
|
-
}
|
|
2215
|
-
|
|
2216
|
-
_this.flag = false;
|
|
2217
|
-
|
|
2218
|
-
var position = _this.getCurrentStore().getPosition();
|
|
2219
|
-
|
|
2220
|
-
var currentTime = now();
|
|
2221
|
-
var isDouble = !_this.isDrag && _this.doubleFlag;
|
|
2222
|
-
_this.prevTime = _this.isDrag || isDouble ? 0 : currentTime;
|
|
2223
|
-
|
|
2224
|
-
_this.emit("dragEnd", __assign({
|
|
2225
|
-
datas: _this.datas,
|
|
2226
|
-
isDouble: isDouble,
|
|
2227
|
-
isDrag: _this.isDrag,
|
|
2228
|
-
isClick: !_this.isDrag,
|
|
2229
|
-
inputEvent: e
|
|
2230
|
-
}, position));
|
|
2231
|
-
|
|
2232
|
-
if (_this.pinchFlag) {
|
|
2233
|
-
_this.onPinchEnd(e);
|
|
2234
|
-
}
|
|
2235
|
-
|
|
2236
|
-
_this.clientStores = [];
|
|
2237
|
-
};
|
|
2238
|
-
|
|
2239
|
-
_this.onBlur = function () {
|
|
2240
|
-
_this.onDragEnd();
|
|
2241
|
-
};
|
|
2242
|
-
|
|
2243
|
-
var elements = [].concat(targets);
|
|
2244
|
-
_this.options = __assign({
|
|
2245
|
-
checkInput: false,
|
|
2246
|
-
container: elements.length > 1 ? window : elements[0],
|
|
2247
|
-
preventRightClick: true,
|
|
2248
|
-
preventDefault: true,
|
|
2249
|
-
checkWindowBlur: false,
|
|
2250
|
-
pinchThreshold: 0,
|
|
2251
|
-
events: ["touch", "mouse"]
|
|
2252
|
-
}, options);
|
|
2253
|
-
var _a = _this.options,
|
|
2254
|
-
container = _a.container,
|
|
2255
|
-
events = _a.events,
|
|
2256
|
-
checkWindowBlur = _a.checkWindowBlur;
|
|
2257
|
-
_this.isTouch = events.indexOf("touch") > -1;
|
|
2258
|
-
_this.isMouse = events.indexOf("mouse") > -1;
|
|
2259
|
-
_this.targets = elements;
|
|
2260
|
-
|
|
2261
|
-
if (_this.isMouse) {
|
|
2262
|
-
elements.forEach(function (el) {
|
|
2263
|
-
addEvent(el, "mousedown", _this.onDragStart);
|
|
2264
|
-
});
|
|
2265
|
-
addEvent(container, "mousemove", _this.onDrag);
|
|
2266
|
-
addEvent(container, "mouseup", _this.onDragEnd);
|
|
2267
|
-
addEvent(container, "contextmenu", _this.onDragEnd);
|
|
2268
|
-
}
|
|
2269
|
-
|
|
2270
|
-
if (checkWindowBlur) {
|
|
2271
|
-
addEvent(window, "blur", _this.onBlur);
|
|
2272
|
-
}
|
|
2273
|
-
|
|
2274
|
-
if (_this.isTouch) {
|
|
2275
|
-
var passive_1 = {
|
|
2276
|
-
passive: false
|
|
2277
|
-
};
|
|
2278
|
-
elements.forEach(function (el) {
|
|
2279
|
-
addEvent(el, "touchstart", _this.onDragStart, passive_1);
|
|
2280
|
-
});
|
|
2281
|
-
addEvent(container, "touchmove", _this.onDrag, passive_1);
|
|
2282
|
-
addEvent(container, "touchend", _this.onDragEnd, passive_1);
|
|
2283
|
-
addEvent(container, "touchcancel", _this.onDragEnd, passive_1);
|
|
2284
|
-
}
|
|
2285
|
-
|
|
2286
|
-
return _this;
|
|
2287
|
-
}
|
|
2288
|
-
/**
|
|
2289
|
-
* Stop Gesto's drag events.
|
|
2290
|
-
*/
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
var __proto = Gesto.prototype;
|
|
2294
|
-
|
|
2295
|
-
__proto.stop = function () {
|
|
2296
|
-
this.isDrag = false;
|
|
2297
|
-
this.flag = false;
|
|
2298
|
-
this.clientStores = [];
|
|
2299
|
-
this.datas = {};
|
|
2300
|
-
};
|
|
2301
|
-
/**
|
|
2302
|
-
* The total moved distance
|
|
2303
|
-
*/
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
__proto.getMovement = function (clients) {
|
|
2307
|
-
return this.getCurrentStore().getMovement(clients) + this.clientStores.slice(1).reduce(function (prev, cur) {
|
|
2308
|
-
return prev + cur.movement;
|
|
2309
|
-
}, 0);
|
|
2310
|
-
};
|
|
2311
|
-
/**
|
|
2312
|
-
* Whether to drag
|
|
2313
|
-
*/
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
__proto.isDragging = function () {
|
|
2317
|
-
return this.isDrag;
|
|
2318
|
-
};
|
|
2319
|
-
/**
|
|
2320
|
-
* Whether to start drag
|
|
2321
|
-
*/
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
__proto.isFlag = function () {
|
|
2325
|
-
return this.flag;
|
|
2326
|
-
};
|
|
2327
|
-
/**
|
|
2328
|
-
* Whether to start pinch
|
|
2329
|
-
*/
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
__proto.isPinchFlag = function () {
|
|
2333
|
-
return this.pinchFlag;
|
|
2334
|
-
};
|
|
2335
|
-
/**
|
|
2336
|
-
* Whether to start double click
|
|
2337
|
-
*/
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
__proto.isDoubleFlag = function () {
|
|
2341
|
-
return this.doubleFlag;
|
|
2342
|
-
};
|
|
2343
|
-
/**
|
|
2344
|
-
* Whether to pinch
|
|
2345
|
-
*/
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
__proto.isPinching = function () {
|
|
2349
|
-
return this.isPinch;
|
|
2350
|
-
};
|
|
2351
|
-
/**
|
|
2352
|
-
* If a scroll event occurs, it is corrected by the scroll distance.
|
|
2353
|
-
*/
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
__proto.scrollBy = function (deltaX, deltaY, e, isCallDrag) {
|
|
2357
|
-
if (isCallDrag === void 0) {
|
|
2358
|
-
isCallDrag = true;
|
|
2359
|
-
}
|
|
2360
|
-
|
|
2361
|
-
if (!this.flag) {
|
|
2362
|
-
return;
|
|
2363
|
-
}
|
|
2364
|
-
|
|
2365
|
-
this.clientStores[0].move(deltaX, deltaY);
|
|
2366
|
-
isCallDrag && this.onDrag(e, true);
|
|
2367
|
-
};
|
|
2368
|
-
/**
|
|
2369
|
-
* Create a virtual drag event.
|
|
2370
|
-
*/
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
__proto.move = function (_a, inputEvent) {
|
|
2374
|
-
var deltaX = _a[0],
|
|
2375
|
-
deltaY = _a[1];
|
|
2376
|
-
var store = this.getCurrentStore();
|
|
2377
|
-
var nextClients = store.prevClients;
|
|
2378
|
-
return this.moveClients(nextClients.map(function (_a) {
|
|
2379
|
-
var clientX = _a.clientX,
|
|
2380
|
-
clientY = _a.clientY;
|
|
2381
|
-
return {
|
|
2382
|
-
clientX: clientX + deltaX,
|
|
2383
|
-
clientY: clientY + deltaY,
|
|
2384
|
-
originalClientX: clientX,
|
|
2385
|
-
originalClientY: clientY
|
|
2386
|
-
};
|
|
2387
|
-
}), inputEvent, true);
|
|
2388
|
-
};
|
|
2389
|
-
/**
|
|
2390
|
-
* The dragStart event is triggered by an external event.
|
|
2391
|
-
*/
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
__proto.triggerDragStart = function (e) {
|
|
2395
|
-
this.onDragStart(e, false);
|
|
2396
|
-
};
|
|
2397
|
-
/**
|
|
2398
|
-
* Set the event data while dragging.
|
|
2399
|
-
*/
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
__proto.setEventDatas = function (datas) {
|
|
2403
|
-
var currentDatas = this.datas;
|
|
2404
|
-
|
|
2405
|
-
for (var name in datas) {
|
|
2406
|
-
currentDatas[name] = datas[name];
|
|
2407
|
-
}
|
|
2408
|
-
|
|
2409
|
-
return this;
|
|
2410
|
-
};
|
|
2411
|
-
/**
|
|
2412
|
-
* Set the event data while dragging.
|
|
2413
|
-
*/
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
__proto.getEventDatas = function () {
|
|
2417
|
-
return this.datas;
|
|
2418
|
-
};
|
|
2419
|
-
/**
|
|
2420
|
-
* Unset Gesto
|
|
2421
|
-
*/
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
__proto.unset = function () {
|
|
2425
|
-
var _this = this;
|
|
2426
|
-
|
|
2427
|
-
var targets = this.targets;
|
|
2428
|
-
var container = this.options.container;
|
|
2429
|
-
this.off();
|
|
2430
|
-
removeEvent(window, "blur", this.onBlur);
|
|
2431
|
-
|
|
2432
|
-
if (this.isMouse) {
|
|
2433
|
-
targets.forEach(function (target) {
|
|
2434
|
-
removeEvent(target, "mousedown", _this.onDragStart);
|
|
2435
|
-
});
|
|
2436
|
-
removeEvent(container, "mousemove", this.onDrag);
|
|
2437
|
-
removeEvent(container, "mouseup", this.onDragEnd);
|
|
2438
|
-
removeEvent(container, "contextmenu", this.onDragEnd);
|
|
2439
|
-
}
|
|
2440
|
-
|
|
2441
|
-
if (this.isTouch) {
|
|
2442
|
-
targets.forEach(function (target) {
|
|
2443
|
-
removeEvent(target, "touchstart", _this.onDragStart);
|
|
2444
|
-
});
|
|
2445
|
-
removeEvent(container, "touchstart", this.onDragStart);
|
|
2446
|
-
removeEvent(container, "touchmove", this.onDrag);
|
|
2447
|
-
removeEvent(container, "touchend", this.onDragEnd);
|
|
2448
|
-
removeEvent(container, "touchcancel", this.onDragEnd);
|
|
2449
|
-
}
|
|
2450
|
-
};
|
|
2451
|
-
|
|
2452
|
-
__proto.onPinchStart = function (e) {
|
|
2453
|
-
var pinchThreshold = this.options.pinchThreshold;
|
|
2454
|
-
|
|
2455
|
-
if (this.isDrag && this.getMovement() > pinchThreshold) {
|
|
2456
|
-
return;
|
|
2457
|
-
}
|
|
2458
|
-
|
|
2459
|
-
var store = new ClientStore(getEventClients(e));
|
|
2460
|
-
this.pinchFlag = true;
|
|
2461
|
-
this.clientStores.splice(0, 0, store);
|
|
2462
|
-
var result = this.emit("pinchStart", __assign({
|
|
2463
|
-
datas: this.datas,
|
|
2464
|
-
angle: store.getAngle(),
|
|
2465
|
-
touches: this.getCurrentStore().getPositions()
|
|
2466
|
-
}, store.getPosition(), {
|
|
2467
|
-
inputEvent: e
|
|
2468
|
-
}));
|
|
2469
|
-
|
|
2470
|
-
if (result === false) {
|
|
2471
|
-
this.pinchFlag = false;
|
|
2472
|
-
}
|
|
2473
|
-
};
|
|
2474
|
-
|
|
2475
|
-
__proto.onPinch = function (e, clients) {
|
|
2476
|
-
if (!this.flag || !this.pinchFlag || clients.length < 2) {
|
|
2477
|
-
return;
|
|
2478
|
-
}
|
|
2479
|
-
|
|
2480
|
-
var store = this.getCurrentStore();
|
|
2481
|
-
this.isPinch = true;
|
|
2482
|
-
this.emit("pinch", __assign({
|
|
2483
|
-
datas: this.datas,
|
|
2484
|
-
movement: this.getMovement(clients),
|
|
2485
|
-
angle: store.getAngle(clients),
|
|
2486
|
-
rotation: store.getRotation(clients),
|
|
2487
|
-
touches: store.getPositions(clients),
|
|
2488
|
-
scale: store.getScale(clients),
|
|
2489
|
-
distance: store.getDistance(clients)
|
|
2490
|
-
}, store.getPosition(clients), {
|
|
2491
|
-
inputEvent: e
|
|
2492
|
-
}));
|
|
2493
|
-
};
|
|
2494
|
-
|
|
2495
|
-
__proto.onPinchEnd = function (e) {
|
|
2496
|
-
if (!this.pinchFlag) {
|
|
2497
|
-
return;
|
|
2498
|
-
}
|
|
2499
|
-
|
|
2500
|
-
var isPinch = this.isPinch;
|
|
2501
|
-
this.isPinch = false;
|
|
2502
|
-
this.pinchFlag = false;
|
|
2503
|
-
var store = this.getCurrentStore();
|
|
2504
|
-
this.emit("pinchEnd", __assign({
|
|
2505
|
-
datas: this.datas,
|
|
2506
|
-
isPinch: isPinch,
|
|
2507
|
-
touches: store.getPositions()
|
|
2508
|
-
}, store.getPosition(), {
|
|
2509
|
-
inputEvent: e
|
|
2510
|
-
}));
|
|
2511
|
-
this.isPinch = false;
|
|
2512
|
-
this.pinchFlag = false;
|
|
2513
|
-
};
|
|
2514
|
-
|
|
2515
|
-
__proto.initDrag = function () {
|
|
2516
|
-
this.clientStores = [];
|
|
2517
|
-
this.pinchFlag = false;
|
|
2518
|
-
this.doubleFlag = false;
|
|
2519
|
-
this.prevTime = 0;
|
|
2520
|
-
this.flag = false;
|
|
2521
|
-
};
|
|
2522
|
-
|
|
2523
|
-
__proto.getCurrentStore = function () {
|
|
2524
|
-
return this.clientStores[0];
|
|
2525
|
-
};
|
|
2526
|
-
|
|
2527
|
-
__proto.moveClients = function (clients, inputEvent, isAdd) {
|
|
2528
|
-
var store = this.getCurrentStore();
|
|
2529
|
-
var position = store[isAdd ? "addClients" : "getPosition"](clients);
|
|
2530
|
-
this.isDrag = true;
|
|
2531
|
-
return __assign({
|
|
2532
|
-
datas: this.datas
|
|
2533
|
-
}, position, {
|
|
2534
|
-
movement: this.getMovement(clients),
|
|
2535
|
-
isDrag: this.isDrag,
|
|
2536
|
-
isPinch: this.isPinch,
|
|
2537
|
-
isScroll: false,
|
|
2538
|
-
inputEvent: inputEvent
|
|
2539
|
-
});
|
|
2540
|
-
};
|
|
2541
|
-
|
|
2542
|
-
return Gesto;
|
|
2543
|
-
}(EventEmitter$1);
|
|
2544
|
-
|
|
2545
|
-
var Gesto$1 = Gesto;
|
|
2546
|
-
|
|
2547
|
-
const _sfc_main$f = vue.defineComponent({
|
|
2548
|
-
name: "m-editor-resize",
|
|
2549
|
-
props: {
|
|
2550
|
-
type: {
|
|
2551
|
-
type: String
|
|
2552
|
-
}
|
|
2553
|
-
},
|
|
2554
|
-
setup(props) {
|
|
2555
|
-
const services = vue.inject("services");
|
|
2556
|
-
const target = vue.ref();
|
|
2557
|
-
let getso;
|
|
2558
|
-
vue.onMounted(() => {
|
|
2559
|
-
if (!target.value)
|
|
2560
|
-
return;
|
|
2561
|
-
getso = new Gesto$1(target.value, {
|
|
2562
|
-
container: window,
|
|
2563
|
-
pinchOutside: true
|
|
2564
|
-
}).on("drag", (e) => {
|
|
2565
|
-
if (!target.value || !services)
|
|
2566
|
-
return;
|
|
2567
|
-
let { left, right } = {
|
|
2568
|
-
...vue.toRaw(services.uiService.get("columnWidth"))
|
|
2569
|
-
};
|
|
2570
|
-
if (props.type === "left") {
|
|
2571
|
-
left += e.deltaX;
|
|
2572
|
-
} else if (props.type === "right") {
|
|
2573
|
-
right -= e.deltaX;
|
|
2574
|
-
}
|
|
2575
|
-
services.uiService.set("columnWidth", {
|
|
2576
|
-
left,
|
|
2577
|
-
right
|
|
2578
|
-
});
|
|
2579
|
-
});
|
|
2580
|
-
});
|
|
2581
|
-
vue.onUnmounted(() => {
|
|
2582
|
-
getso?.unset();
|
|
2583
|
-
});
|
|
2584
|
-
return {
|
|
2585
|
-
target
|
|
2586
|
-
};
|
|
2587
|
-
}
|
|
2588
|
-
});
|
|
2589
|
-
const _hoisted_1$b = {
|
|
2590
|
-
ref: "target",
|
|
2591
|
-
class: "m-editor-resizer"
|
|
2592
|
-
};
|
|
2593
|
-
function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2594
|
-
return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$b, [
|
|
2595
|
-
vue.renderSlot(_ctx.$slots, "default")
|
|
2596
|
-
], 512);
|
|
2597
|
-
}
|
|
2598
|
-
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
|
|
2599
|
-
|
|
2600
|
-
const _sfc_main$e = vue.defineComponent({
|
|
2601
|
-
components: {
|
|
2602
|
-
AddPageBox,
|
|
2603
|
-
Resizer
|
|
2604
|
-
},
|
|
2605
|
-
setup() {
|
|
2606
|
-
const services = vue.inject("services");
|
|
2607
|
-
const root = vue.computed(() => services?.editorService.get("root"));
|
|
2608
|
-
return {
|
|
2609
|
-
root,
|
|
2610
|
-
pageLength: vue.computed(() => root.value?.items?.length || 0),
|
|
2611
|
-
showSrc: vue.computed(() => services?.uiService.get("showSrc")),
|
|
2612
|
-
columnWidth: vue.computed(() => services?.uiService.get("columnWidth")),
|
|
2613
|
-
saveCode(value) {
|
|
2614
|
-
try {
|
|
2615
|
-
services?.editorService.set("root", eval(value));
|
|
2616
|
-
} catch (e) {
|
|
2617
|
-
console.error(e);
|
|
2618
|
-
}
|
|
2619
|
-
}
|
|
2620
|
-
};
|
|
2621
|
-
}
|
|
2622
|
-
});
|
|
2623
|
-
const _hoisted_1$a = { class: "m-editor" };
|
|
2624
|
-
const _hoisted_2$5 = {
|
|
2625
|
-
key: 1,
|
|
2626
|
-
class: "m-editor-content"
|
|
2627
|
-
};
|
|
2628
|
-
function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2629
|
-
const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
|
|
2630
|
-
const _component_resizer = vue.resolveComponent("resizer");
|
|
2631
|
-
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
|
|
2632
|
-
const _component_add_page_box = vue.resolveComponent("add-page-box");
|
|
2633
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
|
|
2634
|
-
vue.renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
2635
|
-
_ctx.showSrc ? (vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
|
|
2636
|
-
key: 0,
|
|
2637
|
-
class: "m-editor-content",
|
|
2638
|
-
"init-values": _ctx.root,
|
|
2639
|
-
onSave: _ctx.saveCode
|
|
2640
|
-
}, null, 8, ["init-values", "onSave"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$5, [
|
|
2641
|
-
vue.createElementVNode("div", {
|
|
2642
|
-
class: "m-editor-framework-left",
|
|
2643
|
-
style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.left}px`)
|
|
2644
|
-
}, [
|
|
2645
|
-
vue.renderSlot(_ctx.$slots, "sidebar")
|
|
2646
|
-
], 4),
|
|
2647
|
-
vue.createVNode(_component_resizer, { type: "left" }),
|
|
2648
|
-
_ctx.pageLength > 0 ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
|
|
2649
|
-
vue.createElementVNode("div", {
|
|
2650
|
-
class: "m-editor-framework-center",
|
|
2651
|
-
style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.center}px`)
|
|
2652
|
-
}, [
|
|
2653
|
-
vue.renderSlot(_ctx.$slots, "workspace")
|
|
2654
|
-
], 4),
|
|
2655
|
-
vue.createVNode(_component_resizer, { type: "right" }),
|
|
2656
|
-
vue.createElementVNode("div", {
|
|
2657
|
-
class: "m-editor-framework-right",
|
|
2658
|
-
style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.right}px`)
|
|
2659
|
-
}, [
|
|
2660
|
-
vue.createVNode(_component_el_scrollbar, null, {
|
|
2661
|
-
default: vue.withCtx(() => [
|
|
2662
|
-
vue.renderSlot(_ctx.$slots, "propsPanel")
|
|
2663
|
-
]),
|
|
2664
|
-
_: 3
|
|
2665
|
-
})
|
|
2666
|
-
], 4)
|
|
2667
|
-
], 64)) : vue.renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
|
|
2668
|
-
vue.createVNode(_component_add_page_box)
|
|
2669
|
-
])
|
|
2670
|
-
]))
|
|
2671
|
-
]);
|
|
2672
|
-
}
|
|
2673
|
-
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
|
|
2674
|
-
|
|
2675
|
-
const _sfc_main$d = vue.defineComponent({
|
|
2676
|
-
name: "m-icon",
|
|
2677
|
-
components: { Edit: icons.Edit },
|
|
2678
|
-
props: {
|
|
2679
|
-
icon: {
|
|
2680
|
-
type: [String, Object]
|
|
1710
|
+
const _sfc_main$f = vue.defineComponent({
|
|
1711
|
+
name: "m-icon",
|
|
1712
|
+
components: { Edit: icons.Edit },
|
|
1713
|
+
props: {
|
|
1714
|
+
icon: {
|
|
1715
|
+
type: [String, Object]
|
|
2681
1716
|
}
|
|
2682
1717
|
},
|
|
2683
1718
|
setup() {
|
|
@@ -2686,8 +1721,8 @@
|
|
|
2686
1721
|
};
|
|
2687
1722
|
}
|
|
2688
1723
|
});
|
|
2689
|
-
const _hoisted_1$
|
|
2690
|
-
function _sfc_render$
|
|
1724
|
+
const _hoisted_1$7 = ["src"];
|
|
1725
|
+
function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2691
1726
|
const _component_edit = vue.resolveComponent("edit");
|
|
2692
1727
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
2693
1728
|
return !_ctx.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
|
|
@@ -2698,7 +1733,7 @@
|
|
|
2698
1733
|
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.createElementBlock("img", {
|
|
2699
1734
|
key: 1,
|
|
2700
1735
|
src: _ctx.icon
|
|
2701
|
-
}, null, 8, _hoisted_1$
|
|
1736
|
+
}, null, 8, _hoisted_1$7)) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
|
|
2702
1737
|
key: 2,
|
|
2703
1738
|
class: vue.normalizeClass(_ctx.icon)
|
|
2704
1739
|
}, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
|
|
@@ -2708,9 +1743,9 @@
|
|
|
2708
1743
|
_: 1
|
|
2709
1744
|
}));
|
|
2710
1745
|
}
|
|
2711
|
-
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1746
|
+
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
|
|
2712
1747
|
|
|
2713
|
-
const _sfc_main$
|
|
1748
|
+
const _sfc_main$e = vue.defineComponent({
|
|
2714
1749
|
components: { MIcon, ArrowDown: icons.ArrowDown },
|
|
2715
1750
|
props: {
|
|
2716
1751
|
data: {
|
|
@@ -2720,16 +1755,20 @@
|
|
|
2720
1755
|
type: "text",
|
|
2721
1756
|
display: false
|
|
2722
1757
|
})
|
|
1758
|
+
},
|
|
1759
|
+
eventType: {
|
|
1760
|
+
type: String,
|
|
1761
|
+
default: "click"
|
|
2723
1762
|
}
|
|
2724
1763
|
},
|
|
2725
1764
|
setup(props) {
|
|
2726
1765
|
const services = vue.inject("services");
|
|
2727
1766
|
const uiService = services?.uiService;
|
|
2728
|
-
const zoomInHandler = () => uiService?.set("zoom", zoom.value + 0.1);
|
|
2729
|
-
const zoomOutHandler = () => uiService?.set("zoom", zoom.value - 0.1);
|
|
2730
1767
|
const zoom = vue.computed(() => uiService?.get("zoom") ?? 1);
|
|
2731
1768
|
const showGuides = vue.computed(() => uiService?.get("showGuides") ?? true);
|
|
2732
1769
|
const showRule = vue.computed(() => uiService?.get("showRule") ?? true);
|
|
1770
|
+
const zoomInHandler = () => uiService?.zoom(0.1);
|
|
1771
|
+
const zoomOutHandler = () => uiService?.zoom(-0.1);
|
|
2733
1772
|
const item = vue.computed(() => {
|
|
2734
1773
|
if (typeof props.data !== "string") {
|
|
2735
1774
|
return props.data;
|
|
@@ -2746,7 +1785,7 @@
|
|
|
2746
1785
|
case "delete":
|
|
2747
1786
|
return {
|
|
2748
1787
|
type: "button",
|
|
2749
|
-
icon: icons.Delete,
|
|
1788
|
+
icon: vue.markRaw(icons.Delete),
|
|
2750
1789
|
tooltip: "\u522A\u9664",
|
|
2751
1790
|
disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
|
|
2752
1791
|
handler: () => services?.editorService.remove(services?.editorService.get("node"))
|
|
@@ -2754,7 +1793,7 @@
|
|
|
2754
1793
|
case "undo":
|
|
2755
1794
|
return {
|
|
2756
1795
|
type: "button",
|
|
2757
|
-
icon: icons.Back,
|
|
1796
|
+
icon: vue.markRaw(icons.Back),
|
|
2758
1797
|
tooltip: "\u540E\u9000",
|
|
2759
1798
|
disabled: () => !services?.historyService.state.canUndo,
|
|
2760
1799
|
handler: () => services?.editorService.undo()
|
|
@@ -2762,7 +1801,7 @@
|
|
|
2762
1801
|
case "redo":
|
|
2763
1802
|
return {
|
|
2764
1803
|
type: "button",
|
|
2765
|
-
icon: icons.Right,
|
|
1804
|
+
icon: vue.markRaw(icons.Right),
|
|
2766
1805
|
tooltip: "\u524D\u8FDB",
|
|
2767
1806
|
disabled: () => !services?.historyService.state.canRedo,
|
|
2768
1807
|
handler: () => services?.editorService.redo()
|
|
@@ -2770,28 +1809,28 @@
|
|
|
2770
1809
|
case "zoom-in":
|
|
2771
1810
|
return {
|
|
2772
1811
|
type: "button",
|
|
2773
|
-
icon: icons.ZoomIn,
|
|
1812
|
+
icon: vue.markRaw(icons.ZoomIn),
|
|
2774
1813
|
tooltip: "\u653E\u5927",
|
|
2775
1814
|
handler: zoomInHandler
|
|
2776
1815
|
};
|
|
2777
1816
|
case "zoom-out":
|
|
2778
1817
|
return {
|
|
2779
1818
|
type: "button",
|
|
2780
|
-
icon: icons.ZoomOut,
|
|
1819
|
+
icon: vue.markRaw(icons.ZoomOut),
|
|
2781
1820
|
tooltip: "\u7E2E\u5C0F",
|
|
2782
1821
|
handler: zoomOutHandler
|
|
2783
1822
|
};
|
|
2784
1823
|
case "rule":
|
|
2785
1824
|
return {
|
|
2786
1825
|
type: "button",
|
|
2787
|
-
icon: icons.ScaleToOriginal,
|
|
1826
|
+
icon: vue.markRaw(icons.ScaleToOriginal),
|
|
2788
1827
|
tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
|
|
2789
1828
|
handler: () => uiService?.set("showRule", !showRule.value)
|
|
2790
1829
|
};
|
|
2791
1830
|
case "guides":
|
|
2792
1831
|
return {
|
|
2793
1832
|
type: "button",
|
|
2794
|
-
icon: icons.Grid,
|
|
1833
|
+
icon: vue.markRaw(icons.Grid),
|
|
2795
1834
|
tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
|
|
2796
1835
|
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
2797
1836
|
};
|
|
@@ -2812,9 +1851,16 @@
|
|
|
2812
1851
|
}
|
|
2813
1852
|
return item.value.disabled;
|
|
2814
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
|
+
};
|
|
2815
1861
|
return {
|
|
2816
|
-
ZoomIn: icons.ZoomIn,
|
|
2817
|
-
ZoomOut: icons.ZoomOut,
|
|
1862
|
+
ZoomIn: vue.markRaw(icons.ZoomIn),
|
|
1863
|
+
ZoomOut: vue.markRaw(icons.ZoomOut),
|
|
2818
1864
|
item,
|
|
2819
1865
|
zoom,
|
|
2820
1866
|
disabled,
|
|
@@ -2835,31 +1881,42 @@
|
|
|
2835
1881
|
command.item.handler(services);
|
|
2836
1882
|
}
|
|
2837
1883
|
},
|
|
2838
|
-
|
|
2839
|
-
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")
|
|
2840
1900
|
return;
|
|
2841
|
-
if (
|
|
2842
|
-
item2
|
|
1901
|
+
if (item2.type === "button") {
|
|
1902
|
+
buttonHandler(item2, event);
|
|
2843
1903
|
}
|
|
2844
1904
|
}
|
|
2845
1905
|
};
|
|
2846
1906
|
}
|
|
2847
1907
|
});
|
|
2848
|
-
const _hoisted_1$
|
|
2849
|
-
key: 0,
|
|
2850
|
-
class: "menu-item"
|
|
2851
|
-
};
|
|
2852
|
-
const _hoisted_2$4 = {
|
|
1908
|
+
const _hoisted_1$6 = {
|
|
2853
1909
|
key: 1,
|
|
2854
1910
|
class: "menu-item-text"
|
|
2855
1911
|
};
|
|
2856
|
-
const
|
|
1912
|
+
const _hoisted_2$2 = {
|
|
2857
1913
|
class: "menu-item-text",
|
|
2858
1914
|
style: { "margin": "0 5px" }
|
|
2859
1915
|
};
|
|
2860
|
-
const
|
|
2861
|
-
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) {
|
|
2862
1918
|
const _component_el_divider = vue.resolveComponent("el-divider");
|
|
1919
|
+
const _component_tool_button = vue.resolveComponent("tool-button", true);
|
|
2863
1920
|
const _component_m_icon = vue.resolveComponent("m-icon");
|
|
2864
1921
|
const _component_el_button = vue.resolveComponent("el-button");
|
|
2865
1922
|
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
@@ -2868,44 +1925,66 @@
|
|
|
2868
1925
|
const _component_el_dropdown_item = vue.resolveComponent("el-dropdown-item");
|
|
2869
1926
|
const _component_el_dropdown_menu = vue.resolveComponent("el-dropdown-menu");
|
|
2870
1927
|
const _component_el_dropdown = vue.resolveComponent("el-dropdown");
|
|
2871
|
-
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
|
+
}, [
|
|
2872
1935
|
_ctx.item.type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
|
|
2873
1936
|
key: 0,
|
|
2874
|
-
direction: "vertical"
|
|
2875
|
-
})) : _ctx.item.type === "text" ? (vue.openBlock(), vue.createElementBlock("div",
|
|
2876
|
-
vue.createVNode(
|
|
2877
|
-
icon: _ctx.
|
|
2878
|
-
|
|
2879
|
-
}, null, 8, ["
|
|
2880
|
-
vue.createElementVNode("span",
|
|
2881
|
-
vue.createVNode(
|
|
2882
|
-
icon: _ctx.
|
|
2883
|
-
|
|
2884
|
-
}, null, 8, ["
|
|
2885
|
-
], 64)) : _ctx.item.type === "button" ? (vue.openBlock(), vue.
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
vue.
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
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, {
|
|
2909
1988
|
key: 4,
|
|
2910
1989
|
trigger: "click",
|
|
2911
1990
|
disabled: _ctx.disabled,
|
|
@@ -2930,7 +2009,7 @@
|
|
|
2930
2009
|
})) : vue.createCommentVNode("", true)
|
|
2931
2010
|
]),
|
|
2932
2011
|
default: vue.withCtx(() => [
|
|
2933
|
-
vue.createElementVNode("span",
|
|
2012
|
+
vue.createElementVNode("span", _hoisted_3$1, [
|
|
2934
2013
|
vue.createTextVNode(vue.toDisplayString(_ctx.item.text), 1),
|
|
2935
2014
|
vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2936
2015
|
default: vue.withCtx(() => [
|
|
@@ -2942,11 +2021,11 @@
|
|
|
2942
2021
|
]),
|
|
2943
2022
|
_: 1
|
|
2944
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)
|
|
2945
|
-
])) : vue.createCommentVNode("", true);
|
|
2024
|
+
], 34)) : vue.createCommentVNode("", true);
|
|
2946
2025
|
}
|
|
2947
|
-
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2026
|
+
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
|
|
2948
2027
|
|
|
2949
|
-
const _sfc_main$
|
|
2028
|
+
const _sfc_main$d = vue.defineComponent({
|
|
2950
2029
|
name: "nav-menu",
|
|
2951
2030
|
components: { ToolButton },
|
|
2952
2031
|
props: {
|
|
@@ -2966,7 +2045,7 @@
|
|
|
2966
2045
|
};
|
|
2967
2046
|
}
|
|
2968
2047
|
});
|
|
2969
|
-
function _sfc_render$
|
|
2048
|
+
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2970
2049
|
const _component_tool_button = vue.resolveComponent("tool-button");
|
|
2971
2050
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
2972
2051
|
class: "m-editor-nav-menu",
|
|
@@ -2988,9 +2067,9 @@
|
|
|
2988
2067
|
}), 128))
|
|
2989
2068
|
], 4);
|
|
2990
2069
|
}
|
|
2991
|
-
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2070
|
+
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
|
|
2992
2071
|
|
|
2993
|
-
const _sfc_main$
|
|
2072
|
+
const _sfc_main$c = vue.defineComponent({
|
|
2994
2073
|
name: "m-editor-props-panel",
|
|
2995
2074
|
emits: ["mounted"],
|
|
2996
2075
|
setup(props, { emit }) {
|
|
@@ -3005,9 +2084,9 @@
|
|
|
3005
2084
|
curFormConfig.value = [];
|
|
3006
2085
|
return;
|
|
3007
2086
|
}
|
|
3008
|
-
values.value = node.value;
|
|
3009
2087
|
const type = node.value.type || (node.value.items ? "container" : "text");
|
|
3010
2088
|
curFormConfig.value = await services?.propsService.getPropsConfig(type) || [];
|
|
2089
|
+
values.value = node.value;
|
|
3011
2090
|
};
|
|
3012
2091
|
vue.watchEffect(init);
|
|
3013
2092
|
services?.propsService.on("props-configs-change", init);
|
|
@@ -3018,6 +2097,7 @@
|
|
|
3018
2097
|
values,
|
|
3019
2098
|
configForm,
|
|
3020
2099
|
curFormConfig,
|
|
2100
|
+
propsPanelSize: vue.computed(() => services?.uiService.get("propsPanelSize") || "small"),
|
|
3021
2101
|
async submit() {
|
|
3022
2102
|
try {
|
|
3023
2103
|
const values2 = await configForm.value?.submitForm();
|
|
@@ -3036,21 +2116,21 @@
|
|
|
3036
2116
|
};
|
|
3037
2117
|
}
|
|
3038
2118
|
});
|
|
3039
|
-
function _sfc_render$
|
|
2119
|
+
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3040
2120
|
const _component_m_form = vue.resolveComponent("m-form");
|
|
3041
2121
|
return vue.openBlock(), vue.createBlock(_component_m_form, {
|
|
3042
|
-
class:
|
|
3043
|
-
"popper-class":
|
|
2122
|
+
class: vue.normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
|
|
2123
|
+
"popper-class": `m-editor-props-panel-popper ${_ctx.propsPanelSize}`,
|
|
3044
2124
|
ref: "configForm",
|
|
3045
|
-
size:
|
|
2125
|
+
size: _ctx.propsPanelSize,
|
|
3046
2126
|
"init-values": _ctx.values,
|
|
3047
2127
|
config: _ctx.curFormConfig,
|
|
3048
2128
|
onChange: _ctx.submit
|
|
3049
|
-
}, null, 8, ["init-values", "config", "onChange"]);
|
|
2129
|
+
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"]);
|
|
3050
2130
|
}
|
|
3051
|
-
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2131
|
+
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
|
|
3052
2132
|
|
|
3053
|
-
const _sfc_main$
|
|
2133
|
+
const _sfc_main$b = vue.defineComponent({
|
|
3054
2134
|
name: "ui-component-panel",
|
|
3055
2135
|
components: { MIcon },
|
|
3056
2136
|
setup() {
|
|
@@ -3065,19 +2145,29 @@
|
|
|
3065
2145
|
searchText,
|
|
3066
2146
|
collapseValue,
|
|
3067
2147
|
list,
|
|
3068
|
-
appendComponent({ text, type,
|
|
2148
|
+
appendComponent({ text, type, data = {} }) {
|
|
3069
2149
|
services?.editorService.add({
|
|
3070
2150
|
name: text,
|
|
3071
2151
|
type,
|
|
3072
|
-
...
|
|
2152
|
+
...data
|
|
3073
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
|
+
}
|
|
3074
2164
|
}
|
|
3075
2165
|
};
|
|
3076
2166
|
}
|
|
3077
2167
|
});
|
|
3078
|
-
const _hoisted_1$
|
|
3079
|
-
const _hoisted_2$
|
|
3080
|
-
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) {
|
|
3081
2171
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
3082
2172
|
const _component_m_icon = vue.resolveComponent("m-icon");
|
|
3083
2173
|
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
@@ -3107,15 +2197,17 @@
|
|
|
3107
2197
|
name: index
|
|
3108
2198
|
}, {
|
|
3109
2199
|
title: vue.withCtx(() => [
|
|
3110
|
-
_hoisted_1$
|
|
2200
|
+
_hoisted_1$5,
|
|
3111
2201
|
vue.createTextVNode(vue.toDisplayString(group.title), 1)
|
|
3112
2202
|
]),
|
|
3113
2203
|
default: vue.withCtx(() => [
|
|
3114
2204
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(group.items, (item) => {
|
|
3115
2205
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
3116
2206
|
class: "component-item",
|
|
2207
|
+
draggable: "true",
|
|
3117
2208
|
key: item.type,
|
|
3118
|
-
onClick: ($event) => _ctx.appendComponent(item)
|
|
2209
|
+
onClick: ($event) => _ctx.appendComponent(item),
|
|
2210
|
+
onDragstart: ($event) => _ctx.dragstartHandler(item, $event)
|
|
3119
2211
|
}, [
|
|
3120
2212
|
vue.createVNode(_component_m_icon, {
|
|
3121
2213
|
icon: item.icon
|
|
@@ -3130,7 +2222,7 @@
|
|
|
3130
2222
|
]),
|
|
3131
2223
|
_: 2
|
|
3132
2224
|
}, 1032, ["content"])
|
|
3133
|
-
],
|
|
2225
|
+
], 40, _hoisted_2$1);
|
|
3134
2226
|
}), 128))
|
|
3135
2227
|
]),
|
|
3136
2228
|
_: 2
|
|
@@ -3144,133 +2236,211 @@
|
|
|
3144
2236
|
_: 1
|
|
3145
2237
|
});
|
|
3146
2238
|
}
|
|
3147
|
-
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2239
|
+
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
|
|
3148
2240
|
|
|
3149
|
-
const _sfc_main$
|
|
3150
|
-
|
|
2241
|
+
const _sfc_main$a = vue.defineComponent({
|
|
2242
|
+
components: { ToolButton },
|
|
3151
2243
|
props: {
|
|
3152
|
-
|
|
2244
|
+
menuData: {
|
|
3153
2245
|
type: Array,
|
|
3154
2246
|
default: () => []
|
|
3155
2247
|
}
|
|
3156
2248
|
},
|
|
3157
|
-
setup(
|
|
3158
|
-
const
|
|
3159
|
-
const
|
|
3160
|
-
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
|
+
});
|
|
3161
2269
|
return {
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
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;
|
|
3169
2283
|
}
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
services?.editorService.add({
|
|
3175
|
-
name: config.text,
|
|
3176
|
-
type: config.type
|
|
2284
|
+
menuStyle.value = {
|
|
2285
|
+
top: `${top}px`,
|
|
2286
|
+
left: `${e.clientX}px`
|
|
2287
|
+
};
|
|
3177
2288
|
});
|
|
3178
2289
|
},
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
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
|
+
}
|
|
3187
2302
|
}
|
|
3188
2303
|
};
|
|
3189
2304
|
}
|
|
3190
2305
|
});
|
|
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
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
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"]);
|
|
3259
2427
|
}
|
|
3260
|
-
var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2428
|
+
var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
|
|
3261
2429
|
|
|
3262
2430
|
const throttleTime = 150;
|
|
3263
|
-
const select = (data, editorService) => {
|
|
2431
|
+
const select = async (data, editorService) => {
|
|
3264
2432
|
if (!data.id) {
|
|
3265
2433
|
throw new Error("\u6CA1\u6709id");
|
|
3266
2434
|
}
|
|
3267
|
-
editorService?.select(data);
|
|
2435
|
+
await editorService?.select(data);
|
|
2436
|
+
editorService?.get("stage")?.select(data.id);
|
|
3268
2437
|
};
|
|
3269
2438
|
const highlight = (data, editorService) => {
|
|
3270
2439
|
if (!data?.id) {
|
|
3271
2440
|
throw new Error("\u6CA1\u6709id");
|
|
3272
2441
|
}
|
|
3273
2442
|
editorService?.highlight(data);
|
|
2443
|
+
editorService?.get("stage")?.highlight(data.id);
|
|
3274
2444
|
};
|
|
3275
2445
|
const useDrop = (tree, editorService) => ({
|
|
3276
2446
|
allowDrop: (draggingNode, dropNode, type) => {
|
|
@@ -3325,7 +2495,8 @@
|
|
|
3325
2495
|
resolve([]);
|
|
3326
2496
|
},
|
|
3327
2497
|
highlightNode,
|
|
3328
|
-
clickNode: node
|
|
2498
|
+
clickNode: node,
|
|
2499
|
+
expandedKeys: vue.computed(() => node.value ? [node.value.id] : [])
|
|
3329
2500
|
};
|
|
3330
2501
|
};
|
|
3331
2502
|
const useFilter = (tree) => ({
|
|
@@ -3337,67 +2508,46 @@
|
|
|
3337
2508
|
let name = "";
|
|
3338
2509
|
if (data.name) {
|
|
3339
2510
|
name = data.name;
|
|
3340
|
-
} else if (data.type) {
|
|
3341
|
-
name = data.type;
|
|
3342
2511
|
} else if (data.items) {
|
|
3343
2512
|
name = "container";
|
|
3344
2513
|
}
|
|
3345
|
-
return name.indexOf(value) !== -1;
|
|
2514
|
+
return `${data.id}${name}${data.type}`.indexOf(value) !== -1;
|
|
3346
2515
|
},
|
|
3347
2516
|
filterTextChangeHandler(val) {
|
|
3348
2517
|
tree.value?.filter(val);
|
|
3349
2518
|
}
|
|
3350
2519
|
});
|
|
3351
|
-
const
|
|
3352
|
-
const menuStyle = vue.ref({
|
|
3353
|
-
position: "absolute",
|
|
3354
|
-
left: "0",
|
|
3355
|
-
top: "0",
|
|
3356
|
-
display: "none"
|
|
3357
|
-
});
|
|
3358
|
-
vue.onMounted(() => {
|
|
3359
|
-
document.addEventListener("click", () => {
|
|
3360
|
-
menuStyle.value.display = "none";
|
|
3361
|
-
}, true);
|
|
3362
|
-
});
|
|
3363
|
-
return {
|
|
3364
|
-
menuStyle,
|
|
3365
|
-
contextmenu(event, data) {
|
|
3366
|
-
const bodyHeight = globalThis.document.body.clientHeight;
|
|
3367
|
-
const left = `${event.clientX + 20}px`;
|
|
3368
|
-
let top = `${event.clientY - 10}px`;
|
|
3369
|
-
if (event.clientY + 300 > bodyHeight) {
|
|
3370
|
-
top = `${bodyHeight - 300}px`;
|
|
3371
|
-
}
|
|
3372
|
-
menuStyle.value.left = left;
|
|
3373
|
-
menuStyle.value.top = top;
|
|
3374
|
-
menuStyle.value.display = "";
|
|
3375
|
-
select(data, editorService);
|
|
3376
|
-
}
|
|
3377
|
-
};
|
|
3378
|
-
};
|
|
3379
|
-
const _sfc_main$7 = vue.defineComponent({
|
|
2520
|
+
const _sfc_main$8 = vue.defineComponent({
|
|
3380
2521
|
name: "magic-editor-layer-panel",
|
|
3381
2522
|
components: { LayerMenu },
|
|
3382
2523
|
setup() {
|
|
3383
2524
|
const services = vue.inject("services");
|
|
3384
2525
|
const tree = vue.ref();
|
|
2526
|
+
const menu = vue.ref();
|
|
3385
2527
|
const clicked = vue.ref(false);
|
|
3386
2528
|
const editorService = services?.editorService;
|
|
3387
2529
|
const highlightHandler = lodashEs.throttle((data) => {
|
|
3388
2530
|
highlight(data, editorService);
|
|
3389
2531
|
}, throttleTime);
|
|
3390
|
-
const
|
|
2532
|
+
const toggleClickFlag = () => {
|
|
3391
2533
|
clicked.value = !clicked.value;
|
|
3392
2534
|
};
|
|
3393
2535
|
const statusData = useStatus(tree, editorService);
|
|
3394
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
|
+
});
|
|
3395
2542
|
return {
|
|
3396
2543
|
tree,
|
|
2544
|
+
menu,
|
|
3397
2545
|
...statusData,
|
|
3398
2546
|
...useDrop(tree, editorService),
|
|
3399
2547
|
...useFilter(tree),
|
|
3400
|
-
|
|
2548
|
+
highlightHandler,
|
|
2549
|
+
toggleClickFlag,
|
|
2550
|
+
canHighlight,
|
|
3401
2551
|
clickHandler(data) {
|
|
3402
2552
|
if (services?.uiService.get("uiSelectMode")) {
|
|
3403
2553
|
document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
|
|
@@ -3406,14 +2556,16 @@
|
|
|
3406
2556
|
tree.value?.setCurrentKey(data.id);
|
|
3407
2557
|
select(data, editorService);
|
|
3408
2558
|
},
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
2559
|
+
async contextmenu(event, data) {
|
|
2560
|
+
event.preventDefault();
|
|
2561
|
+
await select(data, editorService);
|
|
2562
|
+
menu.value?.show(event);
|
|
2563
|
+
}
|
|
3412
2564
|
};
|
|
3413
2565
|
}
|
|
3414
2566
|
});
|
|
3415
|
-
const _hoisted_1$
|
|
3416
|
-
function _sfc_render$
|
|
2567
|
+
const _hoisted_1$4 = ["id", "onMouseenter"];
|
|
2568
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3417
2569
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
3418
2570
|
const _component_el_tree = vue.resolveComponent("el-tree");
|
|
3419
2571
|
const _component_layer_menu = vue.resolveComponent("layer-menu");
|
|
@@ -3434,6 +2586,7 @@
|
|
|
3434
2586
|
ref: "tree",
|
|
3435
2587
|
"node-key": "id",
|
|
3436
2588
|
draggable: "",
|
|
2589
|
+
"default-expanded-keys": _ctx.expandedKeys,
|
|
3437
2590
|
load: _ctx.loadItems,
|
|
3438
2591
|
data: _ctx.values,
|
|
3439
2592
|
"expand-on-click-node": false,
|
|
@@ -3452,8 +2605,8 @@
|
|
|
3452
2605
|
vue.createElementVNode("div", {
|
|
3453
2606
|
id: data.id,
|
|
3454
2607
|
class: vue.normalizeClass(["cus-tree-node", { "cus-tree-node-hover": _ctx.canHighlight && data.id === _ctx.highlightNode?.id }]),
|
|
3455
|
-
onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.
|
|
3456
|
-
onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.
|
|
2608
|
+
onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
|
|
2609
|
+
onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
|
|
3457
2610
|
onMouseenter: ($event) => _ctx.highlightHandler(data)
|
|
3458
2611
|
}, [
|
|
3459
2612
|
vue.renderSlot(_ctx.$slots, "layer-node-content", {
|
|
@@ -3462,42 +2615,33 @@
|
|
|
3462
2615
|
}, () => [
|
|
3463
2616
|
vue.createElementVNode("span", null, vue.toDisplayString(`${data.name} (${data.id})`), 1)
|
|
3464
2617
|
])
|
|
3465
|
-
], 42, _hoisted_1$
|
|
2618
|
+
], 42, _hoisted_1$4)
|
|
3466
2619
|
]),
|
|
3467
2620
|
_: 3
|
|
3468
|
-
}, 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),
|
|
3469
2622
|
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
3470
|
-
vue.createVNode(_component_layer_menu, {
|
|
3471
|
-
style: vue.normalizeStyle(_ctx.menuStyle)
|
|
3472
|
-
}, null, 8, ["style"])
|
|
2623
|
+
vue.createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
|
|
3473
2624
|
]))
|
|
3474
2625
|
]),
|
|
3475
2626
|
_: 3
|
|
3476
2627
|
});
|
|
3477
2628
|
}
|
|
3478
|
-
var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2629
|
+
var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
|
|
3479
2630
|
|
|
3480
|
-
const _sfc_main$
|
|
3481
|
-
name: "m-sidebar",
|
|
2631
|
+
const _sfc_main$7 = vue.defineComponent({
|
|
3482
2632
|
components: { MIcon },
|
|
3483
2633
|
props: {
|
|
3484
2634
|
data: {
|
|
3485
|
-
type: Object
|
|
3486
|
-
default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer"] })
|
|
2635
|
+
type: Object
|
|
3487
2636
|
}
|
|
3488
2637
|
},
|
|
3489
2638
|
setup(props) {
|
|
3490
|
-
const activeTabName = vue.ref(props.data?.status);
|
|
3491
|
-
vue.watch(() => props.data?.status, (status) => {
|
|
3492
|
-
activeTabName.value = status || "0";
|
|
3493
|
-
});
|
|
3494
2639
|
return {
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
return item;
|
|
2640
|
+
config: vue.computed(() => {
|
|
2641
|
+
if (typeof props.data !== "string") {
|
|
2642
|
+
return props.data;
|
|
3499
2643
|
}
|
|
3500
|
-
switch (
|
|
2644
|
+
switch (props.data) {
|
|
3501
2645
|
case "component-list":
|
|
3502
2646
|
return {
|
|
3503
2647
|
type: "component",
|
|
@@ -3515,21 +2659,75 @@
|
|
|
3515
2659
|
slots: {}
|
|
3516
2660
|
};
|
|
3517
2661
|
default:
|
|
3518
|
-
return
|
|
2662
|
+
return void 0;
|
|
3519
2663
|
}
|
|
3520
|
-
})
|
|
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
|
|
3521
2724
|
};
|
|
3522
2725
|
}
|
|
3523
2726
|
});
|
|
3524
|
-
const _hoisted_1$4 = {
|
|
3525
|
-
key: 1,
|
|
3526
|
-
class: "magic-editor-tab-panel-title"
|
|
3527
|
-
};
|
|
3528
2727
|
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3529
|
-
const
|
|
3530
|
-
const _component_el_tab_pane = vue.resolveComponent("el-tab-pane");
|
|
2728
|
+
const _component_tab_pane = vue.resolveComponent("tab-pane");
|
|
3531
2729
|
const _component_el_tabs = vue.resolveComponent("el-tabs");
|
|
3532
|
-
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, {
|
|
3533
2731
|
key: 0,
|
|
3534
2732
|
class: "m-editor-sidebar",
|
|
3535
2733
|
modelValue: _ctx.activeTabName,
|
|
@@ -3538,35 +2736,11 @@
|
|
|
3538
2736
|
"tab-position": "left"
|
|
3539
2737
|
}, {
|
|
3540
2738
|
default: vue.withCtx(() => [
|
|
3541
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.items, (item) => {
|
|
3542
|
-
return vue.openBlock(), vue.createBlock(
|
|
3543
|
-
key:
|
|
3544
|
-
|
|
3545
|
-
},
|
|
3546
|
-
label: vue.withCtx(() => [
|
|
3547
|
-
vue.createElementVNode("span", null, [
|
|
3548
|
-
item.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
|
|
3549
|
-
key: 0,
|
|
3550
|
-
icon: item.icon
|
|
3551
|
-
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
3552
|
-
item.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, vue.toDisplayString(item.text), 1)) : vue.createCommentVNode("", true)
|
|
3553
|
-
])
|
|
3554
|
-
]),
|
|
3555
|
-
default: vue.withCtx(() => [
|
|
3556
|
-
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(item.component), vue.mergeProps(item.props || {}, vue.toHandlers(item.listeners || {})), vue.createSlots({ _: 2 }, [
|
|
3557
|
-
item.slots?.layerNodeContent ? {
|
|
3558
|
-
name: "layer-node-content",
|
|
3559
|
-
fn: vue.withCtx(({ data, node }) => [
|
|
3560
|
-
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(item.slots.layerNodeContent), {
|
|
3561
|
-
data,
|
|
3562
|
-
node
|
|
3563
|
-
}, null, 8, ["data", "node"]))
|
|
3564
|
-
])
|
|
3565
|
-
} : void 0
|
|
3566
|
-
]), 1040))
|
|
3567
|
-
]),
|
|
3568
|
-
_: 2
|
|
3569
|
-
}, 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"]);
|
|
3570
2744
|
}), 128))
|
|
3571
2745
|
]),
|
|
3572
2746
|
_: 1
|
|
@@ -3574,13 +2748,81 @@
|
|
|
3574
2748
|
}
|
|
3575
2749
|
var Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6]]);
|
|
3576
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
|
+
};
|
|
3577
2815
|
const _sfc_main$5 = vue.defineComponent({
|
|
3578
|
-
components: { CaretBottom: icons.CaretBottom, Plus: icons.Plus },
|
|
2816
|
+
components: { ArrowLeftBold: icons.ArrowLeftBold, ArrowRightBold: icons.ArrowRightBold, CaretBottom: icons.CaretBottom, Plus: icons.Plus, ToolButton },
|
|
3579
2817
|
setup() {
|
|
3580
2818
|
const services = vue.inject("services");
|
|
3581
2819
|
const editorService = services?.editorService;
|
|
2820
|
+
const root = vue.computed(() => editorService?.get("root"));
|
|
3582
2821
|
return {
|
|
3583
|
-
|
|
2822
|
+
Delete: vue.markRaw(icons.Delete),
|
|
2823
|
+
DocumentCopy: vue.markRaw(icons.DocumentCopy),
|
|
2824
|
+
...useScroll(root),
|
|
2825
|
+
root,
|
|
3584
2826
|
page: vue.computed(() => editorService?.get("page")),
|
|
3585
2827
|
switchPage(page) {
|
|
3586
2828
|
editorService?.select(page);
|
|
@@ -3607,112 +2849,228 @@
|
|
|
3607
2849
|
};
|
|
3608
2850
|
}
|
|
3609
2851
|
});
|
|
3610
|
-
const _hoisted_1$
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
const
|
|
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" };
|
|
3615
2858
|
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3616
2859
|
const _component_plus = vue.resolveComponent("plus");
|
|
3617
2860
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
2861
|
+
const _component_arrow_left_bold = vue.resolveComponent("arrow-left-bold");
|
|
3618
2862
|
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
2863
|
+
const _component_tool_button = vue.resolveComponent("tool-button");
|
|
3619
2864
|
const _component_caret_bottom = vue.resolveComponent("caret-bottom");
|
|
3620
2865
|
const _component_el_popover = vue.resolveComponent("el-popover");
|
|
3621
|
-
|
|
2866
|
+
const _component_arrow_right_bold = vue.resolveComponent("arrow-right-bold");
|
|
2867
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
|
|
3622
2868
|
vue.createElementVNode("div", {
|
|
3623
|
-
|
|
2869
|
+
id: "m-editor-page-bar-add-icon",
|
|
2870
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3624
2871
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.addPage && _ctx.addPage(...args))
|
|
3625
2872
|
}, [
|
|
3626
|
-
vue.createVNode(_component_el_icon,
|
|
2873
|
+
vue.createVNode(_component_el_icon, null, {
|
|
3627
2874
|
default: vue.withCtx(() => [
|
|
3628
2875
|
vue.createVNode(_component_plus)
|
|
3629
2876
|
]),
|
|
3630
2877
|
_: 1
|
|
3631
2878
|
})
|
|
3632
2879
|
]),
|
|
3633
|
-
_ctx.
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
vue.
|
|
3640
|
-
vue.
|
|
3641
|
-
vue.createVNode(_component_el_tooltip, {
|
|
3642
|
-
effect: "dark",
|
|
3643
|
-
placement: "top-start",
|
|
3644
|
-
content: item.name
|
|
3645
|
-
}, {
|
|
3646
|
-
default: vue.withCtx(() => [
|
|
3647
|
-
vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
|
|
3648
|
-
]),
|
|
3649
|
-
_: 2
|
|
3650
|
-
}, 1032, ["content"])
|
|
3651
|
-
])
|
|
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)
|
|
3652
2888
|
]),
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
]),
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
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"])
|
|
3678
2916
|
])
|
|
3679
2917
|
]),
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
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);
|
|
3685
2972
|
}
|
|
3686
2973
|
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
|
|
3687
2974
|
|
|
3688
2975
|
class ScrollViewer$1 {
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
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();
|
|
3711
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);
|
|
3712
3008
|
this.scroll();
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
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
|
+
};
|
|
3716
3074
|
this.container = options.container;
|
|
3717
3075
|
this.target = options.target;
|
|
3718
3076
|
this.zoom = options.zoom;
|
|
@@ -3748,79 +3106,6 @@
|
|
|
3748
3106
|
document.removeEventListener("mousemove", this.mousemoveHandler);
|
|
3749
3107
|
document.removeEventListener("mouseup", this.mouseupHandler);
|
|
3750
3108
|
}
|
|
3751
|
-
wheelHandler = (event) => {
|
|
3752
|
-
if (this.targetEnter)
|
|
3753
|
-
return;
|
|
3754
|
-
const { deltaX, deltaY, currentTarget } = event;
|
|
3755
|
-
if (currentTarget !== this.container)
|
|
3756
|
-
return;
|
|
3757
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3758
|
-
this.scroll();
|
|
3759
|
-
this.scrollLeft = this.target._left;
|
|
3760
|
-
this.scrollTop = this.target._top;
|
|
3761
|
-
};
|
|
3762
|
-
mouseEnterHandler = () => {
|
|
3763
|
-
this.enter = true;
|
|
3764
|
-
};
|
|
3765
|
-
mouseLeaveHandler = () => {
|
|
3766
|
-
this.enter = false;
|
|
3767
|
-
};
|
|
3768
|
-
targetMouseEnterHandler = () => {
|
|
3769
|
-
this.targetEnter = true;
|
|
3770
|
-
};
|
|
3771
|
-
targetMouseLeaveHandler = () => {
|
|
3772
|
-
this.targetEnter = false;
|
|
3773
|
-
};
|
|
3774
|
-
mousedownHandler = (event) => {
|
|
3775
|
-
if (!this.keydown)
|
|
3776
|
-
return;
|
|
3777
|
-
event.stopImmediatePropagation();
|
|
3778
|
-
event.stopPropagation();
|
|
3779
|
-
this.target.style.cursor = "grabbing";
|
|
3780
|
-
this.x = event.clientX;
|
|
3781
|
-
this.y = event.clientY;
|
|
3782
|
-
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3783
|
-
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3784
|
-
};
|
|
3785
|
-
mouseupHandler = () => {
|
|
3786
|
-
this.x = 0;
|
|
3787
|
-
this.y = 0;
|
|
3788
|
-
this.scrollLeft = this.target._left;
|
|
3789
|
-
this.scrollTop = this.target._top;
|
|
3790
|
-
this.removeHandler();
|
|
3791
|
-
};
|
|
3792
|
-
mousemoveHandler = (event) => {
|
|
3793
|
-
event.stopImmediatePropagation();
|
|
3794
|
-
event.stopPropagation();
|
|
3795
|
-
const deltaX = event.clientX - this.x;
|
|
3796
|
-
const deltaY = event.clientY - this.y;
|
|
3797
|
-
this.setScrollOffset(deltaX, deltaY);
|
|
3798
|
-
this.scroll();
|
|
3799
|
-
};
|
|
3800
|
-
keydownHandler = (event) => {
|
|
3801
|
-
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3802
|
-
event.preventDefault();
|
|
3803
|
-
event.stopImmediatePropagation();
|
|
3804
|
-
event.stopPropagation();
|
|
3805
|
-
}
|
|
3806
|
-
if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
|
|
3807
|
-
return;
|
|
3808
|
-
}
|
|
3809
|
-
this.keydown = true;
|
|
3810
|
-
this.target.style.cursor = "grab";
|
|
3811
|
-
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3812
|
-
};
|
|
3813
|
-
keyupHandler = (event) => {
|
|
3814
|
-
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3815
|
-
return;
|
|
3816
|
-
}
|
|
3817
|
-
event.preventDefault();
|
|
3818
|
-
event.stopImmediatePropagation();
|
|
3819
|
-
event.stopPropagation();
|
|
3820
|
-
this.keydown = false;
|
|
3821
|
-
event.preventDefault();
|
|
3822
|
-
this.removeHandler();
|
|
3823
|
-
};
|
|
3824
3109
|
setScrollOffset(deltaX, deltaY) {
|
|
3825
3110
|
const { width, height } = this.container.getBoundingClientRect();
|
|
3826
3111
|
const targetRect = this.target.getBoundingClientRect();
|
|
@@ -3881,19 +3166,19 @@
|
|
|
3881
3166
|
el,
|
|
3882
3167
|
style: vue.computed(() => `
|
|
3883
3168
|
width: ${props.width}px;
|
|
3884
|
-
height: ${props.height}px;
|
|
3169
|
+
height: ${(props.height || 0) - 40}px;
|
|
3885
3170
|
position: absolute;
|
|
3886
3171
|
margin-top: 30px;
|
|
3887
3172
|
`)
|
|
3888
3173
|
};
|
|
3889
3174
|
}
|
|
3890
3175
|
});
|
|
3891
|
-
const _hoisted_1$
|
|
3176
|
+
const _hoisted_1$1 = {
|
|
3892
3177
|
class: "m-editor-scroll-viewer-container",
|
|
3893
3178
|
ref: "container"
|
|
3894
3179
|
};
|
|
3895
3180
|
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3896
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
3181
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
|
|
3897
3182
|
vue.createElementVNode("div", {
|
|
3898
3183
|
ref: "el",
|
|
3899
3184
|
style: vue.normalizeStyle(_ctx.style)
|
|
@@ -3905,7 +3190,7 @@
|
|
|
3905
3190
|
var ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]);
|
|
3906
3191
|
|
|
3907
3192
|
const _sfc_main$3 = vue.defineComponent({
|
|
3908
|
-
|
|
3193
|
+
components: { ContentMenu },
|
|
3909
3194
|
setup() {
|
|
3910
3195
|
const services = vue.inject("services");
|
|
3911
3196
|
const editorService = services?.editorService;
|
|
@@ -3914,6 +3199,7 @@
|
|
|
3914
3199
|
const canCenter = vue.ref(false);
|
|
3915
3200
|
const node = vue.computed(() => editorService?.get("node"));
|
|
3916
3201
|
const parent = vue.computed(() => editorService?.get("parent"));
|
|
3202
|
+
const isPage = vue.computed(() => node.value?.type === schema.NodeType.PAGE);
|
|
3917
3203
|
vue.onMounted(() => {
|
|
3918
3204
|
const data = globalThis.localStorage.getItem(COPY_STORAGE_KEY);
|
|
3919
3205
|
canPaste.value = data !== "undefined" && !!data;
|
|
@@ -3926,133 +3212,114 @@
|
|
|
3926
3212
|
}, { immediate: true });
|
|
3927
3213
|
return {
|
|
3928
3214
|
menu,
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
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);
|
|
3962
3310
|
}
|
|
3963
3311
|
};
|
|
3964
3312
|
}
|
|
3965
3313
|
});
|
|
3966
|
-
const _hoisted_1$1 = {
|
|
3967
|
-
class: "magic-editor-content-menu",
|
|
3968
|
-
ref: "menu"
|
|
3969
|
-
};
|
|
3970
|
-
const _hoisted_2 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
|
|
3971
|
-
const _hoisted_3 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
|
|
3972
|
-
const _hoisted_4 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
|
|
3973
3314
|
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
onClick: _cache[0] || (_cache[0] = () => _ctx.center())
|
|
3980
|
-
}, "\u6C34\u5E73\u5C45\u4E2D")) : vue.createCommentVNode("", true),
|
|
3981
|
-
vue.createElementVNode("div", {
|
|
3982
|
-
class: "magic-editor-content-menu-item",
|
|
3983
|
-
onClick: _cache[1] || (_cache[1] = () => _ctx.copy())
|
|
3984
|
-
}, "\u590D\u5236"),
|
|
3985
|
-
_ctx.canPaste ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3986
|
-
key: 1,
|
|
3987
|
-
class: "magic-editor-content-menu-item",
|
|
3988
|
-
onClick: _cache[2] || (_cache[2] = (...args) => _ctx.paste && _ctx.paste(...args))
|
|
3989
|
-
}, "\u7C98\u8D34")) : vue.createCommentVNode("", true),
|
|
3990
|
-
_ctx.canMoveZPos ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
|
|
3991
|
-
_hoisted_2,
|
|
3992
|
-
vue.createElementVNode("div", {
|
|
3993
|
-
class: "magic-editor-content-menu-item",
|
|
3994
|
-
onClick: _cache[3] || (_cache[3] = (...args) => _ctx.topItem && _ctx.topItem(...args))
|
|
3995
|
-
}, "\u4E0A\u79FB\u4E00\u5C42"),
|
|
3996
|
-
vue.createElementVNode("div", {
|
|
3997
|
-
class: "magic-editor-content-menu-item",
|
|
3998
|
-
onClick: _cache[4] || (_cache[4] = (...args) => _ctx.bottomItem && _ctx.bottomItem(...args))
|
|
3999
|
-
}, "\u4E0B\u79FB\u4E00\u5C42"),
|
|
4000
|
-
vue.createElementVNode("div", {
|
|
4001
|
-
class: "magic-editor-content-menu-item",
|
|
4002
|
-
onClick: _cache[5] || (_cache[5] = (...args) => _ctx.top && _ctx.top(...args))
|
|
4003
|
-
}, "\u7F6E\u9876"),
|
|
4004
|
-
vue.createElementVNode("div", {
|
|
4005
|
-
class: "magic-editor-content-menu-item",
|
|
4006
|
-
onClick: _cache[6] || (_cache[6] = (...args) => _ctx.bottom && _ctx.bottom(...args))
|
|
4007
|
-
}, "\u7F6E\u5E95")
|
|
4008
|
-
], 64)) : vue.createCommentVNode("", true),
|
|
4009
|
-
_ctx.canDelete ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
|
|
4010
|
-
_hoisted_3,
|
|
4011
|
-
vue.createElementVNode("div", {
|
|
4012
|
-
class: "magic-editor-content-menu-item",
|
|
4013
|
-
onClick: _cache[7] || (_cache[7] = () => _ctx.remove())
|
|
4014
|
-
}, "\u5220\u9664")
|
|
4015
|
-
], 64)) : vue.createCommentVNode("", true),
|
|
4016
|
-
_hoisted_4,
|
|
4017
|
-
vue.createElementVNode("div", {
|
|
4018
|
-
class: "magic-editor-content-menu-item",
|
|
4019
|
-
onClick: _cache[8] || (_cache[8] = (...args) => _ctx.clearGuides && _ctx.clearGuides(...args))
|
|
4020
|
-
}, "\u6E05\u7A7A\u53C2\u8003\u7EBF")
|
|
4021
|
-
])
|
|
4022
|
-
], 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"]);
|
|
4023
3320
|
}
|
|
4024
3321
|
var ViewerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
|
|
4025
3322
|
|
|
4026
|
-
const useMenu = () => {
|
|
4027
|
-
const menu = vue.ref();
|
|
4028
|
-
const menuStyle = vue.ref({
|
|
4029
|
-
display: "none",
|
|
4030
|
-
left: "0",
|
|
4031
|
-
top: "0"
|
|
4032
|
-
});
|
|
4033
|
-
vue.onMounted(() => {
|
|
4034
|
-
document.addEventListener("click", () => {
|
|
4035
|
-
menuStyle.value.display = "none";
|
|
4036
|
-
}, true);
|
|
4037
|
-
});
|
|
4038
|
-
return {
|
|
4039
|
-
menu,
|
|
4040
|
-
menuStyle,
|
|
4041
|
-
contextmenuHandler(e) {
|
|
4042
|
-
e.preventDefault();
|
|
4043
|
-
const menuHeight = menu.value?.$el.clientHeight;
|
|
4044
|
-
let top = e.clientY;
|
|
4045
|
-
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
4046
|
-
top = document.body.clientHeight - menuHeight;
|
|
4047
|
-
}
|
|
4048
|
-
menuStyle.value = {
|
|
4049
|
-
display: "block",
|
|
4050
|
-
top: `${top}px`,
|
|
4051
|
-
left: `${e.clientX}px`
|
|
4052
|
-
};
|
|
4053
|
-
}
|
|
4054
|
-
};
|
|
4055
|
-
};
|
|
4056
3323
|
const _sfc_main$2 = vue.defineComponent({
|
|
4057
3324
|
name: "magic-stage",
|
|
4058
3325
|
components: {
|
|
@@ -4064,6 +3331,7 @@
|
|
|
4064
3331
|
type: Function
|
|
4065
3332
|
},
|
|
4066
3333
|
runtimeUrl: String,
|
|
3334
|
+
autoScrollIntoView: Boolean,
|
|
4067
3335
|
canSelect: {
|
|
4068
3336
|
type: Function,
|
|
4069
3337
|
default: (el) => Boolean(el.id)
|
|
@@ -4075,18 +3343,17 @@
|
|
|
4075
3343
|
})
|
|
4076
3344
|
}
|
|
4077
3345
|
},
|
|
4078
|
-
|
|
4079
|
-
setup(props, { emit }) {
|
|
3346
|
+
setup(props) {
|
|
4080
3347
|
const services = vue.inject("services");
|
|
4081
3348
|
const stageWrap = vue.ref();
|
|
4082
3349
|
const stageContainer = vue.ref();
|
|
3350
|
+
const menu = vue.ref();
|
|
4083
3351
|
const stageRect = vue.computed(() => services?.uiService.get("stageRect"));
|
|
4084
3352
|
const uiSelectMode = vue.computed(() => services?.uiService.get("uiSelectMode"));
|
|
4085
3353
|
const root = vue.computed(() => services?.editorService.get("root"));
|
|
4086
3354
|
const page = vue.computed(() => services?.editorService.get("page"));
|
|
4087
|
-
const zoom = vue.computed(() => services?.uiService.get("zoom"));
|
|
3355
|
+
const zoom = vue.computed(() => services?.uiService.get("zoom") || 1);
|
|
4088
3356
|
const node = vue.computed(() => services?.editorService.get("node"));
|
|
4089
|
-
const highlightNode = vue.computed(() => services?.editorService.get("highlightNode"));
|
|
4090
3357
|
let stage = null;
|
|
4091
3358
|
let runtime = null;
|
|
4092
3359
|
vue.watchEffect(() => {
|
|
@@ -4100,9 +3367,10 @@
|
|
|
4100
3367
|
render: props.render,
|
|
4101
3368
|
runtimeUrl: props.runtimeUrl,
|
|
4102
3369
|
zoom: zoom.value,
|
|
4103
|
-
|
|
3370
|
+
autoScrollIntoView: props.autoScrollIntoView,
|
|
3371
|
+
canSelect: (el, event, stop) => {
|
|
4104
3372
|
const elCanSelect = props.canSelect(el);
|
|
4105
|
-
if (uiSelectMode.value && elCanSelect) {
|
|
3373
|
+
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
4106
3374
|
document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
|
|
4107
3375
|
return stop();
|
|
4108
3376
|
}
|
|
@@ -4110,19 +3378,19 @@
|
|
|
4110
3378
|
},
|
|
4111
3379
|
moveableOptions: props.moveableOptions
|
|
4112
3380
|
});
|
|
4113
|
-
services?.editorService.set("stage", stage);
|
|
3381
|
+
services?.editorService.set("stage", vue.markRaw(stage));
|
|
4114
3382
|
stage?.mount(stageContainer.value);
|
|
4115
3383
|
stage?.on("select", (el) => {
|
|
4116
|
-
|
|
3384
|
+
services?.editorService.select(el.id);
|
|
4117
3385
|
});
|
|
4118
3386
|
stage?.on("highlight", (el) => {
|
|
4119
|
-
|
|
3387
|
+
services?.editorService.highlight(el.id);
|
|
4120
3388
|
});
|
|
4121
3389
|
stage?.on("update", (ev) => {
|
|
4122
|
-
|
|
3390
|
+
services?.editorService.update({ id: ev.el.id, style: ev.style });
|
|
4123
3391
|
});
|
|
4124
3392
|
stage?.on("sort", (ev) => {
|
|
4125
|
-
|
|
3393
|
+
services?.editorService.sort(ev.src, ev.dist);
|
|
4126
3394
|
});
|
|
4127
3395
|
stage?.on("changeGuides", () => {
|
|
4128
3396
|
services?.uiService.set("showGuides", true);
|
|
@@ -4148,16 +3416,6 @@
|
|
|
4148
3416
|
runtime.updateRootConfig(lodashEs.cloneDeep(vue.toRaw(root2)));
|
|
4149
3417
|
}
|
|
4150
3418
|
});
|
|
4151
|
-
vue.watch(() => node.value?.id, (id) => {
|
|
4152
|
-
vue.nextTick(() => {
|
|
4153
|
-
id && stage?.select(id);
|
|
4154
|
-
});
|
|
4155
|
-
});
|
|
4156
|
-
vue.watch(() => highlightNode.value?.id, (id) => {
|
|
4157
|
-
vue.nextTick(() => {
|
|
4158
|
-
id && stage?.highlight(id);
|
|
4159
|
-
});
|
|
4160
|
-
});
|
|
4161
3419
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
4162
3420
|
for (const { contentRect } of entries) {
|
|
4163
3421
|
services?.uiService.set("stageContainerRect", {
|
|
@@ -4177,9 +3435,37 @@
|
|
|
4177
3435
|
return {
|
|
4178
3436
|
stageWrap,
|
|
4179
3437
|
stageContainer,
|
|
3438
|
+
menu,
|
|
4180
3439
|
stageRect,
|
|
4181
3440
|
zoom,
|
|
4182
|
-
|
|
3441
|
+
contextmenuHandler(e2) {
|
|
3442
|
+
e2.preventDefault();
|
|
3443
|
+
menu.value?.show(e2);
|
|
3444
|
+
},
|
|
3445
|
+
dragoverHandler(e2) {
|
|
3446
|
+
e2.preventDefault();
|
|
3447
|
+
if (e2.dataTransfer) {
|
|
3448
|
+
e2.dataTransfer.dropEffect = "move";
|
|
3449
|
+
}
|
|
3450
|
+
},
|
|
3451
|
+
async dropHandler(e) {
|
|
3452
|
+
e.preventDefault();
|
|
3453
|
+
if (e.dataTransfer && page.value && stageContainer.value && stage) {
|
|
3454
|
+
const config = eval(`(${e.dataTransfer.getData("data")})`);
|
|
3455
|
+
const layout = await services?.editorService.getLayout(page.value);
|
|
3456
|
+
const containerRect = stageContainer.value.getBoundingClientRect();
|
|
3457
|
+
const { scrollTop, scrollLeft } = stage.mask;
|
|
3458
|
+
if (layout === Layout.ABSOLUTE) {
|
|
3459
|
+
config.style = {
|
|
3460
|
+
...config.style || {},
|
|
3461
|
+
position: "absolute",
|
|
3462
|
+
top: e.clientY - containerRect.top + scrollTop,
|
|
3463
|
+
left: e.clientX - containerRect.left + scrollLeft
|
|
3464
|
+
};
|
|
3465
|
+
}
|
|
3466
|
+
services?.editorService.add(config, page.value);
|
|
3467
|
+
}
|
|
3468
|
+
}
|
|
4183
3469
|
};
|
|
4184
3470
|
}
|
|
4185
3471
|
});
|
|
@@ -4197,14 +3483,13 @@
|
|
|
4197
3483
|
vue.createElementVNode("div", {
|
|
4198
3484
|
class: "m-editor-stage-container",
|
|
4199
3485
|
ref: "stageContainer",
|
|
3486
|
+
style: vue.normalizeStyle(`transform: scale(${_ctx.zoom})`),
|
|
4200
3487
|
onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
|
|
4201
|
-
|
|
3488
|
+
onDrop: _cache[1] || (_cache[1] = (...args) => _ctx.dropHandler && _ctx.dropHandler(...args)),
|
|
3489
|
+
onDragover: _cache[2] || (_cache[2] = (...args) => _ctx.dragoverHandler && _ctx.dragoverHandler(...args))
|
|
4202
3490
|
}, null, 36),
|
|
4203
3491
|
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
4204
|
-
vue.createVNode(_component_viewer_menu, {
|
|
4205
|
-
ref: "menu",
|
|
4206
|
-
style: vue.normalizeStyle(_ctx.menuStyle)
|
|
4207
|
-
}, null, 8, ["style"])
|
|
3492
|
+
vue.createVNode(_component_viewer_menu, { ref: "menu" }, null, 512)
|
|
4208
3493
|
]))
|
|
4209
3494
|
]),
|
|
4210
3495
|
_: 1
|
|
@@ -4220,6 +3505,7 @@
|
|
|
4220
3505
|
},
|
|
4221
3506
|
props: {
|
|
4222
3507
|
runtimeUrl: String,
|
|
3508
|
+
autoScrollIntoView: Boolean,
|
|
4223
3509
|
render: {
|
|
4224
3510
|
type: Function
|
|
4225
3511
|
},
|
|
@@ -4232,24 +3518,93 @@
|
|
|
4232
3518
|
},
|
|
4233
3519
|
setup() {
|
|
4234
3520
|
const services = vue.inject("services");
|
|
3521
|
+
const workspace = vue.ref();
|
|
3522
|
+
const node = vue.computed(() => services?.editorService.get("node"));
|
|
3523
|
+
let keycon;
|
|
3524
|
+
const mouseenterHandler = () => {
|
|
3525
|
+
workspace.value?.focus();
|
|
3526
|
+
};
|
|
3527
|
+
const mouseleaveHandler = () => {
|
|
3528
|
+
workspace.value?.blur();
|
|
3529
|
+
};
|
|
3530
|
+
vue.onMounted(() => {
|
|
3531
|
+
workspace.value?.addEventListener("mouseenter", mouseenterHandler);
|
|
3532
|
+
workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
|
|
3533
|
+
keycon = new KeyController__default["default"](workspace.value);
|
|
3534
|
+
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
3535
|
+
const ctrl = isMac ? "meta" : "ctrl";
|
|
3536
|
+
keycon.keydown((e) => {
|
|
3537
|
+
console.log(e);
|
|
3538
|
+
e.inputEvent.preventDefault();
|
|
3539
|
+
}).keyup("delete", (e) => {
|
|
3540
|
+
e.inputEvent.preventDefault();
|
|
3541
|
+
if (!node.value || utils.isPage(node.value))
|
|
3542
|
+
return;
|
|
3543
|
+
services?.editorService.remove(node.value);
|
|
3544
|
+
}).keyup("backspace", (e) => {
|
|
3545
|
+
e.inputEvent.preventDefault();
|
|
3546
|
+
if (!node.value || utils.isPage(node.value))
|
|
3547
|
+
return;
|
|
3548
|
+
services?.editorService.remove(node.value);
|
|
3549
|
+
}).keydown([ctrl, "c"], () => {
|
|
3550
|
+
node.value && services?.editorService.copy(node.value);
|
|
3551
|
+
}).keydown([ctrl, "v"], () => {
|
|
3552
|
+
node.value && services?.editorService.paste();
|
|
3553
|
+
}).keydown([ctrl, "x"], () => {
|
|
3554
|
+
if (!node.value || utils.isPage(node.value))
|
|
3555
|
+
return;
|
|
3556
|
+
services?.editorService.copy(node.value);
|
|
3557
|
+
services?.editorService.remove(node.value);
|
|
3558
|
+
}).keydown([ctrl, "z"], () => {
|
|
3559
|
+
services?.editorService.undo();
|
|
3560
|
+
}).keydown([ctrl, "shift", "z"], () => {
|
|
3561
|
+
services?.editorService.redo();
|
|
3562
|
+
}).keydown("up", () => {
|
|
3563
|
+
services?.editorService.move(0, -1);
|
|
3564
|
+
}).keydown("down", () => {
|
|
3565
|
+
services?.editorService.move(0, 1);
|
|
3566
|
+
}).keydown("left", () => {
|
|
3567
|
+
services?.editorService.move(-1, 0);
|
|
3568
|
+
}).keydown("right", () => {
|
|
3569
|
+
services?.editorService.move(1, 0);
|
|
3570
|
+
}).keydown([ctrl, "up"], () => {
|
|
3571
|
+
services?.editorService.move(0, -10);
|
|
3572
|
+
}).keydown([ctrl, "down"], () => {
|
|
3573
|
+
services?.editorService.move(0, 10);
|
|
3574
|
+
}).keydown([ctrl, "left"], () => {
|
|
3575
|
+
services?.editorService.move(-10, 0);
|
|
3576
|
+
}).keydown([ctrl, "right"], () => {
|
|
3577
|
+
services?.editorService.move(10, 0);
|
|
3578
|
+
}).keydown("tab", () => {
|
|
3579
|
+
services?.editorService.selectNextNode();
|
|
3580
|
+
}).keydown([ctrl, "tab"], () => {
|
|
3581
|
+
services?.editorService.selectNextPage();
|
|
3582
|
+
}).keydown([ctrl, "="], () => {
|
|
3583
|
+
services?.uiService.zoom(0.1);
|
|
3584
|
+
}).keydown([ctrl, "numpadplus"], () => {
|
|
3585
|
+
services?.uiService.zoom(0.1);
|
|
3586
|
+
}).keydown([ctrl, "-"], () => {
|
|
3587
|
+
services?.uiService.zoom(-0.1);
|
|
3588
|
+
}).keydown([ctrl, "numpad-"], () => {
|
|
3589
|
+
services?.uiService.zoom(-0.1);
|
|
3590
|
+
});
|
|
3591
|
+
});
|
|
3592
|
+
vue.onUnmounted(() => {
|
|
3593
|
+
workspace.value?.removeEventListener("mouseenter", mouseenterHandler);
|
|
3594
|
+
workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
|
|
3595
|
+
keycon.destroy();
|
|
3596
|
+
});
|
|
4235
3597
|
return {
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
services?.editorService.select(el.id);
|
|
4239
|
-
},
|
|
4240
|
-
updateNodeHandler(node) {
|
|
4241
|
-
services?.editorService.update(node);
|
|
4242
|
-
},
|
|
4243
|
-
sortNodeHandler(ev) {
|
|
4244
|
-
services?.editorService.sort(ev.src, ev.dist);
|
|
4245
|
-
},
|
|
4246
|
-
highlightHandler(el) {
|
|
4247
|
-
services?.editorService.highlight(el.id);
|
|
4248
|
-
}
|
|
3598
|
+
workspace,
|
|
3599
|
+
page: vue.computed(() => services?.editorService.get("page"))
|
|
4249
3600
|
};
|
|
4250
3601
|
}
|
|
4251
3602
|
});
|
|
4252
|
-
const _hoisted_1 = {
|
|
3603
|
+
const _hoisted_1 = {
|
|
3604
|
+
class: "m-editor-workspace",
|
|
3605
|
+
tabindex: "1",
|
|
3606
|
+
ref: "workspace"
|
|
3607
|
+
};
|
|
4253
3608
|
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4254
3609
|
const _component_magic_stage = vue.resolveComponent("magic-stage");
|
|
4255
3610
|
const _component_page_bar = vue.resolveComponent("page-bar");
|
|
@@ -4257,14 +3612,11 @@
|
|
|
4257
3612
|
(vue.openBlock(), vue.createBlock(_component_magic_stage, {
|
|
4258
3613
|
key: _ctx.page?.id,
|
|
4259
3614
|
"runtime-url": _ctx.runtimeUrl,
|
|
3615
|
+
"auto-scroll-into-view": _ctx.autoScrollIntoView,
|
|
4260
3616
|
render: _ctx.render,
|
|
4261
3617
|
"moveable-options": _ctx.moveableOptions,
|
|
4262
|
-
"can-select": _ctx.canSelect
|
|
4263
|
-
|
|
4264
|
-
onHighlight: _ctx.highlightHandler,
|
|
4265
|
-
onUpdate: _ctx.updateNodeHandler,
|
|
4266
|
-
onSort: _ctx.sortNodeHandler
|
|
4267
|
-
}, null, 8, ["runtime-url", "render", "moveable-options", "can-select", "onSelect", "onHighlight", "onUpdate", "onSort"])),
|
|
3618
|
+
"can-select": _ctx.canSelect
|
|
3619
|
+
}, null, 8, ["runtime-url", "auto-scroll-into-view", "render", "moveable-options", "can-select"])),
|
|
4268
3620
|
vue.renderSlot(_ctx.$slots, "workspace-content"),
|
|
4269
3621
|
vue.createVNode(_component_page_bar, null, {
|
|
4270
3622
|
"page-bar-title": vue.withCtx(({ page }) => [
|
|
@@ -4275,16 +3627,16 @@
|
|
|
4275
3627
|
]),
|
|
4276
3628
|
_: 3
|
|
4277
3629
|
})
|
|
4278
|
-
]);
|
|
3630
|
+
], 512);
|
|
4279
3631
|
}
|
|
4280
3632
|
var Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
4281
3633
|
|
|
4282
3634
|
class ComponentList extends BaseService {
|
|
4283
|
-
state = vue.reactive({
|
|
4284
|
-
list: []
|
|
4285
|
-
});
|
|
4286
3635
|
constructor() {
|
|
4287
3636
|
super([]);
|
|
3637
|
+
this.state = vue.reactive({
|
|
3638
|
+
list: []
|
|
3639
|
+
});
|
|
4288
3640
|
}
|
|
4289
3641
|
setList(componentGroupList) {
|
|
4290
3642
|
this.state.list = componentGroupList;
|
|
@@ -4295,6 +3647,14 @@
|
|
|
4295
3647
|
}
|
|
4296
3648
|
var componentListService = new ComponentList();
|
|
4297
3649
|
|
|
3650
|
+
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
3651
|
+
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
3652
|
+
const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
|
|
3653
|
+
const defaultColumnWidth = {
|
|
3654
|
+
left: DEFAULT_LEFT_COLUMN_WIDTH,
|
|
3655
|
+
center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
|
|
3656
|
+
right: DEFAULT_RIGHT_COLUMN_WIDTH
|
|
3657
|
+
};
|
|
4298
3658
|
const state = vue.reactive({
|
|
4299
3659
|
uiSelectMode: false,
|
|
4300
3660
|
showSrc: false,
|
|
@@ -4307,13 +3667,10 @@
|
|
|
4307
3667
|
width: 375,
|
|
4308
3668
|
height: 817
|
|
4309
3669
|
},
|
|
4310
|
-
columnWidth:
|
|
4311
|
-
left: 310,
|
|
4312
|
-
center: globalThis.document.body.clientWidth - 310 - 400,
|
|
4313
|
-
right: 400
|
|
4314
|
-
},
|
|
3670
|
+
columnWidth: defaultColumnWidth,
|
|
4315
3671
|
showGuides: true,
|
|
4316
|
-
showRule: true
|
|
3672
|
+
showRule: true,
|
|
3673
|
+
propsPanelSize: "small"
|
|
4317
3674
|
});
|
|
4318
3675
|
class Ui extends BaseService {
|
|
4319
3676
|
constructor() {
|
|
@@ -4323,6 +3680,15 @@
|
|
|
4323
3680
|
center: "auto"
|
|
4324
3681
|
});
|
|
4325
3682
|
});
|
|
3683
|
+
const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
|
|
3684
|
+
if (columnWidthCacheData) {
|
|
3685
|
+
try {
|
|
3686
|
+
const columnWidthCache = JSON.parse(columnWidthCacheData);
|
|
3687
|
+
this.setColumnWidth(columnWidthCache);
|
|
3688
|
+
} catch (e) {
|
|
3689
|
+
console.error(e);
|
|
3690
|
+
}
|
|
3691
|
+
}
|
|
4326
3692
|
}
|
|
4327
3693
|
set(name, value) {
|
|
4328
3694
|
const mask = editorService.get("stage")?.mask;
|
|
@@ -4348,6 +3714,11 @@
|
|
|
4348
3714
|
get(name) {
|
|
4349
3715
|
return state[name];
|
|
4350
3716
|
}
|
|
3717
|
+
zoom(zoom) {
|
|
3718
|
+
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
3719
|
+
if (this.get("zoom") < 0.1)
|
|
3720
|
+
this.set("zoom", 0.1);
|
|
3721
|
+
}
|
|
4351
3722
|
setColumnWidth({ left, center, right }) {
|
|
4352
3723
|
const columnWidth = {
|
|
4353
3724
|
...vue.toRaw(this.get("columnWidth"))
|
|
@@ -4361,9 +3732,15 @@
|
|
|
4361
3732
|
if (!center || center === "auto") {
|
|
4362
3733
|
const bodyWidth = globalThis.document.body.clientWidth;
|
|
4363
3734
|
columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
|
|
3735
|
+
if (columnWidth.center <= 0) {
|
|
3736
|
+
columnWidth.left = defaultColumnWidth.left;
|
|
3737
|
+
columnWidth.center = defaultColumnWidth.center;
|
|
3738
|
+
columnWidth.right = defaultColumnWidth.right;
|
|
3739
|
+
}
|
|
4364
3740
|
} else {
|
|
4365
3741
|
columnWidth.center = center;
|
|
4366
3742
|
}
|
|
3743
|
+
globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
|
|
4367
3744
|
state.columnWidth = columnWidth;
|
|
4368
3745
|
}
|
|
4369
3746
|
setStageRect(value) {
|
|
@@ -4416,6 +3793,7 @@
|
|
|
4416
3793
|
type: Function
|
|
4417
3794
|
},
|
|
4418
3795
|
runtimeUrl: String,
|
|
3796
|
+
autoScrollIntoView: Boolean,
|
|
4419
3797
|
propsConfigs: {
|
|
4420
3798
|
type: Object,
|
|
4421
3799
|
default: () => ({})
|
|
@@ -4439,6 +3817,10 @@
|
|
|
4439
3817
|
},
|
|
4440
3818
|
stageRect: {
|
|
4441
3819
|
type: [String, Object]
|
|
3820
|
+
},
|
|
3821
|
+
codeOptions: {
|
|
3822
|
+
type: Object,
|
|
3823
|
+
default: () => ({})
|
|
4442
3824
|
}
|
|
4443
3825
|
},
|
|
4444
3826
|
emits: ["props-panel-mounted", "update:modelValue"],
|
|
@@ -4497,7 +3879,7 @@
|
|
|
4497
3879
|
const _component_workspace = vue.resolveComponent("workspace");
|
|
4498
3880
|
const _component_props_panel = vue.resolveComponent("props-panel");
|
|
4499
3881
|
const _component_framework = vue.resolveComponent("framework");
|
|
4500
|
-
return vue.openBlock(), vue.createBlock(_component_framework,
|
|
3882
|
+
return vue.openBlock(), vue.createBlock(_component_framework, { "code-options": _ctx.codeOptions }, {
|
|
4501
3883
|
nav: vue.withCtx(() => [
|
|
4502
3884
|
vue.renderSlot(_ctx.$slots, "nav", { editorService: _ctx.editorService }, () => [
|
|
4503
3885
|
vue.createVNode(_component_nav_menu, { data: _ctx.menu }, null, 8, ["data"])
|
|
@@ -4512,6 +3894,7 @@
|
|
|
4512
3894
|
vue.renderSlot(_ctx.$slots, "workspace", {}, () => [
|
|
4513
3895
|
vue.createVNode(_component_workspace, {
|
|
4514
3896
|
"runtime-url": _ctx.runtimeUrl,
|
|
3897
|
+
"auto-scroll-into-view": _ctx.autoScrollIntoView,
|
|
4515
3898
|
render: _ctx.render,
|
|
4516
3899
|
"moveable-options": _ctx.moveableOptions,
|
|
4517
3900
|
"can-select": _ctx.canSelect
|
|
@@ -4526,7 +3909,7 @@
|
|
|
4526
3909
|
vue.renderSlot(_ctx.$slots, "page-bar-popover", { page })
|
|
4527
3910
|
]),
|
|
4528
3911
|
_: 3
|
|
4529
|
-
}, 8, ["runtime-url", "render", "moveable-options", "can-select"])
|
|
3912
|
+
}, 8, ["runtime-url", "auto-scroll-into-view", "render", "moveable-options", "can-select"])
|
|
4530
3913
|
])
|
|
4531
3914
|
]),
|
|
4532
3915
|
propsPanel: vue.withCtx(() => [
|
|
@@ -4541,7 +3924,7 @@
|
|
|
4541
3924
|
vue.renderSlot(_ctx.$slots, "empty", { editorService: _ctx.editorService })
|
|
4542
3925
|
]),
|
|
4543
3926
|
_: 3
|
|
4544
|
-
});
|
|
3927
|
+
}, 8, ["code-options"]);
|
|
4545
3928
|
}
|
|
4546
3929
|
var Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
4547
3930
|
|
|
@@ -4572,6 +3955,7 @@
|
|
|
4572
3955
|
exports.PropsPanel = PropsPanel;
|
|
4573
3956
|
exports.TMagicCodeEditor = CodeEditor;
|
|
4574
3957
|
exports.TMagicEditor = Editor;
|
|
3958
|
+
exports.ToolButton = ToolButton;
|
|
4575
3959
|
exports.change2Fixed = change2Fixed;
|
|
4576
3960
|
exports.debug = debug;
|
|
4577
3961
|
exports["default"] = index;
|
|
@@ -4600,8 +3984,7 @@
|
|
|
4600
3984
|
exports.uiService = uiService;
|
|
4601
3985
|
exports.warn = warn;
|
|
4602
3986
|
|
|
4603
|
-
Object.
|
|
4604
|
-
exports[Symbol.toStringTag] = 'Module';
|
|
3987
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4605
3988
|
|
|
4606
3989
|
}));
|
|
4607
3990
|
//# sourceMappingURL=tmagic-editor.umd.js.map
|