@wordpress/edit-post 7.29.0 → 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.
Files changed (43) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/editor-initialization/index.js +3 -6
  3. package/build/components/editor-initialization/index.js.map +1 -1
  4. package/build/components/editor-initialization/listener-hooks.js +6 -10
  5. package/build/components/editor-initialization/listener-hooks.js.map +1 -1
  6. package/build/components/header/header-toolbar/index.native.js.map +1 -1
  7. package/build/components/header/index.js +18 -11
  8. package/build/components/header/index.js.map +1 -1
  9. package/build/components/header/more-menu/index.js +10 -2
  10. package/build/components/header/more-menu/index.js.map +1 -1
  11. package/build/editor.js +1 -15
  12. package/build/editor.js.map +1 -1
  13. package/build/store/selectors.js +1 -1
  14. package/build/store/selectors.js.map +1 -1
  15. package/build-module/components/editor-initialization/index.js +3 -6
  16. package/build-module/components/editor-initialization/index.js.map +1 -1
  17. package/build-module/components/editor-initialization/listener-hooks.js +6 -10
  18. package/build-module/components/editor-initialization/listener-hooks.js.map +1 -1
  19. package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
  20. package/build-module/components/header/index.js +19 -12
  21. package/build-module/components/header/index.js.map +1 -1
  22. package/build-module/components/header/more-menu/index.js +12 -4
  23. package/build-module/components/header/more-menu/index.js.map +1 -1
  24. package/build-module/editor.js +1 -15
  25. package/build-module/editor.js.map +1 -1
  26. package/build-module/store/selectors.js +1 -1
  27. package/build-module/store/selectors.js.map +1 -1
  28. package/build-style/classic-rtl.css +1 -0
  29. package/build-style/classic.css +1 -0
  30. package/build-style/style-rtl.css +5 -32
  31. package/build-style/style.css +5 -32
  32. package/package.json +32 -32
  33. package/src/components/editor-initialization/index.js +3 -4
  34. package/src/components/editor-initialization/listener-hooks.js +20 -22
  35. package/src/components/editor-initialization/test/listener-hooks.js +8 -8
  36. package/src/components/header/header-toolbar/index.native.js +1 -1
  37. package/src/components/header/index.js +31 -28
  38. package/src/components/header/more-menu/index.js +13 -9
  39. package/src/components/header/style.scss +4 -0
  40. package/src/components/header/test/index.js +4 -14
  41. package/src/components/sidebar/plugin-post-publish-panel/test/index.js +1 -1
  42. package/src/editor.js +1 -12
  43. package/src/store/selectors.js +1 -1
@@ -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
 
@@ -61,9 +63,8 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) {
61
63
  const blockToolbarRef = useRef();
62
64
  const {
63
65
  isTextEditor,
64
- hasBlockSelection,
66
+ blockSelectionStart,
65
67
  hasActiveMetaboxes,
66
- hasFixedToolbar,
67
68
  isPublishSidebarOpened,
68
69
  showIconLabels,
69
70
  hasHistory,
@@ -73,28 +74,31 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) {
73
74
 
74
75
  return {
75
76
  isTextEditor: getEditorMode() === 'text',
76
- hasBlockSelection:
77
- !! select( blockEditorStore ).getBlockSelectionStart(),
77
+ blockSelectionStart:
78
+ select( blockEditorStore ).getBlockSelectionStart(),
78
79
  hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
79
80
  hasHistory:
80
81
  !! select( editorStore ).getEditorSettings()
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 );
94
+ const hasBlockSelection = !! blockSelectionStart;
91
95
 
92
96
  useEffect( () => {
93
97
  // If we have a new block selection, show the block tools
94
- if ( hasBlockSelection ) {
98
+ if ( blockSelectionStart ) {
95
99
  setIsBlockToolsCollapsed( false );
96
100
  }
97
- }, [ hasBlockSelection ] );
101
+ }, [ blockSelectionStart ] );
98
102
 
99
103
  return (
100
104
  <div className="edit-post-header">
@@ -115,13 +119,15 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) {
115
119
  className="edit-post-header__toolbar"
116
120
  >
117
121
  <DocumentTools disableBlockTools={ isTextEditor } />
118
- { hasFixedToolbar && isLargeViewport && (
122
+ { showTopToolbar && (
119
123
  <>
120
124
  <div
121
125
  className={ classnames(
122
126
  'selected-block-tools-wrapper',
123
127
  {
124
- 'is-collapsed': isBlockToolsCollapsed,
128
+ 'is-collapsed':
129
+ isBlockToolsCollapsed ||
130
+ ! hasBlockSelection,
125
131
  }
126
132
  ) }
127
133
  >
@@ -131,32 +137,29 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) {
131
137
  ref={ blockToolbarRef }
132
138
  name="block-toolbar"
133
139
  />
134
- { hasBlockSelection && (
135
- <Button
136
- className="edit-post-header__block-tools-toggle"
137
- icon={ isBlockToolsCollapsed ? next : previous }
138
- onClick={ () => {
139
- setIsBlockToolsCollapsed(
140
- ( collapsed ) => ! collapsed
141
- );
142
- } }
143
- label={
144
- isBlockToolsCollapsed
145
- ? __( 'Show block tools' )
146
- : __( 'Hide block tools' )
147
- }
148
- />
149
- ) }
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
+ />
150
155
  </>
151
156
  ) }
152
157
  <div
153
158
  className={ classnames( 'edit-post-header__center', {
154
159
  'is-collapsed':
155
160
  hasHistory &&
156
- hasBlockSelection &&
157
161
  ! isBlockToolsCollapsed &&
158
- hasFixedToolbar &&
159
- isLargeViewport,
162
+ showTopToolbar,
160
163
  } ) }
161
164
  >
162
165
  { hasHistory && <DocumentBar /> }
@@ -2,14 +2,11 @@
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';
12
8
  import { privateApis as editorPrivateApis } from '@wordpress/editor';
9
+ import { moreVertical } from '@wordpress/icons';
13
10
 
14
11
  /**
15
12
  * Internal dependencies
@@ -25,10 +22,17 @@ const MoreMenu = ( { showIconLabels } ) => {
25
22
  const isLargeViewport = useViewportMatch( 'large' );
26
23
 
27
24
  return (
28
- <MoreMenuDropdown
25
+ <DropdownMenu
26
+ icon={ moreVertical }
27
+ label={ __( 'Options' ) }
28
+ popoverProps={ {
29
+ placement: 'bottom-end',
30
+ className: 'more-menu-dropdown__content',
31
+ } }
29
32
  toggleProps={ {
30
- showTooltip: ! showIconLabels,
31
33
  ...( showIconLabels && { variant: 'tertiary' } ),
34
+ tooltipPosition: 'bottom',
35
+ showTooltip: ! showIconLabels,
32
36
  size: 'compact',
33
37
  } }
34
38
  >
@@ -54,7 +58,7 @@ const MoreMenu = ( { showIconLabels } ) => {
54
58
  </MenuGroup>
55
59
  </>
56
60
  ) }
57
- </MoreMenuDropdown>
61
+ </DropdownMenu>
58
62
  );
59
63
  };
60
64
 
@@ -322,3 +322,7 @@
322
322
  z-index: 35;
323
323
  }
324
324
  }
325
+
326
+ .components-popover.more-menu-dropdown__content {
327
+ z-index: z-index(".components-popover.more-menu__content");
328
+ }
@@ -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={ true } /> );
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();
@@ -20,7 +20,7 @@ describe( 'PluginPostPublishPanel', () => {
20
20
  <PluginPostPublishPanel
21
21
  className="my-plugin-post-publish-panel"
22
22
  title="My panel title"
23
- initialOpen={ true }
23
+ initialOpen
24
24
  >
25
25
  My panel content
26
26
  </PluginPostPublishPanel>
package/src/editor.js CHANGED
@@ -12,8 +12,6 @@ import { useMemo } from '@wordpress/element';
12
12
  import { SlotFillProvider } from '@wordpress/components';
13
13
  import { store as coreStore } from '@wordpress/core-data';
14
14
  import { CommandMenu } from '@wordpress/commands';
15
- import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
16
- import { __ } from '@wordpress/i18n';
17
15
 
18
16
  /**
19
17
  * Internal dependencies
@@ -25,14 +23,6 @@ import { unlock } from './lock-unlock';
25
23
  import useNavigateToEntityRecord from './hooks/use-navigate-to-entity-record';
26
24
 
27
25
  const { ExperimentalEditorProvider } = unlock( editorPrivateApis );
28
- const { BlockRemovalWarningModal } = unlock( blockEditorPrivateApis );
29
- // Prevent accidental removal of certain blocks, asking the user for
30
- // confirmation.
31
- const blockRemovalRules = {
32
- 'bindings/core/pattern-overrides': __(
33
- 'Blocks from synced patterns that can have overriden content.'
34
- ),
35
- };
36
26
 
37
27
  function Editor( {
38
28
  postId: initialPostId,
@@ -106,9 +96,8 @@ function Editor( {
106
96
  >
107
97
  <ErrorBoundary>
108
98
  <CommandMenu />
109
- <EditorInitialization postId={ currentPost.postId } />
99
+ <EditorInitialization />
110
100
  <Layout initialPost={ initialPost } />
111
- <BlockRemovalWarningModal rules={ blockRemovalRules } />
112
101
  </ErrorBoundary>
113
102
  <PostLockedModal />
114
103
  </ExperimentalEditorProvider>
@@ -538,7 +538,7 @@ export const isEditingTemplate = createRegistrySelector( ( select ) => () => {
538
538
  since: '6.5',
539
539
  alternative: `select( 'core/editor' ).getRenderingMode`,
540
540
  } );
541
- return select( editorStore ).getCurrentPostType() !== 'post-only';
541
+ return select( editorStore ).getCurrentPostType() === 'wp_template';
542
542
  } );
543
543
 
544
544
  /**