@wordpress/block-editor 14.3.3 → 14.3.5

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 (135) hide show
  1. package/README.md +42 -0
  2. package/build/components/block-variation-picker/index.js +2 -4
  3. package/build/components/block-variation-picker/index.js.map +1 -1
  4. package/build/components/block-variation-transforms/index.js +3 -4
  5. package/build/components/block-variation-transforms/index.js.map +1 -1
  6. package/build/components/button-block-appender/index.js +2 -4
  7. package/build/components/button-block-appender/index.js.map +1 -1
  8. package/build/components/colors-gradients/dropdown.js +2 -4
  9. package/build/components/colors-gradients/dropdown.js.map +1 -1
  10. package/build/components/global-styles/color-panel.js +2 -4
  11. package/build/components/global-styles/color-panel.js.map +1 -1
  12. package/build/components/global-styles/filters-panel.js +2 -4
  13. package/build/components/global-styles/filters-panel.js.map +1 -1
  14. package/build/components/global-styles/shadow-panel-components.js +24 -29
  15. package/build/components/global-styles/shadow-panel-components.js.map +1 -1
  16. package/build/components/inspector-controls-tabs/index.js +11 -8
  17. package/build/components/inspector-controls-tabs/index.js.map +1 -1
  18. package/build/components/inspector-popover-header/index.js +4 -8
  19. package/build/components/inspector-popover-header/index.js.map +1 -1
  20. package/build/components/link-control/index.js +4 -8
  21. package/build/components/link-control/index.js.map +1 -1
  22. package/build/components/link-control/settings-drawer.js +2 -4
  23. package/build/components/link-control/settings-drawer.js.map +1 -1
  24. package/build/components/list-view/block-select-button.js +1 -4
  25. package/build/components/list-view/block-select-button.js.map +1 -1
  26. package/build/components/media-placeholder/index.js +29 -43
  27. package/build/components/media-placeholder/index.js.map +1 -1
  28. package/build/components/rich-text/index.js +4 -8
  29. package/build/components/rich-text/index.js.map +1 -1
  30. package/build/components/skip-to-selected-block/index.js +2 -4
  31. package/build/components/skip-to-selected-block/index.js.map +1 -1
  32. package/build/components/tool-selector/index.js +2 -4
  33. package/build/components/tool-selector/index.js.map +1 -1
  34. package/build/components/url-input/button.js +14 -16
  35. package/build/components/url-input/button.js.map +1 -1
  36. package/build/components/url-input/index.js +2 -4
  37. package/build/components/url-input/index.js.map +1 -1
  38. package/build/hooks/block-bindings.js +6 -13
  39. package/build/hooks/block-bindings.js.map +1 -1
  40. package/build/hooks/use-bindings-attributes.js +5 -4
  41. package/build/hooks/use-bindings-attributes.js.map +1 -1
  42. package/build/layouts/flex.js +6 -38
  43. package/build/layouts/flex.js.map +1 -1
  44. package/build/private-apis.js +0 -2
  45. package/build/private-apis.js.map +1 -1
  46. package/build/utils/block-bindings.js +48 -0
  47. package/build/utils/block-bindings.js.map +1 -1
  48. package/build/utils/index.js +7 -0
  49. package/build/utils/index.js.map +1 -1
  50. package/build-module/components/block-variation-picker/index.js +2 -4
  51. package/build-module/components/block-variation-picker/index.js.map +1 -1
  52. package/build-module/components/block-variation-transforms/index.js +3 -4
  53. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  54. package/build-module/components/button-block-appender/index.js +2 -4
  55. package/build-module/components/button-block-appender/index.js.map +1 -1
  56. package/build-module/components/colors-gradients/dropdown.js +2 -4
  57. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  58. package/build-module/components/global-styles/color-panel.js +2 -4
  59. package/build-module/components/global-styles/color-panel.js.map +1 -1
  60. package/build-module/components/global-styles/filters-panel.js +2 -4
  61. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  62. package/build-module/components/global-styles/shadow-panel-components.js +25 -30
  63. package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
  64. package/build-module/components/inspector-controls-tabs/index.js +12 -9
  65. package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
  66. package/build-module/components/inspector-popover-header/index.js +4 -8
  67. package/build-module/components/inspector-popover-header/index.js.map +1 -1
  68. package/build-module/components/link-control/index.js +4 -8
  69. package/build-module/components/link-control/index.js.map +1 -1
  70. package/build-module/components/link-control/settings-drawer.js +2 -4
  71. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  72. package/build-module/components/list-view/block-select-button.js +2 -5
  73. package/build-module/components/list-view/block-select-button.js.map +1 -1
  74. package/build-module/components/media-placeholder/index.js +30 -44
  75. package/build-module/components/media-placeholder/index.js.map +1 -1
  76. package/build-module/components/rich-text/index.js +4 -8
  77. package/build-module/components/rich-text/index.js.map +1 -1
  78. package/build-module/components/skip-to-selected-block/index.js +2 -4
  79. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  80. package/build-module/components/tool-selector/index.js +2 -4
  81. package/build-module/components/tool-selector/index.js.map +1 -1
  82. package/build-module/components/url-input/button.js +15 -17
  83. package/build-module/components/url-input/button.js.map +1 -1
  84. package/build-module/components/url-input/index.js +2 -4
  85. package/build-module/components/url-input/index.js.map +1 -1
  86. package/build-module/hooks/block-bindings.js +6 -13
  87. package/build-module/hooks/block-bindings.js.map +1 -1
  88. package/build-module/hooks/use-bindings-attributes.js +5 -4
  89. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  90. package/build-module/layouts/flex.js +7 -39
  91. package/build-module/layouts/flex.js.map +1 -1
  92. package/build-module/private-apis.js +0 -2
  93. package/build-module/private-apis.js.map +1 -1
  94. package/build-module/utils/block-bindings.js +48 -0
  95. package/build-module/utils/block-bindings.js.map +1 -1
  96. package/build-module/utils/index.js +1 -0
  97. package/build-module/utils/index.js.map +1 -1
  98. package/build-style/content-rtl.css +2 -17
  99. package/build-style/content.css +2 -17
  100. package/build-style/style-rtl.css +18 -25
  101. package/build-style/style.css +18 -25
  102. package/package.json +6 -6
  103. package/src/components/block-inspector/style.scss +2 -0
  104. package/src/components/block-tools/style.scss +5 -0
  105. package/src/components/block-variation-picker/index.js +1 -2
  106. package/src/components/block-variation-transforms/index.js +2 -2
  107. package/src/components/button-block-appender/content.scss +0 -5
  108. package/src/components/button-block-appender/index.js +1 -2
  109. package/src/components/colors-gradients/dropdown.js +1 -5
  110. package/src/components/global-styles/color-panel.js +1 -5
  111. package/src/components/global-styles/filters-panel.js +1 -2
  112. package/src/components/global-styles/shadow-panel-components.js +28 -33
  113. package/src/components/global-styles/style.scss +5 -0
  114. package/src/components/inspector-controls-tabs/index.js +21 -20
  115. package/src/components/inspector-popover-header/index.js +2 -4
  116. package/src/components/inspector-popover-header/style.scss +0 -13
  117. package/src/components/link-control/index.js +2 -4
  118. package/src/components/link-control/settings-drawer.js +1 -2
  119. package/src/components/list-view/block-select-button.js +2 -5
  120. package/src/components/list-view/style.scss +9 -0
  121. package/src/components/media-placeholder/content.scss +3 -19
  122. package/src/components/media-placeholder/index.js +23 -29
  123. package/src/components/rich-text/index.js +4 -13
  124. package/src/components/skip-to-selected-block/index.js +1 -2
  125. package/src/components/skip-to-selected-block/style.scss +0 -9
  126. package/src/components/tool-selector/index.js +1 -2
  127. package/src/components/url-input/button.js +16 -12
  128. package/src/components/url-input/index.js +1 -2
  129. package/src/components/url-input/style.scss +0 -6
  130. package/src/hooks/block-bindings.js +9 -10
  131. package/src/hooks/use-bindings-attributes.js +66 -63
  132. package/src/layouts/flex.js +10 -53
  133. package/src/private-apis.js +0 -2
  134. package/src/utils/block-bindings.js +47 -0
  135. package/src/utils/index.js +1 -0
@@ -12,7 +12,6 @@ import {
12
12
  arrowDown,
13
13
  } from '@wordpress/icons';
14
14
  import {
15
- Button,
16
15
  ToggleControl,
17
16
  Flex,
18
17
  FlexItem,
@@ -110,7 +109,6 @@ export default {
110
109
  <FlexLayoutVerticalAlignmentControl
111
110
  layout={ layout }
112
111
  onChange={ onChange }
113
- isToolbar
114
112
  />
115
113
  ) }
116
114
  </BlockControls>
@@ -190,11 +188,7 @@ export default {
190
188
  },
191
189
  };
192
190
 
193
- function FlexLayoutVerticalAlignmentControl( {
194
- layout,
195
- onChange,
196
- isToolbar = false,
197
- } ) {
191
+ function FlexLayoutVerticalAlignmentControl( { layout, onChange } ) {
198
192
  const { orientation = 'horizontal' } = layout;
199
193
 
200
194
  const defaultVerticalAlignment =
@@ -210,54 +204,17 @@ function FlexLayoutVerticalAlignmentControl( {
210
204
  verticalAlignment: value,
211
205
  } );
212
206
  };
213
- if ( isToolbar ) {
214
- return (
215
- <BlockVerticalAlignmentControl
216
- onChange={ onVerticalAlignmentChange }
217
- value={ verticalAlignment }
218
- controls={
219
- orientation === 'horizontal'
220
- ? [ 'top', 'center', 'bottom', 'stretch' ]
221
- : [ 'top', 'center', 'bottom', 'space-between' ]
222
- }
223
- />
224
- );
225
- }
226
-
227
- const verticalAlignmentOptions = [
228
- {
229
- value: 'flex-start',
230
- label: __( 'Align items top' ),
231
- },
232
- {
233
- value: 'center',
234
- label: __( 'Align items center' ),
235
- },
236
- {
237
- value: 'flex-end',
238
- label: __( 'Align items bottom' ),
239
- },
240
- ];
241
207
 
242
208
  return (
243
- <fieldset className="block-editor-hooks__flex-layout-vertical-alignment-control">
244
- <legend>{ __( 'Vertical alignment' ) }</legend>
245
- <div>
246
- { verticalAlignmentOptions.map( ( value, icon, label ) => {
247
- return (
248
- <Button
249
- // TODO: Switch to `true` (40px size) if possible
250
- __next40pxDefaultSize={ false }
251
- key={ value }
252
- label={ label }
253
- icon={ icon }
254
- isPressed={ verticalAlignment === value }
255
- onClick={ () => onVerticalAlignmentChange( value ) }
256
- />
257
- );
258
- } ) }
259
- </div>
260
- </fieldset>
209
+ <BlockVerticalAlignmentControl
210
+ onChange={ onVerticalAlignmentChange }
211
+ value={ verticalAlignment }
212
+ controls={
213
+ orientation === 'horizontal'
214
+ ? [ 'top', 'center', 'bottom', 'stretch' ]
215
+ : [ 'top', 'center', 'bottom', 'space-between' ]
216
+ }
217
+ />
261
218
  );
262
219
  }
263
220
 
@@ -47,7 +47,6 @@ import { PrivatePublishDateTimePicker } from './components/publish-date-time-pic
47
47
  import useSpacingSizes from './components/spacing-sizes-control/hooks/use-spacing-sizes';
48
48
  import useBlockDisplayTitle from './components/block-title/use-block-display-title';
49
49
  import TabbedSidebar from './components/tabbed-sidebar';
50
- import { useBlockBindingsUtils } from './utils/block-bindings';
51
50
 
52
51
  /**
53
52
  * Private @wordpress/block-editor APIs.
@@ -92,6 +91,5 @@ lock( privateApis, {
92
91
  useBlockDisplayTitle,
93
92
  __unstableBlockStyleVariationOverridesWithConfig,
94
93
  setBackgroundStyleDefaults,
95
- useBlockBindingsUtils,
96
94
  sectionRootClientIdKey,
97
95
  } );
@@ -13,6 +13,53 @@ function isObjectEmpty( object ) {
13
13
  return ! object || Object.keys( object ).length === 0;
14
14
  }
15
15
 
16
+ /**
17
+ * Contains utils to update the block `bindings` metadata.
18
+ *
19
+ * @typedef {Object} WPBlockBindingsUtils
20
+ *
21
+ * @property {Function} updateBlockBindings Updates the value of the bindings connected to block attributes.
22
+ * @property {Function} removeAllBlockBindings Removes the bindings property of the `metadata` attribute.
23
+ */
24
+
25
+ /**
26
+ * Retrieves the existing utils needed to update the block `bindings` metadata.
27
+ * They can be used to create, modify, or remove connections from the existing block attributes.
28
+ *
29
+ * It contains the following utils:
30
+ * - `updateBlockBindings`: Updates the value of the bindings connected to block attributes. It can be used to remove a specific binding by setting the value to `undefined`.
31
+ * - `removeAllBlockBindings`: Removes the bindings property of the `metadata` attribute.
32
+ *
33
+ * @return {?WPBlockBindingsUtils} Object containing the block bindings utils.
34
+ *
35
+ * @example
36
+ * ```js
37
+ * import { useBlockBindingsUtils } from '@wordpress/block-editor'
38
+ * const { updateBlockBindings, removeAllBlockBindings } = useBlockBindingsUtils();
39
+ *
40
+ * // Update url and alt attributes.
41
+ * updateBlockBindings( {
42
+ * url: {
43
+ * source: 'core/post-meta',
44
+ * args: {
45
+ * key: 'url_custom_field',
46
+ * },
47
+ * },
48
+ * alt: {
49
+ * source: 'core/post-meta',
50
+ * args: {
51
+ * key: 'text_custom_field',
52
+ * },
53
+ * },
54
+ * } );
55
+ *
56
+ * // Remove binding from url attribute.
57
+ * updateBlockBindings( { url: undefined } );
58
+ *
59
+ * // Remove bindings from all attributes.
60
+ * removeAllBlockBindings();
61
+ * ```
62
+ */
16
63
  export function useBlockBindingsUtils() {
17
64
  const { clientId } = useBlockEditContext();
18
65
  const { updateBlockAttributes } = useDispatch( blockEditorStore );
@@ -1,2 +1,3 @@
1
1
  export { default as transformStyles } from './transform-styles';
2
2
  export { default as getPxFromCssUnit } from './get-px-from-css-unit';
3
+ export { useBlockBindingsUtils } from './block-bindings';