@wordpress/block-editor 8.5.2 → 8.6.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 (186) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-list/block.native.js +3 -1
  3. package/build/components/block-list/block.native.js.map +1 -1
  4. package/build/components/block-mover/button.js +4 -4
  5. package/build/components/block-mover/button.js.map +1 -1
  6. package/build/components/block-mover/index.js +39 -65
  7. package/build/components/block-mover/index.js.map +1 -1
  8. package/build/components/block-popover/inbetween.js +183 -0
  9. package/build/components/block-popover/inbetween.js.map +1 -0
  10. package/build/components/block-popover/index.js +82 -0
  11. package/build/components/block-popover/index.js.map +1 -0
  12. package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
  13. package/build/components/block-popover/use-popover-scroll.js.map +1 -0
  14. package/build/components/block-styles/index.js +1 -10
  15. package/build/components/block-styles/index.js.map +1 -1
  16. package/build/components/block-tools/back-compat.js +2 -2
  17. package/build/components/block-tools/back-compat.js.map +1 -1
  18. package/build/components/block-tools/block-selection-button.js +4 -2
  19. package/build/components/block-tools/block-selection-button.js.map +1 -1
  20. package/build/components/block-tools/index.js +5 -5
  21. package/build/components/block-tools/index.js.map +1 -1
  22. package/build/components/block-tools/insertion-point.js +14 -121
  23. package/build/components/block-tools/insertion-point.js.map +1 -1
  24. package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
  25. package/build/components/block-tools/selected-block-popover.js.map +1 -0
  26. package/build/components/duotone-control/index.js +5 -1
  27. package/build/components/duotone-control/index.js.map +1 -1
  28. package/build/components/inserter/index.native.js +30 -8
  29. package/build/components/inserter/index.native.js.map +1 -1
  30. package/build/components/rich-text/index.js +0 -5
  31. package/build/components/rich-text/index.js.map +1 -1
  32. package/build/components/rich-text/index.native.js +0 -4
  33. package/build/components/rich-text/index.native.js.map +1 -1
  34. package/build/components/use-block-display-information/index.js +3 -1
  35. package/build/components/use-block-display-information/index.js.map +1 -1
  36. package/build/hooks/border.js +468 -44
  37. package/build/hooks/border.js.map +1 -1
  38. package/build/hooks/duotone.js +66 -16
  39. package/build/hooks/duotone.js.map +1 -1
  40. package/build/hooks/index.js +8 -2
  41. package/build/hooks/index.js.map +1 -1
  42. package/build/hooks/use-border-props.js +22 -32
  43. package/build/hooks/use-border-props.js.map +1 -1
  44. package/build/index.js +7 -0
  45. package/build/index.js.map +1 -1
  46. package/build/store/actions.js +14 -2
  47. package/build/store/actions.js.map +1 -1
  48. package/build/store/reducer.js +0 -26
  49. package/build/store/reducer.js.map +1 -1
  50. package/build/store/selectors.js +9 -3
  51. package/build/store/selectors.js.map +1 -1
  52. package/build-module/components/block-list/block.native.js +3 -1
  53. package/build-module/components/block-list/block.native.js.map +1 -1
  54. package/build-module/components/block-mover/button.js +5 -5
  55. package/build-module/components/block-mover/button.js.map +1 -1
  56. package/build-module/components/block-mover/index.js +38 -63
  57. package/build-module/components/block-mover/index.js.map +1 -1
  58. package/build-module/components/block-popover/inbetween.js +165 -0
  59. package/build-module/components/block-popover/inbetween.js.map +1 -0
  60. package/build-module/components/block-popover/index.js +67 -0
  61. package/build-module/components/block-popover/index.js.map +1 -0
  62. package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  63. package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
  64. package/build-module/components/block-styles/index.js +1 -9
  65. package/build-module/components/block-styles/index.js.map +1 -1
  66. package/build-module/components/block-tools/back-compat.js +1 -1
  67. package/build-module/components/block-tools/back-compat.js.map +1 -1
  68. package/build-module/components/block-tools/block-selection-button.js +3 -2
  69. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  70. package/build-module/components/block-tools/index.js +3 -3
  71. package/build-module/components/block-tools/index.js.map +1 -1
  72. package/build-module/components/block-tools/insertion-point.js +16 -121
  73. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  74. package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
  75. package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
  76. package/build-module/components/duotone-control/index.js +4 -1
  77. package/build-module/components/duotone-control/index.js.map +1 -1
  78. package/build-module/components/inserter/index.native.js +31 -10
  79. package/build-module/components/inserter/index.native.js.map +1 -1
  80. package/build-module/components/rich-text/index.js +0 -4
  81. package/build-module/components/rich-text/index.js.map +1 -1
  82. package/build-module/components/rich-text/index.native.js +0 -4
  83. package/build-module/components/rich-text/index.native.js.map +1 -1
  84. package/build-module/components/use-block-display-information/index.js +3 -1
  85. package/build-module/components/use-block-display-information/index.js.map +1 -1
  86. package/build-module/hooks/border.js +458 -44
  87. package/build-module/hooks/border.js.map +1 -1
  88. package/build-module/hooks/duotone.js +63 -16
  89. package/build-module/hooks/duotone.js.map +1 -1
  90. package/build-module/hooks/index.js +2 -1
  91. package/build-module/hooks/index.js.map +1 -1
  92. package/build-module/hooks/use-border-props.js +21 -30
  93. package/build-module/hooks/use-border-props.js.map +1 -1
  94. package/build-module/index.js +1 -1
  95. package/build-module/index.js.map +1 -1
  96. package/build-module/store/actions.js +14 -2
  97. package/build-module/store/actions.js.map +1 -1
  98. package/build-module/store/reducer.js +0 -24
  99. package/build-module/store/reducer.js.map +1 -1
  100. package/build-module/store/selectors.js +8 -3
  101. package/build-module/store/selectors.js.map +1 -1
  102. package/build-style/style-rtl.css +111 -246
  103. package/build-style/style.css +111 -246
  104. package/package.json +28 -28
  105. package/src/components/block-list/block.native.js +2 -0
  106. package/src/components/block-mover/button.js +5 -7
  107. package/src/components/block-mover/index.js +37 -60
  108. package/src/components/block-mover/stories/index.js +110 -0
  109. package/src/components/block-mover/style.scss +48 -138
  110. package/src/components/block-popover/README.md +41 -0
  111. package/src/components/block-popover/inbetween.js +180 -0
  112. package/src/components/block-popover/index.js +73 -0
  113. package/src/components/block-popover/style.scss +24 -0
  114. package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  115. package/src/components/block-styles/index.js +1 -12
  116. package/src/components/block-switcher/style.scss +0 -4
  117. package/src/components/block-toolbar/style.scss +0 -12
  118. package/src/components/block-tools/back-compat.js +1 -1
  119. package/src/components/block-tools/block-selection-button.js +3 -1
  120. package/src/components/block-tools/index.js +6 -4
  121. package/src/components/block-tools/insertion-point.js +19 -152
  122. package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
  123. package/src/components/block-tools/style.scss +11 -123
  124. package/src/components/border-radius-control/style.scss +5 -2
  125. package/src/components/default-block-appender/style.scss +1 -2
  126. package/src/components/duotone-control/index.js +8 -1
  127. package/src/components/gradients/README.md +29 -0
  128. package/src/components/inserter/index.native.js +60 -25
  129. package/src/components/inserter/style.native.scss +24 -3
  130. package/src/components/navigable-toolbar/README.md +16 -0
  131. package/src/components/rich-text/index.js +0 -2
  132. package/src/components/rich-text/index.native.js +0 -4
  133. package/src/components/use-block-display-information/index.js +2 -0
  134. package/src/hooks/border.js +438 -72
  135. package/src/hooks/border.scss +48 -0
  136. package/src/hooks/duotone.js +98 -62
  137. package/src/hooks/index.js +2 -1
  138. package/src/hooks/use-border-props.js +15 -32
  139. package/src/index.js +1 -0
  140. package/src/store/actions.js +14 -2
  141. package/src/store/reducer.js +0 -21
  142. package/src/store/selectors.js +12 -3
  143. package/src/store/test/actions.js +0 -18
  144. package/src/store/test/reducer.js +0 -19
  145. package/src/store/test/selectors.js +0 -19
  146. package/src/style.scss +1 -1
  147. package/build/components/block-mobile-toolbar/index.js +0 -42
  148. package/build/components/block-mobile-toolbar/index.js.map +0 -1
  149. package/build/components/block-tools/block-popover.js.map +0 -1
  150. package/build/components/block-tools/use-popover-scroll.js.map +0 -1
  151. package/build/components/list-view/appender.js +0 -93
  152. package/build/components/list-view/appender.js.map +0 -1
  153. package/build/components/list-view/list-item.js +0 -62
  154. package/build/components/list-view/list-item.js.map +0 -1
  155. package/build/components/rich-text/use-caret-in-format.js +0 -43
  156. package/build/components/rich-text/use-caret-in-format.js.map +0 -1
  157. package/build/hooks/border-color.js +0 -302
  158. package/build/hooks/border-color.js.map +0 -1
  159. package/build/hooks/border-style.js +0 -96
  160. package/build/hooks/border-style.js.map +0 -1
  161. package/build/hooks/border-width.js +0 -162
  162. package/build/hooks/border-width.js.map +0 -1
  163. package/build-module/components/block-mobile-toolbar/index.js +0 -31
  164. package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
  165. package/build-module/components/block-tools/block-popover.js.map +0 -1
  166. package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
  167. package/build-module/components/list-view/appender.js +0 -76
  168. package/build-module/components/list-view/appender.js.map +0 -1
  169. package/build-module/components/list-view/list-item.js +0 -47
  170. package/build-module/components/list-view/list-item.js.map +0 -1
  171. package/build-module/components/rich-text/use-caret-in-format.js +0 -33
  172. package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
  173. package/build-module/hooks/border-color.js +0 -276
  174. package/build-module/hooks/border-color.js.map +0 -1
  175. package/build-module/hooks/border-style.js +0 -78
  176. package/build-module/hooks/border-style.js.map +0 -1
  177. package/build-module/hooks/border-width.js +0 -143
  178. package/build-module/hooks/border-width.js.map +0 -1
  179. package/src/components/block-mobile-toolbar/index.js +0 -24
  180. package/src/components/block-mobile-toolbar/style.scss +0 -29
  181. package/src/components/list-view/appender.js +0 -82
  182. package/src/components/list-view/list-item.js +0 -59
  183. package/src/components/rich-text/use-caret-in-format.js +0 -28
  184. package/src/hooks/border-color.js +0 -315
  185. package/src/hooks/border-style.js +0 -64
  186. package/src/hooks/border-width.js +0 -139
@@ -9,11 +9,9 @@ import classnames from 'classnames';
9
9
  */
10
10
  import { useState, useRef, useEffect } from '@wordpress/element';
11
11
  import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
12
- import { Popover } from '@wordpress/components';
13
12
  import { useDispatch, useSelect } from '@wordpress/data';
14
13
  import { useShortcut } from '@wordpress/keyboard-shortcuts';
15
14
  import { useViewportMatch } from '@wordpress/compose';
16
- import { getScrollContainer } from '@wordpress/dom';
17
15
 
18
16
  /**
19
17
  * Internal dependencies
@@ -22,8 +20,7 @@ import BlockSelectionButton from './block-selection-button';
22
20
  import BlockContextualToolbar from './block-contextual-toolbar';
23
21
  import Inserter from '../inserter';
24
22
  import { store as blockEditorStore } from '../../store';
25
- import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
26
- import { usePopoverScroll } from './use-popover-scroll';
23
+ import BlockPopover from '../block-popover';
27
24
 
28
25
  function selector( select ) {
29
26
  const {
@@ -31,7 +28,6 @@ function selector( select ) {
31
28
  isMultiSelecting,
32
29
  hasMultiSelection,
33
30
  isTyping,
34
- isCaretWithinFormattedText,
35
31
  getSettings,
36
32
  getLastMultiSelectedBlockClientId,
37
33
  } = select( blockEditorStore );
@@ -39,17 +35,16 @@ function selector( select ) {
39
35
  isNavigationMode: isNavigationMode(),
40
36
  isMultiSelecting: isMultiSelecting(),
41
37
  isTyping: isTyping(),
42
- isCaretWithinFormattedText: isCaretWithinFormattedText(),
43
- hasMultiSelection: hasMultiSelection(),
44
38
  hasFixedToolbar: getSettings().hasFixedToolbar,
45
- lastClientId: getLastMultiSelectedBlockClientId(),
39
+ lastClientId: hasMultiSelection()
40
+ ? getLastMultiSelectedBlockClientId()
41
+ : null,
46
42
  };
47
43
  }
48
44
 
49
- function BlockPopover( {
45
+ function SelectedBlockPopover( {
50
46
  clientId,
51
47
  rootClientId,
52
- isValid,
53
48
  isEmptyDefaultBlock,
54
49
  capturingClientId,
55
50
  __unstablePopoverSlot,
@@ -59,8 +54,6 @@ function BlockPopover( {
59
54
  isNavigationMode,
60
55
  isMultiSelecting,
61
56
  isTyping,
62
- isCaretWithinFormattedText,
63
- hasMultiSelection,
64
57
  hasFixedToolbar,
65
58
  lastClientId,
66
59
  } = useSelect( selector, [] );
@@ -83,22 +76,20 @@ function BlockPopover( {
83
76
  [ clientId ]
84
77
  );
85
78
  const isLargeViewport = useViewportMatch( 'medium' );
86
- const [ isToolbarForced, setIsToolbarForced ] = useState( false );
79
+ const isToolbarForced = useRef( false );
87
80
  const [ isInserterShown, setIsInserterShown ] = useState( false );
88
81
  const { stopTyping } = useDispatch( blockEditorStore );
89
82
 
90
- // Controls when the side inserter on empty lines should
91
- // be shown, including writing and selection modes.
92
83
  const showEmptyBlockSideInserter =
93
- ! isTyping && ! isNavigationMode && isEmptyDefaultBlock && isValid;
84
+ ! isTyping && ! isNavigationMode && isEmptyDefaultBlock;
94
85
  const shouldShowBreadcrumb = isNavigationMode;
95
86
  const shouldShowContextualToolbar =
96
87
  ! isNavigationMode &&
97
88
  ! hasFixedToolbar &&
98
89
  isLargeViewport &&
99
- ! showEmptyBlockSideInserter &&
100
90
  ! isMultiSelecting &&
101
- ( ! isTyping || isCaretWithinFormattedText );
91
+ ! showEmptyBlockSideInserter &&
92
+ ! isTyping;
102
93
  const canFocusHiddenToolbar =
103
94
  ! isNavigationMode &&
104
95
  ! shouldShowContextualToolbar &&
@@ -108,7 +99,7 @@ function BlockPopover( {
108
99
  useShortcut(
109
100
  'core/block-editor/focus-toolbar',
110
101
  () => {
111
- setIsToolbarForced( true );
102
+ isToolbarForced.current = true;
112
103
  stopTyping( true );
113
104
  },
114
105
  {
@@ -117,55 +108,17 @@ function BlockPopover( {
117
108
  );
118
109
 
119
110
  useEffect( () => {
120
- if ( ! shouldShowContextualToolbar ) {
121
- setIsToolbarForced( false );
122
- }
123
- }, [ shouldShowContextualToolbar ] );
111
+ isToolbarForced.current = false;
112
+ } );
124
113
 
125
114
  // Stores the active toolbar item index so the block toolbar can return focus
126
115
  // to it when re-mounting.
127
116
  const initialToolbarItemIndexRef = useRef();
128
117
 
129
- const selectedElement = useBlockElement( clientId );
130
- const lastSelectedElement = useBlockElement( lastClientId );
131
- const capturingElement = useBlockElement( capturingClientId );
132
-
133
- const popoverScrollRef = usePopoverScroll( __unstableContentRef );
134
-
135
- if (
136
- ! shouldShowBreadcrumb &&
137
- ! shouldShowContextualToolbar &&
138
- ! isToolbarForced &&
139
- ! showEmptyBlockSideInserter
140
- ) {
118
+ if ( ! shouldShowBreadcrumb && ! shouldShowContextualToolbar ) {
141
119
  return null;
142
120
  }
143
121
 
144
- let node = selectedElement;
145
-
146
- if ( ! node ) {
147
- return null;
148
- }
149
-
150
- if ( capturingClientId ) {
151
- node = capturingElement;
152
- }
153
-
154
- let anchorRef = node;
155
-
156
- if ( hasMultiSelection ) {
157
- // Wait to render the popover until the bottom reference is available
158
- // as well.
159
- if ( ! lastSelectedElement ) {
160
- return null;
161
- }
162
-
163
- anchorRef = {
164
- top: node,
165
- bottom: lastSelectedElement,
166
- };
167
- }
168
-
169
122
  function onFocus() {
170
123
  setIsInserterShown( true );
171
124
  }
@@ -174,48 +127,17 @@ function BlockPopover( {
174
127
  setIsInserterShown( false );
175
128
  }
176
129
 
177
- // Position above the anchor, pop out towards the right, and position in the
178
- // left corner. For the side inserter, pop out towards the left, and
179
- // position in the right corner.
180
- // To do: refactor `Popover` to make this prop clearer.
181
- const popoverPosition = showEmptyBlockSideInserter
182
- ? 'top left right'
183
- : 'top right left';
184
- const { ownerDocument } = node;
185
- const stickyBoundaryElement = showEmptyBlockSideInserter
186
- ? undefined
187
- : // The sticky boundary element should be the boundary at which the
188
- // the block toolbar becomes sticky when the block scolls out of view.
189
- // In case of an iframe, this should be the iframe boundary, otherwise
190
- // the scroll container.
191
- ownerDocument.defaultView.frameElement ||
192
- getScrollContainer( node ) ||
193
- ownerDocument.body;
194
-
195
130
  return (
196
- <Popover
197
- ref={ popoverScrollRef }
198
- noArrow
199
- animate={ false }
200
- position={ popoverPosition }
201
- focusOnMount={ false }
202
- anchorRef={ anchorRef }
131
+ <BlockPopover
132
+ clientId={ capturingClientId || clientId }
133
+ bottomClientId={ lastClientId }
203
134
  className={ classnames( 'block-editor-block-list__block-popover', {
204
135
  'is-insertion-point-visible': isInsertionPointVisible,
205
136
  } ) }
206
- __unstableStickyBoundaryElement={ stickyBoundaryElement }
207
- // Render in the old slot if needed for backward compatibility,
208
- // otherwise render in place (not in the the default popover slot).
209
- __unstableSlotName={ __unstablePopoverSlot || null }
210
- __unstableBoundaryParent
211
- // Observe movement for block animations (especially horizontal).
212
- __unstableObserveElement={ node }
213
- shouldAnchorIncludePadding
214
- // Used to safeguard sticky position behavior against cases where it would permanently
215
- // obscure specific sections of a block.
216
- __unstableEditorCanvasWrapper={ __unstableContentRef?.current }
137
+ __unstablePopoverSlot={ __unstablePopoverSlot }
138
+ __unstableContentRef={ __unstableContentRef }
217
139
  >
218
- { ( shouldShowContextualToolbar || isToolbarForced ) && (
140
+ { shouldShowContextualToolbar && (
219
141
  <div
220
142
  onFocus={ onFocus }
221
143
  onBlur={ onBlur }
@@ -240,11 +162,11 @@ function BlockPopover( {
240
162
  />
241
163
  </div>
242
164
  ) }
243
- { ( shouldShowContextualToolbar || isToolbarForced ) && (
165
+ { shouldShowContextualToolbar && (
244
166
  <BlockContextualToolbar
245
167
  // If the toolbar is being shown because of being forced
246
168
  // it should focus the toolbar right after the mount.
247
- focusOnMount={ isToolbarForced }
169
+ focusOnMount={ isToolbarForced.current }
248
170
  __experimentalInitialIndex={
249
171
  initialToolbarItemIndexRef.current
250
172
  }
@@ -260,20 +182,9 @@ function BlockPopover( {
260
182
  <BlockSelectionButton
261
183
  clientId={ clientId }
262
184
  rootClientId={ rootClientId }
263
- blockElement={ node }
264
185
  />
265
186
  ) }
266
- { showEmptyBlockSideInserter && (
267
- <div className="block-editor-block-list__empty-block-inserter">
268
- <Inserter
269
- position="bottom right"
270
- rootClientId={ rootClientId }
271
- clientId={ clientId }
272
- __experimentalIsQuick
273
- />
274
- </div>
275
- ) }
276
- </Popover>
187
+ </BlockPopover>
277
188
  );
278
189
  }
279
190
 
@@ -294,7 +205,7 @@ function wrapperSelector( select ) {
294
205
  return;
295
206
  }
296
207
 
297
- const { name, attributes = {}, isValid } = getBlock( clientId ) || {};
208
+ const { name, attributes = {} } = getBlock( clientId ) || {};
298
209
  const blockParentsClientIds = getBlockParents( clientId );
299
210
 
300
211
  // Get Block List Settings for all ancestors of the current Block clientId.
@@ -314,7 +225,6 @@ function wrapperSelector( select ) {
314
225
  clientId,
315
226
  rootClientId: getBlockRootClientId( clientId ),
316
227
  name,
317
- isValid,
318
228
  isEmptyDefaultBlock:
319
229
  name && isUnmodifiedDefaultBlock( { name, attributes } ),
320
230
  capturingClientId,
@@ -335,7 +245,6 @@ export default function WrappedBlockPopover( {
335
245
  clientId,
336
246
  rootClientId,
337
247
  name,
338
- isValid,
339
248
  isEmptyDefaultBlock,
340
249
  capturingClientId,
341
250
  } = selected;
@@ -345,10 +254,9 @@ export default function WrappedBlockPopover( {
345
254
  }
346
255
 
347
256
  return (
348
- <BlockPopover
257
+ <SelectedBlockPopover
349
258
  clientId={ clientId }
350
259
  rootClientId={ rootClientId }
351
- isValid={ isValid }
352
260
  isEmptyDefaultBlock={ isEmptyDefaultBlock }
353
261
  capturingClientId={ capturingClientId }
354
262
  __unstablePopoverSlot={ __unstablePopoverSlot }
@@ -4,6 +4,10 @@
4
4
 
5
5
  .block-editor-block-list__insertion-point {
6
6
  position: absolute;
7
+ top: 0;
8
+ bottom: 0;
9
+ left: 0;
10
+ right: 0;
7
11
  }
8
12
 
9
13
  .block-editor-block-list__insertion-point-indicator {
@@ -49,7 +53,6 @@
49
53
  }
50
54
 
51
55
  // Sibling inserter / "inbetweenserter".
52
- .block-editor-block-list__empty-block-inserter,
53
56
  .block-editor-default-block-appender,
54
57
  .block-editor-block-list__insertion-point-inserter,
55
58
  .block-editor-block-list__block-popover-inserter {
@@ -98,7 +101,7 @@
98
101
  position: sticky;
99
102
  top: 0;
100
103
  width: 100%;
101
- z-index: z-index(".block-editor-block-list__block-popover");
104
+ z-index: z-index(".block-editor-block-popover");
102
105
  // Fill up when empty
103
106
  min-height: $block-toolbar-height;
104
107
  display: block;
@@ -112,42 +115,6 @@
112
115
  border-right-color: $gray-200;
113
116
  }
114
117
  }
115
-
116
- .block-editor-block-mover-button {
117
- overflow: hidden;
118
- }
119
-
120
- // Extra specificity to override standard toolbar button styles.
121
- .block-editor-block-mover.is-horizontal .block-editor-block-mover-button.block-editor-block-mover-button {
122
- min-width: $block-toolbar-height*0.5;
123
- width: $block-toolbar-height*0.5;
124
-
125
- svg {
126
- min-width: $block-toolbar-height*0.5;
127
- }
128
- }
129
- }
130
-
131
- // Position mover arrows for both toolbars.
132
- .block-editor-block-contextual-toolbar .block-editor-block-mover:not(.is-horizontal) {
133
- // Position SVGs.
134
- .block-editor-block-mover-button {
135
- &:focus::before {
136
- left: 0 !important;
137
- min-width: 0;
138
- width: 100%;
139
- }
140
- }
141
-
142
- @include break-small() {
143
- .block-editor-block-mover-button.is-up-button svg {
144
- top: 5px;
145
- }
146
-
147
- .block-editor-block-mover-button.is-down-button svg {
148
- bottom: 5px;
149
- }
150
- }
151
118
  }
152
119
 
153
120
  /**
@@ -217,37 +184,6 @@
217
184
  }
218
185
  }
219
186
 
220
- /**
221
- * Popovers.
222
- */
223
-
224
- .block-editor-block-list__insertion-point-popover.is-without-arrow {
225
- z-index: z-index(".block-editor-block-list__insertion-point-popover");
226
- position: absolute;
227
- pointer-events: none;
228
-
229
- * {
230
- pointer-events: none;
231
- }
232
-
233
- .is-with-inserter {
234
- pointer-events: all;
235
-
236
- * {
237
- pointer-events: all;
238
- }
239
- }
240
-
241
- .components-popover__content.components-popover__content {
242
- // Needs specificity.
243
- background: none;
244
- border: none;
245
- box-shadow: none;
246
- overflow-y: visible;
247
- margin-left: 0;
248
- }
249
- }
250
-
251
187
  // Hide the popover block editor list while dragging.
252
188
  // Using a hacky animation to delay hiding the element.
253
189
  // It's needed because if we hide the element immediately upon dragging,
@@ -262,33 +198,12 @@
262
198
  }
263
199
 
264
200
  .components-popover.block-editor-block-list__block-popover {
265
- z-index: z-index(".block-editor-block-list__block-popover");
266
- position: absolute;
267
-
268
- .components-popover__content {
269
- margin: 0 !important;
270
- min-width: auto;
271
- width: max-content;
272
- background: none;
273
- border: none;
274
- box-shadow: none;
275
- overflow-y: visible;
276
-
277
- // Allow clicking through the toolbar holder.
278
- pointer-events: none;
279
-
280
- .block-editor-block-list__block-selection-button,
281
- .block-editor-block-contextual-toolbar,
282
- .block-editor-block-list__empty-block-inserter {
283
- pointer-events: all;
284
- }
285
-
286
- // Position the block toolbar.
287
- .block-editor-block-list__block-selection-button,
288
- .block-editor-block-contextual-toolbar {
289
- margin-top: $grid-unit-15;
290
- margin-bottom: $grid-unit-15;
291
- }
201
+ // Position the block toolbar.
202
+ .block-editor-block-list__block-selection-button,
203
+ .block-editor-block-contextual-toolbar {
204
+ pointer-events: all;
205
+ margin-top: $grid-unit-15;
206
+ margin-bottom: $grid-unit-15;
292
207
  }
293
208
 
294
209
  // Hide the block toolbar if the insertion point is shown.
@@ -307,30 +222,3 @@
307
222
  .is-dragging-components-draggable .components-tooltip {
308
223
  display: none;
309
224
  }
310
-
311
-
312
- // Size multiple sequential buttons to be optically balanced.
313
- // Icons are 36px, as set by a 24px icon and 12px padding.
314
- .block-editor-block-toolbar > .components-toolbar > .block-editor-block-toolbar__slot, // When a plugin adds to a slot, the segment has a `components-toolbar` class.
315
- .block-editor-block-toolbar > .block-editor-block-toolbar__slot > .components-toolbar, // The nesting order is sometimes reversed.
316
- .block-editor-block-toolbar > .block-editor-block-toolbar__slot > .components-dropdown, // Targets unique markup for the "Replace" button.
317
- .block-editor-block-toolbar .components-toolbar-group {
318
- padding-left: $grid-unit-15 * 0.5; // 6px.
319
- padding-right: $grid-unit-15 * 0.5;
320
-
321
- .components-button,
322
- .components-button.has-icon.has-icon {
323
- min-width: $block-toolbar-height - $grid-unit-15;
324
- padding-left: $grid-unit-15 * 0.5; // 6px.
325
- padding-right: $grid-unit-15 * 0.5;
326
-
327
- svg {
328
- min-width: $button-size-small; // This is the optimal icon size, and we size the whole button after this.
329
- }
330
-
331
- &::before {
332
- left: 2px;
333
- right: 2px;
334
- }
335
- }
336
- }
@@ -11,12 +11,14 @@
11
11
  align-items: flex-start;
12
12
 
13
13
  > .components-unit-control-wrapper {
14
- width: calc(50% - 26px);
14
+ width: 110px;
15
15
  margin-bottom: 0;
16
+ margin-right: #{ $grid-unit-10 };
17
+ flex-shrink: 0;
16
18
  }
17
19
 
18
20
  .components-range-control {
19
- width: calc(50% - 26px);
21
+ flex: 1;
20
22
  margin-bottom: 0;
21
23
 
22
24
  .components-base-control__field {
@@ -49,6 +51,7 @@
49
51
  .component-border-radius-control__linked-button.has-icon {
50
52
  display: flex;
51
53
  justify-content: center;
54
+ margin-left: 2px;
52
55
 
53
56
  svg {
54
57
  margin-right: 0;
@@ -34,8 +34,7 @@
34
34
 
35
35
  // The black plus that shows up on the right side of an empty paragraph block, or the initial appender
36
36
  // that exists only on empty documents.
37
- .block-editor-default-block-appender .block-editor-inserter,
38
- .block-editor-block-list__empty-block-inserter.block-editor-block-list__empty-block-inserter { // This needs specificity to override inherited popover styles.
37
+ .block-editor-default-block-appender .block-editor-inserter {
39
38
  position: absolute;
40
39
  top: 0;
41
40
  right: 0;
@@ -10,6 +10,7 @@ import {
10
10
  } from '@wordpress/components';
11
11
  import { __ } from '@wordpress/i18n';
12
12
  import { DOWN } from '@wordpress/keycodes';
13
+ import { Icon, filter } from '@wordpress/icons';
13
14
 
14
15
  function DuotoneControl( {
15
16
  colorPalette,
@@ -41,7 +42,13 @@ function DuotoneControl( {
41
42
  aria-expanded={ isOpen }
42
43
  onKeyDown={ openOnArrowDown }
43
44
  label={ __( 'Apply duotone filter' ) }
44
- icon={ <DuotoneSwatch values={ value } /> }
45
+ icon={
46
+ value ? (
47
+ <DuotoneSwatch values={ value } />
48
+ ) : (
49
+ <Icon icon={ filter } />
50
+ )
51
+ }
45
52
  />
46
53
  );
47
54
  } }
@@ -0,0 +1,29 @@
1
+ # Gradients
2
+
3
+ The `Gradients` component exposes tools for working with gradients
4
+
5
+ <a name="getGradientSlugByValue" href="#getGradientSlugByValue">#</a> **getGradientSlugByValue**
6
+
7
+ Retrieves the gradient slug per slug.
8
+
9
+ _Parameters_
10
+
11
+ - _gradients_ `Array`: Gradient Palette
12
+ - _value_ `string`: Gradient value
13
+
14
+ _Returns_
15
+
16
+ - `string`: Gradient slug.
17
+
18
+ <a name="getGradientValueBySlug" href="#getGradientValueBySlug">#</a> **getGradientValueBySlug**
19
+
20
+ Retrieves the gradient value per slug.
21
+
22
+ _Parameters_
23
+
24
+ - _gradients_ `Array`: Gradient Palette
25
+ - _slug_ `string`: Gradient slug
26
+
27
+ _Returns_
28
+
29
+ - `string`: Gradient value.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { AccessibilityInfo, Platform } from 'react-native';
4
+ import { AccessibilityInfo, Platform, Text } from 'react-native';
5
5
  import { delay } from 'lodash';
6
6
 
7
7
  /**
@@ -15,6 +15,7 @@ import { compose, withPreferredColorScheme } from '@wordpress/compose';
15
15
  import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
16
16
  import {
17
17
  Icon,
18
+ plus,
18
19
  plusCircle,
19
20
  plusCircleFilled,
20
21
  insertAfter,
@@ -32,27 +33,51 @@ import { store as blockEditorStore } from '../../store';
32
33
 
33
34
  const VOICE_OVER_ANNOUNCEMENT_DELAY = 1000;
34
35
 
35
- const defaultRenderToggle = ( { onToggle, disabled, style, onLongPress } ) => (
36
- <ToolbarButton
37
- title={ _x( 'Add block', 'Generic label for block inserter button' ) }
38
- icon={
39
- <Icon
40
- icon={ plusCircleFilled }
41
- style={ style }
42
- color={ style.color }
43
- />
44
- }
45
- onClick={ onToggle }
46
- extraProps={ {
47
- hint: __( 'Double tap to add a block' ),
48
- // testID is present to disambiguate this element for native UI tests. It's not
49
- // usually required for components. See: https://git.io/JeQ7G.
50
- testID: 'add-block-button',
51
- onLongPress,
52
- } }
53
- isDisabled={ disabled }
54
- />
55
- );
36
+ const defaultRenderToggle = ( {
37
+ onToggle,
38
+ disabled,
39
+ style,
40
+ containerStyle,
41
+ onLongPress,
42
+ useExpandedMode,
43
+ } ) => {
44
+ // The "expanded mode" refers to the editor's appearance when no blocks
45
+ // are currently selected. The "add block" button has a separate style
46
+ // for the "expanded mode", which are added via the below "expandedModeViewProps"
47
+ // and "expandedModeViewText" variables.
48
+ const expandedModeViewProps = useExpandedMode && {
49
+ icon: <Icon icon={ plus } style={ style } />,
50
+ customContainerStyles: containerStyle,
51
+ fixedRatio: false,
52
+ };
53
+ const expandedModeViewText = (
54
+ <Text style={ styles[ 'inserter-menu__add-block-button-text' ] }>
55
+ { __( 'Add Blocks' ) }
56
+ </Text>
57
+ );
58
+
59
+ return (
60
+ <ToolbarButton
61
+ title={ _x(
62
+ 'Add block',
63
+ 'Generic label for block inserter button'
64
+ ) }
65
+ icon={ <Icon icon={ plusCircleFilled } style={ style } /> }
66
+ onClick={ onToggle }
67
+ extraProps={ {
68
+ hint: __( 'Double tap to add a block' ),
69
+ // testID is present to disambiguate this element for native UI tests. It's not
70
+ // usually required for components. See: https://git.io/JeQ7G.
71
+ testID: 'add-block-button',
72
+ onLongPress,
73
+ } }
74
+ isDisabled={ disabled }
75
+ { ...expandedModeViewProps }
76
+ >
77
+ { useExpandedMode && expandedModeViewText }
78
+ </ToolbarButton>
79
+ );
80
+ };
56
81
 
57
82
  export class Inserter extends Component {
58
83
  constructor() {
@@ -219,13 +244,21 @@ export class Inserter extends Component {
219
244
  renderToggle = defaultRenderToggle,
220
245
  getStylesFromColorScheme,
221
246
  showSeparator,
247
+ useExpandedMode,
222
248
  } = this.props;
223
249
  if ( showSeparator && isOpen ) {
224
250
  return <BlockInsertionPoint />;
225
251
  }
226
- const style = getStylesFromColorScheme(
227
- styles.addBlockButton,
228
- styles.addBlockButtonDark
252
+ const style = useExpandedMode
253
+ ? styles[ 'inserter-menu__add-block-button-icon--expanded' ]
254
+ : getStylesFromColorScheme(
255
+ styles[ 'inserter-menu__add-block-button-icon' ],
256
+ styles[ 'inserter-menu__add-block-button-icon--dark' ]
257
+ );
258
+
259
+ const containerStyle = getStylesFromColorScheme(
260
+ styles[ 'inserter-menu__add-block-button' ],
261
+ styles[ 'inserter-menu__add-block-button--dark' ]
229
262
  );
230
263
 
231
264
  const onPress = () => {
@@ -265,7 +298,9 @@ export class Inserter extends Component {
265
298
  isOpen,
266
299
  disabled,
267
300
  style,
301
+ containerStyle,
268
302
  onLongPress,
303
+ useExpandedMode,
269
304
  } ) }
270
305
  <Picker
271
306
  ref={ ( instance ) => ( this.picker = instance ) }