From 7cd6894db6b28f957a23bba6ec8a4aa52752eb70 Mon Sep 17 00:00:00 2001
From: George Mamadashvili
Date: Fri, 5 Jan 2024 12:58:07 +0400
Subject: [PATCH 01/22] Clean up e2e tests package (#57575)
---
.../experiments/experimental-features.js | 39 ---------
.../fixtures/menu-items-request-fixture.json | 84 -------------------
2 files changed, 123 deletions(-)
delete mode 100644 packages/e2e-tests/specs/experiments/experimental-features.js
delete mode 100644 packages/e2e-tests/specs/experiments/fixtures/menu-items-request-fixture.json
diff --git a/packages/e2e-tests/specs/experiments/experimental-features.js b/packages/e2e-tests/specs/experiments/experimental-features.js
deleted file mode 100644
index 3c33f930012dde..00000000000000
--- a/packages/e2e-tests/specs/experiments/experimental-features.js
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * WordPress dependencies
- */
-import { addQueryArgs } from '@wordpress/url';
-import { visitAdminPage } from '@wordpress/e2e-test-utils';
-
-async function setExperimentalFeaturesState( features, enable ) {
- const query = addQueryArgs( '', {
- page: 'gutenberg-experiments',
- } );
- 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( [
- page.waitForNavigation( { waitUntil: 'networkidle0' } ),
- page.click( '#submit' ),
- ] );
-}
-
-/**
- * Establishes test lifecycle to enable experimental feature for the duration of
- * the grouped test block.
- *
- * @param {Array} features Array of {string} selectors of settings to enable.
- * Assumes they can be enabled with one click.
- */
-export function useExperimentalFeatures( features ) {
- beforeAll( () => setExperimentalFeaturesState( features, true ) );
- afterAll( () => setExperimentalFeaturesState( features, false ) );
-}
diff --git a/packages/e2e-tests/specs/experiments/fixtures/menu-items-request-fixture.json b/packages/e2e-tests/specs/experiments/fixtures/menu-items-request-fixture.json
deleted file mode 100644
index 01b844c45ceee4..00000000000000
--- a/packages/e2e-tests/specs/experiments/fixtures/menu-items-request-fixture.json
+++ /dev/null
@@ -1,84 +0,0 @@
-[
- {
- "title": "Home",
- "url": "http://localhost:8889/",
- "menu_order": 1
- },
- {
- "title": "About",
- "type": "post_type",
- "object": "page",
- "menu_order": 2
- },
- {
- "title": "Our team",
- "type": "post_type",
- "object": "page",
- "menu_order": 3,
- "parent": 1
- },
- {
- "title": "Shop",
- "type": "post_type",
- "object": "page",
- "menu_order": 4
- },
- {
- "title": "Winter apparel",
- "type": "post_type",
- "object": "page",
- "menu_order": 5,
- "parent": 3
- },
- {
- "title": "Chunky socks",
- "type": "post_type",
- "object": "page",
- "menu_order": 6,
- "parent": 4
- },
- {
- "title": "Hideous hats",
- "type": "post_type",
- "object": "page",
- "menu_order": 7,
- "parent": 4
- },
- {
- "title": "Glorious gloves",
- "type": "post_type",
- "object": "page",
- "menu_order": 8,
- "parent": 4
- },
- {
- "title": "Jazzy Jumpers",
- "type": "post_type",
- "object": "page",
- "menu_order": 9,
- "parent": 4
- },
- {
- "title": "Shipping",
- "type": "post_type",
- "object": "page",
- "menu_order": 10
- },
- {
- "title": "Contact Us",
- "type": "post_type",
- "object": "page",
- "menu_order": 11
- },
- {
- "title": "WordPress.org",
- "url": "https://wordpress.org",
- "menu_order": 12
- },
- {
- "title": "Google",
- "url": "https://google.com",
- "menu_order": 13,
- "parent": 11
- }
-]
From dd4373729a716f3e805af58361862359f8bc7810 Mon Sep 17 00:00:00 2001
From: George Mamadashvili
Date: Fri, 5 Jan 2024 13:03:59 +0400
Subject: [PATCH 02/22] Migrate 'editor modes' e2e tests to Playwright (#57574)
* Migrate 'editor modes' e2e tests to Playwright
* Remove old test file
* Update inline comment
---
.../specs/editor/various/editor-modes.test.js | 163 ------------------
.../specs/editor/various/editor-modes.spec.js | 158 +++++++++++++++++
2 files changed, 158 insertions(+), 163 deletions(-)
delete mode 100644 packages/e2e-tests/specs/editor/various/editor-modes.test.js
create mode 100644 test/e2e/specs/editor/various/editor-modes.spec.js
diff --git a/packages/e2e-tests/specs/editor/various/editor-modes.test.js b/packages/e2e-tests/specs/editor/various/editor-modes.test.js
deleted file mode 100644
index bb051fe705b38d..00000000000000
--- a/packages/e2e-tests/specs/editor/various/editor-modes.test.js
+++ /dev/null
@@ -1,163 +0,0 @@
-/**
- * WordPress dependencies
- */
-import {
- clickBlockAppender,
- clickBlockToolbarButton,
- clickMenuItem,
- createNewPost,
- getCurrentPostContent,
- switchEditorModeTo,
- pressKeyTimes,
- pressKeyWithModifier,
- openTypographyToolsPanelMenu,
- canvas,
-} from '@wordpress/e2e-test-utils';
-
-describe( 'Editing modes (visual/HTML)', () => {
- beforeEach( async () => {
- await createNewPost();
- await clickBlockAppender();
- await page.keyboard.type( 'Hello world!' );
- } );
-
- it( 'should switch between visual and HTML modes', async () => {
- // This block should be in "visual" mode by default.
- let visualBlock = await canvas().$$( '[data-block].rich-text' );
- expect( visualBlock ).toHaveLength( 1 );
-
- // Change editing mode from "Visual" to "HTML".
- await clickBlockToolbarButton( 'Options' );
- await clickMenuItem( 'Edit as HTML' );
-
- // Wait for the block to be converted to HTML editing mode.
- const htmlBlock = await canvas().$$(
- '[data-block] .block-editor-block-list__block-html-textarea'
- );
- expect( htmlBlock ).toHaveLength( 1 );
-
- // Change editing mode from "HTML" back to "Visual".
- await clickBlockToolbarButton( 'Options' );
- await clickMenuItem( 'Edit visually' );
-
- // This block should be in "visual" mode by default.
- visualBlock = await canvas().$$( '[data-block].rich-text' );
- expect( visualBlock ).toHaveLength( 1 );
- } );
-
- it( 'should display sidebar in HTML mode', async () => {
- // Change editing mode from "Visual" to "HTML".
- await clickBlockToolbarButton( 'Options' );
- await clickMenuItem( 'Edit as HTML' );
-
- // The `drop cap` toggle for the paragraph block should appear, even in
- // HTML editing mode.
- await openTypographyToolsPanelMenu();
- await page.click( 'button[aria-label="Show Drop cap"]' );
-
- const dropCapToggle = await page.$x(
- "//label[contains(text(), 'Drop cap')]"
- );
-
- expect( dropCapToggle ).toHaveLength( 1 );
- } );
-
- it( 'should update HTML in HTML mode when sidebar is used', async () => {
- // Change editing mode from "Visual" to "HTML".
- await clickBlockToolbarButton( 'Options' );
- await clickMenuItem( 'Edit as HTML' );
-
- // Make sure the paragraph content is rendered as expected.
- let htmlBlockContent = await canvas().$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 `drop cap` using the sidebar.
- await openTypographyToolsPanelMenu();
- await page.click( 'button[aria-label="Show Drop cap"]' );
-
- const [ dropCapToggle ] = await page.$x(
- "//label[contains(text(), 'Drop cap')]"
- );
- await dropCapToggle.click();
-
- // Make sure the HTML content updated.
- htmlBlockContent = await canvas().$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 () => {
- // The paragraph block should be selected.
- const title = await page.$eval(
- '.block-editor-block-card__title',
- ( element ) => element.innerText
- );
- expect( title ).toBe( 'Paragraph' );
-
- // The Block inspector should be active.
- let [ blockInspectorTab ] = await page.$x(
- '//button[@role="tab"][@aria-selected="true"][contains(text(), "Block")]'
- );
- expect( blockInspectorTab ).not.toBeNull();
-
- await switchEditorModeTo( 'Code' );
-
- // The Block inspector should not be active anymore.
- [ blockInspectorTab ] = await page.$x(
- '//button[@role="tab"][@aria-selected="true"][contains(text(), "Block")]'
- );
- expect( blockInspectorTab ).toBeUndefined();
-
- // No block is selected.
- const inactiveBlockInspectorTab = await page.waitForXPath(
- '//button[@role="tab"][contains(text(), "Block")]'
- );
- inactiveBlockInspectorTab.click();
- const noBlocksElement = page.waitForSelector(
- '.block-editor-block-inspector__no-blocks'
- );
- expect( noBlocksElement ).not.toBeNull();
-
- // The inserter is disabled.
- const disabledInserter = await page.$(
- '.editor-document-tools__inserter-toggle:disabled, .editor-document-tools__inserter-toggle[aria-disabled="true"]'
- );
- expect( disabledInserter ).not.toBeNull();
- } );
-
- // Test for regressions of https://github.com/WordPress/gutenberg/issues/24054.
- it( 'saves content when using the shortcut in the Code Editor', async () => {
- await switchEditorModeTo( 'Code' );
-
- const textContent = await page.evaluate(
- () => document.querySelector( '.editor-post-text-editor' ).value
- );
- const editPosition = textContent.indexOf( 'Hello' );
-
- // Replace the word 'Hello' with 'Hi'.
- await canvas().click( '.editor-post-title__input' );
- await page.keyboard.press( 'Tab' );
- await pressKeyTimes( 'ArrowRight', editPosition );
- await pressKeyTimes( 'Delete', 5 );
- await page.keyboard.type( 'Hi' );
-
- // Save the post using the shortcut.
- await pressKeyWithModifier( 'primary', 's' );
- await page.waitForSelector( '.editor-post-saved-state.is-saved' );
-
- await switchEditorModeTo( 'Visual' );
-
- expect( await getCurrentPostContent() ).toMatchInlineSnapshot( `
- "
- Hi world!
- "
- ` );
- } );
-} );
diff --git a/test/e2e/specs/editor/various/editor-modes.spec.js b/test/e2e/specs/editor/various/editor-modes.spec.js
new file mode 100644
index 00000000000000..5d5ae9a70ab5cf
--- /dev/null
+++ b/test/e2e/specs/editor/various/editor-modes.spec.js
@@ -0,0 +1,158 @@
+/**
+ * WordPress dependencies
+ */
+const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );
+
+test.describe( 'Editing modes (visual/HTML)', () => {
+ test.beforeEach( async ( { admin, editor } ) => {
+ await admin.createNewPost();
+ await editor.insertBlock( {
+ name: 'core/paragraph',
+ attributes: { content: 'Hello world!' },
+ } );
+ } );
+
+ test( 'should switch between visual and HTML modes', async ( {
+ editor,
+ } ) => {
+ const paragraphBlock = editor.canvas.getByRole( 'document', {
+ name: 'Block: Paragraph',
+ } );
+
+ // This block should be in "visual" mode by default.
+ await expect( paragraphBlock ).toHaveClass( /rich-text/ );
+
+ // Change editing mode from "Visual" to "HTML".
+ await editor.clickBlockOptionsMenuItem( 'Edit as HTML' );
+
+ // Wait for the block to be converted to HTML editing mode.
+ await expect( paragraphBlock.getByRole( 'textbox' ) ).toBeVisible();
+
+ // Change editing mode from "HTML" back to "Visual".
+ await editor.clickBlockOptionsMenuItem( 'Edit visually' );
+
+ // This block should be in "visual" mode again.
+ await expect( paragraphBlock ).toHaveClass( /rich-text/ );
+ } );
+
+ test( 'should display sidebar in HTML mode', async ( { editor, page } ) => {
+ await editor.clickBlockOptionsMenuItem( 'Edit as HTML' );
+ await editor.openDocumentSettingsSidebar();
+
+ // The `drop cap` toggle for the paragraph block should appear, even in
+ // HTML editing mode.
+ await page
+ .getByRole( 'button', { name: 'Typography options' } )
+ .click();
+ await page
+ .getByRole( 'menuitemcheckbox', { name: 'Show Drop cap' } )
+ .click();
+
+ await expect(
+ page.getByRole( 'checkbox', { name: 'Drop cap' } )
+ ).toBeVisible();
+ } );
+
+ test( 'should update HTML in HTML mode when sidebar is used', async ( {
+ editor,
+ page,
+ } ) => {
+ await editor.clickBlockOptionsMenuItem( 'Edit as HTML' );
+ await editor.openDocumentSettingsSidebar();
+
+ const paragraphHTML = editor.canvas
+ .getByRole( 'document', {
+ name: 'Block: Paragraph',
+ } )
+ .getByRole( 'textbox' );
+
+ // Make sure the paragraph content is rendered as expected.
+ await expect( paragraphHTML ).toHaveValue( 'Hello world!
' );
+
+ // Change the `drop cap` using the sidebar.
+ await page
+ .getByRole( 'button', { name: 'Typography options' } )
+ .click();
+ await page
+ .getByRole( 'menuitemcheckbox', { name: 'Show Drop cap' } )
+ .click();
+ await page.getByRole( 'checkbox', { name: 'Drop cap' } ).check();
+
+ // Make sure the HTML content updated.
+ await expect( paragraphHTML ).toHaveValue(
+ 'Hello world!
'
+ );
+ } );
+
+ test( 'the code editor should unselect blocks and disable the inserter', async ( {
+ editor,
+ page,
+ pageUtils,
+ } ) => {
+ await editor.openDocumentSettingsSidebar();
+ const editorSettings = page.getByRole( 'region', {
+ name: 'Editor settings',
+ } );
+ const activeTab = editorSettings.getByRole( 'tab', { selected: true } );
+
+ // The Block inspector should be active.
+ await expect( activeTab ).toHaveText( 'Block' );
+ await expect(
+ editorSettings.locator( '.block-editor-block-card__title' )
+ ).toHaveText( 'Paragraph' );
+
+ // Open the code editor.
+ await pageUtils.pressKeys( 'secondary+M' );
+
+ // The Block inspector should not be active anymore.
+ await expect( activeTab ).not.toHaveText( 'Block' );
+
+ await editorSettings.getByRole( 'tab', { name: 'Block' } ).click();
+ await expect(
+ editorSettings.locator( '.block-editor-block-inspector__no-blocks' )
+ ).toHaveText( 'No block selected.' );
+
+ await expect(
+ page
+ .getByRole( 'toolbar', { name: 'Document tools' } )
+ .getByRole( 'button', { name: 'Toggle block inserter' } )
+ ).toBeDisabled();
+
+ // Go back to the visual editor.
+ await pageUtils.pressKeys( 'secondary+M' );
+ } );
+
+ // Test for regressions of https://github.com/WordPress/gutenberg/issues/24054.
+ test( 'saves content when using the shortcut in the Code Editor', async ( {
+ editor,
+ page,
+ pageUtils,
+ } ) => {
+ // Open the code editor.
+ await pageUtils.pressKeys( 'secondary+M' );
+
+ // Change content.
+ await page.getByRole( 'textbox', { name: 'Type text or HTML' } )
+ .fill( `
+Hi world!
+` );
+
+ // Save the post using the shortcut.
+ await pageUtils.pressKeys( 'primary+s' );
+ await expect(
+ page
+ .getByRole( 'button', { name: 'Dismiss this notice' } )
+ .filter( { hasText: 'Draft saved' } )
+ ).toBeVisible();
+
+ // Go back to the visual editor.
+ await pageUtils.pressKeys( 'secondary+M' );
+
+ await expect.poll( editor.getBlocks ).toMatchObject( [
+ {
+ name: 'core/paragraph',
+ attributes: { content: 'Hi world!' },
+ },
+ ] );
+ } );
+} );
From f79b07472ce13f3bb3a9f7bc67d5008f3b044cbe Mon Sep 17 00:00:00 2001
From: Daniel Richards
Date: Fri, 5 Jan 2024 17:20:08 +0800
Subject: [PATCH 03/22] Code Quality: Improve inserter pattern constants
(#57570)
* Remove unusued synced & unsynced types
* Remove all value from pattern types constant
* Remove all SYNC_TYPE
* Rename PATTERN_TYPES in inserter to INSERTER_PATTERN_TYPES
* Rename SYNC_TYPES in inserter to INSERTER_SYNC_TYPES
---
.../components/block-patterns-list/index.js | 13 +++++----
.../inserter-draggable-blocks/index.js | 4 +--
.../block-patterns-explorer/pattern-list.js | 4 +--
.../pattern-category-previews.js | 4 +--
.../block-patterns-tab/patterns-filter.js | 28 ++++++++++---------
.../use-pattern-categories.js | 4 +--
.../inserter/block-patterns-tab/utils.js | 23 ++++++++-------
.../inserter/hooks/use-patterns-state.js | 4 +--
packages/block-editor/src/store/utils.js | 4 +--
9 files changed, 46 insertions(+), 42 deletions(-)
diff --git a/packages/block-editor/src/components/block-patterns-list/index.js b/packages/block-editor/src/components/block-patterns-list/index.js
index c79d6927c00f07..4b8c37846bad84 100644
--- a/packages/block-editor/src/components/block-patterns-list/index.js
+++ b/packages/block-editor/src/components/block-patterns-list/index.js
@@ -24,7 +24,7 @@ import { unlock } from '../../lock-unlock';
import BlockPreview from '../block-preview';
import InserterDraggableBlocks from '../inserter-draggable-blocks';
import BlockPatternsPaging from '../block-patterns-paging';
-import { PATTERN_TYPES } from '../inserter/block-patterns-tab/utils';
+import { INSERTER_PATTERN_TYPES } from '../inserter/block-patterns-tab/utils';
const {
CompositeV2: Composite,
@@ -78,7 +78,8 @@ function BlockPattern( {
>
@@ -97,7 +98,7 @@ function BlockPattern( {
{
'block-editor-block-patterns-list__list-item-synced':
pattern.type ===
- PATTERN_TYPES.user &&
+ INSERTER_PATTERN_TYPES.user &&
! pattern.syncStatus,
}
) }
@@ -122,7 +123,8 @@ function BlockPattern( {
/>
- { pattern.type === PATTERN_TYPES.user &&
+ { pattern.type ===
+ INSERTER_PATTERN_TYPES.user &&
! pattern.syncStatus && (
) }
{ ( ! showTooltip ||
- pattern.type === PATTERN_TYPES.user ) && (
+ pattern.type ===
+ INSERTER_PATTERN_TYPES.user ) && (
{ pattern.title }
diff --git a/packages/block-editor/src/components/inserter-draggable-blocks/index.js b/packages/block-editor/src/components/inserter-draggable-blocks/index.js
index c6f008426288e1..cdaadcb0f36eb5 100644
--- a/packages/block-editor/src/components/inserter-draggable-blocks/index.js
+++ b/packages/block-editor/src/components/inserter-draggable-blocks/index.js
@@ -12,7 +12,7 @@ import { useSelect } from '@wordpress/data';
* Internal dependencies
*/
import BlockDraggableChip from '../block-draggable/draggable-chip';
-import { PATTERN_TYPES } from '../inserter/block-patterns-tab/utils';
+import { INSERTER_PATTERN_TYPES } from '../inserter/block-patterns-tab/utils';
const InserterDraggableBlocks = ( {
isEnabled,
@@ -42,7 +42,7 @@ const InserterDraggableBlocks = ( {
transferData={ transferData }
onDragStart={ ( event ) => {
const parsedBlocks =
- pattern?.type === PATTERN_TYPES.user &&
+ pattern?.type === INSERTER_PATTERN_TYPES.user &&
pattern?.syncStatus !== 'unsynced'
? [ createBlock( 'core/block', { ref: pattern.id } ) ]
: blocks;
diff --git a/packages/block-editor/src/components/inserter/block-patterns-explorer/pattern-list.js b/packages/block-editor/src/components/inserter/block-patterns-explorer/pattern-list.js
index bf2867be5cdf3c..217f3f21b573df 100644
--- a/packages/block-editor/src/components/inserter/block-patterns-explorer/pattern-list.js
+++ b/packages/block-editor/src/components/inserter/block-patterns-explorer/pattern-list.js
@@ -18,7 +18,7 @@ import { searchItems } from '../search-items';
import BlockPatternsPaging from '../../block-patterns-paging';
import usePatternsPaging from '../hooks/use-patterns-paging';
import {
- PATTERN_TYPES,
+ INSERTER_PATTERN_TYPES,
allPatternsCategory,
myPatternsCategory,
} from '../block-patterns-tab/utils';
@@ -73,7 +73,7 @@ function PatternList( { searchValue, selectedCategory, patternCategories } ) {
}
if (
selectedCategory === myPatternsCategory.name &&
- pattern.type === PATTERN_TYPES.user
+ pattern.type === INSERTER_PATTERN_TYPES.user
) {
return true;
}
diff --git a/packages/block-editor/src/components/inserter/block-patterns-tab/pattern-category-previews.js b/packages/block-editor/src/components/inserter/block-patterns-tab/pattern-category-previews.js
index 071a9c479003fa..7b8fd8e76202a2 100644
--- a/packages/block-editor/src/components/inserter/block-patterns-tab/pattern-category-previews.js
+++ b/packages/block-editor/src/components/inserter/block-patterns-tab/pattern-category-previews.js
@@ -30,7 +30,7 @@ import {
isPatternFiltered,
allPatternsCategory,
myPatternsCategory,
- PATTERN_TYPES,
+ INSERTER_PATTERN_TYPES,
} from './utils';
const noop = () => {};
@@ -73,7 +73,7 @@ export function PatternCategoryPreviews( {
if (
category.name === myPatternsCategory.name &&
- pattern.type === PATTERN_TYPES.user
+ pattern.type === INSERTER_PATTERN_TYPES.user
) {
return true;
}
diff --git a/packages/block-editor/src/components/inserter/block-patterns-tab/patterns-filter.js b/packages/block-editor/src/components/inserter/block-patterns-tab/patterns-filter.js
index 04a0f27d162dd4..e6056c07f0d472 100644
--- a/packages/block-editor/src/components/inserter/block-patterns-tab/patterns-filter.js
+++ b/packages/block-editor/src/components/inserter/block-patterns-tab/patterns-filter.js
@@ -16,11 +16,13 @@ import { useMemo, createInterpolateElement } from '@wordpress/element';
/**
* Internal dependencies
*/
-import { myPatternsCategory, SYNC_TYPES, PATTERN_TYPES } from './utils';
-
-const getShouldDisableSyncFilter = ( sourceFilter ) =>
- sourceFilter !== PATTERN_TYPES.all && sourceFilter !== PATTERN_TYPES.user;
+import {
+ myPatternsCategory,
+ INSERTER_SYNC_TYPES,
+ INSERTER_PATTERN_TYPES,
+} from './utils';
+const getShouldDisableSyncFilter = ( sourceFilter ) => sourceFilter !== 'all';
const getShouldDisableNonUserSources = ( category ) => {
return category.name === myPatternsCategory.name;
};
@@ -39,7 +41,7 @@ export function PatternsFilter( {
// this filter themselves.
const currentPatternSourceFilter =
category.name === myPatternsCategory.name
- ? PATTERN_TYPES.user
+ ? INSERTER_PATTERN_TYPES.user
: patternSourceFilter;
// We need to disable the sync filter option if the source filter is not 'all' or 'user'
@@ -56,11 +58,11 @@ export function PatternsFilter( {
const patternSyncMenuOptions = useMemo(
() => [
{
- value: SYNC_TYPES.all,
+ value: 'all',
label: _x( 'All', 'Option that shows all patterns' ),
},
{
- value: SYNC_TYPES.full,
+ value: INSERTER_SYNC_TYPES.full,
label: _x(
'Synced',
'Option that shows all synchronized patterns'
@@ -68,7 +70,7 @@ export function PatternsFilter( {
disabled: shouldDisableSyncFilter,
},
{
- value: SYNC_TYPES.unsynced,
+ value: INSERTER_SYNC_TYPES.unsynced,
label: _x(
'Not synced',
'Option that shows all patterns that are not synchronized'
@@ -82,22 +84,22 @@ export function PatternsFilter( {
const patternSourceMenuOptions = useMemo(
() => [
{
- value: PATTERN_TYPES.all,
+ value: 'all',
label: __( 'All' ),
disabled: shouldDisableNonUserSources,
},
{
- value: PATTERN_TYPES.directory,
+ value: INSERTER_PATTERN_TYPES.directory,
label: __( 'Pattern Directory' ),
disabled: shouldDisableNonUserSources,
},
{
- value: PATTERN_TYPES.theme,
+ value: INSERTER_PATTERN_TYPES.theme,
label: __( 'Theme & Plugins' ),
disabled: shouldDisableNonUserSources,
},
{
- value: PATTERN_TYPES.user,
+ value: INSERTER_PATTERN_TYPES.user,
label: __( 'User' ),
},
],
@@ -107,7 +109,7 @@ export function PatternsFilter( {
function handleSetSourceFilterChange( newSourceFilter ) {
setPatternSourceFilter( newSourceFilter );
if ( getShouldDisableSyncFilter( newSourceFilter ) ) {
- setPatternSyncFilter( SYNC_TYPES.all );
+ setPatternSyncFilter( 'all' );
}
}
diff --git a/packages/block-editor/src/components/inserter/block-patterns-tab/use-pattern-categories.js b/packages/block-editor/src/components/inserter/block-patterns-tab/use-pattern-categories.js
index 9f4d598ce37cbf..cff5fbf3413820 100644
--- a/packages/block-editor/src/components/inserter/block-patterns-tab/use-pattern-categories.js
+++ b/packages/block-editor/src/components/inserter/block-patterns-tab/use-pattern-categories.js
@@ -14,7 +14,7 @@ import {
isPatternFiltered,
allPatternsCategory,
myPatternsCategory,
- PATTERN_TYPES,
+ INSERTER_PATTERN_TYPES,
} from './utils';
function hasRegisteredCategory( pattern, allCategories ) {
@@ -69,7 +69,7 @@ export function usePatternCategories( rootClientId, sourceFilter = 'all' ) {
}
if (
filteredPatterns.some(
- ( pattern ) => pattern.type === PATTERN_TYPES.user
+ ( pattern ) => pattern.type === INSERTER_PATTERN_TYPES.user
)
) {
categories.unshift( myPatternsCategory );
diff --git a/packages/block-editor/src/components/inserter/block-patterns-tab/utils.js b/packages/block-editor/src/components/inserter/block-patterns-tab/utils.js
index b1e5a99bbe6dc6..189c87c39e5edc 100644
--- a/packages/block-editor/src/components/inserter/block-patterns-tab/utils.js
+++ b/packages/block-editor/src/components/inserter/block-patterns-tab/utils.js
@@ -4,17 +4,13 @@
import { __ } from '@wordpress/i18n';
-export const PATTERN_TYPES = {
- all: 'all',
- synced: 'synced',
- unsynced: 'unsynced',
+export const INSERTER_PATTERN_TYPES = {
user: 'user',
theme: 'theme',
directory: 'directory',
};
-export const SYNC_TYPES = {
- all: 'all',
+export const INSERTER_SYNC_TYPES = {
full: 'fully',
unsynced: 'unsynced',
};
@@ -38,7 +34,7 @@ export function isPatternFiltered( pattern, sourceFilter, syncFilter ) {
// If theme source selected, filter out user created patterns and those from
// the core patterns directory.
if (
- sourceFilter === PATTERN_TYPES.theme &&
+ sourceFilter === INSERTER_PATTERN_TYPES.theme &&
( isUserPattern || isDirectoryPattern )
) {
return true;
@@ -47,7 +43,7 @@ export function isPatternFiltered( pattern, sourceFilter, syncFilter ) {
// If the directory source is selected, filter out user created patterns
// and those bundled with the theme.
if (
- sourceFilter === PATTERN_TYPES.directory &&
+ sourceFilter === INSERTER_PATTERN_TYPES.directory &&
( isUserPattern || ! isDirectoryPattern )
) {
return true;
@@ -55,19 +51,22 @@ export function isPatternFiltered( pattern, sourceFilter, syncFilter ) {
// If user source selected, filter out theme patterns.
if (
- sourceFilter === PATTERN_TYPES.user &&
- pattern.type !== PATTERN_TYPES.user
+ sourceFilter === INSERTER_PATTERN_TYPES.user &&
+ pattern.type !== INSERTER_PATTERN_TYPES.user
) {
return true;
}
// Filter by sync status.
- if ( syncFilter === SYNC_TYPES.full && pattern.syncStatus !== '' ) {
+ if (
+ syncFilter === INSERTER_SYNC_TYPES.full &&
+ pattern.syncStatus !== ''
+ ) {
return true;
}
if (
- syncFilter === SYNC_TYPES.unsynced &&
+ syncFilter === INSERTER_SYNC_TYPES.unsynced &&
pattern.syncStatus !== 'unsynced' &&
isUserPattern
) {
diff --git a/packages/block-editor/src/components/inserter/hooks/use-patterns-state.js b/packages/block-editor/src/components/inserter/hooks/use-patterns-state.js
index 576768c76abca9..b5c8c8551b1118 100644
--- a/packages/block-editor/src/components/inserter/hooks/use-patterns-state.js
+++ b/packages/block-editor/src/components/inserter/hooks/use-patterns-state.js
@@ -11,7 +11,7 @@ import { store as noticesStore } from '@wordpress/notices';
* Internal dependencies
*/
import { store as blockEditorStore } from '../../../store';
-import { PATTERN_TYPES } from '../block-patterns-tab/utils';
+import { INSERTER_PATTERN_TYPES } from '../block-patterns-tab/utils';
/**
* Retrieves the block patterns inserter state.
@@ -58,7 +58,7 @@ const usePatternsState = ( onInsert, rootClientId ) => {
const onClickPattern = useCallback(
( pattern, blocks ) => {
const patternBlocks =
- pattern.type === PATTERN_TYPES.user &&
+ pattern.type === INSERTER_PATTERN_TYPES.user &&
pattern.syncStatus !== 'unsynced'
? [ createBlock( 'core/block', { ref: pattern.id } ) ]
: blocks;
diff --git a/packages/block-editor/src/store/utils.js b/packages/block-editor/src/store/utils.js
index 0103b5192154c4..99281f55fcd093 100644
--- a/packages/block-editor/src/store/utils.js
+++ b/packages/block-editor/src/store/utils.js
@@ -1,7 +1,7 @@
/**
* Internal dependencies
*/
-import { PATTERN_TYPES } from '../components/inserter/block-patterns-tab/utils';
+import { INSERTER_PATTERN_TYPES } from '../components/inserter/block-patterns-tab/utils';
const EMPTY_ARRAY = [];
@@ -18,7 +18,7 @@ export function getUserPatterns( state ) {
return {
name: `core/block/${ userPattern.id }`,
id: userPattern.id,
- type: PATTERN_TYPES.user,
+ type: INSERTER_PATTERN_TYPES.user,
title: userPattern.title.raw,
categories: userPattern.wp_pattern_category.map( ( catId ) =>
categories && categories.get( catId )
From 9325972ca1422e6b76ca2c516ba656e70ef41b60 Mon Sep 17 00:00:00 2001
From: Riad Benguella
Date: Fri, 5 Jan 2024 10:44:22 +0100
Subject: [PATCH 04/22] Editor: Unify the top toolbar preference (#57531)
Co-authored-by: Jerry Jones
---
.../src/editor/set-is-fixed-toolbar.ts | 2 +-
packages/edit-post/src/components/header/index.js | 2 +-
.../src/components/header/writing-menu/index.js | 4 ++--
.../src/components/preferences-modal/index.js | 3 ++-
packages/edit-post/src/editor.js | 9 +--------
packages/edit-post/src/editor.native.js | 14 ++------------
.../src/hooks/commands/use-common-commands.js | 2 +-
packages/edit-post/src/index.js | 2 +-
packages/edit-post/src/index.native.js | 5 ++++-
packages/edit-post/src/store/actions.js | 2 +-
packages/edit-post/src/store/test/actions.js | 4 ++--
.../block-editor/use-site-editor-settings.js | 6 ------
.../src/components/header-edit-mode/index.js | 5 +----
.../components/header-edit-mode/more-menu/index.js | 4 ++--
packages/edit-site/src/components/layout/index.js | 2 +-
.../src/components/preferences-modal/index.js | 2 +-
.../src/hooks/commands/use-edit-mode-commands.js | 2 +-
packages/edit-site/src/index.js | 2 +-
packages/edit-site/src/store/actions.js | 2 +-
packages/edit-site/src/store/test/actions.js | 4 ++--
.../provider/use-block-editor-settings.js | 10 ++++++++--
.../convert-editor-settings.js | 1 +
.../preferences-package-data/test/index.js | 5 +++--
test/e2e/specs/editor/blocks/links.spec.js | 4 ++--
24 files changed, 42 insertions(+), 56 deletions(-)
diff --git a/packages/e2e-test-utils-playwright/src/editor/set-is-fixed-toolbar.ts b/packages/e2e-test-utils-playwright/src/editor/set-is-fixed-toolbar.ts
index 93c2cd14e1ebc5..ab7baef5967f0f 100644
--- a/packages/e2e-test-utils-playwright/src/editor/set-is-fixed-toolbar.ts
+++ b/packages/e2e-test-utils-playwright/src/editor/set-is-fixed-toolbar.ts
@@ -15,6 +15,6 @@ export async function setIsFixedToolbar( this: Editor, isFixed: boolean ) {
await this.page.evaluate( ( _isFixed ) => {
window.wp.data
.dispatch( 'core/preferences' )
- .set( 'core/edit-post', 'fixedToolbar', _isFixed );
+ .set( 'core', 'fixedToolbar', _isFixed );
}, isFixed );
}
diff --git a/packages/edit-post/src/components/header/index.js b/packages/edit-post/src/components/header/index.js
index 82705424175f35..b76b89ff7673db 100644
--- a/packages/edit-post/src/components/header/index.js
+++ b/packages/edit-post/src/components/header/index.js
@@ -82,7 +82,7 @@ function Header( { setEntitiesSavedStatesCallback } ) {
select( editorStore ).getRenderingMode() === 'template-only',
isPublishSidebarOpened:
select( editPostStore ).isPublishSidebarOpened(),
- hasFixedToolbar: getPreference( 'core/edit-post', 'fixedToolbar' ),
+ hasFixedToolbar: getPreference( 'core', 'fixedToolbar' ),
showIconLabels: getPreference( 'core', 'showIconLabels' ),
};
}, [] );
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 f0a4dc762ac5c0..0c01a4df24f3a5 100644
--- a/packages/edit-post/src/components/header/writing-menu/index.js
+++ b/packages/edit-post/src/components/header/writing-menu/index.js
@@ -27,7 +27,7 @@ function WritingMenu() {
const toggleDistractionFree = () => {
registry.batch( () => {
- setPreference( 'core/edit-post', 'fixedToolbar', true );
+ setPreference( 'core', 'fixedToolbar', true );
setIsInserterOpened( false );
setIsListViewOpened( false );
closeGeneralSidebar();
@@ -46,7 +46,7 @@ function WritingMenu() {
return (
{
- setPreference( 'core/edit-post', 'fixedToolbar', true );
+ setPreference( 'core', 'fixedToolbar', true );
setIsInserterOpened( false );
setIsListViewOpened( false );
closeGeneralSidebar();
@@ -186,6 +186,7 @@ export default function EditPostPreferencesModal() {
) }
>
{
- const { isFeatureActive, getEditorMode, getHiddenBlockTypes } =
- select( editPostStore );
+ const { getEditorMode, getHiddenBlockTypes } = select( editPostStore );
const { getBlockTypes } = select( blocksStore );
return {
- hasFixedToolbar: isFeatureActive( 'fixedToolbar' ),
mode: getEditorMode(),
hiddenBlockTypes: getHiddenBlockTypes(),
blockTypes: getBlockTypes(),
diff --git a/packages/edit-post/src/hooks/commands/use-common-commands.js b/packages/edit-post/src/hooks/commands/use-common-commands.js
index c43fafab0af653..eb8b73e20a9f1d 100644
--- a/packages/edit-post/src/hooks/commands/use-common-commands.js
+++ b/packages/edit-post/src/hooks/commands/use-common-commands.js
@@ -134,7 +134,7 @@ export default function useCommonCommands() {
name: 'core/toggle-top-toolbar',
label: __( 'Toggle top toolbar' ),
callback: ( { close } ) => {
- toggle( 'core/edit-post', 'fixedToolbar' );
+ toggle( 'core', 'fixedToolbar' );
if ( isDistractionFree ) {
toggleDistractionFree();
}
diff --git a/packages/edit-post/src/index.js b/packages/edit-post/src/index.js
index 1b7b41e46afa1d..0395c1f4beefa3 100644
--- a/packages/edit-post/src/index.js
+++ b/packages/edit-post/src/index.js
@@ -55,7 +55,6 @@ export function initializeEditor(
dispatch( preferencesStore ).setDefaults( 'core/edit-post', {
editorMode: 'visual',
- fixedToolbar: false,
fullscreenMode: true,
hiddenBlockTypes: [],
inactivePanels: [],
@@ -69,6 +68,7 @@ export function initializeEditor(
dispatch( preferencesStore ).setDefaults( 'core', {
allowRightClickOverrides: true,
+ fixedToolbar: false,
showBlockBreadcrumbs: true,
showIconLabels: false,
showListViewByDefault: false,
diff --git a/packages/edit-post/src/index.native.js b/packages/edit-post/src/index.native.js
index b825d50ace0c01..2828d5317d232e 100644
--- a/packages/edit-post/src/index.native.js
+++ b/packages/edit-post/src/index.native.js
@@ -23,7 +23,6 @@ import Editor from './editor';
export function initializeEditor( id, postType, postId ) {
dispatch( preferencesStore ).setDefaults( 'core/edit-post', {
editorMode: 'visual',
- fixedToolbar: false,
fullscreenMode: true,
hiddenBlockTypes: [],
inactivePanels: [],
@@ -33,5 +32,9 @@ export function initializeEditor( id, postType, postId ) {
welcomeGuide: true,
} );
+ dispatch( preferencesStore ).setDefaults( 'core', {
+ fixedToolbar: false,
+ } );
+
return ;
}
diff --git a/packages/edit-post/src/store/actions.js b/packages/edit-post/src/store/actions.js
index 8bf784aad16d5d..c862fdcb33572a 100644
--- a/packages/edit-post/src/store/actions.js
+++ b/packages/edit-post/src/store/actions.js
@@ -585,7 +585,7 @@ export const toggleDistractionFree =
registry.batch( () => {
registry
.dispatch( preferencesStore )
- .set( 'core/edit-post', 'fixedToolbar', true );
+ .set( 'core', 'fixedToolbar', true );
registry.dispatch( editorStore ).setIsInserterOpened( false );
registry.dispatch( editorStore ).setIsListViewOpened( false );
dispatch.closeGeneralSidebar();
diff --git a/packages/edit-post/src/store/test/actions.js b/packages/edit-post/src/store/test/actions.js
index 82c80eb0f5273e..65dcfcf85fc676 100644
--- a/packages/edit-post/src/store/test/actions.js
+++ b/packages/edit-post/src/store/test/actions.js
@@ -259,7 +259,7 @@ describe( 'actions', () => {
// Enable everything that shouldn't be enabled in distraction free mode.
registry
.dispatch( preferencesStore )
- .set( 'core/edit-post', 'fixedToolbar', true );
+ .set( 'core', 'fixedToolbar', true );
registry.dispatch( editorStore ).setIsListViewOpened( true );
registry
.dispatch( editPostStore )
@@ -269,7 +269,7 @@ describe( 'actions', () => {
expect(
registry
.select( preferencesStore )
- .get( 'core/edit-post', 'fixedToolbar' )
+ .get( 'core', 'fixedToolbar' )
).toBe( true );
expect( registry.select( editorStore ).isListViewOpened() ).toBe(
false
diff --git a/packages/edit-site/src/components/block-editor/use-site-editor-settings.js b/packages/edit-site/src/components/block-editor/use-site-editor-settings.js
index 5328048cc0742a..4bc25690e83389 100644
--- a/packages/edit-site/src/components/block-editor/use-site-editor-settings.js
+++ b/packages/edit-site/src/components/block-editor/use-site-editor-settings.js
@@ -95,7 +95,6 @@ export function useSpecificEditorSettings() {
const {
templateSlug,
isDistractionFree,
- hasFixedToolbar,
canvasMode,
settings,
postWithTemplate,
@@ -124,9 +123,6 @@ export function useSpecificEditorSettings() {
'core/edit-site',
'distractionFree'
),
- hasFixedToolbar:
- !! getPreference( 'core/edit-site', 'fixedToolbar' ) ||
- ! isLargeViewport,
canvasMode: getCanvasMode(),
settings: getSettings(),
postWithTemplate: _context?.postId,
@@ -144,7 +140,6 @@ export function useSpecificEditorSettings() {
supportsTemplateMode: true,
focusMode: canvasMode !== 'view',
isDistractionFree,
- hasFixedToolbar,
defaultRenderingMode,
getPostLinkProps,
// I wonder if they should be set in the post editor too
@@ -155,7 +150,6 @@ export function useSpecificEditorSettings() {
settings,
canvasMode,
isDistractionFree,
- hasFixedToolbar,
defaultRenderingMode,
getPostLinkProps,
archiveLabels.archiveTypeLabel,
diff --git a/packages/edit-site/src/components/header-edit-mode/index.js b/packages/edit-site/src/components/header-edit-mode/index.js
index 9c74930def5e64..b513569589649c 100644
--- a/packages/edit-site/src/components/header-edit-mode/index.js
+++ b/packages/edit-site/src/components/header-edit-mode/index.js
@@ -70,10 +70,7 @@ export default function HeaderEditMode() {
editorCanvasView: unlock(
select( editSiteStore )
).getEditorCanvasContainerView(),
- hasFixedToolbar: getPreference(
- editSiteStore.name,
- 'fixedToolbar'
- ),
+ hasFixedToolbar: getPreference( 'core', 'fixedToolbar' ),
isDistractionFree: getPreference(
editSiteStore.name,
'distractionFree'
diff --git a/packages/edit-site/src/components/header-edit-mode/more-menu/index.js b/packages/edit-site/src/components/header-edit-mode/more-menu/index.js
index 4d56cf4670ab91..ef672aed976f70 100644
--- a/packages/edit-site/src/components/header-edit-mode/more-menu/index.js
+++ b/packages/edit-site/src/components/header-edit-mode/more-menu/index.js
@@ -46,7 +46,7 @@ export default function MoreMenu( { showIconLabels } ) {
const toggleDistractionFree = () => {
registry.batch( () => {
- setPreference( 'core/edit-site', 'fixedToolbar', true );
+ setPreference( 'core', 'fixedToolbar', true );
setIsInserterOpened( false );
setIsListViewOpened( false );
closeGeneralSidebar();
@@ -69,7 +69,7 @@ export default function MoreMenu( { showIconLabels } ) {
<>
{
registry.batch( () => {
- setPreference( 'core/edit-site', 'fixedToolbar', true );
+ setPreference( 'core', 'fixedToolbar', true );
setIsInserterOpened( false );
setIsListViewOpened( false );
closeGeneralSidebar();
diff --git a/packages/edit-site/src/hooks/commands/use-edit-mode-commands.js b/packages/edit-site/src/hooks/commands/use-edit-mode-commands.js
index a855ea32e3b406..745bee52895d22 100644
--- a/packages/edit-site/src/hooks/commands/use-edit-mode-commands.js
+++ b/packages/edit-site/src/hooks/commands/use-edit-mode-commands.js
@@ -291,7 +291,7 @@ function useEditUICommands() {
name: 'core/toggle-top-toolbar',
label: __( 'Toggle top toolbar' ),
callback: ( { close } ) => {
- toggle( 'core/edit-site', 'fixedToolbar' );
+ toggle( 'core', 'fixedToolbar' );
if ( isDistractionFree ) {
toggleDistractionFree();
}
diff --git a/packages/edit-site/src/index.js b/packages/edit-site/src/index.js
index 58d5c84f15575e..0ac3558d5740a6 100644
--- a/packages/edit-site/src/index.js
+++ b/packages/edit-site/src/index.js
@@ -53,7 +53,6 @@ export function initializeEditor( id, settings ) {
// so that we won't trigger unnecessary re-renders with useEffect.
dispatch( preferencesStore ).setDefaults( 'core/edit-site', {
editorMode: 'visual',
- fixedToolbar: false,
distractionFree: false,
welcomeGuide: true,
welcomeGuideStyles: true,
@@ -63,6 +62,7 @@ export function initializeEditor( id, settings ) {
dispatch( preferencesStore ).setDefaults( 'core', {
allowRightClickOverrides: true,
+ fixedToolbar: false,
focusMode: false,
keepCaretInsideBlock: false,
showBlockBreadcrumbs: true,
diff --git a/packages/edit-site/src/store/actions.js b/packages/edit-site/src/store/actions.js
index 820c6f5239cce4..c4435fbd0df412 100644
--- a/packages/edit-site/src/store/actions.js
+++ b/packages/edit-site/src/store/actions.js
@@ -607,7 +607,7 @@ export const toggleDistractionFree =
registry.batch( () => {
registry
.dispatch( preferencesStore )
- .set( 'core/edit-site', 'fixedToolbar', true );
+ .set( 'core', 'fixedToolbar', true );
registry.dispatch( editorStore ).setIsInserterOpened( false );
registry.dispatch( editorStore ).setIsListViewOpened( false );
dispatch.closeGeneralSidebar();
diff --git a/packages/edit-site/src/store/test/actions.js b/packages/edit-site/src/store/test/actions.js
index a0ea9b2fe0885f..602b46bc1962de 100644
--- a/packages/edit-site/src/store/test/actions.js
+++ b/packages/edit-site/src/store/test/actions.js
@@ -120,7 +120,7 @@ describe( 'actions', () => {
// Enable everything that shouldn't be enabled in distraction free mode.
registry
.dispatch( preferencesStore )
- .set( 'core/edit-site', 'fixedToolbar', true );
+ .set( 'core', 'fixedToolbar', true );
registry.dispatch( editorStore ).setIsListViewOpened( true );
registry
.dispatch( editSiteStore )
@@ -130,7 +130,7 @@ describe( 'actions', () => {
expect(
registry
.select( preferencesStore )
- .get( 'core/edit-site', 'fixedToolbar' )
+ .get( 'core', 'fixedToolbar' )
).toBe( true );
expect( registry.select( editorStore ).isListViewOpened() ).toBe(
false
diff --git a/packages/editor/src/components/provider/use-block-editor-settings.js b/packages/editor/src/components/provider/use-block-editor-settings.js
index e28ba9692dc289..f47c0b2ffd34dc 100644
--- a/packages/editor/src/components/provider/use-block-editor-settings.js
+++ b/packages/editor/src/components/provider/use-block-editor-settings.js
@@ -10,6 +10,7 @@ import {
} from '@wordpress/core-data';
import { __ } from '@wordpress/i18n';
import { store as preferencesStore } from '@wordpress/preferences';
+import { useViewportMatch } from '@wordpress/compose';
/**
* Internal dependencies
@@ -51,7 +52,6 @@ const BLOCK_EDITOR_SETTINGS = [
'gradients',
'generateAnchors',
'getPostLinkProps',
- 'hasFixedToolbar',
'hasInlineToolbar',
'isDistractionFree',
'imageDefaultSize',
@@ -87,9 +87,11 @@ const BLOCK_EDITOR_SETTINGS = [
* @return {Object} Block Editor Settings.
*/
function useBlockEditorSettings( settings, postType, postId ) {
+ const isLargeViewport = useViewportMatch( 'medium' );
const {
allowRightClickOverrides,
focusMode,
+ hasFixedToolbar,
keepCaretInsideBlock,
reusableBlocks,
hasUploadPermissions,
@@ -129,6 +131,8 @@ function useBlockEditorSettings( settings, postType, postId ) {
postId
)?._links?.hasOwnProperty( 'wp:action-unfiltered-html' ),
focusMode: get( 'core', 'focusMode' ),
+ hasFixedToolbar:
+ get( 'core', 'fixedToolbar' ) || ! isLargeViewport,
keepCaretInsideBlock: get( 'core', 'keepCaretInsideBlock' ),
reusableBlocks: isWeb
? getEntityRecords( 'postType', 'wp_block', {
@@ -144,7 +148,7 @@ function useBlockEditorSettings( settings, postType, postId ) {
restBlockPatternCategories: getBlockPatternCategories(),
};
},
- [ postType, postId ]
+ [ postType, postId, isLargeViewport ]
);
const settingsBlockPatterns =
@@ -222,6 +226,7 @@ function useBlockEditorSettings( settings, postType, postId ) {
),
allowRightClickOverrides,
focusMode: focusMode && ! forceDisableFocusMode,
+ hasFixedToolbar,
keepCaretInsideBlock,
mediaUpload: hasUploadPermissions ? mediaUpload : undefined,
__experimentalReusableBlocks: reusableBlocks,
@@ -258,6 +263,7 @@ function useBlockEditorSettings( settings, postType, postId ) {
allowRightClickOverrides,
focusMode,
forceDisableFocusMode,
+ hasFixedToolbar,
keepCaretInsideBlock,
settings,
hasUploadPermissions,
diff --git a/packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js b/packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js
index ef522721787d7e..e5be380a309c36 100644
--- a/packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js
+++ b/packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js
@@ -6,6 +6,7 @@ export default function convertEditorSettings( data ) {
let newData = data;
const settingsToMoveToCore = [
'allowRightClickOverrides',
+ 'fixedToolbar',
'focusMode',
'keepCaretInsideBlock',
'showBlockBreadcrumbs',
diff --git a/packages/preferences-persistence/src/migrations/preferences-package-data/test/index.js b/packages/preferences-persistence/src/migrations/preferences-package-data/test/index.js
index 77888461ea078f..693d9586af5e45 100644
--- a/packages/preferences-persistence/src/migrations/preferences-package-data/test/index.js
+++ b/packages/preferences-persistence/src/migrations/preferences-package-data/test/index.js
@@ -42,13 +42,15 @@ describe( 'convertPreferencesPackageData', () => {
expect( convertPreferencesPackageData( input ) )
.toMatchInlineSnapshot( `
{
+ "core": {
+ "fixedToolbar": true,
+ },
"core/customize-widgets": {
"fixedToolbar": true,
"welcomeGuide": false,
},
"core/edit-post": {
"editorMode": "visual",
- "fixedToolbar": true,
"fullscreenMode": false,
"hiddenBlockTypes": [
"core/audio",
@@ -67,7 +69,6 @@ describe( 'convertPreferencesPackageData', () => {
"welcomeGuide": false,
},
"core/edit-site": {
- "fixedToolbar": true,
"isComplementaryAreaVisible": true,
"welcomeGuide": false,
"welcomeGuideStyles": false,
diff --git a/test/e2e/specs/editor/blocks/links.spec.js b/test/e2e/specs/editor/blocks/links.spec.js
index d989a2d7e5559a..9620b45fed9da8 100644
--- a/test/e2e/specs/editor/blocks/links.spec.js
+++ b/test/e2e/specs/editor/blocks/links.spec.js
@@ -1228,10 +1228,10 @@ class LinkUtils {
await this.page.evaluate( ( _isFixed ) => {
const { select, dispatch } = window.wp.data;
const isCurrentlyFixed =
- select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' );
+ select( 'core/preferences' ).get( 'fixedToolbar' );
if ( isCurrentlyFixed !== _isFixed ) {
- dispatch( 'core/edit-post' ).toggleFeature( 'fixedToolbar' );
+ dispatch( 'core/preferences' ).toggle( 'fixedToolbar' );
}
}, isFixed );
}
From eeb6aee9271694954a177b1bbf1d76d4dc4ed2dc Mon Sep 17 00:00:00 2001
From: Riad Benguella
Date: Fri, 5 Jan 2024 11:43:56 +0100
Subject: [PATCH 05/22] Editor: Migrate and unify the panel preferences
(#57529)
---
.../__snapshots__/meta-boxes-section.js.snap | 362 +++++++++---------
packages/edit-post/src/index.js | 4 +-
packages/edit-post/src/index.native.js | 4 +
packages/edit-post/src/store/selectors.js | 7 +-
.../preferences-modal/enable-panel-option.js | 23 ++
.../src/components/preferences-modal/index.js | 103 +++--
packages/edit-site/src/index.js | 2 +
packages/editor/src/store/actions.js | 11 +-
packages/editor/src/store/selectors.js | 4 +-
.../preferences-modal-section/index.js | 4 +-
.../preferences-modal-section/style.scss | 4 +
.../convert-editor-settings.js | 2 +
.../preferences-package-data/test/index.js | 8 +-
13 files changed, 317 insertions(+), 221 deletions(-)
create mode 100644 packages/edit-site/src/components/preferences-modal/enable-panel-option.js
diff --git a/packages/edit-post/src/components/preferences-modal/test/__snapshots__/meta-boxes-section.js.snap b/packages/edit-post/src/components/preferences-modal/test/__snapshots__/meta-boxes-section.js.snap
index 2246e0f12fdef7..c39f90d4aa0e5d 100644
--- a/packages/edit-post/src/components/preferences-modal/test/__snapshots__/meta-boxes-section.js.snap
+++ b/packages/edit-post/src/components/preferences-modal/test/__snapshots__/meta-boxes-section.js.snap
@@ -65,42 +65,46 @@ exports[`MetaBoxesSection renders a Custom Fields option 1`] = `
@@ -173,126 +177,130 @@ exports[`MetaBoxesSection renders a Custom Fields option and meta box options 1`
-
-
-
-
@@ -365,85 +373,89 @@ exports[`MetaBoxesSection renders meta box options 1`] = `
-
-
diff --git a/packages/edit-post/src/index.js b/packages/edit-post/src/index.js
index 0395c1f4beefa3..6a84ce20978f6c 100644
--- a/packages/edit-post/src/index.js
+++ b/packages/edit-post/src/index.js
@@ -57,9 +57,7 @@ export function initializeEditor(
editorMode: 'visual',
fullscreenMode: true,
hiddenBlockTypes: [],
- inactivePanels: [],
isPublishSidebarEnabled: true,
- openPanels: [ 'post-status' ],
preferredStyleVariations: {},
themeStyles: true,
welcomeGuide: true,
@@ -69,6 +67,8 @@ export function initializeEditor(
dispatch( preferencesStore ).setDefaults( 'core', {
allowRightClickOverrides: true,
fixedToolbar: false,
+ inactivePanels: [],
+ openPanels: [ 'post-status' ],
showBlockBreadcrumbs: true,
showIconLabels: false,
showListViewByDefault: false,
diff --git a/packages/edit-post/src/index.native.js b/packages/edit-post/src/index.native.js
index 2828d5317d232e..974f617d609f23 100644
--- a/packages/edit-post/src/index.native.js
+++ b/packages/edit-post/src/index.native.js
@@ -31,6 +31,10 @@ export function initializeEditor( id, postType, postId ) {
preferredStyleVariations: {},
welcomeGuide: true,
} );
+ dispatch( preferencesStore ).setDefaults( 'core', {
+ inactivePanels: [],
+ openPanels: [ 'post-status' ],
+ } );
dispatch( preferencesStore ).setDefaults( 'core', {
fixedToolbar: false,
diff --git a/packages/edit-post/src/store/selectors.js b/packages/edit-post/src/store/selectors.js
index dff5f27c8918af..0d879493f995b9 100644
--- a/packages/edit-post/src/store/selectors.js
+++ b/packages/edit-post/src/store/selectors.js
@@ -186,13 +186,10 @@ export const getPreferences = createRegistrySelector( ( select ) => () => {
// the new preferences store format to old format to ensure no breaking
// changes for plugins.
const inactivePanels = select( preferencesStore ).get(
- 'core/edit-post',
+ 'core',
'inactivePanels'
);
- const openPanels = select( preferencesStore ).get(
- 'core/edit-post',
- 'openPanels'
- );
+ const openPanels = select( preferencesStore ).get( 'core', 'openPanels' );
const panels = convertPanelsToOldFormat( inactivePanels, openPanels );
return {
diff --git a/packages/edit-site/src/components/preferences-modal/enable-panel-option.js b/packages/edit-site/src/components/preferences-modal/enable-panel-option.js
new file mode 100644
index 00000000000000..6c9ea22b7f17dd
--- /dev/null
+++ b/packages/edit-site/src/components/preferences-modal/enable-panel-option.js
@@ -0,0 +1,23 @@
+/**
+ * WordPress dependencies
+ */
+import { compose, ifCondition } from '@wordpress/compose';
+import { withSelect, withDispatch } from '@wordpress/data';
+import { ___unstablePreferencesModalBaseOption as BaseOption } from '@wordpress/interface';
+import { store as editorStore } from '@wordpress/editor';
+
+export default compose(
+ withSelect( ( select, { panelName } ) => {
+ const { isEditorPanelEnabled, isEditorPanelRemoved } =
+ select( editorStore );
+ return {
+ isRemoved: isEditorPanelRemoved( panelName ),
+ isChecked: isEditorPanelEnabled( panelName ),
+ };
+ } ),
+ ifCondition( ( { isRemoved } ) => ! isRemoved ),
+ withDispatch( ( dispatch, { panelName } ) => ( {
+ onChange: () =>
+ dispatch( editorStore ).toggleEditorPanelEnabled( panelName ),
+ } ) )
+)( BaseOption );
diff --git a/packages/edit-site/src/components/preferences-modal/index.js b/packages/edit-site/src/components/preferences-modal/index.js
index 39e6f289bbd546..7960e23d2023fb 100644
--- a/packages/edit-site/src/components/preferences-modal/index.js
+++ b/packages/edit-site/src/components/preferences-modal/index.js
@@ -11,12 +11,20 @@ import { useMemo } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { useSelect, useDispatch, useRegistry } from '@wordpress/data';
import { store as preferencesStore } from '@wordpress/preferences';
-import { store as editorStore } from '@wordpress/editor';
+import {
+ PostTaxonomies,
+ PostExcerptCheck,
+ PageAttributesCheck,
+ PostFeaturedImageCheck,
+ PostTypeSupportCheck,
+ store as editorStore,
+} from '@wordpress/editor';
/**
* Internal dependencies
*/
import EnableFeature from './enable-feature';
+import EnablePanelOption from './enable-panel-option';
import { store as editSiteStore } from '../../store';
export const PREFERENCES_MODAL_NAME = 'edit-site/preferences';
@@ -52,32 +60,75 @@ export default function EditSitePreferencesModal() {
name: 'general',
tabLabel: __( 'General' ),
content: (
-
-
-
-
+
+
+
+
+
+
-
+ >
+ (
+
+ ) }
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
),
},
{
diff --git a/packages/edit-site/src/index.js b/packages/edit-site/src/index.js
index 0ac3558d5740a6..c145147b5e2efa 100644
--- a/packages/edit-site/src/index.js
+++ b/packages/edit-site/src/index.js
@@ -64,7 +64,9 @@ export function initializeEditor( id, settings ) {
allowRightClickOverrides: true,
fixedToolbar: false,
focusMode: false,
+ inactivePanels: [],
keepCaretInsideBlock: false,
+ openPanels: [ 'post-status' ],
showBlockBreadcrumbs: true,
showListViewByDefault: false,
} );
diff --git a/packages/editor/src/store/actions.js b/packages/editor/src/store/actions.js
index 49f49a5d06da5d..a0330321bac8f7 100644
--- a/packages/editor/src/store/actions.js
+++ b/packages/editor/src/store/actions.js
@@ -624,7 +624,7 @@ export const toggleEditorPanelEnabled =
const inactivePanels =
registry
.select( preferencesStore )
- .get( 'core/edit-post', 'inactivePanels' ) ?? [];
+ .get( 'core', 'inactivePanels' ) ?? [];
const isPanelInactive = !! inactivePanels?.includes( panelName );
@@ -641,7 +641,7 @@ export const toggleEditorPanelEnabled =
registry
.dispatch( preferencesStore )
- .set( 'core/edit-post', 'inactivePanels', updatedInactivePanels );
+ .set( 'core', 'inactivePanels', updatedInactivePanels );
};
/**
@@ -653,9 +653,8 @@ export const toggleEditorPanelOpened =
( panelName ) =>
( { registry } ) => {
const openPanels =
- registry
- .select( preferencesStore )
- .get( 'core/edit-post', 'openPanels' ) ?? [];
+ registry.select( preferencesStore ).get( 'core', 'openPanels' ) ??
+ [];
const isPanelOpen = !! openPanels?.includes( panelName );
@@ -672,7 +671,7 @@ export const toggleEditorPanelOpened =
registry
.dispatch( preferencesStore )
- .set( 'core/edit-post', 'openPanels', updatedOpenPanels );
+ .set( 'core', 'openPanels', updatedOpenPanels );
};
/**
diff --git a/packages/editor/src/store/selectors.js b/packages/editor/src/store/selectors.js
index 70d726638a0940..107ffe4dd4625c 100644
--- a/packages/editor/src/store/selectors.js
+++ b/packages/editor/src/store/selectors.js
@@ -1152,7 +1152,7 @@ export const isEditorPanelEnabled = createRegistrySelector(
// For backward compatibility, we check edit-post
// even though now this is in "editor" package.
const inactivePanels = select( preferencesStore ).get(
- 'core/edit-post',
+ 'core',
'inactivePanels'
);
return (
@@ -1176,7 +1176,7 @@ export const isEditorPanelOpened = createRegistrySelector(
// For backward compatibility, we check edit-post
// even though now this is in "editor" package.
const openPanels = select( preferencesStore ).get(
- 'core/edit-post',
+ 'core',
'openPanels'
);
return !! openPanels?.includes( panelName );
diff --git a/packages/interface/src/components/preferences-modal-section/index.js b/packages/interface/src/components/preferences-modal-section/index.js
index ea164128ea54cb..8ea2ca2652d6df 100644
--- a/packages/interface/src/components/preferences-modal-section/index.js
+++ b/packages/interface/src/components/preferences-modal-section/index.js
@@ -10,7 +10,9 @@ const Section = ( { description, title, children } ) => (
) }
- { children }
+
+ { children }
+
);
diff --git a/packages/interface/src/components/preferences-modal-section/style.scss b/packages/interface/src/components/preferences-modal-section/style.scss
index 1a45642a8b7af9..a1259af3430d56 100644
--- a/packages/interface/src/components/preferences-modal-section/style.scss
+++ b/packages/interface/src/components/preferences-modal-section/style.scss
@@ -22,3 +22,7 @@
font-style: normal;
color: $gray-700;
}
+
+.interface-preferences-modal__section:has(.interface-preferences-modal__section-content:empty) {
+ display: none;
+}
diff --git a/packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js b/packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js
index e5be380a309c36..b245fb958571f2 100644
--- a/packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js
+++ b/packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js
@@ -8,7 +8,9 @@ export default function convertEditorSettings( data ) {
'allowRightClickOverrides',
'fixedToolbar',
'focusMode',
+ 'inactivePanels',
'keepCaretInsideBlock',
+ 'openPanels',
'showBlockBreadcrumbs',
'showIconLabels',
'showListViewByDefault',
diff --git a/packages/preferences-persistence/src/migrations/preferences-package-data/test/index.js b/packages/preferences-persistence/src/migrations/preferences-package-data/test/index.js
index 693d9586af5e45..ffa39e630f5099 100644
--- a/packages/preferences-persistence/src/migrations/preferences-package-data/test/index.js
+++ b/packages/preferences-persistence/src/migrations/preferences-package-data/test/index.js
@@ -44,6 +44,10 @@ describe( 'convertPreferencesPackageData', () => {
{
"core": {
"fixedToolbar": true,
+ "inactivePanels": [],
+ "openPanels": [
+ "post-status",
+ ],
},
"core/customize-widgets": {
"fixedToolbar": true,
@@ -56,10 +60,6 @@ describe( 'convertPreferencesPackageData', () => {
"core/audio",
"core/cover",
],
- "inactivePanels": [],
- "openPanels": [
- "post-status",
- ],
"pinnedItems": {
"my-sidebar-plugin/title-sidebar": false,
},
From 49bd0fafc19f8506d79fd145bfeb3f060a0b634d Mon Sep 17 00:00:00 2001
From: Jon Surrell
Date: Fri, 5 Jan 2024 12:05:12 +0100
Subject: [PATCH 06/22] Dependency Extraction Webpack Plugin: Use `import` for
module externals (#57577)
When using `module` externals, webpack always produces a static import:
import x from 'external-module';
That's undesirable in the case of dynamic imports where module loading
could be deferred or avoided altogether. Instead, use the `import`
external type which causes webpack use always use `import()` to load
these external modules.
---
.../lib/index.js | 2 +-
.../test/__snapshots__/build.js.snap | 74 +++++++++----------
2 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/packages/dependency-extraction-webpack-plugin/lib/index.js b/packages/dependency-extraction-webpack-plugin/lib/index.js
index 400ea39c022931..9b04d42e7c919d 100644
--- a/packages/dependency-extraction-webpack-plugin/lib/index.js
+++ b/packages/dependency-extraction-webpack-plugin/lib/index.js
@@ -139,7 +139,7 @@ class DependencyExtractionWebpackPlugin {
* @type {webpack.ExternalsPlugin}
*/
this.externalsPlugin = new webpack.ExternalsPlugin(
- this.useModules ? 'module' : 'window',
+ this.useModules ? 'import' : 'window',
this.externalizeWpDeps.bind( this )
);
diff --git a/packages/dependency-extraction-webpack-plugin/test/__snapshots__/build.js.snap b/packages/dependency-extraction-webpack-plugin/test/__snapshots__/build.js.snap
index 3c8f89fc14ee92..73c72340c15192 100644
--- a/packages/dependency-extraction-webpack-plugin/test/__snapshots__/build.js.snap
+++ b/packages/dependency-extraction-webpack-plugin/test/__snapshots__/build.js.snap
@@ -1,19 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`DependencyExtractionWebpackPlugin modules Webpack \`combine-assets\` should produce expected output: Asset file 'assets.php' should match snapshot 1`] = `
-" array('dependencies' => array('@wordpress/blob'), 'version' => '8652d2bf4a1ea1969a6e', 'type' => 'module'), 'fileB.mjs' => array('dependencies' => array('@wordpress/token-list'), 'version' => '17d7d5b2c152592ff3a0', 'type' => 'module'));
+" array('dependencies' => array('@wordpress/blob'), 'version' => 'b2c5cea79a32b3d91bf8', 'type' => 'module'), 'fileB.mjs' => array('dependencies' => array('@wordpress/token-list'), 'version' => '5c4197fd48811f25807f', 'type' => 'module'));
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`combine-assets\` should produce expected output: External modules should match snapshot 1`] = `
[
{
- "externalType": "module",
+ "externalType": "import",
"request": "@wordpress/blob",
"userRequest": "@wordpress/blob",
},
{
- "externalType": "module",
+ "externalType": "import",
"request": "@wordpress/token-list",
"userRequest": "@wordpress/token-list",
},
@@ -21,14 +21,14 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`combine-assets\` sh
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`cyclic-dependency-graph\` should produce expected output: Asset file 'main.asset.php' should match snapshot 1`] = `
-" array('@wordpress/interactivity'), 'version' => '58fadee5eca3ad30aff6', 'type' => 'module');
+" array('@wordpress/interactivity'), 'version' => 'a2723a31145b5f1ec2fd', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`cyclic-dependency-graph\` should produce expected output: External modules should match snapshot 1`] = `
[
{
- "externalType": "module",
+ "externalType": "import",
"request": "@wordpress/interactivity",
"userRequest": "@wordpress/interactivity",
},
@@ -36,14 +36,14 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`cyclic-dependency-g
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`cyclic-dynamic-dependency-graph\` should produce expected output: Asset file 'main.asset.php' should match snapshot 1`] = `
-" array(array('id' => '@wordpress/interactivity', 'type' => 'dynamic')), 'version' => '293aebad4ca761cf396f', 'type' => 'module');
+" array(array('id' => '@wordpress/interactivity', 'type' => 'dynamic')), 'version' => '095c38db2c83d0d2e168', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`cyclic-dynamic-dependency-graph\` should produce expected output: External modules should match snapshot 1`] = `
[
{
- "externalType": "module",
+ "externalType": "import",
"request": "@wordpress/interactivity",
"userRequest": "@wordpress/interactivity",
},
@@ -51,14 +51,14 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`cyclic-dynamic-depe
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`dynamic-import\` should produce expected output: Asset file 'main.asset.php' should match snapshot 1`] = `
-" array(array('id' => '@wordpress/blob', 'type' => 'dynamic')), 'version' => '092c2bce8c247ee11100', 'type' => 'module');
+" array(array('id' => '@wordpress/blob', 'type' => 'dynamic')), 'version' => '4f59b7847b70a07b2710', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`dynamic-import\` should produce expected output: External modules should match snapshot 1`] = `
[
{
- "externalType": "module",
+ "externalType": "import",
"request": "@wordpress/blob",
"userRequest": "@wordpress/blob",
},
@@ -66,14 +66,14 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`dynamic-import\` sh
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`function-output-filename\` should produce expected output: Asset file 'chunk--main--main.asset.php' should match snapshot 1`] = `
-" array('@wordpress/blob'), 'version' => '5207bcd3fdd29de25f37', 'type' => 'module');
+" array('@wordpress/blob'), 'version' => '2925e30449840a5a80f8', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`function-output-filename\` should produce expected output: External modules should match snapshot 1`] = `
[
{
- "externalType": "module",
+ "externalType": "import",
"request": "@wordpress/blob",
"userRequest": "@wordpress/blob",
},
@@ -81,14 +81,14 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`function-output-fil
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`has-extension-suffix\` should produce expected output: Asset file 'index.min.asset.php' should match snapshot 1`] = `
-" array('@wordpress/blob'), 'version' => '9b89a3e6236b26559c4e', 'type' => 'module');
+" array('@wordpress/blob'), 'version' => '26d6da43027f3522b0ca', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`has-extension-suffix\` should produce expected output: External modules should match snapshot 1`] = `
[
{
- "externalType": "module",
+ "externalType": "import",
"request": "@wordpress/blob",
"userRequest": "@wordpress/blob",
},
@@ -96,19 +96,19 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`has-extension-suffi
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`module-renames\` should produce expected output: Asset file 'main.asset.php' should match snapshot 1`] = `
-" array('renamed--@my/module', 'renamed--other-module'), 'version' => '601cf94eb9a182fcc0ed', 'type' => 'module');
+" array('renamed--@my/module', 'renamed--other-module'), 'version' => '91070a8471d11e83a5f6', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`module-renames\` should produce expected output: External modules should match snapshot 1`] = `
[
{
- "externalType": "module",
+ "externalType": "import",
"request": "renamed--@my/module",
"userRequest": "@my/module",
},
{
- "externalType": "module",
+ "externalType": "import",
"request": "renamed--other-module",
"userRequest": "other-module",
},
@@ -130,14 +130,14 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`no-deps\` should pr
exports[`DependencyExtractionWebpackPlugin modules Webpack \`no-deps\` should produce expected output: External modules should match snapshot 1`] = `[]`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`option-function-output-filename\` should produce expected output: Asset file 'chunk--main--main.asset.php' should match snapshot 1`] = `
-" array('@wordpress/blob'), 'version' => '5207bcd3fdd29de25f37', 'type' => 'module');
+" array('@wordpress/blob'), 'version' => '2925e30449840a5a80f8', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`option-function-output-filename\` should produce expected output: External modules should match snapshot 1`] = `
[
{
- "externalType": "module",
+ "externalType": "import",
"request": "@wordpress/blob",
"userRequest": "@wordpress/blob",
},
@@ -145,14 +145,14 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`option-function-out
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`option-output-filename\` should produce expected output: Asset file 'main-foo.asset.php' should match snapshot 1`] = `
-" array('@wordpress/blob'), 'version' => '5207bcd3fdd29de25f37', 'type' => 'module');
+" array('@wordpress/blob'), 'version' => '2925e30449840a5a80f8', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`option-output-filename\` should produce expected output: External modules should match snapshot 1`] = `
[
{
- "externalType": "module",
+ "externalType": "import",
"request": "@wordpress/blob",
"userRequest": "@wordpress/blob",
},
@@ -164,29 +164,29 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`output-format-json\
exports[`DependencyExtractionWebpackPlugin modules Webpack \`output-format-json\` should produce expected output: External modules should match snapshot 1`] = `[]`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`overrides\` should produce expected output: Asset file 'main.asset.php' should match snapshot 1`] = `
-" array('@wordpress/blob', '@wordpress/url', 'rxjs', 'rxjs/operators'), 'version' => '90f2e6327f4e8fb0264f', 'type' => 'module');
+" array('@wordpress/blob', '@wordpress/url', 'rxjs', 'rxjs/operators'), 'version' => '259fc706528651fc00c1', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`overrides\` should produce expected output: External modules should match snapshot 1`] = `
[
{
- "externalType": "module",
+ "externalType": "import",
"request": "@wordpress/blob",
"userRequest": "@wordpress/blob",
},
{
- "externalType": "module",
+ "externalType": "import",
"request": "@wordpress/url",
"userRequest": "@wordpress/url",
},
{
- "externalType": "module",
+ "externalType": "import",
"request": "rxjs",
"userRequest": "rxjs",
},
{
- "externalType": "module",
+ "externalType": "import",
"request": "rxjs/operators",
"userRequest": "rxjs/operators",
},
@@ -194,24 +194,24 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`overrides\` should
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`runtime-chunk-single\` should produce expected output: Asset file 'a.asset.php' should match snapshot 1`] = `
-" array('@wordpress/blob'), 'version' => 'aeadada5bf49ae3b9dc2', 'type' => 'module');
+" array('@wordpress/blob'), 'version' => '77b6df15bf179d0ae624', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`runtime-chunk-single\` should produce expected output: Asset file 'b.asset.php' should match snapshot 1`] = `
-" array('@wordpress/blob'), 'version' => '10df52cc859c01faa91d', 'type' => 'module');
+" array('@wordpress/blob'), 'version' => 'a0ec8ef279476bb51e19', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`runtime-chunk-single\` should produce expected output: Asset file 'runtime.asset.php' should match snapshot 1`] = `
-" array(), 'version' => 'd081f44e5ece6763f943', 'type' => 'module');
+" array(), 'version' => '0bb8a9fae3dcfcc1ac38', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`runtime-chunk-single\` should produce expected output: External modules should match snapshot 1`] = `
[
{
- "externalType": "module",
+ "externalType": "import",
"request": "@wordpress/blob",
"userRequest": "@wordpress/blob",
},
@@ -219,14 +219,14 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`runtime-chunk-singl
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`style-imports\` should produce expected output: Asset file 'main.asset.php' should match snapshot 1`] = `
-" array('@wordpress/blob'), 'version' => '2d597a618aeebe7ab323', 'type' => 'module');
+" array('@wordpress/blob'), 'version' => '38479966fb62d588f05e', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`style-imports\` should produce expected output: External modules should match snapshot 1`] = `
[
{
- "externalType": "module",
+ "externalType": "import",
"request": "@wordpress/blob",
"userRequest": "@wordpress/blob",
},
@@ -234,14 +234,14 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`style-imports\` sho
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`wordpress\` should produce expected output: Asset file 'main.asset.php' should match snapshot 1`] = `
-" array('@wordpress/blob'), 'version' => '5207bcd3fdd29de25f37', 'type' => 'module');
+" array('@wordpress/blob'), 'version' => '2925e30449840a5a80f8', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`wordpress\` should produce expected output: External modules should match snapshot 1`] = `
[
{
- "externalType": "module",
+ "externalType": "import",
"request": "@wordpress/blob",
"userRequest": "@wordpress/blob",
},
@@ -249,14 +249,14 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`wordpress\` should
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`wordpress-interactivity\` should produce expected output: Asset file 'main.asset.php' should match snapshot 1`] = `
-" array(array('id' => '@wordpress/interactivity', 'type' => 'dynamic')), 'version' => 'f0242eb6da78af6ca4b8', 'type' => 'module');
+" array(array('id' => '@wordpress/interactivity', 'type' => 'dynamic')), 'version' => 'b5625778551023855766', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`wordpress-interactivity\` should produce expected output: External modules should match snapshot 1`] = `
[
{
- "externalType": "module",
+ "externalType": "import",
"request": "@wordpress/interactivity",
"userRequest": "@wordpress/interactivity",
},
@@ -264,14 +264,14 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`wordpress-interacti
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`wordpress-require\` should produce expected output: Asset file 'main.asset.php' should match snapshot 1`] = `
-" array('@wordpress/blob'), 'version' => '7a320492a2396d955292', 'type' => 'module');
+" array('@wordpress/blob'), 'version' => '52c1849898b74d94f025', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`wordpress-require\` should produce expected output: External modules should match snapshot 1`] = `
[
{
- "externalType": "module",
+ "externalType": "import",
"request": "@wordpress/blob",
"userRequest": "@wordpress/blob",
},
From 58c4c13f902fb8f69387daeb34f9ee3c1eb3935a Mon Sep 17 00:00:00 2001
From: James Koster
Date: Fri, 5 Jan 2024 12:35:04 +0000
Subject: [PATCH 07/22] Align icon size + placement in Patterns data view
(#57548)
* Update pattern icon size + placement
* scope new styles under the dataviews container
---------
Co-authored-by: ntsekouras
---
.../page-patterns/dataviews-patterns.js | 26 +++++++++----------
.../src/components/page-patterns/style.scss | 5 ++++
2 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/packages/edit-site/src/components/page-patterns/dataviews-patterns.js b/packages/edit-site/src/components/page-patterns/dataviews-patterns.js
index c626336c4f4982..ed3555f418d95f 100644
--- a/packages/edit-site/src/components/page-patterns/dataviews-patterns.js
+++ b/packages/edit-site/src/components/page-patterns/dataviews-patterns.js
@@ -169,7 +169,7 @@ function Title( { item, categoryId } ) {
item.syncStatus === PATTERN_SYNC_TYPES.full ? symbol : undefined;
}
return (
-
+
{ itemIcon && ! isNonUserPattern && (
) }
+ { item.type === PATTERN_TYPES.theme && (
+
+
+
+ ) }
{ item.type === PATTERN_TYPES.theme ? (
item.title
@@ -199,18 +211,6 @@ function Title( { item, categoryId } ) {
) }
- { item.type === PATTERN_TYPES.theme && (
-
-
-
- ) }
);
diff --git a/packages/edit-site/src/components/page-patterns/style.scss b/packages/edit-site/src/components/page-patterns/style.scss
index dc055b94c4b491..013dc836e19ad3 100644
--- a/packages/edit-site/src/components/page-patterns/style.scss
+++ b/packages/edit-site/src/components/page-patterns/style.scss
@@ -237,6 +237,11 @@
}
}
+ .edit-site-patterns__pattern-icon {
+ fill: var(--wp-block-synced-color);
+ flex-shrink: 0;
+ }
+
.edit-site-patterns__pattern-lock-icon {
min-width: min-content;
}
From c804a695e570733114d08ab49965e7ecd22d97e4 Mon Sep 17 00:00:00 2001
From: Andrew Hayward
Date: Fri, 5 Jan 2024 12:49:15 +0000
Subject: [PATCH 08/22] [Dataviews] Table layout: Ensure focus is not lost on
interaction (#57340)
When tables are sorted or paginated, focus can be lost if the new data takes time to come back. This patch keeps the table header in place, whether data exists or not, ensuring focus is not lost. Additionally, when columns are hidden from the column header menu, focus is also lost as the header menu no longer exists. This patch adds an `onHide` callback to each header menu, which when called will put the focus on a fallback header menu.
---
packages/dataviews/src/view-table.js | 177 ++++++++++++++++++---------
1 file changed, 122 insertions(+), 55 deletions(-)
diff --git a/packages/dataviews/src/view-table.js b/packages/dataviews/src/view-table.js
index 5bfcba5def4aa3..083931bb5203ec 100644
--- a/packages/dataviews/src/view-table.js
+++ b/packages/dataviews/src/view-table.js
@@ -1,3 +1,8 @@
+/**
+ * External dependencies
+ */
+import classNames from 'classnames';
+
/**
* WordPress dependencies
*/
@@ -9,7 +14,15 @@ import {
Icon,
privateApis as componentsPrivateApis,
} from '@wordpress/components';
-import { Children, Fragment } from '@wordpress/element';
+import {
+ Children,
+ Fragment,
+ forwardRef,
+ useEffect,
+ useId,
+ useRef,
+ useState,
+} from '@wordpress/element';
/**
* Internal dependencies
@@ -41,7 +54,10 @@ const sanitizeOperators = ( field ) => {
);
};
-function HeaderMenu( { field, view, onChangeView } ) {
+const HeaderMenu = forwardRef( function HeaderMenu(
+ { field, view, onChangeView, onHide },
+ ref
+) {
const isHidable = field.enableHiding !== false;
const isSortable = field.enableSorting !== false;
@@ -76,6 +92,7 @@ function HeaderMenu( { field, view, onChangeView } ) {
size="compact"
className="dataviews-table-header-button"
style={ { padding: 0 } }
+ ref={ ref }
>
{ field.header }
{ isSorted && (
@@ -132,6 +149,7 @@ function HeaderMenu( { field, view, onChangeView } ) {
}
onClick={ () => {
+ onHide( field );
onChangeView( {
...view,
hiddenFields: view.hiddenFields.concat(
@@ -275,7 +293,7 @@ function HeaderMenu( { field, view, onChangeView } ) {
);
-}
+} );
function WithSeparators( { children } ) {
return Children.toArray( children )
@@ -298,6 +316,35 @@ function ViewTable( {
isLoading = false,
deferredRendering,
} ) {
+ const headerMenuRefs = useRef( new Map() );
+ const headerMenuToFocusRef = useRef();
+ const [ nextHeaderMenuToFocus, setNextHeaderMenuToFocus ] = useState();
+
+ useEffect( () => {
+ if ( headerMenuToFocusRef.current ) {
+ headerMenuToFocusRef.current.focus();
+ headerMenuToFocusRef.current = undefined;
+ }
+ } );
+
+ const asyncData = useAsyncList( data );
+ const tableNoticeId = useId();
+
+ if ( nextHeaderMenuToFocus ) {
+ // If we need to force focus, we short-circuit rendering here
+ // to prevent any additional work while we handle that.
+ // Clearing out the focus directive is necessary to make sure
+ // future renders don't cause unexpected focus jumps.
+ headerMenuToFocusRef.current = nextHeaderMenuToFocus;
+ setNextHeaderMenuToFocus();
+ return;
+ }
+
+ const onHide = ( field ) => {
+ const hidden = headerMenuRefs.current.get( field.id );
+ const fallback = headerMenuRefs.current.get( hidden.fallback );
+ setNextHeaderMenuToFocus( fallback?.node );
+ };
const visibleFields = fields.filter(
( field ) =>
! view.hiddenFields.includes( field.id ) &&
@@ -305,55 +352,70 @@ function ViewTable( {
field.id
)
);
- const shownData = useAsyncList( data );
- const usedData = deferredRendering ? shownData : data;
+ const usedData = deferredRendering ? asyncData : data;
const hasData = !! usedData?.length;
- if ( isLoading ) {
- // TODO:Add spinner or progress bar..
- return (
-
-
{ __( 'Loading' ) }
-
- );
- }
const sortValues = { asc: 'ascending', desc: 'descending' };
+
return (
- { hasData && (
-
-
-
- { visibleFields.map( ( field ) => (
-
+
+
+ { visibleFields.map( ( field, index ) => (
+
+ {
+ if ( node ) {
+ headerMenuRefs.current.set(
+ field.id,
+ {
+ node,
+ fallback:
+ visibleFields[
+ index > 0
+ ? index - 1
+ : 1
+ ]?.id,
+ }
+ );
+ } else {
+ headerMenuRefs.current.delete(
+ field.id
+ );
+ }
} }
- data-field-id={ field.id }
- aria-sort={
- view.sort?.field === field.id &&
- sortValues[ view.sort.direction ]
- }
- scope="col"
- >
-
- |
- ) ) }
- { !! actions?.length && (
-
- { __( 'Actions' ) }
- |
- ) }
-
-
- |
- { usedData.map( ( item ) => (
+ field={ field }
+ view={ view }
+ onChangeView={ onChangeView }
+ onHide={ onHide }
+ />
+
+ ) ) }
+ { !! actions?.length && (
+ { __( 'Actions' ) } |
+ ) }
+
+
+
+ { hasData &&
+ usedData.map( ( item ) => (
{ visibleFields.map( ( field ) => (
) ) }
- |
-
- ) }
- { ! hasData && (
-
-
{ __( 'No results' ) }
-
- ) }
+
+
+
+ { ! hasData && (
+
{ isLoading ? __( 'Loading…' ) : __( 'No results' ) }
+ ) }
+
);
}
From c777b82db1eabe056e1b23b2753f9b675564ac90 Mon Sep 17 00:00:00 2001
From: Aki Hamano <54422211+t-hamano@users.noreply.github.com>
Date: Fri, 5 Jan 2024 23:23:26 +0900
Subject: [PATCH 09/22] Dataview: Change the stacking order of table header
(#57565)
---
packages/dataviews/src/style.scss | 1 +
1 file changed, 1 insertion(+)
diff --git a/packages/dataviews/src/style.scss b/packages/dataviews/src/style.scss
index 3076162dc8de80..edf1500d2cc5ad 100644
--- a/packages/dataviews/src/style.scss
+++ b/packages/dataviews/src/style.scss
@@ -117,6 +117,7 @@
border-top: 1px solid $gray-100;
padding-top: $grid-unit-05;
padding-bottom: $grid-unit-05;
+ z-index: 1;
}
}
From 3ddd0371318588c8821a947e661e7204d03a7f3b Mon Sep 17 00:00:00 2001
From: Andrea Fercia
Date: Fri, 5 Jan 2024 15:35:02 +0100
Subject: [PATCH 10/22] Fullscreen mode description: use full text instead of
abbreviation. (#57518)
---
packages/edit-post/src/components/header/writing-menu/index.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 0c01a4df24f3a5..4d5bc5653e17fc 100644
--- a/packages/edit-post/src/components/header/writing-menu/index.js
+++ b/packages/edit-post/src/components/header/writing-menu/index.js
@@ -78,7 +78,7 @@ function WritingMenu() {
scope="core/edit-post"
name="fullscreenMode"
label={ __( 'Fullscreen mode' ) }
- info={ __( 'Show and hide admin UI' ) }
+ info={ __( 'Show and hide the admin user interface' ) }
messageActivated={ __( 'Fullscreen mode activated' ) }
messageDeactivated={ __( 'Fullscreen mode deactivated' ) }
shortcut={ displayShortcut.secondary( 'f' ) }
From f0cb338cdb5bb2696108b40ccbde01d89bef0c98 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Fri, 5 Jan 2024 10:01:07 -0500
Subject: [PATCH 11/22] Bump gradle/gradle-build-action from 2.9.0 to 2.11.1
(#57262)
Bumps [gradle/gradle-build-action](https://github.com/gradle/gradle-build-action) from 2.9.0 to 2.11.1.
- [Release notes](https://github.com/gradle/gradle-build-action/releases)
- [Commits](https://github.com/gradle/gradle-build-action/compare/842c587ad8aa4c68eeba24c396e15af4c2e9f30a...982da8e78c05368c70dac0351bb82647a9e9a5d2)
---
updated-dependencies:
- dependency-name: gradle/gradle-build-action
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
.github/workflows/rnmobile-android-runner.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/rnmobile-android-runner.yml b/.github/workflows/rnmobile-android-runner.yml
index e1c51a62ed44e7..4121dcc177f39d 100644
--- a/.github/workflows/rnmobile-android-runner.yml
+++ b/.github/workflows/rnmobile-android-runner.yml
@@ -47,7 +47,7 @@ jobs:
run: npm run native test:e2e:setup
- name: Gradle cache
- uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
+ uses: gradle/gradle-build-action@982da8e78c05368c70dac0351bb82647a9e9a5d2 # v2.11.1
- name: AVD cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
From e99a02226a17f4bee24dbfa0eeabb34807cc119a Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Fri, 5 Jan 2024 10:01:40 -0500
Subject: [PATCH 12/22] Bump actions/download-artifact from 4.0.0 to 4.1.0
(#57219)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4.0.0 to 4.1.0.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v4...v4.1.0)
---
updated-dependencies:
- dependency-name: actions/download-artifact
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
.github/workflows/build-plugin-zip.yml | 4 ++--
.github/workflows/end2end-test.yml | 2 +-
.github/workflows/upload-release-to-plugin-repo.yml | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml
index a2628bf7af6160..13b04344365d82 100644
--- a/.github/workflows/build-plugin-zip.yml
+++ b/.github/workflows/build-plugin-zip.yml
@@ -270,12 +270,12 @@ jobs:
run: echo "version=$(echo $VERSION | cut -d / -f 3 | sed 's/-rc./ RC/' )" >> $GITHUB_OUTPUT
- name: Download Plugin Zip Artifact
- uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4 # v4.0.0
+ uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4.1.0
with:
name: gutenberg-plugin
- name: Download Release Notes Artifact
- uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4 # v4.0.0
+ uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4.1.0
with:
name: release-notes
diff --git a/.github/workflows/end2end-test.yml b/.github/workflows/end2end-test.yml
index d065bf8afad44d..362aec73cd6241 100644
--- a/.github/workflows/end2end-test.yml
+++ b/.github/workflows/end2end-test.yml
@@ -120,7 +120,7 @@ jobs:
ref: trunk
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
- - uses: actions/download-artifact@v4
+ - uses: actions/download-artifact@v4.1.0
id: download_artifact
# Don't fail the job if there isn't any flaky tests report.
continue-on-error: true
diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml
index 02ba0e8cd50ff0..d6d5f8da1102bb 100644
--- a/.github/workflows/upload-release-to-plugin-repo.yml
+++ b/.github/workflows/upload-release-to-plugin-repo.yml
@@ -189,7 +189,7 @@ jobs:
sed -i "s/$STABLE_TAG_PLACEHOLDER/Stable tag: $VERSION/g" ./trunk/readme.txt
- name: Download Changelog Artifact
- uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4 # v4.0.0
+ uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4.1.0
with:
name: changelog trunk
path: trunk
@@ -247,7 +247,7 @@ jobs:
sed -i "s/$STABLE_TAG_PLACEHOLDER/Stable tag: $VERSION/g" "$VERSION/readme.txt"
- name: Download Changelog Artifact
- uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4 # v4.0.0
+ uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4.1.0
with:
name: changelog trunk
path: ${{ github.event.release.name }}
From dcc866dceed632af9ec9d6aa7c508c9c425c0e73 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Fri, 5 Jan 2024 10:02:14 -0500
Subject: [PATCH 13/22] Bump actions/setup-node from 4.0.0 to 4.0.1 (#57162)
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/8f152de45cc393bb48ce5d89d36b731f54556e65...b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8)
---
updated-dependencies:
- dependency-name: actions/setup-node
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
.github/workflows/build-plugin-zip.yml | 4 ++--
.github/workflows/bundle-size.yml | 2 +-
.github/workflows/publish-npm-packages.yml | 4 ++--
.github/workflows/pull-request-automation.yml | 2 +-
.github/workflows/static-checks.yml | 2 +-
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml
index 13b04344365d82..5163a343541ca7 100644
--- a/.github/workflows/build-plugin-zip.yml
+++ b/.github/workflows/build-plugin-zip.yml
@@ -171,7 +171,7 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
- name: Use desired version of Node.js
- uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
+ uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
with:
node-version-file: '.nvmrc'
check-latest: true
@@ -333,7 +333,7 @@ jobs:
git config user.email gutenberg@wordpress.org
- name: Setup Node.js
- uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
+ uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
with:
node-version-file: 'main/.nvmrc'
registry-url: 'https://registry.npmjs.org'
diff --git a/.github/workflows/bundle-size.yml b/.github/workflows/bundle-size.yml
index 23b245cb6f114b..c7959b2992f0eb 100644
--- a/.github/workflows/bundle-size.yml
+++ b/.github/workflows/bundle-size.yml
@@ -43,7 +43,7 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
- name: Use desired version of Node.js
- uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
+ uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
with:
node-version-file: '.nvmrc'
check-latest: true
diff --git a/.github/workflows/publish-npm-packages.yml b/.github/workflows/publish-npm-packages.yml
index 163012451d6002..ad108f5db5b049 100644
--- a/.github/workflows/publish-npm-packages.yml
+++ b/.github/workflows/publish-npm-packages.yml
@@ -67,7 +67,7 @@ jobs:
- name: Setup Node.js
if: ${{ github.event.inputs.release_type != 'wp' }}
- uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
+ uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
with:
node-version-file: 'cli/.nvmrc'
registry-url: 'https://registry.npmjs.org'
@@ -75,7 +75,7 @@ jobs:
- name: Setup Node.js (for WP major version)
if: ${{ github.event.inputs.release_type == 'wp' && github.event.inputs.wp_version }}
- uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
+ uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
with:
node-version-file: 'publish/.nvmrc'
registry-url: 'https://registry.npmjs.org'
diff --git a/.github/workflows/pull-request-automation.yml b/.github/workflows/pull-request-automation.yml
index 785b42a19054db..d0b8778a1d3c7c 100644
--- a/.github/workflows/pull-request-automation.yml
+++ b/.github/workflows/pull-request-automation.yml
@@ -18,7 +18,7 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
- name: Use desired version of Node.js
- uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
+ uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
with:
node-version-file: '.nvmrc'
check-latest: true
diff --git a/.github/workflows/static-checks.yml b/.github/workflows/static-checks.yml
index 2465f357a97cf0..e0a899908bbd46 100644
--- a/.github/workflows/static-checks.yml
+++ b/.github/workflows/static-checks.yml
@@ -27,7 +27,7 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
- name: Use desired version of Node.js
- uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
+ uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
with:
node-version-file: '.nvmrc'
check-latest: true
From 37790545b2cc5681cb76681ed1bf846a9c3bbc22 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Fri, 5 Jan 2024 10:02:47 -0500
Subject: [PATCH 14/22] Bump reactivecircus/android-emulator-runner from 2.28.0
to 2.29.0 (#56823)
Bumps [reactivecircus/android-emulator-runner](https://github.com/reactivecircus/android-emulator-runner) from 2.28.0 to 2.29.0.
- [Release notes](https://github.com/reactivecircus/android-emulator-runner/releases)
- [Changelog](https://github.com/ReactiveCircus/android-emulator-runner/blob/main/CHANGELOG.md)
- [Commits](https://github.com/reactivecircus/android-emulator-runner/compare/d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b...99a4aac18b4df9b3af66c4a1f04c1f23fa10c270)
---
updated-dependencies:
- dependency-name: reactivecircus/android-emulator-runner
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
.github/workflows/rnmobile-android-runner.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/rnmobile-android-runner.yml b/.github/workflows/rnmobile-android-runner.yml
index 4121dcc177f39d..4ba1187e816ff6 100644
--- a/.github/workflows/rnmobile-android-runner.yml
+++ b/.github/workflows/rnmobile-android-runner.yml
@@ -60,7 +60,7 @@ jobs:
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
- uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b # v2.28.0
+ uses: reactivecircus/android-emulator-runner@99a4aac18b4df9b3af66c4a1f04c1f23fa10c270 # v2.29.0
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
@@ -71,7 +71,7 @@ jobs:
script: echo "Generated AVD snapshot for caching."
- name: Run tests
- uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b # v2.28.0
+ uses: reactivecircus/android-emulator-runner@99a4aac18b4df9b3af66c4a1f04c1f23fa10c270 # v2.29.0
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
From f1cce9712a57d8a52c2a00ce5c408fd705d596fe Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Fri, 5 Jan 2024 10:03:36 -0500
Subject: [PATCH 15/22] Bump actions/setup-java from 3.13.0 to 4.0.0 (#56687)
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3.13.0 to 4.0.0.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](https://github.com/actions/setup-java/compare/0ab4596768b603586c0de567f2430c30f5b0d2b0...387ac29b308b003ca37ba93a6cab5eb57c8f5f93)
---
updated-dependencies:
- dependency-name: actions/setup-java
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
.github/workflows/rnmobile-android-runner.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/rnmobile-android-runner.yml b/.github/workflows/rnmobile-android-runner.yml
index 4ba1187e816ff6..e0a3b9639cf389 100644
--- a/.github/workflows/rnmobile-android-runner.yml
+++ b/.github/workflows/rnmobile-android-runner.yml
@@ -28,7 +28,7 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
- name: Use desired version of Java
- uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
+ uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
distribution: 'corretto'
java-version: '17'
From 4064c95dfec85921beb30e13c7c1966d2e9fed2a Mon Sep 17 00:00:00 2001
From: Jonathan Desrosiers
Date: Fri, 5 Jan 2024 10:47:59 -0500
Subject: [PATCH 16/22] Group GitHub Action Dependabot updates. (#57591)
* Group GitHub Action Dependabot updates.
* Apply consistent indentation.
* Create two groups for PRs.
---
.github/dependabot.yml | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index cdeffc9b14c88a..76d1e45e3c6ce8 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -11,3 +11,16 @@ updates:
labels:
- 'GitHub Actions'
- '[Type] Build Tooling'
+ groups:
+ github-actions:
+ patterns:
+ - '*'
+ exclude-patterns:
+ - 'actions/setup-java'
+ - 'gradle/*'
+ - 'reactivecircus/*'
+ react-native:
+ patterns:
+ - 'actions/setup-java'
+ - 'gradle/*'
+ - 'reactivecircus/*'
From 08dc545f281489c584c5f78e26b31a97e4f46952 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Fri, 5 Jan 2024 10:48:28 -0500
Subject: [PATCH 17/22] Bump tj-actions/changed-files from 40.2.2 to 41.0.1
(#57366)
Bumps [tj-actions/changed-files](https://github.com/tj-actions/changed-files) from 40.2.2 to 41.0.1.
- [Release notes](https://github.com/tj-actions/changed-files/releases)
- [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md)
- [Commits](https://github.com/tj-actions/changed-files/compare/94549999469dbfa032becf298d95c87a14c34394...716b1e13042866565e00e85fd4ec490e186c4a2f)
---
updated-dependencies:
- dependency-name: tj-actions/changed-files
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
.github/workflows/php-changes-detection.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/php-changes-detection.yml b/.github/workflows/php-changes-detection.yml
index cd3c2664548fd4..fc0ba83b95dbc4 100644
--- a/.github/workflows/php-changes-detection.yml
+++ b/.github/workflows/php-changes-detection.yml
@@ -17,7 +17,7 @@ jobs:
- name: Get changed PHP files
id: changed-files-php
- uses: tj-actions/changed-files@94549999469dbfa032becf298d95c87a14c34394 # v40.2.2
+ uses: tj-actions/changed-files@716b1e13042866565e00e85fd4ec490e186c4a2f # v41.0.1
with:
files: |
*.{php}
From 3d5434d543874638437ed10a27a51848e8637db1 Mon Sep 17 00:00:00 2001
From: Jon Surrell
Date: Fri, 5 Jan 2024 18:05:39 +0100
Subject: [PATCH 18/22] DependencyExtractionWebpackPlugin: Use module for
@wordpress/interactivity (#57602)
Use an explicit module external type by default for the @wordpress/interactivity external module.
In #57577, we switched the default external type from module (externals are always hoisted to static imports) to import (externals are always dynamic import()s).
That's likely desirable for most external modules, but @wordpress/interactivity has some known issues where it may not behave as expected if it's not initialized before DOMContentLoaded (#56986).
By declaring an explicit module external type for @wordpress/interactivity, webpack will always hoist this import to a static import, preventing issues with dynamic imports of the package.
---
.../dependency-extraction-webpack-plugin/lib/util.js | 6 +++++-
.../test/__snapshots__/build.js.snap | 12 ++++++------
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/packages/dependency-extraction-webpack-plugin/lib/util.js b/packages/dependency-extraction-webpack-plugin/lib/util.js
index bc2b2221e8fc9a..50b7eaa8db98fb 100644
--- a/packages/dependency-extraction-webpack-plugin/lib/util.js
+++ b/packages/dependency-extraction-webpack-plugin/lib/util.js
@@ -67,7 +67,11 @@ function defaultRequestToExternal( request ) {
*/
function defaultRequestToExternalModule( request ) {
if ( request === '@wordpress/interactivity' ) {
- return request;
+ // This is a special case. Interactivity does not support dynamic imports at this
+ // time. We add the external "module" type to indicate that webpack should
+ // externalize this as a module (instead of our default `import()` external type)
+ // which forces @wordpress/interactivity imports to be hoisted to static imports.
+ return `module ${ request }`;
}
}
diff --git a/packages/dependency-extraction-webpack-plugin/test/__snapshots__/build.js.snap b/packages/dependency-extraction-webpack-plugin/test/__snapshots__/build.js.snap
index 73c72340c15192..84ed7660802ba2 100644
--- a/packages/dependency-extraction-webpack-plugin/test/__snapshots__/build.js.snap
+++ b/packages/dependency-extraction-webpack-plugin/test/__snapshots__/build.js.snap
@@ -21,14 +21,14 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`combine-assets\` sh
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`cyclic-dependency-graph\` should produce expected output: Asset file 'main.asset.php' should match snapshot 1`] = `
-" array('@wordpress/interactivity'), 'version' => 'a2723a31145b5f1ec2fd', 'type' => 'module');
+" array('@wordpress/interactivity'), 'version' => '58fadee5eca3ad30aff6', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`cyclic-dependency-graph\` should produce expected output: External modules should match snapshot 1`] = `
[
{
- "externalType": "import",
+ "externalType": "module",
"request": "@wordpress/interactivity",
"userRequest": "@wordpress/interactivity",
},
@@ -36,14 +36,14 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`cyclic-dependency-g
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`cyclic-dynamic-dependency-graph\` should produce expected output: Asset file 'main.asset.php' should match snapshot 1`] = `
-" array(array('id' => '@wordpress/interactivity', 'type' => 'dynamic')), 'version' => '095c38db2c83d0d2e168', 'type' => 'module');
+" array(array('id' => '@wordpress/interactivity', 'type' => 'dynamic')), 'version' => '293aebad4ca761cf396f', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`cyclic-dynamic-dependency-graph\` should produce expected output: External modules should match snapshot 1`] = `
[
{
- "externalType": "import",
+ "externalType": "module",
"request": "@wordpress/interactivity",
"userRequest": "@wordpress/interactivity",
},
@@ -249,14 +249,14 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`wordpress\` should
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`wordpress-interactivity\` should produce expected output: Asset file 'main.asset.php' should match snapshot 1`] = `
-" array(array('id' => '@wordpress/interactivity', 'type' => 'dynamic')), 'version' => 'b5625778551023855766', 'type' => 'module');
+" array(array('id' => '@wordpress/interactivity', 'type' => 'dynamic')), 'version' => 'f0242eb6da78af6ca4b8', 'type' => 'module');
"
`;
exports[`DependencyExtractionWebpackPlugin modules Webpack \`wordpress-interactivity\` should produce expected output: External modules should match snapshot 1`] = `
[
{
- "externalType": "import",
+ "externalType": "module",
"request": "@wordpress/interactivity",
"userRequest": "@wordpress/interactivity",
},
From 077ac08fe97ad7ed4a35293743b829f8e37a9bb1 Mon Sep 17 00:00:00 2001
From: Riad Benguella
Date: Fri, 5 Jan 2024 22:12:28 +0100
Subject: [PATCH 19/22] Editor: Unify the distraction free preference (#57590)
---
.../components/header/writing-menu/index.js | 4 ++--
.../edit-post/src/components/layout/index.js | 3 +--
.../src/components/preferences-modal/index.js | 9 +++++----
packages/edit-post/src/editor.js | 4 ----
.../src/hooks/commands/use-common-commands.js | 2 +-
packages/edit-post/src/index.js | 3 +--
packages/edit-post/src/store/actions.js | 14 ++++---------
packages/edit-post/src/store/test/actions.js | 12 +++++------
.../block-editor/use-site-editor-settings.js | 20 ++-----------------
.../src/components/header-edit-mode/index.js | 5 +----
.../header-edit-mode/more-menu/index.js | 4 ++--
.../edit-site/src/components/layout/index.js | 2 +-
.../src/components/preferences-modal/index.js | 9 +++++----
.../hooks/commands/use-edit-mode-commands.js | 2 +-
packages/edit-site/src/index.js | 2 +-
packages/edit-site/src/store/actions.js | 12 ++++-------
.../edit-site/src/store/private-actions.js | 2 +-
packages/edit-site/src/store/test/actions.js | 12 +++++------
.../provider/use-block-editor-settings.js | 6 ++++--
.../convert-editor-settings.js | 1 +
20 files changed, 48 insertions(+), 80 deletions(-)
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 4d5bc5653e17fc..754e65af5200d5 100644
--- a/packages/edit-post/src/components/header/writing-menu/index.js
+++ b/packages/edit-post/src/components/header/writing-menu/index.js
@@ -35,7 +35,7 @@ function WritingMenu() {
};
const turnOffDistractionFree = () => {
- setPreference( 'core/edit-post', 'distractionFree', false );
+ setPreference( 'core', 'distractionFree', false );
};
const isLargeViewport = useViewportMatch( 'medium' );
@@ -57,7 +57,7 @@ function WritingMenu() {
messageDeactivated={ __( 'Top toolbar deactivated' ) }
/>
{
const { getEditorSettings } = select( editorStore );
- const { getEditorMode, isFeatureActive } = select( editPostStore );
+ const { getEditorMode } = select( editPostStore );
+ const { get } = select( preferencesStore );
const modalActive = select( interfaceStore ).isModalActive(
PREFERENCES_MODAL_NAME
);
const mode = getEditorMode();
const isRichEditingEnabled = getEditorSettings().richEditingEnabled;
- const isDistractionFreeEnabled =
- isFeatureActive( 'distractionFree' );
+ const isDistractionFreeEnabled = get( 'core', 'distractionFree' );
return [
modalActive,
! isDistractionFreeEnabled &&
@@ -77,7 +77,7 @@ export default function EditPostPreferencesModal() {
};
const turnOffDistractionFree = () => {
- setPreference( 'core/edit-post', 'distractionFree', false );
+ setPreference( 'core', 'distractionFree', false );
};
const sections = useMemo(
@@ -195,6 +195,7 @@ export default function EditPostPreferencesModal() {
label={ __( 'Top toolbar' ) }
/>
{
const isDistractionFree = registry
.select( preferencesStore )
- .get( 'core/edit-post', 'distractionFree' );
+ .get( 'core', 'distractionFree' );
if ( isDistractionFree ) {
dispatch.toggleDistractionFree();
}
@@ -205,9 +205,7 @@ export const switchEditorMode =
if (
mode === 'text' &&
- registry
- .select( preferencesStore )
- .get( 'core/edit-post', 'distractionFree' )
+ registry.select( preferencesStore ).get( 'core', 'distractionFree' )
) {
dispatch.toggleDistractionFree();
}
@@ -580,7 +578,7 @@ export const toggleDistractionFree =
( { dispatch, registry } ) => {
const isDistractionFree = registry
.select( preferencesStore )
- .get( 'core/edit-post', 'distractionFree' );
+ .get( 'core', 'distractionFree' );
if ( ! isDistractionFree ) {
registry.batch( () => {
registry
@@ -594,11 +592,7 @@ export const toggleDistractionFree =
registry.batch( () => {
registry
.dispatch( preferencesStore )
- .set(
- 'core/edit-post',
- 'distractionFree',
- ! isDistractionFree
- );
+ .set( 'core', 'distractionFree', ! isDistractionFree );
registry
.dispatch( noticesStore )
.createInfoNotice(
diff --git a/packages/edit-post/src/store/test/actions.js b/packages/edit-post/src/store/test/actions.js
index 65dcfcf85fc676..f702d412d55dad 100644
--- a/packages/edit-post/src/store/test/actions.js
+++ b/packages/edit-post/src/store/test/actions.js
@@ -56,14 +56,12 @@ describe( 'actions', () => {
it( 'openGeneralSidebar - should turn off distraction free mode when opening a general sidebar', () => {
registry
.dispatch( preferencesStore )
- .set( 'core/edit-post', 'distractionFree', true );
+ .set( 'core', 'distractionFree', true );
registry
.dispatch( editPostStore )
.openGeneralSidebar( 'edit-post/block' );
expect(
- registry
- .select( preferencesStore )
- .get( 'core/edit-post', 'distractionFree' )
+ registry.select( preferencesStore ).get( 'core', 'distractionFree' )
).toBe( false );
} );
@@ -119,12 +117,12 @@ describe( 'actions', () => {
it( 'should turn off distraction free mode when switching to code editor', () => {
registry
.dispatch( preferencesStore )
- .set( 'core/edit-post', 'distractionFree', true );
+ .set( 'core', 'distractionFree', true );
registry.dispatch( editPostStore ).switchEditorMode( 'text' );
expect(
registry
.select( preferencesStore )
- .get( 'core/edit-post', 'distractionFree' )
+ .get( 'core', 'distractionFree' )
).toBe( false );
} );
} );
@@ -285,7 +283,7 @@ describe( 'actions', () => {
expect(
registry
.select( preferencesStore )
- .get( 'core/edit-post', 'distractionFree' )
+ .get( 'core', 'distractionFree' )
).toBe( true );
} );
} );
diff --git a/packages/edit-site/src/components/block-editor/use-site-editor-settings.js b/packages/edit-site/src/components/block-editor/use-site-editor-settings.js
index 4bc25690e83389..61c2232df6f8e0 100644
--- a/packages/edit-site/src/components/block-editor/use-site-editor-settings.js
+++ b/packages/edit-site/src/components/block-editor/use-site-editor-settings.js
@@ -1,12 +1,10 @@
/**
* WordPress dependencies
*/
-import { useViewportMatch } from '@wordpress/compose';
import { useSelect } from '@wordpress/data';
import { useMemo } from '@wordpress/element';
import { store as coreStore } from '@wordpress/core-data';
import { privateApis as editorPrivateApis } from '@wordpress/editor';
-import { store as preferencesStore } from '@wordpress/preferences';
/**
* Internal dependencies
@@ -90,15 +88,8 @@ function useArchiveLabel( templateSlug ) {
}
export function useSpecificEditorSettings() {
- const isLargeViewport = useViewportMatch( 'medium' );
const getPostLinkProps = usePostLinkProps();
- const {
- templateSlug,
- isDistractionFree,
- canvasMode,
- settings,
- postWithTemplate,
- } = useSelect(
+ const { templateSlug, canvasMode, settings, postWithTemplate } = useSelect(
( select ) => {
const {
getEditedPostType,
@@ -107,7 +98,6 @@ export function useSpecificEditorSettings() {
getCanvasMode,
getSettings,
} = unlock( select( editSiteStore ) );
- const { get: getPreference } = select( preferencesStore );
const { getEditedEntityRecord } = select( coreStore );
const usedPostType = getEditedPostType();
const usedPostId = getEditedPostId();
@@ -119,16 +109,12 @@ export function useSpecificEditorSettings() {
const _context = getEditedPostContext();
return {
templateSlug: _record.slug,
- isDistractionFree: !! getPreference(
- 'core/edit-site',
- 'distractionFree'
- ),
canvasMode: getCanvasMode(),
settings: getSettings(),
postWithTemplate: _context?.postId,
};
},
- [ isLargeViewport ]
+ []
);
const archiveLabels = useArchiveLabel( templateSlug );
const defaultRenderingMode = postWithTemplate ? 'template-locked' : 'all';
@@ -139,7 +125,6 @@ export function useSpecificEditorSettings() {
richEditingEnabled: true,
supportsTemplateMode: true,
focusMode: canvasMode !== 'view',
- isDistractionFree,
defaultRenderingMode,
getPostLinkProps,
// I wonder if they should be set in the post editor too
@@ -149,7 +134,6 @@ export function useSpecificEditorSettings() {
}, [
settings,
canvasMode,
- isDistractionFree,
defaultRenderingMode,
getPostLinkProps,
archiveLabels.archiveTypeLabel,
diff --git a/packages/edit-site/src/components/header-edit-mode/index.js b/packages/edit-site/src/components/header-edit-mode/index.js
index b513569589649c..773edf469143b9 100644
--- a/packages/edit-site/src/components/header-edit-mode/index.js
+++ b/packages/edit-site/src/components/header-edit-mode/index.js
@@ -71,10 +71,7 @@ export default function HeaderEditMode() {
select( editSiteStore )
).getEditorCanvasContainerView(),
hasFixedToolbar: getPreference( 'core', 'fixedToolbar' ),
- isDistractionFree: getPreference(
- editSiteStore.name,
- 'distractionFree'
- ),
+ isDistractionFree: getPreference( 'core', 'distractionFree' ),
isZoomOutMode: __unstableGetEditorMode() === 'zoom-out',
};
}, [] );
diff --git a/packages/edit-site/src/components/header-edit-mode/more-menu/index.js b/packages/edit-site/src/components/header-edit-mode/more-menu/index.js
index ef672aed976f70..1c2991cced9e4b 100644
--- a/packages/edit-site/src/components/header-edit-mode/more-menu/index.js
+++ b/packages/edit-site/src/components/header-edit-mode/more-menu/index.js
@@ -54,7 +54,7 @@ export default function MoreMenu( { showIconLabels } ) {
};
const turnOffDistractionFree = () => {
- setPreference( 'core/edit-site', 'distractionFree', false );
+ setPreference( 'core', 'distractionFree', false );
};
return (
@@ -84,7 +84,7 @@ export default function MoreMenu( { showIconLabels } ) {
) }
/>
{
- setPreference( 'core/edit-site', 'distractionFree', false );
+ setPreference( 'core', 'distractionFree', false );
};
- const sections = useMemo( () => [
+ const sections = [
{
name: 'general',
tabLabel: __( 'General' ),
@@ -142,6 +141,7 @@ export default function EditSitePreferencesModal() {
) }
>
),
},
- ] );
+ ];
if ( ! isModalActive ) {
return null;
}
diff --git a/packages/edit-site/src/hooks/commands/use-edit-mode-commands.js b/packages/edit-site/src/hooks/commands/use-edit-mode-commands.js
index 745bee52895d22..0265329f40b095 100644
--- a/packages/edit-site/src/hooks/commands/use-edit-mode-commands.js
+++ b/packages/edit-site/src/hooks/commands/use-edit-mode-commands.js
@@ -228,7 +228,7 @@ function useEditUICommands() {
),
showBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ),
isListViewOpen: isListViewOpened(),
- isDistractionFree: get( editSiteStore.name, 'distractionFree' ),
+ isDistractionFree: get( 'core', 'distractionFree' ),
};
}, [] );
const { openModal } = useDispatch( interfaceStore );
diff --git a/packages/edit-site/src/index.js b/packages/edit-site/src/index.js
index c145147b5e2efa..29b7df32e6d693 100644
--- a/packages/edit-site/src/index.js
+++ b/packages/edit-site/src/index.js
@@ -53,7 +53,6 @@ export function initializeEditor( id, settings ) {
// so that we won't trigger unnecessary re-renders with useEffect.
dispatch( preferencesStore ).setDefaults( 'core/edit-site', {
editorMode: 'visual',
- distractionFree: false,
welcomeGuide: true,
welcomeGuideStyles: true,
welcomeGuidePage: true,
@@ -62,6 +61,7 @@ export function initializeEditor( id, settings ) {
dispatch( preferencesStore ).setDefaults( 'core', {
allowRightClickOverrides: true,
+ distractionFree: false,
fixedToolbar: false,
focusMode: false,
inactivePanels: [],
diff --git a/packages/edit-site/src/store/actions.js b/packages/edit-site/src/store/actions.js
index c4435fbd0df412..5a8adad8e198b8 100644
--- a/packages/edit-site/src/store/actions.js
+++ b/packages/edit-site/src/store/actions.js
@@ -524,7 +524,7 @@ export const openGeneralSidebar =
( { dispatch, registry } ) => {
const isDistractionFree = registry
.select( preferencesStore )
- .get( 'core/edit-site', 'distractionFree' );
+ .get( 'core', 'distractionFree' );
if ( isDistractionFree ) {
dispatch.toggleDistractionFree();
}
@@ -561,7 +561,7 @@ export const switchEditorMode =
} else if ( mode === 'text' ) {
const isDistractionFree = registry
.select( preferencesStore )
- .get( 'core/edit-site', 'distractionFree' );
+ .get( 'core', 'distractionFree' );
if ( isDistractionFree ) {
dispatch.toggleDistractionFree();
}
@@ -602,7 +602,7 @@ export const toggleDistractionFree =
( { dispatch, registry } ) => {
const isDistractionFree = registry
.select( preferencesStore )
- .get( 'core/edit-site', 'distractionFree' );
+ .get( 'core', 'distractionFree' );
if ( ! isDistractionFree ) {
registry.batch( () => {
registry
@@ -616,11 +616,7 @@ export const toggleDistractionFree =
registry.batch( () => {
registry
.dispatch( preferencesStore )
- .set(
- 'core/edit-site',
- 'distractionFree',
- ! isDistractionFree
- );
+ .set( 'core', 'distractionFree', ! isDistractionFree );
registry
.dispatch( noticesStore )
.createInfoNotice(
diff --git a/packages/edit-site/src/store/private-actions.js b/packages/edit-site/src/store/private-actions.js
index d3037b61b1ccbc..7354f7b9b8843a 100644
--- a/packages/edit-site/src/store/private-actions.js
+++ b/packages/edit-site/src/store/private-actions.js
@@ -27,7 +27,7 @@ export const setCanvasMode =
.get( 'core', 'showListViewByDefault' ) &&
! registry
.select( preferencesStore )
- .get( 'core/edit-site', 'distractionFree' )
+ .get( 'core', 'distractionFree' )
) {
registry.dispatch( editorStore ).setIsListViewOpened( true );
} else {
diff --git a/packages/edit-site/src/store/test/actions.js b/packages/edit-site/src/store/test/actions.js
index 602b46bc1962de..b3612b9a801ccd 100644
--- a/packages/edit-site/src/store/test/actions.js
+++ b/packages/edit-site/src/store/test/actions.js
@@ -81,14 +81,14 @@ describe( 'actions', () => {
const registry = createRegistryWithStores();
registry
.dispatch( preferencesStore )
- .set( 'core/edit-site', 'distractionFree', true );
+ .set( 'core', 'distractionFree', true );
registry
.dispatch( editSiteStore )
.openGeneralSidebar( 'edit-site/global-styles' );
expect(
registry
.select( preferencesStore )
- .get( 'core/edit-site', 'distractionFree' )
+ .get( 'core', 'distractionFree' )
).toBe( false );
} );
} );
@@ -98,18 +98,18 @@ describe( 'actions', () => {
const registry = createRegistryWithStores();
registry
.dispatch( preferencesStore )
- .set( 'core/edit-site', 'distractionFree', true );
+ .set( 'core', 'distractionFree', true );
registry.dispatch( editSiteStore ).switchEditorMode( 'visual' );
expect(
registry
.select( preferencesStore )
- .get( 'core/edit-site', 'distractionFree' )
+ .get( 'core', 'distractionFree' )
).toBe( true );
registry.dispatch( editSiteStore ).switchEditorMode( 'text' );
expect(
registry
.select( preferencesStore )
- .get( 'core/edit-site', 'distractionFree' )
+ .get( 'core', 'distractionFree' )
).toBe( false );
} );
} );
@@ -146,7 +146,7 @@ describe( 'actions', () => {
expect(
registry
.select( preferencesStore )
- .get( 'core/edit-site', 'distractionFree' )
+ .get( 'core', 'distractionFree' )
).toBe( true );
} );
} );
diff --git a/packages/editor/src/components/provider/use-block-editor-settings.js b/packages/editor/src/components/provider/use-block-editor-settings.js
index f47c0b2ffd34dc..eddc295766f8ce 100644
--- a/packages/editor/src/components/provider/use-block-editor-settings.js
+++ b/packages/editor/src/components/provider/use-block-editor-settings.js
@@ -47,13 +47,11 @@ const BLOCK_EDITOR_SETTINGS = [
'enableCustomSpacing',
'enableCustomUnits',
'enableOpenverseMediaCategory',
- 'distractionFree',
'fontSizes',
'gradients',
'generateAnchors',
'getPostLinkProps',
'hasInlineToolbar',
- 'isDistractionFree',
'imageDefaultSize',
'imageDimensions',
'imageEditing',
@@ -92,6 +90,7 @@ function useBlockEditorSettings( settings, postType, postId ) {
allowRightClickOverrides,
focusMode,
hasFixedToolbar,
+ isDistractionFree,
keepCaretInsideBlock,
reusableBlocks,
hasUploadPermissions,
@@ -133,6 +132,7 @@ function useBlockEditorSettings( settings, postType, postId ) {
focusMode: get( 'core', 'focusMode' ),
hasFixedToolbar:
get( 'core', 'fixedToolbar' ) || ! isLargeViewport,
+ isDistractionFree: get( 'core', 'distractionFree' ),
keepCaretInsideBlock: get( 'core', 'keepCaretInsideBlock' ),
reusableBlocks: isWeb
? getEntityRecords( 'postType', 'wp_block', {
@@ -227,6 +227,7 @@ function useBlockEditorSettings( settings, postType, postId ) {
allowRightClickOverrides,
focusMode: focusMode && ! forceDisableFocusMode,
hasFixedToolbar,
+ isDistractionFree,
keepCaretInsideBlock,
mediaUpload: hasUploadPermissions ? mediaUpload : undefined,
__experimentalReusableBlocks: reusableBlocks,
@@ -264,6 +265,7 @@ function useBlockEditorSettings( settings, postType, postId ) {
focusMode,
forceDisableFocusMode,
hasFixedToolbar,
+ isDistractionFree,
keepCaretInsideBlock,
settings,
hasUploadPermissions,
diff --git a/packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js b/packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js
index b245fb958571f2..b1940ef1b10813 100644
--- a/packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js
+++ b/packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js
@@ -6,6 +6,7 @@ export default function convertEditorSettings( data ) {
let newData = data;
const settingsToMoveToCore = [
'allowRightClickOverrides',
+ 'distractionFree',
'fixedToolbar',
'focusMode',
'inactivePanels',
From b983444eb197c6ca4324be9c3b1a87b62bf4358e Mon Sep 17 00:00:00 2001
From: George Mamadashvili
Date: Sat, 6 Jan 2024 11:21:21 +0400
Subject: [PATCH 20/22] File: Remove unnecessary synchronization effect
(#57585)
---
packages/block-library/src/file/edit.js | 35 ++++++++++---------------
1 file changed, 14 insertions(+), 21 deletions(-)
diff --git a/packages/block-library/src/file/edit.js b/packages/block-library/src/file/edit.js
index 20c747de2de988..528a488039acfd 100644
--- a/packages/block-library/src/file/edit.js
+++ b/packages/block-library/src/file/edit.js
@@ -63,7 +63,6 @@ function ClipboardToolbarButton( { text, disabled } ) {
function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
const {
id,
- fileId,
fileName,
href,
textLinkHref,
@@ -85,8 +84,7 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
);
const { createErrorNotice } = useDispatch( noticesStore );
- const { toggleSelection, __unstableMarkNextChangeAsNotPersistent } =
- useDispatch( blockEditorStore );
+ const { toggleSelection } = useDispatch( blockEditorStore );
useEffect( () => {
// Upload a file drag-and-dropped into the editor.
@@ -109,26 +107,21 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
}
}, [] );
- useEffect( () => {
- if ( ! fileId && href ) {
- // Add a unique fileId to each file block.
- __unstableMarkNextChangeAsNotPersistent();
- setAttributes( { fileId: `wp-block-file--media-${ clientId }` } );
- }
- }, [ href, fileId, clientId ] );
-
function onSelectFile( newMedia ) {
- if ( newMedia && newMedia.url ) {
- const isPdf = newMedia.url.endsWith( '.pdf' );
- setAttributes( {
- href: newMedia.url,
- fileName: newMedia.title,
- textLinkHref: newMedia.url,
- id: newMedia.id,
- displayPreview: isPdf ? true : undefined,
- previewHeight: isPdf ? 600 : undefined,
- } );
+ if ( ! newMedia || ! newMedia.url ) {
+ return;
}
+
+ const isPdf = newMedia.url.endsWith( '.pdf' );
+ setAttributes( {
+ href: newMedia.url,
+ fileName: newMedia.title,
+ textLinkHref: newMedia.url,
+ id: newMedia.id,
+ displayPreview: isPdf ? true : undefined,
+ previewHeight: isPdf ? 600 : undefined,
+ fileId: `wp-block-file--media-${ clientId }`,
+ } );
}
function onUploadError( message ) {
From fa12531d697832886333ce7ec0f2670e5117032b Mon Sep 17 00:00:00 2001
From: George Mamadashvili
Date: Sat, 6 Jan 2024 11:27:09 +0400
Subject: [PATCH 21/22] PostFeaturedImage: Remove unnecessary 'block-editor'
store subscription (#57554)
---
.../editor/src/components/post-featured-image/index.js | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/packages/editor/src/components/post-featured-image/index.js b/packages/editor/src/components/post-featured-image/index.js
index 8be344bcdad208..a04701abd28095 100644
--- a/packages/editor/src/components/post-featured-image/index.js
+++ b/packages/editor/src/components/post-featured-image/index.js
@@ -98,17 +98,15 @@ function PostFeaturedImage( {
} ) {
const toggleRef = useRef();
const [ isLoading, setIsLoading ] = useState( false );
- const mediaUpload = useSelect( ( select ) => {
- return select( blockEditorStore ).getSettings().mediaUpload;
- }, [] );
+ const { getSettings } = useSelect( blockEditorStore );
const { mediaWidth, mediaHeight, mediaSourceUrl } = getMediaDetails(
media,
currentPostId
);
function onDropFiles( filesList ) {
- mediaUpload( {
- allowedTypes: [ 'image' ],
+ getSettings().mediaUpload( {
+ allowedTypes: ALLOWED_MEDIA_TYPES,
filesList,
onFileChange( [ image ] ) {
if ( isBlobURL( image?.url ) ) {
From ffbc300ede03b6337cbd950130e99955132ea4fb Mon Sep 17 00:00:00 2001
From: Aki Hamano <54422211+t-hamano@users.noreply.github.com>
Date: Sat, 6 Jan 2024 17:44:10 +0900
Subject: [PATCH 22/22] Footnotes: fix wrong link when adding more than 9
footnotes (#57599)
---
packages/core-data/src/footnotes/index.js | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/packages/core-data/src/footnotes/index.js b/packages/core-data/src/footnotes/index.js
index 9458290f9cb40b..b80ba65d142edb 100644
--- a/packages/core-data/src/footnotes/index.js
+++ b/packages/core-data/src/footnotes/index.js
@@ -75,6 +75,14 @@ export function updateFootnotesFromMeta( blocks, meta ) {
html: replacement.innerHTML,
} );
countValue.text = String( index + 1 );
+ countValue.formats = Array.from(
+ { length: countValue.text.length },
+ () => countValue.formats[ 0 ]
+ );
+ countValue.replacements = Array.from(
+ { length: countValue.text.length },
+ () => countValue.replacements[ 0 ]
+ );
replacement.innerHTML = toHTMLString( {
value: countValue,
} );