@tmagic/editor 1.0.0-beta.2 → 1.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/style.css +11 -10
- package/dist/tmagic-editor.es.js +418 -192
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +438 -194
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/Editor.vue.d.ts +5 -5
- package/dist/types/src/components/ScrollViewer.vue.d.ts +23 -0
- package/dist/types/src/layouts/CodeEditor.vue.d.ts +5 -4
- package/dist/types/src/layouts/NavMenu.vue.d.ts +2 -1
- package/dist/types/src/layouts/workspace/Stage.vue.d.ts +76 -37
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +1 -5
- package/dist/types/src/services/ui.d.ts +10 -3
- package/dist/types/src/type.d.ts +15 -6
- package/dist/types/src/utils/editor.d.ts +0 -1
- package/dist/types/src/utils/scroll-viewer.d.ts +35 -0
- package/package.json +8 -6
- package/src/Editor.vue +5 -5
- package/src/components/ScrollViewer.vue +66 -0
- package/src/layouts/CodeEditor.vue +35 -59
- package/src/layouts/NavMenu.vue +7 -3
- package/src/layouts/PropsPanel.vue +5 -10
- package/src/layouts/workspace/Stage.vue +62 -50
- package/src/layouts/workspace/Workspace.vue +2 -21
- package/src/services/editor.ts +6 -3
- package/src/services/ui.ts +36 -2
- package/src/theme/nav-menu.scss +3 -3
- package/src/theme/stage.scss +8 -7
- package/src/type.ts +17 -6
- package/src/utils/editor.ts +1 -20
- package/src/utils/scroll-viewer.ts +214 -0
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.vue, global.serialize, global.
|
|
5
|
-
})(this, (function (exports, vue, serialize,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('monaco-editor'), require('@element-plus/icons'), require('lodash-es'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('element-plus'), require('@tmagic/stage')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', 'monaco-editor', '@element-plus/icons', 'lodash-es', '@tmagic/utils', 'events', '@tmagic/core', 'element-plus', '@tmagic/stage'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.vue, global.serialize, global.monaco, global.icons, global.lodashEs, global.utils, global.events, global.core, global.elementPlus, global.StageCore));
|
|
5
|
+
})(this, (function (exports, vue, serialize, monaco, icons, lodashEs, utils, events, core, elementPlus, StageCore) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = {__proto__: null, [Symbol.toStringTag]: 'Module'};
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n["default"] = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
9
27
|
var serialize__default = /*#__PURE__*/_interopDefaultLegacy(serialize);
|
|
28
|
+
var monaco__namespace = /*#__PURE__*/_interopNamespace(monaco);
|
|
10
29
|
var StageCore__default = /*#__PURE__*/_interopDefaultLegacy(StageCore);
|
|
11
30
|
|
|
12
31
|
var _export_sfc = (sfc, props) => {
|
|
@@ -17,7 +36,7 @@
|
|
|
17
36
|
return target;
|
|
18
37
|
};
|
|
19
38
|
|
|
20
|
-
const _sfc_main$
|
|
39
|
+
const _sfc_main$k = vue.defineComponent({
|
|
21
40
|
name: "m-fields-vs-code",
|
|
22
41
|
props: ["model", "name", "config", "prop"],
|
|
23
42
|
emits: ["change"],
|
|
@@ -34,7 +53,7 @@
|
|
|
34
53
|
};
|
|
35
54
|
}
|
|
36
55
|
});
|
|
37
|
-
function _sfc_render$
|
|
56
|
+
function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
|
|
38
57
|
const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
|
|
39
58
|
return vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
|
|
40
59
|
style: vue.normalizeStyle(`height: ${_ctx.height}`),
|
|
@@ -43,9 +62,9 @@
|
|
|
43
62
|
onSave: _ctx.save
|
|
44
63
|
}, null, 8, ["style", "init-values", "language", "onSave"]);
|
|
45
64
|
}
|
|
46
|
-
var Code = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
65
|
+
var Code = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$k]]);
|
|
47
66
|
|
|
48
|
-
const _sfc_main$
|
|
67
|
+
const _sfc_main$j = vue.defineComponent({
|
|
49
68
|
name: "m-fields-code-link",
|
|
50
69
|
props: {
|
|
51
70
|
config: {
|
|
@@ -100,7 +119,7 @@
|
|
|
100
119
|
};
|
|
101
120
|
}
|
|
102
121
|
});
|
|
103
|
-
function _sfc_render$
|
|
122
|
+
function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
|
|
104
123
|
const _component_m_fields_link = vue.resolveComponent("m-fields-link");
|
|
105
124
|
return vue.openBlock(), vue.createBlock(_component_m_fields_link, {
|
|
106
125
|
config: _ctx.formConfig,
|
|
@@ -109,11 +128,11 @@
|
|
|
109
128
|
onChange: _ctx.changeHandler
|
|
110
129
|
}, null, 8, ["config", "model", "onChange"]);
|
|
111
130
|
}
|
|
112
|
-
var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
131
|
+
var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$j]]);
|
|
113
132
|
|
|
114
133
|
var UISelect_vue_vue_type_style_index_0_lang = '';
|
|
115
134
|
|
|
116
|
-
const _sfc_main$
|
|
135
|
+
const _sfc_main$i = vue.defineComponent({
|
|
117
136
|
name: "m-fields-ui-select",
|
|
118
137
|
props: {
|
|
119
138
|
labelWidth: String,
|
|
@@ -183,7 +202,7 @@
|
|
|
183
202
|
_hoisted_1$d
|
|
184
203
|
];
|
|
185
204
|
const _hoisted_3$5 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-thumb" }, null, -1);
|
|
186
|
-
function _sfc_render$
|
|
205
|
+
function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
187
206
|
return _ctx.uiSelectMode ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
188
207
|
key: 0,
|
|
189
208
|
class: "m-fields-ui-select",
|
|
@@ -202,23 +221,8 @@
|
|
|
202
221
|
})) : vue.createCommentVNode("", true)
|
|
203
222
|
]));
|
|
204
223
|
}
|
|
205
|
-
var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
224
|
+
var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
|
|
206
225
|
|
|
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
226
|
const toString = (v, language) => {
|
|
223
227
|
let value = "";
|
|
224
228
|
if (typeof v !== "string") {
|
|
@@ -234,7 +238,7 @@
|
|
|
234
238
|
}
|
|
235
239
|
return value;
|
|
236
240
|
};
|
|
237
|
-
const _sfc_main$
|
|
241
|
+
const _sfc_main$h = vue.defineComponent({
|
|
238
242
|
name: "magic-code-editor",
|
|
239
243
|
props: {
|
|
240
244
|
initValues: {
|
|
@@ -252,32 +256,34 @@
|
|
|
252
256
|
default: () => "javascript"
|
|
253
257
|
}
|
|
254
258
|
},
|
|
255
|
-
emits: ["
|
|
259
|
+
emits: ["initd", "save"],
|
|
256
260
|
setup(props, { emit }) {
|
|
257
261
|
let vsEditor = null;
|
|
262
|
+
let vsDiffEditor = null;
|
|
258
263
|
const values = vue.ref("");
|
|
259
264
|
const loading = vue.ref(false);
|
|
260
265
|
const codeEditor = vue.ref();
|
|
261
266
|
const setEditorValue = (v, m) => {
|
|
262
267
|
values.value = toString(v, props.language);
|
|
263
268
|
if (props.type === "diff") {
|
|
264
|
-
const originalModel =
|
|
265
|
-
const modifiedModel =
|
|
266
|
-
return
|
|
269
|
+
const originalModel = monaco__namespace.editor.createModel(values.value, "text/javascript");
|
|
270
|
+
const modifiedModel = monaco__namespace.editor.createModel(toString(m, props.language), "text/javascript");
|
|
271
|
+
return vsDiffEditor?.setModel({
|
|
267
272
|
original: originalModel,
|
|
268
273
|
modified: modifiedModel
|
|
269
274
|
});
|
|
270
275
|
}
|
|
271
|
-
return vsEditor
|
|
276
|
+
return vsEditor?.setValue(values.value);
|
|
272
277
|
};
|
|
273
278
|
const resizeHandler = () => {
|
|
274
279
|
vsEditor?.layout();
|
|
280
|
+
vsDiffEditor?.layout();
|
|
275
281
|
};
|
|
276
|
-
const getEditorValue = () =>
|
|
282
|
+
const getEditorValue = () => props.type === "diff" ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue();
|
|
277
283
|
const init = async () => {
|
|
278
284
|
if (!codeEditor.value)
|
|
279
285
|
return;
|
|
280
|
-
|
|
286
|
+
const options = {
|
|
281
287
|
value: values.value,
|
|
282
288
|
language: props.language,
|
|
283
289
|
tabSize: 2,
|
|
@@ -285,10 +291,15 @@
|
|
|
285
291
|
fontFamily: 'dm, Menlo, Monaco, "Courier New", monospace',
|
|
286
292
|
fontSize: 15,
|
|
287
293
|
formatOnPaste: true
|
|
288
|
-
}
|
|
294
|
+
};
|
|
295
|
+
if (props.type === "diff") {
|
|
296
|
+
vsDiffEditor = monaco__namespace.editor.createDiffEditor(codeEditor.value, options);
|
|
297
|
+
} else {
|
|
298
|
+
vsEditor = monaco__namespace.editor.create(codeEditor.value, options);
|
|
299
|
+
}
|
|
289
300
|
setEditorValue(props.initValues, props.modifiedValues);
|
|
290
301
|
loading.value = false;
|
|
291
|
-
emit("
|
|
302
|
+
emit("initd", vsEditor);
|
|
292
303
|
codeEditor.value.addEventListener("keydown", (e) => {
|
|
293
304
|
if (e.keyCode === 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
|
|
294
305
|
e.preventDefault();
|
|
@@ -296,14 +307,14 @@
|
|
|
296
307
|
}
|
|
297
308
|
});
|
|
298
309
|
if (props.type !== "diff") {
|
|
299
|
-
vsEditor
|
|
310
|
+
vsEditor?.onDidBlurEditorWidget(() => {
|
|
300
311
|
emit("save", getEditorValue());
|
|
301
312
|
});
|
|
302
313
|
}
|
|
303
314
|
globalThis.addEventListener("resize", resizeHandler);
|
|
304
315
|
};
|
|
305
316
|
vue.watch(() => props.initValues, (v, preV) => {
|
|
306
|
-
if (
|
|
317
|
+
if (v !== preV) {
|
|
307
318
|
setEditorValue(props.initValues, props.modifiedValues);
|
|
308
319
|
}
|
|
309
320
|
}, {
|
|
@@ -312,17 +323,7 @@
|
|
|
312
323
|
});
|
|
313
324
|
vue.onMounted(async () => {
|
|
314
325
|
loading.value = true;
|
|
315
|
-
|
|
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
|
+
init();
|
|
326
327
|
});
|
|
327
328
|
vue.onUnmounted(() => {
|
|
328
329
|
globalThis.removeEventListener("resize", resizeHandler);
|
|
@@ -332,11 +333,12 @@
|
|
|
332
333
|
loading,
|
|
333
334
|
codeEditor,
|
|
334
335
|
getEditor() {
|
|
335
|
-
return vsEditor;
|
|
336
|
+
return vsEditor || vsDiffEditor;
|
|
336
337
|
},
|
|
337
338
|
setEditorValue,
|
|
338
339
|
focus() {
|
|
339
|
-
vsEditor
|
|
340
|
+
vsEditor?.focus();
|
|
341
|
+
vsDiffEditor?.focus();
|
|
340
342
|
}
|
|
341
343
|
};
|
|
342
344
|
}
|
|
@@ -345,10 +347,10 @@
|
|
|
345
347
|
ref: "codeEditor",
|
|
346
348
|
class: "magic-code-editor"
|
|
347
349
|
};
|
|
348
|
-
function _sfc_render$
|
|
350
|
+
function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
|
|
349
351
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, null, 512);
|
|
350
352
|
}
|
|
351
|
-
var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
353
|
+
var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
|
|
352
354
|
|
|
353
355
|
let $TMAGIC_EDITOR = {};
|
|
354
356
|
const setConfig = (option) => {
|
|
@@ -621,6 +623,10 @@
|
|
|
621
623
|
Layout2["ABSOLUTE"] = "absolute";
|
|
622
624
|
return Layout2;
|
|
623
625
|
})(Layout || {});
|
|
626
|
+
var Keys = /* @__PURE__ */ ((Keys2) => {
|
|
627
|
+
Keys2["ESCAPE"] = "Space";
|
|
628
|
+
return Keys2;
|
|
629
|
+
})(Keys || {});
|
|
624
630
|
|
|
625
631
|
const COPY_STORAGE_KEY = "$MagicEditorCopyData";
|
|
626
632
|
const generateId = (type) => `${type}_${lodashEs.random(1e4, false)}`;
|
|
@@ -755,22 +761,6 @@
|
|
|
755
761
|
}
|
|
756
762
|
return toRelative(node);
|
|
757
763
|
};
|
|
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
764
|
|
|
775
765
|
const log = (...args) => {
|
|
776
766
|
};
|
|
@@ -939,7 +929,11 @@
|
|
|
939
929
|
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config2.id}\u7684\u8282\u70B9`);
|
|
940
930
|
const node = lodashEs.cloneDeep(vue.toRaw(info.node));
|
|
941
931
|
let newConfig = await this.toggleFixedPosition(vue.toRaw(config2), node, this.get("root"));
|
|
942
|
-
|
|
932
|
+
newConfig = lodashEs.mergeWith(node, newConfig, (objValue, srcValue) => {
|
|
933
|
+
if (Array.isArray(srcValue)) {
|
|
934
|
+
return srcValue;
|
|
935
|
+
}
|
|
936
|
+
});
|
|
943
937
|
if (!newConfig.type)
|
|
944
938
|
throw new Error("\u914D\u7F6E\u7F3A\u5C11type\u503C");
|
|
945
939
|
if (newConfig.type === "app") {
|
|
@@ -1316,7 +1310,7 @@
|
|
|
1316
1310
|
name: type
|
|
1317
1311
|
});
|
|
1318
1312
|
|
|
1319
|
-
const _sfc_main$
|
|
1313
|
+
const _sfc_main$g = vue.defineComponent({
|
|
1320
1314
|
components: { Plus: icons.Plus },
|
|
1321
1315
|
setup() {
|
|
1322
1316
|
const services = vue.inject("services");
|
|
@@ -1336,7 +1330,7 @@
|
|
|
1336
1330
|
const _hoisted_1$b = { class: "m-editor-empty-panel" };
|
|
1337
1331
|
const _hoisted_2$6 = { class: "m-editor-empty-content" };
|
|
1338
1332
|
const _hoisted_3$4 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
1339
|
-
function _sfc_render$
|
|
1333
|
+
function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1340
1334
|
const _component_plus = vue.resolveComponent("plus");
|
|
1341
1335
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
1342
1336
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
|
|
@@ -1358,7 +1352,7 @@
|
|
|
1358
1352
|
])
|
|
1359
1353
|
]);
|
|
1360
1354
|
}
|
|
1361
|
-
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1355
|
+
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
|
|
1362
1356
|
|
|
1363
1357
|
/*
|
|
1364
1358
|
Copyright (c) 2018 Daybrush
|
|
@@ -2527,7 +2521,7 @@
|
|
|
2527
2521
|
|
|
2528
2522
|
var Gesto$1 = Gesto;
|
|
2529
2523
|
|
|
2530
|
-
const _sfc_main$
|
|
2524
|
+
const _sfc_main$f = vue.defineComponent({
|
|
2531
2525
|
name: "m-editor-resize",
|
|
2532
2526
|
props: {
|
|
2533
2527
|
type: {
|
|
@@ -2573,14 +2567,14 @@
|
|
|
2573
2567
|
ref: "target",
|
|
2574
2568
|
class: "m-editor-resizer"
|
|
2575
2569
|
};
|
|
2576
|
-
function _sfc_render$
|
|
2570
|
+
function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2577
2571
|
return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$a, [
|
|
2578
2572
|
vue.renderSlot(_ctx.$slots, "default")
|
|
2579
2573
|
], 512);
|
|
2580
2574
|
}
|
|
2581
|
-
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2575
|
+
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
|
|
2582
2576
|
|
|
2583
|
-
const _sfc_main$
|
|
2577
|
+
const _sfc_main$e = vue.defineComponent({
|
|
2584
2578
|
components: {
|
|
2585
2579
|
AddPageBox,
|
|
2586
2580
|
Resizer
|
|
@@ -2608,7 +2602,7 @@
|
|
|
2608
2602
|
key: 1,
|
|
2609
2603
|
class: "m-editor-content"
|
|
2610
2604
|
};
|
|
2611
|
-
function _sfc_render$
|
|
2605
|
+
function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2612
2606
|
const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
|
|
2613
2607
|
const _component_resizer = vue.resolveComponent("resizer");
|
|
2614
2608
|
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
|
|
@@ -2653,9 +2647,9 @@
|
|
|
2653
2647
|
]))
|
|
2654
2648
|
]);
|
|
2655
2649
|
}
|
|
2656
|
-
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2650
|
+
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
|
|
2657
2651
|
|
|
2658
|
-
const _sfc_main$
|
|
2652
|
+
const _sfc_main$d = vue.defineComponent({
|
|
2659
2653
|
name: "m-icon",
|
|
2660
2654
|
components: { Edit: icons.Edit },
|
|
2661
2655
|
props: {
|
|
@@ -2670,7 +2664,7 @@
|
|
|
2670
2664
|
}
|
|
2671
2665
|
});
|
|
2672
2666
|
const _hoisted_1$8 = ["src"];
|
|
2673
|
-
function _sfc_render$
|
|
2667
|
+
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2674
2668
|
const _component_edit = vue.resolveComponent("edit");
|
|
2675
2669
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
2676
2670
|
return !_ctx.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
|
|
@@ -2691,9 +2685,9 @@
|
|
|
2691
2685
|
_: 1
|
|
2692
2686
|
}));
|
|
2693
2687
|
}
|
|
2694
|
-
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2688
|
+
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
|
|
2695
2689
|
|
|
2696
|
-
const _sfc_main$
|
|
2690
|
+
const _sfc_main$c = vue.defineComponent({
|
|
2697
2691
|
components: { MIcon, ArrowDown: icons.ArrowDown },
|
|
2698
2692
|
props: {
|
|
2699
2693
|
data: {
|
|
@@ -2841,7 +2835,7 @@
|
|
|
2841
2835
|
style: { "margin": "0 5px" }
|
|
2842
2836
|
};
|
|
2843
2837
|
const _hoisted_4$3 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2844
|
-
function _sfc_render$
|
|
2838
|
+
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2845
2839
|
const _component_el_divider = vue.resolveComponent("el-divider");
|
|
2846
2840
|
const _component_m_icon = vue.resolveComponent("m-icon");
|
|
2847
2841
|
const _component_el_button = vue.resolveComponent("el-button");
|
|
@@ -2927,9 +2921,9 @@
|
|
|
2927
2921
|
}, 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
2922
|
])) : vue.createCommentVNode("", true);
|
|
2929
2923
|
}
|
|
2930
|
-
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2924
|
+
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
|
|
2931
2925
|
|
|
2932
|
-
const _sfc_main$
|
|
2926
|
+
const _sfc_main$b = vue.defineComponent({
|
|
2933
2927
|
name: "nav-menu",
|
|
2934
2928
|
components: { ToolButton },
|
|
2935
2929
|
props: {
|
|
@@ -2942,12 +2936,14 @@
|
|
|
2942
2936
|
}
|
|
2943
2937
|
},
|
|
2944
2938
|
setup(props) {
|
|
2939
|
+
const services = vue.inject("services");
|
|
2945
2940
|
return {
|
|
2946
|
-
keys: vue.computed(() => Object.keys(props.data))
|
|
2941
|
+
keys: vue.computed(() => Object.keys(props.data)),
|
|
2942
|
+
columnWidth: vue.computed(() => services?.uiService.get("columnWidth"))
|
|
2947
2943
|
};
|
|
2948
2944
|
}
|
|
2949
2945
|
});
|
|
2950
|
-
function _sfc_render$
|
|
2946
|
+
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2951
2947
|
const _component_tool_button = vue.resolveComponent("tool-button");
|
|
2952
2948
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
2953
2949
|
class: "m-editor-nav-menu",
|
|
@@ -2956,7 +2952,8 @@
|
|
|
2956
2952
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.keys, (key) => {
|
|
2957
2953
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
2958
2954
|
class: vue.normalizeClass(`menu-${key}`),
|
|
2959
|
-
key
|
|
2955
|
+
key,
|
|
2956
|
+
style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.[key]}px`)
|
|
2960
2957
|
}, [
|
|
2961
2958
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.data[key], (item, index) => {
|
|
2962
2959
|
return vue.openBlock(), vue.createBlock(_component_tool_button, {
|
|
@@ -2964,13 +2961,13 @@
|
|
|
2964
2961
|
key: index
|
|
2965
2962
|
}, null, 8, ["data"]);
|
|
2966
2963
|
}), 128))
|
|
2967
|
-
],
|
|
2964
|
+
], 6);
|
|
2968
2965
|
}), 128))
|
|
2969
2966
|
], 4);
|
|
2970
2967
|
}
|
|
2971
|
-
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2968
|
+
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
|
|
2972
2969
|
|
|
2973
|
-
const _sfc_main$
|
|
2970
|
+
const _sfc_main$a = vue.defineComponent({
|
|
2974
2971
|
name: "m-editor-props-panel",
|
|
2975
2972
|
emits: ["mounted"],
|
|
2976
2973
|
setup(props, { emit }) {
|
|
@@ -2979,17 +2976,14 @@
|
|
|
2979
2976
|
const configForm = vue.ref();
|
|
2980
2977
|
const curFormConfig = vue.ref([]);
|
|
2981
2978
|
const services = vue.inject("services");
|
|
2979
|
+
const node = vue.computed(() => services?.editorService.get("node"));
|
|
2982
2980
|
const init = async () => {
|
|
2983
|
-
|
|
2984
|
-
if (!node) {
|
|
2981
|
+
if (!node.value) {
|
|
2985
2982
|
curFormConfig.value = [];
|
|
2986
2983
|
return;
|
|
2987
2984
|
}
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
}
|
|
2991
|
-
values.value = node;
|
|
2992
|
-
const type = node.type || (node.items ? "container" : "text");
|
|
2985
|
+
values.value = node.value;
|
|
2986
|
+
const type = node.value.type || (node.value.items ? "container" : "text");
|
|
2993
2987
|
curFormConfig.value = await services?.propsService.getPropsConfig(type) || [];
|
|
2994
2988
|
};
|
|
2995
2989
|
vue.watchEffect(init);
|
|
@@ -3019,7 +3013,7 @@
|
|
|
3019
3013
|
};
|
|
3020
3014
|
}
|
|
3021
3015
|
});
|
|
3022
|
-
function _sfc_render$
|
|
3016
|
+
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3023
3017
|
const _component_m_form = vue.resolveComponent("m-form");
|
|
3024
3018
|
return vue.openBlock(), vue.createBlock(_component_m_form, {
|
|
3025
3019
|
class: "m-editor-props-panel",
|
|
@@ -3030,9 +3024,9 @@
|
|
|
3030
3024
|
onChange: _ctx.submit
|
|
3031
3025
|
}, null, 8, ["init-values", "config", "onChange"]);
|
|
3032
3026
|
}
|
|
3033
|
-
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3027
|
+
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
|
|
3034
3028
|
|
|
3035
|
-
const _sfc_main$
|
|
3029
|
+
const _sfc_main$9 = vue.defineComponent({
|
|
3036
3030
|
name: "ui-component-panel",
|
|
3037
3031
|
components: { MIcon },
|
|
3038
3032
|
setup() {
|
|
@@ -3059,7 +3053,7 @@
|
|
|
3059
3053
|
});
|
|
3060
3054
|
const _hoisted_1$6 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
3061
3055
|
const _hoisted_2$3 = ["onClick"];
|
|
3062
|
-
function _sfc_render$
|
|
3056
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3063
3057
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
3064
3058
|
const _component_m_icon = vue.resolveComponent("m-icon");
|
|
3065
3059
|
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
@@ -3126,9 +3120,9 @@
|
|
|
3126
3120
|
_: 1
|
|
3127
3121
|
});
|
|
3128
3122
|
}
|
|
3129
|
-
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3123
|
+
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
|
|
3130
3124
|
|
|
3131
|
-
const _sfc_main$
|
|
3125
|
+
const _sfc_main$8 = vue.defineComponent({
|
|
3132
3126
|
name: "magic-editor-content-menu",
|
|
3133
3127
|
props: {
|
|
3134
3128
|
componentGroupList: {
|
|
@@ -3177,7 +3171,7 @@
|
|
|
3177
3171
|
const _hoisted_2$2 = ["onClick"];
|
|
3178
3172
|
const _hoisted_3$2 = ["onClick"];
|
|
3179
3173
|
const _hoisted_4$2 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
|
|
3180
|
-
function _sfc_render$
|
|
3174
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3181
3175
|
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
|
|
3182
3176
|
return _ctx.node ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$5, [
|
|
3183
3177
|
_ctx.node.items ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
@@ -3239,7 +3233,7 @@
|
|
|
3239
3233
|
])
|
|
3240
3234
|
])) : vue.createCommentVNode("", true);
|
|
3241
3235
|
}
|
|
3242
|
-
var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3236
|
+
var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
|
|
3243
3237
|
|
|
3244
3238
|
const select = (data, editorService) => {
|
|
3245
3239
|
if (!data.id) {
|
|
@@ -3346,7 +3340,7 @@
|
|
|
3346
3340
|
}
|
|
3347
3341
|
};
|
|
3348
3342
|
};
|
|
3349
|
-
const _sfc_main$
|
|
3343
|
+
const _sfc_main$7 = vue.defineComponent({
|
|
3350
3344
|
name: "magic-editor-layer-panel",
|
|
3351
3345
|
components: { LayerMenu },
|
|
3352
3346
|
setup() {
|
|
@@ -3369,7 +3363,7 @@
|
|
|
3369
3363
|
};
|
|
3370
3364
|
}
|
|
3371
3365
|
});
|
|
3372
|
-
function _sfc_render$
|
|
3366
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3373
3367
|
const _component_el_input = vue.resolveComponent("el-input");
|
|
3374
3368
|
const _component_el_tree = vue.resolveComponent("el-tree");
|
|
3375
3369
|
const _component_layer_menu = vue.resolveComponent("layer-menu");
|
|
@@ -3423,9 +3417,9 @@
|
|
|
3423
3417
|
_: 3
|
|
3424
3418
|
});
|
|
3425
3419
|
}
|
|
3426
|
-
var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3420
|
+
var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7]]);
|
|
3427
3421
|
|
|
3428
|
-
const _sfc_main$
|
|
3422
|
+
const _sfc_main$6 = vue.defineComponent({
|
|
3429
3423
|
name: "m-sidebar",
|
|
3430
3424
|
components: { MIcon },
|
|
3431
3425
|
props: {
|
|
@@ -3473,7 +3467,7 @@
|
|
|
3473
3467
|
key: 1,
|
|
3474
3468
|
class: "magic-editor-tab-panel-title"
|
|
3475
3469
|
};
|
|
3476
|
-
function _sfc_render$
|
|
3470
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3477
3471
|
const _component_m_icon = vue.resolveComponent("m-icon");
|
|
3478
3472
|
const _component_el_tab_pane = vue.resolveComponent("el-tab-pane");
|
|
3479
3473
|
const _component_el_tabs = vue.resolveComponent("el-tabs");
|
|
@@ -3520,9 +3514,9 @@
|
|
|
3520
3514
|
_: 1
|
|
3521
3515
|
}, 8, ["modelValue"])) : vue.createCommentVNode("", true);
|
|
3522
3516
|
}
|
|
3523
|
-
var Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3517
|
+
var Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6]]);
|
|
3524
3518
|
|
|
3525
|
-
const _sfc_main$
|
|
3519
|
+
const _sfc_main$5 = vue.defineComponent({
|
|
3526
3520
|
components: { CaretBottom: icons.CaretBottom, Plus: icons.Plus },
|
|
3527
3521
|
setup() {
|
|
3528
3522
|
const services = vue.inject("services");
|
|
@@ -3559,7 +3553,7 @@
|
|
|
3559
3553
|
const _hoisted_2$1 = ["onClick"];
|
|
3560
3554
|
const _hoisted_3$1 = ["onClick"];
|
|
3561
3555
|
const _hoisted_4$1 = ["onClick"];
|
|
3562
|
-
function _sfc_render$
|
|
3556
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3563
3557
|
const _component_plus = vue.resolveComponent("plus");
|
|
3564
3558
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
3565
3559
|
const _component_caret_bottom = vue.resolveComponent("caret-bottom");
|
|
@@ -3618,7 +3612,225 @@
|
|
|
3618
3612
|
}), 128)) : vue.createCommentVNode("", true)
|
|
3619
3613
|
]);
|
|
3620
3614
|
}
|
|
3621
|
-
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3615
|
+
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
|
|
3616
|
+
|
|
3617
|
+
class ScrollViewer$1 {
|
|
3618
|
+
enter = false;
|
|
3619
|
+
targetEnter = false;
|
|
3620
|
+
keydown = false;
|
|
3621
|
+
container;
|
|
3622
|
+
target;
|
|
3623
|
+
zoom = 1;
|
|
3624
|
+
scrollLeft = 0;
|
|
3625
|
+
scrollTop = 0;
|
|
3626
|
+
x = 0;
|
|
3627
|
+
y = 0;
|
|
3628
|
+
resizeObserver = new ResizeObserver((entries) => {
|
|
3629
|
+
for (const { contentRect } of entries) {
|
|
3630
|
+
const { width, height } = contentRect;
|
|
3631
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3632
|
+
const targetWidth = targetRect.width * this.zoom;
|
|
3633
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3634
|
+
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
3635
|
+
if (targetWidth < width) {
|
|
3636
|
+
this.target._left = 0;
|
|
3637
|
+
}
|
|
3638
|
+
if (targetHeight < height) {
|
|
3639
|
+
this.target._top = 0;
|
|
3640
|
+
}
|
|
3641
|
+
this.scroll();
|
|
3642
|
+
}
|
|
3643
|
+
});
|
|
3644
|
+
constructor(options) {
|
|
3645
|
+
this.container = options.container;
|
|
3646
|
+
this.target = options.target;
|
|
3647
|
+
this.zoom = options.zoom;
|
|
3648
|
+
globalThis.addEventListener("keydown", this.keydownHandler);
|
|
3649
|
+
globalThis.addEventListener("keyup", this.keyupHandler);
|
|
3650
|
+
this.container.addEventListener("mouseenter", this.mouseEnterHandler);
|
|
3651
|
+
this.container.addEventListener("mouseleave", this.mouseLeaveHandler);
|
|
3652
|
+
this.target.addEventListener("mouseenter", this.targetMouseEnterHandler);
|
|
3653
|
+
this.target.addEventListener("mouseleave", this.targetMouseLeaveHandler);
|
|
3654
|
+
this.container.addEventListener("wheel", this.wheelHandler);
|
|
3655
|
+
this.resizeObserver.observe(this.container);
|
|
3656
|
+
}
|
|
3657
|
+
destroy() {
|
|
3658
|
+
this.resizeObserver.disconnect();
|
|
3659
|
+
this.container.removeEventListener("mouseenter", this.mouseEnterHandler);
|
|
3660
|
+
this.container.removeEventListener("mouseleave", this.mouseLeaveHandler);
|
|
3661
|
+
this.target.removeEventListener("mouseenter", this.targetMouseEnterHandler);
|
|
3662
|
+
this.target.removeEventListener("mouseleave", this.targetMouseLeaveHandler);
|
|
3663
|
+
globalThis.removeEventListener("keydown", this.keydownHandler);
|
|
3664
|
+
globalThis.removeEventListener("keyup", this.keyupHandler);
|
|
3665
|
+
}
|
|
3666
|
+
setZoom(zoom) {
|
|
3667
|
+
this.zoom = zoom;
|
|
3668
|
+
}
|
|
3669
|
+
scroll() {
|
|
3670
|
+
const scrollLeft = this.target._left;
|
|
3671
|
+
const scrollTop = this.target._top;
|
|
3672
|
+
this.target.style.transform = `translate(${scrollLeft}px, ${scrollTop}px)`;
|
|
3673
|
+
}
|
|
3674
|
+
removeHandler() {
|
|
3675
|
+
this.target.style.cursor = "";
|
|
3676
|
+
this.target.removeEventListener("mousedown", this.mousedownHandler);
|
|
3677
|
+
document.removeEventListener("mousemove", this.mousemoveHandler);
|
|
3678
|
+
document.removeEventListener("mouseup", this.mouseupHandler);
|
|
3679
|
+
}
|
|
3680
|
+
wheelHandler = (event) => {
|
|
3681
|
+
if (this.targetEnter)
|
|
3682
|
+
return;
|
|
3683
|
+
const { deltaX, deltaY, currentTarget } = event;
|
|
3684
|
+
if (currentTarget !== this.container)
|
|
3685
|
+
return;
|
|
3686
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3687
|
+
this.scroll();
|
|
3688
|
+
this.scrollLeft = this.target._left;
|
|
3689
|
+
this.scrollTop = this.target._top;
|
|
3690
|
+
};
|
|
3691
|
+
mouseEnterHandler = () => {
|
|
3692
|
+
this.enter = true;
|
|
3693
|
+
};
|
|
3694
|
+
mouseLeaveHandler = () => {
|
|
3695
|
+
this.enter = false;
|
|
3696
|
+
};
|
|
3697
|
+
targetMouseEnterHandler = () => {
|
|
3698
|
+
this.targetEnter = true;
|
|
3699
|
+
};
|
|
3700
|
+
targetMouseLeaveHandler = () => {
|
|
3701
|
+
this.targetEnter = false;
|
|
3702
|
+
};
|
|
3703
|
+
mousedownHandler = (event) => {
|
|
3704
|
+
if (!this.keydown)
|
|
3705
|
+
return;
|
|
3706
|
+
event.stopImmediatePropagation();
|
|
3707
|
+
event.stopPropagation();
|
|
3708
|
+
this.target.style.cursor = "grabbing";
|
|
3709
|
+
this.x = event.clientX;
|
|
3710
|
+
this.y = event.clientY;
|
|
3711
|
+
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3712
|
+
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3713
|
+
};
|
|
3714
|
+
mouseupHandler = () => {
|
|
3715
|
+
this.x = 0;
|
|
3716
|
+
this.y = 0;
|
|
3717
|
+
this.scrollLeft = this.target._left;
|
|
3718
|
+
this.scrollTop = this.target._top;
|
|
3719
|
+
this.removeHandler();
|
|
3720
|
+
};
|
|
3721
|
+
mousemoveHandler = (event) => {
|
|
3722
|
+
event.stopImmediatePropagation();
|
|
3723
|
+
event.stopPropagation();
|
|
3724
|
+
const deltaX = event.clientX - this.x;
|
|
3725
|
+
const deltaY = event.clientY - this.y;
|
|
3726
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3727
|
+
this.scroll();
|
|
3728
|
+
};
|
|
3729
|
+
keydownHandler = (event) => {
|
|
3730
|
+
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3731
|
+
event.preventDefault();
|
|
3732
|
+
event.stopImmediatePropagation();
|
|
3733
|
+
event.stopPropagation();
|
|
3734
|
+
} else if (this.keydown)
|
|
3735
|
+
return;
|
|
3736
|
+
this.keydown = true;
|
|
3737
|
+
event.preventDefault();
|
|
3738
|
+
this.target.style.cursor = "grab";
|
|
3739
|
+
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3740
|
+
};
|
|
3741
|
+
keyupHandler = (event) => {
|
|
3742
|
+
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3743
|
+
return;
|
|
3744
|
+
}
|
|
3745
|
+
event.preventDefault();
|
|
3746
|
+
event.stopImmediatePropagation();
|
|
3747
|
+
event.stopPropagation();
|
|
3748
|
+
this.keydown = false;
|
|
3749
|
+
event.preventDefault();
|
|
3750
|
+
this.removeHandler();
|
|
3751
|
+
};
|
|
3752
|
+
setScrollOffset(deltaX, deltaY) {
|
|
3753
|
+
const { width, height } = this.container.getBoundingClientRect();
|
|
3754
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3755
|
+
const targetWidth = targetRect.width * this.zoom;
|
|
3756
|
+
const targetHeight = targetRect.height * this.zoom;
|
|
3757
|
+
let y = 0;
|
|
3758
|
+
if (targetHeight > height) {
|
|
3759
|
+
if (deltaY > 0) {
|
|
3760
|
+
y = this.scrollTop + Math.min(targetHeight - height - this.scrollTop, deltaY);
|
|
3761
|
+
} else {
|
|
3762
|
+
y = this.scrollTop + Math.max(-(targetHeight - height + this.scrollTop), deltaY);
|
|
3763
|
+
}
|
|
3764
|
+
}
|
|
3765
|
+
let x = 0;
|
|
3766
|
+
if (targetWidth > width) {
|
|
3767
|
+
if (deltaX > 0) {
|
|
3768
|
+
x = this.scrollLeft + Math.min(targetWidth - width - this.scrollLeft, deltaX);
|
|
3769
|
+
} else {
|
|
3770
|
+
x = this.scrollLeft + Math.max(-(targetWidth - width + this.scrollLeft), deltaX);
|
|
3771
|
+
}
|
|
3772
|
+
}
|
|
3773
|
+
this.target._left = x;
|
|
3774
|
+
this.target._top = y;
|
|
3775
|
+
}
|
|
3776
|
+
}
|
|
3777
|
+
|
|
3778
|
+
const _sfc_main$4 = vue.defineComponent({
|
|
3779
|
+
name: "m-editor-scroll-viewer",
|
|
3780
|
+
props: {
|
|
3781
|
+
width: Number,
|
|
3782
|
+
height: Number,
|
|
3783
|
+
zoom: {
|
|
3784
|
+
type: Number,
|
|
3785
|
+
default: 1
|
|
3786
|
+
}
|
|
3787
|
+
},
|
|
3788
|
+
setup(props) {
|
|
3789
|
+
const container = vue.ref();
|
|
3790
|
+
const el = vue.ref();
|
|
3791
|
+
let scrollViewer;
|
|
3792
|
+
vue.onMounted(() => {
|
|
3793
|
+
if (!container.value || !el.value)
|
|
3794
|
+
return;
|
|
3795
|
+
scrollViewer = new ScrollViewer$1({
|
|
3796
|
+
container: container.value,
|
|
3797
|
+
target: el.value,
|
|
3798
|
+
zoom: props.zoom
|
|
3799
|
+
});
|
|
3800
|
+
});
|
|
3801
|
+
vue.onUnmounted(() => {
|
|
3802
|
+
scrollViewer.destroy();
|
|
3803
|
+
});
|
|
3804
|
+
vue.watch(() => props.zoom, () => {
|
|
3805
|
+
scrollViewer.setZoom(props.zoom);
|
|
3806
|
+
});
|
|
3807
|
+
return {
|
|
3808
|
+
container,
|
|
3809
|
+
el,
|
|
3810
|
+
style: vue.computed(() => `
|
|
3811
|
+
width: ${props.width}px;
|
|
3812
|
+
height: ${props.height}px;
|
|
3813
|
+
position: absolute;
|
|
3814
|
+
margin-top: 30px;
|
|
3815
|
+
`)
|
|
3816
|
+
};
|
|
3817
|
+
}
|
|
3818
|
+
});
|
|
3819
|
+
const _hoisted_1$2 = {
|
|
3820
|
+
class: "m-editor-scroll-viewer-container",
|
|
3821
|
+
ref: "container"
|
|
3822
|
+
};
|
|
3823
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3824
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
|
|
3825
|
+
vue.createElementVNode("div", {
|
|
3826
|
+
ref: "el",
|
|
3827
|
+
style: vue.normalizeStyle(_ctx.style)
|
|
3828
|
+
}, [
|
|
3829
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
3830
|
+
], 4)
|
|
3831
|
+
], 512);
|
|
3832
|
+
}
|
|
3833
|
+
var ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]);
|
|
3622
3834
|
|
|
3623
3835
|
const _sfc_main$3 = vue.defineComponent({
|
|
3624
3836
|
name: "magic-editor-ui-viewer-menu",
|
|
@@ -3679,7 +3891,7 @@
|
|
|
3679
3891
|
};
|
|
3680
3892
|
}
|
|
3681
3893
|
});
|
|
3682
|
-
const _hoisted_1$
|
|
3894
|
+
const _hoisted_1$1 = {
|
|
3683
3895
|
class: "magic-editor-content-menu",
|
|
3684
3896
|
ref: "menu"
|
|
3685
3897
|
};
|
|
@@ -3687,7 +3899,7 @@
|
|
|
3687
3899
|
const _hoisted_3 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
|
|
3688
3900
|
const _hoisted_4 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
|
|
3689
3901
|
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3690
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
3902
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
|
|
3691
3903
|
vue.createElementVNode("div", null, [
|
|
3692
3904
|
_ctx.canCenter ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3693
3905
|
key: 0,
|
|
@@ -3772,28 +3984,14 @@
|
|
|
3772
3984
|
const _sfc_main$2 = vue.defineComponent({
|
|
3773
3985
|
name: "magic-stage",
|
|
3774
3986
|
components: {
|
|
3775
|
-
ViewerMenu
|
|
3987
|
+
ViewerMenu,
|
|
3988
|
+
ScrollViewer
|
|
3776
3989
|
},
|
|
3777
3990
|
props: {
|
|
3778
3991
|
render: {
|
|
3779
3992
|
type: Function
|
|
3780
3993
|
},
|
|
3781
3994
|
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
3995
|
canSelect: {
|
|
3798
3996
|
type: Function,
|
|
3799
3997
|
default: (el) => Boolean(el.id)
|
|
@@ -3808,11 +4006,14 @@
|
|
|
3808
4006
|
emits: ["select", "update", "sort"],
|
|
3809
4007
|
setup(props, { emit }) {
|
|
3810
4008
|
const services = vue.inject("services");
|
|
4009
|
+
const stageWrap = vue.ref();
|
|
3811
4010
|
const stageContainer = vue.ref();
|
|
3812
|
-
const
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
4011
|
+
const stageRect = vue.computed(() => services?.uiService.get("stageRect"));
|
|
4012
|
+
const uiSelectMode = vue.computed(() => services?.uiService.get("uiSelectMode"));
|
|
4013
|
+
const root = vue.computed(() => services?.editorService.get("root"));
|
|
4014
|
+
const page = vue.computed(() => services?.editorService.get("page"));
|
|
4015
|
+
const zoom = vue.computed(() => services?.uiService.get("zoom"));
|
|
4016
|
+
const node = vue.computed(() => services?.editorService.get("node"));
|
|
3816
4017
|
let stage = null;
|
|
3817
4018
|
let runtime = null;
|
|
3818
4019
|
vue.watchEffect(() => {
|
|
@@ -3820,15 +4021,15 @@
|
|
|
3820
4021
|
return;
|
|
3821
4022
|
if (!stageContainer.value)
|
|
3822
4023
|
return;
|
|
3823
|
-
if (!(props.runtimeUrl || props.render) || !
|
|
4024
|
+
if (!(props.runtimeUrl || props.render) || !root.value)
|
|
3824
4025
|
return;
|
|
3825
4026
|
stage = new StageCore__default["default"]({
|
|
3826
4027
|
render: props.render,
|
|
3827
4028
|
runtimeUrl: props.runtimeUrl,
|
|
3828
|
-
zoom:
|
|
4029
|
+
zoom: zoom.value,
|
|
3829
4030
|
canSelect: (el, stop) => {
|
|
3830
4031
|
const elCanSelect = props.canSelect(el);
|
|
3831
|
-
if (
|
|
4032
|
+
if (uiSelectMode.value && elCanSelect) {
|
|
3832
4033
|
document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
|
|
3833
4034
|
return stop();
|
|
3834
4035
|
}
|
|
@@ -3848,55 +4049,83 @@
|
|
|
3848
4049
|
stage?.on("changeGuides", () => {
|
|
3849
4050
|
services?.uiService.set("showGuides", true);
|
|
3850
4051
|
});
|
|
3851
|
-
if (!
|
|
4052
|
+
if (!node.value?.id)
|
|
3852
4053
|
return;
|
|
3853
4054
|
stage?.on("runtime-ready", (rt) => {
|
|
3854
4055
|
runtime = rt;
|
|
3855
|
-
|
|
3856
|
-
|
|
4056
|
+
root.value && runtime?.updateRootConfig(lodashEs.cloneDeep(vue.toRaw(root.value)));
|
|
4057
|
+
page.value?.id && runtime?.updatePageId?.(page.value.id);
|
|
3857
4058
|
setTimeout(() => {
|
|
3858
|
-
|
|
4059
|
+
node.value && stage?.select(vue.toRaw(node.value.id));
|
|
3859
4060
|
});
|
|
3860
4061
|
});
|
|
3861
4062
|
});
|
|
3862
|
-
vue.watch(
|
|
3863
|
-
if (!stage || !
|
|
4063
|
+
vue.watch(zoom, (zoom2) => {
|
|
4064
|
+
if (!stage || !zoom2)
|
|
3864
4065
|
return;
|
|
3865
|
-
stage
|
|
4066
|
+
stage.setZoom(zoom2);
|
|
3866
4067
|
});
|
|
3867
|
-
vue.watch(
|
|
3868
|
-
if (runtime &&
|
|
3869
|
-
runtime.updateRootConfig(lodashEs.cloneDeep(vue.toRaw(
|
|
4068
|
+
vue.watch(root, (root2) => {
|
|
4069
|
+
if (runtime && root2) {
|
|
4070
|
+
runtime.updateRootConfig(lodashEs.cloneDeep(vue.toRaw(root2)));
|
|
3870
4071
|
}
|
|
3871
4072
|
});
|
|
4073
|
+
vue.watch(() => node.value?.id, (id) => {
|
|
4074
|
+
vue.nextTick(() => {
|
|
4075
|
+
id && stage?.select(id);
|
|
4076
|
+
});
|
|
4077
|
+
});
|
|
4078
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
4079
|
+
for (const { contentRect } of entries) {
|
|
4080
|
+
services?.uiService.set("stageContainerRect", {
|
|
4081
|
+
width: contentRect.width,
|
|
4082
|
+
height: contentRect.height
|
|
4083
|
+
});
|
|
4084
|
+
}
|
|
4085
|
+
});
|
|
4086
|
+
vue.onMounted(() => {
|
|
4087
|
+
stageWrap.value?.container && resizeObserver.observe(stageWrap.value.container);
|
|
4088
|
+
});
|
|
3872
4089
|
vue.onUnmounted(() => {
|
|
3873
4090
|
stage?.destroy();
|
|
4091
|
+
resizeObserver.disconnect();
|
|
3874
4092
|
services?.editorService.set("stage", null);
|
|
3875
4093
|
});
|
|
3876
4094
|
return {
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
4095
|
+
stageWrap,
|
|
4096
|
+
stageContainer,
|
|
4097
|
+
stageRect,
|
|
4098
|
+
zoom,
|
|
4099
|
+
...useMenu()
|
|
3880
4100
|
};
|
|
3881
4101
|
}
|
|
3882
4102
|
});
|
|
3883
|
-
const _hoisted_1$1 = { class: "m-editor-stage" };
|
|
3884
4103
|
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3885
4104
|
const _component_viewer_menu = vue.resolveComponent("viewer-menu");
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
4105
|
+
const _component_scroll_viewer = vue.resolveComponent("scroll-viewer");
|
|
4106
|
+
return vue.openBlock(), vue.createBlock(_component_scroll_viewer, {
|
|
4107
|
+
class: "m-editor-stage",
|
|
4108
|
+
ref: "stageWrap",
|
|
4109
|
+
width: _ctx.stageRect?.width,
|
|
4110
|
+
height: _ctx.stageRect?.height,
|
|
4111
|
+
zoom: _ctx.zoom
|
|
4112
|
+
}, {
|
|
4113
|
+
default: vue.withCtx(() => [
|
|
4114
|
+
vue.createElementVNode("div", {
|
|
4115
|
+
class: "m-editor-stage-container",
|
|
4116
|
+
ref: "stageContainer",
|
|
4117
|
+
onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
|
|
4118
|
+
style: vue.normalizeStyle(`transform: scale(${_ctx.zoom})`)
|
|
4119
|
+
}, null, 36),
|
|
4120
|
+
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
4121
|
+
vue.createVNode(_component_viewer_menu, {
|
|
4122
|
+
ref: "menu",
|
|
4123
|
+
style: vue.normalizeStyle(_ctx.menuStyle)
|
|
4124
|
+
}, null, 8, ["style"])
|
|
4125
|
+
]))
|
|
4126
|
+
]),
|
|
4127
|
+
_: 1
|
|
4128
|
+
}, 8, ["width", "height", "zoom"]);
|
|
3900
4129
|
}
|
|
3901
4130
|
var MagicStage = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
|
|
3902
4131
|
|
|
@@ -3920,24 +4149,13 @@
|
|
|
3920
4149
|
},
|
|
3921
4150
|
setup() {
|
|
3922
4151
|
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
4152
|
return {
|
|
3931
|
-
uiSelectMode: vue.computed(() => services?.uiService.get("uiSelectMode")),
|
|
3932
|
-
root: vue.computed(() => services?.editorService.get("root")),
|
|
3933
4153
|
page: vue.computed(() => services?.editorService.get("page")),
|
|
3934
|
-
zoom: vue.computed(() => services?.uiService.get("zoom")),
|
|
3935
|
-
node,
|
|
3936
4154
|
selectHandler(el) {
|
|
3937
4155
|
services?.editorService.select(el.id);
|
|
3938
4156
|
},
|
|
3939
|
-
updateNodeHandler(
|
|
3940
|
-
services?.editorService.update(
|
|
4157
|
+
updateNodeHandler(node) {
|
|
4158
|
+
services?.editorService.update(node);
|
|
3941
4159
|
},
|
|
3942
4160
|
sortNodeHandler(ev) {
|
|
3943
4161
|
services?.editorService.sort(ev.src, ev.dist);
|
|
@@ -3954,17 +4172,12 @@
|
|
|
3954
4172
|
key: _ctx.page?.id,
|
|
3955
4173
|
"runtime-url": _ctx.runtimeUrl,
|
|
3956
4174
|
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
4175
|
"moveable-options": _ctx.moveableOptions,
|
|
3963
4176
|
"can-select": _ctx.canSelect,
|
|
3964
4177
|
onSelect: _ctx.selectHandler,
|
|
3965
4178
|
onUpdate: _ctx.updateNodeHandler,
|
|
3966
4179
|
onSort: _ctx.sortNodeHandler
|
|
3967
|
-
}, null, 8, ["runtime-url", "render", "
|
|
4180
|
+
}, null, 8, ["runtime-url", "render", "moveable-options", "can-select", "onSelect", "onUpdate", "onSort"])),
|
|
3968
4181
|
vue.renderSlot(_ctx.$slots, "workspace-content"),
|
|
3969
4182
|
vue.createVNode(_component_page_bar, null, {
|
|
3970
4183
|
"page-bar-title": vue.withCtx(({ page }) => [
|
|
@@ -3999,7 +4212,14 @@
|
|
|
3999
4212
|
uiSelectMode: false,
|
|
4000
4213
|
showSrc: false,
|
|
4001
4214
|
zoom: 1,
|
|
4002
|
-
|
|
4215
|
+
stageContainerRect: {
|
|
4216
|
+
width: 0,
|
|
4217
|
+
height: 0
|
|
4218
|
+
},
|
|
4219
|
+
stageRect: {
|
|
4220
|
+
width: 375,
|
|
4221
|
+
height: 817
|
|
4222
|
+
},
|
|
4003
4223
|
columnWidth: {
|
|
4004
4224
|
left: 310,
|
|
4005
4225
|
center: globalThis.document.body.clientWidth - 310 - 400,
|
|
@@ -4023,6 +4243,10 @@
|
|
|
4023
4243
|
this.setColumnWidth(value);
|
|
4024
4244
|
return;
|
|
4025
4245
|
}
|
|
4246
|
+
if (name === "stageRect") {
|
|
4247
|
+
this.setStageRect(value);
|
|
4248
|
+
return;
|
|
4249
|
+
}
|
|
4026
4250
|
if (name === "showGuides") {
|
|
4027
4251
|
mask?.showGuides(value);
|
|
4028
4252
|
}
|
|
@@ -4030,6 +4254,9 @@
|
|
|
4030
4254
|
mask?.showRule(value);
|
|
4031
4255
|
}
|
|
4032
4256
|
state[name] = value;
|
|
4257
|
+
if (name === "stageContainerRect") {
|
|
4258
|
+
state.zoom = this.calcZoom();
|
|
4259
|
+
}
|
|
4033
4260
|
}
|
|
4034
4261
|
get(name) {
|
|
4035
4262
|
return state[name];
|
|
@@ -4052,6 +4279,23 @@
|
|
|
4052
4279
|
}
|
|
4053
4280
|
state.columnWidth = columnWidth;
|
|
4054
4281
|
}
|
|
4282
|
+
setStageRect(value) {
|
|
4283
|
+
state.stageRect = {
|
|
4284
|
+
...state.stageRect,
|
|
4285
|
+
...value
|
|
4286
|
+
};
|
|
4287
|
+
state.zoom = this.calcZoom();
|
|
4288
|
+
}
|
|
4289
|
+
calcZoom() {
|
|
4290
|
+
const { stageRect, stageContainerRect } = state;
|
|
4291
|
+
const { height, width } = stageContainerRect;
|
|
4292
|
+
if (!width || !height)
|
|
4293
|
+
return 1;
|
|
4294
|
+
if (width > stageRect.width && height > stageRect.height) {
|
|
4295
|
+
return 1;
|
|
4296
|
+
}
|
|
4297
|
+
return Math.min((width - 100) / stageRect.width || 1, (height - 100) / stageRect.height || 1);
|
|
4298
|
+
}
|
|
4055
4299
|
}
|
|
4056
4300
|
var uiService = new Ui();
|
|
4057
4301
|
|
|
@@ -4106,7 +4350,7 @@
|
|
|
4106
4350
|
canSelect: {
|
|
4107
4351
|
type: Function
|
|
4108
4352
|
},
|
|
4109
|
-
|
|
4353
|
+
stageRect: {
|
|
4110
4354
|
type: [String, Object]
|
|
4111
4355
|
}
|
|
4112
4356
|
},
|
|
@@ -4144,7 +4388,7 @@
|
|
|
4144
4388
|
vue.watch(() => props.defaultSelected, (defaultSelected) => defaultSelected && editorService.select(defaultSelected), {
|
|
4145
4389
|
immediate: true
|
|
4146
4390
|
});
|
|
4147
|
-
vue.watch(() => props.
|
|
4391
|
+
vue.watch(() => props.stageRect, (stageRect) => stageRect && uiService.set("stageRect", stageRect), {
|
|
4148
4392
|
immediate: true
|
|
4149
4393
|
});
|
|
4150
4394
|
vue.onUnmounted(() => editorService.destroy());
|
|
@@ -4234,6 +4478,7 @@
|
|
|
4234
4478
|
exports.ComponentListPanel = ComponentListPanel;
|
|
4235
4479
|
exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
|
|
4236
4480
|
exports.Fixed2Other = Fixed2Other;
|
|
4481
|
+
exports.Keys = Keys;
|
|
4237
4482
|
exports.LayerOffset = LayerOffset;
|
|
4238
4483
|
exports.LayerPanel = LayerPanel;
|
|
4239
4484
|
exports.Layout = Layout;
|
|
@@ -4243,7 +4488,6 @@
|
|
|
4243
4488
|
exports.change2Fixed = change2Fixed;
|
|
4244
4489
|
exports.debug = debug;
|
|
4245
4490
|
exports["default"] = index;
|
|
4246
|
-
exports.defaults = defaults;
|
|
4247
4491
|
exports.editorService = editorService;
|
|
4248
4492
|
exports.error = error;
|
|
4249
4493
|
exports.eventsService = eventsService;
|