@wordpress/block-editor 11.3.5 → 11.3.7
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 +11 -1
- package/build/components/block-inspector/index.js +11 -10
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-inspector/useBlockInspectorAnimationSettings.js +46 -0
- package/build/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/inserter/index.js +29 -17
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +10 -11
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/media-tab/media-list.js +5 -108
- package/build/components/inserter/media-tab/media-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +242 -0
- package/build/components/inserter/media-tab/media-preview.js.map +1 -0
- package/build/components/inserter/menu.js +4 -7
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +4 -2
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +10 -3
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/link-control/index.js +17 -44
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +28 -3
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +1 -1
- package/build/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +5 -3
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +4 -1
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/private-apis.js +4 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +28 -14
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +28 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/selectors.js +1 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-inspector/index.js +9 -9
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js +37 -0
- package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/inserter/index.js +28 -16
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +10 -11
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-list.js +6 -105
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +222 -0
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -0
- package/build-module/components/inserter/menu.js +4 -7
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +4 -2
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +10 -3
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/link-control/index.js +16 -44
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +28 -4
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +5 -3
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +4 -1
- package/build-module/components/off-canvas-editor/index.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 +28 -14
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +28 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/selectors.js +1 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +46 -8
- package/build-style/style.css +46 -8
- package/package.json +4 -4
- package/src/components/block-inspector/index.js +11 -14
- package/src/components/block-inspector/useBlockInspectorAnimationSettings.js +53 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/src/components/inserter/index.js +30 -11
- package/src/components/inserter/media-tab/hooks.js +9 -8
- package/src/components/inserter/media-tab/media-list.js +3 -122
- package/src/components/inserter/media-tab/media-preview.js +268 -0
- package/src/components/inserter/menu.js +14 -20
- package/src/components/inserter/quick-inserter.js +2 -0
- package/src/components/inserter/search-results.js +7 -1
- package/src/components/inserter/style.scss +25 -0
- package/src/components/link-control/index.js +23 -58
- package/src/components/link-control/style.scss +23 -7
- package/src/components/link-control/test/index.js +5 -134
- package/src/components/media-replace-flow/test/index.js +1 -1
- package/src/components/off-canvas-editor/appender.js +30 -4
- package/src/components/off-canvas-editor/block-contents.js +1 -1
- package/src/components/off-canvas-editor/branch.js +3 -1
- package/src/components/off-canvas-editor/index.js +3 -0
- package/src/components/spacing-sizes-control/style.scss +1 -1
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +16 -6
- package/src/store/defaults.js +14 -1
- package/src/store/selectors.js +4 -1
- package/src/store/test/actions.js +4 -2
|
@@ -537,7 +537,7 @@ describe( 'Manual link entry', () => {
|
|
|
537
537
|
} );
|
|
538
538
|
|
|
539
539
|
let submitButton = screen.getByRole( 'button', {
|
|
540
|
-
name: '
|
|
540
|
+
name: 'Submit',
|
|
541
541
|
} );
|
|
542
542
|
|
|
543
543
|
expect( submitButton ).toBeDisabled();
|
|
@@ -555,7 +555,7 @@ describe( 'Manual link entry', () => {
|
|
|
555
555
|
await user.keyboard( '[Enter]' );
|
|
556
556
|
|
|
557
557
|
submitButton = screen.getByRole( 'button', {
|
|
558
|
-
name: '
|
|
558
|
+
name: 'Submit',
|
|
559
559
|
} );
|
|
560
560
|
|
|
561
561
|
// Verify the UI hasn't allowed submission.
|
|
@@ -578,7 +578,7 @@ describe( 'Manual link entry', () => {
|
|
|
578
578
|
} );
|
|
579
579
|
|
|
580
580
|
let submitButton = screen.queryByRole( 'button', {
|
|
581
|
-
name: '
|
|
581
|
+
name: 'Submit',
|
|
582
582
|
} );
|
|
583
583
|
|
|
584
584
|
expect( submitButton ).toBeDisabled();
|
|
@@ -597,7 +597,7 @@ describe( 'Manual link entry', () => {
|
|
|
597
597
|
await user.click( submitButton );
|
|
598
598
|
|
|
599
599
|
submitButton = screen.queryByRole( 'button', {
|
|
600
|
-
name: '
|
|
600
|
+
name: 'Submit',
|
|
601
601
|
} );
|
|
602
602
|
|
|
603
603
|
// Verify the UI hasn't allowed submission.
|
|
@@ -608,135 +608,6 @@ describe( 'Manual link entry', () => {
|
|
|
608
608
|
);
|
|
609
609
|
} );
|
|
610
610
|
|
|
611
|
-
describe( 'Handling cancellation', () => {
|
|
612
|
-
it( 'should allow cancellation of the link creation process and reset any entered values', async () => {
|
|
613
|
-
const user = userEvent.setup();
|
|
614
|
-
const mockOnRemove = jest.fn();
|
|
615
|
-
const mockOnCancel = jest.fn();
|
|
616
|
-
|
|
617
|
-
render( <LinkControl onRemove={ mockOnRemove } /> );
|
|
618
|
-
|
|
619
|
-
// Search Input UI.
|
|
620
|
-
const searchInput = screen.getByRole( 'combobox', {
|
|
621
|
-
name: 'URL',
|
|
622
|
-
} );
|
|
623
|
-
|
|
624
|
-
const cancelButton = screen.queryByRole( 'button', {
|
|
625
|
-
name: 'Cancel',
|
|
626
|
-
} );
|
|
627
|
-
|
|
628
|
-
expect( cancelButton ).toBeEnabled();
|
|
629
|
-
expect( cancelButton ).toBeVisible();
|
|
630
|
-
|
|
631
|
-
// Simulate adding a link for a term.
|
|
632
|
-
await user.type( searchInput, 'https://www.wordpress.org' );
|
|
633
|
-
|
|
634
|
-
// Attempt to submit the empty search value in the input.
|
|
635
|
-
await user.click( cancelButton );
|
|
636
|
-
|
|
637
|
-
// Verify the consumer can handle the cancellation.
|
|
638
|
-
expect( mockOnRemove ).toHaveBeenCalled();
|
|
639
|
-
|
|
640
|
-
// Ensure optional callback is not called.
|
|
641
|
-
expect( mockOnCancel ).not.toHaveBeenCalled();
|
|
642
|
-
|
|
643
|
-
expect( searchInput ).toHaveValue( '' );
|
|
644
|
-
} );
|
|
645
|
-
|
|
646
|
-
it( 'should allow cancellation of the link editing process and reset any entered values', async () => {
|
|
647
|
-
const user = userEvent.setup();
|
|
648
|
-
const initialLink = fauxEntitySuggestions[ 0 ];
|
|
649
|
-
|
|
650
|
-
const LinkControlConsumer = () => {
|
|
651
|
-
const [ link, setLink ] = useState( initialLink );
|
|
652
|
-
|
|
653
|
-
return (
|
|
654
|
-
<LinkControl
|
|
655
|
-
value={ link }
|
|
656
|
-
onChange={ ( suggestion ) => {
|
|
657
|
-
setLink( suggestion );
|
|
658
|
-
} }
|
|
659
|
-
hasTextControl
|
|
660
|
-
/>
|
|
661
|
-
);
|
|
662
|
-
};
|
|
663
|
-
|
|
664
|
-
render( <LinkControlConsumer /> );
|
|
665
|
-
|
|
666
|
-
let linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
667
|
-
|
|
668
|
-
expect( linkPreview ).toBeInTheDocument();
|
|
669
|
-
|
|
670
|
-
// Click the "Edit" button to trigger into the editing mode.
|
|
671
|
-
let editButton = screen.queryByRole( 'button', {
|
|
672
|
-
name: 'Edit',
|
|
673
|
-
} );
|
|
674
|
-
|
|
675
|
-
await user.click( editButton );
|
|
676
|
-
|
|
677
|
-
let searchInput = screen.getByRole( 'combobox', {
|
|
678
|
-
name: 'URL',
|
|
679
|
-
} );
|
|
680
|
-
|
|
681
|
-
let textInput = screen.getByRole( 'textbox', {
|
|
682
|
-
name: 'Text',
|
|
683
|
-
} );
|
|
684
|
-
|
|
685
|
-
// Make a change to the search input.
|
|
686
|
-
await user.type( searchInput, 'This URL value was changed!' );
|
|
687
|
-
|
|
688
|
-
// Make a change to the text input.
|
|
689
|
-
await user.type( textInput, 'This text value was changed!' );
|
|
690
|
-
|
|
691
|
-
const cancelButton = screen.queryByRole( 'button', {
|
|
692
|
-
name: 'Cancel',
|
|
693
|
-
} );
|
|
694
|
-
|
|
695
|
-
// Cancel the editing process.
|
|
696
|
-
await user.click( cancelButton );
|
|
697
|
-
|
|
698
|
-
linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
699
|
-
|
|
700
|
-
expect( linkPreview ).toBeInTheDocument();
|
|
701
|
-
|
|
702
|
-
// Re-query the edit button as it's been replaced.
|
|
703
|
-
editButton = screen.queryByRole( 'button', {
|
|
704
|
-
name: 'Edit',
|
|
705
|
-
} );
|
|
706
|
-
|
|
707
|
-
await user.click( editButton );
|
|
708
|
-
|
|
709
|
-
// Re-query the inputs as they have been replaced.
|
|
710
|
-
searchInput = screen.getByRole( 'combobox', {
|
|
711
|
-
name: 'URL',
|
|
712
|
-
} );
|
|
713
|
-
|
|
714
|
-
textInput = screen.getByRole( 'textbox', {
|
|
715
|
-
name: 'Text',
|
|
716
|
-
} );
|
|
717
|
-
|
|
718
|
-
// Expect to see the original link values and **not** the changed values.
|
|
719
|
-
expect( searchInput ).toHaveValue( initialLink.url );
|
|
720
|
-
expect( textInput ).toHaveValue( initialLink.text );
|
|
721
|
-
} );
|
|
722
|
-
|
|
723
|
-
it( 'should call onCancel callback when cancelling if provided', async () => {
|
|
724
|
-
const user = userEvent.setup();
|
|
725
|
-
const mockOnCancel = jest.fn();
|
|
726
|
-
|
|
727
|
-
render( <LinkControl onCancel={ mockOnCancel } /> );
|
|
728
|
-
|
|
729
|
-
const cancelButton = screen.queryByRole( 'button', {
|
|
730
|
-
name: 'Cancel',
|
|
731
|
-
} );
|
|
732
|
-
|
|
733
|
-
await user.click( cancelButton );
|
|
734
|
-
|
|
735
|
-
// Verify the consumer can handle the cancellation.
|
|
736
|
-
expect( mockOnCancel ).toHaveBeenCalled();
|
|
737
|
-
} );
|
|
738
|
-
} );
|
|
739
|
-
|
|
740
611
|
describe( 'Alternative link protocols and formats', () => {
|
|
741
612
|
it.each( [
|
|
742
613
|
[ 'mailto:example123456@wordpress.org', 'mailto' ],
|
|
@@ -1988,7 +1859,7 @@ describe( 'Controlling link title text', () => {
|
|
|
1988
1859
|
expect( textInput ).toHaveValue( textValue );
|
|
1989
1860
|
|
|
1990
1861
|
const submitButton = screen.queryByRole( 'button', {
|
|
1991
|
-
name: '
|
|
1862
|
+
name: 'Submit',
|
|
1992
1863
|
} );
|
|
1993
1864
|
|
|
1994
1865
|
await user.click( submitButton );
|
|
@@ -4,7 +4,12 @@
|
|
|
4
4
|
import { useInstanceId } from '@wordpress/compose';
|
|
5
5
|
import { speak } from '@wordpress/a11y';
|
|
6
6
|
import { useSelect } from '@wordpress/data';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
forwardRef,
|
|
9
|
+
useState,
|
|
10
|
+
useEffect,
|
|
11
|
+
useCallback,
|
|
12
|
+
} from '@wordpress/element';
|
|
8
13
|
import { __, sprintf } from '@wordpress/i18n';
|
|
9
14
|
|
|
10
15
|
/**
|
|
@@ -12,7 +17,14 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
12
17
|
*/
|
|
13
18
|
import { store as blockEditorStore } from '../../store';
|
|
14
19
|
import useBlockDisplayTitle from '../block-title/use-block-display-title';
|
|
15
|
-
|
|
20
|
+
|
|
21
|
+
import { unlock } from '../../lock-unlock';
|
|
22
|
+
import { privateApis as blockEditorPrivateApis } from '../../private-apis';
|
|
23
|
+
|
|
24
|
+
const prioritizedInserterBlocks = [
|
|
25
|
+
'core/navigation-link/page',
|
|
26
|
+
'core/navigation-link',
|
|
27
|
+
];
|
|
16
28
|
|
|
17
29
|
export const Appender = forwardRef(
|
|
18
30
|
( { nestingLevel, blockCount, ...props }, ref ) => {
|
|
@@ -61,10 +73,23 @@ export const Appender = forwardRef(
|
|
|
61
73
|
);
|
|
62
74
|
}, [ insertedBlockTitle ] );
|
|
63
75
|
|
|
76
|
+
const orderInitialBlockItems = useCallback( ( items ) => {
|
|
77
|
+
items.sort( ( { id: aName }, { id: bName } ) => {
|
|
78
|
+
// Sort block items according to `prioritizedInserterBlocks`.
|
|
79
|
+
let aIndex = prioritizedInserterBlocks.indexOf( aName );
|
|
80
|
+
let bIndex = prioritizedInserterBlocks.indexOf( bName );
|
|
81
|
+
// All other block items should come after that.
|
|
82
|
+
if ( aIndex < 0 ) aIndex = prioritizedInserterBlocks.length;
|
|
83
|
+
if ( bIndex < 0 ) bIndex = prioritizedInserterBlocks.length;
|
|
84
|
+
return aIndex - bIndex;
|
|
85
|
+
} );
|
|
86
|
+
return items;
|
|
87
|
+
}, [] );
|
|
88
|
+
|
|
64
89
|
if ( hideInserter ) {
|
|
65
90
|
return null;
|
|
66
91
|
}
|
|
67
|
-
|
|
92
|
+
const { PrivateInserter } = unlock( blockEditorPrivateApis );
|
|
68
93
|
const descriptionId = `off-canvas-editor-appender__${ instanceId }`;
|
|
69
94
|
const description = sprintf(
|
|
70
95
|
/* translators: 1: The name of the block. 2: The numerical position of the block. 3: The level of nesting for the block. */
|
|
@@ -76,7 +101,7 @@ export const Appender = forwardRef(
|
|
|
76
101
|
|
|
77
102
|
return (
|
|
78
103
|
<div className="offcanvas-editor-appender">
|
|
79
|
-
<
|
|
104
|
+
<PrivateInserter
|
|
80
105
|
ref={ ref }
|
|
81
106
|
rootClientId={ clientId }
|
|
82
107
|
position="bottom right"
|
|
@@ -91,6 +116,7 @@ export const Appender = forwardRef(
|
|
|
91
116
|
setInsertedBlock( maybeInsertedBlock );
|
|
92
117
|
}
|
|
93
118
|
} }
|
|
119
|
+
orderInitialBlockItems={ orderInitialBlockItems }
|
|
94
120
|
/>
|
|
95
121
|
<div
|
|
96
122
|
className="offcanvas-editor-appender__description"
|
|
@@ -73,7 +73,7 @@ const ListViewBlockContents = forwardRef(
|
|
|
73
73
|
setInsertedBlockAttributes,
|
|
74
74
|
} = useInsertedBlock( lastInsertedBlockClientId );
|
|
75
75
|
|
|
76
|
-
const hasExistingLinkValue = insertedBlockAttributes?.
|
|
76
|
+
const hasExistingLinkValue = insertedBlockAttributes?.url;
|
|
77
77
|
|
|
78
78
|
useEffect( () => {
|
|
79
79
|
if (
|
|
@@ -97,6 +97,7 @@ function ListViewBranch( props ) {
|
|
|
97
97
|
isExpanded,
|
|
98
98
|
parentId,
|
|
99
99
|
shouldShowInnerBlocks = true,
|
|
100
|
+
showAppender: showAppenderProp = true,
|
|
100
101
|
} = props;
|
|
101
102
|
|
|
102
103
|
const isContentLocked = useSelect(
|
|
@@ -117,7 +118,7 @@ function ListViewBranch( props ) {
|
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
// Only show the appender at the first level.
|
|
120
|
-
const showAppender = level === 1;
|
|
121
|
+
const showAppender = showAppenderProp && level === 1;
|
|
121
122
|
|
|
122
123
|
const filteredBlocks = blocks.filter( Boolean );
|
|
123
124
|
const blockCount = filteredBlocks.length;
|
|
@@ -205,6 +206,7 @@ function ListViewBranch( props ) {
|
|
|
205
206
|
isBranchSelected={ isSelectedBranch }
|
|
206
207
|
selectedClientIds={ selectedClientIds }
|
|
207
208
|
isExpanded={ isExpanded }
|
|
209
|
+
showAppender={ showAppenderProp }
|
|
208
210
|
/>
|
|
209
211
|
) }
|
|
210
212
|
</AsyncModeProvider>
|
|
@@ -62,6 +62,7 @@ export const BLOCK_LIST_ITEM_HEIGHT = 36;
|
|
|
62
62
|
* @param {Object} props.LeafMoreMenu Optional more menu substitution.
|
|
63
63
|
* @param {string} props.description Optional accessible description for the tree grid component.
|
|
64
64
|
* @param {string} props.onSelect Optional callback to be invoked when a block is selected.
|
|
65
|
+
* @param {string} props.showAppender Flag to show or hide the block appender.
|
|
65
66
|
* @param {Object} ref Forwarded ref
|
|
66
67
|
*/
|
|
67
68
|
function OffCanvasEditor(
|
|
@@ -70,6 +71,7 @@ function OffCanvasEditor(
|
|
|
70
71
|
blocks,
|
|
71
72
|
showBlockMovers = false,
|
|
72
73
|
isExpanded = false,
|
|
74
|
+
showAppender = true,
|
|
73
75
|
LeafMoreMenu,
|
|
74
76
|
description = __( 'Block navigation structure' ),
|
|
75
77
|
onSelect,
|
|
@@ -234,6 +236,7 @@ function OffCanvasEditor(
|
|
|
234
236
|
selectedClientIds={ selectedClientIds }
|
|
235
237
|
isExpanded={ isExpanded }
|
|
236
238
|
shouldShowInnerBlocks={ shouldShowInnerBlocks }
|
|
239
|
+
showAppender={ showAppender }
|
|
237
240
|
/>
|
|
238
241
|
<TreeGridRow
|
|
239
242
|
level={ 1 }
|
package/src/private-apis.js
CHANGED
|
@@ -6,6 +6,7 @@ import { ExperimentalBlockEditorProvider } from './components/provider';
|
|
|
6
6
|
import { lock } from './lock-unlock';
|
|
7
7
|
import OffCanvasEditor from './components/off-canvas-editor';
|
|
8
8
|
import LeafMoreMenu from './components/off-canvas-editor/leaf-more-menu';
|
|
9
|
+
import { ComposedPrivateInserter as PrivateInserter } from './components/inserter';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Private @wordpress/block-editor APIs.
|
|
@@ -16,4 +17,5 @@ lock( privateApis, {
|
|
|
16
17
|
ExperimentalBlockEditorProvider,
|
|
17
18
|
LeafMoreMenu,
|
|
18
19
|
OffCanvasEditor,
|
|
20
|
+
PrivateInserter,
|
|
19
21
|
} );
|
package/src/store/actions.js
CHANGED
|
@@ -232,17 +232,24 @@ export function selectBlock( clientId, initialPosition = 0 ) {
|
|
|
232
232
|
|
|
233
233
|
/**
|
|
234
234
|
* Yields action objects used in signalling that the block preceding the given
|
|
235
|
-
* clientId
|
|
235
|
+
* clientId (or optionally, its first parent from bottom to top)
|
|
236
|
+
* should be selected.
|
|
236
237
|
*
|
|
237
|
-
* @param {string}
|
|
238
|
+
* @param {string} clientId Block client ID.
|
|
239
|
+
* @param {boolean} fallbackToParent If true, select the first parent if there is no previous block.
|
|
238
240
|
*/
|
|
239
241
|
export const selectPreviousBlock =
|
|
240
|
-
( clientId ) =>
|
|
242
|
+
( clientId, fallbackToParent = false ) =>
|
|
241
243
|
( { select, dispatch } ) => {
|
|
242
244
|
const previousBlockClientId =
|
|
243
245
|
select.getPreviousBlockClientId( clientId );
|
|
244
246
|
if ( previousBlockClientId ) {
|
|
245
247
|
dispatch.selectBlock( previousBlockClientId, -1 );
|
|
248
|
+
} else if ( fallbackToParent ) {
|
|
249
|
+
const firstParentClientId = select.getBlockRootClientId( clientId );
|
|
250
|
+
if ( firstParentClientId ) {
|
|
251
|
+
dispatch.selectBlock( firstParentClientId, -1 );
|
|
252
|
+
}
|
|
246
253
|
}
|
|
247
254
|
};
|
|
248
255
|
|
|
@@ -1175,8 +1182,11 @@ export const mergeBlocks =
|
|
|
1175
1182
|
* the set of specified client IDs are to be removed.
|
|
1176
1183
|
*
|
|
1177
1184
|
* @param {string|string[]} clientIds Client IDs of blocks to remove.
|
|
1178
|
-
* @param {boolean} selectPrevious True if the previous block
|
|
1179
|
-
*
|
|
1185
|
+
* @param {boolean} selectPrevious True if the previous block
|
|
1186
|
+
* or the immediate parent
|
|
1187
|
+
* (if no previous block exists)
|
|
1188
|
+
* should be selected
|
|
1189
|
+
* when a block is removed.
|
|
1180
1190
|
*/
|
|
1181
1191
|
export const removeBlocks =
|
|
1182
1192
|
( clientIds, selectPrevious = true ) =>
|
|
@@ -1197,7 +1207,7 @@ export const removeBlocks =
|
|
|
1197
1207
|
}
|
|
1198
1208
|
|
|
1199
1209
|
if ( selectPrevious ) {
|
|
1200
|
-
dispatch.selectPreviousBlock( clientIds[ 0 ] );
|
|
1210
|
+
dispatch.selectPreviousBlock( clientIds[ 0 ], selectPrevious );
|
|
1201
1211
|
}
|
|
1202
1212
|
|
|
1203
1213
|
dispatch( { type: 'REMOVE_BLOCKS', clientIds } );
|
package/src/store/defaults.js
CHANGED
|
@@ -170,11 +170,24 @@ export const SETTINGS_DEFAULTS = {
|
|
|
170
170
|
__unstableGalleryWithImageBlocks: false,
|
|
171
171
|
__unstableIsPreviewMode: false,
|
|
172
172
|
|
|
173
|
-
//
|
|
173
|
+
// These settings will be completely revamped in the future.
|
|
174
|
+
// The goal is to evolve this into an API which will instruct
|
|
175
|
+
// the block inspector to animate transitions between what it
|
|
176
|
+
// displays based on the relationship between the selected block
|
|
177
|
+
// and its parent, and only enable it if the parent is controlling
|
|
178
|
+
// its children blocks.
|
|
174
179
|
blockInspectorAnimation: {
|
|
180
|
+
animationParent: 'core/navigation',
|
|
175
181
|
'core/navigation': { enterDirection: 'leftToRight' },
|
|
176
182
|
'core/navigation-submenu': { enterDirection: 'rightToLeft' },
|
|
177
183
|
'core/navigation-link': { enterDirection: 'rightToLeft' },
|
|
184
|
+
'core/search': { enterDirection: 'rightToLeft' },
|
|
185
|
+
'core/social-links': { enterDirection: 'rightToLeft' },
|
|
186
|
+
'core/page-list': { enterDirection: 'rightToLeft' },
|
|
187
|
+
'core/spacer': { enterDirection: 'rightToLeft' },
|
|
188
|
+
'core/home-link': { enterDirection: 'rightToLeft' },
|
|
189
|
+
'core/site-title': { enterDirection: 'rightToLeft' },
|
|
190
|
+
'core/site-logo': { enterDirection: 'rightToLeft' },
|
|
178
191
|
},
|
|
179
192
|
|
|
180
193
|
generateAnchors: false,
|
package/src/store/selectors.js
CHANGED
|
@@ -2742,7 +2742,10 @@ export const __unstableGetContentLockingParent = createSelector(
|
|
|
2742
2742
|
let result;
|
|
2743
2743
|
while ( state.blocks.parents.has( current ) ) {
|
|
2744
2744
|
current = state.blocks.parents.get( current );
|
|
2745
|
-
if (
|
|
2745
|
+
if (
|
|
2746
|
+
current &&
|
|
2747
|
+
getTemplateLock( state, current ) === 'contentOnly'
|
|
2748
|
+
) {
|
|
2746
2749
|
result = current;
|
|
2747
2750
|
}
|
|
2748
2751
|
}
|
|
@@ -625,7 +625,8 @@ describe( 'actions', () => {
|
|
|
625
625
|
removeBlocks( clientIds )( { select, dispatch } );
|
|
626
626
|
|
|
627
627
|
expect( dispatch.selectPreviousBlock ).toHaveBeenCalledWith(
|
|
628
|
-
clientId
|
|
628
|
+
clientId,
|
|
629
|
+
true
|
|
629
630
|
);
|
|
630
631
|
|
|
631
632
|
expect( dispatch ).toHaveBeenCalledWith( {
|
|
@@ -734,7 +735,8 @@ describe( 'actions', () => {
|
|
|
734
735
|
removeBlock( clientId )( { select, dispatch } );
|
|
735
736
|
|
|
736
737
|
expect( dispatch.selectPreviousBlock ).toHaveBeenCalledWith(
|
|
737
|
-
clientId
|
|
738
|
+
clientId,
|
|
739
|
+
true
|
|
738
740
|
);
|
|
739
741
|
|
|
740
742
|
expect( dispatch ).toHaveBeenCalledWith( {
|