import {MarkdownViewer} from '@primer/react/drafts'
The MarkdownViewer
displays rendered Markdown and handles interaction (link clicking and checkbox checking/unchecking) with that content.
const MarkdownViewerExample = () => {return (// eslint-disable-next-line github/unescaped-html-literal<MarkdownViewer dangerousRenderedHTML={{__html: '<strong>Lorem ipsum</strong> dolor sit amet.'}} />)}render(MarkdownViewerExample)
const MarkdownViewerExample = () => {return (<MarkdownViewer// eslint-disable-next-line github/unescaped-html-literaldangerousRenderedHTML={{__html: "<a href='https://example.com'>Example link</a>"}}onLinkClick={ev => console.log(ev)}/>)}render(MarkdownViewerExample)
const markdownSource = `text before list- [ ] item 1- [ ] item 2text after list`const renderedHtml = `<p>text before list</p><ul class='contains-task-list'><li class='task-list-item'><input type='checkbox' class='task-list-item-checkbox' disabled/> item 1</li><li class='task-list-item'><input type='checkbox' class='task-list-item-checkbox' disabled/> item 2</li></ul><p>text after list</p>`const MarkdownViewerExample = () => {return (<MarkdownViewerdangerousRenderedHTML={{__html: renderedHtml}}markdownValue={markdownSource}onChange={value => console.log(value) /* save the value to the server */}disabled={false}/>)}render(MarkdownViewerExample)