MarkdownViewer
Displays rendered Markdown and facilitates interaction.
- Draft
- Not reviewed for accessibility
import {MarkdownViewer} from '@primer/react/drafts'
The MarkdownViewer
displays rendered Markdown and handles interaction (link clicking and checkbox checking/unchecking) with that content.
Name | Type | Default | Description |
---|---|---|---|
markdownValue | string | The markdown the HTML was rendered from. This is not used for viewing, only as a source for change events. | |
dangerousRenderHTML | { __html: string } | Set the rendered HTML of the viewer. To prevent XSS, ensure that the source of this HTML is trusted! | |
loading | boolean | Show a loading spinner instead of content. | |
onLinkClick | (event: MouseEvent) => void | Called when the user clicks a link element. This can be used to intercept the click and provide custom routing. Note that this is a native HTML `MouseEvent` and not a `React.ClickEvent`. | |
openLinksInNewTab | boolean | ||
onChange | (markdown: string) => void | Promise<void> | Called when the user interacts and updates the Markdown. The rendered Markdown is updated eagerly - if the request fails, a rejected Promise should be returned by this handler. In that case, the viewer will revert the visual change. If the change is handled by an async API request (as it typically will be in production code), the viewer should be `disabled` while the request is pending to avoid conflicts. To allow users to check multiple boxes rapidly, the API request should be debounced (an ideal debounce duration is about 1 second). | |
disabled | boolean | Control whether interaction is disabled. |