@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.
Files changed (113) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/device-preview/index.js +6 -6
  3. package/build/components/device-preview/index.js.map +1 -1
  4. package/build/components/header/{document-title → document-actions}/index.js +10 -11
  5. package/build/components/header/document-actions/index.js.map +1 -0
  6. package/build/components/header/header-toolbar/index.js +7 -6
  7. package/build/components/header/header-toolbar/index.js.map +1 -1
  8. package/build/components/header/header-toolbar/index.native.js +92 -49
  9. package/build/components/header/header-toolbar/index.native.js.map +1 -1
  10. package/build/components/header/index.js +4 -9
  11. package/build/components/header/index.js.map +1 -1
  12. package/build/components/header/mode-switcher/index.js +23 -4
  13. package/build/components/header/mode-switcher/index.js.map +1 -1
  14. package/build/components/header/post-publish-button-or-toggle.js +0 -2
  15. package/build/components/header/post-publish-button-or-toggle.js.map +1 -1
  16. package/build/components/layout/actions-panel.js +5 -10
  17. package/build/components/layout/actions-panel.js.map +1 -1
  18. package/build/components/layout/index.js +36 -13
  19. package/build/components/layout/index.js.map +1 -1
  20. package/build/components/secondary-sidebar/list-view-sidebar.js +2 -2
  21. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  22. package/build/components/sidebar/discussion-panel/index.js +20 -20
  23. package/build/components/sidebar/discussion-panel/index.js.map +1 -1
  24. package/build/components/text-editor/index.js +1 -1
  25. package/build/components/text-editor/index.js.map +1 -1
  26. package/build/components/visual-editor/header.native.js +1 -13
  27. package/build/components/visual-editor/header.native.js.map +1 -1
  28. package/build/components/visual-editor/index.js +1 -1
  29. package/build/components/visual-editor/index.js.map +1 -1
  30. package/build/editor.js +2 -39
  31. package/build/editor.js.map +1 -1
  32. package/build/hooks/commands/use-common-commands.js +61 -4
  33. package/build/hooks/commands/use-common-commands.js.map +1 -1
  34. package/build/index.js +2 -1
  35. package/build/index.js.map +1 -1
  36. package/build/plugins/index.js +35 -6
  37. package/build/plugins/index.js.map +1 -1
  38. package/build/store/actions.js +12 -14
  39. package/build/store/actions.js.map +1 -1
  40. package/build-module/components/device-preview/index.js +6 -6
  41. package/build-module/components/device-preview/index.js.map +1 -1
  42. package/build-module/components/header/{document-title → document-actions}/index.js +10 -11
  43. package/build-module/components/header/document-actions/index.js.map +1 -0
  44. package/build-module/components/header/header-toolbar/index.js +7 -6
  45. package/build-module/components/header/header-toolbar/index.js.map +1 -1
  46. package/build-module/components/header/header-toolbar/index.native.js +93 -53
  47. package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
  48. package/build-module/components/header/index.js +4 -9
  49. package/build-module/components/header/index.js.map +1 -1
  50. package/build-module/components/header/mode-switcher/index.js +23 -4
  51. package/build-module/components/header/mode-switcher/index.js.map +1 -1
  52. package/build-module/components/header/post-publish-button-or-toggle.js +0 -2
  53. package/build-module/components/header/post-publish-button-or-toggle.js.map +1 -1
  54. package/build-module/components/layout/actions-panel.js +5 -10
  55. package/build-module/components/layout/actions-panel.js.map +1 -1
  56. package/build-module/components/layout/index.js +37 -14
  57. package/build-module/components/layout/index.js.map +1 -1
  58. package/build-module/components/secondary-sidebar/list-view-sidebar.js +3 -3
  59. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  60. package/build-module/components/sidebar/discussion-panel/index.js +21 -19
  61. package/build-module/components/sidebar/discussion-panel/index.js.map +1 -1
  62. package/build-module/components/text-editor/index.js +2 -2
  63. package/build-module/components/text-editor/index.js.map +1 -1
  64. package/build-module/components/visual-editor/header.native.js +1 -10
  65. package/build-module/components/visual-editor/header.native.js.map +1 -1
  66. package/build-module/components/visual-editor/index.js +2 -2
  67. package/build-module/components/visual-editor/index.js.map +1 -1
  68. package/build-module/editor.js +2 -38
  69. package/build-module/editor.js.map +1 -1
  70. package/build-module/hooks/commands/use-common-commands.js +60 -5
  71. package/build-module/hooks/commands/use-common-commands.js.map +1 -1
  72. package/build-module/index.js +2 -1
  73. package/build-module/index.js.map +1 -1
  74. package/build-module/plugins/index.js +33 -6
  75. package/build-module/plugins/index.js.map +1 -1
  76. package/build-module/store/actions.js +11 -14
  77. package/build-module/store/actions.js.map +1 -1
  78. package/build-style/style-rtl.css +30 -31
  79. package/build-style/style.css +30 -31
  80. package/package.json +32 -32
  81. package/src/components/device-preview/index.js +35 -39
  82. package/src/components/header/{document-title → document-actions}/index.js +22 -23
  83. package/src/components/header/{document-title → document-actions}/style.scss +25 -22
  84. package/src/components/header/header-toolbar/index.js +3 -2
  85. package/src/components/header/header-toolbar/index.native.js +125 -68
  86. package/src/components/header/header-toolbar/style.native.scss +23 -4
  87. package/src/components/header/header-toolbar/style.scss +4 -0
  88. package/src/components/header/index.js +15 -25
  89. package/src/components/header/mode-switcher/index.js +23 -4
  90. package/src/components/header/post-publish-button-or-toggle.js +0 -2
  91. package/src/components/header/style.scss +1 -1
  92. package/src/components/layout/actions-panel.js +5 -7
  93. package/src/components/layout/index.js +45 -9
  94. package/src/components/layout/style.native.scss +1 -1
  95. package/src/components/preferences-modal/test/__snapshots__/index.js.snap +16 -5
  96. package/src/components/preferences-modal/test/index.js +4 -4
  97. package/src/components/secondary-sidebar/list-view-sidebar.js +3 -3
  98. package/src/components/sidebar/discussion-panel/index.js +15 -20
  99. package/src/components/text-editor/index.js +0 -2
  100. package/src/components/visual-editor/header.native.js +1 -17
  101. package/src/components/visual-editor/index.js +1 -6
  102. package/src/components/visual-editor/test/__snapshots__/index.native.js.snap +15 -0
  103. package/src/components/visual-editor/test/index.native.js +118 -1
  104. package/src/editor.js +2 -47
  105. package/src/hooks/commands/use-common-commands.js +81 -15
  106. package/src/index.js +5 -1
  107. package/src/plugins/index.js +32 -8
  108. package/src/store/actions.js +18 -27
  109. package/src/style.scss +2 -8
  110. package/src/test/editor.native.js +4 -3
  111. package/build/components/header/document-title/index.js.map +0 -1
  112. package/build-module/components/header/document-title/index.js.map +0 -1
  113. 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
- hasActiveMetaboxes,
20
- isPostSaveable,
21
- isSaving,
22
- isViewable,
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
- return {
30
- hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
31
- isSaving: select( editPostStore ).isSavingMetaBoxes(),
32
- isPostSaveable: select( editorStore ).isEditedPostSaveable(),
33
- isViewable: postType?.viewable ?? false,
34
- deviceType:
35
- select( editPostStore ).__experimentalGetPreviewDeviceType(),
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
- { isViewable && (
50
- <MenuGroup>
51
- <div className="edit-post-header-preview__grouping-external">
52
- <PostPreviewButton
53
- className={
54
- 'edit-post-header-preview__button-external'
55
- }
56
- role="menuitem"
57
- forceIsAutosaveable={ hasActiveMetaboxes }
58
- forcePreviewLink={ isSaving ? null : undefined }
59
- textContent={
60
- <>
61
- { __( 'Preview in new tab' ) }
62
- <Icon icon={ external } />
63
- </>
64
- }
65
- />
66
- </div>
67
- </MenuGroup>
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 DocumentTitle() {
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-title">
50
- <span className="edit-post-document-title__left">
51
- <Button
52
- onClick={ () => {
53
- clearSelectedBlock();
54
- setIsEditingTemplate( false );
55
- } }
56
- icon={ isRTL() ? chevronRightSmall : chevronLeftSmall }
57
- >
58
- { __( 'Back' ) }
59
- </Button>
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-title__title"
61
+ className="edit-post-document-actions__command"
64
62
  onClick={ () => openCommandCenter() }
65
63
  >
66
- <HStack spacing={ 1 } justify="center">
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
- </Button>
76
- <Button
77
- className="edit-post-document-title__shortcut"
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 DocumentTitle;
85
+ export default DocumentActions;
@@ -1,4 +1,4 @@
1
- .edit-post-document-title {
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
- &:hover {
17
- color: currentColor;
18
- background: $gray-200;
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-title__title.components-button {
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-title__shortcut {
40
- flex-shrink: 0;
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-title__left {
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
- .components-button.has-icon.has-text {
54
- color: $gray-700;
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 { Platform, ScrollView, View } from 'react-native';
4
+ import { ScrollView, StyleSheet, View } from 'react-native';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { useCallback, useRef, useState } from '@wordpress/element';
10
- import { compose, withPreferredColorScheme } from '@wordpress/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
- undo as undoIcon,
23
- redo as redoIcon,
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
- getStylesFromColorScheme,
56
+ insertBlock,
41
57
  onHideKeyboard,
42
58
  isRTL,
43
59
  noContentSelected,
44
60
  } ) {
45
- const wasNoContentSelected = useRef( noContentSelected );
46
- const [ isInserterOpen, setIsInserterOpen ] = useState( false );
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
- const isAndroid = Platform.OS === 'android';
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
- const renderHistoryButtons = () => {
59
- const buttons = [
60
- /* TODO: replace with EditorHistoryRedo and EditorHistoryUndo. */
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="undoButton"
63
- title={ __( 'Undo' ) }
64
- icon={ ! isRTL ? undoIcon : redoIcon }
65
- isDisabled={ ! hasUndo }
66
- onClick={ undo }
112
+ key="imageButton"
113
+ title={ __( 'Image' ) }
114
+ icon={ imageIcon }
115
+ onClick={ onInsertBlock( 'core/image' ) }
116
+ testID="insert-image-button"
67
117
  extraProps={ {
68
- hint: __( 'Double tap to undo last change' ),
118
+ hint: __( 'Insert Image Block' ),
69
119
  } }
70
- />,
120
+ />
71
121
  <ToolbarButton
72
- key="redoButton"
73
- title={ __( 'Redo' ) }
74
- icon={ ! isRTL ? redoIcon : undoIcon }
75
- isDisabled={ ! hasRedo }
76
- onClick={ redo }
122
+ key="videoButton"
123
+ title={ __( 'Video' ) }
124
+ icon={ videoIcon }
125
+ onClick={ onInsertBlock( 'core/video' ) }
126
+ testID="insert-video-button"
77
127
  extraProps={ {
78
- hint: __( 'Double tap to redo last change' ),
128
+ hint: __( 'Insert Video Block' ),
79
129
  } }
80
- />,
81
- ];
82
-
83
- return isRTL ? buttons.reverse() : buttons;
84
- };
85
-
86
- const onToggleInserter = useCallback(
87
- ( isOpen ) => {
88
- if ( isOpen ) {
89
- wasNoContentSelected.current = noContentSelected;
90
- }
91
- setIsInserterOpen( isOpen );
92
- },
93
- [ noContentSelected ]
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
- disabled={ ! showInserter }
131
- useExpandedMode={ useExpandedMode }
132
- onToggle={ onToggleInserter }
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 } = dispatch( blockEditorStore );
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: #e9eff3;
7
- border-top-width: 1px;
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-alt;
12
- border-top-color: $background-dark-elevated;
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 DocumentTitle from './document-title';
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
- hasActiveMetaboxes,
37
- isPublishSidebarOpened,
38
- isSaving,
39
- showIconLabels,
40
- } = useSelect(
41
- ( select ) => ( {
42
- hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
43
- isPublishSidebarOpened:
44
- select( editPostStore ).isPublishSidebarOpened(),
45
- isSaving: select( editPostStore ).isSavingMetaBoxes(),
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-header__document-title">
69
- <DocumentTitle />
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
  }