@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
package/dist/tmagic-editor.es.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, createElementBlock, createElementVNode, toDisplayString, withModifiers, createCommentVNode, watch, onMounted, onUnmounted, reactive, toRaw, createVNode, withCtx, renderSlot, Fragment, normalizeClass, resolveDynamicComponent, renderList, createTextVNode, normalizeProps, mergeProps, getCurrentInstance, withDirectives, vShow, Teleport, toHandlers, createSlots, nextTick, provide } from 'vue';
|
|
2
2
|
import serialize from 'serialize-javascript';
|
|
3
|
-
import
|
|
3
|
+
import * as monaco from 'monaco-editor';
|
|
4
4
|
import { Plus, Edit, ArrowDown, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Delete, Files, Coin, CaretBottom } from '@element-plus/icons';
|
|
5
|
-
import { cloneDeep, random } from 'lodash-es';
|
|
5
|
+
import { cloneDeep, random, mergeWith } from 'lodash-es';
|
|
6
|
+
import { toLine, isPop, getNodePath } from '@tmagic/utils';
|
|
6
7
|
import { EventEmitter as EventEmitter$2 } from 'events';
|
|
7
8
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
8
9
|
import { ElMessage } from 'element-plus';
|
|
@@ -16,7 +17,7 @@ var _export_sfc = (sfc, props) => {
|
|
|
16
17
|
return target;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
const _sfc_main$
|
|
20
|
+
const _sfc_main$k = defineComponent({
|
|
20
21
|
name: "m-fields-vs-code",
|
|
21
22
|
props: ["model", "name", "config", "prop"],
|
|
22
23
|
emits: ["change"],
|
|
@@ -33,7 +34,7 @@ const _sfc_main$j = defineComponent({
|
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
36
|
});
|
|
36
|
-
function _sfc_render$
|
|
37
|
+
function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
|
|
37
38
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
38
39
|
return openBlock(), createBlock(_component_magic_code_editor, {
|
|
39
40
|
style: normalizeStyle(`height: ${_ctx.height}`),
|
|
@@ -42,9 +43,9 @@ function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
42
43
|
onSave: _ctx.save
|
|
43
44
|
}, null, 8, ["style", "init-values", "language", "onSave"]);
|
|
44
45
|
}
|
|
45
|
-
var Code = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
46
|
+
var Code = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$k]]);
|
|
46
47
|
|
|
47
|
-
const _sfc_main$
|
|
48
|
+
const _sfc_main$j = defineComponent({
|
|
48
49
|
name: "m-fields-code-link",
|
|
49
50
|
props: {
|
|
50
51
|
config: {
|
|
@@ -99,7 +100,7 @@ const _sfc_main$i = defineComponent({
|
|
|
99
100
|
};
|
|
100
101
|
}
|
|
101
102
|
});
|
|
102
|
-
function _sfc_render$
|
|
103
|
+
function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
|
|
103
104
|
const _component_m_fields_link = resolveComponent("m-fields-link");
|
|
104
105
|
return openBlock(), createBlock(_component_m_fields_link, {
|
|
105
106
|
config: _ctx.formConfig,
|
|
@@ -108,11 +109,11 @@ function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
108
109
|
onChange: _ctx.changeHandler
|
|
109
110
|
}, null, 8, ["config", "model", "onChange"]);
|
|
110
111
|
}
|
|
111
|
-
var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
112
|
+
var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$j]]);
|
|
112
113
|
|
|
113
114
|
var UISelect_vue_vue_type_style_index_0_lang = '';
|
|
114
115
|
|
|
115
|
-
const _sfc_main$
|
|
116
|
+
const _sfc_main$i = defineComponent({
|
|
116
117
|
name: "m-fields-ui-select",
|
|
117
118
|
props: {
|
|
118
119
|
labelWidth: String,
|
|
@@ -182,7 +183,7 @@ const _hoisted_2$7 = [
|
|
|
182
183
|
_hoisted_1$d
|
|
183
184
|
];
|
|
184
185
|
const _hoisted_3$5 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-thumb" }, null, -1);
|
|
185
|
-
function _sfc_render$
|
|
186
|
+
function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
186
187
|
return _ctx.uiSelectMode ? (openBlock(), createElementBlock("div", {
|
|
187
188
|
key: 0,
|
|
188
189
|
class: "m-fields-ui-select",
|
|
@@ -201,23 +202,8 @@ function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
201
202
|
})) : createCommentVNode("", true)
|
|
202
203
|
]));
|
|
203
204
|
}
|
|
204
|
-
var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
205
|
+
var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
|
|
205
206
|
|
|
206
|
-
const initEditor = () => {
|
|
207
|
-
if (globalThis.monaco) {
|
|
208
|
-
Promise.resolve(globalThis.monaco);
|
|
209
|
-
}
|
|
210
|
-
return asyncLoadJs(`https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.26.1/min/vs/loader.min.js`).then(() => {
|
|
211
|
-
globalThis.require.config({
|
|
212
|
-
paths: { vs: `https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.26.1/min/vs` }
|
|
213
|
-
});
|
|
214
|
-
return new Promise((resolve) => {
|
|
215
|
-
globalThis.require(["vs/editor/editor.main"], () => {
|
|
216
|
-
resolve(globalThis.monaco);
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
};
|
|
221
207
|
const toString = (v, language) => {
|
|
222
208
|
let value = "";
|
|
223
209
|
if (typeof v !== "string") {
|
|
@@ -233,7 +219,7 @@ const toString = (v, language) => {
|
|
|
233
219
|
}
|
|
234
220
|
return value;
|
|
235
221
|
};
|
|
236
|
-
const _sfc_main$
|
|
222
|
+
const _sfc_main$h = defineComponent({
|
|
237
223
|
name: "magic-code-editor",
|
|
238
224
|
props: {
|
|
239
225
|
initValues: {
|
|
@@ -251,32 +237,34 @@ const _sfc_main$g = defineComponent({
|
|
|
251
237
|
default: () => "javascript"
|
|
252
238
|
}
|
|
253
239
|
},
|
|
254
|
-
emits: ["
|
|
240
|
+
emits: ["initd", "save"],
|
|
255
241
|
setup(props, { emit }) {
|
|
256
242
|
let vsEditor = null;
|
|
243
|
+
let vsDiffEditor = null;
|
|
257
244
|
const values = ref("");
|
|
258
245
|
const loading = ref(false);
|
|
259
246
|
const codeEditor = ref();
|
|
260
247
|
const setEditorValue = (v, m) => {
|
|
261
248
|
values.value = toString(v, props.language);
|
|
262
249
|
if (props.type === "diff") {
|
|
263
|
-
const originalModel =
|
|
264
|
-
const modifiedModel =
|
|
265
|
-
return
|
|
250
|
+
const originalModel = monaco.editor.createModel(values.value, "text/javascript");
|
|
251
|
+
const modifiedModel = monaco.editor.createModel(toString(m, props.language), "text/javascript");
|
|
252
|
+
return vsDiffEditor?.setModel({
|
|
266
253
|
original: originalModel,
|
|
267
254
|
modified: modifiedModel
|
|
268
255
|
});
|
|
269
256
|
}
|
|
270
|
-
return vsEditor
|
|
257
|
+
return vsEditor?.setValue(values.value);
|
|
271
258
|
};
|
|
272
259
|
const resizeHandler = () => {
|
|
273
260
|
vsEditor?.layout();
|
|
261
|
+
vsDiffEditor?.layout();
|
|
274
262
|
};
|
|
275
|
-
const getEditorValue = () =>
|
|
263
|
+
const getEditorValue = () => props.type === "diff" ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue();
|
|
276
264
|
const init = async () => {
|
|
277
265
|
if (!codeEditor.value)
|
|
278
266
|
return;
|
|
279
|
-
|
|
267
|
+
const options = {
|
|
280
268
|
value: values.value,
|
|
281
269
|
language: props.language,
|
|
282
270
|
tabSize: 2,
|
|
@@ -284,10 +272,15 @@ const _sfc_main$g = defineComponent({
|
|
|
284
272
|
fontFamily: 'dm, Menlo, Monaco, "Courier New", monospace',
|
|
285
273
|
fontSize: 15,
|
|
286
274
|
formatOnPaste: true
|
|
287
|
-
}
|
|
275
|
+
};
|
|
276
|
+
if (props.type === "diff") {
|
|
277
|
+
vsDiffEditor = monaco.editor.createDiffEditor(codeEditor.value, options);
|
|
278
|
+
} else {
|
|
279
|
+
vsEditor = monaco.editor.create(codeEditor.value, options);
|
|
280
|
+
}
|
|
288
281
|
setEditorValue(props.initValues, props.modifiedValues);
|
|
289
282
|
loading.value = false;
|
|
290
|
-
emit("
|
|
283
|
+
emit("initd", vsEditor);
|
|
291
284
|
codeEditor.value.addEventListener("keydown", (e) => {
|
|
292
285
|
if (e.keyCode === 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
|
|
293
286
|
e.preventDefault();
|
|
@@ -295,14 +288,14 @@ const _sfc_main$g = defineComponent({
|
|
|
295
288
|
}
|
|
296
289
|
});
|
|
297
290
|
if (props.type !== "diff") {
|
|
298
|
-
vsEditor
|
|
291
|
+
vsEditor?.onDidBlurEditorWidget(() => {
|
|
299
292
|
emit("save", getEditorValue());
|
|
300
293
|
});
|
|
301
294
|
}
|
|
302
295
|
globalThis.addEventListener("resize", resizeHandler);
|
|
303
296
|
};
|
|
304
297
|
watch(() => props.initValues, (v, preV) => {
|
|
305
|
-
if (
|
|
298
|
+
if (v !== preV) {
|
|
306
299
|
setEditorValue(props.initValues, props.modifiedValues);
|
|
307
300
|
}
|
|
308
301
|
}, {
|
|
@@ -311,17 +304,7 @@ const _sfc_main$g = defineComponent({
|
|
|
311
304
|
});
|
|
312
305
|
onMounted(async () => {
|
|
313
306
|
loading.value = true;
|
|
314
|
-
|
|
315
|
-
if (!globalThis.monaco) {
|
|
316
|
-
const interval = setInterval(() => {
|
|
317
|
-
if (globalThis.monaco) {
|
|
318
|
-
clearInterval(interval);
|
|
319
|
-
init();
|
|
320
|
-
}
|
|
321
|
-
}, 300);
|
|
322
|
-
} else {
|
|
323
|
-
init();
|
|
324
|
-
}
|
|
307
|
+
init();
|
|
325
308
|
});
|
|
326
309
|
onUnmounted(() => {
|
|
327
310
|
globalThis.removeEventListener("resize", resizeHandler);
|
|
@@ -331,11 +314,12 @@ const _sfc_main$g = defineComponent({
|
|
|
331
314
|
loading,
|
|
332
315
|
codeEditor,
|
|
333
316
|
getEditor() {
|
|
334
|
-
return vsEditor;
|
|
317
|
+
return vsEditor || vsDiffEditor;
|
|
335
318
|
},
|
|
336
319
|
setEditorValue,
|
|
337
320
|
focus() {
|
|
338
|
-
vsEditor
|
|
321
|
+
vsEditor?.focus();
|
|
322
|
+
vsDiffEditor?.focus();
|
|
339
323
|
}
|
|
340
324
|
};
|
|
341
325
|
}
|
|
@@ -344,10 +328,10 @@ const _hoisted_1$c = {
|
|
|
344
328
|
ref: "codeEditor",
|
|
345
329
|
class: "magic-code-editor"
|
|
346
330
|
};
|
|
347
|
-
function _sfc_render$
|
|
331
|
+
function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
|
|
348
332
|
return openBlock(), createElementBlock("div", _hoisted_1$c, null, 512);
|
|
349
333
|
}
|
|
350
|
-
var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
334
|
+
var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
|
|
351
335
|
|
|
352
336
|
let $TMAGIC_EDITOR = {};
|
|
353
337
|
const setConfig = (option) => {
|
|
@@ -620,6 +604,10 @@ var Layout = /* @__PURE__ */ ((Layout2) => {
|
|
|
620
604
|
Layout2["ABSOLUTE"] = "absolute";
|
|
621
605
|
return Layout2;
|
|
622
606
|
})(Layout || {});
|
|
607
|
+
var Keys = /* @__PURE__ */ ((Keys2) => {
|
|
608
|
+
Keys2["ESCAPE"] = "Space";
|
|
609
|
+
return Keys2;
|
|
610
|
+
})(Keys || {});
|
|
623
611
|
|
|
624
612
|
const COPY_STORAGE_KEY = "$MagicEditorCopyData";
|
|
625
613
|
const generateId = (type) => `${type}_${random(1e4, false)}`;
|
|
@@ -754,22 +742,6 @@ const Fixed2Other = async (node, root, getLayout) => {
|
|
|
754
742
|
}
|
|
755
743
|
return toRelative(node);
|
|
756
744
|
};
|
|
757
|
-
const defaults = (object, source) => {
|
|
758
|
-
let o = source;
|
|
759
|
-
if (Array.isArray(object)) {
|
|
760
|
-
o = object;
|
|
761
|
-
}
|
|
762
|
-
Object.entries(o).forEach(([key, value]) => {
|
|
763
|
-
if (typeof object[key] === "undefined") {
|
|
764
|
-
object[key] = value;
|
|
765
|
-
return;
|
|
766
|
-
}
|
|
767
|
-
if (value && typeof value !== "string" && Object.keys(value).length) {
|
|
768
|
-
object[key] = defaults(cloneDeep(object[key]), value);
|
|
769
|
-
}
|
|
770
|
-
});
|
|
771
|
-
return object;
|
|
772
|
-
};
|
|
773
745
|
|
|
774
746
|
const log = (...args) => {
|
|
775
747
|
};
|
|
@@ -938,7 +910,11 @@ class Editor$1 extends BaseService {
|
|
|
938
910
|
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config2.id}\u7684\u8282\u70B9`);
|
|
939
911
|
const node = cloneDeep(toRaw(info.node));
|
|
940
912
|
let newConfig = await this.toggleFixedPosition(toRaw(config2), node, this.get("root"));
|
|
941
|
-
|
|
913
|
+
newConfig = mergeWith(node, newConfig, (objValue, srcValue) => {
|
|
914
|
+
if (Array.isArray(srcValue)) {
|
|
915
|
+
return srcValue;
|
|
916
|
+
}
|
|
917
|
+
});
|
|
942
918
|
if (!newConfig.type)
|
|
943
919
|
throw new Error("\u914D\u7F6E\u7F3A\u5C11type\u503C");
|
|
944
920
|
if (newConfig.type === "app") {
|
|
@@ -1315,7 +1291,7 @@ const getDefaultPropsValue = (type) => ({
|
|
|
1315
1291
|
name: type
|
|
1316
1292
|
});
|
|
1317
1293
|
|
|
1318
|
-
const _sfc_main$
|
|
1294
|
+
const _sfc_main$g = defineComponent({
|
|
1319
1295
|
components: { Plus },
|
|
1320
1296
|
setup() {
|
|
1321
1297
|
const services = inject("services");
|
|
@@ -1335,7 +1311,7 @@ const _sfc_main$f = defineComponent({
|
|
|
1335
1311
|
const _hoisted_1$b = { class: "m-editor-empty-panel" };
|
|
1336
1312
|
const _hoisted_2$6 = { class: "m-editor-empty-content" };
|
|
1337
1313
|
const _hoisted_3$4 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
1338
|
-
function _sfc_render$
|
|
1314
|
+
function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1339
1315
|
const _component_plus = resolveComponent("plus");
|
|
1340
1316
|
const _component_el_icon = resolveComponent("el-icon");
|
|
1341
1317
|
return openBlock(), createElementBlock("div", _hoisted_1$b, [
|
|
@@ -1357,7 +1333,7 @@ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1357
1333
|
])
|
|
1358
1334
|
]);
|
|
1359
1335
|
}
|
|
1360
|
-
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1336
|
+
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
|
|
1361
1337
|
|
|
1362
1338
|
/*
|
|
1363
1339
|
Copyright (c) 2018 Daybrush
|
|
@@ -2526,7 +2502,7 @@ function (_super) {
|
|
|
2526
2502
|
|
|
2527
2503
|
var Gesto$1 = Gesto;
|
|
2528
2504
|
|
|
2529
|
-
const _sfc_main$
|
|
2505
|
+
const _sfc_main$f = defineComponent({
|
|
2530
2506
|
name: "m-editor-resize",
|
|
2531
2507
|
props: {
|
|
2532
2508
|
type: {
|
|
@@ -2572,14 +2548,14 @@ const _hoisted_1$a = {
|
|
|
2572
2548
|
ref: "target",
|
|
2573
2549
|
class: "m-editor-resizer"
|
|
2574
2550
|
};
|
|
2575
|
-
function _sfc_render$
|
|
2551
|
+
function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2576
2552
|
return openBlock(), createElementBlock("span", _hoisted_1$a, [
|
|
2577
2553
|
renderSlot(_ctx.$slots, "default")
|
|
2578
2554
|
], 512);
|
|
2579
2555
|
}
|
|
2580
|
-
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2556
|
+
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
|
|
2581
2557
|
|
|
2582
|
-
const _sfc_main$
|
|
2558
|
+
const _sfc_main$e = defineComponent({
|
|
2583
2559
|
components: {
|
|
2584
2560
|
AddPageBox,
|
|
2585
2561
|
Resizer
|
|
@@ -2607,7 +2583,7 @@ const _hoisted_2$5 = {
|
|
|
2607
2583
|
key: 1,
|
|
2608
2584
|
class: "m-editor-content"
|
|
2609
2585
|
};
|
|
2610
|
-
function _sfc_render$
|
|
2586
|
+
function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2611
2587
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
2612
2588
|
const _component_resizer = resolveComponent("resizer");
|
|
2613
2589
|
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
@@ -2652,9 +2628,9 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2652
2628
|
]))
|
|
2653
2629
|
]);
|
|
2654
2630
|
}
|
|
2655
|
-
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2631
|
+
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
|
|
2656
2632
|
|
|
2657
|
-
const _sfc_main$
|
|
2633
|
+
const _sfc_main$d = defineComponent({
|
|
2658
2634
|
name: "m-icon",
|
|
2659
2635
|
components: { Edit },
|
|
2660
2636
|
props: {
|
|
@@ -2669,7 +2645,7 @@ const _sfc_main$c = defineComponent({
|
|
|
2669
2645
|
}
|
|
2670
2646
|
});
|
|
2671
2647
|
const _hoisted_1$8 = ["src"];
|
|
2672
|
-
function _sfc_render$
|
|
2648
|
+
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2673
2649
|
const _component_edit = resolveComponent("edit");
|
|
2674
2650
|
const _component_el_icon = resolveComponent("el-icon");
|
|
2675
2651
|
return !_ctx.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
|
|
@@ -2690,9 +2666,9 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2690
2666
|
_: 1
|
|
2691
2667
|
}));
|
|
2692
2668
|
}
|
|
2693
|
-
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2669
|
+
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
|
|
2694
2670
|
|
|
2695
|
-
const _sfc_main$
|
|
2671
|
+
const _sfc_main$c = defineComponent({
|
|
2696
2672
|
components: { MIcon, ArrowDown },
|
|
2697
2673
|
props: {
|
|
2698
2674
|
data: {
|
|
@@ -2840,7 +2816,7 @@ const _hoisted_3$3 = {
|
|
|
2840
2816
|
style: { "margin": "0 5px" }
|
|
2841
2817
|
};
|
|
2842
2818
|
const _hoisted_4$3 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2843
|
-
function _sfc_render$
|
|
2819
|
+
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2844
2820
|
const _component_el_divider = resolveComponent("el-divider");
|
|
2845
2821
|
const _component_m_icon = resolveComponent("m-icon");
|
|
2846
2822
|
const _component_el_button = resolveComponent("el-button");
|
|
@@ -2926,9 +2902,9 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2926
2902
|
}, 8, ["disabled", "onCommand"])) : _ctx.item.type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.item.component), normalizeProps(mergeProps({ key: 5 }, _ctx.item.props || {})), null, 16)) : createCommentVNode("", true)
|
|
2927
2903
|
])) : createCommentVNode("", true);
|
|
2928
2904
|
}
|
|
2929
|
-
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2905
|
+
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
|
|
2930
2906
|
|
|
2931
|
-
const _sfc_main$
|
|
2907
|
+
const _sfc_main$b = defineComponent({
|
|
2932
2908
|
name: "nav-menu",
|
|
2933
2909
|
components: { ToolButton },
|
|
2934
2910
|
props: {
|
|
@@ -2941,12 +2917,14 @@ const _sfc_main$a = defineComponent({
|
|
|
2941
2917
|
}
|
|
2942
2918
|
},
|
|
2943
2919
|
setup(props) {
|
|
2920
|
+
const services = inject("services");
|
|
2944
2921
|
return {
|
|
2945
|
-
keys: computed(() => Object.keys(props.data))
|
|
2922
|
+
keys: computed(() => Object.keys(props.data)),
|
|
2923
|
+
columnWidth: computed(() => services?.uiService.get("columnWidth"))
|
|
2946
2924
|
};
|
|
2947
2925
|
}
|
|
2948
2926
|
});
|
|
2949
|
-
function _sfc_render$
|
|
2927
|
+
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2950
2928
|
const _component_tool_button = resolveComponent("tool-button");
|
|
2951
2929
|
return openBlock(), createElementBlock("div", {
|
|
2952
2930
|
class: "m-editor-nav-menu",
|
|
@@ -2955,7 +2933,8 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2955
2933
|
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.keys, (key) => {
|
|
2956
2934
|
return openBlock(), createElementBlock("div", {
|
|
2957
2935
|
class: normalizeClass(`menu-${key}`),
|
|
2958
|
-
key
|
|
2936
|
+
key,
|
|
2937
|
+
style: normalizeStyle(`width: ${_ctx.columnWidth?.[key]}px`)
|
|
2959
2938
|
}, [
|
|
2960
2939
|
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data[key], (item, index) => {
|
|
2961
2940
|
return openBlock(), createBlock(_component_tool_button, {
|
|
@@ -2963,13 +2942,13 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2963
2942
|
key: index
|
|
2964
2943
|
}, null, 8, ["data"]);
|
|
2965
2944
|
}), 128))
|
|
2966
|
-
],
|
|
2945
|
+
], 6);
|
|
2967
2946
|
}), 128))
|
|
2968
2947
|
], 4);
|
|
2969
2948
|
}
|
|
2970
|
-
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2949
|
+
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
|
|
2971
2950
|
|
|
2972
|
-
const _sfc_main$
|
|
2951
|
+
const _sfc_main$a = defineComponent({
|
|
2973
2952
|
name: "m-editor-props-panel",
|
|
2974
2953
|
emits: ["mounted"],
|
|
2975
2954
|
setup(props, { emit }) {
|
|
@@ -2978,17 +2957,14 @@ const _sfc_main$9 = defineComponent({
|
|
|
2978
2957
|
const configForm = ref();
|
|
2979
2958
|
const curFormConfig = ref([]);
|
|
2980
2959
|
const services = inject("services");
|
|
2960
|
+
const node = computed(() => services?.editorService.get("node"));
|
|
2981
2961
|
const init = async () => {
|
|
2982
|
-
|
|
2983
|
-
if (!node) {
|
|
2962
|
+
if (!node.value) {
|
|
2984
2963
|
curFormConfig.value = [];
|
|
2985
2964
|
return;
|
|
2986
2965
|
}
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
}
|
|
2990
|
-
values.value = node;
|
|
2991
|
-
const type = node.type || (node.items ? "container" : "text");
|
|
2966
|
+
values.value = node.value;
|
|
2967
|
+
const type = node.value.type || (node.value.items ? "container" : "text");
|
|
2992
2968
|
curFormConfig.value = await services?.propsService.getPropsConfig(type) || [];
|
|
2993
2969
|
};
|
|
2994
2970
|
watchEffect(init);
|
|
@@ -3018,7 +2994,7 @@ const _sfc_main$9 = defineComponent({
|
|
|
3018
2994
|
};
|
|
3019
2995
|
}
|
|
3020
2996
|
});
|
|
3021
|
-
function _sfc_render$
|
|
2997
|
+
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3022
2998
|
const _component_m_form = resolveComponent("m-form");
|
|
3023
2999
|
return openBlock(), createBlock(_component_m_form, {
|
|
3024
3000
|
class: "m-editor-props-panel",
|
|
@@ -3029,9 +3005,9 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3029
3005
|
onChange: _ctx.submit
|
|
3030
3006
|
}, null, 8, ["init-values", "config", "onChange"]);
|
|
3031
3007
|
}
|
|
3032
|
-
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3008
|
+
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
|
|
3033
3009
|
|
|
3034
|
-
const _sfc_main$
|
|
3010
|
+
const _sfc_main$9 = defineComponent({
|
|
3035
3011
|
name: "ui-component-panel",
|
|
3036
3012
|
components: { MIcon },
|
|
3037
3013
|
setup() {
|
|
@@ -3058,7 +3034,7 @@ const _sfc_main$8 = defineComponent({
|
|
|
3058
3034
|
});
|
|
3059
3035
|
const _hoisted_1$6 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
3060
3036
|
const _hoisted_2$3 = ["onClick"];
|
|
3061
|
-
function _sfc_render$
|
|
3037
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3062
3038
|
const _component_el_input = resolveComponent("el-input");
|
|
3063
3039
|
const _component_m_icon = resolveComponent("m-icon");
|
|
3064
3040
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
@@ -3125,9 +3101,9 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3125
3101
|
_: 1
|
|
3126
3102
|
});
|
|
3127
3103
|
}
|
|
3128
|
-
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3104
|
+
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
|
|
3129
3105
|
|
|
3130
|
-
const _sfc_main$
|
|
3106
|
+
const _sfc_main$8 = defineComponent({
|
|
3131
3107
|
name: "magic-editor-content-menu",
|
|
3132
3108
|
props: {
|
|
3133
3109
|
componentGroupList: {
|
|
@@ -3176,7 +3152,7 @@ const _hoisted_1$5 = {
|
|
|
3176
3152
|
const _hoisted_2$2 = ["onClick"];
|
|
3177
3153
|
const _hoisted_3$2 = ["onClick"];
|
|
3178
3154
|
const _hoisted_4$2 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
3179
|
-
function _sfc_render$
|
|
3155
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3180
3156
|
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
3181
3157
|
return _ctx.node ? (openBlock(), createElementBlock("div", _hoisted_1$5, [
|
|
3182
3158
|
_ctx.node.items ? (openBlock(), createElementBlock("div", {
|
|
@@ -3238,7 +3214,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3238
3214
|
])
|
|
3239
3215
|
])) : createCommentVNode("", true);
|
|
3240
3216
|
}
|
|
3241
|
-
var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3217
|
+
var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
|
|
3242
3218
|
|
|
3243
3219
|
const select = (data, editorService) => {
|
|
3244
3220
|
if (!data.id) {
|
|
@@ -3345,7 +3321,7 @@ const useContentMenu = (editorService) => {
|
|
|
3345
3321
|
}
|
|
3346
3322
|
};
|
|
3347
3323
|
};
|
|
3348
|
-
const _sfc_main$
|
|
3324
|
+
const _sfc_main$7 = defineComponent({
|
|
3349
3325
|
name: "magic-editor-layer-panel",
|
|
3350
3326
|
components: { LayerMenu },
|
|
3351
3327
|
setup() {
|
|
@@ -3368,7 +3344,7 @@ const _sfc_main$6 = defineComponent({
|
|
|
3368
3344
|
};
|
|
3369
3345
|
}
|
|
3370
3346
|
});
|
|
3371
|
-
function _sfc_render$
|
|
3347
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3372
3348
|
const _component_el_input = resolveComponent("el-input");
|
|
3373
3349
|
const _component_el_tree = resolveComponent("el-tree");
|
|
3374
3350
|
const _component_layer_menu = resolveComponent("layer-menu");
|
|
@@ -3422,9 +3398,9 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3422
3398
|
_: 3
|
|
3423
3399
|
});
|
|
3424
3400
|
}
|
|
3425
|
-
var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3401
|
+
var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7]]);
|
|
3426
3402
|
|
|
3427
|
-
const _sfc_main$
|
|
3403
|
+
const _sfc_main$6 = defineComponent({
|
|
3428
3404
|
name: "m-sidebar",
|
|
3429
3405
|
components: { MIcon },
|
|
3430
3406
|
props: {
|
|
@@ -3472,7 +3448,7 @@ const _hoisted_1$4 = {
|
|
|
3472
3448
|
key: 1,
|
|
3473
3449
|
class: "magic-editor-tab-panel-title"
|
|
3474
3450
|
};
|
|
3475
|
-
function _sfc_render$
|
|
3451
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3476
3452
|
const _component_m_icon = resolveComponent("m-icon");
|
|
3477
3453
|
const _component_el_tab_pane = resolveComponent("el-tab-pane");
|
|
3478
3454
|
const _component_el_tabs = resolveComponent("el-tabs");
|
|
@@ -3519,9 +3495,9 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3519
3495
|
_: 1
|
|
3520
3496
|
}, 8, ["modelValue"])) : createCommentVNode("", true);
|
|
3521
3497
|
}
|
|
3522
|
-
var Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3498
|
+
var Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6]]);
|
|
3523
3499
|
|
|
3524
|
-
const _sfc_main$
|
|
3500
|
+
const _sfc_main$5 = defineComponent({
|
|
3525
3501
|
components: { CaretBottom, Plus },
|
|
3526
3502
|
setup() {
|
|
3527
3503
|
const services = inject("services");
|
|
@@ -3558,7 +3534,7 @@ const _hoisted_1$3 = { class: "m-editor-page-bar" };
|
|
|
3558
3534
|
const _hoisted_2$1 = ["onClick"];
|
|
3559
3535
|
const _hoisted_3$1 = ["onClick"];
|
|
3560
3536
|
const _hoisted_4$1 = ["onClick"];
|
|
3561
|
-
function _sfc_render$
|
|
3537
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3562
3538
|
const _component_plus = resolveComponent("plus");
|
|
3563
3539
|
const _component_el_icon = resolveComponent("el-icon");
|
|
3564
3540
|
const _component_caret_bottom = resolveComponent("caret-bottom");
|
|
@@ -3617,7 +3593,225 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3617
3593
|
}), 128)) : createCommentVNode("", true)
|
|
3618
3594
|
]);
|
|
3619
3595
|
}
|
|
3620
|
-
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3596
|
+
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
|
|
3597
|
+
|
|
3598
|
+
class ScrollViewer$1 {
|
|
3599
|
+
enter = false;
|
|
3600
|
+
targetEnter = false;
|
|
3601
|
+
keydown = false;
|
|
3602
|
+
container;
|
|
3603
|
+
target;
|
|
3604
|
+
zoom = 1;
|
|
3605
|
+
scrollLeft = 0;
|
|
3606
|
+
scrollTop = 0;
|
|
3607
|
+
x = 0;
|
|
3608
|
+
y = 0;
|
|
3609
|
+
resizeObserver = new ResizeObserver((entries) => {
|
|
3610
|
+
for (const { contentRect } of entries) {
|
|
3611
|
+
const { width, height } = contentRect;
|
|
3612
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3613
|
+
const targetWidth = targetRect.width * this.zoom;
|
|
3614
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3615
|
+
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
3616
|
+
if (targetWidth < width) {
|
|
3617
|
+
this.target._left = 0;
|
|
3618
|
+
}
|
|
3619
|
+
if (targetHeight < height) {
|
|
3620
|
+
this.target._top = 0;
|
|
3621
|
+
}
|
|
3622
|
+
this.scroll();
|
|
3623
|
+
}
|
|
3624
|
+
});
|
|
3625
|
+
constructor(options) {
|
|
3626
|
+
this.container = options.container;
|
|
3627
|
+
this.target = options.target;
|
|
3628
|
+
this.zoom = options.zoom;
|
|
3629
|
+
globalThis.addEventListener("keydown", this.keydownHandler);
|
|
3630
|
+
globalThis.addEventListener("keyup", this.keyupHandler);
|
|
3631
|
+
this.container.addEventListener("mouseenter", this.mouseEnterHandler);
|
|
3632
|
+
this.container.addEventListener("mouseleave", this.mouseLeaveHandler);
|
|
3633
|
+
this.target.addEventListener("mouseenter", this.targetMouseEnterHandler);
|
|
3634
|
+
this.target.addEventListener("mouseleave", this.targetMouseLeaveHandler);
|
|
3635
|
+
this.container.addEventListener("wheel", this.wheelHandler);
|
|
3636
|
+
this.resizeObserver.observe(this.container);
|
|
3637
|
+
}
|
|
3638
|
+
destroy() {
|
|
3639
|
+
this.resizeObserver.disconnect();
|
|
3640
|
+
this.container.removeEventListener("mouseenter", this.mouseEnterHandler);
|
|
3641
|
+
this.container.removeEventListener("mouseleave", this.mouseLeaveHandler);
|
|
3642
|
+
this.target.removeEventListener("mouseenter", this.targetMouseEnterHandler);
|
|
3643
|
+
this.target.removeEventListener("mouseleave", this.targetMouseLeaveHandler);
|
|
3644
|
+
globalThis.removeEventListener("keydown", this.keydownHandler);
|
|
3645
|
+
globalThis.removeEventListener("keyup", this.keyupHandler);
|
|
3646
|
+
}
|
|
3647
|
+
setZoom(zoom) {
|
|
3648
|
+
this.zoom = zoom;
|
|
3649
|
+
}
|
|
3650
|
+
scroll() {
|
|
3651
|
+
const scrollLeft = this.target._left;
|
|
3652
|
+
const scrollTop = this.target._top;
|
|
3653
|
+
this.target.style.transform = `translate(${scrollLeft}px, ${scrollTop}px)`;
|
|
3654
|
+
}
|
|
3655
|
+
removeHandler() {
|
|
3656
|
+
this.target.style.cursor = "";
|
|
3657
|
+
this.target.removeEventListener("mousedown", this.mousedownHandler);
|
|
3658
|
+
document.removeEventListener("mousemove", this.mousemoveHandler);
|
|
3659
|
+
document.removeEventListener("mouseup", this.mouseupHandler);
|
|
3660
|
+
}
|
|
3661
|
+
wheelHandler = (event) => {
|
|
3662
|
+
if (this.targetEnter)
|
|
3663
|
+
return;
|
|
3664
|
+
const { deltaX, deltaY, currentTarget } = event;
|
|
3665
|
+
if (currentTarget !== this.container)
|
|
3666
|
+
return;
|
|
3667
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3668
|
+
this.scroll();
|
|
3669
|
+
this.scrollLeft = this.target._left;
|
|
3670
|
+
this.scrollTop = this.target._top;
|
|
3671
|
+
};
|
|
3672
|
+
mouseEnterHandler = () => {
|
|
3673
|
+
this.enter = true;
|
|
3674
|
+
};
|
|
3675
|
+
mouseLeaveHandler = () => {
|
|
3676
|
+
this.enter = false;
|
|
3677
|
+
};
|
|
3678
|
+
targetMouseEnterHandler = () => {
|
|
3679
|
+
this.targetEnter = true;
|
|
3680
|
+
};
|
|
3681
|
+
targetMouseLeaveHandler = () => {
|
|
3682
|
+
this.targetEnter = false;
|
|
3683
|
+
};
|
|
3684
|
+
mousedownHandler = (event) => {
|
|
3685
|
+
if (!this.keydown)
|
|
3686
|
+
return;
|
|
3687
|
+
event.stopImmediatePropagation();
|
|
3688
|
+
event.stopPropagation();
|
|
3689
|
+
this.target.style.cursor = "grabbing";
|
|
3690
|
+
this.x = event.clientX;
|
|
3691
|
+
this.y = event.clientY;
|
|
3692
|
+
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3693
|
+
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3694
|
+
};
|
|
3695
|
+
mouseupHandler = () => {
|
|
3696
|
+
this.x = 0;
|
|
3697
|
+
this.y = 0;
|
|
3698
|
+
this.scrollLeft = this.target._left;
|
|
3699
|
+
this.scrollTop = this.target._top;
|
|
3700
|
+
this.removeHandler();
|
|
3701
|
+
};
|
|
3702
|
+
mousemoveHandler = (event) => {
|
|
3703
|
+
event.stopImmediatePropagation();
|
|
3704
|
+
event.stopPropagation();
|
|
3705
|
+
const deltaX = event.clientX - this.x;
|
|
3706
|
+
const deltaY = event.clientY - this.y;
|
|
3707
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3708
|
+
this.scroll();
|
|
3709
|
+
};
|
|
3710
|
+
keydownHandler = (event) => {
|
|
3711
|
+
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3712
|
+
event.preventDefault();
|
|
3713
|
+
event.stopImmediatePropagation();
|
|
3714
|
+
event.stopPropagation();
|
|
3715
|
+
} else if (this.keydown)
|
|
3716
|
+
return;
|
|
3717
|
+
this.keydown = true;
|
|
3718
|
+
event.preventDefault();
|
|
3719
|
+
this.target.style.cursor = "grab";
|
|
3720
|
+
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3721
|
+
};
|
|
3722
|
+
keyupHandler = (event) => {
|
|
3723
|
+
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3724
|
+
return;
|
|
3725
|
+
}
|
|
3726
|
+
event.preventDefault();
|
|
3727
|
+
event.stopImmediatePropagation();
|
|
3728
|
+
event.stopPropagation();
|
|
3729
|
+
this.keydown = false;
|
|
3730
|
+
event.preventDefault();
|
|
3731
|
+
this.removeHandler();
|
|
3732
|
+
};
|
|
3733
|
+
setScrollOffset(deltaX, deltaY) {
|
|
3734
|
+
const { width, height } = this.container.getBoundingClientRect();
|
|
3735
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3736
|
+
const targetWidth = targetRect.width * this.zoom;
|
|
3737
|
+
const targetHeight = targetRect.height * this.zoom;
|
|
3738
|
+
let y = 0;
|
|
3739
|
+
if (targetHeight > height) {
|
|
3740
|
+
if (deltaY > 0) {
|
|
3741
|
+
y = this.scrollTop + Math.min(targetHeight - height - this.scrollTop, deltaY);
|
|
3742
|
+
} else {
|
|
3743
|
+
y = this.scrollTop + Math.max(-(targetHeight - height + this.scrollTop), deltaY);
|
|
3744
|
+
}
|
|
3745
|
+
}
|
|
3746
|
+
let x = 0;
|
|
3747
|
+
if (targetWidth > width) {
|
|
3748
|
+
if (deltaX > 0) {
|
|
3749
|
+
x = this.scrollLeft + Math.min(targetWidth - width - this.scrollLeft, deltaX);
|
|
3750
|
+
} else {
|
|
3751
|
+
x = this.scrollLeft + Math.max(-(targetWidth - width + this.scrollLeft), deltaX);
|
|
3752
|
+
}
|
|
3753
|
+
}
|
|
3754
|
+
this.target._left = x;
|
|
3755
|
+
this.target._top = y;
|
|
3756
|
+
}
|
|
3757
|
+
}
|
|
3758
|
+
|
|
3759
|
+
const _sfc_main$4 = defineComponent({
|
|
3760
|
+
name: "m-editor-scroll-viewer",
|
|
3761
|
+
props: {
|
|
3762
|
+
width: Number,
|
|
3763
|
+
height: Number,
|
|
3764
|
+
zoom: {
|
|
3765
|
+
type: Number,
|
|
3766
|
+
default: 1
|
|
3767
|
+
}
|
|
3768
|
+
},
|
|
3769
|
+
setup(props) {
|
|
3770
|
+
const container = ref();
|
|
3771
|
+
const el = ref();
|
|
3772
|
+
let scrollViewer;
|
|
3773
|
+
onMounted(() => {
|
|
3774
|
+
if (!container.value || !el.value)
|
|
3775
|
+
return;
|
|
3776
|
+
scrollViewer = new ScrollViewer$1({
|
|
3777
|
+
container: container.value,
|
|
3778
|
+
target: el.value,
|
|
3779
|
+
zoom: props.zoom
|
|
3780
|
+
});
|
|
3781
|
+
});
|
|
3782
|
+
onUnmounted(() => {
|
|
3783
|
+
scrollViewer.destroy();
|
|
3784
|
+
});
|
|
3785
|
+
watch(() => props.zoom, () => {
|
|
3786
|
+
scrollViewer.setZoom(props.zoom);
|
|
3787
|
+
});
|
|
3788
|
+
return {
|
|
3789
|
+
container,
|
|
3790
|
+
el,
|
|
3791
|
+
style: computed(() => `
|
|
3792
|
+
width: ${props.width}px;
|
|
3793
|
+
height: ${props.height}px;
|
|
3794
|
+
position: absolute;
|
|
3795
|
+
margin-top: 30px;
|
|
3796
|
+
`)
|
|
3797
|
+
};
|
|
3798
|
+
}
|
|
3799
|
+
});
|
|
3800
|
+
const _hoisted_1$2 = {
|
|
3801
|
+
class: "m-editor-scroll-viewer-container",
|
|
3802
|
+
ref: "container"
|
|
3803
|
+
};
|
|
3804
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3805
|
+
return openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
3806
|
+
createElementVNode("div", {
|
|
3807
|
+
ref: "el",
|
|
3808
|
+
style: normalizeStyle(_ctx.style)
|
|
3809
|
+
}, [
|
|
3810
|
+
renderSlot(_ctx.$slots, "default")
|
|
3811
|
+
], 4)
|
|
3812
|
+
], 512);
|
|
3813
|
+
}
|
|
3814
|
+
var ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]);
|
|
3621
3815
|
|
|
3622
3816
|
const _sfc_main$3 = defineComponent({
|
|
3623
3817
|
name: "magic-editor-ui-viewer-menu",
|
|
@@ -3678,7 +3872,7 @@ const _sfc_main$3 = defineComponent({
|
|
|
3678
3872
|
};
|
|
3679
3873
|
}
|
|
3680
3874
|
});
|
|
3681
|
-
const _hoisted_1$
|
|
3875
|
+
const _hoisted_1$1 = {
|
|
3682
3876
|
class: "magic-editor-content-menu",
|
|
3683
3877
|
ref: "menu"
|
|
3684
3878
|
};
|
|
@@ -3686,7 +3880,7 @@ const _hoisted_2 = /* @__PURE__ */ createElementVNode("div", { class: "separatio
|
|
|
3686
3880
|
const _hoisted_3 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
3687
3881
|
const _hoisted_4 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
3688
3882
|
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3689
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
3883
|
+
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
3690
3884
|
createElementVNode("div", null, [
|
|
3691
3885
|
_ctx.canCenter ? (openBlock(), createElementBlock("div", {
|
|
3692
3886
|
key: 0,
|
|
@@ -3771,28 +3965,14 @@ const useMenu = () => {
|
|
|
3771
3965
|
const _sfc_main$2 = defineComponent({
|
|
3772
3966
|
name: "magic-stage",
|
|
3773
3967
|
components: {
|
|
3774
|
-
ViewerMenu
|
|
3968
|
+
ViewerMenu,
|
|
3969
|
+
ScrollViewer
|
|
3775
3970
|
},
|
|
3776
3971
|
props: {
|
|
3777
3972
|
render: {
|
|
3778
3973
|
type: Function
|
|
3779
3974
|
},
|
|
3780
3975
|
runtimeUrl: String,
|
|
3781
|
-
root: {
|
|
3782
|
-
type: Object
|
|
3783
|
-
},
|
|
3784
|
-
page: {
|
|
3785
|
-
type: Object
|
|
3786
|
-
},
|
|
3787
|
-
node: {
|
|
3788
|
-
type: Object
|
|
3789
|
-
},
|
|
3790
|
-
uiSelectMode: {
|
|
3791
|
-
type: Boolean
|
|
3792
|
-
},
|
|
3793
|
-
zoom: {
|
|
3794
|
-
type: Number
|
|
3795
|
-
},
|
|
3796
3976
|
canSelect: {
|
|
3797
3977
|
type: Function,
|
|
3798
3978
|
default: (el) => Boolean(el.id)
|
|
@@ -3807,11 +3987,14 @@ const _sfc_main$2 = defineComponent({
|
|
|
3807
3987
|
emits: ["select", "update", "sort"],
|
|
3808
3988
|
setup(props, { emit }) {
|
|
3809
3989
|
const services = inject("services");
|
|
3990
|
+
const stageWrap = ref();
|
|
3810
3991
|
const stageContainer = ref();
|
|
3811
|
-
const
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3992
|
+
const stageRect = computed(() => services?.uiService.get("stageRect"));
|
|
3993
|
+
const uiSelectMode = computed(() => services?.uiService.get("uiSelectMode"));
|
|
3994
|
+
const root = computed(() => services?.editorService.get("root"));
|
|
3995
|
+
const page = computed(() => services?.editorService.get("page"));
|
|
3996
|
+
const zoom = computed(() => services?.uiService.get("zoom"));
|
|
3997
|
+
const node = computed(() => services?.editorService.get("node"));
|
|
3815
3998
|
let stage = null;
|
|
3816
3999
|
let runtime = null;
|
|
3817
4000
|
watchEffect(() => {
|
|
@@ -3819,15 +4002,15 @@ const _sfc_main$2 = defineComponent({
|
|
|
3819
4002
|
return;
|
|
3820
4003
|
if (!stageContainer.value)
|
|
3821
4004
|
return;
|
|
3822
|
-
if (!(props.runtimeUrl || props.render) || !
|
|
4005
|
+
if (!(props.runtimeUrl || props.render) || !root.value)
|
|
3823
4006
|
return;
|
|
3824
4007
|
stage = new StageCore({
|
|
3825
4008
|
render: props.render,
|
|
3826
4009
|
runtimeUrl: props.runtimeUrl,
|
|
3827
|
-
zoom:
|
|
4010
|
+
zoom: zoom.value,
|
|
3828
4011
|
canSelect: (el, stop) => {
|
|
3829
4012
|
const elCanSelect = props.canSelect(el);
|
|
3830
|
-
if (
|
|
4013
|
+
if (uiSelectMode.value && elCanSelect) {
|
|
3831
4014
|
document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
|
|
3832
4015
|
return stop();
|
|
3833
4016
|
}
|
|
@@ -3847,55 +4030,83 @@ const _sfc_main$2 = defineComponent({
|
|
|
3847
4030
|
stage?.on("changeGuides", () => {
|
|
3848
4031
|
services?.uiService.set("showGuides", true);
|
|
3849
4032
|
});
|
|
3850
|
-
if (!
|
|
4033
|
+
if (!node.value?.id)
|
|
3851
4034
|
return;
|
|
3852
4035
|
stage?.on("runtime-ready", (rt) => {
|
|
3853
4036
|
runtime = rt;
|
|
3854
|
-
|
|
3855
|
-
|
|
4037
|
+
root.value && runtime?.updateRootConfig(cloneDeep(toRaw(root.value)));
|
|
4038
|
+
page.value?.id && runtime?.updatePageId?.(page.value.id);
|
|
3856
4039
|
setTimeout(() => {
|
|
3857
|
-
|
|
4040
|
+
node.value && stage?.select(toRaw(node.value.id));
|
|
3858
4041
|
});
|
|
3859
4042
|
});
|
|
3860
4043
|
});
|
|
3861
|
-
watch(
|
|
3862
|
-
if (!stage || !
|
|
4044
|
+
watch(zoom, (zoom2) => {
|
|
4045
|
+
if (!stage || !zoom2)
|
|
3863
4046
|
return;
|
|
3864
|
-
stage
|
|
4047
|
+
stage.setZoom(zoom2);
|
|
3865
4048
|
});
|
|
3866
|
-
watch(
|
|
3867
|
-
if (runtime &&
|
|
3868
|
-
runtime.updateRootConfig(cloneDeep(toRaw(
|
|
4049
|
+
watch(root, (root2) => {
|
|
4050
|
+
if (runtime && root2) {
|
|
4051
|
+
runtime.updateRootConfig(cloneDeep(toRaw(root2)));
|
|
3869
4052
|
}
|
|
3870
4053
|
});
|
|
4054
|
+
watch(() => node.value?.id, (id) => {
|
|
4055
|
+
nextTick(() => {
|
|
4056
|
+
id && stage?.select(id);
|
|
4057
|
+
});
|
|
4058
|
+
});
|
|
4059
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
4060
|
+
for (const { contentRect } of entries) {
|
|
4061
|
+
services?.uiService.set("stageContainerRect", {
|
|
4062
|
+
width: contentRect.width,
|
|
4063
|
+
height: contentRect.height
|
|
4064
|
+
});
|
|
4065
|
+
}
|
|
4066
|
+
});
|
|
4067
|
+
onMounted(() => {
|
|
4068
|
+
stageWrap.value?.container && resizeObserver.observe(stageWrap.value.container);
|
|
4069
|
+
});
|
|
3871
4070
|
onUnmounted(() => {
|
|
3872
4071
|
stage?.destroy();
|
|
4072
|
+
resizeObserver.disconnect();
|
|
3873
4073
|
services?.editorService.set("stage", null);
|
|
3874
4074
|
});
|
|
3875
4075
|
return {
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
4076
|
+
stageWrap,
|
|
4077
|
+
stageContainer,
|
|
4078
|
+
stageRect,
|
|
4079
|
+
zoom,
|
|
4080
|
+
...useMenu()
|
|
3879
4081
|
};
|
|
3880
4082
|
}
|
|
3881
4083
|
});
|
|
3882
|
-
const _hoisted_1$1 = { class: "m-editor-stage" };
|
|
3883
4084
|
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3884
4085
|
const _component_viewer_menu = resolveComponent("viewer-menu");
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
4086
|
+
const _component_scroll_viewer = resolveComponent("scroll-viewer");
|
|
4087
|
+
return openBlock(), createBlock(_component_scroll_viewer, {
|
|
4088
|
+
class: "m-editor-stage",
|
|
4089
|
+
ref: "stageWrap",
|
|
4090
|
+
width: _ctx.stageRect?.width,
|
|
4091
|
+
height: _ctx.stageRect?.height,
|
|
4092
|
+
zoom: _ctx.zoom
|
|
4093
|
+
}, {
|
|
4094
|
+
default: withCtx(() => [
|
|
4095
|
+
createElementVNode("div", {
|
|
4096
|
+
class: "m-editor-stage-container",
|
|
4097
|
+
ref: "stageContainer",
|
|
4098
|
+
onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
|
|
4099
|
+
style: normalizeStyle(`transform: scale(${_ctx.zoom})`)
|
|
4100
|
+
}, null, 36),
|
|
4101
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
4102
|
+
createVNode(_component_viewer_menu, {
|
|
4103
|
+
ref: "menu",
|
|
4104
|
+
style: normalizeStyle(_ctx.menuStyle)
|
|
4105
|
+
}, null, 8, ["style"])
|
|
4106
|
+
]))
|
|
4107
|
+
]),
|
|
4108
|
+
_: 1
|
|
4109
|
+
}, 8, ["width", "height", "zoom"]);
|
|
3899
4110
|
}
|
|
3900
4111
|
var MagicStage = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
|
|
3901
4112
|
|
|
@@ -3919,24 +4130,13 @@ const _sfc_main$1 = defineComponent({
|
|
|
3919
4130
|
},
|
|
3920
4131
|
setup() {
|
|
3921
4132
|
const services = inject("services");
|
|
3922
|
-
const node = computed(() => services?.editorService.get("node"));
|
|
3923
|
-
const stage = computed(() => services?.editorService.get("stage"));
|
|
3924
|
-
watch([() => node.value?.id, stage], ([id, stage2]) => {
|
|
3925
|
-
nextTick(() => {
|
|
3926
|
-
id && stage2?.select(id);
|
|
3927
|
-
});
|
|
3928
|
-
});
|
|
3929
4133
|
return {
|
|
3930
|
-
uiSelectMode: computed(() => services?.uiService.get("uiSelectMode")),
|
|
3931
|
-
root: computed(() => services?.editorService.get("root")),
|
|
3932
4134
|
page: computed(() => services?.editorService.get("page")),
|
|
3933
|
-
zoom: computed(() => services?.uiService.get("zoom")),
|
|
3934
|
-
node,
|
|
3935
4135
|
selectHandler(el) {
|
|
3936
4136
|
services?.editorService.select(el.id);
|
|
3937
4137
|
},
|
|
3938
|
-
updateNodeHandler(
|
|
3939
|
-
services?.editorService.update(
|
|
4138
|
+
updateNodeHandler(node) {
|
|
4139
|
+
services?.editorService.update(node);
|
|
3940
4140
|
},
|
|
3941
4141
|
sortNodeHandler(ev) {
|
|
3942
4142
|
services?.editorService.sort(ev.src, ev.dist);
|
|
@@ -3953,17 +4153,12 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3953
4153
|
key: _ctx.page?.id,
|
|
3954
4154
|
"runtime-url": _ctx.runtimeUrl,
|
|
3955
4155
|
render: _ctx.render,
|
|
3956
|
-
"ui-select-mode": _ctx.uiSelectMode,
|
|
3957
|
-
root: _ctx.root,
|
|
3958
|
-
page: _ctx.page,
|
|
3959
|
-
node: _ctx.node,
|
|
3960
|
-
zoom: _ctx.zoom,
|
|
3961
4156
|
"moveable-options": _ctx.moveableOptions,
|
|
3962
4157
|
"can-select": _ctx.canSelect,
|
|
3963
4158
|
onSelect: _ctx.selectHandler,
|
|
3964
4159
|
onUpdate: _ctx.updateNodeHandler,
|
|
3965
4160
|
onSort: _ctx.sortNodeHandler
|
|
3966
|
-
}, null, 8, ["runtime-url", "render", "
|
|
4161
|
+
}, null, 8, ["runtime-url", "render", "moveable-options", "can-select", "onSelect", "onUpdate", "onSort"])),
|
|
3967
4162
|
renderSlot(_ctx.$slots, "workspace-content"),
|
|
3968
4163
|
createVNode(_component_page_bar, null, {
|
|
3969
4164
|
"page-bar-title": withCtx(({ page }) => [
|
|
@@ -3998,7 +4193,14 @@ const state = reactive({
|
|
|
3998
4193
|
uiSelectMode: false,
|
|
3999
4194
|
showSrc: false,
|
|
4000
4195
|
zoom: 1,
|
|
4001
|
-
|
|
4196
|
+
stageContainerRect: {
|
|
4197
|
+
width: 0,
|
|
4198
|
+
height: 0
|
|
4199
|
+
},
|
|
4200
|
+
stageRect: {
|
|
4201
|
+
width: 375,
|
|
4202
|
+
height: 817
|
|
4203
|
+
},
|
|
4002
4204
|
columnWidth: {
|
|
4003
4205
|
left: 310,
|
|
4004
4206
|
center: globalThis.document.body.clientWidth - 310 - 400,
|
|
@@ -4022,6 +4224,10 @@ class Ui extends BaseService {
|
|
|
4022
4224
|
this.setColumnWidth(value);
|
|
4023
4225
|
return;
|
|
4024
4226
|
}
|
|
4227
|
+
if (name === "stageRect") {
|
|
4228
|
+
this.setStageRect(value);
|
|
4229
|
+
return;
|
|
4230
|
+
}
|
|
4025
4231
|
if (name === "showGuides") {
|
|
4026
4232
|
mask?.showGuides(value);
|
|
4027
4233
|
}
|
|
@@ -4029,6 +4235,9 @@ class Ui extends BaseService {
|
|
|
4029
4235
|
mask?.showRule(value);
|
|
4030
4236
|
}
|
|
4031
4237
|
state[name] = value;
|
|
4238
|
+
if (name === "stageContainerRect") {
|
|
4239
|
+
state.zoom = this.calcZoom();
|
|
4240
|
+
}
|
|
4032
4241
|
}
|
|
4033
4242
|
get(name) {
|
|
4034
4243
|
return state[name];
|
|
@@ -4051,6 +4260,23 @@ class Ui extends BaseService {
|
|
|
4051
4260
|
}
|
|
4052
4261
|
state.columnWidth = columnWidth;
|
|
4053
4262
|
}
|
|
4263
|
+
setStageRect(value) {
|
|
4264
|
+
state.stageRect = {
|
|
4265
|
+
...state.stageRect,
|
|
4266
|
+
...value
|
|
4267
|
+
};
|
|
4268
|
+
state.zoom = this.calcZoom();
|
|
4269
|
+
}
|
|
4270
|
+
calcZoom() {
|
|
4271
|
+
const { stageRect, stageContainerRect } = state;
|
|
4272
|
+
const { height, width } = stageContainerRect;
|
|
4273
|
+
if (!width || !height)
|
|
4274
|
+
return 1;
|
|
4275
|
+
if (width > stageRect.width && height > stageRect.height) {
|
|
4276
|
+
return 1;
|
|
4277
|
+
}
|
|
4278
|
+
return Math.min((width - 100) / stageRect.width || 1, (height - 100) / stageRect.height || 1);
|
|
4279
|
+
}
|
|
4054
4280
|
}
|
|
4055
4281
|
var uiService = new Ui();
|
|
4056
4282
|
|
|
@@ -4105,7 +4331,7 @@ const _sfc_main = defineComponent({
|
|
|
4105
4331
|
canSelect: {
|
|
4106
4332
|
type: Function
|
|
4107
4333
|
},
|
|
4108
|
-
|
|
4334
|
+
stageRect: {
|
|
4109
4335
|
type: [String, Object]
|
|
4110
4336
|
}
|
|
4111
4337
|
},
|
|
@@ -4143,7 +4369,7 @@ const _sfc_main = defineComponent({
|
|
|
4143
4369
|
watch(() => props.defaultSelected, (defaultSelected) => defaultSelected && editorService.select(defaultSelected), {
|
|
4144
4370
|
immediate: true
|
|
4145
4371
|
});
|
|
4146
|
-
watch(() => props.
|
|
4372
|
+
watch(() => props.stageRect, (stageRect) => stageRect && uiService.set("stageRect", stageRect), {
|
|
4147
4373
|
immediate: true
|
|
4148
4374
|
});
|
|
4149
4375
|
onUnmounted(() => editorService.destroy());
|
|
@@ -4229,5 +4455,5 @@ var index = {
|
|
|
4229
4455
|
}
|
|
4230
4456
|
};
|
|
4231
4457
|
|
|
4232
|
-
export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, change2Fixed, debug, index as default,
|
|
4458
|
+
export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, generateId, generatePageName, generatePageNameByApp, getConfig, getDefaultPropsValue, getNodeIndex, getPageList, getPageNameList, historyService, info, initPosition, isFixed, log, propsService, setConfig, setLayout, setNewItemId, toRelative, uiService, warn };
|
|
4233
4459
|
//# sourceMappingURL=tmagic-editor.es.js.map
|