svelte-streamdown 2.4.5 → 2.5.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/README.md +98 -4
- package/dist/Block.svelte +4 -4
- package/dist/Block.svelte.d.ts +0 -1
- package/dist/Elements/Alert.svelte +4 -1
- package/dist/Elements/Alert.svelte.d.ts +1 -0
- package/dist/Elements/Citation.svelte +260 -0
- package/dist/Elements/Citation.svelte.d.ts +7 -0
- package/dist/Elements/Code.svelte +13 -41
- package/dist/Elements/Code.svelte.d.ts +1 -0
- package/dist/Elements/Element.svelte +65 -33
- package/dist/Elements/FootnoteRef.svelte +41 -89
- package/dist/Elements/Image.svelte +5 -1
- package/dist/Elements/Image.svelte.d.ts +1 -0
- package/dist/Elements/Link.svelte +5 -1
- package/dist/Elements/Link.svelte.d.ts +1 -0
- package/dist/Elements/Math.svelte +10 -2
- package/dist/Elements/Math.svelte.d.ts +1 -0
- package/dist/Elements/Mermaid.svelte +87 -175
- package/dist/Elements/Mermaid.svelte.d.ts +1 -0
- package/dist/Elements/TableDownload.svelte +216 -0
- package/dist/Elements/TableDownload.svelte.d.ts +8 -0
- package/dist/Elements/icons.d.ts +9 -0
- package/dist/Elements/icons.js +175 -0
- package/dist/Elements/popover.svelte.d.ts +8 -0
- package/dist/Elements/popover.svelte.js +40 -0
- package/dist/Elements/stepperState.svelte.d.ts +35 -0
- package/dist/Elements/stepperState.svelte.js +98 -0
- package/dist/Streamdown.svelte +13 -4
- package/dist/Streamdown.svelte.d.ts +23 -2
- package/dist/context.svelte.d.ts +28 -11
- package/dist/context.svelte.js +14 -6
- package/dist/marked/index.d.ts +4 -2
- package/dist/marked/index.js +4 -2
- package/dist/marked/marked-align.d.ts +10 -0
- package/dist/marked/marked-align.js +36 -0
- package/dist/marked/marked-citations.d.ts +8 -0
- package/dist/marked/marked-citations.js +49 -0
- package/dist/marked/marked-table.js +36 -13
- package/dist/theme.d.ts +66 -21
- package/dist/theme.js +47 -17
- package/dist/utils/get.d.ts +1 -0
- package/dist/utils/get.js +25 -0
- package/dist/utils/panzoom.svelte.d.ts +1 -2
- package/dist/utils/panzoom.svelte.js +87 -43
- package/dist/utils/parse-incomplete-markdown.js +70 -1
- package/package.json +1 -1
|
@@ -10,11 +10,14 @@
|
|
|
10
10
|
import Slot from './Slot.svelte';
|
|
11
11
|
import { useStreamdown } from '../context.svelte.js';
|
|
12
12
|
import FootnoteRef from './FootnoteRef.svelte';
|
|
13
|
+
import Citation from './Citation.svelte';
|
|
14
|
+
import TableDownload from './TableDownload.svelte';
|
|
13
15
|
let { token, children }: { token: StreamdownToken; children: Snippet } = $props();
|
|
14
16
|
const streamdown = useStreamdown();
|
|
15
17
|
|
|
16
18
|
// Only apply animation on block level elements. Leaves text elements to be animated by their text children.
|
|
17
19
|
const style = $derived(streamdown.isMounted ? streamdown.animationBlockStyle : '');
|
|
20
|
+
const id = $props.id();
|
|
18
21
|
</script>
|
|
19
22
|
|
|
20
23
|
{#if token.type === 'heading'}
|
|
@@ -26,67 +29,71 @@
|
|
|
26
29
|
render={streamdown.snippets.heading}
|
|
27
30
|
>
|
|
28
31
|
{#if token.depth === 1}
|
|
29
|
-
<h1 {style} class={streamdown.theme[`h${token.depth}`].base}>
|
|
32
|
+
<h1 data-streamdown-heading-1={id} {style} class={streamdown.theme[`h${token.depth}`].base}>
|
|
30
33
|
{@render children()}
|
|
31
34
|
</h1>
|
|
32
35
|
{:else if token.depth === 2}
|
|
33
|
-
<h2 {style} class={streamdown.theme[`h${token.depth}`].base}>
|
|
36
|
+
<h2 data-streamdown-heading-2={id} {style} class={streamdown.theme[`h${token.depth}`].base}>
|
|
34
37
|
{@render children()}
|
|
35
38
|
</h2>
|
|
36
39
|
{:else if token.depth === 3}
|
|
37
|
-
<h3 {style} class={streamdown.theme[`h${token.depth}`].base}>
|
|
40
|
+
<h3 data-streamdown-heading-3={id} {style} class={streamdown.theme[`h${token.depth}`].base}>
|
|
38
41
|
{@render children()}
|
|
39
42
|
</h3>
|
|
40
43
|
{:else if token.depth === 4}
|
|
41
|
-
<h4 {style} class={streamdown.theme[`h${token.depth}`].base}>
|
|
44
|
+
<h4 data-streamdown-heading-4={id} {style} class={streamdown.theme[`h${token.depth}`].base}>
|
|
42
45
|
{@render children()}
|
|
43
46
|
</h4>
|
|
44
47
|
{:else if token.depth === 5}
|
|
45
|
-
<h5 {style} class={streamdown.theme[`h${token.depth}`].base}>
|
|
48
|
+
<h5 data-streamdown-heading-5={id} {style} class={streamdown.theme[`h${token.depth}`].base}>
|
|
46
49
|
{@render children()}
|
|
47
50
|
</h5>
|
|
48
51
|
{:else if token.depth === 6}
|
|
49
|
-
<h6 {style} class={streamdown.theme[`h${token.depth}`].base}>
|
|
52
|
+
<h6 data-streamdown-heading-6={id} {style} class={streamdown.theme[`h${token.depth}`].base}>
|
|
50
53
|
{@render children()}
|
|
51
54
|
</h6>
|
|
52
55
|
{/if}
|
|
53
56
|
</Slot>
|
|
54
57
|
{:else if token.type === 'paragraph'}
|
|
55
58
|
<Slot props={{ children, token }} render={streamdown.snippets.paragraph}>
|
|
56
|
-
<p {style} class={streamdown.theme.paragraph.base}>
|
|
59
|
+
<p data-streamdown-paragraph={id} {style} class={streamdown.theme.paragraph.base}>
|
|
57
60
|
{@render children()}
|
|
58
61
|
</p>
|
|
59
62
|
</Slot>
|
|
60
63
|
{:else if token.type === 'blockquote'}
|
|
61
64
|
<Slot props={{ children, token }} render={streamdown.snippets.blockquote}>
|
|
62
|
-
<blockquote {style} class={streamdown.theme.blockquote.base}>
|
|
65
|
+
<blockquote data-streamdown-blockquote={id} {style} class={streamdown.theme.blockquote.base}>
|
|
63
66
|
{@render children()}
|
|
64
67
|
</blockquote>
|
|
65
68
|
</Slot>
|
|
66
69
|
{:else if token.type === 'code' && token.lang === 'mermaid'}
|
|
67
70
|
<Slot props={{ children, token }} render={streamdown.snippets.code}>
|
|
68
|
-
<Mermaid {token} />
|
|
71
|
+
<Mermaid {id} {token} />
|
|
69
72
|
</Slot>
|
|
70
73
|
{:else if token.type === 'code'}
|
|
71
74
|
<Slot props={{ children, token }} render={streamdown.snippets.code}>
|
|
72
|
-
<Code {token} />
|
|
75
|
+
<Code {id} {token} />
|
|
73
76
|
</Slot>
|
|
74
77
|
{:else if token.type === 'codespan'}
|
|
75
78
|
<Slot props={{ children, token }} render={streamdown.snippets.codespan}>
|
|
76
|
-
<code class={streamdown.theme.codespan.base}>
|
|
79
|
+
<code data-streamdown-codespan={id} class={streamdown.theme.codespan.base}>
|
|
77
80
|
{@render children()}
|
|
78
81
|
</code>
|
|
79
82
|
</Slot>
|
|
80
83
|
{:else if token.type === 'list'}
|
|
81
84
|
{#if token.ordered}
|
|
82
85
|
<Slot props={{ children, token }} render={streamdown.snippets.ol}>
|
|
83
|
-
<ol
|
|
86
|
+
<ol
|
|
87
|
+
data-streamdown-ol={id}
|
|
88
|
+
style:list-style-type={token.listType}
|
|
89
|
+
class={streamdown.theme.ol.base}
|
|
90
|
+
>
|
|
84
91
|
{@render children()}
|
|
85
92
|
</ol>
|
|
86
93
|
</Slot>
|
|
87
94
|
{:else}
|
|
88
95
|
<Slot props={{ children, token }} render={streamdown.snippets.ul}>
|
|
89
|
-
<ul class={streamdown.theme.ul.base}>
|
|
96
|
+
<ul data-streamdown-ul={id} class={streamdown.theme.ul.base}>
|
|
90
97
|
{@render children()}
|
|
91
98
|
</ul>
|
|
92
99
|
</Slot>
|
|
@@ -94,6 +101,7 @@
|
|
|
94
101
|
{:else if token.type === 'list_item'}
|
|
95
102
|
<Slot props={{ children, token }} render={streamdown.snippets.li}>
|
|
96
103
|
<li
|
|
104
|
+
data-streamdown-li={id}
|
|
97
105
|
{style}
|
|
98
106
|
style:list-style-type={token.task ? 'none' : undefined}
|
|
99
107
|
{...token.value && !token.task ? { value: token.value } : {}}
|
|
@@ -112,7 +120,15 @@
|
|
|
112
120
|
</Slot>
|
|
113
121
|
{:else if token.type === 'table'}
|
|
114
122
|
<Slot props={{ token, children }} render={streamdown.snippets.table}>
|
|
115
|
-
|
|
123
|
+
{#if streamdown.controls.table}
|
|
124
|
+
<TableDownload {id} {token} />
|
|
125
|
+
{/if}
|
|
126
|
+
<div
|
|
127
|
+
data-streamdown-table={id}
|
|
128
|
+
{style}
|
|
129
|
+
class={`${streamdown.theme.table.base} group`}
|
|
130
|
+
style:overscroll-behavior-x="none"
|
|
131
|
+
>
|
|
116
132
|
<table class={streamdown.theme.table.table}>
|
|
117
133
|
{@render children()}
|
|
118
134
|
</table>
|
|
@@ -120,25 +136,25 @@
|
|
|
120
136
|
</Slot>
|
|
121
137
|
{:else if token.type === 'thead'}
|
|
122
138
|
<Slot props={{ token, children }} render={streamdown.snippets.thead}>
|
|
123
|
-
<thead {style} class={streamdown.theme.thead.base}>
|
|
139
|
+
<thead data-streamdown-thead={id} {style} class={streamdown.theme.thead.base}>
|
|
124
140
|
{@render children?.()}
|
|
125
141
|
</thead>
|
|
126
142
|
</Slot>
|
|
127
143
|
{:else if token.type === 'tbody'}
|
|
128
144
|
<Slot props={{ token, children }} render={streamdown.snippets.tbody}>
|
|
129
|
-
<tbody {style} class={streamdown.theme.tbody.base}>
|
|
145
|
+
<tbody data-streamdown-tbody={id} {style} class={streamdown.theme.tbody.base}>
|
|
130
146
|
{@render children?.()}
|
|
131
147
|
</tbody>
|
|
132
148
|
</Slot>
|
|
133
149
|
{:else if token.type === 'tfoot'}
|
|
134
150
|
<Slot props={{ token, children }} render={streamdown.snippets.tfoot}>
|
|
135
|
-
<tfoot {style} class={streamdown.theme.tfoot.base}>
|
|
151
|
+
<tfoot data-streamdown-tfoot={id} {style} class={streamdown.theme.tfoot.base}>
|
|
136
152
|
{@render children?.()}
|
|
137
153
|
</tfoot>
|
|
138
154
|
</Slot>
|
|
139
155
|
{:else if token.type === 'tr'}
|
|
140
156
|
<Slot props={{ token, children }} render={streamdown.snippets.tr}>
|
|
141
|
-
<tr {style} class={streamdown.theme.tr.base}>
|
|
157
|
+
<tr data-streamdown-tr={id} {style} class={streamdown.theme.tr.base}>
|
|
142
158
|
{@render children?.()}
|
|
143
159
|
</tr>
|
|
144
160
|
</Slot>
|
|
@@ -147,6 +163,7 @@
|
|
|
147
163
|
<Slot props={{ children, token }} render={streamdown.snippets.td}>
|
|
148
164
|
<td
|
|
149
165
|
{style}
|
|
166
|
+
data-streamdown-td={id}
|
|
150
167
|
class={streamdown.theme.td.base}
|
|
151
168
|
{...token.colspan > 1 ? { colspan: token.colspan } : {}}
|
|
152
169
|
{...token.rowspan > 1 ? { rowspan: token.rowspan } : {}}
|
|
@@ -163,6 +180,7 @@
|
|
|
163
180
|
<Slot props={{ children, token }} render={streamdown.snippets.th}>
|
|
164
181
|
<th
|
|
165
182
|
{style}
|
|
183
|
+
data-streamdown-th={id}
|
|
166
184
|
class={streamdown.theme.th.base}
|
|
167
185
|
{...token.colspan > 1 ? { colspan: token.colspan } : {}}
|
|
168
186
|
{...token.rowspan > 1 ? { rowspan: token.rowspan } : {}}
|
|
@@ -175,45 +193,45 @@
|
|
|
175
193
|
</Slot>
|
|
176
194
|
{/if}
|
|
177
195
|
{:else if token.type === 'image'}
|
|
178
|
-
<Image {token} {children} />
|
|
196
|
+
<Image {id} {token} {children} />
|
|
179
197
|
{:else if token.type === 'link'}
|
|
180
|
-
<Link {token} {children} />
|
|
198
|
+
<Link {id} {token} {children} />
|
|
181
199
|
{:else if token.type === 'sub'}
|
|
182
200
|
<Slot props={{ children, token }} render={streamdown.snippets.sub}>
|
|
183
|
-
<sub class={streamdown.theme.sub.base}>
|
|
201
|
+
<sub data-streamdown-sub={id} class={streamdown.theme.sub.base}>
|
|
184
202
|
{@render children()}
|
|
185
203
|
</sub>
|
|
186
204
|
</Slot>
|
|
187
205
|
{:else if token.type === 'sup'}
|
|
188
206
|
<Slot props={{ children, token }} render={streamdown.snippets.sup}>
|
|
189
|
-
<sup class={streamdown.theme.sup.base}>
|
|
207
|
+
<sup data-streamdown-sup={id} class={streamdown.theme.sup.base}>
|
|
190
208
|
{@render children()}
|
|
191
209
|
</sup>
|
|
192
210
|
</Slot>
|
|
193
211
|
{:else if token.type === 'strong'}
|
|
194
212
|
<Slot props={{ children, token }} render={streamdown.snippets.strong}>
|
|
195
|
-
<strong class={streamdown.theme.strong.base}>
|
|
213
|
+
<strong data-streamdown-strong={id} class={streamdown.theme.strong.base}>
|
|
196
214
|
{@render children()}
|
|
197
215
|
</strong>
|
|
198
216
|
</Slot>
|
|
199
217
|
{:else if token.type === 'em'}
|
|
200
218
|
<Slot props={{ children, token }} render={streamdown.snippets.em}>
|
|
201
|
-
<em class={streamdown.theme.em.base}>
|
|
219
|
+
<em data-streamdown-em={id} class={streamdown.theme.em.base}>
|
|
202
220
|
{@render children()}
|
|
203
221
|
</em>
|
|
204
222
|
</Slot>
|
|
205
223
|
{:else if token.type === 'del'}
|
|
206
224
|
<Slot props={{ children, token }} render={streamdown.snippets.del}>
|
|
207
|
-
<del class={streamdown.theme.del.base}>
|
|
225
|
+
<del data-streamdown-del={id} class={streamdown.theme.del.base}>
|
|
208
226
|
{@render children()}
|
|
209
227
|
</del>
|
|
210
228
|
</Slot>
|
|
211
229
|
{:else if token.type === 'hr'}
|
|
212
230
|
<Slot props={{ children, token }} render={streamdown.snippets.hr}>
|
|
213
|
-
<hr {style} class={streamdown.theme.hr.base} />
|
|
231
|
+
<hr data-streamdown-hr={id} {style} class={streamdown.theme.hr.base} />
|
|
214
232
|
</Slot>
|
|
215
233
|
{:else if token.type === 'br'}
|
|
216
|
-
<br />
|
|
234
|
+
<br data-streamdown-br={id} />
|
|
217
235
|
{:else if token.type === 'math'}
|
|
218
236
|
<Slot
|
|
219
237
|
props={{
|
|
@@ -222,17 +240,27 @@
|
|
|
222
240
|
}}
|
|
223
241
|
render={streamdown.snippets.math}
|
|
224
242
|
>
|
|
225
|
-
<Math {token} />
|
|
243
|
+
<Math {id} {token} />
|
|
226
244
|
</Slot>
|
|
227
245
|
{:else if token.type === 'alert'}
|
|
228
|
-
<Alert {token} {children} />
|
|
246
|
+
<Alert {id} {token} {children} />
|
|
229
247
|
{:else if token.type === 'footnoteRef'}
|
|
230
|
-
<
|
|
248
|
+
<Slot props={{ token }} render={streamdown.snippets.footnoteRef}>
|
|
249
|
+
<FootnoteRef {token} />
|
|
250
|
+
</Slot>
|
|
251
|
+
{:else if token.type === 'inline-citations'}
|
|
252
|
+
<Slot props={{ token }} render={streamdown.snippets.inlineCitation}>
|
|
253
|
+
<Citation {token} />
|
|
254
|
+
</Slot>
|
|
231
255
|
{:else if token.type === 'footnote'}
|
|
232
256
|
<!-- TODO Footnotes are rendered inside the FootnoteRef popover -->
|
|
233
257
|
{:else if token.type === 'descriptionList'}
|
|
234
258
|
<Slot props={{ children, token }} render={streamdown.snippets.descriptionList}>
|
|
235
|
-
<dl
|
|
259
|
+
<dl
|
|
260
|
+
data-streamdown-description-list={id}
|
|
261
|
+
style={streamdown.animationBlockStyle}
|
|
262
|
+
class={streamdown.theme.descriptionList.base}
|
|
263
|
+
>
|
|
236
264
|
{@render children()}
|
|
237
265
|
</dl>
|
|
238
266
|
</Slot>
|
|
@@ -242,13 +270,17 @@
|
|
|
242
270
|
</Slot>
|
|
243
271
|
{:else if token.type === 'descriptionTerm'}
|
|
244
272
|
<Slot props={{ children, token }} render={streamdown.snippets.descriptionTerm}>
|
|
245
|
-
<dt {style} class={streamdown.theme.descriptionTerm.base}>
|
|
273
|
+
<dt data-streamdown-description-term={id} {style} class={streamdown.theme.descriptionTerm.base}>
|
|
246
274
|
{@render children()}
|
|
247
275
|
</dt>
|
|
248
276
|
</Slot>
|
|
249
277
|
{:else if token.type === 'descriptionDetail'}
|
|
250
278
|
<Slot props={{ children, token }} render={streamdown.snippets.descriptionDetail}>
|
|
251
|
-
<dd
|
|
279
|
+
<dd
|
|
280
|
+
data-streamdown-description-detail={id}
|
|
281
|
+
{style}
|
|
282
|
+
class={streamdown.theme.descriptionDetail.base}
|
|
283
|
+
>
|
|
252
284
|
{@render children()}
|
|
253
285
|
</dd>
|
|
254
286
|
</Slot>
|
|
@@ -2,18 +2,12 @@
|
|
|
2
2
|
import { useStreamdown } from '../context.svelte.js';
|
|
3
3
|
import Slot from './Slot.svelte';
|
|
4
4
|
import type { FootnoteRef } from '../marked/marked-footnotes.js';
|
|
5
|
-
|
|
6
|
-
autoPlacement,
|
|
7
|
-
computePosition,
|
|
8
|
-
autoUpdate,
|
|
9
|
-
hide,
|
|
10
|
-
offset,
|
|
11
|
-
shift
|
|
12
|
-
} from '@floating-ui/dom';
|
|
5
|
+
|
|
13
6
|
import { useClickOutside } from '../utils/useClickOutside.svelte.js';
|
|
14
7
|
import { scale } from 'svelte/transition';
|
|
15
8
|
import Block from '../Block.svelte';
|
|
16
9
|
import { useKeyDown } from '../utils/useKeyDown.svelte.js';
|
|
10
|
+
import { Popover } from './popover.svelte.js';
|
|
17
11
|
|
|
18
12
|
const streamdown = useStreamdown();
|
|
19
13
|
|
|
@@ -24,106 +18,64 @@
|
|
|
24
18
|
} = $props();
|
|
25
19
|
|
|
26
20
|
const id = $props.id();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
let reference = $state<HTMLButtonElement>();
|
|
30
|
-
let content = $state<HTMLDialogElement>();
|
|
21
|
+
const popover = new Popover();
|
|
31
22
|
|
|
32
|
-
|
|
23
|
+
useKeyDown({
|
|
24
|
+
keys: ['Escape'],
|
|
33
25
|
get isActive() {
|
|
34
|
-
return isOpen;
|
|
26
|
+
return popover.isOpen;
|
|
35
27
|
},
|
|
36
28
|
callback: () => {
|
|
37
|
-
isOpen = false;
|
|
29
|
+
popover.isOpen = false;
|
|
38
30
|
}
|
|
39
31
|
});
|
|
40
|
-
|
|
41
|
-
useKeyDown({
|
|
42
|
-
keys: ['Escape'],
|
|
32
|
+
const clickOutside = useClickOutside({
|
|
43
33
|
get isActive() {
|
|
44
|
-
return isOpen;
|
|
34
|
+
return popover.isOpen;
|
|
45
35
|
},
|
|
46
36
|
callback: () => {
|
|
47
|
-
isOpen = false;
|
|
37
|
+
popover.isOpen = false;
|
|
48
38
|
}
|
|
49
39
|
});
|
|
50
|
-
|
|
51
|
-
const place = async (node: HTMLElement) => {
|
|
52
|
-
const middleware = [
|
|
53
|
-
hide(),
|
|
54
|
-
offset(0),
|
|
55
|
-
shift({
|
|
56
|
-
mainAxis: true
|
|
57
|
-
}),
|
|
58
|
-
autoPlacement({
|
|
59
|
-
allowedPlacements: ['top', 'top-end', 'top-start', 'bottom', 'bottom-end', 'bottom-start']
|
|
60
|
-
})
|
|
61
|
-
];
|
|
62
|
-
const { x, y, strategy, placement, middlewareData } = await computePosition(reference!, node, {
|
|
63
|
-
strategy: 'fixed',
|
|
64
|
-
middleware
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
Object.assign(node.style, {
|
|
68
|
-
position: strategy,
|
|
69
|
-
left: `${x}px`,
|
|
70
|
-
top: `${y}px`
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const popoverAttachment = (node: HTMLDialogElement) => {
|
|
75
|
-
content = node;
|
|
76
|
-
void place(node);
|
|
77
|
-
const off = autoUpdate(reference!, node, () => place(node));
|
|
78
|
-
return () => {
|
|
79
|
-
off();
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
40
|
</script>
|
|
83
41
|
|
|
84
|
-
{#if isOpen}
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}}
|
|
90
|
-
|
|
42
|
+
{#if popover.isOpen}
|
|
43
|
+
<dialog
|
|
44
|
+
data-streamdown-footnote-popover={id}
|
|
45
|
+
id={'footnote-popover-' + id}
|
|
46
|
+
aria-modal="false"
|
|
47
|
+
transition:scale|global={{ start: 0.95, duration: 100 }}
|
|
48
|
+
{@attach clickOutside.attachment}
|
|
49
|
+
{@attach popover.popoverAttachment}
|
|
50
|
+
open
|
|
51
|
+
class={`${streamdown.theme.components.popover}`}
|
|
91
52
|
>
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
{
|
|
98
|
-
{@attach popoverAttachment}
|
|
99
|
-
open
|
|
100
|
-
class={`${streamdown.theme.footnotePopover.base}`}
|
|
53
|
+
<Slot
|
|
54
|
+
props={{
|
|
55
|
+
token,
|
|
56
|
+
isOpen: popover.isOpen
|
|
57
|
+
}}
|
|
58
|
+
render={streamdown.snippets.footnotePopover}
|
|
101
59
|
>
|
|
102
60
|
{#each token.content.lines as line}
|
|
103
|
-
<Block
|
|
61
|
+
<Block block={line} />
|
|
104
62
|
{/each}
|
|
105
|
-
</
|
|
106
|
-
</
|
|
63
|
+
</Slot>
|
|
64
|
+
</dialog>
|
|
107
65
|
{/if}
|
|
108
66
|
|
|
109
67
|
{#if token.label !== 'streamdown:footnote'}
|
|
110
|
-
<
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
68
|
+
<button
|
|
69
|
+
data-streamdown-footnote-ref={id}
|
|
70
|
+
style={streamdown.animationBlockStyle}
|
|
71
|
+
bind:this={popover.reference}
|
|
72
|
+
class={streamdown.theme.footnoteRef.base}
|
|
73
|
+
onclick={() => (popover.isOpen = !popover.isOpen)}
|
|
74
|
+
aria-expanded={popover.isOpen}
|
|
75
|
+
aria-haspopup="dialog"
|
|
76
|
+
aria-controls={'footnote-popover-' + id}
|
|
77
|
+
{@attach clickOutside.attachment}
|
|
115
78
|
>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
bind:this={reference}
|
|
119
|
-
class={streamdown.theme.footnoteRef.base}
|
|
120
|
-
onclick={() => (isOpen = !isOpen)}
|
|
121
|
-
aria-expanded={isOpen}
|
|
122
|
-
aria-haspopup="dialog"
|
|
123
|
-
aria-controls={'footnote-popover-' + id}
|
|
124
|
-
{@attach clickOutside.attachment}
|
|
125
|
-
>
|
|
126
|
-
{token.label.replace('^', '')}
|
|
127
|
-
</button>
|
|
128
|
-
</Slot>
|
|
79
|
+
{token.label.replace('^', '')}
|
|
80
|
+
</button>
|
|
129
81
|
{/if}
|
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
|
|
10
10
|
const {
|
|
11
11
|
children,
|
|
12
|
-
token
|
|
12
|
+
token,
|
|
13
|
+
id
|
|
13
14
|
}: {
|
|
14
15
|
children: Snippet;
|
|
15
16
|
token: Tokens.Image;
|
|
17
|
+
id: string;
|
|
16
18
|
} = $props();
|
|
17
19
|
|
|
18
20
|
const transformedUrl = $derived(
|
|
@@ -32,6 +34,7 @@
|
|
|
32
34
|
render={streamdown.snippets.image}
|
|
33
35
|
>
|
|
34
36
|
<span
|
|
37
|
+
data-streamdown-image={id}
|
|
35
38
|
style={streamdown.isMounted ? streamdown.animationBlockStyle : ''}
|
|
36
39
|
class={streamdown.theme.image.base}
|
|
37
40
|
>
|
|
@@ -40,6 +43,7 @@
|
|
|
40
43
|
</Slot>
|
|
41
44
|
{:else}
|
|
42
45
|
<span
|
|
46
|
+
data-streamdown-image-blocked={id}
|
|
43
47
|
class="inline-block rounded bg-gray-200 px-3 py-1 text-sm text-gray-600 dark:bg-gray-700 dark:text-gray-400"
|
|
44
48
|
title={`Blocked URL: ${token.href}`}
|
|
45
49
|
>
|
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
|
|
10
10
|
const {
|
|
11
11
|
children,
|
|
12
|
-
token
|
|
12
|
+
token,
|
|
13
|
+
id
|
|
13
14
|
}: {
|
|
14
15
|
children: Snippet;
|
|
15
16
|
token: Tokens.Link;
|
|
17
|
+
id: string;
|
|
16
18
|
} = $props();
|
|
17
19
|
|
|
18
20
|
const transformedUrl = $derived(
|
|
@@ -33,6 +35,7 @@
|
|
|
33
35
|
render={streamdown.snippets.link}
|
|
34
36
|
>
|
|
35
37
|
<a
|
|
38
|
+
data-streamdown-link={id}
|
|
36
39
|
class={streamdown.theme.link.base}
|
|
37
40
|
href={transformedUrl}
|
|
38
41
|
target="_blank"
|
|
@@ -43,6 +46,7 @@
|
|
|
43
46
|
</Slot>
|
|
44
47
|
{:else}
|
|
45
48
|
<span
|
|
49
|
+
data-streamdown-link-blocked={id}
|
|
46
50
|
class={streamdown.theme.link.blocked}
|
|
47
51
|
title={token.title ? `Blocked URL: ${token.href}` : undefined}
|
|
48
52
|
>
|
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
import 'katex/dist/katex.min.css';
|
|
7
7
|
|
|
8
8
|
const {
|
|
9
|
-
token
|
|
9
|
+
token,
|
|
10
|
+
id
|
|
10
11
|
}: {
|
|
11
12
|
token: MathToken;
|
|
13
|
+
id: string;
|
|
12
14
|
} = $props();
|
|
13
15
|
|
|
14
16
|
const streamdown = useStreamdown();
|
|
@@ -46,6 +48,7 @@
|
|
|
46
48
|
|
|
47
49
|
{#if token.isInline}
|
|
48
50
|
<span
|
|
51
|
+
data-streamdown-inline-math={id}
|
|
49
52
|
style={streamdown.isMounted ? streamdown.animationBlockStyle : ''}
|
|
50
53
|
bind:this={inner}
|
|
51
54
|
class={streamdown.theme.math.inline}
|
|
@@ -53,7 +56,12 @@
|
|
|
53
56
|
{@html html}
|
|
54
57
|
</span>
|
|
55
58
|
{:else}
|
|
56
|
-
<div
|
|
59
|
+
<div
|
|
60
|
+
data-streamdown-block-math={id}
|
|
61
|
+
style={streamdown.isMounted ? streamdown.animationBlockStyle : ''}
|
|
62
|
+
style:height="fit-content"
|
|
63
|
+
style:width="100%"
|
|
64
|
+
>
|
|
57
65
|
<div class="overflow-x-auto">
|
|
58
66
|
<div bind:this={inner} class={streamdown.theme.math.block}>
|
|
59
67
|
{@html html}
|
|
@@ -2,6 +2,7 @@ import type { MathToken } from '../marked/index.js';
|
|
|
2
2
|
import 'katex/dist/katex.min.css';
|
|
3
3
|
type $$ComponentProps = {
|
|
4
4
|
token: MathToken;
|
|
5
|
+
id: string;
|
|
5
6
|
};
|
|
6
7
|
declare const Math: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
8
|
type Math = ReturnType<typeof Math>;
|