@tmagic/editor 1.3.0-alpha.5 → 1.3.0-alpha.7
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 +23 -5
- package/dist/tmagic-editor.js +502 -246
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +505 -247
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +10 -10
- package/src/Editor.vue +5 -0
- package/src/components/ContentMenu.vue +15 -8
- package/src/components/FunctionEditor.vue +6 -4
- package/src/{layouts → components}/Resizer.vue +15 -6
- package/src/components/{Layout.vue → SplitView.vue} +1 -1
- package/src/fields/CodeLink.vue +4 -2
- package/src/index.ts +5 -3
- package/src/initService.ts +2 -0
- package/src/layouts/Framework.vue +6 -5
- package/src/layouts/sidebar/LayerPanel.vue +58 -22
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +3 -3
- package/src/layouts/workspace/Stage.vue +13 -3
- package/src/layouts/workspace/Workspace.vue +4 -133
- package/src/services/codeBlock.ts +3 -2
- package/src/services/keybinding.ts +185 -0
- package/src/services/storage.ts +3 -2
- package/src/theme/resizer.scss +25 -10
- package/src/theme/stage.scss +4 -0
- package/src/type.ts +59 -1
- package/src/utils/config.ts +1 -1
- package/src/utils/keybinding-config.ts +120 -0
- package/types/components/ContentMenu.vue.d.ts +2 -0
- package/types/index.d.ts +3 -2
- package/types/initService.d.ts +1 -1
- package/types/layouts/workspace/Workspace.vue.d.ts +1 -1
- package/types/services/keybinding.d.ts +20 -0
- package/types/type.d.ts +56 -1
- package/types/utils/config.d.ts +1 -1
- package/types/utils/keybinding-config.d.ts +3 -0
- /package/types/{layouts → components}/Resizer.vue.d.ts +0 -0
- /package/types/components/{Layout.vue.d.ts → SplitView.vue.d.ts} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('lodash-es'), require('@tmagic/design'), require('@tmagic/schema'), require('@element-plus/icons-vue'), require('@tmagic/form'), require('@tmagic/table'), require('monaco-editor'), require('gesto'), require('@tmagic/utils'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', 'lodash-es', '@tmagic/design', '@tmagic/schema', '@element-plus/icons-vue', '@tmagic/form', '@tmagic/table', 'monaco-editor', 'gesto', '@tmagic/utils', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.serialize, global.lodashEs, global.design, global.schema, global.iconsVue, global.form, global.table, global.monaco, global.Gesto, global.utils, global.
|
|
5
|
-
})(this, (function (exports, vue, serialize, lodashEs, design, schema, iconsVue, form, table, monaco, Gesto, utils,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('lodash-es'), require('@tmagic/design'), require('@tmagic/schema'), require('@element-plus/icons-vue'), require('@tmagic/form'), require('@tmagic/table'), require('monaco-editor'), require('gesto'), require('@tmagic/utils'), require('@tmagic/stage'), require('events'), require('@tmagic/core'), require('keycon')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', 'lodash-es', '@tmagic/design', '@tmagic/schema', '@element-plus/icons-vue', '@tmagic/form', '@tmagic/table', 'monaco-editor', 'gesto', '@tmagic/utils', '@tmagic/stage', 'events', '@tmagic/core', 'keycon'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.serialize, global.lodashEs, global.design, global.schema, global.iconsVue, global.form, global.table, global.monaco, global.Gesto, global.utils, global.StageCore, global.events, global.core, global.KeyController));
|
|
5
|
+
})(this, (function (exports, vue, serialize, lodashEs, design, schema, iconsVue, form, table, monaco, Gesto, utils, StageCore, events, core, KeyController) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopNamespaceDefault(e) {
|
|
8
8
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
|
|
@@ -56,6 +56,12 @@
|
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
+
let $TMAGIC_EDITOR = {};
|
|
60
|
+
const setConfig = (option) => {
|
|
61
|
+
$TMAGIC_EDITOR = option;
|
|
62
|
+
};
|
|
63
|
+
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
64
|
+
|
|
59
65
|
const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
60
66
|
...{
|
|
61
67
|
name: "MEditorCodeLink"
|
|
@@ -111,7 +117,8 @@
|
|
|
111
117
|
if (!props.name || !props.model)
|
|
112
118
|
return;
|
|
113
119
|
try {
|
|
114
|
-
|
|
120
|
+
const parseDSL = getConfig("parseDSL");
|
|
121
|
+
props.model[props.name] = parseDSL(`(${v[props.name]})`);
|
|
115
122
|
emit("change", props.model[props.name]);
|
|
116
123
|
} catch (e) {
|
|
117
124
|
console.error(e);
|
|
@@ -194,7 +201,7 @@
|
|
|
194
201
|
}
|
|
195
202
|
});
|
|
196
203
|
|
|
197
|
-
const _hoisted_1$
|
|
204
|
+
const _hoisted_1$n = ["src"];
|
|
198
205
|
const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
|
|
199
206
|
...{
|
|
200
207
|
name: "MEditorIcon"
|
|
@@ -218,7 +225,7 @@
|
|
|
218
225
|
class: "magic-editor-icon"
|
|
219
226
|
}, {
|
|
220
227
|
default: vue.withCtx(() => [
|
|
221
|
-
vue.createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$
|
|
228
|
+
vue.createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$n)
|
|
222
229
|
]),
|
|
223
230
|
_: 1
|
|
224
231
|
})) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
|
|
@@ -237,7 +244,7 @@
|
|
|
237
244
|
}
|
|
238
245
|
});
|
|
239
246
|
|
|
240
|
-
const _hoisted_1$
|
|
247
|
+
const _hoisted_1$m = { class: "m-fields-code-select-col" };
|
|
241
248
|
const _hoisted_2$e = { class: "code-select-container" };
|
|
242
249
|
const _sfc_main$A = /* @__PURE__ */ vue.defineComponent({
|
|
243
250
|
...{
|
|
@@ -331,7 +338,7 @@
|
|
|
331
338
|
};
|
|
332
339
|
return (_ctx, _cache) => {
|
|
333
340
|
const _component_m_form_container = vue.resolveComponent("m-form-container");
|
|
334
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
341
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$m, [
|
|
335
342
|
vue.createElementVNode("div", _hoisted_2$e, [
|
|
336
343
|
vue.createVNode(_component_m_form_container, {
|
|
337
344
|
class: "select",
|
|
@@ -355,7 +362,7 @@
|
|
|
355
362
|
}
|
|
356
363
|
});
|
|
357
364
|
|
|
358
|
-
const _hoisted_1$
|
|
365
|
+
const _hoisted_1$l = { class: "m-editor-data-source-fields" };
|
|
359
366
|
const _hoisted_2$d = { class: "m-editor-data-source-fields-footer" };
|
|
360
367
|
const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
|
|
361
368
|
...{
|
|
@@ -503,7 +510,7 @@
|
|
|
503
510
|
}
|
|
504
511
|
];
|
|
505
512
|
return (_ctx, _cache) => {
|
|
506
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
513
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$l, [
|
|
507
514
|
vue.createVNode(vue.unref(table.MagicTable), {
|
|
508
515
|
data: _ctx.model[_ctx.name],
|
|
509
516
|
columns: filedColumns
|
|
@@ -536,7 +543,7 @@
|
|
|
536
543
|
}
|
|
537
544
|
});
|
|
538
545
|
|
|
539
|
-
const _hoisted_1$
|
|
546
|
+
const _hoisted_1$k = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
|
|
540
547
|
const _hoisted_2$c = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
|
|
541
548
|
const _hoisted_3$5 = { class: "el-input__inner" };
|
|
542
549
|
const _sfc_main$y = /* @__PURE__ */ vue.defineComponent({
|
|
@@ -762,7 +769,7 @@
|
|
|
762
769
|
vue.createVNode(_sfc_main$B, { icon: vue.unref(iconsVue.Coin) }, null, 8, ["icon"])
|
|
763
770
|
]),
|
|
764
771
|
default: vue.withCtx(({ item }) => [
|
|
765
|
-
vue.createElementVNode("div", _hoisted_1$
|
|
772
|
+
vue.createElementVNode("div", _hoisted_1$k, [
|
|
766
773
|
vue.createElementVNode("div", null, vue.toDisplayString(item.text), 1),
|
|
767
774
|
vue.createElementVNode("span", _hoisted_2$c, vue.toDisplayString(item.value), 1)
|
|
768
775
|
])
|
|
@@ -801,7 +808,7 @@
|
|
|
801
808
|
}
|
|
802
809
|
});
|
|
803
810
|
|
|
804
|
-
const _hoisted_1$
|
|
811
|
+
const _hoisted_1$j = { class: "m-fields-event-select" };
|
|
805
812
|
const _hoisted_2$b = {
|
|
806
813
|
key: 1,
|
|
807
814
|
class: "fullWidth"
|
|
@@ -968,7 +975,7 @@
|
|
|
968
975
|
const _component_m_form_table = vue.resolveComponent("m-form-table");
|
|
969
976
|
const _component_m_form_container = vue.resolveComponent("m-form-container");
|
|
970
977
|
const _component_m_form_panel = vue.resolveComponent("m-form-panel");
|
|
971
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
978
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$j, [
|
|
972
979
|
isOldVersion.value ? (vue.openBlock(), vue.createBlock(_component_m_form_table, {
|
|
973
980
|
key: 0,
|
|
974
981
|
ref: "eventForm",
|
|
@@ -1019,7 +1026,7 @@
|
|
|
1019
1026
|
}
|
|
1020
1027
|
});
|
|
1021
1028
|
|
|
1022
|
-
const _hoisted_1$
|
|
1029
|
+
const _hoisted_1$i = { class: "m-fields-key-value" };
|
|
1023
1030
|
const _hoisted_2$a = /* @__PURE__ */ vue.createElementVNode("span", { class: "m-fileds-key-value-delimiter" }, ":", -1);
|
|
1024
1031
|
const _sfc_main$w = /* @__PURE__ */ vue.defineComponent({
|
|
1025
1032
|
...{
|
|
@@ -1064,7 +1071,7 @@
|
|
|
1064
1071
|
records.value.splice(index, 1);
|
|
1065
1072
|
};
|
|
1066
1073
|
return (_ctx, _cache) => {
|
|
1067
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
1074
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$i, [
|
|
1068
1075
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(records.value, (item, index) => {
|
|
1069
1076
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
1070
1077
|
class: "m-fields-key-value-item",
|
|
@@ -1356,12 +1363,6 @@
|
|
|
1356
1363
|
}
|
|
1357
1364
|
});
|
|
1358
1365
|
|
|
1359
|
-
let $TMAGIC_EDITOR = {};
|
|
1360
|
-
const setConfig = (option) => {
|
|
1361
|
-
$TMAGIC_EDITOR = option;
|
|
1362
|
-
};
|
|
1363
|
-
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
1364
|
-
|
|
1365
1366
|
const _sfc_main$t = /* @__PURE__ */ vue.defineComponent({
|
|
1366
1367
|
...{
|
|
1367
1368
|
name: "MEditorResizer"
|
|
@@ -1370,6 +1371,7 @@
|
|
|
1370
1371
|
emits: ["change"],
|
|
1371
1372
|
setup(__props, { emit }) {
|
|
1372
1373
|
const target = vue.ref();
|
|
1374
|
+
const isDraging = vue.ref(false);
|
|
1373
1375
|
let getso;
|
|
1374
1376
|
vue.onMounted(() => {
|
|
1375
1377
|
if (!target.value)
|
|
@@ -1381,19 +1383,24 @@
|
|
|
1381
1383
|
if (!target.value)
|
|
1382
1384
|
return;
|
|
1383
1385
|
emit("change", e.deltaX);
|
|
1386
|
+
}).on("dragStart", () => {
|
|
1387
|
+
isDraging.value = true;
|
|
1388
|
+
}).on("dragEnd", () => {
|
|
1389
|
+
isDraging.value = false;
|
|
1384
1390
|
});
|
|
1385
1391
|
});
|
|
1386
1392
|
vue.onUnmounted(() => {
|
|
1387
1393
|
getso?.unset();
|
|
1394
|
+
isDraging.value = false;
|
|
1388
1395
|
});
|
|
1389
1396
|
return (_ctx, _cache) => {
|
|
1390
1397
|
return vue.openBlock(), vue.createElementBlock("span", {
|
|
1391
1398
|
ref_key: "target",
|
|
1392
1399
|
ref: target,
|
|
1393
|
-
class: "m-editor-resizer"
|
|
1400
|
+
class: vue.normalizeClass(["m-editor-resizer", { "m-editor-resizer-draging": isDraging.value }])
|
|
1394
1401
|
}, [
|
|
1395
1402
|
vue.renderSlot(_ctx.$slots, "default")
|
|
1396
|
-
],
|
|
1403
|
+
], 2);
|
|
1397
1404
|
};
|
|
1398
1405
|
}
|
|
1399
1406
|
});
|
|
@@ -1402,7 +1409,7 @@
|
|
|
1402
1409
|
...{
|
|
1403
1410
|
name: "MEditorLayout"
|
|
1404
1411
|
},
|
|
1405
|
-
__name: "
|
|
1412
|
+
__name: "SplitView",
|
|
1406
1413
|
props: {
|
|
1407
1414
|
left: {},
|
|
1408
1415
|
right: {},
|
|
@@ -1771,6 +1778,28 @@
|
|
|
1771
1778
|
return CodeDeleteErrorType2;
|
|
1772
1779
|
})(CodeDeleteErrorType || {});
|
|
1773
1780
|
const CODE_DRAFT_STORAGE_KEY = "magicCodeDraft";
|
|
1781
|
+
var KeyBindingCommand = /* @__PURE__ */ ((KeyBindingCommand2) => {
|
|
1782
|
+
KeyBindingCommand2["COPY_NODE"] = "tmagic-system-copy-node";
|
|
1783
|
+
KeyBindingCommand2["PASTE_NODE"] = "tmagic-system-paste-node";
|
|
1784
|
+
KeyBindingCommand2["DELETE_NODE"] = "tmagic-system-delete-node";
|
|
1785
|
+
KeyBindingCommand2["CUT_NODE"] = "tmagic-system-cut-node";
|
|
1786
|
+
KeyBindingCommand2["UNDO"] = "tmagic-system-undo";
|
|
1787
|
+
KeyBindingCommand2["REDO"] = "tmagic-system-redo";
|
|
1788
|
+
KeyBindingCommand2["ZOOM_IN"] = "tmagic-system-zoom-in";
|
|
1789
|
+
KeyBindingCommand2["ZOOM_OUT"] = "tmagic-system-zoom-out";
|
|
1790
|
+
KeyBindingCommand2["ZOOM_RESET"] = "tmagic-system-zoom-reset";
|
|
1791
|
+
KeyBindingCommand2["ZOOM_FIT"] = "tmagic-system-zoom-fit";
|
|
1792
|
+
KeyBindingCommand2["MOVE_UP_1"] = "tmagic-system-move-up-1";
|
|
1793
|
+
KeyBindingCommand2["MOVE_DOWN_1"] = "tmagic-system-move-down-1";
|
|
1794
|
+
KeyBindingCommand2["MOVE_LEFT_1"] = "tmagic-system-move-left-1";
|
|
1795
|
+
KeyBindingCommand2["MOVE_RIGHT_1"] = "tmagic-system-move-right-1";
|
|
1796
|
+
KeyBindingCommand2["MOVE_UP_10"] = "tmagic-system-move-up-10";
|
|
1797
|
+
KeyBindingCommand2["MOVE_DOWN_10"] = "tmagic-system-move-down-10";
|
|
1798
|
+
KeyBindingCommand2["MOVE_LEFT_10"] = "tmagic-system-move-left-10";
|
|
1799
|
+
KeyBindingCommand2["MOVE_RIGHT_10"] = "tmagic-system-move-right-10";
|
|
1800
|
+
KeyBindingCommand2["SWITCH_NODE"] = "tmagic-system-switch-node";
|
|
1801
|
+
return KeyBindingCommand2;
|
|
1802
|
+
})(KeyBindingCommand || {});
|
|
1774
1803
|
|
|
1775
1804
|
const COPY_STORAGE_KEY = "$MagicEditorCopyData";
|
|
1776
1805
|
const getPageList = (app) => {
|
|
@@ -2217,8 +2246,8 @@
|
|
|
2217
2246
|
* 清理,支持storageService.usePlugin
|
|
2218
2247
|
*/
|
|
2219
2248
|
async clear() {
|
|
2220
|
-
const
|
|
2221
|
-
|
|
2249
|
+
const storage = await this.getStorage();
|
|
2250
|
+
storage.clear();
|
|
2222
2251
|
}
|
|
2223
2252
|
/**
|
|
2224
2253
|
* 获取存储项,支持storageService.usePlugin
|
|
@@ -2232,7 +2261,7 @@
|
|
|
2232
2261
|
return null;
|
|
2233
2262
|
switch (protocol) {
|
|
2234
2263
|
case "object" /* OBJECT */:
|
|
2235
|
-
return
|
|
2264
|
+
return getConfig("parseDSL")(`(${item})`);
|
|
2236
2265
|
case "json" /* JSON */:
|
|
2237
2266
|
return JSON.parse(item);
|
|
2238
2267
|
case "number" /* NUMBER */:
|
|
@@ -2247,49 +2276,49 @@
|
|
|
2247
2276
|
* 获取指定索引位置的key
|
|
2248
2277
|
*/
|
|
2249
2278
|
async key(index) {
|
|
2250
|
-
const
|
|
2251
|
-
return
|
|
2279
|
+
const storage = await this.getStorage();
|
|
2280
|
+
return storage.key(index);
|
|
2252
2281
|
}
|
|
2253
2282
|
/**
|
|
2254
2283
|
* 移除存储项,支持storageService.usePlugin
|
|
2255
2284
|
*/
|
|
2256
|
-
async removeItem(
|
|
2257
|
-
const [
|
|
2258
|
-
|
|
2285
|
+
async removeItem(key, options = {}) {
|
|
2286
|
+
const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
2287
|
+
storage.removeItem(`${options.namespace || namespace}:${key}`);
|
|
2259
2288
|
}
|
|
2260
2289
|
/**
|
|
2261
2290
|
* 设置存储项,支持storageService.usePlugin
|
|
2262
2291
|
*/
|
|
2263
|
-
async setItem(
|
|
2264
|
-
const [
|
|
2265
|
-
let
|
|
2266
|
-
const
|
|
2292
|
+
async setItem(key, value, options = {}) {
|
|
2293
|
+
const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
2294
|
+
let item = value;
|
|
2295
|
+
const protocol = options.protocol ? `${options.protocol}:` : "";
|
|
2267
2296
|
if (typeof value === "string" /* STRING */ || typeof value === "number" /* NUMBER */) {
|
|
2268
|
-
|
|
2297
|
+
item = `${protocol}${value}`;
|
|
2269
2298
|
} else {
|
|
2270
|
-
|
|
2299
|
+
item = `${protocol}${serialize(value)}`;
|
|
2271
2300
|
}
|
|
2272
|
-
|
|
2301
|
+
storage.setItem(`${options.namespace || namespace}:${key}`, item);
|
|
2273
2302
|
}
|
|
2274
2303
|
destroy() {
|
|
2275
2304
|
this.removeAllListeners();
|
|
2276
2305
|
this.removeAllPlugins();
|
|
2277
2306
|
}
|
|
2278
2307
|
getValueAndProtocol(value) {
|
|
2279
|
-
let
|
|
2308
|
+
let protocol = "";
|
|
2280
2309
|
if (value === null) {
|
|
2281
2310
|
return {
|
|
2282
2311
|
item: value,
|
|
2283
|
-
protocol
|
|
2312
|
+
protocol
|
|
2284
2313
|
};
|
|
2285
2314
|
}
|
|
2286
|
-
const
|
|
2287
|
-
|
|
2315
|
+
const item = value.replace(new RegExp(`^(${Object.values(Protocol).join("|")})(:)(.+)`), (_$0, $1, _$2, $3) => {
|
|
2316
|
+
protocol = $1;
|
|
2288
2317
|
return $3;
|
|
2289
2318
|
});
|
|
2290
2319
|
return {
|
|
2291
|
-
protocol
|
|
2292
|
-
item
|
|
2320
|
+
protocol,
|
|
2321
|
+
item
|
|
2293
2322
|
};
|
|
2294
2323
|
}
|
|
2295
2324
|
}
|
|
@@ -3386,7 +3415,7 @@
|
|
|
3386
3415
|
return stage;
|
|
3387
3416
|
};
|
|
3388
3417
|
|
|
3389
|
-
const _hoisted_1$
|
|
3418
|
+
const _hoisted_1$h = { class: "m-editor-empty-panel" };
|
|
3390
3419
|
const _hoisted_2$9 = { class: "m-editor-empty-content" };
|
|
3391
3420
|
const _hoisted_3$4 = /* @__PURE__ */ vue.createElementVNode("p", null, "新增页面", -1);
|
|
3392
3421
|
const _sfc_main$r = /* @__PURE__ */ vue.defineComponent({
|
|
@@ -3409,7 +3438,7 @@
|
|
|
3409
3438
|
});
|
|
3410
3439
|
};
|
|
3411
3440
|
return (_ctx, _cache) => {
|
|
3412
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
3441
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$h, [
|
|
3413
3442
|
vue.createElementVNode("div", _hoisted_2$9, [
|
|
3414
3443
|
vue.createElementVNode("div", {
|
|
3415
3444
|
class: "m-editor-empty-button",
|
|
@@ -3426,7 +3455,7 @@
|
|
|
3426
3455
|
}
|
|
3427
3456
|
});
|
|
3428
3457
|
|
|
3429
|
-
const _hoisted_1$
|
|
3458
|
+
const _hoisted_1$g = { class: "m-editor" };
|
|
3430
3459
|
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
3431
3460
|
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
3432
3461
|
const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
|
|
@@ -3491,13 +3520,14 @@
|
|
|
3491
3520
|
};
|
|
3492
3521
|
const saveCode = (value) => {
|
|
3493
3522
|
try {
|
|
3494
|
-
|
|
3523
|
+
const parseDSL = getConfig("parseDSL");
|
|
3524
|
+
editorService?.set("root", parseDSL(value));
|
|
3495
3525
|
} catch (e) {
|
|
3496
3526
|
console.error(e);
|
|
3497
3527
|
}
|
|
3498
3528
|
};
|
|
3499
3529
|
return (_ctx, _cache) => {
|
|
3500
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
3530
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$g, [
|
|
3501
3531
|
vue.renderSlot(_ctx.$slots, "header"),
|
|
3502
3532
|
vue.renderSlot(_ctx.$slots, "nav"),
|
|
3503
3533
|
vue.renderSlot(_ctx.$slots, "content-before"),
|
|
@@ -3552,7 +3582,7 @@
|
|
|
3552
3582
|
}
|
|
3553
3583
|
});
|
|
3554
3584
|
|
|
3555
|
-
const _hoisted_1$
|
|
3585
|
+
const _hoisted_1$f = {
|
|
3556
3586
|
key: 1,
|
|
3557
3587
|
class: "menu-item-text"
|
|
3558
3588
|
};
|
|
@@ -3636,7 +3666,7 @@
|
|
|
3636
3666
|
_ctx.data.type === "divider" ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDivider), {
|
|
3637
3667
|
key: 0,
|
|
3638
3668
|
direction: _ctx.data.direction || "vertical"
|
|
3639
|
-
}, null, 8, ["direction"])) : _ctx.data.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
3669
|
+
}, null, 8, ["direction"])) : _ctx.data.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$f, vue.toDisplayString(_ctx.data.text), 1)) : _ctx.data.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
|
|
3640
3670
|
_ctx.data.tooltip ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
|
|
3641
3671
|
key: 0,
|
|
3642
3672
|
effect: "dark",
|
|
@@ -3891,7 +3921,7 @@
|
|
|
3891
3921
|
}
|
|
3892
3922
|
});
|
|
3893
3923
|
|
|
3894
|
-
const _hoisted_1$
|
|
3924
|
+
const _hoisted_1$e = { class: "m-editor-props-panel" };
|
|
3895
3925
|
const _sfc_main$n = /* @__PURE__ */ vue.defineComponent({
|
|
3896
3926
|
...{
|
|
3897
3927
|
name: "MEditorPropsPanel"
|
|
@@ -3941,7 +3971,7 @@
|
|
|
3941
3971
|
};
|
|
3942
3972
|
__expose({ submit });
|
|
3943
3973
|
return (_ctx, _cache) => {
|
|
3944
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
3974
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$e, [
|
|
3945
3975
|
vue.renderSlot(_ctx.$slots, "props-panel-header"),
|
|
3946
3976
|
vue.createVNode(vue.unref(form.MForm), {
|
|
3947
3977
|
ref_key: "configForm",
|
|
@@ -3993,7 +4023,7 @@
|
|
|
3993
4023
|
}
|
|
3994
4024
|
});
|
|
3995
4025
|
|
|
3996
|
-
const _hoisted_1$
|
|
4026
|
+
const _hoisted_1$d = { xmlns: "http://www.w3.org/2000/svg" };
|
|
3997
4027
|
const _hoisted_2$7 = /* @__PURE__ */ vue.createElementVNode("g", {
|
|
3998
4028
|
fill: "#7C878E",
|
|
3999
4029
|
"fill-rule": "evenodd"
|
|
@@ -4014,12 +4044,12 @@
|
|
|
4014
4044
|
__name: "AppManageIcon",
|
|
4015
4045
|
setup(__props) {
|
|
4016
4046
|
return (_ctx, _cache) => {
|
|
4017
|
-
return vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$
|
|
4047
|
+
return vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$d, _hoisted_3$3);
|
|
4018
4048
|
};
|
|
4019
4049
|
}
|
|
4020
4050
|
});
|
|
4021
4051
|
|
|
4022
|
-
const _hoisted_1$
|
|
4052
|
+
const _hoisted_1$c = {
|
|
4023
4053
|
viewBox: "0 0 32 32",
|
|
4024
4054
|
version: "1.1",
|
|
4025
4055
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -4036,12 +4066,12 @@
|
|
|
4036
4066
|
__name: "CodeIcon",
|
|
4037
4067
|
setup(__props) {
|
|
4038
4068
|
return (_ctx, _cache) => {
|
|
4039
|
-
return vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$
|
|
4069
|
+
return vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$c, _hoisted_4$3);
|
|
4040
4070
|
};
|
|
4041
4071
|
}
|
|
4042
4072
|
});
|
|
4043
4073
|
|
|
4044
|
-
const _hoisted_1$
|
|
4074
|
+
const _hoisted_1$b = {
|
|
4045
4075
|
key: 0,
|
|
4046
4076
|
class: "m-editor-content-bottom"
|
|
4047
4077
|
};
|
|
@@ -4145,7 +4175,7 @@
|
|
|
4145
4175
|
language: _ctx.language,
|
|
4146
4176
|
options: codeOptions.value
|
|
4147
4177
|
}, null, 8, ["init-values", "language", "options"]),
|
|
4148
|
-
_ctx.editable ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
4178
|
+
_ctx.editable ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
|
|
4149
4179
|
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
4150
4180
|
type: "primary",
|
|
4151
4181
|
class: "button",
|
|
@@ -4201,7 +4231,7 @@
|
|
|
4201
4231
|
}
|
|
4202
4232
|
});
|
|
4203
4233
|
|
|
4204
|
-
const _hoisted_1$
|
|
4234
|
+
const _hoisted_1$a = { class: "code-name-wrapper" };
|
|
4205
4235
|
const _hoisted_2$4 = /* @__PURE__ */ vue.createElementVNode("div", { class: "code-name-label" }, "代码块名称", -1);
|
|
4206
4236
|
const _hoisted_3$2 = { class: "code-name-wrapper" };
|
|
4207
4237
|
const _hoisted_4$2 = /* @__PURE__ */ vue.createElementVNode("div", { class: "code-name-label" }, "参数", -1);
|
|
@@ -4221,6 +4251,7 @@
|
|
|
4221
4251
|
},
|
|
4222
4252
|
setup(__props, { expose: __expose }) {
|
|
4223
4253
|
const props = __props;
|
|
4254
|
+
vue.provide("mForm", {});
|
|
4224
4255
|
const defaultParamColConfig = {
|
|
4225
4256
|
type: "row",
|
|
4226
4257
|
label: "参数类型",
|
|
@@ -4289,29 +4320,29 @@
|
|
|
4289
4320
|
initTableModel();
|
|
4290
4321
|
const beforeSave = (codeValue) => {
|
|
4291
4322
|
try {
|
|
4292
|
-
|
|
4323
|
+
getConfig("parseDSL")(codeValue);
|
|
4293
4324
|
return true;
|
|
4294
4325
|
} catch (e) {
|
|
4295
4326
|
design.tMagicMessage.error(e.stack);
|
|
4296
4327
|
return false;
|
|
4297
4328
|
}
|
|
4298
4329
|
};
|
|
4299
|
-
const saveCode = async (
|
|
4330
|
+
const saveCode = async (codeValue) => {
|
|
4300
4331
|
if (!props.editable)
|
|
4301
4332
|
return;
|
|
4302
|
-
evalRes.value = beforeSave(
|
|
4333
|
+
evalRes.value = beforeSave(codeValue);
|
|
4303
4334
|
if (evalRes.value) {
|
|
4304
4335
|
await services?.codeBlockService.setCodeDslById(props.id, {
|
|
4305
4336
|
name: codeName.value,
|
|
4306
|
-
content:
|
|
4337
|
+
content: codeValue,
|
|
4307
4338
|
params: tableModel.value?.params || []
|
|
4308
4339
|
});
|
|
4309
4340
|
design.tMagicMessage.success("代码成功保存到本地");
|
|
4310
4341
|
services?.codeBlockService.removeCodeDraft(props.id);
|
|
4311
4342
|
}
|
|
4312
4343
|
};
|
|
4313
|
-
const saveAndClose = async (
|
|
4314
|
-
await saveCode(
|
|
4344
|
+
const saveAndClose = async (codeValue) => {
|
|
4345
|
+
await saveCode(codeValue);
|
|
4315
4346
|
if (evalRes.value) {
|
|
4316
4347
|
close();
|
|
4317
4348
|
}
|
|
@@ -4327,7 +4358,7 @@
|
|
|
4327
4358
|
const _component_m_form_table = vue.resolveComponent("m-form-table");
|
|
4328
4359
|
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCard), { shadow: "never" }, {
|
|
4329
4360
|
header: vue.withCtx(() => [
|
|
4330
|
-
vue.createElementVNode("div", _hoisted_1$
|
|
4361
|
+
vue.createElementVNode("div", _hoisted_1$a, [
|
|
4331
4362
|
_hoisted_2$4,
|
|
4332
4363
|
vue.createVNode(vue.unref(design.TMagicInput), {
|
|
4333
4364
|
class: "code-name-input",
|
|
@@ -4369,7 +4400,7 @@
|
|
|
4369
4400
|
}
|
|
4370
4401
|
});
|
|
4371
4402
|
|
|
4372
|
-
const _hoisted_1$
|
|
4403
|
+
const _hoisted_1$9 = {
|
|
4373
4404
|
key: 0,
|
|
4374
4405
|
class: "m-editor-code-block-editor-panel"
|
|
4375
4406
|
};
|
|
@@ -4437,7 +4468,7 @@
|
|
|
4437
4468
|
class: "code-editor-layout"
|
|
4438
4469
|
}, {
|
|
4439
4470
|
center: vue.withCtx(() => [
|
|
4440
|
-
!vue.unref(lodashEs.isEmpty)(codeConfig.value) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
4471
|
+
!vue.unref(lodashEs.isEmpty)(codeConfig.value) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
|
|
4441
4472
|
vue.renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id: id.value }),
|
|
4442
4473
|
codeConfig.value ? (vue.openBlock(), vue.createBlock(_sfc_main$i, {
|
|
4443
4474
|
key: 0,
|
|
@@ -4462,7 +4493,7 @@
|
|
|
4462
4493
|
}
|
|
4463
4494
|
});
|
|
4464
4495
|
|
|
4465
|
-
const _hoisted_1$
|
|
4496
|
+
const _hoisted_1$8 = { class: "search-wrapper" };
|
|
4466
4497
|
const _hoisted_2$3 = ["id"];
|
|
4467
4498
|
const _hoisted_3$1 = { class: "list-item" };
|
|
4468
4499
|
const _hoisted_4$1 = {
|
|
@@ -4565,7 +4596,7 @@
|
|
|
4565
4596
|
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicScrollbar), { class: "m-editor-code-block-list m-editor-dep-list-panel" }, {
|
|
4566
4597
|
default: vue.withCtx(() => [
|
|
4567
4598
|
vue.renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
|
|
4568
|
-
vue.createElementVNode("div", _hoisted_1$
|
|
4599
|
+
vue.createElementVNode("div", _hoisted_1$8, [
|
|
4569
4600
|
vue.createVNode(_sfc_main$m, { onSearch: filterTextChangeHandler }),
|
|
4570
4601
|
editable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
4571
4602
|
key: 0,
|
|
@@ -4760,7 +4791,7 @@
|
|
|
4760
4791
|
}
|
|
4761
4792
|
});
|
|
4762
4793
|
|
|
4763
|
-
const _hoisted_1$
|
|
4794
|
+
const _hoisted_1$7 = { class: "search-wrapper" };
|
|
4764
4795
|
const _hoisted_2$2 = ["id"];
|
|
4765
4796
|
const _hoisted_3 = { class: "list-item" };
|
|
4766
4797
|
const _hoisted_4 = {
|
|
@@ -4829,7 +4860,7 @@
|
|
|
4829
4860
|
return (_ctx, _cache) => {
|
|
4830
4861
|
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicScrollbar), { class: "data-source-list-panel m-editor-dep-list-panel" }, {
|
|
4831
4862
|
default: vue.withCtx(() => [
|
|
4832
|
-
vue.createElementVNode("div", _hoisted_1$
|
|
4863
|
+
vue.createElementVNode("div", _hoisted_1$7, [
|
|
4833
4864
|
vue.createVNode(_sfc_main$m, { onSearch: filterTextChangeHandler }),
|
|
4834
4865
|
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
4835
4866
|
type: "primary",
|
|
@@ -4925,7 +4956,7 @@
|
|
|
4925
4956
|
}
|
|
4926
4957
|
});
|
|
4927
4958
|
|
|
4928
|
-
const _hoisted_1$
|
|
4959
|
+
const _hoisted_1$6 = ["onClick", "onDragstart"];
|
|
4929
4960
|
const _sfc_main$d = /* @__PURE__ */ vue.defineComponent({
|
|
4930
4961
|
...{
|
|
4931
4962
|
name: "MEditorComponentListPanel"
|
|
@@ -5043,7 +5074,7 @@
|
|
|
5043
5074
|
_: 2
|
|
5044
5075
|
}, 1032, ["content"])
|
|
5045
5076
|
])
|
|
5046
|
-
], 40, _hoisted_1$
|
|
5077
|
+
], 40, _hoisted_1$6);
|
|
5047
5078
|
}), 128))
|
|
5048
5079
|
]),
|
|
5049
5080
|
_: 2
|
|
@@ -5080,6 +5111,7 @@
|
|
|
5080
5111
|
left: "0",
|
|
5081
5112
|
top: "0"
|
|
5082
5113
|
});
|
|
5114
|
+
const contains = (el) => menu.value?.contains(el) || subMenu.value?.contains(el);
|
|
5083
5115
|
const hide = () => {
|
|
5084
5116
|
if (!visible.value)
|
|
5085
5117
|
return;
|
|
@@ -5092,7 +5124,7 @@
|
|
|
5092
5124
|
if (!visible.value || !target) {
|
|
5093
5125
|
return;
|
|
5094
5126
|
}
|
|
5095
|
-
if (
|
|
5127
|
+
if (contains(target)) {
|
|
5096
5128
|
return;
|
|
5097
5129
|
}
|
|
5098
5130
|
hide();
|
|
@@ -5119,13 +5151,15 @@
|
|
|
5119
5151
|
if (typeof item !== "object" || !menuItem.items?.length) {
|
|
5120
5152
|
return;
|
|
5121
5153
|
}
|
|
5122
|
-
subMenuData.value = menuItem.items;
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5154
|
+
subMenuData.value = menuItem.items || [];
|
|
5155
|
+
setTimeout(() => {
|
|
5156
|
+
if (menu.value) {
|
|
5157
|
+
subMenu.value?.show({
|
|
5158
|
+
clientX: menu.value.offsetLeft + menu.value.clientWidth,
|
|
5159
|
+
clientY: menu.value.offsetTop
|
|
5160
|
+
});
|
|
5161
|
+
}
|
|
5162
|
+
}, 0);
|
|
5129
5163
|
};
|
|
5130
5164
|
vue.onMounted(() => {
|
|
5131
5165
|
if (props.isSubMenu)
|
|
@@ -5138,8 +5172,10 @@
|
|
|
5138
5172
|
globalThis.removeEventListener("mousedown", hideHandler, true);
|
|
5139
5173
|
});
|
|
5140
5174
|
__expose({
|
|
5175
|
+
menu,
|
|
5141
5176
|
hide,
|
|
5142
|
-
show
|
|
5177
|
+
show,
|
|
5178
|
+
contains
|
|
5143
5179
|
});
|
|
5144
5180
|
return (_ctx, _cache) => {
|
|
5145
5181
|
const _component_content_menu = vue.resolveComponent("content-menu", true);
|
|
@@ -5162,14 +5198,15 @@
|
|
|
5162
5198
|
}), 128))
|
|
5163
5199
|
]),
|
|
5164
5200
|
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
5165
|
-
vue.
|
|
5201
|
+
subMenuData.value.length ? (vue.openBlock(), vue.createBlock(_component_content_menu, {
|
|
5202
|
+
key: 0,
|
|
5166
5203
|
class: "sub-menu",
|
|
5167
5204
|
ref_key: "subMenu",
|
|
5168
5205
|
ref: subMenu,
|
|
5169
5206
|
"menu-data": subMenuData.value,
|
|
5170
5207
|
"is-sub-menu": true,
|
|
5171
5208
|
onHide: hide
|
|
5172
|
-
}, null, 8, ["menu-data"])
|
|
5209
|
+
}, null, 8, ["menu-data"])) : vue.createCommentVNode("", true)
|
|
5173
5210
|
]))
|
|
5174
5211
|
], 4)), [
|
|
5175
5212
|
[vue.vShow, visible.value]
|
|
@@ -5282,7 +5319,7 @@
|
|
|
5282
5319
|
}
|
|
5283
5320
|
});
|
|
5284
5321
|
|
|
5285
|
-
const _hoisted_1$
|
|
5322
|
+
const _hoisted_1$5 = ["id", "onMouseenter"];
|
|
5286
5323
|
const throttleTime = 150;
|
|
5287
5324
|
const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
|
|
5288
5325
|
...{
|
|
@@ -5295,6 +5332,7 @@
|
|
|
5295
5332
|
setup(__props) {
|
|
5296
5333
|
const services = vue.inject("services");
|
|
5297
5334
|
const editorService = services?.editorService;
|
|
5335
|
+
const keybindingService = services?.keybindingService;
|
|
5298
5336
|
const tree = vue.ref();
|
|
5299
5337
|
const menu = vue.ref();
|
|
5300
5338
|
const checkedKeys = vue.ref([]);
|
|
@@ -5428,25 +5466,59 @@
|
|
|
5428
5466
|
const windowBlurHandler = () => {
|
|
5429
5467
|
isCtrlKeyDown.value = false;
|
|
5430
5468
|
};
|
|
5431
|
-
|
|
5469
|
+
keybindingService?.registeCommand("layer-panel-not-ctrl-keydown", (e) => {
|
|
5470
|
+
if (e.key !== keybindingService.ctrlKey) {
|
|
5471
|
+
isCtrlKeyDown.value = false;
|
|
5472
|
+
}
|
|
5473
|
+
});
|
|
5474
|
+
keybindingService?.registeCommand("layer-panel-ctrl-keydown", () => {
|
|
5475
|
+
isCtrlKeyDown.value = true;
|
|
5476
|
+
});
|
|
5477
|
+
keybindingService?.registeCommand("layer-panel-ctrl-keyup", () => {
|
|
5478
|
+
isCtrlKeyDown.value = false;
|
|
5479
|
+
});
|
|
5480
|
+
keybindingService?.registeCommand("layer-panel-global-keydwon", () => {
|
|
5481
|
+
if (!tree.value?.$el.contains(document.activeElement)) {
|
|
5482
|
+
isCtrlKeyDown.value = false;
|
|
5483
|
+
}
|
|
5484
|
+
});
|
|
5485
|
+
keybindingService?.registe([
|
|
5486
|
+
{
|
|
5487
|
+
command: "layer-panel-not-ctrl-keydown",
|
|
5488
|
+
when: [["layer-panel", "keydown"]]
|
|
5489
|
+
},
|
|
5490
|
+
{
|
|
5491
|
+
command: "layer-panel-ctrl-keydown",
|
|
5492
|
+
keybinding: "ctrl",
|
|
5493
|
+
when: [["layer-panel", "keydown"]]
|
|
5494
|
+
},
|
|
5495
|
+
{
|
|
5496
|
+
command: "layer-panel-ctrl-keyup",
|
|
5497
|
+
keybinding: "ctrl",
|
|
5498
|
+
when: [["layer-panel", "keyup"]]
|
|
5499
|
+
},
|
|
5500
|
+
{
|
|
5501
|
+
command: "layer-panel-global-keydwon",
|
|
5502
|
+
keybinding: "ctrl",
|
|
5503
|
+
when: [["global", "keydown"]]
|
|
5504
|
+
}
|
|
5505
|
+
]);
|
|
5506
|
+
vue.watch(tree, () => {
|
|
5507
|
+
if (tree.value?.$el) {
|
|
5508
|
+
keybindingService?.registeEl("layer-panel", tree.value.$el);
|
|
5509
|
+
tree.value.$el.addEventListener("blur", windowBlurHandler);
|
|
5510
|
+
} else {
|
|
5511
|
+
keybindingService?.unregisteEl("layer-panel");
|
|
5512
|
+
}
|
|
5513
|
+
});
|
|
5432
5514
|
vue.onMounted(() => {
|
|
5433
5515
|
editorService?.on("remove", editorServiceRemoveHandler);
|
|
5434
|
-
keycon = new KeyController();
|
|
5435
|
-
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
5436
|
-
const ctrl = isMac ? "meta" : "ctrl";
|
|
5437
|
-
keycon.keydown((e) => {
|
|
5438
|
-
if (e.key !== ctrl) {
|
|
5439
|
-
isCtrlKeyDown.value = false;
|
|
5440
|
-
}
|
|
5441
|
-
}).keydown(ctrl, () => {
|
|
5442
|
-
isCtrlKeyDown.value = true;
|
|
5443
|
-
}).keyup(ctrl, () => {
|
|
5444
|
-
isCtrlKeyDown.value = false;
|
|
5445
|
-
});
|
|
5446
5516
|
globalThis.addEventListener("blur", windowBlurHandler);
|
|
5447
5517
|
});
|
|
5518
|
+
vue.onBeforeUnmount(() => {
|
|
5519
|
+
tree.value?.$el.removeEventListener("blur", windowBlurHandler);
|
|
5520
|
+
});
|
|
5448
5521
|
vue.onUnmounted(() => {
|
|
5449
|
-
keycon.destroy();
|
|
5450
5522
|
editorService?.off("remove", editorServiceRemoveHandler);
|
|
5451
5523
|
globalThis.removeEventListener("blur", windowBlurHandler);
|
|
5452
5524
|
});
|
|
@@ -5493,6 +5565,7 @@
|
|
|
5493
5565
|
ref: tree,
|
|
5494
5566
|
"node-key": "id",
|
|
5495
5567
|
"empty-text": "页面空荡荡的",
|
|
5568
|
+
tabindex: "-1",
|
|
5496
5569
|
draggable: "",
|
|
5497
5570
|
"default-expanded-keys": expandedKeys.value,
|
|
5498
5571
|
"default-checked-keys": checkedKeys.value,
|
|
@@ -5526,7 +5599,7 @@
|
|
|
5526
5599
|
}, () => [
|
|
5527
5600
|
vue.createElementVNode("span", null, vue.toDisplayString(`${data.name} (${data.id})`), 1)
|
|
5528
5601
|
])
|
|
5529
|
-
], 40, _hoisted_1$
|
|
5602
|
+
], 40, _hoisted_1$5)
|
|
5530
5603
|
]),
|
|
5531
5604
|
_: 3
|
|
5532
5605
|
}, 8, ["default-expanded-keys", "default-checked-keys", "current-node-key", "data", "highlight-current", "show-checkbox"])) : vue.createCommentVNode("", true),
|
|
@@ -5544,7 +5617,7 @@
|
|
|
5544
5617
|
}
|
|
5545
5618
|
});
|
|
5546
5619
|
|
|
5547
|
-
const _hoisted_1$
|
|
5620
|
+
const _hoisted_1$4 = {
|
|
5548
5621
|
key: 1,
|
|
5549
5622
|
class: "magic-editor-tab-panel-title"
|
|
5550
5623
|
};
|
|
@@ -5632,7 +5705,7 @@
|
|
|
5632
5705
|
key: 0,
|
|
5633
5706
|
icon: config.icon
|
|
5634
5707
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
5635
|
-
config.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
5708
|
+
config.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, vue.toDisplayString(config.text), 1)) : vue.createCommentVNode("", true)
|
|
5636
5709
|
]))
|
|
5637
5710
|
]),
|
|
5638
5711
|
default: vue.withCtx(() => [
|
|
@@ -5719,7 +5792,7 @@
|
|
|
5719
5792
|
}
|
|
5720
5793
|
});
|
|
5721
5794
|
|
|
5722
|
-
const _hoisted_1$
|
|
5795
|
+
const _hoisted_1$3 = {
|
|
5723
5796
|
key: 0,
|
|
5724
5797
|
class: "m-editor-breadcrumb"
|
|
5725
5798
|
};
|
|
@@ -5741,7 +5814,7 @@
|
|
|
5741
5814
|
editorService?.get("stage")?.select(node2.id);
|
|
5742
5815
|
};
|
|
5743
5816
|
return (_ctx, _cache) => {
|
|
5744
|
-
return nodes.value.length === 1 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
5817
|
+
return nodes.value.length === 1 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, [
|
|
5745
5818
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(path.value, (item, index) => {
|
|
5746
5819
|
return vue.openBlock(), vue.createElementBlock(vue.Fragment, {
|
|
5747
5820
|
key: item.id
|
|
@@ -5764,7 +5837,7 @@
|
|
|
5764
5837
|
}
|
|
5765
5838
|
});
|
|
5766
5839
|
|
|
5767
|
-
const _hoisted_1$
|
|
5840
|
+
const _hoisted_1$2 = {
|
|
5768
5841
|
key: 1,
|
|
5769
5842
|
style: { "width": "21px" }
|
|
5770
5843
|
};
|
|
@@ -5857,7 +5930,7 @@
|
|
|
5857
5930
|
onClick: addPage
|
|
5858
5931
|
}, [
|
|
5859
5932
|
vue.createVNode(_sfc_main$B, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
|
|
5860
|
-
])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
5933
|
+
])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2)),
|
|
5861
5934
|
canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
5862
5935
|
key: 2,
|
|
5863
5936
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
@@ -5886,7 +5959,7 @@
|
|
|
5886
5959
|
}
|
|
5887
5960
|
});
|
|
5888
5961
|
|
|
5889
|
-
const _hoisted_1 = ["onClick"];
|
|
5962
|
+
const _hoisted_1$1 = ["onClick"];
|
|
5890
5963
|
const _hoisted_2 = { class: "m-editor-page-bar-title" };
|
|
5891
5964
|
const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
|
|
5892
5965
|
...{
|
|
@@ -5972,7 +6045,7 @@
|
|
|
5972
6045
|
]),
|
|
5973
6046
|
_: 2
|
|
5974
6047
|
}, 1024)
|
|
5975
|
-
], 10, _hoisted_1);
|
|
6048
|
+
], 10, _hoisted_1$1);
|
|
5976
6049
|
}), 128))
|
|
5977
6050
|
]),
|
|
5978
6051
|
_: 3
|
|
@@ -6491,6 +6564,9 @@
|
|
|
6491
6564
|
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
|
|
6492
6565
|
return;
|
|
6493
6566
|
stage = useStage(stageOptions);
|
|
6567
|
+
stage.on("select", () => {
|
|
6568
|
+
stageWrap.value?.container?.focus();
|
|
6569
|
+
});
|
|
6494
6570
|
services?.editorService.set("stage", vue.markRaw(stage));
|
|
6495
6571
|
stage?.mount(stageContainer.value);
|
|
6496
6572
|
if (!node.value?.id)
|
|
@@ -6531,21 +6607,25 @@
|
|
|
6531
6607
|
}
|
|
6532
6608
|
});
|
|
6533
6609
|
vue.onMounted(() => {
|
|
6534
|
-
|
|
6610
|
+
if (stageWrap.value?.container) {
|
|
6611
|
+
resizeObserver.observe(stageWrap.value.container);
|
|
6612
|
+
services?.keybindingService.registeEl("stage", stageWrap.value.container);
|
|
6613
|
+
}
|
|
6535
6614
|
});
|
|
6536
6615
|
vue.onUnmounted(() => {
|
|
6537
6616
|
stage?.destroy();
|
|
6538
6617
|
resizeObserver.disconnect();
|
|
6539
6618
|
services?.editorService.set("stage", null);
|
|
6619
|
+
services?.keybindingService.unregisteEl("stage");
|
|
6540
6620
|
});
|
|
6541
|
-
const contextmenuHandler = (
|
|
6542
|
-
|
|
6543
|
-
menu.value?.show(
|
|
6621
|
+
const contextmenuHandler = (e) => {
|
|
6622
|
+
e.preventDefault();
|
|
6623
|
+
menu.value?.show(e);
|
|
6544
6624
|
};
|
|
6545
|
-
const dragoverHandler = (
|
|
6546
|
-
|
|
6547
|
-
if (
|
|
6548
|
-
|
|
6625
|
+
const dragoverHandler = (e) => {
|
|
6626
|
+
e.preventDefault();
|
|
6627
|
+
if (e.dataTransfer) {
|
|
6628
|
+
e.dataTransfer.dropEffect = "move";
|
|
6549
6629
|
}
|
|
6550
6630
|
};
|
|
6551
6631
|
const dropHandler = async (e) => {
|
|
@@ -6557,7 +6637,8 @@
|
|
|
6557
6637
|
parent = services?.editorService.getNodeById(parentEl.id, false);
|
|
6558
6638
|
}
|
|
6559
6639
|
if (e.dataTransfer && parent && stageContainer.value && stage) {
|
|
6560
|
-
const
|
|
6640
|
+
const parseDSL = getConfig("parseDSL");
|
|
6641
|
+
const config = parseDSL(`(${e.dataTransfer.getData("data")})`);
|
|
6561
6642
|
const layout = await services?.editorService.getLayout(parent);
|
|
6562
6643
|
const containerRect = stageContainer.value.getBoundingClientRect();
|
|
6563
6644
|
const { scrollTop, scrollLeft } = stage.mask;
|
|
@@ -6590,6 +6671,7 @@
|
|
|
6590
6671
|
class: "m-editor-stage",
|
|
6591
6672
|
ref_key: "stageWrap",
|
|
6592
6673
|
ref: stageWrap,
|
|
6674
|
+
tabindex: "-1",
|
|
6593
6675
|
width: stageRect.value?.width,
|
|
6594
6676
|
height: stageRect.value?.height,
|
|
6595
6677
|
"wrap-width": stageContainerRect.value?.width,
|
|
@@ -6625,6 +6707,7 @@
|
|
|
6625
6707
|
}
|
|
6626
6708
|
});
|
|
6627
6709
|
|
|
6710
|
+
const _hoisted_1 = { class: "m-editor-workspace" };
|
|
6628
6711
|
const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
6629
6712
|
...{
|
|
6630
6713
|
name: "MEditorWorkspace"
|
|
@@ -6635,112 +6718,9 @@
|
|
|
6635
6718
|
},
|
|
6636
6719
|
setup(__props) {
|
|
6637
6720
|
const services = vue.inject("services");
|
|
6638
|
-
const workspace = vue.ref();
|
|
6639
|
-
const nodes = vue.computed(() => services?.editorService.get("nodes"));
|
|
6640
6721
|
const page = vue.computed(() => services?.editorService.get("page"));
|
|
6641
|
-
const mouseenterHandler = () => {
|
|
6642
|
-
workspace.value?.focus();
|
|
6643
|
-
};
|
|
6644
|
-
const mouseleaveHandler = () => {
|
|
6645
|
-
workspace.value?.blur();
|
|
6646
|
-
};
|
|
6647
|
-
let keycon;
|
|
6648
|
-
vue.onMounted(() => {
|
|
6649
|
-
workspace.value?.addEventListener("mouseenter", mouseenterHandler);
|
|
6650
|
-
workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
|
|
6651
|
-
keycon = new KeyController(workspace.value);
|
|
6652
|
-
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
6653
|
-
const ctrl = isMac ? "meta" : "ctrl";
|
|
6654
|
-
keycon.keyup("delete", (e) => {
|
|
6655
|
-
e.inputEvent.preventDefault();
|
|
6656
|
-
if (!nodes.value || utils.isPage(nodes.value[0]))
|
|
6657
|
-
return;
|
|
6658
|
-
services?.editorService.remove(nodes.value);
|
|
6659
|
-
}).keyup("backspace", (e) => {
|
|
6660
|
-
e.inputEvent.preventDefault();
|
|
6661
|
-
if (!nodes.value || utils.isPage(nodes.value[0]))
|
|
6662
|
-
return;
|
|
6663
|
-
services?.editorService.remove(nodes.value);
|
|
6664
|
-
}).keydown([ctrl, "c"], (e) => {
|
|
6665
|
-
e.inputEvent.preventDefault();
|
|
6666
|
-
nodes.value && services?.editorService.copy(nodes.value);
|
|
6667
|
-
}).keydown([ctrl, "v"], (e) => {
|
|
6668
|
-
e.inputEvent.preventDefault();
|
|
6669
|
-
nodes.value && services?.editorService.paste({ offsetX: 10, offsetY: 10 });
|
|
6670
|
-
}).keydown([ctrl, "x"], (e) => {
|
|
6671
|
-
e.inputEvent.preventDefault();
|
|
6672
|
-
if (!nodes.value || utils.isPage(nodes.value[0]))
|
|
6673
|
-
return;
|
|
6674
|
-
services?.editorService.copy(nodes.value);
|
|
6675
|
-
services?.editorService.remove(nodes.value);
|
|
6676
|
-
}).keydown([ctrl, "z"], (e) => {
|
|
6677
|
-
e.inputEvent.preventDefault();
|
|
6678
|
-
services?.editorService.undo();
|
|
6679
|
-
}).keydown([ctrl, "shift", "z"], (e) => {
|
|
6680
|
-
e.inputEvent.preventDefault();
|
|
6681
|
-
services?.editorService.redo();
|
|
6682
|
-
}).keydown("up", (e) => {
|
|
6683
|
-
e.inputEvent.preventDefault();
|
|
6684
|
-
services?.editorService.move(0, -1);
|
|
6685
|
-
}).keydown("down", (e) => {
|
|
6686
|
-
e.inputEvent.preventDefault();
|
|
6687
|
-
services?.editorService.move(0, 1);
|
|
6688
|
-
}).keydown("left", (e) => {
|
|
6689
|
-
e.inputEvent.preventDefault();
|
|
6690
|
-
services?.editorService.move(-1, 0);
|
|
6691
|
-
}).keydown("right", (e) => {
|
|
6692
|
-
e.inputEvent.preventDefault();
|
|
6693
|
-
services?.editorService.move(1, 0);
|
|
6694
|
-
}).keydown([ctrl, "up"], (e) => {
|
|
6695
|
-
e.inputEvent.preventDefault();
|
|
6696
|
-
services?.editorService.move(0, -10);
|
|
6697
|
-
}).keydown([ctrl, "down"], (e) => {
|
|
6698
|
-
e.inputEvent.preventDefault();
|
|
6699
|
-
services?.editorService.move(0, 10);
|
|
6700
|
-
}).keydown([ctrl, "left"], (e) => {
|
|
6701
|
-
e.inputEvent.preventDefault();
|
|
6702
|
-
services?.editorService.move(-10, 0);
|
|
6703
|
-
}).keydown([ctrl, "right"], (e) => {
|
|
6704
|
-
e.inputEvent.preventDefault();
|
|
6705
|
-
services?.editorService.move(10, 0);
|
|
6706
|
-
}).keydown("tab", (e) => {
|
|
6707
|
-
e.inputEvent.preventDefault();
|
|
6708
|
-
services?.editorService.selectNextNode();
|
|
6709
|
-
}).keydown([ctrl, "tab"], (e) => {
|
|
6710
|
-
e.inputEvent.preventDefault();
|
|
6711
|
-
services?.editorService.selectNextPage();
|
|
6712
|
-
}).keydown([ctrl, "="], (e) => {
|
|
6713
|
-
e.inputEvent.preventDefault();
|
|
6714
|
-
services?.uiService.zoom(0.1);
|
|
6715
|
-
}).keydown([ctrl, "numpadplus"], (e) => {
|
|
6716
|
-
e.inputEvent.preventDefault();
|
|
6717
|
-
services?.uiService.zoom(0.1);
|
|
6718
|
-
}).keydown([ctrl, "-"], (e) => {
|
|
6719
|
-
e.inputEvent.preventDefault();
|
|
6720
|
-
services?.uiService.zoom(-0.1);
|
|
6721
|
-
}).keydown([ctrl, "numpad-"], (e) => {
|
|
6722
|
-
e.inputEvent.preventDefault();
|
|
6723
|
-
services?.uiService.zoom(-0.1);
|
|
6724
|
-
}).keydown([ctrl, "0"], async (e) => {
|
|
6725
|
-
e.inputEvent.preventDefault();
|
|
6726
|
-
services?.uiService.set("zoom", await services.uiService.calcZoom());
|
|
6727
|
-
}).keydown([ctrl, "1"], (e) => {
|
|
6728
|
-
e.inputEvent.preventDefault();
|
|
6729
|
-
services?.uiService.set("zoom", 1);
|
|
6730
|
-
});
|
|
6731
|
-
});
|
|
6732
|
-
vue.onUnmounted(() => {
|
|
6733
|
-
workspace.value?.removeEventListener("mouseenter", mouseenterHandler);
|
|
6734
|
-
workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
|
|
6735
|
-
keycon.destroy();
|
|
6736
|
-
});
|
|
6737
6722
|
return (_ctx, _cache) => {
|
|
6738
|
-
return vue.openBlock(), vue.createElementBlock("div",
|
|
6739
|
-
class: "m-editor-workspace",
|
|
6740
|
-
tabindex: "-1",
|
|
6741
|
-
ref_key: "workspace",
|
|
6742
|
-
ref: workspace
|
|
6743
|
-
}, [
|
|
6723
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
|
|
6744
6724
|
vue.createVNode(_sfc_main$8),
|
|
6745
6725
|
vue.renderSlot(_ctx.$slots, "stage", {}, () => [
|
|
6746
6726
|
page.value ? (vue.openBlock(), vue.createBlock(_sfc_main$2, {
|
|
@@ -6758,7 +6738,7 @@
|
|
|
6758
6738
|
]),
|
|
6759
6739
|
_: 3
|
|
6760
6740
|
})
|
|
6761
|
-
]
|
|
6741
|
+
]);
|
|
6762
6742
|
};
|
|
6763
6743
|
}
|
|
6764
6744
|
});
|
|
@@ -6787,8 +6767,8 @@
|
|
|
6787
6767
|
* @param {CodeBlockDSL} codeDsl 代码DSL
|
|
6788
6768
|
* @returns {void}
|
|
6789
6769
|
*/
|
|
6790
|
-
async setCodeDsl(
|
|
6791
|
-
this.state.codeDsl =
|
|
6770
|
+
async setCodeDsl(codeDsl) {
|
|
6771
|
+
this.state.codeDsl = codeDsl;
|
|
6792
6772
|
this.emit("code-dsl-change", this.state.codeDsl);
|
|
6793
6773
|
}
|
|
6794
6774
|
/**
|
|
@@ -6805,13 +6785,13 @@
|
|
|
6805
6785
|
* @param {Id} id 代码块id
|
|
6806
6786
|
* @returns {CodeBlockContent | null}
|
|
6807
6787
|
*/
|
|
6808
|
-
getCodeContentById(
|
|
6809
|
-
if (!
|
|
6788
|
+
getCodeContentById(id) {
|
|
6789
|
+
if (!id)
|
|
6810
6790
|
return null;
|
|
6811
6791
|
const totalCodeDsl = this.getCodeDsl();
|
|
6812
6792
|
if (!totalCodeDsl)
|
|
6813
6793
|
return null;
|
|
6814
|
-
return totalCodeDsl[
|
|
6794
|
+
return totalCodeDsl[id] ?? null;
|
|
6815
6795
|
}
|
|
6816
6796
|
/**
|
|
6817
6797
|
* 设置代码块ID和代码内容到源dsl
|
|
@@ -6826,7 +6806,8 @@
|
|
|
6826
6806
|
}
|
|
6827
6807
|
const codeConfigProcessed = codeConfig;
|
|
6828
6808
|
if (codeConfig.content) {
|
|
6829
|
-
|
|
6809
|
+
const parseDSL = getConfig("parseDSL");
|
|
6810
|
+
codeConfigProcessed.content = parseDSL(codeConfig.content);
|
|
6830
6811
|
}
|
|
6831
6812
|
const existContent = codeDsl[id] || {};
|
|
6832
6813
|
codeDsl[id] = {
|
|
@@ -6841,8 +6822,8 @@
|
|
|
6841
6822
|
* @returns {CodeBlockDSL}
|
|
6842
6823
|
*/
|
|
6843
6824
|
getCodeDslByIds(ids) {
|
|
6844
|
-
const
|
|
6845
|
-
return lodashEs.pick(
|
|
6825
|
+
const codeDsl = this.getCodeDsl();
|
|
6826
|
+
return lodashEs.pick(codeDsl, ids);
|
|
6846
6827
|
}
|
|
6847
6828
|
/**
|
|
6848
6829
|
* 设置代码编辑面板展示状态
|
|
@@ -6865,10 +6846,10 @@
|
|
|
6865
6846
|
* @param {Id} id 代码块id
|
|
6866
6847
|
* @returns {void}
|
|
6867
6848
|
*/
|
|
6868
|
-
setCodeEditorContent(status,
|
|
6869
|
-
if (!
|
|
6849
|
+
setCodeEditorContent(status, id) {
|
|
6850
|
+
if (!id)
|
|
6870
6851
|
return;
|
|
6871
|
-
this.setId(
|
|
6852
|
+
this.setId(id);
|
|
6872
6853
|
this.state.isShowCodeEditor = status;
|
|
6873
6854
|
}
|
|
6874
6855
|
/**
|
|
@@ -6898,10 +6879,10 @@
|
|
|
6898
6879
|
* @param {Id} id 代码块id
|
|
6899
6880
|
* @returns {void}
|
|
6900
6881
|
*/
|
|
6901
|
-
setId(
|
|
6902
|
-
if (!
|
|
6882
|
+
setId(id) {
|
|
6883
|
+
if (!id)
|
|
6903
6884
|
return;
|
|
6904
|
-
this.state.id =
|
|
6885
|
+
this.state.id = id;
|
|
6905
6886
|
}
|
|
6906
6887
|
/**
|
|
6907
6888
|
* 获取当前选中的代码块ID
|
|
@@ -6966,9 +6947,9 @@
|
|
|
6966
6947
|
const currentDsl = await this.getCodeDsl();
|
|
6967
6948
|
if (!currentDsl)
|
|
6968
6949
|
return;
|
|
6969
|
-
codeIds.forEach((
|
|
6970
|
-
delete currentDsl[
|
|
6971
|
-
this.emit("remove",
|
|
6950
|
+
codeIds.forEach((id) => {
|
|
6951
|
+
delete currentDsl[id];
|
|
6952
|
+
this.emit("remove", id);
|
|
6972
6953
|
});
|
|
6973
6954
|
}
|
|
6974
6955
|
/**
|
|
@@ -7482,6 +7463,275 @@
|
|
|
7482
7463
|
}
|
|
7483
7464
|
const eventsService = new Events();
|
|
7484
7465
|
|
|
7466
|
+
class Keybinding extends BaseService {
|
|
7467
|
+
ctrlKey = /mac os x/.test(navigator.userAgent.toLowerCase()) ? "meta" : "ctrl";
|
|
7468
|
+
controllers = /* @__PURE__ */ new Map();
|
|
7469
|
+
bindingList = [];
|
|
7470
|
+
commands = {
|
|
7471
|
+
[KeyBindingCommand.DELETE_NODE]: () => {
|
|
7472
|
+
const nodes = editorService.get("nodes");
|
|
7473
|
+
if (!nodes || utils.isPage(nodes[0]))
|
|
7474
|
+
return;
|
|
7475
|
+
editorService.remove(nodes);
|
|
7476
|
+
},
|
|
7477
|
+
[KeyBindingCommand.COPY_NODE]: () => {
|
|
7478
|
+
const nodes = editorService.get("nodes");
|
|
7479
|
+
nodes && editorService.copy(nodes);
|
|
7480
|
+
},
|
|
7481
|
+
[KeyBindingCommand.CUT_NODE]: () => {
|
|
7482
|
+
const nodes = editorService.get("nodes");
|
|
7483
|
+
if (!nodes || utils.isPage(nodes[0]))
|
|
7484
|
+
return;
|
|
7485
|
+
editorService.copy(nodes);
|
|
7486
|
+
editorService.remove(nodes);
|
|
7487
|
+
},
|
|
7488
|
+
[KeyBindingCommand.PASTE_NODE]: () => {
|
|
7489
|
+
const nodes = editorService.get("nodes");
|
|
7490
|
+
nodes && editorService.paste({ offsetX: 10, offsetY: 10 });
|
|
7491
|
+
},
|
|
7492
|
+
[KeyBindingCommand.UNDO]: () => {
|
|
7493
|
+
editorService.undo();
|
|
7494
|
+
},
|
|
7495
|
+
[KeyBindingCommand.REDO]: () => {
|
|
7496
|
+
editorService.redo();
|
|
7497
|
+
},
|
|
7498
|
+
[KeyBindingCommand.ZOOM_IN]: () => {
|
|
7499
|
+
uiService.zoom(0.1);
|
|
7500
|
+
},
|
|
7501
|
+
[KeyBindingCommand.ZOOM_OUT]: () => {
|
|
7502
|
+
uiService.zoom(-0.1);
|
|
7503
|
+
},
|
|
7504
|
+
[KeyBindingCommand.ZOOM_RESET]: () => {
|
|
7505
|
+
uiService.set("zoom", 1);
|
|
7506
|
+
},
|
|
7507
|
+
[KeyBindingCommand.ZOOM_FIT]: async () => {
|
|
7508
|
+
uiService.set("zoom", await uiService.calcZoom());
|
|
7509
|
+
},
|
|
7510
|
+
[KeyBindingCommand.MOVE_UP_1]: () => {
|
|
7511
|
+
editorService.move(0, -1);
|
|
7512
|
+
},
|
|
7513
|
+
[KeyBindingCommand.MOVE_DOWN_1]: () => {
|
|
7514
|
+
editorService.move(0, 1);
|
|
7515
|
+
},
|
|
7516
|
+
[KeyBindingCommand.MOVE_LEFT_1]: () => {
|
|
7517
|
+
editorService.move(-1, 0);
|
|
7518
|
+
},
|
|
7519
|
+
[KeyBindingCommand.MOVE_RIGHT_1]: () => {
|
|
7520
|
+
editorService.move(1, 0);
|
|
7521
|
+
},
|
|
7522
|
+
[KeyBindingCommand.MOVE_UP_10]: () => {
|
|
7523
|
+
editorService.move(0, -10);
|
|
7524
|
+
},
|
|
7525
|
+
[KeyBindingCommand.MOVE_DOWN_10]: () => {
|
|
7526
|
+
editorService.move(0, 10);
|
|
7527
|
+
},
|
|
7528
|
+
[KeyBindingCommand.MOVE_LEFT_10]: () => {
|
|
7529
|
+
editorService.move(-10, 0);
|
|
7530
|
+
},
|
|
7531
|
+
[KeyBindingCommand.MOVE_RIGHT_10]: () => {
|
|
7532
|
+
editorService.move(10, 0);
|
|
7533
|
+
},
|
|
7534
|
+
[KeyBindingCommand.SWITCH_NODE]: () => {
|
|
7535
|
+
editorService.selectNextNode();
|
|
7536
|
+
}
|
|
7537
|
+
};
|
|
7538
|
+
registeCommand(command, handler) {
|
|
7539
|
+
this.commands[command] = handler;
|
|
7540
|
+
}
|
|
7541
|
+
unregisteCommand(command) {
|
|
7542
|
+
delete this.commands[command];
|
|
7543
|
+
}
|
|
7544
|
+
registeEl(name, el) {
|
|
7545
|
+
if (name !== "global" && !el) {
|
|
7546
|
+
throw new Error("只有name为global可以不传el");
|
|
7547
|
+
}
|
|
7548
|
+
const keycon = new KeyController(el);
|
|
7549
|
+
this.controllers.set(name, keycon);
|
|
7550
|
+
this.bind(name);
|
|
7551
|
+
}
|
|
7552
|
+
unregisteEl(name) {
|
|
7553
|
+
this.controllers.get(name)?.destroy();
|
|
7554
|
+
this.controllers.delete(name);
|
|
7555
|
+
this.bindingList.forEach((item) => {
|
|
7556
|
+
item.binded = false;
|
|
7557
|
+
});
|
|
7558
|
+
}
|
|
7559
|
+
registe(maps) {
|
|
7560
|
+
for (const keybindingItem of maps) {
|
|
7561
|
+
const { command, keybinding, when } = keybindingItem;
|
|
7562
|
+
for (const [type = "", eventType = "keydown"] of when) {
|
|
7563
|
+
const cacheItem = { type, command, keybinding, eventType, binded: false };
|
|
7564
|
+
this.bindingList.push(cacheItem);
|
|
7565
|
+
}
|
|
7566
|
+
}
|
|
7567
|
+
this.bind();
|
|
7568
|
+
}
|
|
7569
|
+
reset() {
|
|
7570
|
+
this.controllers.forEach((keycon) => {
|
|
7571
|
+
keycon.destroy();
|
|
7572
|
+
});
|
|
7573
|
+
this.controllers.clear();
|
|
7574
|
+
this.bindingList = [];
|
|
7575
|
+
}
|
|
7576
|
+
destroy() {
|
|
7577
|
+
this.reset();
|
|
7578
|
+
}
|
|
7579
|
+
bind(name) {
|
|
7580
|
+
for (const item of this.bindingList) {
|
|
7581
|
+
const { type, eventType, command, keybinding, binded } = item;
|
|
7582
|
+
if (name && name !== type) {
|
|
7583
|
+
continue;
|
|
7584
|
+
}
|
|
7585
|
+
if (binded) {
|
|
7586
|
+
continue;
|
|
7587
|
+
}
|
|
7588
|
+
const keycon = this.controllers.get(type);
|
|
7589
|
+
if (!keycon) {
|
|
7590
|
+
continue;
|
|
7591
|
+
}
|
|
7592
|
+
const handler = (e) => {
|
|
7593
|
+
e.inputEvent.preventDefault();
|
|
7594
|
+
this.commands[command]?.(e.inputEvent);
|
|
7595
|
+
};
|
|
7596
|
+
this.getKeyconKeys(keybinding).forEach((keys) => {
|
|
7597
|
+
if (keys[0]) {
|
|
7598
|
+
keycon[eventType](keys, handler);
|
|
7599
|
+
} else {
|
|
7600
|
+
keycon[eventType](handler);
|
|
7601
|
+
}
|
|
7602
|
+
});
|
|
7603
|
+
item.binded = true;
|
|
7604
|
+
}
|
|
7605
|
+
}
|
|
7606
|
+
getKeyconKeys(keybinding = "") {
|
|
7607
|
+
const splitKey = (key) => key.split("+").map((k) => k === "ctrl" ? this.ctrlKey : k);
|
|
7608
|
+
if (Array.isArray(keybinding)) {
|
|
7609
|
+
return keybinding.map((key) => splitKey(key));
|
|
7610
|
+
}
|
|
7611
|
+
return [splitKey(keybinding)];
|
|
7612
|
+
}
|
|
7613
|
+
}
|
|
7614
|
+
const keybindingService = new Keybinding();
|
|
7615
|
+
|
|
7616
|
+
const keybindingConfig = [
|
|
7617
|
+
{
|
|
7618
|
+
command: KeyBindingCommand.DELETE_NODE,
|
|
7619
|
+
keybinding: ["delete", "backspace"],
|
|
7620
|
+
when: [
|
|
7621
|
+
["stage", "keyup"],
|
|
7622
|
+
["layer-panel", "keydown"]
|
|
7623
|
+
]
|
|
7624
|
+
},
|
|
7625
|
+
{
|
|
7626
|
+
command: KeyBindingCommand.COPY_NODE,
|
|
7627
|
+
keybinding: "ctrl+c",
|
|
7628
|
+
when: [
|
|
7629
|
+
["stage", "keydown"],
|
|
7630
|
+
["layer-panel", "keydown"]
|
|
7631
|
+
]
|
|
7632
|
+
},
|
|
7633
|
+
{
|
|
7634
|
+
command: KeyBindingCommand.PASTE_NODE,
|
|
7635
|
+
keybinding: "ctrl+v",
|
|
7636
|
+
when: [
|
|
7637
|
+
["stage", "keydown"],
|
|
7638
|
+
["layer-panel", "keydown"]
|
|
7639
|
+
]
|
|
7640
|
+
},
|
|
7641
|
+
{
|
|
7642
|
+
command: KeyBindingCommand.CUT_NODE,
|
|
7643
|
+
keybinding: "ctrl+x",
|
|
7644
|
+
when: [
|
|
7645
|
+
["stage", "keydown"],
|
|
7646
|
+
["layer-panel", "keydown"]
|
|
7647
|
+
]
|
|
7648
|
+
},
|
|
7649
|
+
{
|
|
7650
|
+
command: KeyBindingCommand.UNDO,
|
|
7651
|
+
keybinding: "ctrl+z",
|
|
7652
|
+
when: [
|
|
7653
|
+
["stage", "keydown"],
|
|
7654
|
+
["layer-panel", "keydown"]
|
|
7655
|
+
]
|
|
7656
|
+
},
|
|
7657
|
+
{
|
|
7658
|
+
command: KeyBindingCommand.REDO,
|
|
7659
|
+
keybinding: "ctrl+shift+z",
|
|
7660
|
+
when: [
|
|
7661
|
+
["stage", "keydown"],
|
|
7662
|
+
["layer-panel", "keydown"]
|
|
7663
|
+
]
|
|
7664
|
+
},
|
|
7665
|
+
{
|
|
7666
|
+
command: KeyBindingCommand.MOVE_UP_1,
|
|
7667
|
+
keybinding: "up",
|
|
7668
|
+
when: [["stage", "keydown"]]
|
|
7669
|
+
},
|
|
7670
|
+
{
|
|
7671
|
+
command: KeyBindingCommand.MOVE_DOWN_1,
|
|
7672
|
+
keybinding: "down",
|
|
7673
|
+
when: [["stage", "keydown"]]
|
|
7674
|
+
},
|
|
7675
|
+
{
|
|
7676
|
+
command: KeyBindingCommand.MOVE_LEFT_1,
|
|
7677
|
+
keybinding: "left",
|
|
7678
|
+
when: [["stage", "keydown"]]
|
|
7679
|
+
},
|
|
7680
|
+
{
|
|
7681
|
+
command: KeyBindingCommand.MOVE_RIGHT_1,
|
|
7682
|
+
keybinding: "right",
|
|
7683
|
+
when: [["stage", "keydown"]]
|
|
7684
|
+
},
|
|
7685
|
+
{
|
|
7686
|
+
command: KeyBindingCommand.MOVE_UP_10,
|
|
7687
|
+
keybinding: "ctrl+up",
|
|
7688
|
+
when: [["stage", "keydown"]]
|
|
7689
|
+
},
|
|
7690
|
+
{
|
|
7691
|
+
command: KeyBindingCommand.MOVE_DOWN_10,
|
|
7692
|
+
keybinding: "ctrl+down",
|
|
7693
|
+
when: [["stage", "keydown"]]
|
|
7694
|
+
},
|
|
7695
|
+
{
|
|
7696
|
+
command: KeyBindingCommand.MOVE_LEFT_10,
|
|
7697
|
+
keybinding: "ctrl+left",
|
|
7698
|
+
when: [["stage", "keydown"]]
|
|
7699
|
+
},
|
|
7700
|
+
{
|
|
7701
|
+
command: KeyBindingCommand.MOVE_RIGHT_10,
|
|
7702
|
+
keybinding: "ctrl+right",
|
|
7703
|
+
when: [["stage", "keydown"]]
|
|
7704
|
+
},
|
|
7705
|
+
{
|
|
7706
|
+
command: KeyBindingCommand.SWITCH_NODE,
|
|
7707
|
+
keybinding: "tab",
|
|
7708
|
+
when: [
|
|
7709
|
+
["stage", "keydown"],
|
|
7710
|
+
["layer-panel", "keydown"]
|
|
7711
|
+
]
|
|
7712
|
+
},
|
|
7713
|
+
{
|
|
7714
|
+
command: KeyBindingCommand.ZOOM_IN,
|
|
7715
|
+
keybinding: ["ctrl+=", "ctrl+numpadplus"],
|
|
7716
|
+
when: [["stage", "keydown"]]
|
|
7717
|
+
},
|
|
7718
|
+
{
|
|
7719
|
+
command: KeyBindingCommand.ZOOM_OUT,
|
|
7720
|
+
keybinding: ["ctrl+-", "ctrl+numpad-"],
|
|
7721
|
+
when: [["stage", "keydown"]]
|
|
7722
|
+
},
|
|
7723
|
+
{
|
|
7724
|
+
command: KeyBindingCommand.ZOOM_FIT,
|
|
7725
|
+
keybinding: "ctrl+0",
|
|
7726
|
+
when: [["stage", "keydown"]]
|
|
7727
|
+
},
|
|
7728
|
+
{
|
|
7729
|
+
command: KeyBindingCommand.ZOOM_RESET,
|
|
7730
|
+
keybinding: "ctrl+1",
|
|
7731
|
+
when: [["stage", "keydown"]]
|
|
7732
|
+
}
|
|
7733
|
+
];
|
|
7734
|
+
|
|
7485
7735
|
const editorProps = {
|
|
7486
7736
|
/** 页面初始值 */
|
|
7487
7737
|
modelValue: {
|
|
@@ -7609,7 +7859,8 @@
|
|
|
7609
7859
|
propsService,
|
|
7610
7860
|
eventsService,
|
|
7611
7861
|
uiService,
|
|
7612
|
-
codeBlockService
|
|
7862
|
+
codeBlockService,
|
|
7863
|
+
keybindingService
|
|
7613
7864
|
}) => {
|
|
7614
7865
|
vue.watch(
|
|
7615
7866
|
() => props.modelValue,
|
|
@@ -7678,6 +7929,7 @@
|
|
|
7678
7929
|
uiService.resetState();
|
|
7679
7930
|
componentListService.resetState();
|
|
7680
7931
|
codeBlockService.resetState();
|
|
7932
|
+
keybindingService.reset();
|
|
7681
7933
|
});
|
|
7682
7934
|
};
|
|
7683
7935
|
const initServiceEvents = (props, emit, { editorService, codeBlockService, dataSourceService, depService }) => {
|
|
@@ -7869,10 +8121,13 @@
|
|
|
7869
8121
|
storageService,
|
|
7870
8122
|
codeBlockService,
|
|
7871
8123
|
depService,
|
|
7872
|
-
dataSourceService
|
|
8124
|
+
dataSourceService,
|
|
8125
|
+
keybindingService
|
|
7873
8126
|
};
|
|
7874
8127
|
initServiceEvents(props, emit, services);
|
|
7875
8128
|
initServiceState(props, services);
|
|
8129
|
+
keybindingService.registe(keybindingConfig);
|
|
8130
|
+
keybindingService.registeEl("global");
|
|
7876
8131
|
vue.provide("services", services);
|
|
7877
8132
|
vue.provide("codeOptions", props.codeOptions);
|
|
7878
8133
|
vue.provide(
|
|
@@ -8009,7 +8264,8 @@
|
|
|
8009
8264
|
const index$1 = '';
|
|
8010
8265
|
|
|
8011
8266
|
const defaultInstallOpt = {
|
|
8012
|
-
//
|
|
8267
|
+
// eslint-disable-next-line no-eval
|
|
8268
|
+
parseDSL: (dsl) => eval(dsl)
|
|
8013
8269
|
};
|
|
8014
8270
|
const index = {
|
|
8015
8271
|
install: (app, opt) => {
|
|
@@ -8045,6 +8301,7 @@
|
|
|
8045
8301
|
exports.Fixed2Other = Fixed2Other;
|
|
8046
8302
|
exports.H_GUIDE_LINE_STORAGE_KEY = H_GUIDE_LINE_STORAGE_KEY;
|
|
8047
8303
|
exports.Icon = _sfc_main$B;
|
|
8304
|
+
exports.KeyBindingCommand = KeyBindingCommand;
|
|
8048
8305
|
exports.KeyValue = _sfc_main$w;
|
|
8049
8306
|
exports.Keys = Keys;
|
|
8050
8307
|
exports.LayerOffset = LayerOffset;
|
|
@@ -8052,6 +8309,7 @@
|
|
|
8052
8309
|
exports.Layout = Layout;
|
|
8053
8310
|
exports.LayoutContainer = _sfc_main$s;
|
|
8054
8311
|
exports.PropsPanel = _sfc_main$n;
|
|
8312
|
+
exports.SplitView = _sfc_main$s;
|
|
8055
8313
|
exports.TMagicCodeEditor = _sfc_main$u;
|
|
8056
8314
|
exports.TMagicEditor = Editor;
|
|
8057
8315
|
exports.ToolButton = _sfc_main$p;
|