svelte-streamdown 0.0.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 +58 -0
- package/dist/Block.svelte +34 -0
- package/dist/Block.svelte.d.ts +6 -0
- package/dist/Elements/A.svelte +48 -0
- package/dist/Elements/A.svelte.d.ts +4 -0
- package/dist/Elements/Alert.svelte +78 -0
- package/dist/Elements/Alert.svelte.d.ts +4 -0
- package/dist/Elements/Blockquote.svelte +26 -0
- package/dist/Elements/Blockquote.svelte.d.ts +4 -0
- package/dist/Elements/Code.svelte +123 -0
- package/dist/Elements/Code.svelte.d.ts +4 -0
- package/dist/Elements/Del.svelte +24 -0
- package/dist/Elements/Del.svelte.d.ts +4 -0
- package/dist/Elements/Element.svelte +122 -0
- package/dist/Elements/Element.svelte.d.ts +12 -0
- package/dist/Elements/Em.svelte +23 -0
- package/dist/Elements/Em.svelte.d.ts +4 -0
- package/dist/Elements/H1.svelte +23 -0
- package/dist/Elements/H1.svelte.d.ts +4 -0
- package/dist/Elements/H2.svelte +23 -0
- package/dist/Elements/H2.svelte.d.ts +4 -0
- package/dist/Elements/H3.svelte +23 -0
- package/dist/Elements/H3.svelte.d.ts +4 -0
- package/dist/Elements/H4.svelte +23 -0
- package/dist/Elements/H4.svelte.d.ts +4 -0
- package/dist/Elements/H5.svelte +23 -0
- package/dist/Elements/H5.svelte.d.ts +4 -0
- package/dist/Elements/H6.svelte +23 -0
- package/dist/Elements/H6.svelte.d.ts +4 -0
- package/dist/Elements/Hr.svelte +20 -0
- package/dist/Elements/Hr.svelte.d.ts +4 -0
- package/dist/Elements/Image.svelte +49 -0
- package/dist/Elements/Image.svelte.d.ts +4 -0
- package/dist/Elements/InlineCode.svelte +23 -0
- package/dist/Elements/InlineCode.svelte.d.ts +4 -0
- package/dist/Elements/Li.svelte +23 -0
- package/dist/Elements/Li.svelte.d.ts +4 -0
- package/dist/Elements/Math.svelte +73 -0
- package/dist/Elements/Math.svelte.d.ts +5 -0
- package/dist/Elements/Mermaid.svelte +80 -0
- package/dist/Elements/Mermaid.svelte.d.ts +4 -0
- package/dist/Elements/Ol.svelte +23 -0
- package/dist/Elements/Ol.svelte.d.ts +4 -0
- package/dist/Elements/P.svelte +23 -0
- package/dist/Elements/P.svelte.d.ts +4 -0
- package/dist/Elements/Slot.svelte +19 -0
- package/dist/Elements/Slot.svelte.d.ts +9 -0
- package/dist/Elements/Strong.svelte +23 -0
- package/dist/Elements/Strong.svelte.d.ts +4 -0
- package/dist/Elements/Sub.svelte +23 -0
- package/dist/Elements/Sub.svelte.d.ts +4 -0
- package/dist/Elements/Sup.svelte +23 -0
- package/dist/Elements/Sup.svelte.d.ts +4 -0
- package/dist/Elements/Table.svelte +25 -0
- package/dist/Elements/Table.svelte.d.ts +4 -0
- package/dist/Elements/Tbody.svelte +23 -0
- package/dist/Elements/Tbody.svelte.d.ts +4 -0
- package/dist/Elements/Td.svelte +23 -0
- package/dist/Elements/Td.svelte.d.ts +4 -0
- package/dist/Elements/Th.svelte +23 -0
- package/dist/Elements/Th.svelte.d.ts +4 -0
- package/dist/Elements/Thead.svelte +23 -0
- package/dist/Elements/Thead.svelte.d.ts +4 -0
- package/dist/Elements/Tr.svelte +23 -0
- package/dist/Elements/Tr.svelte.d.ts +4 -0
- package/dist/Elements/Ul.svelte +23 -0
- package/dist/Elements/Ul.svelte.d.ts +4 -0
- package/dist/Elements/element.d.ts +8 -0
- package/dist/Elements/element.js +1 -0
- package/dist/Elements/index.d.ts +34 -0
- package/dist/Elements/index.js +34 -0
- package/dist/Streamdown.d.ts +83 -0
- package/dist/Streamdown.js +1 -0
- package/dist/Streamdown.svelte +128 -0
- package/dist/Streamdown.svelte.d.ts +18 -0
- package/dist/hightlighter.svelte.d.ts +25 -0
- package/dist/hightlighter.svelte.js +413 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/theme.d.ts +247 -0
- package/dist/theme.js +138 -0
- package/dist/utils/alerts.d.ts +12 -0
- package/dist/utils/alerts.js +207 -0
- package/dist/utils/bind.d.ts +1 -0
- package/dist/utils/bind.js +6 -0
- package/dist/utils/copy.svelte.d.ts +7 -0
- package/dist/utils/copy.svelte.js +35 -0
- package/dist/utils/parse-blocks.d.ts +1 -0
- package/dist/utils/parse-blocks.js +40 -0
- package/dist/utils/parse-incomplete-markdown.d.ts +1 -0
- package/dist/utils/parse-incomplete-markdown.js +442 -0
- package/dist/utils/parse.d.ts +3 -0
- package/dist/utils/parse.js +144 -0
- package/dist/utils/save.d.ts +1 -0
- package/dist/utils/save.js +11 -0
- package/dist/utils/url.d.ts +2 -0
- package/dist/utils/url.js +71 -0
- package/package.json +92 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useStreamdown } from '../Streamdown.svelte';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import type { ElementProps } from './element.js';
|
|
5
|
+
import Slot from './Slot.svelte';
|
|
6
|
+
|
|
7
|
+
const streamdown = useStreamdown();
|
|
8
|
+
|
|
9
|
+
const { children, node, className, props }: ElementProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Slot
|
|
13
|
+
props={{
|
|
14
|
+
children,
|
|
15
|
+
node,
|
|
16
|
+
...props
|
|
17
|
+
}}
|
|
18
|
+
render={streamdown.snippets.h3}
|
|
19
|
+
>
|
|
20
|
+
<h3 {...props} class={clsx(streamdown.theme.h3.base, className)}>
|
|
21
|
+
{@render children()}
|
|
22
|
+
</h3>
|
|
23
|
+
</Slot>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useStreamdown } from '../Streamdown.svelte';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import type { ElementProps } from './element.js';
|
|
5
|
+
import Slot from './Slot.svelte';
|
|
6
|
+
|
|
7
|
+
const streamdown = useStreamdown();
|
|
8
|
+
|
|
9
|
+
const { children, node, className, props }: ElementProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Slot
|
|
13
|
+
props={{
|
|
14
|
+
children,
|
|
15
|
+
node,
|
|
16
|
+
...props
|
|
17
|
+
}}
|
|
18
|
+
render={streamdown.snippets.h4}
|
|
19
|
+
>
|
|
20
|
+
<h4 {...props} class={clsx(streamdown.theme.h4.base, className)}>
|
|
21
|
+
{@render children()}
|
|
22
|
+
</h4>
|
|
23
|
+
</Slot>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useStreamdown } from '../Streamdown.svelte';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import type { ElementProps } from './element.js';
|
|
5
|
+
import Slot from './Slot.svelte';
|
|
6
|
+
|
|
7
|
+
const streamdown = useStreamdown();
|
|
8
|
+
|
|
9
|
+
const { children, node, className, props }: ElementProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Slot
|
|
13
|
+
props={{
|
|
14
|
+
children,
|
|
15
|
+
node,
|
|
16
|
+
...props
|
|
17
|
+
}}
|
|
18
|
+
render={streamdown.snippets.h5}
|
|
19
|
+
>
|
|
20
|
+
<h5 {...props} class={clsx(streamdown.theme.h5.base, className)}>
|
|
21
|
+
{@render children()}
|
|
22
|
+
</h5>
|
|
23
|
+
</Slot>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useStreamdown } from '../Streamdown.svelte';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import type { ElementProps } from './element.js';
|
|
5
|
+
import Slot from './Slot.svelte';
|
|
6
|
+
|
|
7
|
+
const streamdown = useStreamdown();
|
|
8
|
+
|
|
9
|
+
const { children, node, className, props }: ElementProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Slot
|
|
13
|
+
props={{
|
|
14
|
+
children,
|
|
15
|
+
node,
|
|
16
|
+
...props
|
|
17
|
+
}}
|
|
18
|
+
render={streamdown.snippets.h6}
|
|
19
|
+
>
|
|
20
|
+
<h6 {...props} class={clsx(streamdown.theme.h6.base, className)}>
|
|
21
|
+
{@render children()}
|
|
22
|
+
</h6>
|
|
23
|
+
</Slot>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useStreamdown } from '../Streamdown.svelte';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import type { ElementProps } from './element.js';
|
|
5
|
+
import Slot from './Slot.svelte';
|
|
6
|
+
|
|
7
|
+
const streamdown = useStreamdown();
|
|
8
|
+
|
|
9
|
+
const { node, props, className }: ElementProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Slot
|
|
13
|
+
props={{
|
|
14
|
+
node,
|
|
15
|
+
...props
|
|
16
|
+
}}
|
|
17
|
+
render={streamdown.snippets.hr}
|
|
18
|
+
>
|
|
19
|
+
<hr {...props} class={clsx(streamdown.theme.hr.base, className)} />
|
|
20
|
+
</Slot>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useStreamdown } from '../Streamdown.svelte';
|
|
3
|
+
import { transformUrl } from '../utils/url.js';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
import type { ElementProps } from './element.js';
|
|
6
|
+
import Slot from './Slot.svelte';
|
|
7
|
+
|
|
8
|
+
const streamdown = useStreamdown();
|
|
9
|
+
|
|
10
|
+
const { children, node, className, props }: ElementProps = $props();
|
|
11
|
+
|
|
12
|
+
const src = $derived(node.properties.src);
|
|
13
|
+
const alt = $derived(node.properties.alt as string | undefined);
|
|
14
|
+
|
|
15
|
+
const transformedUrl = $derived(
|
|
16
|
+
transformUrl(src, streamdown.allowedImagePrefixes ?? [], streamdown.defaultOrigin)
|
|
17
|
+
);
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
{#if transformedUrl}
|
|
21
|
+
<Slot
|
|
22
|
+
props={{
|
|
23
|
+
src: transformedUrl,
|
|
24
|
+
alt,
|
|
25
|
+
children,
|
|
26
|
+
...props
|
|
27
|
+
}}
|
|
28
|
+
render={streamdown.snippets.img}
|
|
29
|
+
>
|
|
30
|
+
<div class={streamdown.theme.img.container}>
|
|
31
|
+
<img
|
|
32
|
+
src={transformedUrl}
|
|
33
|
+
{alt}
|
|
34
|
+
{...props}
|
|
35
|
+
class={clsx(streamdown.theme.img.base, className)}
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
</Slot>
|
|
39
|
+
{:else}
|
|
40
|
+
<span
|
|
41
|
+
class={clsx(
|
|
42
|
+
'inline-block rounded bg-gray-200 px-3 py-1 text-sm text-gray-600 dark:bg-gray-700 dark:text-gray-400',
|
|
43
|
+
className?.toString()
|
|
44
|
+
)}
|
|
45
|
+
title={`Blocked URL: ${src}`}
|
|
46
|
+
>
|
|
47
|
+
[Image blocked: {alt || 'No description'}]
|
|
48
|
+
</span>
|
|
49
|
+
{/if}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useStreamdown } from '../Streamdown.svelte';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import type { ElementProps } from './element.js';
|
|
5
|
+
import Slot from './Slot.svelte';
|
|
6
|
+
|
|
7
|
+
const streamdown = useStreamdown();
|
|
8
|
+
|
|
9
|
+
const { children, node, className, props }: ElementProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Slot
|
|
13
|
+
props={{
|
|
14
|
+
children,
|
|
15
|
+
node,
|
|
16
|
+
...props
|
|
17
|
+
}}
|
|
18
|
+
render={streamdown.snippets.inlineCode}
|
|
19
|
+
>
|
|
20
|
+
<code {...props} class={clsx(streamdown.theme.inlineCode.base, className)}>
|
|
21
|
+
{@render children()}
|
|
22
|
+
</code>
|
|
23
|
+
</Slot>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useStreamdown } from '../Streamdown.svelte';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import type { ElementProps } from './element.js';
|
|
5
|
+
import Slot from './Slot.svelte';
|
|
6
|
+
|
|
7
|
+
const streamdown = useStreamdown();
|
|
8
|
+
|
|
9
|
+
const { children, node, className, props }: ElementProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Slot
|
|
13
|
+
props={{
|
|
14
|
+
children,
|
|
15
|
+
node,
|
|
16
|
+
...props
|
|
17
|
+
}}
|
|
18
|
+
render={streamdown.snippets.li}
|
|
19
|
+
>
|
|
20
|
+
<li {...props} class={clsx(streamdown.theme.li.base, className)}>
|
|
21
|
+
{@render children()}
|
|
22
|
+
</li>
|
|
23
|
+
</Slot>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount, onDestroy } from 'svelte';
|
|
3
|
+
import { useStreamdown } from '../Streamdown.svelte';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
import type { ElementProps } from './element.js';
|
|
6
|
+
import Slot from './Slot.svelte';
|
|
7
|
+
import type { KatexOptions } from 'katex';
|
|
8
|
+
import 'katex/dist/katex.min.css';
|
|
9
|
+
const streamdown = useStreamdown();
|
|
10
|
+
const { children, node, className, props }: ElementProps = $props();
|
|
11
|
+
const code = $derived((node.children[0] as any).value as string);
|
|
12
|
+
const isInline = className?.includes('inline') ?? false;
|
|
13
|
+
let katex = $state<typeof import('katex').renderToString | null>(null);
|
|
14
|
+
onMount(async () => {
|
|
15
|
+
katex = (await import('katex')).renderToString;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const renderMath = async (code: string, element: HTMLElement) => {
|
|
19
|
+
console.log({ code, node });
|
|
20
|
+
|
|
21
|
+
if (!katex || !code) return;
|
|
22
|
+
try {
|
|
23
|
+
const customConfig =
|
|
24
|
+
typeof streamdown.katexConfig === 'function'
|
|
25
|
+
? streamdown.katexConfig(isInline)
|
|
26
|
+
: streamdown.katexConfig;
|
|
27
|
+
// Default configuration
|
|
28
|
+
const config: KatexOptions = {
|
|
29
|
+
output: 'html',
|
|
30
|
+
displayMode: !isInline,
|
|
31
|
+
...(customConfig || {})
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const html = katex(code, config);
|
|
35
|
+
element.innerHTML = html.toString();
|
|
36
|
+
} catch (err) {
|
|
37
|
+
// Do nothing
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<Slot
|
|
43
|
+
props={{
|
|
44
|
+
children,
|
|
45
|
+
node,
|
|
46
|
+
...props
|
|
47
|
+
}}
|
|
48
|
+
render={streamdown.snippets.math}
|
|
49
|
+
>
|
|
50
|
+
{#if katex}
|
|
51
|
+
{#if isInline}
|
|
52
|
+
<span
|
|
53
|
+
{...props}
|
|
54
|
+
class={clsx(streamdown.theme.math.base, className)}
|
|
55
|
+
{@attach (node) => renderMath(code, node)}
|
|
56
|
+
>
|
|
57
|
+
<!-- -->
|
|
58
|
+
</span>
|
|
59
|
+
{:else}
|
|
60
|
+
<div class="h-fit w-full">
|
|
61
|
+
<div class="overflow-x-auto">
|
|
62
|
+
<div
|
|
63
|
+
{...props}
|
|
64
|
+
class={clsx(streamdown.theme.math.base, className)}
|
|
65
|
+
{@attach (node) => renderMath(code, node)}
|
|
66
|
+
></div>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
{/if}
|
|
70
|
+
{:else}
|
|
71
|
+
<div {...props} class={clsx(streamdown.theme.math.base, className)}></div>
|
|
72
|
+
{/if}
|
|
73
|
+
</Slot>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount, onDestroy } from 'svelte';
|
|
3
|
+
import { useStreamdown } from '../Streamdown.svelte';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
import type { ElementProps } from './element.js';
|
|
6
|
+
import Slot from './Slot.svelte';
|
|
7
|
+
import type { MermaidConfig } from 'mermaid';
|
|
8
|
+
|
|
9
|
+
const streamdown = useStreamdown();
|
|
10
|
+
|
|
11
|
+
const { children, node, className, props }: ElementProps = $props();
|
|
12
|
+
|
|
13
|
+
const code = $derived((node.children[0] as any)?.value as string);
|
|
14
|
+
let mermaid = $state<any>(null);
|
|
15
|
+
onMount(async () => {
|
|
16
|
+
mermaid = (await import('mermaid')).default;
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const renderMermaid = async (code: string, element: HTMLElement) => {
|
|
20
|
+
try {
|
|
21
|
+
// Default configuration
|
|
22
|
+
const defaultConfig: MermaidConfig = {
|
|
23
|
+
theme: 'base',
|
|
24
|
+
startOnLoad: false,
|
|
25
|
+
securityLevel: 'strict',
|
|
26
|
+
fontFamily: 'monospace',
|
|
27
|
+
suppressErrorRendering: true,
|
|
28
|
+
flowchart: {
|
|
29
|
+
useMaxWidth: true,
|
|
30
|
+
htmlLabels: true,
|
|
31
|
+
curve: 'basis'
|
|
32
|
+
},
|
|
33
|
+
...(streamdown.mermaidConfig || {})
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Initialize mermaid with merged config
|
|
37
|
+
const mergedConfig = { ...defaultConfig };
|
|
38
|
+
mermaid.initialize(mergedConfig);
|
|
39
|
+
|
|
40
|
+
// Validate and render the diagram
|
|
41
|
+
const isValidDiagram = await mermaid.parse(code);
|
|
42
|
+
if (!isValidDiagram) {
|
|
43
|
+
throw new Error('Invalid mermaid diagram syntax');
|
|
44
|
+
}
|
|
45
|
+
// Use a stable ID based on chart content hash and timestamp to ensure uniqueness
|
|
46
|
+
const chartHash = code.split('').reduce((acc, char) => {
|
|
47
|
+
// biome-ignore lint/suspicious/noBitwiseOperators: "Required for Mermaid"
|
|
48
|
+
return ((acc << 5) - acc + char.charCodeAt(0)) | 0;
|
|
49
|
+
}, 0);
|
|
50
|
+
const uniqueId = `mermaid-${Math.abs(chartHash)}-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
51
|
+
|
|
52
|
+
// Render the diagram
|
|
53
|
+
const { svg } = await mermaid.render(uniqueId, code);
|
|
54
|
+
|
|
55
|
+
// Insert the SVG into the container
|
|
56
|
+
element.innerHTML = svg;
|
|
57
|
+
} catch (err) {
|
|
58
|
+
// Do nothing
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<Slot
|
|
64
|
+
props={{
|
|
65
|
+
children,
|
|
66
|
+
node,
|
|
67
|
+
...props
|
|
68
|
+
}}
|
|
69
|
+
render={streamdown.snippets.mermaid}
|
|
70
|
+
>
|
|
71
|
+
{#if mermaid}
|
|
72
|
+
<div
|
|
73
|
+
{...props}
|
|
74
|
+
class={clsx(streamdown.theme.mermaid.base, className)}
|
|
75
|
+
{@attach (node) => renderMermaid(code, node)}
|
|
76
|
+
></div>
|
|
77
|
+
{:else}
|
|
78
|
+
<div {...props} class={clsx(streamdown.theme.mermaid.base, className)}></div>
|
|
79
|
+
{/if}
|
|
80
|
+
</Slot>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useStreamdown } from '../Streamdown.svelte';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import type { ElementProps } from './element.js';
|
|
5
|
+
import Slot from './Slot.svelte';
|
|
6
|
+
|
|
7
|
+
const streamdown = useStreamdown();
|
|
8
|
+
|
|
9
|
+
const { children, node, className, props }: ElementProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Slot
|
|
13
|
+
props={{
|
|
14
|
+
children,
|
|
15
|
+
node,
|
|
16
|
+
...props
|
|
17
|
+
}}
|
|
18
|
+
render={streamdown.snippets.ol}
|
|
19
|
+
>
|
|
20
|
+
<ol {...props} class={clsx(streamdown.theme.ol.base, className)}>
|
|
21
|
+
{@render children()}
|
|
22
|
+
</ol>
|
|
23
|
+
</Slot>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useStreamdown } from '../Streamdown.svelte';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import type { ElementProps } from './element.js';
|
|
5
|
+
import Slot from './Slot.svelte';
|
|
6
|
+
|
|
7
|
+
const streamdown = useStreamdown();
|
|
8
|
+
|
|
9
|
+
const { children, node, className, props }: ElementProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Slot
|
|
13
|
+
props={{
|
|
14
|
+
children,
|
|
15
|
+
node,
|
|
16
|
+
...props
|
|
17
|
+
}}
|
|
18
|
+
render={streamdown.snippets.p}
|
|
19
|
+
>
|
|
20
|
+
<p {...props} class={clsx(streamdown.theme.p.base, className)}>
|
|
21
|
+
{@render children()}
|
|
22
|
+
</p>
|
|
23
|
+
</Slot>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
children,
|
|
6
|
+
render,
|
|
7
|
+
props
|
|
8
|
+
}: {
|
|
9
|
+
children: Snippet;
|
|
10
|
+
render?: Snippet<[any]>;
|
|
11
|
+
props: Record<string, any>;
|
|
12
|
+
} = $props();
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
{#if render}
|
|
16
|
+
{@render render(props)}
|
|
17
|
+
{:else}
|
|
18
|
+
{@render children()}
|
|
19
|
+
{/if}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
children: Snippet;
|
|
4
|
+
render?: Snippet<[any]>;
|
|
5
|
+
props: Record<string, any>;
|
|
6
|
+
};
|
|
7
|
+
declare const Slot: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
8
|
+
type Slot = ReturnType<typeof Slot>;
|
|
9
|
+
export default Slot;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useStreamdown } from '../Streamdown.svelte';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import type { ElementProps } from './element.js';
|
|
5
|
+
import Slot from './Slot.svelte';
|
|
6
|
+
|
|
7
|
+
const streamdown = useStreamdown();
|
|
8
|
+
|
|
9
|
+
const { children, node, className, props }: ElementProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Slot
|
|
13
|
+
props={{
|
|
14
|
+
children,
|
|
15
|
+
node,
|
|
16
|
+
...props
|
|
17
|
+
}}
|
|
18
|
+
render={streamdown.snippets.strong}
|
|
19
|
+
>
|
|
20
|
+
<strong {...props} class={clsx(streamdown.theme.strong.base, className)}>
|
|
21
|
+
{@render children()}
|
|
22
|
+
</strong>
|
|
23
|
+
</Slot>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useStreamdown } from '../Streamdown.svelte';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import type { ElementProps } from './element.js';
|
|
5
|
+
import Slot from './Slot.svelte';
|
|
6
|
+
|
|
7
|
+
const streamdown = useStreamdown();
|
|
8
|
+
|
|
9
|
+
const { children, node, className, props }: ElementProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Slot
|
|
13
|
+
props={{
|
|
14
|
+
children,
|
|
15
|
+
node,
|
|
16
|
+
...props
|
|
17
|
+
}}
|
|
18
|
+
render={streamdown.snippets.sub}
|
|
19
|
+
>
|
|
20
|
+
<sub {...props} class={clsx(streamdown.theme.sub.base, className)}>
|
|
21
|
+
{@render children()}
|
|
22
|
+
</sub>
|
|
23
|
+
</Slot>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useStreamdown } from '../Streamdown.svelte';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import type { ElementProps } from './element.js';
|
|
5
|
+
import Slot from './Slot.svelte';
|
|
6
|
+
|
|
7
|
+
const streamdown = useStreamdown();
|
|
8
|
+
|
|
9
|
+
const { children, node, className, props }: ElementProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Slot
|
|
13
|
+
props={{
|
|
14
|
+
children,
|
|
15
|
+
node,
|
|
16
|
+
...props
|
|
17
|
+
}}
|
|
18
|
+
render={streamdown.snippets.sup}
|
|
19
|
+
>
|
|
20
|
+
<sup {...props} class={clsx(streamdown.theme.sup.base, className)}>
|
|
21
|
+
{@render children()}
|
|
22
|
+
</sup>
|
|
23
|
+
</Slot>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useStreamdown } from '../Streamdown.svelte';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import type { ElementProps } from './element.js';
|
|
5
|
+
import Slot from './Slot.svelte';
|
|
6
|
+
|
|
7
|
+
const streamdown = useStreamdown();
|
|
8
|
+
|
|
9
|
+
const { children, node, className, props }: ElementProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Slot
|
|
13
|
+
props={{
|
|
14
|
+
children,
|
|
15
|
+
node,
|
|
16
|
+
...props
|
|
17
|
+
}}
|
|
18
|
+
render={streamdown.snippets.table}
|
|
19
|
+
>
|
|
20
|
+
<div class={clsx(streamdown.theme.table.container)}>
|
|
21
|
+
<table {...props} class={clsx(streamdown.theme.table.base, className)}>
|
|
22
|
+
{@render children()}
|
|
23
|
+
</table>
|
|
24
|
+
</div>
|
|
25
|
+
</Slot>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useStreamdown } from '../Streamdown.svelte';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import type { ElementProps } from './element.js';
|
|
5
|
+
import Slot from './Slot.svelte';
|
|
6
|
+
|
|
7
|
+
const streamdown = useStreamdown();
|
|
8
|
+
|
|
9
|
+
const { children, node, className, props }: ElementProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Slot
|
|
13
|
+
props={{
|
|
14
|
+
children,
|
|
15
|
+
node,
|
|
16
|
+
...props
|
|
17
|
+
}}
|
|
18
|
+
render={streamdown.snippets.tbody}
|
|
19
|
+
>
|
|
20
|
+
<tbody {...props} class={clsx(streamdown.theme.tbody.base, className)}>
|
|
21
|
+
{@render children()}
|
|
22
|
+
</tbody>
|
|
23
|
+
</Slot>
|