@wordpress/block-editor 13.0.0 → 13.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/block-actions/index.js +4 -6
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-draggable/index.js +1 -1
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-list/block.js +2 -2
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +2 -2
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +3 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-lock/use-block-lock.js +2 -4
- package/build/components/block-lock/use-block-lock.js.map +1 -1
- package/build/components/block-mover/index.js +1 -1
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-mover/index.native.js +1 -1
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-switcher/block-variation-transformations.js +1 -3
- package/build/components/block-switcher/block-variation-transformations.js.map +1 -1
- package/build/components/block-switcher/index.js +13 -6
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +6 -10
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +2 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/button-block-appender/index.js +4 -1
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +18 -10
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +3 -3
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +2 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +14 -1
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +3 -3
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.native.js +1 -1
- package/build/components/inserter/block-types-tab.native.js.map +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js +3 -2
- package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build/components/link-control/link-preview.js +13 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block.js +7 -6
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +3 -1
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/use-clipboard-handler.js +1 -1
- package/build/components/list-view/use-clipboard-handler.js.map +1 -1
- package/build/components/provider/use-block-sync.js +1 -7
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/rich-text/index.native.js +4 -0
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +6 -4
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +9 -12
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build/components/use-block-commands/index.js +3 -3
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/components/writing-flow/use-clipboard-handler.js +22 -3
- package/build/components/writing-flow/use-clipboard-handler.js.map +1 -1
- package/build/hooks/block-bindings.js +19 -16
- package/build/hooks/block-bindings.js.map +1 -1
- package/build/hooks/block-style-variation.js +2 -2
- package/build/hooks/block-style-variation.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +7 -2
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/private-apis.js +3 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +4 -4
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +1 -36
- package/build/store/private-actions.js.map +1 -1
- package/build/store/selectors.js +19 -20
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-actions/index.js +4 -6
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-draggable/index.js +1 -1
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-list/block.js +2 -2
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +2 -2
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +3 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-lock/use-block-lock.js +2 -4
- package/build-module/components/block-lock/use-block-lock.js.map +1 -1
- package/build-module/components/block-mover/index.js +1 -1
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +1 -1
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-switcher/block-variation-transformations.js +1 -3
- package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -1
- package/build-module/components/block-switcher/index.js +15 -8
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +7 -10
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +2 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/button-block-appender/index.js +4 -1
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +19 -11
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +4 -4
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +2 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +14 -1
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +3 -3
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.native.js +1 -1
- package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js +4 -3
- package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +15 -1
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block.js +7 -6
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +3 -1
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/use-clipboard-handler.js +1 -1
- package/build-module/components/list-view/use-clipboard-handler.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +1 -7
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +4 -0
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +6 -4
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +9 -12
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +3 -3
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/components/writing-flow/use-clipboard-handler.js +23 -4
- package/build-module/components/writing-flow/use-clipboard-handler.js.map +1 -1
- package/build-module/hooks/block-bindings.js +20 -17
- package/build-module/hooks/block-bindings.js.map +1 -1
- package/build-module/hooks/block-style-variation.js +2 -2
- package/build-module/hooks/block-style-variation.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +7 -2
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +4 -4
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +1 -35
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/selectors.js +19 -20
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/content-rtl.css +1 -1
- package/build-style/content.css +1 -1
- package/build-style/style-rtl.css +13 -17
- package/build-style/style.css +13 -17
- package/package.json +31 -31
- package/src/components/block-actions/index.js +3 -7
- package/src/components/block-canvas/style.scss +2 -2
- package/src/components/block-draggable/index.js +1 -1
- package/src/components/block-list/block.js +2 -2
- package/src/components/block-list/block.native.js +2 -2
- package/src/components/block-list/use-in-between-inserter.js +3 -1
- package/src/components/block-lock/use-block-lock.js +2 -4
- package/src/components/block-mover/index.js +1 -1
- package/src/components/block-mover/index.native.js +1 -1
- package/src/components/block-settings-menu/block-settings-dropdown.js +1 -1
- package/src/components/block-switcher/block-variation-transformations.js +4 -9
- package/src/components/block-switcher/index.js +27 -12
- package/src/components/block-switcher/style.scss +5 -0
- package/src/components/block-toolbar/index.js +7 -9
- package/src/components/block-toolbar/style.scss +9 -6
- package/src/components/block-tools/block-selection-button.js +2 -2
- package/src/components/block-variation-picker/content.scss +1 -1
- package/src/components/button-block-appender/index.js +2 -0
- package/src/components/date-format-picker/index.js +25 -13
- package/src/components/global-styles/background-panel.js +13 -4
- package/src/components/global-styles/hooks.js +2 -4
- package/src/components/global-styles/use-global-styles-output.js +24 -4
- package/src/components/inserter/block-types-tab.js +0 -1
- package/src/components/inserter/block-types-tab.native.js +2 -1
- package/src/components/inserter/hooks/use-block-types-state.js +10 -5
- package/src/components/inserter/style.scss +4 -0
- package/src/components/link-control/link-preview.js +19 -1
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/list-view/block.js +7 -7
- package/src/components/list-view/branch.js +5 -1
- package/src/components/list-view/use-clipboard-handler.js +1 -6
- package/src/components/provider/use-block-sync.js +0 -6
- package/src/components/rich-text/index.native.js +4 -0
- package/src/components/rich-text/native/index.native.js +3 -1
- package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +7 -4
- package/src/components/use-block-commands/index.js +3 -4
- package/src/components/writing-flow/use-clipboard-handler.js +29 -7
- package/src/hooks/block-bindings.js +28 -22
- package/src/hooks/block-style-variation.js +2 -2
- package/src/hooks/use-bindings-attributes.js +11 -1
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +4 -10
- package/src/store/private-actions.js +1 -34
- package/src/store/selectors.js +22 -27
- package/src/style.scss +0 -1
- package/build/components/block-bindings-toolbar-indicator/index.js +0 -106
- package/build/components/block-bindings-toolbar-indicator/index.js.map +0 -1
- package/build/store/undo-ignore.js +0 -11
- package/build/store/undo-ignore.js.map +0 -1
- package/build-module/components/block-bindings-toolbar-indicator/index.js +0 -99
- package/build-module/components/block-bindings-toolbar-indicator/index.js.map +0 -1
- package/build-module/store/undo-ignore.js +0 -5
- package/build-module/store/undo-ignore.js.map +0 -1
- package/src/components/block-bindings-toolbar-indicator/index.js +0 -135
- package/src/components/block-bindings-toolbar-indicator/style.scss +0 -12
- package/src/store/undo-ignore.js +0 -4
package/src/private-apis.js
CHANGED
|
@@ -43,6 +43,7 @@ import { PrivateBlockPopover } from './components/block-popover';
|
|
|
43
43
|
import { PrivateInserterLibrary } from './components/inserter/library';
|
|
44
44
|
import { PrivatePublishDateTimePicker } from './components/publish-date-time-picker';
|
|
45
45
|
import useSpacingSizes from './components/spacing-sizes-control/hooks/use-spacing-sizes';
|
|
46
|
+
import useBlockDisplayTitle from './components/block-title/use-block-display-title';
|
|
46
47
|
|
|
47
48
|
/**
|
|
48
49
|
* Private @wordpress/block-editor APIs.
|
|
@@ -86,4 +87,5 @@ lock( privateApis, {
|
|
|
86
87
|
PrivateBlockPopover,
|
|
87
88
|
PrivatePublishDateTimePicker,
|
|
88
89
|
useSpacingSizes,
|
|
90
|
+
useBlockDisplayTitle,
|
|
89
91
|
} );
|
package/src/store/actions.js
CHANGED
|
@@ -409,7 +409,7 @@ const createOnMove =
|
|
|
409
409
|
( clientIds, rootClientId ) =>
|
|
410
410
|
( { select, dispatch } ) => {
|
|
411
411
|
// If one of the blocks is locked or the parent is locked, we cannot move any block.
|
|
412
|
-
const canMoveBlocks = select.canMoveBlocks( clientIds
|
|
412
|
+
const canMoveBlocks = select.canMoveBlocks( clientIds );
|
|
413
413
|
if ( ! canMoveBlocks ) {
|
|
414
414
|
return;
|
|
415
415
|
}
|
|
@@ -431,10 +431,7 @@ export const moveBlocksUp = createOnMove( 'MOVE_BLOCKS_UP' );
|
|
|
431
431
|
export const moveBlocksToPosition =
|
|
432
432
|
( clientIds, fromRootClientId = '', toRootClientId = '', index ) =>
|
|
433
433
|
( { select, dispatch } ) => {
|
|
434
|
-
const canMoveBlocks = select.canMoveBlocks(
|
|
435
|
-
clientIds,
|
|
436
|
-
fromRootClientId
|
|
437
|
-
);
|
|
434
|
+
const canMoveBlocks = select.canMoveBlocks( clientIds );
|
|
438
435
|
|
|
439
436
|
// If one of the blocks is locked or the parent is locked, we cannot move any block.
|
|
440
437
|
if ( ! canMoveBlocks ) {
|
|
@@ -443,10 +440,7 @@ export const moveBlocksToPosition =
|
|
|
443
440
|
|
|
444
441
|
// If moving inside the same root block the move is always possible.
|
|
445
442
|
if ( fromRootClientId !== toRootClientId ) {
|
|
446
|
-
const canRemoveBlocks = select.canRemoveBlocks(
|
|
447
|
-
clientIds,
|
|
448
|
-
fromRootClientId
|
|
449
|
-
);
|
|
443
|
+
const canRemoveBlocks = select.canRemoveBlocks( clientIds );
|
|
450
444
|
|
|
451
445
|
// If we're moving to another block, it means we're deleting blocks from
|
|
452
446
|
// the original block, so we need to check if removing is possible.
|
|
@@ -2010,7 +2004,7 @@ export function __unstableSetTemporarilyEditingAsBlocks(
|
|
|
2010
2004
|
* per_page: 'page_size',
|
|
2011
2005
|
* search: 'q',
|
|
2012
2006
|
* };
|
|
2013
|
-
* const url = new URL( 'https://api.openverse.
|
|
2007
|
+
* const url = new URL( 'https://api.openverse.org/v1/images/' );
|
|
2014
2008
|
* Object.entries( finalQuery ).forEach( ( [ key, value ] ) => {
|
|
2015
2009
|
* const queryKey = mapFromInserterMediaRequest[ key ] || key;
|
|
2016
2010
|
* url.searchParams.set( queryKey, value );
|
|
@@ -6,7 +6,6 @@ import { Platform } from '@wordpress/element';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { undoIgnoreBlocks } from './undo-ignore';
|
|
10
9
|
import { store as blockEditorStore } from './index';
|
|
11
10
|
import { unlock } from '../lock-unlock';
|
|
12
11
|
|
|
@@ -105,11 +104,7 @@ export const privateRemoveBlocks =
|
|
|
105
104
|
}
|
|
106
105
|
|
|
107
106
|
clientIds = castArray( clientIds );
|
|
108
|
-
const
|
|
109
|
-
const canRemoveBlocks = select.canRemoveBlocks(
|
|
110
|
-
clientIds,
|
|
111
|
-
rootClientId
|
|
112
|
-
);
|
|
107
|
+
const canRemoveBlocks = select.canRemoveBlocks( clientIds );
|
|
113
108
|
|
|
114
109
|
if ( ! canRemoveBlocks ) {
|
|
115
110
|
return;
|
|
@@ -292,34 +287,6 @@ export function deleteStyleOverride( id ) {
|
|
|
292
287
|
};
|
|
293
288
|
}
|
|
294
289
|
|
|
295
|
-
/**
|
|
296
|
-
* A higher-order action that mark every change inside a callback as "non-persistent"
|
|
297
|
-
* and ignore pushing to the undo history stack. It's primarily used for synchronized
|
|
298
|
-
* derived updates from the block editor without affecting the undo history.
|
|
299
|
-
*
|
|
300
|
-
* @param {() => void} callback The synchronous callback to derive updates.
|
|
301
|
-
*/
|
|
302
|
-
export function syncDerivedUpdates( callback ) {
|
|
303
|
-
return ( { dispatch, select, registry } ) => {
|
|
304
|
-
registry.batch( () => {
|
|
305
|
-
// Mark every change in the `callback` as non-persistent.
|
|
306
|
-
dispatch( {
|
|
307
|
-
type: 'SET_EXPLICIT_PERSISTENT',
|
|
308
|
-
isPersistentChange: false,
|
|
309
|
-
} );
|
|
310
|
-
callback();
|
|
311
|
-
dispatch( {
|
|
312
|
-
type: 'SET_EXPLICIT_PERSISTENT',
|
|
313
|
-
isPersistentChange: undefined,
|
|
314
|
-
} );
|
|
315
|
-
|
|
316
|
-
// Ignore pushing undo stack for the updated blocks.
|
|
317
|
-
const updatedBlocks = select.getBlocks();
|
|
318
|
-
undoIgnoreBlocks.add( updatedBlocks );
|
|
319
|
-
} );
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
|
|
323
290
|
/**
|
|
324
291
|
* Action that sets the element that had focus when focus leaves the editor canvas.
|
|
325
292
|
*
|
package/src/store/selectors.js
CHANGED
|
@@ -76,6 +76,8 @@ const EMPTY_ARRAY = [];
|
|
|
76
76
|
*/
|
|
77
77
|
const EMPTY_SET = new Set();
|
|
78
78
|
|
|
79
|
+
const EMPTY_OBJECT = {};
|
|
80
|
+
|
|
79
81
|
/**
|
|
80
82
|
* Returns a block's name given its client ID, or null if no block exists with
|
|
81
83
|
* the client ID.
|
|
@@ -1710,13 +1712,12 @@ export function canInsertBlocks( state, clientIds, rootClientId = null ) {
|
|
|
1710
1712
|
/**
|
|
1711
1713
|
* Determines if the given block is allowed to be deleted.
|
|
1712
1714
|
*
|
|
1713
|
-
* @param {Object}
|
|
1714
|
-
* @param {string}
|
|
1715
|
-
* @param {?string} rootClientId Optional root client ID of block list.
|
|
1715
|
+
* @param {Object} state Editor state.
|
|
1716
|
+
* @param {string} clientId The block client Id.
|
|
1716
1717
|
*
|
|
1717
1718
|
* @return {boolean} Whether the given block is allowed to be removed.
|
|
1718
1719
|
*/
|
|
1719
|
-
export function canRemoveBlock( state, clientId
|
|
1720
|
+
export function canRemoveBlock( state, clientId ) {
|
|
1720
1721
|
const attributes = getBlockAttributes( state, clientId );
|
|
1721
1722
|
if ( attributes === null ) {
|
|
1722
1723
|
return true;
|
|
@@ -1724,6 +1725,8 @@ export function canRemoveBlock( state, clientId, rootClientId = null ) {
|
|
|
1724
1725
|
if ( attributes.lock?.remove !== undefined ) {
|
|
1725
1726
|
return ! attributes.lock.remove;
|
|
1726
1727
|
}
|
|
1728
|
+
|
|
1729
|
+
const rootClientId = getBlockRootClientId( state, clientId );
|
|
1727
1730
|
if ( getTemplateLock( state, rootClientId ) ) {
|
|
1728
1731
|
return false;
|
|
1729
1732
|
}
|
|
@@ -1734,28 +1737,24 @@ export function canRemoveBlock( state, clientId, rootClientId = null ) {
|
|
|
1734
1737
|
/**
|
|
1735
1738
|
* Determines if the given blocks are allowed to be removed.
|
|
1736
1739
|
*
|
|
1737
|
-
* @param {Object}
|
|
1738
|
-
* @param {string}
|
|
1739
|
-
* @param {?string} rootClientId Optional root client ID of block list.
|
|
1740
|
+
* @param {Object} state Editor state.
|
|
1741
|
+
* @param {string} clientIds The block client IDs to be removed.
|
|
1740
1742
|
*
|
|
1741
1743
|
* @return {boolean} Whether the given blocks are allowed to be removed.
|
|
1742
1744
|
*/
|
|
1743
|
-
export function canRemoveBlocks( state, clientIds
|
|
1744
|
-
return clientIds.every( ( clientId ) =>
|
|
1745
|
-
canRemoveBlock( state, clientId, rootClientId )
|
|
1746
|
-
);
|
|
1745
|
+
export function canRemoveBlocks( state, clientIds ) {
|
|
1746
|
+
return clientIds.every( ( clientId ) => canRemoveBlock( state, clientId ) );
|
|
1747
1747
|
}
|
|
1748
1748
|
|
|
1749
1749
|
/**
|
|
1750
1750
|
* Determines if the given block is allowed to be moved.
|
|
1751
1751
|
*
|
|
1752
|
-
* @param {Object}
|
|
1753
|
-
* @param {string}
|
|
1754
|
-
* @param {?string} rootClientId Optional root client ID of block list.
|
|
1752
|
+
* @param {Object} state Editor state.
|
|
1753
|
+
* @param {string} clientId The block client Id.
|
|
1755
1754
|
*
|
|
1756
1755
|
* @return {boolean | undefined} Whether the given block is allowed to be moved.
|
|
1757
1756
|
*/
|
|
1758
|
-
export function canMoveBlock( state, clientId
|
|
1757
|
+
export function canMoveBlock( state, clientId ) {
|
|
1759
1758
|
const attributes = getBlockAttributes( state, clientId );
|
|
1760
1759
|
if ( attributes === null ) {
|
|
1761
1760
|
return true;
|
|
@@ -1763,6 +1762,8 @@ export function canMoveBlock( state, clientId, rootClientId = null ) {
|
|
|
1763
1762
|
if ( attributes.lock?.move !== undefined ) {
|
|
1764
1763
|
return ! attributes.lock.move;
|
|
1765
1764
|
}
|
|
1765
|
+
|
|
1766
|
+
const rootClientId = getBlockRootClientId( state, clientId );
|
|
1766
1767
|
if ( getTemplateLock( state, rootClientId ) === 'all' ) {
|
|
1767
1768
|
return false;
|
|
1768
1769
|
}
|
|
@@ -1772,16 +1773,13 @@ export function canMoveBlock( state, clientId, rootClientId = null ) {
|
|
|
1772
1773
|
/**
|
|
1773
1774
|
* Determines if the given blocks are allowed to be moved.
|
|
1774
1775
|
*
|
|
1775
|
-
* @param {Object}
|
|
1776
|
-
* @param {string}
|
|
1777
|
-
* @param {?string} rootClientId Optional root client ID of block list.
|
|
1776
|
+
* @param {Object} state Editor state.
|
|
1777
|
+
* @param {string} clientIds The block client IDs to be moved.
|
|
1778
1778
|
*
|
|
1779
1779
|
* @return {boolean} Whether the given blocks are allowed to be moved.
|
|
1780
1780
|
*/
|
|
1781
|
-
export function canMoveBlocks( state, clientIds
|
|
1782
|
-
return clientIds.every( ( clientId ) =>
|
|
1783
|
-
canMoveBlock( state, clientId, rootClientId )
|
|
1784
|
-
);
|
|
1781
|
+
export function canMoveBlocks( state, clientIds ) {
|
|
1782
|
+
return clientIds.every( ( clientId ) => canMoveBlock( state, clientId ) );
|
|
1785
1783
|
}
|
|
1786
1784
|
|
|
1787
1785
|
/**
|
|
@@ -1996,7 +1994,7 @@ const buildBlockTypeItem =
|
|
|
1996
1994
|
*/
|
|
1997
1995
|
export const getInserterItems = createRegistrySelector( ( select ) =>
|
|
1998
1996
|
createSelector(
|
|
1999
|
-
( state, rootClientId = null, options =
|
|
1997
|
+
( state, rootClientId = null, options = EMPTY_OBJECT ) => {
|
|
2000
1998
|
const buildReusableBlockInserterItem = ( reusableBlock ) => {
|
|
2001
1999
|
const icon = ! reusableBlock.wp_pattern_sync_status
|
|
2002
2000
|
? {
|
|
@@ -3039,10 +3037,7 @@ export const isGroupable = createRegistrySelector(
|
|
|
3039
3037
|
rootClientId
|
|
3040
3038
|
);
|
|
3041
3039
|
const _isGroupable = groupingBlockAvailable && _clientIds.length;
|
|
3042
|
-
return (
|
|
3043
|
-
_isGroupable &&
|
|
3044
|
-
canRemoveBlocks( state, _clientIds, rootClientId )
|
|
3045
|
-
);
|
|
3040
|
+
return _isGroupable && canRemoveBlocks( state, _clientIds );
|
|
3046
3041
|
}
|
|
3047
3042
|
);
|
|
3048
3043
|
|
package/src/style.scss
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
@import "./autocompleters/style.scss";
|
|
2
2
|
@import "./components/block-alignment-control/style.scss";
|
|
3
|
-
@import "./components/block-bindings-toolbar-indicator/style.scss";
|
|
4
3
|
@import "./components/block-canvas/style.scss";
|
|
5
4
|
@import "./components/block-icon/style.scss";
|
|
6
5
|
@import "./components/block-inspector/style.scss";
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = BlockBindingsToolbarIndicator;
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
var _i18n = require("@wordpress/i18n");
|
|
10
|
-
var _components = require("@wordpress/components");
|
|
11
|
-
var _blocks = require("@wordpress/blocks");
|
|
12
|
-
var _data = require("@wordpress/data");
|
|
13
|
-
var _icons = require("@wordpress/icons");
|
|
14
|
-
var _store = require("../../store");
|
|
15
|
-
var _blockIcon = _interopRequireDefault(require("../block-icon"));
|
|
16
|
-
var _useBlockDisplayTitle = _interopRequireDefault(require("../block-title/use-block-display-title"));
|
|
17
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
-
/**
|
|
19
|
-
* WordPress dependencies
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Internal dependencies
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
function BlockBindingsToolbarIndicator({
|
|
27
|
-
clientIds
|
|
28
|
-
}) {
|
|
29
|
-
const isSingleBlockSelected = clientIds.length === 1;
|
|
30
|
-
const {
|
|
31
|
-
icon,
|
|
32
|
-
firstBlockName,
|
|
33
|
-
isConnectedToPatternOverrides
|
|
34
|
-
} = (0, _data.useSelect)(select => {
|
|
35
|
-
const {
|
|
36
|
-
getBlockAttributes,
|
|
37
|
-
getBlockNamesByClientId,
|
|
38
|
-
getBlocksByClientId
|
|
39
|
-
} = select(_store.store);
|
|
40
|
-
const {
|
|
41
|
-
getBlockType,
|
|
42
|
-
getActiveBlockVariation
|
|
43
|
-
} = select(_blocks.store);
|
|
44
|
-
const blockTypeNames = getBlockNamesByClientId(clientIds);
|
|
45
|
-
const _firstBlockTypeName = blockTypeNames[0];
|
|
46
|
-
const firstBlockType = getBlockType(_firstBlockTypeName);
|
|
47
|
-
let _icon;
|
|
48
|
-
if (isSingleBlockSelected) {
|
|
49
|
-
const match = getActiveBlockVariation(_firstBlockTypeName, getBlockAttributes(clientIds[0]));
|
|
50
|
-
// Take into account active block variations.
|
|
51
|
-
_icon = match?.icon || firstBlockType.icon;
|
|
52
|
-
} else {
|
|
53
|
-
const isSelectionOfSameType = new Set(blockTypeNames).size === 1;
|
|
54
|
-
// When selection consists of blocks of multiple types, display an
|
|
55
|
-
// appropriate icon to communicate the non-uniformity.
|
|
56
|
-
_icon = isSelectionOfSameType ? firstBlockType.icon : _icons.copy;
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
icon: _icon,
|
|
60
|
-
firstBlockName: getBlockAttributes(clientIds[0]).metadata.name,
|
|
61
|
-
isConnectedToPatternOverrides: getBlocksByClientId(clientIds).some(block => Object.values(block?.attributes.metadata?.bindings).some(binding => binding.source === 'core/pattern-overrides'))
|
|
62
|
-
};
|
|
63
|
-
}, [clientIds, isSingleBlockSelected]);
|
|
64
|
-
const firstBlockTitle = (0, _useBlockDisplayTitle.default)({
|
|
65
|
-
clientId: clientIds[0],
|
|
66
|
-
maximumLength: 35
|
|
67
|
-
});
|
|
68
|
-
let blockDescription = isSingleBlockSelected ? (0, _i18n._x)('This block is connected.', 'block toolbar button label and description') : (0, _i18n._x)('These blocks are connected.', 'block toolbar button label and description');
|
|
69
|
-
if (isConnectedToPatternOverrides && firstBlockName) {
|
|
70
|
-
blockDescription = isSingleBlockSelected ? (0, _i18n.sprintf)( /* translators: %1s: The block type's name; %2s: The block's user-provided name (the same as the override name). */
|
|
71
|
-
(0, _i18n.__)('This %1$s is editable using the "%2$s" override.'), firstBlockTitle.toLowerCase(), firstBlockName) : (0, _i18n.__)('These blocks are editable using overrides.');
|
|
72
|
-
}
|
|
73
|
-
const descriptionId = (0, _element.useId)();
|
|
74
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarGroup, {
|
|
75
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarItem, {
|
|
76
|
-
children: toggleProps => /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.DropdownMenu, {
|
|
77
|
-
className: "block-editor-block-bindings-toolbar-indicator",
|
|
78
|
-
label: firstBlockTitle,
|
|
79
|
-
popoverProps: {
|
|
80
|
-
placement: 'bottom-start',
|
|
81
|
-
className: 'block-editor-block-bindings-toolbar-indicator__popover'
|
|
82
|
-
},
|
|
83
|
-
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
84
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockIcon.default, {
|
|
85
|
-
icon: icon,
|
|
86
|
-
className: "block-editor-block-bindings-toolbar-indicator-icon",
|
|
87
|
-
showColors: true
|
|
88
|
-
})
|
|
89
|
-
}),
|
|
90
|
-
toggleProps: {
|
|
91
|
-
describedBy: blockDescription,
|
|
92
|
-
...toggleProps
|
|
93
|
-
},
|
|
94
|
-
menuProps: {
|
|
95
|
-
orientation: 'both',
|
|
96
|
-
'aria-describedby': descriptionId
|
|
97
|
-
},
|
|
98
|
-
children: () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalText, {
|
|
99
|
-
id: descriptionId,
|
|
100
|
-
children: blockDescription
|
|
101
|
-
})
|
|
102
|
-
})
|
|
103
|
-
})
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_i18n","_components","_blocks","_data","_icons","_store","_blockIcon","_interopRequireDefault","_useBlockDisplayTitle","_jsxRuntime","BlockBindingsToolbarIndicator","clientIds","isSingleBlockSelected","length","icon","firstBlockName","isConnectedToPatternOverrides","useSelect","select","getBlockAttributes","getBlockNamesByClientId","getBlocksByClientId","blockEditorStore","getBlockType","getActiveBlockVariation","blocksStore","blockTypeNames","_firstBlockTypeName","firstBlockType","_icon","match","isSelectionOfSameType","Set","size","copy","metadata","name","some","block","Object","values","attributes","bindings","binding","source","firstBlockTitle","useBlockDisplayTitle","clientId","maximumLength","blockDescription","_x","sprintf","__","toLowerCase","descriptionId","useId","jsx","ToolbarGroup","children","ToolbarItem","toggleProps","DropdownMenu","className","label","popoverProps","placement","Fragment","default","showColors","describedBy","menuProps","orientation","__experimentalText","id"],"sources":["@wordpress/block-editor/src/components/block-bindings-toolbar-indicator/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useId } from '@wordpress/element';\nimport { __, sprintf, _x } from '@wordpress/i18n';\nimport {\n\tDropdownMenu,\n\tToolbarGroup,\n\tToolbarItem,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { copy } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\n\nexport default function BlockBindingsToolbarIndicator( { clientIds } ) {\n\tconst isSingleBlockSelected = clientIds.length === 1;\n\tconst { icon, firstBlockName, isConnectedToPatternOverrides } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockNamesByClientId,\n\t\t\t\tgetBlocksByClientId,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst blockTypeNames = getBlockNamesByClientId( clientIds );\n\t\t\tconst _firstBlockTypeName = blockTypeNames[ 0 ];\n\t\t\tconst firstBlockType = getBlockType( _firstBlockTypeName );\n\t\t\tlet _icon;\n\t\t\tif ( isSingleBlockSelected ) {\n\t\t\t\tconst match = getActiveBlockVariation(\n\t\t\t\t\t_firstBlockTypeName,\n\t\t\t\t\tgetBlockAttributes( clientIds[ 0 ] )\n\t\t\t\t);\n\t\t\t\t// Take into account active block variations.\n\t\t\t\t_icon = match?.icon || firstBlockType.icon;\n\t\t\t} else {\n\t\t\t\tconst isSelectionOfSameType =\n\t\t\t\t\tnew Set( blockTypeNames ).size === 1;\n\t\t\t\t// When selection consists of blocks of multiple types, display an\n\t\t\t\t// appropriate icon to communicate the non-uniformity.\n\t\t\t\t_icon = isSelectionOfSameType ? firstBlockType.icon : copy;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ticon: _icon,\n\t\t\t\tfirstBlockName: getBlockAttributes( clientIds[ 0 ] ).metadata\n\t\t\t\t\t.name,\n\t\t\t\tisConnectedToPatternOverrides: getBlocksByClientId(\n\t\t\t\t\tclientIds\n\t\t\t\t).some( ( block ) =>\n\t\t\t\t\tObject.values( block?.attributes.metadata?.bindings ).some(\n\t\t\t\t\t\t( binding ) =>\n\t\t\t\t\t\t\tbinding.source === 'core/pattern-overrides'\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientIds, isSingleBlockSelected ]\n\t);\n\tconst firstBlockTitle = useBlockDisplayTitle( {\n\t\tclientId: clientIds[ 0 ],\n\t\tmaximumLength: 35,\n\t} );\n\n\tlet blockDescription = isSingleBlockSelected\n\t\t? _x(\n\t\t\t\t'This block is connected.',\n\t\t\t\t'block toolbar button label and description'\n\t\t )\n\t\t: _x(\n\t\t\t\t'These blocks are connected.',\n\t\t\t\t'block toolbar button label and description'\n\t\t );\n\tif ( isConnectedToPatternOverrides && firstBlockName ) {\n\t\tblockDescription = isSingleBlockSelected\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %1s: The block type's name; %2s: The block's user-provided name (the same as the override name). */\n\t\t\t\t\t__( 'This %1$s is editable using the \"%2$s\" override.' ),\n\t\t\t\t\tfirstBlockTitle.toLowerCase(),\n\t\t\t\t\tfirstBlockName\n\t\t\t )\n\t\t\t: __( 'These blocks are editable using overrides.' );\n\t}\n\tconst descriptionId = useId();\n\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarItem>\n\t\t\t\t{ ( toggleProps ) => (\n\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\tclassName=\"block-editor-block-bindings-toolbar-indicator\"\n\t\t\t\t\t\tlabel={ firstBlockTitle }\n\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\tplacement: 'bottom-start',\n\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t'block-editor-block-bindings-toolbar-indicator__popover',\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-bindings-toolbar-indicator-icon\"\n\t\t\t\t\t\t\t\t\tshowColors\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\tdescribedBy: blockDescription,\n\t\t\t\t\t\t\t...toggleProps,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tmenuProps={ {\n\t\t\t\t\t\t\torientation: 'both',\n\t\t\t\t\t\t\t'aria-describedby': descriptionId,\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ () => (\n\t\t\t\t\t\t\t<Text id={ descriptionId }>\n\t\t\t\t\t\t\t\t{ blockDescription }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</DropdownMenu>\n\t\t\t\t) }\n\t\t\t</ToolbarItem>\n\t\t</ToolbarGroup>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAMA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAC,sBAAA,CAAAR,OAAA;AACA,IAAAS,qBAAA,GAAAD,sBAAA,CAAAR,OAAA;AAA0E,IAAAU,WAAA,GAAAV,OAAA;AApB1E;AACA;AACA;;AAaA;AACA;AACA;;AAKe,SAASW,6BAA6BA,CAAE;EAAEC;AAAU,CAAC,EAAG;EACtE,MAAMC,qBAAqB,GAAGD,SAAS,CAACE,MAAM,KAAK,CAAC;EACpD,MAAM;IAAEC,IAAI;IAAEC,cAAc;IAAEC;EAA8B,CAAC,GAAG,IAAAC,eAAS,EACtEC,MAAM,IAAM;IACb,MAAM;MACLC,kBAAkB;MAClBC,uBAAuB;MACvBC;IACD,CAAC,GAAGH,MAAM,CAAEI,YAAiB,CAAC;IAC9B,MAAM;MAAEC,YAAY;MAAEC;IAAwB,CAAC,GAC9CN,MAAM,CAAEO,aAAY,CAAC;IACtB,MAAMC,cAAc,GAAGN,uBAAuB,CAAET,SAAU,CAAC;IAC3D,MAAMgB,mBAAmB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
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.undoIgnoreBlocks = void 0;
|
|
7
|
-
// Keep track of the blocks that should not be pushing an additional
|
|
8
|
-
// undo stack when editing the entity.
|
|
9
|
-
// See the implementation of `syncDerivedUpdates` and `useBlockSync`.
|
|
10
|
-
const undoIgnoreBlocks = exports.undoIgnoreBlocks = new WeakSet();
|
|
11
|
-
//# sourceMappingURL=undo-ignore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["undoIgnoreBlocks","exports","WeakSet"],"sources":["@wordpress/block-editor/src/store/undo-ignore.js"],"sourcesContent":["// Keep track of the blocks that should not be pushing an additional\n// undo stack when editing the entity.\n// See the implementation of `syncDerivedUpdates` and `useBlockSync`.\nexport const undoIgnoreBlocks = new WeakSet();\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACO,MAAMA,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,IAAIE,OAAO,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useId } from '@wordpress/element';
|
|
5
|
-
import { __, sprintf, _x } from '@wordpress/i18n';
|
|
6
|
-
import { DropdownMenu, ToolbarGroup, ToolbarItem, __experimentalText as Text } from '@wordpress/components';
|
|
7
|
-
import { store as blocksStore } from '@wordpress/blocks';
|
|
8
|
-
import { useSelect } from '@wordpress/data';
|
|
9
|
-
import { copy } from '@wordpress/icons';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import { store as blockEditorStore } from '../../store';
|
|
15
|
-
import BlockIcon from '../block-icon';
|
|
16
|
-
import useBlockDisplayTitle from '../block-title/use-block-display-title';
|
|
17
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
19
|
-
export default function BlockBindingsToolbarIndicator({
|
|
20
|
-
clientIds
|
|
21
|
-
}) {
|
|
22
|
-
const isSingleBlockSelected = clientIds.length === 1;
|
|
23
|
-
const {
|
|
24
|
-
icon,
|
|
25
|
-
firstBlockName,
|
|
26
|
-
isConnectedToPatternOverrides
|
|
27
|
-
} = useSelect(select => {
|
|
28
|
-
const {
|
|
29
|
-
getBlockAttributes,
|
|
30
|
-
getBlockNamesByClientId,
|
|
31
|
-
getBlocksByClientId
|
|
32
|
-
} = select(blockEditorStore);
|
|
33
|
-
const {
|
|
34
|
-
getBlockType,
|
|
35
|
-
getActiveBlockVariation
|
|
36
|
-
} = select(blocksStore);
|
|
37
|
-
const blockTypeNames = getBlockNamesByClientId(clientIds);
|
|
38
|
-
const _firstBlockTypeName = blockTypeNames[0];
|
|
39
|
-
const firstBlockType = getBlockType(_firstBlockTypeName);
|
|
40
|
-
let _icon;
|
|
41
|
-
if (isSingleBlockSelected) {
|
|
42
|
-
const match = getActiveBlockVariation(_firstBlockTypeName, getBlockAttributes(clientIds[0]));
|
|
43
|
-
// Take into account active block variations.
|
|
44
|
-
_icon = match?.icon || firstBlockType.icon;
|
|
45
|
-
} else {
|
|
46
|
-
const isSelectionOfSameType = new Set(blockTypeNames).size === 1;
|
|
47
|
-
// When selection consists of blocks of multiple types, display an
|
|
48
|
-
// appropriate icon to communicate the non-uniformity.
|
|
49
|
-
_icon = isSelectionOfSameType ? firstBlockType.icon : copy;
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
icon: _icon,
|
|
53
|
-
firstBlockName: getBlockAttributes(clientIds[0]).metadata.name,
|
|
54
|
-
isConnectedToPatternOverrides: getBlocksByClientId(clientIds).some(block => Object.values(block?.attributes.metadata?.bindings).some(binding => binding.source === 'core/pattern-overrides'))
|
|
55
|
-
};
|
|
56
|
-
}, [clientIds, isSingleBlockSelected]);
|
|
57
|
-
const firstBlockTitle = useBlockDisplayTitle({
|
|
58
|
-
clientId: clientIds[0],
|
|
59
|
-
maximumLength: 35
|
|
60
|
-
});
|
|
61
|
-
let blockDescription = isSingleBlockSelected ? _x('This block is connected.', 'block toolbar button label and description') : _x('These blocks are connected.', 'block toolbar button label and description');
|
|
62
|
-
if (isConnectedToPatternOverrides && firstBlockName) {
|
|
63
|
-
blockDescription = isSingleBlockSelected ? sprintf( /* translators: %1s: The block type's name; %2s: The block's user-provided name (the same as the override name). */
|
|
64
|
-
__('This %1$s is editable using the "%2$s" override.'), firstBlockTitle.toLowerCase(), firstBlockName) : __('These blocks are editable using overrides.');
|
|
65
|
-
}
|
|
66
|
-
const descriptionId = useId();
|
|
67
|
-
return /*#__PURE__*/_jsx(ToolbarGroup, {
|
|
68
|
-
children: /*#__PURE__*/_jsx(ToolbarItem, {
|
|
69
|
-
children: toggleProps => /*#__PURE__*/_jsx(DropdownMenu, {
|
|
70
|
-
className: "block-editor-block-bindings-toolbar-indicator",
|
|
71
|
-
label: firstBlockTitle,
|
|
72
|
-
popoverProps: {
|
|
73
|
-
placement: 'bottom-start',
|
|
74
|
-
className: 'block-editor-block-bindings-toolbar-indicator__popover'
|
|
75
|
-
},
|
|
76
|
-
icon: /*#__PURE__*/_jsx(_Fragment, {
|
|
77
|
-
children: /*#__PURE__*/_jsx(BlockIcon, {
|
|
78
|
-
icon: icon,
|
|
79
|
-
className: "block-editor-block-bindings-toolbar-indicator-icon",
|
|
80
|
-
showColors: true
|
|
81
|
-
})
|
|
82
|
-
}),
|
|
83
|
-
toggleProps: {
|
|
84
|
-
describedBy: blockDescription,
|
|
85
|
-
...toggleProps
|
|
86
|
-
},
|
|
87
|
-
menuProps: {
|
|
88
|
-
orientation: 'both',
|
|
89
|
-
'aria-describedby': descriptionId
|
|
90
|
-
},
|
|
91
|
-
children: () => /*#__PURE__*/_jsx(Text, {
|
|
92
|
-
id: descriptionId,
|
|
93
|
-
children: blockDescription
|
|
94
|
-
})
|
|
95
|
-
})
|
|
96
|
-
})
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useId","__","sprintf","_x","DropdownMenu","ToolbarGroup","ToolbarItem","__experimentalText","Text","store","blocksStore","useSelect","copy","blockEditorStore","BlockIcon","useBlockDisplayTitle","jsx","_jsx","Fragment","_Fragment","BlockBindingsToolbarIndicator","clientIds","isSingleBlockSelected","length","icon","firstBlockName","isConnectedToPatternOverrides","select","getBlockAttributes","getBlockNamesByClientId","getBlocksByClientId","getBlockType","getActiveBlockVariation","blockTypeNames","_firstBlockTypeName","firstBlockType","_icon","match","isSelectionOfSameType","Set","size","metadata","name","some","block","Object","values","attributes","bindings","binding","source","firstBlockTitle","clientId","maximumLength","blockDescription","toLowerCase","descriptionId","children","toggleProps","className","label","popoverProps","placement","showColors","describedBy","menuProps","orientation","id"],"sources":["@wordpress/block-editor/src/components/block-bindings-toolbar-indicator/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useId } from '@wordpress/element';\nimport { __, sprintf, _x } from '@wordpress/i18n';\nimport {\n\tDropdownMenu,\n\tToolbarGroup,\n\tToolbarItem,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { copy } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\n\nexport default function BlockBindingsToolbarIndicator( { clientIds } ) {\n\tconst isSingleBlockSelected = clientIds.length === 1;\n\tconst { icon, firstBlockName, isConnectedToPatternOverrides } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockNamesByClientId,\n\t\t\t\tgetBlocksByClientId,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst blockTypeNames = getBlockNamesByClientId( clientIds );\n\t\t\tconst _firstBlockTypeName = blockTypeNames[ 0 ];\n\t\t\tconst firstBlockType = getBlockType( _firstBlockTypeName );\n\t\t\tlet _icon;\n\t\t\tif ( isSingleBlockSelected ) {\n\t\t\t\tconst match = getActiveBlockVariation(\n\t\t\t\t\t_firstBlockTypeName,\n\t\t\t\t\tgetBlockAttributes( clientIds[ 0 ] )\n\t\t\t\t);\n\t\t\t\t// Take into account active block variations.\n\t\t\t\t_icon = match?.icon || firstBlockType.icon;\n\t\t\t} else {\n\t\t\t\tconst isSelectionOfSameType =\n\t\t\t\t\tnew Set( blockTypeNames ).size === 1;\n\t\t\t\t// When selection consists of blocks of multiple types, display an\n\t\t\t\t// appropriate icon to communicate the non-uniformity.\n\t\t\t\t_icon = isSelectionOfSameType ? firstBlockType.icon : copy;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ticon: _icon,\n\t\t\t\tfirstBlockName: getBlockAttributes( clientIds[ 0 ] ).metadata\n\t\t\t\t\t.name,\n\t\t\t\tisConnectedToPatternOverrides: getBlocksByClientId(\n\t\t\t\t\tclientIds\n\t\t\t\t).some( ( block ) =>\n\t\t\t\t\tObject.values( block?.attributes.metadata?.bindings ).some(\n\t\t\t\t\t\t( binding ) =>\n\t\t\t\t\t\t\tbinding.source === 'core/pattern-overrides'\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientIds, isSingleBlockSelected ]\n\t);\n\tconst firstBlockTitle = useBlockDisplayTitle( {\n\t\tclientId: clientIds[ 0 ],\n\t\tmaximumLength: 35,\n\t} );\n\n\tlet blockDescription = isSingleBlockSelected\n\t\t? _x(\n\t\t\t\t'This block is connected.',\n\t\t\t\t'block toolbar button label and description'\n\t\t )\n\t\t: _x(\n\t\t\t\t'These blocks are connected.',\n\t\t\t\t'block toolbar button label and description'\n\t\t );\n\tif ( isConnectedToPatternOverrides && firstBlockName ) {\n\t\tblockDescription = isSingleBlockSelected\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %1s: The block type's name; %2s: The block's user-provided name (the same as the override name). */\n\t\t\t\t\t__( 'This %1$s is editable using the \"%2$s\" override.' ),\n\t\t\t\t\tfirstBlockTitle.toLowerCase(),\n\t\t\t\t\tfirstBlockName\n\t\t\t )\n\t\t\t: __( 'These blocks are editable using overrides.' );\n\t}\n\tconst descriptionId = useId();\n\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarItem>\n\t\t\t\t{ ( toggleProps ) => (\n\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\tclassName=\"block-editor-block-bindings-toolbar-indicator\"\n\t\t\t\t\t\tlabel={ firstBlockTitle }\n\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\tplacement: 'bottom-start',\n\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t'block-editor-block-bindings-toolbar-indicator__popover',\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-bindings-toolbar-indicator-icon\"\n\t\t\t\t\t\t\t\t\tshowColors\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\tdescribedBy: blockDescription,\n\t\t\t\t\t\t\t...toggleProps,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tmenuProps={ {\n\t\t\t\t\t\t\torientation: 'both',\n\t\t\t\t\t\t\t'aria-describedby': descriptionId,\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ () => (\n\t\t\t\t\t\t\t<Text id={ descriptionId }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EACxDkD,eAAe,CAACI,WAAW,CAAC,CAAC,EAC7B9B,cACA,CAAC,GACDxB,EAAE,CAAE,4CAA6C,CAAC;EACtD;EACA,MAAMuD,aAAa,GAAGxD,KAAK,CAAC,CAAC;EAE7B,oBACCiB,IAAA,CAACZ,YAAY;IAAAoD,QAAA,eACZxC,IAAA,CAACX,WAAW;MAAAmD,QAAA,EACPC,WAAW,iBACdzC,IAAA,CAACb,YAAY;QACZuD,SAAS,EAAC,+CAA+C;QACzDC,KAAK,EAAGT,eAAiB;QACzBU,YAAY,EAAG;UACdC,SAAS,EAAE,cAAc;UACzBH,SAAS,EACR;QACF,CAAG;QACHnC,IAAI,eACHP,IAAA,CAAAE,SAAA;UAAAsC,QAAA,eACCxC,IAAA,CAACH,SAAS;YACTU,IAAI,EAAGA,IAAM;YACbmC,SAAS,EAAC,oDAAoD;YAC9DI,UAAU;UAAA,CACV;QAAC,CACD,CACF;QACDL,WAAW,EAAG;UACbM,WAAW,EAAEV,gBAAgB;UAC7B,GAAGI;QACJ,CAAG;QACHO,SAAS,EAAG;UACXC,WAAW,EAAE,MAAM;UACnB,kBAAkB,EAAEV;QACrB,CAAG;QAAAC,QAAA,EAEDA,CAAA,kBACDxC,IAAA,CAACT,IAAI;UAAC2D,EAAE,EAAGX,aAAe;UAAAC,QAAA,EACvBH;QAAgB,CACb;MACN,CACY;IACd,CACW;EAAC,CACD,CAAC;AAEjB","ignoreList":[]}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// Keep track of the blocks that should not be pushing an additional
|
|
2
|
-
// undo stack when editing the entity.
|
|
3
|
-
// See the implementation of `syncDerivedUpdates` and `useBlockSync`.
|
|
4
|
-
export const undoIgnoreBlocks = new WeakSet();
|
|
5
|
-
//# sourceMappingURL=undo-ignore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["undoIgnoreBlocks","WeakSet"],"sources":["@wordpress/block-editor/src/store/undo-ignore.js"],"sourcesContent":["// Keep track of the blocks that should not be pushing an additional\n// undo stack when editing the entity.\n// See the implementation of `syncDerivedUpdates` and `useBlockSync`.\nexport const undoIgnoreBlocks = new WeakSet();\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,MAAMA,gBAAgB,GAAG,IAAIC,OAAO,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useId } from '@wordpress/element';
|
|
5
|
-
import { __, sprintf, _x } from '@wordpress/i18n';
|
|
6
|
-
import {
|
|
7
|
-
DropdownMenu,
|
|
8
|
-
ToolbarGroup,
|
|
9
|
-
ToolbarItem,
|
|
10
|
-
__experimentalText as Text,
|
|
11
|
-
} from '@wordpress/components';
|
|
12
|
-
import { store as blocksStore } from '@wordpress/blocks';
|
|
13
|
-
import { useSelect } from '@wordpress/data';
|
|
14
|
-
import { copy } from '@wordpress/icons';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Internal dependencies
|
|
18
|
-
*/
|
|
19
|
-
import { store as blockEditorStore } from '../../store';
|
|
20
|
-
import BlockIcon from '../block-icon';
|
|
21
|
-
import useBlockDisplayTitle from '../block-title/use-block-display-title';
|
|
22
|
-
|
|
23
|
-
export default function BlockBindingsToolbarIndicator( { clientIds } ) {
|
|
24
|
-
const isSingleBlockSelected = clientIds.length === 1;
|
|
25
|
-
const { icon, firstBlockName, isConnectedToPatternOverrides } = useSelect(
|
|
26
|
-
( select ) => {
|
|
27
|
-
const {
|
|
28
|
-
getBlockAttributes,
|
|
29
|
-
getBlockNamesByClientId,
|
|
30
|
-
getBlocksByClientId,
|
|
31
|
-
} = select( blockEditorStore );
|
|
32
|
-
const { getBlockType, getActiveBlockVariation } =
|
|
33
|
-
select( blocksStore );
|
|
34
|
-
const blockTypeNames = getBlockNamesByClientId( clientIds );
|
|
35
|
-
const _firstBlockTypeName = blockTypeNames[ 0 ];
|
|
36
|
-
const firstBlockType = getBlockType( _firstBlockTypeName );
|
|
37
|
-
let _icon;
|
|
38
|
-
if ( isSingleBlockSelected ) {
|
|
39
|
-
const match = getActiveBlockVariation(
|
|
40
|
-
_firstBlockTypeName,
|
|
41
|
-
getBlockAttributes( clientIds[ 0 ] )
|
|
42
|
-
);
|
|
43
|
-
// Take into account active block variations.
|
|
44
|
-
_icon = match?.icon || firstBlockType.icon;
|
|
45
|
-
} else {
|
|
46
|
-
const isSelectionOfSameType =
|
|
47
|
-
new Set( blockTypeNames ).size === 1;
|
|
48
|
-
// When selection consists of blocks of multiple types, display an
|
|
49
|
-
// appropriate icon to communicate the non-uniformity.
|
|
50
|
-
_icon = isSelectionOfSameType ? firstBlockType.icon : copy;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
icon: _icon,
|
|
55
|
-
firstBlockName: getBlockAttributes( clientIds[ 0 ] ).metadata
|
|
56
|
-
.name,
|
|
57
|
-
isConnectedToPatternOverrides: getBlocksByClientId(
|
|
58
|
-
clientIds
|
|
59
|
-
).some( ( block ) =>
|
|
60
|
-
Object.values( block?.attributes.metadata?.bindings ).some(
|
|
61
|
-
( binding ) =>
|
|
62
|
-
binding.source === 'core/pattern-overrides'
|
|
63
|
-
)
|
|
64
|
-
),
|
|
65
|
-
};
|
|
66
|
-
},
|
|
67
|
-
[ clientIds, isSingleBlockSelected ]
|
|
68
|
-
);
|
|
69
|
-
const firstBlockTitle = useBlockDisplayTitle( {
|
|
70
|
-
clientId: clientIds[ 0 ],
|
|
71
|
-
maximumLength: 35,
|
|
72
|
-
} );
|
|
73
|
-
|
|
74
|
-
let blockDescription = isSingleBlockSelected
|
|
75
|
-
? _x(
|
|
76
|
-
'This block is connected.',
|
|
77
|
-
'block toolbar button label and description'
|
|
78
|
-
)
|
|
79
|
-
: _x(
|
|
80
|
-
'These blocks are connected.',
|
|
81
|
-
'block toolbar button label and description'
|
|
82
|
-
);
|
|
83
|
-
if ( isConnectedToPatternOverrides && firstBlockName ) {
|
|
84
|
-
blockDescription = isSingleBlockSelected
|
|
85
|
-
? sprintf(
|
|
86
|
-
/* translators: %1s: The block type's name; %2s: The block's user-provided name (the same as the override name). */
|
|
87
|
-
__( 'This %1$s is editable using the "%2$s" override.' ),
|
|
88
|
-
firstBlockTitle.toLowerCase(),
|
|
89
|
-
firstBlockName
|
|
90
|
-
)
|
|
91
|
-
: __( 'These blocks are editable using overrides.' );
|
|
92
|
-
}
|
|
93
|
-
const descriptionId = useId();
|
|
94
|
-
|
|
95
|
-
return (
|
|
96
|
-
<ToolbarGroup>
|
|
97
|
-
<ToolbarItem>
|
|
98
|
-
{ ( toggleProps ) => (
|
|
99
|
-
<DropdownMenu
|
|
100
|
-
className="block-editor-block-bindings-toolbar-indicator"
|
|
101
|
-
label={ firstBlockTitle }
|
|
102
|
-
popoverProps={ {
|
|
103
|
-
placement: 'bottom-start',
|
|
104
|
-
className:
|
|
105
|
-
'block-editor-block-bindings-toolbar-indicator__popover',
|
|
106
|
-
} }
|
|
107
|
-
icon={
|
|
108
|
-
<>
|
|
109
|
-
<BlockIcon
|
|
110
|
-
icon={ icon }
|
|
111
|
-
className="block-editor-block-bindings-toolbar-indicator-icon"
|
|
112
|
-
showColors
|
|
113
|
-
/>
|
|
114
|
-
</>
|
|
115
|
-
}
|
|
116
|
-
toggleProps={ {
|
|
117
|
-
describedBy: blockDescription,
|
|
118
|
-
...toggleProps,
|
|
119
|
-
} }
|
|
120
|
-
menuProps={ {
|
|
121
|
-
orientation: 'both',
|
|
122
|
-
'aria-describedby': descriptionId,
|
|
123
|
-
} }
|
|
124
|
-
>
|
|
125
|
-
{ () => (
|
|
126
|
-
<Text id={ descriptionId }>
|
|
127
|
-
{ blockDescription }
|
|
128
|
-
</Text>
|
|
129
|
-
) }
|
|
130
|
-
</DropdownMenu>
|
|
131
|
-
) }
|
|
132
|
-
</ToolbarItem>
|
|
133
|
-
</ToolbarGroup>
|
|
134
|
-
);
|
|
135
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
.block-editor-block-bindings-toolbar-indicator__popover .components-popover__content {
|
|
2
|
-
min-width: 260px;
|
|
3
|
-
padding: $grid-unit-20;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.block-editor-block-bindings-toolbar-indicator .block-editor-block-bindings-toolbar-indicator-icon.has-colors svg {
|
|
7
|
-
fill: var(--wp-block-synced-color);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.editor-collapsible-block-toolbar .block-editor-block-bindings-toolbar-indicator {
|
|
11
|
-
height: 32px;
|
|
12
|
-
}
|