Editor: preserve markdown when copying and pasting - #3371
Open
AlexAndBear wants to merge 8 commits into
Open
AlexAndBear wants to merge 8 commits into
AlexAndBear wants to merge 8 commits into
Conversation
AlexAndBear
force-pushed
the
enhancement/markdown-clipboard-interoperability
branch
10 times, most recently
from
September 14, 2026 23:24
efbc6fb to
591dcff
Compare
AlexAndBear
force-pushed
the
enhancement/markdown-clipboard-interoperability
branch
from
September 14, 2026 23:26
591dcff to
8d24f77
Compare
JammingBen
requested changes
Sep 15, 2026
JammingBen
left a comment
Member
There was a problem hiding this comment.
A paste of a single word or letter is always adding line breaks for some reason. E.g. have foobar in the editor, put the cursor after foo and paste a single letter. This results in 3 lines.
Comment on lines
+26
to
+28
| // Let the original paste handler insert plain text inside code-like nodes. | ||
| // Parsing it as markdown would split pasted code into regular document blocks. | ||
| if (view.state.selection.$from.parent.type.spec.code) { |
Member
There was a problem hiding this comment.
Probably makes sense to guard inline code marks as well here.
Member
Author
There was a problem hiding this comment.
It looks like this is an error in the native paste command, we already return false here, but the issue persists.
This is also the case on demo
JammingBen
approved these changes
Sep 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Improve Markdown clipboard handling in the rendered editor.
Copied selections from Markdown documents are serialized as Markdown text, so they can be pasted into Markdown-aware targets without switching to source mode. Pasted clipboard text is now inserted through the Markdown parser consistently, including when the clipboard also exposes an HTML payload.
Downside: rich formatting that only exists in the HTML clipboard payload, such as bold text copied from a web page, is not preserved in Markdown files. Rich note editing should use the
.ocnotefile extension for that use case.Related Issue
How Has This Been Tested?
pnpm test:unit --run packages/web-pkg/tests/unit/editor/extensions/markdownClipboard.spec.tsTypes of changes