@assistant-ui/react-markdown 0.2.22 → 0.2.24
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 +6 -45
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -307
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -293
- package/dist/index.mjs.map +1 -1
- package/dist/overrides/CodeBlock.d.ts +14 -0
- package/dist/overrides/CodeBlock.d.ts.map +1 -0
- package/dist/overrides/CodeBlock.js +50 -0
- package/dist/overrides/CodeBlock.js.map +1 -0
- package/dist/overrides/CodeBlock.mjs +26 -0
- package/dist/overrides/CodeBlock.mjs.map +1 -0
- package/dist/overrides/CodeOverride.d.ts +16 -0
- package/dist/overrides/CodeOverride.d.ts.map +1 -0
- package/dist/overrides/CodeOverride.js +85 -0
- package/dist/overrides/CodeOverride.js.map +1 -0
- package/dist/overrides/CodeOverride.mjs +61 -0
- package/dist/overrides/CodeOverride.mjs.map +1 -0
- package/dist/overrides/PreOverride.d.ts +6 -0
- package/dist/overrides/PreOverride.d.ts.map +1 -0
- package/dist/overrides/PreOverride.js +41 -0
- package/dist/overrides/PreOverride.js.map +1 -0
- package/dist/overrides/PreOverride.mjs +15 -0
- package/dist/overrides/PreOverride.mjs.map +1 -0
- package/dist/overrides/defaultComponents.d.ts +13 -0
- package/dist/overrides/defaultComponents.d.ts.map +1 -0
- package/dist/overrides/defaultComponents.js +39 -0
- package/dist/overrides/defaultComponents.js.map +1 -0
- package/dist/overrides/defaultComponents.mjs +12 -0
- package/dist/overrides/defaultComponents.mjs.map +1 -0
- package/dist/overrides/types.d.ts +16 -0
- package/dist/overrides/types.d.ts.map +1 -0
- package/dist/overrides/types.js +17 -0
- package/dist/overrides/types.js.map +1 -0
- package/dist/overrides/types.mjs +1 -0
- package/dist/overrides/types.mjs.map +1 -0
- package/dist/overrides/withDefaults.d.ts +4 -0
- package/dist/overrides/withDefaults.d.ts.map +1 -0
- package/dist/overrides/withDefaults.js +49 -0
- package/dist/overrides/withDefaults.js.map +1 -0
- package/dist/overrides/withDefaults.mjs +15 -0
- package/dist/overrides/withDefaults.mjs.map +1 -0
- package/dist/primitives/MarkdownText.d.ts +22 -0
- package/dist/primitives/MarkdownText.d.ts.map +1 -0
- package/dist/primitives/MarkdownText.js +96 -0
- package/dist/primitives/MarkdownText.js.map +1 -0
- package/dist/primitives/MarkdownText.mjs +69 -0
- package/dist/primitives/MarkdownText.mjs.map +1 -0
- package/dist/styles/markdown.css +1 -0
- package/dist/styles/markdown.css.map +1 -0
- package/dist/tailwindcss/index.d.ts +4 -6
- package/dist/tailwindcss/index.d.ts.map +1 -0
- package/dist/tailwindcss/index.js +3 -76
- package/dist/tailwindcss/index.js.map +1 -1
- package/dist/tailwindcss/index.mjs +3 -75
- package/dist/tailwindcss/index.mjs.map +1 -1
- package/dist/ui/code-header.d.ts +4 -0
- package/dist/ui/code-header.d.ts.map +1 -0
- package/dist/ui/code-header.js +52 -0
- package/dist/ui/code-header.js.map +1 -0
- package/dist/ui/code-header.mjs +28 -0
- package/dist/ui/code-header.mjs.map +1 -0
- package/dist/ui/markdown-text.d.ts +4 -0
- package/dist/ui/markdown-text.d.ts.map +1 -0
- package/dist/ui/markdown-text.js +112 -0
- package/dist/ui/markdown-text.js.map +1 -0
- package/dist/ui/markdown-text.mjs +80 -0
- package/dist/ui/markdown-text.mjs.map +1 -0
- package/dist/ui/useCopyToClipboard.d.ts +7 -0
- package/dist/ui/useCopyToClipboard.d.ts.map +1 -0
- package/dist/ui/useCopyToClipboard.js +42 -0
- package/dist/ui/useCopyToClipboard.js.map +1 -0
- package/dist/ui/useCopyToClipboard.mjs +18 -0
- package/dist/ui/useCopyToClipboard.mjs.map +1 -0
- package/package.json +15 -21
- package/src/index.ts +18 -0
- package/src/overrides/CodeBlock.tsx +41 -0
- package/src/overrides/CodeOverride.tsx +91 -0
- package/src/overrides/PreOverride.tsx +15 -0
- package/src/overrides/defaultComponents.tsx +21 -0
- package/src/overrides/types.ts +22 -0
- package/src/overrides/withDefaults.tsx +14 -0
- package/src/primitives/MarkdownText.tsx +110 -0
- package/src/styles/tailwindcss/markdown.css +106 -0
- package/src/tailwindcss/index.ts +8 -0
- package/src/ui/code-header.tsx +32 -0
- package/src/ui/markdown-text.tsx +114 -0
- package/src/ui/useCopyToClipboard.tsx +21 -0
- package/tailwindcss/README.md +1 -0
- package/tailwindcss/package.json +5 -0
- package/dist/index.d.mts +0 -45
- package/dist/tailwindcss/index.d.mts +0 -11
|
@@ -26,88 +26,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/tailwindcss/index.ts
|
|
31
29
|
var tailwindcss_exports = {};
|
|
32
30
|
__export(tailwindcss_exports, {
|
|
33
31
|
default: () => tailwindcss_default
|
|
34
32
|
});
|
|
35
33
|
module.exports = __toCommonJS(tailwindcss_exports);
|
|
36
34
|
var import_plugin = __toESM(require("tailwindcss/plugin.js"));
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
":where(.aui-md-running):empty::after,\n:where(.aui-md-running) > :where(:not(ol):not(ul):not(pre)):last-child::after,\n:where(.aui-md-running) > pre:last-child code::after,\n:where(.aui-md-running)\n > :where(:is(ol, ul):last-child)\n > :where(li:last-child:not(:has(* > li)))::after,\n:where(.aui-md-running)\n > :where(:is(ol, ul):last-child)\n > :where(li:last-child)\n > :where(:is(ol, ul):last-child)\n > :where(li:last-child:not(:has(* > li)))::after,\n:where(.aui-md-running)\n > :where(:is(ol, ul):last-child)\n > :where(li:last-child)\n > :where(:is(ol, ul):last-child)\n > :where(li:last-child)\n > :where(:is(ol, ul):last-child)\n > :where(li:last-child)::after": {
|
|
41
|
-
"@apply animate-pulse font-sans content-['\\25CF'] ltr:ml-1 rtl:mr-1": {}
|
|
42
|
-
},
|
|
43
|
-
".aui-md-h1": {
|
|
44
|
-
"@apply mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0": {}
|
|
45
|
-
},
|
|
46
|
-
".aui-md-h2": {
|
|
47
|
-
"@apply mb-4 mt-8 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0": {}
|
|
48
|
-
},
|
|
49
|
-
".aui-md-h3": {
|
|
50
|
-
"@apply mb-4 mt-6 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0": {}
|
|
51
|
-
},
|
|
52
|
-
".aui-md-h4": {
|
|
53
|
-
"@apply mb-4 mt-6 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0": {}
|
|
54
|
-
},
|
|
55
|
-
".aui-md-h5": {
|
|
56
|
-
"@apply my-4 text-lg font-semibold first:mt-0 last:mb-0": {}
|
|
57
|
-
},
|
|
58
|
-
".aui-md-h6": {
|
|
59
|
-
"@apply my-4 font-semibold first:mt-0 last:mb-0": {}
|
|
60
|
-
},
|
|
61
|
-
".aui-md-p": {
|
|
62
|
-
"@apply mb-5 mt-5 leading-7 first:mt-0 last:mb-0": {}
|
|
63
|
-
},
|
|
64
|
-
".aui-md-a": {
|
|
65
|
-
"@apply text-aui-primary font-medium underline underline-offset-4": {}
|
|
66
|
-
},
|
|
67
|
-
".aui-md-blockquote": {
|
|
68
|
-
"@apply border-l-2 pl-6 italic": {}
|
|
69
|
-
},
|
|
70
|
-
".aui-md-ul": {
|
|
71
|
-
"@apply my-5 ml-6 list-disc [&>li]:mt-2": {}
|
|
72
|
-
},
|
|
73
|
-
".aui-md-ol": {
|
|
74
|
-
"@apply my-5 ml-6 list-decimal [&>li]:mt-2": {}
|
|
75
|
-
},
|
|
76
|
-
".aui-md-hr": {
|
|
77
|
-
"@apply my-5 border-b": {}
|
|
78
|
-
},
|
|
79
|
-
".aui-md-table": {
|
|
80
|
-
"@apply my-5 w-full border-separate border-spacing-0 overflow-y-auto": {}
|
|
81
|
-
},
|
|
82
|
-
".aui-md-th": {
|
|
83
|
-
"@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": {}
|
|
84
|
-
},
|
|
85
|
-
".aui-md-td": {
|
|
86
|
-
"@apply border-b border-l px-4 py-2 text-left last:border-r [&[align=center]]:text-center [&[align=right]]:text-right": {}
|
|
87
|
-
},
|
|
88
|
-
".aui-md-tr": {
|
|
89
|
-
"@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": {}
|
|
90
|
-
},
|
|
91
|
-
".aui-md-sup": {
|
|
92
|
-
"@apply [&>a]:text-xs [&>a]:no-underline": {}
|
|
93
|
-
},
|
|
94
|
-
".aui-md-pre": {
|
|
95
|
-
"@apply overflow-x-auto rounded-b-lg bg-black p-4 text-white": {}
|
|
96
|
-
},
|
|
97
|
-
".aui-md-inline-code": {
|
|
98
|
-
"@apply bg-aui-muted rounded border font-semibold": {}
|
|
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
|
-
".aui-code-header-language": {
|
|
104
|
-
"@apply lowercase [&>span]:text-xs": {}
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// src/tailwindcss/index.ts
|
|
109
|
-
var auiPlugin = import_plugin.default.withOptions(() => ({ addComponents }) => {
|
|
110
|
-
addComponents(markdown_css_default);
|
|
35
|
+
var import_markdown_css = __toESM(require("../../generated/markdown.css.json"));
|
|
36
|
+
const auiPlugin = import_plugin.default.withOptions(() => ({ addComponents }) => {
|
|
37
|
+
addComponents(import_markdown_css.default);
|
|
111
38
|
});
|
|
112
39
|
var tailwindcss_default = auiPlugin;
|
|
113
40
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tailwindcss/index.ts"
|
|
1
|
+
{"version":3,"sources":["../../src/tailwindcss/index.ts"],"sourcesContent":["import plugin from \"tailwindcss/plugin.js\";\nimport markdownCSS from \"../../generated/markdown.css.json\";\n\nconst auiPlugin = plugin.withOptions<{}>(() => ({ addComponents }) => {\n addComponents(markdownCSS);\n});\n\nexport default auiPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AACnB,0BAAwB;AAExB,MAAM,YAAY,cAAAA,QAAO,YAAgB,MAAM,CAAC,EAAE,cAAc,MAAM;AACpE,gBAAc,oBAAAC,OAAW;AAC3B,CAAC;AAED,IAAO,sBAAQ;","names":["plugin","markdownCSS"]}
|
|
@@ -1,79 +1,7 @@
|
|
|
1
|
-
// src/tailwindcss/index.ts
|
|
2
1
|
import plugin from "tailwindcss/plugin.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
":where(.aui-md-running):empty::after,\n:where(.aui-md-running) > :where(:not(ol):not(ul):not(pre)):last-child::after,\n:where(.aui-md-running) > pre:last-child code::after,\n:where(.aui-md-running)\n > :where(:is(ol, ul):last-child)\n > :where(li:last-child:not(:has(* > li)))::after,\n:where(.aui-md-running)\n > :where(:is(ol, ul):last-child)\n > :where(li:last-child)\n > :where(:is(ol, ul):last-child)\n > :where(li:last-child:not(:has(* > li)))::after,\n:where(.aui-md-running)\n > :where(:is(ol, ul):last-child)\n > :where(li:last-child)\n > :where(:is(ol, ul):last-child)\n > :where(li:last-child)\n > :where(:is(ol, ul):last-child)\n > :where(li:last-child)::after": {
|
|
7
|
-
"@apply animate-pulse font-sans content-['\\25CF'] ltr:ml-1 rtl:mr-1": {}
|
|
8
|
-
},
|
|
9
|
-
".aui-md-h1": {
|
|
10
|
-
"@apply mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0": {}
|
|
11
|
-
},
|
|
12
|
-
".aui-md-h2": {
|
|
13
|
-
"@apply mb-4 mt-8 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0": {}
|
|
14
|
-
},
|
|
15
|
-
".aui-md-h3": {
|
|
16
|
-
"@apply mb-4 mt-6 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0": {}
|
|
17
|
-
},
|
|
18
|
-
".aui-md-h4": {
|
|
19
|
-
"@apply mb-4 mt-6 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0": {}
|
|
20
|
-
},
|
|
21
|
-
".aui-md-h5": {
|
|
22
|
-
"@apply my-4 text-lg font-semibold first:mt-0 last:mb-0": {}
|
|
23
|
-
},
|
|
24
|
-
".aui-md-h6": {
|
|
25
|
-
"@apply my-4 font-semibold first:mt-0 last:mb-0": {}
|
|
26
|
-
},
|
|
27
|
-
".aui-md-p": {
|
|
28
|
-
"@apply mb-5 mt-5 leading-7 first:mt-0 last:mb-0": {}
|
|
29
|
-
},
|
|
30
|
-
".aui-md-a": {
|
|
31
|
-
"@apply text-aui-primary font-medium underline underline-offset-4": {}
|
|
32
|
-
},
|
|
33
|
-
".aui-md-blockquote": {
|
|
34
|
-
"@apply border-l-2 pl-6 italic": {}
|
|
35
|
-
},
|
|
36
|
-
".aui-md-ul": {
|
|
37
|
-
"@apply my-5 ml-6 list-disc [&>li]:mt-2": {}
|
|
38
|
-
},
|
|
39
|
-
".aui-md-ol": {
|
|
40
|
-
"@apply my-5 ml-6 list-decimal [&>li]:mt-2": {}
|
|
41
|
-
},
|
|
42
|
-
".aui-md-hr": {
|
|
43
|
-
"@apply my-5 border-b": {}
|
|
44
|
-
},
|
|
45
|
-
".aui-md-table": {
|
|
46
|
-
"@apply my-5 w-full border-separate border-spacing-0 overflow-y-auto": {}
|
|
47
|
-
},
|
|
48
|
-
".aui-md-th": {
|
|
49
|
-
"@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": {}
|
|
50
|
-
},
|
|
51
|
-
".aui-md-td": {
|
|
52
|
-
"@apply border-b border-l px-4 py-2 text-left last:border-r [&[align=center]]:text-center [&[align=right]]:text-right": {}
|
|
53
|
-
},
|
|
54
|
-
".aui-md-tr": {
|
|
55
|
-
"@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": {}
|
|
56
|
-
},
|
|
57
|
-
".aui-md-sup": {
|
|
58
|
-
"@apply [&>a]:text-xs [&>a]:no-underline": {}
|
|
59
|
-
},
|
|
60
|
-
".aui-md-pre": {
|
|
61
|
-
"@apply overflow-x-auto rounded-b-lg bg-black p-4 text-white": {}
|
|
62
|
-
},
|
|
63
|
-
".aui-md-inline-code": {
|
|
64
|
-
"@apply bg-aui-muted rounded border font-semibold": {}
|
|
65
|
-
},
|
|
66
|
-
".aui-code-header-root": {
|
|
67
|
-
"@apply flex items-center justify-between gap-4 rounded-t-lg bg-zinc-900 px-4 py-2 text-sm font-semibold text-white": {}
|
|
68
|
-
},
|
|
69
|
-
".aui-code-header-language": {
|
|
70
|
-
"@apply lowercase [&>span]:text-xs": {}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
// src/tailwindcss/index.ts
|
|
75
|
-
var auiPlugin = plugin.withOptions(() => ({ addComponents }) => {
|
|
76
|
-
addComponents(markdown_css_default);
|
|
2
|
+
import markdownCSS from "../../generated/markdown.css.json";
|
|
3
|
+
const auiPlugin = plugin.withOptions(() => ({ addComponents }) => {
|
|
4
|
+
addComponents(markdownCSS);
|
|
77
5
|
});
|
|
78
6
|
var tailwindcss_default = auiPlugin;
|
|
79
7
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tailwindcss/index.ts"
|
|
1
|
+
{"version":3,"sources":["../../src/tailwindcss/index.ts"],"sourcesContent":["import plugin from \"tailwindcss/plugin.js\";\nimport markdownCSS from \"../../generated/markdown.css.json\";\n\nconst auiPlugin = plugin.withOptions<{}>(() => ({ addComponents }) => {\n addComponents(markdownCSS);\n});\n\nexport default auiPlugin;\n"],"mappings":"AAAA,OAAO,YAAY;AACnB,OAAO,iBAAiB;AAExB,MAAM,YAAY,OAAO,YAAgB,MAAM,CAAC,EAAE,cAAc,MAAM;AACpE,gBAAc,WAAW;AAC3B,CAAC;AAED,IAAO,sBAAQ;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-header.d.ts","sourceRoot":"","sources":["../../src/ui/code-header.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAKrD,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAsB1C,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var code_header_exports = {};
|
|
20
|
+
__export(code_header_exports, {
|
|
21
|
+
CodeHeader: () => CodeHeader
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(code_header_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_lucide_react = require("lucide-react");
|
|
26
|
+
var import_react2 = require("@assistant-ui/react");
|
|
27
|
+
var import_useCopyToClipboard = require("./useCopyToClipboard");
|
|
28
|
+
const { TooltipIconButton } = import_react2.INTERNAL;
|
|
29
|
+
const CodeHeader = ({ language, code }) => {
|
|
30
|
+
const {
|
|
31
|
+
strings: {
|
|
32
|
+
code: { header: { copy: { tooltip = "Copy" } = {} } = {} } = {}
|
|
33
|
+
} = {}
|
|
34
|
+
} = (0, import_react2.useThreadConfig)();
|
|
35
|
+
const { isCopied, copyToClipboard } = (0, import_useCopyToClipboard.useCopyToClipboard)();
|
|
36
|
+
const onCopy = () => {
|
|
37
|
+
if (!code || isCopied) return;
|
|
38
|
+
copyToClipboard(code);
|
|
39
|
+
};
|
|
40
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "aui-code-header-root", children: [
|
|
41
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "aui-code-header-language", children: language }),
|
|
42
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TooltipIconButton, { tooltip, onClick: onCopy, children: [
|
|
43
|
+
!isCopied && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.CopyIcon, {}),
|
|
44
|
+
isCopied && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.CheckIcon, {})
|
|
45
|
+
] })
|
|
46
|
+
] });
|
|
47
|
+
};
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
CodeHeader
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=code-header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/code-header.tsx"],"sourcesContent":["import { FC } from \"react\";\nimport { CheckIcon, CopyIcon } from \"lucide-react\";\nimport { INTERNAL, useThreadConfig } from \"@assistant-ui/react\";\n\nimport { CodeHeaderProps } from \"../overrides/types\";\nimport { useCopyToClipboard } from \"./useCopyToClipboard\";\n\nconst { TooltipIconButton } = INTERNAL;\n\nexport const CodeHeader: FC<CodeHeaderProps> = ({ language, code }) => {\n const {\n strings: {\n code: { header: { copy: { tooltip = \"Copy\" } = {} } = {} } = {},\n } = {},\n } = useThreadConfig();\n\n const { isCopied, copyToClipboard } = useCopyToClipboard();\n const onCopy = () => {\n if (!code || isCopied) return;\n copyToClipboard(code);\n };\n\n return (\n <div className=\"aui-code-header-root\">\n <span className=\"aui-code-header-language\">{language}</span>\n <TooltipIconButton tooltip={tooltip} onClick={onCopy}>\n {!isCopied && <CopyIcon />}\n {isCopied && <CheckIcon />}\n </TooltipIconButton>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBM;AAvBN,0BAAoC;AACpC,IAAAA,gBAA0C;AAG1C,gCAAmC;AAEnC,MAAM,EAAE,kBAAkB,IAAI;AAEvB,MAAM,aAAkC,CAAC,EAAE,UAAU,KAAK,MAAM;AACrE,QAAM;AAAA,IACJ,SAAS;AAAA,MACP,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,OAAO,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC;AAAA,IAChE,IAAI,CAAC;AAAA,EACP,QAAI,+BAAgB;AAEpB,QAAM,EAAE,UAAU,gBAAgB,QAAI,8CAAmB;AACzD,QAAM,SAAS,MAAM;AACnB,QAAI,CAAC,QAAQ,SAAU;AACvB,oBAAgB,IAAI;AAAA,EACtB;AAEA,SACE,6CAAC,SAAI,WAAU,wBACb;AAAA,gDAAC,UAAK,WAAU,4BAA4B,oBAAS;AAAA,IACrD,6CAAC,qBAAkB,SAAkB,SAAS,QAC3C;AAAA,OAAC,YAAY,4CAAC,gCAAS;AAAA,MACvB,YAAY,4CAAC,iCAAU;AAAA,OAC1B;AAAA,KACF;AAEJ;","names":["import_react"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
3
|
+
import { INTERNAL, useThreadConfig } from "@assistant-ui/react";
|
|
4
|
+
import { useCopyToClipboard } from "./useCopyToClipboard";
|
|
5
|
+
const { TooltipIconButton } = INTERNAL;
|
|
6
|
+
const CodeHeader = ({ language, code }) => {
|
|
7
|
+
const {
|
|
8
|
+
strings: {
|
|
9
|
+
code: { header: { copy: { tooltip = "Copy" } = {} } = {} } = {}
|
|
10
|
+
} = {}
|
|
11
|
+
} = useThreadConfig();
|
|
12
|
+
const { isCopied, copyToClipboard } = useCopyToClipboard();
|
|
13
|
+
const onCopy = () => {
|
|
14
|
+
if (!code || isCopied) return;
|
|
15
|
+
copyToClipboard(code);
|
|
16
|
+
};
|
|
17
|
+
return /* @__PURE__ */ jsxs("div", { className: "aui-code-header-root", children: [
|
|
18
|
+
/* @__PURE__ */ jsx("span", { className: "aui-code-header-language", children: language }),
|
|
19
|
+
/* @__PURE__ */ jsxs(TooltipIconButton, { tooltip, onClick: onCopy, children: [
|
|
20
|
+
!isCopied && /* @__PURE__ */ jsx(CopyIcon, {}),
|
|
21
|
+
isCopied && /* @__PURE__ */ jsx(CheckIcon, {})
|
|
22
|
+
] })
|
|
23
|
+
] });
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
CodeHeader
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=code-header.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/code-header.tsx"],"sourcesContent":["import { FC } from \"react\";\nimport { CheckIcon, CopyIcon } from \"lucide-react\";\nimport { INTERNAL, useThreadConfig } from \"@assistant-ui/react\";\n\nimport { CodeHeaderProps } from \"../overrides/types\";\nimport { useCopyToClipboard } from \"./useCopyToClipboard\";\n\nconst { TooltipIconButton } = INTERNAL;\n\nexport const CodeHeader: FC<CodeHeaderProps> = ({ language, code }) => {\n const {\n strings: {\n code: { header: { copy: { tooltip = \"Copy\" } = {} } = {} } = {},\n } = {},\n } = useThreadConfig();\n\n const { isCopied, copyToClipboard } = useCopyToClipboard();\n const onCopy = () => {\n if (!code || isCopied) return;\n copyToClipboard(code);\n };\n\n return (\n <div className=\"aui-code-header-root\">\n <span className=\"aui-code-header-language\">{language}</span>\n <TooltipIconButton tooltip={tooltip} onClick={onCopy}>\n {!isCopied && <CopyIcon />}\n {isCopied && <CheckIcon />}\n </TooltipIconButton>\n </div>\n );\n};\n"],"mappings":"AAwBM,cACA,YADA;AAvBN,SAAS,WAAW,gBAAgB;AACpC,SAAS,UAAU,uBAAuB;AAG1C,SAAS,0BAA0B;AAEnC,MAAM,EAAE,kBAAkB,IAAI;AAEvB,MAAM,aAAkC,CAAC,EAAE,UAAU,KAAK,MAAM;AACrE,QAAM;AAAA,IACJ,SAAS;AAAA,MACP,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,OAAO,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC;AAAA,IAChE,IAAI,CAAC;AAAA,EACP,IAAI,gBAAgB;AAEpB,QAAM,EAAE,UAAU,gBAAgB,IAAI,mBAAmB;AACzD,QAAM,SAAS,MAAM;AACnB,QAAI,CAAC,QAAQ,SAAU;AACvB,oBAAgB,IAAI;AAAA,EACtB;AAEA,SACE,qBAAC,SAAI,WAAU,wBACb;AAAA,wBAAC,UAAK,WAAU,4BAA4B,oBAAS;AAAA,IACrD,qBAAC,qBAAkB,SAAkB,SAAS,QAC3C;AAAA,OAAC,YAAY,oBAAC,YAAS;AAAA,MACvB,YAAY,oBAAC,aAAU;AAAA,OAC1B;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { MarkdownTextPrimitiveProps } from "../primitives/MarkdownText";
|
|
2
|
+
export type MakeMarkdownTextProps = MarkdownTextPrimitiveProps;
|
|
3
|
+
export declare const makeMarkdownText: ({ className, components: userComponents, ...rest }?: MakeMarkdownTextProps) => import("react").NamedExoticComponent<{}>;
|
|
4
|
+
//# sourceMappingURL=markdown-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-text.d.ts","sourceRoot":"","sources":["../../src/ui/markdown-text.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,0BAA0B,EAC3B,MAAM,4BAA4B,CAAC;AAMpC,MAAM,MAAM,qBAAqB,GAAG,0BAA0B,CAAC;AAwE/D,eAAO,MAAM,gBAAgB,wDAI1B,qBAAqB,6CAyBvB,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var markdown_text_exports = {};
|
|
30
|
+
__export(markdown_text_exports, {
|
|
31
|
+
makeMarkdownText: () => makeMarkdownText
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(markdown_text_exports);
|
|
34
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
var import_code_header = require("./code-header");
|
|
37
|
+
var import_classnames = __toESM(require("classnames"));
|
|
38
|
+
var import_MarkdownText = require("../primitives/MarkdownText");
|
|
39
|
+
var import_react2 = require("@assistant-ui/react");
|
|
40
|
+
var import_PreOverride = require("../overrides/PreOverride");
|
|
41
|
+
const { withSmoothContextProvider, useSmoothStatus } = import_react2.INTERNAL;
|
|
42
|
+
const defaultComponents = {
|
|
43
|
+
h1: ({ node, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: (0, import_classnames.default)("aui-md-h1", className), ...props }),
|
|
44
|
+
h2: ({ node, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: (0, import_classnames.default)("aui-md-h2", className), ...props }),
|
|
45
|
+
h3: ({ node, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: (0, import_classnames.default)("aui-md-h3", className), ...props }),
|
|
46
|
+
h4: ({ node, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { className: (0, import_classnames.default)("aui-md-h4", className), ...props }),
|
|
47
|
+
h5: ({ node, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h5", { className: (0, import_classnames.default)("aui-md-h5", className), ...props }),
|
|
48
|
+
h6: ({ node, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h6", { className: (0, import_classnames.default)("aui-md-h6", className), ...props }),
|
|
49
|
+
p: ({ node, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: (0, import_classnames.default)("aui-md-p", className), ...props }),
|
|
50
|
+
a: ({ node, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { className: (0, import_classnames.default)("aui-md-a", className), ...props }),
|
|
51
|
+
blockquote: ({ node, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
52
|
+
"blockquote",
|
|
53
|
+
{
|
|
54
|
+
className: (0, import_classnames.default)("aui-md-blockquote", className),
|
|
55
|
+
...props
|
|
56
|
+
}
|
|
57
|
+
),
|
|
58
|
+
ul: ({ node, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: (0, import_classnames.default)("aui-md-ul", className), ...props }),
|
|
59
|
+
ol: ({ node, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ol", { className: (0, import_classnames.default)("aui-md-ol", className), ...props }),
|
|
60
|
+
hr: ({ node, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("hr", { className: (0, import_classnames.default)("aui-md-hr", className), ...props }),
|
|
61
|
+
table: ({ node, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("table", { className: (0, import_classnames.default)("aui-md-table", className), ...props }),
|
|
62
|
+
th: ({ node, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { className: (0, import_classnames.default)("aui-md-th", className), ...props }),
|
|
63
|
+
td: ({ node, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: (0, import_classnames.default)("aui-md-td", className), ...props }),
|
|
64
|
+
tr: ({ node, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { className: (0, import_classnames.default)("aui-md-tr", className), ...props }),
|
|
65
|
+
sup: ({ node, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("sup", { className: (0, import_classnames.default)("aui-md-sup", className), ...props }),
|
|
66
|
+
pre: ({ node, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: (0, import_classnames.default)("aui-md-pre", className), ...props }),
|
|
67
|
+
code: ({ node, className, ...props }) => {
|
|
68
|
+
const isCodeBlock = (0, import_PreOverride.useIsMarkdownCodeBlock)();
|
|
69
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
70
|
+
"code",
|
|
71
|
+
{
|
|
72
|
+
className: (0, import_classnames.default)(!isCodeBlock && "aui-md-inline-code", className),
|
|
73
|
+
...props
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
},
|
|
77
|
+
CodeHeader: import_code_header.CodeHeader
|
|
78
|
+
};
|
|
79
|
+
const makeMarkdownText = ({
|
|
80
|
+
className,
|
|
81
|
+
components: userComponents,
|
|
82
|
+
...rest
|
|
83
|
+
} = {}) => {
|
|
84
|
+
const components = {
|
|
85
|
+
...defaultComponents,
|
|
86
|
+
...Object.fromEntries(
|
|
87
|
+
// ignore undefined values, so undefined values do not override default components
|
|
88
|
+
Object.entries(userComponents ?? {}).filter(([_, v]) => v !== void 0)
|
|
89
|
+
)
|
|
90
|
+
};
|
|
91
|
+
const MarkdownTextImpl = () => {
|
|
92
|
+
const status = useSmoothStatus();
|
|
93
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
94
|
+
import_MarkdownText.MarkdownTextPrimitive,
|
|
95
|
+
{
|
|
96
|
+
components,
|
|
97
|
+
...rest,
|
|
98
|
+
className: (0, import_classnames.default)(
|
|
99
|
+
status.type === "running" && "aui-md-running",
|
|
100
|
+
className
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
MarkdownTextImpl.displayName = "MarkdownText";
|
|
106
|
+
return (0, import_react.memo)(withSmoothContextProvider(MarkdownTextImpl), () => true);
|
|
107
|
+
};
|
|
108
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
109
|
+
0 && (module.exports = {
|
|
110
|
+
makeMarkdownText
|
|
111
|
+
});
|
|
112
|
+
//# sourceMappingURL=markdown-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/markdown-text.tsx"],"sourcesContent":["import { FC, memo } from \"react\";\nimport { CodeHeader } from \"./code-header\";\nimport classNames from \"classnames\";\nimport {\n MarkdownTextPrimitive,\n MarkdownTextPrimitiveProps,\n} from \"../primitives/MarkdownText\";\nimport { INTERNAL } from \"@assistant-ui/react\";\nimport { useIsMarkdownCodeBlock } from \"../overrides/PreOverride\";\n\nconst { withSmoothContextProvider, useSmoothStatus } = INTERNAL;\n\nexport type MakeMarkdownTextProps = MarkdownTextPrimitiveProps;\n\nconst defaultComponents: MakeMarkdownTextProps[\"components\"] = {\n h1: ({ node, className, ...props }) => (\n <h1 className={classNames(\"aui-md-h1\", className)} {...props} />\n ),\n h2: ({ node, className, ...props }) => (\n <h2 className={classNames(\"aui-md-h2\", className)} {...props} />\n ),\n h3: ({ node, className, ...props }) => (\n <h3 className={classNames(\"aui-md-h3\", className)} {...props} />\n ),\n h4: ({ node, className, ...props }) => (\n <h4 className={classNames(\"aui-md-h4\", className)} {...props} />\n ),\n h5: ({ node, className, ...props }) => (\n <h5 className={classNames(\"aui-md-h5\", className)} {...props} />\n ),\n h6: ({ node, className, ...props }) => (\n <h6 className={classNames(\"aui-md-h6\", className)} {...props} />\n ),\n p: ({ node, className, ...props }) => (\n <p className={classNames(\"aui-md-p\", className)} {...props} />\n ),\n a: ({ node, className, ...props }) => (\n <a className={classNames(\"aui-md-a\", className)} {...props} />\n ),\n blockquote: ({ node, className, ...props }) => (\n <blockquote\n className={classNames(\"aui-md-blockquote\", className)}\n {...props}\n />\n ),\n ul: ({ node, className, ...props }) => (\n <ul className={classNames(\"aui-md-ul\", className)} {...props} />\n ),\n ol: ({ node, className, ...props }) => (\n <ol className={classNames(\"aui-md-ol\", className)} {...props} />\n ),\n hr: ({ node, className, ...props }) => (\n <hr className={classNames(\"aui-md-hr\", className)} {...props} />\n ),\n table: ({ node, className, ...props }) => (\n <table className={classNames(\"aui-md-table\", className)} {...props} />\n ),\n th: ({ node, className, ...props }) => (\n <th className={classNames(\"aui-md-th\", className)} {...props} />\n ),\n td: ({ node, className, ...props }) => (\n <td className={classNames(\"aui-md-td\", className)} {...props} />\n ),\n tr: ({ node, className, ...props }) => (\n <tr className={classNames(\"aui-md-tr\", className)} {...props} />\n ),\n sup: ({ node, className, ...props }) => (\n <sup className={classNames(\"aui-md-sup\", className)} {...props} />\n ),\n pre: ({ node, className, ...props }) => (\n <pre className={classNames(\"aui-md-pre\", className)} {...props} />\n ),\n code: ({ node, className, ...props }) => {\n const isCodeBlock = useIsMarkdownCodeBlock();\n return (\n <code\n className={classNames(!isCodeBlock && \"aui-md-inline-code\", className)}\n {...props}\n />\n );\n },\n CodeHeader,\n};\n\nexport const makeMarkdownText = ({\n className,\n components: userComponents,\n ...rest\n}: MakeMarkdownTextProps = {}) => {\n const components = {\n ...defaultComponents,\n ...Object.fromEntries(\n // ignore undefined values, so undefined values do not override default components\n Object.entries(userComponents ?? {}).filter(([_, v]) => v !== undefined),\n ),\n };\n\n const MarkdownTextImpl: FC = () => {\n const status = useSmoothStatus();\n return (\n <MarkdownTextPrimitive\n components={components}\n {...rest}\n className={classNames(\n status.type === \"running\" && \"aui-md-running\",\n className,\n )}\n />\n );\n };\n MarkdownTextImpl.displayName = \"MarkdownText\";\n\n return memo(withSmoothContextProvider(MarkdownTextImpl), () => true);\n};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AAG,MAAM,MAChC,4CAAC,SAAI,eAAW,kBAAAA,SAAW,cAAc,SAAS,GAAI,GAAG,OAAO;AAAA,EAElE,MAAM,CAAC,EAAE,MAAM,WAAW,GAAG,MAAM,MAAM;AACvC,UAAM,kBAAc,2CAAuB;AAC3C,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,kBAAAA,SAAW,CAAC,eAAe,sBAAsB,SAAS;AAAA,QACpE,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AAAA,EACA;AACF;AAEO,MAAM,mBAAmB,CAAC;AAAA,EAC/B;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,IAA2B,CAAC,MAAM;AAChC,QAAM,aAAa;AAAA,IACjB,GAAG;AAAA,IACH,GAAG,OAAO;AAAA;AAAA,MAER,OAAO,QAAQ,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,MAAM,MAAM,MAAS;AAAA,IACzE;AAAA,EACF;AAEA,QAAM,mBAAuB,MAAM;AACjC,UAAM,SAAS,gBAAgB;AAC/B,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACC,GAAG;AAAA,QACJ,eAAW,kBAAAA;AAAA,UACT,OAAO,SAAS,aAAa;AAAA,UAC7B;AAAA,QACF;AAAA;AAAA,IACF;AAAA,EAEJ;AACA,mBAAiB,cAAc;AAE/B,aAAO,mBAAK,0BAA0B,gBAAgB,GAAG,MAAM,IAAI;AACrE;","names":["import_react","classNames"]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { CodeHeader } from "./code-header";
|
|
4
|
+
import classNames from "classnames";
|
|
5
|
+
import {
|
|
6
|
+
MarkdownTextPrimitive
|
|
7
|
+
} from "../primitives/MarkdownText";
|
|
8
|
+
import { INTERNAL } from "@assistant-ui/react";
|
|
9
|
+
import { useIsMarkdownCodeBlock } from "../overrides/PreOverride";
|
|
10
|
+
const { withSmoothContextProvider, useSmoothStatus } = INTERNAL;
|
|
11
|
+
const defaultComponents = {
|
|
12
|
+
h1: ({ node, className, ...props }) => /* @__PURE__ */ jsx("h1", { className: classNames("aui-md-h1", className), ...props }),
|
|
13
|
+
h2: ({ node, className, ...props }) => /* @__PURE__ */ jsx("h2", { className: classNames("aui-md-h2", className), ...props }),
|
|
14
|
+
h3: ({ node, className, ...props }) => /* @__PURE__ */ jsx("h3", { className: classNames("aui-md-h3", className), ...props }),
|
|
15
|
+
h4: ({ node, className, ...props }) => /* @__PURE__ */ jsx("h4", { className: classNames("aui-md-h4", className), ...props }),
|
|
16
|
+
h5: ({ node, className, ...props }) => /* @__PURE__ */ jsx("h5", { className: classNames("aui-md-h5", className), ...props }),
|
|
17
|
+
h6: ({ node, className, ...props }) => /* @__PURE__ */ jsx("h6", { className: classNames("aui-md-h6", className), ...props }),
|
|
18
|
+
p: ({ node, className, ...props }) => /* @__PURE__ */ jsx("p", { className: classNames("aui-md-p", className), ...props }),
|
|
19
|
+
a: ({ node, className, ...props }) => /* @__PURE__ */ jsx("a", { className: classNames("aui-md-a", className), ...props }),
|
|
20
|
+
blockquote: ({ node, className, ...props }) => /* @__PURE__ */ jsx(
|
|
21
|
+
"blockquote",
|
|
22
|
+
{
|
|
23
|
+
className: classNames("aui-md-blockquote", className),
|
|
24
|
+
...props
|
|
25
|
+
}
|
|
26
|
+
),
|
|
27
|
+
ul: ({ node, className, ...props }) => /* @__PURE__ */ jsx("ul", { className: classNames("aui-md-ul", className), ...props }),
|
|
28
|
+
ol: ({ node, className, ...props }) => /* @__PURE__ */ jsx("ol", { className: classNames("aui-md-ol", className), ...props }),
|
|
29
|
+
hr: ({ node, className, ...props }) => /* @__PURE__ */ jsx("hr", { className: classNames("aui-md-hr", className), ...props }),
|
|
30
|
+
table: ({ node, className, ...props }) => /* @__PURE__ */ jsx("table", { className: classNames("aui-md-table", className), ...props }),
|
|
31
|
+
th: ({ node, className, ...props }) => /* @__PURE__ */ jsx("th", { className: classNames("aui-md-th", className), ...props }),
|
|
32
|
+
td: ({ node, className, ...props }) => /* @__PURE__ */ jsx("td", { className: classNames("aui-md-td", className), ...props }),
|
|
33
|
+
tr: ({ node, className, ...props }) => /* @__PURE__ */ jsx("tr", { className: classNames("aui-md-tr", className), ...props }),
|
|
34
|
+
sup: ({ node, className, ...props }) => /* @__PURE__ */ jsx("sup", { className: classNames("aui-md-sup", className), ...props }),
|
|
35
|
+
pre: ({ node, className, ...props }) => /* @__PURE__ */ jsx("pre", { className: classNames("aui-md-pre", className), ...props }),
|
|
36
|
+
code: ({ node, className, ...props }) => {
|
|
37
|
+
const isCodeBlock = useIsMarkdownCodeBlock();
|
|
38
|
+
return /* @__PURE__ */ jsx(
|
|
39
|
+
"code",
|
|
40
|
+
{
|
|
41
|
+
className: classNames(!isCodeBlock && "aui-md-inline-code", className),
|
|
42
|
+
...props
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
},
|
|
46
|
+
CodeHeader
|
|
47
|
+
};
|
|
48
|
+
const makeMarkdownText = ({
|
|
49
|
+
className,
|
|
50
|
+
components: userComponents,
|
|
51
|
+
...rest
|
|
52
|
+
} = {}) => {
|
|
53
|
+
const components = {
|
|
54
|
+
...defaultComponents,
|
|
55
|
+
...Object.fromEntries(
|
|
56
|
+
// ignore undefined values, so undefined values do not override default components
|
|
57
|
+
Object.entries(userComponents ?? {}).filter(([_, v]) => v !== void 0)
|
|
58
|
+
)
|
|
59
|
+
};
|
|
60
|
+
const MarkdownTextImpl = () => {
|
|
61
|
+
const status = useSmoothStatus();
|
|
62
|
+
return /* @__PURE__ */ jsx(
|
|
63
|
+
MarkdownTextPrimitive,
|
|
64
|
+
{
|
|
65
|
+
components,
|
|
66
|
+
...rest,
|
|
67
|
+
className: classNames(
|
|
68
|
+
status.type === "running" && "aui-md-running",
|
|
69
|
+
className
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
MarkdownTextImpl.displayName = "MarkdownText";
|
|
75
|
+
return memo(withSmoothContextProvider(MarkdownTextImpl), () => true);
|
|
76
|
+
};
|
|
77
|
+
export {
|
|
78
|
+
makeMarkdownText
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=markdown-text.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/markdown-text.tsx"],"sourcesContent":["import { FC, memo } from \"react\";\nimport { CodeHeader } from \"./code-header\";\nimport classNames from \"classnames\";\nimport {\n MarkdownTextPrimitive,\n MarkdownTextPrimitiveProps,\n} from \"../primitives/MarkdownText\";\nimport { INTERNAL } from \"@assistant-ui/react\";\nimport { useIsMarkdownCodeBlock } from \"../overrides/PreOverride\";\n\nconst { withSmoothContextProvider, useSmoothStatus } = INTERNAL;\n\nexport type MakeMarkdownTextProps = MarkdownTextPrimitiveProps;\n\nconst defaultComponents: MakeMarkdownTextProps[\"components\"] = {\n h1: ({ node, className, ...props }) => (\n <h1 className={classNames(\"aui-md-h1\", className)} {...props} />\n ),\n h2: ({ node, className, ...props }) => (\n <h2 className={classNames(\"aui-md-h2\", className)} {...props} />\n ),\n h3: ({ node, className, ...props }) => (\n <h3 className={classNames(\"aui-md-h3\", className)} {...props} />\n ),\n h4: ({ node, className, ...props }) => (\n <h4 className={classNames(\"aui-md-h4\", className)} {...props} />\n ),\n h5: ({ node, className, ...props }) => (\n <h5 className={classNames(\"aui-md-h5\", className)} {...props} />\n ),\n h6: ({ node, className, ...props }) => (\n <h6 className={classNames(\"aui-md-h6\", className)} {...props} />\n ),\n p: ({ node, className, ...props }) => (\n <p className={classNames(\"aui-md-p\", className)} {...props} />\n ),\n a: ({ node, className, ...props }) => (\n <a className={classNames(\"aui-md-a\", className)} {...props} />\n ),\n blockquote: ({ node, className, ...props }) => (\n <blockquote\n className={classNames(\"aui-md-blockquote\", className)}\n {...props}\n />\n ),\n ul: ({ node, className, ...props }) => (\n <ul className={classNames(\"aui-md-ul\", className)} {...props} />\n ),\n ol: ({ node, className, ...props }) => (\n <ol className={classNames(\"aui-md-ol\", className)} {...props} />\n ),\n hr: ({ node, className, ...props }) => (\n <hr className={classNames(\"aui-md-hr\", className)} {...props} />\n ),\n table: ({ node, className, ...props }) => (\n <table className={classNames(\"aui-md-table\", className)} {...props} />\n ),\n th: ({ node, className, ...props }) => (\n <th className={classNames(\"aui-md-th\", className)} {...props} />\n ),\n td: ({ node, className, ...props }) => (\n <td className={classNames(\"aui-md-td\", className)} {...props} />\n ),\n tr: ({ node, className, ...props }) => (\n <tr className={classNames(\"aui-md-tr\", className)} {...props} />\n ),\n sup: ({ node, className, ...props }) => (\n <sup className={classNames(\"aui-md-sup\", className)} {...props} />\n ),\n pre: ({ node, className, ...props }) => (\n <pre className={classNames(\"aui-md-pre\", className)} {...props} />\n ),\n code: ({ node, className, ...props }) => {\n const isCodeBlock = useIsMarkdownCodeBlock();\n return (\n <code\n className={classNames(!isCodeBlock && \"aui-md-inline-code\", className)}\n {...props}\n />\n );\n },\n CodeHeader,\n};\n\nexport const makeMarkdownText = ({\n className,\n components: userComponents,\n ...rest\n}: MakeMarkdownTextProps = {}) => {\n const components = {\n ...defaultComponents,\n ...Object.fromEntries(\n // ignore undefined values, so undefined values do not override default components\n Object.entries(userComponents ?? {}).filter(([_, v]) => v !== undefined),\n ),\n };\n\n const MarkdownTextImpl: FC = () => {\n const status = useSmoothStatus();\n return (\n <MarkdownTextPrimitive\n components={components}\n {...rest}\n className={classNames(\n status.type === \"running\" && \"aui-md-running\",\n className,\n )}\n />\n );\n };\n MarkdownTextImpl.displayName = \"MarkdownText\";\n\n return memo(withSmoothContextProvider(MarkdownTextImpl), () => true);\n};\n"],"mappings":"AAgBI;AAhBJ,SAAa,YAAY;AACzB,SAAS,kBAAkB;AAC3B,OAAO,gBAAgB;AACvB;AAAA,EACE;AAAA,OAEK;AACP,SAAS,gBAAgB;AACzB,SAAS,8BAA8B;AAEvC,MAAM,EAAE,2BAA2B,gBAAgB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AY;AAAA,EACZ,GAAG;AACL,IAA2B,CAAC,MAAM;AAChC,QAAM,aAAa;AAAA,IACjB,GAAG;AAAA,IACH,GAAG,OAAO;AAAA;AAAA,MAER,OAAO,QAAQ,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,MAAM,MAAM,MAAS;AAAA,IACzE;AAAA,EACF;AAEA,QAAM,mBAAuB,MAAM;AACjC,UAAM,SAAS,gBAAgB;AAC/B,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACC,GAAG;AAAA,QACJ,WAAW;AAAA,UACT,OAAO,SAAS,aAAa;AAAA,UAC7B;AAAA,QACF;AAAA;AAAA,IACF;AAAA,EAEJ;AACA,mBAAiB,cAAc;AAE/B,SAAO,KAAK,0BAA0B,gBAAgB,GAAG,MAAM,IAAI;AACrE;","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UseActionBarCopyProps } from "@assistant-ui/react";
|
|
2
|
+
export type useCopyToClipboardProps = UseActionBarCopyProps;
|
|
3
|
+
export declare const useCopyToClipboard: ({ copiedDuration, }?: useCopyToClipboardProps) => {
|
|
4
|
+
isCopied: boolean;
|
|
5
|
+
copyToClipboard: (value: string) => void;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=useCopyToClipboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopyToClipboard.d.ts","sourceRoot":"","sources":["../../src/ui/useCopyToClipboard.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AAE5D,eAAO,MAAM,kBAAkB,yBAE5B,uBAAuB;;6BAGQ,MAAM;CAUvC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useCopyToClipboard_exports = {};
|
|
20
|
+
__export(useCopyToClipboard_exports, {
|
|
21
|
+
useCopyToClipboard: () => useCopyToClipboard
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useCopyToClipboard_exports);
|
|
24
|
+
var import_react = require("react");
|
|
25
|
+
const useCopyToClipboard = ({
|
|
26
|
+
copiedDuration = 3e3
|
|
27
|
+
} = {}) => {
|
|
28
|
+
const [isCopied, setIsCopied] = (0, import_react.useState)(false);
|
|
29
|
+
const copyToClipboard = (value) => {
|
|
30
|
+
if (!value) return;
|
|
31
|
+
navigator.clipboard.writeText(value).then(() => {
|
|
32
|
+
setIsCopied(true);
|
|
33
|
+
setTimeout(() => setIsCopied(false), copiedDuration);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
return { isCopied, copyToClipboard };
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
useCopyToClipboard
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=useCopyToClipboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/useCopyToClipboard.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { UseActionBarCopyProps } from \"@assistant-ui/react\";\n\nexport type useCopyToClipboardProps = UseActionBarCopyProps;\n\nexport const useCopyToClipboard = ({\n copiedDuration = 3000,\n}: useCopyToClipboardProps = {}) => {\n const [isCopied, setIsCopied] = useState<boolean>(false);\n\n const copyToClipboard = (value: string) => {\n if (!value) return;\n\n navigator.clipboard.writeText(value).then(() => {\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), copiedDuration);\n });\n };\n\n return { isCopied, copyToClipboard };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAyB;AAKlB,MAAM,qBAAqB,CAAC;AAAA,EACjC,iBAAiB;AACnB,IAA6B,CAAC,MAAM;AAClC,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAkB,KAAK;AAEvD,QAAM,kBAAkB,CAAC,UAAkB;AACzC,QAAI,CAAC,MAAO;AAEZ,cAAU,UAAU,UAAU,KAAK,EAAE,KAAK,MAAM;AAC9C,kBAAY,IAAI;AAChB,iBAAW,MAAM,YAAY,KAAK,GAAG,cAAc;AAAA,IACrD,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,UAAU,gBAAgB;AACrC;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
const useCopyToClipboard = ({
|
|
3
|
+
copiedDuration = 3e3
|
|
4
|
+
} = {}) => {
|
|
5
|
+
const [isCopied, setIsCopied] = useState(false);
|
|
6
|
+
const copyToClipboard = (value) => {
|
|
7
|
+
if (!value) return;
|
|
8
|
+
navigator.clipboard.writeText(value).then(() => {
|
|
9
|
+
setIsCopied(true);
|
|
10
|
+
setTimeout(() => setIsCopied(false), copiedDuration);
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
return { isCopied, copyToClipboard };
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
useCopyToClipboard
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useCopyToClipboard.mjs.map
|