@wordpress/block-editor 14.2.1-next.1f6eadc42.0 → 14.3.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.
- package/CHANGELOG.md +2 -0
- package/build/components/background-image-control/index.js +566 -0
- package/build/components/background-image-control/index.js.map +1 -0
- package/build/components/block-card/index.js +5 -2
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js +4 -2
- package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -1
- package/build/components/global-styles/background-panel.js +20 -545
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +3 -0
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/iframe/index.js +1 -0
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +6 -0
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/image-editor/use-transform-image.js +1 -0
- package/build/components/image-editor/use-transform-image.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +2 -4
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/index.js +2 -4
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +4 -8
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/inserter/media-tab/media-tab.js +2 -4
- package/build/components/inserter/media-tab/media-tab.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +2 -4
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter-listbox/item.js +2 -4
- package/build/components/inserter-listbox/item.js.map +1 -1
- package/build/components/link-control/index.js +14 -14
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +4 -2
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/rich-text/index.js +10 -4
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +16 -4
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/url-input/index.js +7 -6
- package/build/components/url-input/index.js.map +1 -1
- package/build/hooks/block-bindings.js +64 -53
- package/build/hooks/block-bindings.js.map +1 -1
- package/build/hooks/block-hooks.js +1 -8
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/store/private-selectors.js +10 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build-module/components/background-image-control/index.js +556 -0
- package/build-module/components/background-image-control/index.js.map +1 -0
- package/build-module/components/block-card/index.js +6 -3
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js +4 -2
- package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +22 -546
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +3 -0
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -0
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +6 -0
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/image-editor/use-transform-image.js +1 -0
- package/build-module/components/image-editor/use-transform-image.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +2 -4
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/index.js +2 -4
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +4 -8
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-tab.js +2 -4
- package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +2 -4
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter-listbox/item.js +2 -4
- package/build-module/components/inserter-listbox/item.js.map +1 -1
- package/build-module/components/link-control/index.js +15 -15
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +4 -2
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/rich-text/index.js +10 -4
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +16 -4
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/url-input/index.js +8 -7
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/hooks/block-bindings.js +64 -53
- package/build-module/hooks/block-bindings.js.map +1 -1
- package/build-module/hooks/block-hooks.js +3 -10
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/store/private-selectors.js +10 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-style/style-rtl.css +152 -276
- package/build-style/style.css +152 -276
- package/package.json +32 -32
- package/src/components/background-image-control/index.js +741 -0
- package/src/components/background-image-control/style.scss +170 -0
- package/src/components/background-image-control/test/index.js +47 -0
- package/src/components/block-card/index.js +12 -3
- package/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js +2 -5
- package/src/components/global-styles/background-panel.js +19 -730
- package/src/components/global-styles/dimensions-panel.js +3 -0
- package/src/components/global-styles/style.scss +0 -168
- package/src/components/global-styles/test/background-panel.js +1 -47
- package/src/components/image-editor/use-save-image.js +7 -0
- package/src/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +1 -2
- package/src/components/inserter/block-patterns-tab/index.js +1 -2
- package/src/components/inserter/media-tab/media-preview.js +2 -4
- package/src/components/inserter/media-tab/media-tab.js +1 -2
- package/src/components/inserter/quick-inserter.js +1 -2
- package/src/components/inserter/style.scss +0 -1
- package/src/components/inserter-listbox/item.js +1 -5
- package/src/components/link-control/index.js +19 -14
- package/src/components/link-control/search-input.js +2 -0
- package/src/components/link-control/style.scss +0 -22
- package/src/components/list-view/style.scss +1 -1
- package/src/components/rich-text/index.js +20 -5
- package/src/components/spacing-sizes-control/test/utils.js +18 -25
- package/src/components/spacing-sizes-control/utils.js +22 -5
- package/src/components/url-input/index.js +5 -4
- package/src/components/url-input/style.scss +3 -26
- package/src/hooks/block-bindings.js +63 -49
- package/src/hooks/block-hooks.js +3 -14
- package/src/hooks/block-hooks.scss +0 -9
- package/src/store/private-selectors.js +9 -0
- package/src/style.scss +1 -0
- package/src/utils/test/transform-styles.js +1 -1
|
@@ -9,33 +9,14 @@ $input-size: 300px;
|
|
|
9
9
|
position: relative;
|
|
10
10
|
padding: 1px;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
width:
|
|
14
|
-
|
|
15
|
-
width: $input-size;
|
|
16
|
-
}
|
|
17
|
-
padding: $input-padding;
|
|
18
|
-
margin-left: 0;
|
|
19
|
-
margin-right: 0;
|
|
20
|
-
|
|
21
|
-
/* Fonts smaller than 16px causes mobile safari to zoom. */
|
|
22
|
-
font-size: $mobile-text-min-font-size;
|
|
23
|
-
@include break-small {
|
|
24
|
-
font-size: $default-font-size;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
&::-ms-clear {
|
|
28
|
-
display: none;
|
|
29
|
-
}
|
|
12
|
+
@include break-small() {
|
|
13
|
+
min-width: $input-size;
|
|
14
|
+
width: auto;
|
|
30
15
|
}
|
|
31
16
|
|
|
32
17
|
&.is-full-width {
|
|
33
18
|
width: 100%;
|
|
34
19
|
|
|
35
|
-
.block-editor-url-input__input[type="text"] {
|
|
36
|
-
width: 100%;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
20
|
&__suggestions {
|
|
40
21
|
width: 100%;
|
|
41
22
|
}
|
|
@@ -49,10 +30,6 @@ $input-size: 300px;
|
|
|
49
30
|
}
|
|
50
31
|
}
|
|
51
32
|
|
|
52
|
-
.block-editor-url-input__input[type="text"] {
|
|
53
|
-
@include input-control;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
33
|
// Suggestions
|
|
57
34
|
.block-editor-url-input__suggestions {
|
|
58
35
|
max-height: 200px;
|
|
@@ -31,6 +31,8 @@ import { store as blockEditorStore } from '../store';
|
|
|
31
31
|
|
|
32
32
|
const { DropdownMenuV2 } = unlock( componentsPrivateApis );
|
|
33
33
|
|
|
34
|
+
const EMPTY_OBJECT = {};
|
|
35
|
+
|
|
34
36
|
const useToolsPanelDropdownMenuProps = () => {
|
|
35
37
|
const isMobile = useViewportMatch( 'medium', '<' );
|
|
36
38
|
return ! isMobile
|
|
@@ -59,7 +61,7 @@ function BlockBindingsPanelDropdown( { fieldsList, attribute, binding } ) {
|
|
|
59
61
|
{ registeredSources[ name ].label }
|
|
60
62
|
</DropdownMenuV2.GroupLabel>
|
|
61
63
|
) }
|
|
62
|
-
{ Object.entries( fields ).map( ( [ key,
|
|
64
|
+
{ Object.entries( fields ).map( ( [ key, args ] ) => (
|
|
63
65
|
<DropdownMenuV2.RadioItem
|
|
64
66
|
key={ key }
|
|
65
67
|
onChange={ () =>
|
|
@@ -75,10 +77,10 @@ function BlockBindingsPanelDropdown( { fieldsList, attribute, binding } ) {
|
|
|
75
77
|
checked={ key === currentKey }
|
|
76
78
|
>
|
|
77
79
|
<DropdownMenuV2.ItemLabel>
|
|
78
|
-
{
|
|
80
|
+
{ args?.label }
|
|
79
81
|
</DropdownMenuV2.ItemLabel>
|
|
80
82
|
<DropdownMenuV2.ItemHelpText>
|
|
81
|
-
{ value }
|
|
83
|
+
{ args?.value }
|
|
82
84
|
</DropdownMenuV2.ItemHelpText>
|
|
83
85
|
</DropdownMenuV2.RadioItem>
|
|
84
86
|
) ) }
|
|
@@ -92,7 +94,7 @@ function BlockBindingsPanelDropdown( { fieldsList, attribute, binding } ) {
|
|
|
92
94
|
);
|
|
93
95
|
}
|
|
94
96
|
|
|
95
|
-
function BlockBindingsAttribute( { attribute, binding } ) {
|
|
97
|
+
function BlockBindingsAttribute( { attribute, binding, fieldsList } ) {
|
|
96
98
|
const { source: sourceName, args } = binding || {};
|
|
97
99
|
const sourceProps =
|
|
98
100
|
unlock( blocksPrivateApis ).getBlockBindingsSource( sourceName );
|
|
@@ -108,14 +110,16 @@ function BlockBindingsAttribute( { attribute, binding } ) {
|
|
|
108
110
|
>
|
|
109
111
|
{ isSourceInvalid
|
|
110
112
|
? __( 'Invalid source' )
|
|
111
|
-
: args?.key
|
|
113
|
+
: fieldsList?.[ sourceName ]?.[ args?.key ]?.label ||
|
|
114
|
+
sourceProps?.label ||
|
|
115
|
+
sourceName }
|
|
112
116
|
</Text>
|
|
113
117
|
) }
|
|
114
118
|
</VStack>
|
|
115
119
|
);
|
|
116
120
|
}
|
|
117
121
|
|
|
118
|
-
function ReadOnlyBlockBindingsPanelItems( { bindings } ) {
|
|
122
|
+
function ReadOnlyBlockBindingsPanelItems( { bindings, fieldsList } ) {
|
|
119
123
|
return (
|
|
120
124
|
<>
|
|
121
125
|
{ Object.entries( bindings ).map( ( [ attribute, binding ] ) => (
|
|
@@ -123,6 +127,7 @@ function ReadOnlyBlockBindingsPanelItems( { bindings } ) {
|
|
|
123
127
|
<BlockBindingsAttribute
|
|
124
128
|
attribute={ attribute }
|
|
125
129
|
binding={ binding }
|
|
130
|
+
fieldsList={ fieldsList }
|
|
126
131
|
/>
|
|
127
132
|
</Item>
|
|
128
133
|
) ) }
|
|
@@ -162,6 +167,7 @@ function EditableBlockBindingsPanelItems( {
|
|
|
162
167
|
<BlockBindingsAttribute
|
|
163
168
|
attribute={ attribute }
|
|
164
169
|
binding={ binding }
|
|
170
|
+
fieldsList={ fieldsList }
|
|
165
171
|
/>
|
|
166
172
|
</Item>
|
|
167
173
|
}
|
|
@@ -182,11 +188,60 @@ function EditableBlockBindingsPanelItems( {
|
|
|
182
188
|
export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
|
|
183
189
|
const registry = useRegistry();
|
|
184
190
|
const blockContext = useContext( BlockContext );
|
|
185
|
-
const { bindings } = metadata || {};
|
|
186
191
|
const { removeAllBlockBindings } = useBlockBindingsUtils();
|
|
187
192
|
const bindableAttributes = getBindableAttributes( blockName );
|
|
188
193
|
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
189
194
|
|
|
195
|
+
// `useSelect` is used purposely here to ensure `getFieldsList`
|
|
196
|
+
// is updated whenever there are updates in block context.
|
|
197
|
+
// `source.getFieldsList` may also call a selector via `registry.select`.
|
|
198
|
+
const _fieldsList = {};
|
|
199
|
+
const { fieldsList, canUpdateBlockBindings } = useSelect(
|
|
200
|
+
( select ) => {
|
|
201
|
+
if ( ! bindableAttributes || bindableAttributes.length === 0 ) {
|
|
202
|
+
return EMPTY_OBJECT;
|
|
203
|
+
}
|
|
204
|
+
const { getBlockBindingsSources } = unlock( blocksPrivateApis );
|
|
205
|
+
const registeredSources = getBlockBindingsSources();
|
|
206
|
+
Object.entries( registeredSources ).forEach(
|
|
207
|
+
( [ sourceName, { getFieldsList, usesContext } ] ) => {
|
|
208
|
+
if ( getFieldsList ) {
|
|
209
|
+
// Populate context.
|
|
210
|
+
const context = {};
|
|
211
|
+
if ( usesContext?.length ) {
|
|
212
|
+
for ( const key of usesContext ) {
|
|
213
|
+
context[ key ] = blockContext[ key ];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const sourceList = getFieldsList( {
|
|
217
|
+
registry,
|
|
218
|
+
context,
|
|
219
|
+
} );
|
|
220
|
+
// Only add source if the list is not empty.
|
|
221
|
+
if ( Object.keys( sourceList || {} ).length ) {
|
|
222
|
+
_fieldsList[ sourceName ] = { ...sourceList };
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
return {
|
|
228
|
+
fieldsList:
|
|
229
|
+
Object.values( _fieldsList ).length > 0
|
|
230
|
+
? _fieldsList
|
|
231
|
+
: EMPTY_OBJECT,
|
|
232
|
+
canUpdateBlockBindings:
|
|
233
|
+
select( blockEditorStore ).getSettings()
|
|
234
|
+
.canUpdateBlockBindings,
|
|
235
|
+
};
|
|
236
|
+
},
|
|
237
|
+
[ blockContext, bindableAttributes, registry ]
|
|
238
|
+
);
|
|
239
|
+
// Return early if there are no bindable attributes.
|
|
240
|
+
if ( ! bindableAttributes || bindableAttributes.length === 0 ) {
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
// Filter bindings to only show bindable attributes and remove pattern overrides.
|
|
244
|
+
const { bindings } = metadata || {};
|
|
190
245
|
const filteredBindings = { ...bindings };
|
|
191
246
|
Object.keys( filteredBindings ).forEach( ( key ) => {
|
|
192
247
|
if (
|
|
@@ -197,48 +252,6 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
|
|
|
197
252
|
}
|
|
198
253
|
} );
|
|
199
254
|
|
|
200
|
-
const { canUpdateBlockBindings } = useSelect( ( select ) => {
|
|
201
|
-
return {
|
|
202
|
-
canUpdateBlockBindings:
|
|
203
|
-
select( blockEditorStore ).getSettings().canUpdateBlockBindings,
|
|
204
|
-
};
|
|
205
|
-
}, [] );
|
|
206
|
-
|
|
207
|
-
if ( ! bindableAttributes || bindableAttributes.length === 0 ) {
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const fieldsList = {};
|
|
212
|
-
const { getBlockBindingsSources } = unlock( blocksPrivateApis );
|
|
213
|
-
const registeredSources = getBlockBindingsSources();
|
|
214
|
-
Object.entries( registeredSources ).forEach(
|
|
215
|
-
( [ sourceName, { getFieldsList, usesContext } ] ) => {
|
|
216
|
-
if ( getFieldsList ) {
|
|
217
|
-
// Populate context.
|
|
218
|
-
const context = {};
|
|
219
|
-
if ( usesContext?.length ) {
|
|
220
|
-
for ( const key of usesContext ) {
|
|
221
|
-
context[ key ] = blockContext[ key ];
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
const sourceList = getFieldsList( {
|
|
225
|
-
registry,
|
|
226
|
-
context,
|
|
227
|
-
} );
|
|
228
|
-
// Only add source if the list is not empty.
|
|
229
|
-
if ( sourceList ) {
|
|
230
|
-
fieldsList[ sourceName ] = { ...sourceList };
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
);
|
|
235
|
-
// Remove empty sources.
|
|
236
|
-
Object.entries( fieldsList ).forEach( ( [ key, value ] ) => {
|
|
237
|
-
if ( ! Object.keys( value ).length ) {
|
|
238
|
-
delete fieldsList[ key ];
|
|
239
|
-
}
|
|
240
|
-
} );
|
|
241
|
-
|
|
242
255
|
// Lock the UI when the user can't update bindings or there are no fields to connect to.
|
|
243
256
|
const readOnly =
|
|
244
257
|
! canUpdateBlockBindings || ! Object.keys( fieldsList ).length;
|
|
@@ -261,6 +274,7 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
|
|
|
261
274
|
{ readOnly ? (
|
|
262
275
|
<ReadOnlyBlockBindingsPanelItems
|
|
263
276
|
bindings={ filteredBindings }
|
|
277
|
+
fieldsList={ fieldsList }
|
|
264
278
|
/>
|
|
265
279
|
) : (
|
|
266
280
|
<EditableBlockBindingsPanelItems
|
package/src/hooks/block-hooks.js
CHANGED
|
@@ -3,18 +3,14 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { Fragment, useMemo } from '@wordpress/element';
|
|
6
|
-
import {
|
|
7
|
-
__experimentalHStack as HStack,
|
|
8
|
-
PanelBody,
|
|
9
|
-
ToggleControl,
|
|
10
|
-
} from '@wordpress/components';
|
|
6
|
+
import { PanelBody, ToggleControl } from '@wordpress/components';
|
|
11
7
|
import { createBlock, store as blocksStore } from '@wordpress/blocks';
|
|
12
8
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
13
9
|
|
|
14
10
|
/**
|
|
15
11
|
* Internal dependencies
|
|
16
12
|
*/
|
|
17
|
-
import {
|
|
13
|
+
import { InspectorControls } from '../components';
|
|
18
14
|
import { store as blockEditorStore } from '../store';
|
|
19
15
|
|
|
20
16
|
const EMPTY_OBJECT = {};
|
|
@@ -204,14 +200,7 @@ function BlockHooksControlPure( {
|
|
|
204
200
|
__nextHasNoMarginBottom
|
|
205
201
|
checked={ checked }
|
|
206
202
|
key={ block.title }
|
|
207
|
-
label={
|
|
208
|
-
<HStack justify="flex-start">
|
|
209
|
-
<BlockIcon
|
|
210
|
-
icon={ block.icon }
|
|
211
|
-
/>
|
|
212
|
-
<span>{ block.title }</span>
|
|
213
|
-
</HStack>
|
|
214
|
-
}
|
|
203
|
+
label={ block.title }
|
|
215
204
|
onChange={ () => {
|
|
216
205
|
if ( ! checked ) {
|
|
217
206
|
// Create and insert block.
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
.block-editor-hooks__block-hooks {
|
|
2
|
-
/**
|
|
3
|
-
* Since we're displaying the block icon alongside the block name,
|
|
4
|
-
* we need to right-align the toggle.
|
|
5
|
-
*/
|
|
6
|
-
.components-toggle-control .components-h-stack {
|
|
7
|
-
/* stylelint-disable-next-line declaration-property-value-allowed-list -- This should be refactored to not use the row-reverse value. */
|
|
8
|
-
flex-direction: row-reverse;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
2
|
/**
|
|
12
3
|
* Un-reverse the flex direction for the toggle's label.
|
|
13
4
|
*/
|
|
@@ -548,6 +548,15 @@ export function isZoomOutMode( state ) {
|
|
|
548
548
|
return state.editorMode === 'zoom-out';
|
|
549
549
|
}
|
|
550
550
|
|
|
551
|
+
/**
|
|
552
|
+
* Retrieves the client ID of the block which contains the blocks
|
|
553
|
+
* acting as "sections" in the editor. This is typically the "main content"
|
|
554
|
+
* of the template/post.
|
|
555
|
+
*
|
|
556
|
+
* @param {Object} state Editor state.
|
|
557
|
+
*
|
|
558
|
+
* @return {string|undefined} The section root client ID or undefined if not set.
|
|
559
|
+
*/
|
|
551
560
|
export function getSectionRootClientId( state ) {
|
|
552
561
|
return state.settings?.[ sectionRootClientIdKey ];
|
|
553
562
|
}
|
package/src/style.scss
CHANGED