Props
Common Props for DsMarkdown and MarkdownCMD
| Prop | Type | Description | Default |
|---|---|---|---|
interval | number | IntervalConfig | Typing interval configuration, supports fixed interval or dynamic speed control | 30 |
timerType | 'setTimeout' | 'requestAnimationFrame' | Timer type, cannot be modified dynamically | 'setTimeout' |
answerType | AnswerType | Content type (affects style theme), cannot be modified dynamically | 'answer' |
theme | Theme | Theme type | 'light' |
plugins | IMarkdownPlugin[] | Plugin configuration | [] |
math | IMarkdownMath | Math formula configuration | { splitSymbol: 'dollar' } |
showCursor | boolean | Whether to show cursor during typing animation | false |
cursor | React.ReactNode | 'line' | 'block' | 'underline' | 'circle' | Custom cursor element or built-in cursor type | 'line' (when showCursor is true) |
onEnd | (data?: IEndData) => void | Typing completion callback | - |
onStart | (data?: IStartData) => void | Typing start callback | - |
onBeforeTypedChar | (data?: IBeforeTypedChar) => Promise<void> | Callback before character typing, supports async operations, will block subsequent typing | - |
onTypedChar | (data?: ITypedChar) => void | Callback after each character is typed | - |
disableTyping | boolean | Disable typing animation effect | false |
autoStartTyping | boolean | Whether to automatically start typing animation, set to false for manual trigger, cannot be modified dynamically | true |
codeBlock | IMarkdownCode | Code block configuration | {headerActions: true} |
DsMarkdown Specific Props
| Prop | Type | Description | Default |
|---|---|---|---|
children | string | undefined | Markdown content | - |
MarkdownCMD Specific Props
MarkdownCMD does not require a children prop. Content is added dynamically through the push() method.
Usage Examples
Basic Configuration
<DsMarkdown
interval={20}
theme="dark"
answerType="answer"
showCursor
cursor="block"
>
# Content
</DsMarkdown>Dynamic Speed Control
<DsMarkdown
interval={{
min: 10,
max: 50,
curve: 'ease-out'
}}
>
Content...
</DsMarkdown>Callback Functions
<DsMarkdown
onStart={(data) => console.log('Started', data)}
onEnd={(data) => console.log('Completed', data)}
onTypedChar={(data) => console.log('Typed', data)}
>
Content...
</DsMarkdown>