@windrun-huaiin/third-ui 5.14.0 → 5.14.1
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/fuma/mdx/index.js +114 -10
- package/dist/fuma/mdx/index.js.map +1 -1
- package/dist/fuma/mdx/index.mjs +114 -10
- package/dist/fuma/mdx/index.mjs.map +1 -1
- package/dist/fuma/server.js.map +1 -1
- package/dist/fuma/server.mjs.map +1 -1
- package/package.json +1 -1
- package/src/fuma/mdx/mermaid.tsx +103 -10
package/dist/fuma/mdx/index.mjs
CHANGED
|
@@ -2744,18 +2744,20 @@ function Mermaid({ chart, title, watermarkEnabled, watermarkText, enablePreview
|
|
|
2744
2744
|
}, [chart, id, resolvedTheme, watermarkEnabled, watermarkText]);
|
|
2745
2745
|
const clamp = (v, min, max) => Math.min(Math.max(v, min), max);
|
|
2746
2746
|
const resetTransform = useCallback(() => {
|
|
2747
|
-
setScale(
|
|
2747
|
+
setScale(4);
|
|
2748
2748
|
setTranslate({ x: 0, y: 0 });
|
|
2749
2749
|
}, []);
|
|
2750
2750
|
const zoomBy = useCallback((delta) => {
|
|
2751
|
-
setScale((prev) => clamp(prev + delta, 0.25,
|
|
2751
|
+
setScale((prev) => clamp(prev + delta, 0.25, 10));
|
|
2752
2752
|
}, []);
|
|
2753
2753
|
const onWheel = useCallback((e) => {
|
|
2754
2754
|
if (e.metaKey || e.ctrlKey) {
|
|
2755
2755
|
e.preventDefault();
|
|
2756
|
+
e.stopPropagation();
|
|
2756
2757
|
const delta = e.deltaY > 0 ? -0.1 : 0.1;
|
|
2757
|
-
setScale((prev) => clamp(prev + delta, 0.25,
|
|
2758
|
+
setScale((prev) => clamp(prev + delta, 0.25, 10));
|
|
2758
2759
|
} else {
|
|
2760
|
+
e.stopPropagation();
|
|
2759
2761
|
setTranslate((prev) => ({ x: prev.x, y: prev.y - e.deltaY }));
|
|
2760
2762
|
}
|
|
2761
2763
|
}, []);
|
|
@@ -2775,6 +2777,57 @@ function Mermaid({ chart, title, watermarkEnabled, watermarkText, enablePreview
|
|
|
2775
2777
|
isPanningRef.current = false;
|
|
2776
2778
|
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
2777
2779
|
}, []);
|
|
2780
|
+
useEffect(() => {
|
|
2781
|
+
if (!open) return;
|
|
2782
|
+
resetTransform();
|
|
2783
|
+
const onGlobalWheel = (ev) => {
|
|
2784
|
+
if (ev.ctrlKey || ev.metaKey) {
|
|
2785
|
+
ev.preventDefault();
|
|
2786
|
+
}
|
|
2787
|
+
};
|
|
2788
|
+
const onKeyDown = (ev) => {
|
|
2789
|
+
if (!(ev.ctrlKey || ev.metaKey)) return;
|
|
2790
|
+
const k = ev.key;
|
|
2791
|
+
if (k === "=" || k === "+") {
|
|
2792
|
+
ev.preventDefault();
|
|
2793
|
+
setScale((prev) => clamp(prev + 0.2, 0.25, 10));
|
|
2794
|
+
} else if (k === "-") {
|
|
2795
|
+
ev.preventDefault();
|
|
2796
|
+
setScale((prev) => clamp(prev - 0.2, 0.25, 10));
|
|
2797
|
+
} else if (k === "0") {
|
|
2798
|
+
ev.preventDefault();
|
|
2799
|
+
resetTransform();
|
|
2800
|
+
}
|
|
2801
|
+
};
|
|
2802
|
+
window.addEventListener("wheel", onGlobalWheel, { passive: false, capture: true });
|
|
2803
|
+
window.addEventListener("keydown", onKeyDown, { capture: true });
|
|
2804
|
+
return () => {
|
|
2805
|
+
window.removeEventListener("wheel", onGlobalWheel, true);
|
|
2806
|
+
window.removeEventListener("keydown", onKeyDown, true);
|
|
2807
|
+
};
|
|
2808
|
+
}, [open, resetTransform]);
|
|
2809
|
+
useEffect(() => {
|
|
2810
|
+
if (!open) return;
|
|
2811
|
+
const previousPosition = document.body.style.position;
|
|
2812
|
+
const previousTop = document.body.style.top;
|
|
2813
|
+
const previousLeft = document.body.style.left;
|
|
2814
|
+
const previousRight = document.body.style.right;
|
|
2815
|
+
const previousWidth = document.body.style.width;
|
|
2816
|
+
const scrollY = window.scrollY;
|
|
2817
|
+
document.body.style.position = "fixed";
|
|
2818
|
+
document.body.style.top = `-${scrollY}px`;
|
|
2819
|
+
document.body.style.left = "0";
|
|
2820
|
+
document.body.style.right = "0";
|
|
2821
|
+
document.body.style.width = "100%";
|
|
2822
|
+
return () => {
|
|
2823
|
+
document.body.style.position = previousPosition;
|
|
2824
|
+
document.body.style.top = previousTop;
|
|
2825
|
+
document.body.style.left = previousLeft;
|
|
2826
|
+
document.body.style.right = previousRight;
|
|
2827
|
+
document.body.style.width = previousWidth;
|
|
2828
|
+
window.scrollTo(0, scrollY);
|
|
2829
|
+
};
|
|
2830
|
+
}, [open]);
|
|
2778
2831
|
return /* @__PURE__ */ jsxs10("div", { children: [
|
|
2779
2832
|
/* @__PURE__ */ jsxs10(
|
|
2780
2833
|
"div",
|
|
@@ -2805,10 +2858,24 @@ function Mermaid({ chart, title, watermarkEnabled, watermarkText, enablePreview
|
|
|
2805
2858
|
"aria-label": typeof title === "string" ? title : "Mermaid Preview",
|
|
2806
2859
|
className: "fixed inset-0 z-[9999] flex items-center justify-center",
|
|
2807
2860
|
children: [
|
|
2808
|
-
/* @__PURE__ */ jsx33(
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2861
|
+
/* @__PURE__ */ jsx33(
|
|
2862
|
+
"div",
|
|
2863
|
+
{
|
|
2864
|
+
className: "absolute inset-0 bg-black/60",
|
|
2865
|
+
onClick: () => {
|
|
2866
|
+
setOpen(false);
|
|
2867
|
+
resetTransform();
|
|
2868
|
+
},
|
|
2869
|
+
onWheel: (e) => {
|
|
2870
|
+
e.preventDefault();
|
|
2871
|
+
e.stopPropagation();
|
|
2872
|
+
},
|
|
2873
|
+
onTouchMove: (e) => {
|
|
2874
|
+
e.preventDefault();
|
|
2875
|
+
e.stopPropagation();
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2878
|
+
),
|
|
2812
2879
|
/* @__PURE__ */ jsxs10("div", { className: "relative z-[1] max-w-[95vw] w-[95vw] h-[88vh] p-0 bg-white dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-700 rounded-md shadow-2xl overflow-hidden", children: [
|
|
2813
2880
|
/* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between px-3 py-2 border-b border-neutral-200 dark:border-neutral-700", children: [
|
|
2814
2881
|
/* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2 text-sm text-neutral-600 dark:text-neutral-300", children: [
|
|
@@ -2821,7 +2888,7 @@ function Mermaid({ chart, title, watermarkEnabled, watermarkText, enablePreview
|
|
|
2821
2888
|
{
|
|
2822
2889
|
"aria-label": "Zoom out",
|
|
2823
2890
|
className: "flex h-6 w-6 items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 text-[13px]",
|
|
2824
|
-
onClick: () => zoomBy(-0.
|
|
2891
|
+
onClick: () => zoomBy(-0.5),
|
|
2825
2892
|
children: "\uFF0D"
|
|
2826
2893
|
}
|
|
2827
2894
|
),
|
|
@@ -2834,10 +2901,47 @@ function Mermaid({ chart, title, watermarkEnabled, watermarkText, enablePreview
|
|
|
2834
2901
|
{
|
|
2835
2902
|
"aria-label": "Zoom in",
|
|
2836
2903
|
className: "flex h-6 w-6 items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 text-[13px]",
|
|
2837
|
-
onClick: () => zoomBy(0.
|
|
2904
|
+
onClick: () => zoomBy(0.5),
|
|
2838
2905
|
children: "\uFF0B"
|
|
2839
2906
|
}
|
|
2840
2907
|
),
|
|
2908
|
+
/* @__PURE__ */ jsx33("div", { className: "mx-1 h-4 w-px bg-neutral-300 dark:bg-neutral-700" }),
|
|
2909
|
+
/* @__PURE__ */ jsx33(
|
|
2910
|
+
"button",
|
|
2911
|
+
{
|
|
2912
|
+
"aria-label": "Zoom 100%",
|
|
2913
|
+
className: "inline-flex h-6 min-w-8 items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 px-1.5 text-[12px]",
|
|
2914
|
+
onClick: () => setScale(1),
|
|
2915
|
+
children: "X1"
|
|
2916
|
+
}
|
|
2917
|
+
),
|
|
2918
|
+
/* @__PURE__ */ jsx33(
|
|
2919
|
+
"button",
|
|
2920
|
+
{
|
|
2921
|
+
"aria-label": "Zoom 200%",
|
|
2922
|
+
className: "ml-1 inline-flex h-6 min-w-8 items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 px-1.5 text-[12px]",
|
|
2923
|
+
onClick: () => setScale(2),
|
|
2924
|
+
children: "X2"
|
|
2925
|
+
}
|
|
2926
|
+
),
|
|
2927
|
+
/* @__PURE__ */ jsx33(
|
|
2928
|
+
"button",
|
|
2929
|
+
{
|
|
2930
|
+
"aria-label": "Zoom 300%",
|
|
2931
|
+
className: "ml-1 inline-flex h-6 min-w-8 items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 px-1.5 text-[12px]",
|
|
2932
|
+
onClick: () => setScale(3),
|
|
2933
|
+
children: "X3"
|
|
2934
|
+
}
|
|
2935
|
+
),
|
|
2936
|
+
/* @__PURE__ */ jsx33(
|
|
2937
|
+
"button",
|
|
2938
|
+
{
|
|
2939
|
+
"aria-label": "Zoom 1000%",
|
|
2940
|
+
className: "ml-1 inline-flex h-6 min-w-10 items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 px-1.5 text-[12px]",
|
|
2941
|
+
onClick: () => setScale(10),
|
|
2942
|
+
children: "X10"
|
|
2943
|
+
}
|
|
2944
|
+
),
|
|
2841
2945
|
/* @__PURE__ */ jsx33(
|
|
2842
2946
|
"button",
|
|
2843
2947
|
{
|
|
@@ -2864,7 +2968,7 @@ function Mermaid({ chart, title, watermarkEnabled, watermarkText, enablePreview
|
|
|
2864
2968
|
/* @__PURE__ */ jsxs10(
|
|
2865
2969
|
"div",
|
|
2866
2970
|
{
|
|
2867
|
-
className: "relative h-[calc(88vh-40px)] w-full overflow-hidden bg-white dark:bg-neutral-900",
|
|
2971
|
+
className: "relative h-[calc(88vh-40px)] w-full overflow-hidden bg-white dark:bg-neutral-900 touch-none overscroll-contain",
|
|
2868
2972
|
onWheel,
|
|
2869
2973
|
onPointerDown,
|
|
2870
2974
|
onPointerMove,
|