@wordpress/edit-post 7.14.0 → 7.16.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/{document-title → document-actions}/index.js +10 -11
- package/build/components/header/document-actions/index.js.map +1 -0
- package/build/components/header/header-toolbar/index.js +7 -6
- package/build/components/header/header-toolbar/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.native.js +92 -49
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/index.js +4 -9
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/mode-switcher/index.js +23 -4
- package/build/components/header/mode-switcher/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/layout/actions-panel.js +5 -10
- package/build/components/layout/actions-panel.js.map +1 -1
- package/build/components/layout/index.js +36 -13
- package/build/components/layout/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +2 -2
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/discussion-panel/index.js +20 -20
- package/build/components/sidebar/discussion-panel/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 +2 -39
- package/build/editor.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +61 -4
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/plugins/index.js +35 -6
- package/build/plugins/index.js.map +1 -1
- package/build/store/actions.js +12 -14
- package/build/store/actions.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/{document-title → document-actions}/index.js +10 -11
- package/build-module/components/header/document-actions/index.js.map +1 -0
- package/build-module/components/header/header-toolbar/index.js +7 -6
- package/build-module/components/header/header-toolbar/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.native.js +93 -53
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/index.js +4 -9
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/mode-switcher/index.js +23 -4
- package/build-module/components/header/mode-switcher/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/layout/actions-panel.js +5 -10
- package/build-module/components/layout/actions-panel.js.map +1 -1
- package/build-module/components/layout/index.js +37 -14
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +3 -3
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/discussion-panel/index.js +21 -19
- package/build-module/components/sidebar/discussion-panel/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 -38
- package/build-module/editor.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +60 -5
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/index.js +2 -1
- package/build-module/index.js.map +1 -1
- package/build-module/plugins/index.js +33 -6
- package/build-module/plugins/index.js.map +1 -1
- package/build-module/store/actions.js +11 -14
- package/build-module/store/actions.js.map +1 -1
- package/build-style/style-rtl.css +30 -31
- package/build-style/style.css +30 -31
- package/package.json +32 -32
- package/src/components/device-preview/index.js +35 -39
- package/src/components/header/{document-title → document-actions}/index.js +22 -23
- package/src/components/header/{document-title → document-actions}/style.scss +25 -22
- package/src/components/header/header-toolbar/index.js +3 -2
- package/src/components/header/header-toolbar/index.native.js +125 -68
- package/src/components/header/header-toolbar/style.native.scss +23 -4
- package/src/components/header/header-toolbar/style.scss +4 -0
- package/src/components/header/index.js +15 -25
- package/src/components/header/mode-switcher/index.js +23 -4
- package/src/components/header/post-publish-button-or-toggle.js +0 -2
- package/src/components/header/style.scss +1 -1
- package/src/components/layout/actions-panel.js +5 -7
- package/src/components/layout/index.js +45 -9
- package/src/components/layout/style.native.scss +1 -1
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +16 -5
- package/src/components/preferences-modal/test/index.js +4 -4
- package/src/components/secondary-sidebar/list-view-sidebar.js +3 -3
- package/src/components/sidebar/discussion-panel/index.js +15 -20
- 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 -47
- package/src/hooks/commands/use-common-commands.js +81 -15
- package/src/index.js +5 -1
- package/src/plugins/index.js +32 -8
- package/src/store/actions.js +18 -27
- package/src/style.scss +2 -8
- package/src/test/editor.native.js +4 -3
- package/build/components/header/document-title/index.js.map +0 -1
- package/build-module/components/header/document-title/index.js.map +0 -1
- package/src/components/visual-editor/style.native.scss +0 -18
|
@@ -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,7 +19,7 @@ import { displayShortcut } from '@wordpress/keycodes';
|
|
|
19
19
|
*/
|
|
20
20
|
import { store as editPostStore } from '../../../store';
|
|
21
21
|
|
|
22
|
-
function
|
|
22
|
+
function DocumentActions() {
|
|
23
23
|
const { template, isEditing } = useSelect( ( select ) => {
|
|
24
24
|
const { isEditingTemplate, getEditedPostTemplate } =
|
|
25
25
|
select( editPostStore );
|
|
@@ -46,24 +46,26 @@ function DocumentTitle() {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
return (
|
|
49
|
-
<div className="edit-post-document-
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
</span>
|
|
61
|
-
|
|
49
|
+
<div className="edit-post-document-actions">
|
|
50
|
+
<Button
|
|
51
|
+
className="edit-post-document-actions__back"
|
|
52
|
+
onClick={ () => {
|
|
53
|
+
clearSelectedBlock();
|
|
54
|
+
setIsEditingTemplate( false );
|
|
55
|
+
} }
|
|
56
|
+
icon={ isRTL() ? chevronRightSmall : chevronLeftSmall }
|
|
57
|
+
>
|
|
58
|
+
{ __( 'Back' ) }
|
|
59
|
+
</Button>
|
|
62
60
|
<Button
|
|
63
|
-
className="edit-post-document-
|
|
61
|
+
className="edit-post-document-actions__command"
|
|
64
62
|
onClick={ () => openCommandCenter() }
|
|
65
63
|
>
|
|
66
|
-
<HStack
|
|
64
|
+
<HStack
|
|
65
|
+
className="edit-post-document-actions__title"
|
|
66
|
+
spacing={ 1 }
|
|
67
|
+
justify="center"
|
|
68
|
+
>
|
|
67
69
|
<BlockIcon icon={ layout } />
|
|
68
70
|
<Text size="body" as="h1">
|
|
69
71
|
<VisuallyHidden as="span">
|
|
@@ -72,15 +74,12 @@ function DocumentTitle() {
|
|
|
72
74
|
{ templateTitle }
|
|
73
75
|
</Text>
|
|
74
76
|
</HStack>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
onClick={ () => openCommandCenter() }
|
|
79
|
-
>
|
|
80
|
-
{ displayShortcut.primary( 'k' ) }
|
|
77
|
+
<span className="edit-post-document-actions__shortcut">
|
|
78
|
+
{ displayShortcut.primary( 'k' ) }
|
|
79
|
+
</span>
|
|
81
80
|
</Button>
|
|
82
81
|
</div>
|
|
83
82
|
);
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
export default
|
|
85
|
+
export default DocumentActions;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.edit-post-document-
|
|
1
|
+
.edit-post-document-actions {
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
gap: $grid-unit;
|
|
@@ -13,13 +13,21 @@
|
|
|
13
13
|
border-radius: 4px;
|
|
14
14
|
width: min(100%, 450px);
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
.components-button {
|
|
17
|
+
&:hover {
|
|
18
|
+
color: var(--wp-block-synced-color);
|
|
19
|
+
background: $gray-200;
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
.edit-post-document-
|
|
24
|
+
.edit-post-document-actions__command {
|
|
25
|
+
flex-grow: 1;
|
|
26
|
+
color: var(--wp-block-synced-color);
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.edit-post-document-actions__title {
|
|
23
31
|
flex-grow: 1;
|
|
24
32
|
color: var(--wp-block-synced-color);
|
|
25
33
|
overflow: hidden;
|
|
@@ -28,34 +36,29 @@
|
|
|
28
36
|
color: var(--wp-block-synced-color);
|
|
29
37
|
}
|
|
30
38
|
|
|
39
|
+
.block-editor-block-icon {
|
|
40
|
+
flex-shrink: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
31
43
|
h1 {
|
|
32
|
-
color: var(--wp-block-synced-color);
|
|
33
44
|
white-space: nowrap;
|
|
34
45
|
overflow: hidden;
|
|
35
46
|
text-overflow: ellipsis;
|
|
47
|
+
color: var(--wp-block-synced-color);
|
|
36
48
|
}
|
|
37
49
|
}
|
|
38
50
|
|
|
39
|
-
.edit-post-document-
|
|
40
|
-
|
|
41
|
-
color: $gray-700;
|
|
42
|
-
padding: 0 $grid-unit-15;
|
|
43
|
-
|
|
44
|
-
&:hover {
|
|
45
|
-
color: $gray-700;
|
|
46
|
-
}
|
|
51
|
+
.edit-post-document-actions__shortcut {
|
|
52
|
+
color: $gray-800;
|
|
47
53
|
}
|
|
48
54
|
|
|
49
|
-
.edit-post-document-
|
|
55
|
+
.edit-post-document-actions__back.components-button.has-icon.has-text {
|
|
50
56
|
min-width: $button-size;
|
|
51
57
|
flex-shrink: 0;
|
|
58
|
+
color: $gray-700;
|
|
59
|
+
gap: 0;
|
|
52
60
|
|
|
53
|
-
|
|
54
|
-
color:
|
|
55
|
-
gap: 0;
|
|
56
|
-
|
|
57
|
-
&:hover {
|
|
58
|
-
color: currentColor;
|
|
59
|
-
}
|
|
61
|
+
&:hover {
|
|
62
|
+
color: currentColor;
|
|
60
63
|
}
|
|
61
64
|
}
|
|
@@ -37,8 +37,6 @@ function HeaderToolbar() {
|
|
|
37
37
|
const inserterButton = useRef();
|
|
38
38
|
const { setIsInserterOpened, setIsListViewOpened } =
|
|
39
39
|
useDispatch( editPostStore );
|
|
40
|
-
const { get: getPreference } = useSelect( preferencesStore );
|
|
41
|
-
const hasFixedToolbar = getPreference( 'core/edit-post', 'fixedToolbar' );
|
|
42
40
|
const {
|
|
43
41
|
isInserterEnabled,
|
|
44
42
|
isInserterOpened,
|
|
@@ -46,6 +44,7 @@ function HeaderToolbar() {
|
|
|
46
44
|
showIconLabels,
|
|
47
45
|
isListViewOpen,
|
|
48
46
|
listViewShortcut,
|
|
47
|
+
hasFixedToolbar,
|
|
49
48
|
} = useSelect( ( select ) => {
|
|
50
49
|
const { hasInserterItems, getBlockRootClientId, getBlockSelectionEnd } =
|
|
51
50
|
select( blockEditorStore );
|
|
@@ -53,6 +52,7 @@ function HeaderToolbar() {
|
|
|
53
52
|
const { getEditorMode, isFeatureActive, isListViewOpened } =
|
|
54
53
|
select( editPostStore );
|
|
55
54
|
const { getShortcutRepresentation } = select( keyboardShortcutsStore );
|
|
55
|
+
const { get: getPreference } = select( preferencesStore );
|
|
56
56
|
|
|
57
57
|
return {
|
|
58
58
|
// This setting (richEditingEnabled) should not live in the block editor's setting.
|
|
@@ -69,6 +69,7 @@ function HeaderToolbar() {
|
|
|
69
69
|
listViewShortcut: getShortcutRepresentation(
|
|
70
70
|
'core/edit-post/toggle-list-view'
|
|
71
71
|
),
|
|
72
|
+
hasFixedToolbar: getPreference( 'core/edit-post', 'fixedToolbar' ),
|
|
72
73
|
};
|
|
73
74
|
}, [] );
|
|
74
75
|
|
|
@@ -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,130 @@ 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
|
+
inserterMethod: 'quick-inserter',
|
|
104
|
+
} );
|
|
105
|
+
},
|
|
106
|
+
[ insertBlock ]
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const renderMediaButtons = (
|
|
110
|
+
<ToolbarGroup>
|
|
61
111
|
<ToolbarButton
|
|
62
|
-
key="
|
|
63
|
-
title={ __( '
|
|
64
|
-
icon={
|
|
65
|
-
|
|
66
|
-
|
|
112
|
+
key="imageButton"
|
|
113
|
+
title={ __( 'Image' ) }
|
|
114
|
+
icon={ imageIcon }
|
|
115
|
+
onClick={ onInsertBlock( 'core/image' ) }
|
|
116
|
+
testID="insert-image-button"
|
|
67
117
|
extraProps={ {
|
|
68
|
-
hint: __( '
|
|
118
|
+
hint: __( 'Insert Image Block' ),
|
|
69
119
|
} }
|
|
70
|
-
|
|
120
|
+
/>
|
|
71
121
|
<ToolbarButton
|
|
72
|
-
key="
|
|
73
|
-
title={ __( '
|
|
74
|
-
icon={
|
|
75
|
-
|
|
76
|
-
|
|
122
|
+
key="videoButton"
|
|
123
|
+
title={ __( 'Video' ) }
|
|
124
|
+
icon={ videoIcon }
|
|
125
|
+
onClick={ onInsertBlock( 'core/video' ) }
|
|
126
|
+
testID="insert-video-button"
|
|
77
127
|
extraProps={ {
|
|
78
|
-
hint: __( '
|
|
128
|
+
hint: __( 'Insert Video Block' ),
|
|
79
129
|
} }
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
130
|
+
/>
|
|
131
|
+
<ToolbarButton
|
|
132
|
+
key="galleryButton"
|
|
133
|
+
title={ __( 'Gallery' ) }
|
|
134
|
+
icon={ galleryIcon }
|
|
135
|
+
onClick={ onInsertBlock( 'core/gallery' ) }
|
|
136
|
+
testID="insert-gallery-button"
|
|
137
|
+
extraProps={ {
|
|
138
|
+
hint: __( 'Insert Gallery Block' ),
|
|
139
|
+
} }
|
|
140
|
+
/>
|
|
141
|
+
<ToolbarButton
|
|
142
|
+
key="audioButton"
|
|
143
|
+
title={ __( 'Audio' ) }
|
|
144
|
+
icon={ audioIcon }
|
|
145
|
+
onClick={ onInsertBlock( 'core/audio' ) }
|
|
146
|
+
testID="insert-audio-button"
|
|
147
|
+
extraProps={ {
|
|
148
|
+
hint: __( 'Insert Audio Block' ),
|
|
149
|
+
} }
|
|
150
|
+
/>
|
|
151
|
+
</ToolbarGroup>
|
|
94
152
|
);
|
|
95
153
|
|
|
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
154
|
/* translators: accessibility text for the editor toolbar */
|
|
103
155
|
const toolbarAriaLabel = __( 'Document tools' );
|
|
104
156
|
|
|
157
|
+
const shadowColor = usePreferredColorSchemeStyle(
|
|
158
|
+
styles[ 'header-toolbar__keyboard-hide-shadow--light' ],
|
|
159
|
+
styles[ 'header-toolbar__keyboard-hide-shadow--dark' ]
|
|
160
|
+
);
|
|
161
|
+
const showKeyboardButtonStyles = [
|
|
162
|
+
usePreferredColorSchemeStyle(
|
|
163
|
+
styles[ 'header-toolbar__keyboard-hide-container' ],
|
|
164
|
+
styles[ 'header-toolbar__keyboard-hide-container--dark' ]
|
|
165
|
+
),
|
|
166
|
+
shadowStyle,
|
|
167
|
+
{
|
|
168
|
+
shadowColor: Platform.isAndroid
|
|
169
|
+
? styles[ 'header-toolbar__keyboard-hide-shadow--solid' ].color
|
|
170
|
+
: shadowColor.color,
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
|
|
105
174
|
return (
|
|
106
175
|
<View
|
|
176
|
+
ref={ anchorNodeRef }
|
|
107
177
|
testID={ toolbarAriaLabel }
|
|
108
178
|
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
|
-
] }
|
|
179
|
+
style={ containerStyle }
|
|
117
180
|
>
|
|
118
181
|
<ScrollView
|
|
119
182
|
ref={ scrollViewRef }
|
|
@@ -126,20 +189,13 @@ function HeaderToolbar( {
|
|
|
126
189
|
styles[ 'header-toolbar__scrollable-content' ]
|
|
127
190
|
}
|
|
128
191
|
>
|
|
129
|
-
<Inserter
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
/>
|
|
134
|
-
{ renderHistoryButtons() }
|
|
135
|
-
<BlockToolbar />
|
|
192
|
+
<Inserter disabled={ ! showInserter } />
|
|
193
|
+
|
|
194
|
+
{ noContentSelected && renderMediaButtons }
|
|
195
|
+
<BlockToolbar anchorNodeRef={ anchorNodeRef.current } />
|
|
136
196
|
</ScrollView>
|
|
137
197
|
{ showKeyboardHideButton && (
|
|
138
|
-
<ToolbarGroup
|
|
139
|
-
passedStyle={
|
|
140
|
-
styles[ 'header-toolbar__keyboard-hide-container' ]
|
|
141
|
-
}
|
|
142
|
-
>
|
|
198
|
+
<ToolbarGroup passedStyle={ showKeyboardButtonStyles }>
|
|
143
199
|
<ToolbarButton
|
|
144
200
|
title={ __( 'Hide keyboard' ) }
|
|
145
201
|
icon={ keyboardClose }
|
|
@@ -181,7 +237,8 @@ export default compose( [
|
|
|
181
237
|
};
|
|
182
238
|
} ),
|
|
183
239
|
withDispatch( ( dispatch ) => {
|
|
184
|
-
const { clearSelectedBlock } =
|
|
240
|
+
const { clearSelectedBlock, insertBlock } =
|
|
241
|
+
dispatch( blockEditorStore );
|
|
185
242
|
const { togglePostTitleSelection } = dispatch( editorStore );
|
|
186
243
|
|
|
187
244
|
return {
|
|
@@ -191,8 +248,8 @@ export default compose( [
|
|
|
191
248
|
clearSelectedBlock();
|
|
192
249
|
togglePostTitleSelection( false );
|
|
193
250
|
},
|
|
251
|
+
insertBlock,
|
|
194
252
|
};
|
|
195
253
|
} ),
|
|
196
254
|
withViewportMatch( { isLargeViewport: 'medium' } ),
|
|
197
|
-
withPreferredColorScheme,
|
|
198
255
|
] )( 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
|
}
|
|
@@ -82,6 +82,10 @@
|
|
|
82
82
|
align-items: center;
|
|
83
83
|
padding-left: $grid-unit-10;
|
|
84
84
|
|
|
85
|
+
// Some plugins add buttons here despite best practices.
|
|
86
|
+
// Push them a bit rightwards to fit the top toolbar.
|
|
87
|
+
margin-right: $grid-unit-10;
|
|
88
|
+
|
|
85
89
|
@include break-small() {
|
|
86
90
|
padding-left: $grid-unit-30;
|
|
87
91
|
}
|
|
@@ -18,7 +18,7 @@ import { default as DevicePreview } from '../device-preview';
|
|
|
18
18
|
import ViewLink from '../view-link';
|
|
19
19
|
import MainDashboardButton from './main-dashboard-button';
|
|
20
20
|
import { store as editPostStore } from '../../store';
|
|
21
|
-
import
|
|
21
|
+
import DocumentActions from './document-actions';
|
|
22
22
|
|
|
23
23
|
const slideY = {
|
|
24
24
|
hidden: { y: '-50px' },
|
|
@@ -32,22 +32,17 @@ const slideX = {
|
|
|
32
32
|
|
|
33
33
|
function Header( { setEntitiesSavedStatesCallback } ) {
|
|
34
34
|
const isLargeViewport = useViewportMatch( 'large' );
|
|
35
|
-
const {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
showIconLabels:
|
|
47
|
-
select( editPostStore ).isFeatureActive( 'showIconLabels' ),
|
|
48
|
-
} ),
|
|
49
|
-
[]
|
|
50
|
-
);
|
|
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">
|
|
@@ -65,8 +60,8 @@ function Header( { setEntitiesSavedStatesCallback } ) {
|
|
|
65
60
|
className="edit-post-header__toolbar"
|
|
66
61
|
>
|
|
67
62
|
<HeaderToolbar />
|
|
68
|
-
<div className="edit-post-
|
|
69
|
-
<
|
|
63
|
+
<div className="edit-post-header__center">
|
|
64
|
+
<DocumentActions />
|
|
70
65
|
</div>
|
|
71
66
|
</motion.div>
|
|
72
67
|
<motion.div
|
|
@@ -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
|
}
|