@tmagic/editor 1.0.0-beta.1 → 1.0.0-beta.4
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 +7 -7
- package/dist/tmagic-editor.es.js +403 -167
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +424 -169
- 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/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/scroll-viewer.d.ts +35 -0
- package/package.json +12 -10
- package/src/Editor.vue +5 -5
- package/src/components/ScrollViewer.vue +65 -0
- package/src/layouts/CodeEditor.vue +35 -59
- package/src/layouts/workspace/Stage.vue +62 -50
- package/src/layouts/workspace/Workspace.vue +2 -21
- package/src/services/editor.ts +3 -2
- package/src/services/ui.ts +36 -2
- package/src/theme/stage.scss +7 -7
- package/src/type.ts +17 -6
- package/src/utils/scroll-viewer.ts +213 -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
5
|
import { cloneDeep, random } 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)}`;
|
|
@@ -937,9 +925,6 @@ class Editor$1 extends BaseService {
|
|
|
937
925
|
if (!info.node)
|
|
938
926
|
throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config2.id}\u7684\u8282\u70B9`);
|
|
939
927
|
const node = cloneDeep(toRaw(info.node));
|
|
940
|
-
const { parent } = info;
|
|
941
|
-
if (!parent)
|
|
942
|
-
throw new Error("\u83B7\u53D6\u4E0D\u5230\u7236\u7EA7\u8282\u70B9");
|
|
943
928
|
let newConfig = await this.toggleFixedPosition(toRaw(config2), node, this.get("root"));
|
|
944
929
|
defaults(newConfig, node);
|
|
945
930
|
if (!newConfig.type)
|
|
@@ -948,6 +933,9 @@ class Editor$1 extends BaseService {
|
|
|
948
933
|
this.set("root", newConfig);
|
|
949
934
|
return newConfig;
|
|
950
935
|
}
|
|
936
|
+
const { parent } = info;
|
|
937
|
+
if (!parent)
|
|
938
|
+
throw new Error("\u83B7\u53D6\u4E0D\u5230\u7236\u7EA7\u8282\u70B9");
|
|
951
939
|
const parentNodeItems = parent.items;
|
|
952
940
|
const index = getNodeIndex(newConfig, parent);
|
|
953
941
|
if (!parentNodeItems || typeof index === "undefined" || index === -1)
|
|
@@ -1315,7 +1303,7 @@ const getDefaultPropsValue = (type) => ({
|
|
|
1315
1303
|
name: type
|
|
1316
1304
|
});
|
|
1317
1305
|
|
|
1318
|
-
const _sfc_main$
|
|
1306
|
+
const _sfc_main$g = defineComponent({
|
|
1319
1307
|
components: { Plus },
|
|
1320
1308
|
setup() {
|
|
1321
1309
|
const services = inject("services");
|
|
@@ -1335,7 +1323,7 @@ const _sfc_main$f = defineComponent({
|
|
|
1335
1323
|
const _hoisted_1$b = { class: "m-editor-empty-panel" };
|
|
1336
1324
|
const _hoisted_2$6 = { class: "m-editor-empty-content" };
|
|
1337
1325
|
const _hoisted_3$4 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
1338
|
-
function _sfc_render$
|
|
1326
|
+
function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1339
1327
|
const _component_plus = resolveComponent("plus");
|
|
1340
1328
|
const _component_el_icon = resolveComponent("el-icon");
|
|
1341
1329
|
return openBlock(), createElementBlock("div", _hoisted_1$b, [
|
|
@@ -1357,7 +1345,7 @@ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1357
1345
|
])
|
|
1358
1346
|
]);
|
|
1359
1347
|
}
|
|
1360
|
-
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1348
|
+
var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
|
|
1361
1349
|
|
|
1362
1350
|
/*
|
|
1363
1351
|
Copyright (c) 2018 Daybrush
|
|
@@ -2526,7 +2514,7 @@ function (_super) {
|
|
|
2526
2514
|
|
|
2527
2515
|
var Gesto$1 = Gesto;
|
|
2528
2516
|
|
|
2529
|
-
const _sfc_main$
|
|
2517
|
+
const _sfc_main$f = defineComponent({
|
|
2530
2518
|
name: "m-editor-resize",
|
|
2531
2519
|
props: {
|
|
2532
2520
|
type: {
|
|
@@ -2572,14 +2560,14 @@ const _hoisted_1$a = {
|
|
|
2572
2560
|
ref: "target",
|
|
2573
2561
|
class: "m-editor-resizer"
|
|
2574
2562
|
};
|
|
2575
|
-
function _sfc_render$
|
|
2563
|
+
function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2576
2564
|
return openBlock(), createElementBlock("span", _hoisted_1$a, [
|
|
2577
2565
|
renderSlot(_ctx.$slots, "default")
|
|
2578
2566
|
], 512);
|
|
2579
2567
|
}
|
|
2580
|
-
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2568
|
+
var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
|
|
2581
2569
|
|
|
2582
|
-
const _sfc_main$
|
|
2570
|
+
const _sfc_main$e = defineComponent({
|
|
2583
2571
|
components: {
|
|
2584
2572
|
AddPageBox,
|
|
2585
2573
|
Resizer
|
|
@@ -2607,7 +2595,7 @@ const _hoisted_2$5 = {
|
|
|
2607
2595
|
key: 1,
|
|
2608
2596
|
class: "m-editor-content"
|
|
2609
2597
|
};
|
|
2610
|
-
function _sfc_render$
|
|
2598
|
+
function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2611
2599
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
2612
2600
|
const _component_resizer = resolveComponent("resizer");
|
|
2613
2601
|
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
@@ -2652,9 +2640,9 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2652
2640
|
]))
|
|
2653
2641
|
]);
|
|
2654
2642
|
}
|
|
2655
|
-
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2643
|
+
var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
|
|
2656
2644
|
|
|
2657
|
-
const _sfc_main$
|
|
2645
|
+
const _sfc_main$d = defineComponent({
|
|
2658
2646
|
name: "m-icon",
|
|
2659
2647
|
components: { Edit },
|
|
2660
2648
|
props: {
|
|
@@ -2669,7 +2657,7 @@ const _sfc_main$c = defineComponent({
|
|
|
2669
2657
|
}
|
|
2670
2658
|
});
|
|
2671
2659
|
const _hoisted_1$8 = ["src"];
|
|
2672
|
-
function _sfc_render$
|
|
2660
|
+
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2673
2661
|
const _component_edit = resolveComponent("edit");
|
|
2674
2662
|
const _component_el_icon = resolveComponent("el-icon");
|
|
2675
2663
|
return !_ctx.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
|
|
@@ -2690,9 +2678,9 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2690
2678
|
_: 1
|
|
2691
2679
|
}));
|
|
2692
2680
|
}
|
|
2693
|
-
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2681
|
+
var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
|
|
2694
2682
|
|
|
2695
|
-
const _sfc_main$
|
|
2683
|
+
const _sfc_main$c = defineComponent({
|
|
2696
2684
|
components: { MIcon, ArrowDown },
|
|
2697
2685
|
props: {
|
|
2698
2686
|
data: {
|
|
@@ -2840,7 +2828,7 @@ const _hoisted_3$3 = {
|
|
|
2840
2828
|
style: { "margin": "0 5px" }
|
|
2841
2829
|
};
|
|
2842
2830
|
const _hoisted_4$3 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2843
|
-
function _sfc_render$
|
|
2831
|
+
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2844
2832
|
const _component_el_divider = resolveComponent("el-divider");
|
|
2845
2833
|
const _component_m_icon = resolveComponent("m-icon");
|
|
2846
2834
|
const _component_el_button = resolveComponent("el-button");
|
|
@@ -2926,9 +2914,9 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2926
2914
|
}, 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
2915
|
])) : createCommentVNode("", true);
|
|
2928
2916
|
}
|
|
2929
|
-
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2917
|
+
var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
|
|
2930
2918
|
|
|
2931
|
-
const _sfc_main$
|
|
2919
|
+
const _sfc_main$b = defineComponent({
|
|
2932
2920
|
name: "nav-menu",
|
|
2933
2921
|
components: { ToolButton },
|
|
2934
2922
|
props: {
|
|
@@ -2946,7 +2934,7 @@ const _sfc_main$a = defineComponent({
|
|
|
2946
2934
|
};
|
|
2947
2935
|
}
|
|
2948
2936
|
});
|
|
2949
|
-
function _sfc_render$
|
|
2937
|
+
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2950
2938
|
const _component_tool_button = resolveComponent("tool-button");
|
|
2951
2939
|
return openBlock(), createElementBlock("div", {
|
|
2952
2940
|
class: "m-editor-nav-menu",
|
|
@@ -2967,9 +2955,9 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2967
2955
|
}), 128))
|
|
2968
2956
|
], 4);
|
|
2969
2957
|
}
|
|
2970
|
-
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2958
|
+
var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
|
|
2971
2959
|
|
|
2972
|
-
const _sfc_main$
|
|
2960
|
+
const _sfc_main$a = defineComponent({
|
|
2973
2961
|
name: "m-editor-props-panel",
|
|
2974
2962
|
emits: ["mounted"],
|
|
2975
2963
|
setup(props, { emit }) {
|
|
@@ -3018,7 +3006,7 @@ const _sfc_main$9 = defineComponent({
|
|
|
3018
3006
|
};
|
|
3019
3007
|
}
|
|
3020
3008
|
});
|
|
3021
|
-
function _sfc_render$
|
|
3009
|
+
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3022
3010
|
const _component_m_form = resolveComponent("m-form");
|
|
3023
3011
|
return openBlock(), createBlock(_component_m_form, {
|
|
3024
3012
|
class: "m-editor-props-panel",
|
|
@@ -3029,9 +3017,9 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3029
3017
|
onChange: _ctx.submit
|
|
3030
3018
|
}, null, 8, ["init-values", "config", "onChange"]);
|
|
3031
3019
|
}
|
|
3032
|
-
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3020
|
+
var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
|
|
3033
3021
|
|
|
3034
|
-
const _sfc_main$
|
|
3022
|
+
const _sfc_main$9 = defineComponent({
|
|
3035
3023
|
name: "ui-component-panel",
|
|
3036
3024
|
components: { MIcon },
|
|
3037
3025
|
setup() {
|
|
@@ -3058,7 +3046,7 @@ const _sfc_main$8 = defineComponent({
|
|
|
3058
3046
|
});
|
|
3059
3047
|
const _hoisted_1$6 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
|
|
3060
3048
|
const _hoisted_2$3 = ["onClick"];
|
|
3061
|
-
function _sfc_render$
|
|
3049
|
+
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3062
3050
|
const _component_el_input = resolveComponent("el-input");
|
|
3063
3051
|
const _component_m_icon = resolveComponent("m-icon");
|
|
3064
3052
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
@@ -3125,9 +3113,9 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3125
3113
|
_: 1
|
|
3126
3114
|
});
|
|
3127
3115
|
}
|
|
3128
|
-
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3116
|
+
var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
|
|
3129
3117
|
|
|
3130
|
-
const _sfc_main$
|
|
3118
|
+
const _sfc_main$8 = defineComponent({
|
|
3131
3119
|
name: "magic-editor-content-menu",
|
|
3132
3120
|
props: {
|
|
3133
3121
|
componentGroupList: {
|
|
@@ -3176,7 +3164,7 @@ const _hoisted_1$5 = {
|
|
|
3176
3164
|
const _hoisted_2$2 = ["onClick"];
|
|
3177
3165
|
const _hoisted_3$2 = ["onClick"];
|
|
3178
3166
|
const _hoisted_4$2 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
3179
|
-
function _sfc_render$
|
|
3167
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3180
3168
|
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
3181
3169
|
return _ctx.node ? (openBlock(), createElementBlock("div", _hoisted_1$5, [
|
|
3182
3170
|
_ctx.node.items ? (openBlock(), createElementBlock("div", {
|
|
@@ -3238,7 +3226,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3238
3226
|
])
|
|
3239
3227
|
])) : createCommentVNode("", true);
|
|
3240
3228
|
}
|
|
3241
|
-
var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3229
|
+
var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
|
|
3242
3230
|
|
|
3243
3231
|
const select = (data, editorService) => {
|
|
3244
3232
|
if (!data.id) {
|
|
@@ -3345,7 +3333,7 @@ const useContentMenu = (editorService) => {
|
|
|
3345
3333
|
}
|
|
3346
3334
|
};
|
|
3347
3335
|
};
|
|
3348
|
-
const _sfc_main$
|
|
3336
|
+
const _sfc_main$7 = defineComponent({
|
|
3349
3337
|
name: "magic-editor-layer-panel",
|
|
3350
3338
|
components: { LayerMenu },
|
|
3351
3339
|
setup() {
|
|
@@ -3368,7 +3356,7 @@ const _sfc_main$6 = defineComponent({
|
|
|
3368
3356
|
};
|
|
3369
3357
|
}
|
|
3370
3358
|
});
|
|
3371
|
-
function _sfc_render$
|
|
3359
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3372
3360
|
const _component_el_input = resolveComponent("el-input");
|
|
3373
3361
|
const _component_el_tree = resolveComponent("el-tree");
|
|
3374
3362
|
const _component_layer_menu = resolveComponent("layer-menu");
|
|
@@ -3422,9 +3410,9 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3422
3410
|
_: 3
|
|
3423
3411
|
});
|
|
3424
3412
|
}
|
|
3425
|
-
var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3413
|
+
var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7]]);
|
|
3426
3414
|
|
|
3427
|
-
const _sfc_main$
|
|
3415
|
+
const _sfc_main$6 = defineComponent({
|
|
3428
3416
|
name: "m-sidebar",
|
|
3429
3417
|
components: { MIcon },
|
|
3430
3418
|
props: {
|
|
@@ -3472,7 +3460,7 @@ const _hoisted_1$4 = {
|
|
|
3472
3460
|
key: 1,
|
|
3473
3461
|
class: "magic-editor-tab-panel-title"
|
|
3474
3462
|
};
|
|
3475
|
-
function _sfc_render$
|
|
3463
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3476
3464
|
const _component_m_icon = resolveComponent("m-icon");
|
|
3477
3465
|
const _component_el_tab_pane = resolveComponent("el-tab-pane");
|
|
3478
3466
|
const _component_el_tabs = resolveComponent("el-tabs");
|
|
@@ -3519,9 +3507,9 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3519
3507
|
_: 1
|
|
3520
3508
|
}, 8, ["modelValue"])) : createCommentVNode("", true);
|
|
3521
3509
|
}
|
|
3522
|
-
var Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3510
|
+
var Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6]]);
|
|
3523
3511
|
|
|
3524
|
-
const _sfc_main$
|
|
3512
|
+
const _sfc_main$5 = defineComponent({
|
|
3525
3513
|
components: { CaretBottom, Plus },
|
|
3526
3514
|
setup() {
|
|
3527
3515
|
const services = inject("services");
|
|
@@ -3558,7 +3546,7 @@ const _hoisted_1$3 = { class: "m-editor-page-bar" };
|
|
|
3558
3546
|
const _hoisted_2$1 = ["onClick"];
|
|
3559
3547
|
const _hoisted_3$1 = ["onClick"];
|
|
3560
3548
|
const _hoisted_4$1 = ["onClick"];
|
|
3561
|
-
function _sfc_render$
|
|
3549
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3562
3550
|
const _component_plus = resolveComponent("plus");
|
|
3563
3551
|
const _component_el_icon = resolveComponent("el-icon");
|
|
3564
3552
|
const _component_caret_bottom = resolveComponent("caret-bottom");
|
|
@@ -3617,7 +3605,223 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3617
3605
|
}), 128)) : createCommentVNode("", true)
|
|
3618
3606
|
]);
|
|
3619
3607
|
}
|
|
3620
|
-
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3608
|
+
var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
|
|
3609
|
+
|
|
3610
|
+
class ScrollViewer$1 {
|
|
3611
|
+
enter = false;
|
|
3612
|
+
targetEnter = false;
|
|
3613
|
+
keydown = false;
|
|
3614
|
+
container;
|
|
3615
|
+
target;
|
|
3616
|
+
zoom = 1;
|
|
3617
|
+
scrollLeft = 0;
|
|
3618
|
+
scrollTop = 0;
|
|
3619
|
+
x = 0;
|
|
3620
|
+
y = 0;
|
|
3621
|
+
resizeObserver = new ResizeObserver((entries) => {
|
|
3622
|
+
for (const { contentRect } of entries) {
|
|
3623
|
+
const { width, height } = contentRect;
|
|
3624
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3625
|
+
const targetWidth = targetRect.width * this.zoom;
|
|
3626
|
+
const targetHeight = targetRect.height * this.zoom;
|
|
3627
|
+
if (targetWidth < width) {
|
|
3628
|
+
this.target._left = 0;
|
|
3629
|
+
}
|
|
3630
|
+
if (targetHeight < height) {
|
|
3631
|
+
this.target._top = 0;
|
|
3632
|
+
}
|
|
3633
|
+
this.scroll();
|
|
3634
|
+
}
|
|
3635
|
+
});
|
|
3636
|
+
constructor(options) {
|
|
3637
|
+
this.container = options.container;
|
|
3638
|
+
this.target = options.target;
|
|
3639
|
+
this.zoom = options.zoom;
|
|
3640
|
+
globalThis.addEventListener("keydown", this.keydownHandler);
|
|
3641
|
+
globalThis.addEventListener("keyup", this.keyupHandler);
|
|
3642
|
+
this.container.addEventListener("mouseenter", this.mouseEnterHandler);
|
|
3643
|
+
this.container.addEventListener("mouseleave", this.mouseLeaveHandler);
|
|
3644
|
+
this.target.addEventListener("mouseenter", this.targetMouseEnterHandler);
|
|
3645
|
+
this.target.addEventListener("mouseleave", this.targetMouseLeaveHandler);
|
|
3646
|
+
this.container.addEventListener("wheel", this.wheelHandler);
|
|
3647
|
+
this.resizeObserver.observe(this.container);
|
|
3648
|
+
}
|
|
3649
|
+
destroy() {
|
|
3650
|
+
this.resizeObserver.disconnect();
|
|
3651
|
+
this.container.removeEventListener("mouseenter", this.mouseEnterHandler);
|
|
3652
|
+
this.container.removeEventListener("mouseleave", this.mouseLeaveHandler);
|
|
3653
|
+
this.target.removeEventListener("mouseenter", this.targetMouseEnterHandler);
|
|
3654
|
+
this.target.removeEventListener("mouseleave", this.targetMouseLeaveHandler);
|
|
3655
|
+
globalThis.removeEventListener("keydown", this.keydownHandler);
|
|
3656
|
+
globalThis.removeEventListener("keyup", this.keyupHandler);
|
|
3657
|
+
}
|
|
3658
|
+
setZoom(zoom) {
|
|
3659
|
+
this.zoom = zoom;
|
|
3660
|
+
}
|
|
3661
|
+
scroll() {
|
|
3662
|
+
const scrollLeft = this.target._left;
|
|
3663
|
+
const scrollTop = this.target._top;
|
|
3664
|
+
this.target.style.transform = `translate(${scrollLeft}px, ${scrollTop}px)`;
|
|
3665
|
+
}
|
|
3666
|
+
removeHandler() {
|
|
3667
|
+
this.target.style.cursor = "";
|
|
3668
|
+
this.target.removeEventListener("mousedown", this.mousedownHandler);
|
|
3669
|
+
document.removeEventListener("mousemove", this.mousemoveHandler);
|
|
3670
|
+
document.removeEventListener("mouseup", this.mouseupHandler);
|
|
3671
|
+
}
|
|
3672
|
+
wheelHandler = (event) => {
|
|
3673
|
+
if (this.targetEnter)
|
|
3674
|
+
return;
|
|
3675
|
+
const { deltaX, deltaY, currentTarget } = event;
|
|
3676
|
+
if (currentTarget !== this.container)
|
|
3677
|
+
return;
|
|
3678
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3679
|
+
this.scroll();
|
|
3680
|
+
this.scrollLeft = this.target._left;
|
|
3681
|
+
this.scrollTop = this.target._top;
|
|
3682
|
+
};
|
|
3683
|
+
mouseEnterHandler = () => {
|
|
3684
|
+
this.enter = true;
|
|
3685
|
+
};
|
|
3686
|
+
mouseLeaveHandler = () => {
|
|
3687
|
+
this.enter = false;
|
|
3688
|
+
};
|
|
3689
|
+
targetMouseEnterHandler = () => {
|
|
3690
|
+
this.targetEnter = true;
|
|
3691
|
+
};
|
|
3692
|
+
targetMouseLeaveHandler = () => {
|
|
3693
|
+
this.targetEnter = false;
|
|
3694
|
+
};
|
|
3695
|
+
mousedownHandler = (event) => {
|
|
3696
|
+
if (!this.keydown)
|
|
3697
|
+
return;
|
|
3698
|
+
event.stopImmediatePropagation();
|
|
3699
|
+
event.stopPropagation();
|
|
3700
|
+
this.target.style.cursor = "grabbing";
|
|
3701
|
+
this.x = event.clientX;
|
|
3702
|
+
this.y = event.clientY;
|
|
3703
|
+
document.addEventListener("mousemove", this.mousemoveHandler);
|
|
3704
|
+
document.addEventListener("mouseup", this.mouseupHandler);
|
|
3705
|
+
};
|
|
3706
|
+
mouseupHandler = () => {
|
|
3707
|
+
this.x = 0;
|
|
3708
|
+
this.y = 0;
|
|
3709
|
+
this.scrollLeft = this.target._left;
|
|
3710
|
+
this.scrollTop = this.target._top;
|
|
3711
|
+
this.removeHandler();
|
|
3712
|
+
};
|
|
3713
|
+
mousemoveHandler = (event) => {
|
|
3714
|
+
event.stopImmediatePropagation();
|
|
3715
|
+
event.stopPropagation();
|
|
3716
|
+
const deltaX = event.clientX - this.x;
|
|
3717
|
+
const deltaY = event.clientY - this.y;
|
|
3718
|
+
this.setScrollOffset(deltaX, deltaY);
|
|
3719
|
+
this.scroll();
|
|
3720
|
+
};
|
|
3721
|
+
keydownHandler = (event) => {
|
|
3722
|
+
if (event.code === Keys.ESCAPE && this.enter) {
|
|
3723
|
+
event.preventDefault();
|
|
3724
|
+
event.stopImmediatePropagation();
|
|
3725
|
+
event.stopPropagation();
|
|
3726
|
+
} else if (this.keydown)
|
|
3727
|
+
return;
|
|
3728
|
+
this.keydown = true;
|
|
3729
|
+
event.preventDefault();
|
|
3730
|
+
this.target.style.cursor = "grab";
|
|
3731
|
+
this.container.addEventListener("mousedown", this.mousedownHandler);
|
|
3732
|
+
};
|
|
3733
|
+
keyupHandler = (event) => {
|
|
3734
|
+
if (event.code !== Keys.ESCAPE || !this.keydown) {
|
|
3735
|
+
return;
|
|
3736
|
+
}
|
|
3737
|
+
event.preventDefault();
|
|
3738
|
+
event.stopImmediatePropagation();
|
|
3739
|
+
event.stopPropagation();
|
|
3740
|
+
this.keydown = false;
|
|
3741
|
+
event.preventDefault();
|
|
3742
|
+
this.removeHandler();
|
|
3743
|
+
};
|
|
3744
|
+
setScrollOffset(deltaX, deltaY) {
|
|
3745
|
+
const { width, height } = this.container.getBoundingClientRect();
|
|
3746
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3747
|
+
const targetWidth = targetRect.width * this.zoom;
|
|
3748
|
+
const targetHeight = targetRect.height * this.zoom;
|
|
3749
|
+
let y = 0;
|
|
3750
|
+
if (targetHeight > height) {
|
|
3751
|
+
if (deltaY > 0) {
|
|
3752
|
+
y = this.scrollTop + Math.min(targetHeight - height - this.scrollTop, deltaY);
|
|
3753
|
+
} else {
|
|
3754
|
+
y = this.scrollTop + Math.max(-(targetHeight - height + this.scrollTop), deltaY);
|
|
3755
|
+
}
|
|
3756
|
+
}
|
|
3757
|
+
let x = 0;
|
|
3758
|
+
if (targetWidth > width) {
|
|
3759
|
+
if (deltaX > 0) {
|
|
3760
|
+
x = this.scrollLeft + Math.min(targetWidth - width - this.scrollLeft, deltaX);
|
|
3761
|
+
} else {
|
|
3762
|
+
x = this.scrollLeft + Math.max(-(targetWidth - width + this.scrollLeft), deltaX);
|
|
3763
|
+
}
|
|
3764
|
+
}
|
|
3765
|
+
this.target._left = x;
|
|
3766
|
+
this.target._top = y;
|
|
3767
|
+
}
|
|
3768
|
+
}
|
|
3769
|
+
|
|
3770
|
+
const _sfc_main$4 = defineComponent({
|
|
3771
|
+
name: "m-editor-scroll-viewer",
|
|
3772
|
+
props: {
|
|
3773
|
+
width: Number,
|
|
3774
|
+
height: Number,
|
|
3775
|
+
zoom: {
|
|
3776
|
+
type: Number,
|
|
3777
|
+
default: 1
|
|
3778
|
+
}
|
|
3779
|
+
},
|
|
3780
|
+
setup(props) {
|
|
3781
|
+
const container = ref();
|
|
3782
|
+
const el = ref();
|
|
3783
|
+
let scrollViewer;
|
|
3784
|
+
onMounted(() => {
|
|
3785
|
+
if (!container.value || !el.value)
|
|
3786
|
+
return;
|
|
3787
|
+
scrollViewer = new ScrollViewer$1({
|
|
3788
|
+
container: container.value,
|
|
3789
|
+
target: el.value,
|
|
3790
|
+
zoom: props.zoom
|
|
3791
|
+
});
|
|
3792
|
+
});
|
|
3793
|
+
onUnmounted(() => {
|
|
3794
|
+
scrollViewer.destroy();
|
|
3795
|
+
});
|
|
3796
|
+
watch(() => props.zoom, () => {
|
|
3797
|
+
scrollViewer.setZoom(props.zoom);
|
|
3798
|
+
});
|
|
3799
|
+
return {
|
|
3800
|
+
container,
|
|
3801
|
+
el,
|
|
3802
|
+
style: computed(() => `
|
|
3803
|
+
width: ${props.width}px;
|
|
3804
|
+
height: ${props.height}px;
|
|
3805
|
+
position: absolute;
|
|
3806
|
+
`)
|
|
3807
|
+
};
|
|
3808
|
+
}
|
|
3809
|
+
});
|
|
3810
|
+
const _hoisted_1$2 = {
|
|
3811
|
+
class: "m-editor-scroll-viewer-container",
|
|
3812
|
+
ref: "container"
|
|
3813
|
+
};
|
|
3814
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3815
|
+
return openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
3816
|
+
createElementVNode("div", {
|
|
3817
|
+
ref: "el",
|
|
3818
|
+
style: normalizeStyle(_ctx.style)
|
|
3819
|
+
}, [
|
|
3820
|
+
renderSlot(_ctx.$slots, "default")
|
|
3821
|
+
], 4)
|
|
3822
|
+
], 512);
|
|
3823
|
+
}
|
|
3824
|
+
var ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]);
|
|
3621
3825
|
|
|
3622
3826
|
const _sfc_main$3 = defineComponent({
|
|
3623
3827
|
name: "magic-editor-ui-viewer-menu",
|
|
@@ -3678,7 +3882,7 @@ const _sfc_main$3 = defineComponent({
|
|
|
3678
3882
|
};
|
|
3679
3883
|
}
|
|
3680
3884
|
});
|
|
3681
|
-
const _hoisted_1$
|
|
3885
|
+
const _hoisted_1$1 = {
|
|
3682
3886
|
class: "magic-editor-content-menu",
|
|
3683
3887
|
ref: "menu"
|
|
3684
3888
|
};
|
|
@@ -3686,7 +3890,7 @@ const _hoisted_2 = /* @__PURE__ */ createElementVNode("div", { class: "separatio
|
|
|
3686
3890
|
const _hoisted_3 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
3687
3891
|
const _hoisted_4 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
|
|
3688
3892
|
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3689
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
3893
|
+
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
3690
3894
|
createElementVNode("div", null, [
|
|
3691
3895
|
_ctx.canCenter ? (openBlock(), createElementBlock("div", {
|
|
3692
3896
|
key: 0,
|
|
@@ -3771,28 +3975,14 @@ const useMenu = () => {
|
|
|
3771
3975
|
const _sfc_main$2 = defineComponent({
|
|
3772
3976
|
name: "magic-stage",
|
|
3773
3977
|
components: {
|
|
3774
|
-
ViewerMenu
|
|
3978
|
+
ViewerMenu,
|
|
3979
|
+
ScrollViewer
|
|
3775
3980
|
},
|
|
3776
3981
|
props: {
|
|
3777
3982
|
render: {
|
|
3778
3983
|
type: Function
|
|
3779
3984
|
},
|
|
3780
3985
|
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
3986
|
canSelect: {
|
|
3797
3987
|
type: Function,
|
|
3798
3988
|
default: (el) => Boolean(el.id)
|
|
@@ -3807,11 +3997,14 @@ const _sfc_main$2 = defineComponent({
|
|
|
3807
3997
|
emits: ["select", "update", "sort"],
|
|
3808
3998
|
setup(props, { emit }) {
|
|
3809
3999
|
const services = inject("services");
|
|
4000
|
+
const stageWrap = ref();
|
|
3810
4001
|
const stageContainer = ref();
|
|
3811
|
-
const
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
4002
|
+
const stageRect = computed(() => services?.uiService.get("stageRect"));
|
|
4003
|
+
const uiSelectMode = computed(() => services?.uiService.get("uiSelectMode"));
|
|
4004
|
+
const root = computed(() => services?.editorService.get("root"));
|
|
4005
|
+
const page = computed(() => services?.editorService.get("page"));
|
|
4006
|
+
const zoom = computed(() => services?.uiService.get("zoom"));
|
|
4007
|
+
const node = computed(() => services?.editorService.get("node"));
|
|
3815
4008
|
let stage = null;
|
|
3816
4009
|
let runtime = null;
|
|
3817
4010
|
watchEffect(() => {
|
|
@@ -3819,15 +4012,15 @@ const _sfc_main$2 = defineComponent({
|
|
|
3819
4012
|
return;
|
|
3820
4013
|
if (!stageContainer.value)
|
|
3821
4014
|
return;
|
|
3822
|
-
if (!(props.runtimeUrl || props.render) || !
|
|
4015
|
+
if (!(props.runtimeUrl || props.render) || !root.value)
|
|
3823
4016
|
return;
|
|
3824
4017
|
stage = new StageCore({
|
|
3825
4018
|
render: props.render,
|
|
3826
4019
|
runtimeUrl: props.runtimeUrl,
|
|
3827
|
-
zoom:
|
|
4020
|
+
zoom: zoom.value,
|
|
3828
4021
|
canSelect: (el, stop) => {
|
|
3829
4022
|
const elCanSelect = props.canSelect(el);
|
|
3830
|
-
if (
|
|
4023
|
+
if (uiSelectMode.value && elCanSelect) {
|
|
3831
4024
|
document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
|
|
3832
4025
|
return stop();
|
|
3833
4026
|
}
|
|
@@ -3847,55 +4040,83 @@ const _sfc_main$2 = defineComponent({
|
|
|
3847
4040
|
stage?.on("changeGuides", () => {
|
|
3848
4041
|
services?.uiService.set("showGuides", true);
|
|
3849
4042
|
});
|
|
3850
|
-
if (!
|
|
4043
|
+
if (!node.value?.id)
|
|
3851
4044
|
return;
|
|
3852
4045
|
stage?.on("runtime-ready", (rt) => {
|
|
3853
4046
|
runtime = rt;
|
|
3854
|
-
|
|
3855
|
-
|
|
4047
|
+
root.value && runtime?.updateRootConfig(cloneDeep(toRaw(root.value)));
|
|
4048
|
+
page.value?.id && runtime?.updatePageId?.(page.value.id);
|
|
3856
4049
|
setTimeout(() => {
|
|
3857
|
-
|
|
4050
|
+
node.value && stage?.select(toRaw(node.value.id));
|
|
3858
4051
|
});
|
|
3859
4052
|
});
|
|
3860
4053
|
});
|
|
3861
|
-
watch(
|
|
3862
|
-
if (!stage || !
|
|
4054
|
+
watch(zoom, (zoom2) => {
|
|
4055
|
+
if (!stage || !zoom2)
|
|
3863
4056
|
return;
|
|
3864
|
-
stage
|
|
4057
|
+
stage.setZoom(zoom2);
|
|
3865
4058
|
});
|
|
3866
|
-
watch(
|
|
3867
|
-
if (runtime &&
|
|
3868
|
-
runtime.updateRootConfig(cloneDeep(toRaw(
|
|
4059
|
+
watch(root, (root2) => {
|
|
4060
|
+
if (runtime && root2) {
|
|
4061
|
+
runtime.updateRootConfig(cloneDeep(toRaw(root2)));
|
|
3869
4062
|
}
|
|
3870
4063
|
});
|
|
4064
|
+
watch(() => node.value?.id, (id) => {
|
|
4065
|
+
nextTick(() => {
|
|
4066
|
+
id && stage?.select(id);
|
|
4067
|
+
});
|
|
4068
|
+
});
|
|
4069
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
4070
|
+
for (const { contentRect } of entries) {
|
|
4071
|
+
services?.uiService.set("stageContainerRect", {
|
|
4072
|
+
width: contentRect.width,
|
|
4073
|
+
height: contentRect.height
|
|
4074
|
+
});
|
|
4075
|
+
}
|
|
4076
|
+
});
|
|
4077
|
+
onMounted(() => {
|
|
4078
|
+
stageWrap.value?.container && resizeObserver.observe(stageWrap.value.container);
|
|
4079
|
+
});
|
|
3871
4080
|
onUnmounted(() => {
|
|
3872
4081
|
stage?.destroy();
|
|
4082
|
+
resizeObserver.disconnect();
|
|
3873
4083
|
services?.editorService.set("stage", null);
|
|
3874
4084
|
});
|
|
3875
4085
|
return {
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
4086
|
+
stageWrap,
|
|
4087
|
+
stageContainer,
|
|
4088
|
+
stageRect,
|
|
4089
|
+
zoom,
|
|
4090
|
+
...useMenu()
|
|
3879
4091
|
};
|
|
3880
4092
|
}
|
|
3881
4093
|
});
|
|
3882
|
-
const _hoisted_1$1 = { class: "m-editor-stage" };
|
|
3883
4094
|
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3884
4095
|
const _component_viewer_menu = resolveComponent("viewer-menu");
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
4096
|
+
const _component_scroll_viewer = resolveComponent("scroll-viewer");
|
|
4097
|
+
return openBlock(), createBlock(_component_scroll_viewer, {
|
|
4098
|
+
class: "m-editor-stage",
|
|
4099
|
+
ref: "stageWrap",
|
|
4100
|
+
width: _ctx.stageRect?.width,
|
|
4101
|
+
height: _ctx.stageRect?.height,
|
|
4102
|
+
zoom: _ctx.zoom
|
|
4103
|
+
}, {
|
|
4104
|
+
default: withCtx(() => [
|
|
4105
|
+
createElementVNode("div", {
|
|
4106
|
+
class: "m-editor-stage-container",
|
|
4107
|
+
ref: "stageContainer",
|
|
4108
|
+
onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
|
|
4109
|
+
style: normalizeStyle(`transform: scale(${_ctx.zoom})`)
|
|
4110
|
+
}, null, 36),
|
|
4111
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
4112
|
+
createVNode(_component_viewer_menu, {
|
|
4113
|
+
ref: "menu",
|
|
4114
|
+
style: normalizeStyle(_ctx.menuStyle)
|
|
4115
|
+
}, null, 8, ["style"])
|
|
4116
|
+
]))
|
|
4117
|
+
]),
|
|
4118
|
+
_: 1
|
|
4119
|
+
}, 8, ["width", "height", "zoom"]);
|
|
3899
4120
|
}
|
|
3900
4121
|
var MagicStage = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
|
|
3901
4122
|
|
|
@@ -3919,24 +4140,13 @@ const _sfc_main$1 = defineComponent({
|
|
|
3919
4140
|
},
|
|
3920
4141
|
setup() {
|
|
3921
4142
|
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
4143
|
return {
|
|
3930
|
-
uiSelectMode: computed(() => services?.uiService.get("uiSelectMode")),
|
|
3931
|
-
root: computed(() => services?.editorService.get("root")),
|
|
3932
4144
|
page: computed(() => services?.editorService.get("page")),
|
|
3933
|
-
zoom: computed(() => services?.uiService.get("zoom")),
|
|
3934
|
-
node,
|
|
3935
4145
|
selectHandler(el) {
|
|
3936
4146
|
services?.editorService.select(el.id);
|
|
3937
4147
|
},
|
|
3938
|
-
updateNodeHandler(
|
|
3939
|
-
services?.editorService.update(
|
|
4148
|
+
updateNodeHandler(node) {
|
|
4149
|
+
services?.editorService.update(node);
|
|
3940
4150
|
},
|
|
3941
4151
|
sortNodeHandler(ev) {
|
|
3942
4152
|
services?.editorService.sort(ev.src, ev.dist);
|
|
@@ -3953,17 +4163,12 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3953
4163
|
key: _ctx.page?.id,
|
|
3954
4164
|
"runtime-url": _ctx.runtimeUrl,
|
|
3955
4165
|
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
4166
|
"moveable-options": _ctx.moveableOptions,
|
|
3962
4167
|
"can-select": _ctx.canSelect,
|
|
3963
4168
|
onSelect: _ctx.selectHandler,
|
|
3964
4169
|
onUpdate: _ctx.updateNodeHandler,
|
|
3965
4170
|
onSort: _ctx.sortNodeHandler
|
|
3966
|
-
}, null, 8, ["runtime-url", "render", "
|
|
4171
|
+
}, null, 8, ["runtime-url", "render", "moveable-options", "can-select", "onSelect", "onUpdate", "onSort"])),
|
|
3967
4172
|
renderSlot(_ctx.$slots, "workspace-content"),
|
|
3968
4173
|
createVNode(_component_page_bar, null, {
|
|
3969
4174
|
"page-bar-title": withCtx(({ page }) => [
|
|
@@ -3998,7 +4203,14 @@ const state = reactive({
|
|
|
3998
4203
|
uiSelectMode: false,
|
|
3999
4204
|
showSrc: false,
|
|
4000
4205
|
zoom: 1,
|
|
4001
|
-
|
|
4206
|
+
stageContainerRect: {
|
|
4207
|
+
width: 0,
|
|
4208
|
+
height: 0
|
|
4209
|
+
},
|
|
4210
|
+
stageRect: {
|
|
4211
|
+
width: 375,
|
|
4212
|
+
height: 817
|
|
4213
|
+
},
|
|
4002
4214
|
columnWidth: {
|
|
4003
4215
|
left: 310,
|
|
4004
4216
|
center: globalThis.document.body.clientWidth - 310 - 400,
|
|
@@ -4022,6 +4234,10 @@ class Ui extends BaseService {
|
|
|
4022
4234
|
this.setColumnWidth(value);
|
|
4023
4235
|
return;
|
|
4024
4236
|
}
|
|
4237
|
+
if (name === "stageRect") {
|
|
4238
|
+
this.setStageRect(value);
|
|
4239
|
+
return;
|
|
4240
|
+
}
|
|
4025
4241
|
if (name === "showGuides") {
|
|
4026
4242
|
mask?.showGuides(value);
|
|
4027
4243
|
}
|
|
@@ -4029,6 +4245,9 @@ class Ui extends BaseService {
|
|
|
4029
4245
|
mask?.showRule(value);
|
|
4030
4246
|
}
|
|
4031
4247
|
state[name] = value;
|
|
4248
|
+
if (name === "stageContainerRect") {
|
|
4249
|
+
state.zoom = this.calcZoom();
|
|
4250
|
+
}
|
|
4032
4251
|
}
|
|
4033
4252
|
get(name) {
|
|
4034
4253
|
return state[name];
|
|
@@ -4051,6 +4270,23 @@ class Ui extends BaseService {
|
|
|
4051
4270
|
}
|
|
4052
4271
|
state.columnWidth = columnWidth;
|
|
4053
4272
|
}
|
|
4273
|
+
setStageRect(value) {
|
|
4274
|
+
state.stageRect = {
|
|
4275
|
+
...state.stageRect,
|
|
4276
|
+
...value
|
|
4277
|
+
};
|
|
4278
|
+
state.zoom = this.calcZoom();
|
|
4279
|
+
}
|
|
4280
|
+
calcZoom() {
|
|
4281
|
+
const { stageRect, stageContainerRect } = state;
|
|
4282
|
+
const { height, width } = stageContainerRect;
|
|
4283
|
+
if (!width || !height)
|
|
4284
|
+
return 1;
|
|
4285
|
+
if (width > stageRect.width && height > stageRect.height) {
|
|
4286
|
+
return 1;
|
|
4287
|
+
}
|
|
4288
|
+
return Math.min((width - 100) / stageRect.width || 1, (height - 100) / stageRect.height || 1);
|
|
4289
|
+
}
|
|
4054
4290
|
}
|
|
4055
4291
|
var uiService = new Ui();
|
|
4056
4292
|
|
|
@@ -4105,7 +4341,7 @@ const _sfc_main = defineComponent({
|
|
|
4105
4341
|
canSelect: {
|
|
4106
4342
|
type: Function
|
|
4107
4343
|
},
|
|
4108
|
-
|
|
4344
|
+
stageRect: {
|
|
4109
4345
|
type: [String, Object]
|
|
4110
4346
|
}
|
|
4111
4347
|
},
|
|
@@ -4143,7 +4379,7 @@ const _sfc_main = defineComponent({
|
|
|
4143
4379
|
watch(() => props.defaultSelected, (defaultSelected) => defaultSelected && editorService.select(defaultSelected), {
|
|
4144
4380
|
immediate: true
|
|
4145
4381
|
});
|
|
4146
|
-
watch(() => props.
|
|
4382
|
+
watch(() => props.stageRect, (stageRect) => stageRect && uiService.set("stageRect", stageRect), {
|
|
4147
4383
|
immediate: true
|
|
4148
4384
|
});
|
|
4149
4385
|
onUnmounted(() => editorService.destroy());
|
|
@@ -4229,5 +4465,5 @@ var index = {
|
|
|
4229
4465
|
}
|
|
4230
4466
|
};
|
|
4231
4467
|
|
|
4232
|
-
export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, change2Fixed, debug, index as default, defaults, editorService, error, eventsService, fillConfig, generateId, generatePageName, generatePageNameByApp, getConfig, getDefaultPropsValue, getNodeIndex, getPageList, getPageNameList, historyService, info, initPosition, isFixed, log, propsService, setConfig, setLayout, setNewItemId, toRelative, uiService, warn };
|
|
4468
|
+
export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, change2Fixed, debug, index as default, defaults, 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
4469
|
//# sourceMappingURL=tmagic-editor.es.js.map
|