@wordpress/block-editor 15.1.1-next.0f6f9d12c.0 → 15.2.1-next.f34ab90e9.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/use-block-drop-zone/index.js +7 -1
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/store/actions.js +13 -6
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +2 -2
- package/build/store/reducer.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +7 -1
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/store/actions.js +13 -6
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +2 -2
- package/build-module/store/reducer.js.map +1 -1
- package/package.json +34 -34
- package/src/components/use-block-drop-zone/index.js +12 -4
- package/src/store/actions.js +10 -6
- package/src/store/reducer.js +2 -2
- package/src/store/test/actions.js +14 -2
- package/src/store/test/reducer.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.2.1-next.f34ab90e9.0",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -37,38 +37,38 @@
|
|
|
37
37
|
"@emotion/react": "^11.7.1",
|
|
38
38
|
"@emotion/styled": "^11.6.0",
|
|
39
39
|
"@react-spring/web": "^9.4.5",
|
|
40
|
-
"@wordpress/a11y": "^4.
|
|
41
|
-
"@wordpress/api-fetch": "^7.
|
|
42
|
-
"@wordpress/blob": "^4.
|
|
43
|
-
"@wordpress/block-serialization-default-parser": "^5.
|
|
44
|
-
"@wordpress/blocks": "^15.
|
|
45
|
-
"@wordpress/commands": "^1.
|
|
46
|
-
"@wordpress/components": "^30.2.1-next.
|
|
47
|
-
"@wordpress/compose": "^7.
|
|
48
|
-
"@wordpress/data": "^10.
|
|
49
|
-
"@wordpress/date": "^5.
|
|
50
|
-
"@wordpress/deprecated": "^4.
|
|
51
|
-
"@wordpress/dom": "^4.
|
|
52
|
-
"@wordpress/element": "^6.
|
|
53
|
-
"@wordpress/escape-html": "^3.
|
|
54
|
-
"@wordpress/hooks": "^4.
|
|
55
|
-
"@wordpress/html-entities": "^4.
|
|
56
|
-
"@wordpress/i18n": "^6.
|
|
57
|
-
"@wordpress/icons": "^10.
|
|
58
|
-
"@wordpress/is-shallow-equal": "^5.
|
|
59
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
60
|
-
"@wordpress/keycodes": "^4.
|
|
61
|
-
"@wordpress/notices": "^5.
|
|
62
|
-
"@wordpress/preferences": "^4.
|
|
63
|
-
"@wordpress/priority-queue": "^3.
|
|
64
|
-
"@wordpress/private-apis": "^1.
|
|
65
|
-
"@wordpress/rich-text": "^7.
|
|
66
|
-
"@wordpress/style-engine": "^2.
|
|
67
|
-
"@wordpress/token-list": "^3.
|
|
68
|
-
"@wordpress/upload-media": "^0.
|
|
69
|
-
"@wordpress/url": "^4.
|
|
70
|
-
"@wordpress/warning": "^3.
|
|
71
|
-
"@wordpress/wordcount": "^4.
|
|
40
|
+
"@wordpress/a11y": "^4.29.1-next.f34ab90e9.0",
|
|
41
|
+
"@wordpress/api-fetch": "^7.29.1-next.f34ab90e9.0",
|
|
42
|
+
"@wordpress/blob": "^4.29.1-next.f34ab90e9.0",
|
|
43
|
+
"@wordpress/block-serialization-default-parser": "^5.29.1-next.f34ab90e9.0",
|
|
44
|
+
"@wordpress/blocks": "^15.2.1-next.f34ab90e9.0",
|
|
45
|
+
"@wordpress/commands": "^1.29.1-next.f34ab90e9.0",
|
|
46
|
+
"@wordpress/components": "^30.2.1-next.f34ab90e9.0",
|
|
47
|
+
"@wordpress/compose": "^7.29.1-next.f34ab90e9.0",
|
|
48
|
+
"@wordpress/data": "^10.29.1-next.f34ab90e9.0",
|
|
49
|
+
"@wordpress/date": "^5.29.1-next.f34ab90e9.0",
|
|
50
|
+
"@wordpress/deprecated": "^4.29.1-next.f34ab90e9.0",
|
|
51
|
+
"@wordpress/dom": "^4.29.1-next.f34ab90e9.0",
|
|
52
|
+
"@wordpress/element": "^6.29.1-next.f34ab90e9.0",
|
|
53
|
+
"@wordpress/escape-html": "^3.29.1-next.f34ab90e9.0",
|
|
54
|
+
"@wordpress/hooks": "^4.29.1-next.f34ab90e9.0",
|
|
55
|
+
"@wordpress/html-entities": "^4.29.1-next.f34ab90e9.0",
|
|
56
|
+
"@wordpress/i18n": "^6.2.1-next.f34ab90e9.0",
|
|
57
|
+
"@wordpress/icons": "^10.29.1-next.f34ab90e9.0",
|
|
58
|
+
"@wordpress/is-shallow-equal": "^5.29.1-next.f34ab90e9.0",
|
|
59
|
+
"@wordpress/keyboard-shortcuts": "^5.29.1-next.f34ab90e9.0",
|
|
60
|
+
"@wordpress/keycodes": "^4.29.1-next.f34ab90e9.0",
|
|
61
|
+
"@wordpress/notices": "^5.29.1-next.f34ab90e9.0",
|
|
62
|
+
"@wordpress/preferences": "^4.29.1-next.f34ab90e9.0",
|
|
63
|
+
"@wordpress/priority-queue": "^3.29.1-next.f34ab90e9.0",
|
|
64
|
+
"@wordpress/private-apis": "^1.29.1-next.f34ab90e9.0",
|
|
65
|
+
"@wordpress/rich-text": "^7.29.1-next.f34ab90e9.0",
|
|
66
|
+
"@wordpress/style-engine": "^2.29.1-next.f34ab90e9.0",
|
|
67
|
+
"@wordpress/token-list": "^3.29.1-next.f34ab90e9.0",
|
|
68
|
+
"@wordpress/upload-media": "^0.14.1-next.f34ab90e9.0",
|
|
69
|
+
"@wordpress/url": "^4.29.1-next.f34ab90e9.0",
|
|
70
|
+
"@wordpress/warning": "^3.29.1-next.f34ab90e9.0",
|
|
71
|
+
"@wordpress/wordcount": "^4.29.1-next.f34ab90e9.0",
|
|
72
72
|
"change-case": "^4.1.2",
|
|
73
73
|
"clsx": "^2.1.1",
|
|
74
74
|
"colord": "^2.7.0",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"access": "public"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "91f58004986ec6faf118825f925ac7873d171986"
|
|
95
95
|
}
|
|
@@ -148,6 +148,10 @@ export function getDropTargetPosition(
|
|
|
148
148
|
} ) => {
|
|
149
149
|
const rect = getBoundingClientRect();
|
|
150
150
|
|
|
151
|
+
if ( ! rect ) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
151
155
|
let [ distance, edge ] = getDistanceToNearestEdge(
|
|
152
156
|
position,
|
|
153
157
|
rect,
|
|
@@ -428,10 +432,14 @@ export default function useBlockDropZone( {
|
|
|
428
432
|
return {
|
|
429
433
|
isUnmodifiedDefaultBlock:
|
|
430
434
|
getIsUnmodifiedDefaultBlock( block ),
|
|
431
|
-
getBoundingClientRect: () =>
|
|
432
|
-
ownerDocument
|
|
433
|
-
|
|
434
|
-
|
|
435
|
+
getBoundingClientRect: () => {
|
|
436
|
+
const blockElement = ownerDocument.getElementById(
|
|
437
|
+
`block-${ clientId }`
|
|
438
|
+
);
|
|
439
|
+
return blockElement
|
|
440
|
+
? blockElement.getBoundingClientRect()
|
|
441
|
+
: null;
|
|
442
|
+
},
|
|
435
443
|
blockIndex: getBlockIndex( clientId ),
|
|
436
444
|
blockOrientation:
|
|
437
445
|
getBlockListSettings( clientId )?.orientation,
|
package/src/store/actions.js
CHANGED
|
@@ -155,22 +155,26 @@ export function receiveBlocks( blocks ) {
|
|
|
155
155
|
/**
|
|
156
156
|
* Action that updates attributes of multiple blocks with the specified client IDs.
|
|
157
157
|
*
|
|
158
|
-
* @param {string|string[]} clientIds
|
|
159
|
-
* @param {Object} attributes
|
|
160
|
-
*
|
|
161
|
-
* @param {boolean} uniqueByBlock
|
|
158
|
+
* @param {string|string[]} clientIds Block client IDs.
|
|
159
|
+
* @param {Object} attributes Block attributes to be merged. Should be keyed by clientIds if `options.uniqueByBlock` is true.
|
|
160
|
+
* @param {Object} options Updating options.
|
|
161
|
+
* @param {boolean} [options.uniqueByBlock=false] Whether each block in clientIds array has a unique set of attributes.
|
|
162
162
|
* @return {Object} Action object.
|
|
163
163
|
*/
|
|
164
164
|
export function updateBlockAttributes(
|
|
165
165
|
clientIds,
|
|
166
166
|
attributes,
|
|
167
|
-
|
|
167
|
+
options = { uniqueByBlock: false }
|
|
168
168
|
) {
|
|
169
|
+
if ( typeof options === 'boolean' ) {
|
|
170
|
+
options = { uniqueByBlock: options };
|
|
171
|
+
}
|
|
172
|
+
|
|
169
173
|
return {
|
|
170
174
|
type: 'UPDATE_BLOCK_ATTRIBUTES',
|
|
171
175
|
clientIds: castArray( clientIds ),
|
|
172
176
|
attributes,
|
|
173
|
-
|
|
177
|
+
options,
|
|
174
178
|
};
|
|
175
179
|
}
|
|
176
180
|
|
package/src/store/reducer.js
CHANGED
|
@@ -882,7 +882,7 @@ export const blocks = pipe(
|
|
|
882
882
|
const newState = new Map( state );
|
|
883
883
|
for ( const clientId of action.clientIds ) {
|
|
884
884
|
const updatedAttributeEntries = Object.entries(
|
|
885
|
-
action.uniqueByBlock
|
|
885
|
+
!! action.options?.uniqueByBlock
|
|
886
886
|
? action.attributes[ clientId ]
|
|
887
887
|
: action.attributes ?? {}
|
|
888
888
|
);
|
|
@@ -1833,7 +1833,7 @@ export function lastBlockAttributesChange( state = null, action ) {
|
|
|
1833
1833
|
return action.clientIds.reduce(
|
|
1834
1834
|
( accumulator, id ) => ( {
|
|
1835
1835
|
...accumulator,
|
|
1836
|
-
[ id ]: action.uniqueByBlock
|
|
1836
|
+
[ id ]: !! action.options?.uniqueByBlock
|
|
1837
1837
|
? action.attributes[ id ]
|
|
1838
1838
|
: action.attributes,
|
|
1839
1839
|
} ),
|
|
@@ -89,7 +89,7 @@ describe( 'actions', () => {
|
|
|
89
89
|
type: 'UPDATE_BLOCK_ATTRIBUTES',
|
|
90
90
|
clientIds: [ clientId ],
|
|
91
91
|
attributes,
|
|
92
|
-
uniqueByBlock: false,
|
|
92
|
+
options: { uniqueByBlock: false },
|
|
93
93
|
} );
|
|
94
94
|
} );
|
|
95
95
|
|
|
@@ -101,7 +101,19 @@ describe( 'actions', () => {
|
|
|
101
101
|
type: 'UPDATE_BLOCK_ATTRIBUTES',
|
|
102
102
|
clientIds,
|
|
103
103
|
attributes,
|
|
104
|
-
uniqueByBlock: false,
|
|
104
|
+
options: { uniqueByBlock: false },
|
|
105
|
+
} );
|
|
106
|
+
} );
|
|
107
|
+
|
|
108
|
+
it( 'should fold boolean uniqueByBlock option into an object', () => {
|
|
109
|
+
const clientId = 'myclientid';
|
|
110
|
+
const attributes = {};
|
|
111
|
+
const result = updateBlockAttributes( clientId, attributes, true );
|
|
112
|
+
expect( result ).toEqual( {
|
|
113
|
+
type: 'UPDATE_BLOCK_ATTRIBUTES',
|
|
114
|
+
clientIds: [ clientId ],
|
|
115
|
+
attributes,
|
|
116
|
+
options: { uniqueByBlock: true },
|
|
105
117
|
} );
|
|
106
118
|
} );
|
|
107
119
|
} );
|
|
@@ -1963,7 +1963,7 @@ describe( 'state', () => {
|
|
|
1963
1963
|
attributes: {
|
|
1964
1964
|
kumquat: { updated: true },
|
|
1965
1965
|
},
|
|
1966
|
-
uniqueByBlock: true,
|
|
1966
|
+
options: { uniqueByBlock: true },
|
|
1967
1967
|
} );
|
|
1968
1968
|
|
|
1969
1969
|
expect( state.attributes.get( 'kumquat' ).updated ).toBe(
|
|
@@ -3308,7 +3308,7 @@ describe( 'state', () => {
|
|
|
3308
3308
|
attributes: {
|
|
3309
3309
|
'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1': { food: 'banana' },
|
|
3310
3310
|
},
|
|
3311
|
-
uniqueByBlock: true,
|
|
3311
|
+
options: { uniqueByBlock: true },
|
|
3312
3312
|
} );
|
|
3313
3313
|
|
|
3314
3314
|
expect( state ).toEqual( {
|