@wordpress/edit-post 5.0.24 → 6.0.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 +12 -0
- package/LICENSE.md +1 -1
- package/README.md +10 -4
- package/build/components/block-manager/category.js +42 -47
- package/build/components/block-manager/category.js.map +1 -1
- package/build/components/block-manager/index.js +18 -1
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/header/index.native.js +4 -6
- package/build/components/header/index.native.js.map +1 -1
- package/build/components/header/plugin-more-menu-item/index.js +1 -1
- package/build/components/header/plugin-more-menu-item/index.js.map +1 -1
- package/build/components/layout/index.js +17 -2
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js +3 -3
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/preferences-modal/index.js +27 -9
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +13 -3
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +7 -5
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/post-author/index.js +3 -1
- package/build/components/sidebar/post-author/index.js.map +1 -1
- package/build/components/sidebar/template/actions.js +5 -2
- package/build/components/sidebar/template/actions.js.map +1 -1
- package/build/components/sidebar/template/index.js +25 -13
- package/build/components/sidebar/template/index.js.map +1 -1
- package/build/components/visual-editor/index.js +14 -6
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/components/welcome-guide/template.js +1 -1
- package/build/components/welcome-guide/template.js.map +1 -1
- package/build/editor.js +6 -11
- package/build/editor.js.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/index.native.js +3 -9
- package/build/index.native.js.map +1 -1
- package/build/store/selectors.js +3 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-manager/category.js +44 -48
- package/build-module/components/block-manager/category.js.map +1 -1
- package/build-module/components/block-manager/index.js +17 -2
- package/build-module/components/block-manager/index.js.map +1 -1
- package/build-module/components/header/index.native.js +4 -4
- package/build-module/components/header/index.native.js.map +1 -1
- package/build-module/components/header/plugin-more-menu-item/index.js +1 -1
- package/build-module/components/header/plugin-more-menu-item/index.js.map +1 -1
- package/build-module/components/layout/index.js +18 -4
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js +4 -2
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +27 -9
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +14 -4
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +7 -5
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/post-author/index.js +3 -1
- package/build-module/components/sidebar/post-author/index.js.map +1 -1
- package/build-module/components/sidebar/template/actions.js +5 -2
- package/build-module/components/sidebar/template/actions.js.map +1 -1
- package/build-module/components/sidebar/template/index.js +26 -14
- package/build-module/components/sidebar/template/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +15 -7
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/components/welcome-guide/template.js +1 -1
- package/build-module/components/welcome-guide/template.js.map +1 -1
- package/build-module/editor.js +7 -10
- package/build-module/editor.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +2 -9
- package/build-module/index.native.js.map +1 -1
- package/build-module/store/selectors.js +3 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +25 -16
- package/build-style/style.css +25 -16
- package/package.json +26 -29
- package/src/components/block-manager/category.js +41 -48
- package/src/components/block-manager/index.js +18 -1
- package/src/components/header/index.native.js +10 -4
- package/src/components/header/plugin-more-menu-item/index.js +1 -1
- package/src/components/header/template-title/style.scss +1 -1
- package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +2 -2
- package/src/components/layout/index.js +18 -3
- package/src/components/layout/index.native.js +2 -5
- package/src/components/preferences-modal/index.js +23 -12
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +7 -13
- package/src/components/secondary-sidebar/inserter-sidebar.js +14 -3
- package/src/components/secondary-sidebar/list-view-sidebar.js +12 -5
- package/src/components/secondary-sidebar/style.scss +0 -4
- package/src/components/sidebar/plugin-post-publish-panel/test/__snapshots__/index.js.snap +1 -1
- package/src/components/sidebar/plugin-pre-publish-panel/test/__snapshots__/index.js.snap +1 -1
- package/src/components/sidebar/post-author/index.js +1 -1
- package/src/components/sidebar/template/actions.js +12 -7
- package/src/components/sidebar/template/index.js +56 -31
- package/src/components/sidebar/template/style.scss +8 -0
- package/src/components/visual-editor/index.js +16 -6
- package/src/components/visual-editor/style.scss +1 -0
- package/src/components/welcome-guide/style.scss +8 -1
- package/src/components/welcome-guide/template.js +1 -1
- package/src/editor.js +22 -26
- package/src/index.js +1 -1
- package/src/index.native.js +1 -10
- package/src/store/selectors.js +1 -1
- package/src/style.scss +1 -2
- package/src/test/editor.native.js +4 -4
- package/build/components/edit-post-settings/index.js +0 -16
- package/build/components/edit-post-settings/index.js.map +0 -1
- package/build/prevent-event-discovery.js +0 -24
- package/build/prevent-event-discovery.js.map +0 -1
- package/build-module/components/edit-post-settings/index.js +0 -7
- package/build-module/components/edit-post-settings/index.js.map +0 -1
- package/build-module/prevent-event-discovery.js +0 -17
- package/build-module/prevent-event-discovery.js.map +0 -1
- package/src/components/edit-post-settings/index.js +0 -7
- package/src/prevent-event-discovery.js +0 -21
|
@@ -6,36 +6,59 @@ import { includes, map, without } from 'lodash';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { useMemo, useCallback } from '@wordpress/element';
|
|
10
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
11
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
12
12
|
import { CheckboxControl } from '@wordpress/components';
|
|
13
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Internal dependencies
|
|
16
17
|
*/
|
|
17
18
|
import BlockTypesChecklist from './checklist';
|
|
18
|
-
import EditPostSettings from '../edit-post-settings';
|
|
19
19
|
import { store as editPostStore } from '../../store';
|
|
20
20
|
|
|
21
|
-
function BlockManagerCategory( {
|
|
22
|
-
instanceId
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
function BlockManagerCategory( { title, blockTypes } ) {
|
|
22
|
+
const instanceId = useInstanceId( BlockManagerCategory );
|
|
23
|
+
const { defaultAllowedBlockTypes, hiddenBlockTypes } = useSelect(
|
|
24
|
+
( select ) => {
|
|
25
|
+
const { getEditorSettings } = select( editorStore );
|
|
26
|
+
const { getPreference } = select( editPostStore );
|
|
27
|
+
return {
|
|
28
|
+
defaultAllowedBlockTypes: getEditorSettings()
|
|
29
|
+
.defaultAllowedBlockTypes,
|
|
30
|
+
hiddenBlockTypes: getPreference( 'hiddenBlockTypes' ),
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
[]
|
|
34
|
+
);
|
|
31
35
|
const filteredBlockTypes = useMemo( () => {
|
|
32
|
-
if (
|
|
36
|
+
if ( defaultAllowedBlockTypes === true ) {
|
|
33
37
|
return blockTypes;
|
|
34
38
|
}
|
|
35
39
|
return blockTypes.filter( ( { name } ) => {
|
|
36
|
-
return includes(
|
|
40
|
+
return includes( defaultAllowedBlockTypes || [], name );
|
|
37
41
|
} );
|
|
38
|
-
}, [
|
|
42
|
+
}, [ defaultAllowedBlockTypes, blockTypes ] );
|
|
43
|
+
const { showBlockTypes, hideBlockTypes } = useDispatch( editPostStore );
|
|
44
|
+
const toggleVisible = useCallback( ( blockName, nextIsChecked ) => {
|
|
45
|
+
if ( nextIsChecked ) {
|
|
46
|
+
showBlockTypes( blockName );
|
|
47
|
+
} else {
|
|
48
|
+
hideBlockTypes( blockName );
|
|
49
|
+
}
|
|
50
|
+
}, [] );
|
|
51
|
+
const toggleAllVisible = useCallback(
|
|
52
|
+
( nextIsChecked ) => {
|
|
53
|
+
const blockNames = map( blockTypes, 'name' );
|
|
54
|
+
if ( nextIsChecked ) {
|
|
55
|
+
showBlockTypes( blockNames );
|
|
56
|
+
} else {
|
|
57
|
+
hideBlockTypes( blockNames );
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
[ blockTypes ]
|
|
61
|
+
);
|
|
39
62
|
|
|
40
63
|
if ( ! filteredBlockTypes.length ) {
|
|
41
64
|
return null;
|
|
@@ -81,34 +104,4 @@ function BlockManagerCategory( {
|
|
|
81
104
|
);
|
|
82
105
|
}
|
|
83
106
|
|
|
84
|
-
export default
|
|
85
|
-
withInstanceId,
|
|
86
|
-
withSelect( ( select ) => {
|
|
87
|
-
const { getPreference } = select( editPostStore );
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
hiddenBlockTypes: getPreference( 'hiddenBlockTypes' ),
|
|
91
|
-
};
|
|
92
|
-
} ),
|
|
93
|
-
withDispatch( ( dispatch, ownProps ) => {
|
|
94
|
-
const { showBlockTypes, hideBlockTypes } = dispatch( editPostStore );
|
|
95
|
-
|
|
96
|
-
return {
|
|
97
|
-
toggleVisible( blockName, nextIsChecked ) {
|
|
98
|
-
if ( nextIsChecked ) {
|
|
99
|
-
showBlockTypes( blockName );
|
|
100
|
-
} else {
|
|
101
|
-
hideBlockTypes( blockName );
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
toggleAllVisible( nextIsChecked ) {
|
|
105
|
-
const blockNames = map( ownProps.blockTypes, 'name' );
|
|
106
|
-
if ( nextIsChecked ) {
|
|
107
|
-
showBlockTypes( blockNames );
|
|
108
|
-
} else {
|
|
109
|
-
hideBlockTypes( blockNames );
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
} ),
|
|
114
|
-
] )( BlockManagerCategory );
|
|
107
|
+
export default BlockManagerCategory;
|
|
@@ -10,7 +10,9 @@ import { store as blocksStore } from '@wordpress/blocks';
|
|
|
10
10
|
import { withSelect } from '@wordpress/data';
|
|
11
11
|
import { SearchControl } from '@wordpress/components';
|
|
12
12
|
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
13
|
-
import { useState } from '@wordpress/element';
|
|
13
|
+
import { useEffect, useState } from '@wordpress/element';
|
|
14
|
+
import { useDebounce } from '@wordpress/compose';
|
|
15
|
+
import { speak } from '@wordpress/a11y';
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Internal dependencies
|
|
@@ -25,6 +27,7 @@ function BlockManager( {
|
|
|
25
27
|
isMatchingSearchTerm,
|
|
26
28
|
numberOfHiddenBlocks,
|
|
27
29
|
} ) {
|
|
30
|
+
const debouncedSpeak = useDebounce( speak, 500 );
|
|
28
31
|
const [ search, setSearch ] = useState( '' );
|
|
29
32
|
|
|
30
33
|
// Filtering occurs here (as opposed to `withSelect`) to avoid
|
|
@@ -38,6 +41,20 @@ function BlockManager( {
|
|
|
38
41
|
includes( blockType.parent, 'core/post-content' ) )
|
|
39
42
|
);
|
|
40
43
|
|
|
44
|
+
// Announce search results on change
|
|
45
|
+
useEffect( () => {
|
|
46
|
+
if ( ! search ) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const count = blockTypes.length;
|
|
50
|
+
const resultsFoundMessage = sprintf(
|
|
51
|
+
/* translators: %d: number of results. */
|
|
52
|
+
_n( '%d result found.', '%d results found.', count ),
|
|
53
|
+
count
|
|
54
|
+
);
|
|
55
|
+
debouncedSpeak( resultsFoundMessage );
|
|
56
|
+
}, [ blockTypes.length, search, debouncedSpeak ] );
|
|
57
|
+
|
|
41
58
|
return (
|
|
42
59
|
<div className="edit-post-block-manager__content">
|
|
43
60
|
{ !! numberOfHiddenBlocks && (
|
|
@@ -27,13 +27,19 @@ export default class Header extends Component {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
componentDidMount() {
|
|
30
|
-
Keyboard.addListener(
|
|
31
|
-
|
|
30
|
+
this.keyboardShowSubscription = Keyboard.addListener(
|
|
31
|
+
'keyboardDidShow',
|
|
32
|
+
this.keyboardDidShow
|
|
33
|
+
);
|
|
34
|
+
this.keyboardHideSubscription = Keyboard.addListener(
|
|
35
|
+
'keyboardDidHide',
|
|
36
|
+
this.keyboardDidHide
|
|
37
|
+
);
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
componentWillUnmount() {
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
this.keyboardShowSubscription.remove();
|
|
42
|
+
this.keyboardHideSubscription.remove();
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
keyboardDidShow() {
|
|
@@ -13,7 +13,7 @@ import { withPluginContext } from '@wordpress/plugins';
|
|
|
13
13
|
* @param {string} [props.href] When `href` is provided then the menu item is represented as an anchor rather than button. It corresponds to the `href` attribute of the anchor.
|
|
14
14
|
* @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.
|
|
15
15
|
* @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item.
|
|
16
|
-
* @param {...*} [props.other] Any additional props are passed through to the underlying [MenuItem](/packages/components/src/menu-item/README.md) component.
|
|
16
|
+
* @param {...*} [props.other] Any additional props are passed through to the underlying [MenuItem](https://github.com/WordPress/gutenberg/tree/HEAD/packages/components/src/menu-item/README.md) component.
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* ```js
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`KeyboardShortcutHelpModal should match snapshot when the modal is active 1`] = `
|
|
4
|
-
<Modal
|
|
4
|
+
<ForwardRef(Modal)
|
|
5
5
|
className="edit-post-keyboard-shortcut-help-modal"
|
|
6
6
|
closeLabel="Close"
|
|
7
7
|
onRequestClose={[Function]}
|
|
@@ -80,7 +80,7 @@ exports[`KeyboardShortcutHelpModal should match snapshot when the modal is activ
|
|
|
80
80
|
}
|
|
81
81
|
title="Text formatting"
|
|
82
82
|
/>
|
|
83
|
-
</Modal>
|
|
83
|
+
</ForwardRef(Modal)>
|
|
84
84
|
`;
|
|
85
85
|
|
|
86
86
|
exports[`KeyboardShortcutHelpModal should match snapshot when the modal is not active 1`] = `""`;
|
|
@@ -16,11 +16,11 @@ import {
|
|
|
16
16
|
store as editorStore,
|
|
17
17
|
} from '@wordpress/editor';
|
|
18
18
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
19
|
-
import { BlockBreadcrumb } from '@wordpress/block-editor';
|
|
19
|
+
import { BlockBreadcrumb, BlockStyles } from '@wordpress/block-editor';
|
|
20
20
|
import { Button, ScrollLock, Popover } from '@wordpress/components';
|
|
21
21
|
import { useViewportMatch } from '@wordpress/compose';
|
|
22
22
|
import { PluginArea } from '@wordpress/plugins';
|
|
23
|
-
import { __, _x } from '@wordpress/i18n';
|
|
23
|
+
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
24
24
|
import {
|
|
25
25
|
ComplementaryArea,
|
|
26
26
|
FullscreenMode,
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
} from '@wordpress/interface';
|
|
30
30
|
import { useState, useEffect, useCallback } from '@wordpress/element';
|
|
31
31
|
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
32
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* Internal dependencies
|
|
@@ -70,6 +71,7 @@ function Layout( { styles } ) {
|
|
|
70
71
|
closeGeneralSidebar,
|
|
71
72
|
setIsInserterOpened,
|
|
72
73
|
} = useDispatch( editPostStore );
|
|
74
|
+
const { createErrorNotice } = useDispatch( noticesStore );
|
|
73
75
|
const {
|
|
74
76
|
mode,
|
|
75
77
|
isFullscreenActive,
|
|
@@ -178,6 +180,18 @@ function Layout( { styles } ) {
|
|
|
178
180
|
return null;
|
|
179
181
|
};
|
|
180
182
|
|
|
183
|
+
function onPluginAreaError( name ) {
|
|
184
|
+
createErrorNotice(
|
|
185
|
+
sprintf(
|
|
186
|
+
/* translators: %s: plugin name */
|
|
187
|
+
__(
|
|
188
|
+
'The "%s" plugin has encountered an error and cannot be rendered.'
|
|
189
|
+
),
|
|
190
|
+
name
|
|
191
|
+
)
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
181
195
|
return (
|
|
182
196
|
<>
|
|
183
197
|
<FullscreenMode isActive={ isFullscreenActive } />
|
|
@@ -239,6 +253,7 @@ function Layout( { styles } ) {
|
|
|
239
253
|
{ isMobileViewport && sidebarIsOpened && (
|
|
240
254
|
<ScrollLock />
|
|
241
255
|
) }
|
|
256
|
+
<BlockStyles.Slot scope="core/block-inspector" />
|
|
242
257
|
</>
|
|
243
258
|
}
|
|
244
259
|
footer={
|
|
@@ -272,7 +287,7 @@ function Layout( { styles } ) {
|
|
|
272
287
|
<KeyboardShortcutHelpModal />
|
|
273
288
|
<WelcomeGuide />
|
|
274
289
|
<Popover.Slot />
|
|
275
|
-
<PluginArea />
|
|
290
|
+
<PluginArea onError={ onPluginAreaError } />
|
|
276
291
|
</>
|
|
277
292
|
);
|
|
278
293
|
}
|
|
@@ -53,17 +53,14 @@ class Layout extends Component {
|
|
|
53
53
|
|
|
54
54
|
componentDidMount() {
|
|
55
55
|
this._isMounted = true;
|
|
56
|
-
SafeArea.addEventListener(
|
|
56
|
+
this.safeAreaSubscription = SafeArea.addEventListener(
|
|
57
57
|
'safeAreaInsetsForRootViewDidChange',
|
|
58
58
|
this.onSafeAreaInsetsUpdate
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
componentWillUnmount() {
|
|
63
|
-
|
|
64
|
-
'safeAreaInsetsForRootViewDidChange',
|
|
65
|
-
this.onSafeAreaInsetsUpdate
|
|
66
|
-
);
|
|
63
|
+
this.safeAreaSubscription?.remove();
|
|
67
64
|
this._isMounted = false;
|
|
68
65
|
}
|
|
69
66
|
|
|
@@ -55,21 +55,34 @@ import BlockManager from '../block-manager';
|
|
|
55
55
|
const MODAL_NAME = 'edit-post/preferences';
|
|
56
56
|
const PREFERENCES_MENU = 'preferences-menu';
|
|
57
57
|
|
|
58
|
-
function NavigationButton( {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
58
|
+
function NavigationButton( { as: Tag = Button, path, ...props } ) {
|
|
59
|
+
const { goTo } = useNavigator();
|
|
60
|
+
|
|
61
|
+
const dataAttrName = 'data-navigator-focusable-id';
|
|
62
|
+
const dataAttrValue = path;
|
|
63
|
+
|
|
64
|
+
const dataAttrCssSelector = `[${ dataAttrName }="${ dataAttrValue }"]`;
|
|
65
|
+
|
|
66
|
+
const tagProps = {
|
|
67
|
+
...props,
|
|
68
|
+
[ dataAttrName ]: dataAttrValue,
|
|
69
|
+
};
|
|
70
|
+
|
|
65
71
|
return (
|
|
66
72
|
<Tag
|
|
67
|
-
onClick={ () =>
|
|
68
|
-
|
|
73
|
+
onClick={ () =>
|
|
74
|
+
goTo( path, { focusTargetSelector: dataAttrCssSelector } )
|
|
75
|
+
}
|
|
76
|
+
{ ...tagProps }
|
|
69
77
|
/>
|
|
70
78
|
);
|
|
71
79
|
}
|
|
72
80
|
|
|
81
|
+
function NavigationBackButton( { as: Tag = Button, ...props } ) {
|
|
82
|
+
const { goBack } = useNavigator();
|
|
83
|
+
return <Tag onClick={ goBack } { ...props } />;
|
|
84
|
+
}
|
|
85
|
+
|
|
73
86
|
export default function PreferencesModal() {
|
|
74
87
|
const isLargeViewport = useViewportMatch( 'medium' );
|
|
75
88
|
const { closeModal } = useDispatch( editPostStore );
|
|
@@ -376,12 +389,10 @@ export default function PreferencesModal() {
|
|
|
376
389
|
size="small"
|
|
377
390
|
gap="6"
|
|
378
391
|
>
|
|
379
|
-
<
|
|
380
|
-
path="/"
|
|
392
|
+
<NavigationBackButton
|
|
381
393
|
icon={
|
|
382
394
|
isRTL() ? chevronRight : chevronLeft
|
|
383
395
|
}
|
|
384
|
-
isBack
|
|
385
396
|
aria-label={ __(
|
|
386
397
|
'Navigate to the previous view'
|
|
387
398
|
) }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`PreferencesModal should match snapshot when the modal is active large viewports 1`] = `
|
|
4
|
-
<Modal
|
|
4
|
+
<ForwardRef(Modal)
|
|
5
5
|
className="edit-post-preferences-modal"
|
|
6
6
|
closeLabel="Close"
|
|
7
7
|
onRequestClose={[Function]}
|
|
@@ -30,11 +30,11 @@ exports[`PreferencesModal should match snapshot when the modal is active large v
|
|
|
30
30
|
>
|
|
31
31
|
<Component />
|
|
32
32
|
</TabPanel>
|
|
33
|
-
</Modal>
|
|
33
|
+
</ForwardRef(Modal)>
|
|
34
34
|
`;
|
|
35
35
|
|
|
36
36
|
exports[`PreferencesModal should match snapshot when the modal is active small viewports 1`] = `
|
|
37
|
-
<Modal
|
|
37
|
+
<ForwardRef(Modal)
|
|
38
38
|
className="edit-post-preferences-modal"
|
|
39
39
|
closeLabel="Close"
|
|
40
40
|
onRequestClose={[Function]}
|
|
@@ -187,7 +187,7 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
187
187
|
justify="left"
|
|
188
188
|
size="small"
|
|
189
189
|
>
|
|
190
|
-
<
|
|
190
|
+
<NavigationBackButton
|
|
191
191
|
aria-label="Navigate to the previous view"
|
|
192
192
|
icon={
|
|
193
193
|
<SVG
|
|
@@ -199,8 +199,6 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
199
199
|
/>
|
|
200
200
|
</SVG>
|
|
201
201
|
}
|
|
202
|
-
isBack={true}
|
|
203
|
-
path="/"
|
|
204
202
|
/>
|
|
205
203
|
<Text
|
|
206
204
|
size="16"
|
|
@@ -256,7 +254,7 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
256
254
|
justify="left"
|
|
257
255
|
size="small"
|
|
258
256
|
>
|
|
259
|
-
<
|
|
257
|
+
<NavigationBackButton
|
|
260
258
|
aria-label="Navigate to the previous view"
|
|
261
259
|
icon={
|
|
262
260
|
<SVG
|
|
@@ -268,8 +266,6 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
268
266
|
/>
|
|
269
267
|
</SVG>
|
|
270
268
|
}
|
|
271
|
-
isBack={true}
|
|
272
|
-
path="/"
|
|
273
269
|
/>
|
|
274
270
|
<Text
|
|
275
271
|
size="16"
|
|
@@ -316,7 +312,7 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
316
312
|
justify="left"
|
|
317
313
|
size="small"
|
|
318
314
|
>
|
|
319
|
-
<
|
|
315
|
+
<NavigationBackButton
|
|
320
316
|
aria-label="Navigate to the previous view"
|
|
321
317
|
icon={
|
|
322
318
|
<SVG
|
|
@@ -328,8 +324,6 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
328
324
|
/>
|
|
329
325
|
</SVG>
|
|
330
326
|
}
|
|
331
|
-
isBack={true}
|
|
332
|
-
path="/"
|
|
333
327
|
/>
|
|
334
328
|
<Text
|
|
335
329
|
size="16"
|
|
@@ -386,5 +380,5 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
386
380
|
</Card>
|
|
387
381
|
</NavigatorScreen>
|
|
388
382
|
</NavigatorProvider>
|
|
389
|
-
</Modal>
|
|
383
|
+
</ForwardRef(Modal)>
|
|
390
384
|
`;
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
5
|
-
import { Button } from '@wordpress/components';
|
|
5
|
+
import { Button, VisuallyHidden } from '@wordpress/components';
|
|
6
6
|
import { __experimentalLibrary as Library } from '@wordpress/block-editor';
|
|
7
7
|
import { close } from '@wordpress/icons';
|
|
8
8
|
import {
|
|
9
9
|
useViewportMatch,
|
|
10
10
|
__experimentalUseDialog as useDialog,
|
|
11
11
|
} from '@wordpress/compose';
|
|
12
|
+
import { __ } from '@wordpress/i18n';
|
|
13
|
+
import { useEffect, useRef } from '@wordpress/element';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Internal dependencies
|
|
@@ -28,22 +30,30 @@ export default function InserterSidebar() {
|
|
|
28
30
|
const { setIsInserterOpened } = useDispatch( editPostStore );
|
|
29
31
|
|
|
30
32
|
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
33
|
+
const TagName = ! isMobileViewport ? VisuallyHidden : 'div';
|
|
31
34
|
const [ inserterDialogRef, inserterDialogProps ] = useDialog( {
|
|
32
35
|
onClose: () => setIsInserterOpened( false ),
|
|
36
|
+
focusOnMount: null,
|
|
33
37
|
} );
|
|
34
38
|
|
|
39
|
+
const libraryRef = useRef();
|
|
40
|
+
useEffect( () => {
|
|
41
|
+
libraryRef.current.focusSearch();
|
|
42
|
+
}, [] );
|
|
43
|
+
|
|
35
44
|
return (
|
|
36
45
|
<div
|
|
37
46
|
ref={ inserterDialogRef }
|
|
38
47
|
{ ...inserterDialogProps }
|
|
39
48
|
className="edit-post-editor__inserter-panel"
|
|
40
49
|
>
|
|
41
|
-
<
|
|
50
|
+
<TagName className="edit-post-editor__inserter-panel-header">
|
|
42
51
|
<Button
|
|
43
52
|
icon={ close }
|
|
53
|
+
label={ __( 'Close block inserter' ) }
|
|
44
54
|
onClick={ () => setIsInserterOpened( false ) }
|
|
45
55
|
/>
|
|
46
|
-
</
|
|
56
|
+
</TagName>
|
|
47
57
|
<div className="edit-post-editor__inserter-panel-content">
|
|
48
58
|
<Library
|
|
49
59
|
showMostUsedBlocks={ showMostUsedBlocks }
|
|
@@ -54,6 +64,7 @@ export default function InserterSidebar() {
|
|
|
54
64
|
insertionPoint.insertionIndex
|
|
55
65
|
}
|
|
56
66
|
__experimentalFilterValue={ insertionPoint.filterValue }
|
|
67
|
+
ref={ libraryRef }
|
|
57
68
|
/>
|
|
58
69
|
</div>
|
|
59
70
|
</div>
|
|
@@ -32,7 +32,8 @@ export default function ListViewSidebar() {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const focusOnMountRef = useFocusOnMount( 'firstElement' );
|
|
35
|
-
const
|
|
35
|
+
const headerFocusReturnRef = useFocusReturn();
|
|
36
|
+
const contentFocusReturnRef = useFocusReturn();
|
|
36
37
|
function closeOnEscape( event ) {
|
|
37
38
|
if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
|
|
38
39
|
event.preventDefault();
|
|
@@ -50,17 +51,23 @@ export default function ListViewSidebar() {
|
|
|
50
51
|
className="edit-post-editor__list-view-panel"
|
|
51
52
|
onKeyDown={ closeOnEscape }
|
|
52
53
|
>
|
|
53
|
-
<div
|
|
54
|
-
|
|
54
|
+
<div
|
|
55
|
+
className="edit-post-editor__list-view-panel-header"
|
|
56
|
+
ref={ headerFocusReturnRef }
|
|
57
|
+
>
|
|
58
|
+
<strong id={ labelId }>{ __( 'List View' ) }</strong>
|
|
55
59
|
<Button
|
|
56
60
|
icon={ closeSmall }
|
|
57
|
-
label={ __( 'Close
|
|
61
|
+
label={ __( 'Close List View Sidebar' ) }
|
|
58
62
|
onClick={ () => setIsListViewOpened( false ) }
|
|
59
63
|
/>
|
|
60
64
|
</div>
|
|
61
65
|
<div
|
|
62
66
|
className="edit-post-editor__list-view-panel-content"
|
|
63
|
-
ref={ useMergeRefs( [
|
|
67
|
+
ref={ useMergeRefs( [
|
|
68
|
+
contentFocusReturnRef,
|
|
69
|
+
focusOnMountRef,
|
|
70
|
+
] ) }
|
|
64
71
|
>
|
|
65
72
|
<ListView
|
|
66
73
|
onSelect={ selectEditorBlock }
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`PluginPostPublishPanel renders fill properly 1`] = `"<div class=\\"components-panel__body my-plugin-post-publish-panel is-opened\\"><h2 class=\\"components-panel__body-title\\"><button type=\\"button\\" aria-expanded=\\"true\\" class=\\"components-button components-panel__body-toggle\\"><span aria-hidden=\\"true\\"><svg width=\\"24\\" height=\\"24\\" viewBox=\\"0 0 24 24\\" xmlns=\\"http://www.w3.org/2000/svg\\" class=\\"components-panel__arrow\\"
|
|
3
|
+
exports[`PluginPostPublishPanel renders fill properly 1`] = `"<div class=\\"components-panel__body my-plugin-post-publish-panel is-opened\\"><h2 class=\\"components-panel__body-title\\"><button type=\\"button\\" aria-expanded=\\"true\\" class=\\"components-button components-panel__body-toggle\\"><span aria-hidden=\\"true\\"><svg width=\\"24\\" height=\\"24\\" viewBox=\\"0 0 24 24\\" xmlns=\\"http://www.w3.org/2000/svg\\" class=\\"components-panel__arrow\\" aria-hidden=\\"true\\" focusable=\\"false\\"><path d=\\"M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z\\"></path></svg></span>My panel title</button></h2>My panel content</div>"`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`PluginPrePublishPanel renders fill properly 1`] = `"<div class=\\"components-panel__body my-plugin-pre-publish-panel is-opened\\"><h2 class=\\"components-panel__body-title\\"><button type=\\"button\\" aria-expanded=\\"true\\" class=\\"components-button components-panel__body-toggle\\"><span aria-hidden=\\"true\\"><svg width=\\"24\\" height=\\"24\\" viewBox=\\"0 0 24 24\\" xmlns=\\"http://www.w3.org/2000/svg\\" class=\\"components-panel__arrow\\"
|
|
3
|
+
exports[`PluginPrePublishPanel renders fill properly 1`] = `"<div class=\\"components-panel__body my-plugin-pre-publish-panel is-opened\\"><h2 class=\\"components-panel__body-title\\"><button type=\\"button\\" aria-expanded=\\"true\\" class=\\"components-button components-panel__body-toggle\\"><span aria-hidden=\\"true\\"><svg width=\\"24\\" height=\\"24\\" viewBox=\\"0 0 24 24\\" xmlns=\\"http://www.w3.org/2000/svg\\" class=\\"components-panel__arrow\\" aria-hidden=\\"true\\" focusable=\\"false\\"><path d=\\"M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z\\"></path></svg></span>My panel title</button></h2>My panel content</div>"`;
|
|
4
4
|
q
|
|
@@ -25,7 +25,7 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
25
25
|
import { store as editPostStore } from '../../../store';
|
|
26
26
|
import { createBlock, serialize } from '@wordpress/blocks';
|
|
27
27
|
|
|
28
|
-
function PostTemplateActions() {
|
|
28
|
+
function PostTemplateActions( { isPostsPage } ) {
|
|
29
29
|
const [ isModalOpen, setIsModalOpen ] = useState( false );
|
|
30
30
|
const [ isBusy, setIsBusy ] = useState( false );
|
|
31
31
|
const [ title, setTitle ] = useState( '' );
|
|
@@ -128,12 +128,17 @@ function PostTemplateActions() {
|
|
|
128
128
|
{ __( 'Edit' ) }
|
|
129
129
|
</Button>
|
|
130
130
|
) }
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
131
|
+
{ ! isPostsPage && (
|
|
132
|
+
<Button
|
|
133
|
+
variant="link"
|
|
134
|
+
onClick={ () => setIsModalOpen( true ) }
|
|
135
|
+
>
|
|
136
|
+
{
|
|
137
|
+
/* translators: button to create a new template */
|
|
138
|
+
_x( 'New', 'action' )
|
|
139
|
+
}
|
|
140
|
+
</Button>
|
|
141
|
+
) }
|
|
137
142
|
</div>
|
|
138
143
|
{ isModalOpen && (
|
|
139
144
|
<Modal
|