@wordpress/edit-post 7.13.0 → 7.15.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 +6 -6
- package/build/components/device-preview/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.js +10 -3
- package/build/components/header/header-toolbar/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.native.js +91 -49
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/index.js +26 -30
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/post-publish-button-or-toggle.js +0 -2
- package/build/components/header/post-publish-button-or-toggle.js.map +1 -1
- package/build/components/header/preferences-menu-item/index.js +5 -3
- package/build/components/header/preferences-menu-item/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +8 -6
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +0 -2
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/actions-panel.js +5 -10
- package/build/components/layout/actions-panel.js.map +1 -1
- package/build/components/layout/index.js +2 -2
- package/build/components/layout/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +5 -3
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/sidebar/post-status/index.js +2 -1
- package/build/components/sidebar/post-status/index.js.map +1 -1
- package/build/components/sidebar/post-trash/index.js +1 -5
- package/build/components/sidebar/post-trash/index.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/components/visual-editor/header.native.js +1 -13
- package/build/components/visual-editor/header.native.js.map +1 -1
- package/build/components/visual-editor/index.js +1 -1
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/editor.js +3 -0
- package/build/editor.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +176 -0
- package/build/hooks/commands/use-common-commands.js.map +1 -0
- package/build/plugins/index.js +35 -6
- package/build/plugins/index.js.map +1 -1
- package/build/plugins/keyboard-shortcuts-help-menu-item/index.js +5 -3
- package/build/plugins/keyboard-shortcuts-help-menu-item/index.js.map +1 -1
- package/build/store/actions.js +43 -29
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +0 -23
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +11 -7
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/device-preview/index.js +6 -6
- package/build-module/components/device-preview/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.js +9 -3
- package/build-module/components/header/header-toolbar/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.native.js +92 -53
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/index.js +25 -30
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/post-publish-button-or-toggle.js +0 -2
- package/build-module/components/header/post-publish-button-or-toggle.js.map +1 -1
- package/build-module/components/header/preferences-menu-item/index.js +4 -3
- package/build-module/components/header/preferences-menu-item/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +5 -5
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +0 -2
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/actions-panel.js +5 -10
- package/build-module/components/layout/actions-panel.js.map +1 -1
- package/build-module/components/layout/index.js +3 -3
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +4 -4
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/sidebar/post-status/index.js +2 -1
- package/build-module/components/sidebar/post-status/index.js.map +1 -1
- package/build-module/components/sidebar/post-trash/index.js +1 -4
- package/build-module/components/sidebar/post-trash/index.js.map +1 -1
- package/build-module/components/text-editor/index.js +2 -2
- package/build-module/components/text-editor/index.js.map +1 -1
- package/build-module/components/visual-editor/header.native.js +1 -10
- package/build-module/components/visual-editor/header.native.js.map +1 -1
- package/build-module/components/visual-editor/index.js +2 -2
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/editor.js +2 -0
- package/build-module/editor.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +160 -0
- package/build-module/hooks/commands/use-common-commands.js.map +1 -0
- package/build-module/plugins/index.js +33 -6
- package/build-module/plugins/index.js.map +1 -1
- package/build-module/plugins/keyboard-shortcuts-help-menu-item/index.js +4 -3
- package/build-module/plugins/keyboard-shortcuts-help-menu-item/index.js.map +1 -1
- package/build-module/store/actions.js +35 -25
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +0 -21
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +9 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +10 -15
- package/build-style/style.css +10 -15
- package/package.json +32 -32
- package/src/components/block-manager/style.scss +1 -1
- package/src/components/device-preview/index.js +35 -39
- package/src/components/header/header-toolbar/index.js +5 -1
- package/src/components/header/header-toolbar/index.native.js +124 -68
- package/src/components/header/header-toolbar/style.native.scss +23 -4
- package/src/components/header/index.js +22 -32
- package/src/components/header/post-publish-button-or-toggle.js +0 -2
- package/src/components/header/preferences-menu-item/index.js +4 -3
- package/src/components/keyboard-shortcut-help-modal/index.js +10 -5
- package/src/components/keyboard-shortcuts/index.js +0 -2
- package/src/components/layout/actions-panel.js +5 -7
- package/src/components/layout/index.js +4 -0
- package/src/components/layout/style.native.scss +1 -1
- package/src/components/preferences-modal/index.js +6 -4
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +11 -3
- package/src/components/sidebar/post-status/index.js +1 -0
- package/src/components/sidebar/post-trash/index.js +1 -4
- package/src/components/start-page-options/style.scss +0 -3
- package/src/components/text-editor/index.js +0 -2
- package/src/components/visual-editor/header.native.js +1 -17
- package/src/components/visual-editor/index.js +1 -6
- package/src/components/visual-editor/test/__snapshots__/index.native.js.snap +15 -0
- package/src/components/visual-editor/test/index.native.js +118 -1
- package/src/editor.js +2 -0
- package/src/hooks/commands/use-common-commands.js +155 -0
- package/src/plugins/index.js +32 -8
- package/src/plugins/keyboard-shortcuts-help-menu-item/index.js +4 -3
- package/src/store/actions.js +40 -36
- package/src/store/reducer.js +0 -20
- package/src/store/selectors.js +11 -3
- package/src/store/test/reducer.js +0 -25
- package/src/store/test/selectors.js +0 -27
- package/src/style.scss +1 -7
- package/src/components/visual-editor/style.native.scss +0 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-post",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.15.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": "^25.
|
|
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.38.0",
|
|
31
|
+
"@wordpress/api-fetch": "^6.35.0",
|
|
32
|
+
"@wordpress/block-editor": "^12.6.0",
|
|
33
|
+
"@wordpress/block-library": "^8.15.0",
|
|
34
|
+
"@wordpress/blocks": "^12.15.0",
|
|
35
|
+
"@wordpress/commands": "^0.9.0",
|
|
36
|
+
"@wordpress/components": "^25.4.0",
|
|
37
|
+
"@wordpress/compose": "^6.15.0",
|
|
38
|
+
"@wordpress/core-commands": "^0.7.0",
|
|
39
|
+
"@wordpress/core-data": "^6.15.0",
|
|
40
|
+
"@wordpress/data": "^9.8.0",
|
|
41
|
+
"@wordpress/deprecated": "^3.38.0",
|
|
42
|
+
"@wordpress/dom": "^3.38.0",
|
|
43
|
+
"@wordpress/editor": "^13.15.0",
|
|
44
|
+
"@wordpress/element": "^5.15.0",
|
|
45
|
+
"@wordpress/hooks": "^3.38.0",
|
|
46
|
+
"@wordpress/i18n": "^4.38.0",
|
|
47
|
+
"@wordpress/icons": "^9.29.0",
|
|
48
|
+
"@wordpress/interface": "^5.15.0",
|
|
49
|
+
"@wordpress/keyboard-shortcuts": "^4.15.0",
|
|
50
|
+
"@wordpress/keycodes": "^3.38.0",
|
|
51
|
+
"@wordpress/media-utils": "^4.29.0",
|
|
52
|
+
"@wordpress/notices": "^4.6.0",
|
|
53
|
+
"@wordpress/plugins": "^6.6.0",
|
|
54
|
+
"@wordpress/preferences": "^3.15.0",
|
|
55
|
+
"@wordpress/private-apis": "^0.20.0",
|
|
56
|
+
"@wordpress/url": "^3.39.0",
|
|
57
|
+
"@wordpress/viewport": "^5.15.0",
|
|
58
|
+
"@wordpress/warning": "^2.38.0",
|
|
59
|
+
"@wordpress/widgets": "^3.15.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": "6f14d11ed4cb59df110a28ebaa23ecba95eb673a"
|
|
72
72
|
}
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
|
|
37
37
|
.edit-post-block-manager__category-title {
|
|
38
38
|
position: sticky;
|
|
39
|
-
top:
|
|
39
|
+
top: - $grid-unit-05; // Offsets the top padding on the modal content container
|
|
40
40
|
padding: $grid-unit-20 0;
|
|
41
41
|
background-color: $white;
|
|
42
42
|
z-index: z-index(".edit-post-block-manager__category-title");
|
|
@@ -15,26 +15,22 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
15
15
|
import { store as editPostStore } from '../../store';
|
|
16
16
|
|
|
17
17
|
export default function DevicePreview() {
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
deviceType,
|
|
24
|
-
} = useSelect( ( select ) => {
|
|
25
|
-
const { getEditedPostAttribute } = select( editorStore );
|
|
26
|
-
const { getPostType } = select( coreStore );
|
|
27
|
-
const postType = getPostType( getEditedPostAttribute( 'type' ) );
|
|
18
|
+
const { hasActiveMetaboxes, isPostSaveable, isViewable, deviceType } =
|
|
19
|
+
useSelect( ( select ) => {
|
|
20
|
+
const { getEditedPostAttribute } = select( editorStore );
|
|
21
|
+
const { getPostType } = select( coreStore );
|
|
22
|
+
const postType = getPostType( getEditedPostAttribute( 'type' ) );
|
|
28
23
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
return {
|
|
25
|
+
hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
|
|
26
|
+
isPostSaveable: select( editorStore ).isEditedPostSaveable(),
|
|
27
|
+
isViewable: postType?.viewable ?? false,
|
|
28
|
+
deviceType:
|
|
29
|
+
select(
|
|
30
|
+
editPostStore
|
|
31
|
+
).__experimentalGetPreviewDeviceType(),
|
|
32
|
+
};
|
|
33
|
+
}, [] );
|
|
38
34
|
const { __experimentalSetPreviewDeviceType: setPreviewDeviceType } =
|
|
39
35
|
useDispatch( editPostStore );
|
|
40
36
|
|
|
@@ -46,26 +42,26 @@ export default function DevicePreview() {
|
|
|
46
42
|
setDeviceType={ setPreviewDeviceType }
|
|
47
43
|
label={ __( 'Preview' ) }
|
|
48
44
|
>
|
|
49
|
-
{
|
|
50
|
-
|
|
51
|
-
<
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
</
|
|
67
|
-
|
|
68
|
-
|
|
45
|
+
{ ( { onClose } ) =>
|
|
46
|
+
isViewable && (
|
|
47
|
+
<MenuGroup>
|
|
48
|
+
<div className="edit-post-header-preview__grouping-external">
|
|
49
|
+
<PostPreviewButton
|
|
50
|
+
className="edit-post-header-preview__button-external"
|
|
51
|
+
role="menuitem"
|
|
52
|
+
forceIsAutosaveable={ hasActiveMetaboxes }
|
|
53
|
+
textContent={
|
|
54
|
+
<>
|
|
55
|
+
{ __( 'Preview in new tab' ) }
|
|
56
|
+
<Icon icon={ external } />
|
|
57
|
+
</>
|
|
58
|
+
}
|
|
59
|
+
onPreview={ onClose }
|
|
60
|
+
/>
|
|
61
|
+
</div>
|
|
62
|
+
</MenuGroup>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
69
65
|
</PreviewOptions>
|
|
70
66
|
);
|
|
71
67
|
}
|
|
@@ -19,6 +19,7 @@ import { Button, ToolbarItem } from '@wordpress/components';
|
|
|
19
19
|
import { listView, plus } from '@wordpress/icons';
|
|
20
20
|
import { useRef, useCallback } from '@wordpress/element';
|
|
21
21
|
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
22
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Internal dependencies
|
|
@@ -43,6 +44,7 @@ function HeaderToolbar() {
|
|
|
43
44
|
showIconLabels,
|
|
44
45
|
isListViewOpen,
|
|
45
46
|
listViewShortcut,
|
|
47
|
+
hasFixedToolbar,
|
|
46
48
|
} = useSelect( ( select ) => {
|
|
47
49
|
const { hasInserterItems, getBlockRootClientId, getBlockSelectionEnd } =
|
|
48
50
|
select( blockEditorStore );
|
|
@@ -50,6 +52,7 @@ function HeaderToolbar() {
|
|
|
50
52
|
const { getEditorMode, isFeatureActive, isListViewOpened } =
|
|
51
53
|
select( editPostStore );
|
|
52
54
|
const { getShortcutRepresentation } = select( keyboardShortcutsStore );
|
|
55
|
+
const { get: getPreference } = select( preferencesStore );
|
|
53
56
|
|
|
54
57
|
return {
|
|
55
58
|
// This setting (richEditingEnabled) should not live in the block editor's setting.
|
|
@@ -66,6 +69,7 @@ function HeaderToolbar() {
|
|
|
66
69
|
listViewShortcut: getShortcutRepresentation(
|
|
67
70
|
'core/edit-post/toggle-list-view'
|
|
68
71
|
),
|
|
72
|
+
hasFixedToolbar: getPreference( 'core/edit-post', 'fixedToolbar' ),
|
|
69
73
|
};
|
|
70
74
|
}, [] );
|
|
71
75
|
|
|
@@ -147,7 +151,7 @@ function HeaderToolbar() {
|
|
|
147
151
|
/>
|
|
148
152
|
{ ( isWideViewport || ! showIconLabels ) && (
|
|
149
153
|
<>
|
|
150
|
-
{ isLargeViewport && (
|
|
154
|
+
{ isLargeViewport && ! hasFixedToolbar && (
|
|
151
155
|
<ToolbarItem
|
|
152
156
|
as={ ToolSelector }
|
|
153
157
|
showTooltip={ ! showIconLabels }
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { ScrollView, StyleSheet, View } from 'react-native';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { useCallback, useRef,
|
|
10
|
-
import { compose,
|
|
9
|
+
import { useCallback, useRef, useEffect, Platform } from '@wordpress/element';
|
|
10
|
+
import { compose, usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
11
11
|
import { withSelect, withDispatch } from '@wordpress/data';
|
|
12
12
|
import { withViewportMatch } from '@wordpress/viewport';
|
|
13
13
|
import { __ } from '@wordpress/i18n';
|
|
@@ -19,10 +19,19 @@ import {
|
|
|
19
19
|
import { ToolbarGroup, ToolbarButton } from '@wordpress/components';
|
|
20
20
|
import {
|
|
21
21
|
keyboardClose,
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
audio as audioIcon,
|
|
23
|
+
media as imageIcon,
|
|
24
|
+
video as videoIcon,
|
|
25
|
+
gallery as galleryIcon,
|
|
24
26
|
} from '@wordpress/icons';
|
|
25
27
|
import { store as editorStore } from '@wordpress/editor';
|
|
28
|
+
import { createBlock } from '@wordpress/blocks';
|
|
29
|
+
import {
|
|
30
|
+
toggleUndoButton,
|
|
31
|
+
toggleRedoButton,
|
|
32
|
+
subscribeOnUndoPressed,
|
|
33
|
+
subscribeOnRedoPressed,
|
|
34
|
+
} from '@wordpress/react-native-bridge';
|
|
26
35
|
|
|
27
36
|
/**
|
|
28
37
|
* Internal dependencies
|
|
@@ -30,6 +39,13 @@ import { store as editorStore } from '@wordpress/editor';
|
|
|
30
39
|
import styles from './style.scss';
|
|
31
40
|
import { store as editPostStore } from '../../../store';
|
|
32
41
|
|
|
42
|
+
const shadowStyle = {
|
|
43
|
+
shadowOffset: { width: 2, height: 2 },
|
|
44
|
+
shadowOpacity: 1,
|
|
45
|
+
shadowRadius: 6,
|
|
46
|
+
elevation: 18,
|
|
47
|
+
};
|
|
48
|
+
|
|
33
49
|
function HeaderToolbar( {
|
|
34
50
|
hasRedo,
|
|
35
51
|
hasUndo,
|
|
@@ -37,83 +53,129 @@ function HeaderToolbar( {
|
|
|
37
53
|
undo,
|
|
38
54
|
showInserter,
|
|
39
55
|
showKeyboardHideButton,
|
|
40
|
-
|
|
56
|
+
insertBlock,
|
|
41
57
|
onHideKeyboard,
|
|
42
58
|
isRTL,
|
|
43
59
|
noContentSelected,
|
|
44
60
|
} ) {
|
|
45
|
-
const
|
|
46
|
-
|
|
61
|
+
const anchorNodeRef = useRef();
|
|
62
|
+
|
|
63
|
+
const containerStyle = [
|
|
64
|
+
usePreferredColorSchemeStyle(
|
|
65
|
+
styles[ 'header-toolbar__container' ],
|
|
66
|
+
styles[ 'header-toolbar__container--dark' ]
|
|
67
|
+
),
|
|
68
|
+
{ borderTopWidth: StyleSheet.hairlineWidth },
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
useEffect( () => {
|
|
72
|
+
const onUndoSubscription = subscribeOnUndoPressed( undo );
|
|
73
|
+
const onRedoSubscription = subscribeOnRedoPressed( redo );
|
|
74
|
+
|
|
75
|
+
return () => {
|
|
76
|
+
onUndoSubscription?.remove();
|
|
77
|
+
onRedoSubscription?.remove();
|
|
78
|
+
};
|
|
79
|
+
}, [ undo, redo ] );
|
|
80
|
+
|
|
81
|
+
useEffect( () => {
|
|
82
|
+
toggleUndoButton( ! hasUndo );
|
|
83
|
+
}, [ hasUndo ] );
|
|
84
|
+
|
|
85
|
+
useEffect( () => {
|
|
86
|
+
toggleRedoButton( ! hasRedo );
|
|
87
|
+
}, [ hasRedo ] );
|
|
47
88
|
|
|
48
89
|
const scrollViewRef = useRef( null );
|
|
49
90
|
const scrollToStart = () => {
|
|
50
91
|
// scrollview doesn't seem to automatically adjust to RTL on Android so, scroll to end when Android
|
|
51
|
-
|
|
52
|
-
if ( isAndroid && isRTL ) {
|
|
92
|
+
if ( Platform.isAndroid && isRTL ) {
|
|
53
93
|
scrollViewRef.current.scrollToEnd();
|
|
54
94
|
} else {
|
|
55
95
|
scrollViewRef.current.scrollTo( { x: 0 } );
|
|
56
96
|
}
|
|
57
97
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
98
|
+
|
|
99
|
+
const onInsertBlock = useCallback(
|
|
100
|
+
( blockType ) => () => {
|
|
101
|
+
insertBlock( createBlock( blockType ), undefined, undefined, true, {
|
|
102
|
+
source: 'inserter_menu',
|
|
103
|
+
} );
|
|
104
|
+
},
|
|
105
|
+
[ insertBlock ]
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const renderMediaButtons = (
|
|
109
|
+
<ToolbarGroup>
|
|
61
110
|
<ToolbarButton
|
|
62
|
-
key="
|
|
63
|
-
title={ __( '
|
|
64
|
-
icon={
|
|
65
|
-
|
|
66
|
-
|
|
111
|
+
key="imageButton"
|
|
112
|
+
title={ __( 'Image' ) }
|
|
113
|
+
icon={ imageIcon }
|
|
114
|
+
onClick={ onInsertBlock( 'core/image' ) }
|
|
115
|
+
testID="insert-image-button"
|
|
67
116
|
extraProps={ {
|
|
68
|
-
hint: __( '
|
|
117
|
+
hint: __( 'Insert Image Block' ),
|
|
69
118
|
} }
|
|
70
|
-
|
|
119
|
+
/>
|
|
71
120
|
<ToolbarButton
|
|
72
|
-
key="
|
|
73
|
-
title={ __( '
|
|
74
|
-
icon={
|
|
75
|
-
|
|
76
|
-
|
|
121
|
+
key="videoButton"
|
|
122
|
+
title={ __( 'Video' ) }
|
|
123
|
+
icon={ videoIcon }
|
|
124
|
+
onClick={ onInsertBlock( 'core/video' ) }
|
|
125
|
+
testID="insert-video-button"
|
|
77
126
|
extraProps={ {
|
|
78
|
-
hint: __( '
|
|
127
|
+
hint: __( 'Insert Video Block' ),
|
|
79
128
|
} }
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
129
|
+
/>
|
|
130
|
+
<ToolbarButton
|
|
131
|
+
key="galleryButton"
|
|
132
|
+
title={ __( 'Gallery' ) }
|
|
133
|
+
icon={ galleryIcon }
|
|
134
|
+
onClick={ onInsertBlock( 'core/gallery' ) }
|
|
135
|
+
testID="insert-gallery-button"
|
|
136
|
+
extraProps={ {
|
|
137
|
+
hint: __( 'Insert Gallery Block' ),
|
|
138
|
+
} }
|
|
139
|
+
/>
|
|
140
|
+
<ToolbarButton
|
|
141
|
+
key="audioButton"
|
|
142
|
+
title={ __( 'Audio' ) }
|
|
143
|
+
icon={ audioIcon }
|
|
144
|
+
onClick={ onInsertBlock( 'core/audio' ) }
|
|
145
|
+
testID="insert-audio-button"
|
|
146
|
+
extraProps={ {
|
|
147
|
+
hint: __( 'Insert Audio Block' ),
|
|
148
|
+
} }
|
|
149
|
+
/>
|
|
150
|
+
</ToolbarGroup>
|
|
94
151
|
);
|
|
95
152
|
|
|
96
|
-
// Expanded mode should be preserved while the inserter is open.
|
|
97
|
-
// This way we prevent style updates during the opening transition.
|
|
98
|
-
const useExpandedMode = isInserterOpen
|
|
99
|
-
? wasNoContentSelected.current
|
|
100
|
-
: noContentSelected;
|
|
101
|
-
|
|
102
153
|
/* translators: accessibility text for the editor toolbar */
|
|
103
154
|
const toolbarAriaLabel = __( 'Document tools' );
|
|
104
155
|
|
|
156
|
+
const shadowColor = usePreferredColorSchemeStyle(
|
|
157
|
+
styles[ 'header-toolbar__keyboard-hide-shadow--light' ],
|
|
158
|
+
styles[ 'header-toolbar__keyboard-hide-shadow--dark' ]
|
|
159
|
+
);
|
|
160
|
+
const showKeyboardButtonStyles = [
|
|
161
|
+
usePreferredColorSchemeStyle(
|
|
162
|
+
styles[ 'header-toolbar__keyboard-hide-container' ],
|
|
163
|
+
styles[ 'header-toolbar__keyboard-hide-container--dark' ]
|
|
164
|
+
),
|
|
165
|
+
shadowStyle,
|
|
166
|
+
{
|
|
167
|
+
shadowColor: Platform.isAndroid
|
|
168
|
+
? styles[ 'header-toolbar__keyboard-hide-shadow--solid' ].color
|
|
169
|
+
: shadowColor.color,
|
|
170
|
+
},
|
|
171
|
+
];
|
|
172
|
+
|
|
105
173
|
return (
|
|
106
174
|
<View
|
|
175
|
+
ref={ anchorNodeRef }
|
|
107
176
|
testID={ toolbarAriaLabel }
|
|
108
177
|
accessibilityLabel={ toolbarAriaLabel }
|
|
109
|
-
style={
|
|
110
|
-
getStylesFromColorScheme(
|
|
111
|
-
styles[ 'header-toolbar__container' ],
|
|
112
|
-
styles[ 'header-toolbar__container--dark' ]
|
|
113
|
-
),
|
|
114
|
-
useExpandedMode &&
|
|
115
|
-
styles[ 'header-toolbar__container--expanded' ],
|
|
116
|
-
] }
|
|
178
|
+
style={ containerStyle }
|
|
117
179
|
>
|
|
118
180
|
<ScrollView
|
|
119
181
|
ref={ scrollViewRef }
|
|
@@ -126,20 +188,13 @@ function HeaderToolbar( {
|
|
|
126
188
|
styles[ 'header-toolbar__scrollable-content' ]
|
|
127
189
|
}
|
|
128
190
|
>
|
|
129
|
-
<Inserter
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
/>
|
|
134
|
-
{ renderHistoryButtons() }
|
|
135
|
-
<BlockToolbar />
|
|
191
|
+
<Inserter disabled={ ! showInserter } />
|
|
192
|
+
|
|
193
|
+
{ noContentSelected && renderMediaButtons }
|
|
194
|
+
<BlockToolbar anchorNodeRef={ anchorNodeRef.current } />
|
|
136
195
|
</ScrollView>
|
|
137
196
|
{ showKeyboardHideButton && (
|
|
138
|
-
<ToolbarGroup
|
|
139
|
-
passedStyle={
|
|
140
|
-
styles[ 'header-toolbar__keyboard-hide-container' ]
|
|
141
|
-
}
|
|
142
|
-
>
|
|
197
|
+
<ToolbarGroup passedStyle={ showKeyboardButtonStyles }>
|
|
143
198
|
<ToolbarButton
|
|
144
199
|
title={ __( 'Hide keyboard' ) }
|
|
145
200
|
icon={ keyboardClose }
|
|
@@ -181,7 +236,8 @@ export default compose( [
|
|
|
181
236
|
};
|
|
182
237
|
} ),
|
|
183
238
|
withDispatch( ( dispatch ) => {
|
|
184
|
-
const { clearSelectedBlock } =
|
|
239
|
+
const { clearSelectedBlock, insertBlock } =
|
|
240
|
+
dispatch( blockEditorStore );
|
|
185
241
|
const { togglePostTitleSelection } = dispatch( editorStore );
|
|
186
242
|
|
|
187
243
|
return {
|
|
@@ -191,8 +247,8 @@ export default compose( [
|
|
|
191
247
|
clearSelectedBlock();
|
|
192
248
|
togglePostTitleSelection( false );
|
|
193
249
|
},
|
|
250
|
+
insertBlock,
|
|
194
251
|
};
|
|
195
252
|
} ),
|
|
196
253
|
withViewportMatch( { isLargeViewport: 'medium' } ),
|
|
197
|
-
withPreferredColorScheme,
|
|
198
254
|
] )( HeaderToolbar );
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
height: $mobile-header-toolbar-height;
|
|
4
4
|
flex-direction: row;
|
|
5
5
|
background-color: $app-background;
|
|
6
|
-
border-top-color:
|
|
7
|
-
|
|
6
|
+
border-top-color: $light-quaternary;
|
|
7
|
+
overflow: hidden;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.header-toolbar__container--dark {
|
|
11
|
-
background-color: $app-background-dark
|
|
12
|
-
border-top-color: $
|
|
11
|
+
background-color: $app-safe-area-background-dark;
|
|
12
|
+
border-top-color: $dark-quaternary;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
.header-toolbar__container--expanded {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
.header-toolbar__scrollable-content {
|
|
20
20
|
flex-grow: 1; // Fixes RTL issue on Android.
|
|
21
|
+
padding-right: 8px;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
.header-toolbar__keyboard-hide-container {
|
|
@@ -27,4 +28,22 @@
|
|
|
27
28
|
width: 44px;
|
|
28
29
|
justify-content: center;
|
|
29
30
|
align-items: center;
|
|
31
|
+
border-color: transparent;
|
|
32
|
+
background-color: $app-background;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.header-toolbar__keyboard-hide-container--dark {
|
|
36
|
+
background-color: $app-background-dark-alt;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.header-toolbar__keyboard-hide-shadow--solid {
|
|
40
|
+
color: $black;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.header-toolbar__keyboard-hide-shadow--light {
|
|
44
|
+
color: $light-quaternary;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.header-toolbar__keyboard-hide-shadow--dark {
|
|
48
|
+
color: $light-primary;
|
|
30
49
|
}
|
|
@@ -20,34 +20,29 @@ import MainDashboardButton from './main-dashboard-button';
|
|
|
20
20
|
import { store as editPostStore } from '../../store';
|
|
21
21
|
import DocumentTitle from './document-title';
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
isPublishSidebarOpened,
|
|
28
|
-
isSaving,
|
|
29
|
-
showIconLabels,
|
|
30
|
-
} = useSelect(
|
|
31
|
-
( select ) => ( {
|
|
32
|
-
hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
|
|
33
|
-
isPublishSidebarOpened:
|
|
34
|
-
select( editPostStore ).isPublishSidebarOpened(),
|
|
35
|
-
isSaving: select( editPostStore ).isSavingMetaBoxes(),
|
|
36
|
-
showIconLabels:
|
|
37
|
-
select( editPostStore ).isFeatureActive( 'showIconLabels' ),
|
|
38
|
-
} ),
|
|
39
|
-
[]
|
|
40
|
-
);
|
|
23
|
+
const slideY = {
|
|
24
|
+
hidden: { y: '-50px' },
|
|
25
|
+
hover: { y: 0, transition: { type: 'tween', delay: 0.2 } },
|
|
26
|
+
};
|
|
41
27
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
28
|
+
const slideX = {
|
|
29
|
+
hidden: { x: '-100%' },
|
|
30
|
+
hover: { x: 0, transition: { type: 'tween', delay: 0.2 } },
|
|
31
|
+
};
|
|
46
32
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
33
|
+
function Header( { setEntitiesSavedStatesCallback } ) {
|
|
34
|
+
const isLargeViewport = useViewportMatch( 'large' );
|
|
35
|
+
const { hasActiveMetaboxes, isPublishSidebarOpened, showIconLabels } =
|
|
36
|
+
useSelect(
|
|
37
|
+
( select ) => ( {
|
|
38
|
+
hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
|
|
39
|
+
isPublishSidebarOpened:
|
|
40
|
+
select( editPostStore ).isPublishSidebarOpened(),
|
|
41
|
+
showIconLabels:
|
|
42
|
+
select( editPostStore ).isFeatureActive( 'showIconLabels' ),
|
|
43
|
+
} ),
|
|
44
|
+
[]
|
|
45
|
+
);
|
|
51
46
|
|
|
52
47
|
return (
|
|
53
48
|
<div className="edit-post-header">
|
|
@@ -82,19 +77,14 @@ function Header( { setEntitiesSavedStatesCallback } ) {
|
|
|
82
77
|
// when the publish sidebar has been closed.
|
|
83
78
|
<PostSavedState
|
|
84
79
|
forceIsDirty={ hasActiveMetaboxes }
|
|
85
|
-
forceIsSaving={ isSaving }
|
|
86
80
|
showIconLabels={ showIconLabels }
|
|
87
81
|
/>
|
|
88
82
|
) }
|
|
89
83
|
<DevicePreview />
|
|
90
|
-
<PostPreviewButton
|
|
91
|
-
forceIsAutosaveable={ hasActiveMetaboxes }
|
|
92
|
-
forcePreviewLink={ isSaving ? null : undefined }
|
|
93
|
-
/>
|
|
84
|
+
<PostPreviewButton forceIsAutosaveable={ hasActiveMetaboxes } />
|
|
94
85
|
<ViewLink />
|
|
95
86
|
<PostPublishButtonOrToggle
|
|
96
87
|
forceIsDirty={ hasActiveMetaboxes }
|
|
97
|
-
forceIsSaving={ isSaving }
|
|
98
88
|
setEntitiesSavedStatesCallback={
|
|
99
89
|
setEntitiesSavedStatesCallback
|
|
100
90
|
}
|
|
@@ -12,7 +12,6 @@ import { store as editPostStore } from '../../store';
|
|
|
12
12
|
|
|
13
13
|
export function PostPublishButtonOrToggle( {
|
|
14
14
|
forceIsDirty,
|
|
15
|
-
forceIsSaving,
|
|
16
15
|
hasPublishAction,
|
|
17
16
|
isBeingScheduled,
|
|
18
17
|
isPending,
|
|
@@ -67,7 +66,6 @@ export function PostPublishButtonOrToggle( {
|
|
|
67
66
|
return (
|
|
68
67
|
<PostPublishButton
|
|
69
68
|
forceIsDirty={ forceIsDirty }
|
|
70
|
-
forceIsSaving={ forceIsSaving }
|
|
71
69
|
isOpen={ isPublishSidebarOpened }
|
|
72
70
|
isToggle={ component === IS_TOGGLE }
|
|
73
71
|
onToggle={ togglePublishSidebar }
|
|
@@ -4,18 +4,19 @@
|
|
|
4
4
|
import { useDispatch } from '@wordpress/data';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
import { MenuItem } from '@wordpress/components';
|
|
7
|
+
import { store as interfaceStore } from '@wordpress/interface';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Internal dependencies
|
|
10
11
|
*/
|
|
11
|
-
import {
|
|
12
|
+
import { PREFERENCES_MODAL_NAME } from '../../../components/preferences-modal';
|
|
12
13
|
|
|
13
14
|
export default function PreferencesMenuItem() {
|
|
14
|
-
const { openModal } = useDispatch(
|
|
15
|
+
const { openModal } = useDispatch( interfaceStore );
|
|
15
16
|
return (
|
|
16
17
|
<MenuItem
|
|
17
18
|
onClick={ () => {
|
|
18
|
-
openModal(
|
|
19
|
+
openModal( PREFERENCES_MODAL_NAME );
|
|
19
20
|
} }
|
|
20
21
|
>
|
|
21
22
|
{ __( 'Preferences' ) }
|