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

ui-list paste plaintext-only #2057

Merged
merged 3 commits into from
Feb 27, 2025

Conversation

ollimeier
Copy link
Collaborator

Fixes #2043

@ollimeier ollimeier changed the title ui-list past plaintext-only ui-list paste plaintext-only Feb 26, 2025
Copy link
Collaborator

@justvanrossum justvanrossum left a comment

Choose a reason for hiding this comment

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

Awesome! I didn't know about "plaintext-only".

@justvanrossum
Copy link
Collaborator

Pls wait with merge, though, I found one thing, just a sec.

@justvanrossum
Copy link
Collaborator

if (element.contentEditable === "true") {

This may need to be changed as well. Maybe it is as simple as changing it to element.contentEditable !== "false".

@ollimeier
Copy link
Collaborator Author

if (element.contentEditable === "true") {

This may need to be changed as well. Maybe it is as simple as changing it to element.contentEditable !== "false".

element.contentEditable can also be inherit (which would also be !== "false") why I think it's probably better to use element.contentEditable === "plaintext-only" ||.
I would like to write a unittest for that, but I don't know how, because isActiveElementTypeable uses document.activeElement and I don't know how to mock up such an element for a unittest.

@justvanrossum
Copy link
Collaborator

Ah, actually, we should use isContentEditable: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/isContentEditable

@ollimeier
Copy link
Collaborator Author

Ah, actually, we should use isContentEditable: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/isContentEditable

Thanks for the hint. That's much better. Please see the latest commit.

@justvanrossum justvanrossum merged commit deede0b into main Feb 27, 2025
5 checks passed
@justvanrossum justvanrossum deleted the issue-2043-ui-list-prevent-pasting-rich-text branch February 27, 2025 09:46
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.

[ui-list] Prevent pasting rich text
2 participants