\\s*(<\/?' + allBlocks + '[^>]*>)\\s*<\/p>', 'g' ), '$1' );
+ text = text.replace(
+ new RegExp( '
/g, '$1' );
@@ -243,31 +259,47 @@ export function autop( text, br = true ) {
text = text.replace( /<\/blockquote><\/p>/g, '' );
// If an opening or closing block element tag is preceded by an opening tag, remove it.
- text = text.replace( new RegExp( '
\\s*(<\/?' + allBlocks + '[^>]*>)', 'g' ), '$1' );
+ text = text.replace(
+ new RegExp( '
\\s*(?' + allBlocks + '[^>]*>)', 'g' ),
+ '$1'
+ );
// If an opening or closing block element tag is followed by a closing
tag, remove it.
- text = text.replace( new RegExp( '(<\/?' + allBlocks + '[^>]*>)\\s*<\/p>', 'g' ), '$1' );
+ text = text.replace(
+ new RegExp( '(?' + allBlocks + '[^>]*>)\\s*
', 'g' ),
+ '$1'
+ );
// Optionally insert line breaks.
if ( br ) {
// Replace newlines that shouldn't be touched with a placeholder.
- text = text.replace( /<(script|style).*?<\/\\1>/g, ( match ) => match[ 0 ].replace( /\n/g, ' ' ) );
+ text = text.replace( /<(script|style).*?<\/\\1>/g, ( match ) =>
+ match[ 0 ].replace( /\n/g, ' ' )
+ );
// Normalize
text = text.replace( / | /g, ' ' );
// Replace any new line characters that aren't preceded by a with a .
- text = text.replace( /( )?\s*\n/g, ( a, b ) => b ? a : ' \n' );
+ text = text.replace( /( )?\s*\n/g, ( a, b ) =>
+ b ? a : ' \n'
+ );
// Replace newline placeholders with newlines.
text = text.replace( / /g, '\n' );
}
// If a tag is after an opening or closing block tag, remove it.
- text = text.replace( new RegExp( '(<\/?' + allBlocks + '[^>]*>)\\s* ', 'g' ), '$1' );
+ text = text.replace(
+ new RegExp( '(?' + allBlocks + '[^>]*>)\\s* ', 'g' ),
+ '$1'
+ );
// If a tag is before a subset of opening or closing block tags, remove it.
- text = text.replace( / (\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)/g, '$1' );
+ text = text.replace(
+ / (\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)/g,
+ '$1'
+ );
text = text.replace( /\n<\/p>$/g, '' );
// Replace placeholder tags with their original content.
@@ -301,7 +333,8 @@ export function autop( text, br = true ) {
* @return {string} The content with stripped paragraph tags.
*/
export function removep( html ) {
- const blocklist = 'blockquote|ul|ol|li|dl|dt|dd|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset|figure';
+ const blocklist =
+ 'blockquote|ul|ol|li|dl|dt|dd|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset|figure';
const blocklist1 = blocklist + '|div|p';
const blocklist2 = blocklist + '|pre';
const preserve = [];
@@ -314,7 +347,9 @@ export function removep( html ) {
// Protect script and style tags.
if ( html.indexOf( '';
+ expect( stripHTML( html ) ).toBe( 'This will not throw "Error"' );
+ expect( () => stripHTML( html ) ).not.toThrow();
} );
} );
} );
diff --git a/packages/dom/src/test/tabbable.js b/packages/dom/src/test/tabbable.js
index e262fccd86d65..47ee59aabee08 100644
--- a/packages/dom/src/test/tabbable.js
+++ b/packages/dom/src/test/tabbable.js
@@ -26,11 +26,7 @@ describe( 'tabbable', () => {
const tabbables = find( node );
- expect( tabbables ).toEqual( [
- first,
- second,
- third,
- ] );
+ expect( tabbables ).toEqual( [ first, second, third ] );
} );
it( 'consolidates radio group to the first, if unchecked', () => {
@@ -67,11 +63,7 @@ describe( 'tabbable', () => {
const tabbables = find( node );
- expect( tabbables ).toEqual( [
- firstRadio,
- text,
- fourthRadio,
- ] );
+ expect( tabbables ).toEqual( [ firstRadio, text, fourthRadio ] );
} );
it( 'consolidates radio group to the checked', () => {
@@ -99,10 +91,7 @@ describe( 'tabbable', () => {
const tabbables = find( node );
- expect( tabbables ).toEqual( [
- text,
- thirdRadio,
- ] );
+ expect( tabbables ).toEqual( [ text, thirdRadio ] );
} );
it( 'not consolidate unnamed radio inputs', () => {
@@ -122,11 +111,7 @@ describe( 'tabbable', () => {
const tabbables = find( node );
- expect( tabbables ).toEqual( [
- firstRadio,
- text,
- secondRadio,
- ] );
+ expect( tabbables ).toEqual( [ firstRadio, text, secondRadio ] );
} );
} );
} );
diff --git a/packages/dom/src/test/utils/create-element.js b/packages/dom/src/test/utils/create-element.js
index 2818c19d375c1..bae4273adfa60 100644
--- a/packages/dom/src/test/utils/create-element.js
+++ b/packages/dom/src/test/utils/create-element.js
@@ -9,20 +9,24 @@
export default function createElement( type ) {
const element = document.createElement( type );
- const ifNotHidden = ( value, elseValue ) => function() {
- let isHidden = false;
- let node = this;
- do {
- isHidden = (
- node.style.display === 'none' ||
- node.style.visibility === 'hidden'
- );
+ const ifNotHidden = ( value, elseValue ) =>
+ function() {
+ let isHidden = false;
+ let node = this;
+ do {
+ isHidden =
+ node.style.display === 'none' ||
+ node.style.visibility === 'hidden';
- node = node.parentNode;
- } while ( ! isHidden && node && node.nodeType === window.Node.ELEMENT_NODE );
+ node = node.parentNode;
+ } while (
+ ! isHidden &&
+ node &&
+ node.nodeType === window.Node.ELEMENT_NODE
+ );
- return isHidden ? elseValue : value;
- };
+ return isHidden ? elseValue : value;
+ };
Object.defineProperties( element, {
offsetHeight: {
@@ -33,14 +37,19 @@ export default function createElement( type ) {
},
} );
- element.getClientRects = ifNotHidden( [ {
- width: 10,
- height: 10,
- top: 0,
- right: 10,
- bottom: 10,
- left: 0,
- } ], [] );
+ element.getClientRects = ifNotHidden(
+ [
+ {
+ width: 10,
+ height: 10,
+ top: 0,
+ right: 10,
+ bottom: 10,
+ left: 0,
+ },
+ ],
+ []
+ );
return element;
}
diff --git a/packages/e2e-test-utils/package.json b/packages/e2e-test-utils/package.json
index bc1b8c33df152..ad3cedd9c0296 100644
--- a/packages/e2e-test-utils/package.json
+++ b/packages/e2e-test-utils/package.json
@@ -28,7 +28,7 @@
"main": "build/index.js",
"module": "build-module/index.js",
"dependencies": {
- "@babel/runtime": "^7.4.4",
+ "@babel/runtime": "^7.8.3",
"@wordpress/keycodes": "file:../keycodes",
"@wordpress/url": "file:../url",
"lodash": "^4.17.15",
diff --git a/packages/e2e-test-utils/src/activate-plugin.js b/packages/e2e-test-utils/src/activate-plugin.js
index 9d90f866ff5dd..694321c1193ba 100644
--- a/packages/e2e-test-utils/src/activate-plugin.js
+++ b/packages/e2e-test-utils/src/activate-plugin.js
@@ -13,7 +13,9 @@ import { visitAdminPage } from './visit-admin-page';
export async function activatePlugin( slug ) {
await switchUserToAdmin();
await visitAdminPage( 'plugins.php' );
- const disableLink = await page.$( `tr[data-slug="${ slug }"] .deactivate a` );
+ const disableLink = await page.$(
+ `tr[data-slug="${ slug }"] .deactivate a`
+ );
if ( disableLink ) {
await switchUserToTest();
return;
diff --git a/packages/e2e-test-utils/src/click-block-toolbar-button.js b/packages/e2e-test-utils/src/click-block-toolbar-button.js
index fcdd9d2af91ed..dffc3e313c5d0 100644
--- a/packages/e2e-test-utils/src/click-block-toolbar-button.js
+++ b/packages/e2e-test-utils/src/click-block-toolbar-button.js
@@ -6,7 +6,7 @@
export async function clickBlockToolbarButton( buttonAriaLabel ) {
const BLOCK_TOOLBAR_SELECTOR = '.block-editor-block-toolbar';
const BUTTON_SELECTOR = `${ BLOCK_TOOLBAR_SELECTOR } button[aria-label="${ buttonAriaLabel }"]`;
- if ( await page.$( BLOCK_TOOLBAR_SELECTOR ) === null ) {
+ if ( ( await page.$( BLOCK_TOOLBAR_SELECTOR ) ) === null ) {
// Move the mouse to show the block toolbar
await page.mouse.move( 0, 0 );
await page.mouse.move( 10, 10 );
diff --git a/packages/e2e-test-utils/src/click-button.js b/packages/e2e-test-utils/src/click-button.js
index 9c406c22b24af..634319101e5d0 100644
--- a/packages/e2e-test-utils/src/click-button.js
+++ b/packages/e2e-test-utils/src/click-button.js
@@ -4,6 +4,8 @@
* @param {string} buttonText The text that appears on the button to click.
*/
export async function clickButton( buttonText ) {
- const button = await page.waitForXPath( `//button[contains(text(), '${ buttonText }')]` );
+ const button = await page.waitForXPath(
+ `//button[contains(text(), '${ buttonText }')]`
+ );
await button.click();
}
diff --git a/packages/e2e-test-utils/src/click-on-close-modal-button.js b/packages/e2e-test-utils/src/click-on-close-modal-button.js
index 491037f3ba9af..dfd01c5d4ae48 100644
--- a/packages/e2e-test-utils/src/click-on-close-modal-button.js
+++ b/packages/e2e-test-utils/src/click-on-close-modal-button.js
@@ -4,8 +4,7 @@
* @param {?string} modalClassName Class name for the modal to close
*/
export async function clickOnCloseModalButton( modalClassName ) {
- let closeButtonClassName =
- '.components-modal__header .components-button';
+ let closeButtonClassName = '.components-modal__header .components-button';
if ( modalClassName ) {
closeButtonClassName = `${ modalClassName } ${ closeButtonClassName }`;
diff --git a/packages/e2e-test-utils/src/click-on-more-menu-item.js b/packages/e2e-test-utils/src/click-on-more-menu-item.js
index 28b9acabf1565..564ef6b715e6c 100644
--- a/packages/e2e-test-utils/src/click-on-more-menu-item.js
+++ b/packages/e2e-test-utils/src/click-on-more-menu-item.js
@@ -17,16 +17,20 @@ export async function clickOnMoreMenuItem( buttonLabel ) {
await toggleMoreMenu();
const moreMenuContainerSelector =
'//*[contains(concat(" ", @class, " "), " edit-post-more-menu__content ")]';
- let elementToClick = first( await page.$x(
- `${ moreMenuContainerSelector }//button[contains(text(), "${ buttonLabel }")]`
- ) );
+ let elementToClick = first(
+ await page.$x(
+ `${ moreMenuContainerSelector }//button[contains(text(), "${ buttonLabel }")]`
+ )
+ );
// If button is not found, the label should be on the info wrapper.
if ( ! elementToClick ) {
- elementToClick = first( await page.$x(
- moreMenuContainerSelector +
- '//button' +
- `/*[contains(concat(" ", @class, " "), " components-menu-item__info-wrapper ")][contains(text(), "${ buttonLabel }")]`
- ) );
+ elementToClick = first(
+ await page.$x(
+ moreMenuContainerSelector +
+ '//button' +
+ `/*[contains(concat(" ", @class, " "), " components-menu-item__info-wrapper ")][contains(text(), "${ buttonLabel }")]`
+ )
+ );
}
await elementToClick.click();
}
diff --git a/packages/e2e-test-utils/src/create-new-post.js b/packages/e2e-test-utils/src/create-new-post.js
index a83577de62ddf..7e5b8a9a28710 100644
--- a/packages/e2e-test-utils/src/create-new-post.js
+++ b/packages/e2e-test-utils/src/create-new-post.js
@@ -30,11 +30,13 @@ export async function createNewPost( {
await visitAdminPage( 'post-new.php', query );
const isWelcomeGuideActive = await page.evaluate( () =>
- wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ) );
+ wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' )
+ );
if ( showWelcomeGuide !== isWelcomeGuideActive ) {
await page.evaluate( () =>
- wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' ) );
+ wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'welcomeGuide' )
+ );
await page.reload();
}
diff --git a/packages/e2e-test-utils/src/drag-and-resize.js b/packages/e2e-test-utils/src/drag-and-resize.js
index f8f0b3e996b26..f3c45eec479ec 100644
--- a/packages/e2e-test-utils/src/drag-and-resize.js
+++ b/packages/e2e-test-utils/src/drag-and-resize.js
@@ -16,8 +16,8 @@ export async function dragAndResize( element, delta ) {
height: elementHeight,
} = await element.boundingBox();
- const originX = elementX + ( elementWidth / 2 );
- const originY = elementY + ( elementHeight / 2 );
+ const originX = elementX + elementWidth / 2;
+ const originY = elementY + elementHeight / 2;
await page.mouse.move( originX, originY );
await page.mouse.down();
diff --git a/packages/e2e-test-utils/src/ensure-sidebar-opened.js b/packages/e2e-test-utils/src/ensure-sidebar-opened.js
index 977a432510563..124a5e28b7ae9 100644
--- a/packages/e2e-test-utils/src/ensure-sidebar-opened.js
+++ b/packages/e2e-test-utils/src/ensure-sidebar-opened.js
@@ -10,6 +10,8 @@ export async function ensureSidebarOpened() {
try {
return page.$eval( '.edit-post-sidebar', () => {} );
} catch ( error ) {
- return page.click( '.edit-post-header__settings [aria-label="Settings"]' );
+ return page.click(
+ '.edit-post-header__settings [aria-label="Settings"]'
+ );
}
}
diff --git a/packages/e2e-test-utils/src/find-sidebar-panel-toggle-button-with-title.js b/packages/e2e-test-utils/src/find-sidebar-panel-toggle-button-with-title.js
index 916ddc53f4b6b..cf9c2e57b9a83 100644
--- a/packages/e2e-test-utils/src/find-sidebar-panel-toggle-button-with-title.js
+++ b/packages/e2e-test-utils/src/find-sidebar-panel-toggle-button-with-title.js
@@ -13,5 +13,9 @@ import { first } from 'lodash';
* @return {?ElementHandle} Object that represents an in-page DOM element.
*/
export async function findSidebarPanelToggleButtonWithTitle( panelTitle ) {
- return first( await page.$x( `//div[contains(@class,"edit-post-sidebar")]//button[@class="components-button components-panel__body-toggle"][contains(text(),"${ panelTitle }")]` ) );
+ return first(
+ await page.$x(
+ `//div[contains(@class,"edit-post-sidebar")]//button[@class="components-button components-panel__body-toggle"][contains(text(),"${ panelTitle }")]`
+ )
+ );
}
diff --git a/packages/e2e-test-utils/src/find-sidebar-panel-with-title.js b/packages/e2e-test-utils/src/find-sidebar-panel-with-title.js
index fea4bf968f0a4..485bf3d9f0bb6 100644
--- a/packages/e2e-test-utils/src/find-sidebar-panel-with-title.js
+++ b/packages/e2e-test-utils/src/find-sidebar-panel-with-title.js
@@ -13,8 +13,13 @@ import { first } from 'lodash';
* @return {Promise} Object that represents an in-page DOM element.
*/
export async function findSidebarPanelWithTitle( panelTitle ) {
- const classSelect = ( className ) => `[contains(concat(" ", @class, " "), " ${ className } ")]`;
- const buttonSelector = `//div${ classSelect( 'edit-post-sidebar' ) }//button${ classSelect( 'components-button' ) }${ classSelect( 'components-panel__body-toggle' ) }[contains(text(),"${ panelTitle }")]`;
+ const classSelect = ( className ) =>
+ `[contains(concat(" ", @class, " "), " ${ className } ")]`;
+ const buttonSelector = `//div${ classSelect(
+ 'edit-post-sidebar'
+ ) }//button${ classSelect( 'components-button' ) }${ classSelect(
+ 'components-panel__body-toggle'
+ ) }[contains(text(),"${ panelTitle }")]`;
const panelSelector = `${ buttonSelector }/ancestor::*[contains(concat(" ", @class, " "), " components-panel__body ")]`;
return first( await page.$x( panelSelector ) );
}
diff --git a/packages/e2e-test-utils/src/get-all-block-inserter-item-titles.js b/packages/e2e-test-utils/src/get-all-block-inserter-item-titles.js
index ef564d81b3866..eb2802e879b55 100644
--- a/packages/e2e-test-utils/src/get-all-block-inserter-item-titles.js
+++ b/packages/e2e-test-utils/src/get-all-block-inserter-item-titles.js
@@ -14,11 +14,9 @@ export async function getAllBlockInserterItemTitles() {
document.querySelectorAll(
'.block-editor-inserter__results .block-editor-block-types-list__item-title'
)
- ).map(
- ( inserterItem ) => {
- return inserterItem.innerText;
- }
- );
+ ).map( ( inserterItem ) => {
+ return inserterItem.innerText;
+ } );
} );
return sortBy( uniq( inserterItemTitles ) );
}
diff --git a/packages/e2e-test-utils/src/get-available-block-transforms.js b/packages/e2e-test-utils/src/get-available-block-transforms.js
index d3d1192798a8e..1b3074f0c501a 100644
--- a/packages/e2e-test-utils/src/get-available-block-transforms.js
+++ b/packages/e2e-test-utils/src/get-available-block-transforms.js
@@ -10,16 +10,14 @@ import { hasBlockSwitcher } from './has-block-switcher';
* @return {Promise} Promise resolving with an array containing all possible block transforms
*/
export const getAvailableBlockTransforms = async () => {
- if ( ! await hasBlockSwitcher() ) {
+ if ( ! ( await hasBlockSwitcher() ) ) {
return [];
}
- await page.click( '.block-editor-block-toolbar .block-editor-block-switcher' );
+ await page.click(
+ '.block-editor-block-toolbar .block-editor-block-switcher'
+ );
return page.evaluate( ( buttonSelector ) => {
- return Array.from(
- document.querySelectorAll(
- buttonSelector
- )
- ).map(
+ return Array.from( document.querySelectorAll( buttonSelector ) ).map(
( button ) => {
return button.textContent;
}
diff --git a/packages/e2e-test-utils/src/get-block-setting.js b/packages/e2e-test-utils/src/get-block-setting.js
index e0adf27eaebed..f4a486894b5d3 100644
--- a/packages/e2e-test-utils/src/get-block-setting.js
+++ b/packages/e2e-test-utils/src/get-block-setting.js
@@ -7,8 +7,14 @@
* @return {Promise} Promise resolving with a string containing the block title.
*/
export async function getBlockSetting( blockName, setting ) {
- return page.evaluate( ( _blockName, _setting ) => {
- const blockType = wp.data.select( 'core/blocks' ).getBlockType( _blockName );
- return blockType && blockType[ _setting ];
- }, blockName, setting );
+ return page.evaluate(
+ ( _blockName, _setting ) => {
+ const blockType = wp.data
+ .select( 'core/blocks' )
+ .getBlockType( _blockName );
+ return blockType && blockType[ _setting ];
+ },
+ blockName,
+ setting
+ );
}
diff --git a/packages/e2e-test-utils/src/index.js b/packages/e2e-test-utils/src/index.js
index adb2b2867f737..136496058223b 100644
--- a/packages/e2e-test-utils/src/index.js
+++ b/packages/e2e-test-utils/src/index.js
@@ -27,7 +27,10 @@ export { installPlugin } from './install-plugin';
export { isCurrentURL } from './is-current-url';
export { isInDefaultBlock } from './is-in-default-block';
export { loginUser } from './login-user';
-export { enableFocusLossObservation, disableFocusLossObservation } from './observe-focus-loss';
+export {
+ enableFocusLossObservation,
+ disableFocusLossObservation,
+} from './observe-focus-loss';
export { openAllBlockInserterCategories } from './open-all-block-inserter-categories';
export { openDocumentSettingsSidebar } from './open-document-settings-sidebar';
export { openGlobalBlockInserter } from './open-global-block-inserter';
diff --git a/packages/e2e-test-utils/src/insert-block.js b/packages/e2e-test-utils/src/insert-block.js
index 452f0432d0ed9..4190d7c1136ce 100644
--- a/packages/e2e-test-utils/src/insert-block.js
+++ b/packages/e2e-test-utils/src/insert-block.js
@@ -13,13 +13,13 @@ import { searchForBlock } from './search-for-block';
export async function insertBlock( searchTerm, panelName = null ) {
await searchForBlock( searchTerm );
if ( panelName ) {
- const panelButton = ( await page.$x(
- `//button[contains(text(), '${ panelName }')]`
- ) )[ 0 ];
+ const panelButton = (
+ await page.$x( `//button[contains(text(), '${ panelName }')]` )
+ )[ 0 ];
await panelButton.click();
}
- const insertButton = ( await page.$x(
- `//button//span[contains(text(), '${ searchTerm }')]`
- ) )[ 0 ];
+ const insertButton = (
+ await page.$x( `//button//span[contains(text(), '${ searchTerm }')]` )
+ )[ 0 ];
await insertButton.click();
}
diff --git a/packages/e2e-test-utils/src/install-plugin.js b/packages/e2e-test-utils/src/install-plugin.js
index 37a47ae382a24..6fa47ed53d8e4 100644
--- a/packages/e2e-test-utils/src/install-plugin.js
+++ b/packages/e2e-test-utils/src/install-plugin.js
@@ -13,7 +13,12 @@ import { visitAdminPage } from './visit-admin-page';
*/
export async function installPlugin( slug, searchTerm ) {
await switchUserToAdmin();
- await visitAdminPage( 'plugin-install.php', 's=' + encodeURIComponent( searchTerm || slug ) + '&tab=search&type=term' );
+ await visitAdminPage(
+ 'plugin-install.php',
+ 's=' +
+ encodeURIComponent( searchTerm || slug ) +
+ '&tab=search&type=term'
+ );
await page.click( `.install-now[data-slug="${ slug }"]` );
await page.waitForSelector( `.activate-now[data-slug="${ slug }"]` );
await switchUserToTest();
diff --git a/packages/e2e-test-utils/src/is-in-default-block.js b/packages/e2e-test-utils/src/is-in-default-block.js
index 7558a7b0767e3..21d9a19bf22dd 100644
--- a/packages/e2e-test-utils/src/is-in-default-block.js
+++ b/packages/e2e-test-utils/src/is-in-default-block.js
@@ -10,11 +10,15 @@ export function isInDefaultBlock() {
if ( ! activeElement ) {
return false;
}
- const closestElementWithDataTpe = activeElement.closest( '[data-type]' );
+ const closestElementWithDataTpe = activeElement.closest(
+ '[data-type]'
+ );
if ( ! closestElementWithDataTpe ) {
return false;
}
- const activeBlockName = closestElementWithDataTpe.getAttribute( 'data-type' );
+ const activeBlockName = closestElementWithDataTpe.getAttribute(
+ 'data-type'
+ );
const defaultBlockName = window.wp.blocks.getDefaultBlockName();
return activeBlockName === defaultBlockName;
diff --git a/packages/e2e-test-utils/src/login-user.js b/packages/e2e-test-utils/src/login-user.js
index d06878d69186e..aeecfd9d5cc61 100644
--- a/packages/e2e-test-utils/src/login-user.js
+++ b/packages/e2e-test-utils/src/login-user.js
@@ -12,11 +12,12 @@ import { pressKeyWithModifier } from './press-key-with-modifier';
* @param {?string} username String to be used as user credential.
* @param {?string} password String to be used as user credential.
*/
-export async function loginUser( username = WP_USERNAME, password = WP_PASSWORD ) {
+export async function loginUser(
+ username = WP_USERNAME,
+ password = WP_PASSWORD
+) {
if ( ! isCurrentURL( 'wp-login.php' ) ) {
- await page.goto(
- createURL( 'wp-login.php' )
- );
+ await page.goto( createURL( 'wp-login.php' ) );
}
await page.focus( '#user_login' );
@@ -26,5 +27,8 @@ export async function loginUser( username = WP_USERNAME, password = WP_PASSWORD
await pressKeyWithModifier( 'primary', 'a' );
await page.type( '#user_pass', password );
- await Promise.all( [ page.waitForNavigation(), page.click( '#wp-submit' ) ] );
+ await Promise.all( [
+ page.waitForNavigation(),
+ page.click( '#wp-submit' ),
+ ] );
}
diff --git a/packages/e2e-test-utils/src/mocks/create-embedding-matcher.js b/packages/e2e-test-utils/src/mocks/create-embedding-matcher.js
index 9673ea04706d4..403b3a3911220 100644
--- a/packages/e2e-test-utils/src/mocks/create-embedding-matcher.js
+++ b/packages/e2e-test-utils/src/mocks/create-embedding-matcher.js
@@ -13,7 +13,9 @@ import { createURLMatcher } from './create-url-matcher';
function parameterEquals( parameterName, value ) {
return ( request ) => {
const url = request.url();
- const match = new RegExp( `.*${ parameterName }=([^&]+).*` ).exec( url );
+ const match = new RegExp( `.*${ parameterName }=([^&]+).*` ).exec(
+ url
+ );
if ( ! match ) {
return false;
}
diff --git a/packages/e2e-test-utils/src/mocks/create-json-response.js b/packages/e2e-test-utils/src/mocks/create-json-response.js
index f7bddf0befe64..4836ecbc720be 100644
--- a/packages/e2e-test-utils/src/mocks/create-json-response.js
+++ b/packages/e2e-test-utils/src/mocks/create-json-response.js
@@ -10,5 +10,6 @@ import { getJSONResponse } from '../shared/get-json-response';
* @return {Promise} Promise that responds to a request with the mock JSON response.
*/
export function createJSONResponse( mockResponse ) {
- return async ( request ) => request.respond( getJSONResponse( mockResponse ) );
+ return async ( request ) =>
+ request.respond( getJSONResponse( mockResponse ) );
}
diff --git a/packages/e2e-test-utils/src/mocks/mock-or-transform.js b/packages/e2e-test-utils/src/mocks/mock-or-transform.js
index 12cf8af07b24d..5b2a33de38cca 100644
--- a/packages/e2e-test-utils/src/mocks/mock-or-transform.js
+++ b/packages/e2e-test-utils/src/mocks/mock-or-transform.js
@@ -35,7 +35,9 @@ export function mockOrTransform(
if ( mockCheck( responseObject ) ) {
request.respond( getJSONResponse( mock ) );
} else {
- request.respond( getJSONResponse( responseObjectTransform( responseObject ) ) );
+ request.respond(
+ getJSONResponse( responseObjectTransform( responseObject ) )
+ );
}
};
}
diff --git a/packages/e2e-test-utils/src/observe-focus-loss.js b/packages/e2e-test-utils/src/observe-focus-loss.js
index 1266d0997c1f2..e89cb298273df 100644
--- a/packages/e2e-test-utils/src/observe-focus-loss.js
+++ b/packages/e2e-test-utils/src/observe-focus-loss.js
@@ -5,7 +5,10 @@
export async function enableFocusLossObservation() {
await page.evaluate( () => {
if ( window._detectFocusLoss ) {
- document.body.removeEventListener( 'focusout', window._detectFocusLoss );
+ document.body.removeEventListener(
+ 'focusout',
+ window._detectFocusLoss
+ );
}
window._detectFocusLoss = ( event ) => {
@@ -24,7 +27,10 @@ export async function enableFocusLossObservation() {
export async function disableFocusLossObservation() {
await page.evaluate( () => {
if ( window._detectFocusLoss ) {
- document.body.removeEventListener( 'focusout', window._detectFocusLoss );
+ document.body.removeEventListener(
+ 'focusout',
+ window._detectFocusLoss
+ );
}
} );
}
diff --git a/packages/e2e-test-utils/src/open-all-block-inserter-categories.js b/packages/e2e-test-utils/src/open-all-block-inserter-categories.js
index f022a0921ed1a..9b31a0cd36c4a 100644
--- a/packages/e2e-test-utils/src/open-all-block-inserter-categories.js
+++ b/packages/e2e-test-utils/src/open-all-block-inserter-categories.js
@@ -2,7 +2,8 @@
* Opens all block inserter categories.
*/
export async function openAllBlockInserterCategories() {
- const notOppenedCategorySelector = '.block-editor-inserter__results .components-panel__body:not(.is-opened)';
+ const notOppenedCategorySelector =
+ '.block-editor-inserter__results .components-panel__body:not(.is-opened)';
let categoryPanel = await page.$( notOppenedCategorySelector );
while ( categoryPanel !== null ) {
await categoryPanel.click();
diff --git a/packages/e2e-test-utils/src/press-key-with-modifier.js b/packages/e2e-test-utils/src/press-key-with-modifier.js
index c36b316cea3ef..abb7f168e6090 100644
--- a/packages/e2e-test-utils/src/press-key-with-modifier.js
+++ b/packages/e2e-test-utils/src/press-key-with-modifier.js
@@ -32,7 +32,8 @@ async function emulateSelectAll() {
key: isMac ? 'Meta' : 'Control',
code: isMac ? 'MetaLeft' : 'ControlLeft',
location: window.KeyboardEvent.DOM_KEY_LOCATION_LEFT,
- getModifierState: ( keyArg ) => keyArg === ( isMac ? 'Meta' : 'Control' ),
+ getModifierState: ( keyArg ) =>
+ keyArg === ( isMac ? 'Meta' : 'Control' ),
ctrlKey: ! isMac,
metaKey: isMac,
charCode: 0,
@@ -47,7 +48,8 @@ async function emulateSelectAll() {
key: 'a',
code: 'KeyA',
location: window.KeyboardEvent.DOM_KEY_LOCATION_STANDARD,
- getModifierState: ( keyArg ) => keyArg === ( isMac ? 'Meta' : 'Control' ),
+ getModifierState: ( keyArg ) =>
+ keyArg === ( isMac ? 'Meta' : 'Control' ),
ctrlKey: ! isMac,
metaKey: isMac,
charCode: 0,
@@ -55,10 +57,9 @@ async function emulateSelectAll() {
which: 65,
} );
- const wasPrevented = (
+ const wasPrevented =
! document.activeElement.dispatchEvent( preventableEvent ) ||
- preventableEvent.defaultPrevented
- );
+ preventableEvent.defaultPrevented;
if ( ! wasPrevented ) {
document.execCommand( 'selectall', false, null );
@@ -102,10 +103,12 @@ async function emulateClipboard( type ) {
window._clipboardData.setData( 'text/html', html );
}
- document.activeElement.dispatchEvent( new ClipboardEvent( _type, {
- bubbles: true,
- clipboardData: window._clipboardData,
- } ) );
+ document.activeElement.dispatchEvent(
+ new ClipboardEvent( _type, {
+ bubbles: true,
+ clipboardData: window._clipboardData,
+ } )
+ );
}, type );
}
@@ -136,10 +139,11 @@ export async function pressKeyWithModifier( modifier, key ) {
const isAppleOS = () => process.platform === 'darwin';
const overWrittenModifiers = {
...modifiers,
- shiftAlt: ( _isApple ) => _isApple() ? [ SHIFT, ALT ] : [ SHIFT, CTRL ],
+ shiftAlt: ( _isApple ) =>
+ _isApple() ? [ SHIFT, ALT ] : [ SHIFT, CTRL ],
};
const mappedModifiers = overWrittenModifiers[ modifier ]( isAppleOS );
- const ctrlSwap = ( mod ) => mod === CTRL ? 'control' : mod;
+ const ctrlSwap = ( mod ) => ( mod === CTRL ? 'control' : mod );
await Promise.all(
mappedModifiers.map( async ( mod ) => {
diff --git a/packages/e2e-test-utils/src/set-browser-viewport.js b/packages/e2e-test-utils/src/set-browser-viewport.js
index ddf65df5a8318..3408dfe03903e 100644
--- a/packages/e2e-test-utils/src/set-browser-viewport.js
+++ b/packages/e2e-test-utils/src/set-browser-viewport.js
@@ -43,9 +43,10 @@ const PREDEFINED_DIMENSIONS = {
* @param {WPViewport} viewport Viewport name or dimensions object to assign.
*/
export async function setBrowserViewport( viewport ) {
- const dimensions = typeof viewport === 'string' ?
- PREDEFINED_DIMENSIONS[ viewport ] :
- viewport;
+ const dimensions =
+ typeof viewport === 'string'
+ ? PREDEFINED_DIMENSIONS[ viewport ]
+ : viewport;
await page.setViewport( dimensions );
await waitForWindowDimensions( dimensions.width, dimensions.height );
diff --git a/packages/e2e-test-utils/src/shared/config.js b/packages/e2e-test-utils/src/shared/config.js
index f098b78c52879..3365722bd9072 100644
--- a/packages/e2e-test-utils/src/shared/config.js
+++ b/packages/e2e-test-utils/src/shared/config.js
@@ -9,9 +9,4 @@ const {
WP_BASE_URL = 'http://localhost:8889',
} = process.env;
-export {
- WP_ADMIN_USER,
- WP_USERNAME,
- WP_PASSWORD,
- WP_BASE_URL,
-};
+export { WP_ADMIN_USER, WP_USERNAME, WP_PASSWORD, WP_BASE_URL };
diff --git a/packages/e2e-test-utils/src/toggle-screen-option.js b/packages/e2e-test-utils/src/toggle-screen-option.js
index d66f557fec175..bada7373cafbc 100644
--- a/packages/e2e-test-utils/src/toggle-screen-option.js
+++ b/packages/e2e-test-utils/src/toggle-screen-option.js
@@ -13,7 +13,9 @@ import { clickOnMoreMenuItem } from './click-on-more-menu-item';
*/
export async function toggleScreenOption( label, shouldBeChecked = undefined ) {
await clickOnMoreMenuItem( 'Options' );
- const [ handle ] = await page.$x( `//label[contains(text(), "${ label }")]` );
+ const [ handle ] = await page.$x(
+ `//label[contains(text(), "${ label }")]`
+ );
const isChecked = await page.evaluate(
( element ) => element.control.checked,
diff --git a/packages/e2e-test-utils/src/transform-block-to.js b/packages/e2e-test-utils/src/transform-block-to.js
index 2bf0b5d559a35..018b387c23581 100644
--- a/packages/e2e-test-utils/src/transform-block-to.js
+++ b/packages/e2e-test-utils/src/transform-block-to.js
@@ -6,12 +6,16 @@
export async function transformBlockTo( name ) {
await page.mouse.move( 0, 0 );
await page.mouse.move( 10, 10 );
- const switcherToggle = await page.waitForSelector( '.block-editor-block-switcher__toggle' );
+ const switcherToggle = await page.waitForSelector(
+ '.block-editor-block-switcher__toggle'
+ );
await switcherToggle.click();
// Find the block button option within the switcher popover.
const switcher = await page.$( '.block-editor-block-switcher__container' );
- const insertButton = ( await switcher.$x( `//button[.='${ name }']` ) )[ 0 ];
+ const insertButton = (
+ await switcher.$x( `//button[.='${ name }']` )
+ )[ 0 ];
// Clicks may fail if the button is out of view. Assure it is before click.
await insertButton.evaluate( ( element ) => element.scrollIntoView() );
diff --git a/packages/e2e-test-utils/src/visit-admin-page.js b/packages/e2e-test-utils/src/visit-admin-page.js
index 12a8f327e544b..ac74c4ce68818 100644
--- a/packages/e2e-test-utils/src/visit-admin-page.js
+++ b/packages/e2e-test-utils/src/visit-admin-page.js
@@ -17,9 +17,7 @@ import { loginUser } from './login-user';
* @param {string} query String to be serialized as query portion of URL.
*/
export async function visitAdminPage( adminPath, query ) {
- await page.goto(
- createURL( join( 'wp-admin', adminPath ), query )
- );
+ await page.goto( createURL( join( 'wp-admin', adminPath ), query ) );
if ( isCurrentURL( 'wp-login.php' ) ) {
await loginUser();
diff --git a/packages/e2e-test-utils/src/wp-data-select.js b/packages/e2e-test-utils/src/wp-data-select.js
index 05b92b0a6dbbe..43ddafcd52abf 100644
--- a/packages/e2e-test-utils/src/wp-data-select.js
+++ b/packages/e2e-test-utils/src/wp-data-select.js
@@ -10,7 +10,9 @@
export function wpDataSelect( store, selector, ...parameters ) {
return page.evaluate(
( _store, _selector, ..._parameters ) => {
- return window.wp.data.select( _store )[ _selector ]( ..._parameters );
+ return window.wp.data
+ .select( _store )
+ [ _selector ]( ..._parameters );
},
store,
selector,
diff --git a/packages/e2e-tests/config/gutenberg-phase.js b/packages/e2e-tests/config/gutenberg-phase.js
index 1b6117b3236a6..2e119cd3e89f0 100644
--- a/packages/e2e-tests/config/gutenberg-phase.js
+++ b/packages/e2e-tests/config/gutenberg-phase.js
@@ -2,5 +2,8 @@ global.process.env = {
...global.process.env,
// Inject the `GUTENBERG_PHASE` global, used for feature flagging.
// eslint-disable-next-line @wordpress/gutenberg-phase
- GUTENBERG_PHASE: parseInt( process.env.npm_package_config_GUTENBERG_PHASE, 10 ),
+ GUTENBERG_PHASE: parseInt(
+ process.env.npm_package_config_GUTENBERG_PHASE,
+ 10
+ ),
};
diff --git a/packages/e2e-tests/config/setup-test-framework.js b/packages/e2e-tests/config/setup-test-framework.js
index dd9d390d98e2c..d4f547a7190cc 100644
--- a/packages/e2e-tests/config/setup-test-framework.js
+++ b/packages/e2e-tests/config/setup-test-framework.js
@@ -83,8 +83,8 @@ async function trashExistingPosts() {
}
// Select all posts.
- await page.waitForSelector( '#cb-select-all-1' );
- await page.click( '#cb-select-all-1' );
+ await page.waitForSelector( '[id^=cb-select-all-]' );
+ await page.click( '[id^=cb-select-all-]' );
// Select the "bulk actions" > "trash" option.
await page.select( '#bulk-action-selector-top', 'trash' );
// Submit the form to send all draft/scheduled/published posts to the trash.
@@ -139,7 +139,9 @@ function observeConsoleLogging() {
// See: https://core.trac.wordpress.org/ticket/37000
// See: https://www.chromestatus.com/feature/5088147346030592
// See: https://www.chromestatus.com/feature/5633521622188032
- if ( text.includes( 'A cookie associated with a cross-site resource' ) ) {
+ if (
+ text.includes( 'A cookie associated with a cross-site resource' )
+ ) {
return;
}
@@ -151,7 +153,26 @@ function observeConsoleLogging() {
// Network errors are ignored only if we are intentionally testing
// offline mode.
- if ( text.includes( 'net::ERR_INTERNET_DISCONNECTED' ) && isOfflineMode() ) {
+ if (
+ text.includes( 'net::ERR_INTERNET_DISCONNECTED' ) &&
+ isOfflineMode()
+ ) {
+ return;
+ }
+
+ // As of WordPress 5.3.2 in Chrome 79, navigating to the block editor
+ // (Posts > Add New) will display a console warning about
+ // non - unique IDs.
+ // See: https://core.trac.wordpress.org/ticket/23165
+ if ( text.includes( 'elements with non-unique id #_wpnonce' ) ) {
+ return;
+ }
+
+ // As of WordPress 5.3.2 in Chrome 79, navigating to the block editor
+ // (Posts > Add New) will display a console warning about
+ // non - unique IDs.
+ // See: https://core.trac.wordpress.org/ticket/23165
+ if ( text.includes( 'elements with non-unique id #_wpnonce' ) ) {
return;
}
@@ -168,7 +189,11 @@ function observeConsoleLogging() {
// correctly. Instead, the logic here synchronously inspects the
// internal object shape of the JSHandle to find the error text. If it
// cannot be found, the default text value is used instead.
- text = get( message.args(), [ 0, '_remoteObject', 'description' ], text );
+ text = get(
+ message.args(),
+ [ 0, '_remoteObject', 'description' ],
+ text
+ );
// Disable reason: We intentionally bubble up the console message
// which, unless the test explicitly anticipates the logging via
@@ -186,7 +211,7 @@ function observeConsoleLogging() {
* @return {?Promise} Promise resolving once Axe texts are finished.
*/
async function runAxeTestsForBlockEditor() {
- if ( ! await page.$( '.block-editor' ) ) {
+ if ( ! ( await page.$( '.block-editor' ) ) ) {
return;
}
diff --git a/packages/e2e-tests/experimental-features.js b/packages/e2e-tests/experimental-features.js
index 4b06a761c865a..bbbd3bb6bf743 100644
--- a/packages/e2e-tests/experimental-features.js
+++ b/packages/e2e-tests/experimental-features.js
@@ -10,14 +10,16 @@ async function setExperimentalFeaturesState( features, enable ) {
} );
await visitAdminPage( '/admin.php', query );
- await Promise.all( features.map( async ( feature ) => {
- await page.waitForSelector( feature );
- const checkedSelector = `${ feature }[checked=checked]`;
- const isChecked = !! ( await page.$( checkedSelector ) );
- if ( ( ! isChecked && enable ) || ( isChecked && ! enable ) ) {
- await page.click( feature );
- }
- } ) );
+ await Promise.all(
+ features.map( async ( feature ) => {
+ await page.waitForSelector( feature );
+ const checkedSelector = `${ feature }[checked=checked]`;
+ const isChecked = !! ( await page.$( checkedSelector ) );
+ if ( ( ! isChecked && enable ) || ( isChecked && ! enable ) ) {
+ await page.click( feature );
+ }
+ } )
+ );
await Promise.all( [
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
page.click( '#submit' ),
diff --git a/packages/e2e-tests/fixtures/block-transforms.js b/packages/e2e-tests/fixtures/block-transforms.js
index 3677373fbeb30..30a22bfc3e7c9 100644
--- a/packages/e2e-tests/fixtures/block-transforms.js
+++ b/packages/e2e-tests/fixtures/block-transforms.js
@@ -1,209 +1,127 @@
export const EXPECTED_TRANSFORMS = {
core__archives: {
originalBlock: 'Archives',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__archives__showPostCounts: {
originalBlock: 'Archives',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__audio: {
originalBlock: 'Audio',
- availableTransforms: [
- 'File',
- 'Group',
- ],
+ availableTransforms: [ 'File', 'Group' ],
},
core__button__center: {
originalBlock: 'Button',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__button__squared: {
originalBlock: 'Button',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__buttons: {
originalBlock: 'Buttons',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__calendar: {
originalBlock: 'Calendar',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
'core__media-text': {
originalBlock: 'Media & Text',
- availableTransforms: [
- 'Group',
- 'Image',
- ],
+ availableTransforms: [ 'Group', 'Image' ],
},
'core__media-text__image-alt-no-align': {
originalBlock: 'Media & Text',
- availableTransforms: [
- 'Group',
- 'Image',
- ],
+ availableTransforms: [ 'Group', 'Image' ],
},
'core__media-text__image-fill-no-focal-point-selected': {
originalBlock: 'Media & Text',
- availableTransforms: [
- 'Group',
- 'Image',
- ],
+ availableTransforms: [ 'Group', 'Image' ],
},
'core__media-text__image-fill-with-focal-point-selected': {
originalBlock: 'Media & Text',
- availableTransforms: [
- 'Group',
- 'Image',
- ],
+ availableTransforms: [ 'Group', 'Image' ],
},
'core__media-text__is-stacked-on-mobile': {
originalBlock: 'Media & Text',
- availableTransforms: [
- 'Group',
- 'Video',
- ],
+ availableTransforms: [ 'Group', 'Video' ],
},
'core__media-text__media-right-custom-width': {
originalBlock: 'Media & Text',
- availableTransforms: [
- 'Group',
- 'Video',
- ],
+ availableTransforms: [ 'Group', 'Video' ],
},
'core__media-text__vertical-align-bottom': {
originalBlock: 'Media & Text',
- availableTransforms: [
- 'Group',
- 'Image',
- ],
+ availableTransforms: [ 'Group', 'Image' ],
},
'core__media-text__video': {
originalBlock: 'Media & Text',
- availableTransforms: [
- 'Group',
- 'Video',
- ],
+ availableTransforms: [ 'Group', 'Video' ],
},
core__categories: {
originalBlock: 'Categories',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__code: {
originalBlock: 'Code',
- availableTransforms: [
- 'Group',
- 'Preformatted',
- ],
+ availableTransforms: [ 'Group', 'Preformatted' ],
},
core__columns: {
originalBlock: 'Columns',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__cover: {
- availableTransforms: [
- 'Group',
- 'Image',
- ],
+ availableTransforms: [ 'Group', 'Image' ],
originalBlock: 'Cover',
},
core__cover__gradient: {
- availableTransforms: [
- 'Group',
- 'Image',
- 'Video',
- ],
+ availableTransforms: [ 'Group', 'Image', 'Video' ],
originalBlock: 'Cover',
},
'core__cover__gradient-image': {
- availableTransforms: [
- 'Group',
- 'Image',
- ],
+ availableTransforms: [ 'Group', 'Image' ],
originalBlock: 'Cover',
},
'core__cover__gradient-video': {
- availableTransforms: [
- 'Group',
- 'Video',
- ],
+ availableTransforms: [ 'Group', 'Video' ],
originalBlock: 'Cover',
},
core__cover__video: {
- availableTransforms: [
- 'Group',
- 'Video',
- ],
+ availableTransforms: [ 'Group', 'Video' ],
originalBlock: 'Cover',
},
'core__cover__video-overlay': {
- availableTransforms: [
- 'Group',
- 'Video',
- ],
+ availableTransforms: [ 'Group', 'Video' ],
originalBlock: 'Cover',
},
core__embed: {
originalBlock: 'Embed',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
'core__file__new-window': {
originalBlock: 'File',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
'core__file__no-download-button': {
originalBlock: 'File',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
'core__file__no-text-link': {
originalBlock: 'File',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__gallery: {
originalBlock: 'Gallery',
- availableTransforms: [
- 'Group',
- 'Image',
- ],
+ availableTransforms: [ 'Group', 'Image' ],
},
'core__gallery-with-caption': {
originalBlock: 'Gallery',
- availableTransforms: [
- 'Group',
- 'Image',
- ],
+ availableTransforms: [ 'Group', 'Image' ],
},
core__gallery__columns: {
originalBlock: 'Gallery',
- availableTransforms: [
- 'Group',
- 'Image',
- ],
+ availableTransforms: [ 'Group', 'Image' ],
},
core__group: {
originalBlock: 'Group',
@@ -211,33 +129,19 @@ export const EXPECTED_TRANSFORMS = {
},
'core__heading__h2-color': {
originalBlock: 'Heading',
- availableTransforms: [
- 'Quote',
- 'Group',
- 'Paragraph',
- ],
+ availableTransforms: [ 'Quote', 'Group', 'Paragraph' ],
},
'core__heading__h4-em': {
originalBlock: 'Heading',
- availableTransforms: [
- 'Quote',
- 'Group',
- 'Paragraph',
- ],
+ availableTransforms: [ 'Quote', 'Group', 'Paragraph' ],
},
core__heading__h2: {
originalBlock: 'Heading',
- availableTransforms: [
- 'Quote',
- 'Group',
- 'Paragraph',
- ],
+ availableTransforms: [ 'Quote', 'Group', 'Paragraph' ],
},
core__html: {
originalBlock: 'Custom HTML',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__image: {
originalBlock: 'Image',
@@ -311,65 +215,43 @@ export const EXPECTED_TRANSFORMS = {
},
'core__latest-comments': {
originalBlock: 'Latest Comments',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
'core__latest-posts': {
originalBlock: 'Latest Posts',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
'core__latest-posts__displayPostDate': {
originalBlock: 'Latest Posts',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
'core__legacy-widget': {
originalBlock: 'Legacy Widget (Experimental)',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__list__ul: {
originalBlock: 'List',
- availableTransforms: [
- 'Group',
- 'Paragraph',
- 'Quote',
- ],
+ availableTransforms: [ 'Group', 'Paragraph', 'Quote' ],
},
core__more: {
originalBlock: 'More',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
'core__more__custom-text-teaser': {
originalBlock: 'More',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__navigation: {
originalBlock: 'Navigation',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
'core__navigation-link': {
originalBlock: 'Navigation Link',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__nextpage: {
originalBlock: 'Page Break',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
'core__paragraph__align-right': {
originalBlock: 'Paragraph',
@@ -383,44 +265,28 @@ export const EXPECTED_TRANSFORMS = {
],
},
'core__post-content': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Post Content',
},
'core__post-title': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Post Title',
},
core__preformatted: {
originalBlock: 'Preformatted',
- availableTransforms: [
- 'Group',
- 'Paragraph',
- ],
+ availableTransforms: [ 'Group', 'Paragraph' ],
},
core__pullquote: {
originalBlock: 'Pullquote',
- availableTransforms: [
- 'Quote',
- 'Group',
- ],
+ availableTransforms: [ 'Quote', 'Group' ],
},
'core__pullquote__main-color': {
originalBlock: 'Pullquote',
- availableTransforms: [
- 'Quote',
- 'Group',
- ],
+ availableTransforms: [ 'Quote', 'Group' ],
},
'core__pullquote__multi-paragraph': {
originalBlock: 'Pullquote',
- availableTransforms: [
- 'Quote',
- 'Group',
- ],
+ availableTransforms: [ 'Quote', 'Group' ],
},
'core__quote__style-1': {
originalBlock: 'Quote',
@@ -444,330 +310,218 @@ export const EXPECTED_TRANSFORMS = {
},
core__rss: {
originalBlock: 'RSS',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__search: {
originalBlock: 'Search',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
'core__search__custom-text': {
originalBlock: 'Search',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__separator: {
originalBlock: 'Separator',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__shortcode: {
originalBlock: 'Shortcode',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
'core__site-title': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Site Title',
},
'core__social-link-amazon': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Amazon',
},
'core__social-link-bandcamp': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Bandcamp',
},
'core__social-link-behance': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Behance',
},
'core__social-link-chain': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Link',
},
'core__social-link-codepen': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'CodePen',
},
'core__social-link-deviantart': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'DeviantArt',
},
'core__social-link-dribbble': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Dribbble',
},
'core__social-link-dropbox': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Dropbox',
},
'core__social-link-etsy': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Etsy',
},
'core__social-link-facebook': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Facebook',
},
'core__social-link-feed': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'RSS Feed',
},
'core__social-link-fivehundredpx': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: '500px',
},
'core__social-link-flickr': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Flickr',
},
'core__social-link-foursquare': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Foursquare',
},
'core__social-link-github': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'GitHub',
},
'core__social-link-goodreads': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Goodreads',
},
'core__social-link-google': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Google',
},
'core__social-link-instagram': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Instagram',
},
'core__social-link-lastfm': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Last.fm',
},
'core__social-link-linkedin': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'LinkedIn',
},
'core__social-link-mail': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Mail',
},
'core__social-link-mastodon': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Mastodon',
},
'core__social-link-medium': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Medium',
},
'core__social-link-meetup': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Meetup',
},
'core__social-link-pinterest': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Pinterest',
},
'core__social-link-pocket': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Pocket',
},
'core__social-link-reddit': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Reddit',
},
'core__social-link-skype': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Skype',
},
'core__social-link-snapchat': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Snapchat',
},
'core__social-link-soundcloud': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Soundcloud',
},
'core__social-link-spotify': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Spotify',
},
'core__social-link-tumblr': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Tumblr',
},
'core__social-link-twitch': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Twitch',
},
'core__social-link-twitter': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Twitter',
},
'core__social-link-vimeo': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Vimeo',
},
'core__social-link-vk': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'VK',
},
'core__social-link-wordpress': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'WordPress',
},
'core__social-link-yelp': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'Yelp',
},
'core__social-link-youtube': {
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
originalBlock: 'YouTube',
},
'core__social-links': {
originalBlock: 'Social links',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__spacer: {
originalBlock: 'Spacer',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__table: {
originalBlock: 'Table',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__table__caption: {
originalBlock: 'Table',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
'core__table__scope-attribute': {
originalBlock: 'Table',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
'core__tag-cloud': {
originalBlock: 'Tag Cloud',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
'core__tag-cloud__showTagCounts': {
originalBlock: 'Tag Cloud',
- availableTransforms: [
- 'Group',
- ],
+ availableTransforms: [ 'Group' ],
},
core__verse: {
originalBlock: 'Verse',
- availableTransforms: [
- 'Group',
- 'Paragraph',
- ],
+ availableTransforms: [ 'Group', 'Paragraph' ],
},
core__video: {
originalBlock: 'Video',
- availableTransforms: [
- 'Cover',
- 'File',
- 'Group',
- 'Media & Text',
- ],
+ availableTransforms: [ 'Cover', 'File', 'Group', 'Media & Text' ],
},
};
diff --git a/packages/e2e-tests/fixtures/blocks/core__columns.html b/packages/e2e-tests/fixtures/blocks/core__columns.html
index 10316fc04d135..89383b93f3ad1 100644
--- a/packages/e2e-tests/fixtures/blocks/core__columns.html
+++ b/packages/e2e-tests/fixtures/blocks/core__columns.html
@@ -1,5 +1,5 @@
-
-
+
+
diff --git a/packages/e2e-tests/fixtures/blocks/core__columns.json b/packages/e2e-tests/fixtures/blocks/core__columns.json
index d2c4a123741dc..9741c4ee472aa 100644
--- a/packages/e2e-tests/fixtures/blocks/core__columns.json
+++ b/packages/e2e-tests/fixtures/blocks/core__columns.json
@@ -3,7 +3,9 @@
"clientId": "_clientId_0",
"name": "core/columns",
"isValid": true,
- "attributes": {},
+ "attributes": {
+ "backgroundColor": "secondary"
+ },
"innerBlocks": [
{
"clientId": "_clientId_0",
@@ -68,6 +70,6 @@
"originalContent": "
\n\t\t\n\t\t\n\t
"
}
],
- "originalContent": "
\n\t\n\t\n
"
+ "originalContent": "
\n\t\n\t\n
"
}
]
diff --git a/packages/e2e-tests/fixtures/blocks/core__columns.parsed.json b/packages/e2e-tests/fixtures/blocks/core__columns.parsed.json
index e3a1d3c00b0b1..dec57c6e19e39 100644
--- a/packages/e2e-tests/fixtures/blocks/core__columns.parsed.json
+++ b/packages/e2e-tests/fixtures/blocks/core__columns.parsed.json
@@ -1,7 +1,9 @@
[
{
"blockName": "core/columns",
- "attrs": {},
+ "attrs": {
+ "backgroundColor": "secondary"
+ },
"innerBlocks": [
{
"blockName": "core/column",
@@ -68,9 +70,9 @@
]
}
],
- "innerHTML": "\n
\n\t\n\t\n
\n",
+ "innerHTML": "\n
\n\t\n\t\n
\n",
"innerContent": [
- "\n
\n\t",
+ "\n
\n\t",
null,
"\n\t",
null,
diff --git a/packages/e2e-tests/fixtures/blocks/core__columns.serialized.html b/packages/e2e-tests/fixtures/blocks/core__columns.serialized.html
index 47dcbe2fa6917..664beb08154a7 100644
--- a/packages/e2e-tests/fixtures/blocks/core__columns.serialized.html
+++ b/packages/e2e-tests/fixtures/blocks/core__columns.serialized.html
@@ -1,5 +1,5 @@
-
-
+
+
Column One, Paragraph One
diff --git a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-1.html b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-1.html
index f73ee633132cc..f982c52aa27cc 100644
--- a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-1.html
+++ b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-1.html
@@ -1,5 +1,5 @@
-
-
+
+
diff --git a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-1.json b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-1.json
index 92f3e7f2bd7a3..41b1ca556bf5a 100644
--- a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-1.json
+++ b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-1.json
@@ -17,9 +17,9 @@
"columns": 2,
"imageCrop": true,
"linkTo": "none",
- "align": "none"
+ "align": "wide"
},
"innerBlocks": [],
- "originalContent": "
\n\t
\n\t\t \n\t \n\t
\n\t\t \n\t \n
"
+ "originalContent": "
\n\t
\n\t\t \n\t \n\t
\n\t\t \n\t \n
"
}
]
diff --git a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-1.parsed.json b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-1.parsed.json
index 08adc8d387112..b684a539ed4b3 100644
--- a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-1.parsed.json
+++ b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-1.parsed.json
@@ -2,12 +2,13 @@
{
"blockName": "core/gallery",
"attrs": {
- "columns": 2
+ "columns": 2,
+ "align": "wide"
},
"innerBlocks": [],
- "innerHTML": "\n
\n\t
\n\t\t \n\t \n\t
\n\t\t \n\t \n
\n",
+ "innerHTML": "\n
\n\t
\n\t\t \n\t \n\t
\n\t\t \n\t \n
\n",
"innerContent": [
- "\n
\n\t
\n\t\t \n\t \n\t
\n\t\t \n\t \n
\n"
+ "\n
\n\t
\n\t\t \n\t \n\t
\n\t\t \n\t \n
\n"
]
},
{
diff --git a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-1.serialized.html b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-1.serialized.html
index 3bd376b5c741d..6331b6bd2f740 100644
--- a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-1.serialized.html
+++ b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-1.serialized.html
@@ -1,3 +1,3 @@
-
-
+
+
diff --git a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-2.html b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-2.html
index fec3435d8876e..7ff72ee6bc605 100644
--- a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-2.html
+++ b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-2.html
@@ -1,5 +1,5 @@
-
-
+
+
diff --git a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-2.json b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-2.json
index ae7369c05d01b..84c8db20765a2 100644
--- a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-2.json
+++ b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-2.json
@@ -21,9 +21,10 @@
"ids": [],
"columns": 2,
"imageCrop": true,
- "linkTo": "none"
+ "linkTo": "none",
+ "align": "wide"
},
"innerBlocks": [],
- "originalContent": "\n\t\n\t\t\n\t\t\t \n\t\t \n\t \n\t\n\t\t\n\t\t\t \n\t\t \n\t \n "
+ "originalContent": "\n\t\n\t\t\n\t\t\t \n\t\t \n\t \n\t\n\t\t\n\t\t\t \n\t\t \n\t \n "
}
]
diff --git a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-2.parsed.json b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-2.parsed.json
index acaac1c9499e5..49a8164b3c843 100644
--- a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-2.parsed.json
+++ b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-2.parsed.json
@@ -2,12 +2,13 @@
{
"blockName": "core/gallery",
"attrs": {
- "columns": 2
+ "columns": 2,
+ "align": "wide"
},
"innerBlocks": [],
- "innerHTML": "\n\n\t\n\t\t\n\t\t\t \n\t\t \n\t \n\t\n\t\t\n\t\t\t \n\t\t \n\t \n \n",
+ "innerHTML": "\n\n\t\n\t\t\n\t\t\t \n\t\t \n\t \n\t\n\t\t\n\t\t\t \n\t\t \n\t \n \n",
"innerContent": [
- "\n\n\t\n\t\t\n\t\t\t \n\t\t \n\t \n\t\n\t\t\n\t\t\t \n\t\t \n\t \n \n"
+ "\n\n\t\n\t\t\n\t\t\t \n\t\t \n\t \n\t\n\t\t\n\t\t\t \n\t\t \n\t \n \n"
]
},
{
diff --git a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-2.serialized.html b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-2.serialized.html
index d3fecd0f5a0d7..90d526172ee87 100644
--- a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-2.serialized.html
+++ b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-2.serialized.html
@@ -1,3 +1,3 @@
-
-
+
+
diff --git a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-3.html b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-3.html
index b91a575be9ca5..8b23e16a38a38 100644
--- a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-3.html
+++ b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-3.html
@@ -1,5 +1,5 @@
-
-
+
+
diff --git a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-3.json b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-3.json
index 1ab0e9709401c..a0325e960ab08 100644
--- a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-3.json
+++ b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-3.json
@@ -21,9 +21,10 @@
null
],
"imageCrop": true,
- "linkTo": "none"
+ "linkTo": "none",
+ "align": "wide"
},
"innerBlocks": [],
- "originalContent": "\n\t\n\t\t\n\t\t\t \n\t\t \n\t \n\t\n\t\t\n\t\t\t \n\t\t \n\t \n "
+ "originalContent": "\n\t\n\t\t\n\t\t\t \n\t\t \n\t \n\t\n\t\t\n\t\t\t \n\t\t \n\t \n "
}
]
diff --git a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-3.parsed.json b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-3.parsed.json
index 99c1ac20ed956..82ed8f0225e49 100644
--- a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-3.parsed.json
+++ b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-3.parsed.json
@@ -5,12 +5,13 @@
"ids": [
null,
null
- ]
+ ],
+ "align": "wide"
},
"innerBlocks": [],
- "innerHTML": "\n\n\t\n\t\t\n\t\t\t \n\t\t \n\t \n\t\n\t\t\n\t\t\t \n\t\t \n\t \n \n",
+ "innerHTML": "\n\n\t\n\t\t\n\t\t\t \n\t\t \n\t \n\t\n\t\t\n\t\t\t \n\t\t \n\t \n \n",
"innerContent": [
- "\n\n\t\n\t\t\n\t\t\t \n\t\t \n\t \n\t\n\t\t\n\t\t\t \n\t\t \n\t \n \n"
+ "\n\n\t\n\t\t\n\t\t\t \n\t\t \n\t \n\t\n\t\t\n\t\t\t \n\t\t \n\t \n \n"
]
},
{
diff --git a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-3.serialized.html b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-3.serialized.html
index 4675f6d3cf05b..be64b7f2b23aa 100644
--- a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-3.serialized.html
+++ b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-3.serialized.html
@@ -1,3 +1,3 @@
-
-
+
+
diff --git a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-4.html b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-4.html
new file mode 100644
index 0000000000000..2ec636839051f
--- /dev/null
+++ b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-4.html
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-4.json b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-4.json
new file mode 100644
index 0000000000000..f74bed0428cb8
--- /dev/null
+++ b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-4.json
@@ -0,0 +1,40 @@
+[
+ {
+ "clientId": "_clientId_0",
+ "name": "core/gallery",
+ "isValid": true,
+ "attributes": {
+ "images": [
+ {
+ "url": "https://sergioestevaofolio.files.wordpress.com/2016/09/cropped-img_9054-1.jpg?w=190",
+ "alt": "",
+ "id": "1421",
+ "caption": ""
+ },
+ {
+ "url": "https://sergioestevaofolio.files.wordpress.com/2017/09/cropped-l1001498-1.jpg?w=580",
+ "alt": "",
+ "id": "1440",
+ "caption": ""
+ },
+ {
+ "url": "https://sergioestevaofolio.files.wordpress.com/2017/05/cropped-l1005945-2-2.jpg?w=580",
+ "alt": "",
+ "id": "1362",
+ "caption": ""
+ }
+ ],
+ "ids": [
+ 1421,
+ 1440,
+ 1362
+ ],
+ "caption": "",
+ "imageCrop": true,
+ "linkTo": "none",
+ "align": "wide"
+ },
+ "innerBlocks": [],
+ "originalContent": "\n\t\n\t\t\n\t\t\t\n\t\t\t\t \n\t\t\t \n\t\t \n\t\t\n\t\t\t\n\t\t\t\t \n\t\t\t \n\t\t \n\t\t\n\t\t\t\n\t\t\t\t \n\t\t\t \n\t\t \n\t \n "
+ }
+]
diff --git a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-4.parsed.json b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-4.parsed.json
new file mode 100644
index 0000000000000..3658ae2936479
--- /dev/null
+++ b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-4.parsed.json
@@ -0,0 +1,27 @@
+[
+ {
+ "blockName": "core/gallery",
+ "attrs": {
+ "ids": [
+ "1421",
+ "1440",
+ "1362"
+ ],
+ "align": "wide"
+ },
+ "innerBlocks": [],
+ "innerHTML": "\n\n\t\n\t\t\n\t\t\t\n\t\t\t\t \n\t\t\t \n\t\t \n\t\t\n\t\t\t\n\t\t\t\t \n\t\t\t \n\t\t \n\t\t\n\t\t\t\n\t\t\t\t \n\t\t\t \n\t\t \n\t \n \n",
+ "innerContent": [
+ "\n\n\t\n\t\t\n\t\t\t\n\t\t\t\t \n\t\t\t \n\t\t \n\t\t\n\t\t\t\n\t\t\t\t \n\t\t\t \n\t\t \n\t\t\n\t\t\t\n\t\t\t\t \n\t\t\t \n\t\t \n\t \n \n"
+ ]
+ },
+ {
+ "blockName": null,
+ "attrs": {},
+ "innerBlocks": [],
+ "innerHTML": "\n",
+ "innerContent": [
+ "\n"
+ ]
+ }
+]
diff --git a/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-4.serialized.html b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-4.serialized.html
new file mode 100644
index 0000000000000..5e430b949044c
--- /dev/null
+++ b/packages/e2e-tests/fixtures/blocks/core__gallery__deprecated-4.serialized.html
@@ -0,0 +1,3 @@
+
+
+
diff --git a/packages/e2e-tests/fixtures/blocks/core__navigation.json b/packages/e2e-tests/fixtures/blocks/core__navigation.json
index 2ceda519775fe..638c0ec5ab796 100644
--- a/packages/e2e-tests/fixtures/blocks/core__navigation.json
+++ b/packages/e2e-tests/fixtures/blocks/core__navigation.json
@@ -3,7 +3,9 @@
"clientId": "_clientId_0",
"name": "core/navigation",
"isValid": true,
- "attributes": {},
+ "attributes": {
+ "showSubmenuIcon": false
+ },
"innerBlocks": [],
"originalContent": ""
}
diff --git a/packages/e2e-tests/fixtures/blocks/core__post-author.html b/packages/e2e-tests/fixtures/blocks/core__post-author.html
new file mode 100644
index 0000000000000..7cf982dae7196
--- /dev/null
+++ b/packages/e2e-tests/fixtures/blocks/core__post-author.html
@@ -0,0 +1 @@
+
diff --git a/packages/e2e-tests/fixtures/blocks/core__post-author.json b/packages/e2e-tests/fixtures/blocks/core__post-author.json
new file mode 100644
index 0000000000000..f780184a547e9
--- /dev/null
+++ b/packages/e2e-tests/fixtures/blocks/core__post-author.json
@@ -0,0 +1,10 @@
+[
+ {
+ "clientId": "_clientId_0",
+ "name": "core/post-author",
+ "isValid": true,
+ "attributes": {},
+ "innerBlocks": [],
+ "originalContent": ""
+ }
+]
diff --git a/packages/e2e-tests/fixtures/blocks/core__post-author.parsed.json b/packages/e2e-tests/fixtures/blocks/core__post-author.parsed.json
new file mode 100644
index 0000000000000..82333c4d5a5ff
--- /dev/null
+++ b/packages/e2e-tests/fixtures/blocks/core__post-author.parsed.json
@@ -0,0 +1,18 @@
+[
+ {
+ "blockName": "core/post-author",
+ "attrs": {},
+ "innerBlocks": [],
+ "innerHTML": "",
+ "innerContent": []
+ },
+ {
+ "blockName": null,
+ "attrs": {},
+ "innerBlocks": [],
+ "innerHTML": "\n",
+ "innerContent": [
+ "\n"
+ ]
+ }
+]
diff --git a/packages/e2e-tests/fixtures/blocks/core__post-author.serialized.html b/packages/e2e-tests/fixtures/blocks/core__post-author.serialized.html
new file mode 100644
index 0000000000000..7cf982dae7196
--- /dev/null
+++ b/packages/e2e-tests/fixtures/blocks/core__post-author.serialized.html
@@ -0,0 +1 @@
+
diff --git a/packages/e2e-tests/fixtures/blocks/core__post-date.html b/packages/e2e-tests/fixtures/blocks/core__post-date.html
new file mode 100644
index 0000000000000..56357e03f4990
--- /dev/null
+++ b/packages/e2e-tests/fixtures/blocks/core__post-date.html
@@ -0,0 +1 @@
+
diff --git a/packages/e2e-tests/fixtures/blocks/core__post-date.json b/packages/e2e-tests/fixtures/blocks/core__post-date.json
new file mode 100644
index 0000000000000..42e12a85c4962
--- /dev/null
+++ b/packages/e2e-tests/fixtures/blocks/core__post-date.json
@@ -0,0 +1,10 @@
+[
+ {
+ "clientId": "_clientId_0",
+ "name": "core/post-date",
+ "isValid": true,
+ "attributes": {},
+ "innerBlocks": [],
+ "originalContent": ""
+ }
+]
diff --git a/packages/e2e-tests/fixtures/blocks/core__post-date.parsed.json b/packages/e2e-tests/fixtures/blocks/core__post-date.parsed.json
new file mode 100644
index 0000000000000..6a912b2c3214a
--- /dev/null
+++ b/packages/e2e-tests/fixtures/blocks/core__post-date.parsed.json
@@ -0,0 +1,18 @@
+[
+ {
+ "blockName": "core/post-date",
+ "attrs": {},
+ "innerBlocks": [],
+ "innerHTML": "",
+ "innerContent": []
+ },
+ {
+ "blockName": null,
+ "attrs": {},
+ "innerBlocks": [],
+ "innerHTML": "\n",
+ "innerContent": [
+ "\n"
+ ]
+ }
+]
diff --git a/packages/e2e-tests/fixtures/blocks/core__post-date.serialized.html b/packages/e2e-tests/fixtures/blocks/core__post-date.serialized.html
new file mode 100644
index 0000000000000..56357e03f4990
--- /dev/null
+++ b/packages/e2e-tests/fixtures/blocks/core__post-date.serialized.html
@@ -0,0 +1 @@
+
diff --git a/packages/e2e-tests/fixtures/blocks/core__post-excerpt.html b/packages/e2e-tests/fixtures/blocks/core__post-excerpt.html
new file mode 100644
index 0000000000000..7e9cdd6a03339
--- /dev/null
+++ b/packages/e2e-tests/fixtures/blocks/core__post-excerpt.html
@@ -0,0 +1 @@
+
diff --git a/packages/e2e-tests/fixtures/blocks/core__post-excerpt.json b/packages/e2e-tests/fixtures/blocks/core__post-excerpt.json
new file mode 100644
index 0000000000000..67bee1bd83f27
--- /dev/null
+++ b/packages/e2e-tests/fixtures/blocks/core__post-excerpt.json
@@ -0,0 +1,10 @@
+[
+ {
+ "clientId": "_clientId_0",
+ "name": "core/post-excerpt",
+ "isValid": true,
+ "attributes": {},
+ "innerBlocks": [],
+ "originalContent": ""
+ }
+]
diff --git a/packages/e2e-tests/fixtures/blocks/core__post-excerpt.parsed.json b/packages/e2e-tests/fixtures/blocks/core__post-excerpt.parsed.json
new file mode 100644
index 0000000000000..509101167e1d9
--- /dev/null
+++ b/packages/e2e-tests/fixtures/blocks/core__post-excerpt.parsed.json
@@ -0,0 +1,18 @@
+[
+ {
+ "blockName": "core/post-excerpt",
+ "attrs": {},
+ "innerBlocks": [],
+ "innerHTML": "",
+ "innerContent": []
+ },
+ {
+ "blockName": null,
+ "attrs": {},
+ "innerBlocks": [],
+ "innerHTML": "\n",
+ "innerContent": [
+ "\n"
+ ]
+ }
+]
diff --git a/packages/e2e-tests/fixtures/blocks/core__post-excerpt.serialized.html b/packages/e2e-tests/fixtures/blocks/core__post-excerpt.serialized.html
new file mode 100644
index 0000000000000..7e9cdd6a03339
--- /dev/null
+++ b/packages/e2e-tests/fixtures/blocks/core__post-excerpt.serialized.html
@@ -0,0 +1 @@
+
diff --git a/packages/e2e-tests/fixtures/utils.js b/packages/e2e-tests/fixtures/utils.js
index 344e6d4a0504a..ff96e72d9a011 100644
--- a/packages/e2e-tests/fixtures/utils.js
+++ b/packages/e2e-tests/fixtures/utils.js
@@ -9,20 +9,14 @@ const FIXTURES_DIR = path.join( __dirname, 'blocks' );
function readFixtureFile( fixturesDir, filename ) {
try {
- return fs.readFileSync(
- path.join( fixturesDir, filename ),
- 'utf8'
- );
+ return fs.readFileSync( path.join( fixturesDir, filename ), 'utf8' );
} catch ( err ) {
return null;
}
}
function writeFixtureFile( fixturesDir, filename, content ) {
- fs.writeFileSync(
- path.join( fixturesDir, filename ),
- content
- );
+ fs.writeFileSync( path.join( fixturesDir, filename ), content );
}
export function blockNameToFixtureBasename( blockName ) {
@@ -37,7 +31,8 @@ export function getAvailableBlockFixturesBasenames() {
// - fixture.serialized.html : re-serialized content
// Get the "base" name for each fixture first.
return uniq(
- fs.readdirSync( FIXTURES_DIR )
+ fs
+ .readdirSync( FIXTURES_DIR )
.filter( ( f ) => /(\.html|\.json)$/.test( f ) )
.map( ( f ) => f.replace( /\..+$/, '' ) )
);
diff --git a/packages/e2e-tests/jest.config.js b/packages/e2e-tests/jest.config.js
index 22bccf74e3d1a..6b82ce764de14 100644
--- a/packages/e2e-tests/jest.config.js
+++ b/packages/e2e-tests/jest.config.js
@@ -1,8 +1,6 @@
module.exports = {
...require( '@wordpress/scripts/config/jest-e2e.config' ),
- setupFiles: [
- '/config/gutenberg-phase.js',
- ],
+ setupFiles: [ '/config/gutenberg-phase.js' ],
setupFilesAfterEnv: [
'/config/setup-test-framework.js',
'@wordpress/jest-console',
diff --git a/packages/e2e-tests/jest.performance.config.js b/packages/e2e-tests/jest.performance.config.js
index cc011820f0887..e84d03483ba95 100644
--- a/packages/e2e-tests/jest.performance.config.js
+++ b/packages/e2e-tests/jest.performance.config.js
@@ -1,11 +1,7 @@
module.exports = {
...require( '@wordpress/scripts/config/jest-e2e.config' ),
- testMatch: [
- '**/performance/*.test.js',
- ],
- setupFiles: [
- '/config/gutenberg-phase.js',
- ],
+ testMatch: [ '**/performance/*.test.js' ],
+ setupFiles: [ '/config/gutenberg-phase.js' ],
setupFilesAfterEnv: [
'/config/setup-test-framework.js',
'@wordpress/jest-console',
@@ -16,8 +12,5 @@ module.exports = {
'node_modules',
'scripts/config/puppeteer.config.js',
],
- reporters: [
- 'default',
- '/config/performance-reporter.js',
- ],
+ reporters: [ 'default', '/config/performance-reporter.js' ],
};
diff --git a/packages/e2e-tests/plugins/custom-post-types.php b/packages/e2e-tests/plugins/custom-post-types.php
index 6262c89f66d37..6f2c293cb03b4 100644
--- a/packages/e2e-tests/plugins/custom-post-types.php
+++ b/packages/e2e-tests/plugins/custom-post-types.php
@@ -66,3 +66,23 @@ function public_queryable_true_public_true_cpt() {
);
}
add_action( 'init', 'public_queryable_true_public_true_cpt' );
+
+/**
+ * Registers a custom post type that is hierarchical and does not supports the title attribute.
+ */
+function hierarchical_without_title_cpt() {
+ register_post_type(
+ 'hierar-no-title',
+ array(
+ 'public' => true,
+ 'label' => 'Hierarchical No Title',
+ 'show_in_rest' => true,
+ 'hierarchical' => true,
+ 'supports' => array( 'page-attributes', 'editor', 'thumbnail', 'comments', 'post-formats' ),
+ 'show_ui' => true,
+ 'show_in_menu' => true,
+ )
+ );
+}
+add_action( 'init', 'hierarchical_without_title_cpt' );
+
diff --git a/packages/e2e-tests/specs/editor/blocks/__snapshots__/buttons.test.js.snap b/packages/e2e-tests/specs/editor/blocks/__snapshots__/buttons.test.js.snap
index 4b27f486f66f1..067425ce07d6c 100644
--- a/packages/e2e-tests/specs/editor/blocks/__snapshots__/buttons.test.js.snap
+++ b/packages/e2e-tests/specs/editor/blocks/__snapshots__/buttons.test.js.snap
@@ -3,6 +3,14 @@
exports[`Buttons can jump to the link editor using the keyboard shortcut 1`] = `
"
+"
+`;
+
+exports[`Buttons dismisses link editor when escape is pressed 1`] = `
+"
+
"
diff --git a/packages/e2e-tests/specs/editor/blocks/__snapshots__/heading.test.js.snap b/packages/e2e-tests/specs/editor/blocks/__snapshots__/heading.test.js.snap
index 7e583c75cc68e..e63f85de4cf19 100644
--- a/packages/e2e-tests/specs/editor/blocks/__snapshots__/heading.test.js.snap
+++ b/packages/e2e-tests/specs/editor/blocks/__snapshots__/heading.test.js.snap
@@ -13,14 +13,14 @@ exports[`Heading can be created by prefixing number sign and a space 1`] = `
`;
exports[`Heading it should correctly apply custom colors 1`] = `
-"
-Heading
+"
+Heading
"
`;
exports[`Heading it should correctly apply named colors 1`] = `
-"
-Heading
+"
+Heading
"
`;
diff --git a/packages/e2e-tests/specs/editor/blocks/__snapshots__/navigation.test.js.snap b/packages/e2e-tests/specs/editor/blocks/__snapshots__/navigation.test.js.snap
index 166627ee6e618..82aed4dc7aaef 100644
--- a/packages/e2e-tests/specs/editor/blocks/__snapshots__/navigation.test.js.snap
+++ b/packages/e2e-tests/specs/editor/blocks/__snapshots__/navigation.test.js.snap
@@ -2,9 +2,9 @@
exports[`Navigation allows a navigation menu to be created from an empty menu using a mixture of internal and external links 1`] = `
"
-
+
-
+
"
`;
diff --git a/packages/e2e-tests/specs/editor/blocks/buttons.test.js b/packages/e2e-tests/specs/editor/blocks/buttons.test.js
index a7b97bc18a9fa..3938bc2edb6c1 100644
--- a/packages/e2e-tests/specs/editor/blocks/buttons.test.js
+++ b/packages/e2e-tests/specs/editor/blocks/buttons.test.js
@@ -20,12 +20,27 @@ describe( 'Buttons', () => {
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
+ it( 'dismisses link editor when escape is pressed', async () => {
+ // Regression: https://github.com/WordPress/gutenberg/pull/19885
+ await insertBlock( 'Buttons' );
+ await pressKeyWithModifier( 'primary', 'k' );
+ await page.keyboard.press( 'Escape' );
+ await page.keyboard.type( 'WordPress' );
+
+ expect( await getEditedPostContent() ).toMatchSnapshot();
+ } );
+
it( 'can jump to the link editor using the keyboard shortcut', async () => {
await insertBlock( 'Buttons' );
await page.keyboard.type( 'WordPress' );
await pressKeyWithModifier( 'primary', 'k' );
- await page.keyboard.type( 'https://wwww.wordpress.org/' );
+ await page.keyboard.type( 'https://www.wordpress.org/' );
await page.keyboard.press( 'Enter' );
+ // Make sure that the dialog is still opened, and that focus is retained
+ // within (focusing on the link preview).
+ await page.waitForSelector(
+ ':focus.block-editor-link-control__search-item-title'
+ );
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
diff --git a/packages/e2e-tests/specs/editor/blocks/classic.test.js b/packages/e2e-tests/specs/editor/blocks/classic.test.js
index 29170335d900f..b8295c64d53df 100644
--- a/packages/e2e-tests/specs/editor/blocks/classic.test.js
+++ b/packages/e2e-tests/specs/editor/blocks/classic.test.js
@@ -14,6 +14,8 @@ import {
createNewPost,
insertBlock,
pressKeyWithModifier,
+ clickBlockToolbarButton,
+ clickButton,
} from '@wordpress/e2e-test-utils';
describe( 'Classic', () => {
@@ -34,7 +36,7 @@ describe( 'Classic', () => {
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
- it( 'should insert media', async () => {
+ it( 'should insert media, convert to blocks, and undo in one step', async () => {
await insertBlock( 'Classic' );
// Wait for TinyMCE to initialise.
await page.waitForSelector( '.mce-content-body' );
@@ -45,29 +47,58 @@ describe( 'Classic', () => {
// Click the image button.
await page.waitForSelector( 'div[aria-label^="Add Media"]' );
await page.click( 'div[aria-label^="Add Media"]' );
+ await page.click( '.media-menu-item#menu-item-gallery' );
// Wait for media modal to appear and upload image.
await page.waitForSelector( '.media-modal input[type=file]' );
const inputElement = await page.$( '.media-modal input[type=file]' );
- const testImagePath = path.join( __dirname, '..', '..', '..', 'assets', '10x10_e2e_test_image_z9T8jK.png' );
+ const testImagePath = path.join(
+ __dirname,
+ '..',
+ '..',
+ '..',
+ 'assets',
+ '10x10_e2e_test_image_z9T8jK.png'
+ );
const filename = uuid();
const tmpFileName = path.join( os.tmpdir(), filename + '.png' );
fs.copyFileSync( testImagePath, tmpFileName );
await inputElement.uploadFile( tmpFileName );
// Wait for upload.
- await page.waitForSelector( `.media-modal li[aria-label="${ filename }"]` );
+ await page.waitForSelector(
+ `.media-modal li[aria-label="${ filename }"]`
+ );
// Insert the uploaded image.
+ await page.click( '.media-modal button.media-button-gallery' );
await page.click( '.media-modal button.media-button-insert' );
// Wait for image to be inserted.
await page.waitForSelector( '.mce-content-body img' );
- // Move focus away.
+ // Move focus away and verify gallery was inserted.
await pressKeyWithModifier( 'shift', 'Tab' );
+ expect( await getEditedPostContent() ).toMatch(
+ /\[gallery ids=\"\d+\"\]/
+ );
+
+ // Convert to blocks and verify it worked correctly.
+ await clickBlockToolbarButton( 'More options' );
+ await clickButton( 'Convert to Blocks' );
+ await page.waitForSelector( '.wp-block[data-type="core/gallery"]' );
+ expect( await getEditedPostContent() ).toMatch( /`;
- element.value = element.value.replace( blockDelimiter, `${ _paragraph }${ blockDelimiter }` );
- }, paragraphToAdd, blockSlug );
+ await page.$eval(
+ '.editor-post-text-editor',
+ ( element, _paragraph, _blockSlug ) => {
+ const blockDelimiter = ``;
+ element.value = element.value.replace(
+ blockDelimiter,
+ `${ _paragraph }${ blockDelimiter }`
+ );
+ },
+ paragraphToAdd,
+ blockSlug
+ );
// Press "Enter" inside the Code Editor to fire the `onChange` event for the new value.
await page.click( '.editor-post-text-editor' );
+ await pressKeyWithModifier( 'primary', 'A' );
+ await page.keyboard.press( 'ArrowRight' );
await page.keyboard.press( 'Enter' );
await switchEditorModeTo( 'Visual' );
};
it( 'Ensures blocks without locking are kept intact even if they do not match the template ', async () => {
- await insertBlockAndAddParagraphInside( 'Test Inner Blocks no locking', 'test/test-inner-blocks-no-locking' );
+ await insertBlockAndAddParagraphInside(
+ 'Test Inner Blocks no locking',
+ 'test/test-inner-blocks-no-locking'
+ );
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
it( 'Removes blocks that are not expected by the template if a lock all exists ', async () => {
- await insertBlockAndAddParagraphInside( 'Test InnerBlocks locking all', 'test/test-inner-blocks-locking-all' );
+ await insertBlockAndAddParagraphInside(
+ 'Test InnerBlocks locking all',
+ 'test/test-inner-blocks-locking-all'
+ );
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
@@ -63,7 +80,9 @@ describe( 'InnerBlocks Template Sync', () => {
describe( 'Container block without paragraph support', () => {
beforeAll( async () => {
- await activatePlugin( 'gutenberg-test-container-block-without-paragraph' );
+ await activatePlugin(
+ 'gutenberg-test-container-block-without-paragraph'
+ );
} );
beforeEach( async () => {
@@ -71,19 +90,23 @@ describe( 'Container block without paragraph support', () => {
} );
afterAll( async () => {
- await deactivatePlugin( 'gutenberg-test-container-block-without-paragraph' );
+ await deactivatePlugin(
+ 'gutenberg-test-container-block-without-paragraph'
+ );
} );
it( 'ensures we can use the alternative block appender properly', async () => {
await insertBlock( 'Container without paragraph' );
// Open the specific appender used when there's no paragraph support.
- await page.click( '.block-editor-inner-blocks .block-list-appender .block-list-appender__toggle' );
+ await page.click(
+ '.block-editor-inner-blocks .block-list-appender .block-list-appender__toggle'
+ );
// Insert an image block.
- const insertButton = ( await page.$x(
- `//button//span[contains(text(), 'Image')]`
- ) )[ 0 ];
+ const insertButton = (
+ await page.$x( `//button//span[contains(text(), 'Image')]` )
+ )[ 0 ];
await insertButton.click();
// Check the inserted content.
diff --git a/packages/e2e-tests/specs/editor/plugins/cpt-locking.test.js b/packages/e2e-tests/specs/editor/plugins/cpt-locking.test.js
index 92689539fb5e8..9233dd7157269 100644
--- a/packages/e2e-tests/specs/editor/plugins/cpt-locking.test.js
+++ b/packages/e2e-tests/specs/editor/plugins/cpt-locking.test.js
@@ -28,7 +28,10 @@ describe( 'cpt locking', () => {
};
const shouldNotAllowBlocksToBeRemoved = async () => {
- await page.type( '.block-editor-rich-text__editable.wp-block-paragraph', 'p1' );
+ await page.type(
+ '.block-editor-rich-text__editable.wp-block-paragraph',
+ 'p1'
+ );
await clickBlockToolbarButton( 'More options' );
expect(
await page.$x( '//button[contains(text(), "Remove Block")]' )
@@ -36,12 +39,15 @@ describe( 'cpt locking', () => {
};
const shouldAllowBlocksToBeMoved = async () => {
- await page.click( '.block-editor-rich-text__editable.wp-block-paragraph' );
- expect(
- await page.$( 'button[aria-label="Move up"]' )
- ).not.toBeNull();
+ await page.click(
+ '.block-editor-rich-text__editable.wp-block-paragraph'
+ );
+ expect( await page.$( 'button[aria-label="Move up"]' ) ).not.toBeNull();
await page.click( 'button[aria-label="Move up"]' );
- await page.type( '.block-editor-rich-text__editable.wp-block-paragraph', 'p1' );
+ await page.type(
+ '.block-editor-rich-text__editable.wp-block-paragraph',
+ 'p1'
+ );
expect( await getEditedPostContent() ).toMatchSnapshot();
};
@@ -52,17 +58,22 @@ describe( 'cpt locking', () => {
it( 'should remove the inserter', shouldRemoveTheInserter );
- it( 'should not allow blocks to be removed', shouldNotAllowBlocksToBeRemoved );
+ it(
+ 'should not allow blocks to be removed',
+ shouldNotAllowBlocksToBeRemoved
+ );
it( 'should not allow blocks to be moved', async () => {
- await page.click( '.block-editor-rich-text__editable.wp-block-paragraph' );
- expect(
- await page.$( 'button[aria-label="Move up"]' )
- ).toBeNull();
+ await page.click(
+ '.block-editor-rich-text__editable.wp-block-paragraph'
+ );
+ expect( await page.$( 'button[aria-label="Move up"]' ) ).toBeNull();
} );
it( 'should not error when deleting the cotents of a paragraph', async () => {
- await page.click( '.block-editor-block-list__block[data-type="core/paragraph"] p' );
+ await page.click(
+ '.block-editor-block-list__block[data-type="core/paragraph"] p'
+ );
const textToType = 'Paragraph';
await page.keyboard.type( 'Paragraph' );
await pressKeyTimes( 'Backspace', textToType.length + 1 );
@@ -71,16 +82,21 @@ describe( 'cpt locking', () => {
it( 'should show invalid template notice if the blocks do not match the templte', async () => {
const content = await getEditedPostContent();
- const [ , contentWithoutImage ] = content.split( '' );
+ const [ , contentWithoutImage ] = content.split(
+ ''
+ );
await setPostContent( contentWithoutImage );
- const VALIDATION_PARAGRAPH_SELECTOR = '.editor-template-validation-notice .components-notice__content p';
+ const VALIDATION_PARAGRAPH_SELECTOR =
+ '.editor-template-validation-notice .components-notice__content p';
await page.waitForSelector( VALIDATION_PARAGRAPH_SELECTOR );
expect(
await page.evaluate(
( element ) => element.textContent,
await page.$( VALIDATION_PARAGRAPH_SELECTOR )
)
- ).toEqual( 'The content of your post doesnโt match the template assigned to your post type.' );
+ ).toEqual(
+ 'The content of your post doesnโt match the template assigned to your post type.'
+ );
} );
} );
@@ -91,7 +107,10 @@ describe( 'cpt locking', () => {
it( 'should remove the inserter', shouldRemoveTheInserter );
- it( 'should not allow blocks to be removed', shouldNotAllowBlocksToBeRemoved );
+ it(
+ 'should not allow blocks to be removed',
+ shouldNotAllowBlocksToBeRemoved
+ );
it( 'should allow blocks to be moved', shouldAllowBlocksToBeMoved );
} );
@@ -111,9 +130,14 @@ describe( 'cpt locking', () => {
} );
it( 'should allow blocks to be removed', async () => {
- await page.type( '.block-editor-rich-text__editable.wp-block-paragraph', 'p1' );
+ await page.type(
+ '.block-editor-rich-text__editable.wp-block-paragraph',
+ 'p1'
+ );
await clickBlockToolbarButton( 'More options' );
- const [ removeBlock ] = await page.$x( '//button[contains(text(), "Remove Block")]' );
+ const [ removeBlock ] = await page.$x(
+ '//button[contains(text(), "Remove Block")]'
+ );
await removeBlock.click();
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
diff --git a/packages/e2e-tests/specs/editor/plugins/custom-post-types.test.js b/packages/e2e-tests/specs/editor/plugins/custom-post-types.test.js
new file mode 100644
index 0000000000000..fdfa152256a35
--- /dev/null
+++ b/packages/e2e-tests/specs/editor/plugins/custom-post-types.test.js
@@ -0,0 +1,67 @@
+/**
+ * WordPress dependencies
+ */
+import {
+ activatePlugin,
+ createNewPost,
+ deactivatePlugin,
+ publishPost,
+ findSidebarPanelWithTitle,
+} from '@wordpress/e2e-test-utils';
+
+const openPageAttributesPanel = async () => {
+ const openButton = await findSidebarPanelWithTitle( 'Page Attributes' );
+
+ // Get the classes from the panel
+ const buttonClassName = await (
+ await openButton.getProperty( 'className' )
+ ).jsonValue();
+
+ // Open the panel if needed.
+ if ( -1 === buttonClassName.indexOf( 'is-opened' ) ) {
+ await openButton.click();
+ }
+};
+const SELECT_OPTION_SELECTOR =
+ '.editor-page-attributes__parent option:nth-child(2)';
+
+describe( 'Test Custom Post Types', () => {
+ beforeAll( async () => {
+ await activatePlugin( 'gutenberg-test-custom-post-types' );
+ } );
+
+ afterAll( async () => {
+ await deactivatePlugin( 'gutenberg-test-custom-post-types' );
+ } );
+
+ it( 'It should be able to create an hierarchical post without title support', async () => {
+ // Create a parent post.
+ await createNewPost( { postType: 'hierar-no-title' } );
+ await page.click( '.block-editor-writing-flow' );
+ await page.keyboard.type( 'Parent Post' );
+ await publishPost();
+ // Create a post that is a child of the previously created post.
+ await createNewPost( { postType: 'hierar-no-title' } );
+ await openPageAttributesPanel();
+ await page.waitForSelector( SELECT_OPTION_SELECTOR );
+ const optionToSelect = await page.$( SELECT_OPTION_SELECTOR );
+ const valueToSelect = await (
+ await optionToSelect.getProperty( 'value' )
+ ).jsonValue();
+ await page.select(
+ '.editor-page-attributes__parent select',
+ valueToSelect
+ );
+ await page.click( '.block-editor-writing-flow' );
+ await page.keyboard.type( 'Child Post' );
+ await publishPost();
+ // Reload the child post and verify it is still correctly selected as a child post.
+ await page.reload();
+ await page.waitForSelector( SELECT_OPTION_SELECTOR );
+ const selectedValue = await page.$eval(
+ '.editor-page-attributes__parent select',
+ ( el ) => el.value
+ );
+ expect( selectedValue ).toEqual( valueToSelect );
+ } );
+} );
diff --git a/packages/e2e-tests/specs/editor/plugins/custom-taxonomies.test.js b/packages/e2e-tests/specs/editor/plugins/custom-taxonomies.test.js
index fccba18eafae1..41f15fbb616b2 100644
--- a/packages/e2e-tests/specs/editor/plugins/custom-taxonomies.test.js
+++ b/packages/e2e-tests/specs/editor/plugins/custom-taxonomies.test.js
@@ -4,7 +4,9 @@
import {
activatePlugin,
createNewPost,
- deactivatePlugin, findSidebarPanelWithTitle, openDocumentSettingsSidebar,
+ deactivatePlugin,
+ findSidebarPanelWithTitle,
+ openDocumentSettingsSidebar,
} from '@wordpress/e2e-test-utils';
describe( 'Custom Taxonomies labels are used', () => {
@@ -28,7 +30,9 @@ describe( 'Custom Taxonomies labels are used', () => {
expect( openButton ).not.toBeFalsy();
// Get the classes from the panel
- const buttonClassName = await ( await openButton.getProperty( 'className' ) ).jsonValue();
+ const buttonClassName = await (
+ await openButton.getProperty( 'className' )
+ ).jsonValue();
// Open the panel if needed.
if ( -1 === buttonClassName.indexOf( 'is-opened' ) ) {
@@ -36,15 +40,22 @@ describe( 'Custom Taxonomies labels are used', () => {
}
// Check the add new button
- const labelNew = await page.$x( "//label[@class='components-form-token-field__label' and contains(text(), 'Add New Model')]" );
+ const labelNew = await page.$x(
+ "//label[@class='components-form-token-field__label' and contains(text(), 'Add New Model')]"
+ );
expect( labelNew ).not.toBeFalsy();
// Fill with one entry
- await page.type( 'input.components-form-token-field__input', 'Model 1' );
+ await page.type(
+ 'input.components-form-token-field__input',
+ 'Model 1'
+ );
await page.keyboard.press( 'Enter' );
// Check the "Remove Model"
- const value = await page.$x( "//div[@class='components-form-token-field__input-container']//span//button[@aria-label='Remove Model']" );
+ const value = await page.$x(
+ "//div[@class='components-form-token-field__input-container']//span//button[@aria-label='Remove Model']"
+ );
expect( value ).not.toBeFalsy();
} );
} );
diff --git a/packages/e2e-tests/specs/editor/plugins/hooks-api.test.js b/packages/e2e-tests/specs/editor/plugins/hooks-api.test.js
index 4641c534493b3..07f018c528cf2 100644
--- a/packages/e2e-tests/specs/editor/plugins/hooks-api.test.js
+++ b/packages/e2e-tests/specs/editor/plugins/hooks-api.test.js
@@ -25,13 +25,18 @@ describe( 'Using Hooks API', () => {
it( 'Should contain a reset block button on the sidebar', async () => {
await clickBlockAppender();
await page.keyboard.type( 'First paragraph' );
- expect( await page.$( '.edit-post-sidebar .e2e-reset-block-button' ) ).not.toBeNull();
+ expect(
+ await page.$( '.edit-post-sidebar .e2e-reset-block-button' )
+ ).not.toBeNull();
} );
it( 'Pressing reset block button resets the block', async () => {
await clickBlockAppender();
await page.keyboard.type( 'First paragraph' );
- const paragraphContent = await page.$eval( 'div[data-type="core/paragraph"] p', ( element ) => element.textContent );
+ const paragraphContent = await page.$eval(
+ 'div[data-type="core/paragraph"] p',
+ ( element ) => element.textContent
+ );
expect( paragraphContent ).toEqual( 'First paragraph' );
await page.click( '.edit-post-sidebar .e2e-reset-block-button' );
expect( await getEditedPostContent() ).toMatchSnapshot();
diff --git a/packages/e2e-tests/specs/editor/plugins/inner-blocks-allowed-blocks.test.js b/packages/e2e-tests/specs/editor/plugins/inner-blocks-allowed-blocks.test.js
index c0a2055ade762..24d01d7abaf72 100644
--- a/packages/e2e-tests/specs/editor/plugins/inner-blocks-allowed-blocks.test.js
+++ b/packages/e2e-tests/specs/editor/plugins/inner-blocks-allowed-blocks.test.js
@@ -12,7 +12,8 @@ import {
} from '@wordpress/e2e-test-utils';
describe( 'Allowed Blocks Setting on InnerBlocks ', () => {
- const paragraphSelector = '.block-editor-rich-text__editable.wp-block-paragraph';
+ const paragraphSelector =
+ '.block-editor-rich-text__editable.wp-block-paragraph';
beforeAll( async () => {
await activatePlugin( 'gutenberg-test-innerblocks-allowed-blocks' );
} );
@@ -46,9 +47,7 @@ describe( 'Allowed Blocks Setting on InnerBlocks ', () => {
await page.click( childParagraphSelector );
await openGlobalBlockInserter();
await openAllBlockInserterCategories();
- expect(
- await getAllBlockInserterItemTitles()
- ).toEqual( [
+ expect( await getAllBlockInserterItemTitles() ).toEqual( [
'Button',
'Gallery',
'List',
@@ -65,22 +64,18 @@ describe( 'Allowed Blocks Setting on InnerBlocks ', () => {
await page.waitForSelector( appenderSelector );
await page.click( appenderSelector );
await openAllBlockInserterCategories();
- expect(
- await getAllBlockInserterItemTitles()
- ).toEqual( [
+ expect( await getAllBlockInserterItemTitles() ).toEqual( [
'Image',
'List',
] );
- const insertButton = ( await page.$x(
- `//button//span[contains(text(), 'List')]`
- ) )[ 0 ];
+ const insertButton = (
+ await page.$x( `//button//span[contains(text(), 'List')]` )
+ )[ 0 ];
await insertButton.click();
await insertBlock( 'Image' );
await page.click( appenderSelector );
await openAllBlockInserterCategories();
- expect(
- await getAllBlockInserterItemTitles()
- ).toEqual( [
+ expect( await getAllBlockInserterItemTitles() ).toEqual( [
'Gallery',
'Video',
] );
diff --git a/packages/e2e-tests/specs/editor/plugins/innerblocks-locking-all-embed.js b/packages/e2e-tests/specs/editor/plugins/innerblocks-locking-all-embed.js
index 3cba39c9f129d..c0f081976ecfe 100644
--- a/packages/e2e-tests/specs/editor/plugins/innerblocks-locking-all-embed.js
+++ b/packages/e2e-tests/specs/editor/plugins/innerblocks-locking-all-embed.js
@@ -18,12 +18,15 @@ describe( 'Embed block inside a locked all parent', () => {
} );
afterAll( async () => {
- await deactivatePlugin( 'gutenberg-test-innerblocks-locking-all-embed' );
+ await deactivatePlugin(
+ 'gutenberg-test-innerblocks-locking-all-embed'
+ );
} );
it( 'embed block should be able to embed external content', async () => {
await insertBlock( 'Test Inner Blocks Locking All Embed' );
- const embedInputSelector = '.components-placeholder__input[aria-label="Embed URL"]';
+ const embedInputSelector =
+ '.components-placeholder__input[aria-label="Embed URL"]';
await page.waitForSelector( embedInputSelector );
await page.click( embedInputSelector );
// This URL should not have a trailing slash.
diff --git a/packages/e2e-tests/specs/editor/plugins/meta-attribute-block.test.js b/packages/e2e-tests/specs/editor/plugins/meta-attribute-block.test.js
index 934e2ac73d69d..68f4de2768fbb 100644
--- a/packages/e2e-tests/specs/editor/plugins/meta-attribute-block.test.js
+++ b/packages/e2e-tests/specs/editor/plugins/meta-attribute-block.test.js
@@ -40,7 +40,9 @@ describe( 'Block with a meta attribute', () => {
await page.reload();
expect( await getEditedPostContent() ).toMatchSnapshot();
- const persistedValue = await page.evaluate( () => document.querySelector( '.my-meta-input' ).value );
+ const persistedValue = await page.evaluate(
+ () => document.querySelector( '.my-meta-input' ).value
+ );
expect( persistedValue ).toBe( 'Meta Value' );
} );
@@ -51,15 +53,17 @@ describe( 'Block with a meta attribute', () => {
await page.keyboard.type( 'Meta Value' );
const inputs = await page.$$( '.my-meta-input' );
- await Promise.all( inputs.map( async ( input ) => {
- // Clicking the input selects the block,
- // and selecting the block enables the sync data mode
- // as otherwise the asynchronous re-rendering of unselected blocks
- // may cause the input to have not yet been updated for the other blocks
- await input.click();
- const inputValue = await input.getProperty( 'value' );
- expect( await inputValue.jsonValue() ).toBe( 'Meta Value' );
- } ) );
+ await Promise.all(
+ inputs.map( async ( input ) => {
+ // Clicking the input selects the block,
+ // and selecting the block enables the sync data mode
+ // as otherwise the asynchronous re-rendering of unselected blocks
+ // may cause the input to have not yet been updated for the other blocks
+ await input.click();
+ const inputValue = await input.getProperty( 'value' );
+ expect( await inputValue.jsonValue() ).toBe( 'Meta Value' );
+ } )
+ );
} );
it( 'Should persist the meta attribute properly in a different post type', async () => {
@@ -79,7 +83,9 @@ describe( 'Block with a meta attribute', () => {
await page.reload();
expect( await getEditedPostContent() ).toMatchSnapshot();
- const persistedValue = await page.evaluate( () => document.querySelector( '.my-meta-input' ).value );
+ const persistedValue = await page.evaluate(
+ () => document.querySelector( '.my-meta-input' ).value
+ );
expect( persistedValue ).toBe( 'Meta Value' );
} );
} );
diff --git a/packages/e2e-tests/specs/editor/plugins/meta-boxes.test.js b/packages/e2e-tests/specs/editor/plugins/meta-boxes.test.js
index 0a21dfe20d9d7..b7b13a4be08da 100644
--- a/packages/e2e-tests/specs/editor/plugins/meta-boxes.test.js
+++ b/packages/e2e-tests/specs/editor/plugins/meta-boxes.test.js
@@ -53,7 +53,9 @@ describe( 'Meta boxes', () => {
await publishPost();
// View the post.
- const viewPostLinks = await page.$x( "//a[contains(text(), 'View Post')]" );
+ const viewPostLinks = await page.$x(
+ "//a[contains(text(), 'View Post')]"
+ );
await viewPostLinks[ 0 ].click();
await page.waitForNavigation();
@@ -68,17 +70,17 @@ describe( 'Meta boxes', () => {
await publishPost();
// View the post.
- const viewPostLinks = await page.$x( "//a[contains(text(), 'View Post')]" );
+ const viewPostLinks = await page.$x(
+ "//a[contains(text(), 'View Post')]"
+ );
await viewPostLinks[ 0 ].click();
await page.waitForNavigation();
// Retrieve the excerpt used as meta
const metaExcerpt = await page.evaluate( () => {
- return document.querySelector(
- 'meta[property="gutenberg:hello"]'
- ).getAttribute(
- 'content'
- );
+ return document
+ .querySelector( 'meta[property="gutenberg:hello"]' )
+ .getAttribute( 'content' );
} );
expect( metaExcerpt ).toEqual( 'Excerpt from content.' );
@@ -91,29 +93,34 @@ describe( 'Meta boxes', () => {
// Open the excerpt panel
await openDocumentSettingsSidebar();
- const excerptButton = await findSidebarPanelToggleButtonWithTitle( 'Excerpt' );
+ const excerptButton = await findSidebarPanelToggleButtonWithTitle(
+ 'Excerpt'
+ );
if ( excerptButton ) {
await excerptButton.click( 'button' );
}
await page.waitForSelector( '.editor-post-excerpt textarea' );
- await page.type( '.editor-post-excerpt textarea', 'Explicitly set excerpt.' );
+ await page.type(
+ '.editor-post-excerpt textarea',
+ 'Explicitly set excerpt.'
+ );
await publishPost();
// View the post.
- const viewPostLinks = await page.$x( "//a[contains(text(), 'View Post')]" );
+ const viewPostLinks = await page.$x(
+ "//a[contains(text(), 'View Post')]"
+ );
await viewPostLinks[ 0 ].click();
await page.waitForNavigation();
// Retrieve the excerpt used as meta
const metaExcerpt = await page.evaluate( () => {
- return document.querySelector(
- 'meta[property="gutenberg:hello"]'
- ).getAttribute(
- 'content'
- );
+ return document
+ .querySelector( 'meta[property="gutenberg:hello"]' )
+ .getAttribute( 'content' );
} );
expect( metaExcerpt ).toEqual( 'Explicitly set excerpt.' );
diff --git a/packages/e2e-tests/specs/editor/plugins/plugins-api.test.js b/packages/e2e-tests/specs/editor/plugins/plugins-api.test.js
index fedf3f25503c4..627d3a7493f07 100644
--- a/packages/e2e-tests/specs/editor/plugins/plugins-api.test.js
+++ b/packages/e2e-tests/specs/editor/plugins/plugins-api.test.js
@@ -30,7 +30,10 @@ describe( 'Using Plugins API', () => {
it( 'Should render post status info inside Document Setting sidebar', async () => {
await openDocumentSettingsSidebar();
- const pluginPostStatusInfoText = await page.$eval( '.edit-post-post-status .my-post-status-info-plugin', ( el ) => el.innerText );
+ const pluginPostStatusInfoText = await page.$eval(
+ '.edit-post-post-status .my-post-status-info-plugin',
+ ( el ) => el.innerText
+ );
expect( pluginPostStatusInfoText ).toBe( 'My post status info' );
} );
} );
@@ -45,14 +48,20 @@ describe( 'Using Plugins API', () => {
it( 'Should render publish panel inside Pre-publish sidebar', async () => {
await openPublishPanel();
- const pluginPublishPanelText = await page.$eval( '.editor-post-publish-panel .my-publish-panel-plugin__pre', ( el ) => el.innerText );
+ const pluginPublishPanelText = await page.$eval(
+ '.editor-post-publish-panel .my-publish-panel-plugin__pre',
+ ( el ) => el.innerText
+ );
expect( pluginPublishPanelText ).toMatch( 'My pre publish panel' );
} );
it( 'Should render publish panel inside Post-publish sidebar', async () => {
await publishPost();
- const pluginPublishPanelText = await page.$eval( '.editor-post-publish-panel .my-publish-panel-plugin__post', ( el ) => el.innerText );
+ const pluginPublishPanelText = await page.$eval(
+ '.editor-post-publish-panel .my-publish-panel-plugin__post',
+ ( el ) => el.innerText
+ );
expect( pluginPublishPanelText ).toMatch( 'My post publish panel' );
} );
} );
@@ -61,7 +70,10 @@ describe( 'Using Plugins API', () => {
it( 'Should open plugins sidebar using More Menu item and render content', async () => {
await clickOnMoreMenuItem( 'Sidebar title plugin' );
- const pluginSidebarContent = await page.$eval( '.edit-post-sidebar', ( el ) => el.innerHTML );
+ const pluginSidebarContent = await page.$eval(
+ '.edit-post-sidebar',
+ ( el ) => el.innerHTML
+ );
expect( pluginSidebarContent ).toMatchSnapshot();
} );
@@ -89,7 +101,10 @@ describe( 'Using Plugins API', () => {
it( 'Should open plugins sidebar using More Menu item and render content', async () => {
await clickOnMoreMenuItem( 'Sidebar title plugin' );
- const pluginSidebarContent = await page.$eval( '.edit-post-sidebar', ( el ) => el.innerHTML );
+ const pluginSidebarContent = await page.$eval(
+ '.edit-post-sidebar',
+ ( el ) => el.innerHTML
+ );
expect( pluginSidebarContent ).toMatchSnapshot();
} );
} );
@@ -98,7 +113,10 @@ describe( 'Using Plugins API', () => {
describe( 'Document Setting Custom Panel', () => {
it( 'Should render a custom panel inside Document Setting sidebar', async () => {
await openDocumentSettingsSidebar();
- const pluginDocumentSettingsText = await page.$eval( '.edit-post-sidebar .my-document-setting-plugin', ( el ) => el.innerText );
+ const pluginDocumentSettingsText = await page.$eval(
+ '.edit-post-sidebar .my-document-setting-plugin',
+ ( el ) => el.innerText
+ );
expect( pluginDocumentSettingsText ).toMatchSnapshot();
} );
} );
diff --git a/packages/e2e-tests/specs/editor/plugins/templates.test.js b/packages/e2e-tests/specs/editor/plugins/templates.test.js
index 749842554fe66..a738ffae94da2 100644
--- a/packages/e2e-tests/specs/editor/plugins/templates.test.js
+++ b/packages/e2e-tests/specs/editor/plugins/templates.test.js
@@ -74,12 +74,16 @@ describe( 'templates', () => {
}
beforeAll( async () => {
- await activatePlugin( 'gutenberg-test-plugin-post-formats-support' );
+ await activatePlugin(
+ 'gutenberg-test-plugin-post-formats-support'
+ );
await setPostFormat( 'image' );
} );
afterAll( async () => {
await setPostFormat( STANDARD_FORMAT_VALUE );
- await deactivatePlugin( 'gutenberg-test-plugin-post-formats-support' );
+ await deactivatePlugin(
+ 'gutenberg-test-plugin-post-formats-support'
+ );
} );
it( 'should populate new post with default block for format', async () => {
diff --git a/packages/e2e-tests/specs/editor/various/__snapshots__/keyboard-navigable-blocks.test.js.snap b/packages/e2e-tests/specs/editor/various/__snapshots__/keyboard-navigable-blocks.test.js.snap
new file mode 100644
index 0000000000000..d619d310d5c29
--- /dev/null
+++ b/packages/e2e-tests/specs/editor/various/__snapshots__/keyboard-navigable-blocks.test.js.snap
@@ -0,0 +1,19 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Order of block keyboard navigation should navigate correctly with multi selection 1`] = `
+"
+1
+
+
+
+2
+
+
+
+3
+
+
+
+4
+"
+`;
diff --git a/packages/e2e-tests/specs/editor/various/__snapshots__/multi-block-selection.test.js.snap b/packages/e2e-tests/specs/editor/various/__snapshots__/multi-block-selection.test.js.snap
index 6e241261ff78e..c3bea88fa75fa 100644
--- a/packages/e2e-tests/specs/editor/various/__snapshots__/multi-block-selection.test.js.snap
+++ b/packages/e2e-tests/specs/editor/various/__snapshots__/multi-block-selection.test.js.snap
@@ -8,6 +8,16 @@ exports[`Multi-block selection should allow selecting outer edge if there is no
exports[`Multi-block selection should always expand single line selection 1`] = `""`;
+exports[`Multi-block selection should clear selection when clicking next to blocks 1`] = `
+"
+1
+
+
+
+2
+"
+`;
+
exports[`Multi-block selection should copy and paste 1`] = `
"
1
@@ -52,6 +62,26 @@ exports[`Multi-block selection should only trigger multi-selection when at the e
"
`;
+exports[`Multi-block selection should preserve dragged selection on move 1`] = `
+"
+2
+
+
+
+3
+
+
+
+1
+"
+`;
+
+exports[`Multi-block selection should return original focus after failed multi selection attempt 1`] = `
+"
+2
+"
+`;
+
exports[`Multi-block selection should use selection direction to determine vertical edge 1`] = `
"
1 2.
diff --git a/packages/e2e-tests/specs/editor/various/__snapshots__/writing-flow.test.js.snap b/packages/e2e-tests/specs/editor/various/__snapshots__/writing-flow.test.js.snap
index c6c4bf5e8528e..01dc6c0b68269 100644
--- a/packages/e2e-tests/specs/editor/various/__snapshots__/writing-flow.test.js.snap
+++ b/packages/e2e-tests/specs/editor/various/__snapshots__/writing-flow.test.js.snap
@@ -24,6 +24,16 @@ exports[`Writing Flow Should navigate inner blocks with arrow keys 1`] = `
"
`;
+exports[`Writing Flow should allow selecting entire list with longer last item 1`] = `
+"
+a
+
+
+
+
+"
+`;
+
exports[`Writing Flow should create valid paragraph blocks when rapidly pressing Enter 1`] = `
"
@@ -222,6 +232,26 @@ exports[`Writing Flow should not delete surrounding space when deleting a word w
"
`;
+exports[`Writing Flow should not have a dead zone between blocks (lower) 1`] = `
+"
+1
+
+
+
+23
+"
+`;
+
+exports[`Writing Flow should not have a dead zone between blocks (upper) 1`] = `
+"
+13
+
+
+
+2
+"
+`;
+
exports[`Writing Flow should not prematurely multi-select 1`] = `
"
1
diff --git a/packages/e2e-tests/specs/editor/various/a11y.test.js b/packages/e2e-tests/specs/editor/various/a11y.test.js
index 6f6cc960f204a..8f16e6a7ac636 100644
--- a/packages/e2e-tests/specs/editor/various/a11y.test.js
+++ b/packages/e2e-tests/specs/editor/various/a11y.test.js
@@ -1,10 +1,7 @@
/**
* WordPress dependencies
*/
-import {
- createNewPost,
- pressKeyWithModifier,
-} from '@wordpress/e2e-test-utils';
+import { createNewPost, pressKeyWithModifier } from '@wordpress/e2e-test-utils';
function isCloseButtonFocused() {
return page.$eval( ':focus', ( focusedElement ) => {
@@ -22,9 +19,14 @@ describe( 'a11y', () => {
await page.keyboard.press( 'Tab' );
- const isFocusedToggle = await page.$eval( ':focus', ( focusedElement ) => {
- return focusedElement.classList.contains( 'block-editor-inserter__toggle' );
- } );
+ const isFocusedToggle = await page.$eval(
+ ':focus',
+ ( focusedElement ) => {
+ return focusedElement.classList.contains(
+ 'editor-post-publish-button__button'
+ );
+ }
+ );
expect( isFocusedToggle ).toBe( true );
} );
diff --git a/packages/e2e-tests/specs/editor/various/adding-blocks.test.js b/packages/e2e-tests/specs/editor/various/adding-blocks.test.js
index c0e72c9dc6368..2434e54199091 100644
--- a/packages/e2e-tests/specs/editor/various/adding-blocks.test.js
+++ b/packages/e2e-tests/specs/editor/various/adding-blocks.test.js
@@ -26,7 +26,7 @@ describe( 'adding blocks', () => {
*/
async function clickAtBottom( elementHandle ) {
const box = await elementHandle.boundingBox();
- const x = box.x + ( box.width / 2 );
+ const x = box.x + box.width / 2;
const y = box.y + box.height - 50;
return page.mouse.click( x, y );
}
@@ -41,7 +41,9 @@ describe( 'adding blocks', () => {
await setBrowserViewport( { width: 960, height: 1400 } );
// Click below editor to focus last field (block appender)
- await clickAtBottom( await page.$( '.edit-post-editor-regions__content' ) );
+ await clickAtBottom(
+ await page.$( '.edit-post-editor-regions__content' )
+ );
expect( await page.$( '[data-type="core/paragraph"]' ) ).not.toBeNull();
await page.keyboard.type( 'Paragraph block' );
@@ -92,17 +94,26 @@ describe( 'adding blocks', () => {
await page.click( '.editor-post-title__input' );
// Using the between inserter
- const insertionPoint = await page.$( '[data-type="core/quote"] .block-editor-inserter__toggle' );
+ const insertionPoint = await page.$( '[data-type="core/quote"]' );
const rect = await insertionPoint.boundingBox();
- await page.mouse.move( rect.x + ( rect.width / 2 ), rect.y + ( rect.height / 2 ), { steps: 10 } );
- await page.waitForSelector( '[data-type="core/quote"] .block-editor-inserter__toggle' );
- await page.click( '[data-type="core/quote"] .block-editor-inserter__toggle' );
+ await page.mouse.move( rect.x + rect.width / 2, rect.y - 10, {
+ steps: 10,
+ } );
+ await page.waitForSelector(
+ '.block-editor-block-list__insertion-point .block-editor-inserter__toggle'
+ );
+ await page.click(
+ '.block-editor-block-list__insertion-point .block-editor-inserter__toggle'
+ );
// [TODO]: Search input should be focused immediately. It shouldn't be
// necessary to have `waitForFunction`.
- await page.waitForFunction( () => (
- document.activeElement &&
- document.activeElement.classList.contains( 'block-editor-inserter__search' )
- ) );
+ await page.waitForFunction(
+ () =>
+ document.activeElement &&
+ document.activeElement.classList.contains(
+ 'block-editor-inserter__search'
+ )
+ );
await page.keyboard.type( 'para' );
await pressKeyTimes( 'Tab', 3 );
await page.keyboard.press( 'Enter' );
@@ -117,38 +128,60 @@ describe( 'adding blocks', () => {
it( 'should not allow transfer of focus outside of the block-insertion menu once open', async () => {
// Enter the default block and click the inserter toggle button to the left of it.
await page.keyboard.press( 'ArrowDown' );
- await page.click( '.block-editor-block-list__empty-block-inserter .block-editor-inserter__toggle' );
+ await page.click(
+ '.block-editor-block-list__empty-block-inserter .block-editor-inserter__toggle'
+ );
// Expect the inserter search input to be the active element.
- let activeElementClassList = await page.evaluate( () => document.activeElement.classList );
- expect( Object.values( activeElementClassList ) ).toContain( 'block-editor-inserter__search' );
+ let activeElementClassList = await page.evaluate(
+ () => document.activeElement.classList
+ );
+ expect( Object.values( activeElementClassList ) ).toContain(
+ 'block-editor-inserter__search'
+ );
// Try using the up arrow key (vertical navigation triggers the issue described in #9583).
await page.keyboard.press( 'ArrowUp' );
// Expect the inserter search input to still be the active element.
- activeElementClassList = await page.evaluate( () => document.activeElement.classList );
- expect( Object.values( activeElementClassList ) ).toContain( 'block-editor-inserter__search' );
+ activeElementClassList = await page.evaluate(
+ () => document.activeElement.classList
+ );
+ expect( Object.values( activeElementClassList ) ).toContain(
+ 'block-editor-inserter__search'
+ );
// Tab to the block search results
await page.keyboard.press( 'Tab' );
// Expect the search results to be the active element.
- activeElementClassList = await page.evaluate( () => document.activeElement.classList );
- expect( Object.values( activeElementClassList ) ).toContain( 'block-editor-inserter__results' );
+ activeElementClassList = await page.evaluate(
+ () => document.activeElement.classList
+ );
+ expect( Object.values( activeElementClassList ) ).toContain(
+ 'block-editor-inserter__results'
+ );
// Try using the up arrow key
await page.keyboard.press( 'ArrowUp' );
// Expect the search results to still be the active element.
- activeElementClassList = await page.evaluate( () => document.activeElement.classList );
- expect( Object.values( activeElementClassList ) ).toContain( 'block-editor-inserter__results' );
+ activeElementClassList = await page.evaluate(
+ () => document.activeElement.classList
+ );
+ expect( Object.values( activeElementClassList ) ).toContain(
+ 'block-editor-inserter__results'
+ );
// Press escape to close the block inserter.
await page.keyboard.press( 'Escape' );
// Expect focus to have transferred back to the inserter toggle button.
- activeElementClassList = await page.evaluate( () => document.activeElement.classList );
- expect( Object.values( activeElementClassList ) ).toContain( 'block-editor-inserter__toggle' );
+ activeElementClassList = await page.evaluate(
+ () => document.activeElement.classList
+ );
+ expect( Object.values( activeElementClassList ) ).toContain(
+ 'block-editor-inserter__toggle'
+ );
} );
} );
diff --git a/packages/e2e-tests/specs/editor/various/adding-inline-tokens.test.js b/packages/e2e-tests/specs/editor/various/adding-inline-tokens.test.js
index b11077e70fb3d..0049bdd1d5c3f 100644
--- a/packages/e2e-tests/specs/editor/various/adding-inline-tokens.test.js
+++ b/packages/e2e-tests/specs/editor/various/adding-inline-tokens.test.js
@@ -33,20 +33,31 @@ describe( 'adding inline tokens', () => {
// Wait for media modal to appear and upload image.
await page.waitForSelector( '.media-modal input[type=file]' );
const inputElement = await page.$( '.media-modal input[type=file]' );
- const testImagePath = path.join( __dirname, '..', '..', '..', 'assets', '10x10_e2e_test_image_z9T8jK.png' );
+ const testImagePath = path.join(
+ __dirname,
+ '..',
+ '..',
+ '..',
+ 'assets',
+ '10x10_e2e_test_image_z9T8jK.png'
+ );
const filename = uuid();
const tmpFileName = path.join( os.tmpdir(), filename + '.png' );
fs.copyFileSync( testImagePath, tmpFileName );
await inputElement.uploadFile( tmpFileName );
// Wait for upload.
- await page.waitForSelector( `.media-modal li[aria-label="${ filename }"]` );
+ await page.waitForSelector(
+ `.media-modal li[aria-label="${ filename }"]`
+ );
// Insert the uploaded image.
await page.click( '.media-modal button.media-button-select' );
// Check the content.
- const regex = new RegExp( `\\s*a <\\/p>\\s*` );
+ const regex = new RegExp(
+ `\\s*
a <\\/p>\\s*`
+ );
expect( await getEditedPostContent() ).toMatch( regex );
} );
} );
diff --git a/packages/e2e-tests/specs/editor/various/autosave.test.js b/packages/e2e-tests/specs/editor/various/autosave.test.js
index 3c966f15a0748..a4f6d83b85eb8 100644
--- a/packages/e2e-tests/specs/editor/various/autosave.test.js
+++ b/packages/e2e-tests/specs/editor/various/autosave.test.js
@@ -14,8 +14,10 @@ import {
// Constant to override editor preference
const AUTOSAVE_INTERVAL_SECONDS = 5;
-const AUTOSAVE_NOTICE_REMOTE = 'There is an autosave of this post that is more recent than the version below.';
-const AUTOSAVE_NOTICE_LOCAL = 'The backup of this post in your browser is different from the version below.';
+const AUTOSAVE_NOTICE_REMOTE =
+ 'There is an autosave of this post that is more recent than the version below.';
+const AUTOSAVE_NOTICE_LOCAL =
+ 'The backup of this post in your browser is different from the version below.';
// Save and wait for "Saved" to confirm save complete. Preserves focus in the
// editing area.
@@ -47,14 +49,15 @@ async function readSessionStorageAutosave( postId ) {
}
async function getCurrentPostId() {
- return page.evaluate(
- () => window.wp.data.select( 'core/editor' ).getCurrentPostId()
+ return page.evaluate( () =>
+ window.wp.data.select( 'core/editor' ).getCurrentPostId()
);
}
async function setLocalAutosaveInterval( value ) {
return page.evaluate( ( _value ) => {
- window.wp.data.dispatch( 'core/edit-post' )
+ window.wp.data
+ .dispatch( 'core/edit-post' )
.__experimentalUpdateLocalAutosaveInterval( _value );
}, value );
}
@@ -95,7 +98,9 @@ describe( 'autosave', () => {
await sleep( 2 );
const newAutosave = await readSessionStorageAutosave( id );
- expect( JSON.parse( newAutosave ).content ).toBe( wrapParagraph( 'before save after save 123' ) );
+ expect( JSON.parse( newAutosave ).content ).toBe(
+ wrapParagraph( 'before save after save 123' )
+ );
} );
it( 'should recover from sessionStorage', async () => {
@@ -105,16 +110,27 @@ describe( 'autosave', () => {
await page.keyboard.type( ' after save' );
// Trigger local autosave
- await page.evaluate( () => window.wp.data.dispatch( 'core/editor' ).__experimentalLocalAutosave() );
+ await page.evaluate( () =>
+ window.wp.data
+ .dispatch( 'core/editor' )
+ .__experimentalLocalAutosave()
+ );
// Reload without saving on the server
await page.reload();
- const notice = await page.$eval( '.components-notice__content', ( element ) => element.innerText );
+ const notice = await page.$eval(
+ '.components-notice__content',
+ ( element ) => element.innerText
+ );
expect( notice ).toContain( AUTOSAVE_NOTICE_LOCAL );
- expect( await getEditedPostContent() ).toEqual( wrapParagraph( 'before save' ) );
+ expect( await getEditedPostContent() ).toEqual(
+ wrapParagraph( 'before save' )
+ );
await page.click( '.components-notice__action' );
- expect( await getEditedPostContent() ).toEqual( wrapParagraph( 'before save after save' ) );
+ expect( await getEditedPostContent() ).toEqual(
+ wrapParagraph( 'before save after save' )
+ );
} );
it( 'should clear sessionStorage upon user logout', async () => {
@@ -123,11 +139,21 @@ describe( 'autosave', () => {
await saveDraft();
// Fake local autosave
- await page.evaluate( ( postId ) => window.sessionStorage.setItem(
- `wp-autosave-block-editor-post-${ postId }`,
- JSON.stringify( { post_title: 'A', content: 'B', excerpt: 'C' } )
- ), await getCurrentPostId() );
- expect( await page.evaluate( () => window.sessionStorage.length ) ).toBe( 1 );
+ await page.evaluate(
+ ( postId ) =>
+ window.sessionStorage.setItem(
+ `wp-autosave-block-editor-post-${ postId }`,
+ JSON.stringify( {
+ post_title: 'A',
+ content: 'B',
+ excerpt: 'C',
+ } )
+ ),
+ await getCurrentPostId()
+ );
+ expect(
+ await page.evaluate( () => window.sessionStorage.length )
+ ).toBe( 1 );
await Promise.all( [
page.waitForSelector( '#wp-admin-bar-logout', { visible: true } ),
@@ -138,24 +164,41 @@ describe( 'autosave', () => {
page.click( '#wp-admin-bar-logout' ),
] );
- expect( await page.evaluate( () => window.sessionStorage.length ) ).toBe( 0 );
+ expect(
+ await page.evaluate( () => window.sessionStorage.length )
+ ).toBe( 0 );
} );
- it( 'shouldn\'t contaminate other posts', async () => {
+ it( "shouldn't contaminate other posts", async () => {
await clickBlockAppender();
await page.keyboard.type( 'before save' );
await saveDraft();
// Fake local autosave
- await page.evaluate( ( postId ) => window.sessionStorage.setItem(
- `wp-autosave-block-editor-post-${ postId }`,
- JSON.stringify( { post_title: 'A', content: 'B', excerpt: 'C' } )
- ), await getCurrentPostId() );
- expect( await page.evaluate( () => window.sessionStorage.length ) ).toBe( 1 );
+ await page.evaluate(
+ ( postId ) =>
+ window.sessionStorage.setItem(
+ `wp-autosave-block-editor-post-${ postId }`,
+ JSON.stringify( {
+ post_title: 'A',
+ content: 'B',
+ excerpt: 'C',
+ } )
+ ),
+ await getCurrentPostId()
+ );
+ expect(
+ await page.evaluate( () => window.sessionStorage.length )
+ ).toBe( 1 );
await page.reload();
- const notice = await page.$eval( '.components-notice__content', ( element ) => element.innerText );
- expect( notice ).toContain( 'The backup of this post in your browser is different from the version below.' );
+ const notice = await page.$eval(
+ '.components-notice__content',
+ ( element ) => element.innerText
+ );
+ expect( notice ).toContain(
+ 'The backup of this post in your browser is different from the version below.'
+ );
await createNewPost();
expect( await page.$( '.components-notice__content' ) ).toBe( null );
@@ -169,15 +212,25 @@ describe( 'autosave', () => {
await page.keyboard.type( ' after save' );
// Trigger local autosave
- await page.evaluate( () => window.wp.data.dispatch( 'core/editor' ).__experimentalLocalAutosave() );
- expect( await page.evaluate( () => window.sessionStorage.length ) ).toBe( 1 );
+ await page.evaluate( () =>
+ window.wp.data
+ .dispatch( 'core/editor' )
+ .__experimentalLocalAutosave()
+ );
+ expect(
+ await page.evaluate( () => window.sessionStorage.length )
+ ).toBe( 1 );
// Trigger remote autosave
- await page.evaluate( () => window.wp.data.dispatch( 'core/editor' ).autosave() );
- expect( await page.evaluate( () => window.sessionStorage.length ) ).toBe( 0 );
+ await page.evaluate( () =>
+ window.wp.data.dispatch( 'core/editor' ).autosave()
+ );
+ expect(
+ await page.evaluate( () => window.sessionStorage.length )
+ ).toBe( 0 );
} );
- it( 'shouldn\'t clear local autosave if remote autosave fails', async () => {
+ it( "shouldn't clear local autosave if remote autosave fails", async () => {
// Edit, save draft, edit again
await clickBlockAppender();
await page.keyboard.type( 'before save' );
@@ -185,13 +238,23 @@ describe( 'autosave', () => {
await page.keyboard.type( ' after save' );
// Trigger local autosave
- await page.evaluate( () => window.wp.data.dispatch( 'core/editor' ).__experimentalLocalAutosave() );
- expect( await page.evaluate( () => window.sessionStorage.length ) ).toBe( 1 );
+ await page.evaluate( () =>
+ window.wp.data
+ .dispatch( 'core/editor' )
+ .__experimentalLocalAutosave()
+ );
+ expect(
+ await page.evaluate( () => window.sessionStorage.length )
+ ).toBe( 1 );
// Bring network down and attempt to autosave remotely
toggleOfflineMode( true );
- await page.evaluate( () => window.wp.data.dispatch( 'core/editor' ).autosave() );
- expect( await page.evaluate( () => window.sessionStorage.length ) ).toBe( 1 );
+ await page.evaluate( () =>
+ window.wp.data.dispatch( 'core/editor' ).autosave()
+ );
+ expect(
+ await page.evaluate( () => window.sessionStorage.length )
+ ).toBe( 1 );
} );
it( 'should clear local autosave after successful save', async () => {
@@ -202,14 +265,22 @@ describe( 'autosave', () => {
await page.keyboard.type( ' after save' );
// Trigger local autosave
- await page.evaluate( () => window.wp.data.dispatch( 'core/editor' ).__experimentalLocalAutosave() );
- expect( await page.evaluate( () => window.sessionStorage.length ) ).toBe( 1 );
+ await page.evaluate( () =>
+ window.wp.data
+ .dispatch( 'core/editor' )
+ .__experimentalLocalAutosave()
+ );
+ expect(
+ await page.evaluate( () => window.sessionStorage.length )
+ ).toBe( 1 );
await saveDraftWithKeyboard();
- expect( await page.evaluate( () => window.sessionStorage.length ) ).toBe( 0 );
+ expect(
+ await page.evaluate( () => window.sessionStorage.length )
+ ).toBe( 0 );
} );
- it( 'shouldn\'t clear local autosave if save fails', async () => {
+ it( "shouldn't clear local autosave if save fails", async () => {
// Edit, save draft, edit again
await clickBlockAppender();
await page.keyboard.type( 'before save' );
@@ -217,16 +288,24 @@ describe( 'autosave', () => {
await page.keyboard.type( ' after save' );
// Trigger local autosave
- await page.evaluate( () => window.wp.data.dispatch( 'core/editor' ).__experimentalLocalAutosave() );
- expect( await page.evaluate( () => window.sessionStorage.length ) ).toBe( 1 );
+ await page.evaluate( () =>
+ window.wp.data
+ .dispatch( 'core/editor' )
+ .__experimentalLocalAutosave()
+ );
+ expect(
+ await page.evaluate( () => window.sessionStorage.length )
+ ).toBe( 1 );
// Bring network down and attempt to save
toggleOfflineMode( true );
saveDraftWithKeyboard();
- expect( await page.evaluate( () => window.sessionStorage.length ) ).toBe( 1 );
+ expect(
+ await page.evaluate( () => window.sessionStorage.length )
+ ).toBe( 1 );
} );
- it( 'shouldn\'t conflict with server-side autosave', async () => {
+ it( "shouldn't conflict with server-side autosave", async () => {
await clickBlockAppender();
await page.keyboard.type( 'before publish' );
await publishPost();
@@ -235,11 +314,19 @@ describe( 'autosave', () => {
await page.keyboard.type( ' after publish' );
// Trigger remote autosave
- await page.evaluate( () => window.wp.data.dispatch( 'core/editor' ).autosave() );
+ await page.evaluate( () =>
+ window.wp.data.dispatch( 'core/editor' ).autosave()
+ );
// Force conflicting local autosave
- await page.evaluate( () => window.wp.data.dispatch( 'core/editor' ).__experimentalLocalAutosave() );
- expect( await page.evaluate( () => window.sessionStorage.length ) ).toBe( 1 );
+ await page.evaluate( () =>
+ window.wp.data
+ .dispatch( 'core/editor' )
+ .__experimentalLocalAutosave()
+ );
+ expect(
+ await page.evaluate( () => window.sessionStorage.length )
+ ).toBe( 1 );
await page.reload();
@@ -249,7 +336,11 @@ describe( 'autosave', () => {
// unrelated to *local* autosave, until we can understand them, we'll
// drop this test's expectations if we don't have an autosave object
// available.
- const stillHasRemoteAutosave = await page.evaluate( () => window.wp.data.select( 'core/editor' ).getEditorSettings().autosave );
+ const stillHasRemoteAutosave = await page.evaluate(
+ () =>
+ window.wp.data.select( 'core/editor' ).getEditorSettings()
+ .autosave
+ );
if ( ! stillHasRemoteAutosave ) {
return;
}
@@ -257,7 +348,10 @@ describe( 'autosave', () => {
// Only one autosave notice should be displayed.
const notices = await page.$$( '.components-notice' );
expect( notices.length ).toBe( 1 );
- const notice = await page.$eval( '.components-notice__content', ( element ) => element.innerText );
+ const notice = await page.$eval(
+ '.components-notice__content',
+ ( element ) => element.innerText
+ );
expect( notice ).toContain( AUTOSAVE_NOTICE_REMOTE );
} );
diff --git a/packages/e2e-tests/specs/editor/various/block-deletion.test.js b/packages/e2e-tests/specs/editor/various/block-deletion.test.js
index a231977ed171a..00027d94137cf 100644
--- a/packages/e2e-tests/specs/editor/various/block-deletion.test.js
+++ b/packages/e2e-tests/specs/editor/various/block-deletion.test.js
@@ -35,7 +35,10 @@ const clickOnBlockSettingsMenuRemoveBlockButton = async () => {
let isRemoveButton = false;
- let numButtons = await page.$$eval( '.block-editor-block-settings-menu__content button', ( btns ) => btns.length );
+ let numButtons = await page.$$eval(
+ '.block-editor-block-settings-menu__content button',
+ ( btns ) => btns.length
+ );
// Limit by the number of buttons available
while ( --numButtons ) {
@@ -112,7 +115,9 @@ describe( 'block deletion -', () => {
await page.click( '.editor-post-title' );
// Click on the image block so that its wrapper is selected and backspace to delete it.
- await page.click( '.wp-block[data-type="core/image"] .components-placeholder__label' );
+ await page.click(
+ '.wp-block[data-type="core/image"] .components-placeholder__label'
+ );
await page.keyboard.press( 'Backspace' );
expect( await getEditedPostContent() ).toMatchSnapshot();
@@ -159,7 +164,9 @@ describe( 'deleting all blocks', () => {
await clickOnBlockSettingsMenuRemoveBlockButton();
// There is a default block:
- expect( await page.$$( '.block-editor-block-list__block' ) ).toHaveLength( 1 );
+ expect(
+ await page.$$( '.block-editor-block-list__block' )
+ ).toHaveLength( 1 );
// But the effective saved content is still empty:
expect( await getEditedPostContent() ).toBe( '' );
@@ -179,8 +186,12 @@ describe( 'deleting all blocks', () => {
// configured to not allow the default (paragraph) block type, either
// by plugin editor settings filtering or user block preferences.
await page.evaluate( () => {
- const defaultBlockName = wp.data.select( 'core/blocks' ).getDefaultBlockName();
- wp.data.dispatch( 'core/blocks' ).removeBlockTypes( defaultBlockName );
+ const defaultBlockName = wp.data
+ .select( 'core/blocks' )
+ .getDefaultBlockName();
+ wp.data
+ .dispatch( 'core/blocks' )
+ .removeBlockTypes( defaultBlockName );
} );
// Add and remove a block.
@@ -191,7 +202,9 @@ describe( 'deleting all blocks', () => {
// TODO: There should be expectations around where focus is placed in
// this scenario. Currently, a focus loss occurs (not acceptable).
const selectedBlocksCount = await page.evaluate( () => {
- return wp.data.select( 'core/block-editor' ).getSelectedBlockClientIds().length;
+ return wp.data
+ .select( 'core/block-editor' )
+ .getSelectedBlockClientIds().length;
} );
expect( selectedBlocksCount ).toBe( 0 );
diff --git a/packages/e2e-tests/specs/editor/various/block-grouping.test.js b/packages/e2e-tests/specs/editor/various/block-grouping.test.js
index 8d12894a6b311..01a5c38def41a 100644
--- a/packages/e2e-tests/specs/editor/various/block-grouping.test.js
+++ b/packages/e2e-tests/specs/editor/various/block-grouping.test.js
@@ -78,7 +78,9 @@ describe( 'Block Grouping', () => {
await clickBlockToolbarButton( 'More options' );
- const groupButton = await page.waitForXPath( '//button[text()="Group"]' );
+ const groupButton = await page.waitForXPath(
+ '//button[text()="Group"]'
+ );
await groupButton.click();
expect( await getEditedPostContent() ).toMatchSnapshot();
@@ -92,14 +94,18 @@ describe( 'Block Grouping', () => {
// Group
await clickBlockToolbarButton( 'More options' );
- const groupButton = await page.waitForXPath( '//button[text()="Group"]' );
+ const groupButton = await page.waitForXPath(
+ '//button[text()="Group"]'
+ );
await groupButton.click();
expect( await getEditedPostContent() ).toMatchSnapshot();
// UnGroup
await clickBlockToolbarButton( 'More options' );
- const unGroupButton = await page.waitForXPath( '//button[text()="Ungroup"]' );
+ const unGroupButton = await page.waitForXPath(
+ '//button[text()="Ungroup"]'
+ );
await unGroupButton.click();
expect( await getEditedPostContent() ).toMatchSnapshot();
@@ -108,7 +114,9 @@ describe( 'Block Grouping', () => {
it( 'does not allow ungrouping a group block that has no children', async () => {
await insertBlock( 'Group' );
await clickBlockToolbarButton( 'More options' );
- const ungroupButtons = await page.$x( '//button[text()="Ungroup"]' );
+ const ungroupButtons = await page.$x(
+ '//button[text()="Ungroup"]'
+ );
expect( ungroupButtons ).toHaveLength( 0 );
} );
} );
@@ -138,15 +146,18 @@ describe( 'Block Grouping', () => {
it( 'does not show group transform if Grouping block is disabled', async () => {
const availableTransforms = await getAvailableBlockTransforms();
- expect(
- availableTransforms
- ).not.toContain( 'Group' );
+ expect( availableTransforms ).not.toContain( 'Group' );
} );
it( 'does not show group option in the options toolbar if Grouping block is disabled ', async () => {
await clickBlockToolbarButton( 'More options' );
- const blockOptionsDropdownHTML = await page.evaluate( () => document.querySelector( '.block-editor-block-settings-menu__popover' ).innerHTML );
+ const blockOptionsDropdownHTML = await page.evaluate(
+ () =>
+ document.querySelector(
+ '.block-editor-block-settings-menu__popover'
+ ).innerHTML
+ );
expect( blockOptionsDropdownHTML ).not.toContain( 'Group' );
} );
@@ -160,12 +171,14 @@ describe( 'Block Grouping', () => {
// Full width image.
await insertBlock( 'Image' );
await clickBlockToolbarButton( 'Change alignment' );
- await page.click( '.components-dropdown-menu__menu button svg.dashicons-align-full-width' );
+ const FULL_WIDTH_BUTTON_XPATH = `//button[contains(@class,'components-dropdown-menu__menu-item') and contains(text(), 'Full width')]`;
+ await ( await page.$x( FULL_WIDTH_BUTTON_XPATH ) )[ 0 ].click();
// Wide width image.
await insertBlock( 'Image' );
await clickBlockToolbarButton( 'Change alignment' );
- await page.click( '.components-dropdown-menu__menu button svg.dashicons-align-wide' );
+ const WIDE_BUTTON_XPATH = `//button[contains(@class,'components-dropdown-menu__menu-item') and contains(text(), 'Wide width')]`;
+ await ( await page.$x( WIDE_BUTTON_XPATH ) )[ 0 ].click();
await insertBlock( 'Paragraph' );
await page.keyboard.type( 'Some paragraph' );
@@ -197,7 +210,9 @@ describe( 'Block Grouping', () => {
it( 'should use registered grouping block for grouping interactions', async () => {
// Set custom Block as the Block to use for Grouping
await page.evaluate( () => {
- window.wp.blocks.setGroupingBlockName( 'test/alternative-group-block' );
+ window.wp.blocks.setGroupingBlockName(
+ 'test/alternative-group-block'
+ );
} );
// Creating test blocks
@@ -211,7 +226,9 @@ describe( 'Block Grouping', () => {
// as opposed to "transformTo()" which uses whatever is passed to it. To
// ensure this test is meaningful we must rely on what is registered.
await clickBlockToolbarButton( 'More options' );
- const groupButton = await page.waitForXPath( '//button[text()="Group"]' );
+ const groupButton = await page.waitForXPath(
+ '//button[text()="Group"]'
+ );
await groupButton.click();
expect( await getEditedPostContent() ).toMatchSnapshot();
diff --git a/packages/e2e-tests/specs/editor/various/block-hierarchy-navigation.test.js b/packages/e2e-tests/specs/editor/various/block-hierarchy-navigation.test.js
index 77fe92cbb0db3..643998905e00e 100644
--- a/packages/e2e-tests/specs/editor/various/block-hierarchy-navigation.test.js
+++ b/packages/e2e-tests/specs/editor/various/block-hierarchy-navigation.test.js
@@ -11,7 +11,9 @@ import {
async function openBlockNavigator() {
await pressKeyWithModifier( 'access', 'o' );
- await page.waitForSelector( '.block-editor-block-navigation__item-button.is-selected' );
+ await page.waitForSelector(
+ '.block-editor-block-navigation__item-button.is-selected'
+ );
}
describe( 'Navigating the block hierarchy', () => {
@@ -33,11 +35,17 @@ describe( 'Navigating the block hierarchy', () => {
// Navigate to the columns blocks.
await page.click( '[aria-label="Block navigation"]' );
- const columnsBlockMenuItem = ( await page.$x( "//button[contains(@class,'block-editor-block-navigation__item') and contains(text(), 'Columns')]" ) )[ 0 ];
+ const columnsBlockMenuItem = (
+ await page.$x(
+ "//button[contains(@class,'block-editor-block-navigation__item') and contains(text(), 'Columns')]"
+ )
+ )[ 0 ];
await columnsBlockMenuItem.click();
// Tweak the columns count.
- await page.focus( '.block-editor-block-inspector .components-range-control__number[aria-label="Columns"]' );
+ await page.focus(
+ '.block-editor-block-inspector .components-range-control__number[aria-label="Columns"]'
+ );
await page.keyboard.down( 'Shift' );
await page.keyboard.press( 'ArrowLeft' );
await page.keyboard.up( 'Shift' );
@@ -45,9 +53,11 @@ describe( 'Navigating the block hierarchy', () => {
// Navigate to the last column block.
await page.click( '[aria-label="Block navigation"]' );
- const lastColumnsBlockMenuItem = ( await page.$x(
- "//button[contains(@class,'block-editor-block-navigation__item') and contains(text(), 'Column')]"
- ) )[ 3 ];
+ const lastColumnsBlockMenuItem = (
+ await page.$x(
+ "//button[contains(@class,'block-editor-block-navigation__item') and contains(text(), 'Column')]"
+ )
+ )[ 3 ];
await lastColumnsBlockMenuItem.click();
// Insert text in the last column block.
@@ -81,7 +91,6 @@ describe( 'Navigating the block hierarchy', () => {
await pressKeyWithModifier( 'ctrl', '`' );
await pressKeyWithModifier( 'ctrl', '`' );
await pressKeyWithModifier( 'ctrl', '`' );
- await pressKeyWithModifier( 'ctrl', '`' );
await pressKeyTimes( 'Tab', 4 );
// Tweak the columns count by increasing it by one.
diff --git a/packages/e2e-tests/specs/editor/various/block-switcher.test.js b/packages/e2e-tests/specs/editor/various/block-switcher.test.js
index 9282e83dc855f..12c4044219516 100644
--- a/packages/e2e-tests/specs/editor/various/block-switcher.test.js
+++ b/packages/e2e-tests/specs/editor/various/block-switcher.test.js
@@ -24,9 +24,7 @@ describe( 'adding blocks', () => {
expect( await hasBlockSwitcher() ).toBeTruthy();
// Verify the correct block transforms appear.
- expect(
- await getAvailableBlockTransforms()
- ).toEqual( [
+ expect( await getAvailableBlockTransforms() ).toEqual( [
'Group',
'Paragraph',
'Quote',
@@ -48,9 +46,7 @@ describe( 'adding blocks', () => {
expect( await hasBlockSwitcher() ).toBeTruthy();
// Verify the correct block transforms appear.
- expect(
- await getAvailableBlockTransforms()
- ).toEqual( [
+ expect( await getAvailableBlockTransforms() ).toEqual( [
'Group',
'Paragraph',
] );
@@ -59,11 +55,9 @@ describe( 'adding blocks', () => {
it( 'Should not show the block switcher if all the blocks the list block transforms into are removed', async () => {
// Remove the paragraph and quote block from the list of registered blocks.
await page.evaluate( () => {
- ( [
- 'core/quote',
- 'core/paragraph',
- 'core/group',
- ] ).map( ( block ) => wp.blocks.unregisterBlockType( block ) );
+ [ 'core/quote', 'core/paragraph', 'core/group' ].map( ( block ) =>
+ wp.blocks.unregisterBlockType( block )
+ );
} );
// Insert a list block.
@@ -74,8 +68,6 @@ describe( 'adding blocks', () => {
// Verify the block switcher exists.
expect( await hasBlockSwitcher() ).toBeFalsy();
// Verify the correct block transforms appear.
- expect(
- await getAvailableBlockTransforms()
- ).toHaveLength( 0 );
+ expect( await getAvailableBlockTransforms() ).toHaveLength( 0 );
} );
} );
diff --git a/packages/e2e-tests/specs/editor/various/change-detection.test.js b/packages/e2e-tests/specs/editor/various/change-detection.test.js
index 4f5cb5822fa7f..514a7fdd106f1 100644
--- a/packages/e2e-tests/specs/editor/various/change-detection.test.js
+++ b/packages/e2e-tests/specs/editor/various/change-detection.test.js
@@ -81,7 +81,9 @@ describe( 'Change detection', () => {
// Force autosave to occur immediately.
await Promise.all( [
- page.evaluate( () => window.wp.data.dispatch( 'core/editor' ).autosave() ),
+ page.evaluate( () =>
+ window.wp.data.dispatch( 'core/editor' ).autosave()
+ ),
page.waitForSelector( '.editor-post-saved-state.is-autosaving' ),
page.waitForSelector( '.editor-post-saved-state.is-saved' ),
] );
@@ -96,12 +98,16 @@ describe( 'Change detection', () => {
// Toggle post as needing review (not persisted for autosave).
await ensureSidebarOpened();
- const postPendingReviewButton = ( await page.$x( "//label[contains(text(), 'Pending review')]" ) )[ 0 ];
+ const postPendingReviewButton = (
+ await page.$x( "//label[contains(text(), 'Pending review')]" )
+ )[ 0 ];
await postPendingReviewButton.click( 'button' );
// Force autosave to occur immediately.
await Promise.all( [
- page.evaluate( () => window.wp.data.dispatch( 'core/editor' ).autosave() ),
+ page.evaluate( () =>
+ window.wp.data.dispatch( 'core/editor' ).autosave()
+ ),
page.waitForSelector( '.editor-post-saved-state.is-autosaving' ),
page.waitForSelector( '.editor-post-saved-state.is-saved' ),
] );
@@ -116,7 +122,9 @@ describe( 'Change detection', () => {
// Close publish panel.
await Promise.all( [
- page.waitForFunction( () => ! document.querySelector( '.editor-post-publish-panel' ) ),
+ page.waitForFunction(
+ () => ! document.querySelector( '.editor-post-publish-panel' )
+ ),
page.click( '.editor-post-publish-panel__header button' ),
] );
@@ -125,8 +133,12 @@ describe( 'Change detection', () => {
await Promise.all( [
page.waitForSelector( '.editor-post-publish-button.is-busy' ),
- page.waitForSelector( '.editor-post-publish-button:not( .is-busy )' ),
- page.evaluate( () => window.wp.data.dispatch( 'core/editor' ).autosave() ),
+ page.waitForSelector(
+ '.editor-post-publish-button:not( .is-busy )'
+ ),
+ page.evaluate( () =>
+ window.wp.data.dispatch( 'core/editor' ).autosave()
+ ),
] );
await assertIsDirty( true );
@@ -210,7 +222,9 @@ describe( 'Change detection', () => {
await assertIsDirty( true );
- expect( console ).toHaveErroredWith( 'Failed to load resource: net::ERR_INTERNET_DISCONNECTED' );
+ expect( console ).toHaveErroredWith(
+ 'Failed to load resource: net::ERR_INTERNET_DISCONNECTED'
+ );
} );
it( 'Should prompt if changes and save is in-flight', async () => {
@@ -304,7 +318,11 @@ describe( 'Change detection', () => {
// long as the experimental reusable blocks fetching data flow exists.
//
// See: https://github.com/WordPress/gutenberg/issues/14766
- await page.evaluate( () => window.wp.data.dispatch( 'core/editor' ).__experimentalReceiveReusableBlocks( [] ) );
+ await page.evaluate( () =>
+ window.wp.data
+ .dispatch( 'core/editor' )
+ .__experimentalReceiveReusableBlocks( [] )
+ );
await assertIsDirty( false );
} );
@@ -334,8 +352,8 @@ describe( 'Change detection', () => {
// Save
await saveDraft();
- const postId = await page.evaluate(
- () => window.wp.data.select( 'core/editor' ).getCurrentPostId()
+ const postId = await page.evaluate( () =>
+ window.wp.data.select( 'core/editor' ).getCurrentPostId()
);
// Trash post.
@@ -350,7 +368,12 @@ describe( 'Change detection', () => {
await page.waitForNavigation(),
] );
- expect( isCurrentURL( '/wp-admin/edit.php', `post_type=post&ids=${ postId }` ) ).toBe( true );
+ expect(
+ isCurrentURL(
+ '/wp-admin/edit.php',
+ `post_type=post&ids=${ postId }`
+ )
+ ).toBe( true );
} );
it( 'consecutive edits to the same attribute should mark the post as dirty after a save', async () => {
@@ -371,7 +394,9 @@ describe( 'Change detection', () => {
// Increase the paragraph's font size.
await page.click( '[data-type="core/paragraph"]' );
await page.click( '.components-font-size-picker__select' );
- await page.click( '.components-custom-select-control__item:nth-child(3)' );
+ await page.click(
+ '.components-custom-select-control__item:nth-child(3)'
+ );
await page.click( '[data-type="core/paragraph"]' );
// Check that the post is dirty.
@@ -386,7 +411,9 @@ describe( 'Change detection', () => {
// Increase the paragraph's font size again.
await page.click( '[data-type="core/paragraph"]' );
await page.click( '.components-font-size-picker__select' );
- await page.click( '.components-custom-select-control__item:nth-child(4)' );
+ await page.click(
+ '.components-custom-select-control__item:nth-child(4)'
+ );
await page.click( '[data-type="core/paragraph"]' );
// Check that the post is dirty.
diff --git a/packages/e2e-tests/specs/editor/various/compatibility-classic-editor.test.js b/packages/e2e-tests/specs/editor/various/compatibility-classic-editor.test.js
index 9b311275b7296..eeffbd3c5f533 100644
--- a/packages/e2e-tests/specs/editor/various/compatibility-classic-editor.test.js
+++ b/packages/e2e-tests/specs/editor/various/compatibility-classic-editor.test.js
@@ -1,7 +1,11 @@
/**
* WordPress dependencies
*/
-import { createNewPost, insertBlock, publishPost } from '@wordpress/e2e-test-utils';
+import {
+ createNewPost,
+ insertBlock,
+ publishPost,
+} from '@wordpress/e2e-test-utils';
describe( 'Compatibility with classic editor', () => {
beforeEach( async () => {
@@ -18,13 +22,17 @@ describe( 'Compatibility with classic editor', () => {
await publishPost();
// View the post.
- const viewPostLinks = await page.$x( "//a[contains(text(), 'View Post')]" );
+ const viewPostLinks = await page.$x(
+ "//a[contains(text(), 'View Post')]"
+ );
await viewPostLinks[ 0 ].click();
await page.waitForNavigation();
// Check the the content doesn't contain
tags
await page.waitForSelector( '.entry-content' );
- const content = await page.$eval( '.entry-content', ( element ) => element.innerHTML.trim() );
+ const content = await page.$eval( '.entry-content', ( element ) =>
+ element.innerHTML.trim()
+ );
expect( content ).toMatchSnapshot();
} );
} );
diff --git a/packages/e2e-tests/specs/editor/various/datepicker.test.js b/packages/e2e-tests/specs/editor/various/datepicker.test.js
index e3ce2540d39f2..dc7e8982f17f8 100644
--- a/packages/e2e-tests/specs/editor/various/datepicker.test.js
+++ b/packages/e2e-tests/specs/editor/various/datepicker.test.js
@@ -33,7 +33,9 @@ describe( 'Datepicker', () => {
( dateLabel ) => dateLabel.textContent
);
- expect( publishingDate ).toMatch( /[A-Za-z]{3} \d{1,2}, \d{4} \d{1,2}:\d{2} [ap]m/ );
+ expect( publishingDate ).toMatch(
+ /[A-Za-z]{3} \d{1,2}, \d{4} \d{1,2}:\d{2} [ap]m/
+ );
} );
it( 'should show the publishing date if the date is in the future', async () => {
@@ -54,6 +56,8 @@ describe( 'Datepicker', () => {
expect( publishingDate ).not.toEqual( 'Immediately' );
// The expected date format will be "Sep 26, 2018 11:52 pm".
- expect( publishingDate ).toMatch( /[A-Za-z]{3} \d{1,2}, \d{4} \d{1,2}:\d{2} [ap]m/ );
+ expect( publishingDate ).toMatch(
+ /[A-Za-z]{3} \d{1,2}, \d{4} \d{1,2}:\d{2} [ap]m/
+ );
} );
} );
diff --git a/packages/e2e-tests/specs/editor/various/editor-modes.test.js b/packages/e2e-tests/specs/editor/various/editor-modes.test.js
index 3a002a2d1f25d..f77d25592d35d 100644
--- a/packages/e2e-tests/specs/editor/various/editor-modes.test.js
+++ b/packages/e2e-tests/specs/editor/various/editor-modes.test.js
@@ -17,7 +17,9 @@ describe( 'Editing modes (visual/HTML)', () => {
it( 'should switch between visual and HTML modes', async () => {
// This block should be in "visual" mode by default.
- let visualBlock = await page.$$( '.block-editor-block-list__layout .block-editor-block-list__block .rich-text' );
+ let visualBlock = await page.$$(
+ '.block-editor-block-list__layout .block-editor-block-list__block .rich-text'
+ );
expect( visualBlock ).toHaveLength( 1 );
// Move the mouse to show the block toolbar
@@ -26,11 +28,15 @@ describe( 'Editing modes (visual/HTML)', () => {
// Change editing mode from "Visual" to "HTML".
await clickBlockToolbarButton( 'More options' );
- let changeModeButton = await page.waitForXPath( '//button[text()="Edit as HTML"]' );
+ let changeModeButton = await page.waitForXPath(
+ '//button[text()="Edit as HTML"]'
+ );
await changeModeButton.click();
// Wait for the block to be converted to HTML editing mode.
- const htmlBlock = await page.$$( '.block-editor-block-list__layout .block-editor-block-list__block .block-editor-block-list__block-html-textarea' );
+ const htmlBlock = await page.$$(
+ '.block-editor-block-list__layout .block-editor-block-list__block .block-editor-block-list__block-html-textarea'
+ );
expect( htmlBlock ).toHaveLength( 1 );
// Move the mouse to show the block toolbar
@@ -39,11 +45,15 @@ describe( 'Editing modes (visual/HTML)', () => {
// Change editing mode from "HTML" back to "Visual".
await clickBlockToolbarButton( 'More options' );
- changeModeButton = await page.waitForXPath( '//button[text()="Edit visually"]' );
+ changeModeButton = await page.waitForXPath(
+ '//button[text()="Edit visually"]'
+ );
await changeModeButton.click();
// This block should be in "visual" mode by default.
- visualBlock = await page.$$( '.block-editor-block-list__layout .block-editor-block-list__block .rich-text' );
+ visualBlock = await page.$$(
+ '.block-editor-block-list__layout .block-editor-block-list__block .rich-text'
+ );
expect( visualBlock ).toHaveLength( 1 );
} );
@@ -54,12 +64,16 @@ describe( 'Editing modes (visual/HTML)', () => {
// Change editing mode from "Visual" to "HTML".
await clickBlockToolbarButton( 'More options' );
- const changeModeButton = await page.waitForXPath( '//button[text()="Edit as HTML"]' );
+ const changeModeButton = await page.waitForXPath(
+ '//button[text()="Edit as HTML"]'
+ );
await changeModeButton.click();
// The font size picker for the paragraph block should appear, even in
// HTML editing mode.
- const fontSizePicker = await page.$$( '.edit-post-sidebar .components-font-size-picker__controls' );
+ const fontSizePicker = await page.$$(
+ '.edit-post-sidebar .components-font-size-picker__controls'
+ );
expect( fontSizePicker ).toHaveLength( 1 );
} );
@@ -70,20 +84,32 @@ describe( 'Editing modes (visual/HTML)', () => {
// Change editing mode from "Visual" to "HTML".
await clickBlockToolbarButton( 'More options' );
- const changeModeButton = await page.waitForXPath( '//button[text()="Edit as HTML"]' );
+ const changeModeButton = await page.waitForXPath(
+ '//button[text()="Edit as HTML"]'
+ );
await changeModeButton.click();
// Make sure the paragraph content is rendered as expected.
- let htmlBlockContent = await page.$eval( '.block-editor-block-list__layout .block-editor-block-list__block .block-editor-block-list__block-html-textarea', ( node ) => node.textContent );
+ let htmlBlockContent = await page.$eval(
+ '.block-editor-block-list__layout .block-editor-block-list__block .block-editor-block-list__block-html-textarea',
+ ( node ) => node.textContent
+ );
expect( htmlBlockContent ).toEqual( '
Hello world!
' );
// Change the font size using the sidebar.
await page.click( '.components-font-size-picker__select' );
- await page.click( '.components-custom-select-control__item:nth-child(5)' );
+ await page.click(
+ '.components-custom-select-control__item:nth-child(5)'
+ );
// Make sure the HTML content updated.
- htmlBlockContent = await page.$eval( '.block-editor-block-list__layout .block-editor-block-list__block .block-editor-block-list__block-html-textarea', ( node ) => node.textContent );
- expect( htmlBlockContent ).toEqual( 'Hello world!
' );
+ htmlBlockContent = await page.$eval(
+ '.block-editor-block-list__layout .block-editor-block-list__block .block-editor-block-list__block-html-textarea',
+ ( node ) => node.textContent
+ );
+ expect( htmlBlockContent ).toEqual(
+ 'Hello world!
'
+ );
} );
it( 'the code editor should unselect blocks and disable the inserter', async () => {
@@ -95,22 +121,30 @@ describe( 'Editing modes (visual/HTML)', () => {
expect( title ).toBe( 'Paragraph' );
// The Block inspector should be active
- let blockInspectorTab = await page.$( '.edit-post-sidebar__panel-tab.is-active[data-label="Block"]' );
+ let blockInspectorTab = await page.$(
+ '.edit-post-sidebar__panel-tab.is-active[data-label="Block"]'
+ );
expect( blockInspectorTab ).not.toBeNull();
await switchEditorModeTo( 'Code' );
// The Block inspector should not be active anymore
- blockInspectorTab = await page.$( '.edit-post-sidebar__panel-tab.is-active[data-label="Block"]' );
+ blockInspectorTab = await page.$(
+ '.edit-post-sidebar__panel-tab.is-active[data-label="Block"]'
+ );
expect( blockInspectorTab ).toBeNull();
// No block is selected
await page.click( '.edit-post-sidebar__panel-tab[data-label="Block"]' );
- const noBlocksElement = await page.$( '.block-editor-block-inspector__no-blocks' );
+ const noBlocksElement = await page.$(
+ '.block-editor-block-inspector__no-blocks'
+ );
expect( noBlocksElement ).not.toBeNull();
// The inserter is disabled
- const disabledInserter = await page.$( '.block-editor-inserter > button:disabled' );
+ const disabledInserter = await page.$(
+ '.block-editor-inserter > button:disabled, .block-editor-inserter > button[aria-disabled="true"]'
+ );
expect( disabledInserter ).not.toBeNull();
} );
} );
diff --git a/packages/e2e-tests/specs/editor/various/embedding.test.js b/packages/e2e-tests/specs/editor/various/embedding.test.js
index 53dec26144058..24fc469fca9d7 100644
--- a/packages/e2e-tests/specs/editor/various/embedding.test.js
+++ b/packages/e2e-tests/specs/editor/various/embedding.test.js
@@ -16,7 +16,8 @@ import {
const MOCK_EMBED_WORDPRESS_SUCCESS_RESPONSE = {
url: 'https://wordpress.org/gutenberg/handbook/block-api/attributes/',
- html: 'WordPress embed
',
+ html:
+ 'WordPress embed
',
type: 'rich',
provider_name: 'WordPress',
provider_url: 'https://wordpress.org',
@@ -68,7 +69,8 @@ const MOCK_BAD_EMBED_PROVIDER_RESPONSE = {
const MOCK_CANT_EMBED_RESPONSE = {
provider_name: 'Embed Handler',
- html: 'https://twitter.com/wooyaygutenberg123454312 ',
+ html:
+ 'https://twitter.com/wooyaygutenberg123454312 ',
};
const MOCK_BAD_WORDPRESS_RESPONSE = {
@@ -82,27 +84,41 @@ const MOCK_BAD_WORDPRESS_RESPONSE = {
const MOCK_RESPONSES = [
{
- match: createEmbeddingMatcher( 'https://wordpress.org/gutenberg/handbook' ),
+ match: createEmbeddingMatcher(
+ 'https://wordpress.org/gutenberg/handbook'
+ ),
onRequestMatch: createJSONResponse( MOCK_BAD_WORDPRESS_RESPONSE ),
},
{
- match: createEmbeddingMatcher( 'https://wordpress.org/gutenberg/handbook/' ),
+ match: createEmbeddingMatcher(
+ 'https://wordpress.org/gutenberg/handbook/'
+ ),
onRequestMatch: createJSONResponse( MOCK_BAD_WORDPRESS_RESPONSE ),
},
{
- match: createEmbeddingMatcher( 'https://wordpress.org/gutenberg/handbook/block-api/attributes/' ),
- onRequestMatch: createJSONResponse( MOCK_EMBED_WORDPRESS_SUCCESS_RESPONSE ),
+ match: createEmbeddingMatcher(
+ 'https://wordpress.org/gutenberg/handbook/block-api/attributes/'
+ ),
+ onRequestMatch: createJSONResponse(
+ MOCK_EMBED_WORDPRESS_SUCCESS_RESPONSE
+ ),
},
{
- match: createEmbeddingMatcher( 'https://www.youtube.com/watch?v=lXMskKTw3Bc' ),
+ match: createEmbeddingMatcher(
+ 'https://www.youtube.com/watch?v=lXMskKTw3Bc'
+ ),
onRequestMatch: createJSONResponse( MOCK_EMBED_VIDEO_SUCCESS_RESPONSE ),
},
{
- match: createEmbeddingMatcher( 'https://soundcloud.com/a-boogie-wit-da-hoodie/swervin' ),
+ match: createEmbeddingMatcher(
+ 'https://soundcloud.com/a-boogie-wit-da-hoodie/swervin'
+ ),
onRequestMatch: createJSONResponse( MOCK_EMBED_AUDIO_SUCCESS_RESPONSE ),
},
{
- match: createEmbeddingMatcher( 'https://www.instagram.com/p/Bvl97o2AK6x/' ),
+ match: createEmbeddingMatcher(
+ 'https://www.instagram.com/p/Bvl97o2AK6x/'
+ ),
onRequestMatch: createJSONResponse( MOCK_EMBED_IMAGE_SUCCESS_RESPONSE ),
},
{
@@ -122,7 +138,9 @@ const MOCK_RESPONSES = [
onRequestMatch: createJSONResponse( MOCK_BAD_EMBED_PROVIDER_RESPONSE ),
},
{
- match: createEmbeddingMatcher( 'https://twitter.com/wooyaygutenberg123454312' ),
+ match: createEmbeddingMatcher(
+ 'https://twitter.com/wooyaygutenberg123454312'
+ ),
onRequestMatch: createJSONResponse( MOCK_CANT_EMBED_RESPONSE ),
},
// Respond to the instagram URL with a non-image response, doesn't matter what it is,
@@ -152,9 +170,13 @@ describe( 'Embedding content', () => {
await clickBlockAppender();
await page.keyboard.type( '/embed' );
await page.keyboard.press( 'Enter' );
- await page.keyboard.type( 'https://twitter.com/wooyaygutenberg123454312' );
+ await page.keyboard.type(
+ 'https://twitter.com/wooyaygutenberg123454312'
+ );
await page.keyboard.press( 'Enter' );
- await page.waitForSelector( 'input[value="https://twitter.com/wooyaygutenberg123454312"]' );
+ await page.waitForSelector(
+ 'input[value="https://twitter.com/wooyaygutenberg123454312"]'
+ );
// WordPress invalid content. Should render failed, edit state.
await clickBlockAppender();
@@ -162,7 +184,9 @@ describe( 'Embedding content', () => {
await page.keyboard.press( 'Enter' );
await page.keyboard.type( 'https://wordpress.org/gutenberg/handbook/' );
await page.keyboard.press( 'Enter' );
- await page.waitForSelector( 'input[value="https://wordpress.org/gutenberg/handbook/"]' );
+ await page.waitForSelector(
+ 'input[value="https://wordpress.org/gutenberg/handbook/"]'
+ );
// Provider whose oembed API has gone wrong. Should render failed, edit
// state.
@@ -171,14 +195,18 @@ describe( 'Embedding content', () => {
await page.keyboard.press( 'Enter' );
await page.keyboard.type( 'https://twitter.com/thatbunty' );
await page.keyboard.press( 'Enter' );
- await page.waitForSelector( 'input[value="https://twitter.com/thatbunty"]' );
+ await page.waitForSelector(
+ 'input[value="https://twitter.com/thatbunty"]'
+ );
// WordPress content that can be embedded. Should render valid figure
// element.
await clickBlockAppender();
await page.keyboard.type( '/embed' );
await page.keyboard.press( 'Enter' );
- await page.keyboard.type( 'https://wordpress.org/gutenberg/handbook/block-api/attributes/' );
+ await page.keyboard.type(
+ 'https://wordpress.org/gutenberg/handbook/block-api/attributes/'
+ );
await page.keyboard.press( 'Enter' );
await page.waitForSelector( 'figure.wp-block-embed-wordpress' );
@@ -187,9 +215,13 @@ describe( 'Embedding content', () => {
await clickBlockAppender();
await page.keyboard.type( '/embed' );
await page.keyboard.press( 'Enter' );
- await page.keyboard.type( 'https://www.youtube.com/watch?v=lXMskKTw3Bc' );
+ await page.keyboard.type(
+ 'https://www.youtube.com/watch?v=lXMskKTw3Bc'
+ );
await page.keyboard.press( 'Enter' );
- await page.waitForSelector( 'figure.wp-block-embed-youtube.wp-embed-aspect-16-9' );
+ await page.waitForSelector(
+ 'figure.wp-block-embed-youtube.wp-embed-aspect-16-9'
+ );
// Photo content. Should render valid figure element.
await clickBlockAppender();
@@ -204,9 +236,14 @@ describe( 'Embedding content', () => {
await clickBlockAppender();
await page.keyboard.type( '/embed' );
await page.keyboard.press( 'Enter' );
- await page.keyboard.type( 'https://twitter.com/wooyaygutenberg123454312' );
+ await page.keyboard.type(
+ 'https://twitter.com/wooyaygutenberg123454312'
+ );
await page.keyboard.press( 'Enter' );
+ // Wait for the request to fail and present an error.
+ await page.waitForSelector( '.components-placeholder__error' );
+
await clickButton( 'Convert to link' );
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
@@ -227,17 +264,25 @@ describe( 'Embedding content', () => {
await clickBlockAppender();
await page.keyboard.type( '/embed' );
await page.keyboard.press( 'Enter' );
- await page.keyboard.type( 'https://twitter.com/wooyaygutenberg123454312' );
+ await page.keyboard.type(
+ 'https://twitter.com/wooyaygutenberg123454312'
+ );
await page.keyboard.press( 'Enter' );
+
+ // Wait for the request to fail and present an error.
+ await page.waitForSelector( '.components-placeholder__error' );
+
// Set up a different mock to make sure that try again actually does make the request again.
- await setUpResponseMocking(
- [
- {
- match: createEmbeddingMatcher( 'https://twitter.com/wooyaygutenberg123454312' ),
- onRequestMatch: createJSONResponse( MOCK_EMBED_RICH_SUCCESS_RESPONSE ),
- },
- ]
- );
+ await setUpResponseMocking( [
+ {
+ match: createEmbeddingMatcher(
+ 'https://twitter.com/wooyaygutenberg123454312'
+ ),
+ onRequestMatch: createJSONResponse(
+ MOCK_EMBED_RICH_SUCCESS_RESPONSE
+ ),
+ },
+ ] );
await clickButton( 'Try again' );
await page.waitForSelector( 'figure.wp-block-embed-twitter' );
} );
@@ -251,7 +296,10 @@ describe( 'Embedding content', () => {
await insertBlock( 'Paragraph' );
await page.keyboard.type( 'Hello there!' );
await publishPost();
- const postUrl = await page.$eval( '#inspector-text-control-0', ( el ) => el.value );
+ const postUrl = await page.$eval(
+ '[id^=inspector-text-control-]',
+ ( el ) => el.value
+ );
// Start a new post, embed the previous post.
await createNewPost();
diff --git a/packages/e2e-tests/specs/editor/various/font-size-picker.test.js b/packages/e2e-tests/specs/editor/various/font-size-picker.test.js
index ca1f603ab382c..d3ab21d68d0ac 100644
--- a/packages/e2e-tests/specs/editor/various/font-size-picker.test.js
+++ b/packages/e2e-tests/specs/editor/various/font-size-picker.test.js
@@ -18,7 +18,9 @@ describe( 'Font Size Picker', () => {
await clickBlockAppender();
await page.keyboard.type( 'Paragraph to be made "large"' );
await page.click( '.components-font-size-picker__select' );
- await page.click( '.components-custom-select-control__item:nth-child(5)' );
+ await page.click(
+ '.components-custom-select-control__item:nth-child(5)'
+ );
// Ensure content matches snapshot.
const content = await getEditedPostContent();
@@ -30,7 +32,9 @@ describe( 'Font Size Picker', () => {
await clickBlockAppender();
await page.keyboard.type( 'Paragraph to be made "small"' );
- await page.click( '.components-font-size-picker__controls .components-range-control__number' );
+ await page.click(
+ '.components-font-size-picker__controls .components-range-control__number'
+ );
// This should be the "small" font-size of the editor defaults.
await page.keyboard.type( '13' );
@@ -44,7 +48,9 @@ describe( 'Font Size Picker', () => {
await clickBlockAppender();
await page.keyboard.type( 'Paragraph to be made "small"' );
- await page.click( '.components-font-size-picker__controls .components-range-control__number' );
+ await page.click(
+ '.components-font-size-picker__controls .components-range-control__number'
+ );
await page.keyboard.type( '23' );
// Ensure content matches snapshot.
@@ -55,12 +61,20 @@ describe( 'Font Size Picker', () => {
it( 'should reset a named font size using the reset button', async () => {
// Create a paragraph block with some content.
await clickBlockAppender();
- await page.keyboard.type( 'Paragraph with font size reset using button' );
+ await page.keyboard.type(
+ 'Paragraph with font size reset using button'
+ );
await page.click( '.components-font-size-picker__select' );
- await page.click( '.components-custom-select-control__item:nth-child(2)' );
-
- const resetButton = ( await page.$x( '//*[contains(concat(" ", @class, " "), " components-font-size-picker__controls ")]//*[text()=\'Reset\']' ) )[ 0 ];
+ await page.click(
+ '.components-custom-select-control__item:nth-child(2)'
+ );
+
+ const resetButton = (
+ await page.$x(
+ '//*[contains(concat(" ", @class, " "), " components-font-size-picker__controls ")]//*[text()=\'Reset\']'
+ )
+ )[ 0 ];
await resetButton.click();
// Ensure content matches snapshot.
@@ -71,13 +85,19 @@ describe( 'Font Size Picker', () => {
it( 'should reset a named font size using input field', async () => {
// Create a paragraph block with some content.
await clickBlockAppender();
- await page.keyboard.type( 'Paragraph with font size reset using input field' );
+ await page.keyboard.type(
+ 'Paragraph with font size reset using input field'
+ );
await page.click( '.components-font-size-picker__select' );
- await page.click( '.components-custom-select-control__item:nth-child(3)' );
+ await page.click(
+ '.components-custom-select-control__item:nth-child(3)'
+ );
// Clear the custom font size input.
- await page.click( '.components-font-size-picker__controls .components-range-control__number' );
+ await page.click(
+ '.components-font-size-picker__controls .components-range-control__number'
+ );
await pressKeyTimes( 'ArrowRight', 5 );
await pressKeyTimes( 'Backspace', 5 );
@@ -91,12 +111,16 @@ describe( 'Font Size Picker', () => {
await clickBlockAppender();
await page.keyboard.type( 'Paragraph to be made "small"' );
- await page.click( '.components-font-size-picker__controls .components-range-control__number' );
+ await page.click(
+ '.components-font-size-picker__controls .components-range-control__number'
+ );
await page.keyboard.type( '23' );
await page.keyboard.press( 'Backspace' );
- await page.click( '.components-font-size-picker__controls .components-range-control__number' );
+ await page.click(
+ '.components-font-size-picker__controls .components-range-control__number'
+ );
await page.keyboard.press( 'Backspace' );
await page.keyboard.press( 'Backspace' );
diff --git a/packages/e2e-tests/specs/editor/various/fullscreen-mode.test.js b/packages/e2e-tests/specs/editor/various/fullscreen-mode.test.js
index 42007b1c03acb..5b6bd90ca4c10 100644
--- a/packages/e2e-tests/specs/editor/various/fullscreen-mode.test.js
+++ b/packages/e2e-tests/specs/editor/various/fullscreen-mode.test.js
@@ -22,7 +22,9 @@ describe( 'Fullscreen Mode', () => {
expect( isFullscreenEnabled ).toBe( true );
- const fullscreenToolbar = await page.$( '.edit-post-fullscreen-mode-close__toolbar' );
+ const fullscreenToolbar = await page.$(
+ '.edit-post-fullscreen-mode-close__toolbar'
+ );
expect( fullscreenToolbar ).not.toBeNull();
} );
diff --git a/packages/e2e-tests/specs/editor/various/invalid-block.test.js b/packages/e2e-tests/specs/editor/various/invalid-block.test.js
index d0d8dda5a805d..7185017ddfd3c 100644
--- a/packages/e2e-tests/specs/editor/various/invalid-block.test.js
+++ b/packages/e2e-tests/specs/editor/various/invalid-block.test.js
@@ -20,11 +20,15 @@ describe( 'invalid blocks', () => {
await clickBlockToolbarButton( 'More options' );
// Change to HTML mode and close the options
- const changeModeButton = await page.waitForXPath( '//button[text()="Edit as HTML"]' );
+ const changeModeButton = await page.waitForXPath(
+ '//button[text()="Edit as HTML"]'
+ );
await changeModeButton.click();
// Focus on the textarea and enter an invalid paragraph
- await page.click( '.block-editor-block-list__layout .block-editor-block-list__block .block-editor-block-list__block-html-textarea' );
+ await page.click(
+ '.block-editor-block-list__layout .block-editor-block-list__block .block-editor-block-list__block-html-textarea'
+ );
await page.keyboard.type( 'invalid paragraph' );
// Takes the focus away from the block so the invalid warning is triggered
@@ -36,7 +40,12 @@ describe( 'invalid blocks', () => {
await page.click( '.block-editor-warning__actions button' );
// Check we get the resolve modal with the appropriate contents
- const htmlBlockContent = await page.$eval( '.block-editor-block-compare__html', ( node ) => node.textContent );
- expect( htmlBlockContent ).toEqual( '
hello
invalid paragraph' );
+ const htmlBlockContent = await page.$eval(
+ '.block-editor-block-compare__html',
+ ( node ) => node.textContent
+ );
+ expect( htmlBlockContent ).toEqual(
+ '
hello
invalid paragraph'
+ );
} );
} );
diff --git a/packages/e2e-tests/specs/editor/various/keyboard-navigable-blocks.test.js b/packages/e2e-tests/specs/editor/various/keyboard-navigable-blocks.test.js
index 4543f0efd374d..a32474aad3b5a 100644
--- a/packages/e2e-tests/specs/editor/various/keyboard-navigable-blocks.test.js
+++ b/packages/e2e-tests/specs/editor/various/keyboard-navigable-blocks.test.js
@@ -5,6 +5,8 @@ import {
createNewPost,
insertBlock,
pressKeyWithModifier,
+ clickBlockAppender,
+ getEditedPostContent,
} from '@wordpress/e2e-test-utils';
async function getActiveLabel() {
@@ -23,23 +25,23 @@ const navigateToContentEditorTop = async () => {
};
const tabThroughParagraphBlock = async ( paragraphText ) => {
+ await page.keyboard.press( 'Tab' );
+ await expect( await getActiveLabel() ).toBe( 'Add block' );
+
await tabThroughBlockMoverControl();
await tabThroughBlockToolbar();
await page.keyboard.press( 'Tab' );
await expect( await getActiveLabel() ).toBe( 'Block: Paragraph' );
- await page.keyboard.press( 'Tab' );
- await expect( await getActiveLabel() ).toBe( 'Add block' );
-
await page.keyboard.press( 'Tab' );
await expect( await getActiveLabel() ).toBe( 'Paragraph block' );
- await expect( await page.evaluate( () =>
- document.activeElement.innerHTML
- ) ).toBe( paragraphText );
+ await expect(
+ await page.evaluate( () => document.activeElement.innerHTML )
+ ).toBe( paragraphText );
await page.keyboard.press( 'Tab' );
- await expect( await getActiveLabel() ).toBe( 'Open publish panel' );
+ await expect( await getActiveLabel() ).toBe( 'Document' );
};
const tabThroughBlockMoverControl = async () => {
@@ -117,18 +119,24 @@ describe( 'Order of block keyboard navigation', () => {
} );
await page.keyboard.press( 'Tab' );
- await expect( await page.evaluate( () => {
- return document.activeElement.placeholder;
- } ) ).toBe( 'Add title' );
+ await expect(
+ await page.evaluate( () => {
+ return document.activeElement.placeholder;
+ } )
+ ).toBe( 'Add title' );
await page.keyboard.press( 'Tab' );
- await expect( await getActiveLabel() ).toBe( 'Paragraph' );
+ await expect( await getActiveLabel() ).toBe(
+ 'Paragraph Block. Row 1. 0'
+ );
await page.keyboard.press( 'Tab' );
- await expect( await getActiveLabel() ).toBe( 'Paragraph' );
+ await expect( await getActiveLabel() ).toBe(
+ 'Paragraph Block. Row 2. 1'
+ );
await page.keyboard.press( 'Tab' );
- await expect( await getActiveLabel() ).toBe( 'Open publish panel' );
+ await expect( await getActiveLabel() ).toBe( 'Document (selected)' );
} );
it( 'allows tabbing in navigation mode if no block is selected (reverse)', async () => {
@@ -143,21 +151,54 @@ describe( 'Order of block keyboard navigation', () => {
// Clear the selected block and put focus behind the block list.
await page.evaluate( () => {
document.querySelector( '.edit-post-visual-editor' ).focus();
- document.querySelector( '.edit-post-editor-regions__sidebar' ).focus();
+ document
+ .querySelector( '.edit-post-editor-regions__sidebar' )
+ .focus();
} );
await pressKeyWithModifier( 'shift', 'Tab' );
- await expect( await getActiveLabel() ).toBe( 'Open publish panel' );
+ await expect( await getActiveLabel() ).toBe(
+ 'Paragraph Block. Row 2. 1'
+ );
+
+ await pressKeyWithModifier( 'shift', 'Tab' );
+ await expect( await getActiveLabel() ).toBe(
+ 'Paragraph Block. Row 1. 0'
+ );
await pressKeyWithModifier( 'shift', 'Tab' );
- await expect( await getActiveLabel() ).toBe( 'Paragraph' );
+ await expect(
+ await page.evaluate( () => {
+ return document.activeElement.placeholder;
+ } )
+ ).toBe( 'Add title' );
+ } );
+
+ it( 'should navigate correctly with multi selection', async () => {
+ await clickBlockAppender();
+ await page.keyboard.type( '1' );
+ await page.keyboard.press( 'Enter' );
+ await page.keyboard.type( '2' );
+ await page.keyboard.press( 'Enter' );
+ await page.keyboard.type( '3' );
+ await page.keyboard.press( 'Enter' );
+ await page.keyboard.type( '4' );
+ await page.keyboard.press( 'ArrowUp' );
+ await pressKeyWithModifier( 'shift', 'ArrowUp' );
+
+ expect( await getEditedPostContent() ).toMatchSnapshot();
+
+ expect( await getActiveLabel() ).toBe( 'Multiple selected blocks' );
+
+ await page.keyboard.press( 'Tab' );
+ await expect( await getActiveLabel() ).toBe( 'Document' );
await pressKeyWithModifier( 'shift', 'Tab' );
- await expect( await getActiveLabel() ).toBe( 'Paragraph' );
+ await expect( await getActiveLabel() ).toBe(
+ 'Multiple selected blocks'
+ );
await pressKeyWithModifier( 'shift', 'Tab' );
- await expect( await page.evaluate( () => {
- return document.activeElement.placeholder;
- } ) ).toBe( 'Add title' );
+ await expect( await getActiveLabel() ).toBe( 'More options' );
} );
} );
diff --git a/packages/e2e-tests/specs/editor/various/links.test.js b/packages/e2e-tests/specs/editor/various/links.test.js
index 7589f449d1d00..0f21d248a8650 100644
--- a/packages/e2e-tests/specs/editor/various/links.test.js
+++ b/packages/e2e-tests/specs/editor/various/links.test.js
@@ -7,7 +7,6 @@ import {
getEditedPostContent,
createNewPost,
pressKeyWithModifier,
- insertBlock,
} from '@wordpress/e2e-test-utils';
/**
@@ -22,7 +21,9 @@ describe( 'Links', () => {
} );
const waitForAutoFocus = async () => {
- await page.waitForFunction( () => !! document.activeElement.closest( '.block-editor-url-input' ) );
+ await page.waitForFunction(
+ () => !! document.activeElement.closest( '.block-editor-url-input' )
+ );
};
it( 'can be created by selecting text and clicking Link', async () => {
@@ -42,8 +43,8 @@ describe( 'Links', () => {
// Type a URL
await page.keyboard.type( 'https://wordpress.org/gutenberg' );
- // Click on the Apply button
- await page.click( 'button[aria-label="Apply"]' );
+ // Submit the link
+ await page.keyboard.press( 'Enter' );
// The link should have been inserted
expect( await getEditedPostContent() ).toMatchSnapshot();
@@ -78,9 +79,6 @@ describe( 'Links', () => {
await clickBlockAppender();
await page.keyboard.type( 'This is Gutenberg: ' );
- // Press escape to show the block toolbar
- await page.keyboard.press( 'Escape' );
-
// Press Cmd+K to insert a link
await pressKeyWithModifier( 'primary', 'K' );
@@ -100,7 +98,9 @@ describe( 'Links', () => {
it( 'can be created instantly when a URL is selected', async () => {
// Create a block with some text
await clickBlockAppender();
- await page.keyboard.type( 'This is Gutenberg: https://wordpress.org/gutenberg' );
+ await page.keyboard.type(
+ 'This is Gutenberg: https://wordpress.org/gutenberg'
+ );
// Select the URL
await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
@@ -153,15 +153,16 @@ describe( 'Links', () => {
// Type a URL
await page.keyboard.type( 'https://wordpress.org/gutenberg' );
- // Click on the Apply button
- await page.click( 'button[aria-label="Apply"]' );
+ // Click on the Submit button
+ await page.keyboard.press( 'Enter' );
};
it( 'can be edited', async () => {
await createAndReselectLink();
// Click on the Edit button
- await page.click( 'button[aria-label="Edit"]' );
+ const [ editButton ] = await page.$x( '//button[text()="Edit"]' );
+ await editButton.click();
// Wait for the URL field to auto-focus
await waitForAutoFocus();
@@ -169,8 +170,8 @@ describe( 'Links', () => {
// Change the URL
await page.keyboard.type( '/handbook' );
- // Click on the Apply button
- await page.click( 'button[aria-label="Apply"]' );
+ // Submit the link
+ await page.keyboard.press( 'Enter' );
// The link should have been updated
expect( await getEditedPostContent() ).toMatchSnapshot();
@@ -189,7 +190,9 @@ describe( 'Links', () => {
const toggleFixedToolbar = async ( isFixed ) => {
await page.evaluate( ( _isFixed ) => {
const { select, dispatch } = wp.data;
- const isCurrentlyFixed = select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' );
+ const isCurrentlyFixed = select( 'core/edit-post' ).isFeatureActive(
+ 'fixedToolbar'
+ );
if ( isCurrentlyFixed !== _isFixed ) {
dispatch( 'core/edit-post' ).toggleFeature( 'fixedToolbar' );
}
@@ -205,12 +208,16 @@ describe( 'Links', () => {
// Typing "left" should not close the dialog
await page.keyboard.press( 'ArrowLeft' );
- let popover = await page.$( '.block-editor-url-popover' );
+ let popover = await page.$(
+ '.components-popover__content .block-editor-link-control'
+ );
expect( popover ).not.toBeNull();
// Escape should close the dialog still.
await page.keyboard.press( 'Escape' );
- popover = await page.$( '.block-editor-url-popover' );
+ popover = await page.$(
+ '.components-popover__content .block-editor-link-control'
+ );
expect( popover ).toBeNull();
} );
@@ -224,12 +231,16 @@ describe( 'Links', () => {
// Typing "left" should not close the dialog
await page.keyboard.press( 'ArrowLeft' );
- let popover = await page.$( '.block-editor-url-popover' );
+ let popover = await page.$(
+ '.components-popover__content .block-editor-link-control'
+ );
expect( popover ).not.toBeNull();
// Escape should close the dialog still.
await page.keyboard.press( 'Escape' );
- popover = await page.$( '.block-editor-url-popover' );
+ popover = await page.$(
+ '.components-popover__content .block-editor-link-control'
+ );
expect( popover ).toBeNull();
} );
@@ -241,10 +252,11 @@ describe( 'Links', () => {
// Move the mouse to show the block toolbar
await page.mouse.move( 0, 0 );
await page.mouse.move( 10, 10 );
- await page.click( 'button[aria-label="Edit"]' );
+ const [ editButton ] = await page.$x( '//button[text()="Edit"]' );
+ await editButton.click();
await waitForAutoFocus();
await page.keyboard.type( '/handbook' );
- await page.click( 'button[aria-label="Apply"]' );
+ await page.keyboard.press( 'Enter' );
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
@@ -262,8 +274,15 @@ describe( 'Links', () => {
await page.click( '.editor-post-publish-button' );
// Return the URL of the new post
- await page.waitForSelector( '.post-publish-panel__postpublish-post-address input' );
- return page.evaluate( () => document.querySelector( '.post-publish-panel__postpublish-post-address input' ).value );
+ await page.waitForSelector(
+ '.post-publish-panel__postpublish-post-address input'
+ );
+ return page.evaluate(
+ () =>
+ document.querySelector(
+ '.post-publish-panel__postpublish-post-address input'
+ ).value
+ );
};
it( 'allows use of escape key to dismiss the url popover', async () => {
@@ -282,34 +301,54 @@ describe( 'Links', () => {
// Wait for the URL field to auto-focus
await waitForAutoFocus();
- expect( await page.$( '.block-editor-url-popover' ) ).not.toBeNull();
+ expect(
+ await page.$(
+ '.components-popover__content .block-editor-link-control'
+ )
+ ).not.toBeNull();
// Trigger the autocomplete suggestion list and select the first suggestion.
await page.keyboard.type( titleText );
- await page.waitForSelector( '.block-editor-url-input__suggestion' );
+ await page.waitForSelector( '.block-editor-link-control__search-item' );
await page.keyboard.press( 'ArrowDown' );
// Expect the the escape key to dismiss the popover when the autocomplete suggestion list is open.
await page.keyboard.press( 'Escape' );
- expect( await page.$( '.block-editor-url-popover' ) ).toBeNull();
+ expect(
+ await page.$(
+ '.components-popover__content .block-editor-link-control'
+ )
+ ).toBeNull();
// Press Cmd+K to insert a link
await pressKeyWithModifier( 'primary', 'K' );
// Wait for the URL field to auto-focus
await waitForAutoFocus();
- expect( await page.$( '.block-editor-url-popover' ) ).not.toBeNull();
+ expect(
+ await page.$(
+ '.components-popover__content .block-editor-link-control'
+ )
+ ).not.toBeNull();
// Expect the the escape key to dismiss the popover normally.
await page.keyboard.press( 'Escape' );
- expect( await page.$( '.block-editor-url-popover' ) ).toBeNull();
+ expect(
+ await page.$(
+ '.components-popover__content .block-editor-link-control'
+ )
+ ).toBeNull();
// Press Cmd+K to insert a link
await pressKeyWithModifier( 'primary', 'K' );
// Wait for the URL field to auto-focus
await waitForAutoFocus();
- expect( await page.$( '.block-editor-url-popover' ) ).not.toBeNull();
+ expect(
+ await page.$(
+ '.components-popover__content .block-editor-link-control'
+ )
+ ).not.toBeNull();
// Tab to the settings icon button.
await page.keyboard.press( 'Tab' );
@@ -317,7 +356,11 @@ describe( 'Links', () => {
// Expect the the escape key to dismiss the popover normally.
await page.keyboard.press( 'Escape' );
- expect( await page.$( '.block-editor-url-popover' ) ).toBeNull();
+ expect(
+ await page.$(
+ '.components-popover__content .block-editor-link-control'
+ )
+ ).toBeNull();
} );
it( 'can be modified using the keyboard once a link has been set', async () => {
@@ -335,20 +378,42 @@ describe( 'Links', () => {
// Deselect the link text by moving the caret to the end of the line
// and the link popover should not be displayed.
await page.keyboard.press( 'End' );
- expect( await page.$( '.block-editor-url-popover' ) ).toBeNull();
+ expect(
+ await page.$(
+ '.components-popover__content .block-editor-link-control'
+ )
+ ).toBeNull();
// Move the caret back into the link text and the link popover
// should be displayed.
await page.keyboard.press( 'ArrowLeft' );
- expect( await page.$( '.block-editor-url-popover' ) ).not.toBeNull();
+ expect(
+ await page.$(
+ '.components-popover__content .block-editor-link-control'
+ )
+ ).not.toBeNull();
// Press Cmd+K to edit the link and the url-input should become
// focused with the value previously inserted.
await pressKeyWithModifier( 'primary', 'K' );
+ await page.waitForSelector(
+ ':focus.block-editor-link-control__search-item-title'
+ );
+ await page.keyboard.press( 'Tab' ); // Shift focus to "Edit" button
+ await page.keyboard.press( 'Enter' ); // Click "Edit" button
+
await waitForAutoFocus();
- const activeElementParentClasses = await page.evaluate( () => Object.values( document.activeElement.parentElement.parentElement.classList ) );
- expect( activeElementParentClasses ).toContain( 'block-editor-url-input' );
- const activeElementValue = await page.evaluate( () => document.activeElement.value );
+ const activeElementParentClasses = await page.evaluate( () =>
+ Object.values(
+ document.activeElement.parentElement.parentElement.classList
+ )
+ );
+ expect( activeElementParentClasses ).toContain(
+ 'block-editor-url-input'
+ );
+ const activeElementValue = await page.evaluate(
+ () => document.activeElement.value
+ );
expect( activeElementValue ).toBe( URL );
} );
@@ -360,44 +425,12 @@ describe( 'Links', () => {
await waitForAutoFocus();
await page.keyboard.type( 'http://#test.com' );
await page.keyboard.press( 'Enter' );
- const assertiveContent = await page.evaluate( () => document.querySelector( '#a11y-speak-assertive' ).textContent );
- expect( assertiveContent.trim() ).toBe( 'Warning: the link has been inserted but may have errors. Please test it.' );
- } );
-
- it( 'link popover remains visible after a mouse drag event', async () => {
- // Create some blocks so we have components with event handlers on the page
- for ( let loop = 0; loop < 5; loop++ ) {
- await insertBlock( 'Paragraph' );
- await page.keyboard.type( 'This is Gutenberg' );
- }
-
- // Focus on first paragraph, so the link popover will appear over the subsequent ones
- await page.click( '[aria-label="Block navigation"]' );
- await page.click( '.block-editor-block-navigation__item button' );
-
- // Select some text
- await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' );
-
- // Click on the Link button
- await page.click( 'button[aria-label="Link"]' );
- // Wait for the URL field to auto-focus
- await waitForAutoFocus();
-
- // Click on the Link Settings button
- await page.click( 'button[aria-label="Link settings"]' );
-
- // Move mouse over the 'open in new tab' section, then click and drag
- const settings = await page.$( '.block-editor-url-popover__settings' );
- const bounds = await settings.boundingBox();
-
- await page.mouse.move( bounds.x, bounds.y );
- await page.mouse.down();
- await page.mouse.move( bounds.x + ( bounds.width / 2 ), bounds.y, { steps: 10 } );
- await page.mouse.up();
-
- // The link popover should still be visible
- const popover = await page.$$( '.block-editor-url-popover' );
- expect( popover ).toHaveLength( 1 );
+ const assertiveContent = await page.evaluate(
+ () => document.querySelector( '#a11y-speak-assertive' ).textContent
+ );
+ expect( assertiveContent.trim() ).toBe(
+ 'Warning: the link has been inserted but may have errors. Please test it.'
+ );
} );
it( 'should contain a label when it should open in a new tab', async () => {
@@ -408,19 +441,22 @@ describe( 'Links', () => {
await pressKeyWithModifier( 'primary', 'k' );
await waitForAutoFocus();
await page.keyboard.type( 'w.org' );
- // Navigate to the settings toggle.
- await page.keyboard.press( 'Tab' );
- await page.keyboard.press( 'Tab' );
- // Open settings.
- await page.keyboard.press( 'Space' );
+
+ // Insert the link
+ await page.keyboard.press( 'Enter' );
+
+ // Navigate back to the popover
+ await pressKeyWithModifier( 'primary', 'k' );
+ await page.waitForSelector(
+ '.components-popover__content .block-editor-link-control'
+ );
+
// Navigate to the "Open in New Tab" checkbox.
await page.keyboard.press( 'Tab' );
+ await page.keyboard.press( 'Tab' );
+
// Check the checkbox.
await page.keyboard.press( 'Space' );
- // Navigate back to the input field.
- await page.keyboard.press( 'Tab' );
- // Submit the form.
- await page.keyboard.press( 'Enter' );
expect( await getEditedPostContent() ).toMatchSnapshot();
@@ -436,34 +472,29 @@ describe( 'Links', () => {
await page.keyboard.press( 'ArrowRight' );
// Edit link.
await pressKeyWithModifier( 'primary', 'k' );
+ await page.waitForSelector(
+ ':focus.block-editor-link-control__search-item-title'
+ );
+ await page.keyboard.press( 'Tab' ); // Shift focus to "Edit" button
+ await page.keyboard.press( 'Enter' ); // Click "Edit" button
await waitForAutoFocus();
await pressKeyWithModifier( 'primary', 'a' );
await page.keyboard.type( 'wordpress.org' );
- // Navigate to the settings toggle.
- await page.keyboard.press( 'Tab' );
- await page.keyboard.press( 'Tab' );
- // Open settings.
- await page.keyboard.press( 'Space' );
- // Navigate to the "Open in New Tab" checkbox.
- await page.keyboard.press( 'Tab' );
- // Uncheck the checkbox.
- await page.keyboard.press( 'Space' );
- // Navigate back to the input field.
- await page.keyboard.press( 'Tab' );
- // Submit the form.
+
+ // Update the link
await page.keyboard.press( 'Enter' );
- // Navigate back to inputs to verify appears as changed.
+ // Navigate back to the popover
await pressKeyWithModifier( 'primary', 'k' );
- await waitForAutoFocus();
- const link = await page.evaluate( () => document.activeElement.value );
- expect( link ).toBe( 'http://wordpress.org' );
+ await page.waitForSelector(
+ '.components-popover__content .block-editor-link-control'
+ );
+
+ // Navigate to the "Open in New Tab" checkbox.
await page.keyboard.press( 'Tab' );
await page.keyboard.press( 'Tab' );
+ // Uncheck the checkbox.
await page.keyboard.press( 'Space' );
- await page.keyboard.press( 'Tab' );
- const isChecked = await page.evaluate( () => document.activeElement.checked );
- expect( isChecked ).toBe( false );
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
diff --git a/packages/e2e-tests/specs/editor/various/manage-reusable-blocks.test.js b/packages/e2e-tests/specs/editor/various/manage-reusable-blocks.test.js
index 9d17922f519f3..be20ca9e6d52d 100644
--- a/packages/e2e-tests/specs/editor/various/manage-reusable-blocks.test.js
+++ b/packages/e2e-tests/specs/editor/various/manage-reusable-blocks.test.js
@@ -16,7 +16,9 @@ describe( 'Managing reusable blocks', () => {
* @return {Promise} Promise resolving to number of post list entries.
*/
async function getNumberOfEntries() {
- return page.evaluate( () => document.querySelectorAll( '.hentry' ).length );
+ return page.evaluate(
+ () => document.querySelectorAll( '.hentry' ).length
+ );
}
beforeAll( async () => {
@@ -28,22 +30,38 @@ describe( 'Managing reusable blocks', () => {
// Import Reusable block
await page.waitForSelector( '.list-reusable-blocks__container' );
- const importButton = await page.$( '.list-reusable-blocks__container button' );
+ const importButton = await page.$(
+ '.list-reusable-blocks__container button'
+ );
await importButton.click();
// Select the file to upload
- const testReusableBlockFile = path.join( __dirname, '..', '..', '..', 'assets', 'greeting-reusable-block.json' );
+ const testReusableBlockFile = path.join(
+ __dirname,
+ '..',
+ '..',
+ '..',
+ 'assets',
+ 'greeting-reusable-block.json'
+ );
const input = await page.$( '.list-reusable-blocks-import-form input' );
await input.uploadFile( testReusableBlockFile );
// Submit the form
- const button = await page.$( '.list-reusable-blocks-import-form__button' );
+ const button = await page.$(
+ '.list-reusable-blocks-import-form__button'
+ );
await button.click();
// Wait for the success notice
await page.waitForSelector( '.notice-success' );
- const noticeContent = await page.$eval( '.notice-success', ( element ) => element.textContent );
- expect( noticeContent ).toEqual( 'Reusable block imported successfully!' );
+ const noticeContent = await page.$eval(
+ '.notice-success',
+ ( element ) => element.textContent
+ );
+ expect( noticeContent ).toEqual(
+ 'Reusable block imported successfully!'
+ );
// Refresh the page
await visitAdminPage( 'edit.php', 'post_type=wp_block' );
diff --git a/packages/e2e-tests/specs/editor/various/multi-block-selection.test.js b/packages/e2e-tests/specs/editor/various/multi-block-selection.test.js
index c685dd4bca4f6..832cf25d7d4fa 100644
--- a/packages/e2e-tests/specs/editor/various/multi-block-selection.test.js
+++ b/packages/e2e-tests/specs/editor/various/multi-block-selection.test.js
@@ -7,6 +7,7 @@ import {
pressKeyWithModifier,
pressKeyTimes,
getEditedPostContent,
+ clickBlockToolbarButton,
} from '@wordpress/e2e-test-utils';
async function getSelectedFlatIndices() {
@@ -14,17 +15,17 @@ async function getSelectedFlatIndices() {
const indices = [];
let single;
- Array.from(
- document.querySelectorAll( '.wp-block' )
- ).forEach( ( node, index ) => {
- if ( node.classList.contains( 'is-selected' ) ) {
- single = index;
- }
+ Array.from( document.querySelectorAll( '.wp-block' ) ).forEach(
+ ( node, index ) => {
+ if ( node.classList.contains( 'is-selected' ) ) {
+ single = index;
+ }
- if ( node.classList.contains( 'is-multi-selected' ) ) {
- indices.push( index );
+ if ( node.classList.contains( 'is-multi-selected' ) ) {
+ indices.push( index );
+ }
}
- } );
+ );
return single !== undefined ? single : indices;
} );
@@ -109,7 +110,10 @@ describe( 'Multi-block selection', () => {
// DOM-dependant side-effect setup code and doesn't seem straightforward
// to mock. Instead, we check for the DOM node that `wp.a11y.speak()`
// inserts text into.
- const speakTextContent = await page.$eval( '#a11y-speak-assertive', ( element ) => element.textContent );
+ const speakTextContent = await page.$eval(
+ '#a11y-speak-assertive',
+ ( element ) => element.textContent
+ );
expect( speakTextContent.trim() ).toEqual( '3 blocks selected.' );
} );
@@ -270,17 +274,19 @@ describe( 'Multi-block selection', () => {
await page.keyboard.press( 'ArrowUp' );
const [ coord1, coord2 ] = await page.evaluate( () => {
- const elements = Array.from( document.querySelectorAll( '.wp-block-paragraph' ) );
+ const elements = Array.from(
+ document.querySelectorAll( '.wp-block-paragraph' )
+ );
const rect1 = elements[ 0 ].getBoundingClientRect();
const rect2 = elements[ 1 ].getBoundingClientRect();
return [
{
- x: rect1.x + ( rect1.width / 2 ),
- y: rect1.y + ( rect1.height / 2 ),
+ x: rect1.x + rect1.width / 2,
+ y: rect1.y + rect1.height / 2,
},
{
- x: rect2.x + ( rect2.width / 2 ),
- y: rect2.y + ( rect2.height / 2 ),
+ x: rect2.x + rect2.width / 2,
+ y: rect2.y + rect2.height / 2,
},
];
} );
@@ -302,20 +308,21 @@ describe( 'Multi-block selection', () => {
await page.keyboard.press( 'Enter' );
await page.click( '.components-circular-option-picker__option' );
await page.keyboard.type( '2' );
- await page.keyboard.press( 'ArrowUp' );
const [ coord1, coord2 ] = await page.evaluate( () => {
- const elements = Array.from( document.querySelectorAll( '.wp-block-paragraph' ) );
+ const elements = Array.from(
+ document.querySelectorAll( '.wp-block-paragraph' )
+ );
const rect1 = elements[ 0 ].getBoundingClientRect();
const rect2 = elements[ 1 ].getBoundingClientRect();
return [
{
- x: rect1.x + ( rect1.width / 2 ),
- y: rect1.y + ( rect1.height / 2 ),
+ x: rect1.x + rect1.width / 2,
+ y: rect1.y + rect1.height / 2,
},
{
- x: rect2.x + ( rect2.width / 2 ),
- y: rect2.y + ( rect2.height / 2 ),
+ x: rect2.x + rect2.width / 2,
+ y: rect2.y + rect2.height / 2,
},
];
} );
@@ -364,4 +371,120 @@ describe( 'Multi-block selection', () => {
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
+
+ it( 'should return original focus after failed multi selection attempt', async () => {
+ await clickBlockAppender();
+ await page.keyboard.type( '1' );
+ await page.keyboard.type( '2' );
+ await page.keyboard.press( 'ArrowLeft' );
+
+ const [ coord1, coord2 ] = await page.evaluate( () => {
+ const selection = window.getSelection();
+
+ if ( ! selection.rangeCount ) {
+ return;
+ }
+
+ const range = selection.getRangeAt( 0 );
+ const rect1 = range.getClientRects()[ 0 ];
+ const element = document.querySelector( '.wp-block-paragraph' );
+ const rect2 = element.getBoundingClientRect();
+
+ return [
+ {
+ x: rect1.x,
+ y: rect1.y + rect1.height / 2,
+ },
+ {
+ // Move a bit outside the paragraph.
+ x: rect2.x - 10,
+ y: rect2.y + rect2.height / 2,
+ },
+ ];
+ } );
+
+ await page.mouse.move( coord1.x, coord1.y );
+ await page.mouse.down();
+ await page.mouse.move( coord2.x, coord2.y, { steps: 10 } );
+ await page.mouse.up();
+
+ // Wait for the selection to update.
+ await page.evaluate(
+ () => new Promise( window.requestAnimationFrame )
+ );
+
+ // Only "1" should be deleted.
+ await page.keyboard.press( 'Backspace' );
+
+ expect( await getEditedPostContent() ).toMatchSnapshot();
+ } );
+
+ it( 'should preserve dragged selection on move', async () => {
+ await clickBlockAppender();
+ await page.keyboard.type( '1' );
+ await page.keyboard.press( 'Enter' );
+ await page.keyboard.type( '2' );
+ await page.keyboard.press( 'Enter' );
+ await page.keyboard.type( '3' );
+
+ const [ coord1, coord2 ] = await page.evaluate( () => {
+ const elements = Array.from(
+ document.querySelectorAll( '.wp-block-paragraph' )
+ );
+ const rect1 = elements[ 2 ].getBoundingClientRect();
+ const rect2 = elements[ 1 ].getBoundingClientRect();
+ return [
+ {
+ x: rect1.x + rect1.width / 2,
+ y: rect1.y + rect1.height / 2,
+ },
+ {
+ x: rect2.x + rect2.width / 2,
+ y: rect2.y + rect2.height / 2,
+ },
+ ];
+ } );
+
+ await page.mouse.move( coord1.x, coord1.y );
+ await page.mouse.down();
+ await page.mouse.move( coord2.x, coord2.y );
+ await page.mouse.up();
+
+ await testNativeSelection();
+ expect( await getSelectedFlatIndices() ).toEqual( [ 2, 3 ] );
+
+ await clickBlockToolbarButton( 'Move up' );
+
+ await testNativeSelection();
+ expect( await getSelectedFlatIndices() ).toEqual( [ 1, 2 ] );
+
+ expect( await getEditedPostContent() ).toMatchSnapshot();
+ } );
+
+ it( 'should clear selection when clicking next to blocks', async () => {
+ await clickBlockAppender();
+ await page.keyboard.type( '1' );
+ await page.keyboard.press( 'Enter' );
+ await page.keyboard.type( '2' );
+ await pressKeyWithModifier( 'shift', 'ArrowUp' );
+
+ await testNativeSelection();
+ expect( await getSelectedFlatIndices() ).toEqual( [ 1, 2 ] );
+
+ const coord = await page.evaluate( () => {
+ const element = document.querySelector( '.wp-block-paragraph' );
+ const rect = element.getBoundingClientRect();
+ return {
+ x: rect.x - 1,
+ y: rect.y + rect.height / 2,
+ };
+ } );
+
+ await page.mouse.click( coord.x, coord.y );
+
+ await testNativeSelection();
+ expect( await getSelectedFlatIndices() ).toEqual( [] );
+
+ expect( await getEditedPostContent() ).toMatchSnapshot();
+ } );
} );
diff --git a/packages/e2e-tests/specs/editor/various/navigable-toolbar.test.js b/packages/e2e-tests/specs/editor/various/navigable-toolbar.test.js
index 1b8efda52e1bb..f10ad5f319002 100644
--- a/packages/e2e-tests/specs/editor/various/navigable-toolbar.test.js
+++ b/packages/e2e-tests/specs/editor/various/navigable-toolbar.test.js
@@ -3,43 +3,80 @@
*/
import { createNewPost, pressKeyWithModifier } from '@wordpress/e2e-test-utils';
-describe.each( [ [ 'unified', true ], [ 'contextual', false ] ] )(
- 'block toolbar (%s: %p)',
- ( label, isUnifiedToolbar ) => {
- beforeEach( async () => {
- await createNewPost();
-
- await page.evaluate( ( _isUnifiedToolbar ) => {
- const { select, dispatch } = wp.data;
- const isCurrentlyUnified = select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' );
- if ( isCurrentlyUnified !== _isUnifiedToolbar ) {
- dispatch( 'core/edit-post' ).toggleFeature( 'fixedToolbar' );
- }
- }, isUnifiedToolbar );
- } );
+describe.each( [
+ [ 'unified', true ],
+ [ 'contextual', false ],
+] )( 'block toolbar (%s: %p)', ( label, isUnifiedToolbar ) => {
+ beforeEach( async () => {
+ await createNewPost();
+
+ await page.evaluate( ( _isUnifiedToolbar ) => {
+ const { select, dispatch } = wp.data;
+ const isCurrentlyUnified = select(
+ 'core/edit-post'
+ ).isFeatureActive( 'fixedToolbar' );
+ if ( isCurrentlyUnified !== _isUnifiedToolbar ) {
+ dispatch( 'core/edit-post' ).toggleFeature( 'fixedToolbar' );
+ }
+ }, isUnifiedToolbar );
+ } );
- const isInBlockToolbar = () => page.evaluate( ( _isUnifiedToolbar ) => {
+ const isInBlockToolbar = () =>
+ page.evaluate( ( _isUnifiedToolbar ) => {
if ( _isUnifiedToolbar ) {
return !! document.activeElement
.closest( '.edit-post-header-toolbar' )
.querySelector( '.block-editor-block-toolbar' );
}
- return !! document.activeElement.closest( '.block-editor-block-toolbar' );
+ return !! document.activeElement.closest(
+ '.block-editor-block-toolbar'
+ );
}, isUnifiedToolbar );
- it( 'navigates in and out of toolbar by keyboard (Alt+F10, Escape)', async () => {
- // Assumes new post focus starts in title. Create first new
- // block by ArrowDown.
- await page.keyboard.press( 'ArrowDown' );
+ it( 'navigates in and out of toolbar by keyboard (Alt+F10, Escape)', async () => {
+ // Assumes new post focus starts in title. Create first new
+ // block by ArrowDown.
+ await page.keyboard.press( 'ArrowDown' );
+
+ // [TEMPORARY]: A new paragraph is not technically a block yet
+ // until starting to type within it.
+ await page.keyboard.type( 'Example' );
+
+ // Upward
+ await pressKeyWithModifier( 'alt', 'F10' );
+ expect( await isInBlockToolbar() ).toBe( true );
+ } );
- // [TEMPORARY]: A new paragraph is not technically a block yet
- // until starting to type within it.
- await page.keyboard.type( 'Example' );
+ if ( ! isUnifiedToolbar ) {
+ it( 'should not scroll page', async () => {
+ while (
+ await page.evaluate(
+ () =>
+ wp.dom.getScrollContainer( document.activeElement )
+ .scrollTop === 0
+ )
+ ) {
+ await page.keyboard.press( 'Enter' );
+ }
+
+ await page.keyboard.type( 'a' );
+
+ const scrollTopBefore = await page.evaluate(
+ () =>
+ wp.dom.getScrollContainer( document.activeElement )
+ .scrollTop
+ );
- // Upward
await pressKeyWithModifier( 'alt', 'F10' );
expect( await isInBlockToolbar() ).toBe( true );
+
+ const scrollTopAfter = await page.evaluate(
+ () =>
+ wp.dom.getScrollContainer( document.activeElement )
+ .scrollTop
+ );
+
+ expect( scrollTopBefore ).toBe( scrollTopAfter );
} );
}
-);
-
+} );
diff --git a/packages/e2e-tests/specs/editor/various/new-post-default-content.test.js b/packages/e2e-tests/specs/editor/various/new-post-default-content.test.js
index 3fdad97d46f64..4c917f265eaf3 100644
--- a/packages/e2e-tests/specs/editor/various/new-post-default-content.test.js
+++ b/packages/e2e-tests/specs/editor/various/new-post-default-content.test.js
@@ -33,7 +33,9 @@ describe( 'new editor filtered state', () => {
// open the sidebar, we want to see the excerpt.
await openDocumentSettingsSidebar();
- const excerptButton = await findSidebarPanelToggleButtonWithTitle( 'Excerpt' );
+ const excerptButton = await findSidebarPanelToggleButtonWithTitle(
+ 'Excerpt'
+ );
if ( excerptButton ) {
await excerptButton.click( 'button' );
}
diff --git a/packages/e2e-tests/specs/editor/various/new-post.test.js b/packages/e2e-tests/specs/editor/various/new-post.test.js
index c4cb3fa082dca..41db6ce7148b2 100644
--- a/packages/e2e-tests/specs/editor/various/new-post.test.js
+++ b/packages/e2e-tests/specs/editor/various/new-post.test.js
@@ -21,13 +21,17 @@ describe( 'new editor state', () => {
} );
it( 'should show the New Post page in Gutenberg', async () => {
- expect( page.url() ).toEqual( expect.stringContaining( 'post-new.php' ) );
+ expect( page.url() ).toEqual(
+ expect.stringContaining( 'post-new.php' )
+ );
// Should display the blank title.
const title = await page.$( '[placeholder="Add title"]' );
expect( title ).not.toBeNull();
expect( title.innerHTML ).toBeFalsy();
// Should display the Preview button.
- const postPreviewButton = await page.$( '.editor-post-preview.components-button' );
+ const postPreviewButton = await page.$(
+ '.editor-post-preview.components-button'
+ );
expect( postPreviewButton ).not.toBeNull();
// Should display the Post Formats UI.
const postFormatsUi = await page.$( '.editor-post-format' );
@@ -35,8 +39,12 @@ describe( 'new editor state', () => {
} );
it( 'should have no history', async () => {
- const undoButton = await page.$( '.editor-history__undo[aria-disabled="false"]' );
- const redoButton = await page.$( '.editor-history__redo[aria-disabled="false"]' );
+ const undoButton = await page.$(
+ '.editor-history__undo[aria-disabled="false"]'
+ );
+ const redoButton = await page.$(
+ '.editor-history__redo[aria-disabled="false"]'
+ );
expect( undoButton ).toBeNull();
expect( redoButton ).toBeNull();
@@ -70,7 +78,9 @@ describe( 'new editor state', () => {
return document.activeElement.tagName.toLowerCase();
} );
- expect( activeElementClasses ).not.toContain( 'editor-post-title__input' );
+ expect( activeElementClasses ).not.toContain(
+ 'editor-post-title__input'
+ );
// The document `body` should be the `activeElement`, because nothing is
// focused by default when a post already has a title.
expect( activeElementTagName ).toEqual( 'body' );
diff --git a/packages/e2e-tests/specs/editor/various/nux.test.js b/packages/e2e-tests/specs/editor/various/nux.test.js
index e597272d2feb3..03a795b6c66c7 100644
--- a/packages/e2e-tests/specs/editor/various/nux.test.js
+++ b/packages/e2e-tests/specs/editor/various/nux.test.js
@@ -11,46 +11,70 @@ describe( 'New User Experience (NUX)', () => {
await createNewPost( { showWelcomeGuide: true } );
// Guide should be on page 1 of 4
- welcomeGuideText = await page.$eval( '.edit-post-welcome-guide', ( element ) => element.innerText );
+ welcomeGuideText = await page.$eval(
+ '.edit-post-welcome-guide',
+ ( element ) => element.innerText
+ );
expect( welcomeGuideText ).toContain( 'Welcome to the Block Editor' );
// Click on the 'Next' button
- const [ nextButton ] = await page.$x( '//button[contains(text(), "Next")]' );
+ const [ nextButton ] = await page.$x(
+ '//button[contains(text(), "Next")]'
+ );
await nextButton.click();
// Guide should be on page 2 of 4
- welcomeGuideText = await page.$eval( '.edit-post-welcome-guide', ( element ) => element.innerText );
+ welcomeGuideText = await page.$eval(
+ '.edit-post-welcome-guide',
+ ( element ) => element.innerText
+ );
expect( welcomeGuideText ).toContain( 'Make each block your own' );
// Click on the 'Previous' button
- const [ previousButton ] = await page.$x( '//button[contains(text(), "Previous")]' );
+ const [ previousButton ] = await page.$x(
+ '//button[contains(text(), "Previous")]'
+ );
await previousButton.click();
// Guide should be on page 1 of 4
- welcomeGuideText = await page.$eval( '.edit-post-welcome-guide', ( element ) => element.innerText );
+ welcomeGuideText = await page.$eval(
+ '.edit-post-welcome-guide',
+ ( element ) => element.innerText
+ );
expect( welcomeGuideText ).toContain( 'Welcome to the Block Editor' );
// Press the button for Page 2
await page.click( 'button[aria-label="Page 2 of 4"]' );
- await page.waitForXPath( '//h1[contains(text(), "Make each block your own")]' );
+ await page.waitForXPath(
+ '//h1[contains(text(), "Make each block your own")]'
+ );
// This shouldn't be necessary
// eslint-disable-next-line no-restricted-syntax
await page.waitFor( 500 );
// Press the right arrow key for Page 3
await page.keyboard.press( 'ArrowRight' );
- await page.waitForXPath( '//h1[contains(text(), "Get to know the Block Library")]' );
+ await page.waitForXPath(
+ '//h1[contains(text(), "Get to know the Block Library")]'
+ );
// Press the right arrow key for Page 4
await page.keyboard.press( 'ArrowRight' );
- await page.waitForXPath( '//h1[contains(text(), "Learn how to use the Block Editor")]' );
+ await page.waitForXPath(
+ '//h1[contains(text(), "Learn how to use the Block Editor")]'
+ );
// Click on the *visible* 'Get started' button. There are two in the DOM
// but only one is shown depending on viewport size
let getStartedButton;
- for ( const buttonHandle of await page.$x( '//button[contains(text(), "Get started")]' ) ) {
+ for ( const buttonHandle of await page.$x(
+ '//button[contains(text(), "Get started")]'
+ ) ) {
if (
- await page.evaluate( ( button ) => button.style.display !== 'none', buttonHandle )
+ await page.evaluate(
+ ( button ) => button.style.display !== 'none',
+ buttonHandle
+ )
) {
getStartedButton = buttonHandle;
}
diff --git a/packages/e2e-tests/specs/editor/various/popovers.test.js b/packages/e2e-tests/specs/editor/various/popovers.test.js
index 5a1e17817dabf..2b0399f4569f2 100644
--- a/packages/e2e-tests/specs/editor/various/popovers.test.js
+++ b/packages/e2e-tests/specs/editor/various/popovers.test.js
@@ -10,7 +10,8 @@ describe( 'popovers', () => {
describe( 'dropdown', () => {
it( 'toggles via click', async () => {
- const isMoreMenuOpen = async () => !! await page.$( '.edit-post-more-menu__content' );
+ const isMoreMenuOpen = async () =>
+ !! ( await page.$( '.edit-post-more-menu__content' ) );
expect( await isMoreMenuOpen() ).toBe( false );
diff --git a/packages/e2e-tests/specs/editor/various/post-visibility.test.js b/packages/e2e-tests/specs/editor/various/post-visibility.test.js
index 2aa49ef22c96d..dc04a8e2a8ee2 100644
--- a/packages/e2e-tests/specs/editor/various/post-visibility.test.js
+++ b/packages/e2e-tests/specs/editor/various/post-visibility.test.js
@@ -21,11 +21,15 @@ describe( 'Post visibility', () => {
await page.click( '.edit-post-post-visibility__toggle' );
- const [ privateLabel ] = await page.$x( '//label[text()="Private"]' );
+ const [ privateLabel ] = await page.$x(
+ '//label[text()="Private"]'
+ );
await privateLabel.click();
const currentStatus = await page.evaluate( () => {
- return wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
+ return wp.data
+ .select( 'core/editor' )
+ .getEditedPostAttribute( 'status' );
} );
expect( currentStatus ).toBe( 'private' );
@@ -42,10 +46,14 @@ describe( 'Post visibility', () => {
// Set a publish date for the next month.
await page.click( '.edit-post-post-schedule__toggle' );
- await page.click( 'div[aria-label="Move forward to switch to the next month."]' );
+ await page.click(
+ 'div[aria-label="Move forward to switch to the next month."]'
+ );
await (
- await page.$x( '//td[contains(concat(" ", @class, " "), " CalendarDay ")][text() = "15"]' )
- )[ 0 ].click();
+ await page.$x(
+ '//td[contains(concat(" ", @class, " "), " CalendarDay ")][text() = "15"]'
+ )
+ )[ 0 ].click();
await page.click( '.edit-post-post-visibility__toggle' );
@@ -58,7 +66,9 @@ describe( 'Post visibility', () => {
await page.click( '.editor-post-publish-button' );
const currentStatus = await page.evaluate( () => {
- return wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
+ return wp.data
+ .select( 'core/editor' )
+ .getEditedPostAttribute( 'status' );
} );
expect( currentStatus ).toBe( 'private' );
diff --git a/packages/e2e-tests/specs/editor/various/preferences.test.js b/packages/e2e-tests/specs/editor/various/preferences.test.js
index 24cf347d96501..b21c850b41651 100644
--- a/packages/e2e-tests/specs/editor/various/preferences.test.js
+++ b/packages/e2e-tests/specs/editor/various/preferences.test.js
@@ -44,7 +44,9 @@ describe( 'preferences', () => {
expect( await getActiveSidebarTabText() ).toBe( 'Document' );
// Dismiss
- await page.click( '.edit-post-sidebar__panel-tabs [aria-label="Close settings"]' );
+ await page.click(
+ '.edit-post-sidebar__panel-tabs [aria-label="Close settings"]'
+ );
expect( await getActiveSidebarTabText() ).toBe( null );
// Remember after reload.
diff --git a/packages/e2e-tests/specs/editor/various/preview.test.js b/packages/e2e-tests/specs/editor/various/preview.test.js
index 7c9442f1e982b..324be3f9f2efb 100644
--- a/packages/e2e-tests/specs/editor/various/preview.test.js
+++ b/packages/e2e-tests/specs/editor/various/preview.test.js
@@ -61,7 +61,8 @@ async function waitForPreviewNavigation( previewPage ) {
* @param {boolean} shouldBeChecked If true, turns the option on. If false, off.
*/
async function toggleCustomFieldsOption( shouldBeChecked ) {
- const checkboxXPath = '//*[contains(@class, "edit-post-options-modal")]//label[contains(text(), "Custom fields")]';
+ const checkboxXPath =
+ '//*[contains(@class, "edit-post-options-modal")]//label[contains(text(), "Custom fields")]';
await clickOnMoreMenuItem( 'Options' );
await page.waitForXPath( checkboxXPath );
const [ checkboxHandle ] = await page.$x( checkboxXPath );
@@ -73,7 +74,11 @@ async function toggleCustomFieldsOption( shouldBeChecked ) {
if ( isChecked !== shouldBeChecked ) {
await checkboxHandle.click();
- const [ saveButton ] = await page.$x( shouldBeChecked ? '//button[text()="Enable & Reload"]' : '//button[text()="Disable & Reload"]' );
+ const [ saveButton ] = await page.$x(
+ shouldBeChecked
+ ? '//button[text()="Enable & Reload"]'
+ : '//button[text()="Disable & Reload"]'
+ );
const navigationCompleted = page.waitForNavigation();
saveButton.click();
await navigationCompleted;
@@ -93,8 +98,8 @@ describe( 'Preview', () => {
// Disabled until content present.
const isPreviewDisabled = await editorPage.$$eval(
- '.editor-post-preview:not( :disabled )',
- ( enabledButtons ) => ! enabledButtons.length,
+ '.editor-post-preview:not( :disabled ):not( [aria-disabled="true"] )',
+ ( enabledButtons ) => ! enabledButtons.length
);
expect( isPreviewDisabled ).toBe( true );
@@ -104,15 +109,23 @@ describe( 'Preview', () => {
// When autosave completes for a new post, the URL of the editor should
// update to include the ID. Use this to assert on preview URL.
- const [ , postId ] = await ( await editorPage.waitForFunction( () => {
- return window.location.search.match( /[\?&]post=(\d+)/ );
- } ) ).jsonValue();
-
- const expectedPreviewURL = createURL( '', `?p=${ postId }&preview=true` );
+ const [ , postId ] = await (
+ await editorPage.waitForFunction( () => {
+ return window.location.search.match( /[\?&]post=(\d+)/ );
+ } )
+ ).jsonValue();
+
+ const expectedPreviewURL = createURL(
+ '',
+ `?p=${ postId }&preview=true`
+ );
expect( previewPage.url() ).toBe( expectedPreviewURL );
// Title in preview should match input.
- let previewTitle = await previewPage.$eval( '.entry-title', ( node ) => node.textContent );
+ let previewTitle = await previewPage.$eval(
+ '.entry-title',
+ ( node ) => node.textContent
+ );
expect( previewTitle ).toBe( 'Hello World' );
// Return to editor to change title.
@@ -121,14 +134,20 @@ describe( 'Preview', () => {
await waitForPreviewNavigation( previewPage );
// Title in preview should match updated input.
- previewTitle = await previewPage.$eval( '.entry-title', ( node ) => node.textContent );
+ previewTitle = await previewPage.$eval(
+ '.entry-title',
+ ( node ) => node.textContent
+ );
expect( previewTitle ).toBe( 'Hello World!' );
// Pressing preview without changes should bring same preview window to
// front and reload, but should not show interstitial.
await editorPage.bringToFront();
await waitForPreviewNavigation( previewPage );
- previewTitle = await previewPage.$eval( '.entry-title', ( node ) => node.textContent );
+ previewTitle = await previewPage.$eval(
+ '.entry-title',
+ ( node ) => node.textContent
+ );
expect( previewTitle ).toBe( 'Hello World!' );
// Preview for published post (no unsaved changes) directs to canonical URL for post.
@@ -141,7 +160,10 @@ describe( 'Preview', () => {
await waitForPreviewNavigation( previewPage );
// Title in preview should match updated input.
- previewTitle = await previewPage.$eval( '.entry-title', ( node ) => node.textContent );
+ previewTitle = await previewPage.$eval(
+ '.entry-title',
+ ( node ) => node.textContent
+ );
expect( previewTitle ).toBe( 'Hello World! And more.' );
// Published preview URL should include ID and nonce parameters.
@@ -159,7 +181,10 @@ describe( 'Preview', () => {
await waitForPreviewNavigation( previewPage );
// Title in preview should match updated input.
- previewTitle = await previewPage.$eval( '.entry-title', ( node ) => node.textContent );
+ previewTitle = await previewPage.$eval(
+ '.entry-title',
+ ( node ) => node.textContent
+ );
expect( previewTitle ).toBe( 'Hello World! And more.' );
await previewPage.close();
@@ -180,7 +205,10 @@ describe( 'Preview', () => {
const previewPage = await openPreviewPage( editorPage );
// Title in preview should match input.
- let previewTitle = await previewPage.$eval( '.entry-title', ( node ) => node.textContent );
+ let previewTitle = await previewPage.$eval(
+ '.entry-title',
+ ( node ) => node.textContent
+ );
expect( previewTitle ).toBe( 'aaaaa' );
// Return to editor.
@@ -196,7 +224,10 @@ describe( 'Preview', () => {
await waitForPreviewNavigation( previewPage );
// Title in preview should match updated input.
- previewTitle = await previewPage.$eval( '.entry-title', ( node ) => node.textContent );
+ previewTitle = await previewPage.$eval(
+ '.entry-title',
+ ( node ) => node.textContent
+ );
expect( previewTitle ).toBe( 'aaaaabbbbb' );
await previewPage.close();
@@ -231,9 +262,15 @@ describe( 'Preview with Custom Fields enabled', () => {
const previewPage = await openPreviewPage( editorPage );
// Check the title and preview match.
- let previewTitle = await previewPage.$eval( '.entry-title', ( node ) => node.textContent );
+ let previewTitle = await previewPage.$eval(
+ '.entry-title',
+ ( node ) => node.textContent
+ );
expect( previewTitle ).toBe( 'title 1' );
- let previewContent = await previewPage.$eval( '.entry-content p', ( node ) => node.textContent );
+ let previewContent = await previewPage.$eval(
+ '.entry-content p',
+ ( node ) => node.textContent
+ );
expect( previewContent ).toBe( 'content 1' );
// Return to editor and modify the title and content.
@@ -251,9 +288,15 @@ describe( 'Preview with Custom Fields enabled', () => {
await waitForPreviewNavigation( previewPage );
// Title in preview should match input.
- previewTitle = await previewPage.$eval( '.entry-title', ( node ) => node.textContent );
+ previewTitle = await previewPage.$eval(
+ '.entry-title',
+ ( node ) => node.textContent
+ );
expect( previewTitle ).toBe( 'title 2' );
- previewContent = await previewPage.$eval( '.entry-content p', ( node ) => node.textContent );
+ previewContent = await previewPage.$eval(
+ '.entry-content p',
+ ( node ) => node.textContent
+ );
expect( previewContent ).toBe( 'content 2' );
// Make sure the editor is active for the afterEach function.
diff --git a/packages/e2e-tests/specs/editor/various/publish-button.test.js b/packages/e2e-tests/specs/editor/various/publish-button.test.js
index ecdd6bf76b000..680ca0082c2ed 100644
--- a/packages/e2e-tests/specs/editor/various/publish-button.test.js
+++ b/packages/e2e-tests/specs/editor/various/publish-button.test.js
@@ -11,7 +11,7 @@ import {
describe( 'PostPublishButton', () => {
let werePrePublishChecksEnabled;
beforeEach( async () => {
- await createNewPost( );
+ await createNewPost();
werePrePublishChecksEnabled = await arePrePublishChecksEnabled();
if ( werePrePublishChecksEnabled ) {
await disablePrePublishChecks();
@@ -25,23 +25,35 @@ describe( 'PostPublishButton', () => {
} );
it( 'should be disabled when post is not saveable', async () => {
- const publishButton = await page.$( '.editor-post-publish-button[aria-disabled="true"]' );
+ const publishButton = await page.$(
+ '.editor-post-publish-button[aria-disabled="true"]'
+ );
expect( publishButton ).not.toBeNull();
} );
it( 'should be disabled when post is being saved', async () => {
await page.type( '.editor-post-title__input', 'E2E Test Post' ); // Make it saveable
- expect( await page.$( '.editor-post-publish-button[aria-disabled="true"]' ) ).toBeNull();
+ expect(
+ await page.$( '.editor-post-publish-button[aria-disabled="true"]' )
+ ).toBeNull();
await page.click( '.editor-post-save-draft' );
- expect( await page.$( '.editor-post-publish-button[aria-disabled="true"]' ) ).not.toBeNull();
+ expect(
+ await page.$( '.editor-post-publish-button[aria-disabled="true"]' )
+ ).not.toBeNull();
} );
it( 'should be disabled when metabox is being saved', async () => {
await page.type( '.editor-post-title__input', 'E2E Test Post' ); // Make it saveable
- expect( await page.$( '.editor-post-publish-button[aria-disabled="true"]' ) ).toBeNull();
+ expect(
+ await page.$( '.editor-post-publish-button[aria-disabled="true"]' )
+ ).toBeNull();
- await page.evaluate( () => window.wp.data.dispatch( 'core/edit-post' ).requestMetaBoxUpdates() );
- expect( await page.$( '.editor-post-publish-button[aria-disabled="true"]' ) ).not.toBeNull();
+ await page.evaluate( () =>
+ window.wp.data.dispatch( 'core/edit-post' ).requestMetaBoxUpdates()
+ );
+ expect(
+ await page.$( '.editor-post-publish-button[aria-disabled="true"]' )
+ ).not.toBeNull();
} );
} );
diff --git a/packages/e2e-tests/specs/editor/various/publish-panel.test.js b/packages/e2e-tests/specs/editor/various/publish-panel.test.js
index c28a3837d7443..3a6aefd8f6687 100644
--- a/packages/e2e-tests/specs/editor/various/publish-panel.test.js
+++ b/packages/e2e-tests/specs/editor/various/publish-panel.test.js
@@ -14,7 +14,7 @@ import {
describe( 'PostPublishPanel', () => {
let werePrePublishChecksEnabled;
beforeEach( async () => {
- await createNewPost( );
+ await createNewPost();
werePrePublishChecksEnabled = await arePrePublishChecksEnabled();
if ( ! werePrePublishChecksEnabled ) {
await enablePrePublishChecks();
@@ -31,10 +31,15 @@ describe( 'PostPublishPanel', () => {
await page.type( '.editor-post-title__input', 'E2E Test Post' );
await openPublishPanel();
- const focusedElementClassList = await page.$eval( ':focus', ( focusedElement ) => {
- return Object.values( focusedElement.classList );
- } );
- expect( focusedElementClassList ).toContain( 'editor-post-publish-button' );
+ const focusedElementClassList = await page.$eval(
+ ':focus',
+ ( focusedElement ) => {
+ return Object.values( focusedElement.classList );
+ }
+ );
+ expect( focusedElementClassList ).toContain(
+ 'editor-post-publish-button'
+ );
} );
it( 'PostPublish: post link should have the focus', async () => {
@@ -42,12 +47,18 @@ describe( 'PostPublishPanel', () => {
await page.type( '.editor-post-title__input', postTitle );
await publishPost();
- const focusedElementTag = await page.$eval( ':focus', ( focusedElement ) => {
- return focusedElement.tagName.toLowerCase();
- } );
- const focusedElementText = await page.$eval( ':focus', ( focusedElement ) => {
- return focusedElement.text;
- } );
+ const focusedElementTag = await page.$eval(
+ ':focus',
+ ( focusedElement ) => {
+ return focusedElement.tagName.toLowerCase();
+ }
+ );
+ const focusedElementText = await page.$eval(
+ ':focus',
+ ( focusedElement ) => {
+ return focusedElement.text;
+ }
+ );
expect( focusedElementTag ).toBe( 'a' );
expect( focusedElementText ).toBe( postTitle );
} );
@@ -57,9 +68,14 @@ describe( 'PostPublishPanel', () => {
await openPublishPanel();
await pressKeyWithModifier( 'shift', 'Tab' );
- const focusedElementClassList = await page.$eval( ':focus', ( focusedElement ) => {
- return Object.values( focusedElement.classList );
- } );
- expect( focusedElementClassList ).toContain( 'components-checkbox-control__input' );
+ const focusedElementClassList = await page.$eval(
+ ':focus',
+ ( focusedElement ) => {
+ return Object.values( focusedElement.classList );
+ }
+ );
+ expect( focusedElementClassList ).toContain(
+ 'components-checkbox-control__input'
+ );
} );
} );
diff --git a/packages/e2e-tests/specs/editor/various/publishing.test.js b/packages/e2e-tests/specs/editor/various/publishing.test.js
index 64b8705ef8bab..745008a0a15f1 100644
--- a/packages/e2e-tests/specs/editor/various/publishing.test.js
+++ b/packages/e2e-tests/specs/editor/various/publishing.test.js
@@ -12,41 +12,40 @@ import {
} from '@wordpress/e2e-test-utils';
describe( 'Publishing', () => {
- describe.each( [ 'post', 'page' ] )(
- 'a %s',
- ( postType ) => {
- let werePrePublishChecksEnabled;
+ describe.each( [ 'post', 'page' ] )( 'a %s', ( postType ) => {
+ let werePrePublishChecksEnabled;
- beforeEach( async () => {
- await createNewPost( postType );
- werePrePublishChecksEnabled = await arePrePublishChecksEnabled();
- if ( ! werePrePublishChecksEnabled ) {
- await enablePrePublishChecks();
- }
- } );
+ beforeEach( async () => {
+ await createNewPost( postType );
+ werePrePublishChecksEnabled = await arePrePublishChecksEnabled();
+ if ( ! werePrePublishChecksEnabled ) {
+ await enablePrePublishChecks();
+ }
+ } );
- afterEach( async () => {
- if ( ! werePrePublishChecksEnabled ) {
- await disablePrePublishChecks();
- }
- } );
+ afterEach( async () => {
+ if ( ! werePrePublishChecksEnabled ) {
+ await disablePrePublishChecks();
+ }
+ } );
- it( `should publish the ${ postType } and close the panel once we start editing again.`, async () => {
- await page.type( '.editor-post-title__input', 'E2E Test Post' );
+ it( `should publish the ${ postType } and close the panel once we start editing again.`, async () => {
+ await page.type( '.editor-post-title__input', 'E2E Test Post' );
- await publishPost();
+ await publishPost();
- // The post-publishing panel is visible.
- expect( await page.$( '.editor-post-publish-panel' ) ).not.toBeNull();
+ // The post-publishing panel is visible.
+ expect(
+ await page.$( '.editor-post-publish-panel' )
+ ).not.toBeNull();
- // Start editing again.
- await page.type( '.editor-post-title__input', ' (Updated)' );
+ // Start editing again.
+ await page.type( '.editor-post-title__input', ' (Updated)' );
- // The post-publishing panel is not visible anymore.
- expect( await page.$( '.editor-post-publish-panel' ) ).toBeNull();
- } );
- }
- );
+ // The post-publishing panel is not visible anymore.
+ expect( await page.$( '.editor-post-publish-panel' ) ).toBeNull();
+ } );
+ } );
describe.each( [ 'post', 'page' ] )(
'a %s with pre-publish checks disabled',
@@ -71,13 +70,19 @@ describe( 'Publishing', () => {
await page.type( '.editor-post-title__input', 'E2E Test Post' );
// The "Publish" button should be shown instead of the "Publish..." toggle
- expect( await page.$( '.editor-post-publish-panel__toggle' ) ).toBeNull();
- expect( await page.$( '.editor-post-publish-button' ) ).not.toBeNull();
+ expect(
+ await page.$( '.editor-post-publish-panel__toggle' )
+ ).toBeNull();
+ expect(
+ await page.$( '.editor-post-publish-button' )
+ ).not.toBeNull();
await publishPostWithPrePublishChecksDisabled();
// The post-publishing panel should have been not shown.
- expect( await page.$( '.editor-post-publish-panel' ) ).toBeNull();
+ expect(
+ await page.$( '.editor-post-publish-panel' )
+ ).toBeNull();
} );
}
);
@@ -104,8 +109,12 @@ describe( 'Publishing', () => {
} );
it( `should ignore the pre-publish checks and show the Publish... toggle instead of the Publish button`, async () => {
- expect( await page.$( '.editor-post-publish-panel__toggle' ) ).not.toBeNull();
- expect( await page.$( '.editor-post-publish-button' ) ).toBeNull();
+ expect(
+ await page.$( '.editor-post-publish-panel__toggle' )
+ ).not.toBeNull();
+ expect(
+ await page.$( '.editor-post-publish-button' )
+ ).toBeNull();
} );
}
);
diff --git a/packages/e2e-tests/specs/editor/various/reusable-blocks.test.js b/packages/e2e-tests/specs/editor/various/reusable-blocks.test.js
index 7f2e8a4b6ea03..b453bbc0aeeee 100644
--- a/packages/e2e-tests/specs/editor/various/reusable-blocks.test.js
+++ b/packages/e2e-tests/specs/editor/various/reusable-blocks.test.js
@@ -37,7 +37,9 @@ describe( 'Reusable blocks', () => {
await clickBlockToolbarButton( 'More options' );
- const convertButton = await page.waitForXPath( '//button[text()="Add to Reusable blocks"]' );
+ const convertButton = await page.waitForXPath(
+ '//button[text()="Add to Reusable blocks"]'
+ );
await convertButton.click();
// Wait for creation to finish
@@ -59,7 +61,9 @@ describe( 'Reusable blocks', () => {
await page.waitForXPath( '//button[text()="Edit"]' );
// Check that we have a reusable block on the page
- const block = await page.$( '.block-editor-block-list__block[data-type="core/block"]' );
+ const block = await page.$(
+ '.block-editor-block-list__block[data-type="core/block"]'
+ );
expect( block ).not.toBeNull();
// Check that its title is displayed
@@ -77,7 +81,9 @@ describe( 'Reusable blocks', () => {
await clickBlockToolbarButton( 'More options' );
- const convertButton = await page.waitForXPath( '//button[text()="Add to Reusable blocks"]' );
+ const convertButton = await page.waitForXPath(
+ '//button[text()="Add to Reusable blocks"]'
+ );
await convertButton.click();
// Wait for creation to finish
@@ -93,7 +99,9 @@ describe( 'Reusable blocks', () => {
await page.waitForXPath( '//button[text()="Edit"]' );
// Check that we have a reusable block on the page
- const block = await page.$( '.block-editor-block-list__block[data-type="core/block"]' );
+ const block = await page.$(
+ '.block-editor-block-list__block[data-type="core/block"]'
+ );
expect( block ).not.toBeNull();
// Check that it is untitled
@@ -134,7 +142,9 @@ describe( 'Reusable blocks', () => {
await page.waitForXPath( '//button[text()="Edit"]' );
// Check that we have a reusable block on the page
- const block = await page.$( '.block-editor-block-list__block[data-type="core/block"]' );
+ const block = await page.$(
+ '.block-editor-block-list__block[data-type="core/block"]'
+ );
expect( block ).not.toBeNull();
// Check that its title is displayed
@@ -164,7 +174,9 @@ describe( 'Reusable blocks', () => {
await convertButton.click();
// Check that we have a paragraph block on the page
- const block = await page.$( '.block-editor-block-list__block[data-type="core/paragraph"]' );
+ const block = await page.$(
+ '.block-editor-block-list__block[data-type="core/paragraph"]'
+ );
expect( block ).not.toBeNull();
// Check that its content is up to date
@@ -181,7 +193,9 @@ describe( 'Reusable blocks', () => {
// Delete the block and accept the confirmation dialog
await clickBlockToolbarButton( 'More options' );
- const deleteButton = await page.waitForXPath( '//button[text()="Remove from Reusable blocks"]' );
+ const deleteButton = await page.waitForXPath(
+ '//button[text()="Remove from Reusable blocks"]'
+ );
await Promise.all( [ waitForAndAcceptDialog(), deleteButton.click() ] );
// Wait for deletion to finish
@@ -217,7 +231,9 @@ describe( 'Reusable blocks', () => {
// Convert block to a reusable block
await clickBlockToolbarButton( 'More options' );
- const convertButton = await page.waitForXPath( '//button[text()="Add to Reusable blocks"]' );
+ const convertButton = await page.waitForXPath(
+ '//button[text()="Add to Reusable blocks"]'
+ );
await convertButton.click();
// Wait for creation to finish
@@ -239,7 +255,9 @@ describe( 'Reusable blocks', () => {
await page.waitForXPath( '//button[text()="Edit"]' );
// Check that we have a reusable block on the page
- const block = await page.$( '.block-editor-block-list__block[data-type="core/block"]' );
+ const block = await page.$(
+ '.block-editor-block-list__block[data-type="core/block"]'
+ );
expect( block ).not.toBeNull();
// Check that its title is displayed
diff --git a/packages/e2e-tests/specs/editor/various/rich-text.test.js b/packages/e2e-tests/specs/editor/various/rich-text.test.js
index 262f5c53cbb79..cd3fa85e62fdc 100644
--- a/packages/e2e-tests/specs/editor/various/rich-text.test.js
+++ b/packages/e2e-tests/specs/editor/various/rich-text.test.js
@@ -70,9 +70,11 @@ describe( 'RichText', () => {
await pressKeyWithModifier( 'shift', 'ArrowLeft' );
await pressKeyWithModifier( 'primary', 'b' );
- const count = await page.evaluate( () => document.querySelectorAll(
- '*[data-rich-text-format-boundary]'
- ).length );
+ const count = await page.evaluate(
+ () =>
+ document.querySelectorAll( '*[data-rich-text-format-boundary]' )
+ .length
+ );
expect( count ).toBe( 1 );
} );
@@ -182,21 +184,32 @@ describe( 'RichText', () => {
window.unsubscribes = [ () => mutationObserver.disconnect() ];
- document.addEventListener( 'selectionchange', () => {
- function throwMultipleSelectionChange() {
- throw new Error( 'Typing should only emit one selection change event.' );
- }
-
- document.addEventListener(
- 'selectionchange',
- throwMultipleSelectionChange,
- { once: true }
- );
+ document.addEventListener(
+ 'selectionchange',
+ () => {
+ function throwMultipleSelectionChange() {
+ throw new Error(
+ 'Typing should only emit one selection change event.'
+ );
+ }
- window.unsubscribes.push( () => {
- document.removeEventListener( 'selectionchange', throwMultipleSelectionChange );
- } );
- }, { once: true } );
+ document.addEventListener(
+ 'selectionchange',
+ throwMultipleSelectionChange,
+ {
+ once: true,
+ }
+ );
+
+ window.unsubscribes.push( () => {
+ document.removeEventListener(
+ 'selectionchange',
+ throwMultipleSelectionChange
+ );
+ } );
+ },
+ { once: true }
+ );
} );
await page.keyboard.type( '4' );
@@ -206,7 +219,9 @@ describe( 'RichText', () => {
// one item in `window.unsubscribes`, it means that only one
// function is present to disconnect the `mutationObserver`.
if ( window.unsubscribes.length === 1 ) {
- throw new Error( 'The selection change event listener was never called.' );
+ throw new Error(
+ 'The selection change event listener was never called.'
+ );
}
window.unsubscribes.forEach( ( unsubscribe ) => unsubscribe() );
@@ -275,7 +290,9 @@ describe( 'RichText', () => {
} );
// Wait for the next animation frame, see the focus event listener in
// RichText.
- await page.evaluate( () => new Promise( window.requestAnimationFrame ) );
+ await page.evaluate(
+ () => new Promise( window.requestAnimationFrame )
+ );
await pressKeyWithModifier( 'primary', 'b' );
await page.keyboard.type( '2' );
await pressKeyWithModifier( 'primary', 'b' );
diff --git a/packages/e2e-tests/specs/editor/various/rtl.test.js b/packages/e2e-tests/specs/editor/various/rtl.test.js
index 76e6d15ff9aa3..c4fd3797cc292 100644
--- a/packages/e2e-tests/specs/editor/various/rtl.test.js
+++ b/packages/e2e-tests/specs/editor/various/rtl.test.js
@@ -18,7 +18,7 @@ describe( 'RTL', () => {
} );
it( 'should arrow navigate', async () => {
- await page.evaluate( () => document.dir = 'rtl' );
+ await page.evaluate( () => ( document.dir = 'rtl' ) );
await page.keyboard.press( 'Enter' );
// We need at least three characters as arrow navigation *from* the
@@ -36,7 +36,7 @@ describe( 'RTL', () => {
} );
it( 'should split', async () => {
- await page.evaluate( () => document.dir = 'rtl' );
+ await page.evaluate( () => ( document.dir = 'rtl' ) );
await page.keyboard.press( 'Enter' );
await page.keyboard.type( ARABIC_ZERO );
@@ -48,7 +48,7 @@ describe( 'RTL', () => {
} );
it( 'should merge backward', async () => {
- await page.evaluate( () => document.dir = 'rtl' );
+ await page.evaluate( () => ( document.dir = 'rtl' ) );
await page.keyboard.press( 'Enter' );
await page.keyboard.type( ARABIC_ZERO );
@@ -61,7 +61,7 @@ describe( 'RTL', () => {
} );
it( 'should merge forward', async () => {
- await page.evaluate( () => document.dir = 'rtl' );
+ await page.evaluate( () => ( document.dir = 'rtl' ) );
await page.keyboard.press( 'Enter' );
await page.keyboard.type( ARABIC_ZERO );
@@ -75,7 +75,7 @@ describe( 'RTL', () => {
} );
it( 'should arrow navigate between blocks', async () => {
- await page.evaluate( () => document.dir = 'rtl' );
+ await page.evaluate( () => ( document.dir = 'rtl' ) );
await page.keyboard.press( 'Enter' );
await page.keyboard.type( ARABIC_ZERO );
@@ -101,7 +101,7 @@ describe( 'RTL', () => {
} );
it( 'should navigate inline boundaries', async () => {
- await page.evaluate( () => document.dir = 'rtl' );
+ await page.evaluate( () => ( document.dir = 'rtl' ) );
await page.keyboard.press( 'Enter' );
await pressKeyWithModifier( 'primary', 'b' );
diff --git a/packages/e2e-tests/specs/editor/various/scheduling.test.js b/packages/e2e-tests/specs/editor/various/scheduling.test.js
index 3cd75b21d8e29..7732f8d8a0e7c 100644
--- a/packages/e2e-tests/specs/editor/various/scheduling.test.js
+++ b/packages/e2e-tests/specs/editor/various/scheduling.test.js
@@ -1,16 +1,16 @@
/**
* WordPress dependencies
*/
-import {
- createNewPost,
-} from '@wordpress/e2e-test-utils';
+import { createNewPost } from '@wordpress/e2e-test-utils';
describe( 'Scheduling', () => {
beforeEach( createNewPost );
const isDateTimeComponentFocused = () => {
return page.evaluate( () => {
- const dateTimeElement = document.querySelector( '.components-datetime__date' );
+ const dateTimeElement = document.querySelector(
+ '.components-datetime__date'
+ );
if ( ! dateTimeElement || ! document.activeElement ) {
return false;
}
@@ -20,9 +20,13 @@ describe( 'Scheduling', () => {
it( 'Should keep date time UI focused when the previous and next month buttons are clicked', async () => {
await page.click( '.edit-post-post-schedule__toggle' );
- await page.click( 'div[aria-label="Move backward to switch to the previous month."]' );
+ await page.click(
+ 'div[aria-label="Move backward to switch to the previous month."]'
+ );
expect( await isDateTimeComponentFocused() ).toBe( true );
- await page.click( 'div[aria-label="Move forward to switch to the next month."]' );
+ await page.click(
+ 'div[aria-label="Move forward to switch to the next month."]'
+ );
expect( await isDateTimeComponentFocused() ).toBe( true );
} );
} );
diff --git a/packages/e2e-tests/specs/editor/various/shortcut-help.test.js b/packages/e2e-tests/specs/editor/various/shortcut-help.test.js
index 23d51ef2c2d70..838a3edac2a2a 100644
--- a/packages/e2e-tests/specs/editor/various/shortcut-help.test.js
+++ b/packages/e2e-tests/specs/editor/various/shortcut-help.test.js
@@ -15,25 +15,33 @@ describe( 'keyboard shortcut help modal', () => {
it( 'displays the shortcut help modal when opened using the menu item in the more menu', async () => {
await clickOnMoreMenuItem( 'Keyboard shortcuts' );
- const shortcutHelpModalElements = await page.$$( '.edit-post-keyboard-shortcut-help-modal' );
+ const shortcutHelpModalElements = await page.$$(
+ '.edit-post-keyboard-shortcut-help-modal'
+ );
expect( shortcutHelpModalElements ).toHaveLength( 1 );
} );
it( 'closes the shortcut help modal when the close icon is clicked', async () => {
await clickOnCloseModalButton();
- const shortcutHelpModalElements = await page.$$( '.edit-post-keyboard-shortcut-help-modal' );
+ const shortcutHelpModalElements = await page.$$(
+ '.edit-post-keyboard-shortcut-help-modal'
+ );
expect( shortcutHelpModalElements ).toHaveLength( 0 );
} );
it( 'displays the shortcut help modal when opened using the shortcut key (access+h)', async () => {
await pressKeyWithModifier( 'access', 'h' );
- const shortcutHelpModalElements = await page.$$( '.edit-post-keyboard-shortcut-help-modal' );
+ const shortcutHelpModalElements = await page.$$(
+ '.edit-post-keyboard-shortcut-help-modal'
+ );
expect( shortcutHelpModalElements ).toHaveLength( 1 );
} );
it( 'closes the shortcut help modal when the shortcut key (access+h) is pressed again', async () => {
await pressKeyWithModifier( 'access', 'h' );
- const shortcutHelpModalElements = await page.$$( '.edit-post-keyboard-shortcut-help-modal' );
+ const shortcutHelpModalElements = await page.$$(
+ '.edit-post-keyboard-shortcut-help-modal'
+ );
expect( shortcutHelpModalElements ).toHaveLength( 0 );
} );
} );
diff --git a/packages/e2e-tests/specs/editor/various/sidebar-permalink-panel.test.js b/packages/e2e-tests/specs/editor/various/sidebar-permalink-panel.test.js
index 16de106f570e6..33a58782fa64b 100644
--- a/packages/e2e-tests/specs/editor/various/sidebar-permalink-panel.test.js
+++ b/packages/e2e-tests/specs/editor/various/sidebar-permalink-panel.test.js
@@ -26,7 +26,9 @@ describe( 'Sidebar Permalink Panel', () => {
it( 'should not render permalink sidebar panel while the post is new', async () => {
await createNewPost();
await openDocumentSettingsSidebar();
- expect( await findSidebarPanelWithTitle( 'Permalink' ) ).toBeUndefined();
+ expect(
+ await findSidebarPanelWithTitle( 'Permalink' )
+ ).toBeUndefined();
} );
it( 'should render permalink sidebar panel after the post is published and allow its removal', async () => {
@@ -40,7 +42,9 @@ describe( 'Sidebar Permalink Panel', () => {
const { removeEditorPanel } = wp.data.dispatch( 'core/edit-post' );
removeEditorPanel( 'post-link' );
} );
- expect( await findSidebarPanelWithTitle( 'Permalink' ) ).toBeUndefined();
+ expect(
+ await findSidebarPanelWithTitle( 'Permalink' )
+ ).toBeUndefined();
} );
it( 'should not render link panel when post is publicly queryable but not public', async () => {
@@ -49,7 +53,9 @@ describe( 'Sidebar Permalink Panel', () => {
await publishPost();
// Start editing again.
await page.type( '.editor-post-title__input', ' (Updated)' );
- expect( await findSidebarPanelWithTitle( 'Permalink' ) ).toBeUndefined();
+ expect(
+ await findSidebarPanelWithTitle( 'Permalink' )
+ ).toBeUndefined();
} );
it( 'should not render link panel when post is public but not publicly queryable', async () => {
@@ -58,7 +64,9 @@ describe( 'Sidebar Permalink Panel', () => {
await publishPost();
// Start editing again.
await page.type( '.editor-post-title__input', ' (Updated)' );
- expect( await findSidebarPanelWithTitle( 'Permalink' ) ).toBeUndefined();
+ expect(
+ await findSidebarPanelWithTitle( 'Permalink' )
+ ).toBeUndefined();
} );
it( 'should render link panel when post is public and publicly queryable', async () => {
diff --git a/packages/e2e-tests/specs/editor/various/sidebar.test.js b/packages/e2e-tests/specs/editor/various/sidebar.test.js
index 323a83544ef4d..ab2043f17b887 100644
--- a/packages/e2e-tests/specs/editor/various/sidebar.test.js
+++ b/packages/e2e-tests/specs/editor/various/sidebar.test.js
@@ -26,15 +26,18 @@ describe( 'Sidebar', () => {
await clearLocalStorage();
await createNewPost();
await enableFocusLossObservation();
- const { nodesCount, content, height, width } = await page.$$eval( ACTIVE_SIDEBAR_TAB_SELECTOR, ( nodes ) => {
- const firstNode = nodes[ 0 ];
- return {
- nodesCount: nodes.length,
- content: firstNode.innerText,
- height: firstNode.offsetHeight,
- width: firstNode.offsetWidth,
- };
- } );
+ const { nodesCount, content, height, width } = await page.$$eval(
+ ACTIVE_SIDEBAR_TAB_SELECTOR,
+ ( nodes ) => {
+ const firstNode = nodes[ 0 ];
+ return {
+ nodesCount: nodes.length,
+ content: firstNode.innerText,
+ height: firstNode.offsetHeight,
+ width: firstNode.offsetWidth,
+ };
+ }
+ );
// should have only one active sidebar tab.
expect( nodesCount ).toBe( 1 );
@@ -96,23 +99,24 @@ describe( 'Sidebar', () => {
await pressKeyWithModifier( 'ctrl', '`' );
await pressKeyWithModifier( 'ctrl', '`' );
await pressKeyWithModifier( 'ctrl', '`' );
- await pressKeyWithModifier( 'ctrl', '`' );
// Tab lands at first (presumed selected) option "Document".
await page.keyboard.press( 'Tab' );
- const isActiveDocumentTab = await page.evaluate( () => (
- document.activeElement.textContent === 'Document' &&
- document.activeElement.classList.contains( 'is-active' )
- ) );
+ const isActiveDocumentTab = await page.evaluate(
+ () =>
+ document.activeElement.textContent === 'Document' &&
+ document.activeElement.classList.contains( 'is-active' )
+ );
expect( isActiveDocumentTab ).toBe( true );
// Tab into and activate "Block".
await page.keyboard.press( 'Tab' );
await page.keyboard.press( 'Space' );
- const isActiveBlockTab = await page.evaluate( () => (
- document.activeElement.textContent === 'Block' &&
- document.activeElement.classList.contains( 'is-active' )
- ) );
+ const isActiveBlockTab = await page.evaluate(
+ () =>
+ document.activeElement.textContent === 'Block' &&
+ document.activeElement.classList.contains( 'is-active' )
+ );
expect( isActiveBlockTab ).toBe( true );
} );
@@ -124,10 +128,14 @@ describe( 'Sidebar', () => {
expect( await findSidebarPanelWithTitle( 'Categories' ) ).toBeDefined();
expect( await findSidebarPanelWithTitle( 'Tags' ) ).toBeDefined();
- expect( await findSidebarPanelWithTitle( 'Featured image' ) ).toBeDefined();
+ expect(
+ await findSidebarPanelWithTitle( 'Featured image' )
+ ).toBeDefined();
expect( await findSidebarPanelWithTitle( 'Excerpt' ) ).toBeDefined();
expect( await findSidebarPanelWithTitle( 'Discussion' ) ).toBeDefined();
- expect( await findSidebarPanelWithTitle( 'Status & visibility' ) ).toBeDefined();
+ expect(
+ await findSidebarPanelWithTitle( 'Status & visibility' )
+ ).toBeDefined();
await page.evaluate( () => {
const { removeEditorPanel } = wp.data.dispatch( 'core/edit-post' );
@@ -140,11 +148,19 @@ describe( 'Sidebar', () => {
removeEditorPanel( 'post-status' );
} );
- expect( await findSidebarPanelWithTitle( 'Categories' ) ).toBeUndefined();
+ expect(
+ await findSidebarPanelWithTitle( 'Categories' )
+ ).toBeUndefined();
expect( await findSidebarPanelWithTitle( 'Tags' ) ).toBeUndefined();
- expect( await findSidebarPanelWithTitle( 'Featured image' ) ).toBeUndefined();
+ expect(
+ await findSidebarPanelWithTitle( 'Featured image' )
+ ).toBeUndefined();
expect( await findSidebarPanelWithTitle( 'Excerpt' ) ).toBeUndefined();
- expect( await findSidebarPanelWithTitle( 'Discussion' ) ).toBeUndefined();
- expect( await findSidebarPanelWithTitle( 'Status & visibility' ) ).toBeUndefined();
+ expect(
+ await findSidebarPanelWithTitle( 'Discussion' )
+ ).toBeUndefined();
+ expect(
+ await findSidebarPanelWithTitle( 'Status & visibility' )
+ ).toBeUndefined();
} );
} );
diff --git a/packages/e2e-tests/specs/editor/various/splitting-merging.test.js b/packages/e2e-tests/specs/editor/various/splitting-merging.test.js
index a394317c5dd75..05e08db82afce 100644
--- a/packages/e2e-tests/specs/editor/various/splitting-merging.test.js
+++ b/packages/e2e-tests/specs/editor/various/splitting-merging.test.js
@@ -194,7 +194,9 @@ describe( 'splitting and merging blocks', () => {
await page.keyboard.press( 'Backspace' );
// There is a default block:
- expect( await page.$$( '.block-editor-block-list__block' ) ).toHaveLength( 1 );
+ expect(
+ await page.$$( '.block-editor-block-list__block' )
+ ).toHaveLength( 1 );
// But the effective saved content is still empty:
expect( await getEditedPostContent() ).toBe( '' );
diff --git a/packages/e2e-tests/specs/editor/various/style-variation.test.js b/packages/e2e-tests/specs/editor/various/style-variation.test.js
index 7b073fe7b3f26..9d070c0d95b43 100644
--- a/packages/e2e-tests/specs/editor/various/style-variation.test.js
+++ b/packages/e2e-tests/specs/editor/various/style-variation.test.js
@@ -20,7 +20,9 @@ describe( 'adding blocks', () => {
await clickBlockToolbarButton( 'Change block type or style' );
- const styleVariations = await page.$$( '.block-editor-block-styles__item' );
+ const styleVariations = await page.$$(
+ '.block-editor-block-styles__item'
+ );
await styleVariations[ 1 ].click();
// Check the content
diff --git a/packages/e2e-tests/specs/editor/various/taxonomies.test.js b/packages/e2e-tests/specs/editor/various/taxonomies.test.js
index f68343dcb2866..45ac6cbc1e320 100644
--- a/packages/e2e-tests/specs/editor/various/taxonomies.test.js
+++ b/packages/e2e-tests/specs/editor/various/taxonomies.test.js
@@ -16,43 +16,45 @@ import {
/**
* Module constants
*/
-const TAG_TOKEN_SELECTOR = '.components-form-token-field__token-text span:not(.components-visually-hidden)';
+const TAG_TOKEN_SELECTOR =
+ '.components-form-token-field__token-text span:not(.components-visually-hidden)';
describe( 'Taxonomies', () => {
const canCreatTermInTaxonomy = ( taxonomy ) => {
- return page.evaluate(
- ( _taxonomy ) => {
- const post = wp.data.select( 'core/editor' ).getCurrentPost();
- if ( ! post._links ) {
- return false;
- }
- return !! post._links[ `wp:action-create-${ _taxonomy }` ];
- },
- taxonomy
- );
+ return page.evaluate( ( _taxonomy ) => {
+ const post = wp.data.select( 'core/editor' ).getCurrentPost();
+ if ( ! post._links ) {
+ return false;
+ }
+ return !! post._links[ `wp:action-create-${ _taxonomy }` ];
+ }, taxonomy );
};
const getSelectCategories = () => {
- return page.evaluate(
- () => {
- return Array.from( document.querySelectorAll(
+ return page.evaluate( () => {
+ return Array.from(
+ document.querySelectorAll(
'.editor-post-taxonomies__hierarchical-terms-choice .components-checkbox-control__input:checked'
- ) ).map( ( node ) => {
- return node.parentElement.nextSibling.innerText;
- } );
- }
- );
+ )
+ ).map( ( node ) => {
+ return node.parentElement.nextSibling.innerText;
+ } );
+ } );
};
const getCurrentTags = async () => {
const tagsPanel = await findSidebarPanelWithTitle( 'Tags' );
- return page.evaluate( ( node, selector ) => {
- return Array.from( node.querySelectorAll(
- selector
- ) ).map( ( field ) => {
- return field.innerText;
- } );
- }, tagsPanel, TAG_TOKEN_SELECTOR );
+ return page.evaluate(
+ ( node, selector ) => {
+ return Array.from( node.querySelectorAll( selector ) ).map(
+ ( field ) => {
+ return field.innerText;
+ }
+ );
+ },
+ tagsPanel,
+ TAG_TOKEN_SELECTOR
+ );
};
const openSidebarPanelWithTitle = async ( title ) => {
@@ -74,10 +76,14 @@ describe( 'Taxonomies', () => {
return;
}
- await page.waitForSelector( 'button.editor-post-taxonomies__hierarchical-terms-add' );
+ await page.waitForSelector(
+ 'button.editor-post-taxonomies__hierarchical-terms-add'
+ );
// Click add new category button.
- await page.click( 'button.editor-post-taxonomies__hierarchical-terms-add' );
+ await page.click(
+ 'button.editor-post-taxonomies__hierarchical-terms-add'
+ );
// Type the category name in the field.
await page.type(
@@ -86,10 +92,14 @@ describe( 'Taxonomies', () => {
);
// Click the submit button.
- await page.click( '.editor-post-taxonomies__hierarchical-terms-submit' );
+ await page.click(
+ '.editor-post-taxonomies__hierarchical-terms-submit'
+ );
// Wait for the categories to load.
- await page.waitForSelector( '.editor-post-taxonomies__hierarchical-terms-choice .components-checkbox-control__input:checked' );
+ await page.waitForSelector(
+ '.editor-post-taxonomies__hierarchical-terms-choice .components-checkbox-control__input:checked'
+ );
let selectedCategories = await getSelectCategories();
@@ -107,7 +117,9 @@ describe( 'Taxonomies', () => {
await page.reload();
// Wait for the categories to load.
- await page.waitForSelector( '.editor-post-taxonomies__hierarchical-terms-choice .components-checkbox-control__input:checked' );
+ await page.waitForSelector(
+ '.editor-post-taxonomies__hierarchical-terms-choice .components-checkbox-control__input:checked'
+ );
selectedCategories = await getSelectCategories();
@@ -129,14 +141,12 @@ describe( 'Taxonomies', () => {
}
// At the start there are no tag tokens
- expect(
- await page.$$(
- TAG_TOKEN_SELECTOR
- )
- ).toHaveLength( 0 );
+ expect( await page.$$( TAG_TOKEN_SELECTOR ) ).toHaveLength( 0 );
const tagsPanel = await findSidebarPanelWithTitle( 'Tags' );
- const tagInput = await tagsPanel.$( '.components-form-token-field__input' );
+ const tagInput = await tagsPanel.$(
+ '.components-form-token-field__input'
+ );
// Click the tag input field.
await tagInput.click();
diff --git a/packages/e2e-tests/specs/editor/various/typewriter.test.js b/packages/e2e-tests/specs/editor/various/typewriter.test.js
index 98d54e17da1b7..2661d69acd905 100644
--- a/packages/e2e-tests/specs/editor/various/typewriter.test.js
+++ b/packages/e2e-tests/specs/editor/various/typewriter.test.js
@@ -15,7 +15,7 @@ describe( 'TypeWriter', () => {
const BUFFER = 1;
const getDiff = async ( caretPosition ) =>
- Math.abs( await getCaretPosition() - caretPosition );
+ Math.abs( ( await getCaretPosition() ) - caretPosition );
it( 'should maintain caret position', async () => {
// Create first block.
@@ -29,9 +29,13 @@ describe( 'TypeWriter', () => {
expect( await getCaretPosition() ).toBeGreaterThan( initialPosition );
// Create blocks until the the typewriter effect kicks in.
- while ( await page.evaluate( () =>
- wp.dom.getScrollContainer( document.activeElement ).scrollTop === 0
- ) ) {
+ while (
+ await page.evaluate(
+ () =>
+ wp.dom.getScrollContainer( document.activeElement )
+ .scrollTop === 0
+ )
+ ) {
await page.keyboard.press( 'Enter' );
}
@@ -43,10 +47,16 @@ describe( 'TypeWriter', () => {
expect( await getDiff( newPosition ) ).toBeLessThanOrEqual( BUFFER );
// Type until the text wraps.
- while ( await page.evaluate( () =>
- document.activeElement.clientHeight <=
- parseInt( getComputedStyle( document.activeElement ).lineHeight, 10 )
- ) ) {
+ while (
+ await page.evaluate(
+ () =>
+ document.activeElement.clientHeight <=
+ parseInt(
+ getComputedStyle( document.activeElement ).lineHeight,
+ 10
+ )
+ )
+ ) {
await page.keyboard.type( 'a' );
}
@@ -68,7 +78,9 @@ describe( 'TypeWriter', () => {
// Should be scrolled to new position.
await page.keyboard.press( 'Enter' );
- expect( await getDiff( positionAfterArrowUp ) ).toBeLessThanOrEqual( BUFFER );
+ expect( await getDiff( positionAfterArrowUp ) ).toBeLessThanOrEqual(
+ BUFFER
+ );
} );
it( 'should maintain caret position after scroll', async () => {
@@ -76,14 +88,19 @@ describe( 'TypeWriter', () => {
await page.keyboard.press( 'Enter' );
// Create blocks until there is a scrollable container.
- while ( await page.evaluate( () =>
- ! wp.dom.getScrollContainer( document.activeElement )
- ) ) {
+ while (
+ await page.evaluate(
+ () => ! wp.dom.getScrollContainer( document.activeElement )
+ )
+ ) {
await page.keyboard.press( 'Enter' );
}
- await page.evaluate( () =>
- wp.dom.getScrollContainer( document.activeElement ).scrollTop = 1
+ await page.evaluate(
+ () =>
+ ( wp.dom.getScrollContainer(
+ document.activeElement
+ ).scrollTop = 1 )
);
const initialPosition = await getCaretPosition();
@@ -91,7 +108,9 @@ describe( 'TypeWriter', () => {
// Should maintain scroll position.
await page.keyboard.press( 'Enter' );
- expect( await getDiff( initialPosition ) ).toBeLessThanOrEqual( BUFFER );
+ expect( await getDiff( initialPosition ) ).toBeLessThanOrEqual(
+ BUFFER
+ );
} );
it( 'should maintain caret position after leaving last editable', async () => {
@@ -107,7 +126,9 @@ describe( 'TypeWriter', () => {
// Should maintain scroll position.
await page.keyboard.press( 'Enter' );
- expect( await getDiff( initialPosition ) ).toBeLessThanOrEqual( BUFFER );
+ expect( await getDiff( initialPosition ) ).toBeLessThanOrEqual(
+ BUFFER
+ );
} );
it( 'should scroll caret into view from the top', async () => {
@@ -115,18 +136,24 @@ describe( 'TypeWriter', () => {
await page.keyboard.press( 'Enter' );
// Create blocks until there is a scrollable container.
- while ( await page.evaluate( () =>
- ! wp.dom.getScrollContainer( document.activeElement )
- ) ) {
+ while (
+ await page.evaluate(
+ () => ! wp.dom.getScrollContainer( document.activeElement )
+ )
+ ) {
await page.keyboard.press( 'Enter' );
}
let count = 0;
// Create blocks until the the typewriter effect kicks in.
- while ( await page.evaluate( () =>
- wp.dom.getScrollContainer( document.activeElement ).scrollTop === 0
- ) ) {
+ while (
+ await page.evaluate(
+ () =>
+ wp.dom.getScrollContainer( document.activeElement )
+ .scrollTop === 0
+ )
+ ) {
await page.keyboard.press( 'Enter' );
count++;
}
@@ -150,7 +177,9 @@ describe( 'TypeWriter', () => {
// Should maintain new caret position.
await page.keyboard.press( 'Enter' );
- expect( await getDiff( newBottomPosition ) ).toBeLessThanOrEqual( BUFFER );
+ expect( await getDiff( newBottomPosition ) ).toBeLessThanOrEqual(
+ BUFFER
+ );
await page.keyboard.press( 'Backspace' );
diff --git a/packages/e2e-tests/specs/editor/various/undo.test.js b/packages/e2e-tests/specs/editor/various/undo.test.js
index 7c1a2602d7bfe..ed70af98bdaa2 100644
--- a/packages/e2e-tests/specs/editor/various/undo.test.js
+++ b/packages/e2e-tests/specs/editor/various/undo.test.js
@@ -22,7 +22,9 @@ const getSelection = async () => {
return {};
}
- const editables = Array.from( selectedBlock.querySelectorAll( '[contenteditable]' ) );
+ const editables = Array.from(
+ selectedBlock.querySelectorAll( '[contenteditable]' )
+ );
const editableIndex = editables.indexOf( document.activeElement );
const selection = window.getSelection();
@@ -169,7 +171,9 @@ describe( 'undo', () => {
await pressKeyWithModifier( 'primary', 'b' );
await pressKeyWithModifier( 'primary', 'z' );
- const visibleResult = await page.evaluate( () => document.activeElement.innerHTML );
+ const visibleResult = await page.evaluate(
+ () => document.activeElement.innerHTML
+ );
expect( visibleResult ).toBe( 'test' );
} );
@@ -253,7 +257,9 @@ describe( 'undo', () => {
expect( await getEditedPostContent() ).toBe( '' );
expect( await getSelection() ).toEqual( {} );
// After undoing every action, there should be no more undo history.
- expect( await page.$( '.editor-history__undo[aria-disabled="true"]' ) ).not.toBeNull();
+ expect(
+ await page.$( '.editor-history__undo[aria-disabled="true"]' )
+ ).not.toBeNull();
await pressKeyWithModifier( 'primaryShift', 'z' ); // Redo 1st block.
@@ -265,7 +271,9 @@ describe( 'undo', () => {
endOffset: 0,
} );
// After redoing one change, the undo button should be enabled again.
- expect( await page.$( '.editor-history__undo[aria-disabled="true"]' ) ).toBeNull();
+ expect(
+ await page.$( '.editor-history__undo[aria-disabled="true"]' )
+ ).toBeNull();
await pressKeyWithModifier( 'primaryShift', 'z' ); // Redo 1st paragraph text.
@@ -346,7 +354,9 @@ describe( 'undo', () => {
// regression present was accurate, it would produce the correct
// content. The issue had manifested in the form of what was shown to
// the user since the blocks state failed to sync to block editor.
- const visibleContent = await page.evaluate( () => document.activeElement.textContent );
+ const visibleContent = await page.evaluate(
+ () => document.activeElement.textContent
+ );
expect( visibleContent ).toBe( 'original' );
} );
@@ -376,14 +386,18 @@ describe( 'undo', () => {
await page.reload();
// Expect undo button to be disabled.
- expect( await page.$( '.editor-history__undo[aria-disabled="true"]' ) ).not.toBeNull();
+ expect(
+ await page.$( '.editor-history__undo[aria-disabled="true"]' )
+ ).not.toBeNull();
await page.click( '.wp-block-paragraph' );
await page.keyboard.type( '2' );
// Expect undo button to be enabled.
- expect( await page.$( '.editor-history__undo[aria-disabled="true"]' ) ).toBeNull();
+ expect(
+ await page.$( '.editor-history__undo[aria-disabled="true"]' )
+ ).toBeNull();
await pressKeyWithModifier( 'primary', 'z' );
diff --git a/packages/e2e-tests/specs/editor/various/writing-flow.test.js b/packages/e2e-tests/specs/editor/various/writing-flow.test.js
index 661267778b6ca..d06176cc7de46 100644
--- a/packages/e2e-tests/specs/editor/various/writing-flow.test.js
+++ b/packages/e2e-tests/specs/editor/various/writing-flow.test.js
@@ -10,7 +10,10 @@ import {
insertBlock,
} from '@wordpress/e2e-test-utils';
-const getActiveBlockName = async () => page.evaluate( () => wp.data.select( 'core/block-editor' ).getSelectedBlock().name );
+const getActiveBlockName = async () =>
+ page.evaluate(
+ () => wp.data.select( 'core/block-editor' ).getSelectedBlock().name
+ );
describe( 'Writing Flow', () => {
beforeEach( async () => {
@@ -62,7 +65,9 @@ describe( 'Writing Flow', () => {
await page.keyboard.press( 'ArrowUp' );
activeBlockName = await getActiveBlockName();
expect( activeBlockName ).toBe( 'core/paragraph' );
- activeElementText = await page.evaluate( () => document.activeElement.textContent );
+ activeElementText = await page.evaluate(
+ () => document.activeElement.textContent
+ );
expect( activeElementText ).toBe( '2nd col' );
// Arrow up in inner blocks should navigate through (1) column wrapper,
@@ -73,23 +78,25 @@ describe( 'Writing Flow', () => {
await page.keyboard.press( 'ArrowUp' );
activeBlockName = await getActiveBlockName();
expect( activeBlockName ).toBe( 'core/paragraph' );
- activeElementText = await page.evaluate( () => document.activeElement.textContent );
+ activeElementText = await page.evaluate(
+ () => document.activeElement.textContent
+ );
expect( activeElementText ).toBe( '1st col' );
// Arrow up from first text field in nested context focuses column and
// columns wrappers before escaping out.
let activeElementBlockType;
await page.keyboard.press( 'ArrowUp' );
- activeElementBlockType = await page.evaluate( () => (
+ activeElementBlockType = await page.evaluate( () =>
document.activeElement.getAttribute( 'data-type' )
- ) );
+ );
expect( activeElementBlockType ).toBe( 'core/column' );
activeBlockName = await getActiveBlockName();
expect( activeBlockName ).toBe( 'core/column' );
await page.keyboard.press( 'ArrowUp' );
- activeElementBlockType = await page.evaluate( () => (
+ activeElementBlockType = await page.evaluate( () =>
document.activeElement.getAttribute( 'data-type' )
- ) );
+ );
expect( activeElementBlockType ).toBe( 'core/columns' );
activeBlockName = await getActiveBlockName();
expect( activeBlockName ).toBe( 'core/columns' );
@@ -99,7 +106,9 @@ describe( 'Writing Flow', () => {
await page.keyboard.press( 'ArrowUp' );
activeBlockName = await getActiveBlockName();
expect( activeBlockName ).toBe( 'core/paragraph' );
- activeElementText = await page.evaluate( () => document.activeElement.textContent );
+ activeElementText = await page.evaluate(
+ () => document.activeElement.textContent
+ );
expect( activeElementText ).toBe( 'First paragraph' );
expect( await getEditedPostContent() ).toMatchSnapshot();
@@ -256,23 +265,23 @@ describe( 'Writing Flow', () => {
// Should remain in title upon ArrowRight:
await page.keyboard.press( 'ArrowRight' );
- let isInTitle = await page.evaluate( () => (
- !! document.activeElement.closest( '.editor-post-title' )
- ) );
+ let isInTitle = await page.evaluate(
+ () => !! document.activeElement.closest( '.editor-post-title' )
+ );
expect( isInTitle ).toBe( true );
// Should remain in title upon modifier + ArrowDown:
await pressKeyWithModifier( 'primary', 'ArrowDown' );
- isInTitle = await page.evaluate( () => (
- !! document.activeElement.closest( '.editor-post-title' )
- ) );
+ isInTitle = await page.evaluate(
+ () => !! document.activeElement.closest( '.editor-post-title' )
+ );
expect( isInTitle ).toBe( true );
// Should navigate into blocks list upon ArrowDown:
await page.keyboard.press( 'ArrowDown' );
- const isInBlock = await page.evaluate( () => (
- !! document.activeElement.closest( '[data-type]' )
- ) );
+ const isInBlock = await page.evaluate(
+ () => !! document.activeElement.closest( '[data-type]' )
+ );
expect( isInBlock ).toBe( true );
} );
@@ -440,4 +449,82 @@ describe( 'Writing Flow', () => {
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
+
+ it( 'should allow selecting entire list with longer last item', async () => {
+ await page.keyboard.press( 'Enter' );
+ await page.keyboard.type( 'a' );
+ await page.keyboard.press( 'Enter' );
+ await page.keyboard.type( '* b' );
+ await page.keyboard.press( 'Enter' );
+ await page.keyboard.type( 'cd' );
+ await pressKeyWithModifier( 'shift', 'ArrowUp' );
+ await pressKeyWithModifier( 'shift', 'ArrowUp' );
+
+ // Ensure multi selection is not triggered and selection stays within
+ // the list.
+ await page.keyboard.press( 'Backspace' );
+
+ expect( await getEditedPostContent() ).toMatchSnapshot();
+ } );
+
+ it( 'should not have a dead zone between blocks (lower)', async () => {
+ await page.keyboard.press( 'Enter' );
+ await page.keyboard.type( '1' );
+ await page.keyboard.press( 'Enter' );
+ await page.keyboard.type( '2' );
+ await page.keyboard.press( 'ArrowUp' );
+
+ // Find a point outside the paragraph between the blocks where it's
+ // expected that the sibling inserter would be placed.
+ const paragraph = await page.$( '[data-type="core/paragraph"]' );
+ const paragraphRect = await paragraph.boundingBox();
+ const x = paragraphRect.x + ( 2 * paragraphRect.width ) / 3;
+ const y = paragraphRect.y + paragraphRect.height + 1;
+
+ await page.mouse.move( x, y );
+ await page.waitForSelector(
+ '.block-editor-block-list__insertion-point-inserter'
+ );
+
+ const inserter = await page.$(
+ '.block-editor-block-list__insertion-point-inserter'
+ );
+ const inserterRect = await inserter.boundingBox();
+ const lowerInserterY = inserterRect.y + ( 2 * inserterRect.height ) / 3;
+
+ await page.mouse.click( x, lowerInserterY );
+ await page.keyboard.type( '3' );
+
+ expect( await getEditedPostContent() ).toMatchSnapshot();
+ } );
+
+ it( 'should not have a dead zone between blocks (upper)', async () => {
+ await page.keyboard.press( 'Enter' );
+ await page.keyboard.type( '1' );
+ await page.keyboard.press( 'Enter' );
+ await page.keyboard.type( '2' );
+
+ // Find a point outside the paragraph between the blocks where it's
+ // expected that the sibling inserter would be placed.
+ const paragraph = await page.$( '[data-type="core/paragraph"]' );
+ const paragraphRect = await paragraph.boundingBox();
+ const x = paragraphRect.x + ( 2 * paragraphRect.width ) / 3;
+ const y = paragraphRect.y + paragraphRect.height + 1;
+
+ await page.mouse.move( x, y );
+ await page.waitForSelector(
+ '.block-editor-block-list__insertion-point-inserter'
+ );
+
+ const inserter = await page.$(
+ '.block-editor-block-list__insertion-point-inserter'
+ );
+ const inserterRect = await inserter.boundingBox();
+ const upperInserterY = inserterRect.y + inserterRect.height / 3;
+
+ await page.mouse.click( x, upperInserterY );
+ await page.keyboard.type( '3' );
+
+ expect( await getEditedPostContent() ).toMatchSnapshot();
+ } );
} );
diff --git a/packages/e2e-tests/specs/performance/performance.test.js b/packages/e2e-tests/specs/performance/performance.test.js
index 7f402dad605ca..0bdc172682faf 100644
--- a/packages/e2e-tests/specs/performance/performance.test.js
+++ b/packages/e2e-tests/specs/performance/performance.test.js
@@ -14,12 +14,16 @@ import {
} from '@wordpress/e2e-test-utils';
function readFile( filePath ) {
- return existsSync( filePath ) ? readFileSync( filePath, 'utf8' ).trim() : '';
+ return existsSync( filePath )
+ ? readFileSync( filePath, 'utf8' ).trim()
+ : '';
}
describe( 'Performance', () => {
it( '1000 paragraphs', async () => {
- const html = readFile( join( __dirname, '../../assets/large-post.html' ) );
+ const html = readFile(
+ join( __dirname, '../../assets/large-post.html' )
+ );
await createNewPost();
await page.evaluate( ( _html ) => {
@@ -47,8 +51,12 @@ describe( 'Performance', () => {
let i = 1;
let startTime;
- await page.on( 'load', () => results.load.push( new Date() - startTime ) );
- await page.on( 'domcontentloaded', () => results.domcontentloaded.push( new Date() - startTime ) );
+ await page.on( 'load', () =>
+ results.load.push( new Date() - startTime )
+ );
+ await page.on( 'domcontentloaded', () =>
+ results.domcontentloaded.push( new Date() - startTime )
+ );
while ( i-- ) {
startTime = new Date();
@@ -65,7 +73,10 @@ describe( 'Performance', () => {
results.type.push( new Date() - startTime );
}
- writeFileSync( __dirname + '/results.json', JSON.stringify( results, null, 2 ) );
+ writeFileSync(
+ __dirname + '/results.json',
+ JSON.stringify( results, null, 2 )
+ );
expect( true ).toBe( true );
} );
diff --git a/packages/e2e-tests/specs/plugins/inner-blocks-render-appender.test.js b/packages/e2e-tests/specs/plugins/inner-blocks-render-appender.test.js
index fd5bec2955b11..ad27838a4a8ed 100644
--- a/packages/e2e-tests/specs/plugins/inner-blocks-render-appender.test.js
+++ b/packages/e2e-tests/specs/plugins/inner-blocks-render-appender.test.js
@@ -37,26 +37,28 @@ describe( 'RenderAppender prop of InnerBlocks ', () => {
// Verify if the custom block appender text is the expected one.
expect(
await page.evaluate(
- ( el ) => ( el.innerText ),
+ ( el ) => el.innerText,
await page.$( `${ APPENDER_SELECTOR } > span` )
)
).toEqual( 'My custom awesome appender' );
// Open the inserter of our custom block appender and expand all the categories.
- await page.click( `${ APPENDER_SELECTOR } .block-editor-button-block-appender` );
+ await page.click(
+ `${ APPENDER_SELECTOR } .block-editor-button-block-appender`
+ );
await openAllBlockInserterCategories();
// Verify if the blocks the custom inserter is rendering are the expected ones.
- expect(
- await getAllBlockInserterItemTitles()
- ).toEqual( [
+ expect( await getAllBlockInserterItemTitles() ).toEqual( [
'Quote',
'Video',
] );
// Find the quote block insert button option within the inserter popover.
const inserterPopover = await page.$( INSERTER_RESULTS_SELECTOR );
- const quoteButton = ( await inserterPopover.$x( QUOTE_INSERT_BUTTON_SELECTOR ) )[ 0 ];
+ const quoteButton = (
+ await inserterPopover.$x( QUOTE_INSERT_BUTTON_SELECTOR )
+ )[ 0 ];
// Insert a quote block.
await quoteButton.click();
@@ -82,16 +84,16 @@ describe( 'RenderAppender prop of InnerBlocks ', () => {
await openAllBlockInserterCategories();
// Verify if the blocks the custom inserter is rendering are the expected ones.
- expect(
- await getAllBlockInserterItemTitles()
- ).toEqual( [
+ expect( await getAllBlockInserterItemTitles() ).toEqual( [
'Quote',
'Video',
] );
// Find the quote block insert button option within the inserter popover.
const inserterPopover = await page.$( INSERTER_RESULTS_SELECTOR );
- const quoteButton = ( await inserterPopover.$x( QUOTE_INSERT_BUTTON_SELECTOR ) )[ 0 ];
+ const quoteButton = (
+ await inserterPopover.$x( QUOTE_INSERT_BUTTON_SELECTOR )
+ )[ 0 ];
// Insert a quote block.
await quoteButton.click();
@@ -102,9 +104,7 @@ describe( 'RenderAppender prop of InnerBlocks ', () => {
);
// Verify that the custom appender button is still being rendered.
- expect(
- await page.$( blockAppenderButtonSelector )
- ).toBeTruthy();
+ expect( await page.$( blockAppenderButtonSelector ) ).toBeTruthy();
// Insert a video block.
await insertBlock( 'Video' );
@@ -115,9 +115,7 @@ describe( 'RenderAppender prop of InnerBlocks ', () => {
);
// Verify that the custom appender button is now not being rendered.
- expect(
- await page.$( blockAppenderButtonSelector )
- ).toBeFalsy();
+ expect( await page.$( blockAppenderButtonSelector ) ).toBeFalsy();
// Verify that final block markup is the expected one.
expect( await getEditedPostContent() ).toMatchSnapshot();
diff --git a/packages/edit-post/package.json b/packages/edit-post/package.json
index d7e43445e2dcd..96b9ae2fb4802 100644
--- a/packages/edit-post/package.json
+++ b/packages/edit-post/package.json
@@ -21,7 +21,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
- "@babel/runtime": "^7.4.4",
+ "@babel/runtime": "^7.8.3",
"@wordpress/a11y": "file:../a11y",
"@wordpress/api-fetch": "file:../api-fetch",
"@wordpress/block-editor": "file:../block-editor",
@@ -35,6 +35,7 @@
"@wordpress/element": "file:../element",
"@wordpress/hooks": "file:../hooks",
"@wordpress/i18n": "file:../i18n",
+ "@wordpress/icons": "file:../icons",
"@wordpress/keyboard-shortcuts": "file:../keyboard-shortcuts",
"@wordpress/keycodes": "file:../keycodes",
"@wordpress/media-utils": "file:../media-utils",
diff --git a/packages/edit-post/src/components/admin-notices/index.js b/packages/edit-post/src/components/admin-notices/index.js
index d39c74c34a062..a84d1e2e4388d 100644
--- a/packages/edit-post/src/components/admin-notices/index.js
+++ b/packages/edit-post/src/components/admin-notices/index.js
@@ -27,7 +27,9 @@ const NOTICE_CLASS_STATUSES = {
function getAdminNotices() {
// The order is reversed to match expectations of rendered order, since a
// NoticesList is itself rendered in reverse order (newest to oldest).
- return Array.from( document.querySelectorAll( '#wpbody-content > .notice' ) ).reverse();
+ return Array.from(
+ document.querySelectorAll( '#wpbody-content > .notice' )
+ ).reverse();
}
/**
@@ -81,7 +83,9 @@ export class AdminNotices extends Component {
// Convert and create.
const status = getNoticeStatus( element );
const content = getNoticeHTML( element );
- const isDismissible = element.classList.contains( 'is-dismissible' );
+ const isDismissible = element.classList.contains(
+ 'is-dismissible'
+ );
createNotice( status, content, {
speak: false,
__unstableHTML: true,
diff --git a/packages/edit-post/src/components/admin-notices/test/index.js b/packages/edit-post/src/components/admin-notices/test/index.js
index 1dcda9a00a275..792fe785b78ae 100644
--- a/packages/edit-post/src/components/admin-notices/test/index.js
+++ b/packages/edit-post/src/components/admin-notices/test/index.js
@@ -56,6 +56,8 @@ describe( 'AdminNotices', () => {
] );
// Verify all but `` are removed.
- expect( document.getElementById( 'wpbody-content' ).childElementCount ).toBe( 1 );
+ expect(
+ document.getElementById( 'wpbody-content' ).childElementCount
+ ).toBe( 1 );
} );
} );
diff --git a/packages/edit-post/src/components/block-settings-menu/plugin-block-settings-menu-group.js b/packages/edit-post/src/components/block-settings-menu/plugin-block-settings-menu-group.js
index 435f912ce03a8..02865868864a3 100644
--- a/packages/edit-post/src/components/block-settings-menu/plugin-block-settings-menu-group.js
+++ b/packages/edit-post/src/components/block-settings-menu/plugin-block-settings-menu-group.js
@@ -9,24 +9,32 @@ import { isEmpty, map } from 'lodash';
import { createSlotFill } from '@wordpress/components';
import { withSelect } from '@wordpress/data';
-const { Fill: PluginBlockSettingsMenuGroup, Slot } = createSlotFill( 'PluginBlockSettingsMenuGroup' );
+const { Fill: PluginBlockSettingsMenuGroup, Slot } = createSlotFill(
+ 'PluginBlockSettingsMenuGroup'
+);
const PluginBlockSettingsMenuGroupSlot = ( { fillProps, selectedBlocks } ) => {
selectedBlocks = map( selectedBlocks, ( block ) => block.name );
return (
-
- { ( fills ) => ! isEmpty( fills ) && (
- <>
-
- { fills }
- >
- ) }
+
+ { ( fills ) =>
+ ! isEmpty( fills ) && (
+ <>
+
+ { fills }
+ >
+ )
+ }
);
};
-PluginBlockSettingsMenuGroup.Slot = withSelect( ( select, { fillProps: { clientIds } } ) => ( {
- selectedBlocks: select( 'core/block-editor' ).getBlocksByClientId( clientIds ),
-} ) )( PluginBlockSettingsMenuGroupSlot );
+PluginBlockSettingsMenuGroup.Slot = withSelect(
+ ( select, { fillProps: { clientIds } } ) => ( {
+ selectedBlocks: select( 'core/block-editor' ).getBlocksByClientId(
+ clientIds
+ ),
+ } )
+)( PluginBlockSettingsMenuGroupSlot );
export default PluginBlockSettingsMenuGroup;
diff --git a/packages/edit-post/src/components/block-settings-menu/plugin-block-settings-menu-item.js b/packages/edit-post/src/components/block-settings-menu/plugin-block-settings-menu-item.js
index 938805e057406..026f61d5bd3db 100644
--- a/packages/edit-post/src/components/block-settings-menu/plugin-block-settings-menu-item.js
+++ b/packages/edit-post/src/components/block-settings-menu/plugin-block-settings-menu-item.js
@@ -14,7 +14,8 @@ import { compose } from '@wordpress/compose';
*/
import PluginBlockSettingsMenuGroup from './plugin-block-settings-menu-group';
-const isEverySelectedBlockAllowed = ( selected, allowed ) => difference( selected, allowed ).length === 0;
+const isEverySelectedBlockAllowed = ( selected, allowed ) =>
+ difference( selected, allowed ).length === 0;
/**
* Plugins may want to add an item to the menu either for every block
@@ -27,7 +28,8 @@ const isEverySelectedBlockAllowed = ( selected, allowed ) => difference( selecte
* @param {string[]} allowedBlocks Array containing the names of the blocks allowed
* @return {boolean} Whether the item will be rendered or not.
*/
-const shouldRenderItem = ( selectedBlocks, allowedBlocks ) => ! Array.isArray( allowedBlocks ) ||
+const shouldRenderItem = ( selectedBlocks, allowedBlocks ) =>
+ ! Array.isArray( allowedBlocks ) ||
isEverySelectedBlockAllowed( selectedBlocks, allowedBlocks );
/**
@@ -83,21 +85,29 @@ const shouldRenderItem = ( selectedBlocks, allowedBlocks ) => ! Array.isArray( a
*
* @return {WPComponent} The component to be rendered.
*/
-const PluginBlockSettingsMenuItem = ( { allowedBlocks, icon, label, onClick, small, role } ) => (
+const PluginBlockSettingsMenuItem = ( {
+ allowedBlocks,
+ icon,
+ label,
+ onClick,
+ small,
+ role,
+} ) => (
{ ( { selectedBlocks, onClose } ) => {
if ( ! shouldRenderItem( selectedBlocks, allowedBlocks ) ) {
return null;
}
- return (
- { ! small && label }
- );
+ return (
+
+ { ! small && label }
+
+ );
} }
);
diff --git a/packages/edit-post/src/components/browser-url/index.js b/packages/edit-post/src/components/browser-url/index.js
index 34a8e889cefd4..d4cbd7f867706 100644
--- a/packages/edit-post/src/components/browser-url/index.js
+++ b/packages/edit-post/src/components/browser-url/index.js
@@ -52,7 +52,10 @@ export class BrowserURL extends Component {
return;
}
- if ( ( postId !== prevProps.postId || postId !== historyId ) && postStatus !== 'auto-draft' ) {
+ if (
+ ( postId !== prevProps.postId || postId !== historyId ) &&
+ postStatus !== 'auto-draft'
+ ) {
this.setBrowserURL( postId );
}
}
diff --git a/packages/edit-post/src/components/editor-initialization/listener-hooks.js b/packages/edit-post/src/components/editor-initialization/listener-hooks.js
index edefe8972fddc..ff168dc7413fc 100644
--- a/packages/edit-post/src/components/editor-initialization/listener-hooks.js
+++ b/packages/edit-post/src/components/editor-initialization/listener-hooks.js
@@ -20,10 +20,7 @@ import {
* @param {number} postId The current post id.
*/
export const useBlockSelectionListener = ( postId ) => {
- const {
- hasBlockSelection,
- isEditorSidebarOpened,
- } = useSelect(
+ const { hasBlockSelection, isEditorSidebarOpened } = useSelect(
( select ) => ( {
hasBlockSelection: !! select(
'core/block-editor'
@@ -57,12 +54,16 @@ export const useAdjustSidebarListener = ( postId ) => {
const { isSmall, activeGeneralSidebarName } = useSelect(
( select ) => ( {
isSmall: select( 'core/viewport' ).isViewportMatch( '< medium' ),
- activeGeneralSidebarName: select( STORE_KEY ).getActiveGeneralSidebarName(),
+ activeGeneralSidebarName: select(
+ STORE_KEY
+ ).getActiveGeneralSidebarName(),
} ),
[ postId ]
);
- const { openGeneralSidebar, closeGeneralSidebar } = useDispatch( STORE_KEY );
+ const { openGeneralSidebar, closeGeneralSidebar } = useDispatch(
+ STORE_KEY
+ );
const previousIsSmall = useRef( null );
const sidebarToReOpenOnExpand = useRef( null );
@@ -78,7 +79,10 @@ export const useAdjustSidebarListener = ( postId ) => {
if ( activeGeneralSidebarName ) {
closeGeneralSidebar();
}
- } else if ( sidebarToReOpenOnExpand.current && ! activeGeneralSidebarName ) {
+ } else if (
+ sidebarToReOpenOnExpand.current &&
+ ! activeGeneralSidebarName
+ ) {
openGeneralSidebar( sidebarToReOpenOnExpand.current );
sidebarToReOpenOnExpand.current = null;
}
@@ -101,7 +105,8 @@ export const useUpdatePostLinkListener = ( postId ) => {
const nodeToUpdate = useRef();
useEffect( () => {
- nodeToUpdate.current = document.querySelector( VIEW_AS_PREVIEW_LINK_SELECTOR ) ||
+ nodeToUpdate.current =
+ document.querySelector( VIEW_AS_PREVIEW_LINK_SELECTOR ) ||
document.querySelector( VIEW_AS_LINK_SELECTOR );
}, [ postId ] );
diff --git a/packages/edit-post/src/components/editor-initialization/test/listener-hooks.js b/packages/edit-post/src/components/editor-initialization/test/listener-hooks.js
index 0c8742bbe02fc..e25967fb0f87f 100644
--- a/packages/edit-post/src/components/editor-initialization/test/listener-hooks.js
+++ b/packages/edit-post/src/components/editor-initialization/test/listener-hooks.js
@@ -38,34 +38,36 @@ describe( 'listener hook tests', () => {
};
let subscribeTrigger;
const registry = {
- select: jest.fn().mockImplementation(
- ( storeName ) => mockStores[ storeName ]
- ),
- dispatch: jest.fn().mockImplementation(
- ( storeName ) => mockStores[ storeName ]
- ),
+ select: jest
+ .fn()
+ .mockImplementation( ( storeName ) => mockStores[ storeName ] ),
+ dispatch: jest
+ .fn()
+ .mockImplementation( ( storeName ) => mockStores[ storeName ] ),
subscribe: ( subscription ) => {
subscribeTrigger = subscription;
},
};
const setMockReturnValue = ( store, functionName, value ) => {
- mockStores[ store ][ functionName ] = jest.fn().mockReturnValue( value );
+ mockStores[ store ][ functionName ] = jest
+ .fn()
+ .mockReturnValue( value );
};
- const getSpyedFunction = (
- store,
- functionName
- ) => mockStores[ store ][ functionName ];
+ const getSpyedFunction = ( store, functionName ) =>
+ mockStores[ store ][ functionName ];
const renderComponent = ( testedHook, id, renderer = null ) => {
const TestComponent = ( { postId } ) => {
testedHook( postId );
return null;
};
- const TestedOutput =
-
- ;
- return renderer === null ?
- TestRenderer.create( TestedOutput ) :
- renderer.update( TestedOutput );
+ const TestedOutput = (
+
+
+
+ );
+ return renderer === null
+ ? TestRenderer.create( TestedOutput )
+ : renderer.update( TestedOutput );
};
afterEach( () => {
Object.values( mockStores ).forEach( ( storeMocks ) => {
@@ -90,7 +92,11 @@ describe( 'listener hook tests', () => {
} );
it( 'opens block sidebar if block is selected', () => {
setMockReturnValue( STORE_KEY, 'isEditorSidebarOpened', true );
- setMockReturnValue( 'core/block-editor', 'getBlockSelectionStart', true );
+ setMockReturnValue(
+ 'core/block-editor',
+ 'getBlockSelectionStart',
+ true
+ );
act( () => {
renderComponent( useBlockSelectionListener, 10 );
} );
@@ -100,7 +106,11 @@ describe( 'listener hook tests', () => {
} );
it( 'opens document sidebar if block is not selected', () => {
setMockReturnValue( STORE_KEY, 'isEditorSidebarOpened', true );
- setMockReturnValue( 'core/block-editor', 'getBlockSelectionStart', false );
+ setMockReturnValue(
+ 'core/block-editor',
+ 'getBlockSelectionStart',
+ false
+ );
act( () => {
renderComponent( useBlockSelectionListener, 10 );
} );
@@ -112,21 +122,11 @@ describe( 'listener hook tests', () => {
describe( 'useAdjustSidebarListener', () => {
it( 'initializes and does nothing when viewport is not small', () => {
setMockReturnValue( 'core/viewport', 'isViewPortMatch', false );
- setMockReturnValue( STORE_KEY, 'getActiveGeneralSidebarName', 'edit-post/document' );
- act( () => {
- renderComponent( useAdjustSidebarListener, 10 );
- } );
- expect(
- getSpyedFunction( STORE_KEY, 'openGeneralSidebar' )
- ).not.toHaveBeenCalled();
- expect(
- getSpyedFunction( STORE_KEY, 'closeGeneralSidebar' )
- ).not.toHaveBeenCalled();
- } );
- it( 'does not close sidebar if viewport is small and there is no ' +
- 'active sidebar name available', () => {
- setMockReturnValue( 'core/viewport', 'isViewPortMatch', true );
- setMockReturnValue( STORE_KEY, 'getActiveGeneralSidebarName', null );
+ setMockReturnValue(
+ STORE_KEY,
+ 'getActiveGeneralSidebarName',
+ 'edit-post/document'
+ );
act( () => {
renderComponent( useAdjustSidebarListener, 10 );
} );
@@ -137,78 +137,130 @@ describe( 'listener hook tests', () => {
getSpyedFunction( STORE_KEY, 'closeGeneralSidebar' )
).not.toHaveBeenCalled();
} );
- it( 'closes sidebar if viewport is small and there is an active ' +
- 'sidebar name available on initial render', () => {
- setMockReturnValue( 'core/viewport', 'isViewportMatch', true );
- setMockReturnValue( STORE_KEY, 'getActiveGeneralSidebarName', 'foo' );
- act( () => {
- renderComponent( useAdjustSidebarListener, 10 );
- } );
- expect(
- getSpyedFunction( STORE_KEY, 'openGeneralSidebar' )
- ).not.toHaveBeenCalled();
- expect(
- getSpyedFunction( STORE_KEY, 'closeGeneralSidebar' )
- ).toHaveBeenCalled();
- } );
- it( 'closes sidebar if viewport is small and there is an active ' +
- 'sidebar name available when viewport size changes', () => {
- setMockReturnValue( 'core/viewport', 'isViewportMatch', false );
- setMockReturnValue( STORE_KEY, 'getActiveGeneralSidebarName', 'foo' );
- // initial render does nothing and sidebar will be open already.
- act( () => {
- renderComponent( useAdjustSidebarListener, 10 );
- } );
- setMockReturnValue( 'core/viewport', 'isViewportMatch', true );
- // This render should result in the sidebar closing because viewport is
- // now small triggering a change.
- act( () => {
- subscribeTrigger();
- } );
- expect(
- getSpyedFunction( STORE_KEY, 'openGeneralSidebar' )
- ).not.toHaveBeenCalled();
- expect(
- getSpyedFunction( STORE_KEY, 'closeGeneralSidebar' )
- ).toHaveBeenCalledTimes( 1 );
- } );
- it( 'opens sidebar if viewport is not small, and there is a cached sidebar ' +
- 'to reopen on expand', () => {
- setMockReturnValue( 'core/viewport', 'isViewportMatch', false );
- setMockReturnValue( STORE_KEY, 'getActiveGeneralSidebarName', 'foo' );
- // initial render does nothing and sidebar should be open.
- act( () => {
- renderComponent( useAdjustSidebarListener, 10 );
- } );
- setMockReturnValue( 'core/viewport', 'isViewportMatch', true );
- setMockReturnValue( STORE_KEY, 'getActiveGeneralSidebarName', 'bar' );
- // next render should close the sidebar and active sidebar at time of
- // closing is cached.
- act( () => {
- subscribeTrigger();
- } );
- setMockReturnValue( 'core/viewport', 'isViewportMatch', false );
- setMockReturnValue( STORE_KEY, 'getActiveGeneralSidebarName', '' );
- // next render should open the sidebar to the cached general sidebar name.
- act( () => {
- subscribeTrigger();
- } );
- expect(
- getSpyedFunction( STORE_KEY, 'openGeneralSidebar' )
- ).toHaveBeenCalledWith( 'bar' );
- expect(
- getSpyedFunction( STORE_KEY, 'openGeneralSidebar' )
- ).toHaveBeenCalledTimes( 1 );
- expect(
- getSpyedFunction( STORE_KEY, 'closeGeneralSidebar' )
- ).toHaveBeenCalledTimes( 1 );
- } );
+ it(
+ 'does not close sidebar if viewport is small and there is no ' +
+ 'active sidebar name available',
+ () => {
+ setMockReturnValue( 'core/viewport', 'isViewPortMatch', true );
+ setMockReturnValue(
+ STORE_KEY,
+ 'getActiveGeneralSidebarName',
+ null
+ );
+ act( () => {
+ renderComponent( useAdjustSidebarListener, 10 );
+ } );
+ expect(
+ getSpyedFunction( STORE_KEY, 'openGeneralSidebar' )
+ ).not.toHaveBeenCalled();
+ expect(
+ getSpyedFunction( STORE_KEY, 'closeGeneralSidebar' )
+ ).not.toHaveBeenCalled();
+ }
+ );
+ it(
+ 'closes sidebar if viewport is small and there is an active ' +
+ 'sidebar name available on initial render',
+ () => {
+ setMockReturnValue( 'core/viewport', 'isViewportMatch', true );
+ setMockReturnValue(
+ STORE_KEY,
+ 'getActiveGeneralSidebarName',
+ 'foo'
+ );
+ act( () => {
+ renderComponent( useAdjustSidebarListener, 10 );
+ } );
+ expect(
+ getSpyedFunction( STORE_KEY, 'openGeneralSidebar' )
+ ).not.toHaveBeenCalled();
+ expect(
+ getSpyedFunction( STORE_KEY, 'closeGeneralSidebar' )
+ ).toHaveBeenCalled();
+ }
+ );
+ it(
+ 'closes sidebar if viewport is small and there is an active ' +
+ 'sidebar name available when viewport size changes',
+ () => {
+ setMockReturnValue( 'core/viewport', 'isViewportMatch', false );
+ setMockReturnValue(
+ STORE_KEY,
+ 'getActiveGeneralSidebarName',
+ 'foo'
+ );
+ // initial render does nothing and sidebar will be open already.
+ act( () => {
+ renderComponent( useAdjustSidebarListener, 10 );
+ } );
+ setMockReturnValue( 'core/viewport', 'isViewportMatch', true );
+ // This render should result in the sidebar closing because viewport is
+ // now small triggering a change.
+ act( () => {
+ subscribeTrigger();
+ } );
+ expect(
+ getSpyedFunction( STORE_KEY, 'openGeneralSidebar' )
+ ).not.toHaveBeenCalled();
+ expect(
+ getSpyedFunction( STORE_KEY, 'closeGeneralSidebar' )
+ ).toHaveBeenCalledTimes( 1 );
+ }
+ );
+ it(
+ 'opens sidebar if viewport is not small, and there is a cached sidebar ' +
+ 'to reopen on expand',
+ () => {
+ setMockReturnValue( 'core/viewport', 'isViewportMatch', false );
+ setMockReturnValue(
+ STORE_KEY,
+ 'getActiveGeneralSidebarName',
+ 'foo'
+ );
+ // initial render does nothing and sidebar should be open.
+ act( () => {
+ renderComponent( useAdjustSidebarListener, 10 );
+ } );
+ setMockReturnValue( 'core/viewport', 'isViewportMatch', true );
+ setMockReturnValue(
+ STORE_KEY,
+ 'getActiveGeneralSidebarName',
+ 'bar'
+ );
+ // next render should close the sidebar and active sidebar at time of
+ // closing is cached.
+ act( () => {
+ subscribeTrigger();
+ } );
+ setMockReturnValue( 'core/viewport', 'isViewportMatch', false );
+ setMockReturnValue(
+ STORE_KEY,
+ 'getActiveGeneralSidebarName',
+ ''
+ );
+ // next render should open the sidebar to the cached general sidebar name.
+ act( () => {
+ subscribeTrigger();
+ } );
+ expect(
+ getSpyedFunction( STORE_KEY, 'openGeneralSidebar' )
+ ).toHaveBeenCalledWith( 'bar' );
+ expect(
+ getSpyedFunction( STORE_KEY, 'openGeneralSidebar' )
+ ).toHaveBeenCalledTimes( 1 );
+ expect(
+ getSpyedFunction( STORE_KEY, 'closeGeneralSidebar' )
+ ).toHaveBeenCalledTimes( 1 );
+ }
+ );
} );
describe( 'useUpdatePostLinkListener', () => {
const setAttribute = jest.fn();
const mockSelector = jest.fn();
beforeEach( () => {
- document.querySelector = mockSelector.mockReturnValue( { setAttribute } );
+ document.querySelector = mockSelector.mockReturnValue( {
+ setAttribute,
+ } );
} );
afterEach( () => {
setAttribute.mockClear();
@@ -216,22 +268,16 @@ describe( 'listener hook tests', () => {
} );
it( 'updates nothing if there is no view link available', () => {
mockSelector.mockImplementation( () => null );
- setMockReturnValue(
- 'core/editor',
- 'getCurrentPost',
- { link: 'foo' }
- );
+ setMockReturnValue( 'core/editor', 'getCurrentPost', {
+ link: 'foo',
+ } );
act( () => {
renderComponent( useUpdatePostLinkListener, 10 );
} );
expect( setAttribute ).not.toHaveBeenCalled();
} );
it( 'updates nothing if there is no permalink', () => {
- setMockReturnValue(
- 'core/editor',
- 'getCurrentPost',
- { link: '' }
- );
+ setMockReturnValue( 'core/editor', 'getCurrentPost', { link: '' } );
act( () => {
renderComponent( useUpdatePostLinkListener, 10 );
} );
@@ -239,7 +285,10 @@ describe( 'listener hook tests', () => {
} );
it( 'only calls document query selector once across renders', () => {
act( () => {
- const renderer = renderComponent( useUpdatePostLinkListener, 10 );
+ const renderer = renderComponent(
+ useUpdatePostLinkListener,
+ 10
+ );
renderComponent( useUpdatePostLinkListener, 20, renderer );
} );
expect( mockSelector ).toHaveBeenCalledTimes( 1 );
@@ -249,11 +298,9 @@ describe( 'listener hook tests', () => {
expect( mockSelector ).toHaveBeenCalledTimes( 1 );
} );
it( 'only updates the permalink when it changes', () => {
- setMockReturnValue(
- 'core/editor',
- 'getCurrentPost',
- { link: 'foo' }
- );
+ setMockReturnValue( 'core/editor', 'getCurrentPost', {
+ link: 'foo',
+ } );
act( () => {
renderComponent( useUpdatePostLinkListener, 10 );
} );
@@ -263,19 +310,15 @@ describe( 'listener hook tests', () => {
expect( setAttribute ).toHaveBeenCalledTimes( 1 );
} );
it( 'updates the permalink when it changes', () => {
- setMockReturnValue(
- 'core/editor',
- 'getCurrentPost',
- { link: 'foo' }
- );
+ setMockReturnValue( 'core/editor', 'getCurrentPost', {
+ link: 'foo',
+ } );
act( () => {
renderComponent( useUpdatePostLinkListener, 10 );
} );
- setMockReturnValue(
- 'core/editor',
- 'getCurrentPost',
- { link: 'bar' }
- );
+ setMockReturnValue( 'core/editor', 'getCurrentPost', {
+ link: 'bar',
+ } );
act( () => {
subscribeTrigger();
} );
diff --git a/packages/edit-post/src/components/editor-regions/index.js b/packages/edit-post/src/components/editor-regions/index.js
index f208fed2cef5e..eee9dfcfdae9d 100644
--- a/packages/edit-post/src/components/editor-regions/index.js
+++ b/packages/edit-post/src/components/editor-regions/index.js
@@ -9,7 +9,14 @@ import classnames from 'classnames';
import { navigateRegions } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
-function EditorRegions( { footer, header, sidebar, content, publish, className } ) {
+function EditorRegions( {
+ footer,
+ header,
+ sidebar,
+ content,
+ publish,
+ className,
+} ) {
return (
{ !! header && (
@@ -33,25 +40,26 @@ function EditorRegions( { footer, header, sidebar, content, publish, className }
>
{ content }
- { !! publish && (
+ { !! sidebar && (
- { publish }
+ { sidebar }
) }
- { !! sidebar && (
+ { !! publish && (
- { sidebar }
+ { publish }
) }
@@ -59,7 +67,8 @@ function EditorRegions( { footer, header, sidebar, content, publish, className }
{ footer }
diff --git a/packages/edit-post/src/components/fullscreen-mode/test/index.js b/packages/edit-post/src/components/fullscreen-mode/test/index.js
index 928722b340da2..199930777479f 100644
--- a/packages/edit-post/src/components/fullscreen-mode/test/index.js
+++ b/packages/edit-post/src/components/fullscreen-mode/test/index.js
@@ -12,13 +12,17 @@ describe( 'FullscreenMode', () => {
it( 'fullscreen mode to be added to document body when active', () => {
shallow(
);
- expect( document.body.classList.contains( 'is-fullscreen-mode' ) ).toBe( true );
+ expect( document.body.classList.contains( 'is-fullscreen-mode' ) ).toBe(
+ true
+ );
} );
it( 'fullscreen mode not to be added to document body when active', () => {
shallow(
);
- expect( document.body.classList.contains( 'is-fullscreen-mode' ) ).toBe( false );
+ expect( document.body.classList.contains( 'is-fullscreen-mode' ) ).toBe(
+ false
+ );
} );
it( 'sticky-menu to be removed from the body class if present', () => {
@@ -26,7 +30,9 @@ describe( 'FullscreenMode', () => {
shallow(
);
- expect( document.body.classList.contains( 'sticky-menu' ) ).toBe( false );
+ expect( document.body.classList.contains( 'sticky-menu' ) ).toBe(
+ false
+ );
} );
it( 'sticky-menu to be restored when component unmounted and originally present', () => {
@@ -35,6 +41,8 @@ describe( 'FullscreenMode', () => {
const mode = shallow(
);
mode.unmount();
- expect( document.body.classList.contains( 'sticky-menu' ) ).toBe( true );
+ expect( document.body.classList.contains( 'sticky-menu' ) ).toBe(
+ true
+ );
} );
} );
diff --git a/packages/edit-post/src/components/header/feature-toggle/index.js b/packages/edit-post/src/components/header/feature-toggle/index.js
index 9dc6e3a5a9302..7d19d5d561198 100644
--- a/packages/edit-post/src/components/header/feature-toggle/index.js
+++ b/packages/edit-post/src/components/header/feature-toggle/index.js
@@ -10,8 +10,17 @@ import { withSelect, withDispatch } from '@wordpress/data';
import { compose } from '@wordpress/compose';
import { MenuItem, withSpokenMessages } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
+import { check } from '@wordpress/icons';
-function FeatureToggle( { onToggle, isActive, label, info, messageActivated, messageDeactivated, speak } ) {
+function FeatureToggle( {
+ onToggle,
+ isActive,
+ label,
+ info,
+ messageActivated,
+ messageDeactivated,
+ speak,
+} ) {
const speakMessage = () => {
if ( isActive ) {
speak( messageDeactivated || __( 'Feature deactivated' ) );
@@ -22,7 +31,7 @@ function FeatureToggle( { onToggle, isActive, label, info, messageActivated, mes
return (
( {
- hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' ),
- // This setting (richEditingEnabled) should not live in the block editor's setting.
- showInserter: select( 'core/edit-post' ).getEditorMode() === 'visual' && select( 'core/editor' ).getEditorSettings().richEditingEnabled,
- isTextModeEnabled: select( 'core/edit-post' ).getEditorMode() === 'text',
- } ), [] );
+ const { hasFixedToolbar, showInserter, isTextModeEnabled } = useSelect(
+ ( select ) => ( {
+ hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive(
+ 'fixedToolbar'
+ ),
+ // This setting (richEditingEnabled) should not live in the block editor's setting.
+ showInserter:
+ select( 'core/edit-post' ).getEditorMode() === 'visual' &&
+ select( 'core/editor' ).getEditorSettings().richEditingEnabled,
+ isTextModeEnabled:
+ select( 'core/edit-post' ).getEditorMode() === 'text',
+ } ),
+ []
+ );
const isLargeViewport = useViewportMatch( 'medium' );
- const toolbarAriaLabel = hasFixedToolbar ?
- /* translators: accessibility text for the editor toolbar when Top Toolbar is on */
- __( 'Document and block tools' ) :
- /* translators: accessibility text for the editor toolbar when Top Toolbar is off */
- __( 'Document tools' );
+ const toolbarAriaLabel = hasFixedToolbar
+ ? /* translators: accessibility text for the editor toolbar when Top Toolbar is on */
+ __( 'Document and block tools' )
+ : /* translators: accessibility text for the editor toolbar when Top Toolbar is off */
+ __( 'Document tools' );
return (
-
+
diff --git a/packages/edit-post/src/components/header/header-toolbar/index.native.js b/packages/edit-post/src/components/header/header-toolbar/index.native.js
index 6f87cc7bfc7df..56bb9a4a2dbcf 100644
--- a/packages/edit-post/src/components/header/header-toolbar/index.native.js
+++ b/packages/edit-post/src/components/header/header-toolbar/index.native.js
@@ -11,10 +11,7 @@ import { compose, withPreferredColorScheme } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data';
import { withViewportMatch } from '@wordpress/viewport';
import { __ } from '@wordpress/i18n';
-import {
- Inserter,
- BlockToolbar,
-} from '@wordpress/block-editor';
+import { Inserter, BlockToolbar } from '@wordpress/block-editor';
import { Toolbar, ToolbarButton } from '@wordpress/components';
/**
@@ -39,7 +36,12 @@ function HeaderToolbar( {
};
return (
-
+
- { hasFixedToolbar &&
-
- }
+ { hasFixedToolbar && }
- { showKeyboardHideButton &&
+ { showKeyboardHideButton && (
- }
+ ) }
);
}
@@ -89,10 +95,15 @@ export default compose( [
withSelect( ( select ) => ( {
hasRedo: select( 'core/editor' ).hasEditorRedo(),
hasUndo: select( 'core/editor' ).hasEditorUndo(),
- hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' ),
+ hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive(
+ 'fixedToolbar'
+ ),
// This setting (richEditingEnabled) should not live in the block editor's setting.
- showInserter: select( 'core/edit-post' ).getEditorMode() === 'visual' && select( 'core/editor' ).getEditorSettings().richEditingEnabled,
- isTextModeEnabled: select( 'core/edit-post' ).getEditorMode() === 'text',
+ showInserter:
+ select( 'core/edit-post' ).getEditorMode() === 'visual' &&
+ select( 'core/editor' ).getEditorSettings().richEditingEnabled,
+ isTextModeEnabled:
+ select( 'core/edit-post' ).getEditorMode() === 'text',
} ) ),
withDispatch( ( dispatch ) => {
const { clearSelectedBlock } = dispatch( 'core/block-editor' );
diff --git a/packages/edit-post/src/components/header/header-toolbar/style.scss b/packages/edit-post/src/components/header/header-toolbar/style.scss
index 0f8c0ac306bfc..7521496954e13 100644
--- a/packages/edit-post/src/components/header/header-toolbar/style.scss
+++ b/packages/edit-post/src/components/header/header-toolbar/style.scss
@@ -54,7 +54,7 @@
}
// Move toolbar into top Editor Bar.
- @include break-xlarge {
+ @include break-wide {
padding-left: $grid-size;
position: static;
left: auto;
diff --git a/packages/edit-post/src/components/header/index.js b/packages/edit-post/src/components/header/index.js
index c0a900a9a2341..730bd4d542000 100644
--- a/packages/edit-post/src/components/header/index.js
+++ b/packages/edit-post/src/components/header/index.js
@@ -3,10 +3,7 @@
*/
import { __ } from '@wordpress/i18n';
import { Button } from '@wordpress/components';
-import {
- PostPreviewButton,
- PostSavedState,
-} from '@wordpress/editor';
+import { PostPreviewButton, PostSavedState } from '@wordpress/editor';
import { useSelect, useDispatch } from '@wordpress/data';
/**
@@ -26,26 +23,39 @@ function Header() {
isPublishSidebarOpened,
isSaving,
getBlockSelectionStart,
- } = useSelect( ( select ) => ( {
- shortcut: select( 'core/keyboard-shortcuts' ).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' ),
- hasActiveMetaboxes: select( 'core/edit-post' ).hasMetaBoxes(),
- isEditorSidebarOpened: select( 'core/edit-post' ).isEditorSidebarOpened(),
- isPublishSidebarOpened: select( 'core/edit-post' ).isPublishSidebarOpened(),
- isSaving: select( 'core/edit-post' ).isSavingMetaBoxes(),
- getBlockSelectionStart: select( 'core/block-editor' ).getBlockSelectionStart,
- } ), [] );
- const { openGeneralSidebar, closeGeneralSidebar } = useDispatch( 'core/edit-post' );
+ } = useSelect(
+ ( select ) => ( {
+ shortcut: select(
+ 'core/keyboard-shortcuts'
+ ).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' ),
+ hasActiveMetaboxes: select( 'core/edit-post' ).hasMetaBoxes(),
+ isEditorSidebarOpened: select(
+ 'core/edit-post'
+ ).isEditorSidebarOpened(),
+ isPublishSidebarOpened: select(
+ 'core/edit-post'
+ ).isPublishSidebarOpened(),
+ isSaving: select( 'core/edit-post' ).isSavingMetaBoxes(),
+ getBlockSelectionStart: select( 'core/block-editor' )
+ .getBlockSelectionStart,
+ } ),
+ []
+ );
+ const { openGeneralSidebar, closeGeneralSidebar } = useDispatch(
+ 'core/edit-post'
+ );
- const toggleGeneralSidebar = isEditorSidebarOpened ?
- closeGeneralSidebar :
- () => openGeneralSidebar( getBlockSelectionStart() ? 'edit-post/block' : 'edit-post/document' );
+ const toggleGeneralSidebar = isEditorSidebarOpened
+ ? closeGeneralSidebar
+ : () =>
+ openGeneralSidebar(
+ getBlockSelectionStart()
+ ? 'edit-post/block'
+ : 'edit-post/document'
+ );
return (
-
-
-
-
{ ! isPublishSidebarOpened && (
// This button isn't completely hidden by the publish sidebar.
@@ -77,6 +87,10 @@ function Header() {
+
+
+
+
);
}
diff --git a/packages/edit-post/src/components/header/index.native.js b/packages/edit-post/src/components/header/index.native.js
index 93fbf88ce7967..727061f24aa46 100644
--- a/packages/edit-post/src/components/header/index.native.js
+++ b/packages/edit-post/src/components/header/index.native.js
@@ -45,7 +45,9 @@ export default class Header extends Component {
render() {
return (
-
+
);
}
}
diff --git a/packages/edit-post/src/components/header/mode-switcher/index.js b/packages/edit-post/src/components/header/mode-switcher/index.js
index 49569b034b915..78a522470f729 100644
--- a/packages/edit-post/src/components/header/mode-switcher/index.js
+++ b/packages/edit-post/src/components/header/mode-switcher/index.js
@@ -27,12 +27,19 @@ function ModeSwitcher() {
isRichEditingEnabled,
isCodeEditingEnabled,
mode,
- } = useSelect( ( select ) => ( {
- shortcut: select( 'core/keyboard-shortcuts' ).getShortcutRepresentation( 'core/edit-post/toggle-mode' ),
- isRichEditingEnabled: select( 'core/editor' ).getEditorSettings().richEditingEnabled,
- isCodeEditingEnabled: select( 'core/editor' ).getEditorSettings().codeEditingEnabled,
- mode: select( 'core/edit-post' ).getEditorMode(),
- } ), [] );
+ } = useSelect(
+ ( select ) => ( {
+ shortcut: select(
+ 'core/keyboard-shortcuts'
+ ).getShortcutRepresentation( 'core/edit-post/toggle-mode' ),
+ isRichEditingEnabled: select( 'core/editor' ).getEditorSettings()
+ .richEditingEnabled,
+ isCodeEditingEnabled: select( 'core/editor' ).getEditorSettings()
+ .codeEditingEnabled,
+ mode: select( 'core/edit-post' ).getEditorMode(),
+ } ),
+ []
+ );
const { switchEditorMode } = useDispatch( 'core/edit-post' );
const choices = MODES.map( ( choice ) => {
@@ -47,9 +54,7 @@ function ModeSwitcher() {
}
return (
-
+
{
it( 'should match snapshot', () => {
- const wrapper = mount(
-
- );
+ const wrapper = mount( );
expect( wrapper ).toMatchSnapshot();
} );
diff --git a/packages/edit-post/src/components/header/pinned-plugins/index.js b/packages/edit-post/src/components/header/pinned-plugins/index.js
index 0d6c50f1b78a4..35f07ab0678d8 100644
--- a/packages/edit-post/src/components/header/pinned-plugins/index.js
+++ b/packages/edit-post/src/components/header/pinned-plugins/index.js
@@ -12,11 +12,11 @@ const { Fill: PinnedPlugins, Slot } = createSlotFill( 'PinnedPlugins' );
PinnedPlugins.Slot = ( props ) => (
- { ( fills ) => ! isEmpty( fills ) && (
-
- { fills }
-
- ) }
+ { ( fills ) =>
+ ! isEmpty( fills ) && (
+ { fills }
+ )
+ }
);
diff --git a/packages/edit-post/src/components/header/plugin-more-menu-item/index.js b/packages/edit-post/src/components/header/plugin-more-menu-item/index.js
index 08a5bef83b35e..66940b9579baa 100644
--- a/packages/edit-post/src/components/header/plugin-more-menu-item/index.js
+++ b/packages/edit-post/src/components/header/plugin-more-menu-item/index.js
@@ -85,5 +85,5 @@ export default compose(
return {
icon: ownProps.icon || context.icon,
};
- } ),
+ } )
)( PluginMoreMenuItem );
diff --git a/packages/edit-post/src/components/header/plugin-more-menu-item/test/index.js b/packages/edit-post/src/components/header/plugin-more-menu-item/test/index.js
index 9ab1b35920bcc..1bf7651db97a5 100644
--- a/packages/edit-post/src/components/header/plugin-more-menu-item/test/index.js
+++ b/packages/edit-post/src/components/header/plugin-more-menu-item/test/index.js
@@ -23,9 +23,7 @@ describe( 'PluginMoreMenuItem', () => {
test( 'renders menu item as button properly', () => {
const component = ReactTestRenderer.create(
-
+
My plugin button menu item
@@ -39,10 +37,7 @@ describe( 'PluginMoreMenuItem', () => {
const url = 'https://make.wordpress.org';
const component = ReactTestRenderer.create(
-
+
My plugin link menu item
diff --git a/packages/edit-post/src/components/header/plugin-sidebar-more-menu-item/index.js b/packages/edit-post/src/components/header/plugin-sidebar-more-menu-item/index.js
index c1f4ff42ae98a..fef6449f130a8 100644
--- a/packages/edit-post/src/components/header/plugin-sidebar-more-menu-item/index.js
+++ b/packages/edit-post/src/components/header/plugin-sidebar-more-menu-item/index.js
@@ -4,15 +4,21 @@
import { compose } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data';
import { withPluginContext } from '@wordpress/plugins';
+import { check } from '@wordpress/icons';
/**
* Internal dependencies
*/
import PluginMoreMenuItem from '../plugin-more-menu-item';
-const PluginSidebarMoreMenuItem = ( { children, icon, isSelected, onClick } ) => (
+const PluginSidebarMoreMenuItem = ( {
+ children,
+ icon,
+ isSelected,
+ onClick,
+} ) => (
{
- const {
- getActiveGeneralSidebarName,
- } = select( 'core/edit-post' );
+ const { getActiveGeneralSidebarName } = select( 'core/edit-post' );
return {
isSelected: getActiveGeneralSidebarName() === sidebarName,
};
} ),
withDispatch( ( dispatch, { isSelected, sidebarName } ) => {
- const {
- closeGeneralSidebar,
- openGeneralSidebar,
- } = dispatch( 'core/edit-post' );
- const onClick = isSelected ?
- closeGeneralSidebar :
- () => openGeneralSidebar( sidebarName );
+ const { closeGeneralSidebar, openGeneralSidebar } = dispatch(
+ 'core/edit-post'
+ );
+ const onClick = isSelected
+ ? closeGeneralSidebar
+ : () => openGeneralSidebar( sidebarName );
return { onClick };
- } ),
+ } )
)( PluginSidebarMoreMenuItem );
diff --git a/packages/edit-post/src/components/header/plugins-more-menu-group/index.js b/packages/edit-post/src/components/header/plugins-more-menu-group/index.js
index 82fe50c4d53ec..50b7aa5efd69d 100644
--- a/packages/edit-post/src/components/header/plugins-more-menu-group/index.js
+++ b/packages/edit-post/src/components/header/plugins-more-menu-group/index.js
@@ -9,15 +9,17 @@ import { isEmpty } from 'lodash';
import { createSlotFill, MenuGroup } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
-const { Fill: PluginsMoreMenuGroup, Slot } = createSlotFill( 'PluginsMoreMenuGroup' );
+const { Fill: PluginsMoreMenuGroup, Slot } = createSlotFill(
+ 'PluginsMoreMenuGroup'
+);
PluginsMoreMenuGroup.Slot = ( { fillProps } ) => (
- { ( fills ) => ! isEmpty( fills ) && (
-
- { fills }
-
- ) }
+ { ( fills ) =>
+ ! isEmpty( fills ) && (
+ { fills }
+ )
+ }
);
diff --git a/packages/edit-post/src/components/header/post-publish-button-or-toggle.js b/packages/edit-post/src/components/header/post-publish-button-or-toggle.js
index e483e3ee270bb..6c31425c2e192 100644
--- a/packages/edit-post/src/components/header/post-publish-button-or-toggle.js
+++ b/packages/edit-post/src/components/header/post-publish-button-or-toggle.js
@@ -84,8 +84,12 @@ export default compose(
isBeingScheduled: select( 'core/editor' ).isEditedPostBeingScheduled(),
isPending: select( 'core/editor' ).isCurrentPostPending(),
isPublished: select( 'core/editor' ).isCurrentPostPublished(),
- isPublishSidebarEnabled: select( 'core/editor' ).isPublishSidebarEnabled(),
- isPublishSidebarOpened: select( 'core/edit-post' ).isPublishSidebarOpened(),
+ isPublishSidebarEnabled: select(
+ 'core/editor'
+ ).isPublishSidebarEnabled(),
+ isPublishSidebarOpened: select(
+ 'core/edit-post'
+ ).isPublishSidebarOpened(),
isScheduled: select( 'core/editor' ).isCurrentPostScheduled(),
} ) ),
withDispatch( ( dispatch ) => {
@@ -93,5 +97,5 @@ export default compose(
return {
togglePublishSidebar,
};
- } ),
+ } )
)( PostPublishButtonOrToggle );
diff --git a/packages/edit-post/src/components/header/style.scss b/packages/edit-post/src/components/header/style.scss
index b862dfa1388bc..3c06b4dc15d9f 100644
--- a/packages/edit-post/src/components/header/style.scss
+++ b/packages/edit-post/src/components/header/style.scss
@@ -4,6 +4,7 @@
background: $white;
display: flex;
flex-wrap: wrap;
+ flex-direction: row-reverse;
justify-content: space-between;
align-items: center;
// The header should never be wider than the viewport, or buttons might be hidden. Especially relevant at high zoom levels. Related to https://core.trac.wordpress.org/ticket/47603#ticket.
diff --git a/packages/edit-post/src/components/header/test/index.js b/packages/edit-post/src/components/header/test/index.js
index 95ce0b5fc6136..b004b784304f2 100644
--- a/packages/edit-post/src/components/header/test/index.js
+++ b/packages/edit-post/src/components/header/test/index.js
@@ -10,34 +10,44 @@ import { PostPublishButtonOrToggle } from '../post-publish-button-or-toggle';
describe( 'PostPublishButtonOrToggle should render a', () => {
it( 'button when the post is published (1)', () => {
- const wrapper = shallow( );
+ const wrapper = shallow(
+
+ );
expect( wrapper ).toMatchSnapshot();
} );
it( 'button when the post is scheduled (2)', () => {
- const wrapper = shallow( );
+ const wrapper = shallow(
+
+ );
expect( wrapper ).toMatchSnapshot();
} );
it( 'button when the post is pending and cannot be published but the viewport is >= medium (3)', () => {
- const wrapper = shallow( );
+ const wrapper = shallow(
+
+ );
expect( wrapper ).toMatchSnapshot();
} );
it( 'toggle when post is not (1), (2), (3), the viewport is >= medium, and the publish sidebar is enabled', () => {
- const wrapper = shallow( );
+ const wrapper = shallow(
+
+ );
expect( wrapper ).toMatchSnapshot();
} );
it( 'button when post is not (1), (2), (3), the viewport is >= medium, and the publish sidebar is disabled', () => {
- const wrapper = shallow( );
+ const wrapper = shallow(
+
+ );
expect( wrapper ).toMatchSnapshot();
} );
} );
diff --git a/packages/edit-post/src/components/header/tools-more-menu-group/index.js b/packages/edit-post/src/components/header/tools-more-menu-group/index.js
index 01571604d4cb9..d49db11a0b4af 100644
--- a/packages/edit-post/src/components/header/tools-more-menu-group/index.js
+++ b/packages/edit-post/src/components/header/tools-more-menu-group/index.js
@@ -9,15 +9,17 @@ import { isEmpty } from 'lodash';
import { createSlotFill, MenuGroup } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
-const { Fill: ToolsMoreMenuGroup, Slot } = createSlotFill( 'ToolsMoreMenuGroup' );
+const { Fill: ToolsMoreMenuGroup, Slot } = createSlotFill(
+ 'ToolsMoreMenuGroup'
+);
ToolsMoreMenuGroup.Slot = ( { fillProps } ) => (
- { ( fills ) => ! isEmpty( fills ) && (
-
- { fills }
-
- ) }
+ { ( fills ) =>
+ ! isEmpty( fills ) && (
+ { fills }
+ )
+ }
);
diff --git a/packages/edit-post/src/components/header/writing-menu/index.js b/packages/edit-post/src/components/header/writing-menu/index.js
index ee9769818b1ca..b7c125b0e9a4e 100644
--- a/packages/edit-post/src/components/header/writing-menu/index.js
+++ b/packages/edit-post/src/components/header/writing-menu/index.js
@@ -17,13 +17,13 @@ function WritingMenu() {
}
return (
-
+
diff --git a/packages/edit-post/src/components/keyboard-shortcut-help-modal/index.js b/packages/edit-post/src/components/keyboard-shortcut-help-modal/index.js
index 16181ac4c4776..04e3ebf7e75fc 100644
--- a/packages/edit-post/src/components/keyboard-shortcut-help-modal/index.js
+++ b/packages/edit-post/src/components/keyboard-shortcut-help-modal/index.js
@@ -28,16 +28,20 @@ const ShortcutList = ( { shortcuts } ) => (
* Safari+VoiceOver won't announce the list otherwise.
*/
/* eslint-disable jsx-a11y/no-redundant-roles */
-
+
{ shortcuts.map( ( shortcut, index ) => (
- { isString( shortcut ) ?
- :
+ { isString( shortcut ) ? (
+
+ ) : (
- }
+ ) }
) ) }
@@ -45,7 +49,12 @@ const ShortcutList = ( { shortcuts } ) => (
);
const ShortcutSection = ( { title, shortcuts, className } ) => (
-
+
{ !! title && (
{ title }
@@ -56,7 +65,9 @@ const ShortcutSection = ( { title, shortcuts, className } ) => (
);
export function KeyboardShortcutHelpModal( { isModalActive, toggleModal } ) {
- useShortcut( 'core/edit-post/keyboard-shortcuts', toggleModal, { bindGlobal: true } );
+ useShortcut( 'core/edit-post/keyboard-shortcuts', toggleModal, {
+ bindGlobal: true,
+ } );
if ( ! isModalActive ) {
return null;
@@ -103,7 +114,9 @@ export function KeyboardShortcutHelpModal( { isModalActive, toggleModal } ) {
'core/block-editor/insert-after',
{
keyCombination: { character: '/' },
- description: __( 'Change the block type after adding a new paragraph.' ),
+ description: __(
+ 'Change the block type after adding a new paragraph.'
+ ),
/* translators: The forward-slash character. e.g. '/'. */
ariaLabel: __( 'Forward-slash' ),
},
@@ -122,13 +135,11 @@ export default compose( [
isModalActive: select( 'core/edit-post' ).isModalActive( MODAL_NAME ),
} ) ),
withDispatch( ( dispatch, { isModalActive } ) => {
- const {
- openModal,
- closeModal,
- } = dispatch( 'core/edit-post' );
+ const { openModal, closeModal } = dispatch( 'core/edit-post' );
return {
- toggleModal: () => isModalActive ? closeModal() : openModal( MODAL_NAME ),
+ toggleModal: () =>
+ isModalActive ? closeModal() : openModal( MODAL_NAME ),
};
} ),
] )( KeyboardShortcutHelpModal );
diff --git a/packages/edit-post/src/components/keyboard-shortcut-help-modal/shortcut.js b/packages/edit-post/src/components/keyboard-shortcut-help-modal/shortcut.js
index a0c810528908a..aceed29d2f189 100644
--- a/packages/edit-post/src/components/keyboard-shortcut-help-modal/shortcut.js
+++ b/packages/edit-post/src/components/keyboard-shortcut-help-modal/shortcut.js
@@ -10,12 +10,16 @@ import { Fragment } from '@wordpress/element';
import { displayShortcutList, shortcutAriaLabel } from '@wordpress/keycodes';
function KeyCombination( { keyCombination, forceAriaLabel } ) {
- const shortcut = keyCombination.modifier ?
- displayShortcutList[ keyCombination.modifier ]( keyCombination.character ) :
- keyCombination.character;
- const ariaLabel = keyCombination.modifier ?
- shortcutAriaLabel[ keyCombination.modifier ]( keyCombination.character ) :
- keyCombination.character;
+ const shortcut = keyCombination.modifier
+ ? displayShortcutList[ keyCombination.modifier ](
+ keyCombination.character
+ )
+ : keyCombination.character;
+ const ariaLabel = keyCombination.modifier
+ ? shortcutAriaLabel[ keyCombination.modifier ](
+ keyCombination.character
+ )
+ : keyCombination.character;
return (
{ castArray( shortcut ).map( ( character, index ) => {
if ( character === '+' ) {
- return (
-
- { character }
-
- );
+ return { character } ;
}
return (
@@ -51,9 +51,16 @@ function Shortcut( { description, keyCombination, aliases = [], ariaLabel } ) {
{ description }
-
+
{ aliases.map( ( alias, index ) => (
-
+
) ) }
>
diff --git a/packages/edit-post/src/components/keyboard-shortcuts/index.js b/packages/edit-post/src/components/keyboard-shortcuts/index.js
index 0096c4702d123..d261551e43113 100644
--- a/packages/edit-post/src/components/keyboard-shortcuts/index.js
+++ b/packages/edit-post/src/components/keyboard-shortcuts/index.js
@@ -10,15 +10,17 @@ function KeyboardShortcuts() {
const {
getBlockSelectionStart,
getEditorMode,
- isEditorSidebarOpen,
+ isEditorSidebarOpened,
richEditingEnabled,
codeEditingEnabled,
} = useSelect( ( select ) => {
const settings = select( 'core/editor' ).getEditorSettings();
return {
- getBlockSelectionStart: select( 'core/block-editor' ).getBlockSelectionStart,
+ getBlockSelectionStart: select( 'core/block-editor' )
+ .getBlockSelectionStart,
getEditorMode: select( 'core/edit-post' ).getEditorMode,
- isEditorSidebarOpened: select( 'core/edit-post' ).isEditorSidebarOpened,
+ isEditorSidebarOpened: select( 'core/edit-post' )
+ .isEditorSidebarOpened,
richEditingEnabled: settings.richEditingEnabled,
codeEditingEnabled: settings.codeEditingEnabled,
};
@@ -70,10 +72,12 @@ function KeyboardShortcuts() {
modifier: 'ctrl',
character: '`',
},
- aliases: [ {
- modifier: 'access',
- character: 'n',
- } ],
+ aliases: [
+ {
+ modifier: 'access',
+ character: 'n',
+ },
+ ],
} );
registerShortcut( {
@@ -84,10 +88,12 @@ function KeyboardShortcuts() {
modifier: 'ctrlShift',
character: '`',
},
- aliases: [ {
- modifier: 'access',
- character: 'p',
- } ],
+ aliases: [
+ {
+ modifier: 'access',
+ character: 'p',
+ },
+ ],
} );
registerShortcut( {
@@ -101,22 +107,37 @@ function KeyboardShortcuts() {
} );
}, [] );
- useShortcut( 'core/edit-post/toggle-mode', () => {
- switchEditorMode( getEditorMode() === 'visual' ? 'text' : 'visual' );
- }, { bindGlobal: true, isDisabled: ! richEditingEnabled || ! codeEditingEnabled } );
+ useShortcut(
+ 'core/edit-post/toggle-mode',
+ () => {
+ switchEditorMode(
+ getEditorMode() === 'visual' ? 'text' : 'visual'
+ );
+ },
+ {
+ bindGlobal: true,
+ isDisabled: ! richEditingEnabled || ! codeEditingEnabled,
+ }
+ );
- useShortcut( 'core/edit-post/toggle-sidebar', ( event ) => {
- // This shortcut has no known clashes, but use preventDefault to prevent any
- // obscure shortcuts from triggering.
- event.preventDefault();
+ useShortcut(
+ 'core/edit-post/toggle-sidebar',
+ ( event ) => {
+ // This shortcut has no known clashes, but use preventDefault to prevent any
+ // obscure shortcuts from triggering.
+ event.preventDefault();
- if ( isEditorSidebarOpen ) {
- closeGeneralSidebar();
- } else {
- const sidebarToOpen = getBlockSelectionStart() ? 'edit-post/block' : 'edit-post/document';
- openGeneralSidebar( sidebarToOpen );
- }
- }, { bindGlobal: true } );
+ if ( isEditorSidebarOpened() ) {
+ closeGeneralSidebar();
+ } else {
+ const sidebarToOpen = getBlockSelectionStart()
+ ? 'edit-post/block'
+ : 'edit-post/document';
+ openGeneralSidebar( sidebarToOpen );
+ }
+ },
+ { bindGlobal: true }
+ );
return null;
}
diff --git a/packages/edit-post/src/components/layout/index.js b/packages/edit-post/src/components/layout/index.js
index 7dbb356815d0e..adefc6eb48d83 100644
--- a/packages/edit-post/src/components/layout/index.js
+++ b/packages/edit-post/src/components/layout/index.js
@@ -52,7 +52,9 @@ import WelcomeGuide from '../welcome-guide';
function Layout() {
const isMobileViewport = useViewportMatch( 'small', '<' );
- const { closePublishSidebar, togglePublishSidebar } = useDispatch( 'core/edit-post' );
+ const { closePublishSidebar, togglePublishSidebar } = useDispatch(
+ 'core/edit-post'
+ );
const {
mode,
isRichEditingEnabled,
@@ -65,21 +67,37 @@ function Layout() {
previousShortcut,
nextShortcut,
} = useSelect( ( select ) => {
- return ( {
- hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' ),
- editorSidebarOpened: select( 'core/edit-post' ).isEditorSidebarOpened(),
- pluginSidebarOpened: select( 'core/edit-post' ).isPluginSidebarOpened(),
- publishSidebarOpened: select( 'core/edit-post' ).isPublishSidebarOpened(),
+ return {
+ hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive(
+ 'fixedToolbar'
+ ),
+ editorSidebarOpened: select(
+ 'core/edit-post'
+ ).isEditorSidebarOpened(),
+ pluginSidebarOpened: select(
+ 'core/edit-post'
+ ).isPluginSidebarOpened(),
+ publishSidebarOpened: select(
+ 'core/edit-post'
+ ).isPublishSidebarOpened(),
mode: select( 'core/edit-post' ).getEditorMode(),
- isRichEditingEnabled: select( 'core/editor' ).getEditorSettings().richEditingEnabled,
+ isRichEditingEnabled: select( 'core/editor' ).getEditorSettings()
+ .richEditingEnabled,
hasActiveMetaboxes: select( 'core/edit-post' ).hasMetaBoxes(),
isSaving: select( 'core/edit-post' ).isSavingMetaBoxes(),
- previousShortcut: select( 'core/keyboard-shortcuts' ).getAllShortcutRawKeyCombinations( 'core/edit-post/previous-region' ),
- nextShortcut: select( 'core/keyboard-shortcuts' ).getAllShortcutRawKeyCombinations( 'core/edit-post/next-region' ),
- } );
+ previousShortcut: select(
+ 'core/keyboard-shortcuts'
+ ).getAllShortcutRawKeyCombinations(
+ 'core/edit-post/previous-region'
+ ),
+ nextShortcut: select(
+ 'core/keyboard-shortcuts'
+ ).getAllShortcutRawKeyCombinations( 'core/edit-post/next-region' ),
+ };
}, [] );
const showPageTemplatePicker = __experimentalUsePageTemplatePickerVisible();
- const sidebarIsOpened = editorSidebarOpened || pluginSidebarOpened || publishSidebarOpened;
+ const sidebarIsOpened =
+ editorSidebarOpened || pluginSidebarOpened || publishSidebarOpened;
const className = classnames( 'edit-post-layout', 'is-mode-' + mode, {
'is-sidebar-opened': sidebarIsOpened,
'has-fixed-toolbar': hasFixedToolbar,
@@ -99,50 +117,66 @@ function Layout() {
}
- sidebar={ ! publishSidebarOpened && (
- <>
-
-
- >
- ) }
+ sidebar={
+ ! publishSidebarOpened && (
+ <>
+
+
+ >
+ )
+ }
content={
<>
-
- { ( mode === 'text' || ! isRichEditingEnabled ) &&
}
- { isRichEditingEnabled && mode === 'visual' &&
}
+ { ( mode === 'text' || ! isRichEditingEnabled ) && (
+
+ ) }
+ { isRichEditingEnabled && mode === 'visual' && (
+
+ ) }
- { isMobileViewport && sidebarIsOpened &&
}
+ { isMobileViewport && sidebarIsOpened && (
+
+ ) }
>
}
- footer={ isRichEditingEnabled && mode === 'visual' && (
-
-
-
- ) }
- publish={ publishSidebarOpened ? (
-
- ) : (
-
-
- { __( 'Open publish panel' ) }
-
-
- ) }
+ footer={
+ isRichEditingEnabled &&
+ mode === 'visual' && (
+
+
+
+ )
+ }
+ publish={
+ publishSidebarOpened ? (
+
+ ) : (
+
+
+ { __( 'Open publish panel' ) }
+
+
+ )
+ }
shortcuts={ {
previous: previousShortcut,
next: nextShortcut,
@@ -154,9 +188,10 @@ function Layout() {
- { showPageTemplatePicker && <__experimentalPageTemplatePicker /> }
+ { showPageTemplatePicker && (
+ <__experimentalPageTemplatePicker />
+ ) }
-
>
);
}
diff --git a/packages/edit-post/src/components/layout/index.native.js b/packages/edit-post/src/components/layout/index.native.js
index 2423dd1dabfd1..54ec6aa801e60 100644
--- a/packages/edit-post/src/components/layout/index.native.js
+++ b/packages/edit-post/src/components/layout/index.native.js
@@ -10,9 +10,17 @@ import { sendNativeEditorDidLayout } from 'react-native-gutenberg-bridge';
*/
import { Component } from '@wordpress/element';
import { withSelect } from '@wordpress/data';
-import { BottomSheetSettings, __experimentalPageTemplatePicker, __experimentalWithPageTemplatePickerVisible } from '@wordpress/block-editor';
+import {
+ BottomSheetSettings,
+ __experimentalPageTemplatePicker,
+ __experimentalWithPageTemplatePickerVisible,
+} from '@wordpress/block-editor';
import { compose, withPreferredColorScheme } from '@wordpress/compose';
-import { HTMLTextInput, KeyboardAvoidingView, ReadableContentView } from '@wordpress/components';
+import {
+ HTMLTextInput,
+ KeyboardAvoidingView,
+ ReadableContentView,
+} from '@wordpress/components';
import { AutosaveMonitor } from '@wordpress/editor';
/**
@@ -36,16 +44,24 @@ class Layout extends Component {
isFullyBordered: true,
};
- SafeArea.getSafeAreaInsetsForRootView().then( this.onSafeAreaInsetsUpdate );
+ SafeArea.getSafeAreaInsetsForRootView().then(
+ this.onSafeAreaInsetsUpdate
+ );
}
componentDidMount() {
this._isMounted = true;
- SafeArea.addEventListener( 'safeAreaInsetsForRootViewDidChange', this.onSafeAreaInsetsUpdate );
+ SafeArea.addEventListener(
+ 'safeAreaInsetsForRootViewDidChange',
+ this.onSafeAreaInsetsUpdate
+ );
}
componentWillUnmount() {
- SafeArea.removeEventListener( 'safeAreaInsetsForRootViewDidChange', this.onSafeAreaInsetsUpdate );
+ SafeArea.removeEventListener(
+ 'safeAreaInsetsForRootViewDidChange',
+ this.onSafeAreaInsetsUpdate
+ );
this._isMounted = false;
}
@@ -76,15 +92,11 @@ class Layout extends Component {
}
renderHTML() {
- return (
-
- );
+ return
;
}
renderVisual() {
- const {
- isReady,
- } = this.props;
+ const { isReady } = this.props;
if ( ! isReady ) {
return null;
@@ -108,7 +120,10 @@ class Layout extends Component {
const isHtmlView = mode === 'text';
// add a margin view at the bottom for the header
- const marginBottom = Platform.OS === 'android' && ! isHtmlView ? headerToolbarStyles.container.height : 0;
+ const marginBottom =
+ Platform.OS === 'android' && ! isHtmlView
+ ? headerToolbarStyles.container.height
+ : 0;
const toolbarKeyboardAvoidingViewStyle = {
...styles.toolbarKeyboardAvoidingView,
@@ -118,21 +133,41 @@ class Layout extends Component {
};
return (
-
+
-
+
{ isHtmlView ? this.renderHTML() : this.renderVisual() }
-
+
{ ! isHtmlView && (
+ { showPageTemplatePicker && (
+ <__experimentalPageTemplatePicker />
+ ) }
- ) }
- { showPageTemplatePicker && <__experimentalPageTemplatePicker /> }
+
+ ) }
);
}
@@ -140,12 +175,10 @@ class Layout extends Component {
export default compose( [
withSelect( ( select ) => {
- const {
- __unstableIsEditorReady: isEditorReady,
- } = select( 'core/editor' );
- const {
- getEditorMode,
- } = select( 'core/edit-post' );
+ const { __unstableIsEditorReady: isEditorReady } = select(
+ 'core/editor'
+ );
+ const { getEditorMode } = select( 'core/edit-post' );
return {
isReady: isEditorReady(),
diff --git a/packages/edit-post/src/components/manage-blocks-modal/category.js b/packages/edit-post/src/components/manage-blocks-modal/category.js
index c4beeebb642ea..5df158fe25433 100644
--- a/packages/edit-post/src/components/manage-blocks-modal/category.js
+++ b/packages/edit-post/src/components/manage-blocks-modal/category.js
@@ -27,17 +27,14 @@ function BlockManagerCategory( {
} ) {
const settings = useContext( EditPostSettings );
const { allowedBlockTypes } = settings;
- const filteredBlockTypes = useMemo(
- () => {
- if ( allowedBlockTypes === true ) {
- return blockTypes;
- }
- return blockTypes.filter( ( { name } ) => {
- return includes( allowedBlockTypes || [], name );
- } );
- },
- [ allowedBlockTypes, blockTypes ]
- );
+ const filteredBlockTypes = useMemo( () => {
+ if ( allowedBlockTypes === true ) {
+ return blockTypes;
+ }
+ return blockTypes.filter( ( { name } ) => {
+ return includes( allowedBlockTypes || [], name );
+ } );
+ }, [ allowedBlockTypes, blockTypes ] );
if ( ! filteredBlockTypes.length ) {
return null;
@@ -48,7 +45,8 @@ function BlockManagerCategory( {
...hiddenBlockTypes
);
- const titleId = 'edit-post-manage-blocks-modal__category-title-' + instanceId;
+ const titleId =
+ 'edit-post-manage-blocks-modal__category-title-' + instanceId;
const isAllChecked = checkedBlockNames.length === filteredBlockTypes.length;
@@ -93,10 +91,7 @@ export default compose( [
};
} ),
withDispatch( ( dispatch, ownProps ) => {
- const {
- showBlockTypes,
- hideBlockTypes,
- } = dispatch( 'core/edit-post' );
+ const { showBlockTypes, hideBlockTypes } = dispatch( 'core/edit-post' );
return {
toggleVisible( blockName, nextIsChecked ) {
diff --git a/packages/edit-post/src/components/manage-blocks-modal/checklist.js b/packages/edit-post/src/components/manage-blocks-modal/checklist.js
index 22ebb8139934a..ab561b071fbb4 100644
--- a/packages/edit-post/src/components/manage-blocks-modal/checklist.js
+++ b/packages/edit-post/src/components/manage-blocks-modal/checklist.js
@@ -18,12 +18,12 @@ function BlockTypesChecklist( { blockTypes, value, onItemChange } ) {
className="edit-post-manage-blocks-modal__checklist-item"
>
{ blockType.title }
>
- ) }
+ }
checked={ value.includes( blockType.name ) }
onChange={ partial( onItemChange, blockType.name ) }
/>
diff --git a/packages/edit-post/src/components/manage-blocks-modal/manager.js b/packages/edit-post/src/components/manage-blocks-modal/manager.js
index 541ff85afb7a6..bdb8349be888f 100644
--- a/packages/edit-post/src/components/manage-blocks-modal/manager.js
+++ b/packages/edit-post/src/components/manage-blocks-modal/manager.js
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
-import { filter, isArray } from 'lodash';
+import { filter, includes, isArray } from 'lodash';
/**
* WordPress dependencies
@@ -28,11 +28,13 @@ function BlockManager( {
// Filtering occurs here (as opposed to `withSelect`) to avoid wasted
// wasted renders by consequence of `Array#filter` producing a new
// value reference on each call.
- blockTypes = blockTypes.filter( ( blockType ) => (
- hasBlockSupport( blockType, 'inserter', true ) &&
- ( ! search || isMatchingSearchTerm( blockType, search ) ) &&
- ! blockType.parent
- ) );
+ blockTypes = blockTypes.filter(
+ ( blockType ) =>
+ hasBlockSupport( blockType, 'inserter', true ) &&
+ ( ! search || isMatchingSearchTerm( blockType, search ) ) &&
+ ( ! blockType.parent ||
+ includes( blockType.parent, 'core/post-content' ) )
+ );
return (
@@ -40,23 +42,23 @@ function BlockManager( {
type="search"
label={ __( 'Search for a block' ) }
value={ search }
- onChange={ ( nextSearch ) => setState( {
- search: nextSearch,
- } ) }
+ onChange={ ( nextSearch ) =>
+ setState( {
+ search: nextSearch,
+ } )
+ }
className="edit-post-manage-blocks-modal__search"
/>
{ !! numberOfHiddenBlocks && (
- {
- sprintf(
- _n(
- '%1$d block is disabled.',
- '%1$d blocks are disabled.',
- numberOfHiddenBlocks
- ),
+ { sprintf(
+ _n(
+ '%1$d block is disabled.',
+ '%1$d blocks are disabled.',
numberOfHiddenBlocks
- )
- }
+ ),
+ numberOfHiddenBlocks
+ ) }
) }
- {
- /* translators: Checkbox toggle label */
- __( 'Show section' )
- }
+ { /* translators: Checkbox toggle label */
+ __( 'Show section' ) }
{
- const { isMetaBoxLocationVisible, getMetaBoxesPerLocation } = select( 'core/edit-post' );
+ const { isMetaBoxLocationVisible, getMetaBoxesPerLocation } = select(
+ 'core/edit-post'
+ );
return {
metaBoxes: getMetaBoxesPerLocation( location ),
diff --git a/packages/edit-post/src/components/meta-boxes/meta-box-visibility.js b/packages/edit-post/src/components/meta-boxes/meta-box-visibility.js
index 970cf26355e6c..c6af87bebb260 100644
--- a/packages/edit-post/src/components/meta-boxes/meta-box-visibility.js
+++ b/packages/edit-post/src/components/meta-boxes/meta-box-visibility.js
@@ -36,5 +36,7 @@ class MetaBoxVisibility extends Component {
}
export default withSelect( ( select, { id } ) => ( {
- isVisible: select( 'core/edit-post' ).isEditorPanelEnabled( `meta-box-${ id }` ),
+ isVisible: select( 'core/edit-post' ).isEditorPanelEnabled(
+ `meta-box-${ id }`
+ ),
} ) )( MetaBoxVisibility );
diff --git a/packages/edit-post/src/components/meta-boxes/meta-boxes-area/index.js b/packages/edit-post/src/components/meta-boxes/meta-boxes-area/index.js
index 9a32498c2c275..239d013be69b9 100644
--- a/packages/edit-post/src/components/meta-boxes/meta-boxes-area/index.js
+++ b/packages/edit-post/src/components/meta-boxes/meta-boxes-area/index.js
@@ -23,7 +23,9 @@ class MetaBoxesArea extends Component {
* @inheritdoc
*/
componentDidMount() {
- this.form = document.querySelector( '.metabox-location-' + this.props.location );
+ this.form = document.querySelector(
+ '.metabox-location-' + this.props.location
+ );
if ( this.form ) {
this.container.appendChild( this.form );
}
@@ -64,7 +66,10 @@ class MetaBoxesArea extends Component {
return (
);
diff --git a/packages/edit-post/src/components/options-modal/index.js b/packages/edit-post/src/components/options-modal/index.js
index bd5b83fb3f529..c03648bf2c0bf 100644
--- a/packages/edit-post/src/components/options-modal/index.js
+++ b/packages/edit-post/src/components/options-modal/index.js
@@ -45,13 +45,21 @@ export function OptionsModal( { isModalActive, isViewable, closeModal } ) {
onRequestClose={ closeModal }
>
{ isViewable && (
-
+
) }
(
@@ -62,16 +70,30 @@ export function OptionsModal( { isModalActive, isViewable, closeModal } ) {
) }
/>
-
+
-
+
-
-
+
+
-
+
@@ -86,7 +108,9 @@ export default compose(
const postType = getPostType( getEditedPostAttribute( 'type' ) );
return {
- isModalActive: select( 'core/edit-post' ).isModalActive( MODAL_NAME ),
+ isModalActive: select( 'core/edit-post' ).isModalActive(
+ MODAL_NAME
+ ),
isViewable: get( postType, [ 'viewable' ], false ),
};
} ),
diff --git a/packages/edit-post/src/components/options-modal/meta-boxes-section.js b/packages/edit-post/src/components/options-modal/meta-boxes-section.js
index 0443c47ee5560..802f8a88955a2 100644
--- a/packages/edit-post/src/components/options-modal/meta-boxes-section.js
+++ b/packages/edit-post/src/components/options-modal/meta-boxes-section.js
@@ -15,9 +15,16 @@ import { withSelect } from '@wordpress/data';
import Section from './section';
import { EnableCustomFieldsOption, EnablePanelOption } from './options';
-export function MetaBoxesSection( { areCustomFieldsRegistered, metaBoxes, ...sectionProps } ) {
+export function MetaBoxesSection( {
+ areCustomFieldsRegistered,
+ metaBoxes,
+ ...sectionProps
+} ) {
// The 'Custom Fields' meta box is a special case that we handle separately.
- const thirdPartyMetaBoxes = filter( metaBoxes, ( { id } ) => id !== 'postcustom' );
+ const thirdPartyMetaBoxes = filter(
+ metaBoxes,
+ ( { id } ) => id !== 'postcustom'
+ );
if ( ! areCustomFieldsRegistered && thirdPartyMetaBoxes.length === 0 ) {
return null;
@@ -25,9 +32,15 @@ export function MetaBoxesSection( { areCustomFieldsRegistered, metaBoxes, ...sec
return (
- { areCustomFieldsRegistered && }
+ { areCustomFieldsRegistered && (
+
+ ) }
{ map( thirdPartyMetaBoxes, ( { id, title } ) => (
-
+
) ) }
);
@@ -39,7 +52,8 @@ export default withSelect( ( select ) => {
return {
// This setting should not live in the block editor's store.
- areCustomFieldsRegistered: getEditorSettings().enableCustomFields !== undefined,
+ areCustomFieldsRegistered:
+ getEditorSettings().enableCustomFields !== undefined,
metaBoxes: getAllMetaBoxes(),
};
} )( MetaBoxesSection );
diff --git a/packages/edit-post/src/components/options-modal/options/enable-custom-fields.js b/packages/edit-post/src/components/options-modal/options/enable-custom-fields.js
index bb74c77bf62c8..d93392635a3f9 100644
--- a/packages/edit-post/src/components/options-modal/options/enable-custom-fields.js
+++ b/packages/edit-post/src/components/options-modal/options/enable-custom-fields.js
@@ -17,7 +17,9 @@ export function CustomFieldsConfirmation( { willEnable } ) {
return (
<>
- { __( 'A page reload is required for this change. Make sure your content is saved before reloading.' ) }
+ { __(
+ 'A page reload is required for this change. Make sure your content is saved before reloading.'
+ ) }
{
setIsReloading( true );
- document.getElementById( 'toggle-custom-fields-form' ).submit();
+ document
+ .getElementById( 'toggle-custom-fields-form' )
+ .submit();
} }
>
- { willEnable ? __( 'Enable & Reload' ) : __( 'Disable & Reload' ) }
+ { willEnable
+ ? __( 'Enable & Reload' )
+ : __( 'Disable & Reload' ) }
>
);
@@ -44,11 +50,14 @@ export function EnableCustomFieldsOption( { label, areCustomFieldsEnabled } ) {
isChecked={ isChecked }
onChange={ setIsChecked }
>
- { isChecked !== areCustomFieldsEnabled && }
+ { isChecked !== areCustomFieldsEnabled && (
+
+ ) }
);
}
export default withSelect( ( select ) => ( {
- areCustomFieldsEnabled: !! select( 'core/editor' ).getEditorSettings().enableCustomFields,
+ areCustomFieldsEnabled: !! select( 'core/editor' ).getEditorSettings()
+ .enableCustomFields,
} ) )( EnableCustomFieldsOption );
diff --git a/packages/edit-post/src/components/options-modal/options/enable-panel.js b/packages/edit-post/src/components/options-modal/options/enable-panel.js
index d47ab67e7e6d9..57d134c0e6ef6 100644
--- a/packages/edit-post/src/components/options-modal/options/enable-panel.js
+++ b/packages/edit-post/src/components/options-modal/options/enable-panel.js
@@ -11,7 +11,9 @@ import BaseOption from './base';
export default compose(
withSelect( ( select, { panelName } ) => {
- const { isEditorPanelEnabled, isEditorPanelRemoved } = select( 'core/edit-post' );
+ const { isEditorPanelEnabled, isEditorPanelRemoved } = select(
+ 'core/edit-post'
+ );
return {
isRemoved: isEditorPanelRemoved( panelName ),
isChecked: isEditorPanelEnabled( panelName ),
@@ -19,6 +21,7 @@ export default compose(
} ),
ifCondition( ( { isRemoved } ) => ! isRemoved ),
withDispatch( ( dispatch, { panelName } ) => ( {
- onChange: () => dispatch( 'core/edit-post' ).toggleEditorPanelEnabled( panelName ),
+ onChange: () =>
+ dispatch( 'core/edit-post' ).toggleEditorPanelEnabled( panelName ),
} ) )
)( BaseOption );
diff --git a/packages/edit-post/src/components/options-modal/options/enable-plugin-document-setting-panel.js b/packages/edit-post/src/components/options-modal/options/enable-plugin-document-setting-panel.js
index ac979c357ad78..b18b0436579bc 100644
--- a/packages/edit-post/src/components/options-modal/options/enable-plugin-document-setting-panel.js
+++ b/packages/edit-post/src/components/options-modal/options/enable-plugin-document-setting-panel.js
@@ -8,14 +8,13 @@ import { createSlotFill } from '@wordpress/components';
*/
import { EnablePanelOption } from './index';
-const { Fill, Slot } = createSlotFill( 'EnablePluginDocumentSettingPanelOption' );
+const { Fill, Slot } = createSlotFill(
+ 'EnablePluginDocumentSettingPanelOption'
+);
const EnablePluginDocumentSettingPanelOption = ( { label, panelName } ) => (
-
+
);
diff --git a/packages/edit-post/src/components/options-modal/options/enable-publish-sidebar.js b/packages/edit-post/src/components/options-modal/options/enable-publish-sidebar.js
index e080fae578127..ce2bc2f7528db 100644
--- a/packages/edit-post/src/components/options-modal/options/enable-publish-sidebar.js
+++ b/packages/edit-post/src/components/options-modal/options/enable-publish-sidebar.js
@@ -15,12 +15,15 @@ export default compose(
isChecked: select( 'core/editor' ).isPublishSidebarEnabled(),
} ) ),
withDispatch( ( dispatch ) => {
- const { enablePublishSidebar, disablePublishSidebar } = dispatch( 'core/editor' );
+ const { enablePublishSidebar, disablePublishSidebar } = dispatch(
+ 'core/editor'
+ );
return {
- onChange: ( isEnabled ) => ( isEnabled ? enablePublishSidebar() : disablePublishSidebar() ),
+ onChange: ( isEnabled ) =>
+ isEnabled ? enablePublishSidebar() : disablePublishSidebar(),
};
} ),
// In < medium viewports we override this option and always show the publish sidebar.
// See the edit-post's header component for the specific logic.
- ifViewportMatches( 'medium' ),
+ ifViewportMatches( 'medium' )
)( BaseOption );
diff --git a/packages/edit-post/src/components/options-modal/options/test/__snapshots__/enable-custom-fields.js.snap b/packages/edit-post/src/components/options-modal/options/test/__snapshots__/enable-custom-fields.js.snap
index 03b3c7afb72cf..7988c3f41af70 100644
--- a/packages/edit-post/src/components/options-modal/options/test/__snapshots__/enable-custom-fields.js.snap
+++ b/packages/edit-post/src/components/options-modal/options/test/__snapshots__/enable-custom-fields.js.snap
@@ -23,16 +23,16 @@ exports[`EnableCustomFieldsOption renders a checked checkbox and a confirmation
/>
@@ -81,16 +81,16 @@ exports[`EnableCustomFieldsOption renders a checked checkbox when custom fields
/>
diff --git a/packages/edit-post/src/components/options-modal/options/test/enable-custom-fields.js b/packages/edit-post/src/components/options-modal/options/test/enable-custom-fields.js
index 5ac60c92753af..2ec4bc7af80e4 100644
--- a/packages/edit-post/src/components/options-modal/options/test/enable-custom-fields.js
+++ b/packages/edit-post/src/components/options-modal/options/test/enable-custom-fields.js
@@ -11,12 +11,17 @@ import { Button } from '@wordpress/components';
/**
* Internal dependencies
*/
-import { EnableCustomFieldsOption, CustomFieldsConfirmation } from '../enable-custom-fields';
+import {
+ EnableCustomFieldsOption,
+ CustomFieldsConfirmation,
+} from '../enable-custom-fields';
import BaseOption from '../base';
describe( 'EnableCustomFieldsOption', () => {
it( 'renders a checked checkbox when custom fields are enabled', () => {
- const renderer = TestRenderer.create( );
+ const renderer = TestRenderer.create(
+
+ );
expect( renderer ).toMatchSnapshot();
} );
@@ -28,7 +33,9 @@ describe( 'EnableCustomFieldsOption', () => {
} );
it( 'renders an unchecked checkbox and a confirmation message when toggled off', () => {
- const renderer = new TestRenderer.create( );
+ const renderer = new TestRenderer.create(
+ ( )
+ );
act( () => {
renderer.root.findByType( BaseOption ).props.onChange( false );
} );
@@ -37,7 +44,7 @@ describe( 'EnableCustomFieldsOption', () => {
it( 'renders a checked checkbox and a confirmation message when toggled on', () => {
const renderer = new TestRenderer.create(
-
+ ( )
);
act( () => {
renderer.root.findByType( BaseOption ).props.onChange( true );
@@ -49,16 +56,22 @@ describe( 'EnableCustomFieldsOption', () => {
describe( 'CustomFieldsConfirmation', () => {
it( 'submits the toggle-custom-fields-form', () => {
const submit = jest.fn();
- const getElementById = jest.spyOn( document, 'getElementById' ).mockImplementation( () => ( {
- submit,
- } ) );
+ const getElementById = jest
+ .spyOn( document, 'getElementById' )
+ .mockImplementation( () => ( {
+ submit,
+ } ) );
- const renderer = new TestRenderer.create( );
+ const renderer = new TestRenderer.create(
+ ( )
+ );
act( () => {
renderer.root.findByType( Button ).props.onClick();
} );
- expect( getElementById ).toHaveBeenCalledWith( 'toggle-custom-fields-form' );
+ expect( getElementById ).toHaveBeenCalledWith(
+ 'toggle-custom-fields-form'
+ );
expect( submit ).toHaveBeenCalled();
getElementById.mockRestore();
diff --git a/packages/edit-post/src/components/options-modal/test/meta-boxes-section.js b/packages/edit-post/src/components/options-modal/test/meta-boxes-section.js
index 5cd95105ee34e..b00d2fdffb512 100644
--- a/packages/edit-post/src/components/options-modal/test/meta-boxes-section.js
+++ b/packages/edit-post/src/components/options-modal/test/meta-boxes-section.js
@@ -13,7 +13,9 @@ describe( 'MetaBoxesSection', () => {
const wrapper = shallow(
);
expect( wrapper.isEmptyRender() ).toBe( true );
@@ -24,7 +26,9 @@ describe( 'MetaBoxesSection', () => {
);
expect( wrapper ).toMatchSnapshot();
diff --git a/packages/edit-post/src/components/sidebar/discussion-panel/index.js b/packages/edit-post/src/components/sidebar/discussion-panel/index.js
index 9bb3680199592..47ea5ae4e500b 100644
--- a/packages/edit-post/src/components/sidebar/discussion-panel/index.js
+++ b/packages/edit-post/src/components/sidebar/discussion-panel/index.js
@@ -3,7 +3,11 @@
*/
import { __ } from '@wordpress/i18n';
import { PanelBody, PanelRow } from '@wordpress/components';
-import { PostComments, PostPingbacks, PostTypeSupportCheck } from '@wordpress/editor';
+import {
+ PostComments,
+ PostPingbacks,
+ PostTypeSupportCheck,
+} from '@wordpress/editor';
import { compose } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data';
@@ -19,7 +23,11 @@ function DiscussionPanel( { isEnabled, isOpened, onTogglePanel } ) {
return (
-
+
@@ -39,14 +47,19 @@ function DiscussionPanel( { isEnabled, isOpened, onTogglePanel } ) {
export default compose( [
withSelect( ( select ) => {
return {
- isEnabled: select( 'core/edit-post' ).isEditorPanelEnabled( PANEL_NAME ),
- isOpened: select( 'core/edit-post' ).isEditorPanelOpened( PANEL_NAME ),
+ isEnabled: select( 'core/edit-post' ).isEditorPanelEnabled(
+ PANEL_NAME
+ ),
+ isOpened: select( 'core/edit-post' ).isEditorPanelOpened(
+ PANEL_NAME
+ ),
};
} ),
withDispatch( ( dispatch ) => ( {
onTogglePanel() {
- return dispatch( 'core/edit-post' ).toggleEditorPanelOpened( PANEL_NAME );
+ return dispatch( 'core/edit-post' ).toggleEditorPanelOpened(
+ PANEL_NAME
+ );
},
} ) ),
] )( DiscussionPanel );
-
diff --git a/packages/edit-post/src/components/sidebar/featured-image/index.js b/packages/edit-post/src/components/sidebar/featured-image/index.js
index e6ff45262c161..63a95fb76178b 100644
--- a/packages/edit-post/src/components/sidebar/featured-image/index.js
+++ b/packages/edit-post/src/components/sidebar/featured-image/index.js
@@ -42,7 +42,9 @@ function FeaturedImage( { isEnabled, isOpened, postType, onTogglePanel } ) {
const applyWithSelect = withSelect( ( select ) => {
const { getEditedPostAttribute } = select( 'core/editor' );
const { getPostType } = select( 'core' );
- const { isEditorPanelEnabled, isEditorPanelOpened } = select( 'core/edit-post' );
+ const { isEditorPanelEnabled, isEditorPanelOpened } = select(
+ 'core/edit-post'
+ );
return {
postType: getPostType( getEditedPostAttribute( 'type' ) ),
@@ -59,7 +61,4 @@ const applyWithDispatch = withDispatch( ( dispatch ) => {
};
} );
-export default compose(
- applyWithSelect,
- applyWithDispatch,
-)( FeaturedImage );
+export default compose( applyWithSelect, applyWithDispatch )( FeaturedImage );
diff --git a/packages/edit-post/src/components/sidebar/index.js b/packages/edit-post/src/components/sidebar/index.js
index 790ce933fa972..e6175b72b2685 100644
--- a/packages/edit-post/src/components/sidebar/index.js
+++ b/packages/edit-post/src/components/sidebar/index.js
@@ -6,7 +6,11 @@ import classnames from 'classnames';
/**
* WordPress dependencies
*/
-import { createSlotFill, withFocusReturn, Animate } from '@wordpress/components';
+import {
+ createSlotFill,
+ withFocusReturn,
+ Animate,
+} from '@wordpress/components';
import { withSelect } from '@wordpress/data';
import { ifCondition, compose } from '@wordpress/compose';
@@ -27,7 +31,9 @@ function Sidebar( { children, className } ) {
Sidebar = withFocusReturn( {
onFocusReturn() {
- const button = document.querySelector( '.edit-post-header__settings [aria-label="Settings"]' );
+ const button = document.querySelector(
+ '.edit-post-header__settings [aria-label="Settings"]'
+ );
if ( button ) {
button.focus();
return false;
@@ -47,9 +53,10 @@ function AnimatedSidebarFill( props ) {
const WrappedSidebar = compose(
withSelect( ( select, { name } ) => ( {
- isActive: select( 'core/edit-post' ).getActiveGeneralSidebarName() === name,
+ isActive:
+ select( 'core/edit-post' ).getActiveGeneralSidebarName() === name,
} ) ),
- ifCondition( ( { isActive } ) => isActive ),
+ ifCondition( ( { isActive } ) => isActive )
)( AnimatedSidebarFill );
WrappedSidebar.Slot = Slot;
diff --git a/packages/edit-post/src/components/sidebar/page-attributes/index.js b/packages/edit-post/src/components/sidebar/page-attributes/index.js
index 5095edf98b34b..97e7199ef4187 100644
--- a/packages/edit-post/src/components/sidebar/page-attributes/index.js
+++ b/packages/edit-post/src/components/sidebar/page-attributes/index.js
@@ -9,7 +9,12 @@ import { get, partial } from 'lodash';
import { __ } from '@wordpress/i18n';
import { PanelBody, PanelRow } from '@wordpress/components';
import { compose } from '@wordpress/compose';
-import { PageAttributesCheck, PageAttributesOrder, PageAttributesParent, PageTemplate } from '@wordpress/editor';
+import {
+ PageAttributesCheck,
+ PageAttributesOrder,
+ PageAttributesParent,
+ PageTemplate,
+} from '@wordpress/editor';
import { withSelect, withDispatch } from '@wordpress/data';
/**
@@ -17,14 +22,23 @@ import { withSelect, withDispatch } from '@wordpress/data';
*/
const PANEL_NAME = 'page-attributes';
-export function PageAttributes( { isEnabled, isOpened, onTogglePanel, postType } ) {
+export function PageAttributes( {
+ isEnabled,
+ isOpened,
+ onTogglePanel,
+ postType,
+} ) {
if ( ! isEnabled || ! postType ) {
return null;
}
return (
@@ -40,7 +54,9 @@ export function PageAttributes( { isEnabled, isOpened, onTogglePanel, postType }
const applyWithSelect = withSelect( ( select ) => {
const { getEditedPostAttribute } = select( 'core/editor' );
- const { isEditorPanelEnabled, isEditorPanelOpened } = select( 'core/edit-post' );
+ const { isEditorPanelEnabled, isEditorPanelOpened } = select(
+ 'core/edit-post'
+ );
const { getPostType } = select( 'core' );
return {
isEnabled: isEditorPanelEnabled( PANEL_NAME ),
@@ -57,7 +73,4 @@ const applyWithDispatch = withDispatch( ( dispatch ) => {
};
} );
-export default compose(
- applyWithSelect,
- applyWithDispatch,
-)( PageAttributes );
+export default compose( applyWithSelect, applyWithDispatch )( PageAttributes );
diff --git a/packages/edit-post/src/components/sidebar/plugin-document-setting-panel/index.js b/packages/edit-post/src/components/sidebar/plugin-document-setting-panel/index.js
index 62a651c7f0c24..757e4965e5d99 100644
--- a/packages/edit-post/src/components/sidebar/plugin-document-setting-panel/index.js
+++ b/packages/edit-post/src/components/sidebar/plugin-document-setting-panel/index.js
@@ -17,7 +17,16 @@ import { EnablePluginDocumentSettingPanelOption } from '../../options-modal/opti
export const { Fill, Slot } = createSlotFill( 'PluginDocumentSettingPanel' );
-const PluginDocumentSettingFill = ( { isEnabled, panelName, opened, onToggle, className, title, icon, children } ) => {
+const PluginDocumentSettingFill = ( {
+ isEnabled,
+ panelName,
+ opened,
+ onToggle,
+ className,
+ title,
+ icon,
+ children,
+} ) => {
return (
<>
{
- return (
- {
- opened: select( 'core/edit-post' ).isEditorPanelOpened( panelName ),
- isEnabled: select( 'core/edit-post' ).isEditorPanelEnabled( panelName ),
- }
- );
+ return {
+ opened: select( 'core/edit-post' ).isEditorPanelOpened( panelName ),
+ isEnabled: select( 'core/edit-post' ).isEditorPanelEnabled(
+ panelName
+ ),
+ };
} ),
withDispatch( ( dispatch, { panelName } ) => ( {
onToggle() {
- return dispatch( 'core/edit-post' ).toggleEditorPanelOpened( panelName );
+ return dispatch( 'core/edit-post' ).toggleEditorPanelOpened(
+ panelName
+ );
},
- } ) ),
+ } ) )
)( PluginDocumentSettingFill );
PluginDocumentSettingPanel.Slot = Slot;
diff --git a/packages/edit-post/src/components/sidebar/plugin-post-publish-panel/index.js b/packages/edit-post/src/components/sidebar/plugin-post-publish-panel/index.js
index b1c5337285702..43d1fc2d1eaac 100644
--- a/packages/edit-post/src/components/sidebar/plugin-post-publish-panel/index.js
+++ b/packages/edit-post/src/components/sidebar/plugin-post-publish-panel/index.js
@@ -7,7 +7,13 @@ import { createSlotFill, PanelBody } from '@wordpress/components';
const { Fill, Slot } = createSlotFill( 'PluginPostPublishPanel' );
-const PluginPostPublishPanelFill = ( { children, className, title, initialOpen = false, icon } ) => (
+const PluginPostPublishPanelFill = ( {
+ children,
+ className,
+ title,
+ initialOpen = false,
+ icon,
+} ) => (
My panel title My panel content "`;
+exports[`PluginPostPublishPanel renders fill properly 1`] = `"
My panel titleMy panel content
"`;
diff --git a/packages/edit-post/src/components/sidebar/plugin-post-publish-panel/test/index.js b/packages/edit-post/src/components/sidebar/plugin-post-publish-panel/test/index.js
index f4b5ca77eca16..d140251917559 100644
--- a/packages/edit-post/src/components/sidebar/plugin-post-publish-panel/test/index.js
+++ b/packages/edit-post/src/components/sidebar/plugin-post-publish-panel/test/index.js
@@ -19,7 +19,7 @@ describe( 'PluginPostPublishPanel', () => {
title="My panel title"
initialOpen={ true }
>
- My panel content
+ My panel content
,
diff --git a/packages/edit-post/src/components/sidebar/plugin-post-status-info/index.js b/packages/edit-post/src/components/sidebar/plugin-post-status-info/index.js
index efff9ba774d9e..10259358e764f 100644
--- a/packages/edit-post/src/components/sidebar/plugin-post-status-info/index.js
+++ b/packages/edit-post/src/components/sidebar/plugin-post-status-info/index.js
@@ -53,9 +53,7 @@ export const { Fill, Slot } = createSlotFill( 'PluginPostStatusInfo' );
*/
const PluginPostStatusInfo = ( { children, className } ) => (
-
- { children }
-
+ { children }
);
diff --git a/packages/edit-post/src/components/sidebar/plugin-post-status-info/test/index.js b/packages/edit-post/src/components/sidebar/plugin-post-status-info/test/index.js
index ea7b173a42028..033f9fad709bf 100644
--- a/packages/edit-post/src/components/sidebar/plugin-post-status-info/test/index.js
+++ b/packages/edit-post/src/components/sidebar/plugin-post-status-info/test/index.js
@@ -17,9 +17,7 @@ describe( 'PluginPostStatusInfo', () => {
test( 'renders fill properly', () => {
const tree = ReactTestRenderer.create(
-
+
My plugin post status info
diff --git a/packages/edit-post/src/components/sidebar/plugin-pre-publish-panel/index.js b/packages/edit-post/src/components/sidebar/plugin-pre-publish-panel/index.js
index 13863b24f16d5..db6900995db37 100644
--- a/packages/edit-post/src/components/sidebar/plugin-pre-publish-panel/index.js
+++ b/packages/edit-post/src/components/sidebar/plugin-pre-publish-panel/index.js
@@ -6,7 +6,13 @@ import { compose } from '@wordpress/compose';
import { withPluginContext } from '@wordpress/plugins';
const { Fill, Slot } = createSlotFill( 'PluginPrePublishPanel' );
-const PluginPrePublishPanelFill = ( { children, className, title, initialOpen = false, icon } ) => (
+const PluginPrePublishPanelFill = ( {
+ children,
+ className,
+ title,
+ initialOpen = false,
+ icon,
+} ) => (
My panel title My panel content "`;
+exports[`PluginPrePublishPanel renders fill properly 1`] = `" My panel titleMy panel content
"`;
diff --git a/packages/edit-post/src/components/sidebar/plugin-sidebar/index.js b/packages/edit-post/src/components/sidebar/plugin-sidebar/index.js
index e0977effb87a9..179463f8aeeac 100644
--- a/packages/edit-post/src/components/sidebar/plugin-sidebar/index.js
+++ b/packages/edit-post/src/components/sidebar/plugin-sidebar/index.js
@@ -32,33 +32,35 @@ function PluginSidebar( props ) {
<>
{ isPinnable && (
- { isPinned && }
+ { isPinned && (
+
+ ) }
) }
-
+
{ title }
{ isPinnable && (
) }
-
- { children }
-
+ { children }
>
);
@@ -136,10 +138,9 @@ export default compose(
};
} ),
withSelect( ( select, { sidebarName } ) => {
- const {
- getActiveGeneralSidebarName,
- isPluginItemPinned,
- } = select( 'core/edit-post' );
+ const { getActiveGeneralSidebarName, isPluginItemPinned } = select(
+ 'core/edit-post'
+ );
return {
isActive: getActiveGeneralSidebarName() === sidebarName,
@@ -165,5 +166,5 @@ export default compose(
}
},
};
- } ),
+ } )
)( PluginSidebar );
diff --git a/packages/edit-post/src/components/sidebar/post-author/index.js b/packages/edit-post/src/components/sidebar/post-author/index.js
index 3a876320d70ad..5febcfc14b5a2 100644
--- a/packages/edit-post/src/components/sidebar/post-author/index.js
+++ b/packages/edit-post/src/components/sidebar/post-author/index.js
@@ -2,7 +2,10 @@
* WordPress dependencies
*/
import { PanelRow } from '@wordpress/components';
-import { PostAuthor as PostAuthorForm, PostAuthorCheck } from '@wordpress/editor';
+import {
+ PostAuthor as PostAuthorForm,
+ PostAuthorCheck,
+} from '@wordpress/editor';
export function PostAuthor() {
return (
diff --git a/packages/edit-post/src/components/sidebar/post-excerpt/index.js b/packages/edit-post/src/components/sidebar/post-excerpt/index.js
index 5b9a96cd174d2..1502bc7e7a3de 100644
--- a/packages/edit-post/src/components/sidebar/post-excerpt/index.js
+++ b/packages/edit-post/src/components/sidebar/post-excerpt/index.js
@@ -3,7 +3,10 @@
*/
import { __ } from '@wordpress/i18n';
import { PanelBody } from '@wordpress/components';
-import { PostExcerpt as PostExcerptForm, PostExcerptCheck } from '@wordpress/editor';
+import {
+ PostExcerpt as PostExcerptForm,
+ PostExcerptCheck,
+} from '@wordpress/editor';
import { compose } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data';
@@ -19,7 +22,11 @@ function PostExcerpt( { isEnabled, isOpened, onTogglePanel } ) {
return (
-
+
@@ -29,14 +36,19 @@ function PostExcerpt( { isEnabled, isOpened, onTogglePanel } ) {
export default compose( [
withSelect( ( select ) => {
return {
- isEnabled: select( 'core/edit-post' ).isEditorPanelEnabled( PANEL_NAME ),
- isOpened: select( 'core/edit-post' ).isEditorPanelOpened( PANEL_NAME ),
+ isEnabled: select( 'core/edit-post' ).isEditorPanelEnabled(
+ PANEL_NAME
+ ),
+ isOpened: select( 'core/edit-post' ).isEditorPanelOpened(
+ PANEL_NAME
+ ),
};
} ),
withDispatch( ( dispatch ) => ( {
onTogglePanel() {
- return dispatch( 'core/edit-post' ).toggleEditorPanelOpened( PANEL_NAME );
+ return dispatch( 'core/edit-post' ).toggleEditorPanelOpened(
+ PANEL_NAME
+ );
},
} ) ),
] )( PostExcerpt );
-
diff --git a/packages/edit-post/src/components/sidebar/post-format/index.js b/packages/edit-post/src/components/sidebar/post-format/index.js
index c70dbf70017fa..67f8f690f7403 100644
--- a/packages/edit-post/src/components/sidebar/post-format/index.js
+++ b/packages/edit-post/src/components/sidebar/post-format/index.js
@@ -2,7 +2,10 @@
* WordPress dependencies
*/
import { PanelRow } from '@wordpress/components';
-import { PostFormat as PostFormatForm, PostFormatCheck } from '@wordpress/editor';
+import {
+ PostFormat as PostFormatForm,
+ PostFormatCheck,
+} from '@wordpress/editor';
export function PostFormat() {
return (
diff --git a/packages/edit-post/src/components/sidebar/post-link/index.js b/packages/edit-post/src/components/sidebar/post-link/index.js
index 4fdeb99224138..b1f295a62080c 100644
--- a/packages/edit-post/src/components/sidebar/post-link/index.js
+++ b/packages/edit-post/src/components/sidebar/post-link/index.js
@@ -34,13 +34,18 @@ function PostLink( {
} ) {
const { prefix, suffix } = permalinkParts;
let prefixElement, postNameElement, suffixElement;
- const currentSlug = safeDecodeURIComponent( postSlug ) || cleanForSlug( postTitle ) || postID;
+ const currentSlug =
+ safeDecodeURIComponent( postSlug ) ||
+ cleanForSlug( postTitle ) ||
+ postID;
if ( isEditable ) {
prefixElement = prefix && (
{ prefix }
);
postNameElement = currentSlug && (
- { currentSlug }
+
+ { currentSlug }
+
);
suffixElement = suffix && (
{ suffix }
@@ -88,8 +93,7 @@ function PostLink( {
} }
/>
- { __( 'The last part of the URL.' ) }
- { ' ' }
+ { __( 'The last part of the URL.' ) }{ ' ' }
{ __( 'Read about permalinks' ) }
@@ -105,12 +109,15 @@ function PostLink( {
href={ postLink }
target="_blank"
>
- { isEditable ?
- ( <>
- { prefixElement }{ postNameElement }{ suffixElement }
- > ) :
+ { isEditable ? (
+ <>
+ { prefixElement }
+ { postNameElement }
+ { suffixElement }
+ >
+ ) : (
postLink
- }
+ ) }
@@ -127,13 +134,10 @@ export default compose( [
getPermalinkParts,
getEditedPostAttribute,
} = select( 'core/editor' );
- const {
- isEditorPanelEnabled,
- isEditorPanelOpened,
- } = select( 'core/edit-post' );
- const {
- getPostType,
- } = select( 'core' );
+ const { isEditorPanelEnabled, isEditorPanelOpened } = select(
+ 'core/edit-post'
+ );
+ const { getPostType } = select( 'core' );
const { link, id } = getCurrentPost();
@@ -155,9 +159,13 @@ export default compose( [
postTypeLabel: get( postType, [ 'labels', 'view_item' ] ),
};
} ),
- ifCondition( ( { isEnabled, isNew, postLink, isViewable, permalinkParts } ) => {
- return isEnabled && ! isNew && postLink && isViewable && permalinkParts;
- } ),
+ ifCondition(
+ ( { isEnabled, isNew, postLink, isViewable, permalinkParts } ) => {
+ return (
+ isEnabled && ! isNew && postLink && isViewable && permalinkParts
+ );
+ }
+ ),
withDispatch( ( dispatch ) => {
const { toggleEditorPanelOpened } = dispatch( 'core/edit-post' );
const { editPost } = dispatch( 'core/editor' );
diff --git a/packages/edit-post/src/components/sidebar/post-pending-status/index.js b/packages/edit-post/src/components/sidebar/post-pending-status/index.js
index f961c0880b91c..739aff6034b50 100644
--- a/packages/edit-post/src/components/sidebar/post-pending-status/index.js
+++ b/packages/edit-post/src/components/sidebar/post-pending-status/index.js
@@ -2,7 +2,10 @@
* WordPress dependencies
*/
import { PanelRow } from '@wordpress/components';
-import { PostPendingStatus as PostPendingStatusForm, PostPendingStatusCheck } from '@wordpress/editor';
+import {
+ PostPendingStatus as PostPendingStatusForm,
+ PostPendingStatusCheck,
+} from '@wordpress/editor';
export function PostPendingStatus() {
return (
diff --git a/packages/edit-post/src/components/sidebar/post-schedule/index.js b/packages/edit-post/src/components/sidebar/post-schedule/index.js
index e483e741490d8..ab5fb2ba668d0 100644
--- a/packages/edit-post/src/components/sidebar/post-schedule/index.js
+++ b/packages/edit-post/src/components/sidebar/post-schedule/index.js
@@ -3,15 +3,17 @@
*/
import { __ } from '@wordpress/i18n';
import { PanelRow, Dropdown, Button } from '@wordpress/components';
-import { PostSchedule as PostScheduleForm, PostScheduleLabel, PostScheduleCheck } from '@wordpress/editor';
+import {
+ PostSchedule as PostScheduleForm,
+ PostScheduleLabel,
+ PostScheduleCheck,
+} from '@wordpress/editor';
export function PostSchedule() {
return (
-
- { __( 'Publish' ) }
-
+ { __( 'Publish' ) }
+
{ ( fills ) => (
<>
@@ -50,7 +55,9 @@ export default compose( [
withSelect( ( select ) => {
// We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do
// not use isEditorPanelEnabled since this panel should not be disabled through the UI.
- const { isEditorPanelRemoved, isEditorPanelOpened } = select( 'core/edit-post' );
+ const { isEditorPanelRemoved, isEditorPanelOpened } = select(
+ 'core/edit-post'
+ );
return {
isRemoved: isEditorPanelRemoved( PANEL_NAME ),
isOpened: isEditorPanelOpened( PANEL_NAME ),
@@ -59,8 +66,9 @@ export default compose( [
ifCondition( ( { isRemoved } ) => ! isRemoved ),
withDispatch( ( dispatch ) => ( {
onTogglePanel() {
- return dispatch( 'core/edit-post' ).toggleEditorPanelOpened( PANEL_NAME );
+ return dispatch( 'core/edit-post' ).toggleEditorPanelOpened(
+ PANEL_NAME
+ );
},
} ) ),
] )( PostStatus );
-
diff --git a/packages/edit-post/src/components/sidebar/post-sticky/index.js b/packages/edit-post/src/components/sidebar/post-sticky/index.js
index a8dc776b7b0c1..971428fcd2318 100644
--- a/packages/edit-post/src/components/sidebar/post-sticky/index.js
+++ b/packages/edit-post/src/components/sidebar/post-sticky/index.js
@@ -2,7 +2,10 @@
* WordPress dependencies
*/
import { PanelRow } from '@wordpress/components';
-import { PostSticky as PostStickyForm, PostStickyCheck } from '@wordpress/editor';
+import {
+ PostSticky as PostStickyForm,
+ PostStickyCheck,
+} from '@wordpress/editor';
export function PostSticky() {
return (
diff --git a/packages/edit-post/src/components/sidebar/post-taxonomies/index.js b/packages/edit-post/src/components/sidebar/post-taxonomies/index.js
index be04dbcf6b6f9..d44815ee98b71 100644
--- a/packages/edit-post/src/components/sidebar/post-taxonomies/index.js
+++ b/packages/edit-post/src/components/sidebar/post-taxonomies/index.js
@@ -1,7 +1,10 @@
/**
* WordPress dependencies
*/
-import { PostTaxonomies as PostTaxonomiesForm, PostTaxonomiesCheck } from '@wordpress/editor';
+import {
+ PostTaxonomies as PostTaxonomiesForm,
+ PostTaxonomiesCheck,
+} from '@wordpress/editor';
/**
* Internal dependencies
diff --git a/packages/edit-post/src/components/sidebar/post-taxonomies/taxonomy-panel.js b/packages/edit-post/src/components/sidebar/post-taxonomies/taxonomy-panel.js
index 5c85446e0ac14..59febc55554a3 100644
--- a/packages/edit-post/src/components/sidebar/post-taxonomies/taxonomy-panel.js
+++ b/packages/edit-post/src/components/sidebar/post-taxonomies/taxonomy-panel.js
@@ -10,7 +10,13 @@ import { compose } from '@wordpress/compose';
import { PanelBody } from '@wordpress/components';
import { withSelect, withDispatch } from '@wordpress/data';
-function TaxonomyPanel( { isEnabled, taxonomy, isOpened, onTogglePanel, children } ) {
+function TaxonomyPanel( {
+ isEnabled,
+ taxonomy,
+ isOpened,
+ onTogglePanel,
+ children,
+} ) {
if ( ! isEnabled ) {
return null;
}
@@ -37,17 +43,19 @@ export default compose(
const panelName = slug ? `taxonomy-panel-${ slug }` : '';
return {
panelName,
- isEnabled: slug ?
- select( 'core/edit-post' ).isEditorPanelEnabled( panelName ) :
- false,
- isOpened: slug ?
- select( 'core/edit-post' ).isEditorPanelOpened( panelName ) :
- false,
+ isEnabled: slug
+ ? select( 'core/edit-post' ).isEditorPanelEnabled( panelName )
+ : false,
+ isOpened: slug
+ ? select( 'core/edit-post' ).isEditorPanelOpened( panelName )
+ : false,
};
} ),
withDispatch( ( dispatch, ownProps ) => ( {
onTogglePanel: () => {
- dispatch( 'core/edit-post' ).toggleEditorPanelOpened( ownProps.panelName );
+ dispatch( 'core/edit-post' ).toggleEditorPanelOpened(
+ ownProps.panelName
+ );
},
- } ) ),
+ } ) )
)( TaxonomyPanel );
diff --git a/packages/edit-post/src/components/sidebar/post-visibility/index.js b/packages/edit-post/src/components/sidebar/post-visibility/index.js
index 5bc1e4c563e66..3840c77b1c335 100644
--- a/packages/edit-post/src/components/sidebar/post-visibility/index.js
+++ b/packages/edit-post/src/components/sidebar/post-visibility/index.js
@@ -3,33 +3,43 @@
*/
import { __ } from '@wordpress/i18n';
import { PanelRow, Dropdown, Button } from '@wordpress/components';
-import { PostVisibility as PostVisibilityForm, PostVisibilityLabel, PostVisibilityCheck } from '@wordpress/editor';
+import {
+ PostVisibility as PostVisibilityForm,
+ PostVisibilityLabel,
+ PostVisibilityCheck,
+} from '@wordpress/editor';
export function PostVisibility() {
return (
- (
-
- { __( 'Visibility' ) }
- { ! canEdit && }
- { canEdit && (
- (
-
-
-
- ) }
- renderContent={ () => }
- />
- ) }
-
- ) } />
+ (
+
+ { __( 'Visibility' ) }
+ { ! canEdit && (
+
+
+
+ ) }
+ { canEdit && (
+ (
+
+
+
+ ) }
+ renderContent={ () => }
+ />
+ ) }
+
+ ) }
+ />
);
}
diff --git a/packages/edit-post/src/components/sidebar/settings-header/index.js b/packages/edit-post/src/components/sidebar/settings-header/index.js
index 4bb0ddc0c2235..4f2a2d4ebe9ff 100644
--- a/packages/edit-post/src/components/sidebar/settings-header/index.js
+++ b/packages/edit-post/src/components/sidebar/settings-header/index.js
@@ -10,19 +10,25 @@ import { withDispatch } from '@wordpress/data';
*/
import SidebarHeader from '../sidebar-header';
-const SettingsHeader = ( { openDocumentSettings, openBlockSettings, sidebarName } ) => {
+const SettingsHeader = ( {
+ openDocumentSettings,
+ openBlockSettings,
+ sidebarName,
+} ) => {
const blockLabel = __( 'Block' );
- const [ documentAriaLabel, documentActiveClass ] = sidebarName === 'edit-post/document' ?
- // translators: ARIA label for the Document sidebar tab, selected.
- [ __( 'Document (selected)' ), 'is-active' ] :
- // translators: ARIA label for the Document sidebar tab, not selected.
- [ __( 'Document' ), '' ];
+ const [ documentAriaLabel, documentActiveClass ] =
+ sidebarName === 'edit-post/document'
+ ? // translators: ARIA label for the Document sidebar tab, selected.
+ [ __( 'Document (selected)' ), 'is-active' ]
+ : // translators: ARIA label for the Document sidebar tab, not selected.
+ [ __( 'Document' ), '' ];
- const [ blockAriaLabel, blockActiveClass ] = sidebarName === 'edit-post/block' ?
- // translators: ARIA label for the Settings Sidebar tab, selected.
- [ __( 'Block (selected)' ), 'is-active' ] :
- // translators: ARIA label for the Settings Sidebar tab, not selected.
- [ __( 'Block' ), '' ];
+ const [ blockAriaLabel, blockActiveClass ] =
+ sidebarName === 'edit-post/block'
+ ? // translators: ARIA label for the Settings Sidebar tab, selected.
+ [ __( 'Block (selected)' ), 'is-active' ]
+ : // translators: ARIA label for the Settings Sidebar tab, not selected.
+ [ __( 'Block' ), '' ];
return (
(
>
) }
- { sidebarName === 'edit-post/block' && (
-
- ) }
+ { sidebarName === 'edit-post/block' && }
);
export default compose(
withSelect( ( select ) => {
- const {
- getActiveGeneralSidebarName,
- isEditorSidebarOpened,
- } = select( 'core/edit-post' );
+ const { getActiveGeneralSidebarName, isEditorSidebarOpened } = select(
+ 'core/edit-post'
+ );
return {
isEditorSidebarOpened: isEditorSidebarOpened(),
sidebarName: getActiveGeneralSidebarName(),
};
} ),
- ifCondition( ( { isEditorSidebarOpened } ) => isEditorSidebarOpened ),
+ ifCondition( ( { isEditorSidebarOpened } ) => isEditorSidebarOpened )
)( SettingsSidebar );
diff --git a/packages/edit-post/src/components/sidebar/sidebar-header/index.js b/packages/edit-post/src/components/sidebar/sidebar-header/index.js
index 9592341c0326f..e0133401a58e8 100644
--- a/packages/edit-post/src/components/sidebar/sidebar-header/index.js
+++ b/packages/edit-post/src/components/sidebar/sidebar-header/index.js
@@ -11,10 +11,15 @@ import { Button } from '@wordpress/components';
import { useDispatch, useSelect } from '@wordpress/data';
const SidebarHeader = ( { children, className, closeLabel } ) => {
- const { shortcut, title } = useSelect( ( select ) => ( {
- shortcut: select( 'core/keyboard-shortcuts' ).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' ),
- title: select( 'core/editor' ).getEditedPostAttribute( 'title' ),
- } ), [] );
+ const { shortcut, title } = useSelect(
+ ( select ) => ( {
+ shortcut: select(
+ 'core/keyboard-shortcuts'
+ ).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' ),
+ title: select( 'core/editor' ).getEditedPostAttribute( 'title' ),
+ } ),
+ []
+ );
const { closeGeneralSidebar } = useDispatch( 'core/edit-post' );
return (
@@ -29,7 +34,12 @@ const SidebarHeader = ( { children, className, closeLabel } ) => {
label={ closeLabel }
/>
-
+
{ children }
- ) }
+ ) }
@@ -38,7 +38,8 @@ function TextEditor( { onExit, isRichEditingEnabled } ) {
export default compose(
withSelect( ( select ) => ( {
- isRichEditingEnabled: select( 'core/editor' ).getEditorSettings().richEditingEnabled,
+ isRichEditingEnabled: select( 'core/editor' ).getEditorSettings()
+ .richEditingEnabled,
} ) ),
withDispatch( ( dispatch ) => {
return {
diff --git a/packages/edit-post/src/components/visual-editor/block-inspector-button.js b/packages/edit-post/src/components/visual-editor/block-inspector-button.js
index 524aa99c6bc8f..977e3f55d2de9 100644
--- a/packages/edit-post/src/components/visual-editor/block-inspector-button.js
+++ b/packages/edit-post/src/components/visual-editor/block-inspector-button.js
@@ -15,25 +15,39 @@ export function BlockInspectorButton( {
small = false,
speak,
} ) {
- const { shortcut, areAdvancedSettingsOpened } = useSelect( ( select ) => ( {
- shortcut: select( 'core/keyboard-shortcuts' ).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' ),
- areAdvancedSettingsOpened: select( 'core/edit-post' ).getActiveGeneralSidebarName() === 'edit-post/block',
- } ), [] );
- const { openGeneralSidebar, closeGeneralSidebar } = useDispatch( 'core/edit-post' );
+ const { shortcut, areAdvancedSettingsOpened } = useSelect(
+ ( select ) => ( {
+ shortcut: select(
+ 'core/keyboard-shortcuts'
+ ).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' ),
+ areAdvancedSettingsOpened:
+ select( 'core/edit-post' ).getActiveGeneralSidebarName() ===
+ 'edit-post/block',
+ } ),
+ []
+ );
+ const { openGeneralSidebar, closeGeneralSidebar } = useDispatch(
+ 'core/edit-post'
+ );
const speakMessage = () => {
if ( areAdvancedSettingsOpened ) {
speak( __( 'Block settings closed' ) );
} else {
- speak( __( 'Additional settings are now available in the Editor block settings sidebar' ) );
+ speak(
+ __(
+ 'Additional settings are now available in the Editor block settings sidebar'
+ )
+ );
}
};
- const label = areAdvancedSettingsOpened ? __( 'Hide Block Settings' ) : __( 'Show Block Settings' );
+ const label = areAdvancedSettingsOpened
+ ? __( 'Hide Block Settings' )
+ : __( 'Show Block Settings' );
return (
{
if ( areAdvancedSettingsOpened ) {
closeGeneralSidebar();
diff --git a/packages/edit-post/src/components/visual-editor/index.js b/packages/edit-post/src/components/visual-editor/index.js
index 37d3749f0f498..94ae067d7296e 100644
--- a/packages/edit-post/src/components/visual-editor/index.js
+++ b/packages/edit-post/src/components/visual-editor/index.js
@@ -16,6 +16,7 @@ import {
__experimentalBlockSettingsMenuFirstItem,
__experimentalBlockSettingsMenuPluginsExtension,
} from '@wordpress/block-editor';
+import { Popover } from '@wordpress/components';
/**
* Internal dependencies
@@ -28,21 +29,30 @@ function VisualEditor() {
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
<__experimentalBlockSettingsMenuFirstItem>
- { ( { onClose } ) => }
+ { ( { onClose } ) => (
+
+ ) }
<__experimentalBlockSettingsMenuPluginsExtension>
- { ( { clientIds, onClose } ) => }
+ { ( { clientIds, onClose } ) => (
+
+ ) }
);
diff --git a/packages/edit-post/src/components/visual-editor/index.native.js b/packages/edit-post/src/components/visual-editor/index.native.js
index 44d7c2902cef4..ed52ef5e6eef1 100644
--- a/packages/edit-post/src/components/visual-editor/index.native.js
+++ b/packages/edit-post/src/components/visual-editor/index.native.js
@@ -22,7 +22,10 @@ class VisualEditor extends Component {
title,
getStylesFromColorScheme,
} = this.props;
- const blockHolderFocusedStyle = getStylesFromColorScheme( styles.blockHolderFocused, styles.blockHolderFocusedDark );
+ const blockHolderFocusedStyle = getStylesFromColorScheme(
+ styles.blockHolderFocused,
+ styles.blockHolderFocusedDark
+ );
return (
{
- const {
- getEditedPostAttribute,
- } = select( 'core/editor' );
+ const { getEditedPostAttribute } = select( 'core/editor' );
return {
title: getEditedPostAttribute( 'title' ),
};
} ),
withDispatch( ( dispatch ) => {
- const {
- editPost,
- } = dispatch( 'core/editor' );
+ const { editPost } = dispatch( 'core/editor' );
const { clearSelectedBlock } = dispatch( 'core/block-editor' );
diff --git a/packages/edit-post/src/components/visual-editor/style.scss b/packages/edit-post/src/components/visual-editor/style.scss
index 20a56f91d988e..7dd1f86dab879 100644
--- a/packages/edit-post/src/components/visual-editor/style.scss
+++ b/packages/edit-post/src/components/visual-editor/style.scss
@@ -17,8 +17,9 @@
}
.edit-post-visual-editor > .block-editor__typewriter,
-.edit-post-visual-editor > .block-editor__typewriter > .block-editor-writing-flow,
-.edit-post-visual-editor > .block-editor__typewriter > .block-editor-writing-flow > .block-editor-writing-flow__click-redirect {
+.edit-post-visual-editor > .block-editor__typewriter > div,
+.edit-post-visual-editor > .block-editor__typewriter > div > .block-editor-writing-flow,
+.edit-post-visual-editor > .block-editor__typewriter > div > .block-editor-writing-flow > .block-editor-writing-flow__click-redirect {
height: 100%;
}
@@ -37,36 +38,6 @@
.edit-post-visual-editor .block-editor-block-list__block {
margin-left: auto;
margin-right: auto;
-
- @include break-small() {
- // Center the block toolbar on wide and full-wide blocks.
- // Use specific selector to not affect nested block toolbars.
- &[data-align="wide"] > .block-editor-block-list__block-edit > .block-editor-block-contextual-toolbar,
- &[data-align="full"] > .block-editor-block-list__block-edit > .block-editor-block-contextual-toolbar {
- height: 0; // This collapses the container to an invisible element without margin.
- width: calc(100% - #{$block-side-ui-width * 3} - #{$grid-size-small * 1.5}); // -90px to account for inner element left position value causing overflow-x scrollbars
- margin-left: 0;
- margin-right: 0;
- text-align: center;
- // This float rule takes the toolbar out of the flow, without it having to be absolute positioned.
- // This is necessary because otherwise the mere presence of the toolbar can push down content.
- // Pairs with relative rule on line 49.
- float: left;
-
- @include break-xlarge() {
- width: calc(100% - #{$block-padding * 2} + #{$border-width * 2}); // On the largest screens, line the toolbar up with standard-aligned block controls.
- }
-
- .block-editor-block-toolbar {
- max-width: $content-width;
- width: 100%;
-
- // Necessary for the toolbar to be centered.
- // This unsets an absolute position that will otherwise left align the toolbar.
- position: relative;
- }
- }
- }
}
diff --git a/packages/edit-post/src/components/welcome-guide/index.js b/packages/edit-post/src/components/welcome-guide/index.js
index bdc65c7303659..b71b99638d41c 100644
--- a/packages/edit-post/src/components/welcome-guide/index.js
+++ b/packages/edit-post/src/components/welcome-guide/index.js
@@ -9,10 +9,20 @@ import { __experimentalCreateInterpolateElement } from '@wordpress/element';
/**
* Internal dependencies
*/
-import { CanvasImage, EditorImage, BlockLibraryImage, DocumentationImage, InserterIconImage } from './images';
+import {
+ CanvasImage,
+ EditorImage,
+ BlockLibraryImage,
+ DocumentationImage,
+ InserterIconImage,
+} from './images';
export default function WelcomeGuide() {
- const isActive = useSelect( ( select ) => select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ), [] );
+ const isActive = useSelect(
+ ( select ) =>
+ select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ),
+ []
+ );
const { toggleFeature } = useDispatch( 'core/edit-post' );
@@ -27,14 +37,15 @@ export default function WelcomeGuide() {
finishButtonText={ __( 'Get started' ) }
onFinish={ () => toggleFeature( 'welcomeGuide' ) }
>
-
{ __( 'Welcome to the Block Editor' ) }
- { __( 'In the WordPress editor, each paragraph, image, or video is presented as a distinct โblockโ of content.' ) }
+ { __(
+ 'In the WordPress editor, each paragraph, image, or video is presented as a distinct โblockโ of content.'
+ ) }
@@ -44,7 +55,9 @@ export default function WelcomeGuide() {
- { __( 'Each block comes with its own set of controls for changing things like color, width, and alignment. These will show and hide automatically when you have a block selected.' ) }
+ { __(
+ 'Each block comes with its own set of controls for changing things like color, width, and alignment. These will show and hide automatically when you have a block selected.'
+ ) }
@@ -55,12 +68,12 @@ export default function WelcomeGuide() {
{ __experimentalCreateInterpolateElement(
- __( 'All of the blocks available to you live in the Block Library. Youโll find it wherever you see the icon.' ),
+ __(
+ 'All of the blocks available to you live in the Block Library. Youโll find it wherever you see the icon.'
+ ),
{
InserterIconImage: (
-
+
),
}
) }
@@ -73,15 +86,18 @@ export default function WelcomeGuide() {
- { __( 'New to the Block Editor? Want to learn more about using it? ' ) }
+ { __(
+ 'New to the Block Editor? Want to learn more about using it? '
+ ) }
- { __( 'Here\'s a detailed guide.' ) }
+ { __( "Here's a detailed guide." ) }
-
);
}
diff --git a/packages/edit-post/src/editor.js b/packages/edit-post/src/editor.js
index eb6754e7cf665..8d5f8a2fd5d7d 100644
--- a/packages/edit-post/src/editor.js
+++ b/packages/edit-post/src/editor.js
@@ -8,7 +8,11 @@ import { size, map, without } from 'lodash';
* WordPress dependencies
*/
import { withSelect, withDispatch } from '@wordpress/data';
-import { EditorProvider, ErrorBoundary, PostLockedModal } from '@wordpress/editor';
+import {
+ EditorProvider,
+ ErrorBoundary,
+ PostLockedModal,
+} from '@wordpress/editor';
import { StrictMode, Component } from '@wordpress/element';
import {
KeyboardShortcuts,
@@ -43,7 +47,7 @@ class Editor extends Component {
blockTypes,
preferredStyleVariations,
__experimentalLocalAutosaveInterval,
- updatePreferredStyleVariations,
+ updatePreferredStyleVariations
) {
settings = {
...settings,
@@ -62,15 +66,14 @@ class Editor extends Component {
// Defer to passed setting for `allowedBlockTypes` if provided as
// anything other than `true` (where `true` is equivalent to allow
// all block types).
- const defaultAllowedBlockTypes = (
- true === settings.allowedBlockTypes ?
- map( blockTypes, 'name' ) :
- ( settings.allowedBlockTypes || [] )
- );
+ const defaultAllowedBlockTypes =
+ true === settings.allowedBlockTypes
+ ? map( blockTypes, 'name' )
+ : settings.allowedBlockTypes || [];
settings.allowedBlockTypes = without(
defaultAllowedBlockTypes,
- ...hiddenBlockTypes,
+ ...hiddenBlockTypes
);
}
@@ -108,7 +111,7 @@ class Editor extends Component {
blockTypes,
preferredStyleVariations,
__experimentalLocalAutosaveInterval,
- updatePreferredStyleVariations,
+ updatePreferredStyleVariations
);
return (
@@ -126,7 +129,9 @@ class Editor extends Component {
-
+
@@ -149,10 +154,14 @@ export default compose( [
hasFixedToolbar: isFeatureActive( 'fixedToolbar' ),
focusMode: isFeatureActive( 'focusMode' ),
post: getEntityRecord( 'postType', postType, postId ),
- preferredStyleVariations: getPreference( 'preferredStyleVariations' ),
+ preferredStyleVariations: getPreference(
+ 'preferredStyleVariations'
+ ),
hiddenBlockTypes: getPreference( 'hiddenBlockTypes' ),
blockTypes: getBlockTypes(),
- __experimentalLocalAutosaveInterval: getPreference( 'localAutosaveInterval' ),
+ __experimentalLocalAutosaveInterval: getPreference(
+ 'localAutosaveInterval'
+ ),
};
} ),
withDispatch( ( dispatch ) => {
diff --git a/packages/edit-post/src/editor.native.js b/packages/edit-post/src/editor.native.js
index 097bf4b8c0041..3087d7b0b7854 100644
--- a/packages/edit-post/src/editor.native.js
+++ b/packages/edit-post/src/editor.native.js
@@ -41,7 +41,7 @@ class Editor extends Component {
hasFixedToolbar,
focusMode,
hiddenBlockTypes,
- blockTypes,
+ blockTypes
) {
settings = {
...settings,
@@ -54,15 +54,14 @@ class Editor extends Component {
// Defer to passed setting for `allowedBlockTypes` if provided as
// anything other than `true` (where `true` is equivalent to allow
// all block types).
- const defaultAllowedBlockTypes = (
- true === settings.allowedBlockTypes ?
- map( blockTypes, 'name' ) :
- ( settings.allowedBlockTypes || [] )
- );
+ const defaultAllowedBlockTypes =
+ true === settings.allowedBlockTypes
+ ? map( blockTypes, 'name' )
+ : settings.allowedBlockTypes || [];
settings.allowedBlockTypes = without(
defaultAllowedBlockTypes,
- ...hiddenBlockTypes,
+ ...hiddenBlockTypes
);
}
@@ -70,11 +69,13 @@ class Editor extends Component {
}
componentDidMount() {
- this.subscriptionParentSetFocusOnTitle = subscribeSetFocusOnTitle( () => {
- if ( this.postTitleRef ) {
- this.postTitleRef.focus();
+ this.subscriptionParentSetFocusOnTitle = subscribeSetFocusOnTitle(
+ () => {
+ if ( this.postTitleRef ) {
+ this.postTitleRef.focus();
+ }
}
- } );
+ );
}
componentWillUnmount() {
@@ -105,7 +106,7 @@ class Editor extends Component {
hasFixedToolbar,
focusMode,
hiddenBlockTypes,
- blockTypes,
+ blockTypes
);
const normalizedPost = post || {
@@ -142,7 +143,9 @@ class Editor extends Component {
export default compose( [
withSelect( ( select ) => {
- const { isFeatureActive, getEditorMode, getPreference } = select( 'core/edit-post' );
+ const { isFeatureActive, getEditorMode, getPreference } = select(
+ 'core/edit-post'
+ );
const { getBlockTypes } = select( 'core/blocks' );
return {
@@ -154,9 +157,7 @@ export default compose( [
};
} ),
withDispatch( ( dispatch ) => {
- const {
- switchEditorMode,
- } = dispatch( 'core/edit-post' );
+ const { switchEditorMode } = dispatch( 'core/edit-post' );
return {
switchEditorMode,
diff --git a/packages/edit-post/src/hooks/validate-multiple-use/index.js b/packages/edit-post/src/hooks/validate-multiple-use/index.js
index 32e50d7bb4c5d..b772241685bd4 100644
--- a/packages/edit-post/src/hooks/validate-multiple-use/index.js
+++ b/packages/edit-post/src/hooks/validate-multiple-use/index.js
@@ -44,23 +44,26 @@ const enhance = compose(
// Otherwise, only pass `originalBlockClientId` if it refers to a different
// block from the current one.
const blocks = select( 'core/block-editor' ).getBlocks();
- const firstOfSameType = find( blocks, ( { name } ) => block.name === name );
- const isInvalid = firstOfSameType && firstOfSameType.clientId !== block.clientId;
+ const firstOfSameType = find(
+ blocks,
+ ( { name } ) => block.name === name
+ );
+ const isInvalid =
+ firstOfSameType && firstOfSameType.clientId !== block.clientId;
return {
originalBlockClientId: isInvalid && firstOfSameType.clientId,
};
} ),
withDispatch( ( dispatch, { originalBlockClientId } ) => ( {
- selectFirst: () => dispatch( 'core/block-editor' ).selectBlock( originalBlockClientId ),
- } ) ),
+ selectFirst: () =>
+ dispatch( 'core/block-editor' ).selectBlock(
+ originalBlockClientId
+ ),
+ } ) )
);
const withMultipleValidation = createHigherOrderComponent( ( BlockEdit ) => {
- return enhance( ( {
- originalBlockClientId,
- selectFirst,
- ...props
- } ) => {
+ return enhance( ( { originalBlockClientId, selectFirst, ...props } ) => {
if ( ! originalBlockClientId ) {
return ;
}
@@ -75,22 +78,34 @@ const withMultipleValidation = createHigherOrderComponent( ( BlockEdit ) => {
+
{ __( 'Find original' ) }
,
- props.onReplace( [] ) }>
+ props.onReplace( [] ) }
+ >
{ __( 'Remove' ) }
,
outboundType && (
props.onReplace(
- createBlock( outboundType.name, props.attributes )
- ) }
+ onClick={ () =>
+ props.onReplace(
+ createBlock(
+ outboundType.name,
+ props.attributes
+ )
+ )
+ }
>
- { __( 'Transform into:' ) }{ ' ' }
- { outboundType.title }
+ { __( 'Transform into:' ) } { outboundType.title }
),
] }
diff --git a/packages/edit-post/src/index.js b/packages/edit-post/src/index.js
index fa3f9baec5d55..1f10cb7a36ba6 100644
--- a/packages/edit-post/src/index.js
+++ b/packages/edit-post/src/index.js
@@ -7,7 +7,10 @@ import '@wordpress/editor';
import '@wordpress/keyboard-shortcuts';
import '@wordpress/viewport';
import '@wordpress/notices';
-import { registerCoreBlocks, __experimentalRegisterExperimentalCoreBlocks } from '@wordpress/block-library';
+import {
+ registerCoreBlocks,
+ __experimentalRegisterExperimentalCoreBlocks,
+} from '@wordpress/block-library';
import { render, unmountComponentAtNode } from '@wordpress/element';
/**
@@ -31,9 +34,22 @@ import Editor from './editor';
* considered as non-user-initiated (bypass for
* unsaved changes prompt).
*/
-export function reinitializeEditor( postType, postId, target, settings, initialEdits ) {
+export function reinitializeEditor(
+ postType,
+ postId,
+ target,
+ settings,
+ initialEdits
+) {
unmountComponentAtNode( target );
- const reboot = reinitializeEditor.bind( null, postType, postId, target, settings, initialEdits );
+ const reboot = reinitializeEditor.bind(
+ null,
+ postType,
+ postId,
+ target,
+ settings,
+ initialEdits
+ );
render(
. Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins." );
+ console.warn(
+ "Your browser is using Quirks Mode. \nThis can cause rendering issues such as blocks overlaying meta boxes in the editor. Quirks Mode can be triggered by PHP errors or HTML code appearing before the opening . Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins."
+ );
}
// This is a temporary fix for a couple of issues specific to Webkit on iOS.
@@ -87,12 +119,15 @@ export function initializeEditor( id, postType, postId, settings, initialEdits )
const isIphone = window.navigator.userAgent.indexOf( 'iPhone' ) !== -1;
if ( isIphone ) {
window.addEventListener( 'scroll', function( event ) {
- const editorScrollContainer = document.getElementsByClassName( 'edit-post-editor-regions__body' )[ 0 ];
+ const editorScrollContainer = document.getElementsByClassName(
+ 'edit-post-editor-regions__body'
+ )[ 0 ];
if ( event.target === document ) {
// Scroll element into view by scrolling the editor container by the same amount
// that Mobile Safari tried to scroll the html element upwards.
if ( window.scrollY > 100 ) {
- editorScrollContainer.scrollTop = editorScrollContainer.scrollTop + window.scrollY;
+ editorScrollContainer.scrollTop =
+ editorScrollContainer.scrollTop + window.scrollY;
}
//Undo unwanted scroll on html element
window.scrollTo( 0, 0 );
diff --git a/packages/edit-post/src/index.native.js b/packages/edit-post/src/index.native.js
index 296e37117e5a1..13cf9ce44efe3 100644
--- a/packages/edit-post/src/index.native.js
+++ b/packages/edit-post/src/index.native.js
@@ -7,7 +7,6 @@ import '@wordpress/editor';
import '@wordpress/viewport';
import '@wordpress/notices';
import { registerCoreBlocks } from '@wordpress/block-library';
-import { unregisterBlockType } from '@wordpress/blocks';
import '@wordpress/format-library';
/**
@@ -27,13 +26,6 @@ export function initializeEditor() {
// register and setup blocks
registerCoreBlocks();
-
- // disable Code block for the release
- // eslint-disable-next-line no-undef
- if ( typeof __DEV__ === 'undefined' || ! __DEV__ ) {
- unregisterBlockType( 'core/code' );
- }
-
blocksRegistered = true;
}
diff --git a/packages/edit-post/src/plugins/copy-content-menu-item/index.js b/packages/edit-post/src/plugins/copy-content-menu-item/index.js
index 65e97a05bcfd0..7d3a9c8f1de8b 100644
--- a/packages/edit-post/src/plugins/copy-content-menu-item/index.js
+++ b/packages/edit-post/src/plugins/copy-content-menu-item/index.js
@@ -6,7 +6,12 @@ import { withDispatch, withSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { withState, compose } from '@wordpress/compose';
-function CopyContentMenuItem( { createNotice, editedPostContent, hasCopied, setState } ) {
+function CopyContentMenuItem( {
+ createNotice,
+ editedPostContent,
+ hasCopied,
+ setState,
+} ) {
return (
editedPostContent.length > 0 && (
{
setState( { hasCopied: true } );
- createNotice(
- 'info',
- __( 'All content copied.' ),
- {
- isDismissible: true,
- type: 'snackbar',
- }
- );
+ createNotice( 'info', __( 'All content copied.' ), {
+ isDismissible: true,
+ type: 'snackbar',
+ } );
} }
onFinishCopy={ () => setState( { hasCopied: false } ) }
>
- { hasCopied ?
- __( 'Copied!' ) :
- __( 'Copy all content' ) }
+ { hasCopied ? __( 'Copied!' ) : __( 'Copy all content' ) }
)
);
@@ -36,12 +35,12 @@ function CopyContentMenuItem( { createNotice, editedPostContent, hasCopied, setS
export default compose(
withSelect( ( select ) => ( {
- editedPostContent: select( 'core/editor' ).getEditedPostAttribute( 'content' ),
+ editedPostContent: select( 'core/editor' ).getEditedPostAttribute(
+ 'content'
+ ),
} ) ),
withDispatch( ( dispatch ) => {
- const {
- createNotice,
- } = dispatch( 'core/notices' );
+ const { createNotice } = dispatch( 'core/notices' );
return {
createNotice,
diff --git a/packages/edit-post/src/plugins/index.js b/packages/edit-post/src/plugins/index.js
index 0cbd97f681c24..f84fb5abb7f42 100644
--- a/packages/edit-post/src/plugins/index.js
+++ b/packages/edit-post/src/plugins/index.js
@@ -25,16 +25,22 @@ registerPlugin( 'edit-post', {
{ __( 'Manage all reusable blocks' ) }
-
+
{ __( 'Help' ) }
diff --git a/packages/edit-post/src/plugins/keyboard-shortcuts-help-menu-item/index.js b/packages/edit-post/src/plugins/keyboard-shortcuts-help-menu-item/index.js
index 49e947b9c7ea4..73d3b09683f50 100644
--- a/packages/edit-post/src/plugins/keyboard-shortcuts-help-menu-item/index.js
+++ b/packages/edit-post/src/plugins/keyboard-shortcuts-help-menu-item/index.js
@@ -20,9 +20,7 @@ export function KeyboardShortcutsHelpMenuItem( { openModal } ) {
}
export default withDispatch( ( dispatch ) => {
- const {
- openModal,
- } = dispatch( 'core/edit-post' );
+ const { openModal } = dispatch( 'core/edit-post' );
return {
openModal,
diff --git a/packages/edit-post/src/plugins/manage-blocks-menu-item/index.js b/packages/edit-post/src/plugins/manage-blocks-menu-item/index.js
index fff70dd41a8da..4275f0a36988e 100644
--- a/packages/edit-post/src/plugins/manage-blocks-menu-item/index.js
+++ b/packages/edit-post/src/plugins/manage-blocks-menu-item/index.js
@@ -18,9 +18,7 @@ export function ManageBlocksMenuItem( { openModal } ) {
}
export default withDispatch( ( dispatch ) => {
- const {
- openModal,
- } = dispatch( 'core/edit-post' );
+ const { openModal } = dispatch( 'core/edit-post' );
return {
openModal,
diff --git a/packages/edit-post/src/prevent-event-discovery.js b/packages/edit-post/src/prevent-event-discovery.js
index 36e58f798752c..daf65b20591d3 100644
--- a/packages/edit-post/src/prevent-event-discovery.js
+++ b/packages/edit-post/src/prevent-event-discovery.js
@@ -1,7 +1,9 @@
export default {
't a l e s o f g u t e n b e r g': ( event ) => {
if (
- ! document.activeElement.classList.contains( 'edit-post-visual-editor' ) &&
+ ! document.activeElement.classList.contains(
+ 'edit-post-visual-editor'
+ ) &&
document.activeElement !== document.body
) {
return;
@@ -10,7 +12,8 @@ export default {
event.preventDefault();
window.wp.data.dispatch( 'core/block-editor' ).insertBlock(
window.wp.blocks.createBlock( 'core/paragraph', {
- content: '๐ก๐ข๐ฆ๐ค๐ฆ๐๐ง๐น๐ฆ๐ฆ๐ฆ๐ผ๐ฟ๐๐ด๐๐๐ฆ๐ฆ๐ฑ๐ฯ๐๐๐ง๐ฅจ๐๐๐ ๐ฅฆ๐ฅ๐ฅ๐๐ฅฅ๐ฅ๐ต๐ฅ๐๐ฏ๐พ๐ฒ๐บ๐๐ฎโ๏ธ',
+ content:
+ '๐ก๐ข๐ฆ๐ค๐ฆ๐๐ง๐น๐ฆ๐ฆ๐ฆ๐ผ๐ฟ๐๐ด๐๐๐ฆ๐ฆ๐ฑ๐ฯ๐๐๐ง๐ฅจ๐๐๐ ๐ฅฆ๐ฅ๐ฅ๐๐ฅฅ๐ฅ๐ต๐ฅ๐๐ฏ๐พ๐ฒ๐บ๐๐ฎโ๏ธ',
} )
);
},
diff --git a/packages/edit-post/src/store/actions.js b/packages/edit-post/src/store/actions.js
index 8092dd73f4739..4d586debb737a 100644
--- a/packages/edit-post/src/store/actions.js
+++ b/packages/edit-post/src/store/actions.js
@@ -196,6 +196,13 @@ export function updatePreferredStyleVariations( blockName, blockStyle ) {
};
}
+/**
+ * Returns an action object used in signalling that the editor should attempt
+ * to locally autosave the current post every `interval` seconds.
+ *
+ * @param {number} interval The new interval, in seconds.
+ * @return {Object} Action object.
+ */
export function __experimentalUpdateLocalAutosaveInterval( interval ) {
return {
type: 'UPDATE_LOCAL_AUTOSAVE_INTERVAL',
diff --git a/packages/edit-post/src/store/effects.js b/packages/edit-post/src/store/effects.js
index 118ee40551a31..0e69bd005dd6f 100644
--- a/packages/edit-post/src/store/effects.js
+++ b/packages/edit-post/src/store/effects.js
@@ -54,11 +54,11 @@ const effects = {
const isAutosavingPost = select( 'core/editor' ).isAutosavingPost();
// Save metaboxes on save completion, except for autosaves that are not a post preview.
- const shouldTriggerMetaboxesSave = (
- hasActiveMetaBoxes && (
- ( wasSavingPost && ! isSavingPost && ! wasAutosavingPost )
- )
- );
+ const shouldTriggerMetaboxesSave =
+ hasActiveMetaBoxes &&
+ wasSavingPost &&
+ ! isSavingPost &&
+ ! wasAutosavingPost;
// Save current state for next inspection.
wasSavingPost = isSavingPost;
@@ -81,29 +81,40 @@ const effects = {
// If we do not provide this data, the post will be overridden with the default values.
const post = select( 'core/editor' ).getCurrentPost( state );
const additionalData = [
- post.comment_status ? [ 'comment_status', post.comment_status ] : false,
+ post.comment_status
+ ? [ 'comment_status', post.comment_status ]
+ : false,
post.ping_status ? [ 'ping_status', post.ping_status ] : false,
post.sticky ? [ 'sticky', post.sticky ] : false,
post.author ? [ 'post_author', post.author ] : false,
].filter( Boolean );
// We gather all the metaboxes locations data and the base form data
- const baseFormData = new window.FormData( document.querySelector( '.metabox-base-form' ) );
+ const baseFormData = new window.FormData(
+ document.querySelector( '.metabox-base-form' )
+ );
const formDataToMerge = [
baseFormData,
- ...getActiveMetaBoxLocations( state ).map( ( location ) => (
- new window.FormData( getMetaBoxContainer( location ) )
- ) ),
+ ...getActiveMetaBoxLocations( state ).map(
+ ( location ) =>
+ new window.FormData( getMetaBoxContainer( location ) )
+ ),
];
// Merge all form data objects into a single one.
- const formData = reduce( formDataToMerge, ( memo, currentFormData ) => {
- for ( const [ key, value ] of currentFormData ) {
- memo.append( key, value );
- }
- return memo;
- }, new window.FormData() );
- additionalData.forEach( ( [ key, value ] ) => formData.append( key, value ) );
+ const formData = reduce(
+ formDataToMerge,
+ ( memo, currentFormData ) => {
+ for ( const [ key, value ] of currentFormData ) {
+ memo.append( key, value );
+ }
+ return memo;
+ },
+ new window.FormData()
+ );
+ additionalData.forEach( ( [ key, value ] ) =>
+ formData.append( key, value )
+ );
// Save the metaboxes
apiFetch( {
@@ -111,8 +122,7 @@ const effects = {
method: 'POST',
body: formData,
parse: false,
- } )
- .then( () => store.dispatch( metaBoxUpdatesSuccess() ) );
+ } ).then( () => store.dispatch( metaBoxUpdatesSuccess() ) );
},
SWITCH_MODE( action ) {
// Unselect blocks when we switch to the code editor.
@@ -120,7 +130,10 @@ const effects = {
dispatch( 'core/block-editor' ).clearSelectedBlock();
}
- const message = action.mode === 'visual' ? __( 'Visual editor selected' ) : __( 'Code editor selected' );
+ const message =
+ action.mode === 'visual'
+ ? __( 'Visual editor selected' )
+ : __( 'Code editor selected' );
speak( message, 'assertive' );
},
};
diff --git a/packages/edit-post/src/store/middlewares.js b/packages/edit-post/src/store/middlewares.js
index ee42a43e589b0..06cacf026d58c 100644
--- a/packages/edit-post/src/store/middlewares.js
+++ b/packages/edit-post/src/store/middlewares.js
@@ -17,14 +17,12 @@ import effects from './effects';
* @return {Object} Update Store Object.
*/
function applyMiddlewares( store ) {
- const middlewares = [
- refx( effects ),
- ];
+ const middlewares = [ refx( effects ) ];
let enhancedDispatch = () => {
throw new Error(
'Dispatching while constructing your middleware is not allowed. ' +
- 'Other middleware would not be applied to this dispatch.'
+ 'Other middleware would not be applied to this dispatch.'
);
};
let chain = [];
diff --git a/packages/edit-post/src/store/reducer.js b/packages/edit-post/src/store/reducer.js
index b57c6e174480c..66991a84150f6 100644
--- a/packages/edit-post/src/store/reducer.js
+++ b/packages/edit-post/src/store/reducer.js
@@ -1,14 +1,7 @@
/**
* External dependencies
*/
-import {
- flow,
- get,
- includes,
- omit,
- union,
- without,
-} from 'lodash';
+import { flow, get, includes, omit, union, without } from 'lodash';
/**
* WordPress dependencies
@@ -86,7 +79,9 @@ export const preferences = flow( [
case 'TOGGLE_PANEL_OPENED': {
const { panelName } = action;
- const isOpen = state[ panelName ] === true || get( state, [ panelName, 'opened' ], false );
+ const isOpen =
+ state[ panelName ] === true ||
+ get( state, [ panelName, 'opened' ], false );
return {
...state,
[ panelName ]: {
@@ -120,7 +115,11 @@ export const preferences = flow( [
if ( action.type === 'TOGGLE_PINNED_PLUGIN_ITEM' ) {
return {
...state,
- [ action.pluginName ]: ! get( state, [ action.pluginName ], true ),
+ [ action.pluginName ]: ! get(
+ state,
+ [ action.pluginName ],
+ true
+ ),
};
}
return state;
@@ -175,10 +174,7 @@ export function removedPanels( state = [], action ) {
switch ( action.type ) {
case 'REMOVE_PANEL':
if ( ! includes( state, action.panelName ) ) {
- return [
- ...state,
- action.panelName,
- ];
+ return [ ...state, action.panelName ];
}
}
@@ -194,7 +190,10 @@ export function removedPanels( state = [], action ) {
*
* @return {?string} Updated state.
*/
-export function activeGeneralSidebar( state = DEFAULT_ACTIVE_GENERAL_SIDEBAR, action ) {
+export function activeGeneralSidebar(
+ state = DEFAULT_ACTIVE_GENERAL_SIDEBAR,
+ action
+) {
switch ( action.type ) {
case 'OPEN_GENERAL_SIDEBAR':
return action.name;
diff --git a/packages/edit-post/src/store/selectors.js b/packages/edit-post/src/store/selectors.js
index fff04ac721fe3..d237ee1e9dac1 100644
--- a/packages/edit-post/src/store/selectors.js
+++ b/packages/edit-post/src/store/selectors.js
@@ -25,7 +25,10 @@ export function getEditorMode( state ) {
export function isEditorSidebarOpened( state ) {
const activeGeneralSidebar = getActiveGeneralSidebarName( state );
- return includes( [ 'edit-post/document', 'edit-post/block' ], activeGeneralSidebar );
+ return includes(
+ [ 'edit-post/document', 'edit-post/block' ],
+ activeGeneralSidebar
+ );
}
/**
@@ -55,7 +58,11 @@ export function isPluginSidebarOpened( state ) {
*/
export function getActiveGeneralSidebarName( state ) {
// Dismissal takes precedent.
- const isDismissed = getPreference( state, 'isGeneralSidebarDismissed', false );
+ const isDismissed = getPreference(
+ state,
+ 'isGeneralSidebarDismissed',
+ false
+ );
if ( isDismissed ) {
return null;
}
@@ -124,8 +131,10 @@ export function isEditorPanelRemoved( state, panelName ) {
export function isEditorPanelEnabled( state, panelName ) {
const panels = getPreference( state, 'panels' );
- return ! isEditorPanelRemoved( state, panelName ) &&
- get( panels, [ panelName, 'enabled' ], true );
+ return (
+ ! isEditorPanelRemoved( state, panelName ) &&
+ get( panels, [ panelName, 'enabled' ], true )
+ );
}
/**
@@ -193,12 +202,11 @@ export function isPluginItemPinned( state, pluginName ) {
*/
export const getActiveMetaBoxLocations = createSelector(
( state ) => {
- return Object.keys( state.metaBoxes.locations )
- .filter( ( location ) => isMetaBoxLocationActive( state, location ) );
+ return Object.keys( state.metaBoxes.locations ).filter( ( location ) =>
+ isMetaBoxLocationActive( state, location )
+ );
},
- ( state ) => [
- state.metaBoxes.locations,
- ]
+ ( state ) => [ state.metaBoxes.locations ]
);
/**
@@ -255,9 +263,7 @@ export const getAllMetaBoxes = createSelector(
( state ) => {
return flatten( values( state.metaBoxes.locations ) );
},
- ( state ) => [
- state.metaBoxes.locations,
- ]
+ ( state ) => [ state.metaBoxes.locations ]
);
/**
diff --git a/packages/edit-post/src/store/test/reducer.js b/packages/edit-post/src/store/test/reducer.js
index 4241de25d5b95..b21be5ff26d9b 100644
--- a/packages/edit-post/src/store/test/reducer.js
+++ b/packages/edit-post/src/store/test/reducer.js
@@ -36,10 +36,12 @@ describe( 'state', () => {
} );
it( 'should set the general sidebar undismissed', () => {
- const original = deepFreeze( preferences( undefined, {
- type: 'OPEN_GENERAL_SIDEBAR',
- name: 'edit-post/document',
- } ) );
+ const original = deepFreeze(
+ preferences( undefined, {
+ type: 'OPEN_GENERAL_SIDEBAR',
+ name: 'edit-post/document',
+ } )
+ );
const state = preferences( original, {
type: 'CLOSE_GENERAL_SIDEBAR',
} );
@@ -173,10 +175,13 @@ describe( 'state', () => {
} );
it( 'should toggle a feature flag', () => {
- const state = preferences( deepFreeze( { features: { chicken: true } } ), {
- type: 'TOGGLE_FEATURE',
- feature: 'chicken',
- } );
+ const state = preferences(
+ deepFreeze( { features: { chicken: true } } ),
+ {
+ type: 'TOGGLE_FEATURE',
+ feature: 'chicken',
+ }
+ );
expect( state.features ).toEqual( { chicken: false } );
} );
@@ -195,7 +200,9 @@ describe( 'state', () => {
pluginName: 'foo/does-not-exist',
} );
- expect( state.pinnedPluginItems[ 'foo/does-not-exist' ] ).toBe( false );
+ expect( state.pinnedPluginItems[ 'foo/does-not-exist' ] ).toBe(
+ false
+ );
} );
it( 'should disable a pinned plugin flag when it is enabled', () => {
@@ -204,7 +211,9 @@ describe( 'state', () => {
pluginName: 'foo/enabled',
} );
- expect( state.pinnedPluginItems[ 'foo/enabled' ] ).toBe( false );
+ expect( state.pinnedPluginItems[ 'foo/enabled' ] ).toBe(
+ false
+ );
} );
it( 'should enable a pinned plugin flag when it is disabled', () => {
@@ -213,7 +222,9 @@ describe( 'state', () => {
pluginName: 'foo/disabled',
} );
- expect( state.pinnedPluginItems[ 'foo/disabled' ] ).toBe( true );
+ expect( state.pinnedPluginItems[ 'foo/disabled' ] ).toBe(
+ true
+ );
} );
} );
@@ -228,11 +239,7 @@ describe( 'state', () => {
blockNames: [ 'b', 'c' ],
} );
- expect( state.hiddenBlockTypes ).toEqual( [
- 'a',
- 'b',
- 'c',
- ] );
+ expect( state.hiddenBlockTypes ).toEqual( [ 'a', 'b', 'c' ] );
} );
it( 'omits present names by enable', () => {
@@ -245,9 +252,7 @@ describe( 'state', () => {
blockNames: [ 'b', 'c' ],
} );
- expect( state.hiddenBlockTypes ).toEqual( [
- 'a',
- ] );
+ expect( state.hiddenBlockTypes ).toEqual( [ 'a' ] );
} );
} );
} );
diff --git a/packages/edit-post/src/store/test/selectors.js b/packages/edit-post/src/store/test/selectors.js
index 16131bf8eaf8d..4da4686fc0379 100644
--- a/packages/edit-post/src/store/test/selectors.js
+++ b/packages/edit-post/src/store/test/selectors.js
@@ -65,7 +65,9 @@ describe( 'selectors', () => {
preferences: {},
};
- expect( getPreference( state, 'ribs', 'chicken' ) ).toEqual( 'chicken' );
+ expect( getPreference( state, 'ribs', 'chicken' ) ).toEqual(
+ 'chicken'
+ );
} );
} );
@@ -171,7 +173,9 @@ describe( 'selectors', () => {
activeGeneralSidebar: 'edit-post/block',
};
- expect( getActiveGeneralSidebarName( state ) ).toBe( 'edit-post/block' );
+ expect( getActiveGeneralSidebarName( state ) ).toBe(
+ 'edit-post/block'
+ );
} );
} );
@@ -207,14 +211,14 @@ describe( 'selectors', () => {
removedPanels: [],
} );
- expect( isEditorPanelRemoved( state, 'post-status' ) ).toBe( false );
+ expect( isEditorPanelRemoved( state, 'post-status' ) ).toBe(
+ false
+ );
} );
it( 'should return true when panel was removed', () => {
const state = deepFreeze( {
- removedPanels: [
- 'post-status',
- ],
+ removedPanels: [ 'post-status' ],
} );
expect( isEditorPanelRemoved( state, 'post-status' ) ).toBe( true );
@@ -253,7 +257,9 @@ describe( 'selectors', () => {
},
};
- expect( isEditorPanelEnabled( state, 'post-status' ) ).toBe( false );
+ expect( isEditorPanelEnabled( state, 'post-status' ) ).toBe(
+ false
+ );
} );
it( 'should return false when a panel is enabled but removed', () => {
@@ -268,7 +274,9 @@ describe( 'selectors', () => {
removedPanels: [ 'post-status' ],
} );
- expect( isEditorPanelEnabled( state, 'post-status' ) ).toBe( false );
+ expect( isEditorPanelEnabled( state, 'post-status' ) ).toBe(
+ false
+ );
} );
} );
@@ -378,8 +386,7 @@ describe( 'selectors', () => {
it( 'should return false if feature is not referred', () => {
const state = {
preferences: {
- features: {
- },
+ features: {},
},
};
diff --git a/packages/edit-post/src/test/editor.native.js b/packages/edit-post/src/test/editor.native.js
index 89cfc4a9bcc96..08866099cb3d5 100644
--- a/packages/edit-post/src/test/editor.native.js
+++ b/packages/edit-post/src/test/editor.native.js
@@ -40,8 +40,12 @@ describe( 'Editor', () => {
} );
appContainer.unmount();
- expect( RNReactNativeGutenbergBridge.editorDidMount ).toHaveBeenCalledTimes( 1 );
- expect( RNReactNativeGutenbergBridge.editorDidMount ).toHaveBeenCalledWith( [ 'core/notablock' ] );
+ expect(
+ RNReactNativeGutenbergBridge.editorDidMount
+ ).toHaveBeenCalledTimes( 1 );
+ expect(
+ RNReactNativeGutenbergBridge.editorDidMount
+ ).toHaveBeenCalledWith( [ 'core/notablock' ] );
} );
} );
diff --git a/packages/edit-post/src/utils/meta-boxes.js b/packages/edit-post/src/utils/meta-boxes.js
index 055a239f1c1d9..a781b96318402 100644
--- a/packages/edit-post/src/utils/meta-boxes.js
+++ b/packages/edit-post/src/utils/meta-boxes.js
@@ -7,7 +7,9 @@
* @return {string} HTML content.
*/
export const getMetaBoxContainer = ( location ) => {
- const area = document.querySelector( `.edit-post-meta-boxes-area.is-${ location } .metabox-location-${ location }` );
+ const area = document.querySelector(
+ `.edit-post-meta-boxes-area.is-${ location } .metabox-location-${ location }`
+ );
if ( area ) {
return area;
}
diff --git a/packages/edit-site/package.json b/packages/edit-site/package.json
index 6d8793910a6fa..dba4705d9c351 100644
--- a/packages/edit-site/package.json
+++ b/packages/edit-site/package.json
@@ -21,11 +21,14 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
- "@babel/runtime": "^7.4.4",
+ "@babel/runtime": "^7.8.3",
"@wordpress/block-editor": "file:../block-editor",
"@wordpress/block-library": "file:../block-library",
+ "@wordpress/blocks": "file:../blocks",
"@wordpress/components": "file:../components",
+ "@wordpress/core-data": "file:../core-data",
"@wordpress/data": "file:../data",
+ "@wordpress/editor": "file:../editor",
"@wordpress/element": "file:../element",
"@wordpress/hooks": "file:../hooks",
"@wordpress/i18n": "file:../i18n",
diff --git a/packages/edit-site/src/components/block-editor/index.js b/packages/edit-site/src/components/block-editor/index.js
index c049e78e0c51d..ef886a68f53b5 100644
--- a/packages/edit-site/src/components/block-editor/index.js
+++ b/packages/edit-site/src/components/block-editor/index.js
@@ -2,8 +2,10 @@
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
-import { useMemo, useState } from '@wordpress/element';
+import { useMemo, useCallback } from '@wordpress/element';
import { uploadMedia } from '@wordpress/media-utils';
+import { useEntityProp } from '@wordpress/core-data';
+import { parse, serialize } from '@wordpress/blocks';
import {
BlockEditorProvider,
BlockEditorKeyboardShortcuts,
@@ -21,7 +23,10 @@ import Sidebar from '../sidebar';
export default function BlockEditor( { settings: _settings } ) {
const canUserCreateMedia = useSelect( ( select ) => {
- const _canUserCreateMedia = select( 'core' ).canUser( 'create', 'media' );
+ const _canUserCreateMedia = select( 'core' ).canUser(
+ 'create',
+ 'media'
+ );
return _canUserCreateMedia || _canUserCreateMedia !== false;
}, [] );
const settings = useMemo( () => {
@@ -39,13 +44,32 @@ export default function BlockEditor( { settings: _settings } ) {
},
};
}, [ canUserCreateMedia, _settings ] );
- const [ blocks, setBlocks ] = useState( [] );
+ const [ content, _setContent ] = useEntityProp(
+ 'postType',
+ 'wp_template',
+ 'content'
+ );
+ const initialBlocks = useMemo( () => {
+ if ( typeof content !== 'function' ) {
+ const parsedContent = parse( content );
+ return parsedContent.length ? parsedContent : undefined;
+ }
+ }, [] );
+ const [ blocks = initialBlocks, setBlocks ] = useEntityProp(
+ 'postType',
+ 'wp_template',
+ 'blocks'
+ );
+ const setContent = useCallback( ( nextBlocks ) => {
+ setBlocks( nextBlocks );
+ _setContent( serialize( nextBlocks ) );
+ }, [] );
return (
diff --git a/packages/edit-site/src/components/editor/index.js b/packages/edit-site/src/components/editor/index.js
index f7f0ef0286b10..83a0f498a35fc 100644
--- a/packages/edit-site/src/components/editor/index.js
+++ b/packages/edit-site/src/components/editor/index.js
@@ -1,12 +1,14 @@
/**
* WordPress dependencies
*/
+import { useSelect } from '@wordpress/data';
import {
SlotFillProvider,
DropZoneProvider,
Popover,
navigateRegions,
} from '@wordpress/components';
+import { EntityProvider } from '@wordpress/core-data';
/**
* Internal dependencies
@@ -17,17 +19,32 @@ import Sidebar from '../sidebar';
import BlockEditor from '../block-editor';
function Editor( { settings } ) {
- return (
+ const template = useSelect(
+ ( select ) =>
+ select( 'core' ).getEntityRecord(
+ 'postType',
+ 'wp_template',
+ settings.templateId
+ ),
+ []
+ );
+ return template ? (
-
-
-
-
-
+
+
+
+
+
+
+
- );
+ ) : null;
}
export default navigateRegions( Editor );
diff --git a/packages/edit-site/src/components/header/index.js b/packages/edit-site/src/components/header/index.js
index 2b89acdafa8fb..196b80834eadd 100644
--- a/packages/edit-site/src/components/header/index.js
+++ b/packages/edit-site/src/components/header/index.js
@@ -3,6 +3,11 @@
*/
import { __ } from '@wordpress/i18n';
+/**
+ * Internal dependencies
+ */
+import SaveButton from '../save-button';
+
export default function Header() {
return (
{ __( 'Site Editor' ) } { __( '(beta)' ) }
+
+
+
);
}
diff --git a/packages/edit-site/src/components/header/style.scss b/packages/edit-site/src/components/header/style.scss
index f280aa258020d..84fa28b4cd591 100644
--- a/packages/edit-site/src/components/header/style.scss
+++ b/packages/edit-site/src/components/header/style.scss
@@ -31,3 +31,7 @@
font-size: 16px;
padding: 0 20px;
}
+
+.edit-site-header__actions {
+ padding: 0 20px;
+}
diff --git a/packages/edit-site/src/components/save-button/index.js b/packages/edit-site/src/components/save-button/index.js
new file mode 100644
index 0000000000000..a7d4acc7dab8e
--- /dev/null
+++ b/packages/edit-site/src/components/save-button/index.js
@@ -0,0 +1,66 @@
+/**
+ * WordPress dependencies
+ */
+import { useEntityProp } from '@wordpress/core-data';
+import { useEffect, useState, useCallback } from '@wordpress/element';
+import { useSelect } from '@wordpress/data';
+import { Button } from '@wordpress/components';
+import { __ } from '@wordpress/i18n';
+import { EntitiesSavedStates } from '@wordpress/editor';
+
+export default function SaveButton() {
+ const [ , setStatus ] = useEntityProp(
+ 'postType',
+ 'wp_template',
+ 'status'
+ );
+ // Publish template if not done yet.
+ useEffect( () => setStatus( 'publish' ), [] );
+
+ const { isDirty, isSaving } = useSelect( ( select ) => {
+ const { getEntityRecordChangesByRecord, isSavingEntityRecord } = select(
+ 'core'
+ );
+ const entityRecordChangesByRecord = getEntityRecordChangesByRecord();
+ const changedKinds = Object.keys( entityRecordChangesByRecord );
+ return {
+ isDirty: changedKinds.length > 0,
+ isSaving: changedKinds.some( ( changedKind ) =>
+ Object.keys(
+ entityRecordChangesByRecord[ changedKind ]
+ ).some( ( changedName ) =>
+ Object.keys(
+ entityRecordChangesByRecord[ changedKind ][
+ changedName
+ ]
+ ).some( ( changedKey ) =>
+ isSavingEntityRecord(
+ changedKind,
+ changedName,
+ changedKey
+ )
+ )
+ )
+ ),
+ };
+ } );
+ const disabled = ! isDirty || isSaving;
+
+ const [ isOpen, setIsOpen ] = useState( false );
+ const open = useCallback( setIsOpen.bind( null, true ), [] );
+ const close = useCallback( setIsOpen.bind( null, false ), [] );
+ return (
+ <>
+
+ { __( 'Update' ) }
+
+
+ >
+ );
+}
diff --git a/packages/edit-widgets/package.json b/packages/edit-widgets/package.json
index d01b6922fb5fb..5e20e2542da47 100644
--- a/packages/edit-widgets/package.json
+++ b/packages/edit-widgets/package.json
@@ -21,7 +21,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
- "@babel/runtime": "^7.4.4",
+ "@babel/runtime": "^7.8.3",
"@wordpress/block-editor": "file:../block-editor",
"@wordpress/block-library": "file:../block-library",
"@wordpress/blocks": "file:../blocks",
diff --git a/packages/edit-widgets/src/components/customizer-edit-widgets-initializer/sync-customizer.js b/packages/edit-widgets/src/components/customizer-edit-widgets-initializer/sync-customizer.js
index ebc1099a35f7a..4752d0305c0ba 100644
--- a/packages/edit-widgets/src/components/customizer-edit-widgets-initializer/sync-customizer.js
+++ b/packages/edit-widgets/src/components/customizer-edit-widgets-initializer/sync-customizer.js
@@ -52,14 +52,17 @@ const getWidgetAreasObject = () => {
'core'
);
- return getEntityRecords( 'root', 'widgetArea' ).reduce( ( widgetAreasObject, { id } ) => {
- widgetAreasObject[ id ] = getEditedEntityRecord(
- 'root',
- 'widgetArea',
- id
- ).blocks;
- return widgetAreasObject;
- }, {} );
+ return getEntityRecords( 'root', 'widgetArea' ).reduce(
+ ( widgetAreasObject, { id } ) => {
+ widgetAreasObject[ id ] = getEditedEntityRecord(
+ 'root',
+ 'widgetArea',
+ id
+ ).blocks;
+ return widgetAreasObject;
+ },
+ {}
+ );
};
// Serialize the provided blocks and render them in the widget area with the provided ID.
@@ -67,7 +70,10 @@ const previewBlocksInWidgetArea = throttle( ( id, blocks ) => {
const customizePreviewIframe = document.querySelector(
'#customize-preview > iframe'
);
- if ( ! customizePreviewIframe || ! customizePreviewIframe.contentDocument ) {
+ if (
+ ! customizePreviewIframe ||
+ ! customizePreviewIframe.contentDocument
+ ) {
return;
}
@@ -115,13 +121,17 @@ if ( window.wp && window.wp.customize && window.wp.data ) {
let widgetAreas;
try {
widgetAreas = JSON.parse(
- document.getElementById( '_customize-input-gutenberg_widget_blocks' )
- .value
+ document.getElementById(
+ '_customize-input-gutenberg_widget_blocks'
+ ).value
+ );
+ widgetAreas = Object.keys( widgetAreas ).reduce(
+ ( value, id ) => {
+ value[ id ] = parse( widgetAreas[ id ] );
+ return value;
+ },
+ {}
);
- widgetAreas = Object.keys( widgetAreas ).reduce( ( value, id ) => {
- value[ id ] = parse( widgetAreas[ id ] );
- return value;
- }, {} );
} catch ( err ) {
widgetAreas = {};
}
@@ -130,20 +140,26 @@ if ( window.wp && window.wp.customize && window.wp.data ) {
// if any, and subscribe to registry changes after that so that we can preview
// changes and update the hidden input's value when any of the widget areas change.
waitForSelectValue(
- () => window.wp.data.select( 'core' ).hasFinishedResolution( 'getEntityRecords', [ 'root', 'widgetArea' ] ),
+ () =>
+ window.wp.data
+ .select( 'core' )
+ .hasFinishedResolution( 'getEntityRecords', [
+ 'root',
+ 'widgetArea',
+ ] ),
true,
- () => window.wp.data.select( 'core' ).getEntityRecords( 'root', 'widgetArea' )
+ () =>
+ window.wp.data
+ .select( 'core' )
+ .getEntityRecords( 'root', 'widgetArea' )
).then( () => {
Object.keys( widgetAreas ).forEach( ( id ) => {
- window.wp.data.dispatch( 'core' ).editEntityRecord(
- 'root',
- 'widgetArea',
- id,
- {
+ window.wp.data
+ .dispatch( 'core' )
+ .editEntityRecord( 'root', 'widgetArea', id, {
content: serialize( widgetAreas[ id ] ),
blocks: widgetAreas[ id ],
- }
- );
+ } );
} );
widgetAreas = getWidgetAreasObject();
window.wp.data.subscribe( () => {
@@ -152,7 +168,10 @@ if ( window.wp && window.wp.customize && window.wp.data ) {
let didUpdate = false;
for ( const id of Object.keys( nextWidgetAreas ) ) {
if ( widgetAreas[ id ] !== nextWidgetAreas[ id ] ) {
- previewBlocksInWidgetArea( id, nextWidgetAreas[ id ] );
+ previewBlocksInWidgetArea(
+ id,
+ nextWidgetAreas[ id ]
+ );
didUpdate = true;
}
}
diff --git a/packages/edit-widgets/src/components/edit-widgets-initializer/index.js b/packages/edit-widgets/src/components/edit-widgets-initializer/index.js
index 02e34e13b4cd9..f93745fed15ae 100644
--- a/packages/edit-widgets/src/components/edit-widgets-initializer/index.js
+++ b/packages/edit-widgets/src/components/edit-widgets-initializer/index.js
@@ -4,11 +4,7 @@
import Layout from '../layout';
function EditWidgetsInitializer( { settings } ) {
- return (
-
- );
+ return ;
}
export default EditWidgetsInitializer;
diff --git a/packages/edit-widgets/src/components/inserter/index.js b/packages/edit-widgets/src/components/inserter/index.js
index 12139805745e1..84184b541c918 100644
--- a/packages/edit-widgets/src/components/inserter/index.js
+++ b/packages/edit-widgets/src/components/inserter/index.js
@@ -3,14 +3,14 @@
*/
import { createSlotFill } from '@wordpress/components';
-const { Fill: BlockInserterFill, Slot: BlockInserterSlot } = createSlotFill( 'EditWidgetsInserter' );
+const { Fill: BlockInserterFill, Slot: BlockInserterSlot } = createSlotFill(
+ 'EditWidgetsInserter'
+);
const Inserter = BlockInserterFill;
Inserter.Slot = function() {
- return (
-
- );
+ return ;
};
export default Inserter;
diff --git a/packages/edit-widgets/src/components/layout/index.js b/packages/edit-widgets/src/components/layout/index.js
index 9011f8fff87f7..15480f21f77a4 100644
--- a/packages/edit-widgets/src/components/layout/index.js
+++ b/packages/edit-widgets/src/components/layout/index.js
@@ -9,6 +9,7 @@ import {
SlotFillProvider,
} from '@wordpress/components';
import { useState } from '@wordpress/element';
+import { BlockEditorKeyboardShortcuts } from '@wordpress/block-editor';
/**
* Internal dependencies
@@ -23,6 +24,7 @@ function Layout( { blockEditorSettings } ) {
return (
+
diff --git a/packages/edit-widgets/src/components/save-button/index.js b/packages/edit-widgets/src/components/save-button/index.js
index fc1a2a1cc0602..637aac055e635 100644
--- a/packages/edit-widgets/src/components/save-button/index.js
+++ b/packages/edit-widgets/src/components/save-button/index.js
@@ -12,28 +12,23 @@ import { useCallback } from '@wordpress/element';
import { useDispatch, useSelect } from '@wordpress/data';
function SaveButton() {
- const { editedWidgetAreaIds, isSaving } = useSelect(
- ( select ) => {
- const {
- hasEditsForEntityRecord,
- isSavingEntityRecord,
- getEntityRecords,
- } = select( 'core' );
- const widgetAreas = getEntityRecords( 'root', 'widgetArea' );
- const widgetAreaIds = map( widgetAreas, ( { id } ) => id );
- return {
- editedWidgetAreaIds: filter(
- widgetAreaIds,
- ( id ) => hasEditsForEntityRecord( 'root', 'widgetArea', id )
- ),
- isSaving: some(
- widgetAreaIds,
- ( id ) => isSavingEntityRecord( 'root', 'widgetArea', id )
- ),
- };
- },
- []
- );
+ const { editedWidgetAreaIds, isSaving } = useSelect( ( select ) => {
+ const {
+ hasEditsForEntityRecord,
+ isSavingEntityRecord,
+ getEntityRecords,
+ } = select( 'core' );
+ const widgetAreas = getEntityRecords( 'root', 'widgetArea' );
+ const widgetAreaIds = map( widgetAreas, ( { id } ) => id );
+ return {
+ editedWidgetAreaIds: filter( widgetAreaIds, ( id ) =>
+ hasEditsForEntityRecord( 'root', 'widgetArea', id )
+ ),
+ isSaving: some( widgetAreaIds, ( id ) =>
+ isSavingEntityRecord( 'root', 'widgetArea', id )
+ ),
+ };
+ }, [] );
const { saveEditedEntityRecord } = useDispatch( 'core' );
const onClick = useCallback( () => {
diff --git a/packages/edit-widgets/src/components/sidebar/index.js b/packages/edit-widgets/src/components/sidebar/index.js
index 60cb68b22fb0a..ebd70ac9294cb 100644
--- a/packages/edit-widgets/src/components/sidebar/index.js
+++ b/packages/edit-widgets/src/components/sidebar/index.js
@@ -4,7 +4,10 @@
import { createSlotFill, Panel } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
-export const { Fill: BlockSidebarFill, Slot: BlockSidebarSlot } = createSlotFill( 'EditWidgetsBlockSidebar' );
+export const {
+ Fill: BlockSidebarFill,
+ Slot: BlockSidebarSlot,
+} = createSlotFill( 'EditWidgetsBlockSidebar' );
function Sidebar() {
return (
diff --git a/packages/edit-widgets/src/components/widget-area/index.js b/packages/edit-widgets/src/components/widget-area/index.js
index c30271526926b..b2b4e80126316 100644
--- a/packages/edit-widgets/src/components/widget-area/index.js
+++ b/packages/edit-widgets/src/components/widget-area/index.js
@@ -53,19 +53,30 @@ function WidgetArea( {
isSelectedArea,
onBlockSelected,
} ) {
- const { blocks, widgetAreaName, hasUploadPermissions, rawContent } = useSelect(
+ const {
+ blocks,
+ widgetAreaName,
+ hasUploadPermissions,
+ rawContent,
+ } = useSelect(
( select ) => {
- const {
- canUser,
- getEditedEntityRecord,
- } = select( 'core' );
- const widgetArea = getEditedEntityRecord( 'root', 'widgetArea', id );
+ const { canUser, getEditedEntityRecord } = select( 'core' );
+ const widgetArea = getEditedEntityRecord(
+ 'root',
+ 'widgetArea',
+ id
+ );
const widgetAreaContent = get( widgetArea, [ 'content' ], '' );
return {
blocks: widgetArea && widgetArea.blocks,
- rawContent: widgetAreaContent.raw ? widgetAreaContent.raw : widgetAreaContent,
+ rawContent: widgetAreaContent.raw
+ ? widgetAreaContent.raw
+ : widgetAreaContent,
widgetAreaName: widgetArea && widgetArea.name,
- hasUploadPermissions: defaultTo( canUser( 'create', 'media' ), true ),
+ hasUploadPermissions: defaultTo(
+ canUser( 'create', 'media' ),
+ true
+ ),
};
},
[ id ]
@@ -87,24 +98,19 @@ function WidgetArea( {
[ editEntityRecord, id ]
);
const settings = useMemo(
- () => getBlockEditorSettings( blockEditorSettings, hasUploadPermissions ),
+ () =>
+ getBlockEditorSettings( blockEditorSettings, hasUploadPermissions ),
[ blockEditorSettings, hasUploadPermissions ]
);
- useEffect(
- () => {
- if ( blocks ) {
- return;
- }
- onChange( parse( rawContent ) );
- },
- [ blocks, onChange, rawContent ]
- );
+ useEffect( () => {
+ if ( blocks ) {
+ return;
+ }
+ onChange( parse( rawContent ) );
+ }, [ blocks, onChange, rawContent ] );
return (
-
+
{
// Stop propagation of the focus event to avoid the parent
@@ -132,7 +138,9 @@ function WidgetArea( {
onBlockSelected={ onBlockSelected }
/>
-
+
diff --git a/packages/edit-widgets/src/components/widget-area/style.scss b/packages/edit-widgets/src/components/widget-area/style.scss
index 1b5a3b4f9a316..f7a6d9c3c9d15 100644
--- a/packages/edit-widgets/src/components/widget-area/style.scss
+++ b/packages/edit-widgets/src/components/widget-area/style.scss
@@ -18,7 +18,7 @@
padding-top: $grid-size-xlarge;
}
-.edit-widgets-main-block-list > .block-list-appender {
+.edit-widgets-main-block-list > div > .block-list-appender {
padding-top: $panel-padding;
position: relative;
}
diff --git a/packages/edit-widgets/src/components/widget-areas/index.js b/packages/edit-widgets/src/components/widget-areas/index.js
index 89d19501618b9..b1171e10ac3d8 100644
--- a/packages/edit-widgets/src/components/widget-areas/index.js
+++ b/packages/edit-widgets/src/components/widget-areas/index.js
@@ -11,7 +11,12 @@ import WidgetArea from '../widget-area';
const EMPTY_ARRAY = [];
-function WidgetAreas( { areas, blockEditorSettings, selectedArea, setSelectedArea } ) {
+function WidgetAreas( {
+ areas,
+ blockEditorSettings,
+ selectedArea,
+ setSelectedArea,
+} ) {
return areas.map( ( { id }, index ) => (
,
+ ,
document.getElementById( id )
);
}
@@ -43,9 +44,7 @@ export function customizerInitialize( id, settings ) {
__experimentalRegisterExperimentalCoreBlocks( settings );
}
render(
- ,
+ ,
document.getElementById( id )
);
}
diff --git a/packages/editor/package.json b/packages/editor/package.json
index dc56e097afb33..25b93d197d6ea 100644
--- a/packages/editor/package.json
+++ b/packages/editor/package.json
@@ -21,7 +21,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
- "@babel/runtime": "^7.4.4",
+ "@babel/runtime": "^7.8.3",
"@wordpress/api-fetch": "file:../api-fetch",
"@wordpress/autop": "file:../autop",
"@wordpress/blob": "file:../blob",
@@ -39,6 +39,7 @@
"@wordpress/hooks": "file:../hooks",
"@wordpress/html-entities": "file:../html-entities",
"@wordpress/i18n": "file:../i18n",
+ "@wordpress/icons": "file:../icons",
"@wordpress/is-shallow-equal": "file:../is-shallow-equal",
"@wordpress/keyboard-shortcuts": "file:../keyboard-shortcuts",
"@wordpress/keycodes": "file:../keycodes",
diff --git a/packages/editor/src/components/autocompleters/block.js b/packages/editor/src/components/autocompleters/block.js
index 73ff5583873fa..d4fb7507477d0 100644
--- a/packages/editor/src/components/autocompleters/block.js
+++ b/packages/editor/src/components/autocompleters/block.js
@@ -45,7 +45,9 @@ function defaultGetInserterItems( rootClientId ) {
* block is selected.
*/
function defaultGetSelectedBlockName() {
- const { getSelectedBlockClientId, getBlockName } = select( 'core/block-editor' );
+ const { getSelectedBlockClientId, getBlockName } = select(
+ 'core/block-editor'
+ );
const selectedBlockClientId = getSelectedBlockClientId();
return selectedBlockClientId ? getBlockName( selectedBlockClientId ) : null;
}
@@ -99,10 +101,7 @@ export function createBlockCompleter( {
},
getOptionLabel( inserterItem ) {
const { icon, title } = inserterItem;
- return [
- ,
- title,
- ];
+ return [ , title ];
},
allowContext( before, after ) {
return ! ( /\S/.test( before ) || /\S/.test( after ) );
diff --git a/packages/editor/src/components/autocompleters/style.scss b/packages/editor/src/components/autocompleters/style.scss
index 48a6e1fb299ec..c48cc9f05d14a 100644
--- a/packages/editor/src/components/autocompleters/style.scss
+++ b/packages/editor/src/components/autocompleters/style.scss
@@ -5,6 +5,14 @@
}
.editor-autocompleters__user {
+ .editor-autocompleters__no-avatar::before {
+ /* stylelint-disable */
+ font: normal 20px/1 dashicons;
+ /* stylelint-enable */
+ content: "\f110";
+ margin-right: 5px;
+ vertical-align: middle;
+ }
.editor-autocompleters__user-avatar {
margin-right: 8px;
flex-grow: 0;
diff --git a/packages/editor/src/components/autocompleters/test/block.js b/packages/editor/src/components/autocompleters/test/block.js
index 71582b3e33ba8..87534d69d159d 100644
--- a/packages/editor/src/components/autocompleters/test/block.js
+++ b/packages/editor/src/components/autocompleters/test/block.js
@@ -31,7 +31,9 @@ describe( 'block', () => {
it( 'should retrieve block options for current insertion point', async () => {
const expectedOptions = [ {}, {}, {} ];
- const mockGetBlockInsertionParentClientId = jest.fn( () => 'expected-insertion-point' );
+ const mockGetBlockInsertionParentClientId = jest.fn(
+ () => 'expected-insertion-point'
+ );
const mockGetInserterItems = jest.fn( () => expectedOptions );
const completer = createBlockCompleter( {
@@ -42,7 +44,9 @@ describe( 'block', () => {
const actualOptions = completer.options();
expect( mockGetBlockInsertionParentClientId ).toHaveBeenCalled();
- expect( mockGetInserterItems ).toHaveBeenCalledWith( 'expected-insertion-point' );
+ expect( mockGetInserterItems ).toHaveBeenCalledWith(
+ 'expected-insertion-point'
+ );
expect( actualOptions ).toEqual( expectedOptions );
} );
@@ -53,7 +57,11 @@ describe( 'block', () => {
const completer = createBlockCompleter( {
getBlockInsertionParentClientId: () => 'ignored',
- getInserterItems: () => [ option1, option2CurrentlySelected, option3 ],
+ getInserterItems: () => [
+ option1,
+ option2CurrentlySelected,
+ option3,
+ ],
getSelectedBlockName: () => 'block-2-currently-selected',
} );
@@ -81,25 +89,36 @@ describe( 'block', () => {
// Intentionally omitted keyword list
};
- expect( blockCompleter.getOptionKeywords( inserterItemWithTitleAndKeywords ) )
- .toEqual( [ 'formatting', 'foo-keyword-1', 'foo-keyword-2', 'foo' ] );
- expect( blockCompleter.getOptionKeywords( inserterItemWithTitleAndEmptyKeywords ) )
- .toEqual( [ 'common', 'bar' ] );
- expect( blockCompleter.getOptionKeywords( inserterItemWithTitleAndUndefinedKeywords ) )
- .toEqual( [ 'widgets', 'baz' ] );
+ expect(
+ blockCompleter.getOptionKeywords( inserterItemWithTitleAndKeywords )
+ ).toEqual( [ 'formatting', 'foo-keyword-1', 'foo-keyword-2', 'foo' ] );
+ expect(
+ blockCompleter.getOptionKeywords(
+ inserterItemWithTitleAndEmptyKeywords
+ )
+ ).toEqual( [ 'common', 'bar' ] );
+ expect(
+ blockCompleter.getOptionKeywords(
+ inserterItemWithTitleAndUndefinedKeywords
+ )
+ ).toEqual( [ 'widgets', 'baz' ] );
} );
it( 'should render a block option label', () => {
- const labelComponents = shallow(
- { blockCompleter.getOptionLabel( {
- icon: 'expected-icon',
- title: 'expected-text',
- } ) }
-
).children();
+ const labelComponents = shallow(
+
+ { blockCompleter.getOptionLabel( {
+ icon: 'expected-icon',
+ title: 'expected-text',
+ } ) }
+
+ ).children();
expect( labelComponents ).toHaveLength( 2 );
expect( labelComponents.at( 0 ).name() ).toBe( 'BlockIcon' );
- expect( labelComponents.at( 0 ).prop( 'icon' ) ).toEqual( 'expected-icon' );
+ expect( labelComponents.at( 0 ).prop( 'icon' ) ).toEqual(
+ 'expected-icon'
+ );
expect( labelComponents.at( 1 ).text() ).toBe( 'expected-text' );
} );
@@ -117,7 +136,11 @@ describe( 'block', () => {
isDisabled: false,
};
- expect( blockCompleter.isOptionDisabled( disabledInserterItem ) ).toBe( true );
- expect( blockCompleter.isOptionDisabled( enabledInserterItem ) ).toBe( false );
+ expect( blockCompleter.isOptionDisabled( disabledInserterItem ) ).toBe(
+ true
+ );
+ expect( blockCompleter.isOptionDisabled( enabledInserterItem ) ).toBe(
+ false
+ );
} );
} );
diff --git a/packages/editor/src/components/autocompleters/test/user.js b/packages/editor/src/components/autocompleters/test/user.js
new file mode 100644
index 0000000000000..f699ebfbfd202
--- /dev/null
+++ b/packages/editor/src/components/autocompleters/test/user.js
@@ -0,0 +1,55 @@
+/**
+ * Internal dependencies
+ */
+import userCompleter from '../user';
+
+describe( 'user', () => {
+ describe( 'getOptionLabel', () => {
+ it( 'should return user details fragment', () => {
+ const user = {
+ name: 'Smithers Jones',
+ slug: 'userSlug',
+ avatar_urls: { 24: 'http://my.avatar' },
+ };
+ const userLabel = userCompleter.getOptionLabel( user );
+ expect( userLabel[ 0 ] ).toEqual(
+
+ );
+ expect( userLabel[ 1 ] ).toEqual(
+
+ Smithers Jones
+
+ );
+ expect( userLabel[ 2 ] ).toEqual(
+
+ userSlug
+
+ );
+ } );
+ it( 'should return user details fragment without default avatar dashicon if avatar_urls array not set', () => {
+ const user = {
+ name: 'Smithers Jones',
+ slug: 'userSlug',
+ };
+ const userLabel = userCompleter.getOptionLabel( user );
+ expect( userLabel[ 0 ] ).toEqual(
+
+ );
+ expect( userLabel[ 1 ] ).toEqual(
+
+ Smithers Jones
+
+ );
+ expect( userLabel[ 2 ] ).toEqual(
+
+ userSlug
+
+ );
+ } );
+ } );
+} );
diff --git a/packages/editor/src/components/autocompleters/user.js b/packages/editor/src/components/autocompleters/user.js
index 45eecce3b8e4d..4b8c1f2dbcf37 100644
--- a/packages/editor/src/components/autocompleters/user.js
+++ b/packages/editor/src/components/autocompleters/user.js
@@ -26,10 +26,26 @@ export default {
return [ user.slug, user.name ];
},
getOptionLabel( user ) {
+ const avatar =
+ user.avatar_urls && user.avatar_urls[ 24 ] ? (
+
+ ) : (
+
+ );
+
return [
- ,
- { user.name } ,
- { user.slug } ,
+ avatar,
+
+ { user.name }
+ ,
+
+ { user.slug }
+ ,
];
},
getOptionCompletion( user ) {
diff --git a/packages/editor/src/components/autosave-monitor/index.js b/packages/editor/src/components/autosave-monitor/index.js
index e46ee8e3c20b7..1cc03a6e39ecb 100644
--- a/packages/editor/src/components/autosave-monitor/index.js
+++ b/packages/editor/src/components/autosave-monitor/index.js
@@ -7,7 +7,12 @@ import { withSelect, withDispatch } from '@wordpress/data';
export class AutosaveMonitor extends Component {
componentDidUpdate( prevProps ) {
- const { isDirty, editsReference, isAutosaveable, isAutosaving } = this.props;
+ const {
+ isDirty,
+ editsReference,
+ isAutosaveable,
+ isAutosaving,
+ } = this.props;
// The edits reference is held for comparison to avoid scheduling an
// autosave if an edit has not been made since the last autosave
@@ -30,9 +35,7 @@ export class AutosaveMonitor extends Component {
prevProps.editsReference !== editsReference
) {
this.toggleTimer(
- isDirty &&
- isAutosaveable &&
- ! this.didAutosaveForEditsReference
+ isDirty && isAutosaveable && ! this.didAutosaveForEditsReference
);
}
}
@@ -55,13 +58,10 @@ export class AutosaveMonitor extends Component {
}
if ( isPendingSave && ! ( shouldThrottle && this.pendingSave ) ) {
- this.pendingSave = setTimeout(
- () => {
- this.props.autosave();
- delete this.pendingSave;
- },
- interval * 1000
- );
+ this.pendingSave = setTimeout( () => {
+ this.props.autosave();
+ delete this.pendingSave;
+ }, interval * 1000 );
}
}
@@ -72,9 +72,7 @@ export class AutosaveMonitor extends Component {
export default compose( [
withSelect( ( select, ownProps ) => {
- const {
- getReferenceByDistinctEdits,
- } = select( 'core' );
+ const { getReferenceByDistinctEdits } = select( 'core' );
const {
isEditedPostDirty,
diff --git a/packages/editor/src/components/autosave-monitor/test/index.js b/packages/editor/src/components/autosave-monitor/test/index.js
index efba08ed31d14..68c177171f161 100644
--- a/packages/editor/src/components/autosave-monitor/test/index.js
+++ b/packages/editor/src/components/autosave-monitor/test/index.js
@@ -13,10 +13,9 @@ describe( 'AutosaveMonitor', () => {
let wrapper;
beforeEach( () => {
toggleTimer.mockClear();
- wrapper = shallow(
- ,
- { lifecycleExperimental: true }
- );
+ wrapper = shallow( , {
+ lifecycleExperimental: true,
+ } );
wrapper.instance().toggleTimer = toggleTimer;
} );
@@ -93,14 +92,29 @@ describe( 'AutosaveMonitor', () => {
const afterReference = [];
// A post is non-dirty while autosave is in-flight.
- wrapper.setProps( { isDirty: false, isAutosaving: true, isAutosaveable: true, editsReference: beforeReference } );
+ wrapper.setProps( {
+ isDirty: false,
+ isAutosaving: true,
+ isAutosaveable: true,
+ editsReference: beforeReference,
+ } );
toggleTimer.mockClear();
- wrapper.setProps( { isDirty: true, isAutosaving: false, isAutosaveable: true, editsReference: beforeReference } );
+ wrapper.setProps( {
+ isDirty: true,
+ isAutosaving: false,
+ isAutosaveable: true,
+ editsReference: beforeReference,
+ } );
expect( toggleTimer ).toHaveBeenCalledWith( false );
// Once edit occurs after autosave, resume scheduling.
- wrapper.setProps( { isDirty: true, isAutosaving: false, isAutosaveable: true, editsReference: afterReference } );
+ wrapper.setProps( {
+ isDirty: true,
+ isAutosaving: false,
+ isAutosaveable: true,
+ editsReference: afterReference,
+ } );
expect( toggleTimer.mock.calls[ 1 ][ 0 ] ).toBe( true );
} );
diff --git a/packages/editor/src/components/convert-to-group-buttons/convert-button.js b/packages/editor/src/components/convert-to-group-buttons/convert-button.js
index 9932449e30ae9..8c4734b40f1f9 100644
--- a/packages/editor/src/components/convert-to-group-buttons/convert-button.js
+++ b/packages/editor/src/components/convert-to-group-buttons/convert-button.js
@@ -27,21 +27,16 @@ export function ConvertToGroupButton( {
return (
{ isGroupable && (
-
+
{ _x( 'Group', 'verb' ) }
) }
{ isUngroupable && (
-
- { _x( 'Ungroup', 'Ungrouping blocks from within a Group block back into individual blocks within the Editor ' ) }
+
+ { _x(
+ 'Ungroup',
+ 'Ungrouping blocks from within a Group block back into individual blocks within the Editor '
+ ) }
) }
@@ -56,35 +51,40 @@ export default compose( [
canInsertBlockType,
} = select( 'core/block-editor' );
- const {
- getGroupingBlockName,
- } = select( 'core/blocks' );
+ const { getGroupingBlockName } = select( 'core/blocks' );
const groupingBlockName = getGroupingBlockName();
- const rootClientId = clientIds && clientIds.length > 0 ?
- getBlockRootClientId( clientIds[ 0 ] ) :
- undefined;
+ const rootClientId =
+ clientIds && clientIds.length > 0
+ ? getBlockRootClientId( clientIds[ 0 ] )
+ : undefined;
- const groupingBlockAvailable = canInsertBlockType( groupingBlockName, rootClientId );
+ const groupingBlockAvailable = canInsertBlockType(
+ groupingBlockName,
+ rootClientId
+ );
const blocksSelection = getBlocksByClientId( clientIds );
- const isSingleGroupingBlock = blocksSelection.length === 1 && blocksSelection[ 0 ] && blocksSelection[ 0 ].name === groupingBlockName;
+ const isSingleGroupingBlock =
+ blocksSelection.length === 1 &&
+ blocksSelection[ 0 ] &&
+ blocksSelection[ 0 ].name === groupingBlockName;
// Do we have
// 1. Grouping block available to be inserted?
// 2. One or more blocks selected
// (we allow single Blocks to become groups unless
// they are a soltiary group block themselves)
- const isGroupable = (
+ const isGroupable =
groupingBlockAvailable &&
blocksSelection.length &&
- ! isSingleGroupingBlock
- );
+ ! isSingleGroupingBlock;
// Do we have a single Group Block selected and does that group have inner blocks?
- const isUngroupable = isSingleGroupingBlock && !! blocksSelection[ 0 ].innerBlocks.length;
+ const isUngroupable =
+ isSingleGroupingBlock && !! blocksSelection[ 0 ].innerBlocks.length;
return {
isGroupable,
@@ -93,47 +93,52 @@ export default compose( [
groupingBlockName,
};
} ),
- withDispatch( ( dispatch, { clientIds, onToggle = noop, blocksSelection = [], groupingBlockName } ) => {
- const {
- replaceBlocks,
- } = dispatch( 'core/block-editor' );
-
- return {
- onConvertToGroup() {
- if ( ! blocksSelection.length ) {
- return;
- }
-
- // Activate the `transform` on the Grouping Block which does the conversion
- const newBlocks = switchToBlockType( blocksSelection, groupingBlockName );
-
- if ( newBlocks ) {
- replaceBlocks(
- clientIds,
- newBlocks
+ withDispatch(
+ (
+ dispatch,
+ {
+ clientIds,
+ onToggle = noop,
+ blocksSelection = [],
+ groupingBlockName,
+ }
+ ) => {
+ const { replaceBlocks } = dispatch( 'core/block-editor' );
+
+ return {
+ onConvertToGroup() {
+ if ( ! blocksSelection.length ) {
+ return;
+ }
+
+ // Activate the `transform` on the Grouping Block which does the conversion
+ const newBlocks = switchToBlockType(
+ blocksSelection,
+ groupingBlockName
);
- }
- onToggle();
- },
- onConvertFromGroup() {
- if ( ! blocksSelection.length ) {
- return;
- }
+ if ( newBlocks ) {
+ replaceBlocks( clientIds, newBlocks );
+ }
- const innerBlocks = blocksSelection[ 0 ].innerBlocks;
+ onToggle();
+ },
+ onConvertFromGroup() {
+ if ( ! blocksSelection.length ) {
+ return;
+ }
- if ( ! innerBlocks.length ) {
- return;
- }
+ const innerBlocks = blocksSelection[ 0 ].innerBlocks;
- replaceBlocks(
- clientIds,
- innerBlocks
- );
+ if ( ! innerBlocks.length ) {
+ return;
+ }
- onToggle();
- },
- };
- } ),
+ replaceBlocks( clientIds, innerBlocks );
+
+ onToggle();
+ },
+ };
+ }
+ ),
] )( ConvertToGroupButton );
diff --git a/packages/editor/src/components/convert-to-group-buttons/icons.js b/packages/editor/src/components/convert-to-group-buttons/icons.js
index 990d15dd5ac1c..321dac7a82805 100644
--- a/packages/editor/src/components/convert-to-group-buttons/icons.js
+++ b/packages/editor/src/components/convert-to-group-buttons/icons.js
@@ -3,11 +3,46 @@
*/
import { Icon, SVG, Path } from '@wordpress/components';
-const GroupSVG = ;
+const GroupSVG = (
+
+
+
+
+);
export const Group = ;
-const UngroupSVG = ;
+const UngroupSVG = (
+
+
+
+
+);
export const Ungroup = ;
-
diff --git a/packages/editor/src/components/convert-to-group-buttons/index.native.js b/packages/editor/src/components/convert-to-group-buttons/index.native.js
index bd0c2f440d06f..461f67a0a4bcb 100644
--- a/packages/editor/src/components/convert-to-group-buttons/index.native.js
+++ b/packages/editor/src/components/convert-to-group-buttons/index.native.js
@@ -1,2 +1 @@
-
export default () => null;
diff --git a/packages/editor/src/components/deprecated.js b/packages/editor/src/components/deprecated.js
index 022da5c4023fa..7fa2d89f35cad 100644
--- a/packages/editor/src/components/deprecated.js
+++ b/packages/editor/src/components/deprecated.js
@@ -69,7 +69,7 @@ function deprecateComponent( name, Wrapped, staticsToHoist = [] ) {
alternative: 'wp.blockEditor.' + name,
} );
- return ;
+ return ;
} );
staticsToHoist.forEach( ( staticName ) => {
@@ -93,60 +93,182 @@ function deprecateFunction( name, func ) {
}
const RichText = deprecateComponent( 'RichText', RootRichText, [ 'Content' ] );
-RichText.isEmpty = deprecateFunction( 'RichText.isEmpty', RootRichText.isEmpty );
+RichText.isEmpty = deprecateFunction(
+ 'RichText.isEmpty',
+ RootRichText.isEmpty
+);
export { RichText };
-export const Autocomplete = deprecateComponent( 'Autocomplete', RootAutocomplete );
-export const AlignmentToolbar = deprecateComponent( 'AlignmentToolbar', RootAlignmentToolbar );
-export const BlockAlignmentToolbar = deprecateComponent( 'BlockAlignmentToolbar', RootBlockAlignmentToolbar );
-export const BlockControls = deprecateComponent( 'BlockControls', RootBlockControls, [ 'Slot' ] );
+export const Autocomplete = deprecateComponent(
+ 'Autocomplete',
+ RootAutocomplete
+);
+export const AlignmentToolbar = deprecateComponent(
+ 'AlignmentToolbar',
+ RootAlignmentToolbar
+);
+export const BlockAlignmentToolbar = deprecateComponent(
+ 'BlockAlignmentToolbar',
+ RootBlockAlignmentToolbar
+);
+export const BlockControls = deprecateComponent(
+ 'BlockControls',
+ RootBlockControls,
+ [ 'Slot' ]
+);
export const BlockEdit = deprecateComponent( 'BlockEdit', RootBlockEdit );
-export const BlockEditorKeyboardShortcuts = deprecateComponent( 'BlockEditorKeyboardShortcuts', RootBlockEditorKeyboardShortcuts );
-export const BlockFormatControls = deprecateComponent( 'BlockFormatControls', RootBlockFormatControls, [ 'Slot' ] );
+export const BlockEditorKeyboardShortcuts = deprecateComponent(
+ 'BlockEditorKeyboardShortcuts',
+ RootBlockEditorKeyboardShortcuts
+);
+export const BlockFormatControls = deprecateComponent(
+ 'BlockFormatControls',
+ RootBlockFormatControls,
+ [ 'Slot' ]
+);
export const BlockIcon = deprecateComponent( 'BlockIcon', RootBlockIcon );
-export const BlockInspector = deprecateComponent( 'BlockInspector', RootBlockInspector );
+export const BlockInspector = deprecateComponent(
+ 'BlockInspector',
+ RootBlockInspector
+);
export const BlockList = deprecateComponent( 'BlockList', RootBlockList );
export const BlockMover = deprecateComponent( 'BlockMover', RootBlockMover );
-export const BlockNavigationDropdown = deprecateComponent( 'BlockNavigationDropdown', RootBlockNavigationDropdown );
-export const BlockSelectionClearer = deprecateComponent( 'BlockSelectionClearer', RootBlockSelectionClearer );
-export const BlockSettingsMenu = deprecateComponent( 'BlockSettingsMenu', RootBlockSettingsMenu );
+export const BlockNavigationDropdown = deprecateComponent(
+ 'BlockNavigationDropdown',
+ RootBlockNavigationDropdown
+);
+export const BlockSelectionClearer = deprecateComponent(
+ 'BlockSelectionClearer',
+ RootBlockSelectionClearer
+);
+export const BlockSettingsMenu = deprecateComponent(
+ 'BlockSettingsMenu',
+ RootBlockSettingsMenu
+);
export const BlockTitle = deprecateComponent( 'BlockTitle', RootBlockTitle );
-export const BlockToolbar = deprecateComponent( 'BlockToolbar', RootBlockToolbar );
-export const ColorPalette = deprecateComponent( 'ColorPalette', RootColorPalette );
-export const ContrastChecker = deprecateComponent( 'ContrastChecker', RootContrastChecker );
+export const BlockToolbar = deprecateComponent(
+ 'BlockToolbar',
+ RootBlockToolbar
+);
+export const ColorPalette = deprecateComponent(
+ 'ColorPalette',
+ RootColorPalette
+);
+export const ContrastChecker = deprecateComponent(
+ 'ContrastChecker',
+ RootContrastChecker
+);
export const CopyHandler = deprecateComponent( 'CopyHandler', RootCopyHandler );
-export const DefaultBlockAppender = deprecateComponent( 'DefaultBlockAppender', RootDefaultBlockAppender );
-export const FontSizePicker = deprecateComponent( 'FontSizePicker', RootFontSizePicker );
+export const DefaultBlockAppender = deprecateComponent(
+ 'DefaultBlockAppender',
+ RootDefaultBlockAppender
+);
+export const FontSizePicker = deprecateComponent(
+ 'FontSizePicker',
+ RootFontSizePicker
+);
export const Inserter = deprecateComponent( 'Inserter', RootInserter );
-export const InnerBlocks = deprecateComponent( 'InnerBlocks', RootInnerBlocks, [ 'ButtonBlockAppender', 'DefaultBlockAppender', 'Content' ] );
-export const InspectorAdvancedControls = deprecateComponent( 'InspectorAdvancedControls', RootInspectorAdvancedControls, [ 'Slot' ] );
-export const InspectorControls = deprecateComponent( 'InspectorControls', RootInspectorControls, [ 'Slot' ] );
-export const PanelColorSettings = deprecateComponent( 'PanelColorSettings', RootPanelColorSettings );
+export const InnerBlocks = deprecateComponent( 'InnerBlocks', RootInnerBlocks, [
+ 'ButtonBlockAppender',
+ 'DefaultBlockAppender',
+ 'Content',
+] );
+export const InspectorAdvancedControls = deprecateComponent(
+ 'InspectorAdvancedControls',
+ RootInspectorAdvancedControls,
+ [ 'Slot' ]
+);
+export const InspectorControls = deprecateComponent(
+ 'InspectorControls',
+ RootInspectorControls,
+ [ 'Slot' ]
+);
+export const PanelColorSettings = deprecateComponent(
+ 'PanelColorSettings',
+ RootPanelColorSettings
+);
export const PlainText = deprecateComponent( 'PlainText', RootPlainText );
-export const RichTextShortcut = deprecateComponent( 'RichTextShortcut', RootRichTextShortcut );
-export const RichTextToolbarButton = deprecateComponent( 'RichTextToolbarButton', RootRichTextToolbarButton );
-export const __unstableRichTextInputEvent = deprecateComponent( '__unstableRichTextInputEvent', __unstableRootRichTextInputEvent );
-export const MediaPlaceholder = deprecateComponent( 'MediaPlaceholder', RootMediaPlaceholder );
+export const RichTextShortcut = deprecateComponent(
+ 'RichTextShortcut',
+ RootRichTextShortcut
+);
+export const RichTextToolbarButton = deprecateComponent(
+ 'RichTextToolbarButton',
+ RootRichTextToolbarButton
+);
+export const __unstableRichTextInputEvent = deprecateComponent(
+ '__unstableRichTextInputEvent',
+ __unstableRootRichTextInputEvent
+);
+export const MediaPlaceholder = deprecateComponent(
+ 'MediaPlaceholder',
+ RootMediaPlaceholder
+);
export const MediaUpload = deprecateComponent( 'MediaUpload', RootMediaUpload );
-export const MediaUploadCheck = deprecateComponent( 'MediaUploadCheck', RootMediaUploadCheck );
-export const MultiBlocksSwitcher = deprecateComponent( 'MultiBlocksSwitcher', RootMultiBlocksSwitcher );
-export const MultiSelectScrollIntoView = deprecateComponent( 'MultiSelectScrollIntoView', RootMultiSelectScrollIntoView );
-export const NavigableToolbar = deprecateComponent( 'NavigableToolbar', RootNavigableToolbar );
-export const ObserveTyping = deprecateComponent( 'ObserveTyping', RootObserveTyping );
-export const PreserveScrollInReorder = deprecateComponent( 'PreserveScrollInReorder', RootPreserveScrollInReorder );
-export const SkipToSelectedBlock = deprecateComponent( 'SkipToSelectedBlock', RootSkipToSelectedBlock );
+export const MediaUploadCheck = deprecateComponent(
+ 'MediaUploadCheck',
+ RootMediaUploadCheck
+);
+export const MultiBlocksSwitcher = deprecateComponent(
+ 'MultiBlocksSwitcher',
+ RootMultiBlocksSwitcher
+);
+export const MultiSelectScrollIntoView = deprecateComponent(
+ 'MultiSelectScrollIntoView',
+ RootMultiSelectScrollIntoView
+);
+export const NavigableToolbar = deprecateComponent(
+ 'NavigableToolbar',
+ RootNavigableToolbar
+);
+export const ObserveTyping = deprecateComponent(
+ 'ObserveTyping',
+ RootObserveTyping
+);
+export const PreserveScrollInReorder = deprecateComponent(
+ 'PreserveScrollInReorder',
+ RootPreserveScrollInReorder
+);
+export const SkipToSelectedBlock = deprecateComponent(
+ 'SkipToSelectedBlock',
+ RootSkipToSelectedBlock
+);
export const URLInput = deprecateComponent( 'URLInput', RootURLInput );
-export const URLInputButton = deprecateComponent( 'URLInputButton', RootURLInputButton );
+export const URLInputButton = deprecateComponent(
+ 'URLInputButton',
+ RootURLInputButton
+);
export const URLPopover = deprecateComponent( 'URLPopover', RootURLPopover );
export const Warning = deprecateComponent( 'Warning', RootWarning );
export const WritingFlow = deprecateComponent( 'WritingFlow', RootWritingFlow );
-export const createCustomColorsHOC = deprecateFunction( 'createCustomColorsHOC', rootCreateCustomColorsHOC );
-export const getColorClassName = deprecateFunction( 'getColorClassName', rootGetColorClassName );
-export const getColorObjectByAttributeValues = deprecateFunction( 'getColorObjectByAttributeValues', rootGetColorObjectByAttributeValues );
-export const getColorObjectByColorValue = deprecateFunction( 'getColorObjectByColorValue', rootGetColorObjectByColorValue );
+export const createCustomColorsHOC = deprecateFunction(
+ 'createCustomColorsHOC',
+ rootCreateCustomColorsHOC
+);
+export const getColorClassName = deprecateFunction(
+ 'getColorClassName',
+ rootGetColorClassName
+);
+export const getColorObjectByAttributeValues = deprecateFunction(
+ 'getColorObjectByAttributeValues',
+ rootGetColorObjectByAttributeValues
+);
+export const getColorObjectByColorValue = deprecateFunction(
+ 'getColorObjectByColorValue',
+ rootGetColorObjectByColorValue
+);
export const getFontSize = deprecateFunction( 'getFontSize', rootGetFontSize );
-export const getFontSizeClass = deprecateFunction( 'getFontSizeClass', rootGetFontSizeClass );
-export const withColorContext = deprecateFunction( 'withColorContext', rootWithColorContext );
+export const getFontSizeClass = deprecateFunction(
+ 'getFontSizeClass',
+ rootGetFontSizeClass
+);
+export const withColorContext = deprecateFunction(
+ 'withColorContext',
+ rootWithColorContext
+);
export const withColors = deprecateFunction( 'withColors', rootWithColors );
-export const withFontSizes = deprecateFunction( 'withFontSizes', rootWithFontSizes );
+export const withFontSizes = deprecateFunction(
+ 'withFontSizes',
+ rootWithFontSizes
+);
diff --git a/packages/editor/src/components/document-outline/check.js b/packages/editor/src/components/document-outline/check.js
index ccbf66c27d150..84d988b0a510f 100644
--- a/packages/editor/src/components/document-outline/check.js
+++ b/packages/editor/src/components/document-outline/check.js
@@ -9,7 +9,10 @@ import { filter } from 'lodash';
import { withSelect } from '@wordpress/data';
function DocumentOutlineCheck( { blocks, children } ) {
- const headings = filter( blocks, ( block ) => block.name === 'core/heading' );
+ const headings = filter(
+ blocks,
+ ( block ) => block.name === 'core/heading'
+ );
if ( headings.length < 1 ) {
return null;
diff --git a/packages/editor/src/components/document-outline/index.js b/packages/editor/src/components/document-outline/index.js
index 5a61503909a88..3609f51c42a63 100644
--- a/packages/editor/src/components/document-outline/index.js
+++ b/packages/editor/src/components/document-outline/index.js
@@ -9,10 +9,7 @@ import { countBy, flatMap, get } from 'lodash';
import { __ } from '@wordpress/i18n';
import { compose } from '@wordpress/compose';
import { withSelect } from '@wordpress/data';
-import {
- create,
- getTextContent,
-} from '@wordpress/rich-text';
+import { create, getTextContent } from '@wordpress/rich-text';
/**
* Internal dependencies
@@ -29,11 +26,15 @@ const incorrectLevelContent = [
];
const singleH1Headings = [
,
- { __( '(Your theme may already use a H1 for the post title)' ) } ,
+
+ { __( '(Your theme may already use a H1 for the post title)' ) }
+ ,
];
const multipleH1Headings = [
,
- { __( '(Multiple H1 headings are not recommended)' ) } ,
+
+ { __( '(Multiple H1 headings are not recommended)' ) }
+ ,
];
/**
@@ -62,9 +63,16 @@ const computeOutlineHeadings = ( blocks = [], path = [] ) => {
} );
};
-const isEmptyHeading = ( heading ) => ! heading.attributes.content || heading.attributes.content.length === 0;
+const isEmptyHeading = ( heading ) =>
+ ! heading.attributes.content || heading.attributes.content.length === 0;
-export const DocumentOutline = ( { blocks = [], title, onSelect, isTitleSupported, hasOutlineItemsDisabled } ) => {
+export const DocumentOutline = ( {
+ blocks = [],
+ title,
+ onSelect,
+ isTitleSupported,
+ hasOutlineItemsDisabled,
+} ) => {
const headings = computeOutlineHeadings( blocks );
if ( headings.length < 1 ) {
@@ -98,12 +106,12 @@ export const DocumentOutline = ( { blocks = [], title, onSelect, isTitleSupporte
// Otherwise there are missing levels.
const isIncorrectLevel = item.level > prevHeadingLevel + 1;
- const isValid = (
+ const isValid =
! item.isEmpty &&
! isIncorrectLevel &&
!! item.level &&
- ( item.level !== 1 || ( ! hasMultipleH1 && ! hasTitle ) )
- );
+ ( item.level !== 1 ||
+ ( ! hasMultipleH1 && ! hasTitle ) );
prevHeadingLevel = item.level;
return (
@@ -116,15 +124,21 @@ export const DocumentOutline = ( { blocks = [], title, onSelect, isTitleSupporte
href={ `#block-${ item.clientId }` }
onSelect={ onSelect }
>
- { item.isEmpty ?
- emptyHeadingContent :
- getTextContent(
- create( { html: item.attributes.content } )
- )
- }
+ { item.isEmpty
+ ? emptyHeadingContent
+ : getTextContent(
+ create( {
+ html: item.attributes.content,
+ } )
+ ) }
{ isIncorrectLevel && incorrectLevelContent }
- { item.level === 1 && hasMultipleH1 && multipleH1Headings }
- { hasTitle && item.level === 1 && ! hasMultipleH1 && singleH1Headings }
+ { item.level === 1 &&
+ hasMultipleH1 &&
+ multipleH1Headings }
+ { hasTitle &&
+ item.level === 1 &&
+ ! hasMultipleH1 &&
+ singleH1Headings }
);
} ) }
diff --git a/packages/editor/src/components/document-outline/item.js b/packages/editor/src/components/document-outline/item.js
index 1a92e7dbafc4e..efed6fd733faf 100644
--- a/packages/editor/src/components/document-outline/item.js
+++ b/packages/editor/src/components/document-outline/item.js
@@ -30,22 +30,19 @@ const TableOfContentsItem = ( {
className="document-outline__button"
onClick={ onSelect }
>
-
- {
- // path is an array of nodes that are ancestors of the heading starting in the top level node.
- // This mapping renders each ancestor to make it easier for the user to know where the headings are nested.
- path.map( ( { clientId }, index ) => (
-
-
-
- ) )
- }
-
- { level }
-
-
- { children }
-
+
+ { // path is an array of nodes that are ancestors of the heading starting in the top level node.
+ // This mapping renders each ancestor to make it easier for the user to know where the headings are nested.
+ path.map( ( { clientId }, index ) => (
+
+
+
+ ) ) }
+ { level }
+ { children }
);
diff --git a/packages/editor/src/components/document-outline/test/index.js b/packages/editor/src/components/document-outline/test/index.js
index 5ee66565d2dad..9277e7c4afd3a 100644
--- a/packages/editor/src/components/document-outline/test/index.js
+++ b/packages/editor/src/components/document-outline/test/index.js
@@ -6,7 +6,11 @@ import { mount, shallow } from 'enzyme';
/**
* WordPress dependencies
*/
-import { createBlock, registerBlockType, unregisterBlockType } from '@wordpress/blocks';
+import {
+ createBlock,
+ registerBlockType,
+ unregisterBlockType,
+} from '@wordpress/blocks';
/**
* Internal dependencies
@@ -23,8 +27,8 @@ describe( 'DocumentOutline', () => {
registerBlockType( 'core/heading', {
category: 'common',
title: 'Heading',
- edit: () => { },
- save: () => { },
+ edit: () => {},
+ save: () => {},
attributes: {
level: {
type: 'number',
@@ -39,14 +43,14 @@ describe( 'DocumentOutline', () => {
registerBlockType( 'core/paragraph', {
category: 'common',
title: 'Paragraph',
- edit: () => { },
+ edit: () => {},
save: () => {},
} );
registerBlockType( 'core/columns', {
category: 'common',
title: 'Paragraph',
- edit: () => { },
+ edit: () => {},
save: () => {},
} );
@@ -64,7 +68,9 @@ describe( 'DocumentOutline', () => {
level: 3,
} );
- nestedHeading = createBlock( 'core/columns', undefined, [ headingChild ] );
+ nestedHeading = createBlock( 'core/columns', undefined, [
+ headingChild,
+ ] );
} );
afterAll( () => {
@@ -92,10 +98,12 @@ describe( 'DocumentOutline', () => {
describe( 'header blocks present', () => {
it( 'should match snapshot', () => {
- const blocks = [ headingParent, headingChild ].map( ( block, index ) => {
- // Set client IDs to a predictable value.
- return { ...block, clientId: `clientId_${ index }` };
- } );
+ const blocks = [ headingParent, headingChild ].map(
+ ( block, index ) => {
+ // Set client IDs to a predictable value.
+ return { ...block, clientId: `clientId_${ index }` };
+ }
+ );
const wrapper = shallow( );
expect( wrapper ).toMatchSnapshot();
@@ -109,17 +117,25 @@ describe( 'DocumentOutline', () => {
} );
it( 'should render two items when two headings and some paragraphs provided', () => {
- const blocks = [ paragraph, headingParent, paragraph, headingChild, paragraph ];
+ const blocks = [
+ paragraph,
+ headingParent,
+ paragraph,
+ headingChild,
+ paragraph,
+ ];
const wrapper = shallow( );
expect( wrapper.find( 'TableOfContentsItem' ) ).toHaveLength( 2 );
} );
it( 'should render warnings for multiple h1 headings', () => {
- const blocks = [ headingH1, paragraph, headingH1, paragraph ].map( ( block, index ) => {
- // Set client IDs to a predictable value.
- return { ...block, clientId: `clientId_${ index }` };
- } );
+ const blocks = [ headingH1, paragraph, headingH1, paragraph ].map(
+ ( block, index ) => {
+ // Set client IDs to a predictable value.
+ return { ...block, clientId: `clientId_${ index }` };
+ }
+ );
const wrapper = shallow( );
expect( wrapper ).toMatchSnapshot();
@@ -130,27 +146,44 @@ describe( 'DocumentOutline', () => {
it( 'should render even if the heading is nested', () => {
const tableOfContentItemsSelector = 'TableOfContentsItem';
const outlineLevelsSelector = '.document-outline__level';
- const outlineItemContentSelector = '.document-outline__item-content';
+ const outlineItemContentSelector =
+ '.document-outline__item-content';
const blocks = [ headingParent, nestedHeading ];
const wrapper = mount( );
//heading parent and nested heading should appear as items
- const tableOfContentItems = wrapper.find( tableOfContentItemsSelector );
+ const tableOfContentItems = wrapper.find(
+ tableOfContentItemsSelector
+ );
expect( tableOfContentItems ).toHaveLength( 2 );
//heading parent test
- const firstItemLevels = tableOfContentItems.at( 0 ).find( outlineLevelsSelector );
+ const firstItemLevels = tableOfContentItems
+ .at( 0 )
+ .find( outlineLevelsSelector );
expect( firstItemLevels ).toHaveLength( 1 );
expect( firstItemLevels.at( 0 ).text() ).toEqual( 'H2' );
- expect( tableOfContentItems.at( 0 ).find( outlineItemContentSelector ).text() ).toEqual( 'Heading parent' );
+ expect(
+ tableOfContentItems
+ .at( 0 )
+ .find( outlineItemContentSelector )
+ .text()
+ ).toEqual( 'Heading parent' );
//nested heading test
- const secondItemLevels = tableOfContentItems.at( 1 ).find( outlineLevelsSelector );
+ const secondItemLevels = tableOfContentItems
+ .at( 1 )
+ .find( outlineLevelsSelector );
expect( secondItemLevels ).toHaveLength( 2 );
expect( secondItemLevels.at( 0 ).text() ).toEqual( 'Block Title' );
expect( secondItemLevels.at( 1 ).text() ).toEqual( 'H3' );
- expect( tableOfContentItems.at( 1 ).find( outlineItemContentSelector ).text() ).toEqual( 'Heading child' );
+ expect(
+ tableOfContentItems
+ .at( 1 )
+ .find( outlineItemContentSelector )
+ .text()
+ ).toEqual( 'Heading child' );
} );
} );
} );
diff --git a/packages/editor/src/components/entities-saved-states/index.js b/packages/editor/src/components/entities-saved-states/index.js
index 3c8d770d8d106..621a8e9a03758 100644
--- a/packages/editor/src/components/entities-saved-states/index.js
+++ b/packages/editor/src/components/entities-saved-states/index.js
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
-import { startCase } from 'lodash';
import EquivalentKeyMap from 'equivalent-key-map';
/**
@@ -20,8 +19,9 @@ const EntitiesSavedStatesCheckbox = ( {
setCheckedById,
} ) => (
setCheckedById( id, nextChecked ) }
@@ -38,7 +38,9 @@ export default function EntitiesSavedStates( {
);
const { saveEditedEntityRecord } = useDispatch( 'core' );
- const [ checkedById, _setCheckedById ] = useState( () => new EquivalentKeyMap() );
+ const [ checkedById, _setCheckedById ] = useState(
+ () => new EquivalentKeyMap()
+ );
const setCheckedById = ( id, checked ) =>
_setCheckedById( ( prevCheckedById ) => {
const nextCheckedById = new EquivalentKeyMap( prevCheckedById );
@@ -53,7 +55,9 @@ export default function EntitiesSavedStates( {
checkedById.forEach( ( _checked, id ) => {
if ( ! ignoredForSave.has( id ) ) {
saveEditedEntityRecord(
- ...id.filter( ( s, i ) => i !== id.length - 1 || s !== 'undefined' )
+ ...id.filter(
+ ( s, i ) => i !== id.length - 1 || s !== 'undefined'
+ )
);
}
} );
@@ -66,29 +70,37 @@ export default function EntitiesSavedStates( {
onRequestClose={ () => onRequestClose() }
contentLabel={ __( 'Select items to save.' ) }
>
- { Object.keys( entityRecordChangesByRecord ).map( ( changedKind ) =>
- Object.keys( entityRecordChangesByRecord[ changedKind ] ).map(
- ( changedName ) =>
+ { Object.keys( entityRecordChangesByRecord ).map(
+ ( changedKind ) =>
+ Object.keys(
+ entityRecordChangesByRecord[ changedKind ]
+ ).map( ( changedName ) =>
Object.keys(
- entityRecordChangesByRecord[ changedKind ][ changedName ]
+ entityRecordChangesByRecord[ changedKind ][
+ changedName
+ ]
).map( ( changedKey ) => {
- const id = [ changedKind, changedName, changedKey ];
+ const id = [
+ changedKind,
+ changedName,
+ changedKey,
+ ];
return (
);
} )
- )
+ )
) }
{ __( 'Attempt Recovery' ) }
,
-
+
{ __( 'Copy Post Text' ) }
,
-
+
{ __( 'Copy Error' ) }
,
] }
diff --git a/packages/editor/src/components/global-keyboard-shortcuts/save-shortcut.js b/packages/editor/src/components/global-keyboard-shortcuts/save-shortcut.js
index 64cd864f81ddc..7b96aab26abfb 100644
--- a/packages/editor/src/components/global-keyboard-shortcuts/save-shortcut.js
+++ b/packages/editor/src/components/global-keyboard-shortcuts/save-shortcut.js
@@ -6,22 +6,29 @@ import { useDispatch, useSelect } from '@wordpress/data';
function SaveShortcut() {
const { savePost } = useDispatch( 'core/editor' );
- const isEditedPostDirty = useSelect( ( select ) => select( 'core/editor' ).isEditedPostDirty, [] );
+ const isEditedPostDirty = useSelect(
+ ( select ) => select( 'core/editor' ).isEditedPostDirty,
+ []
+ );
- useShortcut( 'core/editor/save', ( event ) => {
- event.preventDefault();
+ useShortcut(
+ 'core/editor/save',
+ ( event ) => {
+ event.preventDefault();
- // TODO: This should be handled in the `savePost` effect in
- // considering `isSaveable`. See note on `isEditedPostSaveable`
- // selector about dirtiness and meta-boxes.
- //
- // See: `isEditedPostSaveable`
- if ( ! isEditedPostDirty() ) {
- return;
- }
+ // TODO: This should be handled in the `savePost` effect in
+ // considering `isSaveable`. See note on `isEditedPostSaveable`
+ // selector about dirtiness and meta-boxes.
+ //
+ // See: `isEditedPostSaveable`
+ if ( ! isEditedPostDirty() ) {
+ return;
+ }
- savePost();
- }, { bindGlobal: true } );
+ savePost();
+ },
+ { bindGlobal: true }
+ );
return null;
}
diff --git a/packages/editor/src/components/global-keyboard-shortcuts/text-editor-shortcuts.js b/packages/editor/src/components/global-keyboard-shortcuts/text-editor-shortcuts.js
index 2d2d0510fd316..21f76daec567f 100644
--- a/packages/editor/src/components/global-keyboard-shortcuts/text-editor-shortcuts.js
+++ b/packages/editor/src/components/global-keyboard-shortcuts/text-editor-shortcuts.js
@@ -4,7 +4,5 @@
import SaveShortcut from './save-shortcut';
export default function TextEditorGlobalKeyboardShortcuts() {
- return (
-
- );
+ return ;
}
diff --git a/packages/editor/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js b/packages/editor/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js
index d94a7dc4ebbd9..6ca37c90f0fec 100644
--- a/packages/editor/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js
+++ b/packages/editor/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js
@@ -13,32 +13,47 @@ import SaveShortcut from './save-shortcut';
function VisualEditorGlobalKeyboardShortcuts() {
const { redo, undo, savePost } = useDispatch( 'core/editor' );
- const isEditedPostDirty = useSelect( ( select ) => select( 'core/editor' ).isEditedPostDirty, [] );
-
- useShortcut( 'core/editor/undo', ( event ) => {
- undo();
- event.preventDefault();
- }, { bindGlobal: true } );
-
- useShortcut( 'core/editor/redo', ( event ) => {
- redo();
- event.preventDefault();
- }, { bindGlobal: true } );
-
- useShortcut( 'core/editor/save', ( event ) => {
- event.preventDefault();
-
- // TODO: This should be handled in the `savePost` effect in
- // considering `isSaveable`. See note on `isEditedPostSaveable`
- // selector about dirtiness and meta-boxes.
- //
- // See: `isEditedPostSaveable`
- if ( ! isEditedPostDirty() ) {
- return;
- }
-
- savePost();
- }, { bindGlobal: true } );
+ const isEditedPostDirty = useSelect(
+ ( select ) => select( 'core/editor' ).isEditedPostDirty,
+ []
+ );
+
+ useShortcut(
+ 'core/editor/undo',
+ ( event ) => {
+ undo();
+ event.preventDefault();
+ },
+ { bindGlobal: true }
+ );
+
+ useShortcut(
+ 'core/editor/redo',
+ ( event ) => {
+ redo();
+ event.preventDefault();
+ },
+ { bindGlobal: true }
+ );
+
+ useShortcut(
+ 'core/editor/save',
+ ( event ) => {
+ event.preventDefault();
+
+ // TODO: This should be handled in the `savePost` effect in
+ // considering `isSaveable`. See note on `isEditedPostSaveable`
+ // selector about dirtiness and meta-boxes.
+ //
+ // See: `isEditedPostSaveable`
+ if ( ! isEditedPostDirty() ) {
+ return;
+ }
+
+ savePost();
+ },
+ { bindGlobal: true }
+ );
return (
<>
diff --git a/packages/editor/src/components/index.native.js b/packages/editor/src/components/index.native.js
index 45156604efe6f..1c916b4e82c0e 100644
--- a/packages/editor/src/components/index.native.js
+++ b/packages/editor/src/components/index.native.js
@@ -1,4 +1,3 @@
-
// Post Related Components
export { default as AutosaveMonitor } from './autosave-monitor';
export { default as PostTitle } from './post-title';
diff --git a/packages/editor/src/components/local-autosave-monitor/README.md b/packages/editor/src/components/local-autosave-monitor/README.md
new file mode 100644
index 0000000000000..11586c04d656a
--- /dev/null
+++ b/packages/editor/src/components/local-autosave-monitor/README.md
@@ -0,0 +1,20 @@
+# LocalAutosaveMonitor
+
+`LocalAutosaveMonitor` is a component based on `AutosaveMonitor` that ensures that a local copy of the current post is regularly saved in `sessionStorage`. Additionally, it will:
+
+- attempt to clear the local copy if a copy is successful saved on the server;
+- warn the user upon loading a post that there is a local copy that can be loaded;
+- defer to remote autosaves, if any is available.
+
+`LocalAutosaveMonitor` observes a saving interval defined specifically for local autosaves, in contrast with remote (server-side) autosaving. See editor setting `__experimentalLocalAutosaveInterval` and setter `__experimentalUpdateLocalAutosaveInterval`.
+
+## Example
+
+```js
+const MyLayout = () => (
+
+
+
+
+);
+```
diff --git a/packages/editor/src/components/local-autosave-monitor/index.js b/packages/editor/src/components/local-autosave-monitor/index.js
index 3f48bc57de5e3..5dd800530f3b4 100644
--- a/packages/editor/src/components/local-autosave-monitor/index.js
+++ b/packages/editor/src/components/local-autosave-monitor/index.js
@@ -16,12 +16,11 @@ import { parse } from '@wordpress/blocks';
* Internal dependencies
*/
import AutosaveMonitor from '../autosave-monitor';
-import {
- localAutosaveGet,
- localAutosaveClear,
-} from '../../store/controls';
+import { localAutosaveGet, localAutosaveClear } from '../../store/controls';
-const requestIdleCallback = window.requestIdleCallback ? window.requestIdleCallback : window.requestAnimationFrame;
+const requestIdleCallback = window.requestIdleCallback
+ ? window.requestIdleCallback
+ : window.requestAnimationFrame;
/**
* Function which returns true if the current environment supports browser
@@ -46,15 +45,16 @@ const hasSessionStorageSupport = once( () => {
* restore a local autosave, if one exists.
*/
function useAutosaveNotice() {
- const {
- postId,
- getEditedPostAttribute,
- hasRemoteAutosave,
- } = useSelect( ( select ) => ( {
- postId: select( 'core/editor' ).getCurrentPostId(),
- getEditedPostAttribute: select( 'core/editor' ).getEditedPostAttribute,
- hasRemoteAutosave: !! select( 'core/editor' ).getEditorSettings().autosave,
- } ), [] );
+ const { postId, getEditedPostAttribute, hasRemoteAutosave } = useSelect(
+ ( select ) => ( {
+ postId: select( 'core/editor' ).getCurrentPostId(),
+ getEditedPostAttribute: select( 'core/editor' )
+ .getEditedPostAttribute,
+ hasRemoteAutosave: !! select( 'core/editor' ).getEditorSettings()
+ .autosave,
+ } ),
+ []
+ );
const { createWarningNotice, removeNotice } = useDispatch( 'core/notices' );
const { editPost, resetEditorBlocks } = useDispatch( 'core/editor' );
@@ -94,19 +94,24 @@ function useAutosaveNotice() {
}
const noticeId = uniqueId( 'wpEditorAutosaveRestore' );
- createWarningNotice( __( 'The backup of this post in your browser is different from the version below.' ), {
- id: noticeId,
- actions: [
- {
- label: __( 'Restore the backup' ),
- onClick() {
- editPost( omit( edits, [ 'content' ] ) );
- resetEditorBlocks( parse( edits.content ) );
- removeNotice( noticeId );
+ createWarningNotice(
+ __(
+ 'The backup of this post in your browser is different from the version below.'
+ ),
+ {
+ id: noticeId,
+ actions: [
+ {
+ label: __( 'Restore the backup' ),
+ onClick() {
+ editPost( omit( edits, [ 'content' ] ) );
+ resetEditorBlocks( parse( edits.content ) );
+ removeNotice( noticeId );
+ },
},
- },
- ],
- } );
+ ],
+ }
+ );
}, [ postId ] );
}
@@ -114,27 +119,24 @@ function useAutosaveNotice() {
* Custom hook which ejects a local autosave after a successful save occurs.
*/
function useAutosavePurge() {
- const {
- postId,
- isDirty,
- isAutosaving,
- didError,
- } = useSelect( ( select ) => ( {
- postId: select( 'core/editor' ).getCurrentPostId(),
- isDirty: select( 'core/editor' ).isEditedPostDirty(),
- isAutosaving: select( 'core/editor' ).isAutosavingPost(),
- didError: select( 'core/editor' ).didPostSaveRequestFail(),
- } ), [] );
+ const { postId, isDirty, isAutosaving, didError } = useSelect(
+ ( select ) => ( {
+ postId: select( 'core/editor' ).getCurrentPostId(),
+ isDirty: select( 'core/editor' ).isEditedPostDirty(),
+ isAutosaving: select( 'core/editor' ).isAutosavingPost(),
+ didError: select( 'core/editor' ).didPostSaveRequestFail(),
+ } ),
+ []
+ );
const lastIsDirty = useRef( isDirty );
const lastIsAutosaving = useRef( isAutosaving );
useEffect( () => {
if (
- ! didError && (
- ( lastIsAutosaving.current && ! isAutosaving ) ||
- ( lastIsDirty.current && ! isDirty )
- )
+ ! didError &&
+ ( ( lastIsAutosaving.current && ! isAutosaving ) ||
+ ( lastIsDirty.current && ! isDirty ) )
) {
localAutosaveClear( postId );
}
@@ -152,10 +154,13 @@ function LocalAutosaveMonitor() {
useAutosaveNotice();
useAutosavePurge();
- const { localAutosaveInterval } = useSelect( ( select ) => ( {
- localAutosaveInterval: select( 'core/editor' )
- .getEditorSettings().__experimentalLocalAutosaveInterval,
- } ), [] );
+ const { localAutosaveInterval } = useSelect(
+ ( select ) => ( {
+ localAutosaveInterval: select( 'core/editor' ).getEditorSettings()
+ .__experimentalLocalAutosaveInterval,
+ } ),
+ []
+ );
return (
{
- const { getEditedPostAttribute, getEditorSettings } = select( 'core/editor' );
+ const { getEditedPostAttribute, getEditorSettings } = select(
+ 'core/editor'
+ );
const { getPostType } = select( 'core' );
const { availableTemplates } = getEditorSettings();
return {
diff --git a/packages/editor/src/components/page-attributes/order.js b/packages/editor/src/components/page-attributes/order.js
index bd14ab0ced982..16d6eb681a6e2 100644
--- a/packages/editor/src/components/page-attributes/order.js
+++ b/packages/editor/src/components/page-attributes/order.js
@@ -18,35 +18,36 @@ import PostTypeSupportCheck from '../post-type-support-check';
export const PageAttributesOrder = withState( {
orderInput: null,
-} )(
- ( { onUpdateOrder, order = 0, orderInput, setState } ) => {
- const setUpdatedOrder = ( value ) => {
- setState( {
- orderInput: value,
- } );
- const newOrder = Number( value );
- if ( Number.isInteger( newOrder ) && invoke( value, [ 'trim' ] ) !== '' ) {
- onUpdateOrder( Number( value ) );
- }
- };
- const value = orderInput === null ? order : orderInput;
- return (
- {
- setState( {
- orderInput: null,
- } );
- } }
- />
- );
- }
-);
+} )( ( { onUpdateOrder, order = 0, orderInput, setState } ) => {
+ const setUpdatedOrder = ( value ) => {
+ setState( {
+ orderInput: value,
+ } );
+ const newOrder = Number( value );
+ if (
+ Number.isInteger( newOrder ) &&
+ invoke( value, [ 'trim' ] ) !== ''
+ ) {
+ onUpdateOrder( Number( value ) );
+ }
+ };
+ const value = orderInput === null ? order : orderInput;
+ return (
+ {
+ setState( {
+ orderInput: null,
+ } );
+ } }
+ />
+ );
+} );
function PageAttributesOrderWithChecks( props ) {
return (
@@ -59,7 +60,9 @@ function PageAttributesOrderWithChecks( props ) {
export default compose( [
withSelect( ( select ) => {
return {
- order: select( 'core/editor' ).getEditedPostAttribute( 'menu_order' ),
+ order: select( 'core/editor' ).getEditedPostAttribute(
+ 'menu_order'
+ ),
};
} ),
withDispatch( ( dispatch ) => ( {
diff --git a/packages/editor/src/components/page-attributes/parent.js b/packages/editor/src/components/page-attributes/parent.js
index 6032794e75422..b2aa7b6579ced 100644
--- a/packages/editor/src/components/page-attributes/parent.js
+++ b/packages/editor/src/components/page-attributes/parent.js
@@ -16,7 +16,12 @@ import { withSelect, withDispatch } from '@wordpress/data';
*/
import { buildTermsTree } from '../../utils/terms';
-export function PageAttributesParent( { parent, postType, items, onUpdateParent } ) {
+export function PageAttributesParent( {
+ parent,
+ postType,
+ items,
+ onUpdateParent,
+} ) {
const isHierarchical = get( postType, [ 'hierarchical' ], false );
const parentPageLabel = get( postType, [ 'labels', 'parent_item_colon' ] );
const pageItems = items || [];
@@ -24,11 +29,16 @@ export function PageAttributesParent( { parent, postType, items, onUpdateParent
return null;
}
- const pagesTree = buildTermsTree( pageItems.map( ( item ) => ( {
- id: item.id,
- parent: item.parent,
- name: item.title.raw ? item.title.raw : `#${ item.id } (${ __( 'no title' ) })`,
- } ) ) );
+ const pagesTree = buildTermsTree(
+ pageItems.map( ( item ) => ( {
+ id: item.id,
+ parent: item.parent,
+ name:
+ item.title && item.title.raw
+ ? item.title.raw
+ : `#${ item.id } (${ __( 'no title' ) })`,
+ } ) )
+ );
return (
{
const { getPostType, getEntityRecords } = select( 'core' );
- const { getCurrentPostId, getEditedPostAttribute } = select( 'core/editor' );
+ const { getCurrentPostId, getEditedPostAttribute } = select(
+ 'core/editor'
+ );
const postTypeSlug = getEditedPostAttribute( 'type' );
const postType = getPostType( postTypeSlug );
const postId = getCurrentPostId();
@@ -58,7 +70,9 @@ const applyWithSelect = withSelect( ( select ) => {
return {
parent: getEditedPostAttribute( 'parent' ),
- items: isHierarchical ? getEntityRecords( 'postType', postTypeSlug, query ) : [],
+ items: isHierarchical
+ ? getEntityRecords( 'postType', postTypeSlug, query )
+ : [],
postType,
};
} );
@@ -72,7 +86,6 @@ const applyWithDispatch = withDispatch( ( dispatch ) => {
};
} );
-export default compose( [
- applyWithSelect,
- applyWithDispatch,
-] )( PageAttributesParent );
+export default compose( [ applyWithSelect, applyWithDispatch ] )(
+ PageAttributesParent
+);
diff --git a/packages/editor/src/components/page-attributes/template.js b/packages/editor/src/components/page-attributes/template.js
index 3646a05e3206f..a2c7e45fad593 100644
--- a/packages/editor/src/components/page-attributes/template.js
+++ b/packages/editor/src/components/page-attributes/template.js
@@ -11,7 +11,11 @@ import { SelectControl } from '@wordpress/components';
import { compose } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data';
-export function PageTemplate( { availableTemplates, selectedTemplate, onUpdate } ) {
+export function PageTemplate( {
+ availableTemplates,
+ selectedTemplate,
+ onUpdate,
+} ) {
if ( isEmpty( availableTemplates ) ) {
return null;
}
@@ -21,19 +25,22 @@ export function PageTemplate( { availableTemplates, selectedTemplate, onUpdate }
value={ selectedTemplate }
onChange={ onUpdate }
className="editor-page-attributes__template"
- options={
- map( availableTemplates, ( templateName, templateSlug ) => ( {
+ options={ map(
+ availableTemplates,
+ ( templateName, templateSlug ) => ( {
value: templateSlug,
label: templateName,
- } ) )
- }
+ } )
+ ) }
/>
);
}
export default compose(
withSelect( ( select ) => {
- const { getEditedPostAttribute, getEditorSettings } = select( 'core/editor' );
+ const { getEditedPostAttribute, getEditorSettings } = select(
+ 'core/editor'
+ );
const { availableTemplates } = getEditorSettings();
return {
selectedTemplate: getEditedPostAttribute( 'template' ),
@@ -42,7 +49,9 @@ export default compose(
} ),
withDispatch( ( dispatch ) => ( {
onUpdate( templateSlug ) {
- dispatch( 'core/editor' ).editPost( { template: templateSlug || '' } );
+ dispatch( 'core/editor' ).editPost( {
+ template: templateSlug || '',
+ } );
},
- } ) ),
+ } ) )
)( PageTemplate );
diff --git a/packages/editor/src/components/page-attributes/test/check.js b/packages/editor/src/components/page-attributes/test/check.js
index 9519d0540b78a..af815beeb8615 100644
--- a/packages/editor/src/components/page-attributes/test/check.js
+++ b/packages/editor/src/components/page-attributes/test/check.js
@@ -16,20 +16,25 @@ describe( 'PageAttributesCheck', () => {
};
it( 'should not render anything if unknown page attributes and available templates support', () => {
- const wrapper = shallow( content );
+ const wrapper = shallow(
+ content
+ );
expect( wrapper.type() ).toBe( null );
} );
it( 'should not render anything if no page attributes support and no available templates exist', () => {
const wrapper = shallow(
-
+ } }
+ >
content
);
@@ -38,19 +43,36 @@ describe( 'PageAttributesCheck', () => {
} );
it( 'should render if page attributes support is true and no available templates exist', () => {
- const wrapper = shallow( content );
+ const wrapper = shallow(
+
+ content
+
+ );
expect( wrapper.text() ).toContain( 'content' );
} );
it( 'should render if page attributes support is false/unknown and available templates exist', () => {
- const wrapper = shallow( content );
+ const wrapper = shallow(
+
+ content
+
+ );
expect( wrapper.text() ).toContain( 'content' );
} );
it( 'should render if page attributes support is true and available templates exist', () => {
- const wrapper = shallow( content );
+ const wrapper = shallow(
+
+ content
+
+ );
expect( wrapper.text() ).toContain( 'content' );
} );
diff --git a/packages/editor/src/components/post-author/check.js b/packages/editor/src/components/post-author/check.js
index 4f725e792a44f..45475476545a0 100644
--- a/packages/editor/src/components/post-author/check.js
+++ b/packages/editor/src/components/post-author/check.js
@@ -14,19 +14,31 @@ import { withSelect } from '@wordpress/data';
*/
import PostTypeSupportCheck from '../post-type-support-check';
-export function PostAuthorCheck( { hasAssignAuthorAction, authors, children } ) {
+export function PostAuthorCheck( {
+ hasAssignAuthorAction,
+ authors,
+ children,
+} ) {
if ( ! hasAssignAuthorAction || authors.length < 2 ) {
return null;
}
- return { children } ;
+ return (
+
+ { children }
+
+ );
}
export default compose( [
withSelect( ( select ) => {
const post = select( 'core/editor' ).getCurrentPost();
return {
- hasAssignAuthorAction: get( post, [ '_links', 'wp:action-assign-author' ], false ),
+ hasAssignAuthorAction: get(
+ post,
+ [ '_links', 'wp:action-assign-author' ],
+ false
+ ),
postType: select( 'core/editor' ).getCurrentPostType(),
authors: select( 'core' ).getAuthors(),
};
diff --git a/packages/editor/src/components/post-author/index.js b/packages/editor/src/components/post-author/index.js
index 22f43ffd43eb9..b99f3f80ce451 100644
--- a/packages/editor/src/components/post-author/index.js
+++ b/packages/editor/src/components/post-author/index.js
@@ -42,7 +42,9 @@ export class PostAuthor extends Component {
className="editor-post-author__select"
>
{ authors.map( ( author ) => (
- { decodeEntities( author.name ) }
+
+ { decodeEntities( author.name ) }
+
) ) }
@@ -54,7 +56,9 @@ export class PostAuthor extends Component {
export default compose( [
withSelect( ( select ) => {
return {
- postAuthor: select( 'core/editor' ).getEditedPostAttribute( 'author' ),
+ postAuthor: select( 'core/editor' ).getEditedPostAttribute(
+ 'author'
+ ),
authors: select( 'core' ).getAuthors(),
};
} ),
diff --git a/packages/editor/src/components/post-author/test/check.js b/packages/editor/src/components/post-author/test/check.js
index 891068ef12c52..c39d83ef50afc 100644
--- a/packages/editor/src/components/post-author/test/check.js
+++ b/packages/editor/src/components/post-author/test/check.js
@@ -36,13 +36,20 @@ describe( 'PostAuthorCheck', () => {
};
it( 'should not render anything if users unknown', () => {
- const wrapper = shallow( authors );
+ const wrapper = shallow(
+
+ authors
+
+ );
expect( wrapper.type() ).toBe( null );
} );
it( 'should not render anything if single user', () => {
const wrapper = shallow(
-
+
authors
);
diff --git a/packages/editor/src/components/post-author/test/index.js b/packages/editor/src/components/post-author/test/index.js
index 4bce35e977b0b..368be4fda7d26 100644
--- a/packages/editor/src/components/post-author/test/index.js
+++ b/packages/editor/src/components/post-author/test/index.js
@@ -48,7 +48,8 @@ describe( 'PostAuthor', () => {
+ onUpdateAuthor={ onUpdateAuthor }
+ />
);
wrapper.find( 'select' ).simulate( 'change', {
diff --git a/packages/editor/src/components/post-comments/index.js b/packages/editor/src/components/post-comments/index.js
index f4c412b616d59..21a4994c907e0 100644
--- a/packages/editor/src/components/post-comments/index.js
+++ b/packages/editor/src/components/post-comments/index.js
@@ -7,7 +7,10 @@ import { compose } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data';
function PostComments( { commentStatus = 'open', ...props } ) {
- const onToggleComments = () => props.editPost( { comment_status: commentStatus === 'open' ? 'closed' : 'open' } );
+ const onToggleComments = () =>
+ props.editPost( {
+ comment_status: commentStatus === 'open' ? 'closed' : 'open',
+ } );
return (
{
return {
- commentStatus: select( 'core/editor' ).getEditedPostAttribute( 'comment_status' ),
+ commentStatus: select( 'core/editor' ).getEditedPostAttribute(
+ 'comment_status'
+ ),
};
} ),
withDispatch( ( dispatch ) => ( {
diff --git a/packages/editor/src/components/post-excerpt/index.js b/packages/editor/src/components/post-excerpt/index.js
index 5877844b942ac..80c6816b00b81 100644
--- a/packages/editor/src/components/post-excerpt/index.js
+++ b/packages/editor/src/components/post-excerpt/index.js
@@ -15,7 +15,9 @@ function PostExcerpt( { excerpt, onUpdateExcerpt } ) {
onChange={ ( value ) => onUpdateExcerpt( value ) }
value={ excerpt }
/>
-
+
{ __( 'Learn more about manual excerpts' ) }
@@ -25,7 +27,9 @@ function PostExcerpt( { excerpt, onUpdateExcerpt } ) {
export default compose( [
withSelect( ( select ) => {
return {
- excerpt: select( 'core/editor' ).getEditedPostAttribute( 'excerpt' ),
+ excerpt: select( 'core/editor' ).getEditedPostAttribute(
+ 'excerpt'
+ ),
};
} ),
withDispatch( ( dispatch ) => ( {
diff --git a/packages/editor/src/components/post-featured-image/index.js b/packages/editor/src/components/post-featured-image/index.js
index 98e21e2fbc59b..7196358157b9a 100644
--- a/packages/editor/src/components/post-featured-image/index.js
+++ b/packages/editor/src/components/post-featured-image/index.js
@@ -43,11 +43,22 @@ function PostFeaturedImage( {
noticeUI,
} ) {
const postLabel = get( postType, [ 'labels' ], {} );
- const instructions =
{ __( 'To edit the featured image, you need permission to upload media.' ) }
;
+ const instructions = (
+
+ { __(
+ 'To edit the featured image, you need permission to upload media.'
+ ) }
+
+ );
let mediaWidth, mediaHeight, mediaSourceUrl;
if ( media ) {
- const mediaSize = applyFilters( 'editor.PostFeaturedImage.imageSize', 'post-thumbnail', media.id, currentPostId );
+ const mediaSize = applyFilters(
+ 'editor.PostFeaturedImage.imageSize',
+ 'post-thumbnail',
+ media.id,
+ currentPostId
+ );
if ( has( media, [ 'media_details', 'sizes', mediaSize ] ) ) {
// use mediaSize when available
mediaWidth = media.media_details.sizes[ mediaSize ].width;
@@ -55,12 +66,22 @@ function PostFeaturedImage( {
mediaSourceUrl = media.media_details.sizes[ mediaSize ].source_url;
} else {
// get fallbackMediaSize if mediaSize is not available
- const fallbackMediaSize = applyFilters( 'editor.PostFeaturedImage.imageSize', 'thumbnail', media.id, currentPostId );
- if ( has( media, [ 'media_details', 'sizes', fallbackMediaSize ] ) ) {
+ const fallbackMediaSize = applyFilters(
+ 'editor.PostFeaturedImage.imageSize',
+ 'thumbnail',
+ media.id,
+ currentPostId
+ );
+ if (
+ has( media, [ 'media_details', 'sizes', fallbackMediaSize ] )
+ ) {
// use fallbackMediaSize when mediaSize is not available
- mediaWidth = media.media_details.sizes[ fallbackMediaSize ].width;
- mediaHeight = media.media_details.sizes[ fallbackMediaSize ].height;
- mediaSourceUrl = media.media_details.sizes[ fallbackMediaSize ].source_url;
+ mediaWidth =
+ media.media_details.sizes[ fallbackMediaSize ].width;
+ mediaHeight =
+ media.media_details.sizes[ fallbackMediaSize ].height;
+ mediaSourceUrl =
+ media.media_details.sizes[ fallbackMediaSize ].source_url;
} else {
// use full image size when mediaFallbackSize and mediaSize are not available
mediaWidth = media.media_details.width;
@@ -76,28 +97,51 @@ function PostFeaturedImage( {
(
- { !! featuredImageId && media &&
+ aria-label={
+ ! featuredImageId
+ ? null
+ : __( 'Edit or update the image' )
+ }
+ >
+ { !! featuredImageId && media && (
-
+
- }
- { !! featuredImageId && ! media && }
- { ! featuredImageId && ( postLabel.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL ) }
+ ) }
+ { !! featuredImageId && ! media && (
+
+ ) }
+ { ! featuredImageId &&
+ ( postLabel.set_featured_image ||
+ DEFAULT_SET_FEATURE_IMAGE_LABEL ) }
@@ -105,10 +149,13 @@ function PostFeaturedImage( {
value={ featuredImageId }
/>
- { !! featuredImageId && media && ! media.isLoading &&
+ { !! featuredImageId && media && ! media.isLoading && (
- }
- { !! featuredImageId &&
+ ) }
+ { !! featuredImageId && (
- { postLabel.remove_featured_image || DEFAULT_REMOVE_FEATURE_IMAGE_LABEL }
+ { postLabel.remove_featured_image ||
+ DEFAULT_REMOVE_FEATURE_IMAGE_LABEL }
- }
+ ) }
);
@@ -135,7 +183,9 @@ function PostFeaturedImage( {
const applyWithSelect = withSelect( ( select ) => {
const { getMedia, getPostType } = select( 'core' );
- const { getCurrentPostId, getEditedPostAttribute } = select( 'core/editor' );
+ const { getCurrentPostId, getEditedPostAttribute } = select(
+ 'core/editor'
+ );
const featuredImageId = getEditedPostAttribute( 'featured_media' );
return {
@@ -146,36 +196,38 @@ const applyWithSelect = withSelect( ( select ) => {
};
} );
-const applyWithDispatch = withDispatch( ( dispatch, { noticeOperations }, { select } ) => {
- const { editPost } = dispatch( 'core/editor' );
- return {
- onUpdateImage( image ) {
- editPost( { featured_media: image.id } );
- },
- onDropImage( filesList ) {
- select( 'core/block-editor' )
- .getSettings()
- .mediaUpload( {
- allowedTypes: [ 'image' ],
- filesList,
- onFileChange( [ image ] ) {
- editPost( { featured_media: image.id } );
- },
- onError( message ) {
- noticeOperations.removeAllNotices();
- noticeOperations.createErrorNotice( message );
- },
- } );
- },
- onRemoveImage() {
- editPost( { featured_media: 0 } );
- },
- };
-} );
+const applyWithDispatch = withDispatch(
+ ( dispatch, { noticeOperations }, { select } ) => {
+ const { editPost } = dispatch( 'core/editor' );
+ return {
+ onUpdateImage( image ) {
+ editPost( { featured_media: image.id } );
+ },
+ onDropImage( filesList ) {
+ select( 'core/block-editor' )
+ .getSettings()
+ .mediaUpload( {
+ allowedTypes: [ 'image' ],
+ filesList,
+ onFileChange( [ image ] ) {
+ editPost( { featured_media: image.id } );
+ },
+ onError( message ) {
+ noticeOperations.removeAllNotices();
+ noticeOperations.createErrorNotice( message );
+ },
+ } );
+ },
+ onRemoveImage() {
+ editPost( { featured_media: 0 } );
+ },
+ };
+ }
+);
export default compose(
withNotices,
applyWithSelect,
applyWithDispatch,
- withFilters( 'editor.PostFeaturedImage' ),
+ withFilters( 'editor.PostFeaturedImage' )
)( PostFeaturedImage );
diff --git a/packages/editor/src/components/post-format/check.js b/packages/editor/src/components/post-format/check.js
index cd124553a7cf1..d344546f0b553 100644
--- a/packages/editor/src/components/post-format/check.js
+++ b/packages/editor/src/components/post-format/check.js
@@ -9,16 +9,16 @@ import { withSelect } from '@wordpress/data';
import PostTypeSupportCheck from '../post-type-support-check';
function PostFormatCheck( { disablePostFormats, ...props } ) {
- return ! disablePostFormats &&
-
;
+ return (
+ ! disablePostFormats && (
+
+ )
+ );
}
-export default withSelect(
- ( select ) => {
- const editorSettings = select( 'core/editor' ).getEditorSettings();
- return {
- disablePostFormats: editorSettings.disablePostFormats,
- };
- }
-)( PostFormatCheck );
-
+export default withSelect( ( select ) => {
+ const editorSettings = select( 'core/editor' ).getEditorSettings();
+ return {
+ disablePostFormats: editorSettings.disablePostFormats,
+ };
+} )( PostFormatCheck );
diff --git a/packages/editor/src/components/post-format/index.js b/packages/editor/src/components/post-format/index.js
index d3402f953e024..76156d8a29415 100644
--- a/packages/editor/src/components/post-format/index.js
+++ b/packages/editor/src/components/post-format/index.js
@@ -29,10 +29,21 @@ export const POST_FORMATS = [
{ id: 'chat', caption: __( 'Chat' ) },
];
-function PostFormat( { onUpdatePostFormat, postFormat = 'standard', supportedFormats, suggestedFormat, instanceId } ) {
+function PostFormat( {
+ onUpdatePostFormat,
+ postFormat = 'standard',
+ supportedFormats,
+ suggestedFormat,
+ instanceId,
+} ) {
const postFormatSelectorId = 'post-format-selector-' + instanceId;
- const formats = POST_FORMATS.filter( ( format ) => includes( supportedFormats, format.id ) );
- const suggestion = find( formats, ( format ) => format.id === suggestedFormat );
+ const formats = POST_FORMATS.filter( ( format ) =>
+ includes( supportedFormats, format.id )
+ );
+ const suggestion = find(
+ formats,
+ ( format ) => format.id === suggestedFormat
+ );
// Disable reason: We need to change the value immiediately to show/hide the suggestion if needed
@@ -40,7 +51,9 @@ function PostFormat( { onUpdatePostFormat, postFormat = 'standard', supportedFor
-
{ __( 'Post Format' ) }
+
+ { __( 'Post Format' ) }
+
onUpdatePostFormat( format ) }
@@ -55,7 +68,12 @@ function PostFormat( { onUpdatePostFormat, postFormat = 'standard', supportedFor
{ suggestion && suggestion.id !== postFormat && (
{ __( 'Suggestion:' ) }{ ' ' }
- onUpdatePostFormat( suggestion.id ) }>
+
+ onUpdatePostFormat( suggestion.id )
+ }
+ >
{ suggestion.caption }
@@ -67,12 +85,17 @@ function PostFormat( { onUpdatePostFormat, postFormat = 'standard', supportedFor
export default compose( [
withSelect( ( select ) => {
- const { getEditedPostAttribute, getSuggestedPostFormat } = select( 'core/editor' );
+ const { getEditedPostAttribute, getSuggestedPostFormat } = select(
+ 'core/editor'
+ );
const postFormat = getEditedPostAttribute( 'format' );
const themeSupports = select( 'core' ).getThemeSupports();
// Ensure current format is always in the set.
// The current format may not be a format supported by the theme.
- const supportedFormats = union( [ postFormat ], get( themeSupports, [ 'formats' ], [] ) );
+ const supportedFormats = union(
+ [ postFormat ],
+ get( themeSupports, [ 'formats' ], [] )
+ );
return {
postFormat,
supportedFormats,
diff --git a/packages/editor/src/components/post-last-revision/check.js b/packages/editor/src/components/post-last-revision/check.js
index 4d63dc7adc6bc..e47382f52a575 100644
--- a/packages/editor/src/components/post-last-revision/check.js
+++ b/packages/editor/src/components/post-last-revision/check.js
@@ -8,20 +8,29 @@ import { withSelect } from '@wordpress/data';
*/
import PostTypeSupportCheck from '../post-type-support-check';
-export function PostLastRevisionCheck( { lastRevisionId, revisionsCount, children } ) {
+export function PostLastRevisionCheck( {
+ lastRevisionId,
+ revisionsCount,
+ children,
+} ) {
if ( ! lastRevisionId || revisionsCount < 2 ) {
return null;
}
- return { children } ;
+ return (
+
+ { children }
+
+ );
}
-export default withSelect(
- ( select ) => {
- const { getCurrentPostLastRevisionId, getCurrentPostRevisionsCount } = select( 'core/editor' );
- return {
- lastRevisionId: getCurrentPostLastRevisionId(),
- revisionsCount: getCurrentPostRevisionsCount(),
- };
- }
-)( PostLastRevisionCheck );
+export default withSelect( ( select ) => {
+ const {
+ getCurrentPostLastRevisionId,
+ getCurrentPostRevisionsCount,
+ } = select( 'core/editor' );
+ return {
+ lastRevisionId: getCurrentPostLastRevisionId(),
+ revisionsCount: getCurrentPostRevisionsCount(),
+ };
+} )( PostLastRevisionCheck );
diff --git a/packages/editor/src/components/post-last-revision/index.js b/packages/editor/src/components/post-last-revision/index.js
index e61fd8add07f3..10e073b217caf 100644
--- a/packages/editor/src/components/post-last-revision/index.js
+++ b/packages/editor/src/components/post-last-revision/index.js
@@ -15,30 +15,29 @@ function LastRevision( { lastRevisionId, revisionsCount } ) {
return (
- {
- sprintf(
- _n( '%d Revision', '%d Revisions', revisionsCount ),
- revisionsCount
- )
- }
+ { sprintf(
+ _n( '%d Revision', '%d Revisions', revisionsCount ),
+ revisionsCount
+ ) }
);
}
-export default withSelect(
- ( select ) => {
- const {
- getCurrentPostLastRevisionId,
- getCurrentPostRevisionsCount,
- } = select( 'core/editor' );
- return {
- lastRevisionId: getCurrentPostLastRevisionId(),
- revisionsCount: getCurrentPostRevisionsCount(),
- };
- }
-)( LastRevision );
+export default withSelect( ( select ) => {
+ const {
+ getCurrentPostLastRevisionId,
+ getCurrentPostRevisionsCount,
+ } = select( 'core/editor' );
+ return {
+ lastRevisionId: getCurrentPostLastRevisionId(),
+ revisionsCount: getCurrentPostRevisionsCount(),
+ };
+} )( LastRevision );
diff --git a/packages/editor/src/components/post-locked-modal/index.js b/packages/editor/src/components/post-locked-modal/index.js
index 5749db90428c5..99f32e3ae147c 100644
--- a/packages/editor/src/components/post-locked-modal/index.js
+++ b/packages/editor/src/components/post-locked-modal/index.js
@@ -131,7 +131,14 @@ class PostLockedModal extends Component {
}
render() {
- const { user, postId, isLocked, isTakeover, postLockUtils, postType } = this.props;
+ const {
+ user,
+ postId,
+ isLocked,
+ isTakeover,
+ postLockUtils,
+ postType,
+ } = this.props;
if ( ! isLocked ) {
return null;
}
@@ -152,7 +159,11 @@ class PostLockedModal extends Component {
const allPostsLabel = __( 'Exit the Editor' );
return (
- { userDisplayName ?
- sprintf(
- /* translators: %s: user's display name */
- __( '%s now has editing control of this post. Donโt worry, your changes up to this moment have been saved.' ),
- userDisplayName
- ) :
- __( 'Another user now has editing control of this post. Donโt worry, your changes up to this moment have been saved.' )
- }
+ { userDisplayName
+ ? sprintf(
+ /* translators: %s: user's display name */
+ __(
+ '%s now has editing control of this post. Donโt worry, your changes up to this moment have been saved.'
+ ),
+ userDisplayName
+ )
+ : __(
+ 'Another user now has editing control of this post. Donโt worry, your changes up to this moment have been saved.'
+ ) }
@@ -189,14 +203,17 @@ class PostLockedModal extends Component {
{ ! isTakeover && (
- { userDisplayName ?
- sprintf(
- /* translators: %s: user's display name */
- __( '%s is currently working on this post, which means you cannot make changes, unless you take over.' ),
- userDisplayName
- ) :
- __( 'Another user is currently working on this post, which means you cannot make changes, unless you take over.' )
- }
+ { userDisplayName
+ ? sprintf(
+ /* translators: %s: user's display name */
+ __(
+ '%s is currently working on this post, which means you cannot make changes, unless you take over.'
+ ),
+ userDisplayName
+ )
+ : __(
+ 'Another user is currently working on this post, which means you cannot make changes, unless you take over.'
+ ) }
diff --git a/packages/editor/src/components/post-pending-status/check.js b/packages/editor/src/components/post-pending-status/check.js
index 2c6c19b928042..03e526921e06f 100644
--- a/packages/editor/src/components/post-pending-status/check.js
+++ b/packages/editor/src/components/post-pending-status/check.js
@@ -9,7 +9,11 @@ import { get } from 'lodash';
import { compose } from '@wordpress/compose';
import { withSelect } from '@wordpress/data';
-export function PostPendingStatusCheck( { hasPublishAction, isPublished, children } ) {
+export function PostPendingStatusCheck( {
+ hasPublishAction,
+ isPublished,
+ children,
+} ) {
if ( isPublished || ! hasPublishAction ) {
return null;
}
@@ -19,9 +23,17 @@ export function PostPendingStatusCheck( { hasPublishAction, isPublished, childre
export default compose(
withSelect( ( select ) => {
- const { isCurrentPostPublished, getCurrentPostType, getCurrentPost } = select( 'core/editor' );
+ const {
+ isCurrentPostPublished,
+ getCurrentPostType,
+ getCurrentPost,
+ } = select( 'core/editor' );
return {
- hasPublishAction: get( getCurrentPost(), [ '_links', 'wp:action-publish' ], false ),
+ hasPublishAction: get(
+ getCurrentPost(),
+ [ '_links', 'wp:action-publish' ],
+ false
+ ),
isPublished: isCurrentPostPublished(),
postType: getCurrentPostType(),
};
diff --git a/packages/editor/src/components/post-pending-status/index.js b/packages/editor/src/components/post-pending-status/index.js
index e79b7b1bf4186..ba30da1d9498a 100644
--- a/packages/editor/src/components/post-pending-status/index.js
+++ b/packages/editor/src/components/post-pending-status/index.js
@@ -36,5 +36,5 @@ export default compose(
onUpdateStatus( status ) {
dispatch( 'core/editor' ).editPost( { status } );
},
- } ) ),
+ } ) )
)( PostPendingStatus );
diff --git a/packages/editor/src/components/post-pending-status/test/check.js b/packages/editor/src/components/post-pending-status/test/check.js
index b26eebb7331be..bfeba96446fa4 100644
--- a/packages/editor/src/components/post-pending-status/test/check.js
+++ b/packages/editor/src/components/post-pending-status/test/check.js
@@ -19,7 +19,11 @@ describe( 'PostPendingStatusCheck', () => {
} );
it( 'should render if the user has the correct capability', () => {
- const wrapper = shallow(
status );
+ const wrapper = shallow(
+
+ status
+
+ );
expect( wrapper.type() ).not.toBe( null );
} );
} );
diff --git a/packages/editor/src/components/post-permalink/editor.js b/packages/editor/src/components/post-permalink/editor.js
index 408deba736e66..a09ee66ed984a 100644
--- a/packages/editor/src/components/post-permalink/editor.js
+++ b/packages/editor/src/components/post-permalink/editor.js
@@ -62,7 +62,11 @@ class PostPermalinkEditor extends Component {
className="editor-post-permalink-editor__edit"
aria-label={ __( 'Edit post permalink' ) }
value={ editedPostName }
- onChange={ ( event ) => this.setState( { editedPostName: event.target.value } ) }
+ onChange={ ( event ) =>
+ this.setState( {
+ editedPostName: event.target.value,
+ } )
+ }
type="text"
autoFocus
/>
@@ -96,4 +100,3 @@ export default compose( [
return { editPost };
} ),
] )( PostPermalinkEditor );
-
diff --git a/packages/editor/src/components/post-permalink/index.js b/packages/editor/src/components/post-permalink/index.js
index ff9d0a8be1a5e..ab82766dbacc6 100644
--- a/packages/editor/src/components/post-permalink/index.js
+++ b/packages/editor/src/components/post-permalink/index.js
@@ -54,7 +54,10 @@ class PostPermalink extends Component {
}
componentWillUnmount() {
- window.removeEventListener( 'visibilitychange', this.addVisibilityCheck );
+ window.removeEventListener(
+ 'visibilitychange',
+ this.addVisibilityCheck
+ );
}
render() {
@@ -75,16 +78,23 @@ class PostPermalink extends Component {
}
const { isCopied, isEditingPermalink } = this.state;
- const ariaLabel = isCopied ? __( 'Permalink copied' ) : __( 'Copy the permalink' );
+ const ariaLabel = isCopied
+ ? __( 'Permalink copied' )
+ : __( 'Copy the permalink' );
const { prefix, suffix } = permalinkParts;
- const slug = safeDecodeURIComponent( postSlug ) || cleanForSlug( postTitle ) || postID;
- const samplePermalink = ( isEditable ) ? prefix + slug + suffix : prefix;
+ const slug =
+ safeDecodeURIComponent( postSlug ) ||
+ cleanForSlug( postTitle ) ||
+ postID;
+ const samplePermalink = isEditable ? prefix + slug + suffix : prefix;
return (
this.setState( { isCopied: true } ) }
@@ -92,36 +102,44 @@ class PostPermalink extends Component {
icon="admin-links"
/>
- { __( 'Permalink:' ) }
+
+ { __( 'Permalink:' ) }
+
- { ! isEditingPermalink &&
+ { ! isEditingPermalink && (
this.linkElement = linkElement }
+ ref={ ( linkElement ) =>
+ ( this.linkElement = linkElement )
+ }
>
{ safeDecodeURI( samplePermalink ) }
- }
+ ) }
- { isEditingPermalink &&
+ { isEditingPermalink && (
this.setState( { isEditingPermalink: false } ) }
+ onSave={ () =>
+ this.setState( { isEditingPermalink: false } )
+ }
/>
- }
+ ) }
- { isEditable && ! isEditingPermalink &&
+ { isEditable && ! isEditingPermalink && (
this.setState( { isEditingPermalink: true } ) }
+ onClick={ () =>
+ this.setState( { isEditingPermalink: true } )
+ }
>
{ __( 'Edit' ) }
- }
+ ) }
);
}
@@ -137,9 +155,7 @@ export default compose( [
getEditedPostAttribute,
isCurrentPostPublished,
} = select( 'core/editor' );
- const {
- getPostType,
- } = select( 'core' );
+ const { getPostType } = select( 'core' );
const { id, link } = getCurrentPost();
diff --git a/packages/editor/src/components/post-pingbacks/index.js b/packages/editor/src/components/post-pingbacks/index.js
index f18a0368214cb..f181d45ef2ad4 100644
--- a/packages/editor/src/components/post-pingbacks/index.js
+++ b/packages/editor/src/components/post-pingbacks/index.js
@@ -7,7 +7,10 @@ import { withSelect, withDispatch } from '@wordpress/data';
import { compose } from '@wordpress/compose';
function PostPingbacks( { pingStatus = 'open', ...props } ) {
- const onTogglePingback = () => props.editPost( { ping_status: pingStatus === 'open' ? 'closed' : 'open' } );
+ const onTogglePingback = () =>
+ props.editPost( {
+ ping_status: pingStatus === 'open' ? 'closed' : 'open',
+ } );
return (
{
return {
- pingStatus: select( 'core/editor' ).getEditedPostAttribute( 'ping_status' ),
+ pingStatus: select( 'core/editor' ).getEditedPostAttribute(
+ 'ping_status'
+ ),
};
} ),
withDispatch( ( dispatch ) => ( {
diff --git a/packages/editor/src/components/post-preview-button/index.js b/packages/editor/src/components/post-preview-button/index.js
index cd77cf96280bd..620bb9aaf0180 100644
--- a/packages/editor/src/components/post-preview-button/index.js
+++ b/packages/editor/src/components/post-preview-button/index.js
@@ -17,8 +17,16 @@ function writeInterstitialMessage( targetDocument ) {
let markup = renderToString(
-
-
+
+
{ __( 'Generating previewโฆ' ) }
@@ -185,10 +193,8 @@ export class PostPreviewButton extends Component {
>
{ _x( 'Preview', 'imperative verb' ) }
- {
- /* translators: accessibility text */
- __( '(opens in a new tab)' )
- }
+ { /* translators: accessibility text */
+ __( '(opens in a new tab)' ) }
);
@@ -205,9 +211,7 @@ export default compose( [
isEditedPostAutosaveable,
getEditedPostPreviewLink,
} = select( 'core/editor' );
- const {
- getPostType,
- } = select( 'core' );
+ const { getPostType } = select( 'core' );
const previewLink = getEditedPostPreviewLink();
const postType = getPostType( getEditedPostAttribute( 'type' ) );
@@ -215,11 +219,15 @@ export default compose( [
return {
postId: getCurrentPostId(),
currentPostLink: getCurrentPostAttribute( 'link' ),
- previewLink: forcePreviewLink !== undefined ? forcePreviewLink : previewLink,
+ previewLink:
+ forcePreviewLink !== undefined ? forcePreviewLink : previewLink,
isSaveable: isEditedPostSaveable(),
isAutosaveable: forceIsAutosaveable || isEditedPostAutosaveable(),
isViewable: get( postType, [ 'viewable' ], false ),
- isDraft: [ 'draft', 'auto-draft' ].indexOf( getEditedPostAttribute( 'status' ) ) !== -1,
+ isDraft:
+ [ 'draft', 'auto-draft' ].indexOf(
+ getEditedPostAttribute( 'status' )
+ ) !== -1,
};
} ),
withDispatch( ( dispatch ) => ( {
diff --git a/packages/editor/src/components/post-preview-button/test/index.js b/packages/editor/src/components/post-preview-button/test/index.js
index 7bd9856de05c7..674957e0d330f 100644
--- a/packages/editor/src/components/post-preview-button/test/index.js
+++ b/packages/editor/src/components/post-preview-button/test/index.js
@@ -58,7 +58,8 @@ describe( 'PostPreviewButton', () => {
postId={ 1 }
currentPostLink="https://wordpress.org/?p=1"
isSaveable
- modified="2017-08-03T15:05:50" />
+ modified="2017-08-03T15:05:50"
+ />
);
const previewWindow = { location: {} };
@@ -67,7 +68,9 @@ describe( 'PostPreviewButton', () => {
wrapper.setProps( { previewLink: 'https://wordpress.org/?p=1' } );
- expect( previewWindow.location ).toBe( 'https://wordpress.org/?p=1' );
+ expect( previewWindow.location ).toBe(
+ 'https://wordpress.org/?p=1'
+ );
} );
} );
@@ -92,10 +95,7 @@ describe( 'PostPreviewButton', () => {
} ) );
const wrapper = shallow(
-
+
);
wrapper.simulate( 'click', {
@@ -107,7 +107,9 @@ describe( 'PostPreviewButton', () => {
expect( window.open ).toHaveBeenCalledWith( '', 'wp-preview-1' );
expect( wrapper.instance().previewWindow.focus ).toHaveBeenCalled();
expect( autosave ).not.toHaveBeenCalled();
- expect( setLocation ).toHaveBeenCalledWith( 'https://wordpress.org/?p=1' );
+ expect( setLocation ).toHaveBeenCalledWith(
+ 'https://wordpress.org/?p=1'
+ );
} );
it( 'autosaves the post if autosaveable', () => {
@@ -136,8 +138,13 @@ describe( 'PostPreviewButton', () => {
expect( window.open ).toHaveBeenCalledWith( '', 'wp-preview-1' );
expect( wrapper.instance().previewWindow.focus ).toHaveBeenCalled();
expect( autosave ).toHaveBeenCalled();
- expect( wrapper.instance().previewWindow.document.write.mock.calls[ 0 ][ 0 ] ).toContain( 'Generating previewโฆ' );
- expect( wrapper.instance().previewWindow.document.close ).toHaveBeenCalled();
+ expect(
+ wrapper.instance().previewWindow.document.write.mock
+ .calls[ 0 ][ 0 ]
+ ).toContain( 'Generating previewโฆ' );
+ expect(
+ wrapper.instance().previewWindow.document.close
+ ).toHaveBeenCalled();
} );
} );
diff --git a/packages/editor/src/components/post-publish-button/index.js b/packages/editor/src/components/post-publish-button/index.js
index de7b3069d1726..788625851fad9 100644
--- a/packages/editor/src/components/post-publish-button/index.js
+++ b/packages/editor/src/components/post-publish-button/index.js
@@ -27,14 +27,18 @@ export class PostPublishButton extends Component {
this.buttonNode = createRef();
this.createOnClick = this.createOnClick.bind( this );
- this.closeEntitiesSavedStates = this.closeEntitiesSavedStates.bind( this );
+ this.closeEntitiesSavedStates = this.closeEntitiesSavedStates.bind(
+ this
+ );
this.state = {
entitiesSavedStatesCallback: false,
};
this.createIgnoredForSave = memoize(
( postType, postId ) =>
- new EquivalentKeyMap( [ [ [ 'postType', postType, String( postId ) ], true ] ] ),
+ new EquivalentKeyMap( [
+ [ [ 'postType', postType, String( postId ) ], true ],
+ ] ),
{ maxSize: 1 }
);
}
@@ -65,7 +69,10 @@ export class PostPublishButton extends Component {
const { postType, postId } = this.props;
const { entitiesSavedStatesCallback } = this.state;
this.setState( { entitiesSavedStatesCallback: false }, () => {
- if ( savedById && savedById.has( [ 'postType', postType, String( postId ) ] ) ) {
+ if (
+ savedById &&
+ savedById.has( [ 'postType', postType, String( postId ) ] )
+ ) {
// The post entity was checked, call the held callback from `createOnClick`.
entitiesSavedStatesCallback();
}
@@ -94,9 +101,7 @@ export class PostPublishButton extends Component {
postType,
postId,
} = this.props;
- const {
- entitiesSavedStatesCallback,
- } = this.state;
+ const { entitiesSavedStatesCallback } = this.state;
const isButtonDisabled =
isSaving ||
@@ -156,7 +161,9 @@ export class PostPublishButton extends Component {
onClick: this.createOnClick( onClickToggle ),
};
- const toggleChildren = isBeingScheduled ? __( 'Scheduleโฆ' ) : __( 'Publishโฆ' );
+ const toggleChildren = isBeingScheduled
+ ? __( 'Scheduleโฆ' )
+ : __( 'Publishโฆ' );
const buttonChildren = (
{
const { editPost, savePost } = dispatch( 'core/editor' );
return {
- onStatusChange: ( status ) => editPost( { status }, { undoIgnore: true } ),
+ onStatusChange: ( status ) =>
+ editPost( { status }, { undoIgnore: true } ),
onSave: savePost,
};
} ),
diff --git a/packages/editor/src/components/post-publish-button/label.js b/packages/editor/src/components/post-publish-button/label.js
index 5373d39322558..c8801eb85051b 100644
--- a/packages/editor/src/components/post-publish-button/label.js
+++ b/packages/editor/src/components/post-publish-button/label.js
@@ -28,9 +28,9 @@ export function PublishButtonLabel( {
}
if ( ! hasPublishAction ) {
- return hasNonPostEntityChanges ?
- __( 'Submit for Reviewโฆ' ) :
- __( 'Submit for Review' );
+ return hasNonPostEntityChanges
+ ? __( 'Submit for Reviewโฆ' )
+ : __( 'Submit for Review' );
} else if ( isPublished ) {
return hasNonPostEntityChanges ? __( 'Updateโฆ' ) : __( 'Update' );
} else if ( isBeingScheduled ) {
@@ -56,7 +56,11 @@ export default compose( [
isBeingScheduled: isEditedPostBeingScheduled(),
isSaving: forceIsSaving || isSavingPost(),
isPublishing: isPublishingPost(),
- hasPublishAction: get( getCurrentPost(), [ '_links', 'wp:action-publish' ], false ),
+ hasPublishAction: get(
+ getCurrentPost(),
+ [ '_links', 'wp:action-publish' ],
+ false
+ ),
postType: getCurrentPostType(),
isAutosaving: isAutosavingPost(),
};
diff --git a/packages/editor/src/components/post-publish-button/test/index.js b/packages/editor/src/components/post-publish-button/test/index.js
index 6c6684ea375b6..7dbcc34036c02 100644
--- a/packages/editor/src/components/post-publish-button/test/index.js
+++ b/packages/editor/src/components/post-publish-button/test/index.js
@@ -17,26 +17,22 @@ describe( 'PostPublishButton', () => {
describe( 'aria-disabled', () => {
it( 'should be true if post is currently saving', () => {
const wrapper = shallow(
-
+
);
- expect( wrapper.find( Button ).prop( 'aria-disabled' ) ).toBe( true );
+ expect( wrapper.find( Button ).prop( 'aria-disabled' ) ).toBe(
+ true
+ );
} );
it( 'should be true if forceIsSaving is true', () => {
const wrapper = shallow(
-
+
);
- expect( wrapper.find( Button ).prop( 'aria-disabled' ) ).toBe( true );
+ expect( wrapper.find( Button ).prop( 'aria-disabled' ) ).toBe(
+ true
+ );
} );
it( 'should be true if post is not publishable and not forceIsDirty', () => {
@@ -48,18 +44,19 @@ describe( 'PostPublishButton', () => {
/>
);
- expect( wrapper.find( Button ).prop( 'aria-disabled' ) ).toBe( true );
+ expect( wrapper.find( Button ).prop( 'aria-disabled' ) ).toBe(
+ true
+ );
} );
it( 'should be true if post is not saveable', () => {
const wrapper = shallow(
-
+
);
- expect( wrapper.find( Button ).prop( 'aria-disabled' ) ).toBe( true );
+ expect( wrapper.find( Button ).prop( 'aria-disabled' ) ).toBe(
+ true
+ );
} );
it( 'should be true if post saving is locked', () => {
@@ -71,7 +68,9 @@ describe( 'PostPublishButton', () => {
/>
);
- expect( wrapper.find( Button ).prop( 'aria-disabled' ) ).toBe( true );
+ expect( wrapper.find( Button ).prop( 'aria-disabled' ) ).toBe(
+ true
+ );
} );
it( 'should be false if post is saveable but not publishable and forceIsDirty is true', () => {
@@ -83,18 +82,19 @@ describe( 'PostPublishButton', () => {
/>
);
- expect( wrapper.find( Button ).prop( 'aria-disabled' ) ).toBe( false );
+ expect( wrapper.find( Button ).prop( 'aria-disabled' ) ).toBe(
+ false
+ );
} );
it( 'should be false if post is publishave and saveable', () => {
const wrapper = shallow(
-
+
);
- expect( wrapper.find( Button ).prop( 'aria-disabled' ) ).toBe( false );
+ expect( wrapper.find( Button ).prop( 'aria-disabled' ) ).toBe(
+ false
+ );
} );
} );
@@ -127,7 +127,8 @@ describe( 'PostPublishButton', () => {
onSave={ onSave }
isBeingScheduled
isSaveable={ true }
- isPublishable={ true } />
+ isPublishable={ true }
+ />
);
wrapper.find( Button ).simulate( 'click' );
@@ -145,7 +146,8 @@ describe( 'PostPublishButton', () => {
onSave={ onSave }
visibility="private"
isSaveable={ true }
- isPublishable={ true } />
+ isPublishable={ true }
+ />
);
wrapper.find( Button ).simulate( 'click' );
@@ -162,7 +164,8 @@ describe( 'PostPublishButton', () => {
onStatusChange={ onStatusChange }
onSave={ onSave }
isSaveable={ true }
- isPublishable={ true } />
+ isPublishable={ true }
+ />
);
wrapper.find( Button ).simulate( 'click' );
@@ -181,7 +184,8 @@ describe( 'PostPublishButton', () => {
onStatusChange={ onStatusChange }
onSave={ onSave }
isSaveable={ true }
- isPublishable={ true } />
+ isPublishable={ true }
+ />
);
wrapper.find( Button ).simulate( 'click' );
@@ -192,12 +196,7 @@ describe( 'PostPublishButton', () => {
} );
it( 'should have save modifier class', () => {
- const wrapper = shallow(
-
- );
+ const wrapper = shallow( );
expect( wrapper.find( Button ).prop( 'isBusy' ) ).toBe( true );
} );
diff --git a/packages/editor/src/components/post-publish-button/test/label.js b/packages/editor/src/components/post-publish-button/test/label.js
index b3e8eff9725ac..5990e94e36282 100644
--- a/packages/editor/src/components/post-publish-button/test/label.js
+++ b/packages/editor/src/components/post-publish-button/test/label.js
@@ -5,22 +5,37 @@ import { PublishButtonLabel } from '../label';
describe( 'PublishButtonLabel', () => {
it( 'should show publishing if publishing in progress', () => {
- const label = PublishButtonLabel( { hasPublishAction: true, isPublishing: true } );
+ const label = PublishButtonLabel( {
+ hasPublishAction: true,
+ isPublishing: true,
+ } );
expect( label ).toBe( 'Publishingโฆ' );
} );
it( 'should show updating if published and saving in progress', () => {
- const label = PublishButtonLabel( { hasPublishAction: true, isPublished: true, isSaving: true } );
+ const label = PublishButtonLabel( {
+ hasPublishAction: true,
+ isPublished: true,
+ isSaving: true,
+ } );
expect( label ).toBe( 'Updatingโฆ' );
} );
it( 'should show scheduling if scheduled and saving in progress', () => {
- const label = PublishButtonLabel( { hasPublishAction: true, isBeingScheduled: true, isSaving: true } );
+ const label = PublishButtonLabel( {
+ hasPublishAction: true,
+ isBeingScheduled: true,
+ isSaving: true,
+ } );
expect( label ).toBe( 'Schedulingโฆ' );
} );
it( 'should show publish if not published and saving in progress', () => {
- const label = PublishButtonLabel( { hasPublishAction: true, isPublished: false, isSaving: true } );
+ const label = PublishButtonLabel( {
+ hasPublishAction: true,
+ isPublished: false,
+ isSaving: true,
+ } );
expect( label ).toBe( 'Publish' );
} );
@@ -30,12 +45,18 @@ describe( 'PublishButtonLabel', () => {
} );
it( 'should show update for already published', () => {
- const label = PublishButtonLabel( { hasPublishAction: true, isPublished: true } );
+ const label = PublishButtonLabel( {
+ hasPublishAction: true,
+ isPublished: true,
+ } );
expect( label ).toBe( 'Update' );
} );
it( 'should show schedule for scheduled', () => {
- const label = PublishButtonLabel( { hasPublishAction: true, isBeingScheduled: true } );
+ const label = PublishButtonLabel( {
+ hasPublishAction: true,
+ isBeingScheduled: true,
+ } );
expect( label ).toBe( 'Schedule' );
} );
diff --git a/packages/editor/src/components/post-publish-panel/index.js b/packages/editor/src/components/post-publish-panel/index.js
index 1a2db72556f94..4502e79882837 100644
--- a/packages/editor/src/components/post-publish-panel/index.js
+++ b/packages/editor/src/components/post-publish-panel/index.js
@@ -34,7 +34,11 @@ export class PostPublishPanel extends Component {
componentDidUpdate( prevProps ) {
// Automatically collapse the publish sidebar when a post
// is published and the user makes an edit.
- if ( prevProps.isPublished && ! this.props.isSaving && this.props.isDirty ) {
+ if (
+ prevProps.isPublished &&
+ ! this.props.isSaving &&
+ this.props.isDirty
+ ) {
this.props.onClose();
}
}
@@ -61,8 +65,13 @@ export class PostPublishPanel extends Component {
PrePublishExtension,
...additionalProps
} = this.props;
- const propsForPanel = omit( additionalProps, [ 'hasPublishAction', 'isDirty', 'isPostTypeViewable' ] );
- const isPublishedOrScheduled = isPublished || ( isScheduled && isBeingScheduled );
+ const propsForPanel = omit( additionalProps, [
+ 'hasPublishAction',
+ 'isDirty',
+ 'isPostTypeViewable',
+ ] );
+ const isPublishedOrScheduled =
+ isPublished || ( isScheduled && isBeingScheduled );
const isPrePublish = ! isPublishedOrScheduled && ! isSaving;
const isPostPublish = isPublishedOrScheduled && ! isSaving;
return (
@@ -70,11 +79,18 @@ export class PostPublishPanel extends Component {
{ isPostPublish ? (
- { isScheduled ? __( 'Scheduled' ) : __( 'Published' ) }
+ { isScheduled
+ ? __( 'Scheduled' )
+ : __( 'Published' ) }
) : (
) }
) }
{ isPostPublish && (
-
+
{ PostPublishExtension && }
) }
- { isSaving && ( ) }
+ { isSaving && }
{
- const { disablePublishSidebar, enablePublishSidebar } = dispatch( 'core/editor' );
+ const { disablePublishSidebar, enablePublishSidebar } = dispatch(
+ 'core/editor'
+ );
return {
- onTogglePublishSidebar: ( ) => {
+ onTogglePublishSidebar: () => {
if ( isPublishSidebarEnabled ) {
disablePublishSidebar();
} else {
diff --git a/packages/editor/src/components/post-publish-panel/maybe-post-format-panel.js b/packages/editor/src/components/post-publish-panel/maybe-post-format-panel.js
index d3a853b4eb713..fede6a0a33186 100644
--- a/packages/editor/src/components/post-publish-panel/maybe-post-format-panel.js
+++ b/packages/editor/src/components/post-publish-panel/maybe-post-format-panel.js
@@ -16,7 +16,11 @@ import { Button, PanelBody } from '@wordpress/components';
*/
import { POST_FORMATS } from '../post-format';
-const PostFormatSuggestion = ( { suggestedPostFormat, suggestionText, onUpdatePostFormat } ) => (
+const PostFormatSuggestion = ( {
+ suggestedPostFormat,
+ suggestionText,
+ onUpdatePostFormat,
+} ) => (
onUpdatePostFormat( suggestedPostFormat ) }>
{ suggestionText }
@@ -25,17 +29,17 @@ const PostFormatSuggestion = ( { suggestedPostFormat, suggestionText, onUpdatePo
const PostFormatPanel = ( { suggestion, onUpdatePostFormat } ) => {
const panelBodyTitle = [
__( 'Suggestion:' ),
- (
-
- { __( 'Use a post format' ) }
-
- ),
+
+ { __( 'Use a post format' ) }
+ ,
];
return (
-
+
- { __( 'Your theme uses post formats to highlight different kinds of content, like images or videos. Apply a post format to see this special styling.' ) }
+ { __(
+ 'Your theme uses post formats to highlight different kinds of content, like images or videos. Apply a post format to see this special styling.'
+ ) }
{
};
const getSuggestion = ( supportedFormats, suggestedPostFormat ) => {
- const formats = POST_FORMATS.filter( ( format ) => includes( supportedFormats, format.id ) );
+ const formats = POST_FORMATS.filter( ( format ) =>
+ includes( supportedFormats, format.id )
+ );
return find( formats, ( format ) => format.id === suggestedPostFormat );
};
export default compose(
withSelect( ( select ) => {
- const { getEditedPostAttribute, getSuggestedPostFormat } = select( 'core/editor' );
- const supportedFormats = get( select( 'core' ).getThemeSupports(), [ 'formats' ], [] );
+ const { getEditedPostAttribute, getSuggestedPostFormat } = select(
+ 'core/editor'
+ );
+ const supportedFormats = get(
+ select( 'core' ).getThemeSupports(),
+ [ 'formats' ],
+ []
+ );
return {
currentPostFormat: getEditedPostAttribute( 'format' ),
- suggestion: getSuggestion( supportedFormats, getSuggestedPostFormat() ),
+ suggestion: getSuggestion(
+ supportedFormats,
+ getSuggestedPostFormat()
+ ),
};
} ),
withDispatch( ( dispatch ) => ( {
@@ -70,5 +85,8 @@ export default compose(
dispatch( 'core/editor' ).editPost( { format: postFormat } );
},
} ) ),
- ifCondition( ( { suggestion, currentPostFormat } ) => suggestion && suggestion.id !== currentPostFormat ),
+ ifCondition(
+ ( { suggestion, currentPostFormat } ) =>
+ suggestion && suggestion.id !== currentPostFormat
+ )
)( PostFormatPanel );
diff --git a/packages/editor/src/components/post-publish-panel/maybe-tags-panel.js b/packages/editor/src/components/post-publish-panel/maybe-tags-panel.js
index 69d600fcae9e4..4f7a729688901 100644
--- a/packages/editor/src/components/post-publish-panel/maybe-tags-panel.js
+++ b/packages/editor/src/components/post-publish-panel/maybe-tags-panel.js
@@ -20,17 +20,17 @@ import FlatTermSelector from '../post-taxonomies/flat-term-selector';
const TagsPanel = () => {
const panelBodyTitle = [
__( 'Suggestion:' ),
- (
-
- { __( 'Add tags' ) }
-
- ),
+
+ { __( 'Add tags' ) }
+ ,
];
return (
- { __( 'Tags help users and search engines navigate your site and find your content. Add a few keywords to describe your post.' ) }
+ { __(
+ 'Tags help users and search engines navigate your site and find your content. Add a few keywords to describe your post.'
+ ) }
@@ -68,12 +68,21 @@ export default compose(
withSelect( ( select ) => {
const postType = select( 'core/editor' ).getCurrentPostType();
const tagsTaxonomy = select( 'core' ).getTaxonomy( 'post_tag' );
- const tags = tagsTaxonomy && select( 'core/editor' ).getEditedPostAttribute( tagsTaxonomy.rest_base );
+ const tags =
+ tagsTaxonomy &&
+ select( 'core/editor' ).getEditedPostAttribute(
+ tagsTaxonomy.rest_base
+ );
return {
areTagsFetched: tagsTaxonomy !== undefined,
- isPostTypeSupported: tagsTaxonomy && some( tagsTaxonomy.types, ( type ) => type === postType ),
+ isPostTypeSupported:
+ tagsTaxonomy &&
+ some( tagsTaxonomy.types, ( type ) => type === postType ),
hasTags: tags && tags.length,
};
} ),
- ifCondition( ( { areTagsFetched, isPostTypeSupported } ) => isPostTypeSupported && areTagsFetched ),
+ ifCondition(
+ ( { areTagsFetched, isPostTypeSupported } ) =>
+ isPostTypeSupported && areTagsFetched
+ )
)( MaybeTagsPanel );
diff --git a/packages/editor/src/components/post-publish-panel/postpublish.js b/packages/editor/src/components/post-publish-panel/postpublish.js
index 49a23ba7000ba..21ea2144d052f 100644
--- a/packages/editor/src/components/post-publish-panel/postpublish.js
+++ b/packages/editor/src/components/post-publish-panel/postpublish.js
@@ -6,11 +6,17 @@ import { get } from 'lodash';
/**
* WordPress dependencies
*/
-import { PanelBody, Button, ClipboardButton, TextControl } from '@wordpress/components';
+import {
+ PanelBody,
+ Button,
+ ClipboardButton,
+ TextControl,
+} from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import { Component, createRef } from '@wordpress/element';
import { withSelect } from '@wordpress/data';
import { safeDecodeURIComponent } from '@wordpress/url';
+import { decodeEntities } from '@wordpress/html-entities';
/**
* Internal dependencies
@@ -60,14 +66,22 @@ class PostPublishPanelPostpublish extends Component {
const postLabel = get( postType, [ 'labels', 'singular_name' ] );
const viewPostLabel = get( postType, [ 'labels', 'view_item' ] );
- const postPublishNonLinkHeader = isScheduled ?
- <>{ __( 'is now scheduled. It will go live on' ) } .> :
- __( 'is now live.' );
+ const postPublishNonLinkHeader = isScheduled ? (
+ <>
+ { __( 'is now scheduled. It will go live on' ) }{ ' ' }
+ .
+ >
+ ) : (
+ __( 'is now live.' )
+ );
return (
- { post.title || __( '(no title)' ) } { postPublishNonLinkHeader }
+
+ { decodeEntities( post.title ) || __( '(no title)' ) }
+ { ' ' }
+ { postPublishNonLinkHeader }
@@ -78,7 +92,8 @@ class PostPublishPanelPostpublish extends Component {
readOnly
label={ sprintf(
/* translators: %s: post type singular name */
- __( '%s address' ), postLabel
+ __( '%s address' ),
+ postLabel
) }
value={ safeDecodeURIComponent( post.link ) }
onFocus={ this.onSelectInput }
@@ -90,8 +105,14 @@ class PostPublishPanelPostpublish extends Component {
) }
-
- { this.state.showCopyConfirmation ? __( 'Copied!' ) : __( 'Copy Link' ) }
+
+ { this.state.showCopyConfirmation
+ ? __( 'Copied!' )
+ : __( 'Copy Link' ) }
@@ -102,7 +123,11 @@ class PostPublishPanelPostpublish extends Component {
}
export default withSelect( ( select ) => {
- const { getEditedPostAttribute, getCurrentPost, isCurrentPostScheduled } = select( 'core/editor' );
+ const {
+ getEditedPostAttribute,
+ getCurrentPost,
+ isCurrentPostScheduled,
+ } = select( 'core/editor' );
const { getPostType } = select( 'core' );
return {
diff --git a/packages/editor/src/components/post-publish-panel/prepublish.js b/packages/editor/src/components/post-publish-panel/prepublish.js
index 9368db03008db..916f42239fe2e 100644
--- a/packages/editor/src/components/post-publish-panel/prepublish.js
+++ b/packages/editor/src/components/post-publish-panel/prepublish.js
@@ -29,31 +29,55 @@ function PostPublishPanelPrepublish( {
if ( ! hasPublishAction ) {
prePublishTitle = __( 'Are you ready to submit for review?' );
- prePublishBodyText = __( 'When youโre ready, submit your work for review, and an Editor will be able to approve it for you.' );
+ prePublishBodyText = __(
+ 'When youโre ready, submit your work for review, and an Editor will be able to approve it for you.'
+ );
} else if ( isBeingScheduled ) {
prePublishTitle = __( 'Are you ready to schedule?' );
- prePublishBodyText = __( 'Your work will be published at the specified date and time.' );
+ prePublishBodyText = __(
+ 'Your work will be published at the specified date and time.'
+ );
} else {
prePublishTitle = __( 'Are you ready to publish?' );
- prePublishBodyText = __( 'Double-check your settings before publishing.' );
+ prePublishBodyText = __(
+ 'Double-check your settings before publishing.'
+ );
}
return (
-
{ prePublishTitle }
+
+ { prePublishTitle }
+
{ prePublishBodyText }
{ hasPublishAction && (
<>
-
,
- ] }>
+
+
+ ,
+ ] }
+ >
- ,
- ] }>
+
+
+ ,
+ ] }
+ >
>
@@ -65,15 +89,16 @@ function PostPublishPanelPrepublish( {
);
}
-export default withSelect(
- ( select ) => {
- const {
- getCurrentPost,
- isEditedPostBeingScheduled,
- } = select( 'core/editor' );
- return {
- hasPublishAction: get( getCurrentPost(), [ '_links', 'wp:action-publish' ], false ),
- isBeingScheduled: isEditedPostBeingScheduled(),
- };
- }
-)( PostPublishPanelPrepublish );
+export default withSelect( ( select ) => {
+ const { getCurrentPost, isEditedPostBeingScheduled } = select(
+ 'core/editor'
+ );
+ return {
+ hasPublishAction: get(
+ getCurrentPost(),
+ [ '_links', 'wp:action-publish' ],
+ false
+ ),
+ isBeingScheduled: isEditedPostBeingScheduled(),
+ };
+} )( PostPublishPanelPrepublish );
diff --git a/packages/editor/src/components/post-publish-panel/style.scss b/packages/editor/src/components/post-publish-panel/style.scss
index e1f31c46b413a..d4f6e4ce6333f 100644
--- a/packages/editor/src/components/post-publish-panel/style.scss
+++ b/packages/editor/src/components/post-publish-panel/style.scss
@@ -8,7 +8,6 @@
.components-spinner {
display: block;
- float: none;
margin: 100px auto 0;
}
}
diff --git a/packages/editor/src/components/post-publish-panel/test/index.js b/packages/editor/src/components/post-publish-panel/test/index.js
index ee0ac2411d3e2..96bea2969611d 100644
--- a/packages/editor/src/components/post-publish-panel/test/index.js
+++ b/packages/editor/src/components/post-publish-panel/test/index.js
@@ -22,39 +22,25 @@ describe( 'PostPublishPanel', () => {
it( 'should render the pre-publish panel if post status is scheduled but date is before now', () => {
const wrapper = shallow(
-
+
);
expect( wrapper ).toMatchSnapshot();
} );
it( 'should render the spinner if the post is being saved', () => {
- const wrapper = shallow(
-
- );
+ const wrapper = shallow( );
expect( wrapper ).toMatchSnapshot();
} );
it( 'should render the post-publish panel if the post is published', () => {
- const wrapper = shallow(
-
- );
+ const wrapper = shallow( );
expect( wrapper ).toMatchSnapshot();
} );
it( 'should render the post-publish panel if the post is scheduled', () => {
const wrapper = shallow(
-
+
);
expect( wrapper ).toMatchSnapshot();
} );
diff --git a/packages/editor/src/components/post-saved-state/index.js b/packages/editor/src/components/post-saved-state/index.js
index fcabe37c1f230..5d7cf3d475008 100644
--- a/packages/editor/src/components/post-saved-state/index.js
+++ b/packages/editor/src/components/post-saved-state/index.js
@@ -14,6 +14,7 @@ import { withSelect, withDispatch } from '@wordpress/data';
import { displayShortcut } from '@wordpress/keycodes';
import { withSafeTimeout, compose } from '@wordpress/compose';
import { withViewportMatch } from '@wordpress/viewport';
+import { Icon, check } from '@wordpress/icons';
/**
* Internal dependencies
@@ -61,16 +62,27 @@ export class PostSavedState extends Component {
// TODO: Classes generation should be common across all return
// paths of this function, including proper naming convention for
// the "Save Draft" button.
- const classes = classnames( 'editor-post-saved-state', 'is-saving', {
- 'is-autosaving': isAutosaving,
- } );
+ const classes = classnames(
+ 'editor-post-saved-state',
+ 'is-saving',
+ {
+ 'is-autosaving': isAutosaving,
+ }
+ );
return (
{ ( { className: animateClassName } ) => (
-
+
- { isAutosaving ? __( 'Autosaving' ) : __( 'Saving' ) }
+ { isAutosaving
+ ? __( 'Autosaving' )
+ : __( 'Saving' ) }
) }
@@ -88,7 +100,7 @@ export class PostSavedState extends Component {
if ( forceSavedMessage || ( ! isNew && ! isDirty ) ) {
return (
-
+
{ __( 'Saved' ) }
);
@@ -96,7 +108,11 @@ export class PostSavedState extends Component {
// Once the post has been submitted for review this button
// is not needed for the contributor role.
- const hasPublishAction = get( post, [ '_links', 'wp:action-publish' ], false );
+ const hasPublishAction = get(
+ post,
+ [ '_links', 'wp:action-publish' ],
+ false
+ );
if ( ! hasPublishAction && isPending ) {
return null;
}
diff --git a/packages/editor/src/components/post-saved-state/style.scss b/packages/editor/src/components/post-saved-state/style.scss
index 49f546627651a..7840f2816140a 100644
--- a/packages/editor/src/components/post-saved-state/style.scss
+++ b/packages/editor/src/components/post-saved-state/style.scss
@@ -7,10 +7,11 @@
overflow: hidden;
white-space: nowrap;
- .dashicon {
+ svg {
display: inline-block;
flex: 0 0 auto;
- margin-right: $grid-size;
+ margin-right: $grid-size-small;
+ fill: currentColor;
}
@include break-small() {
diff --git a/packages/editor/src/components/post-saved-state/test/index.js b/packages/editor/src/components/post-saved-state/test/index.js
index 38b094c642321..79636fdf0267b 100644
--- a/packages/editor/src/components/post-saved-state/test/index.js
+++ b/packages/editor/src/components/post-saved-state/test/index.js
@@ -15,7 +15,8 @@ describe( 'PostSavedState', () => {
isNew
isDirty={ false }
isSaving={ true }
- isSaveable={ false } />
+ isSaveable={ false }
+ />
);
expect( wrapper.text() ).toContain( 'Saving' );
@@ -27,7 +28,8 @@ describe( 'PostSavedState', () => {
isNew
isDirty={ false }
isSaving={ false }
- isSaveable={ false } />
+ isSaveable={ false }
+ />
);
expect( wrapper.type() ).toBeNull();
@@ -45,10 +47,11 @@ describe( 'PostSavedState', () => {
isNew={ false }
isDirty={ false }
isSaving={ false }
- isSaveable={ true } />
+ isSaveable={ true }
+ />
);
- expect( wrapper.childAt( 0 ).name() ).toBe( 'Dashicon' );
+ expect( wrapper.childAt( 0 ).name() ).toBe( 'Icon' );
expect( wrapper.childAt( 1 ).text() ).toBe( 'Saved' );
} );
diff --git a/packages/editor/src/components/post-schedule/check.js b/packages/editor/src/components/post-schedule/check.js
index 7495f216b014c..bc30eefe08e26 100644
--- a/packages/editor/src/components/post-schedule/check.js
+++ b/packages/editor/src/components/post-schedule/check.js
@@ -21,7 +21,11 @@ export default compose( [
withSelect( ( select ) => {
const { getCurrentPost, getCurrentPostType } = select( 'core/editor' );
return {
- hasPublishAction: get( getCurrentPost(), [ '_links', 'wp:action-publish' ], false ),
+ hasPublishAction: get(
+ getCurrentPost(),
+ [ '_links', 'wp:action-publish' ],
+ false
+ ),
postType: getCurrentPostType(),
};
} ),
diff --git a/packages/editor/src/components/post-schedule/index.js b/packages/editor/src/components/post-schedule/index.js
index 78a8a60c583b2..b22d2b94d809c 100644
--- a/packages/editor/src/components/post-schedule/index.js
+++ b/packages/editor/src/components/post-schedule/index.js
@@ -14,7 +14,9 @@ export function PostSchedule( { date, onUpdateDate } ) {
settings.formats.time
.toLowerCase() // Test only the lower case a
.replace( /\\\\/g, '' ) // Replace "//" with empty strings
- .split( '' ).reverse().join( '' ) // Reverse the string and test for "a" not followed by a slash
+ .split( '' )
+ .reverse()
+ .join( '' ) // Reverse the string and test for "a" not followed by a slash
);
return (
diff --git a/packages/editor/src/components/post-schedule/label.js b/packages/editor/src/components/post-schedule/label.js
index d00f69d2d9ecf..91a025b703d13 100644
--- a/packages/editor/src/components/post-schedule/label.js
+++ b/packages/editor/src/components/post-schedule/label.js
@@ -8,9 +8,12 @@ import { withSelect } from '@wordpress/data';
export function PostScheduleLabel( { date, isFloating } ) {
const settings = __experimentalGetSettings();
- return date && ! isFloating ?
- dateI18n( `${ settings.formats.date } ${ settings.formats.time }`, date ) :
- __( 'Immediately' );
+ return date && ! isFloating
+ ? dateI18n(
+ `${ settings.formats.date } ${ settings.formats.time }`,
+ date
+ )
+ : __( 'Immediately' );
}
export default withSelect( ( select ) => {
diff --git a/packages/editor/src/components/post-schedule/test/check.js b/packages/editor/src/components/post-schedule/test/check.js
index 6d0ce5be79515..768d8e8301ab9 100644
--- a/packages/editor/src/components/post-schedule/test/check.js
+++ b/packages/editor/src/components/post-schedule/test/check.js
@@ -10,12 +10,18 @@ import { PostScheduleCheck } from '../check';
describe( 'PostScheduleCheck', () => {
it( "should not render anything if the user doesn't have the right capabilities", () => {
- const wrapper = shallow( yes );
+ const wrapper = shallow(
+
+ yes
+
+ );
expect( wrapper.type() ).toBe( null );
} );
it( 'should render if the user has the correct capability', () => {
- const wrapper = shallow( yes );
+ const wrapper = shallow(
+ yes
+ );
expect( wrapper.type() ).not.toBe( null );
} );
} );
diff --git a/packages/editor/src/components/post-schedule/test/label.js b/packages/editor/src/components/post-schedule/test/label.js
index f1d063a0d0fcd..eec11bfe96487 100644
--- a/packages/editor/src/components/post-schedule/test/label.js
+++ b/packages/editor/src/components/post-schedule/test/label.js
@@ -16,13 +16,17 @@ describe( 'PostScheduleLabel', () => {
it( 'should show the post will be published immediately if it has a floating date', () => {
const date = '2018-09-17T01:23:45.678Z';
- const wrapper = shallow( );
+ const wrapper = shallow(
+
+ );
expect( wrapper.text() ).toBe( 'Immediately' );
} );
it( 'should show the scheduled publish date if a date has been set', () => {
const date = '2018-09-17T01:23:45.678Z';
- const wrapper = shallow( );
+ const wrapper = shallow(
+
+ );
expect( wrapper.text() ).not.toBe( 'Immediately' );
} );
} );
diff --git a/packages/editor/src/components/post-slug/check.js b/packages/editor/src/components/post-slug/check.js
index 6b243bd6b9f64..80928e4cf1dec 100644
--- a/packages/editor/src/components/post-slug/check.js
+++ b/packages/editor/src/components/post-slug/check.js
@@ -5,6 +5,8 @@ import PostTypeSupportCheck from '../post-type-support-check';
export default function PostSlugCheck( { children } ) {
return (
- { children }
+
+ { children }
+
);
}
diff --git a/packages/editor/src/components/post-slug/index.js b/packages/editor/src/components/post-slug/index.js
index 9a9b2200e72be..6a578c1c7bc20 100644
--- a/packages/editor/src/components/post-slug/index.js
+++ b/packages/editor/src/components/post-slug/index.js
@@ -18,7 +18,10 @@ export class PostSlug extends Component {
super( ...arguments );
this.state = {
- editedSlug: safeDecodeURIComponent( postSlug ) || cleanForSlug( postTitle ) || postID,
+ editedSlug:
+ safeDecodeURIComponent( postSlug ) ||
+ cleanForSlug( postTitle ) ||
+ postID,
};
this.setSlug = this.setSlug.bind( this );
@@ -50,7 +53,9 @@ export class PostSlug extends Component {
type="text"
id={ inputId }
value={ editedSlug }
- onChange={ ( event ) => this.setState( { editedSlug: event.target.value } ) }
+ onChange={ ( event ) =>
+ this.setState( { editedSlug: event.target.value } )
+ }
onBlur={ this.setSlug }
className="editor-post-slug__input"
/>
@@ -61,10 +66,9 @@ export class PostSlug extends Component {
export default compose( [
withSelect( ( select ) => {
- const {
- getCurrentPost,
- getEditedPostAttribute,
- } = select( 'core/editor' );
+ const { getCurrentPost, getEditedPostAttribute } = select(
+ 'core/editor'
+ );
const { id } = getCurrentPost();
return {
diff --git a/packages/editor/src/components/post-slug/test/check.js b/packages/editor/src/components/post-slug/test/check.js
index 90fe356236adb..bb8bd3bf1f07e 100644
--- a/packages/editor/src/components/post-slug/test/check.js
+++ b/packages/editor/src/components/post-slug/test/check.js
@@ -10,11 +10,7 @@ import PostSlugCheck from '../check';
describe( 'PostSlugCheck', () => {
it( 'should render control', () => {
- const wrapper = shallow(
-
- slug
-
- );
+ const wrapper = shallow( slug );
expect( wrapper.type() ).not.toBe( null );
} );
diff --git a/packages/editor/src/components/post-slug/test/index.js b/packages/editor/src/components/post-slug/test/index.js
index cf25f25e0fe37..80bdf0b072e9f 100644
--- a/packages/editor/src/components/post-slug/test/index.js
+++ b/packages/editor/src/components/post-slug/test/index.js
@@ -11,10 +11,7 @@ import { PostSlug } from '../';
describe( 'PostSlug', () => {
describe( '#render()', () => {
it( 'should update internal slug', () => {
- const wrapper = shallow(
-
- );
+ const wrapper = shallow( );
wrapper.find( 'input' ).simulate( 'change', {
target: {
@@ -28,9 +25,7 @@ describe( 'PostSlug', () => {
it( 'should update slug', () => {
const onUpdateSlug = jest.fn();
const wrapper = shallow(
-
+
);
wrapper.find( 'input' ).simulate( 'blur', {
diff --git a/packages/editor/src/components/post-sticky/check.js b/packages/editor/src/components/post-sticky/check.js
index 949c18cf43efd..4757ece4da48f 100644
--- a/packages/editor/src/components/post-sticky/check.js
+++ b/packages/editor/src/components/post-sticky/check.js
@@ -10,10 +10,7 @@ import { compose } from '@wordpress/compose';
import { withSelect } from '@wordpress/data';
export function PostStickyCheck( { hasStickyAction, postType, children } ) {
- if (
- postType !== 'post' ||
- ! hasStickyAction
- ) {
+ if ( postType !== 'post' || ! hasStickyAction ) {
return null;
}
@@ -24,7 +21,11 @@ export default compose( [
withSelect( ( select ) => {
const post = select( 'core/editor' ).getCurrentPost();
return {
- hasStickyAction: get( post, [ '_links', 'wp:action-sticky' ], false ),
+ hasStickyAction: get(
+ post,
+ [ '_links', 'wp:action-sticky' ],
+ false
+ ),
postType: select( 'core/editor' ).getCurrentPostType(),
};
} ),
diff --git a/packages/editor/src/components/post-sticky/index.js b/packages/editor/src/components/post-sticky/index.js
index 9cc787d19a8b1..6458c4fdcaeda 100644
--- a/packages/editor/src/components/post-sticky/index.js
+++ b/packages/editor/src/components/post-sticky/index.js
@@ -26,7 +26,9 @@ export function PostSticky( { onUpdateSticky, postSticky = false } ) {
export default compose( [
withSelect( ( select ) => {
return {
- postSticky: select( 'core/editor' ).getEditedPostAttribute( 'sticky' ),
+ postSticky: select( 'core/editor' ).getEditedPostAttribute(
+ 'sticky'
+ ),
};
} ),
withDispatch( ( dispatch ) => {
diff --git a/packages/editor/src/components/post-switch-to-draft-button/index.js b/packages/editor/src/components/post-switch-to-draft-button/index.js
index d1b9f360c0a5c..122b5f8377e76 100644
--- a/packages/editor/src/components/post-switch-to-draft-button/index.js
+++ b/packages/editor/src/components/post-switch-to-draft-button/index.js
@@ -21,9 +21,13 @@ function PostSwitchToDraftButton( {
const onSwitch = () => {
let alertMessage;
if ( isPublished ) {
- alertMessage = __( 'Are you sure you want to unpublish this post?' );
+ alertMessage = __(
+ 'Are you sure you want to unpublish this post?'
+ );
} else if ( isScheduled ) {
- alertMessage = __( 'Are you sure you want to unschedule this post?' );
+ alertMessage = __(
+ 'Are you sure you want to unschedule this post?'
+ );
}
// eslint-disable-next-line no-alert
if ( window.confirm( alertMessage ) ) {
@@ -45,7 +49,11 @@ function PostSwitchToDraftButton( {
export default compose( [
withSelect( ( select ) => {
- const { isSavingPost, isCurrentPostPublished, isCurrentPostScheduled } = select( 'core/editor' );
+ const {
+ isSavingPost,
+ isCurrentPostPublished,
+ isCurrentPostScheduled,
+ } = select( 'core/editor' );
return {
isSaving: isSavingPost(),
isPublished: isCurrentPostPublished(),
@@ -62,4 +70,3 @@ export default compose( [
};
} ),
] )( PostSwitchToDraftButton );
-
diff --git a/packages/editor/src/components/post-taxonomies/check.js b/packages/editor/src/components/post-taxonomies/check.js
index ab078b1bc70da..75877745b0da7 100644
--- a/packages/editor/src/components/post-taxonomies/check.js
+++ b/packages/editor/src/components/post-taxonomies/check.js
@@ -10,7 +10,9 @@ import { compose } from '@wordpress/compose';
import { withSelect } from '@wordpress/data';
export function PostTaxonomiesCheck( { postType, taxonomies, children } ) {
- const hasTaxonomies = some( taxonomies, ( taxonomy ) => includes( taxonomy.types, postType ) );
+ const hasTaxonomies = some( taxonomies, ( taxonomy ) =>
+ includes( taxonomy.types, postType )
+ );
if ( ! hasTaxonomies ) {
return null;
}
@@ -26,4 +28,3 @@ export default compose( [
};
} ),
] )( PostTaxonomiesCheck );
-
diff --git a/packages/editor/src/components/post-taxonomies/flat-term-selector.js b/packages/editor/src/components/post-taxonomies/flat-term-selector.js
index da6b0782966d4..299245a5e45aa 100644
--- a/packages/editor/src/components/post-taxonomies/flat-term-selector.js
+++ b/packages/editor/src/components/post-taxonomies/flat-term-selector.js
@@ -34,7 +34,8 @@ const DEFAULT_QUERY = {
_fields: 'id,name',
};
const MAX_TERMS_SUGGESTIONS = 20;
-const isSameTermName = ( termA, termB ) => termA.toLowerCase() === termB.toLowerCase();
+const isSameTermName = ( termA, termB ) =>
+ termA.toLowerCase() === termB.toLowerCase();
/**
* Returns a term object with name unescaped.
@@ -118,7 +119,14 @@ class FlatTermSelector extends Component {
request.then( unescapeTerms ).then( ( terms ) => {
this.setState( ( state ) => ( {
availableTerms: state.availableTerms.concat(
- terms.filter( ( term ) => ! find( state.availableTerms, ( availableTerm ) => availableTerm.id === term.id ) )
+ terms.filter(
+ ( term ) =>
+ ! find(
+ state.availableTerms,
+ ( availableTerm ) =>
+ availableTerm.id === term.id
+ )
+ )
),
} ) );
this.updateSelectedTerms( this.props.terms );
@@ -129,7 +137,10 @@ class FlatTermSelector extends Component {
updateSelectedTerms( terms = [] ) {
const selectedTerms = terms.reduce( ( accumulator, termId ) => {
- const termObject = find( this.state.availableTerms, ( term ) => term.id === termId );
+ const termObject = find(
+ this.state.availableTerms,
+ ( term ) => term.id === termId
+ );
if ( termObject ) {
accumulator.push( termObject.name );
}
@@ -149,32 +160,44 @@ class FlatTermSelector extends Component {
path: `/wp/v2/${ taxonomy.rest_base }`,
method: 'POST',
data: { name: termNameEscaped },
- } ).catch( ( error ) => {
- const errorCode = error.code;
- if ( errorCode === 'term_exists' ) {
- // If the terms exist, fetch it instead of creating a new one.
- this.addRequest = apiFetch( {
- path: addQueryArgs( `/wp/v2/${ taxonomy.rest_base }`, { ...DEFAULT_QUERY, search: termNameEscaped } ),
- } ).then( unescapeTerms );
- return this.addRequest.then( ( searchResult ) => {
- return find( searchResult, ( result ) => isSameTermName( result.name, termName ) );
- } );
- }
- return Promise.reject( error );
- } ).then( unescapeTerm );
+ } )
+ .catch( ( error ) => {
+ const errorCode = error.code;
+ if ( errorCode === 'term_exists' ) {
+ // If the terms exist, fetch it instead of creating a new one.
+ this.addRequest = apiFetch( {
+ path: addQueryArgs( `/wp/v2/${ taxonomy.rest_base }`, {
+ ...DEFAULT_QUERY,
+ search: termNameEscaped,
+ } ),
+ } ).then( unescapeTerms );
+ return this.addRequest.then( ( searchResult ) => {
+ return find( searchResult, ( result ) =>
+ isSameTermName( result.name, termName )
+ );
+ } );
+ }
+ return Promise.reject( error );
+ } )
+ .then( unescapeTerm );
}
onChange( termNames ) {
const uniqueTerms = uniqBy( termNames, ( term ) => term.toLowerCase() );
this.setState( { selectedTerms: uniqueTerms } );
- const newTermNames = uniqueTerms.filter( ( termName ) =>
- ! find( this.state.availableTerms, ( term ) => isSameTermName( term.name, termName ) )
+ const newTermNames = uniqueTerms.filter(
+ ( termName ) =>
+ ! find( this.state.availableTerms, ( term ) =>
+ isSameTermName( term.name, termName )
+ )
);
const termNamesToIds = ( names, availableTerms ) => {
- return names
- .map( ( termName ) =>
- find( availableTerms, ( term ) => isSameTermName( term.name, termName ) ).id
- );
+ return names.map(
+ ( termName ) =>
+ find( availableTerms, ( term ) =>
+ isSameTermName( term.name, termName )
+ ).id
+ );
};
if ( newTermNames.length === 0 ) {
@@ -183,16 +206,18 @@ class FlatTermSelector extends Component {
this.props.taxonomy.rest_base
);
}
- Promise
- .all( newTermNames.map( this.findOrCreateTerm ) )
- .then( ( newTerms ) => {
- const newAvailableTerms = this.state.availableTerms.concat( newTerms );
+ Promise.all( newTermNames.map( this.findOrCreateTerm ) ).then(
+ ( newTerms ) => {
+ const newAvailableTerms = this.state.availableTerms.concat(
+ newTerms
+ );
this.setState( { availableTerms: newAvailableTerms } );
return this.props.onUpdateTerms(
termNamesToIds( uniqueTerms, newAvailableTerms ),
this.props.taxonomy.rest_base
);
- } );
+ }
+ );
}
searchTerms( search = '' ) {
@@ -219,9 +244,18 @@ class FlatTermSelector extends Component {
[ 'labels', 'singular_name' ],
slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' )
);
- const termAddedLabel = sprintf( _x( '%s added', 'term' ), singularName );
- const termRemovedLabel = sprintf( _x( '%s removed', 'term' ), singularName );
- const removeTermLabel = sprintf( _x( 'Remove %s', 'term' ), singularName );
+ const termAddedLabel = sprintf(
+ _x( '%s added', 'term' ),
+ singularName
+ );
+ const termRemovedLabel = sprintf(
+ _x( '%s removed', 'term' ),
+ singularName
+ );
+ const removeTermLabel = sprintf(
+ _x( 'Remove %s', 'term' ),
+ singularName
+ );
return (
{
- return ( ( ! term.parent && ! parent ) || parseInt( term.parent ) === parseInt( parent ) ) &&
- term.name.toLowerCase() === name.toLowerCase();
+ return (
+ ( ( ! term.parent && ! parent ) ||
+ parseInt( term.parent ) === parseInt( parent ) ) &&
+ term.name.toLowerCase() === name.toLowerCase()
+ );
} );
}
@@ -95,11 +112,18 @@ class HierarchicalTermSelector extends Component {
}
// check if the term we are adding already exists
- const existingTerm = this.findTerm( availableTerms, formParent, formName );
+ const existingTerm = this.findTerm(
+ availableTerms,
+ formParent,
+ formName
+ );
if ( existingTerm ) {
// if the term we are adding exists but is not selected select it
if ( ! some( terms, ( term ) => term === existingTerm.id ) ) {
- onUpdateTerms( [ ...terms, existingTerm.id ], taxonomy.rest_base );
+ onUpdateTerms(
+ [ ...terms, existingTerm.id ],
+ taxonomy.rest_base
+ );
}
this.setState( {
formName: '',
@@ -120,28 +144,32 @@ class HierarchicalTermSelector extends Component {
},
} );
// Tries to create a term or fetch it if it already exists
- const findOrCreatePromise = this.addRequest
- .catch( ( error ) => {
- const errorCode = error.code;
- if ( errorCode === 'term_exists' ) {
- // search the new category created since last fetch
- this.addRequest = apiFetch( {
- path: addQueryArgs(
- `/wp/v2/${ taxonomy.rest_base }`,
- { ...DEFAULT_QUERY, parent: formParent || 0, search: formName }
- ),
- } );
- return this.addRequest
- .then( ( searchResult ) => {
- return this.findTerm( searchResult, formParent, formName );
- } );
- }
- return Promise.reject( error );
- } );
- findOrCreatePromise
- .then( ( term ) => {
- const hasTerm = !! find( this.state.availableTerms, ( availableTerm ) => availableTerm.id === term.id );
- const newAvailableTerms = hasTerm ? this.state.availableTerms : [ term, ...this.state.availableTerms ];
+ const findOrCreatePromise = this.addRequest.catch( ( error ) => {
+ const errorCode = error.code;
+ if ( errorCode === 'term_exists' ) {
+ // search the new category created since last fetch
+ this.addRequest = apiFetch( {
+ path: addQueryArgs( `/wp/v2/${ taxonomy.rest_base }`, {
+ ...DEFAULT_QUERY,
+ parent: formParent || 0,
+ search: formName,
+ } ),
+ } );
+ return this.addRequest.then( ( searchResult ) => {
+ return this.findTerm( searchResult, formParent, formName );
+ } );
+ }
+ return Promise.reject( error );
+ } );
+ findOrCreatePromise.then(
+ ( term ) => {
+ const hasTerm = !! find(
+ this.state.availableTerms,
+ ( availableTerm ) => availableTerm.id === term.id
+ );
+ const newAvailableTerms = hasTerm
+ ? this.state.availableTerms
+ : [ term, ...this.state.availableTerms ];
const termAddedMessage = sprintf(
_x( '%s added', 'term' ),
get(
@@ -157,10 +185,13 @@ class HierarchicalTermSelector extends Component {
formName: '',
formParent: '',
availableTerms: newAvailableTerms,
- availableTermsTree: this.sortBySelected( buildTermsTree( newAvailableTerms ) ),
+ availableTermsTree: this.sortBySelected(
+ buildTermsTree( newAvailableTerms )
+ ),
} );
onUpdateTerms( [ ...terms, term.id ], taxonomy.rest_base );
- }, ( xhr ) => {
+ },
+ ( xhr ) => {
if ( xhr.statusText === 'abort' ) {
return;
}
@@ -168,7 +199,8 @@ class HierarchicalTermSelector extends Component {
this.setState( {
adding: false,
} );
- } );
+ }
+ );
}
componentDidMount() {
@@ -192,11 +224,17 @@ class HierarchicalTermSelector extends Component {
return;
}
this.fetchRequest = apiFetch( {
- path: addQueryArgs( `/wp/v2/${ taxonomy.rest_base }`, DEFAULT_QUERY ),
+ path: addQueryArgs(
+ `/wp/v2/${ taxonomy.rest_base }`,
+ DEFAULT_QUERY
+ ),
} );
this.fetchRequest.then(
- ( terms ) => { // resolve
- const availableTermsTree = this.sortBySelected( buildTermsTree( terms ) );
+ ( terms ) => {
+ // resolve
+ const availableTermsTree = this.sortBySelected(
+ buildTermsTree( terms )
+ );
this.fetchRequest = null;
this.setState( {
@@ -205,7 +243,8 @@ class HierarchicalTermSelector extends Component {
availableTerms: terms,
} );
},
- ( xhr ) => { // reject
+ ( xhr ) => {
+ // reject
if ( xhr.statusText === 'abort' ) {
return;
}
@@ -226,7 +265,10 @@ class HierarchicalTermSelector extends Component {
if ( undefined === termTree.children ) {
return false;
}
- const anyChildIsSelected = termTree.children.map( treeHasSelection ).filter( ( child ) => child ).length > 0;
+ const anyChildIsSelected =
+ termTree.children
+ .map( treeHasSelection )
+ .filter( ( child ) => child ).length > 0;
if ( anyChildIsSelected ) {
return true;
}
@@ -257,7 +299,9 @@ class HierarchicalTermSelector extends Component {
setFilterValue( event ) {
const { availableTermsTree } = this.state;
const filterValue = event.target.value;
- const filteredTermsTree = availableTermsTree.map( this.getFilterMatcher( filterValue ) ).filter( ( term ) => term );
+ const filteredTermsTree = availableTermsTree
+ .map( this.getFilterMatcher( filterValue ) )
+ .filter( ( term ) => term );
const getResultCount = ( terms ) => {
let count = 0;
for ( let i = 0; i < terms.length; i++ ) {
@@ -268,12 +312,10 @@ class HierarchicalTermSelector extends Component {
}
return count;
};
- this.setState(
- {
- filterValue,
- filteredTermsTree,
- }
- );
+ this.setState( {
+ filterValue,
+ filteredTermsTree,
+ } );
const resultCount = getResultCount( filteredTermsTree );
const resultsFoundMessage = sprintf(
@@ -296,12 +338,20 @@ class HierarchicalTermSelector extends Component {
// Map and filter the children, recursive so we deal with grandchildren
// and any deeper levels.
if ( term.children.length > 0 ) {
- term.children = term.children.map( matchTermsForFilter ).filter( ( child ) => child );
+ term.children = term.children
+ .map( matchTermsForFilter )
+ .filter( ( child ) => child );
}
// If the term's name contains the filterValue, or it has children
// (i.e. some child matched at some point in the tree) then return it.
- if ( -1 !== term.name.toLowerCase().indexOf( filterValue.toLowerCase() ) || term.children.length > 0 ) {
+ if (
+ -1 !==
+ term.name
+ .toLowerCase()
+ .indexOf( filterValue.toLowerCase() ) ||
+ term.children.length > 0
+ ) {
return term;
}
@@ -316,7 +366,10 @@ class HierarchicalTermSelector extends Component {
const { terms = [] } = this.props;
return renderedTerms.map( ( term ) => {
return (
-
+
{
@@ -336,18 +389,38 @@ class HierarchicalTermSelector extends Component {
}
render() {
- const { slug, taxonomy, instanceId, hasCreateAction, hasAssignAction } = this.props;
+ const {
+ slug,
+ taxonomy,
+ instanceId,
+ hasCreateAction,
+ hasAssignAction,
+ } = this.props;
if ( ! hasAssignAction ) {
return null;
}
- const { availableTermsTree, availableTerms, filteredTermsTree, formName, formParent, loading, showForm, filterValue } = this.state;
- const labelWithFallback = ( labelProperty, fallbackIsCategory, fallbackIsNotCategory ) => get(
- taxonomy,
- [ 'labels', labelProperty ],
- slug === 'category' ? fallbackIsCategory : fallbackIsNotCategory
- );
+ const {
+ availableTermsTree,
+ availableTerms,
+ filteredTermsTree,
+ formName,
+ formParent,
+ loading,
+ showForm,
+ filterValue,
+ } = this.state;
+ const labelWithFallback = (
+ labelProperty,
+ fallbackIsCategory,
+ fallbackIsNotCategory
+ ) =>
+ get(
+ taxonomy,
+ [ 'labels', labelProperty ],
+ slug === 'category' ? fallbackIsCategory : fallbackIsNotCategory
+ );
const newTermButtonLabel = labelWithFallback(
'add_new_item',
__( 'Add new category' ),
@@ -380,19 +453,21 @@ class HierarchicalTermSelector extends Component {
const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;
return [
- showFilter &&
- { filterLabel }
- ,
- showFilter && ,
+ showFilter && (
+
+ { filterLabel }
+
+ ),
+ showFilter && (
+
+ ),
- { this.renderTerms( '' !== filterValue ? filteredTermsTree : availableTermsTree ) }
+ { this.renderTerms(
+ '' !== filterValue ? filteredTermsTree : availableTermsTree
+ ) }
,
! loading && hasCreateAction && (
- { !! availableTerms.length &&
+ { !! availableTerms.length && (
- }
+ ) }
includes( taxonomy.types, postType ) );
- const visibleTaxonomies = filter( availableTaxonomies, ( taxonomy ) => taxonomy.visibility.show_ui );
+export function PostTaxonomies( {
+ postType,
+ taxonomies,
+ taxonomyWrapper = identity,
+} ) {
+ const availableTaxonomies = filter( taxonomies, ( taxonomy ) =>
+ includes( taxonomy.types, postType )
+ );
+ const visibleTaxonomies = filter(
+ availableTaxonomies,
+ ( taxonomy ) => taxonomy.visibility.show_ui
+ );
return visibleTaxonomies.map( ( taxonomy ) => {
- const TaxonomyComponent = taxonomy.hierarchical ? HierarchicalTermSelector : FlatTermSelector;
+ const TaxonomyComponent = taxonomy.hierarchical
+ ? HierarchicalTermSelector
+ : FlatTermSelector;
return (
- {
- taxonomyWrapper(
- ,
- taxonomy
- )
- }
+ { taxonomyWrapper(
+ ,
+ taxonomy
+ ) }
);
} );
@@ -42,4 +51,3 @@ export default compose( [
};
} ),
] )( PostTaxonomies );
-
diff --git a/packages/editor/src/components/post-taxonomies/test/index.js b/packages/editor/src/components/post-taxonomies/test/index.js
index b7a941eb65801..40d043072013c 100644
--- a/packages/editor/src/components/post-taxonomies/test/index.js
+++ b/packages/editor/src/components/post-taxonomies/test/index.js
@@ -43,7 +43,8 @@ describe( 'PostTaxonomies', () => {
};
const wrapperOne = shallow(
-
);
@@ -51,7 +52,8 @@ describe( 'PostTaxonomies', () => {
expect( wrapperOne ).toHaveLength( 1 );
const wrapperTwo = shallow(
- {
};
const wrapperOne = shallow(
-
+
);
expect( wrapperOne.at( 0 ) ).toHaveLength( 1 );
const wrapperTwo = shallow(
-
-
+
{ __( 'Type text or HTML' ) }