🐛 fix(vscode): 代码阅读对话里的回答悬停链接时卡片一直闪、盖住链接:回答每次重画都新建 {__html},React 换了对象就整段重设 innerHTML,弹出定义卡片引起的重画把悬停着的链接换成新元素,卡片按脱离页面的旧链接落到左上角盖住链接,指针下的新链接又重新问卡片、再被换掉,来回闪;回答改用 MarkdownPreview,同一段 HTML 用同一个对象,链接不再被换
This commit is contained in:
1 parent
d6960b894c
commit
2841e2b477
3 files changed
+62
-7
No files matched your search
@@ -25,7 +25,8 @@ export const TextPreview = memo(({ text, className, find }: { text: PreviewText,
|
||||
})
|
||||
TextPreview.displayName = 'TextPreview'
|
||||
|
||||
export function MarkdownPreview({ html, className, find }: { html: string, className?: string, find?: string }): ReactElement {
|
||||
export function MarkdownPreview({ html, className, find, streaming }: { html: string, className?: string, find?: string, streaming?: boolean }): ReactElement {
|
||||
// 同一段 HTML 用同一个对象:React 见到新对象就整段重设 innerHTML,里面的链接都换成新元素,悬停着的那个就脱离了页面
|
||||
const content = useMemo(() => ({ __html: html }), [html])
|
||||
return <div className={cn('cr-markdown', className)} data-find={find} dangerouslySetInnerHTML={content} />
|
||||
return <div className={cn('cr-markdown', className)} data-find={find} data-streaming={streaming ? '' : undefined} dangerouslySetInnerHTML={content} />
|
||||
}
|
||||
Reference in new issue
Block a user