@wordpress/block-editor 12.4.0 → 12.6.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 +4 -0
- package/README.md +1 -0
- package/build/components/block-draggable/index.js +6 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-draggable/index.native.js +2 -2
- package/build/components/block-draggable/index.native.js.map +1 -1
- package/build/components/block-edit/edit.js +25 -13
- package/build/components/block-edit/edit.js.map +1 -1
- 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-list/block-outline.native.js +14 -18
- package/build/components/block-list/block-outline.native.js.map +1 -1
- package/build/components/block-list/block.native.js +21 -42
- package/build/components/block-list/block.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-mover/index.native.js +1 -1
- package/build/components/block-mover/index.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 +15 -25
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-settings/button.native.js +2 -2
- package/build/components/block-settings/button.native.js.map +1 -1
- package/build/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +10 -11
- package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -0
- package/build/components/block-toolbar/index.js +12 -8
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/index.native.js +62 -3
- package/build/components/block-toolbar/index.native.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/colors-gradients/control.js +4 -2
- package/build/components/colors-gradients/control.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 +22 -16
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +13 -2
- package/build/components/global-styles/dimensions-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/get-block-css-selector.js +4 -8
- package/build/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build/components/global-styles/hooks.js +15 -25
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +52 -5
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +12 -18
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +6 -6
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/iframe/index.js +36 -48
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/iframe/use-compatibility-styles.js +5 -0
- package/build/components/iframe/use-compatibility-styles.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 +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +3 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +3 -1
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +33 -7
- package/build/components/inner-blocks/use-nested-settings-update.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/index.js +2 -4
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +21 -32
- package/build/components/inserter/index.native.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 +82 -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 +21 -16
- 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/list-view/use-list-view-client-ids.js +2 -2
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/media-placeholder/index.native.js +65 -31
- package/build/components/media-placeholder/index.native.js.map +1 -1
- package/build/components/preview-options/index.js +2 -2
- package/build/components/preview-options/index.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/rich-text/content.js +0 -36
- package/build/components/rich-text/content.js.map +1 -1
- package/build/components/rich-text/get-rich-text-values.js +118 -0
- package/build/components/rich-text/get-rich-text-values.js.map +1 -0
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/axial.js +6 -2
- package/build/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/separated.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/single.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/single.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +1 -1
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/url-input/index.js +4 -2
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-display-information/index.js +7 -3
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.native.js +49 -8
- package/build/components/use-block-drop-zone/index.native.js.map +1 -1
- package/build/components/use-setting/index.js +5 -9
- package/build/components/use-setting/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/margin.js +1 -1
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +1 -1
- package/build/hooks/padding.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 +5 -9
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +16 -3
- 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 +196 -2
- 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 +8 -9
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +22 -9
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +52 -23
- package/build/store/selectors.js.map +1 -1
- package/build/utils/object.js +38 -2
- package/build/utils/object.js.map +1 -1
- package/build-module/components/block-draggable/index.js +6 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +2 -2
- package/build-module/components/block-draggable/index.native.js.map +1 -1
- package/build-module/components/block-edit/edit.js +27 -10
- package/build-module/components/block-edit/edit.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-list/block-outline.native.js +14 -18
- package/build-module/components/block-list/block-outline.native.js.map +1 -1
- package/build-module/components/block-list/block.native.js +24 -43
- package/build-module/components/block-list/block.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-mover/index.native.js +3 -3
- package/build-module/components/block-mover/index.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 +17 -24
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-settings/button.native.js +3 -3
- package/build-module/components/block-settings/button.native.js.map +1 -1
- package/build-module/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +13 -13
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -0
- package/build-module/components/block-toolbar/index.js +12 -8
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.native.js +60 -4
- package/build-module/components/block-toolbar/index.native.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/colors-gradients/control.js +3 -2
- package/build-module/components/colors-gradients/control.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 +22 -16
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +13 -2
- package/build-module/components/global-styles/dimensions-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/get-block-css-selector.js +4 -8
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +14 -24
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +51 -5
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +13 -18
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +5 -5
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +37 -49
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/iframe/use-compatibility-styles.js +5 -0
- package/build-module/components/iframe/use-compatibility-styles.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 +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +3 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +3 -1
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +30 -7
- package/build-module/components/inner-blocks/use-nested-settings-update.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/index.js +2 -4
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +22 -33
- package/build-module/components/inserter/index.native.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 +67 -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 +21 -16
- 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/list-view/use-list-view-client-ids.js +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/media-placeholder/index.native.js +66 -33
- package/build-module/components/media-placeholder/index.native.js.map +1 -1
- package/build-module/components/preview-options/index.js +2 -2
- package/build-module/components/preview-options/index.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/rich-text/content.js +1 -36
- package/build-module/components/rich-text/content.js.map +1 -1
- package/build-module/components/rich-text/get-rich-text-values.js +105 -0
- package/build-module/components/rich-text/get-rich-text-values.js.map +1 -0
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/axial.js +7 -3
- package/build-module/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/separated.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/single.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls/single.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +1 -1
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- 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/use-block-display-information/index.js +7 -3
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.native.js +50 -8
- package/build-module/components/use-block-drop-zone/index.native.js.map +1 -1
- package/build-module/components/use-setting/index.js +5 -9
- package/build-module/components/use-setting/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/margin.js +1 -1
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +1 -1
- package/build-module/hooks/padding.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 +6 -9
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +11 -2
- 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 +193 -3
- 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 +5 -5
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +22 -9
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +49 -21
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/object.js +34 -2
- package/build-module/utils/object.js.map +1 -1
- package/build-style/content-rtl.css +4 -0
- package/build-style/content.css +4 -0
- package/build-style/style-rtl.css +137 -129
- package/build-style/style.css +137 -129
- package/package.json +33 -32
- 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-controls/README.md +89 -0
- package/src/components/block-draggable/index.js +13 -4
- package/src/components/block-draggable/index.native.js +7 -3
- package/src/components/block-draggable/style.scss +1 -0
- package/src/components/block-draggable/test/index.native.js +0 -54
- package/src/components/block-edit/edit.js +26 -9
- package/src/components/block-edit/test/edit.js +1 -1
- 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-list/block-outline.native.js +26 -25
- package/src/components/block-list/block.native.js +24 -38
- package/src/components/block-list/block.native.scss +18 -40
- package/src/components/block-list/style.native.scss +3 -3
- package/src/components/block-lock/toolbar.js +34 -6
- package/src/components/block-mover/index.native.js +3 -3
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +16 -6
- package/src/components/block-parent-selector/index.js +13 -8
- package/src/components/block-removal-warning-modal/index.js +17 -33
- package/src/components/block-settings/button.native.js +12 -6
- package/src/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +19 -18
- package/src/components/block-toolbar/index.js +11 -9
- package/src/components/block-toolbar/index.native.js +86 -6
- package/src/components/{block-mobile-toolbar/test/block-actions-menu.native.js → block-toolbar/test/block-toolbar-menu.native.js} +20 -54
- package/src/components/block-toolbar/test/index.native.js +42 -0
- package/src/components/block-tools/block-contextual-toolbar.js +5 -11
- package/src/components/block-tools/style.scss +73 -26
- package/src/components/button-block-appender/styles.native.scss +2 -2
- package/src/components/caption/README.md +49 -0
- package/src/components/colors-gradients/control.js +3 -2
- 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 +24 -17
- package/src/components/global-styles/dimensions-panel.js +8 -2
- package/src/components/global-styles/filters-panel.js +2 -2
- package/src/components/global-styles/get-block-css-selector.js +5 -9
- package/src/components/global-styles/hooks.js +22 -26
- package/src/components/global-styles/typography-panel.js +57 -5
- package/src/components/global-styles/use-global-styles-output.js +36 -18
- package/src/components/global-styles/utils.js +15 -6
- package/src/components/iframe/index.js +30 -56
- package/src/components/iframe/use-compatibility-styles.js +5 -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 +1 -0
- package/src/components/inner-blocks/README.md +10 -0
- package/src/components/inner-blocks/index.js +4 -0
- package/src/components/inner-blocks/index.native.js +4 -0
- package/src/components/inner-blocks/use-nested-settings-update.js +32 -5
- 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/index.js +2 -3
- package/src/components/inserter/index.native.js +17 -36
- package/src/components/inserter/media-tab/hooks.js +2 -22
- package/src/components/inserter/reusable-block-rename-hint.js +69 -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.native.scss +10 -15
- 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 +36 -29
- 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 +58 -123
- package/src/components/link-control/test/index.js +161 -123
- package/src/components/list-view/appender.js +5 -6
- package/src/components/list-view/style.scss +1 -2
- package/src/components/list-view/use-list-view-client-ids.js +2 -2
- package/src/components/media-placeholder/index.native.js +108 -59
- package/src/components/media-placeholder/styles.native.scss +59 -24
- package/src/components/media-replace-flow/test/index.js +1 -1
- package/src/components/panel-color-settings/README.md +98 -0
- package/src/components/preview-options/README.md +18 -17
- package/src/components/preview-options/index.js +2 -2
- 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/rich-text/content.js +1 -46
- package/src/components/rich-text/get-rich-text-values.js +105 -0
- package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/src/components/spacing-sizes-control/input-controls/axial.js +17 -2
- package/src/components/spacing-sizes-control/input-controls/separated.js +17 -2
- package/src/components/spacing-sizes-control/input-controls/single.js +12 -2
- package/src/components/spacing-sizes-control/utils.js +1 -1
- package/src/components/text-transform-control/README.md +44 -0
- package/src/components/url-input/index.js +2 -0
- package/src/components/use-block-display-information/index.js +12 -5
- package/src/components/use-block-drop-zone/index.native.js +65 -28
- package/src/components/use-setting/index.js +8 -8
- 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/margin.js +4 -1
- package/src/hooks/padding.js +4 -1
- package/src/hooks/supports.js +7 -0
- package/src/hooks/typography.js +2 -0
- package/src/hooks/utils.js +8 -7
- package/src/private-apis.js +13 -1
- package/src/private-apis.native.js +2 -0
- package/src/store/actions.js +195 -3
- 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 +5 -8
- package/src/store/reducer.js +22 -9
- package/src/store/selectors.js +87 -25
- package/src/store/test/actions.js +114 -0
- package/src/store/test/private-actions.js +56 -0
- package/src/store/test/private-selectors.js +5 -5
- package/src/store/test/reducer.js +14 -7
- package/src/store/test/selectors.js +1 -1
- package/src/utils/object.js +32 -2
- package/src/utils/test/object.js +36 -0
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +0 -1
- package/build/components/block-mobile-toolbar/index.native.js +0 -135
- package/build/components/block-mobile-toolbar/index.native.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +0 -116
- package/build-module/components/block-mobile-toolbar/index.native.js.map +0 -1
- package/src/components/block-mobile-toolbar/index.native.js +0 -127
- package/src/components/block-mobile-toolbar/style.native.scss +0 -16
- /package/src/components/{block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap → block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap} +0 -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
|
*
|
|
@@ -2023,7 +2018,7 @@ export const getInserterItems = createSelector(
|
|
|
2023
2018
|
title: reusableBlock.title.raw,
|
|
2024
2019
|
icon,
|
|
2025
2020
|
category: 'reusable',
|
|
2026
|
-
keywords: [],
|
|
2021
|
+
keywords: [ 'reusable' ],
|
|
2027
2022
|
isDisabled: false,
|
|
2028
2023
|
utility: 1, // Deprecated.
|
|
2029
2024
|
frecency,
|
|
@@ -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 ],
|
|
@@ -2211,15 +2214,24 @@ export const getAllowedBlocks = createSelector(
|
|
|
2211
2214
|
return;
|
|
2212
2215
|
}
|
|
2213
2216
|
|
|
2214
|
-
|
|
2217
|
+
const blockTypes = getBlockTypes().filter( ( blockType ) =>
|
|
2215
2218
|
canIncludeBlockTypeInInserter( state, blockType, rootClientId )
|
|
2216
2219
|
);
|
|
2220
|
+
const hasReusableBlock =
|
|
2221
|
+
canInsertBlockTypeUnmemoized( state, 'core/block', rootClientId ) &&
|
|
2222
|
+
getReusableBlocks( state ).length > 0;
|
|
2223
|
+
|
|
2224
|
+
return [
|
|
2225
|
+
...blockTypes,
|
|
2226
|
+
...( hasReusableBlock ? [ 'core/block' ] : [] ),
|
|
2227
|
+
];
|
|
2217
2228
|
},
|
|
2218
2229
|
( state, rootClientId ) => [
|
|
2219
2230
|
state.blockListSettings[ rootClientId ],
|
|
2220
2231
|
state.blocks.byClientId,
|
|
2221
2232
|
state.settings.allowedBlockTypes,
|
|
2222
2233
|
state.settings.templateLock,
|
|
2234
|
+
getReusableBlocks( state ),
|
|
2223
2235
|
getBlockTypes(),
|
|
2224
2236
|
]
|
|
2225
2237
|
);
|
|
@@ -2255,15 +2267,15 @@ export const __experimentalGetAllowedBlocks = createSelector(
|
|
|
2255
2267
|
* @property {?Object} attributes Attributes to pass to the newly created block.
|
|
2256
2268
|
* @property {?Array<string>} attributesToCopy Attributes to be copied from adjecent blocks when inserted.
|
|
2257
2269
|
*/
|
|
2258
|
-
export const
|
|
2270
|
+
export const getDirectInsertBlock = createSelector(
|
|
2259
2271
|
( state, rootClientId = null ) => {
|
|
2260
2272
|
if ( ! rootClientId ) {
|
|
2261
2273
|
return;
|
|
2262
2274
|
}
|
|
2263
2275
|
const defaultBlock =
|
|
2264
|
-
state.blockListSettings[ rootClientId ]?.
|
|
2276
|
+
state.blockListSettings[ rootClientId ]?.defaultBlock;
|
|
2265
2277
|
const directInsert =
|
|
2266
|
-
state.blockListSettings[ rootClientId ]?.
|
|
2278
|
+
state.blockListSettings[ rootClientId ]?.directInsert;
|
|
2267
2279
|
if ( ! defaultBlock || ! directInsert ) {
|
|
2268
2280
|
return;
|
|
2269
2281
|
}
|
|
@@ -2280,6 +2292,25 @@ export const __experimentalGetDirectInsertBlock = createSelector(
|
|
|
2280
2292
|
]
|
|
2281
2293
|
);
|
|
2282
2294
|
|
|
2295
|
+
export const __experimentalGetDirectInsertBlock = createSelector(
|
|
2296
|
+
( state, rootClientId = null ) => {
|
|
2297
|
+
deprecated(
|
|
2298
|
+
'wp.data.select( "core/block-editor" ).__experimentalGetDirectInsertBlock',
|
|
2299
|
+
{
|
|
2300
|
+
alternative:
|
|
2301
|
+
'wp.data.select( "core/block-editor" ).getDirectInsertBlock',
|
|
2302
|
+
since: '6.3',
|
|
2303
|
+
version: '6.4',
|
|
2304
|
+
}
|
|
2305
|
+
);
|
|
2306
|
+
return getDirectInsertBlock( state, rootClientId );
|
|
2307
|
+
},
|
|
2308
|
+
( state, rootClientId ) => [
|
|
2309
|
+
state.blockListSettings[ rootClientId ],
|
|
2310
|
+
state.blocks.tree.get( rootClientId ),
|
|
2311
|
+
]
|
|
2312
|
+
);
|
|
2313
|
+
|
|
2283
2314
|
const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {
|
|
2284
2315
|
if ( typeof allowedBlockTypes === 'boolean' ) {
|
|
2285
2316
|
return allowedBlockTypes;
|
|
@@ -2306,10 +2337,33 @@ const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {
|
|
|
2306
2337
|
return true;
|
|
2307
2338
|
};
|
|
2308
2339
|
|
|
2340
|
+
function getUnsyncedPatterns( state ) {
|
|
2341
|
+
const reusableBlocks =
|
|
2342
|
+
state?.settings?.__experimentalReusableBlocks ?? EMPTY_ARRAY;
|
|
2343
|
+
|
|
2344
|
+
return reusableBlocks
|
|
2345
|
+
.filter(
|
|
2346
|
+
( reusableBlock ) =>
|
|
2347
|
+
reusableBlock.wp_pattern_sync_status === 'unsynced'
|
|
2348
|
+
)
|
|
2349
|
+
.map( ( reusableBlock ) => {
|
|
2350
|
+
return {
|
|
2351
|
+
name: `core/block/${ reusableBlock.id }`,
|
|
2352
|
+
title: reusableBlock.title.raw,
|
|
2353
|
+
categories: [ 'custom' ],
|
|
2354
|
+
content: reusableBlock.content.raw,
|
|
2355
|
+
};
|
|
2356
|
+
} );
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2309
2359
|
export const __experimentalGetParsedPattern = createSelector(
|
|
2310
2360
|
( state, patternName ) => {
|
|
2311
2361
|
const patterns = state.settings.__experimentalBlockPatterns;
|
|
2312
|
-
const
|
|
2362
|
+
const unsyncedPatterns = getUnsyncedPatterns( state );
|
|
2363
|
+
|
|
2364
|
+
const pattern = [ ...patterns, ...unsyncedPatterns ].find(
|
|
2365
|
+
( { name } ) => name === patternName
|
|
2366
|
+
);
|
|
2313
2367
|
if ( ! pattern ) {
|
|
2314
2368
|
return null;
|
|
2315
2369
|
}
|
|
@@ -2320,14 +2374,20 @@ export const __experimentalGetParsedPattern = createSelector(
|
|
|
2320
2374
|
} ),
|
|
2321
2375
|
};
|
|
2322
2376
|
},
|
|
2323
|
-
( state ) => [
|
|
2377
|
+
( state ) => [
|
|
2378
|
+
state.settings.__experimentalBlockPatterns,
|
|
2379
|
+
state.settings.__experimentalReusableBlocks,
|
|
2380
|
+
]
|
|
2324
2381
|
);
|
|
2325
2382
|
|
|
2326
2383
|
const getAllAllowedPatterns = createSelector(
|
|
2327
2384
|
( state ) => {
|
|
2328
2385
|
const patterns = state.settings.__experimentalBlockPatterns;
|
|
2386
|
+
const unsyncedPatterns = getUnsyncedPatterns( state );
|
|
2387
|
+
|
|
2329
2388
|
const { allowedBlockTypes } = getSettings( state );
|
|
2330
|
-
|
|
2389
|
+
|
|
2390
|
+
const parsedPatterns = [ ...patterns, ...unsyncedPatterns ]
|
|
2331
2391
|
.filter( ( { inserter = true } ) => !! inserter )
|
|
2332
2392
|
.map( ( { name } ) =>
|
|
2333
2393
|
__experimentalGetParsedPattern( state, name )
|
|
@@ -2339,6 +2399,7 @@ const getAllAllowedPatterns = createSelector(
|
|
|
2339
2399
|
},
|
|
2340
2400
|
( state ) => [
|
|
2341
2401
|
state.settings.__experimentalBlockPatterns,
|
|
2402
|
+
state.settings.__experimentalReusableBlocks,
|
|
2342
2403
|
state.settings.allowedBlockTypes,
|
|
2343
2404
|
]
|
|
2344
2405
|
);
|
|
@@ -2365,6 +2426,7 @@ export const __experimentalGetAllowedPatterns = createSelector(
|
|
|
2365
2426
|
},
|
|
2366
2427
|
( state, rootClientId ) => [
|
|
2367
2428
|
state.settings.__experimentalBlockPatterns,
|
|
2429
|
+
state.settings.__experimentalReusableBlocks,
|
|
2368
2430
|
state.settings.allowedBlockTypes,
|
|
2369
2431
|
state.settings.templateLock,
|
|
2370
2432
|
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', () => {
|
|
@@ -215,6 +216,7 @@ describe( 'actions', () => {
|
|
|
215
216
|
getBlockCount: () => 1,
|
|
216
217
|
};
|
|
217
218
|
const dispatch = jest.fn();
|
|
219
|
+
dispatch.ensureDefaultBlock = jest.fn();
|
|
218
220
|
|
|
219
221
|
replaceBlock( 'chicken', block )( { select, dispatch } );
|
|
220
222
|
|
|
@@ -280,6 +282,7 @@ describe( 'actions', () => {
|
|
|
280
282
|
getBlockCount: () => 1,
|
|
281
283
|
};
|
|
282
284
|
const dispatch = jest.fn();
|
|
285
|
+
dispatch.ensureDefaultBlock = jest.fn();
|
|
283
286
|
|
|
284
287
|
replaceBlocks( [ 'chicken' ], blocks )( { select, dispatch } );
|
|
285
288
|
|
|
@@ -313,6 +316,7 @@ describe( 'actions', () => {
|
|
|
313
316
|
getBlockCount: () => 1,
|
|
314
317
|
};
|
|
315
318
|
const dispatch = jest.fn();
|
|
319
|
+
dispatch.ensureDefaultBlock = jest.fn();
|
|
316
320
|
|
|
317
321
|
replaceBlocks(
|
|
318
322
|
[ 'chicken' ],
|
|
@@ -617,6 +621,7 @@ describe( 'actions', () => {
|
|
|
617
621
|
const select = {
|
|
618
622
|
getBlockRootClientId: () => undefined,
|
|
619
623
|
canRemoveBlocks: () => true,
|
|
624
|
+
getBlockRemovalRules: () => false,
|
|
620
625
|
};
|
|
621
626
|
const dispatch = Object.assign( jest.fn(), {
|
|
622
627
|
selectPreviousBlock: jest.fn(),
|
|
@@ -727,6 +732,7 @@ describe( 'actions', () => {
|
|
|
727
732
|
const select = {
|
|
728
733
|
getBlockRootClientId: () => null,
|
|
729
734
|
canRemoveBlocks: () => true,
|
|
735
|
+
getBlockRemovalRules: () => false,
|
|
730
736
|
};
|
|
731
737
|
const dispatch = Object.assign( jest.fn(), {
|
|
732
738
|
selectPreviousBlock: jest.fn(),
|
|
@@ -751,6 +757,7 @@ describe( 'actions', () => {
|
|
|
751
757
|
const select = {
|
|
752
758
|
getBlockRootClientId: () => null,
|
|
753
759
|
canRemoveBlocks: () => true,
|
|
760
|
+
getBlockRemovalRules: () => false,
|
|
754
761
|
};
|
|
755
762
|
const dispatch = Object.assign( jest.fn(), {
|
|
756
763
|
selectPreviousBlock: jest.fn(),
|
|
@@ -1209,4 +1216,111 @@ describe( 'actions', () => {
|
|
|
1209
1216
|
expect( result ).toEqual( false );
|
|
1210
1217
|
} );
|
|
1211
1218
|
} );
|
|
1219
|
+
|
|
1220
|
+
describe( 'registerInserterMediaCategory', () => {
|
|
1221
|
+
describe( 'should log errors when invalid', () => {
|
|
1222
|
+
it( 'valid object', () => {
|
|
1223
|
+
registerInserterMediaCategory()( {} );
|
|
1224
|
+
expect( console ).toHaveErroredWith(
|
|
1225
|
+
'Category should be an `InserterMediaCategory` object.'
|
|
1226
|
+
);
|
|
1227
|
+
} );
|
|
1228
|
+
it( 'has name', () => {
|
|
1229
|
+
registerInserterMediaCategory( {} )( {} );
|
|
1230
|
+
expect( console ).toHaveErroredWith(
|
|
1231
|
+
'Category should have a `name` that should be unique among all media categories.'
|
|
1232
|
+
);
|
|
1233
|
+
} );
|
|
1234
|
+
it( 'has labels.name', () => {
|
|
1235
|
+
registerInserterMediaCategory( { name: 'a' } )( {} );
|
|
1236
|
+
expect( console ).toHaveErroredWith(
|
|
1237
|
+
'Category should have a `labels.name`.'
|
|
1238
|
+
);
|
|
1239
|
+
} );
|
|
1240
|
+
it( 'has proper media type', () => {
|
|
1241
|
+
registerInserterMediaCategory( {
|
|
1242
|
+
name: 'a',
|
|
1243
|
+
labels: { name: 'a' },
|
|
1244
|
+
mediaType: 'b',
|
|
1245
|
+
} )( {} );
|
|
1246
|
+
expect( console ).toHaveErroredWith(
|
|
1247
|
+
'Category should have `mediaType` property that is one of `image|audio|video`.'
|
|
1248
|
+
);
|
|
1249
|
+
} );
|
|
1250
|
+
it( 'has fetch function', () => {
|
|
1251
|
+
registerInserterMediaCategory( {
|
|
1252
|
+
name: 'a',
|
|
1253
|
+
labels: { name: 'a' },
|
|
1254
|
+
mediaType: 'image',
|
|
1255
|
+
fetch: 'c',
|
|
1256
|
+
} )( {} );
|
|
1257
|
+
expect( console ).toHaveErroredWith(
|
|
1258
|
+
'Category should have a `fetch` function defined with the following signature `(InserterMediaRequest) => Promise<InserterMediaItem[]>`.'
|
|
1259
|
+
);
|
|
1260
|
+
} );
|
|
1261
|
+
it( 'has unique name', () => {
|
|
1262
|
+
registerInserterMediaCategory( {
|
|
1263
|
+
name: 'a',
|
|
1264
|
+
labels: { name: 'a' },
|
|
1265
|
+
mediaType: 'image',
|
|
1266
|
+
fetch: () => {},
|
|
1267
|
+
} )( {
|
|
1268
|
+
select: {
|
|
1269
|
+
getSettings: () => ( {
|
|
1270
|
+
inserterMediaCategories: [ { name: 'a' } ],
|
|
1271
|
+
} ),
|
|
1272
|
+
},
|
|
1273
|
+
} );
|
|
1274
|
+
expect( console ).toHaveErroredWith(
|
|
1275
|
+
'A category is already registered with the same name: "a".'
|
|
1276
|
+
);
|
|
1277
|
+
} );
|
|
1278
|
+
it( 'has unique labels.name', () => {
|
|
1279
|
+
registerInserterMediaCategory( {
|
|
1280
|
+
name: 'a',
|
|
1281
|
+
labels: { name: 'a' },
|
|
1282
|
+
mediaType: 'image',
|
|
1283
|
+
fetch: () => {},
|
|
1284
|
+
} )( {
|
|
1285
|
+
select: {
|
|
1286
|
+
getSettings: () => ( {
|
|
1287
|
+
inserterMediaCategories: [
|
|
1288
|
+
{ labels: { name: 'a' } },
|
|
1289
|
+
],
|
|
1290
|
+
} ),
|
|
1291
|
+
},
|
|
1292
|
+
} );
|
|
1293
|
+
expect( console ).toHaveErroredWith(
|
|
1294
|
+
'A category is already registered with the same labels.name: "a".'
|
|
1295
|
+
);
|
|
1296
|
+
} );
|
|
1297
|
+
} );
|
|
1298
|
+
it( 'should register a media category', () => {
|
|
1299
|
+
const category = {
|
|
1300
|
+
name: 'new',
|
|
1301
|
+
labels: { name: 'new' },
|
|
1302
|
+
mediaType: 'image',
|
|
1303
|
+
fetch: () => {},
|
|
1304
|
+
};
|
|
1305
|
+
const inserterMediaCategories = [
|
|
1306
|
+
{ name: 'a', labels: { name: 'a' } },
|
|
1307
|
+
];
|
|
1308
|
+
const dispatch = jest.fn();
|
|
1309
|
+
registerInserterMediaCategory( category )( {
|
|
1310
|
+
select: {
|
|
1311
|
+
getSettings: () => ( { inserterMediaCategories } ),
|
|
1312
|
+
},
|
|
1313
|
+
dispatch,
|
|
1314
|
+
} );
|
|
1315
|
+
expect( dispatch ).toHaveBeenLastCalledWith( {
|
|
1316
|
+
type: 'UPDATE_SETTINGS',
|
|
1317
|
+
settings: {
|
|
1318
|
+
inserterMediaCategories: [
|
|
1319
|
+
...inserterMediaCategories,
|
|
1320
|
+
{ ...category, isExternalResource: true },
|
|
1321
|
+
],
|
|
1322
|
+
},
|
|
1323
|
+
} );
|
|
1324
|
+
} );
|
|
1325
|
+
} );
|
|
1212
1326
|
} );
|
|
@@ -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
|
} );
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
getLastInsertedBlocksClientIds,
|
|
12
12
|
getBlockEditingMode,
|
|
13
13
|
isBlockSubtreeDisabled,
|
|
14
|
-
|
|
14
|
+
getEnabledClientIdsTree,
|
|
15
15
|
getEnabledBlockParents,
|
|
16
16
|
} from '../private-selectors';
|
|
17
17
|
|
|
@@ -391,7 +391,7 @@ describe( 'private selectors', () => {
|
|
|
391
391
|
} );
|
|
392
392
|
} );
|
|
393
393
|
|
|
394
|
-
describe( '
|
|
394
|
+
describe( 'getEnabledClientIdsTree', () => {
|
|
395
395
|
const baseState = {
|
|
396
396
|
settings: {},
|
|
397
397
|
blocks: {
|
|
@@ -462,7 +462,7 @@ describe( 'private selectors', () => {
|
|
|
462
462
|
...baseState,
|
|
463
463
|
blockEditingModes: new Map( [] ),
|
|
464
464
|
};
|
|
465
|
-
expect(
|
|
465
|
+
expect( getEnabledClientIdsTree( state ) ).toEqual( [
|
|
466
466
|
{
|
|
467
467
|
clientId: '6cf70164-9097-4460-bcbf-200560546988',
|
|
468
468
|
innerBlocks: [],
|
|
@@ -500,7 +500,7 @@ describe( 'private selectors', () => {
|
|
|
500
500
|
blockEditingModes: new Map( [] ),
|
|
501
501
|
};
|
|
502
502
|
expect(
|
|
503
|
-
|
|
503
|
+
getEnabledClientIdsTree(
|
|
504
504
|
state,
|
|
505
505
|
'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337'
|
|
506
506
|
)
|
|
@@ -534,7 +534,7 @@ describe( 'private selectors', () => {
|
|
|
534
534
|
[ '9b9c5c3f-2e46-4f02-9e14-9fe9515b958f', 'contentOnly' ],
|
|
535
535
|
] ),
|
|
536
536
|
};
|
|
537
|
-
expect(
|
|
537
|
+
expect( getEnabledClientIdsTree( state ) ).toEqual( [
|
|
538
538
|
{
|
|
539
539
|
clientId: 'b26fc763-417d-4f01-b81c-2ec61e14a972',
|
|
540
540
|
innerBlocks: [],
|
|
@@ -3328,25 +3328,32 @@ describe( 'state', () => {
|
|
|
3328
3328
|
expect( state.clientIds ).toEqual( [ clientIdOne, clientIdTwo ] );
|
|
3329
3329
|
} );
|
|
3330
3330
|
|
|
3331
|
-
it( 'should return client ids of
|
|
3332
|
-
const
|
|
3333
|
-
|
|
3331
|
+
it( 'should return client ids of the original blocks when inner blocks are replaced with REPLACE_INNER_BLOCKS', () => {
|
|
3332
|
+
const initialBlocks = deepFreeze( [
|
|
3333
|
+
'62bfef6e-d5e9-43ba-b7f9-c77cf354141f',
|
|
3334
|
+
'9db792c6-a25a-495d-adbd-97d56a4c4189',
|
|
3335
|
+
] );
|
|
3334
3336
|
|
|
3335
3337
|
const action = {
|
|
3336
3338
|
blocks: [
|
|
3337
3339
|
{
|
|
3338
|
-
clientId:
|
|
3340
|
+
clientId: 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1',
|
|
3339
3341
|
},
|
|
3340
3342
|
{
|
|
3341
|
-
clientId:
|
|
3343
|
+
clientId: '14501cc2-90a6-4f52-aa36-ab6e896135d1',
|
|
3342
3344
|
},
|
|
3343
3345
|
],
|
|
3344
3346
|
type: 'REPLACE_INNER_BLOCKS',
|
|
3345
3347
|
};
|
|
3346
3348
|
|
|
3347
|
-
const state = lastBlockInserted(
|
|
3349
|
+
const state = lastBlockInserted(
|
|
3350
|
+
{
|
|
3351
|
+
clientIds: initialBlocks,
|
|
3352
|
+
},
|
|
3353
|
+
action
|
|
3354
|
+
);
|
|
3348
3355
|
|
|
3349
|
-
expect( state.clientIds ).toEqual(
|
|
3356
|
+
expect( state.clientIds ).toEqual( initialBlocks );
|
|
3350
3357
|
} );
|
|
3351
3358
|
|
|
3352
3359
|
it( 'should return empty state if last block inserted is called with action RESET_BLOCKS', () => {
|
|
@@ -3351,7 +3351,7 @@ describe( 'selectors', () => {
|
|
|
3351
3351
|
id: 'core/block/1',
|
|
3352
3352
|
initialAttributes: { ref: 1 },
|
|
3353
3353
|
isDisabled: false,
|
|
3354
|
-
keywords: [],
|
|
3354
|
+
keywords: [ 'reusable' ],
|
|
3355
3355
|
name: 'core/block',
|
|
3356
3356
|
syncStatus: undefined,
|
|
3357
3357
|
title: 'Reusable Block 1',
|
package/src/utils/object.js
CHANGED
|
@@ -56,12 +56,17 @@ export function kebabCase( str ) {
|
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* Clones an object.
|
|
59
|
+
* Arrays are also cloned as arrays.
|
|
59
60
|
* Non-object values are returned unchanged.
|
|
60
61
|
*
|
|
61
62
|
* @param {*} object Object to clone.
|
|
62
63
|
* @return {*} Cloned object, or original literal non-object value.
|
|
63
64
|
*/
|
|
64
65
|
function cloneObject( object ) {
|
|
66
|
+
if ( Array.isArray( object ) ) {
|
|
67
|
+
return object.map( cloneObject );
|
|
68
|
+
}
|
|
69
|
+
|
|
65
70
|
if ( object && typeof object === 'object' ) {
|
|
66
71
|
return {
|
|
67
72
|
...Object.fromEntries(
|
|
@@ -79,7 +84,7 @@ function cloneObject( object ) {
|
|
|
79
84
|
/**
|
|
80
85
|
* Immutably sets a value inside an object. Like `lodash#set`, but returning a
|
|
81
86
|
* new object. Treats nullish initial values as empty objects. Clones any
|
|
82
|
-
* nested objects.
|
|
87
|
+
* nested objects. Supports arrays, too.
|
|
83
88
|
*
|
|
84
89
|
* @param {Object} object Object to set a value in.
|
|
85
90
|
* @param {number|string|Array} path Path in the object to modify.
|
|
@@ -92,7 +97,11 @@ export function setImmutably( object, path, value ) {
|
|
|
92
97
|
|
|
93
98
|
normalizedPath.reduce( ( acc, key, i ) => {
|
|
94
99
|
if ( acc[ key ] === undefined ) {
|
|
95
|
-
|
|
100
|
+
if ( Number.isInteger( path[ i + 1 ] ) ) {
|
|
101
|
+
acc[ key ] = [];
|
|
102
|
+
} else {
|
|
103
|
+
acc[ key ] = {};
|
|
104
|
+
}
|
|
96
105
|
}
|
|
97
106
|
if ( i === normalizedPath.length - 1 ) {
|
|
98
107
|
acc[ key ] = value;
|
|
@@ -102,3 +111,24 @@ export function setImmutably( object, path, value ) {
|
|
|
102
111
|
|
|
103
112
|
return newObject;
|
|
104
113
|
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Helper util to return a value from a certain path of the object.
|
|
117
|
+
* Path is specified as either:
|
|
118
|
+
* - a string of properties, separated by dots, for example: "x.y".
|
|
119
|
+
* - an array of properties, for example `[ 'x', 'y' ]`.
|
|
120
|
+
* You can also specify a default value in case the result is nullish.
|
|
121
|
+
*
|
|
122
|
+
* @param {Object} object Input object.
|
|
123
|
+
* @param {string|Array} path Path to the object property.
|
|
124
|
+
* @param {*} defaultValue Default value if the value at the specified path is nullish.
|
|
125
|
+
* @return {*} Value of the object property at the specified path.
|
|
126
|
+
*/
|
|
127
|
+
export const getValueFromObjectPath = ( object, path, defaultValue ) => {
|
|
128
|
+
const normalizedPath = Array.isArray( path ) ? path : path.split( '.' );
|
|
129
|
+
let value = object;
|
|
130
|
+
normalizedPath.forEach( ( fieldName ) => {
|
|
131
|
+
value = value?.[ fieldName ];
|
|
132
|
+
} );
|
|
133
|
+
return value ?? defaultValue;
|
|
134
|
+
};
|
package/src/utils/test/object.js
CHANGED
|
@@ -150,6 +150,22 @@ describe( 'setImmutably', () => {
|
|
|
150
150
|
expect( result ).toEqual( { test: 2 } );
|
|
151
151
|
} );
|
|
152
152
|
|
|
153
|
+
it( 'handles first level arrays properly', () => {
|
|
154
|
+
const result = setImmutably( [ 5 ], 0, 6 );
|
|
155
|
+
|
|
156
|
+
expect( result ).toEqual( [ 6 ] );
|
|
157
|
+
} );
|
|
158
|
+
|
|
159
|
+
it( 'handles nested arrays properly', () => {
|
|
160
|
+
const result = setImmutably(
|
|
161
|
+
[ [ 'foo', [ 'bar' ] ] ],
|
|
162
|
+
[ 0, 1, 0 ],
|
|
163
|
+
'baz'
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
expect( result ).toEqual( [ [ 'foo', [ 'baz' ] ] ] );
|
|
167
|
+
} );
|
|
168
|
+
|
|
153
169
|
describe( 'with array notation access', () => {
|
|
154
170
|
it( 'assigns values at deeper levels', () => {
|
|
155
171
|
const result = setImmutably( {}, [ 'foo', 'bar', 'baz' ], 5 );
|
|
@@ -236,5 +252,25 @@ describe( 'setImmutably', () => {
|
|
|
236
252
|
expect( result.foo.bar ).not.toBe( input.foo.bar );
|
|
237
253
|
expect( result.foo.bar.baz ).not.toBe( input.foo.bar.baz );
|
|
238
254
|
} );
|
|
255
|
+
|
|
256
|
+
it( 'clones arrays at the first level', () => {
|
|
257
|
+
const input = [];
|
|
258
|
+
const result = setImmutably( input, 0, 1 );
|
|
259
|
+
|
|
260
|
+
expect( result ).not.toBe( input );
|
|
261
|
+
} );
|
|
262
|
+
|
|
263
|
+
it( 'clones arrays at deeper levels', () => {
|
|
264
|
+
const input = [ [ [ [ 'foo', [ 'bar' ] ] ] ] ];
|
|
265
|
+
const result = setImmutably( input, [ 0, 0, 0, 1, 0 ], 'baz' );
|
|
266
|
+
|
|
267
|
+
expect( result ).not.toBe( input );
|
|
268
|
+
expect( result[ 0 ] ).not.toBe( input[ 0 ] );
|
|
269
|
+
expect( result[ 0 ][ 0 ] ).not.toBe( input[ 0 ][ 0 ] );
|
|
270
|
+
expect( result[ 0 ][ 0 ][ 0 ] ).not.toBe( input[ 0 ][ 0 ][ 0 ] );
|
|
271
|
+
expect( result[ 0 ][ 0 ][ 0 ][ 1 ] ).not.toBe(
|
|
272
|
+
input[ 0 ][ 0 ][ 0 ][ 1 ]
|
|
273
|
+
);
|
|
274
|
+
} );
|
|
239
275
|
} );
|
|
240
276
|
} );
|