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

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]),
@@ -3145,18 +3175,17 @@
3145
3175
  }
3146
3176
  });
3147
3177
 
3148
- const _hoisted_1$9 = { class: "m-editor-wrapper" };
3149
- const _hoisted_2$5 = {
3178
+ const _hoisted_1$9 = {
3150
3179
  key: 0,
3151
3180
  class: "m-editor-content-bottom"
3152
3181
  };
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 = {
3182
+ const _hoisted_2$5 = /* @__PURE__ */ vue.createTextVNode("\u4FDD\u5B58");
3183
+ const _hoisted_3$3 = /* @__PURE__ */ vue.createTextVNode("\u5173\u95ED");
3184
+ const _hoisted_4$2 = {
3156
3185
  key: 1,
3157
3186
  class: "m-editor-content-bottom"
3158
3187
  };
3159
- const _hoisted_6$1 = /* @__PURE__ */ vue.createTextVNode("\u5173\u95ED");
3188
+ const _hoisted_5$1 = /* @__PURE__ */ vue.createTextVNode("\u5173\u95ED");
3160
3189
  const __default__$g = vue.defineComponent({
3161
3190
  name: "MEditorCodeDraftEditor"
3162
3191
  });
@@ -3178,6 +3207,7 @@
3178
3207
  const editorContent = vue.ref("");
3179
3208
  const codeEditor = vue.ref();
3180
3209
  const originCodeContent = vue.ref("");
3210
+ const isFullScreen = vue.ref(false);
3181
3211
  const codeOptions = vue.computed(() => ({
3182
3212
  ...props.codeOptions,
3183
3213
  readOnly: !props.editable
@@ -3231,8 +3261,16 @@
3231
3261
  emit("close");
3232
3262
  }
3233
3263
  };
3264
+ const toggleFullScreen = () => {
3265
+ isFullScreen.value = !isFullScreen.value;
3266
+ if (codeEditor.value) {
3267
+ codeEditor.value.focus();
3268
+ }
3269
+ };
3234
3270
  return (_ctx, _cache) => {
3235
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
3271
+ return vue.openBlock(), vue.createElementBlock("div", {
3272
+ class: vue.normalizeClass(["m-editor-wrapper", isFullScreen.value ? "fullScreen" : "normal"])
3273
+ }, [
3236
3274
  vue.createVNode(_sfc_main$q, {
3237
3275
  ref_key: "codeEditor",
3238
3276
  ref: codeEditor,
@@ -3242,14 +3280,24 @@
3242
3280
  language: __props.language,
3243
3281
  options: vue.unref(codeOptions)
3244
3282
  }, null, 8, ["init-values", "language", "options"]),
3245
- __props.editable ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$5, [
3283
+ __props.editable ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
3284
+ vue.createVNode(vue.unref(design.TMagicButton), {
3285
+ type: "primary",
3286
+ class: "button",
3287
+ onClick: toggleFullScreen
3288
+ }, {
3289
+ default: vue.withCtx(() => [
3290
+ vue.createTextVNode(vue.toDisplayString(isFullScreen.value ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F"), 1)
3291
+ ]),
3292
+ _: 1
3293
+ }),
3246
3294
  vue.createVNode(vue.unref(design.TMagicButton), {
3247
3295
  type: "primary",
3248
3296
  class: "button",
3249
3297
  onClick: saveCode
3250
3298
  }, {
3251
3299
  default: vue.withCtx(() => [
3252
- _hoisted_3$3
3300
+ _hoisted_2$5
3253
3301
  ]),
3254
3302
  _: 1
3255
3303
  }),
@@ -3259,23 +3307,33 @@
3259
3307
  onClick: close
3260
3308
  }, {
3261
3309
  default: vue.withCtx(() => [
3262
- _hoisted_4$2
3310
+ _hoisted_3$3
3263
3311
  ]),
3264
3312
  _: 1
3265
3313
  })
3266
- ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_5$1, [
3314
+ ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_4$2, [
3315
+ vue.createVNode(vue.unref(design.TMagicButton), {
3316
+ type: "primary",
3317
+ class: "button",
3318
+ onClick: toggleFullScreen
3319
+ }, {
3320
+ default: vue.withCtx(() => [
3321
+ vue.createTextVNode(vue.toDisplayString(isFullScreen.value ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F"), 1)
3322
+ ]),
3323
+ _: 1
3324
+ }),
3267
3325
  vue.createVNode(vue.unref(design.TMagicButton), {
3268
3326
  type: "primary",
3269
3327
  class: "button",
3270
3328
  onClick: close
3271
3329
  }, {
3272
3330
  default: vue.withCtx(() => [
3273
- _hoisted_6$1
3331
+ _hoisted_5$1
3274
3332
  ]),
3275
3333
  _: 1
3276
3334
  })
3277
3335
  ]))
3278
- ]);
3336
+ ], 2);
3279
3337
  };
3280
3338
  }
3281
3339
  });
@@ -3304,6 +3362,7 @@
3304
3362
  border: true,
3305
3363
  enableFullscreen: false,
3306
3364
  name: "params",
3365
+ maxHeight: "150px",
3307
3366
  items: [
3308
3367
  {
3309
3368
  type: "text",
@@ -4122,7 +4181,7 @@
4122
4181
  {
4123
4182
  type: "button",
4124
4183
  text: "\u590D\u5236",
4125
- icon: vue.markRaw(iconsVue.DocumentCopy),
4184
+ icon: vue.markRaw(iconsVue.CopyDocument),
4126
4185
  display: () => !isRoot.value,
4127
4186
  handler: () => {
4128
4187
  node.value && services?.editorService.copy(node.value);
@@ -5252,7 +5311,7 @@
5252
5311
  {
5253
5312
  type: "button",
5254
5313
  text: "\u590D\u5236",
5255
- icon: vue.markRaw(iconsVue.DocumentCopy),
5314
+ icon: vue.markRaw(iconsVue.CopyDocument),
5256
5315
  handler: () => {
5257
5316
  nodes.value && editorService?.copy(nodes.value);
5258
5317
  canPaste.value = true;
@@ -5261,6 +5320,7 @@
5261
5320
  {
5262
5321
  type: "button",
5263
5322
  text: "\u7C98\u8D34",
5323
+ icon: vue.markRaw(iconsVue.DocumentCopy),
5264
5324
  display: () => canPaste.value,
5265
5325
  handler: () => {
5266
5326
  const rect = menu.value?.$el.getBoundingClientRect();