@wordpress/block-editor 15.11.1-next.v.0 → 15.12.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-breadcrumb/index.cjs +10 -2
- package/build/components/block-breadcrumb/index.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +2 -2
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-list/block.cjs +6 -3
- package/build/components/block-list/block.cjs.map +3 -3
- package/build/components/block-list/index.cjs +26 -18
- package/build/components/block-list/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs +2 -6
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs.map +2 -2
- package/build/components/block-list/use-in-between-inserter.cjs +4 -4
- package/build/components/block-list/use-in-between-inserter.cjs.map +2 -2
- package/build/components/block-settings-menu/block-settings-dropdown.cjs +10 -7
- package/build/components/block-settings-menu/block-settings-dropdown.cjs.map +2 -2
- package/build/components/block-settings-menu-controls/edit-section-menu-item.cjs +1 -1
- package/build/components/block-settings-menu-controls/edit-section-menu-item.cjs.map +2 -2
- package/build/components/block-settings-menu-controls/index.cjs +10 -15
- package/build/components/block-settings-menu-controls/index.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +6 -4
- package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
- package/build/components/block-toolbar/index.cjs +1 -1
- package/build/components/block-toolbar/index.cjs.map +2 -2
- package/build/components/block-variation-transforms/index.cjs +1 -2
- package/build/components/block-variation-transforms/index.cjs.map +2 -2
- package/build/components/block-visibility/modal.cjs +5 -92
- package/build/components/block-visibility/modal.cjs.map +2 -2
- package/build/components/inserter/index.cjs +1 -0
- package/build/components/inserter/index.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/index.cjs +2 -2
- package/build/components/inspector-controls-tabs/index.cjs.map +3 -3
- package/build/components/inspector-controls-tabs/styles-tab.cjs +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/media-replace-flow/index.cjs +2 -2
- package/build/components/media-replace-flow/index.cjs.map +2 -2
- package/build/components/rich-text/index.cjs +1 -1
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/use-block-display-information/index.cjs +1 -1
- package/build/components/use-block-display-information/index.cjs.map +2 -2
- package/build/components/writing-flow/index.cjs +2 -0
- package/build/components/writing-flow/index.cjs.map +2 -2
- package/build/components/writing-flow/use-arrow-nav.cjs +3 -0
- package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
- package/build/components/writing-flow/use-drag-selection.cjs +2 -1
- package/build/components/writing-flow/use-drag-selection.cjs.map +2 -2
- package/build/components/writing-flow/use-preview-mode-nav.cjs +92 -0
- package/build/components/writing-flow/use-preview-mode-nav.cjs.map +7 -0
- package/build/hooks/block-renaming.cjs +1 -1
- package/build/hooks/block-renaming.cjs.map +2 -2
- package/build/hooks/custom-css.cjs +1 -1
- package/build/hooks/custom-css.cjs.map +2 -2
- package/build/hooks/index.cjs +0 -2
- package/build/hooks/index.cjs.map +3 -3
- package/build/store/actions.cjs +5 -0
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +1 -1
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +5 -7
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +15 -0
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/fit-text-utils.cjs +17 -7
- package/build/utils/fit-text-utils.cjs.map +2 -2
- package/build-module/components/block-breadcrumb/index.mjs +10 -2
- package/build-module/components/block-breadcrumb/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +2 -2
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block.mjs +6 -3
- package/build-module/components/block-list/block.mjs.map +3 -3
- package/build-module/components/block-list/index.mjs +26 -18
- package/build-module/components/block-list/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs +2 -6
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs.map +2 -2
- package/build-module/components/block-list/use-in-between-inserter.mjs +4 -4
- package/build-module/components/block-list/use-in-between-inserter.mjs.map +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.mjs +10 -7
- package/build-module/components/block-settings-menu/block-settings-dropdown.mjs.map +2 -2
- package/build-module/components/block-settings-menu-controls/edit-section-menu-item.mjs +1 -1
- package/build-module/components/block-settings-menu-controls/edit-section-menu-item.mjs.map +2 -2
- package/build-module/components/block-settings-menu-controls/index.mjs +10 -15
- package/build-module/components/block-settings-menu-controls/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +6 -4
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
- package/build-module/components/block-toolbar/index.mjs +1 -1
- package/build-module/components/block-toolbar/index.mjs.map +2 -2
- package/build-module/components/block-variation-transforms/index.mjs +1 -2
- package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +5 -92
- package/build-module/components/block-visibility/modal.mjs.map +2 -2
- package/build-module/components/inserter/index.mjs +1 -0
- package/build-module/components/inserter/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/index.mjs +2 -2
- package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/media-replace-flow/index.mjs +2 -2
- package/build-module/components/media-replace-flow/index.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +1 -1
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/use-block-display-information/index.mjs +1 -1
- package/build-module/components/use-block-display-information/index.mjs.map +2 -2
- package/build-module/components/writing-flow/index.mjs +2 -0
- package/build-module/components/writing-flow/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-arrow-nav.mjs +3 -0
- package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
- package/build-module/components/writing-flow/use-drag-selection.mjs +2 -1
- package/build-module/components/writing-flow/use-drag-selection.mjs.map +2 -2
- package/build-module/components/writing-flow/use-preview-mode-nav.mjs +67 -0
- package/build-module/components/writing-flow/use-preview-mode-nav.mjs.map +7 -0
- package/build-module/hooks/block-renaming.mjs +1 -1
- package/build-module/hooks/block-renaming.mjs.map +2 -2
- package/build-module/hooks/custom-css.mjs +1 -1
- package/build-module/hooks/custom-css.mjs.map +2 -2
- package/build-module/hooks/index.mjs +0 -2
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/store/actions.mjs +5 -0
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +1 -1
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +5 -7
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +15 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/fit-text-utils.mjs +17 -7
- package/build-module/utils/fit-text-utils.mjs.map +2 -2
- package/build-style/content-rtl.css +10 -0
- package/build-style/content.css +10 -0
- package/package.json +39 -39
- package/src/components/block-breadcrumb/index.js +6 -1
- package/src/components/block-inspector/index.js +1 -4
- package/src/components/block-list/block.js +5 -2
- package/src/components/block-list/content.scss +11 -0
- package/src/components/block-list/index.js +25 -17
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +2 -7
- package/src/components/block-list/use-in-between-inserter.js +8 -6
- package/src/components/block-settings-menu/block-settings-dropdown.js +11 -6
- package/src/components/block-settings-menu-controls/edit-section-menu-item.js +1 -7
- package/src/components/block-settings-menu-controls/index.js +14 -16
- package/src/components/block-toolbar/block-toolbar-icon.js +6 -10
- package/src/components/block-toolbar/index.js +1 -7
- package/src/components/block-variation-transforms/index.js +1 -4
- package/src/components/inserter/index.js +1 -0
- package/src/components/inserter/stories/index.story.jsx +31 -24
- package/src/components/inspector-controls-tabs/index.js +1 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +7 -8
- package/src/components/media-replace-flow/index.js +3 -3
- package/src/components/rich-text/index.js +1 -1
- package/src/components/use-block-display-information/index.js +1 -5
- package/src/components/writing-flow/index.js +2 -0
- package/src/components/writing-flow/use-arrow-nav.js +5 -0
- package/src/components/writing-flow/use-drag-selection.js +7 -1
- package/src/components/writing-flow/use-preview-mode-nav.js +102 -0
- package/src/hooks/block-renaming.js +5 -2
- package/src/hooks/custom-css.js +1 -1
- package/src/hooks/index.js +0 -2
- package/src/store/actions.js +7 -0
- package/src/store/private-selectors.js +0 -1
- package/src/store/reducer.js +11 -18
- package/src/store/selectors.js +25 -0
- package/src/store/test/reducer.js +258 -266
- package/src/utils/fit-text-utils.js +24 -8
- package/build/components/content-lock/index.cjs +0 -31
- package/build/components/content-lock/index.cjs.map +0 -7
- package/build/components/content-lock/modify-content-lock-menu-item.cjs +0 -70
- package/build/components/content-lock/modify-content-lock-menu-item.cjs.map +0 -7
- package/build/hooks/content-lock-ui.cjs +0 -68
- package/build/hooks/content-lock-ui.cjs.map +0 -7
- package/build-module/components/content-lock/index.mjs +0 -6
- package/build-module/components/content-lock/index.mjs.map +0 -7
- package/build-module/components/content-lock/modify-content-lock-menu-item.mjs +0 -45
- package/build-module/components/content-lock/modify-content-lock-menu-item.mjs.map +0 -7
- package/build-module/hooks/content-lock-ui.mjs +0 -47
- package/build-module/hooks/content-lock-ui.mjs.map +0 -7
- package/src/components/content-lock/index.js +0 -1
- package/src/components/content-lock/modify-content-lock-menu-item.js +0 -67
- package/src/hooks/content-lock-ui.js +0 -76
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { registerCoreBlocks } from '@wordpress/block-library';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Internal dependencies
|
|
3
8
|
*/
|
|
@@ -8,13 +13,17 @@ import Inserter from '../';
|
|
|
8
13
|
|
|
9
14
|
export default { title: 'BlockEditor/Inserter' };
|
|
10
15
|
|
|
16
|
+
// For the purpose of this story, we need to register the core blocks samples.
|
|
17
|
+
registerCoreBlocks();
|
|
18
|
+
|
|
19
|
+
const wrapperStyle = {
|
|
20
|
+
margin: '24px',
|
|
21
|
+
height: 400,
|
|
22
|
+
border: '1px solid #f3f3f3',
|
|
23
|
+
display: 'inline-block',
|
|
24
|
+
};
|
|
25
|
+
|
|
11
26
|
export const LibraryWithoutPatterns = () => {
|
|
12
|
-
const wrapperStyle = {
|
|
13
|
-
margin: '24px',
|
|
14
|
-
height: 400,
|
|
15
|
-
border: '1px solid #f3f3f3',
|
|
16
|
-
display: 'inline-block',
|
|
17
|
-
};
|
|
18
27
|
return (
|
|
19
28
|
<ExperimentalBlockEditorProvider>
|
|
20
29
|
<div style={ wrapperStyle }>
|
|
@@ -25,12 +34,6 @@ export const LibraryWithoutPatterns = () => {
|
|
|
25
34
|
};
|
|
26
35
|
|
|
27
36
|
export const LibraryWithPatterns = () => {
|
|
28
|
-
const wrapperStyle = {
|
|
29
|
-
margin: '24px',
|
|
30
|
-
height: 400,
|
|
31
|
-
border: '1px solid #f3f3f3',
|
|
32
|
-
display: 'inline-block',
|
|
33
|
-
};
|
|
34
37
|
return (
|
|
35
38
|
<ExperimentalBlockEditorProvider
|
|
36
39
|
settings={ {
|
|
@@ -46,12 +49,6 @@ export const LibraryWithPatterns = () => {
|
|
|
46
49
|
};
|
|
47
50
|
|
|
48
51
|
export const LibraryWithPatternsAndReusableBlocks = () => {
|
|
49
|
-
const wrapperStyle = {
|
|
50
|
-
margin: '24px',
|
|
51
|
-
height: 400,
|
|
52
|
-
border: '1px solid #f3f3f3',
|
|
53
|
-
display: 'inline-block',
|
|
54
|
-
};
|
|
55
52
|
return (
|
|
56
53
|
<ExperimentalBlockEditorProvider
|
|
57
54
|
settings={ {
|
|
@@ -67,13 +64,23 @@ export const LibraryWithPatternsAndReusableBlocks = () => {
|
|
|
67
64
|
);
|
|
68
65
|
};
|
|
69
66
|
|
|
67
|
+
export const FullInserter = () => {
|
|
68
|
+
return (
|
|
69
|
+
<ExperimentalBlockEditorProvider
|
|
70
|
+
settings={ {
|
|
71
|
+
__experimentalBlockPatternCategories: patternCategories,
|
|
72
|
+
__experimentalBlockPatterns: patterns,
|
|
73
|
+
__experimentalReusableBlocks: reusableBlocks,
|
|
74
|
+
} }
|
|
75
|
+
>
|
|
76
|
+
<div style={ wrapperStyle }>
|
|
77
|
+
<Inserter />
|
|
78
|
+
</div>
|
|
79
|
+
</ExperimentalBlockEditorProvider>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
70
83
|
export const QuickInserter = () => {
|
|
71
|
-
const wrapperStyle = {
|
|
72
|
-
margin: '24px',
|
|
73
|
-
height: 400,
|
|
74
|
-
border: '1px solid #f3f3f3',
|
|
75
|
-
display: 'inline-block',
|
|
76
|
-
};
|
|
77
84
|
return (
|
|
78
85
|
<ExperimentalBlockEditorProvider
|
|
79
86
|
settings={ {
|
|
@@ -101,8 +101,8 @@ export default function InspectorControlsTabs( {
|
|
|
101
101
|
/>
|
|
102
102
|
</Tabs.TabPanel>
|
|
103
103
|
<Tabs.TabPanel tabId={ TAB_CONTENT.name } focusable={ false }>
|
|
104
|
-
<InspectorControls.Slot group="content" />
|
|
105
104
|
<ContentTab contentClientIds={ contentClientIds } />
|
|
105
|
+
<InspectorControls.Slot group="content" />
|
|
106
106
|
</Tabs.TabPanel>
|
|
107
107
|
<Tabs.TabPanel tabId={ TAB_LIST_VIEW.name } focusable={ false }>
|
|
108
108
|
<InspectorControls.Slot group="list" />
|
|
@@ -71,14 +71,13 @@ const StylesTab = ( {
|
|
|
71
71
|
return (
|
|
72
72
|
<>
|
|
73
73
|
{ hasBlockStyles && <BlockStyles clientId={ clientId } /> }
|
|
74
|
-
{ isSectionBlock &&
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
) }
|
|
74
|
+
{ isSectionBlock && (
|
|
75
|
+
<SectionBlockColorControls
|
|
76
|
+
blockName={ blockName }
|
|
77
|
+
clientId={ clientId }
|
|
78
|
+
contentClientIds={ contentClientIds }
|
|
79
|
+
/>
|
|
80
|
+
) }
|
|
82
81
|
{ ! isSectionBlock && (
|
|
83
82
|
<>
|
|
84
83
|
<InspectorControls.Slot
|
|
@@ -239,6 +239,9 @@ const MediaReplaceFlow = ( {
|
|
|
239
239
|
{ __( 'Use featured image' ) }
|
|
240
240
|
</MenuItem>
|
|
241
241
|
) }
|
|
242
|
+
{ typeof children === 'function'
|
|
243
|
+
? children( { onClose } )
|
|
244
|
+
: children }
|
|
242
245
|
{ mediaURL && onReset && (
|
|
243
246
|
<MenuItem
|
|
244
247
|
onClick={ () => {
|
|
@@ -249,9 +252,6 @@ const MediaReplaceFlow = ( {
|
|
|
249
252
|
{ __( 'Reset' ) }
|
|
250
253
|
</MenuItem>
|
|
251
254
|
) }
|
|
252
|
-
{ typeof children === 'function'
|
|
253
|
-
? children( { onClose } )
|
|
254
|
-
: children }
|
|
255
255
|
</NavigableMenu>
|
|
256
256
|
{ onSelectURL && (
|
|
257
257
|
<form className="block-editor-media-flow__url-input">
|
|
@@ -583,7 +583,7 @@ const PublicForwardedRichTextContainer = forwardRef( ( props, ref ) => {
|
|
|
583
583
|
ref={ ref }
|
|
584
584
|
{ ...contentProps }
|
|
585
585
|
dangerouslySetInnerHTML={ {
|
|
586
|
-
__html: valueToHTMLString( value, multiline ),
|
|
586
|
+
__html: valueToHTMLString( value, multiline ) || '<br>',
|
|
587
587
|
} }
|
|
588
588
|
/>
|
|
589
589
|
);
|
|
@@ -89,12 +89,8 @@ export default function useBlockDisplayInformation( clientId ) {
|
|
|
89
89
|
// Check if this block is a pattern
|
|
90
90
|
const patternName = attributes?.metadata?.patternName;
|
|
91
91
|
|
|
92
|
-
if (
|
|
93
|
-
patternName &&
|
|
94
|
-
window?.__experimentalContentOnlyPatternInsertion
|
|
95
|
-
) {
|
|
92
|
+
if ( patternName ) {
|
|
96
93
|
const pattern = __experimentalGetParsedPattern( patternName );
|
|
97
|
-
|
|
98
94
|
const positionLabel = getPositionTypeLabel( attributes );
|
|
99
95
|
return {
|
|
100
96
|
isSynced: false,
|
|
@@ -17,6 +17,7 @@ import { forwardRef } from '@wordpress/element';
|
|
|
17
17
|
import useMultiSelection from './use-multi-selection';
|
|
18
18
|
import useTabNav from './use-tab-nav';
|
|
19
19
|
import useArrowNav from './use-arrow-nav';
|
|
20
|
+
import { usePreviewModeNav } from './use-preview-mode-nav';
|
|
20
21
|
import useSelectAll from './use-select-all';
|
|
21
22
|
import useDragSelection from './use-drag-selection';
|
|
22
23
|
import useSelectionObserver from './use-selection-observer';
|
|
@@ -44,6 +45,7 @@ export function useWritingFlow() {
|
|
|
44
45
|
useMultiSelection(),
|
|
45
46
|
useSelectAll(),
|
|
46
47
|
useArrowNav(),
|
|
48
|
+
usePreviewModeNav(),
|
|
47
49
|
useRefEffect(
|
|
48
50
|
( node ) => {
|
|
49
51
|
node.tabIndex = 0;
|
|
@@ -209,6 +209,11 @@ export default function useArrowNav() {
|
|
|
209
209
|
return;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
+
// In preview mode, navigation is handled by useSelectableBlocksNav.
|
|
213
|
+
if ( getSettings().isPreviewMode ) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
212
217
|
// If there is a multi-selection, the arrow keys should collapse the
|
|
213
218
|
// selection to the start or end of the selection.
|
|
214
219
|
if ( hasMultiSelection() ) {
|
|
@@ -30,6 +30,7 @@ export default function useDragSelection() {
|
|
|
30
30
|
const { startMultiSelect, stopMultiSelect } =
|
|
31
31
|
useDispatch( blockEditorStore );
|
|
32
32
|
const {
|
|
33
|
+
getSettings,
|
|
33
34
|
isSelectionEnabled,
|
|
34
35
|
hasSelectedBlock,
|
|
35
36
|
isDraggingBlocks,
|
|
@@ -123,7 +124,12 @@ export default function useDragSelection() {
|
|
|
123
124
|
// child elements of the content editable wrapper are editable
|
|
124
125
|
// and return true for this property. We only want to start
|
|
125
126
|
// multi selecting when the mouse leaves the wrapper.
|
|
126
|
-
|
|
127
|
+
// In preview mode, allow drag selection from blocks since they
|
|
128
|
+
// are not contenteditable.
|
|
129
|
+
if (
|
|
130
|
+
target.getAttribute( 'contenteditable' ) !== 'true' &&
|
|
131
|
+
! getSettings().isPreviewMode
|
|
132
|
+
) {
|
|
127
133
|
return;
|
|
128
134
|
}
|
|
129
135
|
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useRefEffect } from '@wordpress/compose';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { TAB, UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { store as blockEditorStore } from '../../store';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* In preview mode, handles Tab and arrow key navigation to move only between
|
|
15
|
+
* block elements, skipping all other focusable content.
|
|
16
|
+
*
|
|
17
|
+
* @return {Function} Ref callback.
|
|
18
|
+
*/
|
|
19
|
+
export function usePreviewModeNav() {
|
|
20
|
+
const isPreviewMode = useSelect(
|
|
21
|
+
( select ) => select( blockEditorStore ).getSettings().isPreviewMode,
|
|
22
|
+
[]
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return useRefEffect(
|
|
26
|
+
( node ) => {
|
|
27
|
+
if ( ! isPreviewMode ) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function onKeyDown( event ) {
|
|
32
|
+
const { keyCode, shiftKey, target } = event;
|
|
33
|
+
|
|
34
|
+
const isTab = keyCode === TAB;
|
|
35
|
+
const isUp = keyCode === UP;
|
|
36
|
+
const isDown = keyCode === DOWN;
|
|
37
|
+
const isLeft = keyCode === LEFT;
|
|
38
|
+
const isRight = keyCode === RIGHT;
|
|
39
|
+
const isArrow = isUp || isDown || isLeft || isRight;
|
|
40
|
+
|
|
41
|
+
if ( ! isTab && ! isArrow ) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const isReverse = isTab ? shiftKey : isUp || isLeft;
|
|
46
|
+
|
|
47
|
+
const blocks = Array.from(
|
|
48
|
+
node.querySelectorAll( '[data-block]' )
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
if ( ! blocks.length ) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const currentBlock = target.closest( '[data-block]' );
|
|
56
|
+
const currentIndex = currentBlock
|
|
57
|
+
? blocks.indexOf( currentBlock )
|
|
58
|
+
: -1;
|
|
59
|
+
|
|
60
|
+
// If focus is not on a block, don't intercept navigation.
|
|
61
|
+
if ( currentIndex === -1 ) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// For Tab navigation, allow escaping the block list at boundaries.
|
|
66
|
+
// For arrow keys, wrap around.
|
|
67
|
+
if ( isTab ) {
|
|
68
|
+
if ( isReverse && currentIndex === 0 ) {
|
|
69
|
+
// At first block, Shift+Tab should exit the block list.
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if ( ! isReverse && currentIndex === blocks.length - 1 ) {
|
|
73
|
+
// At last block, Tab should exit the block list.
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let nextIndex;
|
|
79
|
+
if ( isReverse ) {
|
|
80
|
+
nextIndex =
|
|
81
|
+
currentIndex <= 0
|
|
82
|
+
? blocks.length - 1
|
|
83
|
+
: currentIndex - 1;
|
|
84
|
+
} else {
|
|
85
|
+
nextIndex =
|
|
86
|
+
currentIndex === -1 || currentIndex >= blocks.length - 1
|
|
87
|
+
? 0
|
|
88
|
+
: currentIndex + 1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
blocks[ nextIndex ].focus();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
node.addEventListener( 'keydown', onKeyDown );
|
|
96
|
+
return () => {
|
|
97
|
+
node.removeEventListener( 'keydown', onKeyDown );
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
[ isPreviewMode ]
|
|
101
|
+
);
|
|
102
|
+
}
|
|
@@ -28,8 +28,11 @@ export function addLabelCallback( settings ) {
|
|
|
28
28
|
settings.__experimentalLabel = ( attributes, { context } ) => {
|
|
29
29
|
const { metadata } = attributes;
|
|
30
30
|
|
|
31
|
-
// In the list view, use the block's name attribute as the label.
|
|
32
|
-
if (
|
|
31
|
+
// In the list view and breadcrumb, use the block's name attribute as the label.
|
|
32
|
+
if (
|
|
33
|
+
( context === 'list-view' || context === 'breadcrumb' ) &&
|
|
34
|
+
metadata?.name
|
|
35
|
+
) {
|
|
33
36
|
return metadata.name;
|
|
34
37
|
}
|
|
35
38
|
};
|
package/src/hooks/custom-css.js
CHANGED
package/src/hooks/index.js
CHANGED
|
@@ -32,7 +32,6 @@ import position from './position';
|
|
|
32
32
|
import blockStyleVariation from './block-style-variation';
|
|
33
33
|
import layout from './layout';
|
|
34
34
|
import childLayout from './layout-child';
|
|
35
|
-
import contentLockUI from './content-lock-ui';
|
|
36
35
|
import './metadata';
|
|
37
36
|
import blockHooks from './block-hooks';
|
|
38
37
|
import blockBindingsPanel from './block-bindings';
|
|
@@ -53,7 +52,6 @@ createBlockEditFilter(
|
|
|
53
52
|
fitText,
|
|
54
53
|
position,
|
|
55
54
|
layout,
|
|
56
|
-
contentLockUI,
|
|
57
55
|
blockHooks,
|
|
58
56
|
blockBindingsPanel,
|
|
59
57
|
childLayout,
|
package/src/store/actions.js
CHANGED
|
@@ -248,6 +248,13 @@ export const selectPreviousBlock =
|
|
|
248
248
|
const firstParentClientId = select.getBlockRootClientId( clientId );
|
|
249
249
|
if ( firstParentClientId ) {
|
|
250
250
|
dispatch.selectBlock( firstParentClientId, -1 );
|
|
251
|
+
} else {
|
|
252
|
+
// Fallback to next block when no previous block and no parent
|
|
253
|
+
const nextBlockClientId =
|
|
254
|
+
select.getNextBlockClientId( clientId );
|
|
255
|
+
if ( nextBlockClientId ) {
|
|
256
|
+
dispatch.selectBlock( nextBlockClientId, 0 );
|
|
257
|
+
}
|
|
251
258
|
}
|
|
252
259
|
}
|
|
253
260
|
};
|
package/src/store/reducer.js
CHANGED
|
@@ -2283,22 +2283,17 @@ function getDerivedBlockEditingModesForTree( state, treeClientId = '' ) {
|
|
|
2283
2283
|
|
|
2284
2284
|
// Use array.from for better back compat. Older versions of the iterator returned
|
|
2285
2285
|
// from `keys()` didn't have the `filter` method.
|
|
2286
|
-
const unsyncedPatternClientIds =
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
( clientId )
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
)
|
|
2294
|
-
: [];
|
|
2286
|
+
const unsyncedPatternClientIds = isIsolatedEditor
|
|
2287
|
+
? []
|
|
2288
|
+
: Array.from( state.blocks.attributes.keys() ).filter(
|
|
2289
|
+
( clientId ) =>
|
|
2290
|
+
state.blocks.attributes.get( clientId )?.metadata
|
|
2291
|
+
?.patternName
|
|
2292
|
+
);
|
|
2295
2293
|
const contentOnlyParents = [
|
|
2296
2294
|
...contentOnlyTemplateLockedClientIds,
|
|
2297
2295
|
...unsyncedPatternClientIds,
|
|
2298
|
-
...(
|
|
2299
|
-
! isIsolatedEditor
|
|
2300
|
-
? templatePartClientIds
|
|
2301
|
-
: [] ),
|
|
2296
|
+
...( isIsolatedEditor ? [] : templatePartClientIds ),
|
|
2302
2297
|
];
|
|
2303
2298
|
|
|
2304
2299
|
traverseBlockTree( state, treeClientId, ( block ) => {
|
|
@@ -2323,11 +2318,9 @@ function getDerivedBlockEditingModesForTree( state, treeClientId = '' ) {
|
|
|
2323
2318
|
return;
|
|
2324
2319
|
}
|
|
2325
2320
|
|
|
2326
|
-
//
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
return;
|
|
2330
|
-
}
|
|
2321
|
+
// Disable blocks that are outside of the edited section.
|
|
2322
|
+
derivedBlockEditingModes.set( clientId, 'disabled' );
|
|
2323
|
+
return;
|
|
2331
2324
|
}
|
|
2332
2325
|
|
|
2333
2326
|
// If the block already has an explicit block editing mode set,
|
package/src/store/selectors.js
CHANGED
|
@@ -1681,6 +1681,11 @@ const canInsertBlockTypeUnmemoized = (
|
|
|
1681
1681
|
blockName,
|
|
1682
1682
|
rootClientId = null
|
|
1683
1683
|
) => {
|
|
1684
|
+
// Disable insertion in preview mode.
|
|
1685
|
+
if ( state.settings.isPreviewMode ) {
|
|
1686
|
+
return false;
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1684
1689
|
if ( ! isBlockVisibleInTheInserter( state, blockName, rootClientId ) ) {
|
|
1685
1690
|
return false;
|
|
1686
1691
|
}
|
|
@@ -1868,6 +1873,11 @@ export function canInsertBlocks( state, clientIds, rootClientId = null ) {
|
|
|
1868
1873
|
* @return {boolean} Whether the given block is allowed to be removed.
|
|
1869
1874
|
*/
|
|
1870
1875
|
export function canRemoveBlock( state, clientId ) {
|
|
1876
|
+
// Disable removal in preview mode.
|
|
1877
|
+
if ( state.settings.isPreviewMode ) {
|
|
1878
|
+
return false;
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1871
1881
|
const attributes = getBlockAttributes( state, clientId );
|
|
1872
1882
|
if ( attributes === null ) {
|
|
1873
1883
|
return true;
|
|
@@ -1930,6 +1940,11 @@ export function canRemoveBlocks( state, clientIds ) {
|
|
|
1930
1940
|
* @return {boolean} Whether the given block is allowed to be moved.
|
|
1931
1941
|
*/
|
|
1932
1942
|
export function canMoveBlock( state, clientId ) {
|
|
1943
|
+
// Disable moving in preview mode.
|
|
1944
|
+
if ( state.settings.isPreviewMode ) {
|
|
1945
|
+
return false;
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1933
1948
|
const attributes = getBlockAttributes( state, clientId );
|
|
1934
1949
|
if ( attributes === null ) {
|
|
1935
1950
|
return true;
|
|
@@ -1991,6 +2006,11 @@ export function canMoveBlocks( state, clientIds ) {
|
|
|
1991
2006
|
* @return {boolean} Whether the given block is allowed to be edited.
|
|
1992
2007
|
*/
|
|
1993
2008
|
export function canEditBlock( state, clientId ) {
|
|
2009
|
+
// Disable editing in preview mode.
|
|
2010
|
+
if ( state.settings.isPreviewMode ) {
|
|
2011
|
+
return false;
|
|
2012
|
+
}
|
|
2013
|
+
|
|
1994
2014
|
const attributes = getBlockAttributes( state, clientId );
|
|
1995
2015
|
if ( attributes === null ) {
|
|
1996
2016
|
return true;
|
|
@@ -2011,6 +2031,11 @@ export function canEditBlock( state, clientId ) {
|
|
|
2011
2031
|
* @return {boolean} Whether a given block type can be locked/unlocked.
|
|
2012
2032
|
*/
|
|
2013
2033
|
export function canLockBlockType( state, nameOrType ) {
|
|
2034
|
+
// Disable locking in preview mode.
|
|
2035
|
+
if ( state.settings.isPreviewMode ) {
|
|
2036
|
+
return false;
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2014
2039
|
if ( ! hasBlockSupport( nameOrType, 'lock', true ) ) {
|
|
2015
2040
|
return false;
|
|
2016
2041
|
}
|