@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/actions.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint no-console: [ 'error', { allow: [ 'error', 'warn' ] } ] */
|
|
1
2
|
/**
|
|
2
3
|
* WordPress dependencies
|
|
3
4
|
*/
|
|
@@ -27,7 +28,6 @@ import {
|
|
|
27
28
|
} from '../utils/selection';
|
|
28
29
|
import {
|
|
29
30
|
__experimentalUpdateSettings,
|
|
30
|
-
ensureDefaultBlock,
|
|
31
31
|
privateRemoveBlocks,
|
|
32
32
|
} from './private-actions';
|
|
33
33
|
|
|
@@ -402,7 +402,7 @@ export const replaceBlocks =
|
|
|
402
402
|
initialPosition,
|
|
403
403
|
meta,
|
|
404
404
|
} );
|
|
405
|
-
dispatch
|
|
405
|
+
dispatch.ensureDefaultBlock();
|
|
406
406
|
};
|
|
407
407
|
|
|
408
408
|
/**
|
|
@@ -1389,7 +1389,9 @@ export function updateBlockListSettings( clientId, settings ) {
|
|
|
1389
1389
|
* @return {Object} Action object
|
|
1390
1390
|
*/
|
|
1391
1391
|
export function updateSettings( settings ) {
|
|
1392
|
-
return __experimentalUpdateSettings( settings,
|
|
1392
|
+
return __experimentalUpdateSettings( settings, {
|
|
1393
|
+
stripExperimentalSettings: true,
|
|
1394
|
+
} );
|
|
1393
1395
|
}
|
|
1394
1396
|
|
|
1395
1397
|
/**
|
|
@@ -1692,3 +1694,193 @@ export function __unstableSetTemporarilyEditingAsBlocks(
|
|
|
1692
1694
|
temporarilyEditingAsBlocks,
|
|
1693
1695
|
};
|
|
1694
1696
|
}
|
|
1697
|
+
|
|
1698
|
+
/**
|
|
1699
|
+
* Interface for inserter media requests.
|
|
1700
|
+
*
|
|
1701
|
+
* @typedef {Object} InserterMediaRequest
|
|
1702
|
+
* @property {number} per_page How many items to fetch per page.
|
|
1703
|
+
* @property {string} search The search term to use for filtering the results.
|
|
1704
|
+
*/
|
|
1705
|
+
|
|
1706
|
+
/**
|
|
1707
|
+
* Interface for inserter media responses. Any media resource should
|
|
1708
|
+
* map their response to this interface, in order to create the core
|
|
1709
|
+
* WordPress media blocks (image, video, audio).
|
|
1710
|
+
*
|
|
1711
|
+
* @typedef {Object} InserterMediaItem
|
|
1712
|
+
* @property {string} title The title of the media item.
|
|
1713
|
+
* @property {string} url The source url of the media item.
|
|
1714
|
+
* @property {string} [previewUrl] The preview source url of the media item to display in the media list.
|
|
1715
|
+
* @property {number} [id] The WordPress id of the media item.
|
|
1716
|
+
* @property {number|string} [sourceId] The id of the media item from external source.
|
|
1717
|
+
* @property {string} [alt] The alt text of the media item.
|
|
1718
|
+
* @property {string} [caption] The caption of the media item.
|
|
1719
|
+
*/
|
|
1720
|
+
|
|
1721
|
+
/**
|
|
1722
|
+
* Registers a new inserter media category. Once registered, the media category is
|
|
1723
|
+
* available in the inserter's media tab.
|
|
1724
|
+
*
|
|
1725
|
+
* The following interfaces are used:
|
|
1726
|
+
*
|
|
1727
|
+
* _Type Definition_
|
|
1728
|
+
*
|
|
1729
|
+
* - _InserterMediaRequest_ `Object`: Interface for inserter media requests.
|
|
1730
|
+
*
|
|
1731
|
+
* _Properties_
|
|
1732
|
+
*
|
|
1733
|
+
* - _per_page_ `number`: How many items to fetch per page.
|
|
1734
|
+
* - _search_ `string`: The search term to use for filtering the results.
|
|
1735
|
+
*
|
|
1736
|
+
* _Type Definition_
|
|
1737
|
+
*
|
|
1738
|
+
* - _InserterMediaItem_ `Object`: Interface for inserter media responses. Any media resource should
|
|
1739
|
+
* map their response to this interface, in order to create the core
|
|
1740
|
+
* WordPress media blocks (image, video, audio).
|
|
1741
|
+
*
|
|
1742
|
+
* _Properties_
|
|
1743
|
+
*
|
|
1744
|
+
* - _title_ `string`: The title of the media item.
|
|
1745
|
+
* - _url_ `string: The source url of the media item.
|
|
1746
|
+
* - _previewUrl_ `[string]`: The preview source url of the media item to display in the media list.
|
|
1747
|
+
* - _id_ `[number]`: The WordPress id of the media item.
|
|
1748
|
+
* - _sourceId_ `[number|string]`: The id of the media item from external source.
|
|
1749
|
+
* - _alt_ `[string]`: The alt text of the media item.
|
|
1750
|
+
* - _caption_ `[string]`: The caption of the media item.
|
|
1751
|
+
*
|
|
1752
|
+
* @param {InserterMediaCategory} category The inserter media category to register.
|
|
1753
|
+
*
|
|
1754
|
+
* @example
|
|
1755
|
+
* ```js
|
|
1756
|
+
*
|
|
1757
|
+
* wp.data.dispatch('core/block-editor').registerInserterMediaCategory( {
|
|
1758
|
+
* name: 'openverse',
|
|
1759
|
+
* labels: {
|
|
1760
|
+
* name: 'Openverse',
|
|
1761
|
+
* search_items: 'Search Openverse',
|
|
1762
|
+
* },
|
|
1763
|
+
* mediaType: 'image',
|
|
1764
|
+
* async fetch( query = {} ) {
|
|
1765
|
+
* const defaultArgs = {
|
|
1766
|
+
* mature: false,
|
|
1767
|
+
* excluded_source: 'flickr,inaturalist,wikimedia',
|
|
1768
|
+
* license: 'pdm,cc0',
|
|
1769
|
+
* };
|
|
1770
|
+
* const finalQuery = { ...query, ...defaultArgs };
|
|
1771
|
+
* // Sometimes you might need to map the supported request params according to `InserterMediaRequest`.
|
|
1772
|
+
* // interface. In this example the `search` query param is named `q`.
|
|
1773
|
+
* const mapFromInserterMediaRequest = {
|
|
1774
|
+
* per_page: 'page_size',
|
|
1775
|
+
* search: 'q',
|
|
1776
|
+
* };
|
|
1777
|
+
* const url = new URL( 'https://api.openverse.engineering/v1/images/' );
|
|
1778
|
+
* Object.entries( finalQuery ).forEach( ( [ key, value ] ) => {
|
|
1779
|
+
* const queryKey = mapFromInserterMediaRequest[ key ] || key;
|
|
1780
|
+
* url.searchParams.set( queryKey, value );
|
|
1781
|
+
* } );
|
|
1782
|
+
* const response = await window.fetch( url, {
|
|
1783
|
+
* headers: {
|
|
1784
|
+
* 'User-Agent': 'WordPress/inserter-media-fetch',
|
|
1785
|
+
* },
|
|
1786
|
+
* } );
|
|
1787
|
+
* const jsonResponse = await response.json();
|
|
1788
|
+
* const results = jsonResponse.results;
|
|
1789
|
+
* return results.map( ( result ) => ( {
|
|
1790
|
+
* ...result,
|
|
1791
|
+
* // If your response result includes an `id` prop that you want to access later, it should
|
|
1792
|
+
* // be mapped to `InserterMediaItem`'s `sourceId` prop. This can be useful if you provide
|
|
1793
|
+
* // a report URL getter.
|
|
1794
|
+
* // Additionally you should always clear the `id` value of your response results because
|
|
1795
|
+
* // it is used to identify WordPress media items.
|
|
1796
|
+
* sourceId: result.id,
|
|
1797
|
+
* id: undefined,
|
|
1798
|
+
* caption: result.caption,
|
|
1799
|
+
* previewUrl: result.thumbnail,
|
|
1800
|
+
* } ) );
|
|
1801
|
+
* },
|
|
1802
|
+
* getReportUrl: ( { sourceId } ) =>
|
|
1803
|
+
* `https://wordpress.org/openverse/image/${ sourceId }/report/`,
|
|
1804
|
+
* isExternalResource: true,
|
|
1805
|
+
* } );
|
|
1806
|
+
* ```
|
|
1807
|
+
*
|
|
1808
|
+
* @typedef {Object} InserterMediaCategory Interface for inserter media category.
|
|
1809
|
+
* @property {string} name The name of the media category, that should be unique among all media categories.
|
|
1810
|
+
* @property {Object} labels Labels for the media category.
|
|
1811
|
+
* @property {string} labels.name General name of the media category. It's used in the inserter media items list.
|
|
1812
|
+
* @property {string} [labels.search_items='Search'] Label for searching items. Default is ‘Search Posts’ / ‘Search Pages’.
|
|
1813
|
+
* @property {('image'|'audio'|'video')} mediaType The media type of the media category.
|
|
1814
|
+
* @property {(InserterMediaRequest) => Promise<InserterMediaItem[]>} fetch The function to fetch media items for the category.
|
|
1815
|
+
* @property {(InserterMediaItem) => string} [getReportUrl] If the media category supports reporting media items, this function should return
|
|
1816
|
+
* the report url for the media item. It accepts the `InserterMediaItem` as an argument.
|
|
1817
|
+
* @property {boolean} [isExternalResource] If the media category is an external resource, this should be set to true.
|
|
1818
|
+
* This is used to avoid making a request to the external resource when the user
|
|
1819
|
+
*
|
|
1820
|
+
*/
|
|
1821
|
+
export const registerInserterMediaCategory =
|
|
1822
|
+
( category ) =>
|
|
1823
|
+
( { select, dispatch } ) => {
|
|
1824
|
+
if ( ! category || typeof category !== 'object' ) {
|
|
1825
|
+
console.error(
|
|
1826
|
+
'Category should be an `InserterMediaCategory` object.'
|
|
1827
|
+
);
|
|
1828
|
+
return;
|
|
1829
|
+
}
|
|
1830
|
+
if ( ! category.name ) {
|
|
1831
|
+
console.error(
|
|
1832
|
+
'Category should have a `name` that should be unique among all media categories.'
|
|
1833
|
+
);
|
|
1834
|
+
return;
|
|
1835
|
+
}
|
|
1836
|
+
if ( ! category.labels?.name ) {
|
|
1837
|
+
console.error( 'Category should have a `labels.name`.' );
|
|
1838
|
+
return;
|
|
1839
|
+
}
|
|
1840
|
+
if ( ! [ 'image', 'audio', 'video' ].includes( category.mediaType ) ) {
|
|
1841
|
+
console.error(
|
|
1842
|
+
'Category should have `mediaType` property that is one of `image|audio|video`.'
|
|
1843
|
+
);
|
|
1844
|
+
return;
|
|
1845
|
+
}
|
|
1846
|
+
if ( ! category.fetch || typeof category.fetch !== 'function' ) {
|
|
1847
|
+
console.error(
|
|
1848
|
+
'Category should have a `fetch` function defined with the following signature `(InserterMediaRequest) => Promise<InserterMediaItem[]>`.'
|
|
1849
|
+
);
|
|
1850
|
+
return;
|
|
1851
|
+
}
|
|
1852
|
+
const { inserterMediaCategories = [] } = select.getSettings();
|
|
1853
|
+
if (
|
|
1854
|
+
inserterMediaCategories.some(
|
|
1855
|
+
( { name } ) => name === category.name
|
|
1856
|
+
)
|
|
1857
|
+
) {
|
|
1858
|
+
console.error(
|
|
1859
|
+
`A category is already registered with the same name: "${ category.name }".`
|
|
1860
|
+
);
|
|
1861
|
+
return;
|
|
1862
|
+
}
|
|
1863
|
+
if (
|
|
1864
|
+
inserterMediaCategories.some(
|
|
1865
|
+
( { labels: { name } } ) => name === category.labels?.name
|
|
1866
|
+
)
|
|
1867
|
+
) {
|
|
1868
|
+
console.error(
|
|
1869
|
+
`A category is already registered with the same labels.name: "${ category.labels.name }".`
|
|
1870
|
+
);
|
|
1871
|
+
return;
|
|
1872
|
+
}
|
|
1873
|
+
// `inserterMediaCategories` is a private block editor setting, which means it cannot
|
|
1874
|
+
// be updated through the public `updateSettings` action. We preserve this setting as
|
|
1875
|
+
// private, so extenders can only add new inserter media categories and don't have any
|
|
1876
|
+
// control over the core media categories.
|
|
1877
|
+
dispatch( {
|
|
1878
|
+
type: 'UPDATE_SETTINGS',
|
|
1879
|
+
settings: {
|
|
1880
|
+
inserterMediaCategories: [
|
|
1881
|
+
...inserterMediaCategories,
|
|
1882
|
+
{ ...category, isExternalResource: true },
|
|
1883
|
+
],
|
|
1884
|
+
},
|
|
1885
|
+
} );
|
|
1886
|
+
};
|
package/src/store/defaults.js
CHANGED
|
@@ -18,6 +18,7 @@ export const PREFERENCES_DEFAULTS = {
|
|
|
18
18
|
* @property {number} maxWidth Max width to constraint resizing
|
|
19
19
|
* @property {boolean|Array} allowedBlockTypes Allowed block types
|
|
20
20
|
* @property {boolean} hasFixedToolbar Whether or not the editor toolbar is fixed
|
|
21
|
+
* @property {boolean} distractionFree Whether or not the editor UI is distraction free
|
|
21
22
|
* @property {boolean} focusMode Whether the focus mode is enabled or not
|
|
22
23
|
* @property {Array} styles Editor Styles
|
|
23
24
|
* @property {boolean} keepCaretInsideBlock Whether caret should move between blocks in edit mode
|
package/src/store/index.js
CHANGED
|
@@ -43,3 +43,13 @@ const registeredStore = registerStore( STORE_NAME, {
|
|
|
43
43
|
} );
|
|
44
44
|
unlock( registeredStore ).registerPrivateActions( privateActions );
|
|
45
45
|
unlock( registeredStore ).registerPrivateSelectors( privateSelectors );
|
|
46
|
+
|
|
47
|
+
// TODO: Remove once we switch to the `register` function (see above).
|
|
48
|
+
//
|
|
49
|
+
// Until then, private functions also need to be attached to the original
|
|
50
|
+
// `store` descriptor in order to avoid unit tests failing, which could happen
|
|
51
|
+
// when tests create new registries in which they register stores.
|
|
52
|
+
//
|
|
53
|
+
// @see https://github.com/WordPress/gutenberg/pull/51145#discussion_r1239999590
|
|
54
|
+
unlock( store ).registerPrivateActions( privateActions );
|
|
55
|
+
unlock( store ).registerPrivateSelectors( privateSelectors );
|
|
@@ -3,11 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Platform } from '@wordpress/element';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { blockTypePromptMessages } from '../components/block-removal-warning-modal';
|
|
10
|
-
|
|
11
6
|
const castArray = ( maybeArray ) =>
|
|
12
7
|
Array.isArray( maybeArray ) ? maybeArray : [ maybeArray ];
|
|
13
8
|
|
|
@@ -28,13 +23,15 @@ const privateSettings = [
|
|
|
28
23
|
* Action that updates the block editor settings and
|
|
29
24
|
* conditionally preserves the experimental ones.
|
|
30
25
|
*
|
|
31
|
-
* @param {Object} settings
|
|
32
|
-
* @param {
|
|
26
|
+
* @param {Object} settings Updated settings
|
|
27
|
+
* @param {Object} options Options object.
|
|
28
|
+
* @param {boolean} options.stripExperimentalSettings Whether to strip experimental settings.
|
|
29
|
+
* @param {boolean} options.reset Whether to reset the settings.
|
|
33
30
|
* @return {Object} Action object
|
|
34
31
|
*/
|
|
35
32
|
export function __experimentalUpdateSettings(
|
|
36
33
|
settings,
|
|
37
|
-
stripExperimentalSettings = false
|
|
34
|
+
{ stripExperimentalSettings = false, reset = false } = {}
|
|
38
35
|
) {
|
|
39
36
|
let cleanSettings = settings;
|
|
40
37
|
// There are no plugins in the mobile apps, so there is no
|
|
@@ -50,6 +47,7 @@ export function __experimentalUpdateSettings(
|
|
|
50
47
|
return {
|
|
51
48
|
type: 'UPDATE_SETTINGS',
|
|
52
49
|
settings: cleanSettings,
|
|
50
|
+
reset,
|
|
53
51
|
};
|
|
54
52
|
}
|
|
55
53
|
|
|
@@ -155,35 +153,22 @@ export const privateRemoveBlocks =
|
|
|
155
153
|
// confirmation that they intended to remove such block(s). However,
|
|
156
154
|
// the editor instance is responsible for presenting those confirmation
|
|
157
155
|
// prompts to the user. Any instance opting into removal prompts must
|
|
158
|
-
// register using `
|
|
156
|
+
// register using `setBlockRemovalRules()`.
|
|
159
157
|
//
|
|
160
158
|
// @see https://github.com/WordPress/gutenberg/pull/51145
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
// FIXME: Without this existence check, the unit tests for
|
|
164
|
-
// `__experimentalDeleteReusableBlock` in
|
|
165
|
-
// `packages/reusable-blocks/src/store/test/actions.js` fail due to
|
|
166
|
-
// the fact that the `registry` object passed to the thunk actions
|
|
167
|
-
// doesn't include this private action. This needs to be
|
|
168
|
-
// investigated to understand whether it's a real smell or if it's
|
|
169
|
-
// because not all store code has been updated to accommodate
|
|
170
|
-
// private selectors.
|
|
171
|
-
select.isRemovalPromptSupported &&
|
|
172
|
-
select.isRemovalPromptSupported()
|
|
173
|
-
) {
|
|
159
|
+
const rules = ! forceRemove && select.getBlockRemovalRules();
|
|
160
|
+
if ( rules ) {
|
|
174
161
|
const blockNamesForPrompt = new Set();
|
|
175
162
|
|
|
176
163
|
// Given a list of client IDs of blocks that the user intended to
|
|
177
164
|
// remove, perform a tree search (BFS) to find all block names
|
|
178
165
|
// corresponding to "important" blocks, i.e. blocks that require a
|
|
179
166
|
// removal prompt.
|
|
180
|
-
//
|
|
181
|
-
// @see blockTypePromptMessages
|
|
182
167
|
const queue = [ ...clientIds ];
|
|
183
168
|
while ( queue.length ) {
|
|
184
169
|
const clientId = queue.shift();
|
|
185
170
|
const blockName = select.getBlockName( clientId );
|
|
186
|
-
if (
|
|
171
|
+
if ( rules[ blockName ] ) {
|
|
187
172
|
blockNamesForPrompt.add( blockName );
|
|
188
173
|
}
|
|
189
174
|
const innerBlocks = select.getBlockOrder( clientId );
|
|
@@ -194,7 +179,7 @@ export const privateRemoveBlocks =
|
|
|
194
179
|
// skip any other steps (thus postponing actual removal).
|
|
195
180
|
if ( blockNamesForPrompt.size ) {
|
|
196
181
|
dispatch(
|
|
197
|
-
|
|
182
|
+
displayBlockRemovalPrompt(
|
|
198
183
|
clientIds,
|
|
199
184
|
selectPrevious,
|
|
200
185
|
Array.from( blockNamesForPrompt )
|
|
@@ -246,7 +231,7 @@ export const ensureDefaultBlock =
|
|
|
246
231
|
* Returns an action object used in signalling that a block removal prompt must
|
|
247
232
|
* be displayed.
|
|
248
233
|
*
|
|
249
|
-
* Contrast with `
|
|
234
|
+
* Contrast with `setBlockRemovalRules`.
|
|
250
235
|
*
|
|
251
236
|
* @param {string|string[]} clientIds Client IDs of blocks to remove.
|
|
252
237
|
* @param {boolean} selectPrevious True if the previous block
|
|
@@ -254,16 +239,19 @@ export const ensureDefaultBlock =
|
|
|
254
239
|
* (if no previous block exists)
|
|
255
240
|
* should be selected
|
|
256
241
|
* when a block is removed.
|
|
257
|
-
* @param {string[]} blockNamesForPrompt Names of blocks
|
|
242
|
+
* @param {string[]} blockNamesForPrompt Names of the blocks that
|
|
243
|
+
* triggered the need for
|
|
244
|
+
* confirmation before removal.
|
|
245
|
+
*
|
|
258
246
|
* @return {Object} Action object.
|
|
259
247
|
*/
|
|
260
|
-
|
|
248
|
+
function displayBlockRemovalPrompt(
|
|
261
249
|
clientIds,
|
|
262
250
|
selectPrevious,
|
|
263
251
|
blockNamesForPrompt
|
|
264
252
|
) {
|
|
265
253
|
return {
|
|
266
|
-
type: '
|
|
254
|
+
type: 'DISPLAY_BLOCK_REMOVAL_PROMPT',
|
|
267
255
|
clientIds,
|
|
268
256
|
selectPrevious,
|
|
269
257
|
blockNamesForPrompt,
|
|
@@ -277,24 +265,36 @@ export function displayRemovalPrompt(
|
|
|
277
265
|
*
|
|
278
266
|
* @return {Object} Action object.
|
|
279
267
|
*/
|
|
280
|
-
export function
|
|
268
|
+
export function clearBlockRemovalPrompt() {
|
|
281
269
|
return {
|
|
282
|
-
type: '
|
|
270
|
+
type: 'CLEAR_BLOCK_REMOVAL_PROMPT',
|
|
283
271
|
};
|
|
284
272
|
}
|
|
285
273
|
|
|
286
274
|
/**
|
|
287
|
-
* Returns an action object used
|
|
288
|
-
*
|
|
275
|
+
* Returns an action object used to set up any rules that a block editor may
|
|
276
|
+
* provide in order to prevent a user from accidentally removing certain
|
|
277
|
+
* blocks. These rules are then used to display a confirmation prompt to the
|
|
278
|
+
* user. For instance, in the Site Editor, the Query Loop block is important
|
|
279
|
+
* enough to warrant such confirmation.
|
|
280
|
+
*
|
|
281
|
+
* IMPORTANT: Registering rules implicitly signals to the `privateRemoveBlocks`
|
|
282
|
+
* action that the editor will be responsible for displaying block removal
|
|
283
|
+
* prompts and confirming deletions. This action is meant to be used by
|
|
284
|
+
* component `BlockRemovalWarningModal` only.
|
|
285
|
+
*
|
|
286
|
+
* The data is a record whose keys are block types (e.g. 'core/query') and
|
|
287
|
+
* whose values are the explanation to be shown to users (e.g. 'Query Loop
|
|
288
|
+
* displays a list of posts or pages.').
|
|
289
289
|
*
|
|
290
|
-
* Contrast with `
|
|
290
|
+
* Contrast with `displayBlockRemovalPrompt`.
|
|
291
291
|
*
|
|
292
|
-
* @param {
|
|
292
|
+
* @param {Record<string,string>|false} rules Block removal rules.
|
|
293
293
|
* @return {Object} Action object.
|
|
294
294
|
*/
|
|
295
|
-
export function
|
|
295
|
+
export function setBlockRemovalRules( rules = false ) {
|
|
296
296
|
return {
|
|
297
|
-
type: '
|
|
298
|
-
|
|
297
|
+
type: 'SET_BLOCK_REMOVAL_RULES',
|
|
298
|
+
rules,
|
|
299
299
|
};
|
|
300
300
|
}
|
|
@@ -136,21 +136,18 @@ export const isBlockSubtreeDisabled = createSelector(
|
|
|
136
136
|
*
|
|
137
137
|
* @return {Object[]} Tree of block objects with only clientID and innerBlocks set.
|
|
138
138
|
*/
|
|
139
|
-
export const
|
|
139
|
+
export const getEnabledClientIdsTree = createSelector(
|
|
140
140
|
( state, rootClientId = '' ) => {
|
|
141
141
|
return getBlockOrder( state, rootClientId ).flatMap( ( clientId ) => {
|
|
142
142
|
if ( getBlockEditingMode( state, clientId ) !== 'disabled' ) {
|
|
143
143
|
return [
|
|
144
144
|
{
|
|
145
145
|
clientId,
|
|
146
|
-
innerBlocks:
|
|
147
|
-
state,
|
|
148
|
-
clientId
|
|
149
|
-
),
|
|
146
|
+
innerBlocks: getEnabledClientIdsTree( state, clientId ),
|
|
150
147
|
},
|
|
151
148
|
];
|
|
152
149
|
}
|
|
153
|
-
return
|
|
150
|
+
return getEnabledClientIdsTree( state, clientId );
|
|
154
151
|
} );
|
|
155
152
|
},
|
|
156
153
|
( state ) => [
|
|
@@ -205,6 +202,6 @@ export function getRemovalPromptData( state ) {
|
|
|
205
202
|
*
|
|
206
203
|
* @return {boolean} Whether removal prompt exists.
|
|
207
204
|
*/
|
|
208
|
-
export function
|
|
209
|
-
return state.
|
|
205
|
+
export function getBlockRemovalRules( state ) {
|
|
206
|
+
return state.blockRemovalRules;
|
|
210
207
|
}
|
package/src/store/reducer.js
CHANGED
|
@@ -1480,14 +1480,14 @@ export function isSelectionEnabled( state = true, action ) {
|
|
|
1480
1480
|
*/
|
|
1481
1481
|
function removalPromptData( state = false, action ) {
|
|
1482
1482
|
switch ( action.type ) {
|
|
1483
|
-
case '
|
|
1483
|
+
case 'DISPLAY_BLOCK_REMOVAL_PROMPT':
|
|
1484
1484
|
const { clientIds, selectPrevious, blockNamesForPrompt } = action;
|
|
1485
1485
|
return {
|
|
1486
1486
|
clientIds,
|
|
1487
1487
|
selectPrevious,
|
|
1488
1488
|
blockNamesForPrompt,
|
|
1489
1489
|
};
|
|
1490
|
-
case '
|
|
1490
|
+
case 'CLEAR_BLOCK_REMOVAL_PROMPT':
|
|
1491
1491
|
return false;
|
|
1492
1492
|
}
|
|
1493
1493
|
|
|
@@ -1495,17 +1495,25 @@ function removalPromptData( state = false, action ) {
|
|
|
1495
1495
|
}
|
|
1496
1496
|
|
|
1497
1497
|
/**
|
|
1498
|
-
* Reducer
|
|
1498
|
+
* Reducer returning any rules that a block editor may provide in order to
|
|
1499
|
+
* prevent a user from accidentally removing certain blocks. These rules are
|
|
1500
|
+
* then used to display a confirmation prompt to the user. For instance, in the
|
|
1501
|
+
* Site Editor, the Query Loop block is important enough to warrant such
|
|
1502
|
+
* confirmation.
|
|
1503
|
+
*
|
|
1504
|
+
* The data is a record whose keys are block types (e.g. 'core/query') and
|
|
1505
|
+
* whose values are the explanation to be shown to users (e.g. 'Query Loop
|
|
1506
|
+
* displays a list of posts or pages.').
|
|
1499
1507
|
*
|
|
1500
1508
|
* @param {boolean} state Current state.
|
|
1501
1509
|
* @param {Object} action Dispatched action.
|
|
1502
1510
|
*
|
|
1503
|
-
* @return {
|
|
1511
|
+
* @return {Record<string,string>} Updated state.
|
|
1504
1512
|
*/
|
|
1505
|
-
function
|
|
1513
|
+
function blockRemovalRules( state = false, action ) {
|
|
1506
1514
|
switch ( action.type ) {
|
|
1507
|
-
case '
|
|
1508
|
-
return action.
|
|
1515
|
+
case 'SET_BLOCK_REMOVAL_RULES':
|
|
1516
|
+
return action.rules;
|
|
1509
1517
|
}
|
|
1510
1518
|
|
|
1511
1519
|
return state;
|
|
@@ -1623,6 +1631,12 @@ export function template( state = { isValid: true }, action ) {
|
|
|
1623
1631
|
export function settings( state = SETTINGS_DEFAULTS, action ) {
|
|
1624
1632
|
switch ( action.type ) {
|
|
1625
1633
|
case 'UPDATE_SETTINGS':
|
|
1634
|
+
if ( action.reset ) {
|
|
1635
|
+
return {
|
|
1636
|
+
...SETTINGS_DEFAULTS,
|
|
1637
|
+
...action.settings,
|
|
1638
|
+
};
|
|
1639
|
+
}
|
|
1626
1640
|
return {
|
|
1627
1641
|
...state,
|
|
1628
1642
|
...action.settings,
|
|
@@ -1841,7 +1855,6 @@ export function lastBlockInserted( state = {}, action ) {
|
|
|
1841
1855
|
switch ( action.type ) {
|
|
1842
1856
|
case 'INSERT_BLOCKS':
|
|
1843
1857
|
case 'REPLACE_BLOCKS':
|
|
1844
|
-
case 'REPLACE_INNER_BLOCKS':
|
|
1845
1858
|
if ( ! action.blocks.length ) {
|
|
1846
1859
|
return state;
|
|
1847
1860
|
}
|
|
@@ -1924,7 +1937,7 @@ const combinedReducers = combineReducers( {
|
|
|
1924
1937
|
blockVisibility,
|
|
1925
1938
|
blockEditingModes,
|
|
1926
1939
|
removalPromptData,
|
|
1927
|
-
|
|
1940
|
+
blockRemovalRules,
|
|
1928
1941
|
} );
|
|
1929
1942
|
|
|
1930
1943
|
function withAutomaticChangeReset( reducer ) {
|