@mocanvas/mocanvas · function
declare function applyPlainTextToRichText(previous: RichTextSource, nextText: string): RichTextFold a plain-text edit back into a rich-text document.
The plain-text editing surface (the <textarea> the DOM overlay falls back
to when no TipTap editor is installed) can only express text, not marks. When
the text did not actually change, the original document is returned unchanged
so opening and closing the editor never silently strips formatting. When it
did change, the document is rebuilt from the new text — the honest outcome for
an editor that cannot represent the marks it would have to preserve.
SEMANTICS-ASSUMED: mocanvas owns this seam (it exists because TipTap is optional here), so there is no upstream behaviour to match. "Keep formatting on a no-op, drop it on a real plain-text edit" is the conservative choice: it never loses formatting the user did not touch, and never claims to preserve marks it cannot place.
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.