@assistant-ui/react-markdown 0.7.20 → 0.8.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/index.d.ts +0 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -6
- package/dist/index.mjs.map +1 -1
- package/dist/memoization.d.ts +2 -2
- package/dist/memoization.d.ts.map +1 -1
- package/dist/memoization.js +1 -1
- package/dist/memoization.js.map +1 -1
- package/dist/memoization.mjs +1 -1
- package/dist/memoization.mjs.map +1 -1
- package/dist/overrides/CodeBlock.d.ts +2 -0
- package/dist/overrides/CodeBlock.d.ts.map +1 -1
- package/dist/overrides/CodeBlock.js +3 -1
- package/dist/overrides/CodeBlock.js.map +1 -1
- package/dist/overrides/CodeBlock.mjs +3 -1
- package/dist/overrides/CodeBlock.mjs.map +1 -1
- package/dist/overrides/CodeOverride.d.ts.map +1 -1
- package/dist/overrides/CodeOverride.js +5 -0
- package/dist/overrides/CodeOverride.js.map +1 -1
- package/dist/overrides/CodeOverride.mjs +5 -0
- package/dist/overrides/CodeOverride.mjs.map +1 -1
- package/dist/overrides/defaultComponents.d.ts +2 -0
- package/dist/overrides/defaultComponents.d.ts.map +1 -1
- package/dist/overrides/defaultComponents.js +1 -1
- package/dist/overrides/defaultComponents.js.map +1 -1
- package/dist/overrides/defaultComponents.mjs +1 -1
- package/dist/overrides/defaultComponents.mjs.map +1 -1
- package/dist/overrides/types.d.ts +2 -0
- package/dist/overrides/types.d.ts.map +1 -1
- package/dist/overrides/types.js.map +1 -1
- package/package.json +4 -19
- package/src/index.ts +0 -12
- package/src/memoization.tsx +6 -3
- package/src/overrides/CodeBlock.tsx +5 -1
- package/src/overrides/CodeOverride.tsx +5 -0
- package/src/overrides/defaultComponents.tsx +4 -2
- package/src/overrides/types.ts +2 -0
- package/dist/styles/markdown.css +0 -274
- package/dist/styles/markdown.css.map +0 -1
- package/dist/styles/tailwindcss/markdown.css +0 -106
- package/dist/styles/tailwindcss/markdown.css.json +0 -68
- package/dist/tailwindcss/index.d.ts +0 -9
- package/dist/tailwindcss/index.d.ts.map +0 -1
- package/dist/tailwindcss/index.js +0 -113
- package/dist/tailwindcss/index.js.map +0 -1
- package/dist/tailwindcss/index.mjs +0 -105
- package/dist/tailwindcss/index.mjs.map +0 -1
- package/dist/ui/code-header.d.ts +0 -4
- package/dist/ui/code-header.d.ts.map +0 -1
- package/dist/ui/code-header.js +0 -54
- package/dist/ui/code-header.js.map +0 -1
- package/dist/ui/code-header.mjs +0 -29
- package/dist/ui/code-header.mjs.map +0 -1
- package/dist/ui/markdown-text.d.ts +0 -4
- package/dist/ui/markdown-text.d.ts.map +0 -1
- package/dist/ui/markdown-text.js +0 -114
- package/dist/ui/markdown-text.js.map +0 -1
- package/dist/ui/markdown-text.mjs +0 -81
- package/dist/ui/markdown-text.mjs.map +0 -1
- package/dist/ui/useCopyToClipboard.d.ts +0 -11
- package/dist/ui/useCopyToClipboard.d.ts.map +0 -1
- package/dist/ui/useCopyToClipboard.js +0 -45
- package/dist/ui/useCopyToClipboard.js.map +0 -1
- package/dist/ui/useCopyToClipboard.mjs +0 -21
- package/dist/ui/useCopyToClipboard.mjs.map +0 -1
- package/src/styles/tailwindcss/markdown.css +0 -106
- package/src/tailwindcss/index.ts +0 -8
- package/src/ui/code-header.tsx +0 -32
- package/src/ui/markdown-text.tsx +0 -114
- package/src/ui/useCopyToClipboard.tsx +0 -26
- package/tailwindcss/README.md +0 -1
- package/tailwindcss/package-lock.json +0 -6
- package/tailwindcss/package.json +0 -5
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/* running indicator */
|
|
2
|
-
:where(.aui-md-running):empty::after,
|
|
3
|
-
:where(.aui-md-running) > :where(:not(ol):not(ul):not(pre)):last-child::after,
|
|
4
|
-
:where(.aui-md-running) > pre:last-child code::after,
|
|
5
|
-
:where(.aui-md-running)
|
|
6
|
-
> :where(:is(ol, ul):last-child)
|
|
7
|
-
> :where(li:last-child:not(:has(* > li)))::after,
|
|
8
|
-
:where(.aui-md-running)
|
|
9
|
-
> :where(:is(ol, ul):last-child)
|
|
10
|
-
> :where(li:last-child)
|
|
11
|
-
> :where(:is(ol, ul):last-child)
|
|
12
|
-
> :where(li:last-child:not(:has(* > li)))::after,
|
|
13
|
-
:where(.aui-md-running)
|
|
14
|
-
> :where(:is(ol, ul):last-child)
|
|
15
|
-
> :where(li:last-child)
|
|
16
|
-
> :where(:is(ol, ul):last-child)
|
|
17
|
-
> :where(li:last-child)
|
|
18
|
-
> :where(:is(ol, ul):last-child)
|
|
19
|
-
> :where(li:last-child)::after {
|
|
20
|
-
@apply animate-pulse font-sans content-['\25CF'] ltr:ml-1 rtl:mr-1;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/* typography */
|
|
24
|
-
.aui-md-h1 {
|
|
25
|
-
@apply mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.aui-md-h2 {
|
|
29
|
-
@apply mb-4 mt-8 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.aui-md-h3 {
|
|
33
|
-
@apply mb-4 mt-6 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.aui-md-h4 {
|
|
37
|
-
@apply mb-4 mt-6 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.aui-md-h5 {
|
|
41
|
-
@apply my-4 text-lg font-semibold first:mt-0 last:mb-0;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.aui-md-h6 {
|
|
45
|
-
@apply my-4 font-semibold first:mt-0 last:mb-0;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.aui-md-p {
|
|
49
|
-
@apply mb-5 mt-5 leading-7 first:mt-0 last:mb-0;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.aui-md-a {
|
|
53
|
-
@apply text-aui-primary font-medium underline underline-offset-4;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.aui-md-blockquote {
|
|
57
|
-
@apply border-l-2 pl-6 italic;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.aui-md-ul {
|
|
61
|
-
@apply my-5 ml-6 list-disc [&>li]:mt-2;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.aui-md-ol {
|
|
65
|
-
@apply my-5 ml-6 list-decimal [&>li]:mt-2;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.aui-md-hr {
|
|
69
|
-
@apply my-5 border-b;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.aui-md-table {
|
|
73
|
-
@apply my-5 w-full border-separate border-spacing-0 overflow-y-auto;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.aui-md-th {
|
|
77
|
-
@apply bg-aui-muted px-4 py-2 text-left font-bold first:rounded-tl-lg last:rounded-tr-lg [&[align=center]]:text-center [&[align=right]]:text-right;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.aui-md-td {
|
|
81
|
-
@apply border-b border-l px-4 py-2 text-left last:border-r [&[align=center]]:text-center [&[align=right]]:text-right;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.aui-md-tr {
|
|
85
|
-
@apply m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.aui-md-sup {
|
|
89
|
-
@apply [&>a]:text-xs [&>a]:no-underline;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.aui-md-pre {
|
|
93
|
-
@apply overflow-x-auto rounded-b-lg bg-black p-4 text-white;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.aui-md-inline-code {
|
|
97
|
-
@apply bg-aui-muted rounded border font-semibold;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.aui-code-header-root {
|
|
101
|
-
@apply flex items-center justify-between gap-4 rounded-t-lg bg-zinc-900 px-4 py-2 text-sm font-semibold text-white;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.aui-code-header-language {
|
|
105
|
-
@apply lowercase [&>span]:text-xs;
|
|
106
|
-
}
|
package/src/tailwindcss/index.ts
DELETED
package/src/ui/code-header.tsx
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { FC } from "react";
|
|
2
|
-
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
3
|
-
import { INTERNAL, useThreadConfig } from "@assistant-ui/react";
|
|
4
|
-
|
|
5
|
-
import { CodeHeaderProps } from "../overrides/types";
|
|
6
|
-
import { useCopyToClipboard } from "./useCopyToClipboard";
|
|
7
|
-
|
|
8
|
-
const { TooltipIconButton } = INTERNAL;
|
|
9
|
-
|
|
10
|
-
export const CodeHeader: FC<CodeHeaderProps> = ({ language, code }) => {
|
|
11
|
-
const {
|
|
12
|
-
strings: {
|
|
13
|
-
code: { header: { copy: { tooltip = "Copy" } = {} } = {} } = {},
|
|
14
|
-
} = {},
|
|
15
|
-
} = useThreadConfig();
|
|
16
|
-
|
|
17
|
-
const { isCopied, copyToClipboard } = useCopyToClipboard();
|
|
18
|
-
const onCopy = () => {
|
|
19
|
-
if (!code || isCopied) return;
|
|
20
|
-
copyToClipboard(code);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<div className="aui-code-header-root">
|
|
25
|
-
<span className="aui-code-header-language">{language}</span>
|
|
26
|
-
<TooltipIconButton tooltip={tooltip} onClick={onCopy}>
|
|
27
|
-
{!isCopied && <CopyIcon />}
|
|
28
|
-
{isCopied && <CheckIcon />}
|
|
29
|
-
</TooltipIconButton>
|
|
30
|
-
</div>
|
|
31
|
-
);
|
|
32
|
-
};
|
package/src/ui/markdown-text.tsx
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { FC, memo } from "react";
|
|
2
|
-
import { CodeHeader } from "./code-header";
|
|
3
|
-
import classNames from "classnames";
|
|
4
|
-
import {
|
|
5
|
-
MarkdownTextPrimitive,
|
|
6
|
-
MarkdownTextPrimitiveProps,
|
|
7
|
-
} from "../primitives/MarkdownText";
|
|
8
|
-
import { INTERNAL } from "@assistant-ui/react";
|
|
9
|
-
import { useIsMarkdownCodeBlock } from "../overrides/PreOverride";
|
|
10
|
-
|
|
11
|
-
const { withSmoothContextProvider, useSmoothStatus } = INTERNAL;
|
|
12
|
-
|
|
13
|
-
export type MakeMarkdownTextProps = MarkdownTextPrimitiveProps;
|
|
14
|
-
|
|
15
|
-
const defaultComponents: MakeMarkdownTextProps["components"] = {
|
|
16
|
-
h1: ({ node, className, ...props }) => (
|
|
17
|
-
<h1 className={classNames("aui-md-h1", className)} {...props} />
|
|
18
|
-
),
|
|
19
|
-
h2: ({ node, className, ...props }) => (
|
|
20
|
-
<h2 className={classNames("aui-md-h2", className)} {...props} />
|
|
21
|
-
),
|
|
22
|
-
h3: ({ node, className, ...props }) => (
|
|
23
|
-
<h3 className={classNames("aui-md-h3", className)} {...props} />
|
|
24
|
-
),
|
|
25
|
-
h4: ({ node, className, ...props }) => (
|
|
26
|
-
<h4 className={classNames("aui-md-h4", className)} {...props} />
|
|
27
|
-
),
|
|
28
|
-
h5: ({ node, className, ...props }) => (
|
|
29
|
-
<h5 className={classNames("aui-md-h5", className)} {...props} />
|
|
30
|
-
),
|
|
31
|
-
h6: ({ node, className, ...props }) => (
|
|
32
|
-
<h6 className={classNames("aui-md-h6", className)} {...props} />
|
|
33
|
-
),
|
|
34
|
-
p: ({ node, className, ...props }) => (
|
|
35
|
-
<p className={classNames("aui-md-p", className)} {...props} />
|
|
36
|
-
),
|
|
37
|
-
a: ({ node, className, ...props }) => (
|
|
38
|
-
<a className={classNames("aui-md-a", className)} {...props} />
|
|
39
|
-
),
|
|
40
|
-
blockquote: ({ node, className, ...props }) => (
|
|
41
|
-
<blockquote
|
|
42
|
-
className={classNames("aui-md-blockquote", className)}
|
|
43
|
-
{...props}
|
|
44
|
-
/>
|
|
45
|
-
),
|
|
46
|
-
ul: ({ node, className, ...props }) => (
|
|
47
|
-
<ul className={classNames("aui-md-ul", className)} {...props} />
|
|
48
|
-
),
|
|
49
|
-
ol: ({ node, className, ...props }) => (
|
|
50
|
-
<ol className={classNames("aui-md-ol", className)} {...props} />
|
|
51
|
-
),
|
|
52
|
-
hr: ({ node, className, ...props }) => (
|
|
53
|
-
<hr className={classNames("aui-md-hr", className)} {...props} />
|
|
54
|
-
),
|
|
55
|
-
table: ({ node, className, ...props }) => (
|
|
56
|
-
<table className={classNames("aui-md-table", className)} {...props} />
|
|
57
|
-
),
|
|
58
|
-
th: ({ node, className, ...props }) => (
|
|
59
|
-
<th className={classNames("aui-md-th", className)} {...props} />
|
|
60
|
-
),
|
|
61
|
-
td: ({ node, className, ...props }) => (
|
|
62
|
-
<td className={classNames("aui-md-td", className)} {...props} />
|
|
63
|
-
),
|
|
64
|
-
tr: ({ node, className, ...props }) => (
|
|
65
|
-
<tr className={classNames("aui-md-tr", className)} {...props} />
|
|
66
|
-
),
|
|
67
|
-
sup: ({ node, className, ...props }) => (
|
|
68
|
-
<sup className={classNames("aui-md-sup", className)} {...props} />
|
|
69
|
-
),
|
|
70
|
-
pre: ({ node, className, ...props }) => (
|
|
71
|
-
<pre className={classNames("aui-md-pre", className)} {...props} />
|
|
72
|
-
),
|
|
73
|
-
code: ({ node, className, ...props }) => {
|
|
74
|
-
const isCodeBlock = useIsMarkdownCodeBlock();
|
|
75
|
-
return (
|
|
76
|
-
<code
|
|
77
|
-
className={classNames(!isCodeBlock && "aui-md-inline-code", className)}
|
|
78
|
-
{...props}
|
|
79
|
-
/>
|
|
80
|
-
);
|
|
81
|
-
},
|
|
82
|
-
CodeHeader,
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export const makeMarkdownText = ({
|
|
86
|
-
className,
|
|
87
|
-
components: userComponents,
|
|
88
|
-
...rest
|
|
89
|
-
}: MakeMarkdownTextProps = {}) => {
|
|
90
|
-
const components = {
|
|
91
|
-
...defaultComponents,
|
|
92
|
-
...Object.fromEntries(
|
|
93
|
-
// ignore undefined values, so undefined values do not override default components
|
|
94
|
-
Object.entries(userComponents ?? {}).filter(([_, v]) => v !== undefined),
|
|
95
|
-
),
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const MarkdownTextImpl: FC = () => {
|
|
99
|
-
const status = useSmoothStatus();
|
|
100
|
-
return (
|
|
101
|
-
<MarkdownTextPrimitive
|
|
102
|
-
components={components}
|
|
103
|
-
{...rest}
|
|
104
|
-
className={classNames(
|
|
105
|
-
status.type === "running" && "aui-md-running",
|
|
106
|
-
className,
|
|
107
|
-
)}
|
|
108
|
-
/>
|
|
109
|
-
);
|
|
110
|
-
};
|
|
111
|
-
MarkdownTextImpl.displayName = "MarkdownText";
|
|
112
|
-
|
|
113
|
-
return memo(withSmoothContextProvider(MarkdownTextImpl), () => true);
|
|
114
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
|
|
5
|
-
namespace useCopyToClipboard {
|
|
6
|
-
export interface Options {
|
|
7
|
-
copiedDuration?: number;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const useCopyToClipboard = ({
|
|
12
|
-
copiedDuration = 3000,
|
|
13
|
-
}: useCopyToClipboard.Options = {}) => {
|
|
14
|
-
const [isCopied, setIsCopied] = useState<boolean>(false);
|
|
15
|
-
|
|
16
|
-
const copyToClipboard = (value: string) => {
|
|
17
|
-
if (!value) return;
|
|
18
|
-
|
|
19
|
-
navigator.clipboard.writeText(value).then(() => {
|
|
20
|
-
setIsCopied(true);
|
|
21
|
-
setTimeout(() => setIsCopied(false), copiedDuration);
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return { isCopied, copyToClipboard };
|
|
26
|
-
};
|
package/tailwindcss/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
This directory exists to support subpath imports for TypeScript projects using --moduleResolution node.
|