@assistant-ui/react-markdown 0.7.21 → 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.
Files changed (44) hide show
  1. package/dist/index.d.ts +0 -7
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +0 -6
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +0 -6
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +3 -18
  8. package/src/index.ts +0 -12
  9. package/dist/styles/markdown.css +0 -274
  10. package/dist/styles/markdown.css.map +0 -1
  11. package/dist/styles/tailwindcss/markdown.css +0 -106
  12. package/dist/styles/tailwindcss/markdown.css.json +0 -68
  13. package/dist/tailwindcss/index.d.ts +0 -9
  14. package/dist/tailwindcss/index.d.ts.map +0 -1
  15. package/dist/tailwindcss/index.js +0 -113
  16. package/dist/tailwindcss/index.js.map +0 -1
  17. package/dist/tailwindcss/index.mjs +0 -105
  18. package/dist/tailwindcss/index.mjs.map +0 -1
  19. package/dist/ui/code-header.d.ts +0 -4
  20. package/dist/ui/code-header.d.ts.map +0 -1
  21. package/dist/ui/code-header.js +0 -54
  22. package/dist/ui/code-header.js.map +0 -1
  23. package/dist/ui/code-header.mjs +0 -29
  24. package/dist/ui/code-header.mjs.map +0 -1
  25. package/dist/ui/markdown-text.d.ts +0 -4
  26. package/dist/ui/markdown-text.d.ts.map +0 -1
  27. package/dist/ui/markdown-text.js +0 -114
  28. package/dist/ui/markdown-text.js.map +0 -1
  29. package/dist/ui/markdown-text.mjs +0 -81
  30. package/dist/ui/markdown-text.mjs.map +0 -1
  31. package/dist/ui/useCopyToClipboard.d.ts +0 -11
  32. package/dist/ui/useCopyToClipboard.d.ts.map +0 -1
  33. package/dist/ui/useCopyToClipboard.js +0 -45
  34. package/dist/ui/useCopyToClipboard.js.map +0 -1
  35. package/dist/ui/useCopyToClipboard.mjs +0 -21
  36. package/dist/ui/useCopyToClipboard.mjs.map +0 -1
  37. package/src/styles/tailwindcss/markdown.css +0 -106
  38. package/src/tailwindcss/index.ts +0 -8
  39. package/src/ui/code-header.tsx +0 -32
  40. package/src/ui/markdown-text.tsx +0 -114
  41. package/src/ui/useCopyToClipboard.tsx +0 -26
  42. package/tailwindcss/README.md +0 -1
  43. package/tailwindcss/package-lock.json +0 -6
  44. package/tailwindcss/package.json +0 -5
@@ -1,45 +0,0 @@
1
- "use strict";
2
- "use client";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
-
21
- // src/ui/useCopyToClipboard.tsx
22
- var useCopyToClipboard_exports = {};
23
- __export(useCopyToClipboard_exports, {
24
- useCopyToClipboard: () => useCopyToClipboard
25
- });
26
- module.exports = __toCommonJS(useCopyToClipboard_exports);
27
- var import_react = require("react");
28
- var useCopyToClipboard = ({
29
- copiedDuration = 3e3
30
- } = {}) => {
31
- const [isCopied, setIsCopied] = (0, import_react.useState)(false);
32
- const copyToClipboard = (value) => {
33
- if (!value) return;
34
- navigator.clipboard.writeText(value).then(() => {
35
- setIsCopied(true);
36
- setTimeout(() => setIsCopied(false), copiedDuration);
37
- });
38
- };
39
- return { isCopied, copyToClipboard };
40
- };
41
- // Annotate the CommonJS export names for ESM import in node:
42
- 0 && (module.exports = {
43
- useCopyToClipboard
44
- });
45
- //# sourceMappingURL=useCopyToClipboard.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/ui/useCopyToClipboard.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\n\nnamespace useCopyToClipboard {\n export interface Options {\n copiedDuration?: number;\n }\n}\n\nexport const useCopyToClipboard = ({\n copiedDuration = 3000,\n}: useCopyToClipboard.Options = {}) => {\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;AAEA,mBAAyB;AAQlB,IAAM,qBAAqB,CAAC;AAAA,EACjC,iBAAiB;AACnB,IAAgC,CAAC,MAAM;AACrC,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":[]}
@@ -1,21 +0,0 @@
1
- "use client";
2
-
3
- // src/ui/useCopyToClipboard.tsx
4
- import { useState } from "react";
5
- var useCopyToClipboard = ({
6
- copiedDuration = 3e3
7
- } = {}) => {
8
- const [isCopied, setIsCopied] = useState(false);
9
- const copyToClipboard = (value) => {
10
- if (!value) return;
11
- navigator.clipboard.writeText(value).then(() => {
12
- setIsCopied(true);
13
- setTimeout(() => setIsCopied(false), copiedDuration);
14
- });
15
- };
16
- return { isCopied, copyToClipboard };
17
- };
18
- export {
19
- useCopyToClipboard
20
- };
21
- //# sourceMappingURL=useCopyToClipboard.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/ui/useCopyToClipboard.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\n\nnamespace useCopyToClipboard {\n export interface Options {\n copiedDuration?: number;\n }\n}\n\nexport const useCopyToClipboard = ({\n copiedDuration = 3000,\n}: useCopyToClipboard.Options = {}) => {\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":";;;AAEA,SAAS,gBAAgB;AAQlB,IAAM,qBAAqB,CAAC;AAAA,EACjC,iBAAiB;AACnB,IAAgC,CAAC,MAAM;AACrC,QAAM,CAAC,UAAU,WAAW,IAAI,SAAkB,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":[]}
@@ -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
- }
@@ -1,8 +0,0 @@
1
- import plugin from "tailwindcss/plugin.js";
2
- import markdownCSS from "../../dist/styles/tailwindcss/markdown.css.json";
3
-
4
- const auiPlugin = plugin.withOptions<{}>(() => ({ addComponents }) => {
5
- addComponents(markdownCSS);
6
- });
7
-
8
- export default auiPlugin;
@@ -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
- };
@@ -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
- };
@@ -1 +0,0 @@
1
- This directory exists to support subpath imports for TypeScript projects using --moduleResolution node.
@@ -1,6 +0,0 @@
1
- {
2
- "name": "tailwindcss",
3
- "lockfileVersion": 3,
4
- "requires": true,
5
- "packages": {}
6
- }
@@ -1,5 +0,0 @@
1
- {
2
- "main": "../dist/tailwindcss/index.js",
3
- "module": "../dist/tailwindcss/index.mjs",
4
- "types": "../dist/tailwindcss/index.d.ts"
5
- }