@wordpress/block-editor 15.18.0 → 15.19.1-next.v.202605131006.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 +6 -0
- package/build/components/block-controls/fill.cjs.map +2 -2
- package/build/components/block-inspector/edit-contents.cjs +7 -1
- package/build/components/block-inspector/edit-contents.cjs.map +2 -2
- package/build/components/block-toolbar/edit-section-button.cjs +7 -1
- package/build/components/block-toolbar/edit-section-button.cjs.map +2 -2
- package/build/components/block-variation-transforms/index.cjs +2 -2
- package/build/components/block-variation-transforms/index.cjs.map +2 -2
- package/build/components/block-visibility/modal.cjs +0 -10
- package/build/components/block-visibility/modal.cjs.map +3 -3
- package/build/components/dimensions-tool/scale-tool.cjs +2 -2
- package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
- package/build/components/global-styles/state-control.cjs +111 -37
- package/build/components/global-styles/state-control.cjs.map +3 -3
- package/build/components/gradients/use-gradient.cjs +2 -2
- package/build/components/gradients/use-gradient.cjs.map +2 -2
- package/build/components/iframe/use-scale-canvas.cjs.map +2 -2
- package/build/components/inserter/index.cjs +41 -43
- package/build/components/inserter/index.cjs.map +2 -2
- package/build/components/inserter/menu.cjs +30 -2
- package/build/components/inserter/menu.cjs.map +3 -3
- package/build/components/inserter/tips.cjs +1 -1
- package/build/components/inserter/tips.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/index.cjs.map +2 -2
- package/build/store/actions.cjs +2 -2
- package/build/store/actions.cjs.map +2 -2
- package/build/store/reducer.cjs +8 -30
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs.map +2 -2
- package/build-module/components/block-controls/fill.mjs.map +2 -2
- package/build-module/components/block-inspector/edit-contents.mjs +7 -1
- package/build-module/components/block-inspector/edit-contents.mjs.map +2 -2
- package/build-module/components/block-toolbar/edit-section-button.mjs +7 -1
- package/build-module/components/block-toolbar/edit-section-button.mjs.map +2 -2
- package/build-module/components/block-variation-transforms/index.mjs +2 -2
- package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +0 -10
- package/build-module/components/block-visibility/modal.mjs.map +3 -3
- package/build-module/components/dimensions-tool/scale-tool.mjs +2 -2
- package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
- package/build-module/components/global-styles/state-control.mjs +119 -40
- package/build-module/components/global-styles/state-control.mjs.map +2 -2
- package/build-module/components/gradients/use-gradient.mjs +2 -2
- package/build-module/components/gradients/use-gradient.mjs.map +2 -2
- package/build-module/components/iframe/use-scale-canvas.mjs.map +2 -2
- package/build-module/components/inserter/index.mjs +41 -43
- package/build-module/components/inserter/index.mjs.map +2 -2
- package/build-module/components/inserter/menu.mjs +31 -2
- package/build-module/components/inserter/menu.mjs.map +2 -2
- package/build-module/components/inserter/tips.mjs +1 -1
- package/build-module/components/inserter/tips.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/index.mjs.map +2 -2
- package/build-module/store/actions.mjs +2 -2
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/reducer.mjs +8 -30
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-style/style-rtl.css +29 -3
- package/build-style/style.css +29 -3
- package/build-types/components/block-context/index.d.ts +9 -16
- package/build-types/components/block-context/index.d.ts.map +1 -1
- package/build-types/utils/dom.d.ts +7 -7
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +39 -39
- package/src/components/block-controls/fill.js +1 -0
- package/src/components/block-inspector/edit-contents.js +4 -2
- package/src/components/block-manager/style.scss +3 -2
- package/src/components/block-toolbar/edit-section-button.js +5 -1
- package/src/components/block-variation-transforms/index.js +2 -2
- package/src/components/block-visibility/modal.js +0 -1
- package/src/components/dimensions-tool/scale-tool.js +2 -2
- package/src/components/global-styles/state-control.js +152 -49
- package/src/components/global-styles/style.scss +9 -0
- package/src/components/gradients/use-gradient.js +3 -1
- package/src/components/iframe/use-scale-canvas.js +0 -4
- package/src/components/inner-blocks/README.md +5 -1
- package/src/components/inner-blocks/index.native.js +1 -1
- package/src/components/inserter/index.js +58 -69
- package/src/components/inserter/menu.js +32 -1
- package/src/components/inserter/style.scss +18 -3
- package/src/components/inserter/tips.js +1 -1
- package/src/components/rich-text/event-listeners/index.js +0 -1
- package/src/store/actions.js +12 -6
- package/src/store/reducer.js +11 -39
- package/src/store/selectors.js +6 -0
- package/src/store/test/reducer.js +39 -0
package/src/store/actions.js
CHANGED
|
@@ -88,6 +88,12 @@ export const validateBlocksToTemplate =
|
|
|
88
88
|
/**
|
|
89
89
|
* A block selection object.
|
|
90
90
|
*
|
|
91
|
+
* This type is duplicated to avoid creating circular dependencies.
|
|
92
|
+
*
|
|
93
|
+
* @see {import("@wordpress/block-editor/src/store/selectors").WPBlockSelection}
|
|
94
|
+
* @see {import("@wordpress/core-data/src/types").WPBlockSelection}
|
|
95
|
+
* @see {import("@wordpress/editor/src/store/selectors").WPBlockSelection}
|
|
96
|
+
*
|
|
91
97
|
* @typedef {Object} WPBlockSelection
|
|
92
98
|
*
|
|
93
99
|
* @property {string} clientId A block client ID.
|
|
@@ -1770,9 +1776,9 @@ export const insertBeforeBlock =
|
|
|
1770
1776
|
const rootClientId = select.getBlockRootClientId( clientId );
|
|
1771
1777
|
|
|
1772
1778
|
const blockIndex = select.getBlockIndex( clientId );
|
|
1773
|
-
const directInsertBlock = rootClientId
|
|
1774
|
-
? select.
|
|
1775
|
-
:
|
|
1779
|
+
const { defaultBlock: directInsertBlock } = rootClientId
|
|
1780
|
+
? select.getBlockListSettings( rootClientId ) ?? {}
|
|
1781
|
+
: {};
|
|
1776
1782
|
|
|
1777
1783
|
if ( ! directInsertBlock ) {
|
|
1778
1784
|
return dispatch.insertDefaultBlock( {}, rootClientId, blockIndex );
|
|
@@ -1809,9 +1815,9 @@ export const insertAfterBlock =
|
|
|
1809
1815
|
const rootClientId = select.getBlockRootClientId( clientId );
|
|
1810
1816
|
|
|
1811
1817
|
const blockIndex = select.getBlockIndex( clientId );
|
|
1812
|
-
const directInsertBlock = rootClientId
|
|
1813
|
-
? select.
|
|
1814
|
-
:
|
|
1818
|
+
const { defaultBlock: directInsertBlock } = rootClientId
|
|
1819
|
+
? select.getBlockListSettings( rootClientId ) ?? {}
|
|
1820
|
+
: {};
|
|
1815
1821
|
|
|
1816
1822
|
if ( ! directInsertBlock ) {
|
|
1817
1823
|
return dispatch.insertDefaultBlock(
|
package/src/store/reducer.js
CHANGED
|
@@ -292,7 +292,6 @@ const withBlockTree =
|
|
|
292
292
|
false
|
|
293
293
|
);
|
|
294
294
|
break;
|
|
295
|
-
case 'SYNC_DERIVED_BLOCK_ATTRIBUTES':
|
|
296
295
|
case 'UPDATE_BLOCK_ATTRIBUTES': {
|
|
297
296
|
newState.tree = new Map( newState.tree );
|
|
298
297
|
action.clientIds.forEach( ( clientId ) => {
|
|
@@ -421,63 +420,37 @@ const withBlockTree =
|
|
|
421
420
|
function withPersistentBlockChange( reducer ) {
|
|
422
421
|
let lastAction;
|
|
423
422
|
let markNextChangeAsNotPersistent = false;
|
|
424
|
-
let explicitPersistent;
|
|
425
423
|
|
|
426
424
|
return ( state, action ) => {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
let nextIsPersistentChange;
|
|
430
|
-
if ( action.type === 'SET_EXPLICIT_PERSISTENT' ) {
|
|
431
|
-
explicitPersistent = action.isPersistentChange;
|
|
432
|
-
nextIsPersistentChange = state.isPersistentChange ?? true;
|
|
433
|
-
}
|
|
425
|
+
const nextState = reducer( state, action );
|
|
434
426
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
? nextState
|
|
439
|
-
: {
|
|
440
|
-
...nextState,
|
|
441
|
-
isPersistentChange: nextIsPersistentChange,
|
|
442
|
-
};
|
|
443
|
-
}
|
|
427
|
+
const wasMarkedAsNotPersistent = markNextChangeAsNotPersistent;
|
|
428
|
+
markNextChangeAsNotPersistent =
|
|
429
|
+
action.type === 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT';
|
|
444
430
|
|
|
445
431
|
const isExplicitPersistentChange =
|
|
446
432
|
action.type === 'MARK_LAST_CHANGE_AS_PERSISTENT' ||
|
|
447
|
-
|
|
433
|
+
wasMarkedAsNotPersistent;
|
|
448
434
|
|
|
449
435
|
// Defer to previous state value (or default) unless changing or
|
|
450
436
|
// explicitly marking as persistent.
|
|
451
437
|
if ( state === nextState && ! isExplicitPersistentChange ) {
|
|
452
|
-
|
|
453
|
-
action.type === 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT';
|
|
454
|
-
|
|
455
|
-
nextIsPersistentChange = state?.isPersistentChange ?? true;
|
|
456
|
-
if ( state.isPersistentChange === nextIsPersistentChange ) {
|
|
438
|
+
if ( state.isPersistentChange !== undefined ) {
|
|
457
439
|
return state;
|
|
458
440
|
}
|
|
459
|
-
|
|
460
|
-
return {
|
|
461
|
-
...nextState,
|
|
462
|
-
isPersistentChange: nextIsPersistentChange,
|
|
463
|
-
};
|
|
441
|
+
return { ...nextState, isPersistentChange: true };
|
|
464
442
|
}
|
|
465
443
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
? ! markNextChangeAsNotPersistent
|
|
470
|
-
: ! isUpdatingSameBlockAttribute( action, lastAction ),
|
|
471
|
-
};
|
|
444
|
+
const isPersistentChange = isExplicitPersistentChange
|
|
445
|
+
? ! wasMarkedAsNotPersistent
|
|
446
|
+
: ! isUpdatingSameBlockAttribute( action, lastAction );
|
|
472
447
|
|
|
473
448
|
// In comparing against the previous action, consider only those which
|
|
474
449
|
// would have qualified as one which would have been ignored or not
|
|
475
450
|
// have resulted in a changed state.
|
|
476
451
|
lastAction = action;
|
|
477
|
-
markNextChangeAsNotPersistent =
|
|
478
|
-
action.type === 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT';
|
|
479
452
|
|
|
480
|
-
return nextState;
|
|
453
|
+
return { ...nextState, isPersistentChange };
|
|
481
454
|
};
|
|
482
455
|
}
|
|
483
456
|
|
|
@@ -897,7 +870,6 @@ export const blocks = pipe(
|
|
|
897
870
|
return newState;
|
|
898
871
|
}
|
|
899
872
|
|
|
900
|
-
case 'SYNC_DERIVED_BLOCK_ATTRIBUTES':
|
|
901
873
|
case 'UPDATE_BLOCK_ATTRIBUTES': {
|
|
902
874
|
// Avoid a state change if none of the block IDs are known.
|
|
903
875
|
if ( action.clientIds.every( ( id ) => ! state.get( id ) ) ) {
|
package/src/store/selectors.js
CHANGED
|
@@ -51,6 +51,12 @@ const { isContentBlock } = unlock( blocksPrivateApis );
|
|
|
51
51
|
/**
|
|
52
52
|
* A block selection object.
|
|
53
53
|
*
|
|
54
|
+
* This type is duplicated to avoid creating circular dependencies.
|
|
55
|
+
*
|
|
56
|
+
* @see {import("@wordpress/block-editor/src/store/actions").WPBlockSelection}
|
|
57
|
+
* @see {import("@wordpress/core-data/src/types").WPBlockSelection}
|
|
58
|
+
* @see {import("@wordpress/editor/src/store/selectors").WPBlockSelection}
|
|
59
|
+
*
|
|
54
60
|
* @typedef {Object} WPBlockSelection
|
|
55
61
|
*
|
|
56
62
|
* @property {string} clientId A block client ID.
|
|
@@ -2196,6 +2196,45 @@ describe( 'state', () => {
|
|
|
2196
2196
|
expect( state.isPersistentChange ).toBe( true );
|
|
2197
2197
|
} );
|
|
2198
2198
|
|
|
2199
|
+
it( 'should flag only the next change as not persistent', () => {
|
|
2200
|
+
let original = deepFreeze(
|
|
2201
|
+
blocks( undefined, {
|
|
2202
|
+
type: 'RESET_BLOCKS',
|
|
2203
|
+
blocks: [
|
|
2204
|
+
{
|
|
2205
|
+
clientId: 'kumquat',
|
|
2206
|
+
attributes: {},
|
|
2207
|
+
innerBlocks: [],
|
|
2208
|
+
},
|
|
2209
|
+
],
|
|
2210
|
+
} )
|
|
2211
|
+
);
|
|
2212
|
+
original = blocks( original, {
|
|
2213
|
+
type: 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT',
|
|
2214
|
+
} );
|
|
2215
|
+
|
|
2216
|
+
const nextState = blocks( original, {
|
|
2217
|
+
type: 'UPDATE_BLOCK_ATTRIBUTES',
|
|
2218
|
+
clientIds: [ 'kumquat' ],
|
|
2219
|
+
attributes: {
|
|
2220
|
+
updated: true,
|
|
2221
|
+
},
|
|
2222
|
+
} );
|
|
2223
|
+
|
|
2224
|
+
expect( nextState.isPersistentChange ).toBe( false );
|
|
2225
|
+
|
|
2226
|
+
// A subsequent change should revert to persistent.
|
|
2227
|
+
const subsequentState = blocks( nextState, {
|
|
2228
|
+
type: 'UPDATE_BLOCK_ATTRIBUTES',
|
|
2229
|
+
clientIds: [ 'kumquat' ],
|
|
2230
|
+
attributes: {
|
|
2231
|
+
other: true,
|
|
2232
|
+
},
|
|
2233
|
+
} );
|
|
2234
|
+
|
|
2235
|
+
expect( subsequentState.isPersistentChange ).toBe( true );
|
|
2236
|
+
} );
|
|
2237
|
+
|
|
2199
2238
|
it( 'should retain reference for same state, same persistence', () => {
|
|
2200
2239
|
const original = deepFreeze(
|
|
2201
2240
|
blocks( undefined, {
|