-
Notifications
You must be signed in to change notification settings - Fork 179
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
Added plain text paste handler #4600
Conversation
Size Change: +461 B (0%) Total Size: 1.27 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM -- a test would be great though!
Codecov Report
@@ Coverage Diff @@
## main #4600 +/- ##
===========================================
+ Coverage 70.10% 83.34% +13.24%
===========================================
Files 881 882 +1
Lines 15519 15530 +11
===========================================
+ Hits 10880 12944 +2064
+ Misses 4639 2586 -2053
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I don't think we can test with native paste event for this, but I can try. |
@barklund would an e2e test be possible? If so, happy to help |
Testing this is not easy (in Puppeteer/Playwright/Cypress/Selenium), I had the best luck (consistency across browsers/oss) with something like this: const plainText = "Foo Bar";
const pasteEvent = Object.assign(
new Event("paste", { bubbles: true, cancelable: true }),
{
clipboardData: {
types: ["text/plain"],
items: {
length: 1,
0: {
kind: "string",
type: "text/plain",
getAsString: () => plainText
}
},
getData: (type) => plainText
}
}
);
document.activeElement.dispatchEvent(pasteEvent); |
Summary
Custom handling of pasted (plain text) content.
Note that this ignores formatted content. That work is still pending in #760.
Testing Instructions
NB: Note that rich text formatting is ignored in pasted content. The content is pasted to match the style of the text field, not the original formatting from where it was pasted.
Fixes #1605