@flamingo-stack/openframe-frontend-core 0.0.693 → 0.0.694-2513.7695.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/{chunk-GDZ7IC5B.js → chunk-234IIQIS.js} +2 -2
- package/dist/{chunk-DVEFZ5DU.cjs → chunk-2EQED5SZ.cjs} +34 -34
- package/dist/{chunk-DVEFZ5DU.cjs.map → chunk-2EQED5SZ.cjs.map} +1 -1
- package/dist/{chunk-JUNOY5HK.js → chunk-2HX6AADM.js} +15 -17
- package/dist/chunk-2HX6AADM.js.map +1 -0
- package/dist/{chunk-EZFSUHNP.js → chunk-33L2IR62.js} +3 -3
- package/dist/{chunk-TFSRPBVT.js → chunk-42LIHMRA.js} +4 -4
- package/dist/{chunk-MIZU2OTO.cjs → chunk-63BLVGXZ.cjs} +4 -4
- package/dist/{chunk-MIZU2OTO.cjs.map → chunk-63BLVGXZ.cjs.map} +1 -1
- package/dist/{chunk-BFV4L3D7.js → chunk-6ZSDKDOV.js} +8 -8
- package/dist/{chunk-UVUNBXS6.js → chunk-7IINE3MK.js} +48 -5
- package/dist/chunk-7IINE3MK.js.map +1 -0
- package/dist/{chunk-N3526CTH.cjs → chunk-7TO3CWPM.cjs} +3 -3
- package/dist/{chunk-N3526CTH.cjs.map → chunk-7TO3CWPM.cjs.map} +1 -1
- package/dist/{chunk-WJAMBSMW.js → chunk-7VO6NC67.js} +4 -4
- package/dist/{chunk-SC44YJCF.js → chunk-A7RKT5SO.js} +2 -2
- package/dist/{chunk-ID5QPM3X.js → chunk-BW6YBATM.js} +102 -69
- package/dist/chunk-BW6YBATM.js.map +1 -0
- package/dist/{chunk-CMA74BXW.cjs → chunk-C27F6GBZ.cjs} +751 -718
- package/dist/{chunk-CMA74BXW.cjs.map → chunk-C27F6GBZ.cjs.map} +1 -1
- package/dist/{chunk-DVSPRY2V.cjs → chunk-ESMDIJIN.cjs} +3 -3
- package/dist/{chunk-DVSPRY2V.cjs.map → chunk-ESMDIJIN.cjs.map} +1 -1
- package/dist/{chunk-FMPH6G3E.cjs → chunk-FNGX5WZM.cjs} +497 -474
- package/dist/chunk-FNGX5WZM.cjs.map +1 -0
- package/dist/{chunk-5NUOZZRR.js → chunk-GWQCUC53.js} +4 -4
- package/dist/{chunk-XI2BAIKJ.js → chunk-HBMGSGZY.js} +6 -6
- package/dist/{chunk-HM7ZGABI.js → chunk-HEBLLLLD.js} +2 -2
- package/dist/{chunk-HRGG56GC.cjs → chunk-HJZ3UTUE.cjs} +83 -83
- package/dist/{chunk-HRGG56GC.cjs.map → chunk-HJZ3UTUE.cjs.map} +1 -1
- package/dist/{chunk-3HGVRJTC.cjs → chunk-JB25CCOB.cjs} +47 -47
- package/dist/{chunk-3HGVRJTC.cjs.map → chunk-JB25CCOB.cjs.map} +1 -1
- package/dist/{chunk-BDGNKIHU.cjs → chunk-JISKS7RJ.cjs} +26 -26
- package/dist/{chunk-BDGNKIHU.cjs.map → chunk-JISKS7RJ.cjs.map} +1 -1
- package/dist/{chunk-DDCQG3WO.cjs → chunk-K5GSLGV2.cjs} +18 -18
- package/dist/{chunk-DDCQG3WO.cjs.map → chunk-K5GSLGV2.cjs.map} +1 -1
- package/dist/{chunk-SG57SBYG.cjs → chunk-K5K2FRQK.cjs} +19 -19
- package/dist/{chunk-SG57SBYG.cjs.map → chunk-K5K2FRQK.cjs.map} +1 -1
- package/dist/{chunk-WSYCPIRG.cjs → chunk-KBSL4FCL.cjs} +9 -9
- package/dist/{chunk-WSYCPIRG.cjs.map → chunk-KBSL4FCL.cjs.map} +1 -1
- package/dist/{chunk-SDORFSFK.cjs → chunk-KDUDL4PB.cjs} +37 -37
- package/dist/{chunk-SDORFSFK.cjs.map → chunk-KDUDL4PB.cjs.map} +1 -1
- package/dist/{chunk-RKIMG67Q.cjs → chunk-KJHIFF6H.cjs} +16 -16
- package/dist/{chunk-RKIMG67Q.cjs.map → chunk-KJHIFF6H.cjs.map} +1 -1
- package/dist/{chunk-QDH62H4N.js → chunk-LHYOESIQ.js} +4 -4
- package/dist/{chunk-6H5PPQWP.cjs → chunk-LPFU6U7O.cjs} +5 -5
- package/dist/{chunk-6H5PPQWP.cjs.map → chunk-LPFU6U7O.cjs.map} +1 -1
- package/dist/{chunk-I72FRMF6.js → chunk-N7HFUBOV.js} +3 -3
- package/dist/{chunk-53O6PQ3F.cjs → chunk-NDLFK57D.cjs} +7 -7
- package/dist/{chunk-53O6PQ3F.cjs.map → chunk-NDLFK57D.cjs.map} +1 -1
- package/dist/{chunk-XWAT6ZP5.js → chunk-O4RDXDVS.js} +12 -12
- package/dist/{chunk-4KM5MVBM.cjs → chunk-Q2B2MGFU.cjs} +7 -7
- package/dist/{chunk-4KM5MVBM.cjs.map → chunk-Q2B2MGFU.cjs.map} +1 -1
- package/dist/{chunk-5CZZ4JLE.js → chunk-QP54LMXJ.js} +38 -15
- package/dist/{chunk-5CZZ4JLE.js.map → chunk-QP54LMXJ.js.map} +1 -1
- package/dist/{chunk-QRA2JXE4.cjs → chunk-RE6PGOSS.cjs} +6 -8
- package/dist/chunk-RE6PGOSS.cjs.map +1 -0
- package/dist/{chunk-C2SVJVEB.js → chunk-SH5GPYSV.js} +2 -2
- package/dist/{chunk-UWJZRI5J.cjs → chunk-SJFB4Z4L.cjs} +105 -105
- package/dist/{chunk-UWJZRI5J.cjs.map → chunk-SJFB4Z4L.cjs.map} +1 -1
- package/dist/{chunk-7EPGJOKN.js → chunk-TA3JJFEO.js} +4 -4
- package/dist/{chunk-PPRD3PTW.js → chunk-TBR3UTFY.js} +6 -6
- package/dist/{chunk-USKQURNF.cjs → chunk-TG3VBMDG.cjs} +3 -3
- package/dist/{chunk-USKQURNF.cjs.map → chunk-TG3VBMDG.cjs.map} +1 -1
- package/dist/{chunk-F2ZBNRTF.js → chunk-TV5SZJ3N.js} +12 -12
- package/dist/{chunk-GVMVPMDE.js → chunk-TXSQLORA.js} +6 -6
- package/dist/{chunk-INVP4WLX.js → chunk-UCXZRJIE.js} +7 -7
- package/dist/{chunk-I27PWVWE.cjs → chunk-WT4HURQN.cjs} +46 -3
- package/dist/chunk-WT4HURQN.cjs.map +1 -0
- package/dist/{chunk-XAOAYDGR.js → chunk-WZJWIZVH.js} +4 -4
- package/dist/{chunk-IC2SDW6U.js → chunk-XKNKGBUX.js} +10 -8
- package/dist/{chunk-IC2SDW6U.js.map → chunk-XKNKGBUX.js.map} +1 -1
- package/dist/{chunk-LNKLB7GM.cjs → chunk-XNTQHC26.cjs} +28 -28
- package/dist/{chunk-LNKLB7GM.cjs.map → chunk-XNTQHC26.cjs.map} +1 -1
- package/dist/{chunk-2YVTGPM7.js → chunk-XZILGCXJ.js} +2 -2
- package/dist/{chunk-JAQK3GQJ.cjs → chunk-Y5AFMYYN.cjs} +46 -44
- package/dist/chunk-Y5AFMYYN.cjs.map +1 -0
- package/dist/{chunk-7BC3NJAV.cjs → chunk-ZCPMWXIB.cjs} +25 -25
- package/dist/{chunk-7BC3NJAV.cjs.map → chunk-ZCPMWXIB.cjs.map} +1 -1
- package/dist/{chunk-S54QA2VE.cjs → chunk-ZUGAHQDB.cjs} +7 -7
- package/dist/{chunk-S54QA2VE.cjs.map → chunk-ZUGAHQDB.cjs.map} +1 -1
- package/dist/components/case-studies/index.cjs +21 -21
- package/dist/components/case-studies/index.js +8 -8
- package/dist/components/chat/chat-message-list.d.ts.map +1 -1
- package/dist/components/chat/chat-typing-indicator.d.ts.map +1 -1
- package/dist/components/chat/cycling-phrase.d.ts.map +1 -1
- package/dist/components/chat/index.cjs +5 -5
- package/dist/components/chat/index.js +4 -4
- package/dist/components/contact/index.cjs +9 -9
- package/dist/components/contact/index.js +8 -8
- package/dist/components/docs/index.cjs +12 -12
- package/dist/components/docs/index.js +11 -11
- package/dist/components/embeds/index.cjs +9 -9
- package/dist/components/embeds/index.js +8 -8
- package/dist/components/faq/index.cjs +10 -10
- package/dist/components/faq/index.js +9 -9
- package/dist/components/features/index.cjs +8 -8
- package/dist/components/features/index.js +7 -7
- package/dist/components/help-center-pages/index.cjs +107 -107
- package/dist/components/help-center-pages/index.js +22 -22
- package/dist/components/index.cjs +69 -69
- package/dist/components/index.js +22 -22
- package/dist/components/meeting-scheduler/index.cjs +59 -59
- package/dist/components/meeting-scheduler/index.js +9 -9
- package/dist/components/navigation/app-layout-drawer.d.ts.map +1 -1
- package/dist/components/navigation/index.cjs +11 -11
- package/dist/components/navigation/index.js +10 -10
- package/dist/components/onboarding-guides/index.cjs +12 -12
- package/dist/components/onboarding-guides/index.js +11 -11
- package/dist/components/related-content/index.cjs +6 -6
- package/dist/components/related-content/index.js +5 -5
- package/dist/components/tickets/index.cjs +13 -13
- package/dist/components/tickets/index.js +12 -12
- package/dist/components/ui/index.cjs +8 -8
- package/dist/components/ui/index.js +7 -7
- package/dist/components/ui/markdown/engine.d.ts +0 -21
- package/dist/components/ui/markdown/engine.d.ts.map +1 -1
- package/dist/hooks/index.cjs +6 -6
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.js +5 -5
- package/dist/hooks/use-authed-asset-src.d.ts.map +1 -1
- package/dist/index.cjs +15 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -12
- package/dist/tailwind.config.cjs +14 -1
- package/dist/tailwind.config.cjs.map +1 -1
- package/dist/tailwind.config.js +14 -1
- package/dist/tailwind.config.js.map +1 -1
- package/package.json +1 -1
- package/src/components/chat/chat-message-enhanced.tsx +1 -1
- package/src/components/chat/chat-message-list.tsx +55 -14
- package/src/components/chat/chat-typing-indicator.tsx +18 -29
- package/src/components/chat/cycling-phrase.tsx +1 -11
- package/src/components/chat/embeddable-chat.tsx +9 -6
- package/src/components/navigation/app-layout-drawer.tsx +53 -7
- package/src/components/ui/__tests__/__snapshots__/markdown-parity.test.tsx.snap +29 -29
- package/src/components/ui/markdown/engine.tsx +56 -12
- package/src/hooks/use-authed-asset-src.ts +58 -6
- package/tailwind.config.ts +13 -0
- package/dist/chunk-FMPH6G3E.cjs.map +0 -1
- package/dist/chunk-I27PWVWE.cjs.map +0 -1
- package/dist/chunk-ID5QPM3X.js.map +0 -1
- package/dist/chunk-JAQK3GQJ.cjs.map +0 -1
- package/dist/chunk-JUNOY5HK.js.map +0 -1
- package/dist/chunk-QRA2JXE4.cjs.map +0 -1
- package/dist/chunk-UVUNBXS6.js.map +0 -1
- /package/dist/{chunk-GDZ7IC5B.js.map → chunk-234IIQIS.js.map} +0 -0
- /package/dist/{chunk-EZFSUHNP.js.map → chunk-33L2IR62.js.map} +0 -0
- /package/dist/{chunk-TFSRPBVT.js.map → chunk-42LIHMRA.js.map} +0 -0
- /package/dist/{chunk-BFV4L3D7.js.map → chunk-6ZSDKDOV.js.map} +0 -0
- /package/dist/{chunk-WJAMBSMW.js.map → chunk-7VO6NC67.js.map} +0 -0
- /package/dist/{chunk-SC44YJCF.js.map → chunk-A7RKT5SO.js.map} +0 -0
- /package/dist/{chunk-5NUOZZRR.js.map → chunk-GWQCUC53.js.map} +0 -0
- /package/dist/{chunk-XI2BAIKJ.js.map → chunk-HBMGSGZY.js.map} +0 -0
- /package/dist/{chunk-HM7ZGABI.js.map → chunk-HEBLLLLD.js.map} +0 -0
- /package/dist/{chunk-QDH62H4N.js.map → chunk-LHYOESIQ.js.map} +0 -0
- /package/dist/{chunk-I72FRMF6.js.map → chunk-N7HFUBOV.js.map} +0 -0
- /package/dist/{chunk-XWAT6ZP5.js.map → chunk-O4RDXDVS.js.map} +0 -0
- /package/dist/{chunk-C2SVJVEB.js.map → chunk-SH5GPYSV.js.map} +0 -0
- /package/dist/{chunk-7EPGJOKN.js.map → chunk-TA3JJFEO.js.map} +0 -0
- /package/dist/{chunk-PPRD3PTW.js.map → chunk-TBR3UTFY.js.map} +0 -0
- /package/dist/{chunk-F2ZBNRTF.js.map → chunk-TV5SZJ3N.js.map} +0 -0
- /package/dist/{chunk-GVMVPMDE.js.map → chunk-TXSQLORA.js.map} +0 -0
- /package/dist/{chunk-INVP4WLX.js.map → chunk-UCXZRJIE.js.map} +0 -0
- /package/dist/{chunk-XAOAYDGR.js.map → chunk-WZJWIZVH.js.map} +0 -0
- /package/dist/{chunk-2YVTGPM7.js.map → chunk-XZILGCXJ.js.map} +0 -0
|
@@ -16,44 +16,33 @@ const ChatTypingIndicator = forwardRef<HTMLDivElement, ChatTypingIndicatorProps>
|
|
|
16
16
|
lg: 'h-8',
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
const dotAnimation = `
|
|
20
|
-
@keyframes dotPulse {
|
|
21
|
-
0%, 80%, 100% {
|
|
22
|
-
transform: scale(1);
|
|
23
|
-
opacity: 0.7;
|
|
24
|
-
}
|
|
25
|
-
40% {
|
|
26
|
-
transform: scale(1.5);
|
|
27
|
-
opacity: 1;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
`;
|
|
31
|
-
|
|
32
19
|
return (
|
|
33
20
|
<div ref={ref} className={cn('flex items-center gap-2', className)} {...props}>
|
|
34
|
-
<style dangerouslySetInnerHTML={{ __html: dotAnimation }} />
|
|
35
21
|
{showText && <span className="text-ods-text-secondary text-h6">Assistant is typing</span>}
|
|
36
22
|
<div className={cn('inline-flex items-center justify-center gap-1', containerSizeClasses[size])}>
|
|
37
23
|
<div
|
|
38
|
-
className={cn(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
24
|
+
className={cn(
|
|
25
|
+
dotSizeClasses[size],
|
|
26
|
+
'animate-dot-pulse rounded-full',
|
|
27
|
+
dotClassName || 'bg-ods-text-primary',
|
|
28
|
+
)}
|
|
29
|
+
style={{ animationDelay: '0ms' }}
|
|
43
30
|
/>
|
|
44
31
|
<div
|
|
45
|
-
className={cn(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
32
|
+
className={cn(
|
|
33
|
+
dotSizeClasses[size],
|
|
34
|
+
'animate-dot-pulse rounded-full',
|
|
35
|
+
dotClassName || 'bg-ods-text-primary',
|
|
36
|
+
)}
|
|
37
|
+
style={{ animationDelay: '200ms' }}
|
|
50
38
|
/>
|
|
51
39
|
<div
|
|
52
|
-
className={cn(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
40
|
+
className={cn(
|
|
41
|
+
dotSizeClasses[size],
|
|
42
|
+
'animate-dot-pulse rounded-full',
|
|
43
|
+
dotClassName || 'bg-ods-text-primary',
|
|
44
|
+
)}
|
|
45
|
+
style={{ animationDelay: '400ms' }}
|
|
57
46
|
/>
|
|
58
47
|
</div>
|
|
59
48
|
</div>
|
|
@@ -14,14 +14,6 @@ interface CyclingPhraseProps {
|
|
|
14
14
|
holdMs?: number;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
// Idempotent keyframe — multiple component instances share the same
|
|
18
|
-
// CSS rule, no duplication issues.
|
|
19
|
-
const BLINK_KEYFRAMES = `
|
|
20
|
-
@keyframes cyclingCursorBlink {
|
|
21
|
-
50% { opacity: 0; }
|
|
22
|
-
}
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
17
|
/**
|
|
26
18
|
* Terminal-style cycling word: a fixed-size block cursor walks left-
|
|
27
19
|
* to-right through the word, overwriting the previous word's char at
|
|
@@ -99,21 +91,19 @@ export function CyclingPhrase({ words, className, charMs = 60, holdMs = 4500 }:
|
|
|
99
91
|
const cursorBlock = (
|
|
100
92
|
<span
|
|
101
93
|
aria-hidden
|
|
102
|
-
className="inline-block bg-current align-baseline"
|
|
94
|
+
className="inline-block animate-cursor-blink bg-current align-baseline"
|
|
103
95
|
style={{
|
|
104
96
|
width: '0.6em',
|
|
105
97
|
height: '1em',
|
|
106
98
|
verticalAlign: '-0.1em',
|
|
107
99
|
marginLeft: '1px',
|
|
108
100
|
marginRight: '1px',
|
|
109
|
-
animation: 'cyclingCursorBlink 1s steps(1) infinite',
|
|
110
101
|
}}
|
|
111
102
|
/>
|
|
112
103
|
);
|
|
113
104
|
|
|
114
105
|
return (
|
|
115
106
|
<span className={cn('relative inline-block whitespace-nowrap', className)}>
|
|
116
|
-
<style dangerouslySetInnerHTML={{ __html: BLINK_KEYFRAMES }} />
|
|
117
107
|
{/* Invisible placeholder — pins width to longest word + "..." */}
|
|
118
108
|
<span aria-hidden className="invisible">
|
|
119
109
|
{placeholder}...
|
|
@@ -1932,16 +1932,20 @@ function EmbeddableChatInner({
|
|
|
1932
1932
|
// Measured off the panel NODE (state), not a ref read once on mount. In the
|
|
1933
1933
|
// `drawer` shell the panel body does not exist until the drawer opens, so a
|
|
1934
1934
|
// mount-time ref read saw `null`, bailed, and — with `[]` deps — never ran
|
|
1935
|
-
// again:
|
|
1935
|
+
// again: the width stayed 0, `canSplit` stayed false, and EVERY drawer
|
|
1936
1936
|
// host was silently pinned to the stacked single-column list no matter how
|
|
1937
1937
|
// wide it was. Only `shell="none"` hosts (the panel is inline and present at
|
|
1938
1938
|
// mount) ever reached the split layout.
|
|
1939
|
-
|
|
1939
|
+
//
|
|
1940
|
+
// Only the split threshold is state, not the width: the observer fires on
|
|
1941
|
+
// every pixel of a drawer drag, and a width in state re-rendered this whole
|
|
1942
|
+
// component each frame for a value that changes at one width.
|
|
1943
|
+
const [canSplit, setCanSplit] = useState(false);
|
|
1940
1944
|
useEffect(() => {
|
|
1941
1945
|
if (!panelBoundary || typeof ResizeObserver === 'undefined') return undefined;
|
|
1942
1946
|
const ro = new ResizeObserver(entries => {
|
|
1943
1947
|
const w = entries[0]?.contentRect?.width;
|
|
1944
|
-
if (typeof w === 'number')
|
|
1948
|
+
if (typeof w === 'number') setCanSplit(w >= SPLIT_MIN_WIDTH);
|
|
1945
1949
|
});
|
|
1946
1950
|
ro.observe(panelBoundary);
|
|
1947
1951
|
return () => ro.disconnect();
|
|
@@ -1959,7 +1963,7 @@ function EmbeddableChatInner({
|
|
|
1959
1963
|
// a reactive (non-mount-only) effect.
|
|
1960
1964
|
const setPanelNode = useCallback((node: HTMLDivElement | null) => {
|
|
1961
1965
|
setPanelBoundary(node);
|
|
1962
|
-
if (node)
|
|
1966
|
+
if (node) setCanSplit(node.clientWidth >= SPLIT_MIN_WIDTH);
|
|
1963
1967
|
}, []);
|
|
1964
1968
|
|
|
1965
1969
|
// Rail collapse toggle (Figma ⟶| control), persisted so it survives the
|
|
@@ -2005,7 +2009,6 @@ function EmbeddableChatInner({
|
|
|
2005
2009
|
// right chat block stays put), and only falls back to the full-panel archive
|
|
2006
2010
|
// when stacked/collapsed.
|
|
2007
2011
|
const splitEligible = historyListMode;
|
|
2008
|
-
const canSplit = panelWidth >= SPLIT_MIN_WIDTH;
|
|
2009
2012
|
// Embedded previews (hero demo tabs) always use the compact single-column
|
|
2010
2013
|
// header, never the two-column split — so `previewMode` opts out of `wideMingo`.
|
|
2011
2014
|
const wideMingo = splitEligible && canSplit && !previewMode;
|
|
@@ -2286,7 +2289,7 @@ function EmbeddableChatInner({
|
|
|
2286
2289
|
// expand toggle + the chat-block header (the fill column shows
|
|
2287
2290
|
// the chat / new-chat welcome). No back chevron — chat-list
|
|
2288
2291
|
// navigation is the rail toggle. Shown whenever the panel is wide
|
|
2289
|
-
// enough to split (
|
|
2292
|
+
// enough to split (width ≥ `SPLIT_MIN_WIDTH`), NOT gated on
|
|
2290
2293
|
// the viewport `md` breakpoint — otherwise a 720–799px panel on a
|
|
2291
2294
|
// sub-`md` viewport would split the body yet drop to the mobile
|
|
2292
2295
|
// single-bar header (no rail search / collapse controls).
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
type ComponentRef,
|
|
9
9
|
type KeyboardEvent,
|
|
10
10
|
type PointerEvent,
|
|
11
|
+
type RefObject,
|
|
11
12
|
createContext,
|
|
12
13
|
forwardRef,
|
|
13
14
|
useCallback,
|
|
@@ -299,7 +300,22 @@ function useContainedResizableSize({
|
|
|
299
300
|
}
|
|
300
301
|
}, [enabled, size, storageKey]);
|
|
301
302
|
|
|
302
|
-
return { size, setSize };
|
|
303
|
+
return { size, setSize, clampSize: clampToContainer };
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/** Ends a drawer resize drag: commits the size it reached and restores the
|
|
307
|
+
* page's cursor and text selection. No-op when no drag is in progress. */
|
|
308
|
+
function finishDrag(
|
|
309
|
+
startRef: RefObject<{ x: number; y: number; size: number } | null>,
|
|
310
|
+
dragSizeRef: RefObject<number | null>,
|
|
311
|
+
commit: (size: number) => void,
|
|
312
|
+
): void {
|
|
313
|
+
if (!startRef.current) return;
|
|
314
|
+
startRef.current = null;
|
|
315
|
+
if (dragSizeRef.current !== null) commit(dragSizeRef.current);
|
|
316
|
+
dragSizeRef.current = null;
|
|
317
|
+
document.body.style.cursor = '';
|
|
318
|
+
document.body.style.userSelect = '';
|
|
303
319
|
}
|
|
304
320
|
|
|
305
321
|
interface AppLayoutDrawerResizeHandleProps {
|
|
@@ -308,6 +324,10 @@ interface AppLayoutDrawerResizeHandleProps {
|
|
|
308
324
|
minSize: number;
|
|
309
325
|
maxSize: number;
|
|
310
326
|
onSize: (next: number) => void;
|
|
327
|
+
/** Clamp a candidate size to the min/max and the container. */
|
|
328
|
+
clampSize: (next: number) => number;
|
|
329
|
+
/** The panel the size applies to — written directly while dragging. */
|
|
330
|
+
panelRef: RefObject<HTMLDivElement | null>;
|
|
311
331
|
ariaLabel?: string;
|
|
312
332
|
}
|
|
313
333
|
|
|
@@ -317,10 +337,22 @@ function AppLayoutDrawerResizeHandle({
|
|
|
317
337
|
minSize,
|
|
318
338
|
maxSize,
|
|
319
339
|
onSize,
|
|
340
|
+
clampSize,
|
|
341
|
+
panelRef,
|
|
320
342
|
ariaLabel,
|
|
321
343
|
}: AppLayoutDrawerResizeHandleProps) {
|
|
322
344
|
const isHorizontal = HORIZONTAL_SIDES.has(side);
|
|
323
345
|
const startRef = useRef<{ x: number; y: number; size: number } | null>(null);
|
|
346
|
+
// Size reached by the drag in progress, committed to React state on release.
|
|
347
|
+
const dragSizeRef = useRef<number | null>(null);
|
|
348
|
+
const onSizeRef = useRef(onSize);
|
|
349
|
+
useEffect(() => {
|
|
350
|
+
onSizeRef.current = onSize;
|
|
351
|
+
}, [onSize]);
|
|
352
|
+
// The handle can unmount mid-drag (a persist-mode drawer closing), and then
|
|
353
|
+
// no pointer event ends the drag: end it here, or the panel keeps a width
|
|
354
|
+
// React state never received and the page keeps the resize cursor.
|
|
355
|
+
useEffect(() => () => finishDrag(startRef, dragSizeRef, onSizeRef.current), []);
|
|
324
356
|
|
|
325
357
|
const direction = side === 'right' || side === 'bottom' ? -1 : 1;
|
|
326
358
|
|
|
@@ -333,23 +365,32 @@ function AppLayoutDrawerResizeHandle({
|
|
|
333
365
|
document.body.style.userSelect = 'none';
|
|
334
366
|
};
|
|
335
367
|
|
|
368
|
+
// The drag writes the panel's size straight to the DOM and commits it to
|
|
369
|
+
// state once, on release. Committing every pointermove re-rendered the
|
|
370
|
+
// drawer per event — ~16% of a drag's CPU in WebKit on top of the reflow the
|
|
371
|
+
// resize itself costs. ResizeObserver consumers inside the panel still see
|
|
372
|
+
// every change. A re-render of the drawer mid-drag (e.g. a streamed chunk)
|
|
373
|
+
// does not undo the write: React diffs against its previous render, where
|
|
374
|
+
// the size is unchanged, so it leaves the style alone.
|
|
336
375
|
const handlePointerMove = (e: PointerEvent<HTMLDivElement>) => {
|
|
337
376
|
const start = startRef.current;
|
|
338
|
-
|
|
377
|
+
const panel = panelRef.current;
|
|
378
|
+
if (!start || !panel) return;
|
|
339
379
|
const delta = isHorizontal ? e.clientX - start.x : e.clientY - start.y;
|
|
340
|
-
|
|
380
|
+
const next = clampSize(start.size + delta * direction);
|
|
381
|
+
dragSizeRef.current = next;
|
|
382
|
+
panel.style[isHorizontal ? 'width' : 'height'] = `${next}px`;
|
|
383
|
+
e.currentTarget.setAttribute('aria-valuenow', String(Math.round(next)));
|
|
341
384
|
};
|
|
342
385
|
|
|
343
386
|
const endDrag = (e: PointerEvent<HTMLDivElement>) => {
|
|
344
387
|
if (!startRef.current) return;
|
|
345
|
-
startRef
|
|
388
|
+
finishDrag(startRef, dragSizeRef, onSize);
|
|
346
389
|
try {
|
|
347
390
|
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
348
391
|
} catch {
|
|
349
392
|
// ignore — pointer may already be released
|
|
350
393
|
}
|
|
351
|
-
document.body.style.cursor = '';
|
|
352
|
-
document.body.style.userSelect = '';
|
|
353
394
|
};
|
|
354
395
|
|
|
355
396
|
const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
|
|
@@ -405,6 +446,7 @@ function AppLayoutDrawerResizeHandle({
|
|
|
405
446
|
onPointerMove={handlePointerMove}
|
|
406
447
|
onPointerUp={endDrag}
|
|
407
448
|
onPointerCancel={endDrag}
|
|
449
|
+
onLostPointerCapture={endDrag}
|
|
408
450
|
onKeyDown={handleKeyDown}
|
|
409
451
|
className={cn(
|
|
410
452
|
'group absolute z-20 flex touch-none select-none',
|
|
@@ -585,7 +627,8 @@ const AppLayoutDrawerContent = forwardRef<ComponentRef<typeof DialogPrimitive.Co
|
|
|
585
627
|
return () => mq.removeEventListener('change', update);
|
|
586
628
|
}, [mobileBreakpoint]);
|
|
587
629
|
|
|
588
|
-
const
|
|
630
|
+
const panelRef = useRef<HTMLDivElement>(null);
|
|
631
|
+
const { size, setSize, clampSize } = useContainedResizableSize({
|
|
589
632
|
enabled: resizable,
|
|
590
633
|
isHorizontal,
|
|
591
634
|
minSize,
|
|
@@ -670,10 +713,13 @@ const AppLayoutDrawerContent = forwardRef<ComponentRef<typeof DialogPrimitive.Co
|
|
|
670
713
|
minSize={minSize}
|
|
671
714
|
maxSize={maxSize}
|
|
672
715
|
onSize={setSize}
|
|
716
|
+
clampSize={clampSize}
|
|
717
|
+
panelRef={panelRef}
|
|
673
718
|
ariaLabel={resizeAriaLabel}
|
|
674
719
|
/>
|
|
675
720
|
) : null}
|
|
676
721
|
<div
|
|
722
|
+
ref={panelRef}
|
|
677
723
|
className={cn(
|
|
678
724
|
appLayoutDrawerPanelVariants({ side, flush }),
|
|
679
725
|
// Mobile: fill the container (the side already pins one axis) and
|
|
@@ -23,7 +23,7 @@ exports[`RichMarkdownRenderer golden parity > renders fixture: auto-url-generic-
|
|
|
23
23
|
|
|
24
24
|
exports[`RichMarkdownRenderer golden parity > renders fixture: auto-url-inside-code-not-embedded 1`] = `
|
|
25
25
|
"<div class="simple-markdown-renderer "><div class="content-wrapper max-w-none"><article class="prose prose-lg max-w-none"><p class="text-ods-text-primary first:mt-0 last:mb-0 font-sans text-[16px] md:text-[18px] lg:text-[20px] leading-[1.6] my-4">code <code class="rounded border border-ods-border bg-ods-card px-1.5 py-0.5 font-mono text-[0.9em] text-ods-text-primary">https://blog.example.com/post-3</code> inline</p>
|
|
26
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
26
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);">https://blog.example.com/post-4
|
|
27
27
|
</code></pre></div></div></pre></article></div></div>"
|
|
28
28
|
`;
|
|
29
29
|
|
|
@@ -181,7 +181,7 @@ exports[`RichMarkdownRenderer golden parity > renders fixture: images 1`] = `
|
|
|
181
181
|
|
|
182
182
|
exports[`RichMarkdownRenderer golden parity > renders fixture: indented-code-angle-bracket-not-escaped 1`] = `
|
|
183
183
|
"<div class="simple-markdown-renderer "><div class="content-wrapper max-w-none"><article class="prose prose-lg max-w-none"><p class="text-ods-text-primary first:mt-0 last:mb-0 font-sans text-[16px] md:text-[18px] lg:text-[20px] leading-[1.6] my-4">Para</p>
|
|
184
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
184
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);">if a <b then
|
|
185
185
|
done
|
|
186
186
|
</code></pre></div></div></pre></article></div></div>"
|
|
187
187
|
`;
|
|
@@ -225,9 +225,9 @@ exports[`RichMarkdownRenderer golden parity > renders fixture: list-continuation
|
|
|
225
225
|
|
|
226
226
|
exports[`RichMarkdownRenderer golden parity > renders fixture: list-marker-inside-fence-does-not-shift-indent-columns 1`] = `
|
|
227
227
|
"<div class="simple-markdown-renderer "><div class="content-wrapper max-w-none"><article class="prose prose-lg max-w-none"><p class="text-ods-text-primary first:mt-0 last:mb-0 font-sans text-[16px] md:text-[18px] lg:text-[20px] leading-[1.6] my-4">A <textarea></p>
|
|
228
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
228
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);">- x
|
|
229
229
|
</code></pre></div></div></pre>
|
|
230
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
230
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);"></textarea>
|
|
231
231
|
</code></pre></div></div></pre></article></div></div>"
|
|
232
232
|
`;
|
|
233
233
|
|
|
@@ -235,9 +235,9 @@ exports[`RichMarkdownRenderer golden parity > renders fixture: list-marker-insid
|
|
|
235
235
|
"<div class="simple-markdown-renderer "><div class="content-wrapper max-w-none"><article class="prose prose-lg max-w-none"><div>
|
|
236
236
|
<textarea>
|
|
237
237
|
</div>
|
|
238
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
238
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);">- x
|
|
239
239
|
</code></pre></div></div></pre>
|
|
240
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
240
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);"></textarea>
|
|
241
241
|
</code></pre></div></div></pre>
|
|
242
242
|
<h1 id="heading-after" class="mb-4 mt-8 font-sans font-bold text-ods-text-primary first:mt-0 text-[32px] md:text-[40px] lg:text-[48px] leading-[1.25]">Heading after</h1>
|
|
243
243
|
<p class="text-ods-text-primary first:mt-0 last:mb-0 font-sans text-[16px] md:text-[18px] lg:text-[20px] leading-[1.6] my-4">Body after.</p></article></div></div>"
|
|
@@ -287,13 +287,13 @@ exports[`RichMarkdownRenderer golden parity > renders fixture: mermaid 1`] = `
|
|
|
287
287
|
`;
|
|
288
288
|
|
|
289
289
|
exports[`RichMarkdownRenderer golden parity > renders fixture: mismatched-fence-carve-does-not-shelter-opener 1`] = `
|
|
290
|
-
"<div class="simple-markdown-renderer "><div class="content-wrapper max-w-none"><article class="prose prose-lg max-w-none"><pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
290
|
+
"<div class="simple-markdown-renderer "><div class="content-wrapper max-w-none"><article class="prose prose-lg max-w-none"><pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);">\`\`\`js
|
|
291
291
|
~~~
|
|
292
|
-
</
|
|
292
|
+
</code></pre></div></div></pre>
|
|
293
293
|
<p class="text-ods-text-primary first:mt-0 last:mb-0 font-sans text-[16px] md:text-[18px] lg:text-[20px] leading-[1.6] my-4"><textarea><br>
|
|
294
294
|
hello</p>
|
|
295
|
-
<pre><
|
|
296
|
-
</code></pre></article></div></div>"
|
|
295
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);">after
|
|
296
|
+
</code></pre></div></div></pre></article></div></div>"
|
|
297
297
|
`;
|
|
298
298
|
|
|
299
299
|
exports[`RichMarkdownRenderer golden parity > renders fixture: nested-lists 1`] = `
|
|
@@ -430,7 +430,7 @@ exports[`RichMarkdownRenderer golden parity > renders fixture: rawtext-closer-in
|
|
|
430
430
|
exports[`RichMarkdownRenderer golden parity > renders fixture: rawtext-closer-in-indented-code-does-not-unescape 1`] = `
|
|
431
431
|
"<div class="simple-markdown-renderer "><div class="content-wrapper max-w-none"><article class="prose prose-lg max-w-none"><p class="text-ods-text-primary first:mt-0 last:mb-0 font-sans text-[16px] md:text-[18px] lg:text-[20px] leading-[1.6] my-4">Explaining <textarea> in prose.</p>
|
|
432
432
|
<h2 id="after-heading" class="mb-4 mt-8 border-b border-ods-border pb-2 font-sans font-semibold text-ods-text-primary text-[28px] md:text-[32px]">After heading</h2>
|
|
433
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
433
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);"></textarea>
|
|
434
434
|
</code></pre></div></div></pre>
|
|
435
435
|
<p class="text-ods-text-primary first:mt-0 last:mb-0 font-sans text-[16px] md:text-[18px] lg:text-[20px] leading-[1.6] my-4">tail</p></article></div></div>"
|
|
436
436
|
`;
|
|
@@ -501,9 +501,9 @@ exports[`RichMarkdownRenderer golden parity > renders fixture: rawtext-closer-in
|
|
|
501
501
|
<ul class="my-4 ml-8 list-outside list-disc space-y-2 text-ods-text-primary">
|
|
502
502
|
<li class="pl-2 text-[16px] md:text-[18px]">
|
|
503
503
|
<p class="text-ods-text-primary first:mt-0 last:mb-0 font-sans text-[16px] md:text-[18px] lg:text-[20px] leading-[1.6] my-4">item</p>
|
|
504
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
504
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);">\`\`\`html
|
|
505
505
|
</textarea>
|
|
506
|
-
|
|
506
|
+
\`\`\`
|
|
507
507
|
</code></pre></div></div></pre>
|
|
508
508
|
</li>
|
|
509
509
|
</ul>
|
|
@@ -725,7 +725,7 @@ exports[`RichMarkdownRenderer golden parity > renders fixture: rawtext-closer-in
|
|
|
725
725
|
exports[`RichMarkdownRenderer golden parity > renders fixture: rawtext-closer-in-tab-indented-code-does-not-unescape 1`] = `
|
|
726
726
|
"<div class="simple-markdown-renderer "><div class="content-wrapper max-w-none"><article class="prose prose-lg max-w-none"><p class="text-ods-text-primary first:mt-0 last:mb-0 font-sans text-[16px] md:text-[18px] lg:text-[20px] leading-[1.6] my-4">Explaining <textarea> in prose.</p>
|
|
727
727
|
<h2 id="after-heading" class="mb-4 mt-8 border-b border-ods-border pb-2 font-sans font-semibold text-ods-text-primary text-[28px] md:text-[32px]">After heading</h2>
|
|
728
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
728
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);"></textarea>
|
|
729
729
|
</code></pre></div></div></pre>
|
|
730
730
|
<p class="text-ods-text-primary first:mt-0 last:mb-0 font-sans text-[16px] md:text-[18px] lg:text-[20px] leading-[1.6] my-4">tail</p></article></div></div>"
|
|
731
731
|
`;
|
|
@@ -1170,7 +1170,7 @@ exports[`RichMarkdownRenderer golden parity > renders fixture: wide-list-marker-
|
|
|
1170
1170
|
"<div class="simple-markdown-renderer "><div class="content-wrapper max-w-none"><article class="prose prose-lg max-w-none"><p class="text-ods-text-primary first:mt-0 last:mb-0 font-sans text-[16px] md:text-[18px] lg:text-[20px] leading-[1.6] my-4">Explaining <textarea> in HTML.</p>
|
|
1171
1171
|
<ul class="my-4 ml-8 list-outside list-disc space-y-2 text-ods-text-primary">
|
|
1172
1172
|
<li class="pl-2 text-[16px] md:text-[18px]">
|
|
1173
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
1173
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);"> foo
|
|
1174
1174
|
</textarea>
|
|
1175
1175
|
</code></pre></div></div></pre>
|
|
1176
1176
|
</li>
|
|
@@ -1322,7 +1322,7 @@ exports[`SimpleMarkdownRenderer golden parity > renders fixture: images 1`] = `
|
|
|
1322
1322
|
|
|
1323
1323
|
exports[`SimpleMarkdownRenderer golden parity > renders fixture: indented-code-angle-bracket-not-escaped 1`] = `
|
|
1324
1324
|
"<div class="simple-markdown-renderer "><div class="content-wrapper max-w-none"><article class="prose prose-lg max-w-none"><p class="mb-4 leading-relaxed text-ods-text-primary first:mt-0 last:mb-0 md:text-h4 lg:text-h4">Para</p>
|
|
1325
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
1325
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);">if a <b then
|
|
1326
1326
|
done
|
|
1327
1327
|
</code></pre></div></div></pre></article></div></div>"
|
|
1328
1328
|
`;
|
|
@@ -1366,9 +1366,9 @@ exports[`SimpleMarkdownRenderer golden parity > renders fixture: list-continuati
|
|
|
1366
1366
|
|
|
1367
1367
|
exports[`SimpleMarkdownRenderer golden parity > renders fixture: list-marker-inside-fence-does-not-shift-indent-columns 1`] = `
|
|
1368
1368
|
"<div class="simple-markdown-renderer "><div class="content-wrapper max-w-none"><article class="prose prose-lg max-w-none"><p class="mb-4 leading-relaxed text-ods-text-primary first:mt-0 last:mb-0 md:text-h4 lg:text-h4">A <textarea></p>
|
|
1369
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
1369
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);">- x
|
|
1370
1370
|
</code></pre></div></div></pre>
|
|
1371
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
1371
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);"></textarea>
|
|
1372
1372
|
</code></pre></div></div></pre></article></div></div>"
|
|
1373
1373
|
`;
|
|
1374
1374
|
|
|
@@ -1376,9 +1376,9 @@ exports[`SimpleMarkdownRenderer golden parity > renders fixture: list-marker-ins
|
|
|
1376
1376
|
"<div class="simple-markdown-renderer "><div class="content-wrapper max-w-none"><article class="prose prose-lg max-w-none"><div>
|
|
1377
1377
|
<textarea>
|
|
1378
1378
|
</div>
|
|
1379
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
1379
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);">- x
|
|
1380
1380
|
</code></pre></div></div></pre>
|
|
1381
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
1381
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);"></textarea>
|
|
1382
1382
|
</code></pre></div></div></pre>
|
|
1383
1383
|
<h1 id="heading-after" class="mb-4 mt-8 font-sans font-bold first:mt-0 text-heading-1">Heading after</h1>
|
|
1384
1384
|
<p class="mb-4 leading-relaxed text-ods-text-primary first:mt-0 last:mb-0 md:text-h4 lg:text-h4">Body after.</p></article></div></div>"
|
|
@@ -1428,13 +1428,13 @@ exports[`SimpleMarkdownRenderer golden parity > renders fixture: mermaid 1`] = `
|
|
|
1428
1428
|
`;
|
|
1429
1429
|
|
|
1430
1430
|
exports[`SimpleMarkdownRenderer golden parity > renders fixture: mismatched-fence-carve-does-not-shelter-opener 1`] = `
|
|
1431
|
-
"<div class="simple-markdown-renderer "><div class="content-wrapper max-w-none"><article class="prose prose-lg max-w-none"><pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
1431
|
+
"<div class="simple-markdown-renderer "><div class="content-wrapper max-w-none"><article class="prose prose-lg max-w-none"><pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);">\`\`\`js
|
|
1432
1432
|
~~~
|
|
1433
|
-
</
|
|
1433
|
+
</code></pre></div></div></pre>
|
|
1434
1434
|
<p class="mb-4 leading-relaxed text-ods-text-primary first:mt-0 last:mb-0 md:text-h4 lg:text-h4"><textarea><br>
|
|
1435
1435
|
hello</p>
|
|
1436
|
-
<pre><
|
|
1437
|
-
</code></pre></article></div></div>"
|
|
1436
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);">after
|
|
1437
|
+
</code></pre></div></div></pre></article></div></div>"
|
|
1438
1438
|
`;
|
|
1439
1439
|
|
|
1440
1440
|
exports[`SimpleMarkdownRenderer golden parity > renders fixture: nested-lists 1`] = `
|
|
@@ -1569,7 +1569,7 @@ exports[`SimpleMarkdownRenderer golden parity > renders fixture: rawtext-closer-
|
|
|
1569
1569
|
exports[`SimpleMarkdownRenderer golden parity > renders fixture: rawtext-closer-in-indented-code-does-not-unescape 1`] = `
|
|
1570
1570
|
"<div class="simple-markdown-renderer "><div class="content-wrapper max-w-none"><article class="prose prose-lg max-w-none"><p class="mb-4 leading-relaxed text-ods-text-primary first:mt-0 last:mb-0 md:text-h4 lg:text-h4">Explaining <textarea> in prose.</p>
|
|
1571
1571
|
<h2 id="after-heading" class="mb-4 mt-8 border-b border-ods-border pb-2 font-sans font-semibold text-heading-2">After heading</h2>
|
|
1572
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
1572
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);"></textarea>
|
|
1573
1573
|
</code></pre></div></div></pre>
|
|
1574
1574
|
<p class="mb-4 leading-relaxed text-ods-text-primary first:mt-0 last:mb-0 md:text-h4 lg:text-h4">tail</p></article></div></div>"
|
|
1575
1575
|
`;
|
|
@@ -1640,9 +1640,9 @@ exports[`SimpleMarkdownRenderer golden parity > renders fixture: rawtext-closer-
|
|
|
1640
1640
|
<ul class="my-4 ml-8 list-outside list-disc space-y-2 text-ods-text-primary">
|
|
1641
1641
|
<li class="pl-2 text-base md:text-lg">
|
|
1642
1642
|
<p class="mb-4 leading-relaxed text-ods-text-primary first:mt-0 last:mb-0 md:text-h4 lg:text-h4">item</p>
|
|
1643
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
1643
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);">\`\`\`html
|
|
1644
1644
|
</textarea>
|
|
1645
|
-
|
|
1645
|
+
\`\`\`
|
|
1646
1646
|
</code></pre></div></div></pre>
|
|
1647
1647
|
</li>
|
|
1648
1648
|
</ul>
|
|
@@ -1864,7 +1864,7 @@ exports[`SimpleMarkdownRenderer golden parity > renders fixture: rawtext-closer-
|
|
|
1864
1864
|
exports[`SimpleMarkdownRenderer golden parity > renders fixture: rawtext-closer-in-tab-indented-code-does-not-unescape 1`] = `
|
|
1865
1865
|
"<div class="simple-markdown-renderer "><div class="content-wrapper max-w-none"><article class="prose prose-lg max-w-none"><p class="mb-4 leading-relaxed text-ods-text-primary first:mt-0 last:mb-0 md:text-h4 lg:text-h4">Explaining <textarea> in prose.</p>
|
|
1866
1866
|
<h2 id="after-heading" class="mb-4 mt-8 border-b border-ods-border pb-2 font-sans font-semibold text-heading-2">After heading</h2>
|
|
1867
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
1867
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);"></textarea>
|
|
1868
1868
|
</code></pre></div></div></pre>
|
|
1869
1869
|
<p class="mb-4 leading-relaxed text-ods-text-primary first:mt-0 last:mb-0 md:text-h4 lg:text-h4">tail</p></article></div></div>"
|
|
1870
1870
|
`;
|
|
@@ -2285,7 +2285,7 @@ exports[`SimpleMarkdownRenderer golden parity > renders fixture: wide-list-marke
|
|
|
2285
2285
|
"<div class="simple-markdown-renderer "><div class="content-wrapper max-w-none"><article class="prose prose-lg max-w-none"><p class="mb-4 leading-relaxed text-ods-text-primary first:mt-0 last:mb-0 md:text-h4 lg:text-h4">Explaining <textarea> in HTML.</p>
|
|
2286
2286
|
<ul class="my-4 ml-8 list-outside list-disc space-y-2 text-ods-text-primary">
|
|
2287
2287
|
<li class="pl-2 text-base md:text-lg">
|
|
2288
|
-
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">
|
|
2288
|
+
<pre><div class="code-block-container my-6 overflow-hidden rounded-lg border border-ods-border bg-ods-card"><div class="code-header border-b border-ods-border bg-ods-card px-4 py-2"><span class="font-sans text-xs uppercase tracking-wide text-ods-text-tertiary">code</span></div><div class="p-4"><pre class="overflow-x-auto"><code class="language-code hljs font-mono text-[14px]" style="background: transparent; color: var(--color-text-primary);"> foo
|
|
2289
2289
|
</textarea>
|
|
2290
2290
|
</code></pre></div></div></pre>
|
|
2291
2291
|
</li>
|
|
@@ -17,10 +17,12 @@
|
|
|
17
17
|
* → escapeUnknownHtmlTags (text pre-pass, React 19 crash guard)
|
|
18
18
|
* → remark: remarkGfm, remarkBreaks, ...additionalRemarkPlugins
|
|
19
19
|
* → rehype: rehypeRaw → rehypeSanitize(schema) → rehypeStripUnsafe
|
|
20
|
-
* → rehypeHighlight
|
|
20
|
+
* → rehypeLabelBareFences → rehypeHighlight (not on the streaming tail)
|
|
21
21
|
* → urlTransform: cardAwareUrlTransform
|
|
22
22
|
* → components: buildBaseComponents(...) spread-last componentOverrides
|
|
23
23
|
*/
|
|
24
|
+
|
|
25
|
+
import type { Element, Root } from 'hast';
|
|
24
26
|
import type React from 'react';
|
|
25
27
|
import { memo, useMemo } from 'react';
|
|
26
28
|
import ReactMarkdown, { type Components } from 'react-markdown';
|
|
@@ -64,6 +66,36 @@ export type { ResolveLinkResult };
|
|
|
64
66
|
*/
|
|
65
67
|
export const NO_BROKEN_LINKS: readonly string[] = [];
|
|
66
68
|
|
|
69
|
+
const BARE_FENCE_LANGUAGE = 'code';
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Gives a fenced code block written without a language the `language-code`
|
|
73
|
+
* class. The `code` renderer tells a fenced block from inline code only by a
|
|
74
|
+
* `language-*` class, which unlabelled fences used to get from
|
|
75
|
+
* rehype-highlight's language detection; without detection (and on the
|
|
76
|
+
* streaming tail, which is not highlighted at all) they would render as
|
|
77
|
+
* inline-code pills. `code` is in rehype-highlight's `plainText` list, so
|
|
78
|
+
* the block is left unhighlighted, and its header reads "code".
|
|
79
|
+
*/
|
|
80
|
+
function rehypeLabelBareFences() {
|
|
81
|
+
const visit = (node: Root | Element) => {
|
|
82
|
+
for (const child of node.children) {
|
|
83
|
+
if (child.type !== 'element') continue;
|
|
84
|
+
if (child.tagName === 'pre') {
|
|
85
|
+
for (const code of child.children) {
|
|
86
|
+
if (code.type !== 'element' || code.tagName !== 'code') continue;
|
|
87
|
+
const classes = Array.isArray(code.properties.className) ? code.properties.className : [];
|
|
88
|
+
if (!classes.some(c => String(c).startsWith('language-'))) {
|
|
89
|
+
code.properties.className = [...classes, `language-${BARE_FENCE_LANGUAGE}`];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
visit(child);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
return (tree: Root) => visit(tree);
|
|
97
|
+
}
|
|
98
|
+
|
|
67
99
|
export interface MarkdownEngineProps {
|
|
68
100
|
content: string;
|
|
69
101
|
className?: string;
|
|
@@ -195,19 +227,31 @@ const MarkdownEngineImpl: React.FC<MarkdownEngineProps> = ({
|
|
|
195
227
|
[additionalRemarkPlugins],
|
|
196
228
|
);
|
|
197
229
|
|
|
198
|
-
const rehypePlugins = useMemo
|
|
230
|
+
const { rehypePlugins, liveRehypePlugins } = useMemo(() => {
|
|
199
231
|
const schema = buildSanitizeSchema({
|
|
200
232
|
extraAllowedHtmlTags: extraTagsKey ? extraTagsKey.split('|') : undefined,
|
|
201
233
|
});
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
234
|
+
// ORDER MATTERS: rehype-raw parses embedded raw HTML into HAST;
|
|
235
|
+
// rehypeSanitize is the allow-list boundary; rehypeStripUnsafe is
|
|
236
|
+
// defense-in-depth (srcset scanning, iframe[srcdoc]); the fence label
|
|
237
|
+
// goes on after sanitizing and before highlight, which runs last.
|
|
238
|
+
const safe: PluggableList = [rehypeRaw, [rehypeSanitize, schema], rehypeStripUnsafe, rehypeLabelBareFences];
|
|
239
|
+
const highlighted: PluggableList = [
|
|
240
|
+
...safe,
|
|
241
|
+
// No language detection: it ran highlightAuto over every registered
|
|
242
|
+
// grammar for each unlabelled fence (~2.5x the cost of opening a
|
|
243
|
+
// thread) and often guessed wrong (PowerShell shown as "VBNET").
|
|
244
|
+
[rehypeHighlight, { plainText: [BARE_FENCE_LANGUAGE] }],
|
|
210
245
|
];
|
|
246
|
+
return {
|
|
247
|
+
rehypePlugins: highlighted,
|
|
248
|
+
// The streaming tail re-parses on every chunk, and a code fence being
|
|
249
|
+
// typed is one tail block — highlighting it every chunk was the
|
|
250
|
+
// costliest step of a streamed reply. It is highlighted once it
|
|
251
|
+
// completes: every block before the tail and the final parse use
|
|
252
|
+
// `rehypePlugins`.
|
|
253
|
+
liveRehypePlugins: safe,
|
|
254
|
+
};
|
|
211
255
|
}, [extraTagsKey]);
|
|
212
256
|
|
|
213
257
|
const components: Components = useMemo(
|
|
@@ -238,7 +282,7 @@ const MarkdownEngineImpl: React.FC<MarkdownEngineProps> = ({
|
|
|
238
282
|
// spam (polite + additions). Streaming caret/pulse affordances live in
|
|
239
283
|
// chat components and honor prefers-reduced-motion there.
|
|
240
284
|
<div aria-live="polite" aria-relevant="additions text">
|
|
241
|
-
{streamingBlocks.map(block => (
|
|
285
|
+
{streamingBlocks.map((block, i) => (
|
|
242
286
|
// Each unit is parsed on its own, so hast positions restart at 1;
|
|
243
287
|
// the offset maps them back onto the document-wide heading-id map.
|
|
244
288
|
<HeadingLineOffsetContext.Provider key={block.index} value={block.startLine - 1}>
|
|
@@ -252,7 +296,7 @@ const MarkdownEngineImpl: React.FC<MarkdownEngineProps> = ({
|
|
|
252
296
|
) : (
|
|
253
297
|
<ReactMarkdown
|
|
254
298
|
remarkPlugins={remarkPlugins}
|
|
255
|
-
rehypePlugins={rehypePlugins}
|
|
299
|
+
rehypePlugins={i === streamingBlocks.length - 1 ? liveRehypePlugins : rehypePlugins}
|
|
256
300
|
urlTransform={cardAwareUrlTransform}
|
|
257
301
|
components={components}
|
|
258
302
|
>
|