@wordpress/edit-post 7.3.2 → 7.4.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/header/header-toolbar/index.js +6 -3
- package/build/components/header/header-toolbar/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-shortcut-help-modal/config.js +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +6 -1
- 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/editor.js +3 -3
- package/build/editor.js.map +1 -1
- package/build/{experiments.js → private-apis.js} +3 -3
- package/build/private-apis.js.map +1 -0
- package/build-module/components/header/header-toolbar/index.js +6 -3
- package/build-module/components/header/header-toolbar/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-shortcut-help-modal/config.js +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +6 -1
- 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/editor.js +4 -4
- package/build-module/editor.js.map +1 -1
- package/build-module/{experiments.js → private-apis.js} +2 -2
- package/build-module/private-apis.js.map +1 -0
- package/package.json +30 -29
- package/src/components/header/header-toolbar/index.js +6 -3
- package/src/components/header/index.js +1 -8
- package/src/components/keyboard-shortcut-help-modal/config.js +1 -1
- package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +780 -778
- package/src/components/keyboard-shortcuts/index.js +6 -3
- 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/editor.js +4 -3
- package/src/{experiments.js → private-apis.js} +1 -1
- package/build/experiments.js.map +0 -1
- package/build-module/experiments.js.map +0 -1
|
@@ -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
|
>
|
package/src/editor.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
ErrorBoundary,
|
|
8
8
|
PostLockedModal,
|
|
9
9
|
store as editorStore,
|
|
10
|
-
|
|
10
|
+
privateApis as editorPrivateApis,
|
|
11
11
|
} from '@wordpress/editor';
|
|
12
12
|
import { useMemo } from '@wordpress/element';
|
|
13
13
|
import { SlotFillProvider } from '@wordpress/components';
|
|
@@ -21,9 +21,9 @@ import { store as preferencesStore } from '@wordpress/preferences';
|
|
|
21
21
|
import Layout from './components/layout';
|
|
22
22
|
import EditorInitialization from './components/editor-initialization';
|
|
23
23
|
import { store as editPostStore } from './store';
|
|
24
|
-
import { unlock } from './
|
|
24
|
+
import { unlock } from './private-apis';
|
|
25
25
|
|
|
26
|
-
const { ExperimentalEditorProvider } = unlock(
|
|
26
|
+
const { ExperimentalEditorProvider } = unlock( editorPrivateApis );
|
|
27
27
|
|
|
28
28
|
function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
29
29
|
const {
|
|
@@ -139,6 +139,7 @@ function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
|
139
139
|
}, [
|
|
140
140
|
settings,
|
|
141
141
|
hasFixedToolbar,
|
|
142
|
+
hasInlineToolbar,
|
|
142
143
|
focusMode,
|
|
143
144
|
isDistractionFree,
|
|
144
145
|
hiddenBlockTypes,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/
|
|
4
|
+
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';
|
|
5
5
|
|
|
6
6
|
export const { lock, unlock } =
|
|
7
7
|
__dangerousOptInToUnstableAPIsOnlyForCoreModules(
|
package/build/experiments.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/experiments.js"],"names":["lock","unlock"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAM;AAAEA,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IACZ,mEACC,8GADD,EAEC,sBAFD,CADM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/experiments';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/edit-post'\n\t);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/experiments.js"],"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAT,QAAiE,wBAAjE;AAEA,OAAO,MAAM;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IACZF,gDAAgD,CAC/C,8GAD+C,EAE/C,sBAF+C,CAD1C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/experiments';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/edit-post'\n\t);\n"]}
|