@tmagic/editor 1.2.0-beta.3 → 1.2.0-beta.5

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.
@@ -2550,8 +2550,11 @@
2550
2550
  const changeLeft = (deltaX) => {
2551
2551
  if (typeof props.left === "undefined")
2552
2552
  return;
2553
- const left = Math.max(props.left + deltaX, props.minLeft) || 0;
2553
+ let left = Math.max(props.left + deltaX, props.minLeft) || 0;
2554
2554
  emit("update:left", left);
2555
+ if (clientWidth - left - (props.right || 0) <= 0) {
2556
+ left = props.left;
2557
+ }
2555
2558
  center.value = clientWidth - left - (props.right || 0);
2556
2559
  emit("change", {
2557
2560
  left,
@@ -2562,8 +2565,11 @@
2562
2565
  const changeRight = (deltaX) => {
2563
2566
  if (typeof props.right === "undefined")
2564
2567
  return;
2565
- const right = Math.max(props.right - deltaX, props.minRight) || 0;
2568
+ let right = Math.max(props.right - deltaX, props.minRight) || 0;
2566
2569
  emit("update:right", right);
2570
+ if (clientWidth - (props.left || 0) - right <= 0) {
2571
+ right = props.right;
2572
+ }
2567
2573
  center.value = clientWidth - (props.left || 0) - right;
2568
2574
  emit("change", {
2569
2575
  left: props.left,
@@ -2619,41 +2625,57 @@
2619
2625
  const root = vue.computed(() => editorService?.get("root"));
2620
2626
  const pageLength = vue.computed(() => editorService?.get("pageLength") || 0);
2621
2627
  const showSrc = vue.computed(() => uiService?.get("showSrc"));
2628
+ const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
2629
+ const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
2630
+ const leftColumnWidthCacheData = Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY));
2631
+ const RightColumnWidthCacheData = Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY));
2622
2632
  const columnWidth = vue.ref({
2623
- left: DEFAULT_LEFT_COLUMN_WIDTH,
2633
+ left: leftColumnWidthCacheData,
2624
2634
  center: 0,
2625
- right: 0
2635
+ right: RightColumnWidthCacheData
2626
2636
  });
2627
- uiService?.set("columnWidth", columnWidth.value);
2628
- vue.watchEffect(() => {
2629
- if (pageLength.value <= 0) {
2630
- columnWidth.value.right = void 0;
2631
- columnWidth.value.center = globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH;
2632
- } else {
2633
- columnWidth.value.right = columnWidth.value.right || DEFAULT_RIGHT_COLUMN_WIDTH;
2634
- columnWidth.value.center = globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH;
2637
+ vue.watch(
2638
+ pageLength,
2639
+ (length) => {
2640
+ const left = columnWidth.value.left || DEFAULT_LEFT_COLUMN_WIDTH;
2641
+ columnWidth.value.left = left;
2642
+ if (length <= 0) {
2643
+ columnWidth.value.right = void 0;
2644
+ columnWidth.value.center = globalThis.document.body.clientWidth - left;
2645
+ } else {
2646
+ const right = columnWidth.value.right || RightColumnWidthCacheData || DEFAULT_RIGHT_COLUMN_WIDTH;
2647
+ columnWidth.value.right = right;
2648
+ columnWidth.value.center = globalThis.document.body.clientWidth - left - right;
2649
+ }
2650
+ uiService?.set("columnWidth", columnWidth);
2651
+ },
2652
+ {
2653
+ immediate: true
2635
2654
  }
2636
- });
2637
- const saveCode = (value) => {
2638
- try {
2639
- editorService?.set("root", eval(value));
2640
- } catch (e) {
2641
- console.error(e);
2655
+ );
2656
+ vue.watch(
2657
+ () => columnWidth.value.right,
2658
+ (right) => {
2659
+ if (typeof right === "undefined")
2660
+ return;
2661
+ globalThis.localStorage.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, `${right}`);
2642
2662
  }
2663
+ );
2664
+ vue.watch(
2665
+ () => columnWidth.value.left,
2666
+ (left) => {
2667
+ globalThis.localStorage.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, `${left}`);
2668
+ }
2669
+ );
2670
+ const columnWidthChange = (columnWidth2) => {
2671
+ uiService?.set("columnWidth", columnWidth2);
2643
2672
  };
2644
- const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
2645
- const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
2646
- if (columnWidthCacheData) {
2673
+ const saveCode = (value) => {
2647
2674
  try {
2648
- const columnWidthCache = JSON.parse(columnWidthCacheData);
2649
- columnWidth.value = columnWidthCache;
2675
+ editorService?.set("root", eval(value));
2650
2676
  } catch (e) {
2651
2677
  console.error(e);
2652
2678
  }
2653
- }
2654
- const columnWidthChange = (columnWidth2) => {
2655
- uiService?.set("columnWidth", columnWidth2);
2656
- globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth2));
2657
2679
  };
2658
2680
  return (_ctx, _cache) => {
2659
2681
  const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");