@wordpress/edit-post 7.28.2 → 7.28.4
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/build/components/editor-initialization/listener-hooks.js +14 -6
- package/build/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build/components/header/index.js +6 -5
- package/build/components/header/index.js.map +1 -1
- package/build/components/layout/index.js +1 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/store/selectors.js +1 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/editor-initialization/listener-hooks.js +14 -6
- package/build-module/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build-module/components/header/index.js +6 -5
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/layout/index.js +1 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/index.js +3 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/selectors.js +1 -1
- package/build-module/store/selectors.js.map +1 -1
- package/package.json +15 -15
- package/src/components/editor-initialization/listener-hooks.js +16 -9
- package/src/components/editor-initialization/test/listener-hooks.js +40 -0
- package/src/components/header/index.js +9 -6
- package/src/components/layout/index.js +1 -1
- package/src/index.js +3 -0
- package/src/store/selectors.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-post",
|
|
3
|
-
"version": "7.28.
|
|
3
|
+
"version": "7.28.4",
|
|
4
4
|
"description": "Edit Post module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -29,34 +29,34 @@
|
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
30
|
"@wordpress/a11y": "^3.51.1",
|
|
31
31
|
"@wordpress/api-fetch": "^6.48.1",
|
|
32
|
-
"@wordpress/block-editor": "^12.19.
|
|
33
|
-
"@wordpress/block-library": "^8.28.
|
|
34
|
-
"@wordpress/blocks": "^12.28.
|
|
35
|
-
"@wordpress/commands": "^0.22.
|
|
36
|
-
"@wordpress/components": "^26.0.
|
|
32
|
+
"@wordpress/block-editor": "^12.19.4",
|
|
33
|
+
"@wordpress/block-library": "^8.28.4",
|
|
34
|
+
"@wordpress/blocks": "^12.28.4",
|
|
35
|
+
"@wordpress/commands": "^0.22.3",
|
|
36
|
+
"@wordpress/components": "^26.0.3",
|
|
37
37
|
"@wordpress/compose": "^6.28.1",
|
|
38
|
-
"@wordpress/core-commands": "^0.20.
|
|
39
|
-
"@wordpress/core-data": "^6.28.
|
|
38
|
+
"@wordpress/core-commands": "^0.20.4",
|
|
39
|
+
"@wordpress/core-data": "^6.28.4",
|
|
40
40
|
"@wordpress/data": "^9.21.1",
|
|
41
41
|
"@wordpress/deprecated": "^3.51.1",
|
|
42
42
|
"@wordpress/dom": "^3.51.1",
|
|
43
|
-
"@wordpress/editor": "^13.28.
|
|
43
|
+
"@wordpress/editor": "^13.28.4",
|
|
44
44
|
"@wordpress/element": "^5.28.1",
|
|
45
45
|
"@wordpress/hooks": "^3.51.1",
|
|
46
46
|
"@wordpress/i18n": "^4.51.1",
|
|
47
|
-
"@wordpress/icons": "^9.42.
|
|
48
|
-
"@wordpress/interface": "^5.28.
|
|
47
|
+
"@wordpress/icons": "^9.42.2",
|
|
48
|
+
"@wordpress/interface": "^5.28.3",
|
|
49
49
|
"@wordpress/keyboard-shortcuts": "^4.28.1",
|
|
50
50
|
"@wordpress/keycodes": "^3.51.1",
|
|
51
51
|
"@wordpress/media-utils": "^4.42.1",
|
|
52
52
|
"@wordpress/notices": "^4.19.1",
|
|
53
|
-
"@wordpress/plugins": "^6.19.
|
|
54
|
-
"@wordpress/preferences": "^3.28.
|
|
53
|
+
"@wordpress/plugins": "^6.19.3",
|
|
54
|
+
"@wordpress/preferences": "^3.28.3",
|
|
55
55
|
"@wordpress/private-apis": "^0.33.1",
|
|
56
56
|
"@wordpress/url": "^3.52.1",
|
|
57
57
|
"@wordpress/viewport": "^5.28.1",
|
|
58
58
|
"@wordpress/warning": "^2.51.1",
|
|
59
|
-
"@wordpress/widgets": "^3.28.
|
|
59
|
+
"@wordpress/widgets": "^3.28.4",
|
|
60
60
|
"classnames": "^2.3.1",
|
|
61
61
|
"memize": "^2.1.0",
|
|
62
62
|
"rememo": "^4.0.2"
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"publishConfig": {
|
|
69
69
|
"access": "public"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "864c1c553cb284def3bd5c907998da45f5c143ea"
|
|
72
72
|
}
|
|
@@ -5,6 +5,7 @@ import { useSelect, useDispatch } from '@wordpress/data';
|
|
|
5
5
|
import { useEffect, useRef } from '@wordpress/element';
|
|
6
6
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
7
7
|
import { store as editorStore } from '@wordpress/editor';
|
|
8
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
@@ -22,19 +23,25 @@ import {
|
|
|
22
23
|
* @param {number} postId The current post id.
|
|
23
24
|
*/
|
|
24
25
|
export const useBlockSelectionListener = ( postId ) => {
|
|
25
|
-
const { hasBlockSelection, isEditorSidebarOpened } =
|
|
26
|
-
(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
const { hasBlockSelection, isEditorSidebarOpened, isDistractionFree } =
|
|
27
|
+
useSelect(
|
|
28
|
+
( select ) => {
|
|
29
|
+
const { get } = select( preferencesStore );
|
|
30
|
+
return {
|
|
31
|
+
hasBlockSelection:
|
|
32
|
+
!! select( blockEditorStore ).getBlockSelectionStart(),
|
|
33
|
+
isEditorSidebarOpened:
|
|
34
|
+
select( STORE_NAME ).isEditorSidebarOpened(),
|
|
35
|
+
isDistractionFree: get( 'core', 'distractionFree' ),
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
[ postId ]
|
|
39
|
+
);
|
|
33
40
|
|
|
34
41
|
const { openGeneralSidebar } = useDispatch( STORE_NAME );
|
|
35
42
|
|
|
36
43
|
useEffect( () => {
|
|
37
|
-
if ( ! isEditorSidebarOpened ) {
|
|
44
|
+
if ( ! isEditorSidebarOpened || isDistractionFree ) {
|
|
38
45
|
return;
|
|
39
46
|
}
|
|
40
47
|
if ( hasBlockSelection ) {
|
|
@@ -44,6 +44,12 @@ describe( 'listener hook tests', () => {
|
|
|
44
44
|
isViewportMatch: jest.fn(),
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
|
+
'core/preferences': {
|
|
48
|
+
...storeConfig,
|
|
49
|
+
selectors: {
|
|
50
|
+
get: jest.fn(),
|
|
51
|
+
},
|
|
52
|
+
},
|
|
47
53
|
[ STORE_NAME ]: {
|
|
48
54
|
...storeConfig,
|
|
49
55
|
actions: {
|
|
@@ -112,6 +118,7 @@ describe( 'listener hook tests', () => {
|
|
|
112
118
|
'getBlockSelectionStart',
|
|
113
119
|
true
|
|
114
120
|
);
|
|
121
|
+
setMockReturnValue( 'core/preferences', 'get', false );
|
|
115
122
|
|
|
116
123
|
render( <TestedOutput /> );
|
|
117
124
|
|
|
@@ -120,12 +127,14 @@ describe( 'listener hook tests', () => {
|
|
|
120
127
|
).toHaveBeenCalledWith( 'edit-post/block' );
|
|
121
128
|
} );
|
|
122
129
|
it( 'opens document sidebar if block is not selected', () => {
|
|
130
|
+
setMockReturnValue( STORE_NAME, 'isEditorSidebarOpened', true );
|
|
123
131
|
setMockReturnValue( STORE_NAME, 'isEditorSidebarOpened', true );
|
|
124
132
|
setMockReturnValue(
|
|
125
133
|
'core/block-editor',
|
|
126
134
|
'getBlockSelectionStart',
|
|
127
135
|
false
|
|
128
136
|
);
|
|
137
|
+
setMockReturnValue( 'core/preferences', 'get', false );
|
|
129
138
|
|
|
130
139
|
render( <TestedOutput /> );
|
|
131
140
|
|
|
@@ -133,6 +142,37 @@ describe( 'listener hook tests', () => {
|
|
|
133
142
|
getSpyedAction( STORE_NAME, 'openGeneralSidebar' )
|
|
134
143
|
).toHaveBeenCalledWith( 'edit-post/document' );
|
|
135
144
|
} );
|
|
145
|
+
it( 'does not open block sidebar if block is selected and distraction free mode is on', () => {
|
|
146
|
+
setMockReturnValue( STORE_NAME, 'isEditorSidebarOpened', true );
|
|
147
|
+
setMockReturnValue(
|
|
148
|
+
'core/block-editor',
|
|
149
|
+
'getBlockSelectionStart',
|
|
150
|
+
true
|
|
151
|
+
);
|
|
152
|
+
setMockReturnValue( 'core/preferences', 'get', true );
|
|
153
|
+
|
|
154
|
+
render( <TestedOutput /> );
|
|
155
|
+
|
|
156
|
+
expect(
|
|
157
|
+
getSpyedAction( STORE_NAME, 'openGeneralSidebar' )
|
|
158
|
+
).toHaveBeenCalledTimes( 0 );
|
|
159
|
+
} );
|
|
160
|
+
it( 'does not open document sidebar if block is not selected and distraction free is on', () => {
|
|
161
|
+
setMockReturnValue( STORE_NAME, 'isEditorSidebarOpened', true );
|
|
162
|
+
setMockReturnValue( STORE_NAME, 'isEditorSidebarOpened', true );
|
|
163
|
+
setMockReturnValue(
|
|
164
|
+
'core/block-editor',
|
|
165
|
+
'getBlockSelectionStart',
|
|
166
|
+
false
|
|
167
|
+
);
|
|
168
|
+
setMockReturnValue( 'core/preferences', 'get', true );
|
|
169
|
+
|
|
170
|
+
render( <TestedOutput /> );
|
|
171
|
+
|
|
172
|
+
expect(
|
|
173
|
+
getSpyedAction( STORE_NAME, 'openGeneralSidebar' )
|
|
174
|
+
).toHaveBeenCalledTimes( 0 );
|
|
175
|
+
} );
|
|
136
176
|
} );
|
|
137
177
|
|
|
138
178
|
describe( 'useUpdatePostLinkListener', () => {
|
|
@@ -61,7 +61,7 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) {
|
|
|
61
61
|
const blockToolbarRef = useRef();
|
|
62
62
|
const {
|
|
63
63
|
isTextEditor,
|
|
64
|
-
|
|
64
|
+
blockSelectionStart,
|
|
65
65
|
hasActiveMetaboxes,
|
|
66
66
|
hasFixedToolbar,
|
|
67
67
|
isPublishSidebarOpened,
|
|
@@ -73,8 +73,8 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) {
|
|
|
73
73
|
|
|
74
74
|
return {
|
|
75
75
|
isTextEditor: getEditorMode() === 'text',
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
blockSelectionStart:
|
|
77
|
+
select( blockEditorStore ).getBlockSelectionStart(),
|
|
78
78
|
hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
|
|
79
79
|
hasHistory:
|
|
80
80
|
!! select( editorStore ).getEditorSettings()
|
|
@@ -88,13 +88,14 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) {
|
|
|
88
88
|
|
|
89
89
|
const [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] =
|
|
90
90
|
useState( true );
|
|
91
|
+
const hasBlockSelection = !! blockSelectionStart;
|
|
91
92
|
|
|
92
93
|
useEffect( () => {
|
|
93
94
|
// If we have a new block selection, show the block tools
|
|
94
|
-
if (
|
|
95
|
+
if ( blockSelectionStart ) {
|
|
95
96
|
setIsBlockToolsCollapsed( false );
|
|
96
97
|
}
|
|
97
|
-
}, [
|
|
98
|
+
}, [ blockSelectionStart ] );
|
|
98
99
|
|
|
99
100
|
return (
|
|
100
101
|
<div className="edit-post-header">
|
|
@@ -121,7 +122,9 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) {
|
|
|
121
122
|
className={ classnames(
|
|
122
123
|
'selected-block-tools-wrapper',
|
|
123
124
|
{
|
|
124
|
-
'is-collapsed':
|
|
125
|
+
'is-collapsed':
|
|
126
|
+
isBlockToolsCollapsed ||
|
|
127
|
+
! hasBlockSelection,
|
|
125
128
|
}
|
|
126
129
|
) }
|
|
127
130
|
>
|
package/src/index.js
CHANGED
|
@@ -49,6 +49,7 @@ export function initializeEditor(
|
|
|
49
49
|
settings,
|
|
50
50
|
initialEdits
|
|
51
51
|
) {
|
|
52
|
+
const isMediumOrBigger = window.matchMedia( '(min-width: 782px)' ).matches;
|
|
52
53
|
const target = document.getElementById( id );
|
|
53
54
|
const root = createRoot( target );
|
|
54
55
|
|
|
@@ -77,7 +78,9 @@ export function initializeEditor(
|
|
|
77
78
|
|
|
78
79
|
// Check if the block list view should be open by default.
|
|
79
80
|
// If `distractionFree` mode is enabled, the block list view should not be open.
|
|
81
|
+
// This behavior is disabled for small viewports.
|
|
80
82
|
if (
|
|
83
|
+
isMediumOrBigger &&
|
|
81
84
|
select( preferencesStore ).get( 'core', 'showListViewByDefault' ) &&
|
|
82
85
|
! select( preferencesStore ).get( 'core', 'distractionFree' )
|
|
83
86
|
) {
|
package/src/store/selectors.js
CHANGED
|
@@ -556,7 +556,7 @@ export const isEditingTemplate = createRegistrySelector( ( select ) => () => {
|
|
|
556
556
|
since: '6.5',
|
|
557
557
|
alternative: `select( 'core/editor' ).getRenderingMode`,
|
|
558
558
|
} );
|
|
559
|
-
return select( editorStore ).getCurrentPostType()
|
|
559
|
+
return select( editorStore ).getCurrentPostType() === 'wp_template';
|
|
560
560
|
} );
|
|
561
561
|
|
|
562
562
|
/**
|