Repository navigation
Editor: preserve markdown when copying and pasting - #3371
Conversation
591dcff to
8d24f77
Compare
JammingBen
left a comment
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.
| // 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) { |
There was a problem hiding this comment.
Probably makes sense to guard inline code marks as well here.
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
12b1df5 to
03a741b
Compare
|
@JammingBen thanks for your review! Anyways, I decided to change the strategy entirely because we didn't use the native tip tap paste handler anymore and therefore we would need to care about a lot of quirks. So now we convert the pasted text to markdown and then let the the original paste handler take care. Which unfortantly means, this PR needs a new review with a fresh eye 👁️ |
03a741b to
31c1fce
Compare
Description
Add Markdown-aware clipboard handling to the rendered Markdown editor view.
Users can now copy rendered Markdown and paste it into Markdown-aware tools while keeping the Markdown syntax. Pasting Markdown back into the editor also works from tools like IntelliJ, even when they provide both text and HTML clipboard content.
For Markdown files we now prefer clipboard text over HTML. This means rich formatting copied from websites is not preserved unless it exists as Markdown syntax. Rich note editing should use
.ocnote.Related Issue
How Has This Been Tested?
Types of changes