@wordpress/block-editor 12.22.0 → 12.23.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/README.md +4 -0
- package/build/components/block-list/block.js +11 -3
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-mover/button.js +4 -1
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +5 -1
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +4 -1
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +7 -3
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-switcher/index.js +4 -3
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +5 -4
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +18 -9
- package/build/components/block-toolbar/shuffle.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +48 -8
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +14 -2
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/global-styles/advanced-panel.js +9 -2
- package/build/components/global-styles/advanced-panel.js.map +1 -1
- package/build/components/global-styles/background-panel.js +444 -0
- package/build/components/global-styles/background-panel.js.map +1 -0
- package/build/components/global-styles/color-panel.js +2 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/get-global-styles-changes.js +3 -0
- package/build/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build/components/global-styles/hooks.js +1 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +13 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +15 -14
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/iframe/index.js +9 -4
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +5 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
- package/build/components/inserter/library.js +2 -0
- package/build/components/inserter/library.js.map +1 -1
- package/build/components/inserter/menu.js +8 -2
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/search-items.js +36 -15
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +11 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +16 -0
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +1 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/index.js +17 -2
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-list-view-collapse-items.js +47 -0
- package/build/components/list-view/use-list-view-collapse-items.js.map +1 -0
- package/build/components/rich-text/index.js +14 -11
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +17 -11
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/get-format-colors.native.js +1 -1
- package/build/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +2 -2
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/rich-text/with-deprecations.js +0 -3
- package/build/components/rich-text/with-deprecations.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +50 -36
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/use-block-display-information/index.js +4 -6
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/hooks/anchor.js +2 -2
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/background.js +70 -424
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/index.js +7 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use-zoom-out.js +47 -0
- package/build/hooks/use-zoom-out.js.map +1 -0
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/private-apis.js +6 -1
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +3 -1
- package/build/private-apis.native.js.map +1 -1
- package/build/store/private-actions.js +13 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-keys.js +2 -1
- package/build/store/private-keys.js.map +1 -1
- package/build/store/private-selectors.js +24 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +22 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +34 -32
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +7 -1
- package/build/store/utils.js.map +1 -1
- package/build/utils/transform-styles/index.js +2 -1
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/components/block-list/block.js +11 -3
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-mover/button.js +4 -1
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +5 -1
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +4 -1
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +7 -3
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-switcher/index.js +4 -3
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +5 -4
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +18 -9
- package/build-module/components/block-toolbar/shuffle.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +50 -10
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +14 -2
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/global-styles/advanced-panel.js +9 -2
- package/build-module/components/global-styles/advanced-panel.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +430 -0
- package/build-module/components/global-styles/background-panel.js.map +1 -0
- package/build-module/components/global-styles/color-panel.js +2 -1
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/get-global-styles-changes.js +3 -0
- package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +1 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +1 -0
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +16 -15
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +1 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +9 -4
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +5 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
- package/build-module/components/inserter/library.js +2 -0
- package/build-module/components/inserter/library.js.map +1 -1
- package/build-module/components/inserter/menu.js +8 -2
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/search-items.js +33 -15
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +11 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +16 -0
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +1 -1
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/index.js +17 -2
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-list-view-collapse-items.js +40 -0
- package/build-module/components/list-view/use-list-view-collapse-items.js.map +1 -0
- package/build-module/components/rich-text/index.js +15 -12
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +16 -11
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/get-format-colors.native.js +1 -1
- package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +2 -2
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/rich-text/with-deprecations.js +0 -3
- package/build-module/components/rich-text/with-deprecations.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +50 -36
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +5 -7
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/hooks/anchor.js +2 -2
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/background.js +67 -419
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/use-zoom-out.js +41 -0
- package/build-module/hooks/use-zoom-out.js.map +1 -0
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/private-apis.js +7 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +3 -1
- package/build-module/private-apis.native.js.map +1 -1
- package/build-module/store/private-actions.js +12 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-keys.js +1 -0
- package/build-module/store/private-keys.js.map +1 -1
- package/build-module/store/private-selectors.js +22 -4
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +21 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +35 -33
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +6 -1
- package/build-module/store/utils.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +2 -1
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +4 -1
- package/build-style/content.css +4 -1
- package/build-style/style-rtl.css +84 -79
- package/build-style/style.css +84 -79
- package/package.json +31 -31
- package/src/components/block-list/block.js +19 -3
- package/src/components/block-mover/button.js +4 -1
- package/src/components/block-mover/index.js +8 -1
- package/src/components/block-patterns-list/index.js +22 -17
- package/src/components/block-preview/style.scss +28 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +8 -2
- package/src/components/block-switcher/index.js +5 -3
- package/src/components/block-switcher/style.scss +1 -1
- package/src/components/block-toolbar/index.js +22 -19
- package/src/components/block-toolbar/shuffle.js +19 -13
- package/src/components/block-toolbar/style.scss +1 -1
- package/src/components/block-tools/block-selection-button.js +66 -9
- package/src/components/block-tools/index.js +18 -1
- package/src/components/button-block-appender/content.scss +5 -1
- package/src/components/default-block-appender/content.scss +2 -2
- package/src/components/global-styles/advanced-panel.js +8 -2
- package/src/components/global-styles/background-panel.js +591 -0
- package/src/components/global-styles/color-panel.js +2 -1
- package/src/components/global-styles/get-global-styles-changes.js +3 -0
- package/src/components/global-styles/hooks.js +1 -0
- package/src/components/global-styles/index.js +4 -0
- package/src/components/global-styles/style.scss +78 -1
- package/src/{hooks/test/background.js → components/global-styles/test/background-panel.js} +36 -1
- package/src/components/global-styles/test/get-global-styles-changes.js +22 -3
- package/src/components/global-styles/test/use-global-styles-output.js +9 -9
- package/src/components/global-styles/use-global-styles-output.js +27 -16
- package/src/components/global-styles/utils.js +1 -0
- package/src/components/iframe/index.js +19 -9
- package/src/components/inserter/block-patterns-tab/index.js +1 -0
- package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +5 -0
- package/src/components/inserter/library.js +4 -0
- package/src/components/inserter/menu.js +8 -1
- package/src/components/inserter/search-items.js +37 -15
- package/src/components/inserter/style.scss +6 -12
- package/src/components/keyboard-shortcuts/index.js +11 -0
- package/src/components/list-view/block-select-button.js +13 -1
- package/src/components/list-view/block.js +1 -1
- package/src/components/list-view/index.js +18 -1
- package/src/components/list-view/style.scss +4 -4
- package/src/components/list-view/use-list-view-collapse-items.js +33 -0
- package/src/components/rich-text/index.js +30 -13
- package/src/components/rich-text/index.native.js +14 -11
- package/src/components/rich-text/native/get-format-colors.native.js +1 -1
- package/src/components/rich-text/native/index.native.js +2 -2
- package/src/components/rich-text/with-deprecations.js +0 -3
- package/src/components/url-popover/image-url-input-ui.js +68 -51
- package/src/components/use-block-display-information/index.js +8 -10
- package/src/hooks/anchor.js +11 -9
- package/src/hooks/background.js +77 -538
- package/src/hooks/index.js +1 -0
- package/src/hooks/use-zoom-out.js +36 -0
- package/src/index.js +1 -0
- package/src/private-apis.js +13 -1
- package/src/private-apis.native.js +2 -0
- package/src/store/private-actions.js +12 -0
- package/src/store/private-keys.js +1 -0
- package/src/store/private-selectors.js +54 -27
- package/src/store/reducer.js +22 -0
- package/src/store/selectors.js +195 -180
- package/src/store/test/private-actions.js +10 -0
- package/src/store/test/private-selectors.js +13 -0
- package/src/store/test/reducer.js +26 -0
- package/src/store/test/selectors.js +90 -199
- package/src/store/utils.js +13 -0
- package/src/style.scss +0 -2
- package/src/utils/transform-styles/index.js +2 -1
- package/src/hooks/anchor.scss +0 -4
- package/src/hooks/background.scss +0 -75
|
@@ -8,11 +8,13 @@ import {
|
|
|
8
8
|
} from '@wordpress/blocks';
|
|
9
9
|
import { RawHTML } from '@wordpress/element';
|
|
10
10
|
import { symbol } from '@wordpress/icons';
|
|
11
|
+
import { select, dispatch } from '@wordpress/data';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Internal dependencies
|
|
14
15
|
*/
|
|
15
16
|
import * as selectors from '../selectors';
|
|
17
|
+
import { store } from '../';
|
|
16
18
|
|
|
17
19
|
const {
|
|
18
20
|
getBlockName,
|
|
@@ -55,7 +57,6 @@ const {
|
|
|
55
57
|
isSelectionEnabled,
|
|
56
58
|
canInsertBlockType,
|
|
57
59
|
canInsertBlocks,
|
|
58
|
-
getInserterItems,
|
|
59
60
|
getBlockTransformItems,
|
|
60
61
|
isValidTemplate,
|
|
61
62
|
getTemplate,
|
|
@@ -3286,41 +3287,26 @@ describe( 'selectors', () => {
|
|
|
3286
3287
|
} );
|
|
3287
3288
|
|
|
3288
3289
|
describe( 'getInserterItems', () => {
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
clientId: 'block1',
|
|
3310
|
-
title: { raw: 'Reusable Block 1' },
|
|
3311
|
-
content: { raw: '<!-- /wp:test-block-a -->' },
|
|
3312
|
-
},
|
|
3313
|
-
],
|
|
3314
|
-
},
|
|
3315
|
-
// Intentionally include a test case which considers
|
|
3316
|
-
// `insertUsage` as not present within preferences.
|
|
3317
|
-
//
|
|
3318
|
-
// See: https://github.com/WordPress/gutenberg/issues/14580
|
|
3319
|
-
preferences: {},
|
|
3320
|
-
blockListSettings: {},
|
|
3321
|
-
blockEditingModes: new Map(),
|
|
3322
|
-
};
|
|
3323
|
-
const items = getInserterItems( state );
|
|
3290
|
+
afterAll( async () => {
|
|
3291
|
+
await dispatch( store ).updateSettings( {
|
|
3292
|
+
__experimentalReusableBlocks: [],
|
|
3293
|
+
} );
|
|
3294
|
+
await dispatch( store ).resetBlocks( [] );
|
|
3295
|
+
} );
|
|
3296
|
+
|
|
3297
|
+
it( 'should properly list block type and reusable block items', async () => {
|
|
3298
|
+
await dispatch( store ).updateSettings( {
|
|
3299
|
+
__experimentalReusableBlocks: [
|
|
3300
|
+
{
|
|
3301
|
+
id: 1,
|
|
3302
|
+
isTemporary: false,
|
|
3303
|
+
clientId: 'block1',
|
|
3304
|
+
title: { raw: 'Reusable Block 1' },
|
|
3305
|
+
content: { raw: '<!-- /wp:test-block-a -->' },
|
|
3306
|
+
},
|
|
3307
|
+
],
|
|
3308
|
+
} );
|
|
3309
|
+
const items = select( store ).getInserterItems();
|
|
3324
3310
|
const testBlockAItem = items.find(
|
|
3325
3311
|
( item ) => item.id === 'core/test-block-a'
|
|
3326
3312
|
);
|
|
@@ -3361,93 +3347,48 @@ describe( 'selectors', () => {
|
|
|
3361
3347
|
} );
|
|
3362
3348
|
} );
|
|
3363
3349
|
|
|
3364
|
-
it( 'should correctly cache the return values', () => {
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
}
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
Object.entries( {
|
|
3381
|
-
'': [ 'block3', 'block4' ],
|
|
3382
|
-
} )
|
|
3383
|
-
),
|
|
3384
|
-
parents: new Map(
|
|
3385
|
-
Object.entries( {
|
|
3386
|
-
block3: '',
|
|
3387
|
-
block4: '',
|
|
3388
|
-
} )
|
|
3389
|
-
),
|
|
3390
|
-
tree: new Map(
|
|
3391
|
-
Object.entries( {
|
|
3392
|
-
block3: {
|
|
3393
|
-
clientId: 'block3',
|
|
3394
|
-
name: 'core/test-block-a',
|
|
3395
|
-
attributes: {},
|
|
3396
|
-
innerBlocks: [],
|
|
3397
|
-
},
|
|
3398
|
-
block4: {
|
|
3399
|
-
clientId: 'block4',
|
|
3400
|
-
name: 'core/test-block-a',
|
|
3401
|
-
attributes: {},
|
|
3402
|
-
innerBlocks: [],
|
|
3403
|
-
},
|
|
3404
|
-
} )
|
|
3405
|
-
),
|
|
3406
|
-
controlledInnerBlocks: {},
|
|
3407
|
-
},
|
|
3408
|
-
settings: {
|
|
3409
|
-
__experimentalReusableBlocks: [
|
|
3410
|
-
{
|
|
3411
|
-
id: 1,
|
|
3412
|
-
isTemporary: false,
|
|
3413
|
-
clientId: 'block1',
|
|
3414
|
-
title: { raw: 'Reusable Block 1' },
|
|
3415
|
-
content: { raw: '<!-- /wp:test-block-a -->' },
|
|
3416
|
-
},
|
|
3417
|
-
{
|
|
3418
|
-
id: 2,
|
|
3419
|
-
isTemporary: false,
|
|
3420
|
-
clientId: 'block2',
|
|
3421
|
-
title: { raw: 'Reusable Block 2' },
|
|
3422
|
-
content: { raw: '<!-- /wp:test-block-b -->' },
|
|
3423
|
-
},
|
|
3424
|
-
],
|
|
3425
|
-
},
|
|
3426
|
-
preferences: {
|
|
3427
|
-
insertUsage: {},
|
|
3428
|
-
},
|
|
3429
|
-
blockListSettings: {
|
|
3430
|
-
block3: {},
|
|
3431
|
-
block4: {},
|
|
3432
|
-
},
|
|
3433
|
-
blockEditingModes: new Map(),
|
|
3434
|
-
};
|
|
3435
|
-
|
|
3436
|
-
const stateSecondBlockRestricted = {
|
|
3437
|
-
...state,
|
|
3438
|
-
blockListSettings: {
|
|
3439
|
-
...state.blockListSettings,
|
|
3440
|
-
block4: {
|
|
3441
|
-
allowedBlocks: [ 'core/test-block-b' ],
|
|
3350
|
+
it( 'should correctly cache the return values', async () => {
|
|
3351
|
+
await dispatch( store ).updateSettings( {
|
|
3352
|
+
__experimentalReusableBlocks: [
|
|
3353
|
+
{
|
|
3354
|
+
id: 1,
|
|
3355
|
+
isTemporary: false,
|
|
3356
|
+
clientId: 'block1',
|
|
3357
|
+
title: { raw: 'Reusable Block 1' },
|
|
3358
|
+
content: { raw: '<!-- /wp:test-block-a -->' },
|
|
3359
|
+
},
|
|
3360
|
+
{
|
|
3361
|
+
id: 2,
|
|
3362
|
+
isTemporary: false,
|
|
3363
|
+
clientId: 'block2',
|
|
3364
|
+
title: { raw: 'Reusable Block 2' },
|
|
3365
|
+
content: { raw: '<!-- /wp:test-block-b -->' },
|
|
3442
3366
|
},
|
|
3367
|
+
],
|
|
3368
|
+
} );
|
|
3369
|
+
await dispatch( store ).resetBlocks( [
|
|
3370
|
+
{
|
|
3371
|
+
clientId: 'block3',
|
|
3372
|
+
name: 'core/test-block-a',
|
|
3373
|
+
innerBlocks: [],
|
|
3443
3374
|
},
|
|
3444
|
-
|
|
3375
|
+
{
|
|
3376
|
+
clientId: 'block4',
|
|
3377
|
+
name: 'core/test-block-a',
|
|
3378
|
+
innerBlocks: [],
|
|
3379
|
+
},
|
|
3380
|
+
] );
|
|
3381
|
+
await dispatch( store ).updateBlockListSettings( 'block3', {} );
|
|
3382
|
+
await dispatch( store ).updateBlockListSettings( 'block4', {} );
|
|
3445
3383
|
|
|
3446
|
-
const firstBlockFirstCall =
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
'
|
|
3450
|
-
);
|
|
3384
|
+
const firstBlockFirstCall =
|
|
3385
|
+
select( store ).getInserterItems( 'block3' );
|
|
3386
|
+
await dispatch( store ).updateBlockListSettings( 'block4', {
|
|
3387
|
+
allowedBlocks: [ 'core/test-block-b' ],
|
|
3388
|
+
} );
|
|
3389
|
+
const firstBlockSecondCall =
|
|
3390
|
+
select( store ).getInserterItems( 'block3' );
|
|
3391
|
+
await dispatch( store ).updateBlockListSettings( 'block4', {} );
|
|
3451
3392
|
expect( firstBlockFirstCall ).toBe( firstBlockSecondCall );
|
|
3452
3393
|
expect( firstBlockFirstCall.map( ( item ) => item.id ) ).toEqual( [
|
|
3453
3394
|
'core/test-block-a',
|
|
@@ -3459,11 +3400,14 @@ describe( 'selectors', () => {
|
|
|
3459
3400
|
'core/block/2',
|
|
3460
3401
|
] );
|
|
3461
3402
|
|
|
3462
|
-
const secondBlockFirstCall =
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
'
|
|
3466
|
-
);
|
|
3403
|
+
const secondBlockFirstCall =
|
|
3404
|
+
select( store ).getInserterItems( 'block4' );
|
|
3405
|
+
await dispatch( store ).updateBlockListSettings( 'block4', {
|
|
3406
|
+
allowedBlocks: [ 'core/test-block-b' ],
|
|
3407
|
+
} );
|
|
3408
|
+
const secondBlockSecondCall =
|
|
3409
|
+
select( store ).getInserterItems( 'block4' );
|
|
3410
|
+
await dispatch( store ).updateBlockListSettings( 'block4', {} );
|
|
3467
3411
|
expect( secondBlockFirstCall ).not.toBe( secondBlockSecondCall );
|
|
3468
3412
|
expect( secondBlockFirstCall.map( ( item ) => item.id ) ).toEqual( [
|
|
3469
3413
|
'core/test-block-a',
|
|
@@ -3479,77 +3423,37 @@ describe( 'selectors', () => {
|
|
|
3479
3423
|
);
|
|
3480
3424
|
} );
|
|
3481
3425
|
|
|
3482
|
-
it( 'should set isDisabled when a block with `multiple: false` has been used', () => {
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
clientId: 'block1',
|
|
3489
|
-
name: 'core/test-block-b',
|
|
3490
|
-
},
|
|
3491
|
-
} )
|
|
3492
|
-
),
|
|
3493
|
-
attributes: new Map(
|
|
3494
|
-
Object.entries( {
|
|
3495
|
-
block1: { attribute: {} },
|
|
3496
|
-
} )
|
|
3497
|
-
),
|
|
3498
|
-
order: new Map(
|
|
3499
|
-
Object.entries( {
|
|
3500
|
-
'': [ 'block1' ],
|
|
3501
|
-
} )
|
|
3502
|
-
),
|
|
3503
|
-
tree: new Map(
|
|
3504
|
-
Object.entries( {
|
|
3505
|
-
block1: {
|
|
3506
|
-
clientId: 'block1',
|
|
3507
|
-
name: 'core/test-block-b',
|
|
3508
|
-
attributes: {},
|
|
3509
|
-
innerBlocks: [],
|
|
3510
|
-
},
|
|
3511
|
-
} )
|
|
3512
|
-
),
|
|
3513
|
-
controlledInnerBlocks: {},
|
|
3514
|
-
parents: new Map(),
|
|
3515
|
-
},
|
|
3516
|
-
preferences: {
|
|
3517
|
-
insertUsage: {},
|
|
3426
|
+
it( 'should set isDisabled when a block with `multiple: false` has been used', async () => {
|
|
3427
|
+
await dispatch( store ).resetBlocks( [
|
|
3428
|
+
{
|
|
3429
|
+
clientId: 'block1',
|
|
3430
|
+
name: 'core/test-block-b',
|
|
3431
|
+
innerBlocks: [],
|
|
3518
3432
|
},
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
blockEditingModes: new Map(),
|
|
3522
|
-
};
|
|
3523
|
-
const items = getInserterItems( state );
|
|
3433
|
+
] );
|
|
3434
|
+
const items = select( store ).getInserterItems();
|
|
3524
3435
|
const testBlockBItem = items.find(
|
|
3525
3436
|
( item ) => item.id === 'core/test-block-b'
|
|
3526
3437
|
);
|
|
3527
3438
|
expect( testBlockBItem.isDisabled ).toBe( true );
|
|
3528
3439
|
} );
|
|
3529
3440
|
|
|
3530
|
-
it( 'should set a frecency', () => {
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
cache: {},
|
|
3538
|
-
},
|
|
3539
|
-
preferences: {
|
|
3540
|
-
insertUsage: {
|
|
3541
|
-
'core/test-block-b': { count: 10, time: 1000 },
|
|
3441
|
+
it( 'should set a frecency', async () => {
|
|
3442
|
+
for ( let i = 0; i < 10; i++ ) {
|
|
3443
|
+
await dispatch( store ).insertBlocks( [
|
|
3444
|
+
{
|
|
3445
|
+
clientId: 'block1',
|
|
3446
|
+
name: 'core/test-block-b',
|
|
3447
|
+
innerBlocks: [],
|
|
3542
3448
|
},
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
};
|
|
3548
|
-
const items = getInserterItems( state );
|
|
3449
|
+
] );
|
|
3450
|
+
}
|
|
3451
|
+
|
|
3452
|
+
const items = select( store ).getInserterItems();
|
|
3549
3453
|
const reusableBlock2Item = items.find(
|
|
3550
3454
|
( item ) => item.id === 'core/test-block-b'
|
|
3551
3455
|
);
|
|
3552
|
-
expect( reusableBlock2Item.frecency ).toBe(
|
|
3456
|
+
expect( reusableBlock2Item.frecency ).toBe( 40 );
|
|
3553
3457
|
} );
|
|
3554
3458
|
} );
|
|
3555
3459
|
|
|
@@ -4304,20 +4208,7 @@ describe( 'getInserterItems with core blocks prioritization', () => {
|
|
|
4304
4208
|
].forEach( unregisterBlockType );
|
|
4305
4209
|
} );
|
|
4306
4210
|
it( 'should prioritize core blocks by sorting them at the top of the returned list', () => {
|
|
4307
|
-
const
|
|
4308
|
-
blocks: {
|
|
4309
|
-
byClientId: new Map(),
|
|
4310
|
-
attributes: new Map(),
|
|
4311
|
-
order: new Map(),
|
|
4312
|
-
parents: new Map(),
|
|
4313
|
-
cache: {},
|
|
4314
|
-
},
|
|
4315
|
-
settings: {},
|
|
4316
|
-
preferences: {},
|
|
4317
|
-
blockListSettings: {},
|
|
4318
|
-
blockEditingModes: new Map(),
|
|
4319
|
-
};
|
|
4320
|
-
const items = getInserterItems( state );
|
|
4211
|
+
const items = select( store ).getInserterItems();
|
|
4321
4212
|
const expectedResult = [
|
|
4322
4213
|
'core/block',
|
|
4323
4214
|
'core/test-block-a',
|
package/src/store/utils.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { selectBlockPatternsKey } from './private-keys';
|
|
5
|
+
import { unlock } from '../lock-unlock';
|
|
6
|
+
import { STORE_NAME } from './constants';
|
|
5
7
|
|
|
6
8
|
export const checkAllowList = ( list, item, defaultResult = null ) => {
|
|
7
9
|
if ( typeof list === 'boolean' ) {
|
|
@@ -52,5 +54,16 @@ export const getAllPatternsDependants = ( select ) => ( state ) => {
|
|
|
52
54
|
state.settings.__experimentalReusableBlocks,
|
|
53
55
|
state.settings[ selectBlockPatternsKey ]?.( select ),
|
|
54
56
|
state.blockPatterns,
|
|
57
|
+
unlock( select( STORE_NAME ) ).getReusableBlocks(),
|
|
55
58
|
];
|
|
56
59
|
};
|
|
60
|
+
|
|
61
|
+
export function getInsertBlockTypeDependants( state, rootClientId ) {
|
|
62
|
+
return [
|
|
63
|
+
state.blockListSettings[ rootClientId ],
|
|
64
|
+
state.blocks.byClientId.get( rootClientId ),
|
|
65
|
+
state.settings.allowedBlockTypes,
|
|
66
|
+
state.settings.templateLock,
|
|
67
|
+
state.blockEditingModes,
|
|
68
|
+
];
|
|
69
|
+
}
|
package/src/style.scss
CHANGED
|
@@ -47,9 +47,7 @@
|
|
|
47
47
|
@import "./components/tool-selector/style.scss";
|
|
48
48
|
@import "./components/url-input/style.scss";
|
|
49
49
|
@import "./components/url-popover/style.scss";
|
|
50
|
-
@import "./hooks/anchor.scss";
|
|
51
50
|
@import "./hooks/block-hooks.scss";
|
|
52
|
-
@import "./hooks/background.scss";
|
|
53
51
|
@import "./hooks/border.scss";
|
|
54
52
|
@import "./hooks/color.scss";
|
|
55
53
|
@import "./hooks/dimensions.scss";
|
|
@@ -19,6 +19,7 @@ function transformStyle(
|
|
|
19
19
|
return css;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
const postcssFriendlyCSS = css.replace( ':where(body)', 'body' );
|
|
22
23
|
try {
|
|
23
24
|
return postcss(
|
|
24
25
|
[
|
|
@@ -31,7 +32,7 @@ function transformStyle(
|
|
|
31
32
|
} ),
|
|
32
33
|
baseURL && rebaseUrl( { rootUrl: baseURL } ),
|
|
33
34
|
].filter( Boolean )
|
|
34
|
-
).process(
|
|
35
|
+
).process( postcssFriendlyCSS, {} ).css; // use sync PostCSS API
|
|
35
36
|
} catch ( error ) {
|
|
36
37
|
if ( error instanceof CssSyntaxError ) {
|
|
37
38
|
// eslint-disable-next-line no-console
|
package/src/hooks/anchor.scss
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
.block-editor-hooks__background__inspector-media-replace-container {
|
|
2
|
-
position: relative;
|
|
3
|
-
// Since there is no option to skip rendering the drag'n'drop icon in drop
|
|
4
|
-
// zone, we hide it for now.
|
|
5
|
-
.components-drop-zone__content-icon {
|
|
6
|
-
display: none;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
button.components-button {
|
|
10
|
-
color: $gray-900;
|
|
11
|
-
box-shadow: inset 0 0 0 $border-width $gray-300;
|
|
12
|
-
width: 100%;
|
|
13
|
-
display: block;
|
|
14
|
-
height: $grid-unit-50;
|
|
15
|
-
|
|
16
|
-
&:hover {
|
|
17
|
-
color: var(--wp-admin-theme-color);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
&:focus {
|
|
21
|
-
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.block-editor-hooks__background__inspector-media-replace-title {
|
|
26
|
-
word-break: break-all;
|
|
27
|
-
// The Button component is white-space: nowrap, and that won't work with line-clamp.
|
|
28
|
-
white-space: normal;
|
|
29
|
-
|
|
30
|
-
// Without this, the ellipsis can sometimes be partially hidden by the Button padding.
|
|
31
|
-
text-align: start;
|
|
32
|
-
text-align-last: center;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.components-dropdown {
|
|
36
|
-
display: block;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.block-editor-hooks__background__inspector-image-indicator-wrapper {
|
|
41
|
-
background: #fff linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%); // Show a diagonal line (crossed out) for empty background image.
|
|
42
|
-
border-radius: $radius-round !important; // Override the default border-radius inherited from FlexItem.
|
|
43
|
-
box-shadow: inset 0 0 0 $border-width rgba(0, 0, 0, 0.2);
|
|
44
|
-
display: block;
|
|
45
|
-
width: 20px;
|
|
46
|
-
height: 20px;
|
|
47
|
-
flex: none;
|
|
48
|
-
|
|
49
|
-
&.has-image {
|
|
50
|
-
background: #fff; // No diagonal line for non-empty background image. A background color is in use to account for partially transparent images.
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.block-editor-hooks__background__inspector-image-indicator {
|
|
55
|
-
background-size: cover;
|
|
56
|
-
border-radius: $radius-round;
|
|
57
|
-
width: 20px;
|
|
58
|
-
height: 20px;
|
|
59
|
-
display: block;
|
|
60
|
-
position: relative;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.block-editor-hooks__background__inspector-image-indicator::after {
|
|
64
|
-
content: "";
|
|
65
|
-
position: absolute;
|
|
66
|
-
top: -1px;
|
|
67
|
-
left: -1px;
|
|
68
|
-
bottom: -1px;
|
|
69
|
-
right: -1px;
|
|
70
|
-
border-radius: $radius-round;
|
|
71
|
-
box-shadow: inset 0 0 0 $border-width rgba(0, 0, 0, 0.2);
|
|
72
|
-
// Show a thin outline in Windows high contrast mode, otherwise the button is invisible.
|
|
73
|
-
border: 1px solid transparent;
|
|
74
|
-
box-sizing: inherit;
|
|
75
|
-
}
|