@tmagic/editor 1.3.0-alpha.5 → 1.3.0-alpha.6

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.
@@ -185,7 +185,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
185
185
  }
186
186
  });
187
187
 
188
- const _hoisted_1$m = ["src"];
188
+ const _hoisted_1$n = ["src"];
189
189
  const _sfc_main$B = /* @__PURE__ */ defineComponent({
190
190
  ...{
191
191
  name: "MEditorIcon"
@@ -209,7 +209,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
209
209
  class: "magic-editor-icon"
210
210
  }, {
211
211
  default: withCtx(() => [
212
- createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$m)
212
+ createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$n)
213
213
  ]),
214
214
  _: 1
215
215
  })) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
@@ -228,7 +228,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
228
228
  }
229
229
  });
230
230
 
231
- const _hoisted_1$l = { class: "m-fields-code-select-col" };
231
+ const _hoisted_1$m = { class: "m-fields-code-select-col" };
232
232
  const _hoisted_2$e = { class: "code-select-container" };
233
233
  const _sfc_main$A = /* @__PURE__ */ defineComponent({
234
234
  ...{
@@ -322,7 +322,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
322
322
  };
323
323
  return (_ctx, _cache) => {
324
324
  const _component_m_form_container = resolveComponent("m-form-container");
325
- return openBlock(), createElementBlock("div", _hoisted_1$l, [
325
+ return openBlock(), createElementBlock("div", _hoisted_1$m, [
326
326
  createElementVNode("div", _hoisted_2$e, [
327
327
  createVNode(_component_m_form_container, {
328
328
  class: "select",
@@ -346,7 +346,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
346
346
  }
347
347
  });
348
348
 
349
- const _hoisted_1$k = { class: "m-editor-data-source-fields" };
349
+ const _hoisted_1$l = { class: "m-editor-data-source-fields" };
350
350
  const _hoisted_2$d = { class: "m-editor-data-source-fields-footer" };
351
351
  const _sfc_main$z = /* @__PURE__ */ defineComponent({
352
352
  ...{
@@ -494,7 +494,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
494
494
  }
495
495
  ];
496
496
  return (_ctx, _cache) => {
497
- return openBlock(), createElementBlock("div", _hoisted_1$k, [
497
+ return openBlock(), createElementBlock("div", _hoisted_1$l, [
498
498
  createVNode(unref(MagicTable), {
499
499
  data: _ctx.model[_ctx.name],
500
500
  columns: filedColumns
@@ -527,7 +527,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
527
527
  }
528
528
  });
529
529
 
530
- const _hoisted_1$j = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
530
+ const _hoisted_1$k = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
531
531
  const _hoisted_2$c = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
532
532
  const _hoisted_3$5 = { class: "el-input__inner" };
533
533
  const _sfc_main$y = /* @__PURE__ */ defineComponent({
@@ -753,7 +753,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
753
753
  createVNode(_sfc_main$B, { icon: unref(Coin) }, null, 8, ["icon"])
754
754
  ]),
755
755
  default: withCtx(({ item }) => [
756
- createElementVNode("div", _hoisted_1$j, [
756
+ createElementVNode("div", _hoisted_1$k, [
757
757
  createElementVNode("div", null, toDisplayString(item.text), 1),
758
758
  createElementVNode("span", _hoisted_2$c, toDisplayString(item.value), 1)
759
759
  ])
@@ -792,7 +792,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
792
792
  }
793
793
  });
794
794
 
795
- const _hoisted_1$i = { class: "m-fields-event-select" };
795
+ const _hoisted_1$j = { class: "m-fields-event-select" };
796
796
  const _hoisted_2$b = {
797
797
  key: 1,
798
798
  class: "fullWidth"
@@ -959,7 +959,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
959
959
  const _component_m_form_table = resolveComponent("m-form-table");
960
960
  const _component_m_form_container = resolveComponent("m-form-container");
961
961
  const _component_m_form_panel = resolveComponent("m-form-panel");
962
- return openBlock(), createElementBlock("div", _hoisted_1$i, [
962
+ return openBlock(), createElementBlock("div", _hoisted_1$j, [
963
963
  isOldVersion.value ? (openBlock(), createBlock(_component_m_form_table, {
964
964
  key: 0,
965
965
  ref: "eventForm",
@@ -1010,7 +1010,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
1010
1010
  }
1011
1011
  });
1012
1012
 
1013
- const _hoisted_1$h = { class: "m-fields-key-value" };
1013
+ const _hoisted_1$i = { class: "m-fields-key-value" };
1014
1014
  const _hoisted_2$a = /* @__PURE__ */ createElementVNode("span", { class: "m-fileds-key-value-delimiter" }, ":", -1);
1015
1015
  const _sfc_main$w = /* @__PURE__ */ defineComponent({
1016
1016
  ...{
@@ -1055,7 +1055,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
1055
1055
  records.value.splice(index, 1);
1056
1056
  };
1057
1057
  return (_ctx, _cache) => {
1058
- return openBlock(), createElementBlock("div", _hoisted_1$h, [
1058
+ return openBlock(), createElementBlock("div", _hoisted_1$i, [
1059
1059
  (openBlock(true), createElementBlock(Fragment, null, renderList(records.value, (item, index) => {
1060
1060
  return openBlock(), createElementBlock("div", {
1061
1061
  class: "m-fields-key-value-item",
@@ -1361,6 +1361,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
1361
1361
  emits: ["change"],
1362
1362
  setup(__props, { emit }) {
1363
1363
  const target = ref();
1364
+ const isDraging = ref(false);
1364
1365
  let getso;
1365
1366
  onMounted(() => {
1366
1367
  if (!target.value)
@@ -1372,19 +1373,24 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
1372
1373
  if (!target.value)
1373
1374
  return;
1374
1375
  emit("change", e.deltaX);
1376
+ }).on("dragStart", () => {
1377
+ isDraging.value = true;
1378
+ }).on("dragEnd", () => {
1379
+ isDraging.value = false;
1375
1380
  });
1376
1381
  });
1377
1382
  onUnmounted(() => {
1378
1383
  getso?.unset();
1384
+ isDraging.value = false;
1379
1385
  });
1380
1386
  return (_ctx, _cache) => {
1381
1387
  return openBlock(), createElementBlock("span", {
1382
1388
  ref_key: "target",
1383
1389
  ref: target,
1384
- class: "m-editor-resizer"
1390
+ class: normalizeClass(["m-editor-resizer", { "m-editor-resizer-draging": isDraging.value }])
1385
1391
  }, [
1386
1392
  renderSlot(_ctx.$slots, "default")
1387
- ], 512);
1393
+ ], 2);
1388
1394
  };
1389
1395
  }
1390
1396
  });
@@ -1393,7 +1399,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
1393
1399
  ...{
1394
1400
  name: "MEditorLayout"
1395
1401
  },
1396
- __name: "Layout",
1402
+ __name: "SplitView",
1397
1403
  props: {
1398
1404
  left: {},
1399
1405
  right: {},
@@ -3377,7 +3383,7 @@ const useStage = (stageOptions) => {
3377
3383
  return stage;
3378
3384
  };
3379
3385
 
3380
- const _hoisted_1$g = { class: "m-editor-empty-panel" };
3386
+ const _hoisted_1$h = { class: "m-editor-empty-panel" };
3381
3387
  const _hoisted_2$9 = { class: "m-editor-empty-content" };
3382
3388
  const _hoisted_3$4 = /* @__PURE__ */ createElementVNode("p", null, "新增页面", -1);
3383
3389
  const _sfc_main$r = /* @__PURE__ */ defineComponent({
@@ -3400,7 +3406,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
3400
3406
  });
3401
3407
  };
3402
3408
  return (_ctx, _cache) => {
3403
- return openBlock(), createElementBlock("div", _hoisted_1$g, [
3409
+ return openBlock(), createElementBlock("div", _hoisted_1$h, [
3404
3410
  createElementVNode("div", _hoisted_2$9, [
3405
3411
  createElementVNode("div", {
3406
3412
  class: "m-editor-empty-button",
@@ -3417,7 +3423,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
3417
3423
  }
3418
3424
  });
3419
3425
 
3420
- const _hoisted_1$f = { class: "m-editor" };
3426
+ const _hoisted_1$g = { class: "m-editor" };
3421
3427
  const DEFAULT_LEFT_COLUMN_WIDTH = 310;
3422
3428
  const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
3423
3429
  const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
@@ -3488,7 +3494,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
3488
3494
  }
3489
3495
  };
3490
3496
  return (_ctx, _cache) => {
3491
- return openBlock(), createElementBlock("div", _hoisted_1$f, [
3497
+ return openBlock(), createElementBlock("div", _hoisted_1$g, [
3492
3498
  renderSlot(_ctx.$slots, "header"),
3493
3499
  renderSlot(_ctx.$slots, "nav"),
3494
3500
  renderSlot(_ctx.$slots, "content-before"),
@@ -3543,7 +3549,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
3543
3549
  }
3544
3550
  });
3545
3551
 
3546
- const _hoisted_1$e = {
3552
+ const _hoisted_1$f = {
3547
3553
  key: 1,
3548
3554
  class: "menu-item-text"
3549
3555
  };
@@ -3627,7 +3633,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
3627
3633
  _ctx.data.type === "divider" ? (openBlock(), createBlock(unref(TMagicDivider), {
3628
3634
  key: 0,
3629
3635
  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 }, [
3636
+ }, 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
3637
  _ctx.data.tooltip ? (openBlock(), createBlock(unref(TMagicTooltip), {
3632
3638
  key: 0,
3633
3639
  effect: "dark",
@@ -3882,7 +3888,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
3882
3888
  }
3883
3889
  });
3884
3890
 
3885
- const _hoisted_1$d = { class: "m-editor-props-panel" };
3891
+ const _hoisted_1$e = { class: "m-editor-props-panel" };
3886
3892
  const _sfc_main$n = /* @__PURE__ */ defineComponent({
3887
3893
  ...{
3888
3894
  name: "MEditorPropsPanel"
@@ -3932,7 +3938,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
3932
3938
  };
3933
3939
  __expose({ submit });
3934
3940
  return (_ctx, _cache) => {
3935
- return openBlock(), createElementBlock("div", _hoisted_1$d, [
3941
+ return openBlock(), createElementBlock("div", _hoisted_1$e, [
3936
3942
  renderSlot(_ctx.$slots, "props-panel-header"),
3937
3943
  createVNode(unref(MForm), {
3938
3944
  ref_key: "configForm",
@@ -3984,7 +3990,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
3984
3990
  }
3985
3991
  });
3986
3992
 
3987
- const _hoisted_1$c = { xmlns: "http://www.w3.org/2000/svg" };
3993
+ const _hoisted_1$d = { xmlns: "http://www.w3.org/2000/svg" };
3988
3994
  const _hoisted_2$7 = /* @__PURE__ */ createElementVNode("g", {
3989
3995
  fill: "#7C878E",
3990
3996
  "fill-rule": "evenodd"
@@ -4005,12 +4011,12 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
4005
4011
  __name: "AppManageIcon",
4006
4012
  setup(__props) {
4007
4013
  return (_ctx, _cache) => {
4008
- return openBlock(), createElementBlock("svg", _hoisted_1$c, _hoisted_3$3);
4014
+ return openBlock(), createElementBlock("svg", _hoisted_1$d, _hoisted_3$3);
4009
4015
  };
4010
4016
  }
4011
4017
  });
4012
4018
 
4013
- const _hoisted_1$b = {
4019
+ const _hoisted_1$c = {
4014
4020
  viewBox: "0 0 32 32",
4015
4021
  version: "1.1",
4016
4022
  xmlns: "http://www.w3.org/2000/svg",
@@ -4027,12 +4033,12 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
4027
4033
  __name: "CodeIcon",
4028
4034
  setup(__props) {
4029
4035
  return (_ctx, _cache) => {
4030
- return openBlock(), createElementBlock("svg", _hoisted_1$b, _hoisted_4$3);
4036
+ return openBlock(), createElementBlock("svg", _hoisted_1$c, _hoisted_4$3);
4031
4037
  };
4032
4038
  }
4033
4039
  });
4034
4040
 
4035
- const _hoisted_1$a = {
4041
+ const _hoisted_1$b = {
4036
4042
  key: 0,
4037
4043
  class: "m-editor-content-bottom"
4038
4044
  };
@@ -4136,7 +4142,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
4136
4142
  language: _ctx.language,
4137
4143
  options: codeOptions.value
4138
4144
  }, null, 8, ["init-values", "language", "options"]),
4139
- _ctx.editable ? (openBlock(), createElementBlock("div", _hoisted_1$a, [
4145
+ _ctx.editable ? (openBlock(), createElementBlock("div", _hoisted_1$b, [
4140
4146
  createVNode(unref(TMagicButton), {
4141
4147
  type: "primary",
4142
4148
  class: "button",
@@ -4192,7 +4198,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
4192
4198
  }
4193
4199
  });
4194
4200
 
4195
- const _hoisted_1$9 = { class: "code-name-wrapper" };
4201
+ const _hoisted_1$a = { class: "code-name-wrapper" };
4196
4202
  const _hoisted_2$4 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "代码块名称", -1);
4197
4203
  const _hoisted_3$2 = { class: "code-name-wrapper" };
4198
4204
  const _hoisted_4$2 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "参数", -1);
@@ -4318,7 +4324,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
4318
4324
  const _component_m_form_table = resolveComponent("m-form-table");
4319
4325
  return openBlock(), createBlock(unref(TMagicCard), { shadow: "never" }, {
4320
4326
  header: withCtx(() => [
4321
- createElementVNode("div", _hoisted_1$9, [
4327
+ createElementVNode("div", _hoisted_1$a, [
4322
4328
  _hoisted_2$4,
4323
4329
  createVNode(unref(TMagicInput), {
4324
4330
  class: "code-name-input",
@@ -4360,7 +4366,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
4360
4366
  }
4361
4367
  });
4362
4368
 
4363
- const _hoisted_1$8 = {
4369
+ const _hoisted_1$9 = {
4364
4370
  key: 0,
4365
4371
  class: "m-editor-code-block-editor-panel"
4366
4372
  };
@@ -4428,7 +4434,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
4428
4434
  class: "code-editor-layout"
4429
4435
  }, {
4430
4436
  center: withCtx(() => [
4431
- !unref(isEmpty)(codeConfig.value) ? (openBlock(), createElementBlock("div", _hoisted_1$8, [
4437
+ !unref(isEmpty)(codeConfig.value) ? (openBlock(), createElementBlock("div", _hoisted_1$9, [
4432
4438
  renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id: id.value }),
4433
4439
  codeConfig.value ? (openBlock(), createBlock(_sfc_main$i, {
4434
4440
  key: 0,
@@ -4453,7 +4459,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
4453
4459
  }
4454
4460
  });
4455
4461
 
4456
- const _hoisted_1$7 = { class: "search-wrapper" };
4462
+ const _hoisted_1$8 = { class: "search-wrapper" };
4457
4463
  const _hoisted_2$3 = ["id"];
4458
4464
  const _hoisted_3$1 = { class: "list-item" };
4459
4465
  const _hoisted_4$1 = {
@@ -4556,7 +4562,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
4556
4562
  return openBlock(), createBlock(unref(TMagicScrollbar), { class: "m-editor-code-block-list m-editor-dep-list-panel" }, {
4557
4563
  default: withCtx(() => [
4558
4564
  renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
4559
- createElementVNode("div", _hoisted_1$7, [
4565
+ createElementVNode("div", _hoisted_1$8, [
4560
4566
  createVNode(_sfc_main$m, { onSearch: filterTextChangeHandler }),
4561
4567
  editable.value ? (openBlock(), createBlock(unref(TMagicButton), {
4562
4568
  key: 0,
@@ -4751,7 +4757,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
4751
4757
  }
4752
4758
  });
4753
4759
 
4754
- const _hoisted_1$6 = { class: "search-wrapper" };
4760
+ const _hoisted_1$7 = { class: "search-wrapper" };
4755
4761
  const _hoisted_2$2 = ["id"];
4756
4762
  const _hoisted_3 = { class: "list-item" };
4757
4763
  const _hoisted_4 = {
@@ -4820,7 +4826,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4820
4826
  return (_ctx, _cache) => {
4821
4827
  return openBlock(), createBlock(unref(TMagicScrollbar), { class: "data-source-list-panel m-editor-dep-list-panel" }, {
4822
4828
  default: withCtx(() => [
4823
- createElementVNode("div", _hoisted_1$6, [
4829
+ createElementVNode("div", _hoisted_1$7, [
4824
4830
  createVNode(_sfc_main$m, { onSearch: filterTextChangeHandler }),
4825
4831
  createVNode(unref(TMagicButton), {
4826
4832
  type: "primary",
@@ -4916,7 +4922,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4916
4922
  }
4917
4923
  });
4918
4924
 
4919
- const _hoisted_1$5 = ["onClick", "onDragstart"];
4925
+ const _hoisted_1$6 = ["onClick", "onDragstart"];
4920
4926
  const _sfc_main$d = /* @__PURE__ */ defineComponent({
4921
4927
  ...{
4922
4928
  name: "MEditorComponentListPanel"
@@ -5034,7 +5040,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
5034
5040
  _: 2
5035
5041
  }, 1032, ["content"])
5036
5042
  ])
5037
- ], 40, _hoisted_1$5);
5043
+ ], 40, _hoisted_1$6);
5038
5044
  }), 128))
5039
5045
  ]),
5040
5046
  _: 2
@@ -5273,7 +5279,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
5273
5279
  }
5274
5280
  });
5275
5281
 
5276
- const _hoisted_1$4 = ["id", "onMouseenter"];
5282
+ const _hoisted_1$5 = ["id", "onMouseenter"];
5277
5283
  const throttleTime = 150;
5278
5284
  const _sfc_main$a = /* @__PURE__ */ defineComponent({
5279
5285
  ...{
@@ -5286,6 +5292,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
5286
5292
  setup(__props) {
5287
5293
  const services = inject("services");
5288
5294
  const editorService = services?.editorService;
5295
+ const keybindingService = services?.keybindingService;
5289
5296
  const tree = ref();
5290
5297
  const menu = ref();
5291
5298
  const checkedKeys = ref([]);
@@ -5419,27 +5426,38 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
5419
5426
  const windowBlurHandler = () => {
5420
5427
  isCtrlKeyDown.value = false;
5421
5428
  };
5429
+ const globalKeyupHandler = () => {
5430
+ if (document.activeElement !== tree.value?.$el) {
5431
+ isCtrlKeyDown.value = false;
5432
+ }
5433
+ };
5422
5434
  let keycon;
5423
5435
  onMounted(() => {
5424
5436
  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) {
5437
+ if (tree.value?.$el) {
5438
+ keybindingService?.on("keyup", globalKeyupHandler);
5439
+ keycon = new KeyController(tree.value.$el);
5440
+ const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
5441
+ const ctrl = isMac ? "meta" : "ctrl";
5442
+ keycon.keydown((e) => {
5443
+ if (e.key !== ctrl) {
5444
+ isCtrlKeyDown.value = false;
5445
+ }
5446
+ }).keydown(ctrl, () => {
5447
+ isCtrlKeyDown.value = true;
5448
+ }).keyup(ctrl, () => {
5430
5449
  isCtrlKeyDown.value = false;
5431
- }
5432
- }).keydown(ctrl, () => {
5433
- isCtrlKeyDown.value = true;
5434
- }).keyup(ctrl, () => {
5435
- isCtrlKeyDown.value = false;
5436
- });
5450
+ });
5451
+ tree.value.$el.addEventListener("blur", windowBlurHandler);
5452
+ }
5437
5453
  globalThis.addEventListener("blur", windowBlurHandler);
5438
5454
  });
5439
5455
  onUnmounted(() => {
5440
5456
  keycon.destroy();
5441
5457
  editorService?.off("remove", editorServiceRemoveHandler);
5458
+ keybindingService?.off("keyup", globalKeyupHandler);
5442
5459
  globalThis.removeEventListener("blur", windowBlurHandler);
5460
+ tree.value?.$el.removeEventListener("blur", windowBlurHandler);
5443
5461
  });
5444
5462
  const highlightHandler = throttle((data) => {
5445
5463
  highlight(data);
@@ -5484,6 +5502,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
5484
5502
  ref: tree,
5485
5503
  "node-key": "id",
5486
5504
  "empty-text": "页面空荡荡的",
5505
+ tabindex: "-1",
5487
5506
  draggable: "",
5488
5507
  "default-expanded-keys": expandedKeys.value,
5489
5508
  "default-checked-keys": checkedKeys.value,
@@ -5517,7 +5536,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
5517
5536
  }, () => [
5518
5537
  createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
5519
5538
  ])
5520
- ], 40, _hoisted_1$4)
5539
+ ], 40, _hoisted_1$5)
5521
5540
  ]),
5522
5541
  _: 3
5523
5542
  }, 8, ["default-expanded-keys", "default-checked-keys", "current-node-key", "data", "highlight-current", "show-checkbox"])) : createCommentVNode("", true),
@@ -5535,7 +5554,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
5535
5554
  }
5536
5555
  });
5537
5556
 
5538
- const _hoisted_1$3 = {
5557
+ const _hoisted_1$4 = {
5539
5558
  key: 1,
5540
5559
  class: "magic-editor-tab-panel-title"
5541
5560
  };
@@ -5623,7 +5642,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
5623
5642
  key: 0,
5624
5643
  icon: config.icon
5625
5644
  }, null, 8, ["icon"])) : createCommentVNode("", true),
5626
- config.text ? (openBlock(), createElementBlock("div", _hoisted_1$3, toDisplayString(config.text), 1)) : createCommentVNode("", true)
5645
+ config.text ? (openBlock(), createElementBlock("div", _hoisted_1$4, toDisplayString(config.text), 1)) : createCommentVNode("", true)
5627
5646
  ]))
5628
5647
  ]),
5629
5648
  default: withCtx(() => [
@@ -5710,7 +5729,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
5710
5729
  }
5711
5730
  });
5712
5731
 
5713
- const _hoisted_1$2 = {
5732
+ const _hoisted_1$3 = {
5714
5733
  key: 0,
5715
5734
  class: "m-editor-breadcrumb"
5716
5735
  };
@@ -5732,7 +5751,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
5732
5751
  editorService?.get("stage")?.select(node2.id);
5733
5752
  };
5734
5753
  return (_ctx, _cache) => {
5735
- return nodes.value.length === 1 ? (openBlock(), createElementBlock("div", _hoisted_1$2, [
5754
+ return nodes.value.length === 1 ? (openBlock(), createElementBlock("div", _hoisted_1$3, [
5736
5755
  (openBlock(true), createElementBlock(Fragment, null, renderList(path.value, (item, index) => {
5737
5756
  return openBlock(), createElementBlock(Fragment, {
5738
5757
  key: item.id
@@ -5755,7 +5774,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
5755
5774
  }
5756
5775
  });
5757
5776
 
5758
- const _hoisted_1$1 = {
5777
+ const _hoisted_1$2 = {
5759
5778
  key: 1,
5760
5779
  style: { "width": "21px" }
5761
5780
  };
@@ -5848,7 +5867,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
5848
5867
  onClick: addPage
5849
5868
  }, [
5850
5869
  createVNode(_sfc_main$B, { icon: unref(Plus) }, null, 8, ["icon"])
5851
- ])) : (openBlock(), createElementBlock("div", _hoisted_1$1)),
5870
+ ])) : (openBlock(), createElementBlock("div", _hoisted_1$2)),
5852
5871
  canScroll.value ? (openBlock(), createElementBlock("div", {
5853
5872
  key: 2,
5854
5873
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
@@ -5877,7 +5896,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
5877
5896
  }
5878
5897
  });
5879
5898
 
5880
- const _hoisted_1 = ["onClick"];
5899
+ const _hoisted_1$1 = ["onClick"];
5881
5900
  const _hoisted_2 = { class: "m-editor-page-bar-title" };
5882
5901
  const _sfc_main$6 = /* @__PURE__ */ defineComponent({
5883
5902
  ...{
@@ -5963,7 +5982,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
5963
5982
  ]),
5964
5983
  _: 2
5965
5984
  }, 1024)
5966
- ], 10, _hoisted_1);
5985
+ ], 10, _hoisted_1$1);
5967
5986
  }), 128))
5968
5987
  ]),
5969
5988
  _: 3
@@ -6616,6 +6635,10 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
6616
6635
  }
6617
6636
  });
6618
6637
 
6638
+ const _hoisted_1 = {
6639
+ class: "m-editor-workspace",
6640
+ tabindex: "-1"
6641
+ };
6619
6642
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
6620
6643
  ...{
6621
6644
  name: "MEditorWorkspace"
@@ -6626,112 +6649,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
6626
6649
  },
6627
6650
  setup(__props) {
6628
6651
  const services = inject("services");
6629
- const workspace = ref();
6630
- const nodes = computed(() => services?.editorService.get("nodes"));
6631
6652
  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
6653
  return (_ctx, _cache) => {
6729
- return openBlock(), createElementBlock("div", {
6730
- class: "m-editor-workspace",
6731
- tabindex: "-1",
6732
- ref_key: "workspace",
6733
- ref: workspace
6734
- }, [
6654
+ return openBlock(), createElementBlock("div", _hoisted_1, [
6735
6655
  createVNode(_sfc_main$8),
6736
6656
  renderSlot(_ctx.$slots, "stage", {}, () => [
6737
6657
  page.value ? (openBlock(), createBlock(_sfc_main$2, {
@@ -6749,7 +6669,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
6749
6669
  ]),
6750
6670
  _: 3
6751
6671
  })
6752
- ], 512);
6672
+ ]);
6753
6673
  };
6754
6674
  }
6755
6675
  });
@@ -7473,6 +7393,177 @@ class Events extends BaseService {
7473
7393
  }
7474
7394
  const eventsService = new Events();
7475
7395
 
7396
+ class Keybinding extends BaseService {
7397
+ keycon = new KeyController();
7398
+ ctrlKey = /mac os x/.test(navigator.userAgent.toLowerCase()) ? "meta" : "ctrl";
7399
+ constructor() {
7400
+ super();
7401
+ this.keycon.keyup((e) => {
7402
+ this.emit("keyup", e.inputEvent);
7403
+ }).keyup("delete", (e) => {
7404
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7405
+ return;
7406
+ }
7407
+ e.inputEvent.preventDefault();
7408
+ this.removeNode();
7409
+ }).keyup("backspace", (e) => {
7410
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7411
+ return;
7412
+ }
7413
+ e.inputEvent.preventDefault();
7414
+ this.removeNode();
7415
+ }).keydown([this.ctrlKey, "c"], (e) => {
7416
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7417
+ return;
7418
+ }
7419
+ e.inputEvent.preventDefault();
7420
+ const nodes = editorService.get("nodes");
7421
+ nodes && editorService.copy(nodes);
7422
+ }).keydown([this.ctrlKey, "v"], (e) => {
7423
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7424
+ return;
7425
+ }
7426
+ e.inputEvent.preventDefault();
7427
+ const nodes = editorService.get("nodes");
7428
+ nodes && editorService.paste({ offsetX: 10, offsetY: 10 });
7429
+ }).keydown([this.ctrlKey, "x"], (e) => {
7430
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7431
+ return;
7432
+ }
7433
+ e.inputEvent.preventDefault();
7434
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7435
+ return;
7436
+ }
7437
+ const nodes = editorService.get("nodes");
7438
+ if (!nodes || isPage(nodes[0]))
7439
+ return;
7440
+ editorService.copy(nodes);
7441
+ editorService.remove(nodes);
7442
+ }).keydown([this.ctrlKey, "z"], (e) => {
7443
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7444
+ return;
7445
+ }
7446
+ e.inputEvent.preventDefault();
7447
+ editorService.undo();
7448
+ }).keydown([this.ctrlKey, "shift", "z"], (e) => {
7449
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7450
+ return;
7451
+ }
7452
+ e.inputEvent.preventDefault();
7453
+ editorService.redo();
7454
+ }).keydown("up", (e) => {
7455
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7456
+ return;
7457
+ }
7458
+ e.inputEvent.preventDefault();
7459
+ editorService.move(0, -1);
7460
+ }).keydown("down", (e) => {
7461
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7462
+ return;
7463
+ }
7464
+ e.inputEvent.preventDefault();
7465
+ editorService.move(0, 1);
7466
+ }).keydown("left", (e) => {
7467
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7468
+ return;
7469
+ }
7470
+ e.inputEvent.preventDefault();
7471
+ editorService.move(-1, 0);
7472
+ }).keydown("right", (e) => {
7473
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7474
+ return;
7475
+ }
7476
+ e.inputEvent.preventDefault();
7477
+ editorService.move(1, 0);
7478
+ }).keydown([this.ctrlKey, "up"], (e) => {
7479
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7480
+ return;
7481
+ }
7482
+ e.inputEvent.preventDefault();
7483
+ editorService.move(0, -10);
7484
+ }).keydown([this.ctrlKey, "down"], (e) => {
7485
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7486
+ return;
7487
+ }
7488
+ e.inputEvent.preventDefault();
7489
+ editorService.move(0, 10);
7490
+ }).keydown([this.ctrlKey, "left"], (e) => {
7491
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7492
+ return;
7493
+ }
7494
+ e.inputEvent.preventDefault();
7495
+ editorService.move(-10, 0);
7496
+ }).keydown([this.ctrlKey, "right"], (e) => {
7497
+ e.inputEvent.preventDefault();
7498
+ editorService.move(10, 0);
7499
+ }).keydown("tab", (e) => {
7500
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7501
+ return;
7502
+ }
7503
+ e.inputEvent.preventDefault();
7504
+ editorService.selectNextNode();
7505
+ }).keydown([this.ctrlKey, "tab"], (e) => {
7506
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7507
+ return;
7508
+ }
7509
+ e.inputEvent.preventDefault();
7510
+ editorService.selectNextPage();
7511
+ }).keydown([this.ctrlKey, "="], (e) => {
7512
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7513
+ return;
7514
+ }
7515
+ e.inputEvent.preventDefault();
7516
+ uiService.zoom(0.1);
7517
+ }).keydown([this.ctrlKey, "numpadplus"], (e) => {
7518
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7519
+ return;
7520
+ }
7521
+ e.inputEvent.preventDefault();
7522
+ uiService.zoom(0.1);
7523
+ }).keydown([this.ctrlKey, "-"], (e) => {
7524
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7525
+ return;
7526
+ }
7527
+ e.inputEvent.preventDefault();
7528
+ uiService.zoom(-0.1);
7529
+ }).keydown([this.ctrlKey, "numpad-"], (e) => {
7530
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7531
+ return;
7532
+ }
7533
+ e.inputEvent.preventDefault();
7534
+ uiService.zoom(-0.1);
7535
+ }).keydown([this.ctrlKey, "0"], async (e) => {
7536
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7537
+ return;
7538
+ }
7539
+ e.inputEvent.preventDefault();
7540
+ uiService.set("zoom", await uiService.calcZoom());
7541
+ }).keydown([this.ctrlKey, "1"], (e) => {
7542
+ if (this.isDisabledKeyEvent(e.inputEvent.target)) {
7543
+ return;
7544
+ }
7545
+ e.inputEvent.preventDefault();
7546
+ uiService.set("zoom", 1);
7547
+ });
7548
+ }
7549
+ destroy() {
7550
+ this.keycon.destroy();
7551
+ }
7552
+ isDisabledKeyEvent(node) {
7553
+ const el = node;
7554
+ if (!el)
7555
+ return false;
7556
+ return el.tagName === "INPUT" || el.tagName === "TEXTAREA" || el.isContentEditable;
7557
+ }
7558
+ removeNode() {
7559
+ const nodes = editorService.get("nodes");
7560
+ if (!nodes || isPage(nodes[0]))
7561
+ return;
7562
+ editorService.remove(nodes);
7563
+ }
7564
+ }
7565
+ const keybindingService = new Keybinding();
7566
+
7476
7567
  const editorProps = {
7477
7568
  /** 页面初始值 */
7478
7569
  modelValue: {
@@ -7860,7 +7951,8 @@ const _sfc_main = defineComponent({
7860
7951
  storageService,
7861
7952
  codeBlockService,
7862
7953
  depService,
7863
- dataSourceService
7954
+ dataSourceService,
7955
+ keybindingService
7864
7956
  };
7865
7957
  initServiceEvents(props, emit, services);
7866
7958
  initServiceState(props, services);
@@ -8021,5 +8113,5 @@ const index = {
8021
8113
  }
8022
8114
  };
8023
8115
 
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 };
8116
+ 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$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
8117
  //# sourceMappingURL=tmagic-editor.js.map