Bug: pasting plain-text Markdown only converts inline marks — block elements (headings, dividers) have no paste rules #1317
marcusbellamyshaw-cell
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Bug
Pasting plain-text Markdown into the Portable Text editor only partially converts. Inline marks (
**bold**,_italic_) convert correctly but block-level syntax (# Heading,## Heading,---dividers) pastes as literal text regardless of editor focus or paste method.Pasting from an HTML source (e.g. copying a rendered response from a browser chat UI) works correctly because TipTap picks up the HTML from the clipboard and parses
<h1>,<h2>,<hr>etc. as structured blocks. The problem is specifically with plain-text Markdown in the clipboard.Root cause
There is no Markdown clipboard text parser in the editor. TipTap has two separate rule systems:
markPasteRule) — fire on paste events. StarterKit'sBold,Italic, andCodemarks have these, which is why inline formatting converts correctly.textblockTypeInputRule) — fire on typed input only, never on paste.HeadingandHorizontalRuleonly have input rules, so they never convert pasted content regardless of focus state.Fix
Add a
clipboardTextParserextension toPortableTextEditor.tsxthat detects plain-text Markdown and routes it through the existingmarkdownToPortableText→portableTextToProsemirrorpipeline already in the codebase (packages/core/src/client/portable-text.ts). This bypasses the input rule / paste rule distinction entirely and makes plain-text Markdown paste work consistently.Impact
Any editor who writes content in Markdown and pastes from a plain-text source (document editor, AI tool text output, text file) hits this. Copying from a rendered HTML source such as a browser-based chat UI works as a workaround because the clipboard carries HTML, but this is non-obvious and easy to miss.
Beta Was this translation helpful? Give feedback.
All reactions