@tmagic/editor 1.2.0-beta.13 → 1.2.0-beta.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/style.css CHANGED
@@ -655,9 +655,7 @@
655
655
  align-items: center;
656
656
  }
657
657
  .m-editor-code-block-list .list-container .list-item .right-tool {
658
- position: absolute;
659
- right: 15px;
660
- padding-left: 5px;
658
+ width: fit-content !important;
661
659
  display: flex;
662
660
  align-items: center;
663
661
  }
@@ -670,7 +668,8 @@
670
668
  white-space: nowrap;
671
669
  text-overflow: ellipsis;
672
670
  padding: 10px 15px;
673
- margin-right: 60px;
671
+ width: 0 !important;
672
+ flex: 1;
674
673
  }
675
674
  .m-editor-code-block-list .list-container .code-comp-map-wrapper {
676
675
  display: flex;
@@ -694,6 +693,9 @@
694
693
  .m-fields-code-select {
695
694
  width: 100%;
696
695
  }
696
+ .el-dialog.is-fullscreen.code-editor-dialog {
697
+ overflow: hidden;
698
+ }
697
699
  .code-editor-dialog .el-dialog__body {
698
700
  height: 90%;
699
701
  padding-top: 10px;
@@ -758,7 +760,7 @@
758
760
  position: absolute;
759
761
  top: 0;
760
762
  left: 4px;
761
- width: 100%;
763
+ width: calc(100% - 9px);
762
764
  height: 100%;
763
765
  z-index: 10;
764
766
  background: #fff;
@@ -769,8 +771,16 @@
769
771
  .code-editor-dialog .m-editor-wrapper {
770
772
  height: 100%;
771
773
  }
774
+ .code-editor-dialog .m-editor-wrapper.fullScreen {
775
+ height: 100%;
776
+ width: 100%;
777
+ position: fixed;
778
+ top: 0;
779
+ left: 0;
780
+ z-index: 100;
781
+ }
772
782
  .code-editor-dialog .m-editor-wrapper .m-editor-container {
773
- height: calc(100% - 65px);
783
+ height: calc(100% - 45px);
774
784
  }
775
785
  .code-editor-dialog .m-editor-wrapper .m-editor-content-bottom {
776
786
  height: 45px;
@@ -784,7 +794,7 @@
784
794
  }
785
795
  .code-editor-dialog .m-editor-wrapper .m-editor-content-bottom > button {
786
796
  height: 30px;
787
- margin-top: 15px;
797
+ margin-top: 5px;
788
798
  }
789
799
  .m-editor-layout {
790
800
  width: 100%;
@@ -2,7 +2,7 @@ import { defineComponent, computed, resolveComponent, openBlock, createBlock, no
2
2
  import serialize from 'serialize-javascript';
3
3
  import { isEmpty, map, throttle, pick, omit, keys, cloneDeep, forIn, mergeWith, uniq, isObject } from 'lodash-es';
4
4
  import { HookType, NodeType } from '@tmagic/schema';
5
- import { Delete, Close, Edit, Plus, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, View, Link, Search, Files, DocumentCopy, Coin, EditPen, ArrowLeftBold, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons-vue';
5
+ import { Delete, Close, Edit, Plus, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, View, Link, Search, Files, CopyDocument, Coin, EditPen, ArrowLeftBold, ArrowRightBold, CaretBottom, DocumentCopy, Top, Bottom } from '@element-plus/icons-vue';
6
6
  import { TMagicButton, TMagicTooltip, TMagicIcon, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, tMagicMessage, tMagicMessageBox, TMagicCard, TMagicInput, TMagicDialog, TMagicTree, TMagicCollapse, TMagicCollapseItem, getConfig as getConfig$1, TMagicTabs, TMagicPopover } from '@tmagic/design';
7
7
  import * as monaco from 'monaco-editor';
8
8
  import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS, ContainerHighlightType } from '@tmagic/stage';
@@ -513,8 +513,9 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
513
513
  props: {
514
514
  left: null,
515
515
  right: null,
516
- minLeft: { default: 1 },
516
+ minLeft: { default: 46 },
517
517
  minRight: { default: 1 },
518
+ minCenter: { default: 1 },
518
519
  leftClass: null,
519
520
  rightClass: null,
520
521
  centerClass: null
@@ -523,15 +524,42 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
523
524
  setup(__props, { emit }) {
524
525
  const props = __props;
525
526
  const el = ref();
527
+ const hasLeft = computed(() => typeof props.left !== "undefined");
528
+ const hasRight = computed(() => typeof props.left !== "undefined");
529
+ const getCenterWidth = (clientWidth2, left, right) => {
530
+ let center2 = clientWidth2 - left - right;
531
+ if (center2 < props.minCenter) {
532
+ center2 = props.minCenter;
533
+ if (left < right) {
534
+ right = clientWidth2 - left - props.minCenter;
535
+ } else {
536
+ left = clientWidth2 - right - props.minCenter;
537
+ }
538
+ }
539
+ return {
540
+ center: center2,
541
+ left,
542
+ right
543
+ };
544
+ };
526
545
  let clientWidth = 0;
527
546
  const resizerObserver = new ResizeObserver((entries) => {
528
547
  for (const { contentRect } of entries) {
529
548
  clientWidth = contentRect.width;
530
- center.value = clientWidth - (props.left || 0) - (props.right || 0);
549
+ let left = props.left || 0;
550
+ let right = props.right || 0;
551
+ if (left > clientWidth) {
552
+ left = clientWidth / 3;
553
+ }
554
+ if (right > clientWidth) {
555
+ right = clientWidth / 3;
556
+ }
557
+ const columnWidth = getCenterWidth(clientWidth, left, right);
558
+ center.value = columnWidth.center;
531
559
  emit("change", {
532
- left: props.left,
560
+ left: columnWidth.left,
533
561
  center: center.value,
534
- right: props.right
562
+ right: columnWidth.right
535
563
  });
536
564
  }
537
565
  });
@@ -552,11 +580,12 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
552
580
  if (clientWidth - left - (props.right || 0) <= 0) {
553
581
  left = props.left;
554
582
  }
555
- center.value = clientWidth - left - (props.right || 0);
583
+ const columnWidth = getCenterWidth(clientWidth, left, props.right || 0);
584
+ center.value = columnWidth.center;
556
585
  emit("change", {
557
- left,
586
+ left: columnWidth.left,
558
587
  center: center.value,
559
- right: props.right
588
+ right: columnWidth.right
560
589
  });
561
590
  };
562
591
  const changeRight = (deltaX) => {
@@ -567,11 +596,12 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
567
596
  if (clientWidth - (props.left || 0) - right <= 0) {
568
597
  right = props.right;
569
598
  }
570
- center.value = clientWidth - (props.left || 0) - right;
599
+ const columnWidth = getCenterWidth(clientWidth, props.left || 0, right);
600
+ center.value = columnWidth.center;
571
601
  emit("change", {
572
- left: props.left,
602
+ left: columnWidth.left,
573
603
  center: center.value,
574
- right
604
+ right: columnWidth.right
575
605
  });
576
606
  };
577
607
  return (_ctx, _cache) => {
@@ -580,7 +610,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
580
610
  ref: el,
581
611
  class: "m-editor-layout"
582
612
  }, [
583
- typeof props.left !== "undefined" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
613
+ unref(hasLeft) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
584
614
  createElementVNode("div", {
585
615
  class: normalizeClass(["m-editor-layout-left", __props.leftClass]),
586
616
  style: normalizeStyle(`width: ${__props.left}px`)
@@ -595,7 +625,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
595
625
  }, [
596
626
  renderSlot(_ctx.$slots, "center")
597
627
  ], 6),
598
- typeof props.right !== "undefined" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
628
+ unref(hasRight) ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
599
629
  createVNode(_sfc_main$p, { onChange: changeRight }),
600
630
  createElementVNode("div", {
601
631
  class: normalizeClass(["m-editor-layout-right", __props.rightClass]),
@@ -880,11 +910,14 @@ class CodeBlock extends BaseService {
880
910
  }
881
911
  async setCodeDslById(id, codeConfig) {
882
912
  let codeDsl = await this.getCodeDsl();
913
+ const codeConfigProcessed = codeConfig;
914
+ if (codeConfig.content) {
915
+ codeConfigProcessed.content = eval(codeConfig.content);
916
+ }
883
917
  if (!codeDsl) {
884
918
  codeDsl = {
885
919
  [id]: {
886
- ...codeConfig,
887
- content: eval(codeConfig.content)
920
+ ...codeConfigProcessed
888
921
  }
889
922
  };
890
923
  } else {
@@ -893,8 +926,7 @@ class CodeBlock extends BaseService {
893
926
  ...codeDsl,
894
927
  [id]: {
895
928
  ...existContent,
896
- ...codeConfig,
897
- content: eval(codeConfig.content)
929
+ ...codeConfigProcessed
898
930
  }
899
931
  };
900
932
  }
@@ -3127,18 +3159,17 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
3127
3159
  }
3128
3160
  });
3129
3161
 
3130
- const _hoisted_1$9 = { class: "m-editor-wrapper" };
3131
- const _hoisted_2$5 = {
3162
+ const _hoisted_1$9 = {
3132
3163
  key: 0,
3133
3164
  class: "m-editor-content-bottom"
3134
3165
  };
3135
- const _hoisted_3$3 = /* @__PURE__ */ createTextVNode("\u4FDD\u5B58");
3136
- const _hoisted_4$2 = /* @__PURE__ */ createTextVNode("\u5173\u95ED");
3137
- const _hoisted_5$1 = {
3166
+ const _hoisted_2$5 = /* @__PURE__ */ createTextVNode("\u4FDD\u5B58");
3167
+ const _hoisted_3$3 = /* @__PURE__ */ createTextVNode("\u5173\u95ED");
3168
+ const _hoisted_4$2 = {
3138
3169
  key: 1,
3139
3170
  class: "m-editor-content-bottom"
3140
3171
  };
3141
- const _hoisted_6$1 = /* @__PURE__ */ createTextVNode("\u5173\u95ED");
3172
+ const _hoisted_5$1 = /* @__PURE__ */ createTextVNode("\u5173\u95ED");
3142
3173
  const __default__$g = defineComponent({
3143
3174
  name: "MEditorCodeDraftEditor"
3144
3175
  });
@@ -3160,6 +3191,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
3160
3191
  const editorContent = ref("");
3161
3192
  const codeEditor = ref();
3162
3193
  const originCodeContent = ref("");
3194
+ const isFullScreen = ref(false);
3163
3195
  const codeOptions = computed(() => ({
3164
3196
  ...props.codeOptions,
3165
3197
  readOnly: !props.editable
@@ -3213,8 +3245,16 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
3213
3245
  emit("close");
3214
3246
  }
3215
3247
  };
3248
+ const toggleFullScreen = () => {
3249
+ isFullScreen.value = !isFullScreen.value;
3250
+ if (codeEditor.value) {
3251
+ codeEditor.value.focus();
3252
+ }
3253
+ };
3216
3254
  return (_ctx, _cache) => {
3217
- return openBlock(), createElementBlock("div", _hoisted_1$9, [
3255
+ return openBlock(), createElementBlock("div", {
3256
+ class: normalizeClass(["m-editor-wrapper", isFullScreen.value ? "fullScreen" : "normal"])
3257
+ }, [
3218
3258
  createVNode(_sfc_main$q, {
3219
3259
  ref_key: "codeEditor",
3220
3260
  ref: codeEditor,
@@ -3224,14 +3264,24 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
3224
3264
  language: __props.language,
3225
3265
  options: unref(codeOptions)
3226
3266
  }, null, 8, ["init-values", "language", "options"]),
3227
- __props.editable ? (openBlock(), createElementBlock("div", _hoisted_2$5, [
3267
+ __props.editable ? (openBlock(), createElementBlock("div", _hoisted_1$9, [
3268
+ createVNode(unref(TMagicButton), {
3269
+ type: "primary",
3270
+ class: "button",
3271
+ onClick: toggleFullScreen
3272
+ }, {
3273
+ default: withCtx(() => [
3274
+ createTextVNode(toDisplayString(isFullScreen.value ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F"), 1)
3275
+ ]),
3276
+ _: 1
3277
+ }),
3228
3278
  createVNode(unref(TMagicButton), {
3229
3279
  type: "primary",
3230
3280
  class: "button",
3231
3281
  onClick: saveCode
3232
3282
  }, {
3233
3283
  default: withCtx(() => [
3234
- _hoisted_3$3
3284
+ _hoisted_2$5
3235
3285
  ]),
3236
3286
  _: 1
3237
3287
  }),
@@ -3241,23 +3291,33 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
3241
3291
  onClick: close
3242
3292
  }, {
3243
3293
  default: withCtx(() => [
3244
- _hoisted_4$2
3294
+ _hoisted_3$3
3245
3295
  ]),
3246
3296
  _: 1
3247
3297
  })
3248
- ])) : (openBlock(), createElementBlock("div", _hoisted_5$1, [
3298
+ ])) : (openBlock(), createElementBlock("div", _hoisted_4$2, [
3299
+ createVNode(unref(TMagicButton), {
3300
+ type: "primary",
3301
+ class: "button",
3302
+ onClick: toggleFullScreen
3303
+ }, {
3304
+ default: withCtx(() => [
3305
+ createTextVNode(toDisplayString(isFullScreen.value ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F"), 1)
3306
+ ]),
3307
+ _: 1
3308
+ }),
3249
3309
  createVNode(unref(TMagicButton), {
3250
3310
  type: "primary",
3251
3311
  class: "button",
3252
3312
  onClick: close
3253
3313
  }, {
3254
3314
  default: withCtx(() => [
3255
- _hoisted_6$1
3315
+ _hoisted_5$1
3256
3316
  ]),
3257
3317
  _: 1
3258
3318
  })
3259
3319
  ]))
3260
- ]);
3320
+ ], 2);
3261
3321
  };
3262
3322
  }
3263
3323
  });
@@ -3286,6 +3346,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
3286
3346
  border: true,
3287
3347
  enableFullscreen: false,
3288
3348
  name: "params",
3349
+ maxHeight: "150px",
3289
3350
  items: [
3290
3351
  {
3291
3352
  type: "text",
@@ -3593,7 +3654,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
3593
3654
  }
3594
3655
  const codeConfig = {
3595
3656
  name: "\u4EE3\u7801\u5757",
3596
- content: `() => {
3657
+ content: `({app, params}) => {
3597
3658
  // place your code here
3598
3659
  }`,
3599
3660
  params: []
@@ -4104,7 +4165,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
4104
4165
  {
4105
4166
  type: "button",
4106
4167
  text: "\u590D\u5236",
4107
- icon: markRaw(DocumentCopy),
4168
+ icon: markRaw(CopyDocument),
4108
4169
  display: () => !isRoot.value,
4109
4170
  handler: () => {
4110
4171
  node.value && services?.editorService.copy(node.value);
@@ -4408,6 +4469,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
4408
4469
  "default-expanded-keys": unref(defaultExpandedKeys),
4409
4470
  load: loadItems,
4410
4471
  data: unref(values),
4472
+ "default-expand-all": true,
4411
4473
  "expand-on-click-node": false,
4412
4474
  "highlight-current": true,
4413
4475
  props: {
@@ -5234,7 +5296,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
5234
5296
  {
5235
5297
  type: "button",
5236
5298
  text: "\u590D\u5236",
5237
- icon: markRaw(DocumentCopy),
5299
+ icon: markRaw(CopyDocument),
5238
5300
  handler: () => {
5239
5301
  nodes.value && editorService?.copy(nodes.value);
5240
5302
  canPaste.value = true;
@@ -5243,6 +5305,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
5243
5305
  {
5244
5306
  type: "button",
5245
5307
  text: "\u7C98\u8D34",
5308
+ icon: markRaw(DocumentCopy),
5246
5309
  display: () => canPaste.value,
5247
5310
  handler: () => {
5248
5311
  const rect = menu.value?.$el.getBoundingClientRect();