@wordpress/block-editor 12.4.0 → 12.5.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 +5 -0
- package/build/components/block-heading-level-dropdown/heading-level-icon.js +10 -2
- package/build/components/block-heading-level-dropdown/heading-level-icon.js.map +1 -1
- package/build/components/block-heading-level-dropdown/index.native.js +4 -3
- package/build/components/block-heading-level-dropdown/index.native.js.map +1 -1
- package/build/components/block-lock/toolbar.js +25 -6
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +3 -6
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-parent-selector/index.js +8 -5
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +18 -25
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +8 -5
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +7 -11
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/dimensions-tool/aspect-ratio-tool.js +99 -0
- package/build/components/dimensions-tool/aspect-ratio-tool.js.map +1 -0
- package/build/components/dimensions-tool/index.js +207 -0
- package/build/components/dimensions-tool/index.js.map +1 -0
- package/build/components/dimensions-tool/scale-tool.js +111 -0
- package/build/components/dimensions-tool/scale-tool.js.map +1 -0
- package/build/components/dimensions-tool/width-height-tool.js +125 -0
- package/build/components/dimensions-tool/width-height-tool.js.map +1 -0
- package/build/components/global-styles/color-panel.js +1 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +1 -1
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +2 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +34 -2
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +1 -2
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/image-size-control/index.js +6 -0
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/index.js +19 -1
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/patterns-list.js +2 -2
- package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +7 -35
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js +3 -4
- package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js +9 -3
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +2 -21
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/reusable-block-rename-hint.js +62 -0
- package/build/components/inserter/reusable-block-rename-hint.js.map +1 -0
- package/build/components/inserter/reusable-blocks-tab.js +6 -2
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +2 -2
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/tabs.native.js +1 -1
- package/build/components/inserter/tabs.native.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +9 -1
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/link-control/constants.js +1 -1
- package/build/components/link-control/constants.js.map +1 -1
- package/build/components/link-control/index.js +17 -15
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-create-button.js +5 -21
- package/build/components/link-control/search-create-button.js.map +1 -1
- package/build/components/link-control/search-input.js +4 -4
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/search-item.js +13 -30
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/link-control/search-results.js +2 -2
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +2 -3
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/list-view/appender.js +2 -6
- package/build/components/list-view/appender.js.map +1 -1
- package/build/components/provider/index.js +5 -2
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +21 -0
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/resolution-tool/index.js +55 -0
- package/build/components/resolution-tool/index.js.map +1 -0
- package/build/components/url-input/index.js +4 -2
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +10 -27
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/components/writing-mode-control/index.js +70 -0
- package/build/components/writing-mode-control/index.js.map +1 -0
- package/build/hooks/behaviors.js +25 -20
- package/build/hooks/behaviors.js.map +1 -1
- package/build/hooks/supports.js +7 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +2 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +4 -2
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +10 -1
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +3 -0
- package/build/private-apis.native.js.map +1 -1
- package/build/store/actions.js +195 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +1 -0
- package/build/store/defaults.js.map +1 -1
- package/build/store/index.js +10 -1
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +46 -40
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +3 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +22 -8
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +33 -15
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/heading-level-icon.js +9 -2
- package/build-module/components/block-heading-level-dropdown/heading-level-icon.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.native.js +4 -3
- package/build-module/components/block-heading-level-dropdown/index.native.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +25 -7
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +4 -6
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +7 -5
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +20 -24
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +8 -5
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +8 -11
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/dimensions-tool/aspect-ratio-tool.js +87 -0
- package/build-module/components/dimensions-tool/aspect-ratio-tool.js.map +1 -0
- package/build-module/components/dimensions-tool/index.js +195 -0
- package/build-module/components/dimensions-tool/index.js.map +1 -0
- package/build-module/components/dimensions-tool/scale-tool.js +103 -0
- package/build-module/components/dimensions-tool/scale-tool.js.map +1 -0
- package/build-module/components/dimensions-tool/width-height-tool.js +122 -0
- package/build-module/components/dimensions-tool/width-height-tool.js.map +1 -0
- package/build-module/components/global-styles/color-panel.js +1 -1
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +2 -2
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +2 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +33 -2
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +1 -2
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/image-size-control/index.js +5 -0
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/index.js +6 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +2 -2
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +7 -33
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js +3 -4
- package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js +9 -3
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +2 -21
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/reusable-block-rename-hint.js +48 -0
- package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -0
- package/build-module/components/inserter/reusable-blocks-tab.js +5 -2
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +2 -2
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/tabs.native.js +1 -1
- package/build-module/components/inserter/tabs.native.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +9 -2
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/link-control/constants.js +1 -1
- package/build-module/components/link-control/constants.js.map +1 -1
- package/build-module/components/link-control/index.js +17 -15
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-create-button.js +7 -20
- package/build-module/components/link-control/search-create-button.js.map +1 -1
- package/build-module/components/link-control/search-input.js +4 -4
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/search-item.js +14 -28
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/link-control/search-results.js +3 -3
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +4 -5
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/list-view/appender.js +2 -6
- package/build-module/components/list-view/appender.js.map +1 -1
- package/build-module/components/provider/index.js +5 -2
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +21 -0
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/resolution-tool/index.js +45 -0
- package/build-module/components/resolution-tool/index.js.map +1 -0
- package/build-module/components/url-input/index.js +4 -2
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +8 -26
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/components/writing-mode-control/index.js +57 -0
- package/build-module/components/writing-mode-control/index.js.map +1 -0
- package/build-module/hooks/behaviors.js +26 -20
- package/build-module/hooks/behaviors.js.map +1 -1
- package/build-module/hooks/supports.js +7 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +2 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +4 -2
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +7 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +2 -0
- package/build-module/private-apis.native.js.map +1 -1
- package/build-module/store/actions.js +191 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +1 -0
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/index.js +10 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +45 -36
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +2 -2
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +22 -8
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +33 -15
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/content-rtl.css +3 -0
- package/build-style/content.css +3 -0
- package/build-style/style-rtl.css +131 -129
- package/build-style/style.css +131 -129
- package/package.json +32 -31
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -6
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -5
- package/src/components/block-draggable/style.scss +1 -0
- package/src/components/block-heading-level-dropdown/heading-level-icon.js +6 -1
- package/src/components/block-heading-level-dropdown/index.native.js +8 -4
- package/src/components/block-inspector/style.scss +2 -1
- package/src/components/block-lock/toolbar.js +34 -6
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +4 -8
- package/src/components/block-parent-selector/index.js +13 -8
- package/src/components/block-removal-warning-modal/index.js +20 -33
- package/src/components/block-toolbar/index.js +9 -6
- package/src/components/block-tools/block-contextual-toolbar.js +5 -11
- package/src/components/block-tools/style.scss +73 -26
- package/src/components/default-block-appender/content.scss +11 -0
- package/src/components/dimensions-tool/aspect-ratio-tool.js +124 -0
- package/src/components/dimensions-tool/index.js +212 -0
- package/src/components/dimensions-tool/scale-tool.js +124 -0
- package/src/components/dimensions-tool/stories/aspect-ratio-tool.js +52 -0
- package/src/components/dimensions-tool/stories/index.js +54 -0
- package/src/components/dimensions-tool/stories/scale-tool.js +48 -0
- package/src/components/dimensions-tool/stories/width-height-tool.js +54 -0
- package/src/components/dimensions-tool/test/index.js +641 -0
- package/src/components/dimensions-tool/width-height-tool.js +113 -0
- package/src/components/font-family/README.md +71 -0
- package/src/components/global-styles/color-panel.js +1 -1
- package/src/components/global-styles/filters-panel.js +2 -2
- package/src/components/global-styles/hooks.js +2 -0
- package/src/components/global-styles/typography-panel.js +40 -0
- package/src/components/image-editor/aspect-ratio-dropdown.js +1 -1
- package/src/components/image-editor/use-save-image.js +0 -1
- package/src/components/image-size-control/index.js +6 -0
- package/src/components/index.js +6 -0
- package/src/components/inserter/block-patterns-explorer/patterns-list.js +8 -2
- package/src/components/inserter/block-patterns-tab.js +8 -56
- package/src/components/inserter/hooks/use-block-types-state.js +3 -4
- package/src/components/inserter/hooks/use-patterns-state.js +35 -19
- package/src/components/inserter/media-tab/hooks.js +2 -22
- package/src/components/inserter/reusable-block-rename-hint.js +52 -0
- package/src/components/inserter/reusable-blocks-tab.js +5 -1
- package/src/components/inserter/reusable-blocks-tab.native.js +2 -2
- package/src/components/inserter/style.scss +28 -0
- package/src/components/inserter/tabs.native.js +5 -1
- package/src/components/inserter-draggable-blocks/index.js +13 -2
- package/src/components/link-control/constants.js +1 -1
- package/src/components/link-control/index.js +32 -28
- package/src/components/link-control/search-create-button.js +8 -26
- package/src/components/link-control/search-input.js +4 -3
- package/src/components/link-control/search-item.js +21 -43
- package/src/components/link-control/search-results.js +48 -46
- package/src/components/link-control/settings-drawer.js +6 -5
- package/src/components/link-control/style.scss +51 -123
- package/src/components/link-control/test/index.js +135 -123
- package/src/components/list-view/appender.js +5 -6
- package/src/components/list-view/style.scss +1 -2
- package/src/components/media-replace-flow/test/index.js +1 -1
- package/src/components/panel-color-settings/README.md +98 -0
- package/src/components/provider/index.js +9 -2
- package/src/components/provider/test/use-block-sync.js +21 -6
- package/src/components/provider/use-block-sync.js +19 -0
- package/src/components/recursion-provider/README.md +101 -0
- package/src/components/resolution-tool/index.js +56 -0
- package/src/components/resolution-tool/stories/index.js +48 -0
- package/src/components/url-input/index.js +2 -0
- package/src/components/writing-flow/use-tab-nav.js +10 -33
- package/src/components/writing-mode-control/index.js +68 -0
- package/src/components/writing-mode-control/style.scss +18 -0
- package/src/hooks/behaviors.js +25 -16
- package/src/hooks/supports.js +7 -0
- package/src/hooks/typography.js +2 -0
- package/src/hooks/utils.js +3 -0
- package/src/private-apis.js +6 -0
- package/src/private-apis.native.js +2 -0
- package/src/store/actions.js +194 -1
- package/src/store/defaults.js +1 -0
- package/src/store/index.js +10 -0
- package/src/store/private-actions.js +39 -39
- package/src/store/private-selectors.js +2 -2
- package/src/store/reducer.js +22 -8
- package/src/store/selectors.js +54 -20
- package/src/store/test/actions.js +111 -0
- package/src/store/test/private-actions.js +56 -0
package/src/store/selectors.js
CHANGED
|
@@ -1945,7 +1945,6 @@ const buildBlockTypeItem =
|
|
|
1945
1945
|
*
|
|
1946
1946
|
* @param {Object} state Editor state.
|
|
1947
1947
|
* @param {?string} rootClientId Optional root client ID of block list.
|
|
1948
|
-
* @param {?string} syncStatus Optional sync status to filter pattern blocks by.
|
|
1949
1948
|
*
|
|
1950
1949
|
* @return {WPEditorInserterItem[]} Items that appear in inserter.
|
|
1951
1950
|
*
|
|
@@ -1962,11 +1961,7 @@ const buildBlockTypeItem =
|
|
|
1962
1961
|
* @property {number} frecency Heuristic that combines frequency and recency.
|
|
1963
1962
|
*/
|
|
1964
1963
|
export const getInserterItems = createSelector(
|
|
1965
|
-
( state, rootClientId = null
|
|
1966
|
-
const buildBlockTypeInserterItem = buildBlockTypeItem( state, {
|
|
1967
|
-
buildScope: 'inserter',
|
|
1968
|
-
} );
|
|
1969
|
-
|
|
1964
|
+
( state, rootClientId = null ) => {
|
|
1970
1965
|
/*
|
|
1971
1966
|
* Matches block comment delimiters amid serialized content.
|
|
1972
1967
|
*
|
|
@@ -2031,13 +2026,7 @@ export const getInserterItems = createSelector(
|
|
|
2031
2026
|
};
|
|
2032
2027
|
};
|
|
2033
2028
|
|
|
2034
|
-
const
|
|
2035
|
-
.filter( ( blockType ) =>
|
|
2036
|
-
canIncludeBlockTypeInInserter( state, blockType, rootClientId )
|
|
2037
|
-
)
|
|
2038
|
-
.map( buildBlockTypeInserterItem );
|
|
2039
|
-
|
|
2040
|
-
const reusableBlockInserterItems = canInsertBlockTypeUnmemoized(
|
|
2029
|
+
const syncedPatternInserterItems = canInsertBlockTypeUnmemoized(
|
|
2041
2030
|
state,
|
|
2042
2031
|
'core/block',
|
|
2043
2032
|
rootClientId
|
|
@@ -2045,13 +2034,27 @@ export const getInserterItems = createSelector(
|
|
|
2045
2034
|
? getReusableBlocks( state )
|
|
2046
2035
|
.filter(
|
|
2047
2036
|
( reusableBlock ) =>
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2037
|
+
// Reusable blocks that are fully synced should have no sync status set
|
|
2038
|
+
// for backwards compat between patterns and old reusable blocks, but
|
|
2039
|
+
// some in release 16.1 may have had sync status inadvertantly set to
|
|
2040
|
+
// 'fully' if created in the site editor.
|
|
2041
|
+
reusableBlock.wp_pattern_sync_status === 'fully' ||
|
|
2042
|
+
reusableBlock.wp_pattern_sync_status === '' ||
|
|
2043
|
+
! reusableBlock.wp_pattern_sync_status
|
|
2051
2044
|
)
|
|
2052
2045
|
.map( buildReusableBlockInserterItem )
|
|
2053
2046
|
: [];
|
|
2054
2047
|
|
|
2048
|
+
const buildBlockTypeInserterItem = buildBlockTypeItem( state, {
|
|
2049
|
+
buildScope: 'inserter',
|
|
2050
|
+
} );
|
|
2051
|
+
|
|
2052
|
+
const blockTypeInserterItems = getBlockTypes()
|
|
2053
|
+
.filter( ( blockType ) =>
|
|
2054
|
+
canIncludeBlockTypeInInserter( state, blockType, rootClientId )
|
|
2055
|
+
)
|
|
2056
|
+
.map( buildBlockTypeInserterItem );
|
|
2057
|
+
|
|
2055
2058
|
const items = blockTypeInserterItems.reduce( ( accumulator, item ) => {
|
|
2056
2059
|
const { variations = [] } = item;
|
|
2057
2060
|
// Exclude any block type item that is to be replaced by a default variation.
|
|
@@ -2082,7 +2085,7 @@ export const getInserterItems = createSelector(
|
|
|
2082
2085
|
{ core: [], noncore: [] }
|
|
2083
2086
|
);
|
|
2084
2087
|
const sortedBlockTypes = [ ...coreItems, ...nonCoreItems ];
|
|
2085
|
-
return [ ...sortedBlockTypes, ...
|
|
2088
|
+
return [ ...sortedBlockTypes, ...syncedPatternInserterItems ];
|
|
2086
2089
|
},
|
|
2087
2090
|
( state, rootClientId ) => [
|
|
2088
2091
|
state.blockListSettings[ rootClientId ],
|
|
@@ -2306,10 +2309,33 @@ const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {
|
|
|
2306
2309
|
return true;
|
|
2307
2310
|
};
|
|
2308
2311
|
|
|
2312
|
+
function getUnsyncedPatterns( state ) {
|
|
2313
|
+
const reusableBlocks =
|
|
2314
|
+
state?.settings?.__experimentalReusableBlocks ?? EMPTY_ARRAY;
|
|
2315
|
+
|
|
2316
|
+
return reusableBlocks
|
|
2317
|
+
.filter(
|
|
2318
|
+
( reusableBlock ) =>
|
|
2319
|
+
reusableBlock.wp_pattern_sync_status === 'unsynced'
|
|
2320
|
+
)
|
|
2321
|
+
.map( ( reusableBlock ) => {
|
|
2322
|
+
return {
|
|
2323
|
+
name: `core/block/${ reusableBlock.id }`,
|
|
2324
|
+
title: reusableBlock.title.raw,
|
|
2325
|
+
categories: [ 'custom' ],
|
|
2326
|
+
content: reusableBlock.content.raw,
|
|
2327
|
+
};
|
|
2328
|
+
} );
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2309
2331
|
export const __experimentalGetParsedPattern = createSelector(
|
|
2310
2332
|
( state, patternName ) => {
|
|
2311
2333
|
const patterns = state.settings.__experimentalBlockPatterns;
|
|
2312
|
-
const
|
|
2334
|
+
const unsyncedPatterns = getUnsyncedPatterns( state );
|
|
2335
|
+
|
|
2336
|
+
const pattern = [ ...patterns, ...unsyncedPatterns ].find(
|
|
2337
|
+
( { name } ) => name === patternName
|
|
2338
|
+
);
|
|
2313
2339
|
if ( ! pattern ) {
|
|
2314
2340
|
return null;
|
|
2315
2341
|
}
|
|
@@ -2320,14 +2346,20 @@ export const __experimentalGetParsedPattern = createSelector(
|
|
|
2320
2346
|
} ),
|
|
2321
2347
|
};
|
|
2322
2348
|
},
|
|
2323
|
-
( state ) => [
|
|
2349
|
+
( state ) => [
|
|
2350
|
+
state.settings.__experimentalBlockPatterns,
|
|
2351
|
+
state.settings.__experimentalReusableBlocks,
|
|
2352
|
+
]
|
|
2324
2353
|
);
|
|
2325
2354
|
|
|
2326
2355
|
const getAllAllowedPatterns = createSelector(
|
|
2327
2356
|
( state ) => {
|
|
2328
2357
|
const patterns = state.settings.__experimentalBlockPatterns;
|
|
2358
|
+
const unsyncedPatterns = getUnsyncedPatterns( state );
|
|
2359
|
+
|
|
2329
2360
|
const { allowedBlockTypes } = getSettings( state );
|
|
2330
|
-
|
|
2361
|
+
|
|
2362
|
+
const parsedPatterns = [ ...patterns, ...unsyncedPatterns ]
|
|
2331
2363
|
.filter( ( { inserter = true } ) => !! inserter )
|
|
2332
2364
|
.map( ( { name } ) =>
|
|
2333
2365
|
__experimentalGetParsedPattern( state, name )
|
|
@@ -2339,6 +2371,7 @@ const getAllAllowedPatterns = createSelector(
|
|
|
2339
2371
|
},
|
|
2340
2372
|
( state ) => [
|
|
2341
2373
|
state.settings.__experimentalBlockPatterns,
|
|
2374
|
+
state.settings.__experimentalReusableBlocks,
|
|
2342
2375
|
state.settings.allowedBlockTypes,
|
|
2343
2376
|
]
|
|
2344
2377
|
);
|
|
@@ -2365,6 +2398,7 @@ export const __experimentalGetAllowedPatterns = createSelector(
|
|
|
2365
2398
|
},
|
|
2366
2399
|
( state, rootClientId ) => [
|
|
2367
2400
|
state.settings.__experimentalBlockPatterns,
|
|
2401
|
+
state.settings.__experimentalReusableBlocks,
|
|
2368
2402
|
state.settings.allowedBlockTypes,
|
|
2369
2403
|
state.settings.templateLock,
|
|
2370
2404
|
state.blockListSettings[ rootClientId ],
|
|
@@ -53,6 +53,7 @@ const {
|
|
|
53
53
|
updateBlockListSettings,
|
|
54
54
|
updateSettings,
|
|
55
55
|
validateBlocksToTemplate,
|
|
56
|
+
registerInserterMediaCategory,
|
|
56
57
|
} = actions;
|
|
57
58
|
|
|
58
59
|
describe( 'actions', () => {
|
|
@@ -617,6 +618,7 @@ describe( 'actions', () => {
|
|
|
617
618
|
const select = {
|
|
618
619
|
getBlockRootClientId: () => undefined,
|
|
619
620
|
canRemoveBlocks: () => true,
|
|
621
|
+
getBlockRemovalRules: () => false,
|
|
620
622
|
};
|
|
621
623
|
const dispatch = Object.assign( jest.fn(), {
|
|
622
624
|
selectPreviousBlock: jest.fn(),
|
|
@@ -727,6 +729,7 @@ describe( 'actions', () => {
|
|
|
727
729
|
const select = {
|
|
728
730
|
getBlockRootClientId: () => null,
|
|
729
731
|
canRemoveBlocks: () => true,
|
|
732
|
+
getBlockRemovalRules: () => false,
|
|
730
733
|
};
|
|
731
734
|
const dispatch = Object.assign( jest.fn(), {
|
|
732
735
|
selectPreviousBlock: jest.fn(),
|
|
@@ -751,6 +754,7 @@ describe( 'actions', () => {
|
|
|
751
754
|
const select = {
|
|
752
755
|
getBlockRootClientId: () => null,
|
|
753
756
|
canRemoveBlocks: () => true,
|
|
757
|
+
getBlockRemovalRules: () => false,
|
|
754
758
|
};
|
|
755
759
|
const dispatch = Object.assign( jest.fn(), {
|
|
756
760
|
selectPreviousBlock: jest.fn(),
|
|
@@ -1209,4 +1213,111 @@ describe( 'actions', () => {
|
|
|
1209
1213
|
expect( result ).toEqual( false );
|
|
1210
1214
|
} );
|
|
1211
1215
|
} );
|
|
1216
|
+
|
|
1217
|
+
describe( 'registerInserterMediaCategory', () => {
|
|
1218
|
+
describe( 'should log errors when invalid', () => {
|
|
1219
|
+
it( 'valid object', () => {
|
|
1220
|
+
registerInserterMediaCategory()( {} );
|
|
1221
|
+
expect( console ).toHaveErroredWith(
|
|
1222
|
+
'Category should be an `InserterMediaCategory` object.'
|
|
1223
|
+
);
|
|
1224
|
+
} );
|
|
1225
|
+
it( 'has name', () => {
|
|
1226
|
+
registerInserterMediaCategory( {} )( {} );
|
|
1227
|
+
expect( console ).toHaveErroredWith(
|
|
1228
|
+
'Category should have a `name` that should be unique among all media categories.'
|
|
1229
|
+
);
|
|
1230
|
+
} );
|
|
1231
|
+
it( 'has labels.name', () => {
|
|
1232
|
+
registerInserterMediaCategory( { name: 'a' } )( {} );
|
|
1233
|
+
expect( console ).toHaveErroredWith(
|
|
1234
|
+
'Category should have a `labels.name`.'
|
|
1235
|
+
);
|
|
1236
|
+
} );
|
|
1237
|
+
it( 'has proper media type', () => {
|
|
1238
|
+
registerInserterMediaCategory( {
|
|
1239
|
+
name: 'a',
|
|
1240
|
+
labels: { name: 'a' },
|
|
1241
|
+
mediaType: 'b',
|
|
1242
|
+
} )( {} );
|
|
1243
|
+
expect( console ).toHaveErroredWith(
|
|
1244
|
+
'Category should have `mediaType` property that is one of `image|audio|video`.'
|
|
1245
|
+
);
|
|
1246
|
+
} );
|
|
1247
|
+
it( 'has fetch function', () => {
|
|
1248
|
+
registerInserterMediaCategory( {
|
|
1249
|
+
name: 'a',
|
|
1250
|
+
labels: { name: 'a' },
|
|
1251
|
+
mediaType: 'image',
|
|
1252
|
+
fetch: 'c',
|
|
1253
|
+
} )( {} );
|
|
1254
|
+
expect( console ).toHaveErroredWith(
|
|
1255
|
+
'Category should have a `fetch` function defined with the following signature `(InserterMediaRequest) => Promise<InserterMediaItem[]>`.'
|
|
1256
|
+
);
|
|
1257
|
+
} );
|
|
1258
|
+
it( 'has unique name', () => {
|
|
1259
|
+
registerInserterMediaCategory( {
|
|
1260
|
+
name: 'a',
|
|
1261
|
+
labels: { name: 'a' },
|
|
1262
|
+
mediaType: 'image',
|
|
1263
|
+
fetch: () => {},
|
|
1264
|
+
} )( {
|
|
1265
|
+
select: {
|
|
1266
|
+
getSettings: () => ( {
|
|
1267
|
+
inserterMediaCategories: [ { name: 'a' } ],
|
|
1268
|
+
} ),
|
|
1269
|
+
},
|
|
1270
|
+
} );
|
|
1271
|
+
expect( console ).toHaveErroredWith(
|
|
1272
|
+
'A category is already registered with the same name: "a".'
|
|
1273
|
+
);
|
|
1274
|
+
} );
|
|
1275
|
+
it( 'has unique labels.name', () => {
|
|
1276
|
+
registerInserterMediaCategory( {
|
|
1277
|
+
name: 'a',
|
|
1278
|
+
labels: { name: 'a' },
|
|
1279
|
+
mediaType: 'image',
|
|
1280
|
+
fetch: () => {},
|
|
1281
|
+
} )( {
|
|
1282
|
+
select: {
|
|
1283
|
+
getSettings: () => ( {
|
|
1284
|
+
inserterMediaCategories: [
|
|
1285
|
+
{ labels: { name: 'a' } },
|
|
1286
|
+
],
|
|
1287
|
+
} ),
|
|
1288
|
+
},
|
|
1289
|
+
} );
|
|
1290
|
+
expect( console ).toHaveErroredWith(
|
|
1291
|
+
'A category is already registered with the same labels.name: "a".'
|
|
1292
|
+
);
|
|
1293
|
+
} );
|
|
1294
|
+
} );
|
|
1295
|
+
it( 'should register a media category', () => {
|
|
1296
|
+
const category = {
|
|
1297
|
+
name: 'new',
|
|
1298
|
+
labels: { name: 'new' },
|
|
1299
|
+
mediaType: 'image',
|
|
1300
|
+
fetch: () => {},
|
|
1301
|
+
};
|
|
1302
|
+
const inserterMediaCategories = [
|
|
1303
|
+
{ name: 'a', labels: { name: 'a' } },
|
|
1304
|
+
];
|
|
1305
|
+
const dispatch = jest.fn();
|
|
1306
|
+
registerInserterMediaCategory( category )( {
|
|
1307
|
+
select: {
|
|
1308
|
+
getSettings: () => ( { inserterMediaCategories } ),
|
|
1309
|
+
},
|
|
1310
|
+
dispatch,
|
|
1311
|
+
} );
|
|
1312
|
+
expect( dispatch ).toHaveBeenLastCalledWith( {
|
|
1313
|
+
type: 'UPDATE_SETTINGS',
|
|
1314
|
+
settings: {
|
|
1315
|
+
inserterMediaCategories: [
|
|
1316
|
+
...inserterMediaCategories,
|
|
1317
|
+
{ ...category, isExternalResource: true },
|
|
1318
|
+
],
|
|
1319
|
+
},
|
|
1320
|
+
} );
|
|
1321
|
+
} );
|
|
1322
|
+
} );
|
|
1212
1323
|
} );
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
showBlockInterface,
|
|
7
7
|
setBlockEditingMode,
|
|
8
8
|
unsetBlockEditingMode,
|
|
9
|
+
__experimentalUpdateSettings,
|
|
9
10
|
} from '../private-actions';
|
|
10
11
|
|
|
11
12
|
describe( 'private actions', () => {
|
|
@@ -50,4 +51,59 @@ describe( 'private actions', () => {
|
|
|
50
51
|
} );
|
|
51
52
|
} );
|
|
52
53
|
} );
|
|
54
|
+
|
|
55
|
+
describe( '__experimentalUpdateSettings', () => {
|
|
56
|
+
const experimentalSettings = {
|
|
57
|
+
inserterMediaCategories: 'foo',
|
|
58
|
+
blockInspectorAnimation: 'bar',
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const stableSettings = {
|
|
62
|
+
foo: 'foo',
|
|
63
|
+
bar: 'bar',
|
|
64
|
+
baz: 'baz',
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const settings = {
|
|
68
|
+
...experimentalSettings,
|
|
69
|
+
...stableSettings,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
it( 'should dispatch provided settings by default', () => {
|
|
73
|
+
expect( __experimentalUpdateSettings( settings ) ).toEqual( {
|
|
74
|
+
type: 'UPDATE_SETTINGS',
|
|
75
|
+
settings,
|
|
76
|
+
reset: false,
|
|
77
|
+
} );
|
|
78
|
+
} );
|
|
79
|
+
|
|
80
|
+
it( 'should dispatch provided settings with reset flag when `reset` argument is truthy', () => {
|
|
81
|
+
expect(
|
|
82
|
+
__experimentalUpdateSettings( settings, {
|
|
83
|
+
stripExperimentalSettings: false,
|
|
84
|
+
reset: true,
|
|
85
|
+
} )
|
|
86
|
+
).toEqual( {
|
|
87
|
+
type: 'UPDATE_SETTINGS',
|
|
88
|
+
settings,
|
|
89
|
+
reset: true,
|
|
90
|
+
} );
|
|
91
|
+
} );
|
|
92
|
+
|
|
93
|
+
it( 'should strip experimental settings from a given settings object when `stripExperimentalSettings` argument is truthy', () => {
|
|
94
|
+
expect(
|
|
95
|
+
__experimentalUpdateSettings( settings, {
|
|
96
|
+
stripExperimentalSettings: true,
|
|
97
|
+
} )
|
|
98
|
+
).toEqual( {
|
|
99
|
+
type: 'UPDATE_SETTINGS',
|
|
100
|
+
settings: {
|
|
101
|
+
foo: 'foo',
|
|
102
|
+
bar: 'bar',
|
|
103
|
+
baz: 'baz',
|
|
104
|
+
},
|
|
105
|
+
reset: false,
|
|
106
|
+
} );
|
|
107
|
+
} );
|
|
108
|
+
} );
|
|
53
109
|
} );
|