From f3c160f1037d37cc6dac9c2531f9aa28ded13a93 Mon Sep 17 00:00:00 2001 From: mt Date: Thu, 11 Jun 2026 09:50:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(artifact):=20artifact=20markdown=20?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E5=A4=8D=E7=94=A8=20CopyButton?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ArtifactFilePreview 中 Streamdown 的 table 组件覆盖为 MarkdownTable - artifact 区表格复制/下载行为与聊天区一致 --- .../artifacts/artifact-file-detail.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx b/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx index d6b0ab07..0e6763b6 100644 --- a/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx +++ b/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx @@ -14,6 +14,7 @@ import { useState, type CSSProperties, type ComponentProps, + type ComponentPropsWithoutRef, type HTMLAttributes, } from "react"; import { toast } from "sonner"; @@ -40,6 +41,7 @@ import { CodeEditor } from "@/components/workspace/code-editor"; import { useArtifactContent } from "@/core/artifacts/hooks"; import { resolveArtifactURL, urlOfArtifact } from "@/core/artifacts/utils"; import { useI18n } from "@/core/i18n/hooks"; +import { MarkdownTable } from "@/components/workspace/messages/markdown-content"; import { streamdownPlugins } from "@/core/streamdown"; import { checkCodeFile, getFileName } from "@/core/utils/files"; import { useMarkdownDownload } from "@/core/utils/markdown-download"; @@ -909,11 +911,26 @@ export function ArtifactFilePreview({ threadId: string; filepath?: string; }) { + const { t } = useI18n(); const zoomScale = zoom / 100; const normalizedContent = useMemo(() => { return rewriteArtifactImagePaths(content ?? "", threadId, filepath); }, [content, threadId, filepath]); + const streamdownComponents = useMemo( + () => ({ + a: CitationLink, + table: (props: ComponentPropsWithoutRef<"table">) => ( + + ), + }), + [t.clipboard.copyToClipboard, t.common.download], + ); + if (language === "markdown") { return (
{normalizedContent}