@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
@@ -475,16 +475,14 @@ function LinkControl( {
475
475
  className="block-editor-link-control__search-actions"
476
476
  >
477
477
  <Button
478
- // TODO: Switch to `true` (40px size) if possible
479
- __next40pxDefaultSize={ false }
478
+ __next40pxDefaultSize
480
479
  variant="tertiary"
481
480
  onClick={ handleCancel }
482
481
  >
483
482
  { __( 'Cancel' ) }
484
483
  </Button>
485
484
  <Button
486
- // TODO: Switch to `true` (40px size) if possible
487
- __next40pxDefaultSize={ false }
485
+ __next40pxDefaultSize
488
486
  variant="primary"
489
487
  onClick={ isDisabled ? noop : handleSubmit }
490
488
  className="block-editor-link-control__search-submit"
@@ -25,8 +25,7 @@ function LinkSettingsDrawer( { children, settingsOpen, setSettingsOpen } ) {
25
25
  return (
26
26
  <>
27
27
  <Button
28
- // TODO: Switch to `true` (40px size) if possible
29
- __next40pxDefaultSize={ false }
28
+ __next40pxDefaultSize
30
29
  className="block-editor-link-control__drawer-toggle"
31
30
  aria-expanded={ settingsOpen }
32
31
  onClick={ () => setSettingsOpen( ! settingsOpen ) }
@@ -7,7 +7,6 @@ import clsx from 'clsx';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import {
10
- Button,
11
10
  __experimentalHStack as HStack,
12
11
  __experimentalTruncate as Truncate,
13
12
  } from '@wordpress/components';
@@ -82,9 +81,7 @@ function ListViewBlockSelectButton(
82
81
  }
83
82
 
84
83
  return (
85
- <Button
86
- // TODO: Switch to `true` (40px size) if possible
87
- __next40pxDefaultSize={ false }
84
+ <a
88
85
  className={ clsx(
89
86
  'block-editor-list-view-block-select-button',
90
87
  className
@@ -156,7 +153,7 @@ function ListViewBlockSelectButton(
156
153
  </span>
157
154
  ) }
158
155
  </HStack>
159
- </Button>
156
+ </a>
160
157
  );
161
158
  }
162
159
 
@@ -216,6 +216,15 @@
216
216
  text-align: left;
217
217
  position: relative;
218
218
  white-space: nowrap;
219
+ border-radius: 2px;
220
+ box-sizing: border-box;
221
+ color: inherit;
222
+ font-family: inherit;
223
+ font-size: 13px;
224
+ font-weight: 400;
225
+ margin: 0;
226
+ text-decoration: none;
227
+ transition: box-shadow 0.1s linear;
219
228
 
220
229
  &.is-dropping-before::before {
221
230
  content: "";
@@ -1,27 +1,11 @@
1
1
  .block-editor-media-placeholder__url-input-form {
2
- display: flex;
3
-
4
- // Selector requires a lot of specificity to override base styles.
5
- input[type="url"].block-editor-media-placeholder__url-input-field {
6
- width: 100%;
7
- min-width: 200px;
8
-
9
- @include break-small() {
10
- width: 300px;
11
- }
12
-
13
- flex-grow: 1;
14
- border: none;
15
- border-radius: 0;
16
- margin: 2px;
2
+ min-width: 260px;
17
3
 
4
+ @include break-small() {
5
+ width: 300px;
18
6
  }
19
7
  }
20
8
 
21
- .block-editor-media-placeholder__url-input-submit-button {
22
- flex-shrink: 1;
23
- }
24
-
25
9
  .block-editor-media-placeholder__cancel-button.is-link {
26
10
  margin: 1em;
27
11
  display: block;
@@ -11,6 +11,8 @@ import {
11
11
  FormFileUpload,
12
12
  Placeholder,
13
13
  DropZone,
14
+ __experimentalInputControl as InputControl,
15
+ __experimentalInputControlSuffixWrapper as InputControlSuffixWrapper,
14
16
  withFilters,
15
17
  } from '@wordpress/components';
16
18
  import { __ } from '@wordpress/i18n';
@@ -42,21 +44,23 @@ const InsertFromURLPopover = ( {
42
44
  className="block-editor-media-placeholder__url-input-form"
43
45
  onSubmit={ onSubmit }
44
46
  >
45
- <input
46
- className="block-editor-media-placeholder__url-input-field"
47
- type="text"
48
- aria-label={ __( 'URL' ) }
47
+ <InputControl
48
+ __next40pxDefaultSize
49
+ label={ __( 'URL' ) }
50
+ hideLabelFromVision
49
51
  placeholder={ __( 'Paste or type URL' ) }
50
52
  onChange={ onChange }
51
53
  value={ src }
52
- />
53
- <Button
54
- // TODO: Switch to `true` (40px size) if possible
55
- __next40pxDefaultSize={ false }
56
- className="block-editor-media-placeholder__url-input-submit-button"
57
- icon={ keyboardReturn }
58
- label={ __( 'Apply' ) }
59
- type="submit"
54
+ suffix={
55
+ <InputControlSuffixWrapper variant="control">
56
+ <Button
57
+ size="small"
58
+ icon={ keyboardReturn }
59
+ label={ __( 'Apply' ) }
60
+ type="submit"
61
+ />
62
+ </InputControlSuffixWrapper>
63
+ }
60
64
  />
61
65
  </form>
62
66
  </URLPopover>
@@ -87,8 +91,7 @@ const URLSelectionUI = ( { src, onChangeSrc, onSelectURL } ) => {
87
91
  return (
88
92
  <div className="block-editor-media-placeholder__url-input-container">
89
93
  <Button
90
- // TODO: Switch to `true` (40px size) if possible
91
- __next40pxDefaultSize={ false }
94
+ __next40pxDefaultSize
92
95
  className="block-editor-media-placeholder__button"
93
96
  onClick={ openURLInput }
94
97
  isPressed={ isURLInputVisible }
@@ -167,10 +170,6 @@ export function MediaPlaceholder( {
167
170
  );
168
171
  };
169
172
 
170
- const onChangeSrc = ( event ) => {
171
- setSrc( event.target.value );
172
- };
173
-
174
173
  const onFilesUpload = ( files ) => {
175
174
  if (
176
175
  ! handleUpload ||
@@ -389,8 +388,7 @@ export function MediaPlaceholder( {
389
388
  return (
390
389
  onCancel && (
391
390
  <Button
392
- // TODO: Switch to `true` (40px size) if possible
393
- __next40pxDefaultSize={ false }
391
+ __next40pxDefaultSize
394
392
  className="block-editor-media-placeholder__cancel-button"
395
393
  title={ __( 'Cancel' ) }
396
394
  variant="link"
@@ -407,7 +405,7 @@ export function MediaPlaceholder( {
407
405
  onSelectURL && (
408
406
  <URLSelectionUI
409
407
  src={ src }
410
- onChangeSrc={ onChangeSrc }
408
+ onChangeSrc={ setSrc }
411
409
  onSelectURL={ onSelectURL }
412
410
  />
413
411
  )
@@ -419,8 +417,7 @@ export function MediaPlaceholder( {
419
417
  onToggleFeaturedImage && (
420
418
  <div className="block-editor-media-placeholder__url-input-container">
421
419
  <Button
422
- // TODO: Switch to `true` (40px size) if possible
423
- __next40pxDefaultSize={ false }
420
+ __next40pxDefaultSize
424
421
  className="block-editor-media-placeholder__button"
425
422
  onClick={ onToggleFeaturedImage }
426
423
  variant="secondary"
@@ -436,8 +433,7 @@ export function MediaPlaceholder( {
436
433
  const defaultButton = ( { open } ) => {
437
434
  return (
438
435
  <Button
439
- // TODO: Switch to `true` (40px size) if possible
440
- __next40pxDefaultSize={ false }
436
+ __next40pxDefaultSize
441
437
  variant="secondary"
442
438
  onClick={ () => {
443
439
  open();
@@ -477,8 +473,7 @@ export function MediaPlaceholder( {
477
473
  const content = (
478
474
  <>
479
475
  <Button
480
- // TODO: Switch to `true` (40px size) if possible
481
- __next40pxDefaultSize={ false }
476
+ __next40pxDefaultSize
482
477
  variant="primary"
483
478
  className={ clsx(
484
479
  'block-editor-media-placeholder__button',
@@ -508,8 +503,7 @@ export function MediaPlaceholder( {
508
503
  <FormFileUpload
509
504
  render={ ( { openFileDialog } ) => (
510
505
  <Button
511
- // TODO: Switch to `true` (40px size) if possible
512
- __next40pxDefaultSize={ false }
506
+ __next40pxDefaultSize
513
507
  onClick={ openFileDialog }
514
508
  variant="primary"
515
509
  className={ clsx(
@@ -20,7 +20,7 @@ import {
20
20
  removeFormat,
21
21
  } from '@wordpress/rich-text';
22
22
  import { Popover } from '@wordpress/components';
23
- import { store as blocksStore } from '@wordpress/blocks';
23
+ import { getBlockBindingsSource } from '@wordpress/blocks';
24
24
  import deprecated from '@wordpress/deprecated';
25
25
  import { __, sprintf } from '@wordpress/i18n';
26
26
 
@@ -39,7 +39,6 @@ import FormatEdit from './format-edit';
39
39
  import { getAllowedFormats } from './utils';
40
40
  import { Content, valueToHTMLString } from './content';
41
41
  import { withDeprecations } from './with-deprecations';
42
- import { unlock } from '../../lock-unlock';
43
42
  import { canBindBlock } from '../../hooks/use-bindings-attributes';
44
43
  import BlockContext from '../block-context';
45
44
 
@@ -175,7 +174,6 @@ export function RichTextWrapper(
175
174
  }
176
175
 
177
176
  const relatedBinding = blockBindings[ identifier ];
178
- const { getBlockBindingsSource } = unlock( select( blocksStore ) );
179
177
  const blockBindingsSource = getBlockBindingsSource(
180
178
  relatedBinding.source
181
179
  );
@@ -188,7 +186,7 @@ export function RichTextWrapper(
188
186
 
189
187
  const _disableBoundBlock =
190
188
  ! blockBindingsSource?.canUserEditValue?.( {
191
- registry,
189
+ select,
192
190
  context: blockBindingsContext,
193
191
  args: relatedBinding.args,
194
192
  } );
@@ -206,7 +204,7 @@ export function RichTextWrapper(
206
204
  const { getBlockAttributes } = select( blockEditorStore );
207
205
  const blockAttributes = getBlockAttributes( clientId );
208
206
  const fieldsList = blockBindingsSource?.getFieldsList?.( {
209
- registry,
207
+ select,
210
208
  context: blockBindingsContext,
211
209
  } );
212
210
  const bindingKey =
@@ -235,14 +233,7 @@ export function RichTextWrapper(
235
233
  bindingsLabel: _bindingsLabel,
236
234
  };
237
235
  },
238
- [
239
- blockBindings,
240
- identifier,
241
- blockName,
242
- blockContext,
243
- registry,
244
- adjustedValue,
245
- ]
236
+ [ blockBindings, identifier, blockName, blockContext, adjustedValue ]
246
237
  );
247
238
 
248
239
  const shouldDisableEditing = readOnly || disableBoundBlock;
@@ -28,8 +28,7 @@ export default function SkipToSelectedBlock() {
28
28
 
29
29
  return selectedBlockClientId ? (
30
30
  <Button
31
- // TODO: Switch to `true` (40px size) if possible
32
- __next40pxDefaultSize={ false }
31
+ __next40pxDefaultSize
33
32
  variant="secondary"
34
33
  className="block-editor-skip-to-selected-block"
35
34
  onClick={ onClick }
@@ -3,18 +3,9 @@
3
3
  top: -9999em;
4
4
 
5
5
  &:focus {
6
- height: auto;
7
- width: auto;
8
- display: block;
9
6
  font-size: 14px;
10
7
  font-weight: 600;
11
- padding: 15px 23px 14px;
12
8
  background: #f1f1f1;
13
- color: var(--wp-admin-theme-color);
14
- line-height: normal;
15
- box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
16
- text-decoration: none;
17
- outline: none;
18
9
  z-index: z-index(".skip-to-selected-block");
19
10
  }
20
11
  }
@@ -44,8 +44,7 @@ function ToolSelector( props, ref ) {
44
44
  <Dropdown
45
45
  renderToggle={ ( { isOpen, onToggle } ) => (
46
46
  <Button
47
- // TODO: Switch to `true` (40px size) if possible
48
- __next40pxDefaultSize={ false }
47
+ size="compact"
49
48
  { ...props }
50
49
  ref={ ref }
51
50
  icon={ mode === 'navigation' ? selectIcon : editIcon }
@@ -3,7 +3,10 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { Component } from '@wordpress/element';
6
- import { Button } from '@wordpress/components';
6
+ import {
7
+ Button,
8
+ __experimentalInputControlSuffixWrapper as InputControlSuffixWrapper,
9
+ } from '@wordpress/components';
7
10
  import { link, keyboardReturn, arrowLeft } from '@wordpress/icons';
8
11
 
9
12
  /**
@@ -38,8 +41,7 @@ class URLInputButton extends Component {
38
41
  return (
39
42
  <div className="block-editor-url-input__button">
40
43
  <Button
41
- // TODO: Switch to `true` (40px size) if possible
42
- __next40pxDefaultSize={ false }
44
+ size="compact"
43
45
  icon={ link }
44
46
  label={ buttonLabel }
45
47
  onClick={ this.toggle }
@@ -53,8 +55,7 @@ class URLInputButton extends Component {
53
55
  >
54
56
  <div className="block-editor-url-input__button-modal-line">
55
57
  <Button
56
- // TODO: Switch to `true` (40px size) if possible
57
- __next40pxDefaultSize={ false }
58
+ __next40pxDefaultSize
58
59
  className="block-editor-url-input__back"
59
60
  icon={ arrowLeft }
60
61
  label={ __( 'Close' ) }
@@ -63,13 +64,16 @@ class URLInputButton extends Component {
63
64
  <URLInput
64
65
  value={ url || '' }
65
66
  onChange={ onChange }
66
- />
67
- <Button
68
- // TODO: Switch to `true` (40px size) if possible
69
- __next40pxDefaultSize={ false }
70
- icon={ keyboardReturn }
71
- label={ __( 'Submit' ) }
72
- type="submit"
67
+ suffix={
68
+ <InputControlSuffixWrapper variant="control">
69
+ <Button
70
+ size="small"
71
+ icon={ keyboardReturn }
72
+ label={ __( 'Submit' ) }
73
+ type="submit"
74
+ />
75
+ </InputControlSuffixWrapper>
76
+ }
73
77
  />
74
78
  </div>
75
79
  </form>
@@ -540,8 +540,7 @@ class URLInput extends Component {
540
540
  >
541
541
  { suggestions.map( ( suggestion, index ) => (
542
542
  <Button
543
- // TODO: Switch to `true` (40px size) if possible
544
- __next40pxDefaultSize={ false }
543
+ __next40pxDefaultSize
545
544
  { ...buildSuggestionItemProps( suggestion, index ) }
546
545
  key={ suggestion.id }
547
546
  className={ clsx(
@@ -109,10 +109,4 @@ $input-size: 300px;
109
109
  flex-shrink: 1;
110
110
  min-width: 0;
111
111
  align-items: flex-start;
112
-
113
- .components-button {
114
- flex-shrink: 0;
115
- width: $button-size;
116
- height: $button-size;
117
- }
118
112
  }
@@ -2,7 +2,10 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import { privateApis as blocksPrivateApis } from '@wordpress/blocks';
5
+ import {
6
+ getBlockBindingsSource,
7
+ getBlockBindingsSources,
8
+ } from '@wordpress/blocks';
6
9
  import {
7
10
  __experimentalItemGroup as ItemGroup,
8
11
  __experimentalItem as Item,
@@ -12,7 +15,7 @@ import {
12
15
  __experimentalVStack as VStack,
13
16
  privateApis as componentsPrivateApis,
14
17
  } from '@wordpress/components';
15
- import { useRegistry, useSelect } from '@wordpress/data';
18
+ import { useSelect } from '@wordpress/data';
16
19
  import { useContext, Fragment } from '@wordpress/element';
17
20
  import { useViewportMatch } from '@wordpress/compose';
18
21
 
@@ -47,7 +50,6 @@ const useToolsPanelDropdownMenuProps = () => {
47
50
  };
48
51
 
49
52
  function BlockBindingsPanelDropdown( { fieldsList, attribute, binding } ) {
50
- const { getBlockBindingsSources } = unlock( blocksPrivateApis );
51
53
  const registeredSources = getBlockBindingsSources();
52
54
  const { updateBlockBindings } = useBlockBindingsUtils();
53
55
  const currentKey = binding?.args?.key;
@@ -96,8 +98,7 @@ function BlockBindingsPanelDropdown( { fieldsList, attribute, binding } ) {
96
98
 
97
99
  function BlockBindingsAttribute( { attribute, binding, fieldsList } ) {
98
100
  const { source: sourceName, args } = binding || {};
99
- const sourceProps =
100
- unlock( blocksPrivateApis ).getBlockBindingsSource( sourceName );
101
+ const sourceProps = getBlockBindingsSource( sourceName );
101
102
  const isSourceInvalid = ! sourceProps;
102
103
  return (
103
104
  <VStack className="block-editor-bindings__item" spacing={ 0 }>
@@ -186,7 +187,6 @@ function EditableBlockBindingsPanelItems( {
186
187
  }
187
188
 
188
189
  export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
189
- const registry = useRegistry();
190
190
  const blockContext = useContext( BlockContext );
191
191
  const { removeAllBlockBindings } = useBlockBindingsUtils();
192
192
  const bindableAttributes = getBindableAttributes( blockName );
@@ -194,14 +194,13 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
194
194
 
195
195
  // `useSelect` is used purposely here to ensure `getFieldsList`
196
196
  // is updated whenever there are updates in block context.
197
- // `source.getFieldsList` may also call a selector via `registry.select`.
197
+ // `source.getFieldsList` may also call a selector via `select`.
198
198
  const _fieldsList = {};
199
199
  const { fieldsList, canUpdateBlockBindings } = useSelect(
200
200
  ( select ) => {
201
201
  if ( ! bindableAttributes || bindableAttributes.length === 0 ) {
202
202
  return EMPTY_OBJECT;
203
203
  }
204
- const { getBlockBindingsSources } = unlock( blocksPrivateApis );
205
204
  const registeredSources = getBlockBindingsSources();
206
205
  Object.entries( registeredSources ).forEach(
207
206
  ( [ sourceName, { getFieldsList, usesContext } ] ) => {
@@ -214,7 +213,7 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
214
213
  }
215
214
  }
216
215
  const sourceList = getFieldsList( {
217
- registry,
216
+ select,
218
217
  context,
219
218
  } );
220
219
  // Only add source if the list is not empty.
@@ -234,7 +233,7 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
234
233
  .canUpdateBlockBindings,
235
234
  };
236
235
  },
237
- [ blockContext, bindableAttributes, registry ]
236
+ [ blockContext, bindableAttributes ]
238
237
  );
239
238
  // Return early if there are no bindable attributes.
240
239
  if ( ! bindableAttributes || bindableAttributes.length === 0 ) {
@@ -118,79 +118,81 @@ export const withBlockBindingSupport = createHigherOrderComponent(
118
118
  // there are attribute updates.
119
119
  // `source.getValues` may also call a selector via `registry.select`.
120
120
  const updatedContext = {};
121
- const boundAttributes = useSelect( () => {
122
- if ( ! blockBindings ) {
123
- return;
124
- }
121
+ const boundAttributes = useSelect(
122
+ ( select ) => {
123
+ if ( ! blockBindings ) {
124
+ return;
125
+ }
125
126
 
126
- const attributes = {};
127
+ const attributes = {};
127
128
 
128
- const blockBindingsBySource = new Map();
129
+ const blockBindingsBySource = new Map();
129
130
 
130
- for ( const [ attributeName, binding ] of Object.entries(
131
- blockBindings
132
- ) ) {
133
- const { source: sourceName, args: sourceArgs } = binding;
134
- const source = sources[ sourceName ];
135
- if ( ! source || ! canBindAttribute( name, attributeName ) ) {
136
- continue;
137
- }
131
+ for ( const [ attributeName, binding ] of Object.entries(
132
+ blockBindings
133
+ ) ) {
134
+ const { source: sourceName, args: sourceArgs } = binding;
135
+ const source = sources[ sourceName ];
136
+ if (
137
+ ! source ||
138
+ ! canBindAttribute( name, attributeName )
139
+ ) {
140
+ continue;
141
+ }
138
142
 
139
- // Populate context.
140
- for ( const key of source.usesContext || [] ) {
141
- updatedContext[ key ] = blockContext[ key ];
142
- }
143
+ // Populate context.
144
+ for ( const key of source.usesContext || [] ) {
145
+ updatedContext[ key ] = blockContext[ key ];
146
+ }
143
147
 
144
- blockBindingsBySource.set( source, {
145
- ...blockBindingsBySource.get( source ),
146
- [ attributeName ]: {
147
- args: sourceArgs,
148
- },
149
- } );
150
- }
148
+ blockBindingsBySource.set( source, {
149
+ ...blockBindingsBySource.get( source ),
150
+ [ attributeName ]: {
151
+ args: sourceArgs,
152
+ },
153
+ } );
154
+ }
151
155
 
152
- if ( blockBindingsBySource.size ) {
153
- for ( const [ source, bindings ] of blockBindingsBySource ) {
154
- // Get values in batch if the source supports it.
155
- let values = {};
156
- if ( ! source.getValues ) {
157
- Object.keys( bindings ).forEach( ( attr ) => {
158
- // Default to the the source label when `getValues` doesn't exist.
159
- values[ attr ] = source.label;
160
- } );
161
- } else {
162
- values = source.getValues( {
163
- registry,
164
- context: updatedContext,
165
- clientId,
166
- bindings,
167
- } );
168
- }
169
- for ( const [ attributeName, value ] of Object.entries(
170
- values
171
- ) ) {
172
- if (
173
- attributeName === 'url' &&
174
- ( ! value || ! isURLLike( value ) )
175
- ) {
176
- // Return null if value is not a valid URL.
177
- attributes[ attributeName ] = null;
156
+ if ( blockBindingsBySource.size ) {
157
+ for ( const [
158
+ source,
159
+ bindings,
160
+ ] of blockBindingsBySource ) {
161
+ // Get values in batch if the source supports it.
162
+ let values = {};
163
+ if ( ! source.getValues ) {
164
+ Object.keys( bindings ).forEach( ( attr ) => {
165
+ // Default to the the source label when `getValues` doesn't exist.
166
+ values[ attr ] = source.label;
167
+ } );
178
168
  } else {
179
- attributes[ attributeName ] = value;
169
+ values = source.getValues( {
170
+ select,
171
+ context: updatedContext,
172
+ clientId,
173
+ bindings,
174
+ } );
175
+ }
176
+ for ( const [ attributeName, value ] of Object.entries(
177
+ values
178
+ ) ) {
179
+ if (
180
+ attributeName === 'url' &&
181
+ ( ! value || ! isURLLike( value ) )
182
+ ) {
183
+ // Return null if value is not a valid URL.
184
+ attributes[ attributeName ] = null;
185
+ } else {
186
+ attributes[ attributeName ] = value;
187
+ }
180
188
  }
181
189
  }
182
190
  }
183
- }
184
191
 
185
- return attributes;
186
- }, [
187
- blockBindings,
188
- name,
189
- clientId,
190
- updatedContext,
191
- registry,
192
- sources,
193
- ] );
192
+ return attributes;
193
+ },
194
+ [ blockBindings, name, clientId, updatedContext, sources ]
195
+ );
194
196
 
195
197
  const hasParentPattern = !! updatedContext[ 'pattern/overrides' ];
196
198
  const hasPatternOverridesDefaultBinding =
@@ -240,7 +242,8 @@ export const withBlockBindingSupport = createHigherOrderComponent(
240
242
  bindings,
241
243
  ] of blockBindingsBySource ) {
242
244
  source.setValues( {
243
- registry,
245
+ select: registry.select,
246
+ dispatch: registry.dispatch,
244
247
  context: updatedContext,
245
248
  clientId,
246
249
  bindings,