@wordpress/block-editor 8.0.10 → 8.0.13
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/build/components/block-inspector/index.js +12 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block.js +1 -1
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +2 -3
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +1 -3
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +1 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +2 -2
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mover/button.js +2 -2
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +2 -2
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-mover/index.native.js +2 -2
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-preview/index.js +51 -0
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +3 -3
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +9 -0
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/gradients/use-gradient.js +4 -4
- package/build/components/gradients/use-gradient.js.map +1 -1
- package/build/components/index.js +8 -1
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +2 -2
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/index.js +2 -2
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +2 -2
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +1 -1
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +50 -22
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/provider/use-block-sync.js +37 -10
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +1 -1
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-setting/index.js +7 -0
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/color.js +6 -5
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/layout.js +2 -1
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/style.js +2 -1
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/flex.js +9 -29
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +10 -6
- package/build/layouts/flow.js.map +1 -1
- package/build/store/actions.js +3 -3
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +34 -83
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +27 -9
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-inspector/index.js +12 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block.js +1 -1
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +2 -3
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +1 -3
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +2 -2
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mover/button.js +2 -2
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +2 -2
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +2 -2
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-preview/index.js +46 -0
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +3 -3
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +9 -0
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/gradients/use-gradient.js +4 -3
- package/build-module/components/gradients/use-gradient.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +2 -2
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/index.js +2 -2
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +2 -2
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +1 -1
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +50 -22
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +41 -14
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +1 -1
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +7 -0
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/color.js +6 -5
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/layout.js +2 -1
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/style.js +2 -1
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/flex.js +9 -29
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +10 -6
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/store/actions.js +3 -3
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +35 -84
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +26 -9
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +14 -0
- package/build-style/style.css +14 -0
- package/package.json +9 -9
- package/src/components/block-inspector/index.js +17 -1
- package/src/components/block-list/block.js +1 -1
- package/src/components/block-list/block.native.js +2 -2
- package/src/components/block-list/use-block-props/index.js +1 -3
- package/src/components/block-list/use-in-between-inserter.js +1 -1
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +2 -5
- package/src/components/block-mover/button.js +2 -6
- package/src/components/block-mover/index.js +2 -5
- package/src/components/block-mover/index.native.js +2 -5
- package/src/components/block-preview/index.js +60 -0
- package/src/components/block-preview/style.scss +23 -0
- package/src/components/block-preview/test/index.js +114 -0
- package/src/components/block-tools/block-selection-button.js +3 -9
- package/src/components/block-tools/index.js +11 -0
- package/src/components/gradients/use-gradient.js +7 -7
- package/src/components/index.js +4 -1
- package/src/components/inserter/hooks/use-insertion-point.js +2 -9
- package/src/components/inserter/index.js +2 -2
- package/src/components/inserter/index.native.js +2 -5
- package/src/components/inserter/quick-inserter.js +1 -1
- package/src/components/inspector-controls/block-support-tools-panel.js +57 -21
- package/src/components/list-view/use-list-view-drop-zone.js +1 -1
- package/src/components/provider/use-block-sync.js +45 -11
- package/src/components/use-on-block-drop/index.js +1 -4
- package/src/components/use-setting/index.js +9 -0
- package/src/hooks/color.js +13 -14
- package/src/hooks/layout.js +1 -0
- package/src/hooks/style.js +2 -1
- package/src/hooks/test/style.js +0 -2
- package/src/layouts/flex.js +8 -31
- package/src/layouts/flow.js +8 -6
- package/src/store/actions.js +3 -4
- package/src/store/reducer.js +36 -105
- package/src/store/selectors.js +39 -9
- package/src/store/test/reducer.js +35 -0
- package/src/store/test/selectors.js +1 -1
package/src/store/selectors.js
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
parse,
|
|
31
31
|
} from '@wordpress/blocks';
|
|
32
32
|
import { Platform } from '@wordpress/element';
|
|
33
|
+
import { applyFilters } from '@wordpress/hooks';
|
|
33
34
|
import { symbol } from '@wordpress/icons';
|
|
34
35
|
|
|
35
36
|
/**
|
|
@@ -826,6 +827,7 @@ export const isAncestorMultiSelected = createSelector(
|
|
|
826
827
|
state.selection.selectionEnd.clientId,
|
|
827
828
|
]
|
|
828
829
|
);
|
|
830
|
+
|
|
829
831
|
/**
|
|
830
832
|
* Returns the client ID of the block which begins the multi-selection set, or
|
|
831
833
|
* null if there is no multi-selection.
|
|
@@ -890,11 +892,11 @@ export function getBlockOrder( state, rootClientId ) {
|
|
|
890
892
|
*
|
|
891
893
|
* @param {Object} state Editor state.
|
|
892
894
|
* @param {string} clientId Block client ID.
|
|
893
|
-
* @param {?string} rootClientId Optional root client ID of block list.
|
|
894
895
|
*
|
|
895
896
|
* @return {number} Index at which block exists in order.
|
|
896
897
|
*/
|
|
897
|
-
export function getBlockIndex( state, clientId
|
|
898
|
+
export function getBlockIndex( state, clientId ) {
|
|
899
|
+
const rootClientId = getBlockRootClientId( state, clientId );
|
|
898
900
|
return getBlockOrder( state, rootClientId ).indexOf( clientId );
|
|
899
901
|
}
|
|
900
902
|
|
|
@@ -1259,15 +1261,43 @@ const canInsertBlockTypeUnmemoized = (
|
|
|
1259
1261
|
parentName
|
|
1260
1262
|
);
|
|
1261
1263
|
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1264
|
+
const canInsert =
|
|
1265
|
+
( hasParentAllowedBlock === null && hasBlockAllowedParent === null ) ||
|
|
1266
|
+
hasParentAllowedBlock === true ||
|
|
1267
|
+
hasBlockAllowedParent === true;
|
|
1268
|
+
|
|
1269
|
+
if ( ! canInsert ) {
|
|
1270
|
+
return canInsert;
|
|
1268
1271
|
}
|
|
1269
1272
|
|
|
1270
|
-
|
|
1273
|
+
/**
|
|
1274
|
+
* This filter is an ad-hoc solution to prevent adding template parts inside post content.
|
|
1275
|
+
* Conceptually, having a filter inside a selector is bad pattern so this code will be
|
|
1276
|
+
* replaced by a declarative API that doesn't the following drawbacks:
|
|
1277
|
+
*
|
|
1278
|
+
* Filters are not reactive: Upon switching between "template mode" and non "template mode",
|
|
1279
|
+
* the filter and selector won't necessarily be executed again. For now, it doesn't matter much
|
|
1280
|
+
* because you can't switch between the two modes while the inserter stays open.
|
|
1281
|
+
*
|
|
1282
|
+
* Filters are global: Once they're defined, they will affect all editor instances and all registries.
|
|
1283
|
+
* An ideal API would only affect specific editor instances.
|
|
1284
|
+
*/
|
|
1285
|
+
return applyFilters(
|
|
1286
|
+
'blockEditor.__unstableCanInsertBlockType',
|
|
1287
|
+
canInsert,
|
|
1288
|
+
blockType,
|
|
1289
|
+
rootClientId,
|
|
1290
|
+
{
|
|
1291
|
+
// Pass bound selectors of the current registry. If we're in a nested
|
|
1292
|
+
// context, the data will differ from the one selected from the root
|
|
1293
|
+
// registry.
|
|
1294
|
+
getBlock: getBlock.bind( null, state ),
|
|
1295
|
+
getBlockParentsByBlockName: getBlockParentsByBlockName.bind(
|
|
1296
|
+
null,
|
|
1297
|
+
state
|
|
1298
|
+
),
|
|
1299
|
+
}
|
|
1300
|
+
);
|
|
1271
1301
|
};
|
|
1272
1302
|
|
|
1273
1303
|
/**
|
|
@@ -2050,6 +2050,41 @@ describe( 'state', () => {
|
|
|
2050
2050
|
expect( state.isIgnoredChange ).toBe( true );
|
|
2051
2051
|
} );
|
|
2052
2052
|
} );
|
|
2053
|
+
|
|
2054
|
+
describe( 'controlledInnerBlocks', () => {
|
|
2055
|
+
it( 'should remove the content of the block if it switches from controlled to uncontrolled or opposite', () => {
|
|
2056
|
+
const original = blocks( undefined, {
|
|
2057
|
+
type: 'RESET_BLOCKS',
|
|
2058
|
+
blocks: [
|
|
2059
|
+
{
|
|
2060
|
+
clientId: 'chicken',
|
|
2061
|
+
name: 'core/test-block',
|
|
2062
|
+
attributes: {},
|
|
2063
|
+
innerBlocks: [
|
|
2064
|
+
{
|
|
2065
|
+
clientId: 'child',
|
|
2066
|
+
name: 'core/test-block',
|
|
2067
|
+
attributes: {},
|
|
2068
|
+
innerBlocks: [],
|
|
2069
|
+
},
|
|
2070
|
+
],
|
|
2071
|
+
},
|
|
2072
|
+
],
|
|
2073
|
+
} );
|
|
2074
|
+
|
|
2075
|
+
const state = blocks( original, {
|
|
2076
|
+
type: 'SET_HAS_CONTROLLED_INNER_BLOCKS',
|
|
2077
|
+
clientId: 'chicken',
|
|
2078
|
+
hasControlledInnerBlocks: true,
|
|
2079
|
+
} );
|
|
2080
|
+
|
|
2081
|
+
expect( state.controlledInnerBlocks.chicken ).toBe( true );
|
|
2082
|
+
// The previous content of the block should be removed
|
|
2083
|
+
expect( state.byClientId.child ).toBeUndefined();
|
|
2084
|
+
expect( state.tree.child ).toBeUndefined();
|
|
2085
|
+
expect( state.tree.chicken.innerBlocks ).toEqual( [] );
|
|
2086
|
+
} );
|
|
2087
|
+
} );
|
|
2053
2088
|
} );
|
|
2054
2089
|
} );
|
|
2055
2090
|
|