-
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.
Testing: Create new selectAll, selectAllBlocks utilities
- Loading branch information
Showing
9 changed files
with
67 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { pressKeyWithModifier } from './press-key-with-modifier'; | ||
import { __unstableSelectAll } from './select-all'; | ||
|
||
/** | ||
* Selects all blocks present in the block editor. | ||
* | ||
* @return {Promise} Promise resolving once active element selected. | ||
*/ | ||
export async function selectAllBlocks() { | ||
// NOTE: `__unstableSelectAll` is used for cross-platform compatibility | ||
// alternative to Cmd+A. The second issuance of the key combination is | ||
// handled internerally by the block editor's KeyboardShortcuts utility, | ||
// and is not subject to the same buggy browser/OS emulation. | ||
await __unstableSelectAll(); | ||
await pressKeyWithModifier( 'primary', 'a' ); | ||
} |
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,15 @@ | ||
/** | ||
* Selects all text within the current active element field. Throws if there is | ||
* no active element. | ||
* | ||
* This serves as a temporary solution to a bug present as of Puppeteer 1.6.1 | ||
* in which the Cmd+A keyboard combination does not work correctly in macOS | ||
* environments. Once the bug is resolved, the utility will be removed. | ||
* | ||
* @link https://github.com/GoogleChrome/puppeteer/issues/1313 | ||
* | ||
* @return {Promise} Promise resolving once active element selected. | ||
*/ | ||
export async function __unstableSelectAll() { | ||
await page.evaluate( () => document.execCommand( 'selectall', false, null ) ); | ||
} |
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