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

Prevent rich-formatting paste #4327

Merged
merged 2 commits into from
Jun 13, 2024

Conversation

mary-ext
Copy link
Contributor

@mary-ext mary-ext commented Jun 3, 2024

Fixes #1321
Fixes #3032
Fixes #4301

We don't actually support rich WYSIWYG formatting in the composer, check if what's being pasted is one, and retrieve a plain-text version of it. This won't interfere with pasting HTML files (even though that's not supported either) as pasted files only have Files in the types array.

@mary-ext
Copy link
Contributor Author

mary-ext commented Jun 3, 2024

Fix works for me, just need verification from others, easiest way to test is to have a fresh copy of Edge on Windows, and copy any links, like from the address bar.

@gaearon
Copy link
Collaborator

gaearon commented Jun 3, 2024

would be good to verify that the fix works, then we can pull it in.

@auroursa
Copy link
Contributor

auroursa commented Jun 4, 2024

It seems to partially resolve the issue, but the link preview is not working (I'm not sure if this is the expected behavior).
By the way, the link I tested is https://github.com/bluesky-social, and my Edge version is 125.0.2535.85.

屏幕截图 2024-06-04 105704

Copy link

@boly38 boly38 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some little note while reviewing your diff

@mary-ext
Copy link
Contributor Author

mary-ext commented Jun 7, 2024

It seems to partially resolve the issue

I'll take another look tomorrow to see if there's anything that can be done, don't want to resort to detecting links and snipping the rest of it off

@Zero3K
Copy link

Zero3K commented Jun 8, 2024

I wonder how Twitter/Upwork does it. Maybe someone could look into that and then use either of their methods.

@mary-ext
Copy link
Contributor Author

mary-ext commented Jun 10, 2024

Looks like this is happening because .preventDefault() doesn't seem to prevent pasting, so we're still inserting the original pasted text, for some reason. I think this might be on ProseMirror though when I last looked at its code, so let me see.

@mary-ext
Copy link
Contributor Author

mary-ext commented Jun 10, 2024

@mary-ext
Copy link
Contributor Author

mary-ext commented Jun 10, 2024

@auroursa Can you verify this again? I've confirmed that it works as it should on my end.

@auroursa
Copy link
Contributor

@mary-ext Yeah it works very well for me.

Copy link
Collaborator

@gaearon gaearon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't test Edge but this does result in more sensible paste output on macOS when pasting HTML from random places, let's give this a try.

@gaearon gaearon merged commit 247af5a into bluesky-social:main Jun 13, 2024
6 checks passed
This was referenced Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants