-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Writing flow: Copy whole block if no text is selected (#22186)
* Writing flow: Copy whole block if no text is selected * Append change to package changelog * Consider full selection when not copying/cutting * Copy notice: Reveal block type if only one block copied * Flash block outline in response to copy action * Notify of copy and cut actions w/ useNotifyCopy hook * Reduce block highlight time. * Block Editor: Add action `flashBlock` * E2E: Test whole-block copy, cut and paste Co-authored-by: Matías Ventura <[email protected]>
- Loading branch information
Showing
9 changed files
with
270 additions
and
20 deletions.
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(); | ||
} ); | ||
} ); |