@chat-lab/ui 0.1.0-beta.79 → 0.1.0-beta.80
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/components/assistant-ui/markdown-text.cjs +12 -12
- package/dist/components/assistant-ui/markdown-text.cjs.map +1 -1
- package/dist/components/assistant-ui/markdown-text.js +12 -12
- package/dist/components/assistant-ui/markdown-text.js.map +1 -1
- package/dist/components/assistant-ui/message-components-with-avatar.cjs +23 -27
- package/dist/components/assistant-ui/message-components-with-avatar.cjs.map +1 -1
- package/dist/components/assistant-ui/message-components-with-avatar.d.ts +3 -1
- package/dist/components/assistant-ui/message-components-with-avatar.d.ts.map +1 -1
- package/dist/components/assistant-ui/message-components-with-avatar.js +23 -27
- package/dist/components/assistant-ui/message-components-with-avatar.js.map +1 -1
- package/dist/components/assistant-ui/thread.cjs +12 -3
- package/dist/components/assistant-ui/thread.cjs.map +1 -1
- package/dist/components/assistant-ui/thread.d.ts.map +1 -1
- package/dist/components/assistant-ui/thread.js +13 -4
- package/dist/components/assistant-ui/thread.js.map +1 -1
- package/dist/core/dist/index.cjs +42 -10
- package/dist/core/dist/index.cjs.map +1 -1
- package/dist/core/dist/index.js +42 -10
- package/dist/core/dist/index.js.map +1 -1
- package/dist/hooks/useClawChat/ClawProtocolAdaptor.cjs +0 -6
- package/dist/hooks/useClawChat/ClawProtocolAdaptor.cjs.map +1 -1
- package/dist/hooks/useClawChat/ClawProtocolAdaptor.d.ts.map +1 -1
- package/dist/hooks/useClawChat/ClawProtocolAdaptor.js +0 -6
- package/dist/hooks/useClawChat/ClawProtocolAdaptor.js.map +1 -1
- package/dist/hooks/useClawChat/clawCompletion.cjs +1 -1
- package/dist/hooks/useClawChat/clawCompletion.cjs.map +1 -1
- package/dist/hooks/useClawChat/clawCompletion.d.ts +1 -1
- package/dist/hooks/useClawChat/clawCompletion.d.ts.map +1 -1
- package/dist/hooks/useClawChat/clawCompletion.js +1 -1
- package/dist/hooks/useClawChat/clawCompletion.js.map +1 -1
- package/dist/hooks/useClawChat/clawPlugin.cjs +23 -3
- package/dist/hooks/useClawChat/clawPlugin.cjs.map +1 -1
- package/dist/hooks/useClawChat/clawPlugin.d.ts +2 -0
- package/dist/hooks/useClawChat/clawPlugin.d.ts.map +1 -1
- package/dist/hooks/useClawChat/clawPlugin.js +23 -3
- package/dist/hooks/useClawChat/clawPlugin.js.map +1 -1
- package/dist/hooks/useClawChat/index.cjs +12 -9
- package/dist/hooks/useClawChat/index.cjs.map +1 -1
- package/dist/hooks/useClawChat/index.d.ts.map +1 -1
- package/dist/hooks/useClawChat/index.js +12 -9
- package/dist/hooks/useClawChat/index.js.map +1 -1
- package/dist/hooks/useClawChat/types.cjs +2 -2
- package/dist/hooks/useClawChat/types.cjs.map +1 -1
- package/dist/hooks/useClawChat/types.d.ts.map +1 -1
- package/dist/hooks/useClawChat/types.js +2 -2
- package/dist/hooks/useClawChat/types.js.map +1 -1
- package/dist/index.css +1 -1
- package/package.json +1 -1
|
@@ -102,13 +102,13 @@ const useCopyToClipboard = ({ copiedDuration = 3000, } = {}) => {
|
|
|
102
102
|
return { isCopied, copyToClipboard };
|
|
103
103
|
};
|
|
104
104
|
const defaultComponents = reactMarkdown.unstable_memoizeMarkdownComponents({
|
|
105
|
-
h1: ({ className, ...props }) => (jsxRuntime.jsx("h1", { className: utils.cn('aui-md-h1 mb-
|
|
106
|
-
h2: ({ className, ...props }) => (jsxRuntime.jsx("h2", { className: utils.cn('aui-md-h2 mt-6 mb-4 scroll-m-20 text-
|
|
107
|
-
h3: ({ className, ...props }) => (jsxRuntime.jsx("h3", { className: utils.cn('aui-md-h3 mt-
|
|
108
|
-
h4: ({ className, ...props }) => (jsxRuntime.jsx("h4", { className: utils.cn('aui-md-h4 mt-
|
|
109
|
-
h5: ({ className, ...props }) => (jsxRuntime.jsx("h5", { className: utils.cn('aui-md-h5 my-
|
|
105
|
+
h1: ({ className, ...props }) => (jsxRuntime.jsx("h1", { className: utils.cn('aui-md-h1 mb-[12px] scroll-m-20 text-[26px] leading-[37px] font-extrabold tracking-tight last:mb-0', className), ...props })),
|
|
106
|
+
h2: ({ className, ...props }) => (jsxRuntime.jsx("h2", { className: utils.cn('aui-md-h2 mt-6 mb-4 scroll-m-20 text-[22px] leading-[30px] font-[500] tracking-tight first:mt-0 last:mb-0', className), ...props })),
|
|
107
|
+
h3: ({ className, ...props }) => (jsxRuntime.jsx("h3", { className: utils.cn('aui-md-h3 mt-[12px] mb-[12px] scroll-m-20 text-[20px] font-[500] leading-[28px] tracking-tight first:mt-0 last:mb-0', className), ...props })),
|
|
108
|
+
h4: ({ className, ...props }) => (jsxRuntime.jsx("h4", { className: utils.cn('aui-md-h4 mt-[12px] mb-[12px] scroll-m-20 text-[18px] leading-[25px] font-[500] tracking-tight first:mt-0 last:mb-0', className), ...props })),
|
|
109
|
+
h5: ({ className, ...props }) => (jsxRuntime.jsx("h5", { className: utils.cn('aui-md-h5 my-[12px] text-[16px] leading-[22px] font-[500] first:mt-0 last:mb-0', className), ...props })),
|
|
110
110
|
h6: ({ className, ...props }) => (jsxRuntime.jsx("h6", { className: utils.cn('aui-md-h6 my-4 font-semibold first:mt-0 last:mb-0', className), ...props })),
|
|
111
|
-
p: ({ className, ...props }) => (jsxRuntime.jsx("p", { className: utils.cn('aui-md-p text-[
|
|
111
|
+
p: ({ className, ...props }) => (jsxRuntime.jsx("p", { className: utils.cn('aui-md-p text-[16px] mt-[12px] mb-[12px] leading-[24px] first:mt-0 last:mb-0 chatkit-md-text-p', className), ...props })),
|
|
112
112
|
image: ({ className, ...props }) => (jsxRuntime.jsx("img", { src: props.href, style: { maxWidth: 400 }, className: utils.cn('aui-md-img max-w-full rounded-lg', className) })),
|
|
113
113
|
a: ({ className, ...props }) => {
|
|
114
114
|
const isVideo = (href) => {
|
|
@@ -119,13 +119,13 @@ const defaultComponents = reactMarkdown.unstable_memoizeMarkdownComponents({
|
|
|
119
119
|
if (isVideo(props.href)) {
|
|
120
120
|
return jsxRuntime.jsx(Video, { src: props.href, className: className, ...props });
|
|
121
121
|
}
|
|
122
|
-
return (jsxRuntime.jsx("a", { className: utils.cn('aui-md-a font-
|
|
122
|
+
return (jsxRuntime.jsx("a", { className: utils.cn('aui-md-a font-[400] leading-[24px] text-[16px] underline underline-offset-4', className), ...props }));
|
|
123
123
|
},
|
|
124
124
|
video: ({ className, ...props }) => (jsxRuntime.jsx(Video, { className: className, ...props })),
|
|
125
|
-
blockquote: ({ className, ...props }) => (jsxRuntime.jsx("blockquote", { className: utils.cn('aui-md-blockquote border-
|
|
126
|
-
ul: ({ className, ...props }) => (jsxRuntime.jsx("ul", { className: utils.cn('aui-md-ul my-
|
|
127
|
-
ol: ({ className, ...props }) => (jsxRuntime.jsx("ol", { className: utils.cn('aui-md-ol my-
|
|
128
|
-
hr: ({ className, ...props }) => (jsxRuntime.jsx("hr", { className: utils.cn('aui-md-hr my-
|
|
125
|
+
blockquote: ({ className, ...props }) => (jsxRuntime.jsx("blockquote", { className: utils.cn('aui-md-blockquote border-[1px solid #F5F6F7] pl-6 italic', className), ...props })),
|
|
126
|
+
ul: ({ className, ...props }) => (jsxRuntime.jsx("ul", { className: utils.cn('aui-md-ul my-[12px] ml-6 list-disc [&>li]:mt-2 [&>li]:text-[16px] leading-[24px]', className), ...props })),
|
|
127
|
+
ol: ({ className, ...props }) => (jsxRuntime.jsx("ol", { className: utils.cn('aui-md-ol my-[12px] ml-6 list-decimal [&>li]:mt-2 [&>li]:text-[16px] leading-[24px]', className), ...props })),
|
|
128
|
+
hr: ({ className, ...props }) => (jsxRuntime.jsx("hr", { className: utils.cn('aui-md-hr my-[12px] border-b', className), ...props })),
|
|
129
129
|
table: ({ className, ...props }) => (jsxRuntime.jsx("table", { className: utils.cn('aui-md-table my-5 w-full border-separate border-spacing-0 overflow-y-auto', className), ...props })),
|
|
130
130
|
th: ({ className, ...props }) => (jsxRuntime.jsx("th", { className: utils.cn('aui-md-th bg-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', className), ...props })),
|
|
131
131
|
td: ({ className, ...props }) => (jsxRuntime.jsx("td", { className: utils.cn('aui-md-td border-b border-l px-4 py-2 text-left last:border-r [&[align=center]]:text-center [&[align=right]]:text-right', className), ...props })),
|
|
@@ -136,7 +136,7 @@ const defaultComponents = reactMarkdown.unstable_memoizeMarkdownComponents({
|
|
|
136
136
|
code: function Code({ className, ...props }) {
|
|
137
137
|
const isCodeBlock = reactMarkdown.useIsMarkdownCodeBlock();
|
|
138
138
|
return (jsxRuntime.jsx("code", { className: utils.cn(!isCodeBlock
|
|
139
|
-
&& 'aui-md-inline-code rounded border bg-muted font-
|
|
139
|
+
&& 'aui-md-inline-code rounded border bg-muted font-[400] text-[16px] leading-[24px] px-[2px]', className), ...props }));
|
|
140
140
|
},
|
|
141
141
|
CodeHeader,
|
|
142
142
|
div: ({ className, ...props }) => jsxRuntime.jsx("div", { className: className, ...props }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-text.cjs","sources":["../../../src/components/assistant-ui/markdown-text.tsx"],"sourcesContent":["'use client';\n\nimport '@assistant-ui/react-markdown/styles/dot.css';\n\nimport {\n type CodeHeaderProps,\n MarkdownTextPrimitive,\n unstable_memoizeMarkdownComponents as memoizeMarkdownComponents,\n useIsMarkdownCodeBlock,\n} from '@assistant-ui/react-markdown';\nimport remarkGfm from 'remark-gfm';\nimport remarkBreaks from 'remark-breaks';\nimport rehypeRaw from 'rehype-raw';\nimport rehypeSanitize, { defaultSchema } from 'rehype-sanitize';\nimport { type FC, memo, useState } from 'react';\nimport { CheckIcon, CopyIcon, Loader2 } from 'lucide-react';\nimport './index.less';\nimport { TooltipIconButton } from '@/components/assistant-ui/tooltip-icon-button';\nimport { cn } from '@/lib/utils';\nimport { useDebounce } from '@/hooks/useDebounce';\nimport { PluggableList } from 'unified';\nimport { useI18n } from '@/contexts/I18nContext';\nimport { SyntaxHighlighter } from './shiki-highlighter';\n\nconst schema = {\n ...defaultSchema,\n // 1. 添加标签到白名单\n tagNames: [...(defaultSchema.tagNames || []), 'video', 'source', 'iframe'],\n // 2. 添加允许的属性\n attributes: {\n ...defaultSchema.attributes,\n iframe: [\n 'src',\n 'width',\n 'height',\n 'frameborder',\n 'allow',\n 'allowfullscreen',\n ],\n // 允许 video 标签使用的属性\n video: [\n 'controls',\n 'width',\n 'height',\n 'poster',\n 'preload',\n 'src',\n 'muted',\n 'loop',\n 'autoPlay',\n 'playsInline',\n ],\n div: [\n ...(defaultSchema.attributes?.div || []),\n 'className', //\n 'data-content', // 如果你在插件里用了 data-content\n ],\n // 允许 source 标签使用的属性\n source: ['src', 'type'],\n },\n};\n\nconst remarkPlugins: PluggableList = [remarkGfm, remarkBreaks];\n\nconst rehypePlugins: PluggableList = [\n rehypeRaw,\n [rehypeSanitize, schema],\n // rehypeAppendCursor,\n];\n\nfunction MarkdownTextImpl() {\n return (\n <MarkdownTextPrimitive\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n className=\"aui-md\"\n // smooth={false}\n components={defaultComponents}\n />\n );\n}\n\nexport const MarkdownText = memo(MarkdownTextImpl);\n\nconst CodeHeader: FC<CodeHeaderProps> = ({ language, code }) => {\n const { isCopied, copyToClipboard } = useCopyToClipboard();\n const processedLanguage = language == 'unknown' ? 'text' : language;\n const { t } = useI18n();\n const onCopy = () => {\n if (!code || isCopied) return;\n copyToClipboard(code);\n };\n\n return (\n <div className=\"aui-code-header-root mt-4 flex items-center justify-between gap-4 rounded-t-lg border bg-muted-foreground/15 px-4 py-2 text-sm font-semibold text-foreground max-w-[800px] overflow-auto\">\n <span className=\"aui-code-header-language lowercase [&>span]:text-xs\">\n {processedLanguage}\n </span>\n <TooltipIconButton tooltip={t('thread.copy')} onClick={onCopy}>\n {!isCopied && <CopyIcon />}\n {isCopied && <CheckIcon />}\n </TooltipIconButton>\n </div>\n );\n};\n\nfunction Video({\n src,\n className,\n ...props\n}: {\n src?: string;\n className?: string;\n}) {\n const debouncedSrc = useDebounce(src, 500);\n return (\n <video\n src={debouncedSrc}\n style={{ maxWidth: 400 }}\n className={cn('aui-md-video max-w-full rounded-lg', className)}\n controls\n {...props}\n />\n );\n}\n\nconst videoExtensions = [\n '.mp4',\n '.avi',\n '.mov',\n '.wmv',\n '.flv',\n '.webm',\n '.mkv',\n '.m4v',\n];\n\nconst useCopyToClipboard = ({\n copiedDuration = 3000,\n}: {\n copiedDuration?: number;\n} = {}) => {\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\nconst defaultComponents = memoizeMarkdownComponents({\n h1: ({ className, ...props }) => (\n <h1\n className={cn(\n 'aui-md-h1 mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h2: ({ className, ...props }) => (\n <h2\n className={cn(\n 'aui-md-h2 mt-6 mb-4 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h3: ({ className, ...props }) => (\n <h3\n className={cn(\n 'aui-md-h3 mt-6 mb-4 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h4: ({ className, ...props }) => (\n <h4\n className={cn(\n 'aui-md-h4 mt-6 mb-4 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h5: ({ className, ...props }) => (\n <h5\n className={cn(\n 'aui-md-h5 my-4 text-lg font-semibold first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h6: ({ className, ...props }) => (\n <h6\n className={cn(\n 'aui-md-h6 my-4 font-semibold first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n p: ({ className, ...props }) => (\n <p\n className={cn(\n 'aui-md-p text-[13px] mt-5 mb-5 leading-7 first:mt-0 last:mb-0 chatkit-md-text-p',\n className,\n )}\n {...props}\n />\n ),\n image: ({ className, ...props }) => (\n <img\n src={props.href}\n style={{ maxWidth: 400 }}\n className={cn('aui-md-img max-w-full rounded-lg', className)}\n />\n ),\n a: ({ className, ...props }) => {\n const isVideo = (href: string | undefined) => {\n if (!href) return false;\n return videoExtensions.some((ext) => href.toLowerCase().includes(ext));\n };\n\n if (isVideo(props.href)) {\n return <Video src={props.href} className={className} {...props} />;\n }\n\n return (\n <a\n className={cn(\n 'aui-md-a font-medium text-primary underline underline-offset-4',\n className,\n )}\n {...props}\n />\n );\n },\n video: ({ className, ...props }) => (\n <Video className={className} {...props} />\n ),\n blockquote: ({ className, ...props }) => (\n <blockquote\n className={cn('aui-md-blockquote border-l-2 pl-6 italic', className)}\n {...props}\n />\n ),\n ul: ({ className, ...props }) => (\n <ul\n className={cn('aui-md-ul my-5 ml-6 list-disc [&>li]:mt-2', className)}\n {...props}\n />\n ),\n ol: ({ className, ...props }) => (\n <ol\n className={cn('aui-md-ol my-5 ml-6 list-decimal [&>li]:mt-2', className)}\n {...props}\n />\n ),\n hr: ({ className, ...props }) => (\n <hr className={cn('aui-md-hr my-5 border-b', className)} {...props} />\n ),\n table: ({ className, ...props }) => (\n <table\n className={cn(\n 'aui-md-table my-5 w-full border-separate border-spacing-0 overflow-y-auto',\n className,\n )}\n {...props}\n />\n ),\n th: ({ className, ...props }) => (\n <th\n className={cn(\n 'aui-md-th bg-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',\n className,\n )}\n {...props}\n />\n ),\n td: ({ className, ...props }) => (\n <td\n className={cn(\n 'aui-md-td border-b border-l px-4 py-2 text-left last:border-r [&[align=center]]:text-center [&[align=right]]:text-right',\n className,\n )}\n {...props}\n />\n ),\n tr: ({ className, ...props }) => (\n <tr\n className={cn(\n 'aui-md-tr 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',\n className,\n )}\n {...props}\n />\n ),\n sup: ({ className, ...props }) => (\n <sup\n className={cn('aui-md-sup [&>a]:text-xs [&>a]:no-underline', className)}\n {...props}\n />\n ),\n SyntaxHighlighter,\n pre: ({ className, ...props }) => (\n <pre\n className={cn(\n 'aui-md-pre overflow-x-auto !rounded-t-none rounded-b-lg p-4',\n className,\n )}\n {...props}\n />\n ),\n code: function Code({ className, ...props }) {\n const isCodeBlock = useIsMarkdownCodeBlock();\n return (\n <code\n className={cn(\n !isCodeBlock\n && 'aui-md-inline-code rounded border bg-muted font-semibold',\n className,\n )}\n {...props}\n />\n );\n },\n CodeHeader,\n div: ({ className, ...props }) => <div className={className} {...props} />,\n});\n"],"names":["defaultSchema","_jsx","MarkdownTextPrimitive","memo","useI18n","_jsxs","TooltipIconButton","CopyIcon","CheckIcon","useDebounce","cn","useState","memoizeMarkdownComponents","SyntaxHighlighter","useIsMarkdownCodeBlock"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,MAAM,MAAM,GAAG;AACb,IAAA,GAAGA,4BAAa;;AAEhB,IAAA,QAAQ,EAAE,CAAC,IAAIA,4BAAa,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC;;AAE1E,IAAA,UAAU,EAAE;QACV,GAAGA,4BAAa,CAAC,UAAU;AAC3B,QAAA,MAAM,EAAE;YACN,KAAK;YACL,OAAO;YACP,QAAQ;YACR,aAAa;YACb,OAAO;YACP,iBAAiB;AAClB,SAAA;;AAED,QAAA,KAAK,EAAE;YACL,UAAU;YACV,OAAO;YACP,QAAQ;YACR,QAAQ;YACR,SAAS;YACT,KAAK;YACL,OAAO;YACP,MAAM;YACN,UAAU;YACV,aAAa;AACd,SAAA;AACD,QAAA,GAAG,EAAE;YACH,IAAIA,4BAAa,C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AAES,QAAE,CACX,6DAA6D,EAC7D,SAAS,CACV,EAAA,GACG,KAAK,EAAA,CACT,CACH;IACD,IAAI,EAAE,SAAS,IAAI,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAA;AACzC,QAAA,MAAM,WAAW,GAAGI,oCAAsB,EAAE,CAAC;AAC7C,QAAA,QACEb,cACE,CAAA,MAAA,EAAA,EAAA,SAAS,EAAES,QAAE,CACX,CAAC,WAAW;AACP,mBAAA,0DAA0D,EAC/D,SAAS,CACV,KACG,KAAK,EAAA,CACT,EACF;KACH;IACD,UAAU;AACV,IAAA,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,KAAKT,cAAK,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,SAAS,EAAA,GAAM,KAAK,EAAI,CAAA;AAC3E,CAAA,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"markdown-text.cjs","sources":["../../../src/components/assistant-ui/markdown-text.tsx"],"sourcesContent":["'use client';\n\nimport '@assistant-ui/react-markdown/styles/dot.css';\n\nimport {\n type CodeHeaderProps,\n MarkdownTextPrimitive,\n unstable_memoizeMarkdownComponents as memoizeMarkdownComponents,\n useIsMarkdownCodeBlock,\n} from '@assistant-ui/react-markdown';\nimport remarkGfm from 'remark-gfm';\nimport remarkBreaks from 'remark-breaks';\nimport rehypeRaw from 'rehype-raw';\nimport rehypeSanitize, { defaultSchema } from 'rehype-sanitize';\nimport { type FC, memo, useState } from 'react';\nimport { CheckIcon, CopyIcon, Loader2 } from 'lucide-react';\nimport './index.less';\nimport { TooltipIconButton } from '@/components/assistant-ui/tooltip-icon-button';\nimport { cn } from '@/lib/utils';\nimport { useDebounce } from '@/hooks/useDebounce';\nimport { PluggableList } from 'unified';\nimport { useI18n } from '@/contexts/I18nContext';\nimport { SyntaxHighlighter } from './shiki-highlighter';\n\nconst schema = {\n ...defaultSchema,\n // 1. 添加标签到白名单\n tagNames: [...(defaultSchema.tagNames || []), 'video', 'source', 'iframe'],\n // 2. 添加允许的属性\n attributes: {\n ...defaultSchema.attributes,\n iframe: [\n 'src',\n 'width',\n 'height',\n 'frameborder',\n 'allow',\n 'allowfullscreen',\n ],\n // 允许 video 标签使用的属性\n video: [\n 'controls',\n 'width',\n 'height',\n 'poster',\n 'preload',\n 'src',\n 'muted',\n 'loop',\n 'autoPlay',\n 'playsInline',\n ],\n div: [\n ...(defaultSchema.attributes?.div || []),\n 'className', //\n 'data-content', // 如果你在插件里用了 data-content\n ],\n // 允许 source 标签使用的属性\n source: ['src', 'type'],\n },\n};\n\nconst remarkPlugins: PluggableList = [remarkGfm, remarkBreaks];\n\nconst rehypePlugins: PluggableList = [\n rehypeRaw,\n [rehypeSanitize, schema],\n // rehypeAppendCursor,\n];\n\nfunction MarkdownTextImpl() {\n return (\n <MarkdownTextPrimitive\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n className=\"aui-md\"\n // smooth={false}\n components={defaultComponents}\n />\n );\n}\n\nexport const MarkdownText = memo(MarkdownTextImpl);\n\nconst CodeHeader: FC<CodeHeaderProps> = ({ language, code }) => {\n const { isCopied, copyToClipboard } = useCopyToClipboard();\n const processedLanguage = language == 'unknown' ? 'text' : language;\n const { t } = useI18n();\n const onCopy = () => {\n if (!code || isCopied) return;\n copyToClipboard(code);\n };\n\n return (\n <div className=\"aui-code-header-root mt-4 flex items-center justify-between gap-4 rounded-t-lg border bg-muted-foreground/15 px-4 py-2 text-sm font-semibold text-foreground max-w-[800px] overflow-auto\">\n <span className=\"aui-code-header-language lowercase [&>span]:text-xs\">\n {processedLanguage}\n </span>\n <TooltipIconButton tooltip={t('thread.copy')} onClick={onCopy}>\n {!isCopied && <CopyIcon />}\n {isCopied && <CheckIcon />}\n </TooltipIconButton>\n </div>\n );\n};\n\nfunction Video({\n src,\n className,\n ...props\n}: {\n src?: string;\n className?: string;\n}) {\n const debouncedSrc = useDebounce(src, 500);\n return (\n <video\n src={debouncedSrc}\n style={{ maxWidth: 400 }}\n className={cn('aui-md-video max-w-full rounded-lg', className)}\n controls\n {...props}\n />\n );\n}\n\nconst videoExtensions = [\n '.mp4',\n '.avi',\n '.mov',\n '.wmv',\n '.flv',\n '.webm',\n '.mkv',\n '.m4v',\n];\n\nconst useCopyToClipboard = ({\n copiedDuration = 3000,\n}: {\n copiedDuration?: number;\n} = {}) => {\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\nconst defaultComponents = memoizeMarkdownComponents({\n h1: ({ className, ...props }) => (\n <h1\n className={cn(\n 'aui-md-h1 mb-[12px] scroll-m-20 text-[26px] leading-[37px] font-extrabold tracking-tight last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h2: ({ className, ...props }) => (\n <h2\n className={cn(\n 'aui-md-h2 mt-6 mb-4 scroll-m-20 text-[22px] leading-[30px] font-[500] tracking-tight first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h3: ({ className, ...props }) => (\n <h3\n className={cn(\n 'aui-md-h3 mt-[12px] mb-[12px] scroll-m-20 text-[20px] font-[500] leading-[28px] tracking-tight first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h4: ({ className, ...props }) => (\n <h4\n className={cn(\n 'aui-md-h4 mt-[12px] mb-[12px] scroll-m-20 text-[18px] leading-[25px] font-[500] tracking-tight first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h5: ({ className, ...props }) => (\n <h5\n className={cn(\n 'aui-md-h5 my-[12px] text-[16px] leading-[22px] font-[500] first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h6: ({ className, ...props }) => (\n <h6\n className={cn(\n 'aui-md-h6 my-4 font-semibold first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n p: ({ className, ...props }) => (\n <p\n className={cn(\n 'aui-md-p text-[16px] mt-[12px] mb-[12px] leading-[24px] first:mt-0 last:mb-0 chatkit-md-text-p',\n className,\n )}\n {...props}\n />\n ),\n image: ({ className, ...props }) => (\n <img\n src={props.href}\n style={{ maxWidth: 400 }}\n className={cn('aui-md-img max-w-full rounded-lg', className)}\n />\n ),\n a: ({ className, ...props }) => {\n const isVideo = (href: string | undefined) => {\n if (!href) return false;\n return videoExtensions.some((ext) => href.toLowerCase().includes(ext));\n };\n\n if (isVideo(props.href)) {\n return <Video src={props.href} className={className} {...props} />;\n }\n\n return (\n <a\n className={cn(\n 'aui-md-a font-[400] leading-[24px] text-[16px] underline underline-offset-4',\n className,\n )}\n {...props}\n />\n );\n },\n video: ({ className, ...props }) => (\n <Video className={className} {...props} />\n ),\n blockquote: ({ className, ...props }) => (\n <blockquote\n className={cn('aui-md-blockquote border-[1px solid #F5F6F7] pl-6 italic', className)}\n {...props}\n />\n ),\n ul: ({ className, ...props }) => (\n <ul\n className={cn('aui-md-ul my-[12px] ml-6 list-disc [&>li]:mt-2 [&>li]:text-[16px] leading-[24px]', className)}\n {...props}\n />\n ),\n ol: ({ className, ...props }) => (\n <ol\n className={cn('aui-md-ol my-[12px] ml-6 list-decimal [&>li]:mt-2 [&>li]:text-[16px] leading-[24px]', className)}\n {...props}\n />\n ),\n hr: ({ className, ...props }) => (\n <hr className={cn('aui-md-hr my-[12px] border-b', className)} {...props} />\n ),\n table: ({ className, ...props }) => (\n <table\n className={cn(\n 'aui-md-table my-5 w-full border-separate border-spacing-0 overflow-y-auto',\n className,\n )}\n {...props}\n />\n ),\n th: ({ className, ...props }) => (\n <th\n className={cn(\n 'aui-md-th bg-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',\n className,\n )}\n {...props}\n />\n ),\n td: ({ className, ...props }) => (\n <td\n className={cn(\n 'aui-md-td border-b border-l px-4 py-2 text-left last:border-r [&[align=center]]:text-center [&[align=right]]:text-right',\n className,\n )}\n {...props}\n />\n ),\n tr: ({ className, ...props }) => (\n <tr\n className={cn(\n 'aui-md-tr 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',\n className,\n )}\n {...props}\n />\n ),\n sup: ({ className, ...props }) => (\n <sup\n className={cn('aui-md-sup [&>a]:text-xs [&>a]:no-underline', className)}\n {...props}\n />\n ),\n SyntaxHighlighter,\n pre: ({ className, ...props }) => (\n <pre\n className={cn(\n 'aui-md-pre overflow-x-auto !rounded-t-none rounded-b-lg p-4',\n className,\n )}\n {...props}\n />\n ),\n code: function Code({ className, ...props }) {\n const isCodeBlock = useIsMarkdownCodeBlock();\n return (\n <code\n className={cn(\n !isCodeBlock\n && 'aui-md-inline-code rounded border bg-muted font-[400] text-[16px] leading-[24px] px-[2px]',\n className,\n )}\n {...props}\n />\n );\n },\n CodeHeader,\n div: ({ className, ...props }) => <div className={className} {...props} />,\n});\n"],"names":["defaultSchema","_jsx","MarkdownTextPrimitive","memo","useI18n","_jsxs","TooltipIconButton","CopyIcon","CheckIcon","useDebounce","cn","useState","memoizeMarkdownComponents","SyntaxHighlighter","useIsMarkdownCodeBlock"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,MAAM,MAAM,GAAG;AACb,IAAA,GAAGA,4BAAa;;AAEhB,IAAA,QAAQ,EAAE,CAAC,IAAIA,4BAAa,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC;;AAE1E,IAAA,UAAU,EAAE;QACV,GAAGA,4BAAa,CAAC,UAAU;AAC3B,QAAA,MAAM,EAAE;YACN,KAAK;YACL,OAAO;YACP,QAAQ;YACR,aAAa;YACb,OAAO;YACP,iBAAiB;AAClB,SAAA;;AAED,QAAA,KAAK,EAAE;YACL,UAAU;YACV,OAAO;YACP,QAAQ;YACR,QAAQ;YACR,SAAS;YACT,KAAK;YACL,OAAO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iB;IACjB,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,MAC3BZ,wBACE,SAAS,EAAES,QAAE,CACX,6DAA6D,EAC7D,SAAS,CACV,EAAA,GACG,KAAK,EAAA,CACT,CACH;IACD,IAAI,EAAE,SAAS,IAAI,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAA;AACzC,QAAA,MAAM,WAAW,GAAGI,oCAAsB,EAAE,CAAC;AAC7C,QAAA,QACEb,cACE,CAAA,MAAA,EAAA,EAAA,SAAS,EAAES,QAAE,CACX,CAAC,WAAW;AACP,mBAAA,2FAA2F,EAChG,SAAS,CACV,KACG,KAAK,EAAA,CACT,EACF;KACH;IACD,UAAU;AACV,IAAA,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,KAAKT,cAAK,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,SAAS,EAAA,GAAM,KAAK,EAAI,CAAA;AAC3E,CAAA,CAAC;;;;"}
|
|
@@ -100,13 +100,13 @@ const useCopyToClipboard = ({ copiedDuration = 3000, } = {}) => {
|
|
|
100
100
|
return { isCopied, copyToClipboard };
|
|
101
101
|
};
|
|
102
102
|
const defaultComponents = unstable_memoizeMarkdownComponents({
|
|
103
|
-
h1: ({ className, ...props }) => (jsx("h1", { className: cn('aui-md-h1 mb-
|
|
104
|
-
h2: ({ className, ...props }) => (jsx("h2", { className: cn('aui-md-h2 mt-6 mb-4 scroll-m-20 text-
|
|
105
|
-
h3: ({ className, ...props }) => (jsx("h3", { className: cn('aui-md-h3 mt-
|
|
106
|
-
h4: ({ className, ...props }) => (jsx("h4", { className: cn('aui-md-h4 mt-
|
|
107
|
-
h5: ({ className, ...props }) => (jsx("h5", { className: cn('aui-md-h5 my-
|
|
103
|
+
h1: ({ className, ...props }) => (jsx("h1", { className: cn('aui-md-h1 mb-[12px] scroll-m-20 text-[26px] leading-[37px] font-extrabold tracking-tight last:mb-0', className), ...props })),
|
|
104
|
+
h2: ({ className, ...props }) => (jsx("h2", { className: cn('aui-md-h2 mt-6 mb-4 scroll-m-20 text-[22px] leading-[30px] font-[500] tracking-tight first:mt-0 last:mb-0', className), ...props })),
|
|
105
|
+
h3: ({ className, ...props }) => (jsx("h3", { className: cn('aui-md-h3 mt-[12px] mb-[12px] scroll-m-20 text-[20px] font-[500] leading-[28px] tracking-tight first:mt-0 last:mb-0', className), ...props })),
|
|
106
|
+
h4: ({ className, ...props }) => (jsx("h4", { className: cn('aui-md-h4 mt-[12px] mb-[12px] scroll-m-20 text-[18px] leading-[25px] font-[500] tracking-tight first:mt-0 last:mb-0', className), ...props })),
|
|
107
|
+
h5: ({ className, ...props }) => (jsx("h5", { className: cn('aui-md-h5 my-[12px] text-[16px] leading-[22px] font-[500] first:mt-0 last:mb-0', className), ...props })),
|
|
108
108
|
h6: ({ className, ...props }) => (jsx("h6", { className: cn('aui-md-h6 my-4 font-semibold first:mt-0 last:mb-0', className), ...props })),
|
|
109
|
-
p: ({ className, ...props }) => (jsx("p", { className: cn('aui-md-p text-[
|
|
109
|
+
p: ({ className, ...props }) => (jsx("p", { className: cn('aui-md-p text-[16px] mt-[12px] mb-[12px] leading-[24px] first:mt-0 last:mb-0 chatkit-md-text-p', className), ...props })),
|
|
110
110
|
image: ({ className, ...props }) => (jsx("img", { src: props.href, style: { maxWidth: 400 }, className: cn('aui-md-img max-w-full rounded-lg', className) })),
|
|
111
111
|
a: ({ className, ...props }) => {
|
|
112
112
|
const isVideo = (href) => {
|
|
@@ -117,13 +117,13 @@ const defaultComponents = unstable_memoizeMarkdownComponents({
|
|
|
117
117
|
if (isVideo(props.href)) {
|
|
118
118
|
return jsx(Video, { src: props.href, className: className, ...props });
|
|
119
119
|
}
|
|
120
|
-
return (jsx("a", { className: cn('aui-md-a font-
|
|
120
|
+
return (jsx("a", { className: cn('aui-md-a font-[400] leading-[24px] text-[16px] underline underline-offset-4', className), ...props }));
|
|
121
121
|
},
|
|
122
122
|
video: ({ className, ...props }) => (jsx(Video, { className: className, ...props })),
|
|
123
|
-
blockquote: ({ className, ...props }) => (jsx("blockquote", { className: cn('aui-md-blockquote border-
|
|
124
|
-
ul: ({ className, ...props }) => (jsx("ul", { className: cn('aui-md-ul my-
|
|
125
|
-
ol: ({ className, ...props }) => (jsx("ol", { className: cn('aui-md-ol my-
|
|
126
|
-
hr: ({ className, ...props }) => (jsx("hr", { className: cn('aui-md-hr my-
|
|
123
|
+
blockquote: ({ className, ...props }) => (jsx("blockquote", { className: cn('aui-md-blockquote border-[1px solid #F5F6F7] pl-6 italic', className), ...props })),
|
|
124
|
+
ul: ({ className, ...props }) => (jsx("ul", { className: cn('aui-md-ul my-[12px] ml-6 list-disc [&>li]:mt-2 [&>li]:text-[16px] leading-[24px]', className), ...props })),
|
|
125
|
+
ol: ({ className, ...props }) => (jsx("ol", { className: cn('aui-md-ol my-[12px] ml-6 list-decimal [&>li]:mt-2 [&>li]:text-[16px] leading-[24px]', className), ...props })),
|
|
126
|
+
hr: ({ className, ...props }) => (jsx("hr", { className: cn('aui-md-hr my-[12px] border-b', className), ...props })),
|
|
127
127
|
table: ({ className, ...props }) => (jsx("table", { className: cn('aui-md-table my-5 w-full border-separate border-spacing-0 overflow-y-auto', className), ...props })),
|
|
128
128
|
th: ({ className, ...props }) => (jsx("th", { className: cn('aui-md-th bg-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', className), ...props })),
|
|
129
129
|
td: ({ className, ...props }) => (jsx("td", { className: cn('aui-md-td border-b border-l px-4 py-2 text-left last:border-r [&[align=center]]:text-center [&[align=right]]:text-right', className), ...props })),
|
|
@@ -134,7 +134,7 @@ const defaultComponents = unstable_memoizeMarkdownComponents({
|
|
|
134
134
|
code: function Code({ className, ...props }) {
|
|
135
135
|
const isCodeBlock = useIsMarkdownCodeBlock();
|
|
136
136
|
return (jsx("code", { className: cn(!isCodeBlock
|
|
137
|
-
&& 'aui-md-inline-code rounded border bg-muted font-
|
|
137
|
+
&& 'aui-md-inline-code rounded border bg-muted font-[400] text-[16px] leading-[24px] px-[2px]', className), ...props }));
|
|
138
138
|
},
|
|
139
139
|
CodeHeader,
|
|
140
140
|
div: ({ className, ...props }) => jsx("div", { className: className, ...props }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-text.js","sources":["../../../src/components/assistant-ui/markdown-text.tsx"],"sourcesContent":["'use client';\n\nimport '@assistant-ui/react-markdown/styles/dot.css';\n\nimport {\n type CodeHeaderProps,\n MarkdownTextPrimitive,\n unstable_memoizeMarkdownComponents as memoizeMarkdownComponents,\n useIsMarkdownCodeBlock,\n} from '@assistant-ui/react-markdown';\nimport remarkGfm from 'remark-gfm';\nimport remarkBreaks from 'remark-breaks';\nimport rehypeRaw from 'rehype-raw';\nimport rehypeSanitize, { defaultSchema } from 'rehype-sanitize';\nimport { type FC, memo, useState } from 'react';\nimport { CheckIcon, CopyIcon, Loader2 } from 'lucide-react';\nimport './index.less';\nimport { TooltipIconButton } from '@/components/assistant-ui/tooltip-icon-button';\nimport { cn } from '@/lib/utils';\nimport { useDebounce } from '@/hooks/useDebounce';\nimport { PluggableList } from 'unified';\nimport { useI18n } from '@/contexts/I18nContext';\nimport { SyntaxHighlighter } from './shiki-highlighter';\n\nconst schema = {\n ...defaultSchema,\n // 1. 添加标签到白名单\n tagNames: [...(defaultSchema.tagNames || []), 'video', 'source', 'iframe'],\n // 2. 添加允许的属性\n attributes: {\n ...defaultSchema.attributes,\n iframe: [\n 'src',\n 'width',\n 'height',\n 'frameborder',\n 'allow',\n 'allowfullscreen',\n ],\n // 允许 video 标签使用的属性\n video: [\n 'controls',\n 'width',\n 'height',\n 'poster',\n 'preload',\n 'src',\n 'muted',\n 'loop',\n 'autoPlay',\n 'playsInline',\n ],\n div: [\n ...(defaultSchema.attributes?.div || []),\n 'className', //\n 'data-content', // 如果你在插件里用了 data-content\n ],\n // 允许 source 标签使用的属性\n source: ['src', 'type'],\n },\n};\n\nconst remarkPlugins: PluggableList = [remarkGfm, remarkBreaks];\n\nconst rehypePlugins: PluggableList = [\n rehypeRaw,\n [rehypeSanitize, schema],\n // rehypeAppendCursor,\n];\n\nfunction MarkdownTextImpl() {\n return (\n <MarkdownTextPrimitive\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n className=\"aui-md\"\n // smooth={false}\n components={defaultComponents}\n />\n );\n}\n\nexport const MarkdownText = memo(MarkdownTextImpl);\n\nconst CodeHeader: FC<CodeHeaderProps> = ({ language, code }) => {\n const { isCopied, copyToClipboard } = useCopyToClipboard();\n const processedLanguage = language == 'unknown' ? 'text' : language;\n const { t } = useI18n();\n const onCopy = () => {\n if (!code || isCopied) return;\n copyToClipboard(code);\n };\n\n return (\n <div className=\"aui-code-header-root mt-4 flex items-center justify-between gap-4 rounded-t-lg border bg-muted-foreground/15 px-4 py-2 text-sm font-semibold text-foreground max-w-[800px] overflow-auto\">\n <span className=\"aui-code-header-language lowercase [&>span]:text-xs\">\n {processedLanguage}\n </span>\n <TooltipIconButton tooltip={t('thread.copy')} onClick={onCopy}>\n {!isCopied && <CopyIcon />}\n {isCopied && <CheckIcon />}\n </TooltipIconButton>\n </div>\n );\n};\n\nfunction Video({\n src,\n className,\n ...props\n}: {\n src?: string;\n className?: string;\n}) {\n const debouncedSrc = useDebounce(src, 500);\n return (\n <video\n src={debouncedSrc}\n style={{ maxWidth: 400 }}\n className={cn('aui-md-video max-w-full rounded-lg', className)}\n controls\n {...props}\n />\n );\n}\n\nconst videoExtensions = [\n '.mp4',\n '.avi',\n '.mov',\n '.wmv',\n '.flv',\n '.webm',\n '.mkv',\n '.m4v',\n];\n\nconst useCopyToClipboard = ({\n copiedDuration = 3000,\n}: {\n copiedDuration?: number;\n} = {}) => {\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\nconst defaultComponents = memoizeMarkdownComponents({\n h1: ({ className, ...props }) => (\n <h1\n className={cn(\n 'aui-md-h1 mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h2: ({ className, ...props }) => (\n <h2\n className={cn(\n 'aui-md-h2 mt-6 mb-4 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h3: ({ className, ...props }) => (\n <h3\n className={cn(\n 'aui-md-h3 mt-6 mb-4 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h4: ({ className, ...props }) => (\n <h4\n className={cn(\n 'aui-md-h4 mt-6 mb-4 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h5: ({ className, ...props }) => (\n <h5\n className={cn(\n 'aui-md-h5 my-4 text-lg font-semibold first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h6: ({ className, ...props }) => (\n <h6\n className={cn(\n 'aui-md-h6 my-4 font-semibold first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n p: ({ className, ...props }) => (\n <p\n className={cn(\n 'aui-md-p text-[13px] mt-5 mb-5 leading-7 first:mt-0 last:mb-0 chatkit-md-text-p',\n className,\n )}\n {...props}\n />\n ),\n image: ({ className, ...props }) => (\n <img\n src={props.href}\n style={{ maxWidth: 400 }}\n className={cn('aui-md-img max-w-full rounded-lg', className)}\n />\n ),\n a: ({ className, ...props }) => {\n const isVideo = (href: string | undefined) => {\n if (!href) return false;\n return videoExtensions.some((ext) => href.toLowerCase().includes(ext));\n };\n\n if (isVideo(props.href)) {\n return <Video src={props.href} className={className} {...props} />;\n }\n\n return (\n <a\n className={cn(\n 'aui-md-a font-medium text-primary underline underline-offset-4',\n className,\n )}\n {...props}\n />\n );\n },\n video: ({ className, ...props }) => (\n <Video className={className} {...props} />\n ),\n blockquote: ({ className, ...props }) => (\n <blockquote\n className={cn('aui-md-blockquote border-l-2 pl-6 italic', className)}\n {...props}\n />\n ),\n ul: ({ className, ...props }) => (\n <ul\n className={cn('aui-md-ul my-5 ml-6 list-disc [&>li]:mt-2', className)}\n {...props}\n />\n ),\n ol: ({ className, ...props }) => (\n <ol\n className={cn('aui-md-ol my-5 ml-6 list-decimal [&>li]:mt-2', className)}\n {...props}\n />\n ),\n hr: ({ className, ...props }) => (\n <hr className={cn('aui-md-hr my-5 border-b', className)} {...props} />\n ),\n table: ({ className, ...props }) => (\n <table\n className={cn(\n 'aui-md-table my-5 w-full border-separate border-spacing-0 overflow-y-auto',\n className,\n )}\n {...props}\n />\n ),\n th: ({ className, ...props }) => (\n <th\n className={cn(\n 'aui-md-th bg-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',\n className,\n )}\n {...props}\n />\n ),\n td: ({ className, ...props }) => (\n <td\n className={cn(\n 'aui-md-td border-b border-l px-4 py-2 text-left last:border-r [&[align=center]]:text-center [&[align=right]]:text-right',\n className,\n )}\n {...props}\n />\n ),\n tr: ({ className, ...props }) => (\n <tr\n className={cn(\n 'aui-md-tr 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',\n className,\n )}\n {...props}\n />\n ),\n sup: ({ className, ...props }) => (\n <sup\n className={cn('aui-md-sup [&>a]:text-xs [&>a]:no-underline', className)}\n {...props}\n />\n ),\n SyntaxHighlighter,\n pre: ({ className, ...props }) => (\n <pre\n className={cn(\n 'aui-md-pre overflow-x-auto !rounded-t-none rounded-b-lg p-4',\n className,\n )}\n {...props}\n />\n ),\n code: function Code({ className, ...props }) {\n const isCodeBlock = useIsMarkdownCodeBlock();\n return (\n <code\n className={cn(\n !isCodeBlock\n && 'aui-md-inline-code rounded border bg-muted font-semibold',\n className,\n )}\n {...props}\n />\n );\n },\n CodeHeader,\n div: ({ className, ...props }) => <div className={className} {...props} />,\n});\n"],"names":["_jsx","_jsxs","memoizeMarkdownComponents"],"mappings":";;;;;;;;;;;;;;;AAwBA,MAAM,MAAM,GAAG;AACb,IAAA,GAAG,aAAa;;AAEhB,IAAA,QAAQ,EAAE,CAAC,IAAI,aAAa,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC;;AAE1E,IAAA,UAAU,EAAE;QACV,GAAG,aAAa,CAAC,UAAU;AAC3B,QAAA,MAAM,EAAE;YACN,KAAK;YACL,OAAO;YACP,QAAQ;YACR,aAAa;YACb,OAAO;YACP,iBAAiB;AAClB,SAAA;;AAED,QAAA,KAAK,EAAE;YACL,UAAU;YACV,OAAO;YACP,QAAQ;YACR,QAAQ;YACR,SAAS;YACT,KAAK;YACL,OAAO;YACP,MAAM;YACN,UAAU;YACV,aAAa;AACd,SAAA;AACD,QAAA,GAAG,EAAE;YACH,IAAI,aAAa,CAAC,UAAU,EAAE,GAAG,IAAI,EAAE,CAAC;AACxC,YAAA,WAAW;AACX,YAAA,cAAc;AACf,SAAA;;AAED,QAAA,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;AACxB,KAAA;CACF,CAAC;AAEF,MAAM,aAAa,GAAkB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AAE/D,MAAM,aAAa,GAAkB;IACnC,SAAS;IACT,CAAC,cAAc,EAAE,MAAM,CAAC;;CAEzB,CAAC;AAEF,SAAS,gBAAgB,GAAA;AACvB,IAAA,QACEA,GAAA,CAAC,qBAAqB,EAAA,EACpB,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAC,QAAQ;;AAElB,QAAA,UAAU,EAAE,iBAAiB,EAC7B,CAAA,EACF;AACJ,CAAC;MAEY,YAAY,GAAG,IAAI,CAAC,g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ant-ui/markdown-text.tsx"],"sourcesContent":["'use client';\n\nimport '@assistant-ui/react-markdown/styles/dot.css';\n\nimport {\n type CodeHeaderProps,\n MarkdownTextPrimitive,\n unstable_memoizeMarkdownComponents as memoizeMarkdownComponents,\n useIsMarkdownCodeBlock,\n} from '@assistant-ui/react-markdown';\nimport remarkGfm from 'remark-gfm';\nimport remarkBreaks from 'remark-breaks';\nimport rehypeRaw from 'rehype-raw';\nimport rehypeSanitize, { defaultSchema } from 'rehype-sanitize';\nimport { type FC, memo, useState } from 'react';\nimport { CheckIcon, CopyIcon, Loader2 } from 'lucide-react';\nimport './index.less';\nimport { TooltipIconButton } from '@/components/assistant-ui/tooltip-icon-button';\nimport { cn } from '@/lib/utils';\nimport { useDebounce } from '@/hooks/useDebounce';\nimport { PluggableList } from 'unified';\nimport { useI18n } from '@/contexts/I18nContext';\nimport { SyntaxHighlighter } from './shiki-highlighter';\n\nconst schema = {\n ...defaultSchema,\n // 1. 添加标签到白名单\n tagNames: [...(defaultSchema.tagNames || []), 'video', 'source', 'iframe'],\n // 2. 添加允许的属性\n attributes: {\n ...defaultSchema.attributes,\n iframe: [\n 'src',\n 'width',\n 'height',\n 'frameborder',\n 'allow',\n 'allowfullscreen',\n ],\n // 允许 video 标签使用的属性\n video: [\n 'controls',\n 'width',\n 'height',\n 'poster',\n 'preload',\n 'src',\n 'muted',\n 'loop',\n 'autoPlay',\n 'playsInline',\n ],\n div: [\n ...(defaultSchema.attributes?.div || []),\n 'className', //\n 'data-content', // 如果你在插件里用了 data-content\n ],\n // 允许 source 标签使用的属性\n source: ['src', 'type'],\n },\n};\n\nconst remarkPlugins: PluggableList = [remarkGfm, remarkBreaks];\n\nconst rehypePlugins: PluggableList = [\n rehypeRaw,\n [rehypeSanitize, schema],\n // rehypeAppendCursor,\n];\n\nfunction MarkdownTextImpl() {\n return (\n <MarkdownTextPrimitive\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n className=\"aui-md\"\n // smooth={false}\n components={defaultComponents}\n />\n );\n}\n\nexport const MarkdownText = memo(MarkdownTextImpl);\n\nconst CodeHeader: FC<CodeHeaderProps> = ({ language, code }) => {\n const { isCopied, copyToClipboard } = useCopyToClipboard();\n const processedLanguage = language == 'unknown' ? 'text' : language;\n const { t } = useI18n();\n const onCopy = () => {\n if (!code || isCopied) return;\n copyToClipboard(code);\n };\n\n return (\n <div className=\"aui-code-header-root mt-4 flex items-center justify-between gap-4 rounded-t-lg border bg-muted-foreground/15 px-4 py-2 text-sm font-semibold text-foreground max-w-[800px] overflow-auto\">\n <span className=\"aui-code-header-language lowercase [&>span]:text-xs\">\n {processedLanguage}\n </span>\n <TooltipIconButton tooltip={t('thread.copy')} onClick={onCopy}>\n {!isCopied && <CopyIcon />}\n {isCopied && <CheckIcon />}\n </TooltipIconButton>\n </div>\n );\n};\n\nfunction Video({\n src,\n className,\n ...props\n}: {\n src?: string;\n className?: string;\n}) {\n const debouncedSrc = useDebounce(src, 500);\n return (\n <video\n src={debouncedSrc}\n style={{ maxWidth: 400 }}\n className={cn('aui-md-video max-w-full rounded-lg', className)}\n controls\n {...props}\n />\n );\n}\n\nconst videoExtensions = [\n '.mp4',\n '.avi',\n '.mov',\n '.wmv',\n '.flv',\n '.webm',\n '.mkv',\n '.m4v',\n];\n\nconst useCopyToClipboard = ({\n copiedDuration = 3000,\n}: {\n copiedDuration?: number;\n} = {}) => {\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\nconst defaultComponents = memoizeMarkdownComponents({\n h1: ({ className, ...props }) => (\n <h1\n className={cn(\n 'aui-md-h1 mb-[12px] scroll-m-20 text-[26px] leading-[37px] font-extrabold tracking-tight last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h2: ({ className, ...props }) => (\n <h2\n className={cn(\n 'aui-md-h2 mt-6 mb-4 scroll-m-20 text-[22px] leading-[30px] font-[500] tracking-tight first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h3: ({ className, ...props }) => (\n <h3\n className={cn(\n 'aui-md-h3 mt-[12px] mb-[12px] scroll-m-20 text-[20px] font-[500] leading-[28px] tracking-tight first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h4: ({ className, ...props }) => (\n <h4\n className={cn(\n 'aui-md-h4 mt-[12px] mb-[12px] scroll-m-20 text-[18px] leading-[25px] font-[500] tracking-tight first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h5: ({ className, ...props }) => (\n <h5\n className={cn(\n 'aui-md-h5 my-[12px] text-[16px] leading-[22px] font-[500] first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n h6: ({ className, ...props }) => (\n <h6\n className={cn(\n 'aui-md-h6 my-4 font-semibold first:mt-0 last:mb-0',\n className,\n )}\n {...props}\n />\n ),\n p: ({ className, ...props }) => (\n <p\n className={cn(\n 'aui-md-p text-[16px] mt-[12px] mb-[12px] leading-[24px] first:mt-0 last:mb-0 chatkit-md-text-p',\n className,\n )}\n {...props}\n />\n ),\n image: ({ className, ...props }) => (\n <img\n src={props.href}\n style={{ maxWidth: 400 }}\n className={cn('aui-md-img max-w-full rounded-lg', className)}\n />\n ),\n a: ({ className, ...props }) => {\n const isVideo = (href: string | undefined) => {\n if (!href) return false;\n return videoExtensions.some((ext) => href.toLowerCase().includes(ext));\n };\n\n if (isVideo(props.href)) {\n return <Video src={props.href} className={className} {...props} />;\n }\n\n return (\n <a\n className={cn(\n 'aui-md-a font-[400] leading-[24px] text-[16px] underline underline-offset-4',\n className,\n )}\n {...props}\n />\n );\n },\n video: ({ className, ...props }) => (\n <Video className={className} {...props} />\n ),\n blockquote: ({ className, ...props }) => (\n <blockquote\n className={cn('aui-md-blockquote border-[1px solid #F5F6F7] pl-6 italic', className)}\n {...props}\n />\n ),\n ul: ({ className, ...props }) => (\n <ul\n className={cn('aui-md-ul my-[12px] ml-6 list-disc [&>li]:mt-2 [&>li]:text-[16px] leading-[24px]', className)}\n {...props}\n />\n ),\n ol: ({ className, ...props }) => (\n <ol\n className={cn('aui-md-ol my-[12px] ml-6 list-decimal [&>li]:mt-2 [&>li]:text-[16px] leading-[24px]', className)}\n {...props}\n />\n ),\n hr: ({ className, ...props }) => (\n <hr className={cn('aui-md-hr my-[12px] border-b', className)} {...props} />\n ),\n table: ({ className, ...props }) => (\n <table\n className={cn(\n 'aui-md-table my-5 w-full border-separate border-spacing-0 overflow-y-auto',\n className,\n )}\n {...props}\n />\n ),\n th: ({ className, ...props }) => (\n <th\n className={cn(\n 'aui-md-th bg-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',\n className,\n )}\n {...props}\n />\n ),\n td: ({ className, ...props }) => (\n <td\n className={cn(\n 'aui-md-td border-b border-l px-4 py-2 text-left last:border-r [&[align=center]]:text-center [&[align=right]]:text-right',\n className,\n )}\n {...props}\n />\n ),\n tr: ({ className, ...props }) => (\n <tr\n className={cn(\n 'aui-md-tr 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',\n className,\n )}\n {...props}\n />\n ),\n sup: ({ className, ...props }) => (\n <sup\n className={cn('aui-md-sup [&>a]:text-xs [&>a]:no-underline', className)}\n {...props}\n />\n ),\n SyntaxHighlighter,\n pre: ({ className, ...props }) => (\n <pre\n className={cn(\n 'aui-md-pre overflow-x-auto !rounded-t-none rounded-b-lg p-4',\n className,\n )}\n {...props}\n />\n ),\n code: function Code({ className, ...props }) {\n const isCodeBlock = useIsMarkdownCodeBlock();\n return (\n <code\n className={cn(\n !isCodeBlock\n && 'aui-md-inline-code rounded border bg-muted font-[400] text-[16px] leading-[24px] px-[2px]',\n className,\n )}\n {...props}\n />\n );\n },\n CodeHeader,\n div: ({ className, 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,CACT,CACH;IACD,EAAE,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,MAC1BA,YACE,SAAS,EAAE,EAAE,CACX,yHAAyH,EACzH,SAAS,CACV,EAAA,GACG,KAAK,EAAA,CACT,CACH;IACD,EAAE,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,MAC1BA,YACE,SAAS,EAAE,EAAE,CACX,kIAAkI,EAClI,SAAS,CACV,EAAA,GACG,KAAK,EAAA,CACT,CACH;IACD,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,MAC3BA,aACE,SAAS,EAAE,EAAE,CAAC,6CAA6C,EAAE,SAAS,CAAC,EAAA,GACnE,KAAK,EAAA,CACT,CACH;IACD,iBAAiB;IACjB,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,MAC3BA,aACE,SAAS,EAAE,EAAE,CACX,6DAA6D,EAC7D,SAAS,CACV,EAAA,GACG,KAAK,EAAA,CACT,CACH;IACD,IAAI,EAAE,SAAS,IAAI,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAA;AACzC,QAAA,MAAM,WAAW,GAAG,sBAAsB,EAAE,CAAC;AAC7C,QAAA,QACEA,GACE,CAAA,MAAA,EAAA,EAAA,SAAS,EAAE,EAAE,CACX,CAAC,WAAW;AACP,mBAAA,2FAA2F,EAChG,SAAS,CACV,KACG,KAAK,EAAA,CACT,EACF;KACH;IACD,UAAU;AACV,IAAA,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,KAAKA,GAAK,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,SAAS,EAAA,GAAM,KAAK,EAAI,CAAA;AAC3E,CAAA,CAAC;;;;"}
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var React = require('react');
|
|
5
|
-
var markdownText = require('./markdown-text.cjs');
|
|
6
|
-
var reasoning = require('./reasoning.cjs');
|
|
7
|
-
var toolFallback = require('./tool-fallback.cjs');
|
|
8
5
|
var react = require('@assistant-ui/react');
|
|
9
6
|
var avatarGroup = require('../../assets/avatarGroup.cjs');
|
|
10
7
|
var lodashEs = require('lodash-es');
|
|
11
8
|
var lucideReact = require('lucide-react');
|
|
9
|
+
var toolFallback = require('./tool-fallback.cjs');
|
|
10
|
+
var reasoning = require('./reasoning.cjs');
|
|
11
|
+
var markdownText = require('./markdown-text.cjs');
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
function File(props) {
|
|
14
14
|
const { filename } = props;
|
|
15
15
|
const content = (jsxRuntime.jsx("div", { className: "flex flex-col gap-2", children: jsxRuntime.jsxs("div", { className: "flex items-center p-3 bg-[#F7F8FA] rounded-xl border border-[#E5E6EB] max-w-[300px]", children: [jsxRuntime.jsx("div", { className: "w-10 h-10 bg-[#E8F3FF] rounded-lg flex items-center justify-center mr-3 shrink-0", children: jsxRuntime.jsx(lucideReact.FileText, { className: "text-[#1677FF]", size: 24 }) }), jsxRuntime.jsx("div", { className: "flex flex-col overflow-hidden", children: jsxRuntime.jsx("span", { className: "text-[14px] font-medium text-[#1D2129] truncate", title: filename, children: filename }) })] }) }));
|
|
16
16
|
return content;
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
18
|
const assistantMessageComponents = {
|
|
19
19
|
Text: markdownText.MarkdownText,
|
|
20
20
|
tools: {
|
|
@@ -31,29 +31,25 @@ const getAvatarByIdx = (idx) => {
|
|
|
31
31
|
}
|
|
32
32
|
return avatarGroup.AvatarList[idx % avatarListLength];
|
|
33
33
|
};
|
|
34
|
-
const wrapComponentsForTextWithAvatar = (component) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return (jsxRuntime.jsxs("div", { className: "flex items-start", children: [jsxRuntime.jsx("div", { className: "fit-content mr-[12px] flex-shrink-0 flex-grow-0", children: jsxRuntime.jsx(Avatar, {}) }), jsxRuntime.jsxs("div", { className: "flex-1 max-w-[90%]", children: [jsxRuntime.jsx("div", { className: "font-medium text-[15px] leading-[22px] mb-[6px] color-[#0C0D0E]", children: text?.author || 'Agent' }), React.createElement(component, props)] })] }));
|
|
44
|
-
};
|
|
34
|
+
const wrapComponentsForTextWithAvatar = (component) => function (props) {
|
|
35
|
+
const text = react.useMessagePartText();
|
|
36
|
+
const showAvatar = text?.showAvatar;
|
|
37
|
+
const marginLeft = text?.marginLeft;
|
|
38
|
+
const Avatar = getAvatarByIdx(text?.authorIdx);
|
|
39
|
+
if (!showAvatar) {
|
|
40
|
+
return (jsxRuntime.jsx("div", { className: `${marginLeft ? 'ml-[50px]' : ''}`, children: React.createElement(component, props) }));
|
|
41
|
+
}
|
|
42
|
+
return (jsxRuntime.jsxs("div", { className: "flex items-start", children: [jsxRuntime.jsx("div", { className: "fit-content mr-[12px] flex-shrink-0 flex-grow-0", children: jsxRuntime.jsx(Avatar, {}) }), jsxRuntime.jsxs("div", { className: "flex-1 max-w-[90%]", children: [jsxRuntime.jsx("div", { className: "font-medium text-[15px] leading-[22px] mb-[6px] color-[#0C0D0E]", children: text?.author || 'Agent' }), React.createElement(component, props)] })] }));
|
|
45
43
|
};
|
|
46
|
-
const wrapComponentsForReasoningWithAvatar = (component) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return (jsxRuntime.jsxs("div", { className: "flex items-start", children: [jsxRuntime.jsx("div", { className: "fit-content mr-[12px] flex-shrink-0 flex-grow-0", children: jsxRuntime.jsx(Avatar, {}) }), jsxRuntime.jsxs("div", { className: "flex-1 max-w-[90%]", children: [jsxRuntime.jsx("div", { className: "font-medium text-[15px] leading-[22px] mb-[6px] color-[#0C0D0E]", children: text?.author || 'Agent' }), React.createElement(component, props)] })] }));
|
|
56
|
-
};
|
|
44
|
+
const wrapComponentsForReasoningWithAvatar = (component) => function (props) {
|
|
45
|
+
const text = react.useMessagePartReasoning();
|
|
46
|
+
const showAvatar = text?.showAvatar;
|
|
47
|
+
const marginLeft = text?.marginLeft;
|
|
48
|
+
const Avatar = getAvatarByIdx(text?.authorIdx);
|
|
49
|
+
if (!showAvatar) {
|
|
50
|
+
return (jsxRuntime.jsx("div", { className: `${marginLeft ? 'ml-[50px]' : ''}`, children: React.createElement(component, props) }));
|
|
51
|
+
}
|
|
52
|
+
return (jsxRuntime.jsxs("div", { className: "flex items-start", children: [jsxRuntime.jsx("div", { className: "fit-content mr-[12px] flex-shrink-0 flex-grow-0", children: jsxRuntime.jsx(Avatar, {}) }), jsxRuntime.jsxs("div", { className: "flex-1 max-w-[90%]", children: [jsxRuntime.jsx("div", { className: "font-medium text-[15px] leading-[22px] mb-[6px] color-[#0C0D0E]", children: text?.author || 'Agent' }), React.createElement(component, props)] })] }));
|
|
57
53
|
};
|
|
58
54
|
const assistantMessageComponentsWithAvatar = {
|
|
59
55
|
...assistantMessageComponents,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-components-with-avatar.cjs","sources":["../../../src/components/assistant-ui/message-components-with-avatar.tsx"],"sourcesContent":["import React, { Attributes } from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"message-components-with-avatar.cjs","sources":["../../../src/components/assistant-ui/message-components-with-avatar.tsx"],"sourcesContent":["import React, { Attributes } from 'react';\nimport {\n FileMessagePartProps,\n useMessagePartReasoning,\n useMessagePartText,\n} from '@assistant-ui/react';\nimport { AvatarList } from '@/assets/avatarGroup';\nimport { isNil } from 'lodash-es';\n\nimport { FileText } from 'lucide-react';\nimport { ToolFallback } from './tool-fallback';\nimport { Reasoning, ReasoningGroup } from './reasoning';\nimport { MarkdownText } from './markdown-text';\n\nfunction File(props: FileMessagePartProps) {\n const { filename } = props;\n\n const content = (\n <div className=\"flex flex-col gap-2\">\n <div className=\"flex items-center p-3 bg-[#F7F8FA] rounded-xl border border-[#E5E6EB] max-w-[300px]\">\n <div className=\"w-10 h-10 bg-[#E8F3FF] rounded-lg flex items-center justify-center mr-3 shrink-0\">\n <FileText className=\"text-[#1677FF]\" size={24} />\n </div>\n <div className=\"flex flex-col overflow-hidden\">\n <span\n className=\"text-[14px] font-medium text-[#1D2129] truncate\"\n title={filename}\n >\n {filename}\n </span>\n </div>\n </div>\n </div>\n );\n\n return content;\n}\n\nconst assistantMessageComponents = {\n Text: MarkdownText,\n tools: {\n Fallback: ToolFallback,\n },\n File,\n Reasoning,\n ReasoningGroup,\n};\nconst avatarListLength = AvatarList.length;\n\nexport const getAvatarByIdx = (idx?: number) => {\n if (isNil(idx) || idx < 0 || idx >= avatarListLength) {\n return AvatarList[0];\n }\n return AvatarList[idx % avatarListLength];\n};\nconst wrapComponentsForTextWithAvatar = (\n component: React.JSXElementConstructor<unknown>,\n) => function (props: Attributes) {\n const text = useMessagePartText() as any;\n\n const showAvatar = text?.showAvatar;\n const marginLeft = text?.marginLeft;\n const Avatar = getAvatarByIdx(\n text?.authorIdx,\n ) as React.JSXElementConstructor<unknown>;\n if (!showAvatar) {\n return (\n <div className={`${marginLeft ? 'ml-[50px]' : ''}`}>\n {React.createElement(component, props)}\n </div>\n );\n }\n return (\n <div className=\"flex items-start\">\n <div className=\"fit-content mr-[12px] flex-shrink-0 flex-grow-0\">\n <Avatar />\n </div>\n <div className=\"flex-1 max-w-[90%]\">\n <div className=\"font-medium text-[15px] leading-[22px] mb-[6px] color-[#0C0D0E]\">\n {text?.author || 'Agent'}\n </div>\n {React.createElement(component, props)}\n </div>\n </div>\n );\n};\n\nconst wrapComponentsForReasoningWithAvatar = (\n component: React.JSXElementConstructor<unknown>,\n) => function (props: Attributes) {\n const text = useMessagePartReasoning() as any;\n\n const showAvatar = text?.showAvatar;\n const marginLeft = text?.marginLeft;\n const Avatar = getAvatarByIdx(\n text?.authorIdx,\n ) as React.JSXElementConstructor<unknown>;\n if (!showAvatar) {\n return (\n <div className={`${marginLeft ? 'ml-[50px]' : ''}`}>\n {React.createElement(component, props)}\n </div>\n );\n }\n return (\n <div className=\"flex items-start\">\n <div className=\"fit-content mr-[12px] flex-shrink-0 flex-grow-0\">\n <Avatar />\n </div>\n <div className=\"flex-1 max-w-[90%]\">\n <div className=\"font-medium text-[15px] leading-[22px] mb-[6px] color-[#0C0D0E]\">\n {text?.author || 'Agent'}\n </div>\n {React.createElement(component, props)}\n </div>\n </div>\n );\n};\nexport const assistantMessageComponentsWithAvatar = {\n ...assistantMessageComponents,\n Text: wrapComponentsForTextWithAvatar(MarkdownText),\n Reasoning: wrapComponentsForReasoningWithAvatar(Reasoning as any),\n};\n"],"names":["_jsx","_jsxs","FileText","MarkdownText","ToolFallback","Reasoning","ReasoningGroup","AvatarList","isNil","useMessagePartText","useMessagePartReasoning"],"mappings":";;;;;;;;;;;;AAcA,SAAS,IAAI,CAAC,KAA2B,EAAA;AACvC,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAE3B,MAAM,OAAO,IACXA,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,qBAAqB,EAClC,QAAA,EAAAC,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,qFAAqF,EAClG,QAAA,EAAA,CAAAD,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,kFAAkF,EAAA,QAAA,EAC/FA,eAACE,oBAAQ,EAAA,EAAC,SAAS,EAAC,gBAAgB,EAAC,IAAI,EAAE,EAAE,EAAI,CAAA,EAAA,CAC7C,EACNF,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,+BAA+B,EAC5C,QAAA,EAAAA,cAAA,CAAA,MAAA,EAAA,EACE,SAAS,EAAC,iDAAiD,EAC3D,KAAK,EAAE,QAAQ,EAEd,QAAA,EAAA,QAAQ,GACJ,EACH,CAAA,CAAA,EAAA,CACF,EACF,CAAA,CACP,CAAC;AAEF,I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AA,GAAG,0BAA0B;AAC7B,IAAA,IAAI,EAAE,+BAA+B,CAACG,yBAAY,CAAC;AACnD,IAAA,SAAS,EAAE,oCAAoC,CAACE,mBAAgB,CAAC;;;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { Attributes } from 'react';
|
|
2
2
|
import { FileMessagePartProps } from '@assistant-ui/react';
|
|
3
|
+
declare function File(props: FileMessagePartProps): JSX.Element;
|
|
3
4
|
export declare const getAvatarByIdx: (idx?: number) => () => JSX.Element;
|
|
4
5
|
export declare const assistantMessageComponentsWithAvatar: {
|
|
5
6
|
Text: (props: Attributes) => JSX.Element;
|
|
@@ -7,7 +8,8 @@ export declare const assistantMessageComponentsWithAvatar: {
|
|
|
7
8
|
tools: {
|
|
8
9
|
Fallback: import("@assistant-ui/react").ToolCallMessagePartComponent;
|
|
9
10
|
};
|
|
10
|
-
File:
|
|
11
|
+
File: typeof File;
|
|
11
12
|
ReasoningGroup: React.NamedExoticComponent<import("@assistant-ui/react").ReasoningGroupProps>;
|
|
12
13
|
};
|
|
14
|
+
export {};
|
|
13
15
|
//# sourceMappingURL=message-components-with-avatar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-components-with-avatar.d.ts","sourceRoot":"","sources":["../../../src/components/assistant-ui/message-components-with-avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"message-components-with-avatar.d.ts","sourceRoot":"","sources":["../../../src/components/assistant-ui/message-components-with-avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EACL,oBAAoB,EAGrB,MAAM,qBAAqB,CAAC;AAS7B,iBAAS,IAAI,CAAC,KAAK,EAAE,oBAAoB,eAsBxC;AAaD,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,sBAK1C,CAAC;AAgEF,eAAO,MAAM,oCAAoC;kBA7D3B,UAAU;uBAgCV,UAAU;;;;;;CAiC/B,CAAC"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
-
import { MarkdownText } from './markdown-text.js';
|
|
4
|
-
import { Reasoning, ReasoningGroup } from './reasoning.js';
|
|
5
|
-
import { ToolFallback } from './tool-fallback.js';
|
|
6
3
|
import { useMessagePartText, useMessagePartReasoning } from '@assistant-ui/react';
|
|
7
4
|
import { AvatarList } from '../../assets/avatarGroup.js';
|
|
8
5
|
import { isNil } from 'lodash-es';
|
|
9
6
|
import { FileText } from 'lucide-react';
|
|
7
|
+
import { ToolFallback } from './tool-fallback.js';
|
|
8
|
+
import { Reasoning, ReasoningGroup } from './reasoning.js';
|
|
9
|
+
import { MarkdownText } from './markdown-text.js';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
function File(props) {
|
|
12
12
|
const { filename } = props;
|
|
13
13
|
const content = (jsx("div", { className: "flex flex-col gap-2", children: jsxs("div", { className: "flex items-center p-3 bg-[#F7F8FA] rounded-xl border border-[#E5E6EB] max-w-[300px]", children: [jsx("div", { className: "w-10 h-10 bg-[#E8F3FF] rounded-lg flex items-center justify-center mr-3 shrink-0", children: jsx(FileText, { className: "text-[#1677FF]", size: 24 }) }), jsx("div", { className: "flex flex-col overflow-hidden", children: jsx("span", { className: "text-[14px] font-medium text-[#1D2129] truncate", title: filename, children: filename }) })] }) }));
|
|
14
14
|
return content;
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
16
|
const assistantMessageComponents = {
|
|
17
17
|
Text: MarkdownText,
|
|
18
18
|
tools: {
|
|
@@ -29,29 +29,25 @@ const getAvatarByIdx = (idx) => {
|
|
|
29
29
|
}
|
|
30
30
|
return AvatarList[idx % avatarListLength];
|
|
31
31
|
};
|
|
32
|
-
const wrapComponentsForTextWithAvatar = (component) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return (jsxs("div", { className: "flex items-start", children: [jsx("div", { className: "fit-content mr-[12px] flex-shrink-0 flex-grow-0", children: jsx(Avatar, {}) }), jsxs("div", { className: "flex-1 max-w-[90%]", children: [jsx("div", { className: "font-medium text-[15px] leading-[22px] mb-[6px] color-[#0C0D0E]", children: text?.author || 'Agent' }), React__default.createElement(component, props)] })] }));
|
|
42
|
-
};
|
|
32
|
+
const wrapComponentsForTextWithAvatar = (component) => function (props) {
|
|
33
|
+
const text = useMessagePartText();
|
|
34
|
+
const showAvatar = text?.showAvatar;
|
|
35
|
+
const marginLeft = text?.marginLeft;
|
|
36
|
+
const Avatar = getAvatarByIdx(text?.authorIdx);
|
|
37
|
+
if (!showAvatar) {
|
|
38
|
+
return (jsx("div", { className: `${marginLeft ? 'ml-[50px]' : ''}`, children: React__default.createElement(component, props) }));
|
|
39
|
+
}
|
|
40
|
+
return (jsxs("div", { className: "flex items-start", children: [jsx("div", { className: "fit-content mr-[12px] flex-shrink-0 flex-grow-0", children: jsx(Avatar, {}) }), jsxs("div", { className: "flex-1 max-w-[90%]", children: [jsx("div", { className: "font-medium text-[15px] leading-[22px] mb-[6px] color-[#0C0D0E]", children: text?.author || 'Agent' }), React__default.createElement(component, props)] })] }));
|
|
43
41
|
};
|
|
44
|
-
const wrapComponentsForReasoningWithAvatar = (component) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return (jsxs("div", { className: "flex items-start", children: [jsx("div", { className: "fit-content mr-[12px] flex-shrink-0 flex-grow-0", children: jsx(Avatar, {}) }), jsxs("div", { className: "flex-1 max-w-[90%]", children: [jsx("div", { className: "font-medium text-[15px] leading-[22px] mb-[6px] color-[#0C0D0E]", children: text?.author || 'Agent' }), React__default.createElement(component, props)] })] }));
|
|
54
|
-
};
|
|
42
|
+
const wrapComponentsForReasoningWithAvatar = (component) => function (props) {
|
|
43
|
+
const text = useMessagePartReasoning();
|
|
44
|
+
const showAvatar = text?.showAvatar;
|
|
45
|
+
const marginLeft = text?.marginLeft;
|
|
46
|
+
const Avatar = getAvatarByIdx(text?.authorIdx);
|
|
47
|
+
if (!showAvatar) {
|
|
48
|
+
return (jsx("div", { className: `${marginLeft ? 'ml-[50px]' : ''}`, children: React__default.createElement(component, props) }));
|
|
49
|
+
}
|
|
50
|
+
return (jsxs("div", { className: "flex items-start", children: [jsx("div", { className: "fit-content mr-[12px] flex-shrink-0 flex-grow-0", children: jsx(Avatar, {}) }), jsxs("div", { className: "flex-1 max-w-[90%]", children: [jsx("div", { className: "font-medium text-[15px] leading-[22px] mb-[6px] color-[#0C0D0E]", children: text?.author || 'Agent' }), React__default.createElement(component, props)] })] }));
|
|
55
51
|
};
|
|
56
52
|
const assistantMessageComponentsWithAvatar = {
|
|
57
53
|
...assistantMessageComponents,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-components-with-avatar.js","sources":["../../../src/components/assistant-ui/message-components-with-avatar.tsx"],"sourcesContent":["import React, { Attributes } from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"message-components-with-avatar.js","sources":["../../../src/components/assistant-ui/message-components-with-avatar.tsx"],"sourcesContent":["import React, { Attributes } from 'react';\nimport {\n FileMessagePartProps,\n useMessagePartReasoning,\n useMessagePartText,\n} from '@assistant-ui/react';\nimport { AvatarList } from '@/assets/avatarGroup';\nimport { isNil } from 'lodash-es';\n\nimport { FileText } from 'lucide-react';\nimport { ToolFallback } from './tool-fallback';\nimport { Reasoning, ReasoningGroup } from './reasoning';\nimport { MarkdownText } from './markdown-text';\n\nfunction File(props: FileMessagePartProps) {\n const { filename } = props;\n\n const content = (\n <div className=\"flex flex-col gap-2\">\n <div className=\"flex items-center p-3 bg-[#F7F8FA] rounded-xl border border-[#E5E6EB] max-w-[300px]\">\n <div className=\"w-10 h-10 bg-[#E8F3FF] rounded-lg flex items-center justify-center mr-3 shrink-0\">\n <FileText className=\"text-[#1677FF]\" size={24} />\n </div>\n <div className=\"flex flex-col overflow-hidden\">\n <span\n className=\"text-[14px] font-medium text-[#1D2129] truncate\"\n title={filename}\n >\n {filename}\n </span>\n </div>\n </div>\n </div>\n );\n\n return content;\n}\n\nconst assistantMessageComponents = {\n Text: MarkdownText,\n tools: {\n Fallback: ToolFallback,\n },\n File,\n Reasoning,\n ReasoningGroup,\n};\nconst avatarListLength = AvatarList.length;\n\nexport const getAvatarByIdx = (idx?: number) => {\n if (isNil(idx) || idx < 0 || idx >= avatarListLength) {\n return AvatarList[0];\n }\n return AvatarList[idx % avatarListLength];\n};\nconst wrapComponentsForTextWithAvatar = (\n component: React.JSXElementConstructor<unknown>,\n) => function (props: Attributes) {\n const text = useMessagePartText() as any;\n\n const showAvatar = text?.showAvatar;\n const marginLeft = text?.marginLeft;\n const Avatar = getAvatarByIdx(\n text?.authorIdx,\n ) as React.JSXElementConstructor<unknown>;\n if (!showAvatar) {\n return (\n <div className={`${marginLeft ? 'ml-[50px]' : ''}`}>\n {React.createElement(component, props)}\n </div>\n );\n }\n return (\n <div className=\"flex items-start\">\n <div className=\"fit-content mr-[12px] flex-shrink-0 flex-grow-0\">\n <Avatar />\n </div>\n <div className=\"flex-1 max-w-[90%]\">\n <div className=\"font-medium text-[15px] leading-[22px] mb-[6px] color-[#0C0D0E]\">\n {text?.author || 'Agent'}\n </div>\n {React.createElement(component, props)}\n </div>\n </div>\n );\n};\n\nconst wrapComponentsForReasoningWithAvatar = (\n component: React.JSXElementConstructor<unknown>,\n) => function (props: Attributes) {\n const text = useMessagePartReasoning() as any;\n\n const showAvatar = text?.showAvatar;\n const marginLeft = text?.marginLeft;\n const Avatar = getAvatarByIdx(\n text?.authorIdx,\n ) as React.JSXElementConstructor<unknown>;\n if (!showAvatar) {\n return (\n <div className={`${marginLeft ? 'ml-[50px]' : ''}`}>\n {React.createElement(component, props)}\n </div>\n );\n }\n return (\n <div className=\"flex items-start\">\n <div className=\"fit-content mr-[12px] flex-shrink-0 flex-grow-0\">\n <Avatar />\n </div>\n <div className=\"flex-1 max-w-[90%]\">\n <div className=\"font-medium text-[15px] leading-[22px] mb-[6px] color-[#0C0D0E]\">\n {text?.author || 'Agent'}\n </div>\n {React.createElement(component, props)}\n </div>\n </div>\n );\n};\nexport const assistantMessageComponentsWithAvatar = {\n ...assistantMessageComponents,\n Text: wrapComponentsForTextWithAvatar(MarkdownText),\n Reasoning: wrapComponentsForReasoningWithAvatar(Reasoning as any),\n};\n"],"names":["_jsx","_jsxs","React"],"mappings":";;;;;;;;;;AAcA,SAAS,IAAI,CAAC,KAA2B,EAAA;AACvC,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAE3B,MAAM,OAAO,IACXA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,qBAAqB,EAClC,QAAA,EAAAC,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,qFAAqF,EAClG,QAAA,EAAA,CAAAD,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,kFAAkF,EAAA,QAAA,EAC/FA,IAAC,QAAQ,EAAA,EAAC,SAAS,EAAC,gBAAgB,EAAC,IAAI,EAAE,EAAE,EAAI,CAAA,EAAA,CAC7C,EACNA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,+BAA+B,EAC5C,QAAA,EAAAA,GAAA,CAAA,MAAA,EAAA,EACE,SAAS,EAAC,iDAAiD,EAC3D,KAAK,EAAE,QAAQ,EAEd,QAAA,EAAA,QAAQ,GACJ,EACH,CAAA,CAAA,EAAA,CACF,EACF,CAAA,CACP,CAAC;AAEF,IAAA,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,0BAA0B,GAAG;AACjC,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,KAAK,EAAE;AACL,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