-
Notifications
You must be signed in to change notification settings - Fork 4.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
Writing flow: Copy whole block if no text is selected #22186
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6acc2cd
Writing flow: Copy whole block if no text is selected
mcsf 15e442d
Append change to package changelog
mcsf 5106b31
Consider full selection when not copying/cutting
mcsf cba7b5f
Copy notice: Reveal block type if only one block copied
mcsf 089f870
Flash block outline in response to copy action
mcsf 5b4aad8
Notify of copy and cut actions w/ useNotifyCopy hook
mcsf 6ea321e
Reduce block highlight time.
mtias 059ccc9
Block Editor: Add action `flashBlock`
mcsf f305234
E2E: Test whole-block copy, cut and paste
mcsf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...ges/e2e-tests/specs/editor/various/__snapshots__/copy-cut-paste-whole-blocks.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Multi-block selection should copy and paste individual blocks 1`] = ` | ||
"<!-- wp:paragraph --> | ||
<p>Here is a unique string so we can test copying.</p> | ||
<!-- /wp:paragraph --> | ||
|
||
<!-- wp:paragraph --> | ||
<p>2</p> | ||
<!-- /wp:paragraph -->" | ||
`; | ||
|
||
exports[`Multi-block selection should copy and paste individual blocks 2`] = ` | ||
"<!-- wp:paragraph --> | ||
<p>Here is a unique string so we can test copying.</p> | ||
<!-- /wp:paragraph --> | ||
|
||
<!-- wp:paragraph --> | ||
<p>2</p> | ||
<!-- /wp:paragraph --> | ||
|
||
<!-- wp:paragraph --> | ||
<p>Here is a unique string so we can test copying.</p> | ||
<!-- /wp:paragraph --> | ||
|
||
<!-- wp:paragraph --> | ||
<p></p> | ||
<!-- /wp:paragraph -->" | ||
`; | ||
|
||
exports[`Multi-block selection should cut and paste individual blocks 1`] = ` | ||
"<!-- wp:paragraph --> | ||
<p>2</p> | ||
<!-- /wp:paragraph -->" | ||
`; | ||
|
||
exports[`Multi-block selection should cut and paste individual blocks 2`] = ` | ||
"<!-- wp:paragraph --> | ||
<p>2</p> | ||
<!-- /wp:paragraph --> | ||
|
||
<!-- wp:paragraph --> | ||
<p>Yet another unique string.</p> | ||
<!-- /wp:paragraph --> | ||
|
||
<!-- wp:paragraph --> | ||
<p></p> | ||
<!-- /wp:paragraph -->" | ||
`; | ||
|
||
exports[`Multi-block selection should respect inline copy when text is selected 1`] = ` | ||
"<!-- wp:paragraph --> | ||
<p>First block</p> | ||
<!-- /wp:paragraph --> | ||
|
||
<!-- wp:paragraph --> | ||
<p>Second block</p> | ||
<!-- /wp:paragraph -->" | ||
`; | ||
|
||
exports[`Multi-block selection should respect inline copy when text is selected 2`] = ` | ||
"<!-- wp:paragraph --> | ||
<p>First block</p> | ||
<!-- /wp:paragraph --> | ||
|
||
<!-- wp:paragraph --> | ||
<p>ck</p> | ||
<!-- /wp:paragraph --> | ||
|
||
<!-- wp:paragraph --> | ||
<p>Second block</p> | ||
<!-- /wp:paragraph -->" | ||
`; |
66 changes: 66 additions & 0 deletions
66
packages/e2e-tests/specs/editor/various/copy-cut-paste-whole-blocks.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
clickBlockAppender, | ||
createNewPost, | ||
pressKeyWithModifier, | ||
getEditedPostContent, | ||
} from '@wordpress/e2e-test-utils'; | ||
|
||
describe( 'Multi-block selection', () => { | ||
beforeEach( async () => { | ||
await createNewPost(); | ||
} ); | ||
|
||
it( 'should copy and paste individual blocks', async () => { | ||
await clickBlockAppender(); | ||
await page.keyboard.type( | ||
'Here is a unique string so we can test copying.' | ||
); | ||
await page.keyboard.press( 'Enter' ); | ||
await page.keyboard.type( '2' ); | ||
await page.keyboard.press( 'ArrowUp' ); | ||
|
||
await pressKeyWithModifier( 'primary', 'c' ); | ||
expect( await getEditedPostContent() ).toMatchSnapshot(); | ||
|
||
await page.keyboard.press( 'ArrowDown' ); | ||
await pressKeyWithModifier( 'primary', 'v' ); | ||
expect( await getEditedPostContent() ).toMatchSnapshot(); | ||
} ); | ||
|
||
it( 'should cut and paste individual blocks', async () => { | ||
await clickBlockAppender(); | ||
await page.keyboard.type( 'Yet another unique string.' ); | ||
await page.keyboard.press( 'Enter' ); | ||
await page.keyboard.type( '2' ); | ||
await page.keyboard.press( 'ArrowUp' ); | ||
|
||
await pressKeyWithModifier( 'primary', 'x' ); | ||
expect( await getEditedPostContent() ).toMatchSnapshot(); | ||
|
||
await page.keyboard.press( 'Tab' ); | ||
await page.keyboard.press( 'ArrowDown' ); | ||
await pressKeyWithModifier( 'primary', 'v' ); | ||
expect( await getEditedPostContent() ).toMatchSnapshot(); | ||
} ); | ||
|
||
it( 'should respect inline copy when text is selected', async () => { | ||
await clickBlockAppender(); | ||
await page.keyboard.type( 'First block' ); | ||
await page.keyboard.press( 'Enter' ); | ||
await page.keyboard.type( 'Second block' ); | ||
await page.keyboard.press( 'ArrowUp' ); | ||
await pressKeyWithModifier( 'shift', 'ArrowLeft' ); | ||
await pressKeyWithModifier( 'shift', 'ArrowLeft' ); | ||
|
||
await pressKeyWithModifier( 'primary', 'c' ); | ||
await page.keyboard.press( 'ArrowRight' ); | ||
expect( await getEditedPostContent() ).toMatchSnapshot(); | ||
|
||
await page.keyboard.press( 'Enter' ); | ||
await pressKeyWithModifier( 'primary', 'v' ); | ||
expect( await getEditedPostContent() ).toMatchSnapshot(); | ||
} ); | ||
} ); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
For the record, I don't like these empty paragraphs that the pasting yields, but this is tangent to the PR itself.