Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support paste and match style #3927

Merged
merged 2 commits into from
Jan 26, 2024
Merged

Conversation

fnlctrl
Copy link
Contributor

@fnlctrl fnlctrl commented Dec 9, 2023

Most browsers/editors have a paste option "Paste and match style" or "Paste as plain text". When it's triggered, the clipboard data only contains "text/plain" and no "text/html", and editors would use the style at the cursor for the pasted text.
Currently it's not working in quill because formats isn't used in new Delta().insert(text) for text/plain. This PR adds support for it.

Chrome
image
image

Google Docs
image

@fnlctrl
Copy link
Contributor Author

fnlctrl commented Jan 24, 2024

@luin can you help take a look?

@luin
Copy link
Member

luin commented Jan 25, 2024

@fnlctrl Sorry for the delay! Was on a vacation and forgot it. I think the idea generally makes sense and will take a look soon.

@luin luin merged commit 9234fc9 into slab:develop Jan 26, 2024
5 checks passed
@luin luin changed the title support paste and match style Support paste and match style Jan 26, 2024
@fnlctrl fnlctrl deleted the paste-and-match-style branch January 30, 2024 02:27
alecgibson added a commit to reedsy/quill that referenced this pull request Feb 9, 2024
This is a reimplementation of slab#3530

At the moment, if the clipboard pastes `text/plain` content and no
`text/html` content, the `Clipboard.convert()` function will completely
skip the matching logic.

This is surprising when registering text node clipboard matchers.

This change updates the `convert()` function to match the plain text
against the plain text matchers, just like we do with HTML.

Note that these matchers will run _before_ applying the formats for
["paste and match style"][1], so they won't match an element matchers
for the target formatting (which I think should be expected anyway).

[1]: slab#3927
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants