Skip to content

ui-list paste plaintext-only - #2057

Merged
justvanrossum merged 3 commits into
mainfrom
issue-2043-ui-list-prevent-pasting-rich-text
Feb 27, 2025
Merged

justvanrossum merged 3 commits into
mainfrom
issue-2043-ui-list-prevent-pasting-rich-text

Conversation

@ollimeier

Copy link
Copy Markdown
Contributor

Fixes #2043

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

@justvanrossum justvanrossum left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

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

@justvanrossum

Copy link
Copy Markdown
Member

https://github.com/googlefonts/fontra/blob/715766525773908242750e99b5eec268ef290981/src/fontra/client/core/utils.js#L314

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

@ollimeier

Copy link
Copy Markdown
Contributor Author

https://github.com/googlefonts/fontra/blob/715766525773908242750e99b5eec268ef290981/src/fontra/client/core/utils.js#L314

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
Copy Markdown
Member

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

@ollimeier

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