@wordpress/edit-post 7.28.5 → 7.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/editor-initialization/index.js +3 -6
- package/build/components/editor-initialization/index.js.map +1 -1
- package/build/components/editor-initialization/listener-hooks.js +6 -10
- package/build/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/index.js +13 -7
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +16 -4
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/writing-menu/index.js +2 -6
- package/build/components/header/writing-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -38
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +2 -3
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js +2 -5
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/text-editor/index.js +1 -1
- package/build/components/text-editor/index.js.map +1 -1
- package/build/editor.js +3 -31
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +2 -3
- package/build/editor.native.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +2 -135
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/index.js +0 -30
- package/build/index.js.map +1 -1
- package/build/index.native.js +0 -1
- package/build/index.native.js.map +1 -1
- package/build/store/actions.js +24 -77
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +0 -12
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/editor-initialization/index.js +3 -6
- package/build-module/components/editor-initialization/index.js.map +1 -1
- package/build-module/components/editor-initialization/listener-hooks.js +6 -10
- package/build-module/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/index.js +14 -8
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +17 -5
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/writing-menu/index.js +2 -6
- package/build-module/components/header/writing-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -38
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +3 -4
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js +2 -5
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/text-editor/index.js +1 -1
- package/build-module/components/text-editor/index.js.map +1 -1
- package/build-module/editor.js +4 -32
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +3 -4
- package/build-module/editor.native.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +3 -136
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/index.js +0 -30
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +0 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/store/actions.js +23 -75
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +0 -12
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +10 -38
- package/build-style/style.css +10 -38
- package/package.json +32 -32
- package/src/components/editor-initialization/index.js +3 -4
- package/src/components/editor-initialization/listener-hooks.js +20 -22
- package/src/components/editor-initialization/test/listener-hooks.js +8 -8
- package/src/components/header/header-toolbar/index.native.js +1 -1
- package/src/components/header/index.js +23 -23
- package/src/components/header/more-menu/index.js +17 -10
- package/src/components/header/style.scss +4 -0
- package/src/components/header/test/index.js +4 -14
- package/src/components/header/writing-menu/index.js +2 -6
- package/src/components/keyboard-shortcuts/index.js +3 -50
- package/src/components/layout/index.js +3 -4
- package/src/components/layout/index.native.js +1 -3
- package/src/components/sidebar/plugin-post-publish-panel/test/index.js +1 -1
- package/src/components/text-editor/index.js +1 -1
- package/src/editor.js +32 -65
- package/src/editor.native.js +3 -4
- package/src/hooks/commands/use-common-commands.js +17 -170
- package/src/index.js +0 -44
- package/src/index.native.js +0 -1
- package/src/store/actions.js +24 -126
- package/src/store/selectors.js +0 -18
- package/src/store/test/actions.js +0 -146
- package/src/style.scss +1 -2
- package/build/components/header/mode-switcher/index.js +0 -87
- package/build/components/header/mode-switcher/index.js.map +0 -1
- package/build-module/components/header/mode-switcher/index.js +0 -81
- package/build-module/components/header/mode-switcher/index.js.map +0 -1
- package/src/components/header/mode-switcher/index.js +0 -91
package/build-style/style.css
CHANGED
|
@@ -113,6 +113,7 @@
|
|
|
113
113
|
text-overflow: ellipsis;
|
|
114
114
|
white-space: nowrap;
|
|
115
115
|
width: 100%;
|
|
116
|
+
margin: 0;
|
|
116
117
|
}
|
|
117
118
|
@media (min-width: 782px) {
|
|
118
119
|
.components-panel__header.interface-complementary-area-header__small {
|
|
@@ -124,6 +125,9 @@
|
|
|
124
125
|
background: #fff;
|
|
125
126
|
padding-right: 4px;
|
|
126
127
|
}
|
|
128
|
+
.interface-complementary-area-header .interface-complementary-area-header__title {
|
|
129
|
+
margin: 0;
|
|
130
|
+
}
|
|
127
131
|
.interface-complementary-area-header .components-button.has-icon {
|
|
128
132
|
display: none;
|
|
129
133
|
margin-left: auto;
|
|
@@ -435,38 +439,6 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
435
439
|
}
|
|
436
440
|
}
|
|
437
441
|
|
|
438
|
-
.interface-more-menu-dropdown {
|
|
439
|
-
margin-left: -4px;
|
|
440
|
-
}
|
|
441
|
-
.interface-more-menu-dropdown .components-button {
|
|
442
|
-
width: auto;
|
|
443
|
-
padding: 0 2px;
|
|
444
|
-
}
|
|
445
|
-
@media (min-width: 600px) {
|
|
446
|
-
.interface-more-menu-dropdown {
|
|
447
|
-
margin-left: 0;
|
|
448
|
-
}
|
|
449
|
-
.interface-more-menu-dropdown .components-button {
|
|
450
|
-
padding: 0 4px;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
.interface-more-menu-dropdown__content .components-popover__content {
|
|
455
|
-
min-width: 300px;
|
|
456
|
-
}
|
|
457
|
-
@media (min-width: 480px) {
|
|
458
|
-
.interface-more-menu-dropdown__content .components-popover__content {
|
|
459
|
-
max-width: 480px;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
.interface-more-menu-dropdown__content .components-popover__content .components-dropdown-menu__menu {
|
|
463
|
-
padding: 0;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
.components-popover.interface-more-menu-dropdown__content {
|
|
467
|
-
z-index: 99998;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
442
|
.interface-pinned-items {
|
|
471
443
|
display: flex;
|
|
472
444
|
gap: 8px;
|
|
@@ -776,6 +748,10 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
776
748
|
z-index: 35;
|
|
777
749
|
}
|
|
778
750
|
|
|
751
|
+
.components-popover.more-menu-dropdown__content {
|
|
752
|
+
z-index: 99998;
|
|
753
|
+
}
|
|
754
|
+
|
|
779
755
|
.edit-post-fullscreen-mode-close.components-button {
|
|
780
756
|
display: none;
|
|
781
757
|
}
|
|
@@ -1371,8 +1347,7 @@ body.js.block-editor-page .media-frame select.attachment-filters:last-of-type {
|
|
|
1371
1347
|
.edit-post-header,
|
|
1372
1348
|
.edit-post-text-editor,
|
|
1373
1349
|
.edit-post-sidebar,
|
|
1374
|
-
.editor-post-publish-panel
|
|
1375
|
-
.components-modal__frame {
|
|
1350
|
+
.editor-post-publish-panel {
|
|
1376
1351
|
box-sizing: border-box;
|
|
1377
1352
|
}
|
|
1378
1353
|
.edit-post-header *,
|
|
@@ -1386,10 +1361,7 @@ body.js.block-editor-page .media-frame select.attachment-filters:last-of-type {
|
|
|
1386
1361
|
.edit-post-sidebar *::after,
|
|
1387
1362
|
.editor-post-publish-panel *,
|
|
1388
1363
|
.editor-post-publish-panel *::before,
|
|
1389
|
-
.editor-post-publish-panel *::after
|
|
1390
|
-
.components-modal__frame *,
|
|
1391
|
-
.components-modal__frame *::before,
|
|
1392
|
-
.components-modal__frame *::after {
|
|
1364
|
+
.editor-post-publish-panel *::after {
|
|
1393
1365
|
box-sizing: inherit;
|
|
1394
1366
|
}
|
|
1395
1367
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-post",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.30.0",
|
|
4
4
|
"description": "Edit Post module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -27,36 +27,36 @@
|
|
|
27
27
|
"react-native": "src/index",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
|
-
"@wordpress/a11y": "^3.
|
|
31
|
-
"@wordpress/api-fetch": "^6.
|
|
32
|
-
"@wordpress/block-editor": "^12.
|
|
33
|
-
"@wordpress/block-library": "^8.
|
|
34
|
-
"@wordpress/blocks": "^12.
|
|
35
|
-
"@wordpress/commands": "^0.
|
|
36
|
-
"@wordpress/components": "^
|
|
37
|
-
"@wordpress/compose": "^6.
|
|
38
|
-
"@wordpress/core-commands": "^0.
|
|
39
|
-
"@wordpress/core-data": "^6.
|
|
40
|
-
"@wordpress/data": "^9.
|
|
41
|
-
"@wordpress/deprecated": "^3.
|
|
42
|
-
"@wordpress/dom": "^3.
|
|
43
|
-
"@wordpress/editor": "^13.
|
|
44
|
-
"@wordpress/element": "^5.
|
|
45
|
-
"@wordpress/hooks": "^3.
|
|
46
|
-
"@wordpress/i18n": "^4.
|
|
47
|
-
"@wordpress/icons": "^9.
|
|
48
|
-
"@wordpress/interface": "^5.
|
|
49
|
-
"@wordpress/keyboard-shortcuts": "^4.
|
|
50
|
-
"@wordpress/keycodes": "^3.
|
|
51
|
-
"@wordpress/media-utils": "^4.
|
|
52
|
-
"@wordpress/notices": "^4.
|
|
53
|
-
"@wordpress/plugins": "^6.
|
|
54
|
-
"@wordpress/preferences": "^3.
|
|
55
|
-
"@wordpress/private-apis": "^0.
|
|
56
|
-
"@wordpress/url": "^3.
|
|
57
|
-
"@wordpress/viewport": "^5.
|
|
58
|
-
"@wordpress/warning": "^2.
|
|
59
|
-
"@wordpress/widgets": "^3.
|
|
30
|
+
"@wordpress/a11y": "^3.53.0",
|
|
31
|
+
"@wordpress/api-fetch": "^6.50.0",
|
|
32
|
+
"@wordpress/block-editor": "^12.21.0",
|
|
33
|
+
"@wordpress/block-library": "^8.30.0",
|
|
34
|
+
"@wordpress/blocks": "^12.30.0",
|
|
35
|
+
"@wordpress/commands": "^0.24.0",
|
|
36
|
+
"@wordpress/components": "^27.1.0",
|
|
37
|
+
"@wordpress/compose": "^6.30.0",
|
|
38
|
+
"@wordpress/core-commands": "^0.22.0",
|
|
39
|
+
"@wordpress/core-data": "^6.30.0",
|
|
40
|
+
"@wordpress/data": "^9.23.0",
|
|
41
|
+
"@wordpress/deprecated": "^3.53.0",
|
|
42
|
+
"@wordpress/dom": "^3.53.0",
|
|
43
|
+
"@wordpress/editor": "^13.30.0",
|
|
44
|
+
"@wordpress/element": "^5.30.0",
|
|
45
|
+
"@wordpress/hooks": "^3.53.0",
|
|
46
|
+
"@wordpress/i18n": "^4.53.0",
|
|
47
|
+
"@wordpress/icons": "^9.44.0",
|
|
48
|
+
"@wordpress/interface": "^5.30.0",
|
|
49
|
+
"@wordpress/keyboard-shortcuts": "^4.30.0",
|
|
50
|
+
"@wordpress/keycodes": "^3.53.0",
|
|
51
|
+
"@wordpress/media-utils": "^4.44.0",
|
|
52
|
+
"@wordpress/notices": "^4.21.0",
|
|
53
|
+
"@wordpress/plugins": "^6.21.0",
|
|
54
|
+
"@wordpress/preferences": "^3.30.0",
|
|
55
|
+
"@wordpress/private-apis": "^0.35.0",
|
|
56
|
+
"@wordpress/url": "^3.54.0",
|
|
57
|
+
"@wordpress/viewport": "^5.30.0",
|
|
58
|
+
"@wordpress/warning": "^2.53.0",
|
|
59
|
+
"@wordpress/widgets": "^3.30.0",
|
|
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": "ac3c3e465a083081a86a4da6ee6fb817b41e5130"
|
|
72
72
|
}
|
|
@@ -10,11 +10,10 @@ import {
|
|
|
10
10
|
* Data component used for initializing the editor and re-initializes
|
|
11
11
|
* when postId changes or on unmount.
|
|
12
12
|
*
|
|
13
|
-
* @param {number} postId The id of the post.
|
|
14
13
|
* @return {null} This is a data component so does not render any ui.
|
|
15
14
|
*/
|
|
16
|
-
export default function EditorInitialization(
|
|
17
|
-
useBlockSelectionListener(
|
|
18
|
-
useUpdatePostLinkListener(
|
|
15
|
+
export default function EditorInitialization() {
|
|
16
|
+
useBlockSelectionListener();
|
|
17
|
+
useUpdatePostLinkListener();
|
|
19
18
|
return null;
|
|
20
19
|
}
|
|
@@ -19,24 +19,19 @@ import {
|
|
|
19
19
|
/**
|
|
20
20
|
* This listener hook monitors for block selection and triggers the appropriate
|
|
21
21
|
* sidebar state.
|
|
22
|
-
*
|
|
23
|
-
* @param {number} postId The current post id.
|
|
24
22
|
*/
|
|
25
|
-
export const useBlockSelectionListener = (
|
|
23
|
+
export const useBlockSelectionListener = () => {
|
|
26
24
|
const { hasBlockSelection, isEditorSidebarOpened, isDistractionFree } =
|
|
27
|
-
useSelect(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
isEditorSidebarOpened
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
[ postId ]
|
|
39
|
-
);
|
|
25
|
+
useSelect( ( select ) => {
|
|
26
|
+
const { get } = select( preferencesStore );
|
|
27
|
+
return {
|
|
28
|
+
hasBlockSelection:
|
|
29
|
+
!! select( blockEditorStore ).getBlockSelectionStart(),
|
|
30
|
+
isEditorSidebarOpened:
|
|
31
|
+
select( STORE_NAME ).isEditorSidebarOpened(),
|
|
32
|
+
isDistractionFree: get( 'core', 'distractionFree' ),
|
|
33
|
+
};
|
|
34
|
+
}, [] );
|
|
40
35
|
|
|
41
36
|
const { openGeneralSidebar } = useDispatch( STORE_NAME );
|
|
42
37
|
|
|
@@ -49,21 +44,24 @@ export const useBlockSelectionListener = ( postId ) => {
|
|
|
49
44
|
} else {
|
|
50
45
|
openGeneralSidebar( 'edit-post/document' );
|
|
51
46
|
}
|
|
52
|
-
}, [
|
|
47
|
+
}, [
|
|
48
|
+
hasBlockSelection,
|
|
49
|
+
isDistractionFree,
|
|
50
|
+
isEditorSidebarOpened,
|
|
51
|
+
openGeneralSidebar,
|
|
52
|
+
] );
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* This listener hook monitors any change in permalink and updates the view
|
|
57
57
|
* post link in the admin bar.
|
|
58
|
-
*
|
|
59
|
-
* @param {number} postId
|
|
60
58
|
*/
|
|
61
|
-
export const useUpdatePostLinkListener = (
|
|
59
|
+
export const useUpdatePostLinkListener = () => {
|
|
62
60
|
const { newPermalink } = useSelect(
|
|
63
61
|
( select ) => ( {
|
|
64
62
|
newPermalink: select( editorStore ).getCurrentPost().link,
|
|
65
63
|
} ),
|
|
66
|
-
[
|
|
64
|
+
[]
|
|
67
65
|
);
|
|
68
66
|
const nodeToUpdate = useRef();
|
|
69
67
|
|
|
@@ -71,7 +69,7 @@ export const useUpdatePostLinkListener = ( postId ) => {
|
|
|
71
69
|
nodeToUpdate.current =
|
|
72
70
|
document.querySelector( VIEW_AS_PREVIEW_LINK_SELECTOR ) ||
|
|
73
71
|
document.querySelector( VIEW_AS_LINK_SELECTOR );
|
|
74
|
-
}, [
|
|
72
|
+
}, [] );
|
|
75
73
|
|
|
76
74
|
useEffect( () => {
|
|
77
75
|
if ( ! newPermalink || ! nodeToUpdate.current ) {
|
|
@@ -88,14 +88,14 @@ describe( 'listener hook tests', () => {
|
|
|
88
88
|
} );
|
|
89
89
|
describe( 'useBlockSelectionListener', () => {
|
|
90
90
|
const registry = createRegistry( mockStores );
|
|
91
|
-
const TestComponent = (
|
|
92
|
-
useBlockSelectionListener(
|
|
91
|
+
const TestComponent = () => {
|
|
92
|
+
useBlockSelectionListener();
|
|
93
93
|
return null;
|
|
94
94
|
};
|
|
95
95
|
const TestedOutput = () => {
|
|
96
96
|
return (
|
|
97
97
|
<RegistryProvider value={ registry }>
|
|
98
|
-
<TestComponent
|
|
98
|
+
<TestComponent />
|
|
99
99
|
</RegistryProvider>
|
|
100
100
|
);
|
|
101
101
|
};
|
|
@@ -177,14 +177,14 @@ describe( 'listener hook tests', () => {
|
|
|
177
177
|
|
|
178
178
|
describe( 'useUpdatePostLinkListener', () => {
|
|
179
179
|
const registry = createRegistry( mockStores );
|
|
180
|
-
const TestComponent = (
|
|
181
|
-
useUpdatePostLinkListener(
|
|
180
|
+
const TestComponent = () => {
|
|
181
|
+
useUpdatePostLinkListener();
|
|
182
182
|
return null;
|
|
183
183
|
};
|
|
184
|
-
const TestedOutput = (
|
|
184
|
+
const TestedOutput = () => {
|
|
185
185
|
return (
|
|
186
186
|
<RegistryProvider value={ registry }>
|
|
187
|
-
<TestComponent
|
|
187
|
+
<TestComponent />
|
|
188
188
|
</RegistryProvider>
|
|
189
189
|
);
|
|
190
190
|
};
|
|
@@ -222,7 +222,7 @@ describe( 'listener hook tests', () => {
|
|
|
222
222
|
} );
|
|
223
223
|
const { rerender } = render( <TestedOutput /> );
|
|
224
224
|
|
|
225
|
-
rerender( <TestedOutput
|
|
225
|
+
rerender( <TestedOutput /> );
|
|
226
226
|
|
|
227
227
|
expect( mockSelector ).toHaveBeenCalledTimes( 1 );
|
|
228
228
|
act( () => {
|
|
@@ -181,7 +181,7 @@ function HeaderToolbar( {
|
|
|
181
181
|
<ScrollView
|
|
182
182
|
ref={ scrollViewRef }
|
|
183
183
|
onContentSizeChange={ scrollToStart }
|
|
184
|
-
horizontal
|
|
184
|
+
horizontal
|
|
185
185
|
showsHorizontalScrollIndicator={ false }
|
|
186
186
|
keyboardShouldPersistTaps="always"
|
|
187
187
|
alwaysBounceHorizontal={ false }
|
|
@@ -8,6 +8,7 @@ import classnames from 'classnames';
|
|
|
8
8
|
*/
|
|
9
9
|
import {
|
|
10
10
|
BlockToolbar,
|
|
11
|
+
privateApis as blockEditorPrivateApis,
|
|
11
12
|
store as blockEditorStore,
|
|
12
13
|
} from '@wordpress/block-editor';
|
|
13
14
|
import {
|
|
@@ -40,6 +41,7 @@ import MainDashboardButton from './main-dashboard-button';
|
|
|
40
41
|
import { store as editPostStore } from '../../store';
|
|
41
42
|
import { unlock } from '../../lock-unlock';
|
|
42
43
|
|
|
44
|
+
const { useShowBlockTools } = unlock( blockEditorPrivateApis );
|
|
43
45
|
const { DocumentTools, PostViewLink, PreviewDropdown } =
|
|
44
46
|
unlock( editorPrivateApis );
|
|
45
47
|
|
|
@@ -63,13 +65,12 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) {
|
|
|
63
65
|
isTextEditor,
|
|
64
66
|
blockSelectionStart,
|
|
65
67
|
hasActiveMetaboxes,
|
|
66
|
-
hasFixedToolbar,
|
|
67
68
|
isPublishSidebarOpened,
|
|
68
69
|
showIconLabels,
|
|
69
70
|
hasHistory,
|
|
70
71
|
} = useSelect( ( select ) => {
|
|
71
72
|
const { get: getPreference } = select( preferencesStore );
|
|
72
|
-
const { getEditorMode } = select(
|
|
73
|
+
const { getEditorMode } = select( editorStore );
|
|
73
74
|
|
|
74
75
|
return {
|
|
75
76
|
isTextEditor: getEditorMode() === 'text',
|
|
@@ -81,11 +82,13 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) {
|
|
|
81
82
|
.onNavigateToPreviousEntityRecord,
|
|
82
83
|
isPublishSidebarOpened:
|
|
83
84
|
select( editPostStore ).isPublishSidebarOpened(),
|
|
84
|
-
hasFixedToolbar: getPreference( 'core', 'fixedToolbar' ),
|
|
85
85
|
showIconLabels: getPreference( 'core', 'showIconLabels' ),
|
|
86
86
|
};
|
|
87
87
|
}, [] );
|
|
88
88
|
|
|
89
|
+
const { showFixedToolbar } = useShowBlockTools();
|
|
90
|
+
const showTopToolbar = isLargeViewport && showFixedToolbar;
|
|
91
|
+
|
|
89
92
|
const [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] =
|
|
90
93
|
useState( true );
|
|
91
94
|
const hasBlockSelection = !! blockSelectionStart;
|
|
@@ -116,7 +119,7 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) {
|
|
|
116
119
|
className="edit-post-header__toolbar"
|
|
117
120
|
>
|
|
118
121
|
<DocumentTools disableBlockTools={ isTextEditor } />
|
|
119
|
-
{
|
|
122
|
+
{ showTopToolbar && (
|
|
120
123
|
<>
|
|
121
124
|
<div
|
|
122
125
|
className={ classnames(
|
|
@@ -134,32 +137,29 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) {
|
|
|
134
137
|
ref={ blockToolbarRef }
|
|
135
138
|
name="block-toolbar"
|
|
136
139
|
/>
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
) }
|
|
140
|
+
<Button
|
|
141
|
+
className="edit-post-header__block-tools-toggle"
|
|
142
|
+
icon={ isBlockToolsCollapsed ? next : previous }
|
|
143
|
+
onClick={ () => {
|
|
144
|
+
setIsBlockToolsCollapsed(
|
|
145
|
+
( collapsed ) => ! collapsed
|
|
146
|
+
);
|
|
147
|
+
} }
|
|
148
|
+
label={
|
|
149
|
+
isBlockToolsCollapsed
|
|
150
|
+
? __( 'Show block tools' )
|
|
151
|
+
: __( 'Hide block tools' )
|
|
152
|
+
}
|
|
153
|
+
size="compact"
|
|
154
|
+
/>
|
|
153
155
|
</>
|
|
154
156
|
) }
|
|
155
157
|
<div
|
|
156
158
|
className={ classnames( 'edit-post-header__center', {
|
|
157
159
|
'is-collapsed':
|
|
158
160
|
hasHistory &&
|
|
159
|
-
hasBlockSelection &&
|
|
160
161
|
! isBlockToolsCollapsed &&
|
|
161
|
-
|
|
162
|
-
isLargeViewport,
|
|
162
|
+
showTopToolbar,
|
|
163
163
|
} ) }
|
|
164
164
|
>
|
|
165
165
|
{ hasHistory && <DocumentBar /> }
|
|
@@ -2,30 +2,37 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { MenuGroup } from '@wordpress/components';
|
|
6
|
-
import {
|
|
7
|
-
ActionItem,
|
|
8
|
-
MoreMenuDropdown,
|
|
9
|
-
PinnedItems,
|
|
10
|
-
} from '@wordpress/interface';
|
|
5
|
+
import { MenuGroup, DropdownMenu } from '@wordpress/components';
|
|
6
|
+
import { ActionItem, PinnedItems } from '@wordpress/interface';
|
|
11
7
|
import { useViewportMatch } from '@wordpress/compose';
|
|
8
|
+
import { privateApis as editorPrivateApis } from '@wordpress/editor';
|
|
9
|
+
import { moreVertical } from '@wordpress/icons';
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* Internal dependencies
|
|
15
13
|
*/
|
|
16
|
-
import ModeSwitcher from '../mode-switcher';
|
|
17
14
|
import PreferencesMenuItem from '../preferences-menu-item';
|
|
18
15
|
import ToolsMoreMenuGroup from '../tools-more-menu-group';
|
|
19
16
|
import WritingMenu from '../writing-menu';
|
|
17
|
+
import { unlock } from '../../../lock-unlock';
|
|
18
|
+
|
|
19
|
+
const { ModeSwitcher } = unlock( editorPrivateApis );
|
|
20
20
|
|
|
21
21
|
const MoreMenu = ( { showIconLabels } ) => {
|
|
22
22
|
const isLargeViewport = useViewportMatch( 'large' );
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
|
-
<
|
|
25
|
+
<DropdownMenu
|
|
26
|
+
icon={ moreVertical }
|
|
27
|
+
label={ __( 'Options' ) }
|
|
28
|
+
popoverProps={ {
|
|
29
|
+
placement: 'bottom-end',
|
|
30
|
+
className: 'more-menu-dropdown__content',
|
|
31
|
+
} }
|
|
26
32
|
toggleProps={ {
|
|
27
|
-
showTooltip: ! showIconLabels,
|
|
28
33
|
...( showIconLabels && { variant: 'tertiary' } ),
|
|
34
|
+
tooltipPosition: 'bottom',
|
|
35
|
+
showTooltip: ! showIconLabels,
|
|
29
36
|
size: 'compact',
|
|
30
37
|
} }
|
|
31
38
|
>
|
|
@@ -51,7 +58,7 @@ const MoreMenu = ( { showIconLabels } ) => {
|
|
|
51
58
|
</MenuGroup>
|
|
52
59
|
</>
|
|
53
60
|
) }
|
|
54
|
-
</
|
|
61
|
+
</DropdownMenu>
|
|
55
62
|
);
|
|
56
63
|
};
|
|
57
64
|
|
|
@@ -10,19 +10,14 @@ import { PostPublishButtonOrToggle } from '../post-publish-button-or-toggle';
|
|
|
10
10
|
|
|
11
11
|
describe( 'PostPublishButtonOrToggle should render a', () => {
|
|
12
12
|
it( 'button when the post is published (1)', () => {
|
|
13
|
-
render( <PostPublishButtonOrToggle isPublished
|
|
13
|
+
render( <PostPublishButtonOrToggle isPublished /> );
|
|
14
14
|
expect(
|
|
15
15
|
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
16
16
|
).toBeVisible();
|
|
17
17
|
} );
|
|
18
18
|
|
|
19
19
|
it( 'button when the post is scheduled (2)', () => {
|
|
20
|
-
render(
|
|
21
|
-
<PostPublishButtonOrToggle
|
|
22
|
-
isScheduled={ true }
|
|
23
|
-
isBeingScheduled={ true }
|
|
24
|
-
/>
|
|
25
|
-
);
|
|
20
|
+
render( <PostPublishButtonOrToggle isScheduled isBeingScheduled /> );
|
|
26
21
|
expect(
|
|
27
22
|
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
28
23
|
).toBeVisible();
|
|
@@ -30,10 +25,7 @@ describe( 'PostPublishButtonOrToggle should render a', () => {
|
|
|
30
25
|
|
|
31
26
|
it( 'button when the post is pending and cannot be published but the viewport is >= medium (3)', () => {
|
|
32
27
|
render(
|
|
33
|
-
<PostPublishButtonOrToggle
|
|
34
|
-
isPending={ true }
|
|
35
|
-
hasPublishAction={ false }
|
|
36
|
-
/>
|
|
28
|
+
<PostPublishButtonOrToggle isPending hasPublishAction={ false } />
|
|
37
29
|
);
|
|
38
30
|
|
|
39
31
|
expect(
|
|
@@ -42,9 +34,7 @@ describe( 'PostPublishButtonOrToggle should render a', () => {
|
|
|
42
34
|
} );
|
|
43
35
|
|
|
44
36
|
it( 'toggle when post is not (1), (2), (3), the viewport is >= medium, and the publish sidebar is enabled', () => {
|
|
45
|
-
render(
|
|
46
|
-
<PostPublishButtonOrToggle isPublishSidebarEnabled={ true } />
|
|
47
|
-
);
|
|
37
|
+
render( <PostPublishButtonOrToggle isPublishSidebarEnabled /> );
|
|
48
38
|
expect(
|
|
49
39
|
screen.getByRole( 'button', { name: 'Publish' } )
|
|
50
40
|
).toBeVisible();
|
|
@@ -10,15 +10,11 @@ import {
|
|
|
10
10
|
PreferenceToggleMenuItem,
|
|
11
11
|
store as preferencesStore,
|
|
12
12
|
} from '@wordpress/preferences';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Internal dependencies
|
|
16
|
-
*/
|
|
17
|
-
import { store as postEditorStore } from '../../../store';
|
|
13
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
18
14
|
|
|
19
15
|
function WritingMenu() {
|
|
20
16
|
const { set: setPreference } = useDispatch( preferencesStore );
|
|
21
|
-
const { toggleDistractionFree } = useDispatch(
|
|
17
|
+
const { toggleDistractionFree } = useDispatch( editorStore );
|
|
22
18
|
|
|
23
19
|
const turnOffDistractionFree = () => {
|
|
24
20
|
setPreference( 'core', 'distractionFree', false );
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
store as keyboardShortcutsStore,
|
|
9
9
|
} from '@wordpress/keyboard-shortcuts';
|
|
10
10
|
import { __ } from '@wordpress/i18n';
|
|
11
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
12
11
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
13
12
|
import { createBlock } from '@wordpress/blocks';
|
|
14
13
|
|
|
@@ -18,19 +17,9 @@ import { createBlock } from '@wordpress/blocks';
|
|
|
18
17
|
import { store as editPostStore } from '../../store';
|
|
19
18
|
|
|
20
19
|
function KeyboardShortcuts() {
|
|
21
|
-
const {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
select( editorStore ).getEditorSettings();
|
|
25
|
-
return ! richEditingEnabled || ! codeEditingEnabled;
|
|
26
|
-
}, [] );
|
|
27
|
-
const {
|
|
28
|
-
switchEditorMode,
|
|
29
|
-
openGeneralSidebar,
|
|
30
|
-
closeGeneralSidebar,
|
|
31
|
-
toggleFeature,
|
|
32
|
-
toggleDistractionFree,
|
|
33
|
-
} = useDispatch( editPostStore );
|
|
20
|
+
const { isEditorSidebarOpened } = useSelect( editPostStore );
|
|
21
|
+
const { openGeneralSidebar, closeGeneralSidebar, toggleFeature } =
|
|
22
|
+
useDispatch( editPostStore );
|
|
34
23
|
const { registerShortcut } = useDispatch( keyboardShortcutsStore );
|
|
35
24
|
const { replaceBlocks } = useDispatch( blockEditorStore );
|
|
36
25
|
const {
|
|
@@ -69,26 +58,6 @@ function KeyboardShortcuts() {
|
|
|
69
58
|
};
|
|
70
59
|
|
|
71
60
|
useEffect( () => {
|
|
72
|
-
registerShortcut( {
|
|
73
|
-
name: 'core/edit-post/toggle-mode',
|
|
74
|
-
category: 'global',
|
|
75
|
-
description: __( 'Switch between visual editor and code editor.' ),
|
|
76
|
-
keyCombination: {
|
|
77
|
-
modifier: 'secondary',
|
|
78
|
-
character: 'm',
|
|
79
|
-
},
|
|
80
|
-
} );
|
|
81
|
-
|
|
82
|
-
registerShortcut( {
|
|
83
|
-
name: 'core/edit-post/toggle-distraction-free',
|
|
84
|
-
category: 'global',
|
|
85
|
-
description: __( 'Toggle distraction free mode.' ),
|
|
86
|
-
keyCombination: {
|
|
87
|
-
modifier: 'primaryShift',
|
|
88
|
-
character: '\\',
|
|
89
|
-
},
|
|
90
|
-
} );
|
|
91
|
-
|
|
92
61
|
registerShortcut( {
|
|
93
62
|
name: 'core/edit-post/toggle-fullscreen',
|
|
94
63
|
category: 'global',
|
|
@@ -178,26 +147,10 @@ function KeyboardShortcuts() {
|
|
|
178
147
|
} );
|
|
179
148
|
}, [] );
|
|
180
149
|
|
|
181
|
-
useShortcut(
|
|
182
|
-
'core/edit-post/toggle-mode',
|
|
183
|
-
() => {
|
|
184
|
-
switchEditorMode(
|
|
185
|
-
getEditorMode() === 'visual' ? 'text' : 'visual'
|
|
186
|
-
);
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
isDisabled: isModeToggleDisabled,
|
|
190
|
-
}
|
|
191
|
-
);
|
|
192
|
-
|
|
193
150
|
useShortcut( 'core/edit-post/toggle-fullscreen', () => {
|
|
194
151
|
toggleFeature( 'fullscreenMode' );
|
|
195
152
|
} );
|
|
196
153
|
|
|
197
|
-
useShortcut( 'core/edit-post/toggle-distraction-free', () => {
|
|
198
|
-
toggleDistractionFree();
|
|
199
|
-
} );
|
|
200
|
-
|
|
201
154
|
useShortcut( 'core/edit-post/toggle-sidebar', ( event ) => {
|
|
202
155
|
// This shortcut has no known clashes, but use preventDefault to prevent any
|
|
203
156
|
// obscure shortcuts from triggering.
|
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
} from '@wordpress/editor';
|
|
21
21
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
22
22
|
import {
|
|
23
|
-
useBlockCommands,
|
|
24
23
|
BlockBreadcrumb,
|
|
25
24
|
BlockToolbar,
|
|
26
25
|
privateApis as blockEditorPrivateApis,
|
|
@@ -134,7 +133,6 @@ function useEditorStyles() {
|
|
|
134
133
|
function Layout( { initialPost } ) {
|
|
135
134
|
useCommands();
|
|
136
135
|
useCommonCommands();
|
|
137
|
-
useBlockCommands();
|
|
138
136
|
|
|
139
137
|
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
140
138
|
const isHugeViewport = useViewportMatch( 'huge', '>=' );
|
|
@@ -180,7 +178,7 @@ function Layout( { initialPost } ) {
|
|
|
180
178
|
select( editPostStore ).isFeatureActive( 'fullscreenMode' ),
|
|
181
179
|
isInserterOpened: select( editorStore ).isInserterOpened(),
|
|
182
180
|
isListViewOpened: select( editorStore ).isListViewOpened(),
|
|
183
|
-
mode: select(
|
|
181
|
+
mode: select( editorStore ).getEditorMode(),
|
|
184
182
|
isRichEditingEnabled: editorSettings.richEditingEnabled,
|
|
185
183
|
hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
|
|
186
184
|
previousShortcut: select(
|
|
@@ -310,7 +308,8 @@ function Layout( { initialPost } ) {
|
|
|
310
308
|
editorNotices={ <EditorNotices /> }
|
|
311
309
|
secondarySidebar={ secondarySidebar() }
|
|
312
310
|
sidebar={
|
|
313
|
-
(
|
|
311
|
+
( ( isMobileViewport && sidebarIsOpened ) ||
|
|
312
|
+
( ! isMobileViewport && ! isDistractionFree ) ) && (
|
|
314
313
|
<>
|
|
315
314
|
{ ! isMobileViewport && ! sidebarIsOpened && (
|
|
316
315
|
<div className="edit-post-layout__toggle-sidebar-panel">
|