@vvedantb/ui 0.84.0 → 0.85.0
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/shell/src/DockArrow.js +37 -5
- package/dist/shell/src/SidebarChrome.js +135 -117
- package/dist/shell/src/SidebarPanel.js +14 -12
- package/dist/shell/src/SidebarPeek.js +274 -98
- package/dist/src/markdown/Markdown.js +43 -28
- package/dist/src/markdown/codeHighlight.js +70 -37
- package/dist/src/markdown/lazyMath.js +36 -0
- package/dist/src/markdown/mathPlugin.js +2 -0
- package/package.json +1 -1
- package/shell/src/DockArrow.tsx +36 -6
- package/shell/src/SidebarChrome.tsx +7 -2
- package/shell/src/SidebarPanel.tsx +1 -1
- package/shell/src/SidebarPeek.ts +131 -24
- package/src/client.ts +1 -1
- package/src/index.ts +1 -1
- package/src/markdown/Markdown.tsx +12 -6
- package/src/markdown/codeHighlight.ts +46 -10
- package/src/markdown/lazyMath.ts +36 -0
- package/src/markdown/mathPlugin.ts +3 -0
|
@@ -4,8 +4,10 @@ import { flushSync } from "react-dom";
|
|
|
4
4
|
import { dockPopIn, dockPopOut } from "../../src/motion/dock-motion.js";
|
|
5
5
|
const OPEN_DELAY_MS = 120;
|
|
6
6
|
const CLOSE_DELAY_MS = 350;
|
|
7
|
+
const MENU_CLOSE_DELAY_MS = 2000;
|
|
7
8
|
const OPEN_MENU_TRIGGER = '[aria-haspopup][aria-expanded="true"]';
|
|
8
9
|
const PANEL_SELECTOR = "[data-sidebar-panel]";
|
|
10
|
+
const PORTAL_MENU = '[role="menu"]';
|
|
9
11
|
function peekTile(target) {
|
|
10
12
|
if (!(target instanceof Element)) return null;
|
|
11
13
|
const tile = target.closest("[data-rail-peek]");
|
|
@@ -14,153 +16,326 @@ function peekTile(target) {
|
|
|
14
16
|
function inPanel(target) {
|
|
15
17
|
return target instanceof Element && target.closest(PANEL_SELECTOR) !== null;
|
|
16
18
|
}
|
|
19
|
+
function inPortal(aside, target) {
|
|
20
|
+
return target instanceof Node && !aside.contains(target);
|
|
21
|
+
}
|
|
22
|
+
function inPortalMenu(aside, target) {
|
|
23
|
+
return target instanceof Element && target.closest(PORTAL_MENU) !== null && !aside.contains(target);
|
|
24
|
+
}
|
|
25
|
+
function openPortalMenu(aside) {
|
|
26
|
+
return Array.from(document.querySelectorAll(PORTAL_MENU)).some(menu => !aside.contains(menu) && menu.getAttribute("data-state") !== "closed");
|
|
27
|
+
}
|
|
17
28
|
/**
|
|
18
29
|
* Hover and focus state of an unpinned sidebar. The panel opens as an overlay
|
|
19
30
|
* when the pointer or focus is on a rail item that has `data-rail-peek` (rail
|
|
20
31
|
* links and tabs have it), and stays open while the pointer or focus is on a
|
|
21
32
|
* rail item or in the panel. It grows out of the hovered item with
|
|
22
33
|
* `dockPopIn` and shrinks back with `dockPopOut`. It stays open while a menu
|
|
23
|
-
* opened from the sidebar is open
|
|
34
|
+
* opened from the sidebar is open, a right-click menu included, and closes
|
|
35
|
+
* `menuCloseDelay` after that menu closes with the pointer outside. A rail item
|
|
36
|
+
* whose page has no panel closes it, like empty rail. `Sidebar.Root` makes one when none is
|
|
24
37
|
* passed; pass your own to read `previewPath` or `previewValue` and show the
|
|
25
38
|
* hovered item's panel without navigating.
|
|
26
39
|
*/
|
|
27
|
-
export function useSidebarPeek() {
|
|
28
|
-
const $ = _c(
|
|
40
|
+
export function useSidebarPeek(t0) {
|
|
41
|
+
const $ = _c(31);
|
|
42
|
+
let t1;
|
|
43
|
+
if ($[0] !== t0) {
|
|
44
|
+
t1 = t0 === undefined ? {} : t0;
|
|
45
|
+
$[0] = t0;
|
|
46
|
+
$[1] = t1;
|
|
47
|
+
} else {
|
|
48
|
+
t1 = $[1];
|
|
49
|
+
}
|
|
50
|
+
const {
|
|
51
|
+
menuCloseDelay: t2
|
|
52
|
+
} = t1;
|
|
53
|
+
const menuCloseDelay = t2 === undefined ? MENU_CLOSE_DELAY_MS : t2;
|
|
29
54
|
const [peeking, setPeeking] = useState(false);
|
|
30
55
|
const [tile, setTile] = useState(null);
|
|
31
56
|
const timer = useRef(undefined);
|
|
32
57
|
const open = useRef(false);
|
|
33
58
|
const tileRef = useRef(null);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
59
|
+
const noPanelTile = useRef(null);
|
|
60
|
+
const contextMenu = useRef(false);
|
|
61
|
+
const stopWatch = useRef(null);
|
|
62
|
+
let t3;
|
|
63
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
64
|
+
t3 = () => window.clearTimeout(timer.current);
|
|
65
|
+
$[2] = t3;
|
|
38
66
|
} else {
|
|
39
|
-
|
|
67
|
+
t3 = $[2];
|
|
40
68
|
}
|
|
41
|
-
const cancelPending =
|
|
42
|
-
let
|
|
43
|
-
if ($[
|
|
44
|
-
|
|
69
|
+
const cancelPending = t3;
|
|
70
|
+
let t4;
|
|
71
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
72
|
+
t4 = () => {
|
|
73
|
+
stopWatch.current?.();
|
|
74
|
+
stopWatch.current = null;
|
|
75
|
+
contextMenu.current = false;
|
|
76
|
+
};
|
|
77
|
+
$[3] = t4;
|
|
78
|
+
} else {
|
|
79
|
+
t4 = $[3];
|
|
80
|
+
}
|
|
81
|
+
const endMenuWatch = t4;
|
|
82
|
+
let t5;
|
|
83
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
84
|
+
t5 = () => {
|
|
45
85
|
cancelPending();
|
|
86
|
+
endMenuWatch();
|
|
46
87
|
open.current = false;
|
|
47
88
|
setPeeking(false);
|
|
48
89
|
setTile(null);
|
|
49
90
|
};
|
|
50
|
-
$[
|
|
91
|
+
$[4] = t5;
|
|
51
92
|
} else {
|
|
52
|
-
|
|
93
|
+
t5 = $[4];
|
|
53
94
|
}
|
|
54
|
-
const reset =
|
|
55
|
-
let
|
|
56
|
-
if ($[
|
|
57
|
-
|
|
95
|
+
const reset = t5;
|
|
96
|
+
let t6;
|
|
97
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
98
|
+
t6 = () => {
|
|
58
99
|
cancelPending();
|
|
59
100
|
open.current = true;
|
|
60
101
|
setPeeking(true);
|
|
61
102
|
};
|
|
62
|
-
$[
|
|
103
|
+
$[5] = t6;
|
|
63
104
|
} else {
|
|
64
|
-
|
|
105
|
+
t6 = $[5];
|
|
65
106
|
}
|
|
66
|
-
const hold =
|
|
67
|
-
let
|
|
68
|
-
if ($[
|
|
69
|
-
|
|
107
|
+
const hold = t6;
|
|
108
|
+
let t7;
|
|
109
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
110
|
+
t7 = aside => aside.querySelector(OPEN_MENU_TRIGGER) !== null || contextMenu.current && openPortalMenu(aside);
|
|
111
|
+
$[6] = t7;
|
|
112
|
+
} else {
|
|
113
|
+
t7 = $[6];
|
|
114
|
+
}
|
|
115
|
+
const menuHeld = t7;
|
|
116
|
+
let t8;
|
|
117
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
118
|
+
t8 = () => {
|
|
119
|
+
noPanelTile.current = tileRef.current;
|
|
120
|
+
reset();
|
|
121
|
+
};
|
|
122
|
+
$[7] = t8;
|
|
123
|
+
} else {
|
|
124
|
+
t8 = $[7];
|
|
125
|
+
}
|
|
126
|
+
const closeWithoutPanel = t8;
|
|
127
|
+
let scheduleClose;
|
|
128
|
+
let watchMenu;
|
|
129
|
+
if ($[8] !== menuCloseDelay) {
|
|
130
|
+
scheduleClose = (aside_0, t9) => {
|
|
131
|
+
const delayMs = t9 === undefined ? CLOSE_DELAY_MS : t9;
|
|
70
132
|
cancelPending();
|
|
71
|
-
if (open.current) {
|
|
133
|
+
if (!open.current) {
|
|
72
134
|
return;
|
|
73
135
|
}
|
|
74
136
|
timer.current = window.setTimeout(() => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (panel && !panel.hasAttribute("data-sidebar-floating")) {
|
|
79
|
-
dockPopIn(panel, tileRef.current, "left");
|
|
137
|
+
if (menuHeld(aside_0)) {
|
|
138
|
+
watchMenu(aside_0, true);
|
|
139
|
+
return;
|
|
80
140
|
}
|
|
141
|
+
const panel = aside_0.querySelector(PANEL_SELECTOR);
|
|
142
|
+
if (!panel) {
|
|
143
|
+
reset();
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const card = panel.querySelector("[data-sidebar-card]") ?? panel;
|
|
147
|
+
const arrow = panel.querySelector("[data-dock-arrow]");
|
|
148
|
+
dockPopOut(card, tileRef.current, "left", reset, arrow);
|
|
81
149
|
}, delayMs);
|
|
82
150
|
};
|
|
83
|
-
|
|
151
|
+
watchMenu = (aside_1, alreadyOpen) => {
|
|
152
|
+
if (stopWatch.current) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
let seenOpen = alreadyOpen;
|
|
156
|
+
let pointerInside = aside_1.matches(":hover");
|
|
157
|
+
const enter = () => {
|
|
158
|
+
pointerInside = true;
|
|
159
|
+
};
|
|
160
|
+
const leave = () => {
|
|
161
|
+
pointerInside = false;
|
|
162
|
+
};
|
|
163
|
+
const observer = new MutationObserver(() => {
|
|
164
|
+
if (!aside_1.isConnected) {
|
|
165
|
+
return endMenuWatch();
|
|
166
|
+
}
|
|
167
|
+
if (menuHeld(aside_1)) {
|
|
168
|
+
seenOpen = true;
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (!seenOpen) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
endMenuWatch();
|
|
175
|
+
if (!pointerInside) {
|
|
176
|
+
scheduleClose(aside_1, menuCloseDelay);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
observer.observe(document.body, {
|
|
180
|
+
childList: true,
|
|
181
|
+
subtree: true,
|
|
182
|
+
attributes: true,
|
|
183
|
+
attributeFilter: ["aria-expanded", "data-state"]
|
|
184
|
+
});
|
|
185
|
+
aside_1.addEventListener("pointerenter", enter);
|
|
186
|
+
aside_1.addEventListener("pointerleave", leave);
|
|
187
|
+
stopWatch.current = () => {
|
|
188
|
+
observer.disconnect();
|
|
189
|
+
aside_1.removeEventListener("pointerenter", enter);
|
|
190
|
+
aside_1.removeEventListener("pointerleave", leave);
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
$[8] = menuCloseDelay;
|
|
194
|
+
$[9] = scheduleClose;
|
|
195
|
+
$[10] = watchMenu;
|
|
84
196
|
} else {
|
|
85
|
-
|
|
197
|
+
scheduleClose = $[9];
|
|
198
|
+
watchMenu = $[10];
|
|
86
199
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
t4 = aside_0 => {
|
|
200
|
+
let t9;
|
|
201
|
+
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
202
|
+
const scheduleOpen = (aside_2, delayMs_0) => {
|
|
91
203
|
cancelPending();
|
|
92
|
-
if (
|
|
204
|
+
if (open.current) {
|
|
93
205
|
return;
|
|
94
206
|
}
|
|
95
207
|
timer.current = window.setTimeout(() => {
|
|
96
|
-
|
|
97
|
-
|
|
208
|
+
open.current = true;
|
|
209
|
+
flushSync(() => setPeeking(true));
|
|
210
|
+
const panel_0 = aside_2.querySelector(PANEL_SELECTOR);
|
|
211
|
+
if (!panel_0) {
|
|
212
|
+
return closeWithoutPanel();
|
|
98
213
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}, CLOSE_DELAY_MS);
|
|
214
|
+
if (!panel_0.hasAttribute("data-sidebar-floating")) {
|
|
215
|
+
dockPopIn(panel_0, tileRef.current, "left");
|
|
216
|
+
}
|
|
217
|
+
}, delayMs_0);
|
|
104
218
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
112
|
-
t5 = (aside_1, next, delayMs_0) => {
|
|
219
|
+
t9 = (aside_3, next, delayMs_1) => {
|
|
220
|
+
if (next === noPanelTile.current && !open.current) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
noPanelTile.current = null;
|
|
224
|
+
const changed = next !== tileRef.current;
|
|
113
225
|
tileRef.current = next;
|
|
226
|
+
if (open.current && changed) {
|
|
227
|
+
cancelPending();
|
|
228
|
+
flushSync(() => setTile(next));
|
|
229
|
+
if (!aside_3.querySelector(PANEL_SELECTOR)) {
|
|
230
|
+
closeWithoutPanel();
|
|
231
|
+
}
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
114
234
|
setTile(next);
|
|
115
|
-
scheduleOpen(
|
|
235
|
+
scheduleOpen(aside_3, delayMs_1);
|
|
116
236
|
};
|
|
117
|
-
$[
|
|
237
|
+
$[11] = t9;
|
|
118
238
|
} else {
|
|
119
|
-
|
|
239
|
+
t9 = $[11];
|
|
120
240
|
}
|
|
121
|
-
const onTile =
|
|
122
|
-
let
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
241
|
+
const onTile = t9;
|
|
242
|
+
let t10;
|
|
243
|
+
let t11;
|
|
244
|
+
if ($[12] !== scheduleClose) {
|
|
245
|
+
t10 = event => {
|
|
246
|
+
const aside_4 = event.currentTarget;
|
|
247
|
+
const next_0 = peekTile(event.target);
|
|
248
|
+
if (next_0) {
|
|
249
|
+
return onTile(aside_4, next_0, OPEN_DELAY_MS);
|
|
250
|
+
}
|
|
251
|
+
noPanelTile.current = null;
|
|
252
|
+
if (inPanel(event.target) || inPortal(aside_4, event.target)) {
|
|
253
|
+
cancelPending();
|
|
254
|
+
} else {
|
|
255
|
+
scheduleClose(aside_4);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
t11 = event_0 => {
|
|
259
|
+
noPanelTile.current = null;
|
|
260
|
+
scheduleClose(event_0.currentTarget);
|
|
261
|
+
};
|
|
262
|
+
$[12] = scheduleClose;
|
|
263
|
+
$[13] = t10;
|
|
264
|
+
$[14] = t11;
|
|
265
|
+
} else {
|
|
266
|
+
t10 = $[13];
|
|
267
|
+
t11 = $[14];
|
|
268
|
+
}
|
|
269
|
+
let t12;
|
|
270
|
+
if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
|
|
271
|
+
t12 = event_1 => {
|
|
272
|
+
const aside_5 = event_1.currentTarget;
|
|
273
|
+
const next_1 = peekTile(event_1.target);
|
|
274
|
+
if (next_1) {
|
|
275
|
+
onTile(aside_5, next_1, 0);
|
|
276
|
+
} else {
|
|
277
|
+
if (inPanel(event_1.target) || inPortal(aside_5, event_1.target)) {
|
|
278
|
+
cancelPending();
|
|
151
279
|
}
|
|
152
280
|
}
|
|
153
281
|
};
|
|
154
|
-
$[
|
|
282
|
+
$[15] = t12;
|
|
283
|
+
} else {
|
|
284
|
+
t12 = $[15];
|
|
285
|
+
}
|
|
286
|
+
let t13;
|
|
287
|
+
if ($[16] !== scheduleClose) {
|
|
288
|
+
t13 = event_2 => {
|
|
289
|
+
const aside_6 = event_2.currentTarget;
|
|
290
|
+
const to = event_2.relatedTarget;
|
|
291
|
+
if (peekTile(to) !== null || inPanel(to) || inPortalMenu(aside_6, to)) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
scheduleClose(aside_6);
|
|
295
|
+
};
|
|
296
|
+
$[16] = scheduleClose;
|
|
297
|
+
$[17] = t13;
|
|
155
298
|
} else {
|
|
156
|
-
|
|
299
|
+
t13 = $[17];
|
|
157
300
|
}
|
|
158
|
-
|
|
301
|
+
let t14;
|
|
302
|
+
if ($[18] !== watchMenu) {
|
|
303
|
+
t14 = event_3 => {
|
|
304
|
+
if (!open.current) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
cancelPending();
|
|
308
|
+
contextMenu.current = true;
|
|
309
|
+
watchMenu(event_3.currentTarget, false);
|
|
310
|
+
};
|
|
311
|
+
$[18] = watchMenu;
|
|
312
|
+
$[19] = t14;
|
|
313
|
+
} else {
|
|
314
|
+
t14 = $[19];
|
|
315
|
+
}
|
|
316
|
+
let t15;
|
|
317
|
+
if ($[20] !== t10 || $[21] !== t11 || $[22] !== t13 || $[23] !== t14) {
|
|
318
|
+
t15 = {
|
|
319
|
+
onPointerOver: t10,
|
|
320
|
+
onPointerLeave: t11,
|
|
321
|
+
onFocus: t12,
|
|
322
|
+
onBlur: t13,
|
|
323
|
+
onContextMenu: t14
|
|
324
|
+
};
|
|
325
|
+
$[20] = t10;
|
|
326
|
+
$[21] = t11;
|
|
327
|
+
$[22] = t13;
|
|
328
|
+
$[23] = t14;
|
|
329
|
+
$[24] = t15;
|
|
330
|
+
} else {
|
|
331
|
+
t15 = $[24];
|
|
332
|
+
}
|
|
333
|
+
const handlers = t15;
|
|
159
334
|
const previewPath = peeking && tile instanceof HTMLAnchorElement ? tile.pathname : null;
|
|
160
335
|
const previewValue = peeking && tile ? tile.dataset.railPeek || null : null;
|
|
161
|
-
let
|
|
162
|
-
if ($[
|
|
163
|
-
|
|
336
|
+
let t16;
|
|
337
|
+
if ($[25] !== handlers || $[26] !== peeking || $[27] !== previewPath || $[28] !== previewValue || $[29] !== tile) {
|
|
338
|
+
t16 = {
|
|
164
339
|
peeking,
|
|
165
340
|
previewPath,
|
|
166
341
|
previewValue,
|
|
@@ -169,13 +344,14 @@ export function useSidebarPeek() {
|
|
|
169
344
|
reset,
|
|
170
345
|
hold
|
|
171
346
|
};
|
|
172
|
-
$[
|
|
173
|
-
$[
|
|
174
|
-
$[
|
|
175
|
-
$[
|
|
176
|
-
$[
|
|
347
|
+
$[25] = handlers;
|
|
348
|
+
$[26] = peeking;
|
|
349
|
+
$[27] = previewPath;
|
|
350
|
+
$[28] = previewValue;
|
|
351
|
+
$[29] = tile;
|
|
352
|
+
$[30] = t16;
|
|
177
353
|
} else {
|
|
178
|
-
|
|
354
|
+
t16 = $[30];
|
|
179
355
|
}
|
|
180
|
-
return
|
|
356
|
+
return t16;
|
|
181
357
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import { memo } from "react";
|
|
3
3
|
import { cjk } from "@streamdown/cjk";
|
|
4
|
-
import { code } from "@streamdown/code";
|
|
5
|
-
import { math } from "@streamdown/math";
|
|
6
4
|
import { Streamdown, defaultRehypePlugins, defaultRemarkPlugins } from "streamdown";
|
|
7
5
|
import { useCn } from "../ui/ui-config.js";
|
|
8
6
|
import { parseMarkdownIntoBlocksIncremental } from "./incrementalBlocks.js";
|
|
@@ -10,18 +8,25 @@ import { MarkdownBlockquote } from "./MarkdownBlockquote.js";
|
|
|
10
8
|
import { MarkdownPre } from "./MarkdownCodeBlock.js";
|
|
11
9
|
import { MarkdownInlineCode } from "./MarkdownInlineCode.js";
|
|
12
10
|
import { MarkdownLink } from "./MarkdownLink.js";
|
|
11
|
+
import { useMathPlugin } from "./lazyMath.js";
|
|
13
12
|
import { mermaidPlugin } from "./mermaid.js";
|
|
14
13
|
import { copyMarkdownSelection } from "./markdownClipboard.js";
|
|
15
14
|
import { rehypeGithubAlerts } from "./rehypeGithubAlerts.js";
|
|
16
|
-
import "katex/dist/katex.min.css";
|
|
17
15
|
import { useSmoothText } from "./useSmoothText.js";
|
|
18
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
17
|
const PLUGINS = {
|
|
20
18
|
cjk,
|
|
21
|
-
code,
|
|
22
|
-
math,
|
|
23
19
|
mermaid: mermaidPlugin
|
|
24
20
|
};
|
|
21
|
+
let pluginsWithMath = null;
|
|
22
|
+
function pluginsFor(math) {
|
|
23
|
+
if (math === null) return PLUGINS;
|
|
24
|
+
pluginsWithMath ??= {
|
|
25
|
+
...PLUGINS,
|
|
26
|
+
math
|
|
27
|
+
};
|
|
28
|
+
return pluginsWithMath;
|
|
29
|
+
}
|
|
25
30
|
const REMARK_PLUGINS = Object.values(defaultRemarkPlugins);
|
|
26
31
|
const REHYPE_PLUGINS = [...Object.values(defaultRehypePlugins), rehypeGithubAlerts];
|
|
27
32
|
const MARKDOWN_COMPONENTS = {
|
|
@@ -55,7 +60,7 @@ const MARKDOWN_COMPONENTS = {
|
|
|
55
60
|
* (mention chips, line breaks).
|
|
56
61
|
*/
|
|
57
62
|
export const Markdown = /*#__PURE__*/memo(function Markdown(t0) {
|
|
58
|
-
const $ = _c(
|
|
63
|
+
const $ = _c(23);
|
|
59
64
|
let children;
|
|
60
65
|
let className;
|
|
61
66
|
let components;
|
|
@@ -89,6 +94,7 @@ export const Markdown = /*#__PURE__*/memo(function Markdown(t0) {
|
|
|
89
94
|
const smooth = t1 === undefined ? true : t1;
|
|
90
95
|
const merge = useCn();
|
|
91
96
|
const text = useSmoothText(children, smooth && props.mode === "streaming");
|
|
97
|
+
const math = useMathPlugin(text);
|
|
92
98
|
let t2;
|
|
93
99
|
if ($[7] !== className || $[8] !== merge) {
|
|
94
100
|
t2 = merge("markdown", className);
|
|
@@ -99,48 +105,57 @@ export const Markdown = /*#__PURE__*/memo(function Markdown(t0) {
|
|
|
99
105
|
t2 = $[9];
|
|
100
106
|
}
|
|
101
107
|
let t3;
|
|
102
|
-
if ($[10] !==
|
|
103
|
-
t3 =
|
|
104
|
-
|
|
105
|
-
...components
|
|
106
|
-
} : MARKDOWN_COMPONENTS;
|
|
107
|
-
$[10] = components;
|
|
108
|
+
if ($[10] !== math) {
|
|
109
|
+
t3 = pluginsFor(math);
|
|
110
|
+
$[10] = math;
|
|
108
111
|
$[11] = t3;
|
|
109
112
|
} else {
|
|
110
113
|
t3 = $[11];
|
|
111
114
|
}
|
|
112
115
|
let t4;
|
|
113
|
-
if ($[12] !==
|
|
114
|
-
t4 =
|
|
115
|
-
|
|
116
|
+
if ($[12] !== components) {
|
|
117
|
+
t4 = components ? {
|
|
118
|
+
...MARKDOWN_COMPONENTS,
|
|
119
|
+
...components
|
|
120
|
+
} : MARKDOWN_COMPONENTS;
|
|
121
|
+
$[12] = components;
|
|
116
122
|
$[13] = t4;
|
|
117
123
|
} else {
|
|
118
124
|
t4 = $[13];
|
|
119
125
|
}
|
|
120
126
|
let t5;
|
|
121
|
-
if ($[14] !==
|
|
122
|
-
t5 =
|
|
127
|
+
if ($[14] !== remarkPlugins) {
|
|
128
|
+
t5 = remarkPlugins ? [...REMARK_PLUGINS, ...remarkPlugins] : REMARK_PLUGINS;
|
|
129
|
+
$[14] = remarkPlugins;
|
|
130
|
+
$[15] = t5;
|
|
131
|
+
} else {
|
|
132
|
+
t5 = $[15];
|
|
133
|
+
}
|
|
134
|
+
let t6;
|
|
135
|
+
if ($[16] !== props || $[17] !== t2 || $[18] !== t3 || $[19] !== t4 || $[20] !== t5 || $[21] !== text) {
|
|
136
|
+
t6 = /*#__PURE__*/_jsx("div", {
|
|
123
137
|
className: "contents",
|
|
124
138
|
onCopy: copyMarkdownSelection,
|
|
125
139
|
children: /*#__PURE__*/_jsx(Streamdown, {
|
|
126
140
|
className: t2,
|
|
127
|
-
plugins:
|
|
128
|
-
components:
|
|
129
|
-
remarkPlugins:
|
|
141
|
+
plugins: t3,
|
|
142
|
+
components: t4,
|
|
143
|
+
remarkPlugins: t5,
|
|
130
144
|
rehypePlugins: REHYPE_PLUGINS,
|
|
131
145
|
parseMarkdownIntoBlocksFn: parseMarkdownIntoBlocksIncremental,
|
|
132
146
|
...props,
|
|
133
147
|
children: text
|
|
134
148
|
})
|
|
135
149
|
});
|
|
136
|
-
$[
|
|
137
|
-
$[
|
|
138
|
-
$[
|
|
139
|
-
$[
|
|
140
|
-
$[
|
|
141
|
-
$[
|
|
150
|
+
$[16] = props;
|
|
151
|
+
$[17] = t2;
|
|
152
|
+
$[18] = t3;
|
|
153
|
+
$[19] = t4;
|
|
154
|
+
$[20] = t5;
|
|
155
|
+
$[21] = text;
|
|
156
|
+
$[22] = t6;
|
|
142
157
|
} else {
|
|
143
|
-
|
|
158
|
+
t6 = $[22];
|
|
144
159
|
}
|
|
145
|
-
return
|
|
160
|
+
return t6;
|
|
146
161
|
});
|