@mocanvas/mocanvas · function

renderHtmlFromRichTextForMeasurement

declare function renderHtmlFromRichTextForMeasurement(editor: Editor | null | undefined, richText: RichTextSource): string

Render a rich-text value to the HTML the text measurer sizes.

The markup is generated from the document JSON with the editor's configured extensions: text is escaped, link hrefs are scheme-checked, and no whitespace is emitted between tags (the probe lays out with white-space: pre-wrap, where an indenting newline would measure as a space). A plain string is accepted too and renders as the paragraphs it splits into, so a caller does not have to know which of props.richText and props.text the store holds.

The result is only meant for measurement and for mocanvas's own label rendering. It is not a general-purpose export format — use richTextToSvg for SVG.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.