For AI agents: the complete documentation index is available at /apps-plugin/docs/llms.txt, the full documentation bundle is available at /apps-plugin/docs/llms-full.txt, and this page is available as Markdown at /apps-plugin/docs/components/media/markdown.md.

markdown

Markdown 渲染组件,用于渲染 Markdown 内容,支持打字机动画、文本选择和文本标注。

扫码预览

扫码预览 markdown

Props

属性名类型默认值必填说明
animationType"none" | "typewriter"'none'否动画类型
animationVelocitynumber1否动画速度。打字机模式下表示每秒输出字符数
classNamestring-否组件类名
contentstring-是Markdown 源内容
contentCompletebooleantrue否打字机动画完成后是否隐藏光标并触发绘制完成事件
contentIdstring-否内容标识,会在事件和 UI 方法中回传
contentRangenumber[][0, int32_max]否需要解析的内容区间
enableGifbooleanfalse否是否启用 GIF 动画
idstring-否元素的唯一标识
initialAnimationStepnumber0否动画起始步数
keystring | number | null-否React key 属性
markdownEffectMarkdownEffect{}否额外 Markdown 效果配置
markdownStyleMarkdownStyle{}否Markdown 内部元素样式表。它不是普通的 CSS style:颜色使用不带 # 的十六进制字符串
(如 '151515'),尺寸使用 number(如 fontSize: 15、lineHeight: 22),
不要传 var(--color)、'#151515' 或 '15px'。
onAnimationStep(event: MarkdownEvent<"bindanimationStep", MarkdownAnimationStepEvent>) => void-否动画每步结束时触发
onDrawEnd(event: MarkdownEvent<"binddrawEnd">) => void-否绘制完成时触发
onDrawStart(event: MarkdownEvent<"binddrawStart">) => void-否开始绘制时触发
onImageTap(event: MarkdownEvent<"bindimageTap", MarkdownImageTapEvent>) => void-否点击图片时触发
onLink(event: MarkdownEvent<"bindlink", MarkdownLinkEvent>) => void-否点击链接时触发
onOverflow(event: MarkdownEvent<"bindoverflow", MarkdownOverflowEvent>) => void-否文本溢出时触发
onParseEnd(event: MarkdownEvent<"bindparseEnd", MarkdownParseEndEvent>) => void-否解析完成时触发
onSelectionChange(event: MarkdownEvent<"bindselectionchange", MarkdownSelectionChangeEvent>) => void-否文本选择变化时触发
onTextClick(event: MarkdownEvent<"bindtextClick", MarkdownTextClickEvent>) => void-否点击 textMarkAttachments 中的可点击标注时触发
refRef<MarkdownRef>-否用于获取组件实例的 ref
styleCSSProperties-否组件样式
textMarkAttachmentsMarkdownMarkAttachment[][]否文本高亮、下划线等标注配置
textMaxlinenumber-否最大文本行数,表格行也会计为一行
textSelectionbooleanfalse否是否支持文本选择
typewriterDynamicHeightbooleanfalse否打字机模式下高度是否跟随已输出内容变化
typewriterHeightTransitionDurationnumber0否打字机动画扩展高度时的过渡时长

Ref 方法

方法名类型说明
getContent(options?: MarkdownContentRangeOptions) => Promise<MarkdownContentResult>获取指定区间的已解析内容
getImages() => Promise<MarkdownImagesResult>获取 Markdown 中的所有图片地址
getParseResult(options: MarkdownParseResultOptions) => Promise<MarkdownParseResult>获取指定标签对应的源码区间
getSelectedText() => Promise<MarkdownSelectedTextResult>获取当前选中的文本
getTextBoundingRect(options?: MarkdownTextBoundingRectOptions) => Promise<MarkdownTextBoundingRectResult>获取指定文本区间的布局包围盒
pauseAnimation() => Promise<MarkdownAnimationStepResult>暂停打字机动画
resumeAnimation(options?: MarkdownResumeAnimationOptions) => Promise<void>继续打字机动画
setTextSelection(options: MarkdownTextSelectionOptions) => Promise<MarkdownTextSelectionResult>通过坐标设置文本选区