@wordpress/editor 13.28.5 → 13.30.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 +4 -0
- package/build/components/block-removal-warnings/index.js +70 -0
- package/build/components/block-removal-warnings/index.js.map +1 -0
- package/build/components/commands/index.js +209 -0
- package/build/components/commands/index.js.map +1 -0
- package/build/components/commands/index.native.js +9 -0
- package/build/components/commands/index.native.js.map +1 -0
- package/build/components/document-bar/index.js +78 -67
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/document-outline/check.js +8 -7
- package/build/components/document-outline/check.js.map +1 -1
- package/build/components/document-outline/index.js +26 -27
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/document-tools/index.js +5 -3
- package/build/components/document-tools/index.js.map +1 -1
- package/build/components/editor-help/intro-to-blocks.native.js.map +1 -1
- package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/index.js +20 -2
- package/build/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js +18 -0
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build/components/list-view-sidebar/index.js +1 -1
- package/build/components/list-view-sidebar/index.js.map +1 -1
- package/build/components/mode-switcher/index.js +86 -0
- package/build/components/mode-switcher/index.js.map +1 -0
- package/build/components/post-locked-modal/index.js.map +1 -1
- package/build/components/post-preview-button/index.js +2 -1
- package/build/components/post-preview-button/index.js.map +1 -1
- package/build/components/post-publish-button/index.js +2 -1
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js +3 -0
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-title/index.js +0 -5
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/post-title/post-title-raw.js.map +1 -1
- package/build/components/post-view-link/index.js +2 -1
- package/build/components/post-view-link/index.js.map +1 -1
- package/build/components/provider/index.js +8 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/index.native.js +4 -9
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +1 -1
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/provider/use-hide-blocks-from-inserter.js +53 -0
- package/build/components/provider/use-hide-blocks-from-inserter.js.map +1 -0
- package/build/private-apis.js +2 -0
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +69 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +13 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-removal-warnings/index.js +64 -0
- package/build-module/components/block-removal-warnings/index.js.map +1 -0
- package/build-module/components/commands/index.js +202 -0
- package/build-module/components/commands/index.js.map +1 -0
- package/build-module/components/commands/index.native.js +3 -0
- package/build-module/components/commands/index.native.js.map +1 -0
- package/build-module/components/document-bar/index.js +81 -70
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/document-outline/check.js +9 -8
- package/build-module/components/document-outline/check.js.map +1 -1
- package/build-module/components/document-outline/index.js +26 -26
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/document-tools/index.js +5 -3
- package/build-module/components/document-tools/index.js.map +1 -1
- package/build-module/components/editor-help/intro-to-blocks.native.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/index.js +20 -2
- package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +18 -0
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build-module/components/list-view-sidebar/index.js +1 -1
- package/build-module/components/list-view-sidebar/index.js.map +1 -1
- package/build-module/components/mode-switcher/index.js +80 -0
- package/build-module/components/mode-switcher/index.js.map +1 -0
- package/build-module/components/post-locked-modal/index.js.map +1 -1
- package/build-module/components/post-preview-button/index.js +2 -1
- package/build-module/components/post-preview-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/index.js +2 -1
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js +3 -0
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-title/index.js +0 -5
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/post-title/post-title-raw.js.map +1 -1
- package/build-module/components/post-view-link/index.js +2 -1
- package/build-module/components/post-view-link/index.js.map +1 -1
- package/build-module/components/provider/index.js +8 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +4 -10
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +1 -1
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/provider/use-hide-blocks-from-inserter.js +47 -0
- package/build-module/components/provider/use-hide-blocks-from-inserter.js.map +1 -0
- package/build-module/private-apis.js +2 -0
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +66 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +12 -0
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +4 -47
- package/build-style/style.css +4 -47
- package/package.json +32 -32
- package/src/components/block-removal-warnings/index.js +92 -0
- package/src/components/commands/index.js +210 -0
- package/src/components/commands/index.native.js +2 -0
- package/src/components/document-bar/index.js +115 -94
- package/src/components/document-bar/style.scss +4 -37
- package/src/components/document-outline/check.js +8 -10
- package/src/components/document-outline/index.js +18 -23
- package/src/components/document-outline/test/index.js +26 -7
- package/src/components/document-tools/index.js +3 -3
- package/src/components/editor-help/intro-to-blocks.native.js +1 -1
- package/src/components/entities-saved-states/entity-type-list.js +1 -1
- package/src/components/global-keyboard-shortcuts/index.js +35 -4
- package/src/components/global-keyboard-shortcuts/register-shortcuts.js +20 -0
- package/src/components/list-view-sidebar/index.js +1 -1
- package/src/components/mode-switcher/index.js +90 -0
- package/src/components/post-locked-modal/index.js +1 -1
- package/src/components/post-preview-button/index.js +1 -0
- package/src/components/post-publish-button/index.js +1 -0
- package/src/components/post-publish-panel/index.js +1 -1
- package/src/components/post-publish-panel/maybe-upload-media.js +1 -1
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +3 -3
- package/src/components/post-taxonomies/hierarchical-term-selector.js +3 -0
- package/src/components/post-title/index.js +0 -3
- package/src/components/post-title/index.native.js +2 -2
- package/src/components/post-title/post-title-raw.js +1 -1
- package/src/components/post-view-link/index.js +1 -0
- package/src/components/provider/index.js +9 -0
- package/src/components/provider/index.native.js +7 -6
- package/src/components/provider/use-block-editor-settings.js +0 -3
- package/src/components/provider/use-hide-blocks-from-inserter.js +81 -0
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +95 -0
- package/src/store/selectors.js +12 -0
- package/src/store/test/actions.js +82 -0
|
@@ -40,6 +40,10 @@
|
|
|
40
40
|
flex-grow: 1;
|
|
41
41
|
overflow: hidden;
|
|
42
42
|
color: $gray-800;
|
|
43
|
+
gap: $grid-unit-05;
|
|
44
|
+
display: flex;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
align-items: center;
|
|
43
47
|
|
|
44
48
|
// Offset the layout based on the width of the ⌘K label. This ensures the title is centrally aligned.
|
|
45
49
|
@include break-small() {
|
|
@@ -66,16 +70,6 @@
|
|
|
66
70
|
max-width: 50%;
|
|
67
71
|
color: currentColor;
|
|
68
72
|
}
|
|
69
|
-
|
|
70
|
-
.editor-document-bar.is-animated.has-back-button & {
|
|
71
|
-
animation: editor-document-bar__slide-in-left 0.3s;
|
|
72
|
-
@include reduce-motion("animation");
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.editor-document-bar.is-animated & {
|
|
76
|
-
animation: editor-document-bar__slide-in-right 0.3s;
|
|
77
|
-
@include reduce-motion("animation");
|
|
78
|
-
}
|
|
79
73
|
}
|
|
80
74
|
|
|
81
75
|
.editor-document-bar__shortcut {
|
|
@@ -100,31 +94,4 @@
|
|
|
100
94
|
color: var(--wp-block-synced-color);
|
|
101
95
|
background-color: transparent;
|
|
102
96
|
}
|
|
103
|
-
|
|
104
|
-
.editor-document-bar.is-animated & {
|
|
105
|
-
animation: editor-document-bar__slide-in-left 0.3s;
|
|
106
|
-
@include reduce-motion("animation");
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
@keyframes editor-document-bar__slide-in-right {
|
|
111
|
-
from {
|
|
112
|
-
transform: translateX(-15%);
|
|
113
|
-
opacity: 0;
|
|
114
|
-
}
|
|
115
|
-
to {
|
|
116
|
-
transform: translateX(0);
|
|
117
|
-
opacity: 1;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
@keyframes editor-document-bar__slide-in-left {
|
|
122
|
-
from {
|
|
123
|
-
transform: translateX(15%);
|
|
124
|
-
opacity: 0;
|
|
125
|
-
}
|
|
126
|
-
to {
|
|
127
|
-
transform: translateX(0);
|
|
128
|
-
opacity: 1;
|
|
129
|
-
}
|
|
130
97
|
}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
5
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
6
6
|
|
|
7
|
-
function DocumentOutlineCheck( {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
);
|
|
7
|
+
export default function DocumentOutlineCheck( { children } ) {
|
|
8
|
+
const hasHeadings = useSelect( ( select ) => {
|
|
9
|
+
const { getGlobalBlockCount } = select( blockEditorStore );
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
return getGlobalBlockCount( 'core/heading' ) > 0;
|
|
12
|
+
} );
|
|
13
|
+
|
|
14
|
+
if ( hasHeadings ) {
|
|
13
15
|
return null;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
return children;
|
|
17
19
|
}
|
|
18
|
-
|
|
19
|
-
export default withSelect( ( select ) => ( {
|
|
20
|
-
blocks: select( blockEditorStore ).getBlocks(),
|
|
21
|
-
} ) )( DocumentOutlineCheck );
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
6
|
-
import { withSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
7
6
|
import { create, getTextContent } from '@wordpress/rich-text';
|
|
8
7
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
9
8
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -98,15 +97,26 @@ const computeOutlineHeadings = ( blocks = [] ) => {
|
|
|
98
97
|
const isEmptyHeading = ( heading ) =>
|
|
99
98
|
! heading.attributes.content || heading.attributes.content.length === 0;
|
|
100
99
|
|
|
101
|
-
export
|
|
102
|
-
blocks = [],
|
|
103
|
-
title,
|
|
100
|
+
export default function DocumentOutline( {
|
|
104
101
|
onSelect,
|
|
105
102
|
isTitleSupported,
|
|
106
103
|
hasOutlineItemsDisabled,
|
|
107
|
-
} )
|
|
108
|
-
const headings = computeOutlineHeadings( blocks );
|
|
104
|
+
} ) {
|
|
109
105
|
const { selectBlock } = useDispatch( blockEditorStore );
|
|
106
|
+
const { blocks, title } = useSelect( ( select ) => {
|
|
107
|
+
const { getBlocks } = select( blockEditorStore );
|
|
108
|
+
const { getEditedPostAttribute } = select( editorStore );
|
|
109
|
+
const { getPostType } = select( coreStore );
|
|
110
|
+
const postType = getPostType( getEditedPostAttribute( 'type' ) );
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
title: getEditedPostAttribute( 'title' ),
|
|
114
|
+
blocks: getBlocks(),
|
|
115
|
+
isTitleSupported: postType?.supports?.title ?? false,
|
|
116
|
+
};
|
|
117
|
+
} );
|
|
118
|
+
|
|
119
|
+
const headings = computeOutlineHeadings( blocks );
|
|
110
120
|
if ( headings.length < 1 ) {
|
|
111
121
|
return (
|
|
112
122
|
<div className="editor-document-outline has-no-headings">
|
|
@@ -194,19 +204,4 @@ export const DocumentOutline = ( {
|
|
|
194
204
|
</ul>
|
|
195
205
|
</div>
|
|
196
206
|
);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export default compose(
|
|
200
|
-
withSelect( ( select ) => {
|
|
201
|
-
const { getBlocks } = select( blockEditorStore );
|
|
202
|
-
const { getEditedPostAttribute } = select( editorStore );
|
|
203
|
-
const { getPostType } = select( coreStore );
|
|
204
|
-
const postType = getPostType( getEditedPostAttribute( 'type' ) );
|
|
205
|
-
|
|
206
|
-
return {
|
|
207
|
-
title: getEditedPostAttribute( 'title' ),
|
|
208
|
-
blocks: getBlocks(),
|
|
209
|
-
isTitleSupported: postType?.supports?.title ?? false,
|
|
210
|
-
};
|
|
211
|
-
} )
|
|
212
|
-
)( DocumentOutline );
|
|
207
|
+
}
|
|
@@ -11,15 +11,27 @@ import {
|
|
|
11
11
|
registerBlockType,
|
|
12
12
|
unregisterBlockType,
|
|
13
13
|
} from '@wordpress/blocks';
|
|
14
|
+
import { useSelect } from '@wordpress/data';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Internal dependencies
|
|
17
18
|
*/
|
|
18
|
-
import
|
|
19
|
+
import DocumentOutline from '../';
|
|
19
20
|
|
|
20
21
|
jest.mock( '@wordpress/block-editor', () => ( {
|
|
21
22
|
BlockTitle: () => 'Block Title',
|
|
22
23
|
} ) );
|
|
24
|
+
jest.mock( '@wordpress/data/src/components/use-select', () => jest.fn() );
|
|
25
|
+
|
|
26
|
+
function setupMockSelect( blocks ) {
|
|
27
|
+
useSelect.mockImplementation( ( mapSelect ) => {
|
|
28
|
+
return mapSelect( () => ( {
|
|
29
|
+
getBlocks: () => blocks,
|
|
30
|
+
getEditedPostAttribute: () => null,
|
|
31
|
+
getPostType: () => null,
|
|
32
|
+
} ) );
|
|
33
|
+
} );
|
|
34
|
+
}
|
|
23
35
|
|
|
24
36
|
describe( 'DocumentOutline', () => {
|
|
25
37
|
let paragraph, headingH1, headingH2, headingH3, nestedHeading;
|
|
@@ -77,6 +89,7 @@ describe( 'DocumentOutline', () => {
|
|
|
77
89
|
|
|
78
90
|
describe( 'no header blocks present', () => {
|
|
79
91
|
it( 'should not render when no blocks provided', () => {
|
|
92
|
+
setupMockSelect( [] );
|
|
80
93
|
render( <DocumentOutline /> );
|
|
81
94
|
|
|
82
95
|
expect( screen.queryByRole( 'list' ) ).not.toBeInTheDocument();
|
|
@@ -87,7 +100,8 @@ describe( 'DocumentOutline', () => {
|
|
|
87
100
|
// Set client IDs to a predictable value.
|
|
88
101
|
return { ...block, clientId: `clientId_${ index }` };
|
|
89
102
|
} );
|
|
90
|
-
|
|
103
|
+
setupMockSelect( blocks );
|
|
104
|
+
render( <DocumentOutline /> );
|
|
91
105
|
|
|
92
106
|
expect( screen.queryByRole( 'list' ) ).not.toBeInTheDocument();
|
|
93
107
|
} );
|
|
@@ -99,14 +113,16 @@ describe( 'DocumentOutline', () => {
|
|
|
99
113
|
// Set client IDs to a predictable value.
|
|
100
114
|
return { ...block, clientId: `clientId_${ index }` };
|
|
101
115
|
} );
|
|
102
|
-
|
|
116
|
+
setupMockSelect( blocks );
|
|
117
|
+
render( <DocumentOutline /> );
|
|
103
118
|
|
|
104
119
|
expect( screen.getByRole( 'list' ) ).toMatchSnapshot();
|
|
105
120
|
} );
|
|
106
121
|
|
|
107
122
|
it( 'should render an item when only one heading provided', () => {
|
|
108
123
|
const blocks = [ headingH2 ];
|
|
109
|
-
|
|
124
|
+
setupMockSelect( blocks );
|
|
125
|
+
render( <DocumentOutline /> );
|
|
110
126
|
|
|
111
127
|
const tableOfContentItem = within(
|
|
112
128
|
screen.getByRole( 'list' )
|
|
@@ -123,7 +139,8 @@ describe( 'DocumentOutline', () => {
|
|
|
123
139
|
headingH3,
|
|
124
140
|
paragraph,
|
|
125
141
|
];
|
|
126
|
-
|
|
142
|
+
setupMockSelect( blocks );
|
|
143
|
+
render( <DocumentOutline /> );
|
|
127
144
|
|
|
128
145
|
expect(
|
|
129
146
|
within( screen.getByRole( 'list' ) ).getAllByRole( 'listitem' )
|
|
@@ -137,7 +154,8 @@ describe( 'DocumentOutline', () => {
|
|
|
137
154
|
return { ...block, clientId: `clientId_${ index }` };
|
|
138
155
|
}
|
|
139
156
|
);
|
|
140
|
-
|
|
157
|
+
setupMockSelect( blocks );
|
|
158
|
+
render( <DocumentOutline /> );
|
|
141
159
|
|
|
142
160
|
expect( screen.getByRole( 'list' ) ).toMatchSnapshot();
|
|
143
161
|
} );
|
|
@@ -146,7 +164,8 @@ describe( 'DocumentOutline', () => {
|
|
|
146
164
|
describe( 'nested headings', () => {
|
|
147
165
|
it( 'should render even if the heading is nested', () => {
|
|
148
166
|
const blocks = [ headingH2, nestedHeading ];
|
|
149
|
-
|
|
167
|
+
setupMockSelect( blocks );
|
|
168
|
+
render( <DocumentOutline /> );
|
|
150
169
|
|
|
151
170
|
// Unnested heading and nested heading should appear as items.
|
|
152
171
|
const tableOfContentItems = within(
|
|
@@ -29,7 +29,7 @@ import { store as editorStore } from '../../store';
|
|
|
29
29
|
import EditorHistoryRedo from '../editor-history/redo';
|
|
30
30
|
import EditorHistoryUndo from '../editor-history/undo';
|
|
31
31
|
|
|
32
|
-
const {
|
|
32
|
+
const { useShowBlockTools } = unlock( blockEditorPrivateApis );
|
|
33
33
|
|
|
34
34
|
const preventDefault = ( event ) => {
|
|
35
35
|
event.preventDefault();
|
|
@@ -76,7 +76,7 @@ function DocumentTools( {
|
|
|
76
76
|
|
|
77
77
|
const isLargeViewport = useViewportMatch( 'medium' );
|
|
78
78
|
const isWideViewport = useViewportMatch( 'wide' );
|
|
79
|
-
const
|
|
79
|
+
const { showFixedToolbar } = useShowBlockTools();
|
|
80
80
|
|
|
81
81
|
/* translators: accessibility text for the editor toolbar */
|
|
82
82
|
const toolbarAriaLabel = __( 'Document tools' );
|
|
@@ -117,7 +117,7 @@ function DocumentTools( {
|
|
|
117
117
|
className
|
|
118
118
|
) }
|
|
119
119
|
aria-label={ toolbarAriaLabel }
|
|
120
|
-
shouldUseKeyboardFocusShortcut={ !
|
|
120
|
+
shouldUseKeyboardFocusShortcut={ ! showFixedToolbar }
|
|
121
121
|
variant="unstyled"
|
|
122
122
|
>
|
|
123
123
|
<div className="editor-document-tools__left">
|
|
@@ -94,7 +94,7 @@ export default function EntityTypeList( {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
return (
|
|
97
|
-
<PanelBody title={ entityLabel } initialOpen
|
|
97
|
+
<PanelBody title={ entityLabel } initialOpen>
|
|
98
98
|
<EntityDescription record={ firstRecord } count={ count } />
|
|
99
99
|
{ list.map( ( record ) => {
|
|
100
100
|
return (
|
|
@@ -10,10 +10,41 @@ import { useDispatch, useSelect } from '@wordpress/data';
|
|
|
10
10
|
import { store as editorStore } from '../../store';
|
|
11
11
|
|
|
12
12
|
export default function EditorKeyboardShortcuts() {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const isModeToggleDisabled = useSelect( ( select ) => {
|
|
14
|
+
const { richEditingEnabled, codeEditingEnabled } =
|
|
15
|
+
select( editorStore ).getEditorSettings();
|
|
16
|
+
return ! richEditingEnabled || ! codeEditingEnabled;
|
|
17
|
+
}, [] );
|
|
18
|
+
const {
|
|
19
|
+
redo,
|
|
20
|
+
undo,
|
|
21
|
+
savePost,
|
|
22
|
+
setIsListViewOpened,
|
|
23
|
+
switchEditorMode,
|
|
24
|
+
toggleDistractionFree,
|
|
25
|
+
} = useDispatch( editorStore );
|
|
26
|
+
const {
|
|
27
|
+
isEditedPostDirty,
|
|
28
|
+
isPostSavingLocked,
|
|
29
|
+
isListViewOpened,
|
|
30
|
+
getEditorMode,
|
|
31
|
+
} = useSelect( editorStore );
|
|
32
|
+
|
|
33
|
+
useShortcut(
|
|
34
|
+
'core/editor/toggle-mode',
|
|
35
|
+
() => {
|
|
36
|
+
switchEditorMode(
|
|
37
|
+
getEditorMode() === 'visual' ? 'text' : 'visual'
|
|
38
|
+
);
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
isDisabled: isModeToggleDisabled,
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
useShortcut( 'core/editor/toggle-distraction-free', () => {
|
|
46
|
+
toggleDistractionFree();
|
|
47
|
+
} );
|
|
17
48
|
|
|
18
49
|
useShortcut( 'core/editor/undo', ( event ) => {
|
|
19
50
|
undo();
|
|
@@ -12,6 +12,16 @@ function EditorKeyboardShortcutsRegister() {
|
|
|
12
12
|
// Registering the shortcuts.
|
|
13
13
|
const { registerShortcut } = useDispatch( keyboardShortcutsStore );
|
|
14
14
|
useEffect( () => {
|
|
15
|
+
registerShortcut( {
|
|
16
|
+
name: 'core/editor/toggle-mode',
|
|
17
|
+
category: 'global',
|
|
18
|
+
description: __( 'Switch between visual editor and code editor.' ),
|
|
19
|
+
keyCombination: {
|
|
20
|
+
modifier: 'secondary',
|
|
21
|
+
character: 'm',
|
|
22
|
+
},
|
|
23
|
+
} );
|
|
24
|
+
|
|
15
25
|
registerShortcut( {
|
|
16
26
|
name: 'core/editor/save',
|
|
17
27
|
category: 'global',
|
|
@@ -63,6 +73,16 @@ function EditorKeyboardShortcutsRegister() {
|
|
|
63
73
|
character: 'o',
|
|
64
74
|
},
|
|
65
75
|
} );
|
|
76
|
+
|
|
77
|
+
registerShortcut( {
|
|
78
|
+
name: 'core/editor/toggle-distraction-free',
|
|
79
|
+
category: 'global',
|
|
80
|
+
description: __( 'Toggle distraction free mode.' ),
|
|
81
|
+
keyCombination: {
|
|
82
|
+
modifier: 'primaryShift',
|
|
83
|
+
character: '\\',
|
|
84
|
+
},
|
|
85
|
+
} );
|
|
66
86
|
}, [ registerShortcut ] );
|
|
67
87
|
|
|
68
88
|
return <BlockEditorKeyboardShortcuts.Register />;
|
|
@@ -127,7 +127,7 @@ export default function ListViewSidebar() {
|
|
|
127
127
|
// render where no tab is selected. This ensures that the
|
|
128
128
|
// tabpanel height is correct so the relevant scroll container
|
|
129
129
|
// can be rendered internally.
|
|
130
|
-
|
|
130
|
+
defaultTabId="list-view"
|
|
131
131
|
>
|
|
132
132
|
<div className="edit-post-editor__document-overview-panel__header">
|
|
133
133
|
<Button
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { MenuItemsChoice, MenuGroup } from '@wordpress/components';
|
|
6
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
|
+
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { store as editorStore } from '../../store';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Set of available mode options.
|
|
16
|
+
*
|
|
17
|
+
* @type {Array}
|
|
18
|
+
*/
|
|
19
|
+
const MODES = [
|
|
20
|
+
{
|
|
21
|
+
value: 'visual',
|
|
22
|
+
label: __( 'Visual editor' ),
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
value: 'text',
|
|
26
|
+
label: __( 'Code editor' ),
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
function ModeSwitcher() {
|
|
31
|
+
const { shortcut, isRichEditingEnabled, isCodeEditingEnabled, mode } =
|
|
32
|
+
useSelect(
|
|
33
|
+
( select ) => ( {
|
|
34
|
+
shortcut: select(
|
|
35
|
+
keyboardShortcutsStore
|
|
36
|
+
).getShortcutRepresentation( 'core/editor/toggle-mode' ),
|
|
37
|
+
isRichEditingEnabled:
|
|
38
|
+
select( editorStore ).getEditorSettings()
|
|
39
|
+
.richEditingEnabled,
|
|
40
|
+
isCodeEditingEnabled:
|
|
41
|
+
select( editorStore ).getEditorSettings()
|
|
42
|
+
.codeEditingEnabled,
|
|
43
|
+
mode: select( editorStore ).getEditorMode(),
|
|
44
|
+
} ),
|
|
45
|
+
[]
|
|
46
|
+
);
|
|
47
|
+
const { switchEditorMode } = useDispatch( editorStore );
|
|
48
|
+
|
|
49
|
+
let selectedMode = mode;
|
|
50
|
+
if ( ! isRichEditingEnabled && mode === 'visual' ) {
|
|
51
|
+
selectedMode = 'text';
|
|
52
|
+
}
|
|
53
|
+
if ( ! isCodeEditingEnabled && mode === 'text' ) {
|
|
54
|
+
selectedMode = 'visual';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const choices = MODES.map( ( choice ) => {
|
|
58
|
+
if ( ! isCodeEditingEnabled && choice.value === 'text' ) {
|
|
59
|
+
choice = {
|
|
60
|
+
...choice,
|
|
61
|
+
disabled: true,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if ( ! isRichEditingEnabled && choice.value === 'visual' ) {
|
|
65
|
+
choice = {
|
|
66
|
+
...choice,
|
|
67
|
+
disabled: true,
|
|
68
|
+
info: __(
|
|
69
|
+
'You can enable the visual editor in your profile settings.'
|
|
70
|
+
),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if ( choice.value !== selectedMode && ! choice.disabled ) {
|
|
74
|
+
return { ...choice, shortcut };
|
|
75
|
+
}
|
|
76
|
+
return choice;
|
|
77
|
+
} );
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<MenuGroup label={ __( 'Editor' ) }>
|
|
81
|
+
<MenuItemsChoice
|
|
82
|
+
choices={ choices }
|
|
83
|
+
value={ selectedMode }
|
|
84
|
+
onSelect={ switchEditorMode }
|
|
85
|
+
/>
|
|
86
|
+
</MenuGroup>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default ModeSwitcher;
|
|
@@ -168,7 +168,7 @@ export default function PostLockedModal() {
|
|
|
168
168
|
? __( 'Someone else has taken over this post' )
|
|
169
169
|
: __( 'This post is already being edited' )
|
|
170
170
|
}
|
|
171
|
-
focusOnMount
|
|
171
|
+
focusOnMount
|
|
172
172
|
shouldCloseOnClickOutside={ false }
|
|
173
173
|
shouldCloseOnEsc={ false }
|
|
174
174
|
isDismissible={ false }
|
|
@@ -110,7 +110,7 @@ export class PostPublishPanel extends Component {
|
|
|
110
110
|
</PostPublishPanelPrepublish>
|
|
111
111
|
) }
|
|
112
112
|
{ isPostPublish && (
|
|
113
|
-
<PostPublishPanelPostpublish focusOnMount
|
|
113
|
+
<PostPublishPanelPostpublish focusOnMount>
|
|
114
114
|
{ PostPublishExtension && <PostPublishExtension /> }
|
|
115
115
|
</PostPublishPanelPostpublish>
|
|
116
116
|
) }
|
|
@@ -131,7 +131,7 @@ export default function PostFormatPanel() {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
return (
|
|
134
|
-
<PanelBody initialOpen
|
|
134
|
+
<PanelBody initialOpen title={ panelBodyTitle }>
|
|
135
135
|
<p>
|
|
136
136
|
{ __(
|
|
137
137
|
'Upload external images to the Media Library. Images from different domains may load slowly, display incorrectly, or be removed unexpectedly.'
|
|
@@ -353,7 +353,7 @@ exports[`PostPublishPanel should render the pre-publish panel if post status is
|
|
|
353
353
|
>
|
|
354
354
|
<button
|
|
355
355
|
aria-disabled="true"
|
|
356
|
-
class="components-button editor-post-publish-button editor-post-publish-button__button is-primary"
|
|
356
|
+
class="components-button editor-post-publish-button editor-post-publish-button__button is-primary is-compact"
|
|
357
357
|
type="button"
|
|
358
358
|
>
|
|
359
359
|
Submit for Review
|
|
@@ -476,7 +476,7 @@ exports[`PostPublishPanel should render the pre-publish panel if the post is not
|
|
|
476
476
|
>
|
|
477
477
|
<button
|
|
478
478
|
aria-disabled="true"
|
|
479
|
-
class="components-button editor-post-publish-button editor-post-publish-button__button is-primary"
|
|
479
|
+
class="components-button editor-post-publish-button editor-post-publish-button__button is-primary is-compact"
|
|
480
480
|
type="button"
|
|
481
481
|
>
|
|
482
482
|
Submit for Review
|
|
@@ -643,7 +643,7 @@ exports[`PostPublishPanel should render the spinner if the post is being saved 1
|
|
|
643
643
|
>
|
|
644
644
|
<button
|
|
645
645
|
aria-disabled="true"
|
|
646
|
-
class="components-button editor-post-publish-button editor-post-publish-button__button is-primary"
|
|
646
|
+
class="components-button editor-post-publish-button editor-post-publish-button__button is-primary is-compact"
|
|
647
647
|
type="button"
|
|
648
648
|
>
|
|
649
649
|
Submit for Review
|
|
@@ -439,6 +439,7 @@ export function HierarchicalTermSelector( { slug } ) {
|
|
|
439
439
|
<form onSubmit={ onAddTerm }>
|
|
440
440
|
<Flex direction="column" gap="4">
|
|
441
441
|
<TextControl
|
|
442
|
+
__next40pxDefaultSize
|
|
442
443
|
__nextHasNoMarginBottom
|
|
443
444
|
className="editor-post-taxonomies__hierarchical-terms-input"
|
|
444
445
|
label={ newTermLabel }
|
|
@@ -448,6 +449,7 @@ export function HierarchicalTermSelector( { slug } ) {
|
|
|
448
449
|
/>
|
|
449
450
|
{ !! availableTerms.length && (
|
|
450
451
|
<TreeSelect
|
|
452
|
+
__next40pxDefaultSize
|
|
451
453
|
__nextHasNoMarginBottom
|
|
452
454
|
label={ parentSelectLabel }
|
|
453
455
|
noOptionLabel={ noParentOption }
|
|
@@ -458,6 +460,7 @@ export function HierarchicalTermSelector( { slug } ) {
|
|
|
458
460
|
) }
|
|
459
461
|
<FlexItem>
|
|
460
462
|
<Button
|
|
463
|
+
__next40pxDefaultSize
|
|
461
464
|
variant="secondary"
|
|
462
465
|
type="submit"
|
|
463
466
|
className="editor-post-taxonomies__hierarchical-terms-submit"
|
|
@@ -25,7 +25,6 @@ import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
|
25
25
|
/**
|
|
26
26
|
* Internal dependencies
|
|
27
27
|
*/
|
|
28
|
-
import { store as editorStore } from '../../store';
|
|
29
28
|
import { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';
|
|
30
29
|
import usePostTitleFocus from './use-post-title-focus';
|
|
31
30
|
import usePostTitle from './use-post-title';
|
|
@@ -33,13 +32,11 @@ import PostTypeSupportCheck from '../post-type-support-check';
|
|
|
33
32
|
|
|
34
33
|
function PostTitle( _, forwardedRef ) {
|
|
35
34
|
const { placeholder, hasFixedToolbar } = useSelect( ( select ) => {
|
|
36
|
-
const { getEditedPostAttribute } = select( editorStore );
|
|
37
35
|
const { getSettings } = select( blockEditorStore );
|
|
38
36
|
const { titlePlaceholder, hasFixedToolbar: _hasFixedToolbar } =
|
|
39
37
|
getSettings();
|
|
40
38
|
|
|
41
39
|
return {
|
|
42
|
-
title: getEditedPostAttribute( 'title' ),
|
|
43
40
|
placeholder: titlePlaceholder,
|
|
44
41
|
hasFixedToolbar: _hasFixedToolbar,
|
|
45
42
|
};
|
|
@@ -175,7 +175,7 @@ class PostTitle extends Component {
|
|
|
175
175
|
fontSize={ 24 }
|
|
176
176
|
lineHeight={ 1 }
|
|
177
177
|
fontWeight={ 'bold' }
|
|
178
|
-
deleteEnter
|
|
178
|
+
deleteEnter
|
|
179
179
|
onChange={ ( value ) => {
|
|
180
180
|
this.props.onUpdate( value );
|
|
181
181
|
} }
|
|
@@ -184,7 +184,7 @@ class PostTitle extends Component {
|
|
|
184
184
|
value={ title }
|
|
185
185
|
onSelectionChange={ () => {} }
|
|
186
186
|
onEnter={ this.props.onEnterPress }
|
|
187
|
-
disableEditingMenu
|
|
187
|
+
disableEditingMenu
|
|
188
188
|
__unstableIsSelected={ this.props.isSelected }
|
|
189
189
|
__unstableOnCreateUndoLevel={ () => {} }
|
|
190
190
|
/>
|
|
@@ -23,6 +23,9 @@ import useBlockEditorSettings from './use-block-editor-settings';
|
|
|
23
23
|
import { unlock } from '../../lock-unlock';
|
|
24
24
|
import DisableNonPageContentBlocks from './disable-non-page-content-blocks';
|
|
25
25
|
import NavigationBlockEditingMode from './navigation-block-editing-mode';
|
|
26
|
+
import { useHideBlocksFromInserter } from './use-hide-blocks-from-inserter';
|
|
27
|
+
import useCommands from '../commands';
|
|
28
|
+
import BlockRemovalWarnings from '../block-removal-warnings';
|
|
26
29
|
|
|
27
30
|
const { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );
|
|
28
31
|
const { PatternsMenuItems } = unlock( editPatternsPrivateApis );
|
|
@@ -229,6 +232,11 @@ export const ExperimentalEditorProvider = withRegistryProvider(
|
|
|
229
232
|
setRenderingMode( settings.defaultRenderingMode ?? 'post-only' );
|
|
230
233
|
}, [ settings.defaultRenderingMode, setRenderingMode ] );
|
|
231
234
|
|
|
235
|
+
useHideBlocksFromInserter( post.type );
|
|
236
|
+
|
|
237
|
+
// Register the editor commands.
|
|
238
|
+
useCommands();
|
|
239
|
+
|
|
232
240
|
if ( ! isReady ) {
|
|
233
241
|
return null;
|
|
234
242
|
}
|
|
@@ -257,6 +265,7 @@ export const ExperimentalEditorProvider = withRegistryProvider(
|
|
|
257
265
|
{ type === 'wp_navigation' && (
|
|
258
266
|
<NavigationBlockEditingMode />
|
|
259
267
|
) }
|
|
268
|
+
<BlockRemovalWarnings />
|
|
260
269
|
</BlockEditorProviderComponent>
|
|
261
270
|
</BlockContextProvider>
|
|
262
271
|
</EntityProvider>
|