@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.
Files changed (37) hide show
  1. package/dist/style.css +23 -5
  2. package/dist/tmagic-editor.js +502 -246
  3. package/dist/tmagic-editor.js.map +1 -1
  4. package/dist/tmagic-editor.umd.cjs +505 -247
  5. package/dist/tmagic-editor.umd.cjs.map +1 -1
  6. package/package.json +10 -10
  7. package/src/Editor.vue +5 -0
  8. package/src/components/ContentMenu.vue +15 -8
  9. package/src/components/FunctionEditor.vue +6 -4
  10. package/src/{layouts → components}/Resizer.vue +15 -6
  11. package/src/components/{Layout.vue → SplitView.vue} +1 -1
  12. package/src/fields/CodeLink.vue +4 -2
  13. package/src/index.ts +5 -3
  14. package/src/initService.ts +2 -0
  15. package/src/layouts/Framework.vue +6 -5
  16. package/src/layouts/sidebar/LayerPanel.vue +58 -22
  17. package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +3 -3
  18. package/src/layouts/workspace/Stage.vue +13 -3
  19. package/src/layouts/workspace/Workspace.vue +4 -133
  20. package/src/services/codeBlock.ts +3 -2
  21. package/src/services/keybinding.ts +185 -0
  22. package/src/services/storage.ts +3 -2
  23. package/src/theme/resizer.scss +25 -10
  24. package/src/theme/stage.scss +4 -0
  25. package/src/type.ts +59 -1
  26. package/src/utils/config.ts +1 -1
  27. package/src/utils/keybinding-config.ts +120 -0
  28. package/types/components/ContentMenu.vue.d.ts +2 -0
  29. package/types/index.d.ts +3 -2
  30. package/types/initService.d.ts +1 -1
  31. package/types/layouts/workspace/Workspace.vue.d.ts +1 -1
  32. package/types/services/keybinding.d.ts +20 -0
  33. package/types/type.d.ts +56 -1
  34. package/types/utils/config.d.ts +1 -1
  35. package/types/utils/keybinding-config.d.ts +3 -0
  36. /package/types/{layouts → components}/Resizer.vue.d.ts +0 -0
  37. /package/types/components/{Layout.vue.d.ts → SplitView.vue.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, reactive, watch, createElementBlock, normalizeClass, createVNode, unref, withCtx, createElementVNode, resolveDynamicComponent, toRaw, inject, ref, createTextVNode, mergeProps, toDisplayString, Fragment, renderList, createCommentVNode, nextTick, watchEffect, withModifiers, onMounted, onUnmounted, renderSlot, createSlots, normalizeProps, markRaw, getCurrentInstance, createStaticVNode, withDirectives, Teleport, vShow, toHandlers, provide } from 'vue';
1
+ import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, reactive, watch, createElementBlock, normalizeClass, createVNode, unref, withCtx, createElementVNode, resolveDynamicComponent, toRaw, inject, ref, createTextVNode, mergeProps, toDisplayString, Fragment, renderList, createCommentVNode, nextTick, watchEffect, withModifiers, onMounted, onUnmounted, renderSlot, createSlots, normalizeProps, markRaw, getCurrentInstance, createStaticVNode, provide, withDirectives, Teleport, vShow, onBeforeUnmount, toHandlers } from 'vue';
2
2
  import serialize from 'serialize-javascript';
3
3
  import { isEmpty, map, has, throttle, cloneDeep, mergeWith, isObject, uniq, forIn, difference, union, pick, keys } from 'lodash-es';
4
4
  import { TMagicCard, TMagicIcon, TMagicButton, tMagicMessageBox, getConfig as getConfig$1, TMagicTag, TMagicInput, TMagicTooltip, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, tMagicMessage, TMagicDrawer, TMagicTree, TMagicCollapse, TMagicCollapseItem, TMagicPopover } from '@tmagic/design';
@@ -9,10 +9,10 @@ import { MagicTable } from '@tmagic/table';
9
9
  import * as monaco from 'monaco-editor';
10
10
  import Gesto from 'gesto';
11
11
  import { isPop, getNodePath, isNumber, isPage, toLine, guid, datetimeFormatter, removeClassNameByClassName, getNodes } from '@tmagic/utils';
12
- import KeyController from 'keycon';
13
12
  import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType } from '@tmagic/stage';
14
13
  import { EventEmitter } from 'events';
15
14
  import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
15
+ import KeyController from 'keycon';
16
16
 
17
17
  const _sfc_main$E = /* @__PURE__ */ defineComponent({
18
18
  ...{
@@ -47,6 +47,12 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
47
47
  }
48
48
  });
49
49
 
50
+ let $TMAGIC_EDITOR = {};
51
+ const setConfig = (option) => {
52
+ $TMAGIC_EDITOR = option;
53
+ };
54
+ const getConfig = (key) => $TMAGIC_EDITOR[key];
55
+
50
56
  const _sfc_main$D = /* @__PURE__ */ defineComponent({
51
57
  ...{
52
58
  name: "MEditorCodeLink"
@@ -102,7 +108,8 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
102
108
  if (!props.name || !props.model)
103
109
  return;
104
110
  try {
105
- props.model[props.name] = eval(`(${v[props.name]})`);
111
+ const parseDSL = getConfig("parseDSL");
112
+ props.model[props.name] = parseDSL(`(${v[props.name]})`);
106
113
  emit("change", props.model[props.name]);
107
114
  } catch (e) {
108
115
  console.error(e);
@@ -185,7 +192,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
185
192
  }
186
193
  });
187
194
 
188
- const _hoisted_1$m = ["src"];
195
+ const _hoisted_1$n = ["src"];
189
196
  const _sfc_main$B = /* @__PURE__ */ defineComponent({
190
197
  ...{
191
198
  name: "MEditorIcon"
@@ -209,7 +216,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
209
216
  class: "magic-editor-icon"
210
217
  }, {
211
218
  default: withCtx(() => [
212
- createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$m)
219
+ createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$n)
213
220
  ]),
214
221
  _: 1
215
222
  })) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
@@ -228,7 +235,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
228
235
  }
229
236
  });
230
237
 
231
- const _hoisted_1$l = { class: "m-fields-code-select-col" };
238
+ const _hoisted_1$m = { class: "m-fields-code-select-col" };
232
239
  const _hoisted_2$e = { class: "code-select-container" };
233
240
  const _sfc_main$A = /* @__PURE__ */ defineComponent({
234
241
  ...{
@@ -322,7 +329,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
322
329
  };
323
330
  return (_ctx, _cache) => {
324
331
  const _component_m_form_container = resolveComponent("m-form-container");
325
- return openBlock(), createElementBlock("div", _hoisted_1$l, [
332
+ return openBlock(), createElementBlock("div", _hoisted_1$m, [
326
333
  createElementVNode("div", _hoisted_2$e, [
327
334
  createVNode(_component_m_form_container, {
328
335
  class: "select",
@@ -346,7 +353,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
346
353
  }
347
354
  });
348
355
 
349
- const _hoisted_1$k = { class: "m-editor-data-source-fields" };
356
+ const _hoisted_1$l = { class: "m-editor-data-source-fields" };
350
357
  const _hoisted_2$d = { class: "m-editor-data-source-fields-footer" };
351
358
  const _sfc_main$z = /* @__PURE__ */ defineComponent({
352
359
  ...{
@@ -494,7 +501,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
494
501
  }
495
502
  ];
496
503
  return (_ctx, _cache) => {
497
- return openBlock(), createElementBlock("div", _hoisted_1$k, [
504
+ return openBlock(), createElementBlock("div", _hoisted_1$l, [
498
505
  createVNode(unref(MagicTable), {
499
506
  data: _ctx.model[_ctx.name],
500
507
  columns: filedColumns
@@ -527,7 +534,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
527
534
  }
528
535
  });
529
536
 
530
- const _hoisted_1$j = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
537
+ const _hoisted_1$k = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
531
538
  const _hoisted_2$c = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
532
539
  const _hoisted_3$5 = { class: "el-input__inner" };
533
540
  const _sfc_main$y = /* @__PURE__ */ defineComponent({
@@ -753,7 +760,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
753
760
  createVNode(_sfc_main$B, { icon: unref(Coin) }, null, 8, ["icon"])
754
761
  ]),
755
762
  default: withCtx(({ item }) => [
756
- createElementVNode("div", _hoisted_1$j, [
763
+ createElementVNode("div", _hoisted_1$k, [
757
764
  createElementVNode("div", null, toDisplayString(item.text), 1),
758
765
  createElementVNode("span", _hoisted_2$c, toDisplayString(item.value), 1)
759
766
  ])
@@ -792,7 +799,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
792
799
  }
793
800
  });
794
801
 
795
- const _hoisted_1$i = { class: "m-fields-event-select" };
802
+ const _hoisted_1$j = { class: "m-fields-event-select" };
796
803
  const _hoisted_2$b = {
797
804
  key: 1,
798
805
  class: "fullWidth"
@@ -959,7 +966,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
959
966
  const _component_m_form_table = resolveComponent("m-form-table");
960
967
  const _component_m_form_container = resolveComponent("m-form-container");
961
968
  const _component_m_form_panel = resolveComponent("m-form-panel");
962
- return openBlock(), createElementBlock("div", _hoisted_1$i, [
969
+ return openBlock(), createElementBlock("div", _hoisted_1$j, [
963
970
  isOldVersion.value ? (openBlock(), createBlock(_component_m_form_table, {
964
971
  key: 0,
965
972
  ref: "eventForm",
@@ -1010,7 +1017,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
1010
1017
  }
1011
1018
  });
1012
1019
 
1013
- const _hoisted_1$h = { class: "m-fields-key-value" };
1020
+ const _hoisted_1$i = { class: "m-fields-key-value" };
1014
1021
  const _hoisted_2$a = /* @__PURE__ */ createElementVNode("span", { class: "m-fileds-key-value-delimiter" }, ":", -1);
1015
1022
  const _sfc_main$w = /* @__PURE__ */ defineComponent({
1016
1023
  ...{
@@ -1055,7 +1062,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
1055
1062
  records.value.splice(index, 1);
1056
1063
  };
1057
1064
  return (_ctx, _cache) => {
1058
- return openBlock(), createElementBlock("div", _hoisted_1$h, [
1065
+ return openBlock(), createElementBlock("div", _hoisted_1$i, [
1059
1066
  (openBlock(true), createElementBlock(Fragment, null, renderList(records.value, (item, index) => {
1060
1067
  return openBlock(), createElementBlock("div", {
1061
1068
  class: "m-fields-key-value-item",
@@ -1347,12 +1354,6 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
1347
1354
  }
1348
1355
  });
1349
1356
 
1350
- let $TMAGIC_EDITOR = {};
1351
- const setConfig = (option) => {
1352
- $TMAGIC_EDITOR = option;
1353
- };
1354
- const getConfig = (key) => $TMAGIC_EDITOR[key];
1355
-
1356
1357
  const _sfc_main$t = /* @__PURE__ */ defineComponent({
1357
1358
  ...{
1358
1359
  name: "MEditorResizer"
@@ -1361,6 +1362,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
1361
1362
  emits: ["change"],
1362
1363
  setup(__props, { emit }) {
1363
1364
  const target = ref();
1365
+ const isDraging = ref(false);
1364
1366
  let getso;
1365
1367
  onMounted(() => {
1366
1368
  if (!target.value)
@@ -1372,19 +1374,24 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
1372
1374
  if (!target.value)
1373
1375
  return;
1374
1376
  emit("change", e.deltaX);
1377
+ }).on("dragStart", () => {
1378
+ isDraging.value = true;
1379
+ }).on("dragEnd", () => {
1380
+ isDraging.value = false;
1375
1381
  });
1376
1382
  });
1377
1383
  onUnmounted(() => {
1378
1384
  getso?.unset();
1385
+ isDraging.value = false;
1379
1386
  });
1380
1387
  return (_ctx, _cache) => {
1381
1388
  return openBlock(), createElementBlock("span", {
1382
1389
  ref_key: "target",
1383
1390
  ref: target,
1384
- class: "m-editor-resizer"
1391
+ class: normalizeClass(["m-editor-resizer", { "m-editor-resizer-draging": isDraging.value }])
1385
1392
  }, [
1386
1393
  renderSlot(_ctx.$slots, "default")
1387
- ], 512);
1394
+ ], 2);
1388
1395
  };
1389
1396
  }
1390
1397
  });
@@ -1393,7 +1400,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
1393
1400
  ...{
1394
1401
  name: "MEditorLayout"
1395
1402
  },
1396
- __name: "Layout",
1403
+ __name: "SplitView",
1397
1404
  props: {
1398
1405
  left: {},
1399
1406
  right: {},
@@ -1762,6 +1769,28 @@ var CodeDeleteErrorType = /* @__PURE__ */ ((CodeDeleteErrorType2) => {
1762
1769
  return CodeDeleteErrorType2;
1763
1770
  })(CodeDeleteErrorType || {});
1764
1771
  const CODE_DRAFT_STORAGE_KEY = "magicCodeDraft";
1772
+ var KeyBindingCommand = /* @__PURE__ */ ((KeyBindingCommand2) => {
1773
+ KeyBindingCommand2["COPY_NODE"] = "tmagic-system-copy-node";
1774
+ KeyBindingCommand2["PASTE_NODE"] = "tmagic-system-paste-node";
1775
+ KeyBindingCommand2["DELETE_NODE"] = "tmagic-system-delete-node";
1776
+ KeyBindingCommand2["CUT_NODE"] = "tmagic-system-cut-node";
1777
+ KeyBindingCommand2["UNDO"] = "tmagic-system-undo";
1778
+ KeyBindingCommand2["REDO"] = "tmagic-system-redo";
1779
+ KeyBindingCommand2["ZOOM_IN"] = "tmagic-system-zoom-in";
1780
+ KeyBindingCommand2["ZOOM_OUT"] = "tmagic-system-zoom-out";
1781
+ KeyBindingCommand2["ZOOM_RESET"] = "tmagic-system-zoom-reset";
1782
+ KeyBindingCommand2["ZOOM_FIT"] = "tmagic-system-zoom-fit";
1783
+ KeyBindingCommand2["MOVE_UP_1"] = "tmagic-system-move-up-1";
1784
+ KeyBindingCommand2["MOVE_DOWN_1"] = "tmagic-system-move-down-1";
1785
+ KeyBindingCommand2["MOVE_LEFT_1"] = "tmagic-system-move-left-1";
1786
+ KeyBindingCommand2["MOVE_RIGHT_1"] = "tmagic-system-move-right-1";
1787
+ KeyBindingCommand2["MOVE_UP_10"] = "tmagic-system-move-up-10";
1788
+ KeyBindingCommand2["MOVE_DOWN_10"] = "tmagic-system-move-down-10";
1789
+ KeyBindingCommand2["MOVE_LEFT_10"] = "tmagic-system-move-left-10";
1790
+ KeyBindingCommand2["MOVE_RIGHT_10"] = "tmagic-system-move-right-10";
1791
+ KeyBindingCommand2["SWITCH_NODE"] = "tmagic-system-switch-node";
1792
+ return KeyBindingCommand2;
1793
+ })(KeyBindingCommand || {});
1765
1794
 
1766
1795
  const COPY_STORAGE_KEY = "$MagicEditorCopyData";
1767
1796
  const getPageList = (app) => {
@@ -2208,8 +2237,8 @@ class WebStorage extends BaseService {
2208
2237
  * 清理,支持storageService.usePlugin
2209
2238
  */
2210
2239
  async clear() {
2211
- const storage2 = await this.getStorage();
2212
- storage2.clear();
2240
+ const storage = await this.getStorage();
2241
+ storage.clear();
2213
2242
  }
2214
2243
  /**
2215
2244
  * 获取存储项,支持storageService.usePlugin
@@ -2223,7 +2252,7 @@ class WebStorage extends BaseService {
2223
2252
  return null;
2224
2253
  switch (protocol) {
2225
2254
  case "object" /* OBJECT */:
2226
- return eval(`(${item})`);
2255
+ return getConfig("parseDSL")(`(${item})`);
2227
2256
  case "json" /* JSON */:
2228
2257
  return JSON.parse(item);
2229
2258
  case "number" /* NUMBER */:
@@ -2238,49 +2267,49 @@ class WebStorage extends BaseService {
2238
2267
  * 获取指定索引位置的key
2239
2268
  */
2240
2269
  async key(index) {
2241
- const storage2 = await this.getStorage();
2242
- return storage2.key(index);
2270
+ const storage = await this.getStorage();
2271
+ return storage.key(index);
2243
2272
  }
2244
2273
  /**
2245
2274
  * 移除存储项,支持storageService.usePlugin
2246
2275
  */
2247
- async removeItem(key2, options2 = {}) {
2248
- const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
2249
- storage2.removeItem(`${options2.namespace || namespace2}:${key2}`);
2276
+ async removeItem(key, options = {}) {
2277
+ const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
2278
+ storage.removeItem(`${options.namespace || namespace}:${key}`);
2250
2279
  }
2251
2280
  /**
2252
2281
  * 设置存储项,支持storageService.usePlugin
2253
2282
  */
2254
- async setItem(key2, value, options2 = {}) {
2255
- const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
2256
- let item2 = value;
2257
- const protocol2 = options2.protocol ? `${options2.protocol}:` : "";
2283
+ async setItem(key, value, options = {}) {
2284
+ const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
2285
+ let item = value;
2286
+ const protocol = options.protocol ? `${options.protocol}:` : "";
2258
2287
  if (typeof value === "string" /* STRING */ || typeof value === "number" /* NUMBER */) {
2259
- item2 = `${protocol2}${value}`;
2288
+ item = `${protocol}${value}`;
2260
2289
  } else {
2261
- item2 = `${protocol2}${serialize(value)}`;
2290
+ item = `${protocol}${serialize(value)}`;
2262
2291
  }
2263
- storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
2292
+ storage.setItem(`${options.namespace || namespace}:${key}`, item);
2264
2293
  }
2265
2294
  destroy() {
2266
2295
  this.removeAllListeners();
2267
2296
  this.removeAllPlugins();
2268
2297
  }
2269
2298
  getValueAndProtocol(value) {
2270
- let protocol2 = "";
2299
+ let protocol = "";
2271
2300
  if (value === null) {
2272
2301
  return {
2273
2302
  item: value,
2274
- protocol: protocol2
2303
+ protocol
2275
2304
  };
2276
2305
  }
2277
- const item2 = value.replace(new RegExp(`^(${Object.values(Protocol).join("|")})(:)(.+)`), (_$0, $1, _$2, $3) => {
2278
- protocol2 = $1;
2306
+ const item = value.replace(new RegExp(`^(${Object.values(Protocol).join("|")})(:)(.+)`), (_$0, $1, _$2, $3) => {
2307
+ protocol = $1;
2279
2308
  return $3;
2280
2309
  });
2281
2310
  return {
2282
- protocol: protocol2,
2283
- item: item2
2311
+ protocol,
2312
+ item
2284
2313
  };
2285
2314
  }
2286
2315
  }
@@ -3377,7 +3406,7 @@ const useStage = (stageOptions) => {
3377
3406
  return stage;
3378
3407
  };
3379
3408
 
3380
- const _hoisted_1$g = { class: "m-editor-empty-panel" };
3409
+ const _hoisted_1$h = { class: "m-editor-empty-panel" };
3381
3410
  const _hoisted_2$9 = { class: "m-editor-empty-content" };
3382
3411
  const _hoisted_3$4 = /* @__PURE__ */ createElementVNode("p", null, "新增页面", -1);
3383
3412
  const _sfc_main$r = /* @__PURE__ */ defineComponent({
@@ -3400,7 +3429,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
3400
3429
  });
3401
3430
  };
3402
3431
  return (_ctx, _cache) => {
3403
- return openBlock(), createElementBlock("div", _hoisted_1$g, [
3432
+ return openBlock(), createElementBlock("div", _hoisted_1$h, [
3404
3433
  createElementVNode("div", _hoisted_2$9, [
3405
3434
  createElementVNode("div", {
3406
3435
  class: "m-editor-empty-button",
@@ -3417,7 +3446,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
3417
3446
  }
3418
3447
  });
3419
3448
 
3420
- const _hoisted_1$f = { class: "m-editor" };
3449
+ const _hoisted_1$g = { class: "m-editor" };
3421
3450
  const DEFAULT_LEFT_COLUMN_WIDTH = 310;
3422
3451
  const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
3423
3452
  const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
@@ -3482,13 +3511,14 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
3482
3511
  };
3483
3512
  const saveCode = (value) => {
3484
3513
  try {
3485
- editorService?.set("root", eval(value));
3514
+ const parseDSL = getConfig("parseDSL");
3515
+ editorService?.set("root", parseDSL(value));
3486
3516
  } catch (e) {
3487
3517
  console.error(e);
3488
3518
  }
3489
3519
  };
3490
3520
  return (_ctx, _cache) => {
3491
- return openBlock(), createElementBlock("div", _hoisted_1$f, [
3521
+ return openBlock(), createElementBlock("div", _hoisted_1$g, [
3492
3522
  renderSlot(_ctx.$slots, "header"),
3493
3523
  renderSlot(_ctx.$slots, "nav"),
3494
3524
  renderSlot(_ctx.$slots, "content-before"),
@@ -3543,7 +3573,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
3543
3573
  }
3544
3574
  });
3545
3575
 
3546
- const _hoisted_1$e = {
3576
+ const _hoisted_1$f = {
3547
3577
  key: 1,
3548
3578
  class: "menu-item-text"
3549
3579
  };
@@ -3627,7 +3657,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
3627
3657
  _ctx.data.type === "divider" ? (openBlock(), createBlock(unref(TMagicDivider), {
3628
3658
  key: 0,
3629
3659
  direction: _ctx.data.direction || "vertical"
3630
- }, null, 8, ["direction"])) : _ctx.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$e, toDisplayString(_ctx.data.text), 1)) : _ctx.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
3660
+ }, null, 8, ["direction"])) : _ctx.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$f, toDisplayString(_ctx.data.text), 1)) : _ctx.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
3631
3661
  _ctx.data.tooltip ? (openBlock(), createBlock(unref(TMagicTooltip), {
3632
3662
  key: 0,
3633
3663
  effect: "dark",
@@ -3882,7 +3912,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
3882
3912
  }
3883
3913
  });
3884
3914
 
3885
- const _hoisted_1$d = { class: "m-editor-props-panel" };
3915
+ const _hoisted_1$e = { class: "m-editor-props-panel" };
3886
3916
  const _sfc_main$n = /* @__PURE__ */ defineComponent({
3887
3917
  ...{
3888
3918
  name: "MEditorPropsPanel"
@@ -3932,7 +3962,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
3932
3962
  };
3933
3963
  __expose({ submit });
3934
3964
  return (_ctx, _cache) => {
3935
- return openBlock(), createElementBlock("div", _hoisted_1$d, [
3965
+ return openBlock(), createElementBlock("div", _hoisted_1$e, [
3936
3966
  renderSlot(_ctx.$slots, "props-panel-header"),
3937
3967
  createVNode(unref(MForm), {
3938
3968
  ref_key: "configForm",
@@ -3984,7 +4014,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
3984
4014
  }
3985
4015
  });
3986
4016
 
3987
- const _hoisted_1$c = { xmlns: "http://www.w3.org/2000/svg" };
4017
+ const _hoisted_1$d = { xmlns: "http://www.w3.org/2000/svg" };
3988
4018
  const _hoisted_2$7 = /* @__PURE__ */ createElementVNode("g", {
3989
4019
  fill: "#7C878E",
3990
4020
  "fill-rule": "evenodd"
@@ -4005,12 +4035,12 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
4005
4035
  __name: "AppManageIcon",
4006
4036
  setup(__props) {
4007
4037
  return (_ctx, _cache) => {
4008
- return openBlock(), createElementBlock("svg", _hoisted_1$c, _hoisted_3$3);
4038
+ return openBlock(), createElementBlock("svg", _hoisted_1$d, _hoisted_3$3);
4009
4039
  };
4010
4040
  }
4011
4041
  });
4012
4042
 
4013
- const _hoisted_1$b = {
4043
+ const _hoisted_1$c = {
4014
4044
  viewBox: "0 0 32 32",
4015
4045
  version: "1.1",
4016
4046
  xmlns: "http://www.w3.org/2000/svg",
@@ -4027,12 +4057,12 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
4027
4057
  __name: "CodeIcon",
4028
4058
  setup(__props) {
4029
4059
  return (_ctx, _cache) => {
4030
- return openBlock(), createElementBlock("svg", _hoisted_1$b, _hoisted_4$3);
4060
+ return openBlock(), createElementBlock("svg", _hoisted_1$c, _hoisted_4$3);
4031
4061
  };
4032
4062
  }
4033
4063
  });
4034
4064
 
4035
- const _hoisted_1$a = {
4065
+ const _hoisted_1$b = {
4036
4066
  key: 0,
4037
4067
  class: "m-editor-content-bottom"
4038
4068
  };
@@ -4136,7 +4166,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
4136
4166
  language: _ctx.language,
4137
4167
  options: codeOptions.value
4138
4168
  }, null, 8, ["init-values", "language", "options"]),
4139
- _ctx.editable ? (openBlock(), createElementBlock("div", _hoisted_1$a, [
4169
+ _ctx.editable ? (openBlock(), createElementBlock("div", _hoisted_1$b, [
4140
4170
  createVNode(unref(TMagicButton), {
4141
4171
  type: "primary",
4142
4172
  class: "button",
@@ -4192,7 +4222,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
4192
4222
  }
4193
4223
  });
4194
4224
 
4195
- const _hoisted_1$9 = { class: "code-name-wrapper" };
4225
+ const _hoisted_1$a = { class: "code-name-wrapper" };
4196
4226
  const _hoisted_2$4 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "代码块名称", -1);
4197
4227
  const _hoisted_3$2 = { class: "code-name-wrapper" };
4198
4228
  const _hoisted_4$2 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "参数", -1);
@@ -4212,6 +4242,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
4212
4242
  },
4213
4243
  setup(__props, { expose: __expose }) {
4214
4244
  const props = __props;
4245
+ provide("mForm", {});
4215
4246
  const defaultParamColConfig = {
4216
4247
  type: "row",
4217
4248
  label: "参数类型",
@@ -4280,29 +4311,29 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
4280
4311
  initTableModel();
4281
4312
  const beforeSave = (codeValue) => {
4282
4313
  try {
4283
- eval(codeValue);
4314
+ getConfig("parseDSL")(codeValue);
4284
4315
  return true;
4285
4316
  } catch (e) {
4286
4317
  tMagicMessage.error(e.stack);
4287
4318
  return false;
4288
4319
  }
4289
4320
  };
4290
- const saveCode = async (codeValue2) => {
4321
+ const saveCode = async (codeValue) => {
4291
4322
  if (!props.editable)
4292
4323
  return;
4293
- evalRes.value = beforeSave(codeValue2);
4324
+ evalRes.value = beforeSave(codeValue);
4294
4325
  if (evalRes.value) {
4295
4326
  await services?.codeBlockService.setCodeDslById(props.id, {
4296
4327
  name: codeName.value,
4297
- content: codeValue2,
4328
+ content: codeValue,
4298
4329
  params: tableModel.value?.params || []
4299
4330
  });
4300
4331
  tMagicMessage.success("代码成功保存到本地");
4301
4332
  services?.codeBlockService.removeCodeDraft(props.id);
4302
4333
  }
4303
4334
  };
4304
- const saveAndClose = async (codeValue2) => {
4305
- await saveCode(codeValue2);
4335
+ const saveAndClose = async (codeValue) => {
4336
+ await saveCode(codeValue);
4306
4337
  if (evalRes.value) {
4307
4338
  close();
4308
4339
  }
@@ -4318,7 +4349,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
4318
4349
  const _component_m_form_table = resolveComponent("m-form-table");
4319
4350
  return openBlock(), createBlock(unref(TMagicCard), { shadow: "never" }, {
4320
4351
  header: withCtx(() => [
4321
- createElementVNode("div", _hoisted_1$9, [
4352
+ createElementVNode("div", _hoisted_1$a, [
4322
4353
  _hoisted_2$4,
4323
4354
  createVNode(unref(TMagicInput), {
4324
4355
  class: "code-name-input",
@@ -4360,7 +4391,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
4360
4391
  }
4361
4392
  });
4362
4393
 
4363
- const _hoisted_1$8 = {
4394
+ const _hoisted_1$9 = {
4364
4395
  key: 0,
4365
4396
  class: "m-editor-code-block-editor-panel"
4366
4397
  };
@@ -4428,7 +4459,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
4428
4459
  class: "code-editor-layout"
4429
4460
  }, {
4430
4461
  center: withCtx(() => [
4431
- !unref(isEmpty)(codeConfig.value) ? (openBlock(), createElementBlock("div", _hoisted_1$8, [
4462
+ !unref(isEmpty)(codeConfig.value) ? (openBlock(), createElementBlock("div", _hoisted_1$9, [
4432
4463
  renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id: id.value }),
4433
4464
  codeConfig.value ? (openBlock(), createBlock(_sfc_main$i, {
4434
4465
  key: 0,
@@ -4453,7 +4484,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
4453
4484
  }
4454
4485
  });
4455
4486
 
4456
- const _hoisted_1$7 = { class: "search-wrapper" };
4487
+ const _hoisted_1$8 = { class: "search-wrapper" };
4457
4488
  const _hoisted_2$3 = ["id"];
4458
4489
  const _hoisted_3$1 = { class: "list-item" };
4459
4490
  const _hoisted_4$1 = {
@@ -4556,7 +4587,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
4556
4587
  return openBlock(), createBlock(unref(TMagicScrollbar), { class: "m-editor-code-block-list m-editor-dep-list-panel" }, {
4557
4588
  default: withCtx(() => [
4558
4589
  renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
4559
- createElementVNode("div", _hoisted_1$7, [
4590
+ createElementVNode("div", _hoisted_1$8, [
4560
4591
  createVNode(_sfc_main$m, { onSearch: filterTextChangeHandler }),
4561
4592
  editable.value ? (openBlock(), createBlock(unref(TMagicButton), {
4562
4593
  key: 0,
@@ -4751,7 +4782,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
4751
4782
  }
4752
4783
  });
4753
4784
 
4754
- const _hoisted_1$6 = { class: "search-wrapper" };
4785
+ const _hoisted_1$7 = { class: "search-wrapper" };
4755
4786
  const _hoisted_2$2 = ["id"];
4756
4787
  const _hoisted_3 = { class: "list-item" };
4757
4788
  const _hoisted_4 = {
@@ -4820,7 +4851,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4820
4851
  return (_ctx, _cache) => {
4821
4852
  return openBlock(), createBlock(unref(TMagicScrollbar), { class: "data-source-list-panel m-editor-dep-list-panel" }, {
4822
4853
  default: withCtx(() => [
4823
- createElementVNode("div", _hoisted_1$6, [
4854
+ createElementVNode("div", _hoisted_1$7, [
4824
4855
  createVNode(_sfc_main$m, { onSearch: filterTextChangeHandler }),
4825
4856
  createVNode(unref(TMagicButton), {
4826
4857
  type: "primary",
@@ -4916,7 +4947,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4916
4947
  }
4917
4948
  });
4918
4949
 
4919
- const _hoisted_1$5 = ["onClick", "onDragstart"];
4950
+ const _hoisted_1$6 = ["onClick", "onDragstart"];
4920
4951
  const _sfc_main$d = /* @__PURE__ */ defineComponent({
4921
4952
  ...{
4922
4953
  name: "MEditorComponentListPanel"
@@ -5034,7 +5065,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
5034
5065
  _: 2
5035
5066
  }, 1032, ["content"])
5036
5067
  ])
5037
- ], 40, _hoisted_1$5);
5068
+ ], 40, _hoisted_1$6);
5038
5069
  }), 128))
5039
5070
  ]),
5040
5071
  _: 2
@@ -5071,6 +5102,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
5071
5102
  left: "0",
5072
5103
  top: "0"
5073
5104
  });
5105
+ const contains = (el) => menu.value?.contains(el) || subMenu.value?.contains(el);
5074
5106
  const hide = () => {
5075
5107
  if (!visible.value)
5076
5108
  return;
@@ -5083,7 +5115,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
5083
5115
  if (!visible.value || !target) {
5084
5116
  return;
5085
5117
  }
5086
- if (menu.value?.contains(target) || subMenu.value?.$el?.contains(target)) {
5118
+ if (contains(target)) {
5087
5119
  return;
5088
5120
  }
5089
5121
  hide();
@@ -5110,13 +5142,15 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
5110
5142
  if (typeof item !== "object" || !menuItem.items?.length) {
5111
5143
  return;
5112
5144
  }
5113
- subMenuData.value = menuItem.items;
5114
- if (menu.value) {
5115
- subMenu.value.show({
5116
- clientX: menu.value.offsetLeft + menu.value.clientWidth,
5117
- clientY: menu.value.offsetTop
5118
- });
5119
- }
5145
+ subMenuData.value = menuItem.items || [];
5146
+ setTimeout(() => {
5147
+ if (menu.value) {
5148
+ subMenu.value?.show({
5149
+ clientX: menu.value.offsetLeft + menu.value.clientWidth,
5150
+ clientY: menu.value.offsetTop
5151
+ });
5152
+ }
5153
+ }, 0);
5120
5154
  };
5121
5155
  onMounted(() => {
5122
5156
  if (props.isSubMenu)
@@ -5129,8 +5163,10 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
5129
5163
  globalThis.removeEventListener("mousedown", hideHandler, true);
5130
5164
  });
5131
5165
  __expose({
5166
+ menu,
5132
5167
  hide,
5133
- show
5168
+ show,
5169
+ contains
5134
5170
  });
5135
5171
  return (_ctx, _cache) => {
5136
5172
  const _component_content_menu = resolveComponent("content-menu", true);
@@ -5153,14 +5189,15 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
5153
5189
  }), 128))
5154
5190
  ]),
5155
5191
  (openBlock(), createBlock(Teleport, { to: "body" }, [
5156
- createVNode(_component_content_menu, {
5192
+ subMenuData.value.length ? (openBlock(), createBlock(_component_content_menu, {
5193
+ key: 0,
5157
5194
  class: "sub-menu",
5158
5195
  ref_key: "subMenu",
5159
5196
  ref: subMenu,
5160
5197
  "menu-data": subMenuData.value,
5161
5198
  "is-sub-menu": true,
5162
5199
  onHide: hide
5163
- }, null, 8, ["menu-data"])
5200
+ }, null, 8, ["menu-data"])) : createCommentVNode("", true)
5164
5201
  ]))
5165
5202
  ], 4)), [
5166
5203
  [vShow, visible.value]
@@ -5273,7 +5310,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
5273
5310
  }
5274
5311
  });
5275
5312
 
5276
- const _hoisted_1$4 = ["id", "onMouseenter"];
5313
+ const _hoisted_1$5 = ["id", "onMouseenter"];
5277
5314
  const throttleTime = 150;
5278
5315
  const _sfc_main$a = /* @__PURE__ */ defineComponent({
5279
5316
  ...{
@@ -5286,6 +5323,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
5286
5323
  setup(__props) {
5287
5324
  const services = inject("services");
5288
5325
  const editorService = services?.editorService;
5326
+ const keybindingService = services?.keybindingService;
5289
5327
  const tree = ref();
5290
5328
  const menu = ref();
5291
5329
  const checkedKeys = ref([]);
@@ -5419,25 +5457,59 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
5419
5457
  const windowBlurHandler = () => {
5420
5458
  isCtrlKeyDown.value = false;
5421
5459
  };
5422
- let keycon;
5460
+ keybindingService?.registeCommand("layer-panel-not-ctrl-keydown", (e) => {
5461
+ if (e.key !== keybindingService.ctrlKey) {
5462
+ isCtrlKeyDown.value = false;
5463
+ }
5464
+ });
5465
+ keybindingService?.registeCommand("layer-panel-ctrl-keydown", () => {
5466
+ isCtrlKeyDown.value = true;
5467
+ });
5468
+ keybindingService?.registeCommand("layer-panel-ctrl-keyup", () => {
5469
+ isCtrlKeyDown.value = false;
5470
+ });
5471
+ keybindingService?.registeCommand("layer-panel-global-keydwon", () => {
5472
+ if (!tree.value?.$el.contains(document.activeElement)) {
5473
+ isCtrlKeyDown.value = false;
5474
+ }
5475
+ });
5476
+ keybindingService?.registe([
5477
+ {
5478
+ command: "layer-panel-not-ctrl-keydown",
5479
+ when: [["layer-panel", "keydown"]]
5480
+ },
5481
+ {
5482
+ command: "layer-panel-ctrl-keydown",
5483
+ keybinding: "ctrl",
5484
+ when: [["layer-panel", "keydown"]]
5485
+ },
5486
+ {
5487
+ command: "layer-panel-ctrl-keyup",
5488
+ keybinding: "ctrl",
5489
+ when: [["layer-panel", "keyup"]]
5490
+ },
5491
+ {
5492
+ command: "layer-panel-global-keydwon",
5493
+ keybinding: "ctrl",
5494
+ when: [["global", "keydown"]]
5495
+ }
5496
+ ]);
5497
+ watch(tree, () => {
5498
+ if (tree.value?.$el) {
5499
+ keybindingService?.registeEl("layer-panel", tree.value.$el);
5500
+ tree.value.$el.addEventListener("blur", windowBlurHandler);
5501
+ } else {
5502
+ keybindingService?.unregisteEl("layer-panel");
5503
+ }
5504
+ });
5423
5505
  onMounted(() => {
5424
5506
  editorService?.on("remove", editorServiceRemoveHandler);
5425
- keycon = new KeyController();
5426
- const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
5427
- const ctrl = isMac ? "meta" : "ctrl";
5428
- keycon.keydown((e) => {
5429
- if (e.key !== ctrl) {
5430
- isCtrlKeyDown.value = false;
5431
- }
5432
- }).keydown(ctrl, () => {
5433
- isCtrlKeyDown.value = true;
5434
- }).keyup(ctrl, () => {
5435
- isCtrlKeyDown.value = false;
5436
- });
5437
5507
  globalThis.addEventListener("blur", windowBlurHandler);
5438
5508
  });
5509
+ onBeforeUnmount(() => {
5510
+ tree.value?.$el.removeEventListener("blur", windowBlurHandler);
5511
+ });
5439
5512
  onUnmounted(() => {
5440
- keycon.destroy();
5441
5513
  editorService?.off("remove", editorServiceRemoveHandler);
5442
5514
  globalThis.removeEventListener("blur", windowBlurHandler);
5443
5515
  });
@@ -5484,6 +5556,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
5484
5556
  ref: tree,
5485
5557
  "node-key": "id",
5486
5558
  "empty-text": "页面空荡荡的",
5559
+ tabindex: "-1",
5487
5560
  draggable: "",
5488
5561
  "default-expanded-keys": expandedKeys.value,
5489
5562
  "default-checked-keys": checkedKeys.value,
@@ -5517,7 +5590,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
5517
5590
  }, () => [
5518
5591
  createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
5519
5592
  ])
5520
- ], 40, _hoisted_1$4)
5593
+ ], 40, _hoisted_1$5)
5521
5594
  ]),
5522
5595
  _: 3
5523
5596
  }, 8, ["default-expanded-keys", "default-checked-keys", "current-node-key", "data", "highlight-current", "show-checkbox"])) : createCommentVNode("", true),
@@ -5535,7 +5608,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
5535
5608
  }
5536
5609
  });
5537
5610
 
5538
- const _hoisted_1$3 = {
5611
+ const _hoisted_1$4 = {
5539
5612
  key: 1,
5540
5613
  class: "magic-editor-tab-panel-title"
5541
5614
  };
@@ -5623,7 +5696,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
5623
5696
  key: 0,
5624
5697
  icon: config.icon
5625
5698
  }, null, 8, ["icon"])) : createCommentVNode("", true),
5626
- config.text ? (openBlock(), createElementBlock("div", _hoisted_1$3, toDisplayString(config.text), 1)) : createCommentVNode("", true)
5699
+ config.text ? (openBlock(), createElementBlock("div", _hoisted_1$4, toDisplayString(config.text), 1)) : createCommentVNode("", true)
5627
5700
  ]))
5628
5701
  ]),
5629
5702
  default: withCtx(() => [
@@ -5710,7 +5783,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
5710
5783
  }
5711
5784
  });
5712
5785
 
5713
- const _hoisted_1$2 = {
5786
+ const _hoisted_1$3 = {
5714
5787
  key: 0,
5715
5788
  class: "m-editor-breadcrumb"
5716
5789
  };
@@ -5732,7 +5805,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
5732
5805
  editorService?.get("stage")?.select(node2.id);
5733
5806
  };
5734
5807
  return (_ctx, _cache) => {
5735
- return nodes.value.length === 1 ? (openBlock(), createElementBlock("div", _hoisted_1$2, [
5808
+ return nodes.value.length === 1 ? (openBlock(), createElementBlock("div", _hoisted_1$3, [
5736
5809
  (openBlock(true), createElementBlock(Fragment, null, renderList(path.value, (item, index) => {
5737
5810
  return openBlock(), createElementBlock(Fragment, {
5738
5811
  key: item.id
@@ -5755,7 +5828,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
5755
5828
  }
5756
5829
  });
5757
5830
 
5758
- const _hoisted_1$1 = {
5831
+ const _hoisted_1$2 = {
5759
5832
  key: 1,
5760
5833
  style: { "width": "21px" }
5761
5834
  };
@@ -5848,7 +5921,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
5848
5921
  onClick: addPage
5849
5922
  }, [
5850
5923
  createVNode(_sfc_main$B, { icon: unref(Plus) }, null, 8, ["icon"])
5851
- ])) : (openBlock(), createElementBlock("div", _hoisted_1$1)),
5924
+ ])) : (openBlock(), createElementBlock("div", _hoisted_1$2)),
5852
5925
  canScroll.value ? (openBlock(), createElementBlock("div", {
5853
5926
  key: 2,
5854
5927
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
@@ -5877,7 +5950,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
5877
5950
  }
5878
5951
  });
5879
5952
 
5880
- const _hoisted_1 = ["onClick"];
5953
+ const _hoisted_1$1 = ["onClick"];
5881
5954
  const _hoisted_2 = { class: "m-editor-page-bar-title" };
5882
5955
  const _sfc_main$6 = /* @__PURE__ */ defineComponent({
5883
5956
  ...{
@@ -5963,7 +6036,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
5963
6036
  ]),
5964
6037
  _: 2
5965
6038
  }, 1024)
5966
- ], 10, _hoisted_1);
6039
+ ], 10, _hoisted_1$1);
5967
6040
  }), 128))
5968
6041
  ]),
5969
6042
  _: 3
@@ -6482,6 +6555,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
6482
6555
  if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
6483
6556
  return;
6484
6557
  stage = useStage(stageOptions);
6558
+ stage.on("select", () => {
6559
+ stageWrap.value?.container?.focus();
6560
+ });
6485
6561
  services?.editorService.set("stage", markRaw(stage));
6486
6562
  stage?.mount(stageContainer.value);
6487
6563
  if (!node.value?.id)
@@ -6522,21 +6598,25 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
6522
6598
  }
6523
6599
  });
6524
6600
  onMounted(() => {
6525
- stageWrap.value?.container && resizeObserver.observe(stageWrap.value.container);
6601
+ if (stageWrap.value?.container) {
6602
+ resizeObserver.observe(stageWrap.value.container);
6603
+ services?.keybindingService.registeEl("stage", stageWrap.value.container);
6604
+ }
6526
6605
  });
6527
6606
  onUnmounted(() => {
6528
6607
  stage?.destroy();
6529
6608
  resizeObserver.disconnect();
6530
6609
  services?.editorService.set("stage", null);
6610
+ services?.keybindingService.unregisteEl("stage");
6531
6611
  });
6532
- const contextmenuHandler = (e2) => {
6533
- e2.preventDefault();
6534
- menu.value?.show(e2);
6612
+ const contextmenuHandler = (e) => {
6613
+ e.preventDefault();
6614
+ menu.value?.show(e);
6535
6615
  };
6536
- const dragoverHandler = (e2) => {
6537
- e2.preventDefault();
6538
- if (e2.dataTransfer) {
6539
- e2.dataTransfer.dropEffect = "move";
6616
+ const dragoverHandler = (e) => {
6617
+ e.preventDefault();
6618
+ if (e.dataTransfer) {
6619
+ e.dataTransfer.dropEffect = "move";
6540
6620
  }
6541
6621
  };
6542
6622
  const dropHandler = async (e) => {
@@ -6548,7 +6628,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
6548
6628
  parent = services?.editorService.getNodeById(parentEl.id, false);
6549
6629
  }
6550
6630
  if (e.dataTransfer && parent && stageContainer.value && stage) {
6551
- const config = eval(`(${e.dataTransfer.getData("data")})`);
6631
+ const parseDSL = getConfig("parseDSL");
6632
+ const config = parseDSL(`(${e.dataTransfer.getData("data")})`);
6552
6633
  const layout = await services?.editorService.getLayout(parent);
6553
6634
  const containerRect = stageContainer.value.getBoundingClientRect();
6554
6635
  const { scrollTop, scrollLeft } = stage.mask;
@@ -6581,6 +6662,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
6581
6662
  class: "m-editor-stage",
6582
6663
  ref_key: "stageWrap",
6583
6664
  ref: stageWrap,
6665
+ tabindex: "-1",
6584
6666
  width: stageRect.value?.width,
6585
6667
  height: stageRect.value?.height,
6586
6668
  "wrap-width": stageContainerRect.value?.width,
@@ -6616,6 +6698,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
6616
6698
  }
6617
6699
  });
6618
6700
 
6701
+ const _hoisted_1 = { class: "m-editor-workspace" };
6619
6702
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
6620
6703
  ...{
6621
6704
  name: "MEditorWorkspace"
@@ -6626,112 +6709,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
6626
6709
  },
6627
6710
  setup(__props) {
6628
6711
  const services = inject("services");
6629
- const workspace = ref();
6630
- const nodes = computed(() => services?.editorService.get("nodes"));
6631
6712
  const page = computed(() => services?.editorService.get("page"));
6632
- const mouseenterHandler = () => {
6633
- workspace.value?.focus();
6634
- };
6635
- const mouseleaveHandler = () => {
6636
- workspace.value?.blur();
6637
- };
6638
- let keycon;
6639
- onMounted(() => {
6640
- workspace.value?.addEventListener("mouseenter", mouseenterHandler);
6641
- workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
6642
- keycon = new KeyController(workspace.value);
6643
- const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
6644
- const ctrl = isMac ? "meta" : "ctrl";
6645
- keycon.keyup("delete", (e) => {
6646
- e.inputEvent.preventDefault();
6647
- if (!nodes.value || isPage(nodes.value[0]))
6648
- return;
6649
- services?.editorService.remove(nodes.value);
6650
- }).keyup("backspace", (e) => {
6651
- e.inputEvent.preventDefault();
6652
- if (!nodes.value || isPage(nodes.value[0]))
6653
- return;
6654
- services?.editorService.remove(nodes.value);
6655
- }).keydown([ctrl, "c"], (e) => {
6656
- e.inputEvent.preventDefault();
6657
- nodes.value && services?.editorService.copy(nodes.value);
6658
- }).keydown([ctrl, "v"], (e) => {
6659
- e.inputEvent.preventDefault();
6660
- nodes.value && services?.editorService.paste({ offsetX: 10, offsetY: 10 });
6661
- }).keydown([ctrl, "x"], (e) => {
6662
- e.inputEvent.preventDefault();
6663
- if (!nodes.value || isPage(nodes.value[0]))
6664
- return;
6665
- services?.editorService.copy(nodes.value);
6666
- services?.editorService.remove(nodes.value);
6667
- }).keydown([ctrl, "z"], (e) => {
6668
- e.inputEvent.preventDefault();
6669
- services?.editorService.undo();
6670
- }).keydown([ctrl, "shift", "z"], (e) => {
6671
- e.inputEvent.preventDefault();
6672
- services?.editorService.redo();
6673
- }).keydown("up", (e) => {
6674
- e.inputEvent.preventDefault();
6675
- services?.editorService.move(0, -1);
6676
- }).keydown("down", (e) => {
6677
- e.inputEvent.preventDefault();
6678
- services?.editorService.move(0, 1);
6679
- }).keydown("left", (e) => {
6680
- e.inputEvent.preventDefault();
6681
- services?.editorService.move(-1, 0);
6682
- }).keydown("right", (e) => {
6683
- e.inputEvent.preventDefault();
6684
- services?.editorService.move(1, 0);
6685
- }).keydown([ctrl, "up"], (e) => {
6686
- e.inputEvent.preventDefault();
6687
- services?.editorService.move(0, -10);
6688
- }).keydown([ctrl, "down"], (e) => {
6689
- e.inputEvent.preventDefault();
6690
- services?.editorService.move(0, 10);
6691
- }).keydown([ctrl, "left"], (e) => {
6692
- e.inputEvent.preventDefault();
6693
- services?.editorService.move(-10, 0);
6694
- }).keydown([ctrl, "right"], (e) => {
6695
- e.inputEvent.preventDefault();
6696
- services?.editorService.move(10, 0);
6697
- }).keydown("tab", (e) => {
6698
- e.inputEvent.preventDefault();
6699
- services?.editorService.selectNextNode();
6700
- }).keydown([ctrl, "tab"], (e) => {
6701
- e.inputEvent.preventDefault();
6702
- services?.editorService.selectNextPage();
6703
- }).keydown([ctrl, "="], (e) => {
6704
- e.inputEvent.preventDefault();
6705
- services?.uiService.zoom(0.1);
6706
- }).keydown([ctrl, "numpadplus"], (e) => {
6707
- e.inputEvent.preventDefault();
6708
- services?.uiService.zoom(0.1);
6709
- }).keydown([ctrl, "-"], (e) => {
6710
- e.inputEvent.preventDefault();
6711
- services?.uiService.zoom(-0.1);
6712
- }).keydown([ctrl, "numpad-"], (e) => {
6713
- e.inputEvent.preventDefault();
6714
- services?.uiService.zoom(-0.1);
6715
- }).keydown([ctrl, "0"], async (e) => {
6716
- e.inputEvent.preventDefault();
6717
- services?.uiService.set("zoom", await services.uiService.calcZoom());
6718
- }).keydown([ctrl, "1"], (e) => {
6719
- e.inputEvent.preventDefault();
6720
- services?.uiService.set("zoom", 1);
6721
- });
6722
- });
6723
- onUnmounted(() => {
6724
- workspace.value?.removeEventListener("mouseenter", mouseenterHandler);
6725
- workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
6726
- keycon.destroy();
6727
- });
6728
6713
  return (_ctx, _cache) => {
6729
- return openBlock(), createElementBlock("div", {
6730
- class: "m-editor-workspace",
6731
- tabindex: "-1",
6732
- ref_key: "workspace",
6733
- ref: workspace
6734
- }, [
6714
+ return openBlock(), createElementBlock("div", _hoisted_1, [
6735
6715
  createVNode(_sfc_main$8),
6736
6716
  renderSlot(_ctx.$slots, "stage", {}, () => [
6737
6717
  page.value ? (openBlock(), createBlock(_sfc_main$2, {
@@ -6749,7 +6729,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
6749
6729
  ]),
6750
6730
  _: 3
6751
6731
  })
6752
- ], 512);
6732
+ ]);
6753
6733
  };
6754
6734
  }
6755
6735
  });
@@ -6778,8 +6758,8 @@ class CodeBlock extends BaseService {
6778
6758
  * @param {CodeBlockDSL} codeDsl 代码DSL
6779
6759
  * @returns {void}
6780
6760
  */
6781
- async setCodeDsl(codeDsl2) {
6782
- this.state.codeDsl = codeDsl2;
6761
+ async setCodeDsl(codeDsl) {
6762
+ this.state.codeDsl = codeDsl;
6783
6763
  this.emit("code-dsl-change", this.state.codeDsl);
6784
6764
  }
6785
6765
  /**
@@ -6796,13 +6776,13 @@ class CodeBlock extends BaseService {
6796
6776
  * @param {Id} id 代码块id
6797
6777
  * @returns {CodeBlockContent | null}
6798
6778
  */
6799
- getCodeContentById(id2) {
6800
- if (!id2)
6779
+ getCodeContentById(id) {
6780
+ if (!id)
6801
6781
  return null;
6802
6782
  const totalCodeDsl = this.getCodeDsl();
6803
6783
  if (!totalCodeDsl)
6804
6784
  return null;
6805
- return totalCodeDsl[id2] ?? null;
6785
+ return totalCodeDsl[id] ?? null;
6806
6786
  }
6807
6787
  /**
6808
6788
  * 设置代码块ID和代码内容到源dsl
@@ -6817,7 +6797,8 @@ class CodeBlock extends BaseService {
6817
6797
  }
6818
6798
  const codeConfigProcessed = codeConfig;
6819
6799
  if (codeConfig.content) {
6820
- codeConfigProcessed.content = eval(codeConfig.content);
6800
+ const parseDSL = getConfig("parseDSL");
6801
+ codeConfigProcessed.content = parseDSL(codeConfig.content);
6821
6802
  }
6822
6803
  const existContent = codeDsl[id] || {};
6823
6804
  codeDsl[id] = {
@@ -6832,8 +6813,8 @@ class CodeBlock extends BaseService {
6832
6813
  * @returns {CodeBlockDSL}
6833
6814
  */
6834
6815
  getCodeDslByIds(ids) {
6835
- const codeDsl2 = this.getCodeDsl();
6836
- return pick(codeDsl2, ids);
6816
+ const codeDsl = this.getCodeDsl();
6817
+ return pick(codeDsl, ids);
6837
6818
  }
6838
6819
  /**
6839
6820
  * 设置代码编辑面板展示状态
@@ -6856,10 +6837,10 @@ class CodeBlock extends BaseService {
6856
6837
  * @param {Id} id 代码块id
6857
6838
  * @returns {void}
6858
6839
  */
6859
- setCodeEditorContent(status, id2) {
6860
- if (!id2)
6840
+ setCodeEditorContent(status, id) {
6841
+ if (!id)
6861
6842
  return;
6862
- this.setId(id2);
6843
+ this.setId(id);
6863
6844
  this.state.isShowCodeEditor = status;
6864
6845
  }
6865
6846
  /**
@@ -6889,10 +6870,10 @@ class CodeBlock extends BaseService {
6889
6870
  * @param {Id} id 代码块id
6890
6871
  * @returns {void}
6891
6872
  */
6892
- setId(id2) {
6893
- if (!id2)
6873
+ setId(id) {
6874
+ if (!id)
6894
6875
  return;
6895
- this.state.id = id2;
6876
+ this.state.id = id;
6896
6877
  }
6897
6878
  /**
6898
6879
  * 获取当前选中的代码块ID
@@ -6957,9 +6938,9 @@ class CodeBlock extends BaseService {
6957
6938
  const currentDsl = await this.getCodeDsl();
6958
6939
  if (!currentDsl)
6959
6940
  return;
6960
- codeIds.forEach((id2) => {
6961
- delete currentDsl[id2];
6962
- this.emit("remove", id2);
6941
+ codeIds.forEach((id) => {
6942
+ delete currentDsl[id];
6943
+ this.emit("remove", id);
6963
6944
  });
6964
6945
  }
6965
6946
  /**
@@ -7473,6 +7454,275 @@ class Events extends BaseService {
7473
7454
  }
7474
7455
  const eventsService = new Events();
7475
7456
 
7457
+ class Keybinding extends BaseService {
7458
+ ctrlKey = /mac os x/.test(navigator.userAgent.toLowerCase()) ? "meta" : "ctrl";
7459
+ controllers = /* @__PURE__ */ new Map();
7460
+ bindingList = [];
7461
+ commands = {
7462
+ [KeyBindingCommand.DELETE_NODE]: () => {
7463
+ const nodes = editorService.get("nodes");
7464
+ if (!nodes || isPage(nodes[0]))
7465
+ return;
7466
+ editorService.remove(nodes);
7467
+ },
7468
+ [KeyBindingCommand.COPY_NODE]: () => {
7469
+ const nodes = editorService.get("nodes");
7470
+ nodes && editorService.copy(nodes);
7471
+ },
7472
+ [KeyBindingCommand.CUT_NODE]: () => {
7473
+ const nodes = editorService.get("nodes");
7474
+ if (!nodes || isPage(nodes[0]))
7475
+ return;
7476
+ editorService.copy(nodes);
7477
+ editorService.remove(nodes);
7478
+ },
7479
+ [KeyBindingCommand.PASTE_NODE]: () => {
7480
+ const nodes = editorService.get("nodes");
7481
+ nodes && editorService.paste({ offsetX: 10, offsetY: 10 });
7482
+ },
7483
+ [KeyBindingCommand.UNDO]: () => {
7484
+ editorService.undo();
7485
+ },
7486
+ [KeyBindingCommand.REDO]: () => {
7487
+ editorService.redo();
7488
+ },
7489
+ [KeyBindingCommand.ZOOM_IN]: () => {
7490
+ uiService.zoom(0.1);
7491
+ },
7492
+ [KeyBindingCommand.ZOOM_OUT]: () => {
7493
+ uiService.zoom(-0.1);
7494
+ },
7495
+ [KeyBindingCommand.ZOOM_RESET]: () => {
7496
+ uiService.set("zoom", 1);
7497
+ },
7498
+ [KeyBindingCommand.ZOOM_FIT]: async () => {
7499
+ uiService.set("zoom", await uiService.calcZoom());
7500
+ },
7501
+ [KeyBindingCommand.MOVE_UP_1]: () => {
7502
+ editorService.move(0, -1);
7503
+ },
7504
+ [KeyBindingCommand.MOVE_DOWN_1]: () => {
7505
+ editorService.move(0, 1);
7506
+ },
7507
+ [KeyBindingCommand.MOVE_LEFT_1]: () => {
7508
+ editorService.move(-1, 0);
7509
+ },
7510
+ [KeyBindingCommand.MOVE_RIGHT_1]: () => {
7511
+ editorService.move(1, 0);
7512
+ },
7513
+ [KeyBindingCommand.MOVE_UP_10]: () => {
7514
+ editorService.move(0, -10);
7515
+ },
7516
+ [KeyBindingCommand.MOVE_DOWN_10]: () => {
7517
+ editorService.move(0, 10);
7518
+ },
7519
+ [KeyBindingCommand.MOVE_LEFT_10]: () => {
7520
+ editorService.move(-10, 0);
7521
+ },
7522
+ [KeyBindingCommand.MOVE_RIGHT_10]: () => {
7523
+ editorService.move(10, 0);
7524
+ },
7525
+ [KeyBindingCommand.SWITCH_NODE]: () => {
7526
+ editorService.selectNextNode();
7527
+ }
7528
+ };
7529
+ registeCommand(command, handler) {
7530
+ this.commands[command] = handler;
7531
+ }
7532
+ unregisteCommand(command) {
7533
+ delete this.commands[command];
7534
+ }
7535
+ registeEl(name, el) {
7536
+ if (name !== "global" && !el) {
7537
+ throw new Error("只有name为global可以不传el");
7538
+ }
7539
+ const keycon = new KeyController(el);
7540
+ this.controllers.set(name, keycon);
7541
+ this.bind(name);
7542
+ }
7543
+ unregisteEl(name) {
7544
+ this.controllers.get(name)?.destroy();
7545
+ this.controllers.delete(name);
7546
+ this.bindingList.forEach((item) => {
7547
+ item.binded = false;
7548
+ });
7549
+ }
7550
+ registe(maps) {
7551
+ for (const keybindingItem of maps) {
7552
+ const { command, keybinding, when } = keybindingItem;
7553
+ for (const [type = "", eventType = "keydown"] of when) {
7554
+ const cacheItem = { type, command, keybinding, eventType, binded: false };
7555
+ this.bindingList.push(cacheItem);
7556
+ }
7557
+ }
7558
+ this.bind();
7559
+ }
7560
+ reset() {
7561
+ this.controllers.forEach((keycon) => {
7562
+ keycon.destroy();
7563
+ });
7564
+ this.controllers.clear();
7565
+ this.bindingList = [];
7566
+ }
7567
+ destroy() {
7568
+ this.reset();
7569
+ }
7570
+ bind(name) {
7571
+ for (const item of this.bindingList) {
7572
+ const { type, eventType, command, keybinding, binded } = item;
7573
+ if (name && name !== type) {
7574
+ continue;
7575
+ }
7576
+ if (binded) {
7577
+ continue;
7578
+ }
7579
+ const keycon = this.controllers.get(type);
7580
+ if (!keycon) {
7581
+ continue;
7582
+ }
7583
+ const handler = (e) => {
7584
+ e.inputEvent.preventDefault();
7585
+ this.commands[command]?.(e.inputEvent);
7586
+ };
7587
+ this.getKeyconKeys(keybinding).forEach((keys) => {
7588
+ if (keys[0]) {
7589
+ keycon[eventType](keys, handler);
7590
+ } else {
7591
+ keycon[eventType](handler);
7592
+ }
7593
+ });
7594
+ item.binded = true;
7595
+ }
7596
+ }
7597
+ getKeyconKeys(keybinding = "") {
7598
+ const splitKey = (key) => key.split("+").map((k) => k === "ctrl" ? this.ctrlKey : k);
7599
+ if (Array.isArray(keybinding)) {
7600
+ return keybinding.map((key) => splitKey(key));
7601
+ }
7602
+ return [splitKey(keybinding)];
7603
+ }
7604
+ }
7605
+ const keybindingService = new Keybinding();
7606
+
7607
+ const keybindingConfig = [
7608
+ {
7609
+ command: KeyBindingCommand.DELETE_NODE,
7610
+ keybinding: ["delete", "backspace"],
7611
+ when: [
7612
+ ["stage", "keyup"],
7613
+ ["layer-panel", "keydown"]
7614
+ ]
7615
+ },
7616
+ {
7617
+ command: KeyBindingCommand.COPY_NODE,
7618
+ keybinding: "ctrl+c",
7619
+ when: [
7620
+ ["stage", "keydown"],
7621
+ ["layer-panel", "keydown"]
7622
+ ]
7623
+ },
7624
+ {
7625
+ command: KeyBindingCommand.PASTE_NODE,
7626
+ keybinding: "ctrl+v",
7627
+ when: [
7628
+ ["stage", "keydown"],
7629
+ ["layer-panel", "keydown"]
7630
+ ]
7631
+ },
7632
+ {
7633
+ command: KeyBindingCommand.CUT_NODE,
7634
+ keybinding: "ctrl+x",
7635
+ when: [
7636
+ ["stage", "keydown"],
7637
+ ["layer-panel", "keydown"]
7638
+ ]
7639
+ },
7640
+ {
7641
+ command: KeyBindingCommand.UNDO,
7642
+ keybinding: "ctrl+z",
7643
+ when: [
7644
+ ["stage", "keydown"],
7645
+ ["layer-panel", "keydown"]
7646
+ ]
7647
+ },
7648
+ {
7649
+ command: KeyBindingCommand.REDO,
7650
+ keybinding: "ctrl+shift+z",
7651
+ when: [
7652
+ ["stage", "keydown"],
7653
+ ["layer-panel", "keydown"]
7654
+ ]
7655
+ },
7656
+ {
7657
+ command: KeyBindingCommand.MOVE_UP_1,
7658
+ keybinding: "up",
7659
+ when: [["stage", "keydown"]]
7660
+ },
7661
+ {
7662
+ command: KeyBindingCommand.MOVE_DOWN_1,
7663
+ keybinding: "down",
7664
+ when: [["stage", "keydown"]]
7665
+ },
7666
+ {
7667
+ command: KeyBindingCommand.MOVE_LEFT_1,
7668
+ keybinding: "left",
7669
+ when: [["stage", "keydown"]]
7670
+ },
7671
+ {
7672
+ command: KeyBindingCommand.MOVE_RIGHT_1,
7673
+ keybinding: "right",
7674
+ when: [["stage", "keydown"]]
7675
+ },
7676
+ {
7677
+ command: KeyBindingCommand.MOVE_UP_10,
7678
+ keybinding: "ctrl+up",
7679
+ when: [["stage", "keydown"]]
7680
+ },
7681
+ {
7682
+ command: KeyBindingCommand.MOVE_DOWN_10,
7683
+ keybinding: "ctrl+down",
7684
+ when: [["stage", "keydown"]]
7685
+ },
7686
+ {
7687
+ command: KeyBindingCommand.MOVE_LEFT_10,
7688
+ keybinding: "ctrl+left",
7689
+ when: [["stage", "keydown"]]
7690
+ },
7691
+ {
7692
+ command: KeyBindingCommand.MOVE_RIGHT_10,
7693
+ keybinding: "ctrl+right",
7694
+ when: [["stage", "keydown"]]
7695
+ },
7696
+ {
7697
+ command: KeyBindingCommand.SWITCH_NODE,
7698
+ keybinding: "tab",
7699
+ when: [
7700
+ ["stage", "keydown"],
7701
+ ["layer-panel", "keydown"]
7702
+ ]
7703
+ },
7704
+ {
7705
+ command: KeyBindingCommand.ZOOM_IN,
7706
+ keybinding: ["ctrl+=", "ctrl+numpadplus"],
7707
+ when: [["stage", "keydown"]]
7708
+ },
7709
+ {
7710
+ command: KeyBindingCommand.ZOOM_OUT,
7711
+ keybinding: ["ctrl+-", "ctrl+numpad-"],
7712
+ when: [["stage", "keydown"]]
7713
+ },
7714
+ {
7715
+ command: KeyBindingCommand.ZOOM_FIT,
7716
+ keybinding: "ctrl+0",
7717
+ when: [["stage", "keydown"]]
7718
+ },
7719
+ {
7720
+ command: KeyBindingCommand.ZOOM_RESET,
7721
+ keybinding: "ctrl+1",
7722
+ when: [["stage", "keydown"]]
7723
+ }
7724
+ ];
7725
+
7476
7726
  const editorProps = {
7477
7727
  /** 页面初始值 */
7478
7728
  modelValue: {
@@ -7600,7 +7850,8 @@ const initServiceState = (props, {
7600
7850
  propsService,
7601
7851
  eventsService,
7602
7852
  uiService,
7603
- codeBlockService
7853
+ codeBlockService,
7854
+ keybindingService
7604
7855
  }) => {
7605
7856
  watch(
7606
7857
  () => props.modelValue,
@@ -7669,6 +7920,7 @@ const initServiceState = (props, {
7669
7920
  uiService.resetState();
7670
7921
  componentListService.resetState();
7671
7922
  codeBlockService.resetState();
7923
+ keybindingService.reset();
7672
7924
  });
7673
7925
  };
7674
7926
  const initServiceEvents = (props, emit, { editorService, codeBlockService, dataSourceService, depService }) => {
@@ -7860,10 +8112,13 @@ const _sfc_main = defineComponent({
7860
8112
  storageService,
7861
8113
  codeBlockService,
7862
8114
  depService,
7863
- dataSourceService
8115
+ dataSourceService,
8116
+ keybindingService
7864
8117
  };
7865
8118
  initServiceEvents(props, emit, services);
7866
8119
  initServiceState(props, services);
8120
+ keybindingService.registe(keybindingConfig);
8121
+ keybindingService.registeEl("global");
7867
8122
  provide("services", services);
7868
8123
  provide("codeOptions", props.codeOptions);
7869
8124
  provide(
@@ -8000,7 +8255,8 @@ const Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]])
8000
8255
  const index$1 = '';
8001
8256
 
8002
8257
  const defaultInstallOpt = {
8003
- // @todo, 自定义图片上传方法等编辑器依赖的外部选项
8258
+ // eslint-disable-next-line no-eval
8259
+ parseDSL: (dsl) => eval(dsl)
8004
8260
  };
8005
8261
  const index = {
8006
8262
  install: (app, opt) => {
@@ -8021,5 +8277,5 @@ const index = {
8021
8277
  }
8022
8278
  };
8023
8279
 
8024
- export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$g as CodeBlockList, CodeDeleteErrorType, _sfc_main$C as CodeSelect, _sfc_main$A as CodeSelectCol, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$c as ContentMenu, _sfc_main$z as DataSourceFields, _sfc_main$y as DataSourceInput, _sfc_main$x as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$B as Icon, _sfc_main$w as KeyValue, Keys, LayerOffset, _sfc_main$a as LayerPanel, Layout, _sfc_main$s as LayoutContainer, _sfc_main$n as PropsPanel, _sfc_main$u as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$p as ToolButton, V_GUIDE_LINE_STORAGE_KEY, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, editorService, error, eventsService, fillConfig$1 as fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, uiService, useStage, warn };
8280
+ export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$g as CodeBlockList, CodeDeleteErrorType, _sfc_main$C as CodeSelect, _sfc_main$A as CodeSelectCol, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$c as ContentMenu, _sfc_main$z as DataSourceFields, _sfc_main$y as DataSourceInput, _sfc_main$x as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$B as Icon, KeyBindingCommand, _sfc_main$w as KeyValue, Keys, LayerOffset, _sfc_main$a as LayerPanel, Layout, _sfc_main$s as LayoutContainer, _sfc_main$n as PropsPanel, _sfc_main$s as SplitView, _sfc_main$u as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$p as ToolButton, V_GUIDE_LINE_STORAGE_KEY, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, editorService, error, eventsService, fillConfig$1 as fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, uiService, useStage, warn };
8025
8281
  //# sourceMappingURL=tmagic-editor.js.map