@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.
- package/dist/tmagic-editor.mjs +49 -27
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +49 -27
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +9 -9
- package/src/layouts/Framework.vue +55 -35
- package/src/layouts/Layout.vue +12 -2
package/dist/tmagic-editor.mjs
CHANGED
|
@@ -2532,8 +2532,11 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
2532
2532
|
const changeLeft = (deltaX) => {
|
|
2533
2533
|
if (typeof props.left === "undefined")
|
|
2534
2534
|
return;
|
|
2535
|
-
|
|
2535
|
+
let left = Math.max(props.left + deltaX, props.minLeft) || 0;
|
|
2536
2536
|
emit("update:left", left);
|
|
2537
|
+
if (clientWidth - left - (props.right || 0) <= 0) {
|
|
2538
|
+
left = props.left;
|
|
2539
|
+
}
|
|
2537
2540
|
center.value = clientWidth - left - (props.right || 0);
|
|
2538
2541
|
emit("change", {
|
|
2539
2542
|
left,
|
|
@@ -2544,8 +2547,11 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
2544
2547
|
const changeRight = (deltaX) => {
|
|
2545
2548
|
if (typeof props.right === "undefined")
|
|
2546
2549
|
return;
|
|
2547
|
-
|
|
2550
|
+
let right = Math.max(props.right - deltaX, props.minRight) || 0;
|
|
2548
2551
|
emit("update:right", right);
|
|
2552
|
+
if (clientWidth - (props.left || 0) - right <= 0) {
|
|
2553
|
+
right = props.right;
|
|
2554
|
+
}
|
|
2549
2555
|
center.value = clientWidth - (props.left || 0) - right;
|
|
2550
2556
|
emit("change", {
|
|
2551
2557
|
left: props.left,
|
|
@@ -2601,41 +2607,57 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
2601
2607
|
const root = computed(() => editorService?.get("root"));
|
|
2602
2608
|
const pageLength = computed(() => editorService?.get("pageLength") || 0);
|
|
2603
2609
|
const showSrc = computed(() => uiService?.get("showSrc"));
|
|
2610
|
+
const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
|
|
2611
|
+
const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
|
|
2612
|
+
const leftColumnWidthCacheData = Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY));
|
|
2613
|
+
const RightColumnWidthCacheData = Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY));
|
|
2604
2614
|
const columnWidth = ref({
|
|
2605
|
-
left:
|
|
2615
|
+
left: leftColumnWidthCacheData,
|
|
2606
2616
|
center: 0,
|
|
2607
|
-
right:
|
|
2617
|
+
right: RightColumnWidthCacheData
|
|
2608
2618
|
});
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
columnWidth.value.
|
|
2613
|
-
columnWidth.value.
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2619
|
+
watch(
|
|
2620
|
+
pageLength,
|
|
2621
|
+
(length) => {
|
|
2622
|
+
const left = columnWidth.value.left || DEFAULT_LEFT_COLUMN_WIDTH;
|
|
2623
|
+
columnWidth.value.left = left;
|
|
2624
|
+
if (length <= 0) {
|
|
2625
|
+
columnWidth.value.right = void 0;
|
|
2626
|
+
columnWidth.value.center = globalThis.document.body.clientWidth - left;
|
|
2627
|
+
} else {
|
|
2628
|
+
const right = columnWidth.value.right || RightColumnWidthCacheData || DEFAULT_RIGHT_COLUMN_WIDTH;
|
|
2629
|
+
columnWidth.value.right = right;
|
|
2630
|
+
columnWidth.value.center = globalThis.document.body.clientWidth - left - right;
|
|
2631
|
+
}
|
|
2632
|
+
uiService?.set("columnWidth", columnWidth);
|
|
2633
|
+
},
|
|
2634
|
+
{
|
|
2635
|
+
immediate: true
|
|
2617
2636
|
}
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2637
|
+
);
|
|
2638
|
+
watch(
|
|
2639
|
+
() => columnWidth.value.right,
|
|
2640
|
+
(right) => {
|
|
2641
|
+
if (typeof right === "undefined")
|
|
2642
|
+
return;
|
|
2643
|
+
globalThis.localStorage.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, `${right}`);
|
|
2624
2644
|
}
|
|
2645
|
+
);
|
|
2646
|
+
watch(
|
|
2647
|
+
() => columnWidth.value.left,
|
|
2648
|
+
(left) => {
|
|
2649
|
+
globalThis.localStorage.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, `${left}`);
|
|
2650
|
+
}
|
|
2651
|
+
);
|
|
2652
|
+
const columnWidthChange = (columnWidth2) => {
|
|
2653
|
+
uiService?.set("columnWidth", columnWidth2);
|
|
2625
2654
|
};
|
|
2626
|
-
const
|
|
2627
|
-
const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
|
|
2628
|
-
if (columnWidthCacheData) {
|
|
2655
|
+
const saveCode = (value) => {
|
|
2629
2656
|
try {
|
|
2630
|
-
|
|
2631
|
-
columnWidth.value = columnWidthCache;
|
|
2657
|
+
editorService?.set("root", eval(value));
|
|
2632
2658
|
} catch (e) {
|
|
2633
2659
|
console.error(e);
|
|
2634
2660
|
}
|
|
2635
|
-
}
|
|
2636
|
-
const columnWidthChange = (columnWidth2) => {
|
|
2637
|
-
uiService?.set("columnWidth", columnWidth2);
|
|
2638
|
-
globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth2));
|
|
2639
2661
|
};
|
|
2640
2662
|
return (_ctx, _cache) => {
|
|
2641
2663
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|