svelte-streamdown 2.5.0 → 2.5.2

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.
@@ -5,13 +5,16 @@
5
5
  import type { MermaidConfig } from 'mermaid';
6
6
  import { on } from 'svelte/events';
7
7
  import { usePanzoom } from '../utils/panzoom.svelte';
8
+ import { fitViewIcon, fullscreenIcon, zoomInIcon, zoomOutIcon } from './icons.js';
8
9
 
9
10
  const streamdown = useStreamdown();
10
11
 
11
12
  const {
12
- token
13
+ token,
14
+ id
13
15
  }: {
14
16
  token: Tokens.Code;
17
+ id: string;
15
18
  } = $props();
16
19
 
17
20
  let mermaid = $state<any>(null);
@@ -154,6 +157,7 @@
154
157
  const renderMermaid = async (code: string, element: HTMLElement) => {
155
158
  try {
156
159
  // Sanitize the code first
160
+ const sanitizedCode = sanitizeMermaidCode(code);
157
161
 
158
162
  // Default configuration
159
163
  const defaultConfig: MermaidConfig = {
@@ -172,8 +176,7 @@
172
176
  };
173
177
 
174
178
  // Initialize mermaid with merged config
175
- const mergedConfig = { ...defaultConfig };
176
- mermaid.initialize(mergedConfig);
179
+ mermaid.initialize(defaultConfig);
177
180
 
178
181
  const chartHash = code.split('').reduce((acc, char) => {
179
182
  return ((acc << 5) - acc + char.charCodeAt(0)) | 0;
@@ -182,25 +185,33 @@
182
185
  const uniqueId = `mermaid-${Math.abs(chartHash)}-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
183
186
 
184
187
  // Render the diagram
185
- const { svg: svgString } = await mermaid.render(uniqueId, sanitizeMermaidCode(code));
186
- const svg = new DOMParser().parseFromString(svgString, 'image/svg+xml').documentElement;
187
-
188
- const svgTarget = element.querySelector('[data-mermaid-svg]')!;
189
- svg.id = uniqueId;
190
- Array.from(svg.attributes).forEach((attribute) => {
191
- svgTarget.setAttribute(attribute.name, attribute.value);
192
- });
193
- svgTarget.innerHTML = svg.innerHTML;
194
-
195
- panzoom.zoomToFit();
196
- panzoom.zoomToFit();
188
+ const { svg: svgString } = await mermaid.render(uniqueId, sanitizedCode);
189
+
190
+ // Insert the SVG into the target element
191
+ const svgTarget = element.querySelector('[data-mermaid-svg]') as SVGElement;
192
+ if (svgTarget) {
193
+ svgTarget.innerHTML = svgString;
194
+ svgTarget.id = uniqueId;
195
+
196
+ // Apply any additional attributes from the rendered SVG
197
+ const tempSvg = new DOMParser().parseFromString(svgString, 'image/svg+xml').documentElement;
198
+ Array.from(tempSvg.attributes).forEach((attribute) => {
199
+ if (attribute.name !== 'id') {
200
+ svgTarget.setAttribute(attribute.name, attribute.value);
201
+ }
202
+ });
203
+
204
+ panzoom.zoomToFit();
205
+ panzoom.zoomToFit();
206
+ }
197
207
  } catch (err) {
198
- const sanitizedCode = sanitizeMermaidCode(code);
208
+ console.warn('Mermaid rendering error:', err);
209
+ // Could show error state in UI here
199
210
  }
200
211
  };
201
212
  </script>
202
213
 
203
- <div>
214
+ <div data-streamdown-mermaid={id}>
204
215
  {#if mermaid}
205
216
  <div
206
217
  style={streamdown.isMounted ? streamdown.animationBlockStyle : ''}
@@ -251,79 +262,6 @@
251
262
  <div class={streamdown.theme.mermaid.base}></div>
252
263
  {/if}
253
264
  </div>
254
- {#snippet zoomInIcon()}
255
- <svg
256
- class={streamdown.theme.mermaid.icon}
257
- xmlns="http://www.w3.org/2000/svg"
258
- width="100%"
259
- height="100%"
260
- viewBox="0 0 24 24"
261
- fill="none"
262
- stroke="currentColor"
263
- stroke-width="2"
264
- stroke-linecap="round"
265
- stroke-linejoin="round"
266
- >
267
- <circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" />
268
- <line x1="11" x2="11" y1="8" y2="14" />
269
- <line x1="8" x2="14" y1="11" y2="11" />
270
- </svg>
271
- {/snippet}
272
-
273
- {#snippet zoomOutIcon()}
274
- <svg
275
- class={streamdown.theme.mermaid.icon}
276
- xmlns="http://www.w3.org/2000/svg"
277
- width="100%"
278
- height="100%"
279
- viewBox="0 0 24 24"
280
- fill="none"
281
- stroke="currentColor"
282
- stroke-width="2"
283
- stroke-linecap="round"
284
- stroke-linejoin="round"
285
- >
286
- <circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line
287
- x1="8"
288
- x2="14"
289
- y1="11"
290
- y2="11"
291
- />
292
- </svg>
293
- {/snippet}
294
-
295
- {#snippet fitViewIcon()}
296
- <svg
297
- class={streamdown.theme.mermaid.icon}
298
- xmlns="http://www.w3.org/2000/svg"
299
- viewBox="0 0 24 24"
300
- fill="none"
301
- stroke="currentColor"
302
- stroke-width="2"
303
- stroke-linecap="round"
304
- stroke-linejoin="round"
305
- >
306
- <path d="M3 7V5a2 2 0 0 1 2-2h2" />
307
- <path d="M17 3h2a2 2 0 0 1 2 2v2" /><path d="M21 17v2a2 2 0 0 1-2 2h-2" />
308
- <path d="M7 21H5a2 2 0 0 1-2-2v-2" /><rect width="10" height="8" x="7" y="8" rx="1" />
309
- </svg>
310
- {/snippet}
311
-
312
- {#snippet fullscreenIcon()}
313
- <svg
314
- class={streamdown.theme.mermaid.icon}
315
- xmlns="http://www.w3.org/2000/svg"
316
- viewBox="0 0 24 24"
317
- fill="none"
318
- stroke="currentColor"
319
- stroke-width="2"
320
- stroke-linecap="round"
321
- stroke-linejoin="round"
322
- >
323
- <path d="m15 15 6 6" /><path d="m15 9 6-6" /><path d="M21 16v5h-5" /><path d="M21 8V3h-5" />
324
- <path d="M3 16v5h5" /><path d="m3 21 6-6" /><path d="M3 8V3h5" /><path d="M9 9 3 3" />
325
- </svg>
326
- {/snippet}
327
265
 
328
266
  <style>
329
267
  :global([data-expanded='true']) {
@@ -335,4 +273,13 @@
335
273
  z-index: 2147483647;
336
274
  margin: 0px;
337
275
  }
276
+
277
+ /* Hide Mermaid's temporary rendering containers */
278
+ :global(div[id^='dmermaid-']) {
279
+ position: absolute !important;
280
+ left: -9999px !important;
281
+ top: -9999px !important;
282
+ visibility: hidden !important;
283
+ pointer-events: none !important;
284
+ }
338
285
  </style>
@@ -1,6 +1,7 @@
1
1
  import type { Tokens } from 'marked';
2
2
  type $$ComponentProps = {
3
3
  token: Tokens.Code;
4
+ id: string;
4
5
  };
5
6
  declare const Mermaid: import("svelte").Component<$$ComponentProps, {}, "">;
6
7
  type Mermaid = ReturnType<typeof Mermaid>;
@@ -0,0 +1,216 @@
1
+ <script lang="ts">
2
+ import { useStreamdown } from '../context.svelte.js';
3
+ import { scale } from 'svelte/transition';
4
+ import { checkIcon, copyIcon, downloadIcon } from './icons.js';
5
+ import { Popover } from './popover.svelte.js';
6
+ import { useClickOutside } from '../utils/useClickOutside.svelte.js';
7
+ import { useKeyDown } from '../utils/useKeyDown.svelte.js';
8
+ import type { TableToken } from '../marked/marked-table.js';
9
+ import { useCopy } from '../utils/copy.svelte.js';
10
+ import { save } from '../utils/save.js';
11
+
12
+ let {
13
+ token,
14
+ id
15
+ }: {
16
+ token: TableToken;
17
+ id: string;
18
+ } = $props();
19
+ const streamdown = useStreamdown();
20
+ const popover = new Popover();
21
+ let modeState = $state<'download' | 'copy'>('download');
22
+
23
+ useKeyDown({
24
+ keys: ['Escape'],
25
+ get isActive() {
26
+ return popover.isOpen;
27
+ },
28
+ callback: () => {
29
+ popover.isOpen = false;
30
+ }
31
+ });
32
+ const clickOutside = useClickOutside({
33
+ get isActive() {
34
+ return popover.isOpen;
35
+ },
36
+ callback: () => {
37
+ popover.isOpen = false;
38
+ }
39
+ });
40
+
41
+ let copyValue = $state(token.raw);
42
+
43
+ const copy = useCopy({
44
+ get content() {
45
+ return copyValue;
46
+ }
47
+ });
48
+
49
+ const copyOrDownload = (type: 'Markdown' | 'HTML' | 'CSV') => {
50
+ if (type === 'Markdown') {
51
+ copyValue = token.raw;
52
+ if (modeState === 'copy') {
53
+ copy.copy();
54
+ } else {
55
+ save('table.md', copyValue, 'text/markdown');
56
+ }
57
+ } else if (type === 'HTML') {
58
+ const table = document.querySelector(`[data-streamdown-table=${id}]`);
59
+
60
+ if (table) {
61
+ let html = (table.cloneNode(true) as HTMLElement).outerHTML;
62
+ // remove comments
63
+ html = html.replace(/<!--[\s\S]*?-->/g, '');
64
+ copyValue = html;
65
+ // Remove class and style attributes
66
+ html = html.replace(/class="[^"]*"/g, '');
67
+ html = html.replace(/style="[^"]*"/g, '');
68
+ // remove space between the tag name and the closing chrevron like <table > -> <table> for every tagnmae
69
+ html = html.replace(/<([^>]+)>\s+</g, '<$1><');
70
+ // Remove spaces before closing bracket >
71
+ html = html.replace(/\s+>/g, '>');
72
+ // Remove spaces after opening bracket <
73
+ html = html.replace(/<\s+/g, '<');
74
+ // Collapse multiple spaces within tags to single space
75
+ html = html.replace(/<([^>]+)>/g, (match) => match.replace(/\s+/g, ' '));
76
+
77
+ copyValue = html;
78
+
79
+ if (modeState === 'copy') {
80
+ copy.copy();
81
+ } else {
82
+ save('table.html', copyValue, 'text/html');
83
+ }
84
+ }
85
+ } else if (type === 'CSV') {
86
+ const table = document.querySelector(`[data-streamdown-table=${id}]`);
87
+
88
+ if (table) {
89
+ const rows = table.querySelectorAll('tr');
90
+ const rowSpanFills: Array<{ rowIndex: number; colIndex: number; colSpan: number }> = [];
91
+
92
+ const matrix = Array.from(rows).reduce((acc, row, rowIndex) => {
93
+ const cells = row.querySelectorAll('td, th');
94
+ const rowData: string[] = [];
95
+ let actualCol = 0; // Track actual column position in the output matrix
96
+
97
+ Array.from(cells).forEach((cell) => {
98
+ const colSpan = parseInt(cell.getAttribute('colspan') || '1');
99
+ const rowSpan = parseInt(cell.getAttribute('rowspan') || '1');
100
+
101
+ // Add the cell content
102
+ // Add the cell content, quoting if it contains commas, quotes, or newlines
103
+ const content = cell.textContent || '';
104
+ const needsQuoting = /[,"\n]/.test(content);
105
+ const escapedContent = content.replace(/"/g, '""');
106
+ rowData.push(needsQuoting ? `"${escapedContent}"` : content);
107
+
108
+ // Add empty cells for colspan
109
+ for (let i = 0; i < colSpan - 1; i++) {
110
+ rowData.push('');
111
+ }
112
+
113
+ // Track rowspan fills needed in future rows
114
+ if (rowSpan > 1) {
115
+ for (let r = 1; r < rowSpan; r++) {
116
+ rowSpanFills.push({
117
+ rowIndex: rowIndex + r,
118
+ colIndex: actualCol,
119
+ colSpan: colSpan
120
+ });
121
+ }
122
+ }
123
+
124
+ actualCol += colSpan;
125
+ });
126
+
127
+ acc.push(rowData);
128
+ return acc;
129
+ }, [] as string[][]);
130
+
131
+ // Process rowspan fills - insert empty cells at correct positions
132
+ rowSpanFills.forEach(({ rowIndex, colIndex, colSpan }) => {
133
+ if (matrix[rowIndex]) {
134
+ matrix[rowIndex].splice(colIndex, 0, ...Array(colSpan).fill(''));
135
+ }
136
+ });
137
+
138
+ const csv = matrix.map((row) => row.join(',')).join('\n');
139
+ copyValue = csv;
140
+ if (modeState === 'copy') {
141
+ copy.copy();
142
+ } else {
143
+ save('table.csv', copyValue, 'text/csv');
144
+ }
145
+ }
146
+ }
147
+ popover.isOpen = false;
148
+ };
149
+ </script>
150
+
151
+ {#if popover.isOpen}
152
+ <dialog
153
+ id={'table-download-popover'}
154
+ aria-modal="false"
155
+ transition:scale|global={{ start: 0.95, duration: 100 }}
156
+ {@attach clickOutside.attachment}
157
+ {@attach popover.popoverAttachment}
158
+ open
159
+ style:width="fit-content !important"
160
+ style:min-width="fit-content !important"
161
+ class={streamdown.theme.components.popover}
162
+ >
163
+ {#each ['Markdown', 'HTML', 'CSV'] as type}
164
+ <button
165
+ style="width: 100%; text-align: left; justify-content: flex-start; padding: 1rem 1rem; margin: 0.2rem 0;"
166
+ onclick={() => copyOrDownload(type as 'Markdown' | 'HTML' | 'CSV')}
167
+ class={streamdown.theme.components.button}
168
+ >
169
+ {type}
170
+ </button>
171
+ {/each}
172
+ </dialog>
173
+ {/if}
174
+
175
+ <div
176
+ data-streamdown-table-download
177
+ class=" right-0 ml-auto flex items-center justify-end gap-2 p-1"
178
+ >
179
+ {#each ['download', 'copy'] as mode (mode)}
180
+ <button
181
+ class={streamdown.theme.components.button}
182
+ onclick={async (e: MouseEvent) => {
183
+ if (modeState === mode && popover.isOpen) {
184
+ popover.isOpen = false;
185
+ return;
186
+ }
187
+ if (popover.isOpen && modeState !== mode) {
188
+ popover.isOpen = false;
189
+ const wait = new Promise((resolve) => {
190
+ setTimeout(resolve, 80);
191
+ });
192
+ await wait;
193
+ }
194
+ popover.reference = e.target as HTMLButtonElement;
195
+ popover.isOpen = true;
196
+ modeState = mode as 'download' | 'copy';
197
+ }}
198
+ {@attach clickOutside.attachment}
199
+ title={mode === 'download' ? 'Download table' : 'Copy table'}
200
+ >
201
+ {#if mode === 'download'}
202
+ {@render (streamdown.icons?.download || downloadIcon)()}
203
+ {:else if copy.isCopied}
204
+ {@render (streamdown.icons?.check || checkIcon)()}
205
+ {:else}
206
+ {@render (streamdown.icons?.copy || copyIcon)()}
207
+ {/if}
208
+ </button>
209
+ {/each}
210
+ </div>
211
+
212
+ <style>
213
+ :global([data-streamdown-table-download] + div) {
214
+ margin-top: 0px;
215
+ }
216
+ </style>
@@ -0,0 +1,8 @@
1
+ import type { TableToken } from '../marked/marked-table.js';
2
+ type $$ComponentProps = {
3
+ token: TableToken;
4
+ id: string;
5
+ };
6
+ declare const TableDownload: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type TableDownload = ReturnType<typeof TableDownload>;
8
+ export default TableDownload;
@@ -0,0 +1,9 @@
1
+ export declare const copyIcon: import("svelte").Snippet<[]>;
2
+ export declare const downloadIcon: import("svelte").Snippet<[]>;
3
+ export declare const checkIcon: import("svelte").Snippet<[]>;
4
+ export declare const zoomInIcon: import("svelte").Snippet<[]>;
5
+ export declare const zoomOutIcon: import("svelte").Snippet<[]>;
6
+ export declare const fitViewIcon: import("svelte").Snippet<[]>;
7
+ export declare const fullscreenIcon: import("svelte").Snippet<[]>;
8
+ export declare const chevronRight: import("svelte").Snippet<[]>;
9
+ export declare const chevronLeft: import("svelte").Snippet<[]>;
@@ -0,0 +1,175 @@
1
+ import { createRawSnippet } from 'svelte';
2
+ export const copyIcon = createRawSnippet(() => {
3
+ return {
4
+ render: () => {
5
+ return `
6
+ <svg
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ width="100%"
9
+ height="100%"
10
+ viewBox="0 0 24 24"
11
+ fill="none"
12
+ stroke="currentColor"
13
+ stroke-width="2"
14
+ stroke-linecap="round"
15
+ stroke-linejoin="round"
16
+ ><rect width="8" height="4" x="8" y="2" rx="1" ry="1" /><path
17
+ d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"
18
+ /></svg>
19
+ `;
20
+ }
21
+ };
22
+ });
23
+ export const downloadIcon = createRawSnippet(() => {
24
+ return {
25
+ render: () => {
26
+ return `<svg
27
+ xmlns="http://www.w3.org/2000/svg"
28
+ width="100%"
29
+ height="100%"
30
+ viewBox="0 0 24 24"
31
+ fill="none"
32
+ stroke="currentColor"
33
+ stroke-width="2"
34
+ stroke-linecap="round"
35
+ stroke-linejoin="round"
36
+ ><path d="M12 15V3" /><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /><path
37
+ d="m7 10 5 5 5-5"
38
+ /></svg
39
+ >`;
40
+ }
41
+ };
42
+ });
43
+ export const checkIcon = createRawSnippet(() => {
44
+ return {
45
+ render: () => {
46
+ return `
47
+ <svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"/></svg>
48
+ `;
49
+ }
50
+ };
51
+ });
52
+ export const zoomInIcon = createRawSnippet(() => {
53
+ return {
54
+ render: () => `
55
+ <svg
56
+ width="100%"
57
+ height="100%"
58
+ viewBox="0 0 24 24"
59
+ fill="none"
60
+ stroke="currentColor"
61
+ stroke-width="2"
62
+ stroke-linecap="round"
63
+ stroke-linejoin="round"
64
+ xmlns="http://www.w3.org/2000/svg"
65
+ >
66
+ <circle cx="11" cy="11" r="8" />
67
+ <line x1="21" x2="16.65" y1="21" y2="16.65" />
68
+ <line x1="11" x2="11" y1="8" y2="14" />
69
+ <line x1="8" x2="14" y1="11" y2="11" />
70
+ </svg>
71
+ `
72
+ };
73
+ });
74
+ export const zoomOutIcon = createRawSnippet(() => {
75
+ return {
76
+ render: () => `
77
+ <svg
78
+ width="100%"
79
+ height="100%"
80
+ viewBox="0 0 24 24"
81
+ fill="none"
82
+ stroke="currentColor"
83
+ stroke-width="2"
84
+ stroke-linecap="round"
85
+ stroke-linejoin="round"
86
+ xmlns="http://www.w3.org/2000/svg"
87
+ >
88
+ <circle cx="11" cy="11" r="8" />
89
+ <line x1="21" x2="16.65" y1="21" y2="16.65" />
90
+ <line x1="8" x2="14" y1="11" y2="11" />
91
+ </svg>
92
+ `
93
+ };
94
+ });
95
+ export const fitViewIcon = createRawSnippet(() => {
96
+ return {
97
+ render: () => `
98
+ <svg
99
+ width="100%"
100
+ height="100%"
101
+ viewBox="0 0 24 24"
102
+ fill="none"
103
+ stroke="currentColor"
104
+ stroke-width="2"
105
+ stroke-linecap="round"
106
+ stroke-linejoin="round"
107
+ xmlns="http://www.w3.org/2000/svg"
108
+ >
109
+ <path d="M3 7V5a2 2 0 0 1 2-2h2" />
110
+ <path d="M17 3h2a2 2 0 0 1 2 2v2" />
111
+ <path d="M21 17v2a2 2 0 0 1-2 2h-2" />
112
+ <path d="M7 21H5a2 2 0 0 1-2-2v-2" />
113
+ <rect width="10" height="8" x="7" y="8" rx="1" />
114
+ </svg>
115
+ `
116
+ };
117
+ });
118
+ export const fullscreenIcon = createRawSnippet(() => {
119
+ return {
120
+ render: () => `
121
+ <svg
122
+ width="100%"
123
+ height="100%"
124
+ viewBox="0 0 24 24"
125
+ fill="none"
126
+ stroke="currentColor"
127
+ stroke-width="2"
128
+ stroke-linecap="round"
129
+ stroke-linejoin="round"
130
+ xmlns="http://www.w3.org/2000/svg"
131
+ >
132
+ <path d="m15 15 6 6" /><path d="m15 9 6-6" /><path d="M21 16v5h-5" /><path d="M21 8V3h-5" />
133
+ <path d="M3 16v5h5" /><path d="m3 21 6-6" /><path d="M3 8V3h5" /><path d="M9 9 3 3" />
134
+ </svg>
135
+ `
136
+ };
137
+ });
138
+ export const chevronRight = createRawSnippet(() => {
139
+ return {
140
+ render: () => `
141
+ <svg
142
+ xmlns="http://www.w3.org/2000/svg"
143
+ width="100%"
144
+ height="100%"
145
+ viewBox="0 0 24 24"
146
+ fill="none"
147
+ stroke="currentColor"
148
+ stroke-width="2"
149
+ stroke-linecap="round"
150
+ stroke-linejoin="round"
151
+ >
152
+ <path d="m9 18 6-6-6-6" />
153
+ </svg>
154
+ `
155
+ };
156
+ });
157
+ export const chevronLeft = createRawSnippet(() => {
158
+ return {
159
+ render: () => `
160
+ <svg
161
+ xmlns="http://www.w3.org/2000/svg"
162
+ width="100%"
163
+ height="100%"
164
+ viewBox="0 0 24 24"
165
+ fill="none"
166
+ stroke="currentColor"
167
+ stroke-width="2"
168
+ stroke-linecap="round"
169
+ stroke-linejoin="round"
170
+ >
171
+ <path d="m15 18-6-6 6-6" />
172
+ </svg>
173
+ `
174
+ };
175
+ });
@@ -103,9 +103,11 @@
103
103
  get controls() {
104
104
  const codeControls = controls?.code ?? true;
105
105
  const mermaidControls = controls?.mermaid ?? true;
106
+ const tableControls = controls?.table ?? true;
106
107
  return {
107
108
  code: codeControls,
108
- mermaid: mermaidControls
109
+ mermaid: mermaidControls,
110
+ table: tableControls
109
111
  };
110
112
  },
111
113
  get children() {
@@ -10,6 +10,7 @@ export interface StreamdownContext extends Omit<StreamdownProps, keyof Snippets
10
10
  controls: {
11
11
  code: boolean;
12
12
  mermaid: boolean;
13
+ table: boolean;
13
14
  };
14
15
  inlineCitationsMode: 'list' | 'carousel';
15
16
  animation: {
@@ -117,6 +118,7 @@ export type StreamdownProps<Source extends Record<string, any> = Record<string,
117
118
  controls?: {
118
119
  code?: boolean;
119
120
  mermaid?: boolean;
121
+ table?: boolean;
120
122
  };
121
123
  renderHtml?: boolean | ((token: Tokens.HTML | Tokens.Tag) => string);
122
124
  animation?: {
@@ -141,6 +143,7 @@ export type StreamdownProps<Source extends Record<string, any> = Record<string,
141
143
  important?: Snippet;
142
144
  chevronLeft?: Snippet;
143
145
  chevronRight?: Snippet;
146
+ check?: Snippet;
144
147
  };
145
148
  extensions?: Extension[];
146
149
  children?: Snippet<[{
@@ -22,7 +22,7 @@ export type Extension = {
22
22
  start?: TokenizerStartFunction;
23
23
  applyInBlockParsing?: boolean;
24
24
  };
25
- export type StreamdownToken = Exclude<MarkedToken, Tokens.List | Tokens.ListItem> | ListToken | ListItemToken | MathToken | AlertToken | FootnoteToken | SubSupToken | BrToken | HrToken | TableToken | THead | TBody | TFoot | THeadRow | TRow | TH | TD | DescriptionListToken | DescriptionToken | DescriptionDetailToken | DescriptionTermToken | AlignToken | CitationToken;
25
+ export type StreamdownToken = Exclude<MarkedToken, Tokens.List | Tokens.ListItem | Tokens.Table> | ListToken | ListItemToken | MathToken | AlertToken | FootnoteToken | SubSupToken | BrToken | HrToken | TableToken | THead | TBody | TFoot | THeadRow | TRow | TH | TD | DescriptionListToken | DescriptionToken | DescriptionDetailToken | DescriptionTermToken | AlignToken | CitationToken;
26
26
  export type { TableToken, THead, TBody, TFoot, THeadRow, TRow, TH, TD } from './marked-table.js';
27
27
  export declare const lex: (markdown: string, extensions?: Extension[]) => StreamdownToken[];
28
28
  export declare const parseBlocks: (markdown: string, extensions?: Extension[]) => string[];
package/dist/theme.js CHANGED
@@ -104,7 +104,7 @@ export const theme = {
104
104
  mermaid: {
105
105
  base: 'group relative my-4 h-auto rounded-xl border border-gray-200 bg-white overflow-hidden items-center min-h-[500px]',
106
106
  icon: 'size-5',
107
- buttons: 'absolute right-1 top-1 z-10 flex h-fit w-fit items-center gap-1'
107
+ buttons: 'absolute right-1 top-1 flex h-fit w-fit items-center gap-1'
108
108
  },
109
109
  math: {
110
110
  block: '',
@@ -151,7 +151,7 @@ export const theme = {
151
151
  },
152
152
  components: {
153
153
  button: 'disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer p-1 text-gray-600 transition-all hover:text-gray-900 rounded hover:bg-gray-100 w-6 h-6',
154
- popover: 'fixed z-[1000] max-h-[30vh] max-w-3xl overflow-y-auto rounded-lg bg-white p-4 shadow'
154
+ popover: 'min-w-[250px] max-w-md fixed z-[1000] max-h-md overflow-y-auto rounded-lg bg-white p-4 shadow'
155
155
  }
156
156
  };
157
157
  export const shadcnTheme = {
@@ -257,7 +257,7 @@ export const shadcnTheme = {
257
257
  mermaid: {
258
258
  base: 'group relative my-4 h-auto rounded-lg border border-border bg-card overflow-hidden items-center min-h-[500px]',
259
259
  icon: 'size-5',
260
- buttons: 'absolute right-1 top-1 z-10 flex h-fit w-fit items-center gap-1'
260
+ buttons: 'absolute right-1 top-1 flex h-fit w-fit items-center gap-1'
261
261
  },
262
262
  math: {
263
263
  block: 'text-foreground',
@@ -304,7 +304,7 @@ export const shadcnTheme = {
304
304
  },
305
305
  components: {
306
306
  button: 'disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground rounded hover:bg-border flex items-center justify-center w-6 h-6',
307
- popover: 'fixed z-[1000] max-h-[30vh] max-w-3xl overflow-y-auto rounded-lg bg-popover border border-border p-2 shadow'
307
+ popover: 'min-w-[250px] max-w-md fixed z-[1000] max-h-md overflow-y-auto rounded-lg bg-popover border border-border p-2 shadow'
308
308
  }
309
309
  };
310
310
  export const mergeTheme = (customTheme, baseTheme) => {