@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.
@@ -531,8 +531,9 @@
531
531
  props: {
532
532
  left: null,
533
533
  right: null,
534
- minLeft: { default: 1 },
534
+ minLeft: { default: 46 },
535
535
  minRight: { default: 1 },
536
+ minCenter: { default: 1 },
536
537
  leftClass: null,
537
538
  rightClass: null,
538
539
  centerClass: null
@@ -541,15 +542,42 @@
541
542
  setup(__props, { emit }) {
542
543
  const props = __props;
543
544
  const el = vue.ref();
545
+ const hasLeft = vue.computed(() => typeof props.left !== "undefined");
546
+ const hasRight = vue.computed(() => typeof props.left !== "undefined");
547
+ const getCenterWidth = (clientWidth2, left, right) => {
548
+ let center2 = clientWidth2 - left - right;
549
+ if (center2 < props.minCenter) {
550
+ center2 = props.minCenter;
551
+ if (left < right) {
552
+ right = clientWidth2 - left - props.minCenter;
553
+ } else {
554
+ left = clientWidth2 - right - props.minCenter;
555
+ }
556
+ }
557
+ return {
558
+ center: center2,
559
+ left,
560
+ right
561
+ };
562
+ };
544
563
  let clientWidth = 0;
545
564
  const resizerObserver = new ResizeObserver((entries) => {
546
565
  for (const { contentRect } of entries) {
547
566
  clientWidth = contentRect.width;
548
- center.value = clientWidth - (props.left || 0) - (props.right || 0);
567
+ let left = props.left || 0;
568
+ let right = props.right || 0;
569
+ if (left > clientWidth) {
570
+ left = clientWidth / 3;
571
+ }
572
+ if (right > clientWidth) {
573
+ right = clientWidth / 3;
574
+ }
575
+ const columnWidth = getCenterWidth(clientWidth, left, right);
576
+ center.value = columnWidth.center;
549
577
  emit("change", {
550
- left: props.left,
578
+ left: columnWidth.left,
551
579
  center: center.value,
552
- right: props.right
580
+ right: columnWidth.right
553
581
  });
554
582
  }
555
583
  });
@@ -570,11 +598,12 @@
570
598
  if (clientWidth - left - (props.right || 0) <= 0) {
571
599
  left = props.left;
572
600
  }
573
- center.value = clientWidth - left - (props.right || 0);
601
+ const columnWidth = getCenterWidth(clientWidth, left, props.right || 0);
602
+ center.value = columnWidth.center;
574
603
  emit("change", {
575
- left,
604
+ left: columnWidth.left,
576
605
  center: center.value,
577
- right: props.right
606
+ right: columnWidth.right
578
607
  });
579
608
  };
580
609
  const changeRight = (deltaX) => {
@@ -585,11 +614,12 @@
585
614
  if (clientWidth - (props.left || 0) - right <= 0) {
586
615
  right = props.right;
587
616
  }
588
- center.value = clientWidth - (props.left || 0) - right;
617
+ const columnWidth = getCenterWidth(clientWidth, props.left || 0, right);
618
+ center.value = columnWidth.center;
589
619
  emit("change", {
590
- left: props.left,
620
+ left: columnWidth.left,
591
621
  center: center.value,
592
- right
622
+ right: columnWidth.right
593
623
  });
594
624
  };
595
625
  return (_ctx, _cache) => {
@@ -598,7 +628,7 @@
598
628
  ref: el,
599
629
  class: "m-editor-layout"
600
630
  }, [
601
- typeof props.left !== "undefined" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
631
+ vue.unref(hasLeft) ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
602
632
  vue.createElementVNode("div", {
603
633
  class: vue.normalizeClass(["m-editor-layout-left", __props.leftClass]),
604
634
  style: vue.normalizeStyle(`width: ${__props.left}px`)
@@ -613,7 +643,7 @@
613
643
  }, [
614
644
  vue.renderSlot(_ctx.$slots, "center")
615
645
  ], 6),
616
- typeof props.right !== "undefined" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
646
+ vue.unref(hasRight) ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
617
647
  vue.createVNode(_sfc_main$p, { onChange: changeRight }),
618
648
  vue.createElementVNode("div", {
619
649
  class: vue.normalizeClass(["m-editor-layout-right", __props.rightClass]),
@@ -898,11 +928,14 @@
898
928
  }
899
929
  async setCodeDslById(id, codeConfig) {
900
930
  let codeDsl = await this.getCodeDsl();
931
+ const codeConfigProcessed = codeConfig;
932
+ if (codeConfig.content) {
933
+ codeConfigProcessed.content = eval(codeConfig.content);
934
+ }
901
935
  if (!codeDsl) {
902
936
  codeDsl = {
903
937
  [id]: {
904
- ...codeConfig,
905
- content: eval(codeConfig.content)
938
+ ...codeConfigProcessed
906
939
  }
907
940
  };
908
941
  } else {
@@ -911,8 +944,7 @@
911
944
  ...codeDsl,
912
945
  [id]: {
913
946
  ...existContent,
914
- ...codeConfig,
915
- content: eval(codeConfig.content)
947
+ ...codeConfigProcessed
916
948
  }
917
949
  };
918
950
  }
@@ -3145,18 +3177,17 @@
3145
3177
  }
3146
3178
  });
3147
3179
 
3148
- const _hoisted_1$9 = { class: "m-editor-wrapper" };
3149
- const _hoisted_2$5 = {
3180
+ const _hoisted_1$9 = {
3150
3181
  key: 0,
3151
3182
  class: "m-editor-content-bottom"
3152
3183
  };
3153
- const _hoisted_3$3 = /* @__PURE__ */ vue.createTextVNode("\u4FDD\u5B58");
3154
- const _hoisted_4$2 = /* @__PURE__ */ vue.createTextVNode("\u5173\u95ED");
3155
- const _hoisted_5$1 = {
3184
+ const _hoisted_2$5 = /* @__PURE__ */ vue.createTextVNode("\u4FDD\u5B58");
3185
+ const _hoisted_3$3 = /* @__PURE__ */ vue.createTextVNode("\u5173\u95ED");
3186
+ const _hoisted_4$2 = {
3156
3187
  key: 1,
3157
3188
  class: "m-editor-content-bottom"
3158
3189
  };
3159
- const _hoisted_6$1 = /* @__PURE__ */ vue.createTextVNode("\u5173\u95ED");
3190
+ const _hoisted_5$1 = /* @__PURE__ */ vue.createTextVNode("\u5173\u95ED");
3160
3191
  const __default__$g = vue.defineComponent({
3161
3192
  name: "MEditorCodeDraftEditor"
3162
3193
  });
@@ -3178,6 +3209,7 @@
3178
3209
  const editorContent = vue.ref("");
3179
3210
  const codeEditor = vue.ref();
3180
3211
  const originCodeContent = vue.ref("");
3212
+ const isFullScreen = vue.ref(false);
3181
3213
  const codeOptions = vue.computed(() => ({
3182
3214
  ...props.codeOptions,
3183
3215
  readOnly: !props.editable
@@ -3231,8 +3263,16 @@
3231
3263
  emit("close");
3232
3264
  }
3233
3265
  };
3266
+ const toggleFullScreen = () => {
3267
+ isFullScreen.value = !isFullScreen.value;
3268
+ if (codeEditor.value) {
3269
+ codeEditor.value.focus();
3270
+ }
3271
+ };
3234
3272
  return (_ctx, _cache) => {
3235
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
3273
+ return vue.openBlock(), vue.createElementBlock("div", {
3274
+ class: vue.normalizeClass(["m-editor-wrapper", isFullScreen.value ? "fullScreen" : "normal"])
3275
+ }, [
3236
3276
  vue.createVNode(_sfc_main$q, {
3237
3277
  ref_key: "codeEditor",
3238
3278
  ref: codeEditor,
@@ -3242,14 +3282,24 @@
3242
3282
  language: __props.language,
3243
3283
  options: vue.unref(codeOptions)
3244
3284
  }, null, 8, ["init-values", "language", "options"]),
3245
- __props.editable ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$5, [
3285
+ __props.editable ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
3286
+ vue.createVNode(vue.unref(design.TMagicButton), {
3287
+ type: "primary",
3288
+ class: "button",
3289
+ onClick: toggleFullScreen
3290
+ }, {
3291
+ default: vue.withCtx(() => [
3292
+ vue.createTextVNode(vue.toDisplayString(isFullScreen.value ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F"), 1)
3293
+ ]),
3294
+ _: 1
3295
+ }),
3246
3296
  vue.createVNode(vue.unref(design.TMagicButton), {
3247
3297
  type: "primary",
3248
3298
  class: "button",
3249
3299
  onClick: saveCode
3250
3300
  }, {
3251
3301
  default: vue.withCtx(() => [
3252
- _hoisted_3$3
3302
+ _hoisted_2$5
3253
3303
  ]),
3254
3304
  _: 1
3255
3305
  }),
@@ -3259,23 +3309,33 @@
3259
3309
  onClick: close
3260
3310
  }, {
3261
3311
  default: vue.withCtx(() => [
3262
- _hoisted_4$2
3312
+ _hoisted_3$3
3263
3313
  ]),
3264
3314
  _: 1
3265
3315
  })
3266
- ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_5$1, [
3316
+ ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_4$2, [
3317
+ vue.createVNode(vue.unref(design.TMagicButton), {
3318
+ type: "primary",
3319
+ class: "button",
3320
+ onClick: toggleFullScreen
3321
+ }, {
3322
+ default: vue.withCtx(() => [
3323
+ vue.createTextVNode(vue.toDisplayString(isFullScreen.value ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F"), 1)
3324
+ ]),
3325
+ _: 1
3326
+ }),
3267
3327
  vue.createVNode(vue.unref(design.TMagicButton), {
3268
3328
  type: "primary",
3269
3329
  class: "button",
3270
3330
  onClick: close
3271
3331
  }, {
3272
3332
  default: vue.withCtx(() => [
3273
- _hoisted_6$1
3333
+ _hoisted_5$1
3274
3334
  ]),
3275
3335
  _: 1
3276
3336
  })
3277
3337
  ]))
3278
- ]);
3338
+ ], 2);
3279
3339
  };
3280
3340
  }
3281
3341
  });
@@ -3304,6 +3364,7 @@
3304
3364
  border: true,
3305
3365
  enableFullscreen: false,
3306
3366
  name: "params",
3367
+ maxHeight: "150px",
3307
3368
  items: [
3308
3369
  {
3309
3370
  type: "text",
@@ -3611,7 +3672,7 @@
3611
3672
  }
3612
3673
  const codeConfig = {
3613
3674
  name: "\u4EE3\u7801\u5757",
3614
- content: `() => {
3675
+ content: `({app, params}) => {
3615
3676
  // place your code here
3616
3677
  }`,
3617
3678
  params: []
@@ -4122,7 +4183,7 @@
4122
4183
  {
4123
4184
  type: "button",
4124
4185
  text: "\u590D\u5236",
4125
- icon: vue.markRaw(iconsVue.DocumentCopy),
4186
+ icon: vue.markRaw(iconsVue.CopyDocument),
4126
4187
  display: () => !isRoot.value,
4127
4188
  handler: () => {
4128
4189
  node.value && services?.editorService.copy(node.value);
@@ -4426,6 +4487,7 @@
4426
4487
  "default-expanded-keys": vue.unref(defaultExpandedKeys),
4427
4488
  load: loadItems,
4428
4489
  data: vue.unref(values),
4490
+ "default-expand-all": true,
4429
4491
  "expand-on-click-node": false,
4430
4492
  "highlight-current": true,
4431
4493
  props: {
@@ -5252,7 +5314,7 @@
5252
5314
  {
5253
5315
  type: "button",
5254
5316
  text: "\u590D\u5236",
5255
- icon: vue.markRaw(iconsVue.DocumentCopy),
5317
+ icon: vue.markRaw(iconsVue.CopyDocument),
5256
5318
  handler: () => {
5257
5319
  nodes.value && editorService?.copy(nodes.value);
5258
5320
  canPaste.value = true;
@@ -5261,6 +5323,7 @@
5261
5323
  {
5262
5324
  type: "button",
5263
5325
  text: "\u7C98\u8D34",
5326
+ icon: vue.markRaw(iconsVue.DocumentCopy),
5264
5327
  display: () => canPaste.value,
5265
5328
  handler: () => {
5266
5329
  const rect = menu.value?.$el.getBoundingClientRect();