@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
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
import { useEffect } from '@wordpress/element';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { store as blockEditorStore } from '../store';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A hook used to set the editor mode to zoomed out mode, invoking the hook sets the mode.
|
|
14
|
+
*/
|
|
15
|
+
export function useZoomOut() {
|
|
16
|
+
const { __unstableSetEditorMode } = useDispatch( blockEditorStore );
|
|
17
|
+
const { mode } = useSelect( ( select ) => {
|
|
18
|
+
return {
|
|
19
|
+
mode: select( blockEditorStore ).__unstableGetEditorMode(),
|
|
20
|
+
};
|
|
21
|
+
}, [] );
|
|
22
|
+
|
|
23
|
+
// Intentionality left without any dependency.
|
|
24
|
+
// This effect should only run when the component is rendered and unmounted.
|
|
25
|
+
// The effect opens the zoom-out view if it is not open before when applying a style variation.
|
|
26
|
+
useEffect( () => {
|
|
27
|
+
if ( mode !== 'zoom-out' ) {
|
|
28
|
+
__unstableSetEditorMode( 'zoom-out' );
|
|
29
|
+
return () => {
|
|
30
|
+
// Revert to original mode
|
|
31
|
+
__unstableSetEditorMode( mode );
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
+
}, [] );
|
|
36
|
+
}
|
package/src/index.js
CHANGED
package/src/private-apis.js
CHANGED
|
@@ -8,6 +8,11 @@ import { getRichTextValues } from './components/rich-text/get-rich-text-values';
|
|
|
8
8
|
import ResizableBoxPopover from './components/resizable-box-popover';
|
|
9
9
|
import { ComposedPrivateInserter as PrivateInserter } from './components/inserter';
|
|
10
10
|
import { default as PrivateQuickInserter } from './components/inserter/quick-inserter';
|
|
11
|
+
import {
|
|
12
|
+
extractWords,
|
|
13
|
+
getNormalizedSearchTerms,
|
|
14
|
+
normalizeString,
|
|
15
|
+
} from './components/inserter/search-items';
|
|
11
16
|
import { PrivateListView } from './components/list-view';
|
|
12
17
|
import BlockInfo from './components/block-info-slot-fill';
|
|
13
18
|
import { useShowBlockTools } from './components/block-tools/use-show-block-tools';
|
|
@@ -26,7 +31,10 @@ import { usesContextKey } from './components/rich-text/format-edit';
|
|
|
26
31
|
import { ExperimentalBlockCanvas } from './components/block-canvas';
|
|
27
32
|
import { getDuotoneFilter } from './components/duotone/utils';
|
|
28
33
|
import { useFlashEditableBlocks } from './components/use-flash-editable-blocks';
|
|
29
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
selectBlockPatternsKey,
|
|
36
|
+
reusableBlocksSelectKey,
|
|
37
|
+
} from './store/private-keys';
|
|
30
38
|
import { requiresWrapperOnCopy } from './components/writing-flow/utils';
|
|
31
39
|
import { PrivateRichText } from './components/rich-text/';
|
|
32
40
|
|
|
@@ -42,6 +50,9 @@ lock( privateApis, {
|
|
|
42
50
|
getRichTextValues,
|
|
43
51
|
PrivateInserter,
|
|
44
52
|
PrivateQuickInserter,
|
|
53
|
+
extractWords,
|
|
54
|
+
getNormalizedSearchTerms,
|
|
55
|
+
normalizeString,
|
|
45
56
|
PrivateListView,
|
|
46
57
|
ResizableBoxPopover,
|
|
47
58
|
BlockInfo,
|
|
@@ -62,4 +73,5 @@ lock( privateApis, {
|
|
|
62
73
|
selectBlockPatternsKey,
|
|
63
74
|
requiresWrapperOnCopy,
|
|
64
75
|
PrivateRichText,
|
|
76
|
+
reusableBlocksSelectKey,
|
|
65
77
|
} );
|
|
@@ -5,6 +5,7 @@ import * as globalStyles from './components/global-styles';
|
|
|
5
5
|
import { ExperimentalBlockEditorProvider } from './components/provider';
|
|
6
6
|
import { getRichTextValues } from './components/rich-text/get-rich-text-values';
|
|
7
7
|
import { lock } from './lock-unlock';
|
|
8
|
+
import { PrivateRichText } from './components/rich-text/';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Private @wordpress/block-editor APIs.
|
|
@@ -14,4 +15,5 @@ lock( privateApis, {
|
|
|
14
15
|
...globalStyles,
|
|
15
16
|
ExperimentalBlockEditorProvider,
|
|
16
17
|
getRichTextValues,
|
|
18
|
+
PrivateRichText,
|
|
17
19
|
} );
|
|
@@ -376,3 +376,15 @@ export function stopDragging() {
|
|
|
376
376
|
type: 'STOP_DRAGGING',
|
|
377
377
|
};
|
|
378
378
|
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* @param {string|null} clientId The block's clientId, or `null` to clear.
|
|
382
|
+
*
|
|
383
|
+
* @return {Object} Action object.
|
|
384
|
+
*/
|
|
385
|
+
export function expandBlock( clientId ) {
|
|
386
|
+
return {
|
|
387
|
+
type: 'SET_BLOCK_EXPANDED_IN_LIST_VIEW',
|
|
388
|
+
clientId,
|
|
389
|
+
};
|
|
390
|
+
}
|
|
@@ -18,11 +18,18 @@ import {
|
|
|
18
18
|
getSettings,
|
|
19
19
|
canInsertBlockType,
|
|
20
20
|
} from './selectors';
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
checkAllowListRecursive,
|
|
23
|
+
getAllPatternsDependants,
|
|
24
|
+
getInsertBlockTypeDependants,
|
|
25
|
+
} from './utils';
|
|
22
26
|
import { INSERTER_PATTERN_TYPES } from '../components/inserter/block-patterns-tab/utils';
|
|
23
27
|
import { STORE_NAME } from './constants';
|
|
24
28
|
import { unlock } from '../lock-unlock';
|
|
25
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
selectBlockPatternsKey,
|
|
31
|
+
reusableBlocksSelectKey,
|
|
32
|
+
} from './private-keys';
|
|
26
33
|
|
|
27
34
|
export { getBlockSettings } from './get-block-settings';
|
|
28
35
|
|
|
@@ -282,11 +289,8 @@ export const hasAllowedPatterns = createRegistrySelector( ( select ) =>
|
|
|
282
289
|
} );
|
|
283
290
|
},
|
|
284
291
|
( state, rootClientId ) => [
|
|
285
|
-
getAllPatternsDependants( select )( state ),
|
|
286
|
-
state
|
|
287
|
-
state.settings.templateLock,
|
|
288
|
-
state.blockListSettings[ rootClientId ],
|
|
289
|
-
state.blocks.byClientId.get( rootClientId ),
|
|
292
|
+
...getAllPatternsDependants( select )( state ),
|
|
293
|
+
...getInsertBlockTypeDependants( state, rootClientId ),
|
|
290
294
|
]
|
|
291
295
|
)
|
|
292
296
|
);
|
|
@@ -299,26 +303,27 @@ export const getAllPatterns = createRegistrySelector( ( select ) =>
|
|
|
299
303
|
__experimentalUserPatternCategories = [],
|
|
300
304
|
__experimentalReusableBlocks = [],
|
|
301
305
|
} = state.settings;
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
)
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
306
|
+
const reusableBlocksSelect = state.settings[ reusableBlocksSelectKey ];
|
|
307
|
+
const userPatterns = (
|
|
308
|
+
reusableBlocksSelect
|
|
309
|
+
? reusableBlocksSelect( select )
|
|
310
|
+
: __experimentalReusableBlocks ?? []
|
|
311
|
+
).map( ( userPattern ) => {
|
|
312
|
+
return {
|
|
313
|
+
name: `core/block/${ userPattern.id }`,
|
|
314
|
+
id: userPattern.id,
|
|
315
|
+
type: INSERTER_PATTERN_TYPES.user,
|
|
316
|
+
title: userPattern.title.raw,
|
|
317
|
+
categories: userPattern.wp_pattern_category.map( ( catId ) => {
|
|
318
|
+
const category = (
|
|
319
|
+
__experimentalUserPatternCategories ?? []
|
|
320
|
+
).find( ( { id } ) => id === catId );
|
|
321
|
+
return category ? category.slug : catId;
|
|
322
|
+
} ),
|
|
323
|
+
content: userPattern.content.raw,
|
|
324
|
+
syncStatus: userPattern.wp_pattern_sync_status,
|
|
325
|
+
};
|
|
326
|
+
} );
|
|
322
327
|
return [
|
|
323
328
|
...userPatterns,
|
|
324
329
|
...__experimentalBlockPatterns,
|
|
@@ -330,6 +335,17 @@ export const getAllPatterns = createRegistrySelector( ( select ) =>
|
|
|
330
335
|
}, getAllPatternsDependants( select ) )
|
|
331
336
|
);
|
|
332
337
|
|
|
338
|
+
const EMPTY_ARRAY = [];
|
|
339
|
+
|
|
340
|
+
export const getReusableBlocks = createRegistrySelector(
|
|
341
|
+
( select ) => ( state ) => {
|
|
342
|
+
const reusableBlocksSelect = state.settings[ reusableBlocksSelectKey ];
|
|
343
|
+
return reusableBlocksSelect
|
|
344
|
+
? reusableBlocksSelect( select )
|
|
345
|
+
: state.settings.__experimentalReusableBlocks ?? EMPTY_ARRAY;
|
|
346
|
+
}
|
|
347
|
+
);
|
|
348
|
+
|
|
333
349
|
/**
|
|
334
350
|
* Returns the element of the last element that had focus when focus left the editor canvas.
|
|
335
351
|
*
|
|
@@ -353,3 +369,14 @@ export function getLastFocus( state ) {
|
|
|
353
369
|
export function isDragging( state ) {
|
|
354
370
|
return state.isDragging;
|
|
355
371
|
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Retrieves the expanded block from the state.
|
|
375
|
+
*
|
|
376
|
+
* @param {Object} state Block editor state.
|
|
377
|
+
*
|
|
378
|
+
* @return {string|null} The client ID of the expanded block, if set.
|
|
379
|
+
*/
|
|
380
|
+
export function getExpandedBlock( state ) {
|
|
381
|
+
return state.expandedBlock;
|
|
382
|
+
}
|
package/src/store/reducer.js
CHANGED
|
@@ -1889,6 +1889,27 @@ export function highlightedBlock( state, action ) {
|
|
|
1889
1889
|
return state;
|
|
1890
1890
|
}
|
|
1891
1891
|
|
|
1892
|
+
/**
|
|
1893
|
+
* Reducer returning current expanded block in the list view.
|
|
1894
|
+
*
|
|
1895
|
+
* @param {string|null} state Current expanded block.
|
|
1896
|
+
* @param {Object} action Dispatched action.
|
|
1897
|
+
*
|
|
1898
|
+
* @return {string|null} Updated state.
|
|
1899
|
+
*/
|
|
1900
|
+
export function expandedBlock( state = null, action ) {
|
|
1901
|
+
switch ( action.type ) {
|
|
1902
|
+
case 'SET_BLOCK_EXPANDED_IN_LIST_VIEW':
|
|
1903
|
+
return action.clientId;
|
|
1904
|
+
case 'SELECT_BLOCK':
|
|
1905
|
+
if ( action.clientId !== state ) {
|
|
1906
|
+
return null;
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1910
|
+
return state;
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1892
1913
|
/**
|
|
1893
1914
|
* Reducer returning the block insertion event list state.
|
|
1894
1915
|
*
|
|
@@ -2064,6 +2085,7 @@ const combinedReducers = combineReducers( {
|
|
|
2064
2085
|
lastFocus,
|
|
2065
2086
|
editorMode,
|
|
2066
2087
|
hasBlockMovingClientId,
|
|
2088
|
+
expandedBlock,
|
|
2067
2089
|
highlightedBlock,
|
|
2068
2090
|
lastBlockInserted,
|
|
2069
2091
|
temporarilyEditingAsBlocks,
|