@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.
- package/README.md +42 -0
- package/build/components/block-variation-picker/index.js +2 -4
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +3 -4
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/button-block-appender/index.js +2 -4
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +2 -4
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/global-styles/color-panel.js +2 -4
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +2 -4
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/shadow-panel-components.js +24 -29
- package/build/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build/components/inspector-controls-tabs/index.js +11 -8
- package/build/components/inspector-controls-tabs/index.js.map +1 -1
- package/build/components/inspector-popover-header/index.js +4 -8
- package/build/components/inspector-popover-header/index.js.map +1 -1
- package/build/components/link-control/index.js +4 -8
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +2 -4
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/list-view/block-select-button.js +1 -4
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/media-placeholder/index.js +29 -43
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/rich-text/index.js +4 -8
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/skip-to-selected-block/index.js +2 -4
- package/build/components/skip-to-selected-block/index.js.map +1 -1
- package/build/components/tool-selector/index.js +2 -4
- package/build/components/tool-selector/index.js.map +1 -1
- package/build/components/url-input/button.js +14 -16
- package/build/components/url-input/button.js.map +1 -1
- package/build/components/url-input/index.js +2 -4
- package/build/components/url-input/index.js.map +1 -1
- package/build/hooks/block-bindings.js +6 -13
- package/build/hooks/block-bindings.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +5 -4
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/layouts/flex.js +6 -38
- package/build/layouts/flex.js.map +1 -1
- package/build/private-apis.js +0 -2
- package/build/private-apis.js.map +1 -1
- package/build/utils/block-bindings.js +48 -0
- package/build/utils/block-bindings.js.map +1 -1
- package/build/utils/index.js +7 -0
- package/build/utils/index.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +2 -4
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +3 -4
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/button-block-appender/index.js +2 -4
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +2 -4
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +2 -4
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +2 -4
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel-components.js +25 -30
- package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/index.js +12 -9
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
- package/build-module/components/inspector-popover-header/index.js +4 -8
- package/build-module/components/inspector-popover-header/index.js.map +1 -1
- package/build-module/components/link-control/index.js +4 -8
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +2 -4
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +2 -5
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +30 -44
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +4 -8
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/skip-to-selected-block/index.js +2 -4
- package/build-module/components/skip-to-selected-block/index.js.map +1 -1
- package/build-module/components/tool-selector/index.js +2 -4
- package/build-module/components/tool-selector/index.js.map +1 -1
- package/build-module/components/url-input/button.js +15 -17
- package/build-module/components/url-input/button.js.map +1 -1
- package/build-module/components/url-input/index.js +2 -4
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/hooks/block-bindings.js +6 -13
- package/build-module/hooks/block-bindings.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +5 -4
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/layouts/flex.js +7 -39
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/private-apis.js +0 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/utils/block-bindings.js +48 -0
- package/build-module/utils/block-bindings.js.map +1 -1
- package/build-module/utils/index.js +1 -0
- package/build-module/utils/index.js.map +1 -1
- package/build-style/content-rtl.css +2 -17
- package/build-style/content.css +2 -17
- package/build-style/style-rtl.css +18 -25
- package/build-style/style.css +18 -25
- package/package.json +6 -6
- package/src/components/block-inspector/style.scss +2 -0
- package/src/components/block-tools/style.scss +5 -0
- package/src/components/block-variation-picker/index.js +1 -2
- package/src/components/block-variation-transforms/index.js +2 -2
- package/src/components/button-block-appender/content.scss +0 -5
- package/src/components/button-block-appender/index.js +1 -2
- package/src/components/colors-gradients/dropdown.js +1 -5
- package/src/components/global-styles/color-panel.js +1 -5
- package/src/components/global-styles/filters-panel.js +1 -2
- package/src/components/global-styles/shadow-panel-components.js +28 -33
- package/src/components/global-styles/style.scss +5 -0
- package/src/components/inspector-controls-tabs/index.js +21 -20
- package/src/components/inspector-popover-header/index.js +2 -4
- package/src/components/inspector-popover-header/style.scss +0 -13
- package/src/components/link-control/index.js +2 -4
- package/src/components/link-control/settings-drawer.js +1 -2
- package/src/components/list-view/block-select-button.js +2 -5
- package/src/components/list-view/style.scss +9 -0
- package/src/components/media-placeholder/content.scss +3 -19
- package/src/components/media-placeholder/index.js +23 -29
- package/src/components/rich-text/index.js +4 -13
- package/src/components/skip-to-selected-block/index.js +1 -2
- package/src/components/skip-to-selected-block/style.scss +0 -9
- package/src/components/tool-selector/index.js +1 -2
- package/src/components/url-input/button.js +16 -12
- package/src/components/url-input/index.js +1 -2
- package/src/components/url-input/style.scss +0 -6
- package/src/hooks/block-bindings.js +9 -10
- package/src/hooks/use-bindings-attributes.js +66 -63
- package/src/layouts/flex.js +10 -53
- package/src/private-apis.js +0 -2
- package/src/utils/block-bindings.js +47 -0
- 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
<
|
|
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
|
-
</
|
|
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
|
-
|
|
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
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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={
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
544
|
-
__next40pxDefaultSize={ false }
|
|
543
|
+
__next40pxDefaultSize
|
|
545
544
|
{ ...buildSuggestionItemProps( suggestion, index ) }
|
|
546
545
|
key={ suggestion.id }
|
|
547
546
|
className={ clsx(
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
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 {
|
|
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 `
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
const boundAttributes = useSelect(
|
|
122
|
+
( select ) => {
|
|
123
|
+
if ( ! blockBindings ) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
125
126
|
|
|
126
|
-
|
|
127
|
+
const attributes = {};
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
const blockBindingsBySource = new Map();
|
|
129
130
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
+
// Populate context.
|
|
144
|
+
for ( const key of source.usesContext || [] ) {
|
|
145
|
+
updatedContext[ key ] = blockContext[ key ];
|
|
146
|
+
}
|
|
143
147
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
blockBindingsBySource.set( source, {
|
|
149
|
+
...blockBindingsBySource.get( source ),
|
|
150
|
+
[ attributeName ]: {
|
|
151
|
+
args: sourceArgs,
|
|
152
|
+
},
|
|
153
|
+
} );
|
|
154
|
+
}
|
|
151
155
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
-
|
|
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
|
-
|
|
186
|
-
|
|
187
|
-
blockBindings,
|
|
188
|
-
|
|
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,
|