@tmagic/editor 1.0.0-beta.1

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