@wordpress/edit-post 7.3.6 → 7.5.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/device-preview/index.js +3 -7
- package/build/components/device-preview/index.js.map +1 -1
- package/build/components/header/fullscreen-mode-close/index.js +3 -3
- package/build/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build/components/header/index.js +1 -8
- package/build/components/header/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +17 -12
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +48 -3
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/featured-image/index.js +3 -7
- package/build/components/sidebar/featured-image/index.js.map +1 -1
- package/build/components/sidebar/page-attributes/index.js +3 -7
- package/build/components/sidebar/page-attributes/index.js.map +1 -1
- package/build/editor.js +1 -1
- package/build/editor.js.map +1 -1
- package/build-module/components/device-preview/index.js +3 -6
- package/build-module/components/device-preview/index.js.map +1 -1
- package/build-module/components/header/fullscreen-mode-close/index.js +3 -2
- package/build-module/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build-module/components/header/index.js +1 -7
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +17 -12
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +46 -4
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/featured-image/index.js +3 -6
- package/build-module/components/sidebar/featured-image/index.js.map +1 -1
- package/build-module/components/sidebar/page-attributes/index.js +3 -6
- package/build-module/components/sidebar/page-attributes/index.js.map +1 -1
- package/build-module/editor.js +1 -1
- package/build-module/editor.js.map +1 -1
- package/package.json +30 -29
- package/src/components/device-preview/index.js +1 -6
- package/src/components/header/fullscreen-mode-close/index.js +1 -6
- package/src/components/header/index.js +1 -8
- package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +780 -778
- package/src/components/keyboard-shortcuts/index.js +19 -14
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +481 -477
- package/src/components/secondary-sidebar/list-view-sidebar.js +58 -1
- package/src/components/sidebar/featured-image/index.js +3 -10
- package/src/components/sidebar/page-attributes/index.js +3 -10
- package/src/editor.js +1 -0
|
@@ -14,10 +14,12 @@ import {
|
|
|
14
14
|
useMergeRefs,
|
|
15
15
|
} from '@wordpress/compose';
|
|
16
16
|
import { useDispatch } from '@wordpress/data';
|
|
17
|
+
import { focus } from '@wordpress/dom';
|
|
18
|
+
import { useRef, useState } from '@wordpress/element';
|
|
17
19
|
import { __ } from '@wordpress/i18n';
|
|
18
20
|
import { closeSmall } from '@wordpress/icons';
|
|
21
|
+
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
19
22
|
import { ESCAPE } from '@wordpress/keycodes';
|
|
20
|
-
import { useState } from '@wordpress/element';
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
25
|
* Internal dependencies
|
|
@@ -31,6 +33,7 @@ export default function ListViewSidebar() {
|
|
|
31
33
|
const focusOnMountRef = useFocusOnMount( 'firstElement' );
|
|
32
34
|
const headerFocusReturnRef = useFocusReturn();
|
|
33
35
|
const contentFocusReturnRef = useFocusReturn();
|
|
36
|
+
|
|
34
37
|
function closeOnEscape( event ) {
|
|
35
38
|
if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
|
|
36
39
|
event.preventDefault();
|
|
@@ -40,12 +43,63 @@ export default function ListViewSidebar() {
|
|
|
40
43
|
|
|
41
44
|
const [ tab, setTab ] = useState( 'list-view' );
|
|
42
45
|
|
|
46
|
+
// This ref refers to the sidebar as a whole.
|
|
47
|
+
const sidebarRef = useRef();
|
|
48
|
+
// This ref refers to the list view tab button.
|
|
49
|
+
const listViewTabRef = useRef();
|
|
50
|
+
// This ref refers to the outline tab button.
|
|
51
|
+
const outlineTabRef = useRef();
|
|
52
|
+
// This ref refers to the list view application area.
|
|
53
|
+
const listViewRef = useRef();
|
|
54
|
+
|
|
55
|
+
/*
|
|
56
|
+
* Callback function to handle list view or outline focus.
|
|
57
|
+
*
|
|
58
|
+
* @param {string} currentTab The current tab. Either list view or outline.
|
|
59
|
+
*
|
|
60
|
+
* @return void
|
|
61
|
+
*/
|
|
62
|
+
function handleSidebarFocus( currentTab ) {
|
|
63
|
+
// List view tab is selected.
|
|
64
|
+
if ( currentTab === 'list-view' ) {
|
|
65
|
+
// Either focus the list view or the list view tab button. Must have a fallback because the list view does not render when there are no blocks.
|
|
66
|
+
const listViewApplicationFocus = focus.tabbable.find(
|
|
67
|
+
listViewRef.current
|
|
68
|
+
)[ 0 ];
|
|
69
|
+
const listViewFocusArea = sidebarRef.current.contains(
|
|
70
|
+
listViewApplicationFocus
|
|
71
|
+
)
|
|
72
|
+
? listViewApplicationFocus
|
|
73
|
+
: listViewTabRef.current;
|
|
74
|
+
listViewFocusArea.focus();
|
|
75
|
+
// Outline tab is selected.
|
|
76
|
+
} else {
|
|
77
|
+
outlineTabRef.current.focus();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// This only fires when the sidebar is open because of the conditional rendering. It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.
|
|
82
|
+
useShortcut( 'core/edit-post/toggle-list-view', () => {
|
|
83
|
+
// If the sidebar has focus, it is safe to close.
|
|
84
|
+
if (
|
|
85
|
+
sidebarRef.current.contains(
|
|
86
|
+
sidebarRef.current.ownerDocument.activeElement
|
|
87
|
+
)
|
|
88
|
+
) {
|
|
89
|
+
setIsListViewOpened( false );
|
|
90
|
+
// If the list view or outline does not have focus, focus should be moved to it.
|
|
91
|
+
} else {
|
|
92
|
+
handleSidebarFocus( tab );
|
|
93
|
+
}
|
|
94
|
+
} );
|
|
95
|
+
|
|
43
96
|
return (
|
|
44
97
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
45
98
|
<div
|
|
46
99
|
aria-label={ __( 'Document Overview' ) }
|
|
47
100
|
className="edit-post-editor__document-overview-panel"
|
|
48
101
|
onKeyDown={ closeOnEscape }
|
|
102
|
+
ref={ sidebarRef }
|
|
49
103
|
>
|
|
50
104
|
<div
|
|
51
105
|
className="edit-post-editor__document-overview-panel-header components-panel__header edit-post-sidebar__panel-tabs"
|
|
@@ -59,6 +113,7 @@ export default function ListViewSidebar() {
|
|
|
59
113
|
<ul>
|
|
60
114
|
<li>
|
|
61
115
|
<Button
|
|
116
|
+
ref={ listViewTabRef }
|
|
62
117
|
onClick={ () => {
|
|
63
118
|
setTab( 'list-view' );
|
|
64
119
|
} }
|
|
@@ -73,6 +128,7 @@ export default function ListViewSidebar() {
|
|
|
73
128
|
</li>
|
|
74
129
|
<li>
|
|
75
130
|
<Button
|
|
131
|
+
ref={ outlineTabRef }
|
|
76
132
|
onClick={ () => {
|
|
77
133
|
setTab( 'outline' );
|
|
78
134
|
} }
|
|
@@ -91,6 +147,7 @@ export default function ListViewSidebar() {
|
|
|
91
147
|
ref={ useMergeRefs( [
|
|
92
148
|
contentFocusReturnRef,
|
|
93
149
|
focusOnMountRef,
|
|
150
|
+
listViewRef,
|
|
94
151
|
] ) }
|
|
95
152
|
className="edit-post-editor__list-view-container"
|
|
96
153
|
>
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { get } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -35,11 +30,9 @@ function FeaturedImage( { isEnabled, isOpened, postType, onTogglePanel } ) {
|
|
|
35
30
|
return (
|
|
36
31
|
<PostFeaturedImageCheck>
|
|
37
32
|
<PanelBody
|
|
38
|
-
title={
|
|
39
|
-
postType
|
|
40
|
-
|
|
41
|
-
__( 'Featured image' )
|
|
42
|
-
) }
|
|
33
|
+
title={
|
|
34
|
+
postType?.labels?.featured_image ?? __( 'Featured image' )
|
|
35
|
+
}
|
|
43
36
|
opened={ isOpened }
|
|
44
37
|
onToggle={ onTogglePanel }
|
|
45
38
|
>
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { get } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -52,11 +47,9 @@ export function PageAttributes() {
|
|
|
52
47
|
return (
|
|
53
48
|
<PageAttributesCheck>
|
|
54
49
|
<PanelBody
|
|
55
|
-
title={
|
|
56
|
-
postType
|
|
57
|
-
|
|
58
|
-
__( 'Page attributes' )
|
|
59
|
-
) }
|
|
50
|
+
title={
|
|
51
|
+
postType?.labels?.attributes ?? __( 'Page attributes' )
|
|
52
|
+
}
|
|
60
53
|
opened={ isOpened }
|
|
61
54
|
onToggle={ onTogglePanel }
|
|
62
55
|
>
|