import type { ReactElement } from 'react'
import type { PreviewText } from './types'
import { memo, useMemo } from 'react'
import { cn } from '@/lib/utils'
import { renderMarkdown } from './markdown'
import { SegmentText } from './SegmentText'
/**
* 预览里的一段文字:着色的词按源码排版;Markdown 说明渲染成段落、列表、代码块。
* `find` 是卡片上这段字的记号(见 [textKey](vscode/webview-ui/src/codeReader/viewState.ts#textKey)),查找栏按它找到这段字画高亮。
*/
export const TextPreview = memo(({ text, className, find }: { text: PreviewText, className?: string, find?: string }): ReactElement => {
if ('markdown' in text)
return