@wordpress/block-editor 9.1.0 → 9.2.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 (170) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-draggable/draggable-chip.native.js +2 -1
  3. package/build/components/block-draggable/draggable-chip.native.js.map +1 -1
  4. package/build/components/block-draggable/index.native.js +7 -3
  5. package/build/components/block-draggable/index.native.js.map +1 -1
  6. package/build/components/block-list/block.native.js +2 -1
  7. package/build/components/block-list/block.native.js.map +1 -1
  8. package/build/components/block-list/index.js +34 -32
  9. package/build/components/block-list/index.js.map +1 -1
  10. package/build/components/block-mobile-toolbar/index.native.js +2 -1
  11. package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
  12. package/build/components/block-popover/inbetween.js +9 -6
  13. package/build/components/block-popover/inbetween.js.map +1 -1
  14. package/build/components/block-popover/index.js +2 -1
  15. package/build/components/block-popover/index.js.map +1 -1
  16. package/build/components/block-tools/block-selection-button.js +1 -0
  17. package/build/components/block-tools/block-selection-button.js.map +1 -1
  18. package/build/components/block-variation-transforms/index.js +16 -2
  19. package/build/components/block-variation-transforms/index.js.map +1 -1
  20. package/build/components/colors-gradients/dropdown.js +70 -94
  21. package/build/components/colors-gradients/dropdown.js.map +1 -1
  22. package/build/components/colors-gradients/panel-color-gradient-settings.js +35 -60
  23. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  24. package/build/components/convert-to-group-buttons/toolbar.js +22 -5
  25. package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
  26. package/build/components/index.js +9 -0
  27. package/build/components/index.js.map +1 -1
  28. package/build/components/media-placeholder/index.js +0 -2
  29. package/build/components/media-placeholder/index.js.map +1 -1
  30. package/build/components/media-replace-flow/index.js +0 -2
  31. package/build/components/media-replace-flow/index.js.map +1 -1
  32. package/build/components/media-upload/index.native.js +10 -4
  33. package/build/components/media-upload/index.native.js.map +1 -1
  34. package/build/components/plain-text/index.native.js +62 -7
  35. package/build/components/plain-text/index.native.js.map +1 -1
  36. package/build/components/publish-date-time-picker/index.js +55 -0
  37. package/build/components/publish-date-time-picker/index.js.map +1 -0
  38. package/build/components/rich-text/index.js +1 -1
  39. package/build/components/rich-text/index.js.map +1 -1
  40. package/build/components/rich-text/index.native.js +5 -1
  41. package/build/components/rich-text/index.native.js.map +1 -1
  42. package/build/components/writing-flow/use-input.js +15 -0
  43. package/build/components/writing-flow/use-input.js.map +1 -1
  44. package/build/elements/index.js +9 -0
  45. package/build/elements/index.js.map +1 -0
  46. package/build/hooks/color.js +8 -88
  47. package/build/hooks/color.js.map +1 -1
  48. package/build/hooks/dimensions.js +14 -4
  49. package/build/hooks/dimensions.js.map +1 -1
  50. package/build/index.js +14 -0
  51. package/build/index.js.map +1 -1
  52. package/build/layouts/flex.js +5 -2
  53. package/build/layouts/flex.js.map +1 -1
  54. package/build/store/actions.js +14 -0
  55. package/build/store/actions.js.map +1 -1
  56. package/build/store/reducer.js +17 -2
  57. package/build/store/reducer.js.map +1 -1
  58. package/build/store/selectors.js +29 -1
  59. package/build/store/selectors.js.map +1 -1
  60. package/build-module/components/block-draggable/draggable-chip.native.js +2 -1
  61. package/build-module/components/block-draggable/draggable-chip.native.js.map +1 -1
  62. package/build-module/components/block-draggable/index.native.js +7 -3
  63. package/build-module/components/block-draggable/index.native.js.map +1 -1
  64. package/build-module/components/block-list/block.native.js +2 -1
  65. package/build-module/components/block-list/block.native.js.map +1 -1
  66. package/build-module/components/block-list/index.js +35 -33
  67. package/build-module/components/block-list/index.js.map +1 -1
  68. package/build-module/components/block-mobile-toolbar/index.native.js +2 -1
  69. package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
  70. package/build-module/components/block-popover/inbetween.js +9 -6
  71. package/build-module/components/block-popover/inbetween.js.map +1 -1
  72. package/build-module/components/block-popover/index.js +2 -1
  73. package/build-module/components/block-popover/index.js.map +1 -1
  74. package/build-module/components/block-tools/block-selection-button.js +1 -0
  75. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  76. package/build-module/components/block-variation-transforms/index.js +13 -2
  77. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  78. package/build-module/components/colors-gradients/dropdown.js +72 -96
  79. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  80. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +36 -64
  81. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  82. package/build-module/components/convert-to-group-buttons/toolbar.js +23 -6
  83. package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
  84. package/build-module/components/index.js +1 -0
  85. package/build-module/components/index.js.map +1 -1
  86. package/build-module/components/media-placeholder/index.js +0 -2
  87. package/build-module/components/media-placeholder/index.js.map +1 -1
  88. package/build-module/components/media-replace-flow/index.js +0 -2
  89. package/build-module/components/media-replace-flow/index.js.map +1 -1
  90. package/build-module/components/media-upload/index.native.js +8 -3
  91. package/build-module/components/media-upload/index.native.js.map +1 -1
  92. package/build-module/components/plain-text/index.native.js +63 -8
  93. package/build-module/components/plain-text/index.native.js.map +1 -1
  94. package/build-module/components/publish-date-time-picker/index.js +42 -0
  95. package/build-module/components/publish-date-time-picker/index.js.map +1 -0
  96. package/build-module/components/rich-text/index.js +1 -1
  97. package/build-module/components/rich-text/index.js.map +1 -1
  98. package/build-module/components/rich-text/index.native.js +5 -1
  99. package/build-module/components/rich-text/index.native.js.map +1 -1
  100. package/build-module/components/writing-flow/use-input.js +15 -0
  101. package/build-module/components/writing-flow/use-input.js.map +1 -1
  102. package/build-module/elements/index.js +2 -0
  103. package/build-module/elements/index.js.map +1 -0
  104. package/build-module/hooks/color.js +8 -88
  105. package/build-module/hooks/color.js.map +1 -1
  106. package/build-module/hooks/dimensions.js +14 -4
  107. package/build-module/hooks/dimensions.js.map +1 -1
  108. package/build-module/index.js +1 -0
  109. package/build-module/index.js.map +1 -1
  110. package/build-module/layouts/flex.js +4 -2
  111. package/build-module/layouts/flex.js.map +1 -1
  112. package/build-module/store/actions.js +12 -0
  113. package/build-module/store/actions.js.map +1 -1
  114. package/build-module/store/reducer.js +17 -2
  115. package/build-module/store/reducer.js.map +1 -1
  116. package/build-module/store/selectors.js +23 -0
  117. package/build-module/store/selectors.js.map +1 -1
  118. package/build-style/style-rtl.css +37 -34
  119. package/build-style/style.css +37 -34
  120. package/package.json +30 -30
  121. package/src/components/block-draggable/draggable-chip.native.js +1 -1
  122. package/src/components/block-draggable/index.native.js +4 -0
  123. package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +73 -0
  124. package/src/components/block-draggable/test/helpers.native.js +183 -0
  125. package/src/components/block-draggable/test/index.native.js +496 -0
  126. package/src/components/block-list/block.native.js +1 -0
  127. package/src/components/block-list/index.js +44 -44
  128. package/src/components/block-mobile-toolbar/index.native.js +1 -0
  129. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +4 -0
  130. package/src/components/block-popover/inbetween.js +12 -7
  131. package/src/components/block-popover/index.js +1 -0
  132. package/src/components/block-tools/block-selection-button.js +1 -0
  133. package/src/components/block-variation-transforms/index.js +6 -2
  134. package/src/components/colors-gradients/dropdown.js +35 -61
  135. package/src/components/colors-gradients/panel-color-gradient-settings.js +30 -76
  136. package/src/components/colors-gradients/style.scss +11 -37
  137. package/src/components/convert-to-group-buttons/toolbar.js +30 -13
  138. package/src/components/index.js +1 -0
  139. package/src/components/media-placeholder/index.js +0 -2
  140. package/src/components/media-replace-flow/index.js +0 -2
  141. package/src/components/media-upload/index.native.js +6 -2
  142. package/src/components/media-upload/test/index.native.js +31 -6
  143. package/src/components/plain-text/index.native.js +64 -8
  144. package/src/components/publish-date-time-picker/README.md +52 -0
  145. package/src/components/publish-date-time-picker/index.js +50 -0
  146. package/src/components/publish-date-time-picker/style.scss +20 -0
  147. package/src/components/rich-text/index.js +2 -0
  148. package/src/components/rich-text/index.native.js +4 -0
  149. package/src/components/writing-flow/use-input.js +12 -0
  150. package/src/elements/index.js +1 -0
  151. package/src/hooks/color.js +5 -74
  152. package/src/hooks/color.scss +9 -0
  153. package/src/hooks/dimensions.js +11 -3
  154. package/src/index.js +1 -0
  155. package/src/layouts/flex.js +11 -3
  156. package/src/store/actions.js +12 -0
  157. package/src/store/reducer.js +14 -1
  158. package/src/store/selectors.js +28 -0
  159. package/src/store/test/reducer.js +5 -0
  160. package/src/style.scss +1 -0
  161. package/build/components/colors/color-panel.js +0 -82
  162. package/build/components/colors/color-panel.js.map +0 -1
  163. package/build/components/colors/color-panel.native.js +0 -11
  164. package/build/components/colors/color-panel.native.js.map +0 -1
  165. package/build-module/components/colors/color-panel.js +0 -70
  166. package/build-module/components/colors/color-panel.js.map +0 -1
  167. package/build-module/components/colors/color-panel.native.js +0 -4
  168. package/build-module/components/colors/color-panel.native.js.map +0 -1
  169. package/src/components/colors/color-panel.js +0 -91
  170. package/src/components/colors/color-panel.native.js +0 -3
@@ -28,11 +28,13 @@ function BlockPopoverInbetween( {
28
28
  __unstableContentRef,
29
29
  ...props
30
30
  } ) {
31
- const { orientation, rootClientId } = useSelect(
31
+ const { orientation, rootClientId, isVisible } = useSelect(
32
32
  ( select ) => {
33
- const { getBlockListSettings, getBlockRootClientId } = select(
34
- blockEditorStore
35
- );
33
+ const {
34
+ getBlockListSettings,
35
+ getBlockRootClientId,
36
+ isBlockVisible,
37
+ } = select( blockEditorStore );
36
38
 
37
39
  const _rootClientId = getBlockRootClientId( previousClientId );
38
40
  return {
@@ -40,6 +42,9 @@ function BlockPopoverInbetween( {
40
42
  getBlockListSettings( _rootClientId )?.orientation ||
41
43
  'vertical',
42
44
  rootClientId: _rootClientId,
45
+ isVisible:
46
+ isBlockVisible( previousClientId ) &&
47
+ isBlockVisible( nextClientId ),
43
48
  };
44
49
  },
45
50
  [ previousClientId ]
@@ -48,7 +53,7 @@ function BlockPopoverInbetween( {
48
53
  const nextElement = useBlockElement( nextClientId );
49
54
  const isVertical = orientation === 'vertical';
50
55
  const style = useMemo( () => {
51
- if ( ! previousElement && ! nextElement ) {
56
+ if ( ( ! previousElement && ! nextElement ) || ! isVisible ) {
52
57
  return {};
53
58
  }
54
59
 
@@ -87,7 +92,7 @@ function BlockPopoverInbetween( {
87
92
  }, [ previousElement, nextElement, isVertical ] );
88
93
 
89
94
  const getAnchorRect = useCallback( () => {
90
- if ( ! previousElement && ! nextElement ) {
95
+ if ( ( ! previousElement && ! nextElement ) || ! isVisible ) {
91
96
  return {};
92
97
  }
93
98
 
@@ -149,7 +154,7 @@ function BlockPopoverInbetween( {
149
154
 
150
155
  const popoverScrollRef = usePopoverScroll( __unstableContentRef );
151
156
 
152
- if ( ! previousElement || ! nextElement ) {
157
+ if ( ! previousElement || ! nextElement || ! isVisible ) {
153
158
  return null;
154
159
  }
155
160
 
@@ -62,6 +62,7 @@ export default function BlockPopover( {
62
62
  // Observe movement for block animations (especially horizontal).
63
63
  __unstableObserveElement={ selectedElement }
64
64
  __unstableForcePosition
65
+ __unstableShift
65
66
  { ...props }
66
67
  className={ classnames(
67
68
  'block-editor-block-popover',
@@ -262,6 +262,7 @@ function BlockSelectionButton( { clientId, rootClientId } ) {
262
262
  onClick={ () => setNavigationMode( false ) }
263
263
  onKeyDown={ onKeyDown }
264
264
  label={ label }
265
+ showTooltip={ false }
265
266
  className="block-selection-button_select-button"
266
267
  >
267
268
  <BlockTitle
@@ -17,6 +17,7 @@ import { chevronDown } from '@wordpress/icons';
17
17
  /**
18
18
  * Internal dependencies
19
19
  */
20
+ import BlockIcon from '../block-icon';
20
21
  import { store as blockEditorStore } from '../../store';
21
22
 
22
23
  function VariationsButtons( {
@@ -33,7 +34,7 @@ function VariationsButtons( {
33
34
  { variations.map( ( variation ) => (
34
35
  <Button
35
36
  key={ variation.name }
36
- icon={ variation.icon }
37
+ icon={ <BlockIcon icon={ variation.icon } showColors /> }
37
38
  isPressed={ selectedValue === variation.name }
38
39
  label={
39
40
  selectedValue === variation.name
@@ -121,9 +122,12 @@ function __experimentalBlockVariationTransforms( { blockClientId } ) {
121
122
  // Check if each variation has a unique icon.
122
123
  const hasUniqueIcons = useMemo( () => {
123
124
  const variationIcons = new Set();
125
+ if ( ! variations ) {
126
+ return false;
127
+ }
124
128
  variations.forEach( ( variation ) => {
125
129
  if ( variation.icon ) {
126
- variationIcons.add( variation.icon );
130
+ variationIcons.add( variation.icon?.src || variation.icon );
127
131
  }
128
132
  } );
129
133
  return variationIcons.size === variations.length;
@@ -12,8 +12,6 @@ import {
12
12
  Dropdown,
13
13
  FlexItem,
14
14
  __experimentalHStack as HStack,
15
- __experimentalItem as Item,
16
- __experimentalItemGroup as ItemGroup,
17
15
  __experimentalToolsPanelItem as ToolsPanelItem,
18
16
  } from '@wordpress/components';
19
17
 
@@ -22,46 +20,34 @@ import {
22
20
  */
23
21
  import ColorGradientControl from './control';
24
22
 
25
- // Conditionally wraps the `ColorGradientSettingsDropdown` color controls in an
26
- // `ItemGroup` allowing for a standalone group of controls to be
27
- // rendered semantically.
28
- const WithItemGroup = ( { __experimentalIsItemGroup, children } ) => {
29
- if ( ! __experimentalIsItemGroup ) {
30
- return children;
31
- }
32
-
33
- return (
34
- <ItemGroup
35
- isBordered
36
- isSeparated
37
- className="block-editor-panel-color-gradient-settings__item-group"
38
- >
39
- { children }
40
- </ItemGroup>
41
- );
42
- };
43
-
44
23
  // When the `ColorGradientSettingsDropdown` controls are being rendered to a
45
24
  // `ToolsPanel` they must be wrapped in a `ToolsPanelItem`.
46
- const WithToolsPanelItem = ( {
47
- __experimentalIsItemGroup,
48
- settings,
49
- children,
50
- ...props
51
- } ) => {
52
- if ( __experimentalIsItemGroup ) {
53
- return children;
54
- }
55
-
25
+ const WithToolsPanelItem = ( { setting, children, panelId, ...props } ) => {
26
+ const clearValue = () => {
27
+ if ( setting.colorValue ) {
28
+ setting.onColorChange();
29
+ } else if ( setting.gradientValue ) {
30
+ setting.onGradientChange();
31
+ }
32
+ };
56
33
  return (
57
34
  <ToolsPanelItem
58
- hasValue={ settings.hasValue }
59
- label={ settings.label }
60
- onDeselect={ settings.onDeselect }
61
- isShownByDefault={ settings.isShownByDefault }
62
- resetAllFilter={ settings.resetAllFilter }
35
+ hasValue={ () => {
36
+ return !! setting.colorValue || !! setting.gradientValue;
37
+ } }
38
+ label={ setting.label }
39
+ onDeselect={ clearValue }
40
+ isShownByDefault={
41
+ setting.isShownByDefault !== undefined
42
+ ? setting.isShownByDefault
43
+ : true
44
+ }
63
45
  { ...props }
64
46
  className="block-editor-tools-panel-color-gradient-settings__item"
47
+ panelId={ panelId }
48
+ // Pass resetAllFilter if supplied due to rendering via SlotFill
49
+ // into parent ToolsPanel.
50
+ resetAllFilter={ setting.resetAllFilter }
65
51
  >
66
52
  { children }
67
53
  </ToolsPanelItem>
@@ -82,23 +68,21 @@ const LabeledColorIndicator = ( { colorValue, label } ) => (
82
68
  // or as a `Button` if it isn't e.g. the controls are being rendered in
83
69
  // a `ToolsPanel`.
84
70
  const renderToggle = ( settings ) => ( { onToggle, isOpen } ) => {
85
- const { __experimentalIsItemGroup, colorValue, label } = settings;
71
+ const { colorValue, label } = settings;
86
72
 
87
- // Determine component, `Item` or `Button`, to wrap color indicator with.
88
- const ToggleComponent = __experimentalIsItemGroup ? Item : Button;
89
- const toggleClassName = __experimentalIsItemGroup
90
- ? 'block-editor-panel-color-gradient-settings__item'
91
- : 'block-editor-panel-color-gradient-settings__dropdown';
92
73
  const toggleProps = {
93
74
  onClick: onToggle,
94
- className: classnames( toggleClassName, { 'is-open': isOpen } ),
95
- 'aria-expanded': __experimentalIsItemGroup ? undefined : isOpen,
75
+ className: classnames(
76
+ 'block-editor-panel-color-gradient-settings__dropdown',
77
+ { 'is-open': isOpen }
78
+ ),
79
+ 'aria-expanded': isOpen,
96
80
  };
97
81
 
98
82
  return (
99
- <ToggleComponent { ...toggleProps }>
83
+ <Button { ...toggleProps }>
100
84
  <LabeledColorIndicator colorValue={ colorValue } label={ label } />
101
- </ToggleComponent>
85
+ </Button>
102
86
  );
103
87
  };
104
88
 
@@ -115,15 +99,11 @@ export default function ColorGradientSettingsDropdown( {
115
99
  disableCustomGradients,
116
100
  enableAlpha,
117
101
  gradients,
118
- __experimentalIsItemGroup = true,
119
102
  settings,
120
103
  __experimentalHasMultipleOrigins,
121
104
  __experimentalIsRenderedInSidebar,
122
105
  ...props
123
106
  } ) {
124
- const dropdownClassName = __experimentalIsItemGroup
125
- ? 'block-editor-panel-color-gradient-settings__dropdown'
126
- : 'block-editor-tools-panel-color-gradient-settings__dropdown';
127
107
  let popoverProps;
128
108
  if ( __experimentalIsRenderedInSidebar ) {
129
109
  popoverProps = {
@@ -133,12 +113,10 @@ export default function ColorGradientSettingsDropdown( {
133
113
  }
134
114
 
135
115
  return (
136
- // Only wrap with `ItemGroup` if these controls are being rendered
137
- // semantically.
138
- <WithItemGroup __experimentalIsItemGroup={ __experimentalIsItemGroup }>
116
+ <>
139
117
  { settings.map( ( setting, index ) => {
140
118
  const controlProps = {
141
- clearable: __experimentalIsItemGroup ? undefined : false,
119
+ clearable: false,
142
120
  colorValue: setting.colorValue,
143
121
  colors,
144
122
  disableCustomColors,
@@ -156,7 +134,6 @@ export default function ColorGradientSettingsDropdown( {
156
134
  };
157
135
  const toggleSettings = {
158
136
  colorValue: setting.gradientValue ?? setting.colorValue,
159
- __experimentalIsItemGroup,
160
137
  label: setting.label,
161
138
  };
162
139
 
@@ -166,15 +143,12 @@ export default function ColorGradientSettingsDropdown( {
166
143
  // `ToolsPanelItem`
167
144
  <WithToolsPanelItem
168
145
  key={ index }
169
- __experimentalIsItemGroup={
170
- __experimentalIsItemGroup
171
- }
172
- settings={ setting }
146
+ setting={ setting }
173
147
  { ...props }
174
148
  >
175
149
  <Dropdown
176
150
  popoverProps={ popoverProps }
177
- className={ dropdownClassName }
151
+ className="block-editor-tools-panel-color-gradient-settings__dropdown"
178
152
  contentClassName="block-editor-panel-color-gradient-settings__dropdown-content"
179
153
  renderToggle={ renderToggle( toggleSettings ) }
180
154
  renderContent={ () => (
@@ -185,6 +159,6 @@ export default function ColorGradientSettingsDropdown( {
185
159
  )
186
160
  );
187
161
  } ) }
188
- </WithItemGroup>
162
+ </>
189
163
  );
190
164
  }
@@ -9,27 +9,19 @@ import { every, isEmpty } from 'lodash';
9
9
  */
10
10
  import {
11
11
  __experimentalSpacer as Spacer,
12
- ColorIndicator,
13
- PanelBody,
12
+ __experimentalToolsPanel as ToolsPanel,
14
13
  } from '@wordpress/components';
15
- import { sprintf, __ } from '@wordpress/i18n';
14
+ import { useRegistry } from '@wordpress/data';
15
+ import { useInstanceId } from '@wordpress/compose';
16
16
 
17
17
  /**
18
18
  * Internal dependencies
19
19
  */
20
20
  import ColorGradientSettingsDropdown from './dropdown';
21
- import { getColorObjectByColorValue } from '../colors';
22
- import { __experimentalGetGradientObjectByGradientValue } from '../gradients';
23
21
  import useSetting from '../use-setting';
24
22
  import useCommonSingleMultipleSelects from './use-common-single-multiple-selects';
25
23
  import useMultipleOriginColorsAndGradients from './use-multiple-origin-colors-and-gradients';
26
24
 
27
- // translators: first %s: The type of color or gradient (e.g. background, overlay...), second %s: the color name or value (e.g. red or #ff0000)
28
- const colorIndicatorAriaLabel = __( '(%s: color %s)' );
29
-
30
- // translators: first %s: The type of color or gradient (e.g. background, overlay...), second %s: the color name or value (e.g. red or #ff0000)
31
- const gradientIndicatorAriaLabel = __( '(%s: gradient %s)' );
32
-
33
25
  const colorsAndGradientKeys = [
34
26
  'colors',
35
27
  'disableCustomColors',
@@ -37,55 +29,6 @@ const colorsAndGradientKeys = [
37
29
  'disableCustomGradients',
38
30
  ];
39
31
 
40
- const Indicators = ( { colors, gradients, settings } ) => {
41
- return settings.map(
42
- (
43
- {
44
- colorValue,
45
- gradientValue,
46
- label,
47
- colors: availableColors,
48
- gradients: availableGradients,
49
- },
50
- index
51
- ) => {
52
- if ( ! colorValue && ! gradientValue ) {
53
- return null;
54
- }
55
- let ariaLabel;
56
- if ( colorValue ) {
57
- const colorObject = getColorObjectByColorValue(
58
- availableColors || colors,
59
- colorValue
60
- );
61
- ariaLabel = sprintf(
62
- colorIndicatorAriaLabel,
63
- label.toLowerCase(),
64
- ( colorObject && colorObject.name ) || colorValue
65
- );
66
- } else {
67
- const gradientObject = __experimentalGetGradientObjectByGradientValue(
68
- availableGradients || gradients,
69
- colorValue
70
- );
71
- ariaLabel = sprintf(
72
- gradientIndicatorAriaLabel,
73
- label.toLowerCase(),
74
- ( gradientObject && gradientObject.name ) || gradientValue
75
- );
76
- }
77
-
78
- return (
79
- <ColorIndicator
80
- key={ index }
81
- colorValue={ colorValue || gradientValue }
82
- aria-label={ ariaLabel }
83
- />
84
- );
85
- }
86
- );
87
- };
88
-
89
32
  export const PanelColorGradientSettingsInner = ( {
90
33
  className,
91
34
  colors,
@@ -99,8 +42,9 @@ export const PanelColorGradientSettingsInner = ( {
99
42
  __experimentalHasMultipleOrigins,
100
43
  __experimentalIsRenderedInSidebar,
101
44
  enableAlpha,
102
- ...props
103
45
  } ) => {
46
+ const panelId = useInstanceId( PanelColorGradientSettingsInner );
47
+ const { batch } = useRegistry();
104
48
  if (
105
49
  isEmpty( colors ) &&
106
50
  isEmpty( gradients ) &&
@@ -120,28 +64,38 @@ export const PanelColorGradientSettingsInner = ( {
120
64
  return null;
121
65
  }
122
66
 
123
- const titleElement = (
124
- <span className="block-editor-panel-color-gradient-settings__panel-title">
125
- { title }
126
- <Indicators
127
- colors={ colors }
128
- gradients={ gradients }
129
- settings={ settings }
130
- />
131
- </span>
132
- );
133
-
134
67
  return (
135
- <PanelBody
68
+ <ToolsPanel
136
69
  className={ classnames(
137
70
  'block-editor-panel-color-gradient-settings',
138
71
  className
139
72
  ) }
140
- title={ showTitle ? titleElement : undefined }
141
- { ...props }
73
+ label={ showTitle ? title : undefined }
74
+ resetAll={ () => {
75
+ batch( () => {
76
+ settings.forEach(
77
+ ( {
78
+ colorValue,
79
+ gradientValue,
80
+ onColorChange,
81
+ onGradientChange,
82
+ } ) => {
83
+ if ( colorValue ) {
84
+ onColorChange();
85
+ } else if ( gradientValue ) {
86
+ onGradientChange();
87
+ }
88
+ }
89
+ );
90
+ } );
91
+ } }
92
+ panelId={ panelId }
93
+ __experimentalFirstVisibleItemClass="first"
94
+ __experimentalLastVisibleItemClass="last"
142
95
  >
143
96
  <ColorGradientSettingsDropdown
144
97
  settings={ settings }
98
+ panelId={ panelId }
145
99
  { ...{
146
100
  colors,
147
101
  gradients,
@@ -157,7 +111,7 @@ export const PanelColorGradientSettingsInner = ( {
157
111
  <Spacer marginY={ 4 } /> { children }
158
112
  </>
159
113
  ) }
160
- </PanelBody>
114
+ </ToolsPanel>
161
115
  );
162
116
  };
163
117
 
@@ -10,25 +10,14 @@
10
10
  min-width: 0;
11
11
  }
12
12
 
13
- .block-editor-panel-color-gradient-settings {
14
- .block-editor-panel-color-gradient-settings__panel-title {
15
- display: flex;
16
- gap: $grid-unit-10;
17
-
18
- .component-color-indicator {
19
- width: $grid-unit-15;
20
- height: $grid-unit-15;
21
- align-self: center;
22
-
23
- &:first-child {
24
- margin-left: $grid-unit-15;
25
- }
26
- }
13
+ .block-editor-panel-color-gradient-settings.block-editor-panel-color-gradient-settings {
14
+ &,
15
+ & > div:not(:first-of-type) {
16
+ display: block;
27
17
  }
18
+ }
28
19
 
29
- &.is-opened &__panel-title .component-color-indicator {
30
- display: none;
31
- }
20
+ .block-editor-panel-color-gradient-settings {
32
21
 
33
22
  // Must equal $color-palette-circle-size from:
34
23
  // @wordpress/components/src/circular-option-picker/style.scss
@@ -49,32 +38,12 @@
49
38
  margin-bottom: inherit;
50
39
  }
51
40
 
52
- .block-editor-panel-color-gradient-settings__dropdown {
53
- display: block;
54
- }
55
- }
56
-
57
- .block-editor-panel-color-gradient-settings__dropdown {
58
- width: 100%;
59
41
  }
60
42
 
61
43
  .block-editor-panel-color-gradient-settings__dropdown-content .components-popover__content {
62
44
  width: $sidebar-width;
63
45
  }
64
46
 
65
- .block-editor-panel-color-gradient-settings__dropdown:last-child > div {
66
- border-bottom-width: 0;
67
- }
68
-
69
- .block-editor-panel-color-gradient-settings__item {
70
- padding-top: $grid-unit-15 !important;
71
- padding-bottom: $grid-unit-15 !important;
72
-
73
- &.is-open {
74
- background: $gray-100;
75
- color: var(--wp-admin-theme-color);
76
- }
77
- }
78
47
 
79
48
  .block-editor-panel-color-gradient-settings__color-indicator {
80
49
  // Show a diagonal line (crossed out) for empty swatches.
@@ -97,6 +66,7 @@
97
66
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
98
67
 
99
68
  &.first {
69
+ margin-top: $grid-unit-30;
100
70
  border-top-left-radius: 2px;
101
71
  border-top-right-radius: 2px;
102
72
  border-top: 1px solid rgba(0, 0, 0, 0.1);
@@ -126,3 +96,7 @@
126
96
  }
127
97
  }
128
98
  }
99
+
100
+ .block-editor-panel-color-gradient-settings__dropdown {
101
+ width: 100%;
102
+ }
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useDispatch, useSelect } from '@wordpress/data';
5
- import { switchToBlockType } from '@wordpress/blocks';
5
+ import { switchToBlockType, store as blocksStore } from '@wordpress/blocks';
6
6
  import { ToolbarButton, ToolbarGroup } from '@wordpress/components';
7
7
  import { group, row, stack } from '@wordpress/icons';
8
8
  import { _x } from '@wordpress/i18n';
@@ -28,14 +28,20 @@ function BlockGroupToolbar() {
28
28
  } = useConvertToGroupButtonProps();
29
29
  const { replaceBlocks } = useDispatch( blockEditorStore );
30
30
 
31
- const { canRemove } = useSelect(
31
+ const { canRemove, variations } = useSelect(
32
32
  ( select ) => {
33
33
  const { canRemoveBlocks } = select( blockEditorStore );
34
+ const { getBlockVariations } = select( blocksStore );
35
+
34
36
  return {
35
37
  canRemove: canRemoveBlocks( clientIds ),
38
+ variations: getBlockVariations(
39
+ groupingBlockName,
40
+ 'transform'
41
+ ),
36
42
  };
37
43
  },
38
- [ clientIds ]
44
+ [ clientIds, groupingBlockName ]
39
45
  );
40
46
 
41
47
  const onConvertToGroup = ( layout = 'group' ) => {
@@ -63,6 +69,13 @@ function BlockGroupToolbar() {
63
69
  return null;
64
70
  }
65
71
 
72
+ const canInsertRow = !! variations.find(
73
+ ( { name } ) => name === 'group-row'
74
+ );
75
+ const canInsertStack = !! variations.find(
76
+ ( { name } ) => name === 'group-stack'
77
+ );
78
+
66
79
  return (
67
80
  <ToolbarGroup>
68
81
  <ToolbarButton
@@ -70,16 +83,20 @@ function BlockGroupToolbar() {
70
83
  label={ _x( 'Group', 'verb' ) }
71
84
  onClick={ onConvertToGroup }
72
85
  />
73
- <ToolbarButton
74
- icon={ row }
75
- label={ _x( 'Row', 'single horizontal line' ) }
76
- onClick={ onConvertToRow }
77
- />
78
- <ToolbarButton
79
- icon={ stack }
80
- label={ _x( 'Stack', 'verb' ) }
81
- onClick={ onConvertToStack }
82
- />
86
+ { canInsertRow && (
87
+ <ToolbarButton
88
+ icon={ row }
89
+ label={ _x( 'Row', 'single horizontal line' ) }
90
+ onClick={ onConvertToRow }
91
+ />
92
+ ) }
93
+ { canInsertStack && (
94
+ <ToolbarButton
95
+ icon={ stack }
96
+ label={ _x( 'Stack', 'verb' ) }
97
+ onClick={ onConvertToStack }
98
+ />
99
+ ) }
83
100
  </ToolbarGroup>
84
101
  );
85
102
  }
@@ -147,6 +147,7 @@ export { default as useBlockDisplayInformation } from './use-block-display-infor
147
147
  export { default as __unstableIframe } from './iframe';
148
148
  export { default as __experimentalUseNoRecursiveRenders } from './use-no-recursive-renders';
149
149
  export { default as __experimentalBlockPatternsList } from './block-patterns-list';
150
+ export { default as __experimentalPublishDateTimePicker } from './publish-date-time-picker';
150
151
 
151
152
  /*
152
153
  * State Related Components
@@ -73,7 +73,6 @@ export function MediaPlaceholder( {
73
73
  onDoubleClick,
74
74
  onFilesPreUpload = noop,
75
75
  onHTMLDrop = noop,
76
- onClose = noop,
77
76
  children,
78
77
  mediaLibraryButton,
79
78
  placeholder,
@@ -327,7 +326,6 @@ export function MediaPlaceholder( {
327
326
  gallery={ multiple && onlyAllowsImages() }
328
327
  multiple={ multiple }
329
328
  onSelect={ onSelect }
330
- onClose={ onClose }
331
329
  allowedTypes={ allowedTypes }
332
330
  value={
333
331
  Array.isArray( value )
@@ -42,7 +42,6 @@ const MediaReplaceFlow = ( {
42
42
  onSelect,
43
43
  onSelectURL,
44
44
  onFilesUpload = noop,
45
- onCloseModal = noop,
46
45
  name = __( 'Replace' ),
47
46
  createNotice,
48
47
  removeNotice,
@@ -158,7 +157,6 @@ const MediaReplaceFlow = ( {
158
157
  selectMedia( media, onClose )
159
158
  }
160
159
  allowedTypes={ allowedTypes }
161
- onClose={ onCloseModal }
162
160
  render={ ( { open } ) => (
163
161
  <MenuItem icon={ mediaIcon } onClick={ open }>
164
162
  { __( 'Open Media Library' ) }
@@ -39,6 +39,7 @@ export const OPTION_TAKE_VIDEO = __( 'Take a Video' );
39
39
  export const OPTION_TAKE_PHOTO = __( 'Take a Photo' );
40
40
  export const OPTION_TAKE_PHOTO_OR_VIDEO = __( 'Take a Photo or Video' );
41
41
  export const OPTION_INSERT_FROM_URL = __( 'Insert from URL' );
42
+ export const OPTION_WORDPRESS_MEDIA_LIBRARY = __( 'WordPress Media Library' );
42
43
 
43
44
  const URL_MEDIA_SOURCE = 'URL';
44
45
 
@@ -78,6 +79,8 @@ export class MediaUpload extends Component {
78
79
  }
79
80
 
80
81
  getAllSources() {
82
+ const { onSelectURL } = this.props;
83
+
81
84
  const cameraImageSource = {
82
85
  id: mediaSources.deviceCamera, // ID is the value sent to native.
83
86
  value: mediaSources.deviceCamera + '-IMAGE', // This is needed to diferenciate image-camera from video-camera sources.
@@ -124,16 +127,17 @@ export class MediaUpload extends Component {
124
127
  id: URL_MEDIA_SOURCE,
125
128
  value: URL_MEDIA_SOURCE,
126
129
  label: __( 'Insert from URL' ),
127
- types: [ MEDIA_TYPE_AUDIO ],
130
+ types: [ MEDIA_TYPE_AUDIO, MEDIA_TYPE_IMAGE ],
128
131
  icon: globe,
129
132
  };
130
133
 
134
+ // Only include `urlSource` option if `onSelectURL` prop is present, in order to match the web behavior.
131
135
  const internalSources = [
132
136
  deviceLibrarySource,
133
137
  cameraImageSource,
134
138
  cameraVideoSource,
135
139
  siteLibrarySource,
136
- urlSource,
140
+ ...( onSelectURL ? [ urlSource ] : [] ),
137
141
  ];
138
142
 
139
143
  return internalSources.concat( this.state.otherMediaOptions );