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

Run clipboard matchers against plain text pastes #3530

Closed
wants to merge 1 commit into from

Conversation

alecgibson
Copy link
Contributor

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 change the plain text
into basic HTML, which is passed through the matchers.

The conversion interprets newlines as paragraph <p> elements,
consistent with Quill's existing behaviour.

@gordoncl
Copy link

I think this is a duplicate of #2706. This seems to have been a regression for over 3 years now?

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 change the plain text
into basic HTML, which is passed through the matchers.

The conversion interprets newlines as paragraph `<p>` elements,
consistent with Quill's existing behaviour.
@luin
Copy link
Member

luin commented Feb 9, 2024

This is a bit conflicted with #3927 where we want to match the target format when user pastes with "Paste and Match Style". I think it's hard to say what is the expected behavior unless browsers provide an API telling us whether the user selects "Paste and Match Style" or the source is a plain text.

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
@alecgibson
Copy link
Contributor Author

@luin I've reimplemented this in #4002

@alecgibson alecgibson closed this Feb 9, 2024
@alecgibson alecgibson deleted the plain-text-matchers branch February 9, 2024 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants