-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Handle paste events for images and text properly #7679
Conversation
better event handling
Code is ready and smoke tested, @akhenry . Just gonna write up some tests |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7679 +/- ##
==========================================
- Coverage 56.63% 56.29% -0.34%
==========================================
Files 672 672
Lines 27124 27135 +11
Branches 2632 2634 +2
==========================================
- Hits 15361 15276 -85
- Misses 11436 11531 +95
- Partials 327 328 +1
... and 10 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
add clipboard functions
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.
Looks mostly G2G just a few small comments
@@ -27,6 +27,7 @@ This test suite is dedicated to tests which verify the basic operations surround | |||
import { fileURLToPath } from 'url'; | |||
|
|||
import { createDomainObjectWithDefaults } from '../../../../appActions.js'; | |||
import hotkeys from '../../../../helper/hotkeys/hotkeys.js'; |
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.
import hotkeys from '../../../../helper/hotkeys/hotkeys.js'; | |
import { copy, paste, selectAll } from '../../../../helper/hotkeys/hotkeys.js'; |
await hotkeys.selectAll(page); | ||
await hotkeys.copy(page); |
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.
await hotkeys.selectAll(page); | |
await hotkeys.copy(page); | |
await selectAll(page); | |
await copy(page); |
etc
await expect(await page.locator(`text="${TEST_TEXT.repeat(1)}"`).count()).toEqual(1); | ||
await expect(await page.locator(`text="${TEST_TEXT.repeat(2)}"`).count()).toEqual(0); |
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.
await expect(await page.locator(`text="${TEST_TEXT.repeat(1)}"`).count()).toEqual(1); | |
await expect(await page.locator(`text="${TEST_TEXT.repeat(2)}"`).count()).toEqual(0); | |
expect(await page.locator(`text="${TEST_TEXT.repeat(1)}"`).count()).toEqual(1); | |
expect(await page.locator(`text="${TEST_TEXT.repeat(2)}"`).count()).toEqual(0); |
// If the clipboard contained an image, prevent the paste event from reaching the textarea. | ||
if (hasImage) { | ||
addTextFromPaste(event) { | ||
if (!this.editMode) { |
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.
This is easily confused for the API's Edit mode. Can we rename this to make it clear that it refers to the notebook entry being editable?
Co-authored-by: Jesse Mazzella <[email protected]>
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
Closes #7686
Describe your changes:
paste text outside text area
: no-oppaste text inside text area (editing)
: default paste event behaviorpaste image outside text area
: image attachedpaste image inside text area (editing)
: image attached (FEATURE, DEFINITELY NOT A BUG: this persists the notebook entry, including any text edits made prior to the image paste, and leaves the entry in edit mode. If you want the entry to be committed on image paste, not in edit mode, or something else entirely, let me know @charlesh88 )All Submissions:
Author Checklist
type:
label? Note: this is not necessarily the same as the original issue.Reviewer Checklist