@wordpress/block-editor 14.3.5 → 14.3.7

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 (157) hide show
  1. package/README.md +6 -2
  2. package/build/components/block-list/block.js +0 -3
  3. package/build/components/block-list/block.js.map +1 -1
  4. package/build/components/block-list/use-block-props/index.js +1 -4
  5. package/build/components/block-list/use-block-props/index.js.map +1 -1
  6. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +14 -6
  7. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  8. package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js +9 -12
  9. package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -1
  10. package/build/components/block-list/zoom-out-separator.js +10 -7
  11. package/build/components/block-list/zoom-out-separator.js.map +1 -1
  12. package/build/components/block-popover/index.js +1 -1
  13. package/build/components/block-popover/index.js.map +1 -1
  14. package/build/components/block-toolbar/index.js +28 -16
  15. package/build/components/block-toolbar/index.js.map +1 -1
  16. package/build/components/block-toolbar/use-has-block-toolbar.js +3 -3
  17. package/build/components/block-toolbar/use-has-block-toolbar.js.map +1 -1
  18. package/build/components/block-tools/index.js +1 -6
  19. package/build/components/block-tools/index.js.map +1 -1
  20. package/build/components/block-tools/use-show-block-tools.js +4 -6
  21. package/build/components/block-tools/use-show-block-tools.js.map +1 -1
  22. package/build/components/block-tools/zoom-out-mode-inserters.js +22 -36
  23. package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  24. package/build/components/iframe/index.js +45 -10
  25. package/build/components/iframe/index.js.map +1 -1
  26. package/build/components/inserter/block-patterns-tab/index.js +4 -0
  27. package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
  28. package/build/components/inserter/hooks/use-insertion-point.js +16 -4
  29. package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
  30. package/build/components/inserter/media-tab/media-tab.js +4 -0
  31. package/build/components/inserter/media-tab/media-tab.js.map +1 -1
  32. package/build/components/inserter/menu.js +8 -2
  33. package/build/components/inserter/menu.js.map +1 -1
  34. package/build/components/tool-selector/index.js +5 -1
  35. package/build/components/tool-selector/index.js.map +1 -1
  36. package/build/components/use-resize-canvas/index.js +1 -2
  37. package/build/components/use-resize-canvas/index.js.map +1 -1
  38. package/build/hooks/block-bindings.js +12 -1
  39. package/build/hooks/block-bindings.js.map +1 -1
  40. package/build/hooks/grid-visualizer.js +13 -11
  41. package/build/hooks/grid-visualizer.js.map +1 -1
  42. package/build/hooks/layout-child.js +41 -3
  43. package/build/hooks/layout-child.js.map +1 -1
  44. package/build/hooks/use-zoom-out.js +24 -16
  45. package/build/hooks/use-zoom-out.js.map +1 -1
  46. package/build/private-apis.js +2 -0
  47. package/build/private-apis.js.map +1 -1
  48. package/build/store/private-selectors.js +37 -2
  49. package/build/store/private-selectors.js.map +1 -1
  50. package/build/store/selectors.js +15 -8
  51. package/build/store/selectors.js.map +1 -1
  52. package/build/utils/block-bindings.js +9 -6
  53. package/build/utils/block-bindings.js.map +1 -1
  54. package/build-module/components/block-list/block.js +0 -3
  55. package/build-module/components/block-list/block.js.map +1 -1
  56. package/build-module/components/block-list/use-block-props/index.js +1 -4
  57. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  58. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +14 -6
  59. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  60. package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js +9 -12
  61. package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -1
  62. package/build-module/components/block-list/zoom-out-separator.js +10 -7
  63. package/build-module/components/block-list/zoom-out-separator.js.map +1 -1
  64. package/build-module/components/block-popover/index.js +1 -1
  65. package/build-module/components/block-popover/index.js.map +1 -1
  66. package/build-module/components/block-toolbar/index.js +30 -18
  67. package/build-module/components/block-toolbar/index.js.map +1 -1
  68. package/build-module/components/block-toolbar/use-has-block-toolbar.js +3 -3
  69. package/build-module/components/block-toolbar/use-has-block-toolbar.js.map +1 -1
  70. package/build-module/components/block-tools/index.js +1 -6
  71. package/build-module/components/block-tools/index.js.map +1 -1
  72. package/build-module/components/block-tools/use-show-block-tools.js +4 -6
  73. package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
  74. package/build-module/components/block-tools/zoom-out-mode-inserters.js +22 -36
  75. package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  76. package/build-module/components/iframe/index.js +45 -10
  77. package/build-module/components/iframe/index.js.map +1 -1
  78. package/build-module/components/inserter/block-patterns-tab/index.js +5 -1
  79. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
  80. package/build-module/components/inserter/hooks/use-insertion-point.js +16 -4
  81. package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
  82. package/build-module/components/inserter/media-tab/media-tab.js +5 -1
  83. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
  84. package/build-module/components/inserter/menu.js +8 -2
  85. package/build-module/components/inserter/menu.js.map +1 -1
  86. package/build-module/components/tool-selector/index.js +5 -1
  87. package/build-module/components/tool-selector/index.js.map +1 -1
  88. package/build-module/components/use-resize-canvas/index.js +1 -2
  89. package/build-module/components/use-resize-canvas/index.js.map +1 -1
  90. package/build-module/hooks/block-bindings.js +13 -2
  91. package/build-module/hooks/block-bindings.js.map +1 -1
  92. package/build-module/hooks/grid-visualizer.js +13 -11
  93. package/build-module/hooks/grid-visualizer.js.map +1 -1
  94. package/build-module/hooks/layout-child.js +41 -3
  95. package/build-module/hooks/layout-child.js.map +1 -1
  96. package/build-module/hooks/use-zoom-out.js +24 -17
  97. package/build-module/hooks/use-zoom-out.js.map +1 -1
  98. package/build-module/private-apis.js +2 -0
  99. package/build-module/private-apis.js.map +1 -1
  100. package/build-module/store/private-selectors.js +35 -2
  101. package/build-module/store/private-selectors.js.map +1 -1
  102. package/build-module/store/selectors.js +15 -8
  103. package/build-module/store/selectors.js.map +1 -1
  104. package/build-module/utils/block-bindings.js +9 -6
  105. package/build-module/utils/block-bindings.js.map +1 -1
  106. package/build-style/content-rtl.css +19 -26
  107. package/build-style/content.css +19 -26
  108. package/build-style/style-rtl.css +36 -21
  109. package/build-style/style.css +36 -21
  110. package/package.json +6 -6
  111. package/src/components/block-canvas/style.scss +1 -0
  112. package/src/components/block-list/block.js +0 -3
  113. package/src/components/block-list/content.scss +3 -2
  114. package/src/components/block-list/use-block-props/index.js +1 -2
  115. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +25 -4
  116. package/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js +19 -11
  117. package/src/components/block-list/zoom-out-separator.js +8 -6
  118. package/src/components/block-popover/index.js +2 -2
  119. package/src/components/block-toolbar/index.js +37 -24
  120. package/src/components/block-toolbar/style.scss +10 -1
  121. package/src/components/block-toolbar/use-has-block-toolbar.js +19 -28
  122. package/src/components/block-tools/index.js +0 -9
  123. package/src/components/block-tools/style.scss +2 -26
  124. package/src/components/block-tools/use-show-block-tools.js +2 -10
  125. package/src/components/block-tools/zoom-out-mode-inserters.js +26 -50
  126. package/src/components/iframe/content.scss +23 -32
  127. package/src/components/iframe/index.js +60 -13
  128. package/src/components/iframe/style.scss +18 -0
  129. package/src/components/inserter/block-patterns-tab/index.js +6 -1
  130. package/src/components/inserter/hooks/use-insertion-point.js +23 -5
  131. package/src/components/inserter/media-tab/media-tab.js +6 -1
  132. package/src/components/inserter/menu.js +12 -1
  133. package/src/components/inserter/style.scss +6 -0
  134. package/src/components/list-view/style.scss +9 -0
  135. package/src/components/rich-text/style.scss +5 -0
  136. package/src/components/tool-selector/index.js +5 -2
  137. package/src/components/use-resize-canvas/index.js +1 -3
  138. package/src/hooks/block-bindings.js +40 -23
  139. package/src/hooks/grid-visualizer.js +23 -9
  140. package/src/hooks/layout-child.js +48 -3
  141. package/src/hooks/use-zoom-out.js +36 -20
  142. package/src/private-apis.js +2 -0
  143. package/src/store/private-selectors.js +40 -1
  144. package/src/store/selectors.js +16 -8
  145. package/src/style.scss +1 -0
  146. package/src/utils/block-bindings.js +9 -6
  147. package/src/utils/test/use-block-bindings-utils.js +174 -0
  148. package/build/components/block-tools/zoom-out-popover.js +0 -57
  149. package/build/components/block-tools/zoom-out-popover.js.map +0 -1
  150. package/build/components/block-tools/zoom-out-toolbar.js +0 -159
  151. package/build/components/block-tools/zoom-out-toolbar.js.map +0 -1
  152. package/build-module/components/block-tools/zoom-out-popover.js +0 -48
  153. package/build-module/components/block-tools/zoom-out-popover.js.map +0 -1
  154. package/build-module/components/block-tools/zoom-out-toolbar.js +0 -152
  155. package/build-module/components/block-tools/zoom-out-toolbar.js.map +0 -1
  156. package/src/components/block-tools/zoom-out-popover.js +0 -46
  157. package/src/components/block-tools/zoom-out-toolbar.js +0 -167
@@ -12,25 +12,27 @@ import { unlock } from '../../../lock-unlock';
12
12
 
13
13
  /**
14
14
  * Allows Zoom Out mode to be exited by double clicking in the selected block.
15
- *
16
- * @param {string} clientId Block client ID.
17
15
  */
18
- export function useZoomOutModeExit( { editorMode } ) {
19
- const { getSettings, isZoomOut } = unlock( useSelect( blockEditorStore ) );
16
+ export function useZoomOutModeExit() {
17
+ const { getSettings, isZoomOut, __unstableGetEditorMode } = unlock(
18
+ useSelect( blockEditorStore )
19
+ );
20
+
20
21
  const { __unstableSetEditorMode, resetZoomLevel } = unlock(
21
22
  useDispatch( blockEditorStore )
22
23
  );
23
24
 
24
25
  return useRefEffect(
25
26
  ( node ) => {
26
- // In "compose" mode.
27
- const composeMode = editorMode === 'zoom-out' && isZoomOut();
27
+ function onDoubleClick( event ) {
28
+ // In "compose" mode.
29
+ const composeMode =
30
+ __unstableGetEditorMode() === 'zoom-out' && isZoomOut();
28
31
 
29
- if ( ! composeMode ) {
30
- return;
31
- }
32
+ if ( ! composeMode ) {
33
+ return;
34
+ }
32
35
 
33
- function onDoubleClick( event ) {
34
36
  if ( ! event.defaultPrevented ) {
35
37
  event.preventDefault();
36
38
 
@@ -52,6 +54,12 @@ export function useZoomOutModeExit( { editorMode } ) {
52
54
  node.removeEventListener( 'dblclick', onDoubleClick );
53
55
  };
54
56
  },
55
- [ editorMode, getSettings, __unstableSetEditorMode ]
57
+ [
58
+ getSettings,
59
+ __unstableSetEditorMode,
60
+ __unstableGetEditorMode,
61
+ isZoomOut,
62
+ resetZoomLevel,
63
+ ]
56
64
  );
57
65
  }
@@ -85,14 +85,15 @@ export function ZoomOutSeparator( {
85
85
  <AnimatePresence>
86
86
  { isVisible && (
87
87
  <motion.div
88
- as="button"
89
- layout={ ! isReducedMotion }
90
88
  initial={ { height: 0 } }
91
- animate={ { height: '120px' } }
89
+ animate={ {
90
+ // Use a height equal to that of the zoom out frame size.
91
+ height: 'calc(1.5 * var(--wp-block-editor-iframe-zoom-out-frame-size) / var(--wp-block-editor-iframe-zoom-out-scale)',
92
+ } }
92
93
  exit={ { height: 0 } }
93
94
  transition={ {
94
95
  type: 'tween',
95
- duration: 0.2,
96
+ duration: isReducedMotion ? 0 : 0.2,
96
97
  ease: [ 0.6, 0, 0.4, 1 ],
97
98
  } }
98
99
  className={ clsx(
@@ -108,10 +109,11 @@ export function ZoomOutSeparator( {
108
109
  <motion.div
109
110
  initial={ { opacity: 0 } }
110
111
  animate={ { opacity: 1 } }
111
- exit={ { opacity: 0 } }
112
+ exit={ { opacity: 0, transition: { delay: -0.125 } } }
112
113
  transition={ {
113
- type: 'tween',
114
+ ease: 'linear',
114
115
  duration: 0.1,
116
+ delay: 0.125,
115
117
  } }
116
118
  >
117
119
  { __( 'Drop pattern.' ) }
@@ -98,10 +98,10 @@ function BlockPopover(
98
98
  contextElement: selectedElement,
99
99
  };
100
100
  }, [
101
+ popoverDimensionsRecomputeCounter,
102
+ selectedElement,
101
103
  bottomClientId,
102
104
  lastSelectedElement,
103
- selectedElement,
104
- popoverDimensionsRecomputeCounter,
105
105
  ] );
106
106
 
107
107
  if ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {
@@ -16,7 +16,7 @@ import {
16
16
  isReusableBlock,
17
17
  isTemplatePart,
18
18
  } from '@wordpress/blocks';
19
- import { ToolbarGroup } from '@wordpress/components';
19
+ import { ToolbarGroup, ToolbarButton } from '@wordpress/components';
20
20
 
21
21
  /**
22
22
  * Internal dependencies
@@ -35,6 +35,8 @@ import { store as blockEditorStore } from '../../store';
35
35
  import __unstableBlockNameContext from './block-name-context';
36
36
  import NavigableToolbar from '../navigable-toolbar';
37
37
  import { useHasBlockToolbar } from './use-has-block-toolbar';
38
+ import Shuffle from './shuffle';
39
+ import { unlock } from '../../lock-unlock';
38
40
 
39
41
  /**
40
42
  * Renders the block toolbar.
@@ -58,7 +60,6 @@ export function PrivateBlockToolbar( {
58
60
  const {
59
61
  blockClientId,
60
62
  blockClientIds,
61
- isContentOnlyEditingMode,
62
63
  isDefaultEditingMode,
63
64
  blockType,
64
65
  toolbarKey,
@@ -67,6 +68,10 @@ export function PrivateBlockToolbar( {
67
68
  isUsingBindings,
68
69
  hasParentPattern,
69
70
  hasContentOnlyLocking,
71
+ showShuffleButton,
72
+ showSlots,
73
+ showGroupButtons,
74
+ showLockButtons,
70
75
  } = useSelect( ( select ) => {
71
76
  const {
72
77
  getBlockName,
@@ -78,7 +83,8 @@ export function PrivateBlockToolbar( {
78
83
  getBlockAttributes,
79
84
  getBlockParentsByBlockName,
80
85
  getTemplateLock,
81
- } = select( blockEditorStore );
86
+ isZoomOutMode,
87
+ } = unlock( select( blockEditorStore ) );
82
88
  const selectedBlockClientIds = getSelectedBlockClientIds();
83
89
  const selectedBlockClientId = selectedBlockClientIds[ 0 ];
84
90
  const parents = getBlockParents( selectedBlockClientId );
@@ -112,12 +118,12 @@ export function PrivateBlockToolbar( {
112
118
  return {
113
119
  blockClientId: selectedBlockClientId,
114
120
  blockClientIds: selectedBlockClientIds,
115
- isContentOnlyEditingMode: editingMode === 'contentOnly',
116
121
  isDefaultEditingMode: _isDefaultEditingMode,
117
122
  blockType: selectedBlockClientId && getBlockType( _blockName ),
118
123
  shouldShowVisualToolbar: isValid && isVisual,
119
124
  toolbarKey: `${ selectedBlockClientId }${ firstParentClientId }`,
120
125
  showParentSelector:
126
+ ! isZoomOutMode() &&
121
127
  parentBlockType &&
122
128
  getBlockEditingMode( firstParentClientId ) === 'default' &&
123
129
  hasBlockSupport(
@@ -130,6 +136,10 @@ export function PrivateBlockToolbar( {
130
136
  isUsingBindings: _isUsingBindings,
131
137
  hasParentPattern: _hasParentPattern,
132
138
  hasContentOnlyLocking: _hasTemplateLock,
139
+ showShuffleButton: isZoomOutMode(),
140
+ showSlots: ! isZoomOutMode(),
141
+ showGroupButtons: ! isZoomOutMode(),
142
+ showLockButtons: ! isZoomOutMode(),
133
143
  };
134
144
  }, [] );
135
145
 
@@ -179,13 +189,11 @@ export function PrivateBlockToolbar( {
179
189
  key={ toolbarKey }
180
190
  >
181
191
  <div ref={ toolbarWrapperRef } className={ innerClasses }>
182
- { ! isMultiToolbar &&
183
- isLargeViewport &&
184
- isDefaultEditingMode && <BlockParentSelector /> }
192
+ { showParentSelector && ! isMultiToolbar && isLargeViewport && (
193
+ <BlockParentSelector />
194
+ ) }
185
195
  { ( shouldShowVisualToolbar || isMultiToolbar ) &&
186
- ( isDefaultEditingMode ||
187
- ( isContentOnlyEditingMode && ! hasParentPattern ) ||
188
- isSynced ) && (
196
+ ! hasParentPattern && (
189
197
  <div
190
198
  ref={ nodeRef }
191
199
  { ...showHoveredOrFocusedGestures }
@@ -196,26 +204,31 @@ export function PrivateBlockToolbar( {
196
204
  disabled={ ! isDefaultEditingMode }
197
205
  isUsingBindings={ isUsingBindings }
198
206
  />
199
- { isDefaultEditingMode && (
200
- <>
201
- { ! isMultiToolbar && (
202
- <BlockLockToolbar
203
- clientId={ blockClientId }
204
- />
205
- ) }
206
- <BlockMover
207
- clientIds={ blockClientIds }
208
- hideDragHandle={ hideDragHandle }
209
- />
210
- </>
207
+ { ! isMultiToolbar && showLockButtons && (
208
+ <BlockLockToolbar
209
+ clientId={ blockClientId }
210
+ />
211
211
  ) }
212
+ <BlockMover
213
+ clientIds={ blockClientIds }
214
+ hideDragHandle={ hideDragHandle }
215
+ />
212
216
  </ToolbarGroup>
213
217
  </div>
214
218
  ) }
215
219
  { ! hasContentOnlyLocking &&
216
220
  shouldShowVisualToolbar &&
217
- isMultiToolbar && <BlockGroupToolbar /> }
218
- { shouldShowVisualToolbar && (
221
+ isMultiToolbar &&
222
+ showGroupButtons && <BlockGroupToolbar /> }
223
+ { showShuffleButton && (
224
+ <ToolbarGroup>
225
+ <Shuffle
226
+ clientId={ blockClientIds[ 0 ] }
227
+ as={ ToolbarButton }
228
+ />
229
+ </ToolbarGroup>
230
+ ) }
231
+ { shouldShowVisualToolbar && showSlots && (
219
232
  <>
220
233
  <BlockControls.Slot
221
234
  group="parent"
@@ -59,9 +59,18 @@
59
59
 
60
60
  > :last-child,
61
61
  > :last-child .components-toolbar-group,
62
- > :last-child .components-toolbar {
62
+ > :last-child .components-toolbar,
63
+ // If the last toolbar group is empty,
64
+ // we need to remove the double border from the penultimate one.
65
+ &:has(> :last-child:empty) > :nth-last-child(2),
66
+ &:has(> :last-child:empty) > :nth-last-child(2) .components-toolbar-group,
67
+ &:has(> :last-child:empty) > :nth-last-child(2) .components-toolbar {
63
68
  border-right: none;
64
69
  }
70
+
71
+ .components-toolbar-group:empty {
72
+ display: none;
73
+ }
65
74
  }
66
75
 
67
76
  .block-editor-block-contextual-toolbar {
@@ -15,40 +15,31 @@ import { useHasAnyBlockControls } from '../block-controls/use-has-block-controls
15
15
  * @return {boolean} Whether the block toolbar component will be rendered.
16
16
  */
17
17
  export function useHasBlockToolbar() {
18
- const { isToolbarEnabled, isDefaultEditingMode } = useSelect(
19
- ( select ) => {
20
- const {
21
- getBlockEditingMode,
22
- getBlockName,
23
- getBlockSelectionStart,
24
- } = select( blockEditorStore );
18
+ const { isToolbarEnabled, isBlockDisabled } = useSelect( ( select ) => {
19
+ const { getBlockEditingMode, getBlockName, getBlockSelectionStart } =
20
+ select( blockEditorStore );
25
21
 
26
- // we only care about the 1st selected block
27
- // for the toolbar, so we use getBlockSelectionStart
28
- // instead of getSelectedBlockClientIds
29
- const selectedBlockClientId = getBlockSelectionStart();
22
+ // we only care about the 1st selected block
23
+ // for the toolbar, so we use getBlockSelectionStart
24
+ // instead of getSelectedBlockClientIds
25
+ const selectedBlockClientId = getBlockSelectionStart();
30
26
 
31
- const blockType =
32
- selectedBlockClientId &&
33
- getBlockType( getBlockName( selectedBlockClientId ) );
27
+ const blockType =
28
+ selectedBlockClientId &&
29
+ getBlockType( getBlockName( selectedBlockClientId ) );
34
30
 
35
- return {
36
- isToolbarEnabled:
37
- blockType &&
38
- hasBlockSupport( blockType, '__experimentalToolbar', true ),
39
- isDefaultEditingMode:
40
- getBlockEditingMode( selectedBlockClientId ) === 'default',
41
- };
42
- },
43
- []
44
- );
31
+ return {
32
+ isToolbarEnabled:
33
+ blockType &&
34
+ hasBlockSupport( blockType, '__experimentalToolbar', true ),
35
+ isBlockDisabled:
36
+ getBlockEditingMode( selectedBlockClientId ) === 'disabled',
37
+ };
38
+ }, [] );
45
39
 
46
40
  const hasAnyBlockControls = useHasAnyBlockControls();
47
41
 
48
- if (
49
- ! isToolbarEnabled ||
50
- ( ! isDefaultEditingMode && ! hasAnyBlockControls )
51
- ) {
42
+ if ( ! isToolbarEnabled || ( isBlockDisabled && ! hasAnyBlockControls ) ) {
52
43
  return false;
53
44
  }
54
45
 
@@ -20,7 +20,6 @@ import {
20
20
  } from './insertion-point';
21
21
  import BlockToolbarPopover from './block-toolbar-popover';
22
22
  import BlockToolbarBreadcrumb from './block-toolbar-breadcrumb';
23
- import ZoomOutPopover from './zoom-out-popover';
24
23
  import { store as blockEditorStore } from '../../store';
25
24
  import usePopoverScroll from '../block-popover/use-popover-scroll';
26
25
  import ZoomOutModeInserters from './zoom-out-mode-inserters';
@@ -80,7 +79,6 @@ export default function BlockTools( {
80
79
  showEmptyBlockSideInserter,
81
80
  showBreadcrumb,
82
81
  showBlockToolbarPopover,
83
- showZoomOutToolbar,
84
82
  } = useShowBlockTools();
85
83
 
86
84
  const {
@@ -231,13 +229,6 @@ export default function BlockTools( {
231
229
  />
232
230
  ) }
233
231
 
234
- { showZoomOutToolbar && (
235
- <ZoomOutPopover
236
- __unstableContentRef={ __unstableContentRef }
237
- clientId={ clientId }
238
- />
239
- ) }
240
-
241
232
  { /* Used for the inline rich text toolbar. Until this toolbar is combined into BlockToolbar, someone implementing their own BlockToolbar will also need to use this to see the image caption toolbar. */ }
242
233
  { ! isZoomOutMode && ! hasFixedToolbar && (
243
234
  <Popover.Slot
@@ -270,30 +270,6 @@
270
270
  left: 50%;
271
271
  }
272
272
 
273
- .zoom-out-toolbar {
274
-
275
- .block-editor-block-mover-button.block-editor-block-mover-button:focus-visible::before,
276
- .zoom-out-toolbar-button:focus::before,
277
- .block-editor-block-toolbar-shuffle:focus::before,
278
- .block-selection-button_drag-handle:focus::before {
279
- box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
280
- }
281
-
282
- .block-editor-block-mover {
283
- background: none;
284
- border: none;
285
- }
286
-
287
- // Make the spacing consistent between controls.
288
- .zoom-out-toolbar-button {
289
- height: $button-size-next-default-40px;
290
- }
291
- }
292
-
293
- .block-editor-block-tools__zoom-out-mode-inserter-button {
294
- visibility: hidden;
295
-
296
- &.is-visible {
297
- visibility: visible;
298
- }
273
+ .components-button.block-editor-button-pattern-inserter__button.block-editor-block-tools__zoom-out-mode-inserter-button {
274
+ top: -1px;
299
275
  }
@@ -8,6 +8,7 @@ import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
8
8
  * Internal dependencies
9
9
  */
10
10
  import { store as blockEditorStore } from '../../store';
11
+ import { unlock } from '../../lock-unlock';
11
12
 
12
13
  /**
13
14
  * Source of truth for which block tools are showing in the block editor.
@@ -25,7 +26,7 @@ export function useShowBlockTools() {
25
26
  hasMultiSelection,
26
27
  __unstableGetEditorMode,
27
28
  isTyping,
28
- } = select( blockEditorStore );
29
+ } = unlock( select( blockEditorStore ) );
29
30
 
30
31
  const clientId =
31
32
  getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();
@@ -46,15 +47,7 @@ export function useShowBlockTools() {
46
47
  hasSelectedBlock &&
47
48
  ! hasMultiSelection() &&
48
49
  editorMode === 'navigation';
49
-
50
- const isZoomOut = editorMode === 'zoom-out';
51
- const _showZoomOutToolbar =
52
- isZoomOut &&
53
- block?.attributes?.align === 'full' &&
54
- ! _showEmptyBlockSideInserter &&
55
- ! maybeShowBreadcrumb;
56
50
  const _showBlockToolbarPopover =
57
- ! _showZoomOutToolbar &&
58
51
  ! getSettings().hasFixedToolbar &&
59
52
  ! _showEmptyBlockSideInserter &&
60
53
  hasSelectedBlock &&
@@ -66,7 +59,6 @@ export function useShowBlockTools() {
66
59
  showBreadcrumb:
67
60
  ! _showEmptyBlockSideInserter && maybeShowBreadcrumb,
68
61
  showBlockToolbarPopover: _showBlockToolbarPopover,
69
- showZoomOutToolbar: _showZoomOutToolbar,
70
62
  };
71
63
  }, [] );
72
64
  }
@@ -16,22 +16,16 @@ function ZoomOutModeInserters() {
16
16
  const [ isReady, setIsReady ] = useState( false );
17
17
  const {
18
18
  hasSelection,
19
- blockInsertionPoint,
20
19
  blockOrder,
21
- blockInsertionPointVisible,
22
20
  setInserterIsOpened,
23
21
  sectionRootClientId,
24
22
  selectedBlockClientId,
25
- hoveredBlockClientId,
26
23
  } = useSelect( ( select ) => {
27
24
  const {
28
25
  getSettings,
29
- getBlockInsertionPoint,
30
26
  getBlockOrder,
31
27
  getSelectionStart,
32
28
  getSelectedBlockClientId,
33
- getHoveredBlockClientId,
34
- isBlockInsertionPointVisible,
35
29
  getSectionRootClientId,
36
30
  } = unlock( select( blockEditorStore ) );
37
31
 
@@ -39,14 +33,11 @@ function ZoomOutModeInserters() {
39
33
 
40
34
  return {
41
35
  hasSelection: !! getSelectionStart().clientId,
42
- blockInsertionPoint: getBlockInsertionPoint(),
43
36
  blockOrder: getBlockOrder( root ),
44
- blockInsertionPointVisible: isBlockInsertionPointVisible(),
45
37
  sectionRootClientId: root,
46
38
  setInserterIsOpened:
47
39
  getSettings().__experimentalSetIsInserterOpened,
48
40
  selectedBlockClientId: getSelectedBlockClientId(),
49
- hoveredBlockClientId: getHoveredBlockClientId(),
50
41
  };
51
42
  }, [] );
52
43
 
@@ -62,51 +53,36 @@ function ZoomOutModeInserters() {
62
53
  };
63
54
  }, [] );
64
55
 
65
- if ( ! isReady ) {
56
+ if ( ! isReady || ! hasSelection ) {
66
57
  return null;
67
58
  }
68
59
 
69
- return [ undefined, ...blockOrder ].map( ( clientId, index ) => {
70
- const shouldRenderInsertionPoint =
71
- blockInsertionPointVisible && blockInsertionPoint.index === index;
60
+ const previousClientId = selectedBlockClientId;
61
+ const index = blockOrder.findIndex(
62
+ ( clientId ) => selectedBlockClientId === clientId
63
+ );
64
+ const nextClientId = blockOrder[ index + 1 ];
72
65
 
73
- const previousClientId = clientId;
74
- const nextClientId = blockOrder[ index ];
75
-
76
- const isSelected =
77
- hasSelection &&
78
- ( selectedBlockClientId === previousClientId ||
79
- selectedBlockClientId === nextClientId );
80
-
81
- const isHovered =
82
- hoveredBlockClientId === previousClientId ||
83
- hoveredBlockClientId === nextClientId;
84
-
85
- return (
86
- <BlockPopoverInbetween
87
- key={ index }
88
- previousClientId={ previousClientId }
89
- nextClientId={ nextClientId }
90
- >
91
- { ! shouldRenderInsertionPoint && (
92
- <ZoomOutModeInserterButton
93
- isVisible={ isSelected || isHovered }
94
- onClick={ () => {
95
- setInserterIsOpened( {
96
- rootClientId: sectionRootClientId,
97
- insertionIndex: index,
98
- tab: 'patterns',
99
- category: 'all',
100
- } );
101
- showInsertionPoint( sectionRootClientId, index, {
102
- operation: 'insert',
103
- } );
104
- } }
105
- />
106
- ) }
107
- </BlockPopoverInbetween>
108
- );
109
- } );
66
+ return (
67
+ <BlockPopoverInbetween
68
+ previousClientId={ previousClientId }
69
+ nextClientId={ nextClientId }
70
+ >
71
+ <ZoomOutModeInserterButton
72
+ onClick={ () => {
73
+ setInserterIsOpened( {
74
+ rootClientId: sectionRootClientId,
75
+ insertionIndex: index + 1,
76
+ tab: 'patterns',
77
+ category: 'all',
78
+ } );
79
+ showInsertionPoint( sectionRootClientId, index + 1, {
80
+ operation: 'insert',
81
+ } );
82
+ } }
83
+ />
84
+ </BlockPopoverInbetween>
85
+ );
110
86
  }
111
87
 
112
88
  export default ZoomOutModeInserters;
@@ -1,30 +1,21 @@
1
1
  .block-editor-iframe__body {
2
2
  position: relative;
3
- }
4
-
5
- .block-editor-iframe__container {
6
- width: 100%;
7
- height: 100%;
8
- overflow-x: hidden;
9
- }
10
-
11
- .block-editor-iframe__scale-container {
12
- width: 100%;
13
- height: 100%;
14
- display: flex;
15
- }
16
-
17
- .block-editor-iframe__scale-container.is-zoomed-out {
18
- $container-width: var(--wp-block-editor-iframe-zoom-out-container-width, 100vw);
19
- $prev-container-width: var(--wp-block-editor-iframe-zoom-out-prev-container-width, 100vw);
20
- width: $prev-container-width;
21
- margin-left: calc(-1 * (#{$prev-container-width} - #{$container-width}) / 2);
3
+ border: 0.01px solid transparent;
22
4
  }
23
5
 
24
6
  .block-editor-iframe__html {
25
- border: 0 solid $gray-300;
26
7
  transform-origin: top center;
27
- @include editor-canvas-resize-animation;
8
+ // We don't want to animate the transform of the translateX because it is used
9
+ // to "center" the canvas. Leaving it on causes the canvas to slide around in
10
+ // odd ways.
11
+ @include editor-canvas-resize-animation(transform 0s, scale 0s, padding 0s);
12
+
13
+ &.zoom-out-animation {
14
+ // we only want to animate the scaling when entering zoom out. When sidebars
15
+ // are toggled, the resizing of the iframe handles scaling the canvas as well,
16
+ // and the doubled animations cause very odd animations.
17
+ @include editor-canvas-resize-animation(transform 0s);
18
+ }
28
19
  }
29
20
 
30
21
  .block-editor-iframe__html.is-zoomed-out {
@@ -32,27 +23,27 @@
32
23
  $frame-size: var(--wp-block-editor-iframe-zoom-out-frame-size);
33
24
  $inner-height: var(--wp-block-editor-iframe-zoom-out-inner-height);
34
25
  $content-height: var(--wp-block-editor-iframe-zoom-out-content-height);
35
- $prev-container-width: var(--wp-block-editor-iframe-zoom-out-prev-container-width);
36
-
37
- transform: scale(#{$scale});
38
-
26
+ $scale-container-width: var(--wp-block-editor-iframe-zoom-out-scale-container-width);
27
+ $container-width: var(--wp-block-editor-iframe-zoom-out-container-width, 100vw);
28
+ // Apply an X translation to center the scaled content within the available space.
29
+ transform: translateX(calc((#{$scale-container-width} - #{$container-width}) / 2 / #{$scale}));
30
+ scale: #{$scale};
39
31
  background-color: $gray-300;
40
32
 
41
- // Firefox and Safari don't render margin-bottom here and margin-bottom is needed for Chrome
42
- // layout, so we use border matching the background instead of margins.
43
- border: calc(#{$frame-size} / #{$scale}) solid $gray-300;
44
-
45
33
  // Chrome seems to respect that transform scale shouldn't affect the layout size of the element,
46
34
  // so we need to adjust the height of the content to match the scale by using negative margins.
47
35
  $extra-content-height: calc(#{$content-height} * (1 - #{$scale}));
48
- $total-frame-height: calc(2 * #{$frame-size});
36
+ $total-frame-height: calc(2 * #{$frame-size} / #{$scale});
49
37
  $total-height: calc(#{$extra-content-height} + #{$total-frame-height} + 2px);
50
38
  margin-bottom: calc(-1 * #{$total-height});
39
+ // Add the top/bottom frame size. We use scaling to account for the left/right, as
40
+ // the padding left/right causes the contents to reflow, which breaks the 1:1 scaling
41
+ // of the content.
42
+ padding-top: calc(#{$frame-size} / #{$scale});
43
+ padding-bottom: calc(#{$frame-size} / #{$scale});
51
44
 
52
45
  body {
53
46
  min-height: calc((#{$inner-height} - #{$total-frame-height}) / #{$scale});
54
- display: flex;
55
- flex-direction: column;
56
47
 
57
48
  > .is-root-container:not(.wp-block-post-content) {
58
49
  flex: 1;