import { useMemo, useRef } from "react"; import { MarkdownSelectionTooltip } from "@/v4/MarkdownSelectionTooltip.js"; import type { MarkdownSelectionTarget } from "@/lib/conversationSelectionReference.js"; import { MessageResponse } from "@/components/ai-elements/message.js"; import type { CodePreviewSettings } from "@/lib/codePreviewSettings.js"; import type { Theme } from "@/useTheme.js"; interface MarkdownPreviewContentProps { content: string; sourceKey?: string; sourceTitle?: string; sourcePath?: string; selectionTarget?: MarkdownSelectionTarget; workspacePath?: string; /** 应用主题(store 耦合剥离):透传给 markdown 渲染,缺省按 "system" 兜底。 */ theme?: Theme; /** 代码预览设置(store 耦合剥离):透传给 markdown 渲染,需保持引用稳定。 */ codePreviewSettings?: CodePreviewSettings; onOpenBrowserUrl?: (url: string) => void; } export function MarkdownPreviewContent({ content, sourceKey, sourceTitle, sourcePath, selectionTarget, workspacePath, theme, codePreviewSettings, onOpenBrowserUrl, }: MarkdownPreviewContentProps) { const rootRef = useRef(null); const selectionScope = useMemo( () => ({}), [content, sourceKey, sourcePath, selectionTarget?.workspaceKey, selectionTarget?.sessionId], ); return (
{selectionTarget && sourceKey ? ( ) : null}
{content}
); }