@prosemark/paste-rich-text
v0.0.5
Published
CodeMirror 6 extensions for **pasting clipboard HTML as Markdown** and for **paste without formatting**.
Readme
@prosemark/paste-rich-text
CodeMirror 6 extensions for pasting clipboard HTML as Markdown and for paste without formatting.
Published on npm: @prosemark/paste-rich-text.
What it provides
pasteRichTextExtension— Interceptspastewhen the clipboard hastext/html, converts HTML to Markdown with Turndown, and inserts the result. Skips conversion when the selection is inside a fenced code block.pastePlainTextExtension—Mod-Shift-Vreads plain text from the clipboard and inserts it (bypasses rich paste).
Both accept an optional callback after insert (for example to run spellcheck or sync document state).
Install
bun add @prosemark/paste-rich-textUsage
import {
pasteRichTextExtension,
pastePlainTextExtension,
} from '@prosemark/paste-rich-text';
const extensions = [pasteRichTextExtension(), pastePlainTextExtension()];With callbacks (as in the demo app and VS Code webview):
pasteRichTextExtension((event, view, from, to) => {
// e.g. refresh decorations after paste
});
pastePlainTextExtension((view, from, to) => {
// same
});Dependencies
@codemirror/view,@codemirror/state,@codemirror/language(fenced-code detection)turndown
