@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-patterns-state.js"],"names":["useCallback","cloneBlock","useDispatch","useSelect","__","sprintf","store","noticesStore","blockEditorStore","usePatternsState","onInsert","rootClientId","patternCategories","patterns","select","__experimentalGetAllowedPatterns","getSettings","__experimentalBlockPatternCategories","createSuccessNotice","onClickPattern","pattern","blocks","map","block","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-patterns-state.js"],"names":["useCallback","useMemo","cloneBlock","useDispatch","useSelect","__","sprintf","store","noticesStore","blockEditorStore","CUSTOM_CATEGORY","name","label","description","usePatternsState","onInsert","rootClientId","patternCategories","patterns","select","__experimentalGetAllowedPatterns","getSettings","__experimentalBlockPatternCategories","allCategories","createSuccessNotice","onClickPattern","pattern","blocks","map","block","title","type"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AACA,SAASC,U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Aa3B,UAAU,CAAE2B,KAAF,CAA7C,CADO,EAEPH,OAAO,CAACf,IAFD,CAAR;AAIAa,IAAAA,mBAAmB,CAClBlB,OAAO;AACN;AACAD,IAAAA,EAAE,CAAE,8BAAF,CAFI,EAGNqB,OAAO,CAACI,KAHF,CADW,EAMlB;AACCC,MAAAA,IAAI,EAAE;AADP,KANkB,CAAnB;AAUA,GAhBgC,EAiBjC,CAAEP,mBAAF,EAAuBT,QAAvB,CAjBiC,CAAlC;AAoBA,SAAO,CAAEG,QAAF,EAAYK,aAAZ,EAA2BE,cAA3B,CAAP;AACA,CA1CD;;AA4CA,eAAeX,gBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\nconst CUSTOM_CATEGORY = {\n\tname: 'custom',\n\tlabel: __( 'My patterns' ),\n\tdescription: __( 'Custom patterns add by site users' ),\n};\n\n/**\n * Retrieves the block patterns inserter state.\n *\n * @param {Function} onInsert function called when inserter a list of blocks.\n * @param {string=} rootClientId Insertion's root client ID.\n *\n * @return {Array} Returns the patterns state. (patterns, categories, onSelect handler)\n */\nconst usePatternsState = ( onInsert, rootClientId ) => {\n\tconst { patternCategories, patterns } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { __experimentalGetAllowedPatterns, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tpatterns: __experimentalGetAllowedPatterns( rootClientId ),\n\t\t\t\tpatternCategories:\n\t\t\t\t\tgetSettings().__experimentalBlockPatternCategories,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tconst allCategories = useMemo(\n\t\t() => [ ...patternCategories, CUSTOM_CATEGORY ],\n\t\t[ patternCategories ]\n\t);\n\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst onClickPattern = useCallback(\n\t\t( pattern, blocks ) => {\n\t\t\tonInsert(\n\t\t\t\t( blocks ?? [] ).map( ( block ) => cloneBlock( block ) ),\n\t\t\t\tpattern.name\n\t\t\t);\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: block pattern title. */\n\t\t\t\t\t__( 'Block pattern \"%s\" inserted.' ),\n\t\t\t\t\tpattern.title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t\t[ createSuccessNotice, onInsert ]\n\t);\n\n\treturn [ patterns, allCategories, onClickPattern ];\n};\n\nexport default usePatternsState;\n"]}
|
|
@@ -231,7 +231,7 @@ export const ComposedPrivateInserter = compose([withSelect((select, {
|
|
|
231
231
|
getBlockRootClientId,
|
|
232
232
|
hasInserterItems,
|
|
233
233
|
getAllowedBlocks,
|
|
234
|
-
|
|
234
|
+
getDirectInsertBlock,
|
|
235
235
|
getSettings
|
|
236
236
|
} = select(blockEditorStore);
|
|
237
237
|
const {
|
|
@@ -239,9 +239,7 @@ export const ComposedPrivateInserter = compose([withSelect((select, {
|
|
|
239
239
|
} = select(blocksStore);
|
|
240
240
|
rootClientId = rootClientId || getBlockRootClientId(clientId) || undefined;
|
|
241
241
|
const allowedBlocks = getAllowedBlocks(rootClientId);
|
|
242
|
-
|
|
243
|
-
const directInsertBlock = shouldDirectInsert && __experimentalGetDirectInsertBlock(rootClientId);
|
|
244
|
-
|
|
242
|
+
const directInsertBlock = shouldDirectInsert && getDirectInsertBlock(rootClientId);
|
|
245
243
|
const settings = getSettings();
|
|
246
244
|
const hasSingleBlockType = allowedBlocks?.length === 1 && getBlockVariations(allowedBlocks[0].name, 'inserter')?.length === 0;
|
|
247
245
|
let allowedBlockType = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/index.js"],"names":["classnames","speak","__","_x","sprintf","Dropdown","Button","forwardRef","Component","withDispatch","withSelect","compose","ifCondition","createBlock","store","blocksStore","plus","InserterMenu","QuickInserter","blockEditorStore","defaultRenderToggle","onToggle","disabled","isOpen","blockTitle","hasSingleBlockType","toggleProps","prioritizePatterns","as","Wrapper","label","labelProp","onClick","rest","handleClick","event","PrivateInserter","constructor","arguments","bind","renderToggle","renderContent","props","directInsertBlock","hasItems","onClose","rootClientId","clientId","isAppender","showInserterHelpPanel","__experimentalIsQuick","isQuick","onSelectOrClose","selectBlockOnInsert","blocks","firstBlock","Array","isArray","length","render","position","insertOnlyAllowedBlock","shift","ComposedPrivateInserter","select","shouldDirectInsert","getBlockRootClientId","hasInserterItems","getAllowedBlocks","__experimentalGetDirectInsertBlock","getSettings","getBlockVariations","undefined","allowedBlocks","settings","name","allowedBlockType","title","__experimentalPreferPatternsOnRoot","dispatch","ownProps","getAdjacentBlockAttributes","attributesToCopy","getBlock","getPreviousBlockClientId","result","adjacentAttributes","parentBlock","innerBlocks","lastInnerBlock","attributes","currentBlock","previousBlock","forEach","attribute","hasOwnProperty","getInsertionIndex","getBlockIndex","getBlockSelectionEnd","getBlockOrder","end","insertBlock","blockToInsert","newAttributes","message","Inserter","ref"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SAASC,QAAT,EAAmBC,MAAnB,QAAiC,uBAAjC;AACA,SAASC,UAAT,EAAqBC,SAArB,QAAsC,oBAAtC;AACA,SAASC,YAAT,EAAuBC,UAAvB,QAAyC,iBAAzC;AACA,SAASC,OAAT,EAAkBC,WAAlB,QAAqC,oBAArC;AACA,SAASC,WAAT,EAAsBC,KAAK,IAAIC,WAA/B,QAAkD,mBAAlD;AACA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,UAAKD,eAAL,EAAuB;AACtBA,QAAAA,eAAe,CAAE;AAChBL,UAAAA,QAAQ,EAAEuD,aAAa,EAAEvD;AADT,SAAF,CAAf;AAGA;;AAED,YAAMyD,OAAO,GAAGpG,OAAO,EACtB;AACAF,MAAAA,EAAE,CAAE,gBAAF,CAFoB,EAGtB0E,gBAAgB,CAACC,KAHK,CAAvB;AAKA5E,MAAAA,KAAK,CAAEuG,OAAF,CAAL;AACA;;AA5IK,GAAP;AA8IA,CA/IW,CA/CmC,EA+L/C;AACA;AACA5F,WAAW,CACV,CAAE;AAAEgC,EAAAA,QAAF;AAAYI,EAAAA,UAAZ;AAAwBF,EAAAA,YAAxB;AAAsCC,EAAAA;AAAtC,CAAF,KACCH,QAAQ,IAAM,CAAEI,UAAF,IAAgB,CAAEF,YAAlB,IAAkC,CAAEC,QAFzC,CAjMoC,CAAF,CAAP,CAqMlCX,eArMkC,CAAhC;AAuMP,MAAMqE,QAAQ,GAAGlG,UAAU,CAAE,CAAEmC,KAAF,EAASgE,GAAT,KAAkB;AAC9C,SAAO,cAAC,uBAAD;AAAyB,IAAA,GAAG,EAAGA,GAA/B;AAAA,OAA0ChE;AAA1C,IAAP;AACA,CAF0B,CAA3B;AAIA,eAAe+D,QAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { forwardRef, Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, ifCondition } from '@wordpress/compose';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport InserterMenu from './menu';\nimport QuickInserter from './quick-inserter';\nimport { store as blockEditorStore } from '../../store';\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\tisOpen,\n\tblockTitle,\n\thasSingleBlockType,\n\ttoggleProps = {},\n\tprioritizePatterns,\n} ) => {\n\tconst {\n\t\tas: Wrapper = Button,\n\t\tlabel: labelProp,\n\t\tonClick,\n\t\t...rest\n\t} = toggleProps;\n\n\tlet label = labelProp;\n\tif ( ! label && hasSingleBlockType ) {\n\t\tlabel = sprintf(\n\t\t\t// translators: %s: the name of the block when there is only one\n\t\t\t_x( 'Add %s', 'directly add the only allowed block' ),\n\t\t\tblockTitle\n\t\t);\n\t} else if ( ! label && prioritizePatterns ) {\n\t\tlabel = __( 'Add pattern' );\n\t} else if ( ! label ) {\n\t\tlabel = _x( 'Add block', 'Generic label for block inserter button' );\n\t}\n\n\t// Handle both onClick functions from the toggle and the parent component.\n\tfunction handleClick( event ) {\n\t\tif ( onToggle ) {\n\t\t\tonToggle( event );\n\t\t}\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Wrapper\n\t\t\ticon={ plus }\n\t\t\tlabel={ label }\n\t\t\ttooltipPosition=\"bottom\"\n\t\t\tonClick={ handleClick }\n\t\t\tclassName=\"block-editor-inserter__toggle\"\n\t\t\taria-haspopup={ ! hasSingleBlockType ? 'true' : false }\n\t\t\taria-expanded={ ! hasSingleBlockType ? isOpen : false }\n\t\t\tdisabled={ disabled }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n};\n\nclass PrivateInserter extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderToggle = this.renderToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { onToggle } = this.props;\n\n\t\t// Surface toggle callback to parent component.\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown toggle element.\n\t */\n\trenderToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\ttoggleProps,\n\t\t\thasItems,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t\tprioritizePatterns,\n\t\t} = this.props;\n\n\t\treturn renderToggle( {\n\t\t\tonToggle,\n\t\t\tisOpen,\n\t\t\tdisabled: disabled || ! hasItems,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\ttoggleProps,\n\t\t\tprioritizePatterns,\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t *\n\t * @return {WPElement} Dropdown content element.\n\t */\n\trenderContent( { onClose } ) {\n\t\tconst {\n\t\t\trootClientId,\n\t\t\tclientId,\n\t\t\tisAppender,\n\t\t\tshowInserterHelpPanel,\n\n\t\t\t// This prop is experimental to give some time for the quick inserter to mature\n\t\t\t// Feel free to make them stable after a few releases.\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tprioritizePatterns,\n\t\t\tonSelectOrClose,\n\t\t\tselectBlockOnInsert,\n\t\t} = this.props;\n\n\t\tif ( isQuick ) {\n\t\t\treturn (\n\t\t\t\t<QuickInserter\n\t\t\t\t\tonSelect={ ( blocks ) => {\n\t\t\t\t\t\tconst firstBlock =\n\t\t\t\t\t\t\tArray.isArray( blocks ) && blocks?.length\n\t\t\t\t\t\t\t\t? blocks[ 0 ]\n\t\t\t\t\t\t\t\t: blocks;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tonSelectOrClose &&\n\t\t\t\t\t\t\ttypeof onSelectOrClose === 'function'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tonSelectOrClose( firstBlock );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t\tprioritizePatterns={ prioritizePatterns }\n\t\t\t\t\tselectBlockOnInsert={ selectBlockOnInsert }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tonSelect={ () => {\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshowInserterHelpPanel={ showInserterHelpPanel }\n\t\t\t\tprioritizePatterns={ prioritizePatterns }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tposition,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\tinsertOnlyAllowedBlock,\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t} = this.props;\n\n\t\tif ( hasSingleBlockType || directInsertBlock ) {\n\t\t\treturn this.renderToggle( { onToggle: insertOnlyAllowedBlock } );\n\t\t}\n\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tclassName=\"block-editor-inserter\"\n\t\t\t\tcontentClassName={ classnames(\n\t\t\t\t\t'block-editor-inserter__popover',\n\t\t\t\t\t{ 'is-quick': isQuick }\n\t\t\t\t) }\n\t\t\t\tpopoverProps={ { position, shift: true } }\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\texpandOnMobile\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t\tonClose={ onSelectOrClose }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport const ComposedPrivateInserter = compose( [\n\twithSelect(\n\t\t( select, { clientId, rootClientId, shouldDirectInsert = true } ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasInserterItems,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\t__experimentalGetDirectInsertBlock,\n\t\t\t\tgetSettings,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst { getBlockVariations } = select( blocksStore );\n\n\t\t\trootClientId =\n\t\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( rootClientId );\n\n\t\t\tconst directInsertBlock =\n\t\t\t\tshouldDirectInsert &&\n\t\t\t\t__experimentalGetDirectInsertBlock( rootClientId );\n\n\t\t\tconst settings = getSettings();\n\n\t\t\tconst hasSingleBlockType =\n\t\t\t\tallowedBlocks?.length === 1 &&\n\t\t\t\tgetBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )\n\t\t\t\t\t?.length === 0;\n\n\t\t\tlet allowedBlockType = false;\n\t\t\tif ( hasSingleBlockType ) {\n\t\t\t\tallowedBlockType = allowedBlocks[ 0 ];\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\thasItems: hasInserterItems( rootClientId ),\n\t\t\t\thasSingleBlockType,\n\t\t\t\tblockTitle: allowedBlockType ? allowedBlockType.title : '',\n\t\t\t\tallowedBlockType,\n\t\t\t\tdirectInsertBlock,\n\t\t\t\trootClientId,\n\t\t\t\tprioritizePatterns:\n\t\t\t\t\tsettings.__experimentalPreferPatternsOnRoot &&\n\t\t\t\t\t! rootClientId,\n\t\t\t};\n\t\t}\n\t),\n\twithDispatch( ( dispatch, ownProps, { select } ) => {\n\t\treturn {\n\t\t\tinsertOnlyAllowedBlock() {\n\t\t\t\tconst {\n\t\t\t\t\trootClientId,\n\t\t\t\t\tclientId,\n\t\t\t\t\tisAppender,\n\t\t\t\t\thasSingleBlockType,\n\t\t\t\t\tallowedBlockType,\n\t\t\t\t\tdirectInsertBlock,\n\t\t\t\t\tonSelectOrClose,\n\t\t\t\t\tselectBlockOnInsert,\n\t\t\t\t} = ownProps;\n\n\t\t\t\tif ( ! hasSingleBlockType && ! directInsertBlock ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tfunction getAdjacentBlockAttributes( attributesToCopy ) {\n\t\t\t\t\tconst { getBlock, getPreviousBlockClientId } =\n\t\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t! attributesToCopy ||\n\t\t\t\t\t\t( ! clientId && ! rootClientId )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn {};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst result = {};\n\t\t\t\t\tlet adjacentAttributes = {};\n\n\t\t\t\t\t// If there is no clientId, then attempt to get attributes\n\t\t\t\t\t// from the last block within innerBlocks of the root block.\n\t\t\t\t\tif ( ! clientId ) {\n\t\t\t\t\t\tconst parentBlock = getBlock( rootClientId );\n\n\t\t\t\t\t\tif ( parentBlock?.innerBlocks?.length ) {\n\t\t\t\t\t\t\tconst lastInnerBlock =\n\t\t\t\t\t\t\t\tparentBlock.innerBlocks[\n\t\t\t\t\t\t\t\t\tparentBlock.innerBlocks.length - 1\n\t\t\t\t\t\t\t\t];\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tdirectInsertBlock &&\n\t\t\t\t\t\t\t\tdirectInsertBlock?.name === lastInnerBlock.name\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tadjacentAttributes = lastInnerBlock.attributes;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Otherwise, attempt to get attributes from the\n\t\t\t\t\t\t// previous block relative to the current clientId.\n\t\t\t\t\t\tconst currentBlock = getBlock( clientId );\n\t\t\t\t\t\tconst previousBlock = getBlock(\n\t\t\t\t\t\t\tgetPreviousBlockClientId( clientId )\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( currentBlock?.name === previousBlock?.name ) {\n\t\t\t\t\t\t\tadjacentAttributes =\n\t\t\t\t\t\t\t\tpreviousBlock?.attributes || {};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Copy over only those attributes flagged to be copied.\n\t\t\t\t\tattributesToCopy.forEach( ( attribute ) => {\n\t\t\t\t\t\tif ( adjacentAttributes.hasOwnProperty( attribute ) ) {\n\t\t\t\t\t\t\tresult[ attribute ] =\n\t\t\t\t\t\t\t\tadjacentAttributes[ attribute ];\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tfunction getInsertionIndex() {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetBlockIndex,\n\t\t\t\t\t\tgetBlockSelectionEnd,\n\t\t\t\t\t\tgetBlockOrder,\n\t\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\t\t\tif ( clientId ) {\n\t\t\t\t\t\treturn getBlockIndex( clientId );\n\t\t\t\t\t}\n\n\t\t\t\t\t// If there a selected block, we insert after the selected block.\n\t\t\t\t\tconst end = getBlockSelectionEnd();\n\t\t\t\t\tif (\n\t\t\t\t\t\t! isAppender &&\n\t\t\t\t\t\tend &&\n\t\t\t\t\t\tgetBlockRootClientId( end ) === rootClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn getBlockIndex( end ) + 1;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\t\t\treturn getBlockOrder( rootClientId ).length;\n\t\t\t\t}\n\n\t\t\t\tconst { insertBlock } = dispatch( blockEditorStore );\n\n\t\t\t\tlet blockToInsert;\n\n\t\t\t\t// Attempt to augment the directInsertBlock with attributes from an adjacent block.\n\t\t\t\t// This ensures styling from nearby blocks is preserved in the newly inserted block.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/issues/37904\n\t\t\t\tif ( directInsertBlock ) {\n\t\t\t\t\tconst newAttributes = getAdjacentBlockAttributes(\n\t\t\t\t\t\tdirectInsertBlock.attributesToCopy\n\t\t\t\t\t);\n\n\t\t\t\t\tblockToInsert = createBlock( directInsertBlock.name, {\n\t\t\t\t\t\t...( directInsertBlock.attributes || {} ),\n\t\t\t\t\t\t...newAttributes,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tblockToInsert = createBlock( allowedBlockType.name );\n\t\t\t\t}\n\n\t\t\t\tinsertBlock(\n\t\t\t\t\tblockToInsert,\n\t\t\t\t\tgetInsertionIndex(),\n\t\t\t\t\trootClientId,\n\t\t\t\t\tselectBlockOnInsert\n\t\t\t\t);\n\n\t\t\t\tif ( onSelectOrClose ) {\n\t\t\t\t\tonSelectOrClose( {\n\t\t\t\t\t\tclientId: blockToInsert?.clientId,\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %s: the name of the block that has been added\n\t\t\t\t\t__( '%s block added' ),\n\t\t\t\t\tallowedBlockType.title\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t},\n\t\t};\n\t} ),\n\t// The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as\n\t// a way to detect the global Inserter.\n\tifCondition(\n\t\t( { hasItems, isAppender, rootClientId, clientId } ) =>\n\t\t\thasItems || ( ! isAppender && ! rootClientId && ! clientId )\n\t),\n] )( PrivateInserter );\n\nconst Inserter = forwardRef( ( props, ref ) => {\n\treturn <ComposedPrivateInserter ref={ ref } { ...props } />;\n} );\n\nexport default Inserter;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/index.js"],"names":["classnames","speak","__","_x","sprintf","Dropdown","Button","forwardRef","Component","withDispatch","withSelect","compose","ifCondition","createBlock","store","blocksStore","plus","InserterMenu","QuickInserter","blockEditorStore","defaultRenderToggle","onToggle","disabled","isOpen","blockTitle","hasSingleBlockType","toggleProps","prioritizePatterns","as","Wrapper","label","labelProp","onClick","rest","handleClick","event","PrivateInserter","constructor","arguments","bind","renderToggle","renderContent","props","directInsertBlock","hasItems","onClose","rootClientId","clientId","isAppender","showInserterHelpPanel","__experimentalIsQuick","isQuick","onSelectOrClose","selectBlockOnInsert","blocks","firstBlock","Array","isArray","length","render","position","insertOnlyAllowedBlock","shift","ComposedPrivateInserter","select","shouldDirectInsert","getBlockRootClientId","hasInserterItems","getAllowedBlocks","getDirectInsertBlock","getSettings","getBlockVariations","undefined","allowedBlocks","settings","name","allowedBlockType","title","__experimentalPreferPatternsOnRoot","dispatch","ownProps","getAdjacentBlockAttributes","attributesToCopy","getBlock","getPreviousBlockClientId","result","adjacentAttributes","parentBlock","innerBlocks","lastInnerBlock","attributes","currentBlock","previousBlock","forEach","attribute","hasOwnProperty","getInsertionIndex","getBlockIndex","getBlockSelectionEnd","getBlockOrder","end","insertBlock","blockToInsert","newAttributes","message","Inserter","ref"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SAASC,QAAT,EAAmBC,MAAnB,QAAiC,uBAAjC;AACA,SAASC,UAAT,EAAqBC,SAArB,QAAsC,oBAAtC;AACA,SAASC,YAAT,EAAuBC,UAAvB,QAAyC,iBAAzC;AACA,SAASC,OAAT,EAAkBC,WAAlB,QAAqC,oBAArC;AACA,SAASC,WAAT,EAAsBC,KAAK,IAAIC,WAA/B,QAAkD,mBAAlD;AACA,SAASC,IAAT,QAAqB,kBAArB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,QAAzB;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,SAASJ,KAAK,IAAIK,gBAAlB,QAA0C,aAA1C;;AAEA,MAAMC,mBAAmB,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AF,CAFoB,EAGtB0E,gBAAgB,CAACC,KAHK,CAAvB;AAKA5E,MAAAA,KAAK,CAAEuG,OAAF,CAAL;AACA;;AA5IK,GAAP;AA8IA,CA/IW,CA9CmC,EA8L/C;AACA;AACA5F,WAAW,CACV,CAAE;AAAEgC,EAAAA,QAAF;AAAYI,EAAAA,UAAZ;AAAwBF,EAAAA,YAAxB;AAAsCC,EAAAA;AAAtC,CAAF,KACCH,QAAQ,IAAM,CAAEI,UAAF,IAAgB,CAAEF,YAAlB,IAAkC,CAAEC,QAFzC,CAhMoC,CAAF,CAAP,CAoMlCX,eApMkC,CAAhC;AAsMP,MAAMqE,QAAQ,GAAGlG,UAAU,CAAE,CAAEmC,KAAF,EAASgE,GAAT,KAAkB;AAC9C,SAAO,cAAC,uBAAD;AAAyB,IAAA,GAAG,EAAGA,GAA/B;AAAA,OAA0ChE;AAA1C,IAAP;AACA,CAF0B,CAA3B;AAIA,eAAe+D,QAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { forwardRef, Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, ifCondition } from '@wordpress/compose';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport InserterMenu from './menu';\nimport QuickInserter from './quick-inserter';\nimport { store as blockEditorStore } from '../../store';\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\tisOpen,\n\tblockTitle,\n\thasSingleBlockType,\n\ttoggleProps = {},\n\tprioritizePatterns,\n} ) => {\n\tconst {\n\t\tas: Wrapper = Button,\n\t\tlabel: labelProp,\n\t\tonClick,\n\t\t...rest\n\t} = toggleProps;\n\n\tlet label = labelProp;\n\tif ( ! label && hasSingleBlockType ) {\n\t\tlabel = sprintf(\n\t\t\t// translators: %s: the name of the block when there is only one\n\t\t\t_x( 'Add %s', 'directly add the only allowed block' ),\n\t\t\tblockTitle\n\t\t);\n\t} else if ( ! label && prioritizePatterns ) {\n\t\tlabel = __( 'Add pattern' );\n\t} else if ( ! label ) {\n\t\tlabel = _x( 'Add block', 'Generic label for block inserter button' );\n\t}\n\n\t// Handle both onClick functions from the toggle and the parent component.\n\tfunction handleClick( event ) {\n\t\tif ( onToggle ) {\n\t\t\tonToggle( event );\n\t\t}\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Wrapper\n\t\t\ticon={ plus }\n\t\t\tlabel={ label }\n\t\t\ttooltipPosition=\"bottom\"\n\t\t\tonClick={ handleClick }\n\t\t\tclassName=\"block-editor-inserter__toggle\"\n\t\t\taria-haspopup={ ! hasSingleBlockType ? 'true' : false }\n\t\t\taria-expanded={ ! hasSingleBlockType ? isOpen : false }\n\t\t\tdisabled={ disabled }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n};\n\nclass PrivateInserter extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderToggle = this.renderToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { onToggle } = this.props;\n\n\t\t// Surface toggle callback to parent component.\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown toggle element.\n\t */\n\trenderToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\ttoggleProps,\n\t\t\thasItems,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t\tprioritizePatterns,\n\t\t} = this.props;\n\n\t\treturn renderToggle( {\n\t\t\tonToggle,\n\t\t\tisOpen,\n\t\t\tdisabled: disabled || ! hasItems,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\ttoggleProps,\n\t\t\tprioritizePatterns,\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t *\n\t * @return {WPElement} Dropdown content element.\n\t */\n\trenderContent( { onClose } ) {\n\t\tconst {\n\t\t\trootClientId,\n\t\t\tclientId,\n\t\t\tisAppender,\n\t\t\tshowInserterHelpPanel,\n\n\t\t\t// This prop is experimental to give some time for the quick inserter to mature\n\t\t\t// Feel free to make them stable after a few releases.\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tprioritizePatterns,\n\t\t\tonSelectOrClose,\n\t\t\tselectBlockOnInsert,\n\t\t} = this.props;\n\n\t\tif ( isQuick ) {\n\t\t\treturn (\n\t\t\t\t<QuickInserter\n\t\t\t\t\tonSelect={ ( blocks ) => {\n\t\t\t\t\t\tconst firstBlock =\n\t\t\t\t\t\t\tArray.isArray( blocks ) && blocks?.length\n\t\t\t\t\t\t\t\t? blocks[ 0 ]\n\t\t\t\t\t\t\t\t: blocks;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tonSelectOrClose &&\n\t\t\t\t\t\t\ttypeof onSelectOrClose === 'function'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tonSelectOrClose( firstBlock );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t\tprioritizePatterns={ prioritizePatterns }\n\t\t\t\t\tselectBlockOnInsert={ selectBlockOnInsert }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tonSelect={ () => {\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshowInserterHelpPanel={ showInserterHelpPanel }\n\t\t\t\tprioritizePatterns={ prioritizePatterns }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tposition,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\tinsertOnlyAllowedBlock,\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t} = this.props;\n\n\t\tif ( hasSingleBlockType || directInsertBlock ) {\n\t\t\treturn this.renderToggle( { onToggle: insertOnlyAllowedBlock } );\n\t\t}\n\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tclassName=\"block-editor-inserter\"\n\t\t\t\tcontentClassName={ classnames(\n\t\t\t\t\t'block-editor-inserter__popover',\n\t\t\t\t\t{ 'is-quick': isQuick }\n\t\t\t\t) }\n\t\t\t\tpopoverProps={ { position, shift: true } }\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\texpandOnMobile\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t\tonClose={ onSelectOrClose }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport const ComposedPrivateInserter = compose( [\n\twithSelect(\n\t\t( select, { clientId, rootClientId, shouldDirectInsert = true } ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasInserterItems,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\tgetDirectInsertBlock,\n\t\t\t\tgetSettings,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst { getBlockVariations } = select( blocksStore );\n\n\t\t\trootClientId =\n\t\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( rootClientId );\n\n\t\t\tconst directInsertBlock =\n\t\t\t\tshouldDirectInsert && getDirectInsertBlock( rootClientId );\n\n\t\t\tconst settings = getSettings();\n\n\t\t\tconst hasSingleBlockType =\n\t\t\t\tallowedBlocks?.length === 1 &&\n\t\t\t\tgetBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )\n\t\t\t\t\t?.length === 0;\n\n\t\t\tlet allowedBlockType = false;\n\t\t\tif ( hasSingleBlockType ) {\n\t\t\t\tallowedBlockType = allowedBlocks[ 0 ];\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\thasItems: hasInserterItems( rootClientId ),\n\t\t\t\thasSingleBlockType,\n\t\t\t\tblockTitle: allowedBlockType ? allowedBlockType.title : '',\n\t\t\t\tallowedBlockType,\n\t\t\t\tdirectInsertBlock,\n\t\t\t\trootClientId,\n\t\t\t\tprioritizePatterns:\n\t\t\t\t\tsettings.__experimentalPreferPatternsOnRoot &&\n\t\t\t\t\t! rootClientId,\n\t\t\t};\n\t\t}\n\t),\n\twithDispatch( ( dispatch, ownProps, { select } ) => {\n\t\treturn {\n\t\t\tinsertOnlyAllowedBlock() {\n\t\t\t\tconst {\n\t\t\t\t\trootClientId,\n\t\t\t\t\tclientId,\n\t\t\t\t\tisAppender,\n\t\t\t\t\thasSingleBlockType,\n\t\t\t\t\tallowedBlockType,\n\t\t\t\t\tdirectInsertBlock,\n\t\t\t\t\tonSelectOrClose,\n\t\t\t\t\tselectBlockOnInsert,\n\t\t\t\t} = ownProps;\n\n\t\t\t\tif ( ! hasSingleBlockType && ! directInsertBlock ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tfunction getAdjacentBlockAttributes( attributesToCopy ) {\n\t\t\t\t\tconst { getBlock, getPreviousBlockClientId } =\n\t\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t! attributesToCopy ||\n\t\t\t\t\t\t( ! clientId && ! rootClientId )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn {};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst result = {};\n\t\t\t\t\tlet adjacentAttributes = {};\n\n\t\t\t\t\t// If there is no clientId, then attempt to get attributes\n\t\t\t\t\t// from the last block within innerBlocks of the root block.\n\t\t\t\t\tif ( ! clientId ) {\n\t\t\t\t\t\tconst parentBlock = getBlock( rootClientId );\n\n\t\t\t\t\t\tif ( parentBlock?.innerBlocks?.length ) {\n\t\t\t\t\t\t\tconst lastInnerBlock =\n\t\t\t\t\t\t\t\tparentBlock.innerBlocks[\n\t\t\t\t\t\t\t\t\tparentBlock.innerBlocks.length - 1\n\t\t\t\t\t\t\t\t];\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tdirectInsertBlock &&\n\t\t\t\t\t\t\t\tdirectInsertBlock?.name === lastInnerBlock.name\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tadjacentAttributes = lastInnerBlock.attributes;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Otherwise, attempt to get attributes from the\n\t\t\t\t\t\t// previous block relative to the current clientId.\n\t\t\t\t\t\tconst currentBlock = getBlock( clientId );\n\t\t\t\t\t\tconst previousBlock = getBlock(\n\t\t\t\t\t\t\tgetPreviousBlockClientId( clientId )\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( currentBlock?.name === previousBlock?.name ) {\n\t\t\t\t\t\t\tadjacentAttributes =\n\t\t\t\t\t\t\t\tpreviousBlock?.attributes || {};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Copy over only those attributes flagged to be copied.\n\t\t\t\t\tattributesToCopy.forEach( ( attribute ) => {\n\t\t\t\t\t\tif ( adjacentAttributes.hasOwnProperty( attribute ) ) {\n\t\t\t\t\t\t\tresult[ attribute ] =\n\t\t\t\t\t\t\t\tadjacentAttributes[ attribute ];\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tfunction getInsertionIndex() {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetBlockIndex,\n\t\t\t\t\t\tgetBlockSelectionEnd,\n\t\t\t\t\t\tgetBlockOrder,\n\t\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\t\t\tif ( clientId ) {\n\t\t\t\t\t\treturn getBlockIndex( clientId );\n\t\t\t\t\t}\n\n\t\t\t\t\t// If there a selected block, we insert after the selected block.\n\t\t\t\t\tconst end = getBlockSelectionEnd();\n\t\t\t\t\tif (\n\t\t\t\t\t\t! isAppender &&\n\t\t\t\t\t\tend &&\n\t\t\t\t\t\tgetBlockRootClientId( end ) === rootClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn getBlockIndex( end ) + 1;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\t\t\treturn getBlockOrder( rootClientId ).length;\n\t\t\t\t}\n\n\t\t\t\tconst { insertBlock } = dispatch( blockEditorStore );\n\n\t\t\t\tlet blockToInsert;\n\n\t\t\t\t// Attempt to augment the directInsertBlock with attributes from an adjacent block.\n\t\t\t\t// This ensures styling from nearby blocks is preserved in the newly inserted block.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/issues/37904\n\t\t\t\tif ( directInsertBlock ) {\n\t\t\t\t\tconst newAttributes = getAdjacentBlockAttributes(\n\t\t\t\t\t\tdirectInsertBlock.attributesToCopy\n\t\t\t\t\t);\n\n\t\t\t\t\tblockToInsert = createBlock( directInsertBlock.name, {\n\t\t\t\t\t\t...( directInsertBlock.attributes || {} ),\n\t\t\t\t\t\t...newAttributes,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tblockToInsert = createBlock( allowedBlockType.name );\n\t\t\t\t}\n\n\t\t\t\tinsertBlock(\n\t\t\t\t\tblockToInsert,\n\t\t\t\t\tgetInsertionIndex(),\n\t\t\t\t\trootClientId,\n\t\t\t\t\tselectBlockOnInsert\n\t\t\t\t);\n\n\t\t\t\tif ( onSelectOrClose ) {\n\t\t\t\t\tonSelectOrClose( {\n\t\t\t\t\t\tclientId: blockToInsert?.clientId,\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %s: the name of the block that has been added\n\t\t\t\t\t__( '%s block added' ),\n\t\t\t\t\tallowedBlockType.title\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t},\n\t\t};\n\t} ),\n\t// The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as\n\t// a way to detect the global Inserter.\n\tifCondition(\n\t\t( { hasItems, isAppender, rootClientId, clientId } ) =>\n\t\t\thasItems || ( ! isAppender && ! rootClientId && ! clientId )\n\t),\n] )( PrivateInserter );\n\nconst Inserter = forwardRef( ( props, ref ) => {\n\treturn <ComposedPrivateInserter ref={ ref } { ...props } />;\n} );\n\nexport default Inserter;\n"]}
|
|
@@ -3,7 +3,7 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { AccessibilityInfo, Platform
|
|
6
|
+
import { AccessibilityInfo, Platform } from 'react-native';
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
@@ -29,31 +29,15 @@ const VOICE_OVER_ANNOUNCEMENT_DELAY = 1000;
|
|
|
29
29
|
const defaultRenderToggle = ({
|
|
30
30
|
onToggle,
|
|
31
31
|
disabled,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
onLongPress
|
|
35
|
-
useExpandedMode
|
|
32
|
+
iconStyle,
|
|
33
|
+
buttonStyle,
|
|
34
|
+
onLongPress
|
|
36
35
|
}) => {
|
|
37
|
-
// The "expanded mode" refers to the editor's appearance when no blocks
|
|
38
|
-
// are currently selected. The "add block" button has a separate style
|
|
39
|
-
// for the "expanded mode", which are added via the below "expandedModeViewProps"
|
|
40
|
-
// and "expandedModeViewText" variables.
|
|
41
|
-
const expandedModeViewProps = useExpandedMode && {
|
|
42
|
-
icon: createElement(Icon, {
|
|
43
|
-
icon: plus,
|
|
44
|
-
style: style
|
|
45
|
-
}),
|
|
46
|
-
customContainerStyles: containerStyle,
|
|
47
|
-
fixedRatio: false
|
|
48
|
-
};
|
|
49
|
-
const expandedModeViewText = createElement(Text, {
|
|
50
|
-
style: styles['inserter-menu__add-block-button-text']
|
|
51
|
-
}, __('Add blocks'));
|
|
52
36
|
return createElement(ToolbarButton, {
|
|
53
37
|
title: _x('Add block', 'Generic label for block inserter button'),
|
|
54
38
|
icon: createElement(Icon, {
|
|
55
|
-
icon:
|
|
56
|
-
style:
|
|
39
|
+
icon: plus,
|
|
40
|
+
style: iconStyle
|
|
57
41
|
}),
|
|
58
42
|
onClick: onToggle,
|
|
59
43
|
extraProps: {
|
|
@@ -61,11 +45,18 @@ const defaultRenderToggle = ({
|
|
|
61
45
|
// testID is present to disambiguate this element for native UI tests. It's not
|
|
62
46
|
// usually required for components. See: https://github.com/WordPress/gutenberg/pull/18832#issuecomment-561411389.
|
|
63
47
|
testID: 'add-block-button',
|
|
64
|
-
onLongPress
|
|
48
|
+
onLongPress,
|
|
49
|
+
hitSlop: {
|
|
50
|
+
top: 10,
|
|
51
|
+
bottom: 10,
|
|
52
|
+
left: 10,
|
|
53
|
+
right: 10
|
|
54
|
+
}
|
|
65
55
|
},
|
|
66
56
|
isDisabled: disabled,
|
|
67
|
-
|
|
68
|
-
|
|
57
|
+
customContainerStyles: buttonStyle,
|
|
58
|
+
fixedRatio: false
|
|
59
|
+
});
|
|
69
60
|
};
|
|
70
61
|
|
|
71
62
|
export class Inserter extends Component {
|
|
@@ -228,16 +219,15 @@ export class Inserter extends Component {
|
|
|
228
219
|
disabled,
|
|
229
220
|
renderToggle = defaultRenderToggle,
|
|
230
221
|
getStylesFromColorScheme,
|
|
231
|
-
showSeparator
|
|
232
|
-
useExpandedMode
|
|
222
|
+
showSeparator
|
|
233
223
|
} = this.props;
|
|
234
224
|
|
|
235
225
|
if (showSeparator && isOpen) {
|
|
236
226
|
return createElement(BlockInsertionPoint, null);
|
|
237
227
|
}
|
|
238
228
|
|
|
239
|
-
const
|
|
240
|
-
const
|
|
229
|
+
const buttonStyle = getStylesFromColorScheme(styles['inserter-menu__add-block-button'], styles['inserter-menu__add-block-button--dark']);
|
|
230
|
+
const iconStyle = getStylesFromColorScheme(styles['inserter-menu__add-block-button-icon'], styles['inserter-menu__add-block-button-icon--dark']);
|
|
241
231
|
|
|
242
232
|
const onPress = () => {
|
|
243
233
|
this.setState({
|
|
@@ -265,10 +255,9 @@ export class Inserter extends Component {
|
|
|
265
255
|
onToggle: onPress,
|
|
266
256
|
isOpen,
|
|
267
257
|
disabled,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
onLongPress
|
|
271
|
-
useExpandedMode
|
|
258
|
+
iconStyle,
|
|
259
|
+
buttonStyle,
|
|
260
|
+
onLongPress
|
|
272
261
|
}), createElement(Picker, {
|
|
273
262
|
ref: instance => this.picker = instance,
|
|
274
263
|
options: this.getInsertionOptions(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/index.native.js"],"names":["AccessibilityInfo","Platform","Text","__","_x","Dropdown","ToolbarButton","Picker","Component","withDispatch","withSelect","compose","withPreferredColorScheme","isUnmodifiedDefaultBlock","Icon","plus","plusCircle","plusCircleFilled","insertAfter","insertBefore","setBlockTypeImpressions","styles","InserterMenu","BlockInsertionPoint","store","blockEditorStore","VOICE_OVER_ANNOUNCEMENT_DELAY","defaultRenderToggle","onToggle","disabled","style","containerStyle","onLongPress","useExpandedMode","expandedModeViewProps","icon","customContainerStyles","fixedRatio","expandedModeViewText","hint","testID","Inserter","announcementTimeout","constructor","arguments","bind","renderInserterToggle","renderContent","componentWillUnmount","clearTimeout","getInsertionOptions","addBeforeOption","value","label","replaceCurrentOption","addAfterOption","addToBeginningOption","addToEndOption","isAnyBlockSelected","isSelectedBlockReplaceable","props","getInsertionIndex","insertionType","insertionIndexDefault","insertionIndexStart","insertionIndexBefore","insertionIndexAfter","insertionIndexEnd","shouldReplaceBlock","isOpen","blockTypeImpressions","updateSettings","impressionsRemain","Object","values","some","count","decrementedImpressions","entries","reduce","acc","blockName","Math","max","impressions","onInserterToggledAnnouncement","isScreenReaderEnabled","then","isEnabled","isIOS","OS","announcement","setTimeout","announceForAccessibility","renderToggle","getStylesFromColorScheme","showSeparator","onPress","setState","destinationRootClientId","insertionIndex","picker","presentPicker","onPickerSelect","instance","onClose","clientId","isAppender","state","render","dispatch","select","rootClientId","getBlockRootClientId","getBlockSelectionEnd","getBlockOrder","getBlockIndex","getBlock","getSettings","getBlockEditorSettings","end","selectedBlockIndex","endOfRootIndex","length","isSelectedUnmodifiedDefaultBlock","undefined","getDefaultInsertionIndex","__experimentalShouldInsertAtTheTop","shouldInsertAtTheTop"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,iBAAT,EAA4BC,QAA5B,EAAsCC,IAAtC,QAAkD,cAAlD;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,QAAT,EAAmBC,aAAnB,EAAkCC,MAAlC,QAAgD,uBAAhD;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,YAAT,EAAuBC,UAAvB,QAAyC,iBAAzC;AACA,SAASC,OAAT,EAAkBC,wBAAlB,QAAkD,oBAAlD;AACA,SAASC,wBAAT,QAAyC,mBAAzC;AACA,SACCC,IADD,EAECC,IAFD,EAGCC,UAHD,E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IA,WAASC,wBAAT,GAAoC;AACnC,UAAM;AAAEC,MAAAA,kCAAkC,EAAEC;AAAtC,QACLT,sBAAsB,EADvB,CADmC,CAInC;;AACA,QAAKS,oBAAL,EAA4B;AAC3B,aAAO,CAAP;AACA,KAPkC,CASnC;;;AACA,QAAKtB,QAAL,EAAgB;AACf,aAAOU,aAAa,CAAEV,QAAF,CAApB;AACA,KAZkC,CAcnC;;;AACA,QAAKhD,kBAAL,EAA0B;AACzB;AACA,UAAKkE,gCAAL,EAAwC;AACvC,eAAOH,kBAAP;AACA,OAJwB,CAMzB;;;AACA,aAAOA,kBAAkB,GAAG,CAA5B;AACA,KAvBkC,CAyBnC;;;AACA,WAAOC,cAAP;AACA;;AAED,QAAM1D,mBAAmB,GAAG,CAA5B;AAEA,QAAMC,oBAAoB,GAAGP,kBAAkB,GAC5C+D,kBAD4C,GAE5CzD,mBAFH;AAIA,QAAME,mBAAmB,GAAGR,kBAAkB,GAC3C+D,kBAAkB,GAAG,CADsB,GAE3CC,cAFH;AAIA,QAAMvD,iBAAiB,GAAGuD,cAA1B;AAEA,SAAO;AACNpD,IAAAA,oBAAoB,EAAEiD,sBAAsB,GAAGnC,WADzC;AAENe,IAAAA,uBAFM;AAGNpC,IAAAA,qBAAqB,EAAE+D,wBAAwB,EAHzC;AAIN7D,IAAAA,oBAJM;AAKNC,IAAAA,mBALM;AAMNF,IAAAA,mBANM;AAONG,IAAAA,iBAPM;AAQNT,IAAAA,kBAAkB,EAAE,CAAC,CAAEA,kBARjB;AASNC,IAAAA,0BAA0B,EAAEiE;AATtB,GAAP;AAWA,CA5ES,CALa,EAmFvBhH,wBAnFuB,CAAF,CAAP,CAoFV6B,QApFU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { AccessibilityInfo, Platform, Text } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { Dropdown, ToolbarButton, Picker } from '@wordpress/components';\nimport { Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, withPreferredColorScheme } from '@wordpress/compose';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport {\n\tIcon,\n\tplus,\n\tplusCircle,\n\tplusCircleFilled,\n\tinsertAfter,\n\tinsertBefore,\n} from '@wordpress/icons';\nimport { setBlockTypeImpressions } from '@wordpress/react-native-bridge';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport InserterMenu from './menu';\nimport BlockInsertionPoint from '../block-list/insertion-point';\nimport { store as blockEditorStore } from '../../store';\n\nconst VOICE_OVER_ANNOUNCEMENT_DELAY = 1000;\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\tstyle,\n\tcontainerStyle,\n\tonLongPress,\n\tuseExpandedMode,\n} ) => {\n\t// The \"expanded mode\" refers to the editor's appearance when no blocks\n\t// are currently selected. The \"add block\" button has a separate style\n\t// for the \"expanded mode\", which are added via the below \"expandedModeViewProps\"\n\t// and \"expandedModeViewText\" variables.\n\tconst expandedModeViewProps = useExpandedMode && {\n\t\ticon: <Icon icon={ plus } style={ style } />,\n\t\tcustomContainerStyles: containerStyle,\n\t\tfixedRatio: false,\n\t};\n\tconst expandedModeViewText = (\n\t\t<Text style={ styles[ 'inserter-menu__add-block-button-text' ] }>\n\t\t\t{ __( 'Add blocks' ) }\n\t\t</Text>\n\t);\n\n\treturn (\n\t\t<ToolbarButton\n\t\t\ttitle={ _x(\n\t\t\t\t'Add block',\n\t\t\t\t'Generic label for block inserter button'\n\t\t\t) }\n\t\t\ticon={ <Icon icon={ plusCircleFilled } style={ style } /> }\n\t\t\tonClick={ onToggle }\n\t\t\textraProps={ {\n\t\t\t\thint: __( 'Double tap to add a block' ),\n\t\t\t\t// testID is present to disambiguate this element for native UI tests. It's not\n\t\t\t\t// usually required for components. See: https://github.com/WordPress/gutenberg/pull/18832#issuecomment-561411389.\n\t\t\t\ttestID: 'add-block-button',\n\t\t\t\tonLongPress,\n\t\t\t} }\n\t\t\tisDisabled={ disabled }\n\t\t\t{ ...expandedModeViewProps }\n\t\t>\n\t\t\t{ useExpandedMode && expandedModeViewText }\n\t\t</ToolbarButton>\n\t);\n};\n\nexport class Inserter extends Component {\n\tannouncementTimeout;\n\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderInserterToggle = this.renderInserterToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tclearTimeout( this.announcementTimeout );\n\t}\n\n\tgetInsertionOptions() {\n\t\tconst addBeforeOption = {\n\t\t\tvalue: 'before',\n\t\t\tlabel: __( 'Add Block Before' ),\n\t\t\ticon: plusCircle,\n\t\t};\n\n\t\tconst replaceCurrentOption = {\n\t\t\tvalue: 'replace',\n\t\t\tlabel: __( 'Replace Current Block' ),\n\t\t\ticon: plusCircleFilled,\n\t\t};\n\n\t\tconst addAfterOption = {\n\t\t\tvalue: 'after',\n\t\t\tlabel: __( 'Add Block After' ),\n\t\t\ticon: plusCircle,\n\t\t};\n\n\t\tconst addToBeginningOption = {\n\t\t\tvalue: 'start',\n\t\t\tlabel: __( 'Add To Beginning' ),\n\t\t\ticon: insertBefore,\n\t\t};\n\n\t\tconst addToEndOption = {\n\t\t\tvalue: 'end',\n\t\t\tlabel: __( 'Add To End' ),\n\t\t\ticon: insertAfter,\n\t\t};\n\n\t\tconst { isAnyBlockSelected, isSelectedBlockReplaceable } = this.props;\n\t\tif ( isAnyBlockSelected ) {\n\t\t\tif ( isSelectedBlockReplaceable ) {\n\t\t\t\treturn [\n\t\t\t\t\taddToBeginningOption,\n\t\t\t\t\taddBeforeOption,\n\t\t\t\t\treplaceCurrentOption,\n\t\t\t\t\taddAfterOption,\n\t\t\t\t\taddToEndOption,\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn [\n\t\t\t\taddToBeginningOption,\n\t\t\t\taddBeforeOption,\n\t\t\t\taddAfterOption,\n\t\t\t\taddToEndOption,\n\t\t\t];\n\t\t}\n\t\treturn [ addToBeginningOption, addToEndOption ];\n\t}\n\n\tgetInsertionIndex( insertionType ) {\n\t\tconst {\n\t\t\tinsertionIndexDefault,\n\t\t\tinsertionIndexStart,\n\t\t\tinsertionIndexBefore,\n\t\t\tinsertionIndexAfter,\n\t\t\tinsertionIndexEnd,\n\t\t} = this.props;\n\t\tif ( insertionType === 'start' ) {\n\t\t\treturn insertionIndexStart;\n\t\t}\n\t\tif ( insertionType === 'before' || insertionType === 'replace' ) {\n\t\t\treturn insertionIndexBefore;\n\t\t}\n\t\tif ( insertionType === 'after' ) {\n\t\t\treturn insertionIndexAfter;\n\t\t}\n\t\tif ( insertionType === 'end' ) {\n\t\t\treturn insertionIndexEnd;\n\t\t}\n\t\treturn insertionIndexDefault;\n\t}\n\n\tshouldReplaceBlock( insertionType ) {\n\t\tconst { isSelectedBlockReplaceable } = this.props;\n\t\tif ( insertionType === 'replace' ) {\n\t\t\treturn true;\n\t\t}\n\t\tif ( insertionType === 'default' && isSelectedBlockReplaceable ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { blockTypeImpressions, onToggle, updateSettings } = this.props;\n\n\t\tif ( ! isOpen ) {\n\t\t\tconst impressionsRemain = Object.values(\n\t\t\t\tblockTypeImpressions\n\t\t\t).some( ( count ) => count > 0 );\n\n\t\t\tif ( impressionsRemain ) {\n\t\t\t\tconst decrementedImpressions = Object.entries(\n\t\t\t\t\tblockTypeImpressions\n\t\t\t\t).reduce(\n\t\t\t\t\t( acc, [ blockName, count ] ) => ( {\n\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t[ blockName ]: Math.max( count - 1, 0 ),\n\t\t\t\t\t} ),\n\t\t\t\t\t{}\n\t\t\t\t);\n\n\t\t\t\t// Persist block type impression to JavaScript store.\n\t\t\t\tupdateSettings( {\n\t\t\t\t\timpressions: decrementedImpressions,\n\t\t\t\t} );\n\n\t\t\t\t// Persist block type impression count to native app store.\n\t\t\t\tsetBlockTypeImpressions( decrementedImpressions );\n\t\t\t}\n\t\t}\n\n\t\t// Surface toggle callback to parent component.\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t\tthis.onInserterToggledAnnouncement( isOpen );\n\t}\n\n\tonInserterToggledAnnouncement( isOpen ) {\n\t\tAccessibilityInfo.isScreenReaderEnabled().then( ( isEnabled ) => {\n\t\t\tif ( isEnabled ) {\n\t\t\t\tconst isIOS = Platform.OS === 'ios';\n\t\t\t\tconst announcement = isOpen\n\t\t\t\t\t? __( 'Scrollable block menu opened. Select a block.' )\n\t\t\t\t\t: __( 'Scrollable block menu closed.' );\n\t\t\t\tthis.announcementTimeout = setTimeout(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tAccessibilityInfo.announceForAccessibility(\n\t\t\t\t\t\t\tannouncement\n\t\t\t\t\t\t),\n\t\t\t\t\tisIOS ? VOICE_OVER_ANNOUNCEMENT_DELAY : 0\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown toggle element.\n\t */\n\trenderInserterToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t\tgetStylesFromColorScheme,\n\t\t\tshowSeparator,\n\t\t\tuseExpandedMode,\n\t\t} = this.props;\n\t\tif ( showSeparator && isOpen ) {\n\t\t\treturn <BlockInsertionPoint />;\n\t\t}\n\t\tconst style = useExpandedMode\n\t\t\t? styles[ 'inserter-menu__add-block-button-icon--expanded' ]\n\t\t\t: getStylesFromColorScheme(\n\t\t\t\t\tstyles[ 'inserter-menu__add-block-button-icon' ],\n\t\t\t\t\tstyles[ 'inserter-menu__add-block-button-icon--dark' ]\n\t\t\t );\n\n\t\tconst containerStyle = getStylesFromColorScheme(\n\t\t\tstyles[ 'inserter-menu__add-block-button' ],\n\t\t\tstyles[ 'inserter-menu__add-block-button--dark' ]\n\t\t);\n\n\t\tconst onPress = () => {\n\t\t\tthis.setState(\n\t\t\t\t{\n\t\t\t\t\tdestinationRootClientId: this.props.destinationRootClientId,\n\t\t\t\t\tshouldReplaceBlock: this.shouldReplaceBlock( 'default' ),\n\t\t\t\t\tinsertionIndex: this.getInsertionIndex( 'default' ),\n\t\t\t\t},\n\t\t\t\tonToggle\n\t\t\t);\n\t\t};\n\n\t\tconst onLongPress = () => {\n\t\t\tif ( this.picker ) {\n\t\t\t\tthis.picker.presentPicker();\n\t\t\t}\n\t\t};\n\n\t\tconst onPickerSelect = ( insertionType ) => {\n\t\t\tthis.setState(\n\t\t\t\t{\n\t\t\t\t\tdestinationRootClientId: this.props.destinationRootClientId,\n\t\t\t\t\tshouldReplaceBlock:\n\t\t\t\t\t\tthis.shouldReplaceBlock( insertionType ),\n\t\t\t\t\tinsertionIndex: this.getInsertionIndex( insertionType ),\n\t\t\t\t},\n\t\t\t\tonToggle\n\t\t\t);\n\t\t};\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ renderToggle( {\n\t\t\t\t\tonToggle: onPress,\n\t\t\t\t\tisOpen,\n\t\t\t\t\tdisabled,\n\t\t\t\t\tstyle,\n\t\t\t\t\tcontainerStyle,\n\t\t\t\t\tonLongPress,\n\t\t\t\t\tuseExpandedMode,\n\t\t\t\t} ) }\n\t\t\t\t<Picker\n\t\t\t\t\tref={ ( instance ) => ( this.picker = instance ) }\n\t\t\t\t\toptions={ this.getInsertionOptions() }\n\t\t\t\t\tonChange={ onPickerSelect }\n\t\t\t\t\thideCancelButton\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown content element.\n\t */\n\trenderContent( { onClose, isOpen } ) {\n\t\tconst { clientId, isAppender } = this.props;\n\t\tconst { destinationRootClientId, shouldReplaceBlock, insertionIndex } =\n\t\t\tthis.state;\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tisOpen={ isOpen }\n\t\t\t\tonSelect={ onClose }\n\t\t\t\tonDismiss={ onClose }\n\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshouldReplaceBlock={ shouldReplaceBlock }\n\t\t\t\tinsertionIndex={ insertionIndex }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderInserterToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithDispatch( ( dispatch ) => {\n\t\tconst { updateSettings } = dispatch( blockEditorStore );\n\t\treturn { updateSettings };\n\t} ),\n\twithSelect( ( select, { clientId, isAppender, rootClientId } ) => {\n\t\tconst {\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockSelectionEnd,\n\t\t\tgetBlockOrder,\n\t\t\tgetBlockIndex,\n\t\t\tgetBlock,\n\t\t\tgetSettings: getBlockEditorSettings,\n\t\t} = select( blockEditorStore );\n\n\t\tconst end = getBlockSelectionEnd();\n\t\t// `end` argument (id) can refer to the component which is removed\n\t\t// due to pressing `undo` button, that's why we need to check\n\t\t// if `getBlock( end) is valid, otherwise `null` is passed\n\t\tconst isAnyBlockSelected = ! isAppender && end && getBlock( end );\n\t\tconst destinationRootClientId = isAnyBlockSelected\n\t\t\t? getBlockRootClientId( end )\n\t\t\t: rootClientId;\n\t\tconst selectedBlockIndex = getBlockIndex( end );\n\t\tconst endOfRootIndex = getBlockOrder( rootClientId ).length;\n\t\tconst isSelectedUnmodifiedDefaultBlock = isAnyBlockSelected\n\t\t\t? isUnmodifiedDefaultBlock( getBlock( end ) )\n\t\t\t: undefined;\n\n\t\tfunction getDefaultInsertionIndex() {\n\t\t\tconst { __experimentalShouldInsertAtTheTop: shouldInsertAtTheTop } =\n\t\t\t\tgetBlockEditorSettings();\n\n\t\t\t// If post title is selected insert as first block.\n\t\t\tif ( shouldInsertAtTheTop ) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\tif ( clientId ) {\n\t\t\t\treturn getBlockIndex( clientId );\n\t\t\t}\n\n\t\t\t// If there is a selected block,\n\t\t\tif ( isAnyBlockSelected ) {\n\t\t\t\t// And the last selected block is unmodified (empty), it will be replaced.\n\t\t\t\tif ( isSelectedUnmodifiedDefaultBlock ) {\n\t\t\t\t\treturn selectedBlockIndex;\n\t\t\t\t}\n\n\t\t\t\t// We insert after the selected block.\n\t\t\t\treturn selectedBlockIndex + 1;\n\t\t\t}\n\n\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\treturn endOfRootIndex;\n\t\t}\n\n\t\tconst insertionIndexStart = 0;\n\n\t\tconst insertionIndexBefore = isAnyBlockSelected\n\t\t\t? selectedBlockIndex\n\t\t\t: insertionIndexStart;\n\n\t\tconst insertionIndexAfter = isAnyBlockSelected\n\t\t\t? selectedBlockIndex + 1\n\t\t\t: endOfRootIndex;\n\n\t\tconst insertionIndexEnd = endOfRootIndex;\n\n\t\treturn {\n\t\t\tblockTypeImpressions: getBlockEditorSettings().impressions,\n\t\t\tdestinationRootClientId,\n\t\t\tinsertionIndexDefault: getDefaultInsertionIndex(),\n\t\t\tinsertionIndexBefore,\n\t\t\tinsertionIndexAfter,\n\t\t\tinsertionIndexStart,\n\t\t\tinsertionIndexEnd,\n\t\t\tisAnyBlockSelected: !! isAnyBlockSelected,\n\t\t\tisSelectedBlockReplaceable: isSelectedUnmodifiedDefaultBlock,\n\t\t};\n\t} ),\n\n\twithPreferredColorScheme,\n] )( Inserter );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/index.native.js"],"names":["AccessibilityInfo","Platform","__","_x","Dropdown","ToolbarButton","Picker","Component","withDispatch","withSelect","compose","withPreferredColorScheme","isUnmodifiedDefaultBlock","Icon","plus","plusCircle","plusCircleFilled","insertAfter","insertBefore","setBlockTypeImpressions","styles","InserterMenu","BlockInsertionPoint","store","blockEditorStore","VOICE_OVER_ANNOUNCEMENT_DELAY","defaultRenderToggle","onToggle","disabled","iconStyle","buttonStyle","onLongPress","hint","testID","hitSlop","top","bottom","left","right","Inserter","announcementTimeout","constructor","arguments","bind","renderInserterToggle","renderContent","componentWillUnmount","clearTimeout","getInsertionOptions","addBeforeOption","value","label","icon","replaceCurrentOption","addAfterOption","addToBeginningOption","addToEndOption","isAnyBlockSelected","isSelectedBlockReplaceable","props","getInsertionIndex","insertionType","insertionIndexDefault","insertionIndexStart","insertionIndexBefore","insertionIndexAfter","insertionIndexEnd","shouldReplaceBlock","isOpen","blockTypeImpressions","updateSettings","impressionsRemain","Object","values","some","count","decrementedImpressions","entries","reduce","acc","blockName","Math","max","impressions","onInserterToggledAnnouncement","isScreenReaderEnabled","then","isEnabled","isIOS","OS","announcement","setTimeout","announceForAccessibility","renderToggle","getStylesFromColorScheme","showSeparator","onPress","setState","destinationRootClientId","insertionIndex","picker","presentPicker","onPickerSelect","instance","onClose","clientId","isAppender","state","render","dispatch","select","rootClientId","getBlockRootClientId","getBlockSelectionEnd","getBlockOrder","getBlockIndex","getBlock","getSettings","getBlockEditorSettings","end","selectedBlockIndex","endOfRootIndex","length","isSelectedUnmodifiedDefaultBlock","undefined","getDefaultInsertionIndex","__experimentalShouldInsertAtTheTop","shouldInsertAtTheTop"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,iBAAT,EA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CAAEwG,QAAQ,CAAEG,GAAF,CAAV,CADgC,GAExDK,SAFH;;AAIA,WAASC,wBAAT,GAAoC;AACnC,UAAM;AAAEC,MAAAA,kCAAkC,EAAEC;AAAtC,QACLT,sBAAsB,EADvB,CADmC,CAInC;;AACA,QAAKS,oBAAL,EAA4B;AAC3B,aAAO,CAAP;AACA,KAPkC,CASnC;;;AACA,QAAKtB,QAAL,EAAgB;AACf,aAAOU,aAAa,CAAEV,QAAF,CAApB;AACA,KAZkC,CAcnC;;;AACA,QAAKhD,kBAAL,EAA0B;AACzB;AACA,UAAKkE,gCAAL,EAAwC;AACvC,eAAOH,kBAAP;AACA,OAJwB,CAMzB;;;AACA,aAAOA,kBAAkB,GAAG,CAA5B;AACA,KAvBkC,CAyBnC;;;AACA,WAAOC,cAAP;AACA;;AAED,QAAM1D,mBAAmB,GAAG,CAA5B;AAEA,QAAMC,oBAAoB,GAAGP,kBAAkB,GAC5C+D,kBAD4C,GAE5CzD,mBAFH;AAIA,QAAME,mBAAmB,GAAGR,kBAAkB,GAC3C+D,kBAAkB,GAAG,CADsB,GAE3CC,cAFH;AAIA,QAAMvD,iBAAiB,GAAGuD,cAA1B;AAEA,SAAO;AACNpD,IAAAA,oBAAoB,EAAEiD,sBAAsB,GAAGnC,WADzC;AAENe,IAAAA,uBAFM;AAGNpC,IAAAA,qBAAqB,EAAE+D,wBAAwB,EAHzC;AAIN7D,IAAAA,oBAJM;AAKNC,IAAAA,mBALM;AAMNF,IAAAA,mBANM;AAONG,IAAAA,iBAPM;AAQNT,IAAAA,kBAAkB,EAAE,CAAC,CAAEA,kBARjB;AASNC,IAAAA,0BAA0B,EAAEiE;AATtB,GAAP;AAWA,CA5ES,CALa,EAmFvBhH,wBAnFuB,CAAF,CAAP,CAoFV4B,QApFU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { AccessibilityInfo, Platform } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { Dropdown, ToolbarButton, Picker } from '@wordpress/components';\nimport { Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, withPreferredColorScheme } from '@wordpress/compose';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport {\n\tIcon,\n\tplus,\n\tplusCircle,\n\tplusCircleFilled,\n\tinsertAfter,\n\tinsertBefore,\n} from '@wordpress/icons';\nimport { setBlockTypeImpressions } from '@wordpress/react-native-bridge';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport InserterMenu from './menu';\nimport BlockInsertionPoint from '../block-list/insertion-point';\nimport { store as blockEditorStore } from '../../store';\n\nconst VOICE_OVER_ANNOUNCEMENT_DELAY = 1000;\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\ticonStyle,\n\tbuttonStyle,\n\tonLongPress,\n} ) => {\n\treturn (\n\t\t<ToolbarButton\n\t\t\ttitle={ _x(\n\t\t\t\t'Add block',\n\t\t\t\t'Generic label for block inserter button'\n\t\t\t) }\n\t\t\ticon={ <Icon icon={ plus } style={ iconStyle } /> }\n\t\t\tonClick={ onToggle }\n\t\t\textraProps={ {\n\t\t\t\thint: __( 'Double tap to add a block' ),\n\t\t\t\t// testID is present to disambiguate this element for native UI tests. It's not\n\t\t\t\t// usually required for components. See: https://github.com/WordPress/gutenberg/pull/18832#issuecomment-561411389.\n\t\t\t\ttestID: 'add-block-button',\n\t\t\t\tonLongPress,\n\t\t\t\thitSlop: { top: 10, bottom: 10, left: 10, right: 10 },\n\t\t\t} }\n\t\t\tisDisabled={ disabled }\n\t\t\tcustomContainerStyles={ buttonStyle }\n\t\t\tfixedRatio={ false }\n\t\t/>\n\t);\n};\n\nexport class Inserter extends Component {\n\tannouncementTimeout;\n\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderInserterToggle = this.renderInserterToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tclearTimeout( this.announcementTimeout );\n\t}\n\n\tgetInsertionOptions() {\n\t\tconst addBeforeOption = {\n\t\t\tvalue: 'before',\n\t\t\tlabel: __( 'Add Block Before' ),\n\t\t\ticon: plusCircle,\n\t\t};\n\n\t\tconst replaceCurrentOption = {\n\t\t\tvalue: 'replace',\n\t\t\tlabel: __( 'Replace Current Block' ),\n\t\t\ticon: plusCircleFilled,\n\t\t};\n\n\t\tconst addAfterOption = {\n\t\t\tvalue: 'after',\n\t\t\tlabel: __( 'Add Block After' ),\n\t\t\ticon: plusCircle,\n\t\t};\n\n\t\tconst addToBeginningOption = {\n\t\t\tvalue: 'start',\n\t\t\tlabel: __( 'Add To Beginning' ),\n\t\t\ticon: insertBefore,\n\t\t};\n\n\t\tconst addToEndOption = {\n\t\t\tvalue: 'end',\n\t\t\tlabel: __( 'Add To End' ),\n\t\t\ticon: insertAfter,\n\t\t};\n\n\t\tconst { isAnyBlockSelected, isSelectedBlockReplaceable } = this.props;\n\t\tif ( isAnyBlockSelected ) {\n\t\t\tif ( isSelectedBlockReplaceable ) {\n\t\t\t\treturn [\n\t\t\t\t\taddToBeginningOption,\n\t\t\t\t\taddBeforeOption,\n\t\t\t\t\treplaceCurrentOption,\n\t\t\t\t\taddAfterOption,\n\t\t\t\t\taddToEndOption,\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn [\n\t\t\t\taddToBeginningOption,\n\t\t\t\taddBeforeOption,\n\t\t\t\taddAfterOption,\n\t\t\t\taddToEndOption,\n\t\t\t];\n\t\t}\n\t\treturn [ addToBeginningOption, addToEndOption ];\n\t}\n\n\tgetInsertionIndex( insertionType ) {\n\t\tconst {\n\t\t\tinsertionIndexDefault,\n\t\t\tinsertionIndexStart,\n\t\t\tinsertionIndexBefore,\n\t\t\tinsertionIndexAfter,\n\t\t\tinsertionIndexEnd,\n\t\t} = this.props;\n\t\tif ( insertionType === 'start' ) {\n\t\t\treturn insertionIndexStart;\n\t\t}\n\t\tif ( insertionType === 'before' || insertionType === 'replace' ) {\n\t\t\treturn insertionIndexBefore;\n\t\t}\n\t\tif ( insertionType === 'after' ) {\n\t\t\treturn insertionIndexAfter;\n\t\t}\n\t\tif ( insertionType === 'end' ) {\n\t\t\treturn insertionIndexEnd;\n\t\t}\n\t\treturn insertionIndexDefault;\n\t}\n\n\tshouldReplaceBlock( insertionType ) {\n\t\tconst { isSelectedBlockReplaceable } = this.props;\n\t\tif ( insertionType === 'replace' ) {\n\t\t\treturn true;\n\t\t}\n\t\tif ( insertionType === 'default' && isSelectedBlockReplaceable ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { blockTypeImpressions, onToggle, updateSettings } = this.props;\n\n\t\tif ( ! isOpen ) {\n\t\t\tconst impressionsRemain = Object.values(\n\t\t\t\tblockTypeImpressions\n\t\t\t).some( ( count ) => count > 0 );\n\n\t\t\tif ( impressionsRemain ) {\n\t\t\t\tconst decrementedImpressions = Object.entries(\n\t\t\t\t\tblockTypeImpressions\n\t\t\t\t).reduce(\n\t\t\t\t\t( acc, [ blockName, count ] ) => ( {\n\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t[ blockName ]: Math.max( count - 1, 0 ),\n\t\t\t\t\t} ),\n\t\t\t\t\t{}\n\t\t\t\t);\n\n\t\t\t\t// Persist block type impression to JavaScript store.\n\t\t\t\tupdateSettings( {\n\t\t\t\t\timpressions: decrementedImpressions,\n\t\t\t\t} );\n\n\t\t\t\t// Persist block type impression count to native app store.\n\t\t\t\tsetBlockTypeImpressions( decrementedImpressions );\n\t\t\t}\n\t\t}\n\n\t\t// Surface toggle callback to parent component.\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t\tthis.onInserterToggledAnnouncement( isOpen );\n\t}\n\n\tonInserterToggledAnnouncement( isOpen ) {\n\t\tAccessibilityInfo.isScreenReaderEnabled().then( ( isEnabled ) => {\n\t\t\tif ( isEnabled ) {\n\t\t\t\tconst isIOS = Platform.OS === 'ios';\n\t\t\t\tconst announcement = isOpen\n\t\t\t\t\t? __( 'Scrollable block menu opened. Select a block.' )\n\t\t\t\t\t: __( 'Scrollable block menu closed.' );\n\t\t\t\tthis.announcementTimeout = setTimeout(\n\t\t\t\t\t() =>\n\t\t\t\t\t\tAccessibilityInfo.announceForAccessibility(\n\t\t\t\t\t\t\tannouncement\n\t\t\t\t\t\t),\n\t\t\t\t\tisIOS ? VOICE_OVER_ANNOUNCEMENT_DELAY : 0\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown toggle element.\n\t */\n\trenderInserterToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t\tgetStylesFromColorScheme,\n\t\t\tshowSeparator,\n\t\t} = this.props;\n\t\tif ( showSeparator && isOpen ) {\n\t\t\treturn <BlockInsertionPoint />;\n\t\t}\n\n\t\tconst buttonStyle = getStylesFromColorScheme(\n\t\t\tstyles[ 'inserter-menu__add-block-button' ],\n\t\t\tstyles[ 'inserter-menu__add-block-button--dark' ]\n\t\t);\n\n\t\tconst iconStyle = getStylesFromColorScheme(\n\t\t\tstyles[ 'inserter-menu__add-block-button-icon' ],\n\t\t\tstyles[ 'inserter-menu__add-block-button-icon--dark' ]\n\t\t);\n\n\t\tconst onPress = () => {\n\t\t\tthis.setState(\n\t\t\t\t{\n\t\t\t\t\tdestinationRootClientId: this.props.destinationRootClientId,\n\t\t\t\t\tshouldReplaceBlock: this.shouldReplaceBlock( 'default' ),\n\t\t\t\t\tinsertionIndex: this.getInsertionIndex( 'default' ),\n\t\t\t\t},\n\t\t\t\tonToggle\n\t\t\t);\n\t\t};\n\n\t\tconst onLongPress = () => {\n\t\t\tif ( this.picker ) {\n\t\t\t\tthis.picker.presentPicker();\n\t\t\t}\n\t\t};\n\n\t\tconst onPickerSelect = ( insertionType ) => {\n\t\t\tthis.setState(\n\t\t\t\t{\n\t\t\t\t\tdestinationRootClientId: this.props.destinationRootClientId,\n\t\t\t\t\tshouldReplaceBlock:\n\t\t\t\t\t\tthis.shouldReplaceBlock( insertionType ),\n\t\t\t\t\tinsertionIndex: this.getInsertionIndex( insertionType ),\n\t\t\t\t},\n\t\t\t\tonToggle\n\t\t\t);\n\t\t};\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ renderToggle( {\n\t\t\t\t\tonToggle: onPress,\n\t\t\t\t\tisOpen,\n\t\t\t\t\tdisabled,\n\t\t\t\t\ticonStyle,\n\t\t\t\t\tbuttonStyle,\n\t\t\t\t\tonLongPress,\n\t\t\t\t} ) }\n\t\t\t\t<Picker\n\t\t\t\t\tref={ ( instance ) => ( this.picker = instance ) }\n\t\t\t\t\toptions={ this.getInsertionOptions() }\n\t\t\t\t\tonChange={ onPickerSelect }\n\t\t\t\t\thideCancelButton\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown content element.\n\t */\n\trenderContent( { onClose, isOpen } ) {\n\t\tconst { clientId, isAppender } = this.props;\n\t\tconst { destinationRootClientId, shouldReplaceBlock, insertionIndex } =\n\t\t\tthis.state;\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tisOpen={ isOpen }\n\t\t\t\tonSelect={ onClose }\n\t\t\t\tonDismiss={ onClose }\n\t\t\t\trootClientId={ destinationRootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshouldReplaceBlock={ shouldReplaceBlock }\n\t\t\t\tinsertionIndex={ insertionIndex }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderInserterToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithDispatch( ( dispatch ) => {\n\t\tconst { updateSettings } = dispatch( blockEditorStore );\n\t\treturn { updateSettings };\n\t} ),\n\twithSelect( ( select, { clientId, isAppender, rootClientId } ) => {\n\t\tconst {\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockSelectionEnd,\n\t\t\tgetBlockOrder,\n\t\t\tgetBlockIndex,\n\t\t\tgetBlock,\n\t\t\tgetSettings: getBlockEditorSettings,\n\t\t} = select( blockEditorStore );\n\n\t\tconst end = getBlockSelectionEnd();\n\t\t// `end` argument (id) can refer to the component which is removed\n\t\t// due to pressing `undo` button, that's why we need to check\n\t\t// if `getBlock( end) is valid, otherwise `null` is passed\n\t\tconst isAnyBlockSelected = ! isAppender && end && getBlock( end );\n\t\tconst destinationRootClientId = isAnyBlockSelected\n\t\t\t? getBlockRootClientId( end )\n\t\t\t: rootClientId;\n\t\tconst selectedBlockIndex = getBlockIndex( end );\n\t\tconst endOfRootIndex = getBlockOrder( rootClientId ).length;\n\t\tconst isSelectedUnmodifiedDefaultBlock = isAnyBlockSelected\n\t\t\t? isUnmodifiedDefaultBlock( getBlock( end ) )\n\t\t\t: undefined;\n\n\t\tfunction getDefaultInsertionIndex() {\n\t\t\tconst { __experimentalShouldInsertAtTheTop: shouldInsertAtTheTop } =\n\t\t\t\tgetBlockEditorSettings();\n\n\t\t\t// If post title is selected insert as first block.\n\t\t\tif ( shouldInsertAtTheTop ) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\tif ( clientId ) {\n\t\t\t\treturn getBlockIndex( clientId );\n\t\t\t}\n\n\t\t\t// If there is a selected block,\n\t\t\tif ( isAnyBlockSelected ) {\n\t\t\t\t// And the last selected block is unmodified (empty), it will be replaced.\n\t\t\t\tif ( isSelectedUnmodifiedDefaultBlock ) {\n\t\t\t\t\treturn selectedBlockIndex;\n\t\t\t\t}\n\n\t\t\t\t// We insert after the selected block.\n\t\t\t\treturn selectedBlockIndex + 1;\n\t\t\t}\n\n\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\treturn endOfRootIndex;\n\t\t}\n\n\t\tconst insertionIndexStart = 0;\n\n\t\tconst insertionIndexBefore = isAnyBlockSelected\n\t\t\t? selectedBlockIndex\n\t\t\t: insertionIndexStart;\n\n\t\tconst insertionIndexAfter = isAnyBlockSelected\n\t\t\t? selectedBlockIndex + 1\n\t\t\t: endOfRootIndex;\n\n\t\tconst insertionIndexEnd = endOfRootIndex;\n\n\t\treturn {\n\t\t\tblockTypeImpressions: getBlockEditorSettings().impressions,\n\t\t\tdestinationRootClientId,\n\t\t\tinsertionIndexDefault: getDefaultInsertionIndex(),\n\t\t\tinsertionIndexBefore,\n\t\t\tinsertionIndexAfter,\n\t\t\tinsertionIndexStart,\n\t\t\tinsertionIndexEnd,\n\t\t\tisAnyBlockSelected: !! isAnyBlockSelected,\n\t\t\tisSelectedBlockReplaceable: isSelectedUnmodifiedDefaultBlock,\n\t\t};\n\t} ),\n\n\twithPreferredColorScheme,\n] )( Inserter );\n"]}
|
|
@@ -8,28 +8,9 @@ import { useSelect } from '@wordpress/data';
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { store as blockEditorStore } from '../../../store';
|
|
11
|
-
/**
|
|
12
|
-
* Interface for inserter media requests.
|
|
13
|
-
*
|
|
14
|
-
* @typedef {Object} InserterMediaRequest
|
|
15
|
-
* @property {number} per_page How many items to fetch per page.
|
|
16
|
-
* @property {string} search The search term to use for filtering the results.
|
|
17
|
-
*/
|
|
11
|
+
/** @typedef {import('./api').InserterMediaRequest} InserterMediaRequest */
|
|
18
12
|
|
|
19
|
-
/**
|
|
20
|
-
* Interface for inserter media responses. Any media resource should
|
|
21
|
-
* map their response to this interface, in order to create the core
|
|
22
|
-
* WordPress media blocks (image, video, audio).
|
|
23
|
-
*
|
|
24
|
-
* @typedef {Object} InserterMediaItem
|
|
25
|
-
* @property {string} title The title of the media item.
|
|
26
|
-
* @property {string} url The source url of the media item.
|
|
27
|
-
* @property {string} [previewUrl] The preview source url of the media item to display in the media list.
|
|
28
|
-
* @property {number} [id] The WordPress id of the media item.
|
|
29
|
-
* @property {number|string} [sourceId] The id of the media item from external source.
|
|
30
|
-
* @property {string} [alt] The alt text of the media item.
|
|
31
|
-
* @property {string} [caption] The caption of the media item.
|
|
32
|
-
*/
|
|
13
|
+
/** @typedef {import('./api').InserterMediaItem} InserterMediaItem */
|
|
33
14
|
|
|
34
15
|
/**
|
|
35
16
|
* Fetches media items based on the provided category.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/media-tab/hooks.js"],"names":["useEffect","useState","useRef","useMemo","useSelect","store","blockEditorStore","useMediaResults","category","query","mediaList","setMediaList","isLoading","setIsLoading","lastRequest","key","JSON","stringify","name","current","_media","fetch","Object","values","useInserterMediaCategories","inserterMediaCategories","allowedMimeTypes","enableOpenverseMediaCategory","select","settings","getSettings","allowedCategories","filter","some","mimeType","startsWith","mediaType","useMediaCategories","rootClientId","categories","setCategories","canInsertImage","canInsertVideo","canInsertAudio","canInsertBlockType","_categories","categoriesHaveMedia","Map","Promise","all","map","isExternalResource","results","per_page","e","length","canInsertMediaType","image","video","audio","forEach","get","push"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,QAApB,EAA8BC,MAA9B,EAAsCC,OAAtC,QAAqD,oBAArD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,SAASC,K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EAAEhB;AAHmB,OAA3B;AAKAlB,MAAAA,uBAAuB,CAACmC,OAAxB,CAAmCpD,QAAF,IAAgB;AAChD,YACCgD,kBAAkB,CAAEhD,QAAQ,CAAC4B,SAAX,CAAlB,IACAU,mBAAmB,CAACe,GAApB,CAAyBrD,QAAQ,CAACU,IAAlC,CAFD,EAGE;AACD2B,UAAAA,WAAW,CAACiB,IAAZ,CAAkBtD,QAAlB;AACA;AACD,OAPD;;AAQA,UAAK,CAAC,CAAEqC,WAAW,CAACU,MAApB,EAA6B;AAC5Bf,QAAAA,aAAa,CAAEK,WAAF,CAAb;AACA;AACD,KA/CD;AAgDA,GAjDQ,EAiDN,CACFJ,cADE,EAEFC,cAFE,EAGFC,cAHE,EAIFlB,uBAJE,CAjDM,CAAT;AAuDA,SAAOc,UAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useRef, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * Interface for inserter media requests.\n *\n * @typedef {Object} InserterMediaRequest\n * @property {number} per_page How many items to fetch per page.\n * @property {string} search The search term to use for filtering the results.\n */\n\n/**\n * Interface for inserter media responses. Any media resource should\n * map their response to this interface, in order to create the core\n * WordPress media blocks (image, video, audio).\n *\n * @typedef {Object} InserterMediaItem\n * @property {string} title The title of the media item.\n * @property {string} url The source url of the media item.\n * @property {string} [previewUrl] The preview source url of the media item to display in the media list.\n * @property {number} [id] The WordPress id of the media item.\n * @property {number|string} [sourceId] The id of the media item from external source.\n * @property {string} [alt] The alt text of the media item.\n * @property {string} [caption] The caption of the media item.\n */\n\n/**\n * Fetches media items based on the provided category.\n * Each media category is responsible for providing a `fetch` function.\n *\n * @param {Object} category The media category to fetch results for.\n * @param {InserterMediaRequest} query The query args to use for the request.\n * @return {InserterMediaItem[]} The media results.\n */\nexport function useMediaResults( category, query = {} ) {\n\tconst [ mediaList, setMediaList ] = useState();\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\t// We need to keep track of the last request made because\n\t// multiple request can be fired without knowing the order\n\t// of resolution, and we need to ensure we are showing\n\t// the results of the last request.\n\t// In the future we could use AbortController to cancel previous\n\t// requests, but we don't for now as it involves adding support\n\t// for this to `core-data` package.\n\tconst lastRequest = useRef();\n\tuseEffect( () => {\n\t\t( async () => {\n\t\t\tconst key = JSON.stringify( {\n\t\t\t\tcategory: category.name,\n\t\t\t\t...query,\n\t\t\t} );\n\t\t\tlastRequest.current = key;\n\t\t\tsetIsLoading( true );\n\t\t\tsetMediaList( [] ); // Empty the previous results.\n\t\t\tconst _media = await category.fetch?.( query );\n\t\t\tif ( key === lastRequest.current ) {\n\t\t\t\tsetMediaList( _media );\n\t\t\t\tsetIsLoading( false );\n\t\t\t}\n\t\t} )();\n\t}, [ category.name, ...Object.values( query ) ] );\n\treturn { mediaList, isLoading };\n}\n\nfunction useInserterMediaCategories() {\n\tconst {\n\t\tinserterMediaCategories,\n\t\tallowedMimeTypes,\n\t\tenableOpenverseMediaCategory,\n\t} = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tinserterMediaCategories: settings.inserterMediaCategories,\n\t\t\tallowedMimeTypes: settings.allowedMimeTypes,\n\t\t\tenableOpenverseMediaCategory: settings.enableOpenverseMediaCategory,\n\t\t};\n\t}, [] );\n\t// The allowed `mime_types` can be altered by `upload_mimes` filter and restrict\n\t// some of them. In this case we shouldn't add the category to the available media\n\t// categories list in the inserter.\n\tconst allowedCategories = useMemo( () => {\n\t\tif ( ! inserterMediaCategories || ! allowedMimeTypes ) {\n\t\t\treturn;\n\t\t}\n\t\treturn inserterMediaCategories.filter( ( category ) => {\n\t\t\t// Check if Openverse category is enabled.\n\t\t\tif (\n\t\t\t\t! enableOpenverseMediaCategory &&\n\t\t\t\tcategory.name === 'openverse'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn Object.values( allowedMimeTypes ).some( ( mimeType ) =>\n\t\t\t\tmimeType.startsWith( `${ category.mediaType }/` )\n\t\t\t);\n\t\t} );\n\t}, [\n\t\tinserterMediaCategories,\n\t\tallowedMimeTypes,\n\t\tenableOpenverseMediaCategory,\n\t] );\n\treturn allowedCategories;\n}\n\nexport function useMediaCategories( rootClientId ) {\n\tconst [ categories, setCategories ] = useState( [] );\n\tconst { canInsertImage, canInsertVideo, canInsertAudio } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canInsertBlockType } = select( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tcanInsertImage: canInsertBlockType(\n\t\t\t\t\t'core/image',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tcanInsertVideo: canInsertBlockType(\n\t\t\t\t\t'core/video',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tcanInsertAudio: canInsertBlockType(\n\t\t\t\t\t'core/audio',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\tconst inserterMediaCategories = useInserterMediaCategories();\n\tuseEffect( () => {\n\t\t( async () => {\n\t\t\tconst _categories = [];\n\t\t\t// If `inserterMediaCategories` is not defined in\n\t\t\t// block editor settings, do not show any media categories.\n\t\t\tif ( ! inserterMediaCategories ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Loop through categories to check if they have at least one media item.\n\t\t\tconst categoriesHaveMedia = new Map(\n\t\t\t\tawait Promise.all(\n\t\t\t\t\tinserterMediaCategories.map( async ( category ) => {\n\t\t\t\t\t\t// Some sources are external and we don't need to make a request.\n\t\t\t\t\t\tif ( category.isExternalResource ) {\n\t\t\t\t\t\t\treturn [ category.name, true ];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlet results = [];\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresults = await category.fetch( {\n\t\t\t\t\t\t\t\tper_page: 1,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} catch ( e ) {\n\t\t\t\t\t\t\t// If the request fails, we shallow the error and just don't show\n\t\t\t\t\t\t\t// the category, in order to not break the media tab.\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn [ category.name, !! results.length ];\n\t\t\t\t\t} )\n\t\t\t\t)\n\t\t\t);\n\t\t\t// We need to filter out categories that don't have any media items or\n\t\t\t// whose corresponding block type is not allowed to be inserted, based\n\t\t\t// on the category's `mediaType`.\n\t\t\tconst canInsertMediaType = {\n\t\t\t\timage: canInsertImage,\n\t\t\t\tvideo: canInsertVideo,\n\t\t\t\taudio: canInsertAudio,\n\t\t\t};\n\t\t\tinserterMediaCategories.forEach( ( category ) => {\n\t\t\t\tif (\n\t\t\t\t\tcanInsertMediaType[ category.mediaType ] &&\n\t\t\t\t\tcategoriesHaveMedia.get( category.name )\n\t\t\t\t) {\n\t\t\t\t\t_categories.push( category );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tif ( !! _categories.length ) {\n\t\t\t\tsetCategories( _categories );\n\t\t\t}\n\t\t} )();\n\t}, [\n\t\tcanInsertImage,\n\t\tcanInsertVideo,\n\t\tcanInsertAudio,\n\t\tinserterMediaCategories,\n\t] );\n\treturn categories;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/media-tab/hooks.js"],"names":["useEffect","useState","useRef","useMemo","useSelect","store","blockEditorStore","useMediaResults","category","query","mediaList","setMediaList","isLoading","setIsLoading","lastRequest","key","JSON","stringify","name","current","_media","fetch","Object","values","useInserterMediaCategories","inserterMediaCategories","allowedMimeTypes","enableOpenverseMediaCategory","select","settings","getSettings","allowedCategories","filter","some","mimeType","startsWith","mediaType","useMediaCategories","rootClientId","categories","setCategories","canInsertImage","canInsertVideo","canInsertAudio","canInsertBlockType","_categories","categoriesHaveMedia","Map","Promise","all","map","isExternalResource","results","per_page","e","length","canInsertMediaType","image","video","audio","forEach","get","push"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAo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;AAG1BiB,QAAAA,KAAK,EAAEhB;AAHmB,OAA3B;AAKAlB,MAAAA,uBAAuB,CAACmC,OAAxB,CAAmCpD,QAAF,IAAgB;AAChD,YACCgD,kBAAkB,CAAEhD,QAAQ,CAAC4B,SAAX,CAAlB,IACAU,mBAAmB,CAACe,GAApB,CAAyBrD,QAAQ,CAACU,IAAlC,CAFD,EAGE;AACD2B,UAAAA,WAAW,CAACiB,IAAZ,CAAkBtD,QAAlB;AACA;AACD,OAPD;;AAQA,UAAK,CAAC,CAAEqC,WAAW,CAACU,MAApB,EAA6B;AAC5Bf,QAAAA,aAAa,CAAEK,WAAF,CAAb;AACA;AACD,KA/CD;AAgDA,GAjDQ,EAiDN,CACFJ,cADE,EAEFC,cAFE,EAGFC,cAHE,EAIFlB,uBAJE,CAjDM,CAAT;AAuDA,SAAOc,UAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useRef, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\n/** @typedef {import('./api').InserterMediaRequest} InserterMediaRequest */\n/** @typedef {import('./api').InserterMediaItem} InserterMediaItem */\n\n/**\n * Fetches media items based on the provided category.\n * Each media category is responsible for providing a `fetch` function.\n *\n * @param {Object} category The media category to fetch results for.\n * @param {InserterMediaRequest} query The query args to use for the request.\n * @return {InserterMediaItem[]} The media results.\n */\nexport function useMediaResults( category, query = {} ) {\n\tconst [ mediaList, setMediaList ] = useState();\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\t// We need to keep track of the last request made because\n\t// multiple request can be fired without knowing the order\n\t// of resolution, and we need to ensure we are showing\n\t// the results of the last request.\n\t// In the future we could use AbortController to cancel previous\n\t// requests, but we don't for now as it involves adding support\n\t// for this to `core-data` package.\n\tconst lastRequest = useRef();\n\tuseEffect( () => {\n\t\t( async () => {\n\t\t\tconst key = JSON.stringify( {\n\t\t\t\tcategory: category.name,\n\t\t\t\t...query,\n\t\t\t} );\n\t\t\tlastRequest.current = key;\n\t\t\tsetIsLoading( true );\n\t\t\tsetMediaList( [] ); // Empty the previous results.\n\t\t\tconst _media = await category.fetch?.( query );\n\t\t\tif ( key === lastRequest.current ) {\n\t\t\t\tsetMediaList( _media );\n\t\t\t\tsetIsLoading( false );\n\t\t\t}\n\t\t} )();\n\t}, [ category.name, ...Object.values( query ) ] );\n\treturn { mediaList, isLoading };\n}\n\nfunction useInserterMediaCategories() {\n\tconst {\n\t\tinserterMediaCategories,\n\t\tallowedMimeTypes,\n\t\tenableOpenverseMediaCategory,\n\t} = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tinserterMediaCategories: settings.inserterMediaCategories,\n\t\t\tallowedMimeTypes: settings.allowedMimeTypes,\n\t\t\tenableOpenverseMediaCategory: settings.enableOpenverseMediaCategory,\n\t\t};\n\t}, [] );\n\t// The allowed `mime_types` can be altered by `upload_mimes` filter and restrict\n\t// some of them. In this case we shouldn't add the category to the available media\n\t// categories list in the inserter.\n\tconst allowedCategories = useMemo( () => {\n\t\tif ( ! inserterMediaCategories || ! allowedMimeTypes ) {\n\t\t\treturn;\n\t\t}\n\t\treturn inserterMediaCategories.filter( ( category ) => {\n\t\t\t// Check if Openverse category is enabled.\n\t\t\tif (\n\t\t\t\t! enableOpenverseMediaCategory &&\n\t\t\t\tcategory.name === 'openverse'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn Object.values( allowedMimeTypes ).some( ( mimeType ) =>\n\t\t\t\tmimeType.startsWith( `${ category.mediaType }/` )\n\t\t\t);\n\t\t} );\n\t}, [\n\t\tinserterMediaCategories,\n\t\tallowedMimeTypes,\n\t\tenableOpenverseMediaCategory,\n\t] );\n\treturn allowedCategories;\n}\n\nexport function useMediaCategories( rootClientId ) {\n\tconst [ categories, setCategories ] = useState( [] );\n\tconst { canInsertImage, canInsertVideo, canInsertAudio } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canInsertBlockType } = select( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tcanInsertImage: canInsertBlockType(\n\t\t\t\t\t'core/image',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tcanInsertVideo: canInsertBlockType(\n\t\t\t\t\t'core/video',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tcanInsertAudio: canInsertBlockType(\n\t\t\t\t\t'core/audio',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\tconst inserterMediaCategories = useInserterMediaCategories();\n\tuseEffect( () => {\n\t\t( async () => {\n\t\t\tconst _categories = [];\n\t\t\t// If `inserterMediaCategories` is not defined in\n\t\t\t// block editor settings, do not show any media categories.\n\t\t\tif ( ! inserterMediaCategories ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Loop through categories to check if they have at least one media item.\n\t\t\tconst categoriesHaveMedia = new Map(\n\t\t\t\tawait Promise.all(\n\t\t\t\t\tinserterMediaCategories.map( async ( category ) => {\n\t\t\t\t\t\t// Some sources are external and we don't need to make a request.\n\t\t\t\t\t\tif ( category.isExternalResource ) {\n\t\t\t\t\t\t\treturn [ category.name, true ];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlet results = [];\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresults = await category.fetch( {\n\t\t\t\t\t\t\t\tper_page: 1,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} catch ( e ) {\n\t\t\t\t\t\t\t// If the request fails, we shallow the error and just don't show\n\t\t\t\t\t\t\t// the category, in order to not break the media tab.\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn [ category.name, !! results.length ];\n\t\t\t\t\t} )\n\t\t\t\t)\n\t\t\t);\n\t\t\t// We need to filter out categories that don't have any media items or\n\t\t\t// whose corresponding block type is not allowed to be inserted, based\n\t\t\t// on the category's `mediaType`.\n\t\t\tconst canInsertMediaType = {\n\t\t\t\timage: canInsertImage,\n\t\t\t\tvideo: canInsertVideo,\n\t\t\t\taudio: canInsertAudio,\n\t\t\t};\n\t\t\tinserterMediaCategories.forEach( ( category ) => {\n\t\t\t\tif (\n\t\t\t\t\tcanInsertMediaType[ category.mediaType ] &&\n\t\t\t\t\tcategoriesHaveMedia.get( category.name )\n\t\t\t\t) {\n\t\t\t\t\t_categories.push( category );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tif ( !! _categories.length ) {\n\t\t\t\tsetCategories( _categories );\n\t\t\t}\n\t\t} )();\n\t}, [\n\t\tcanInsertImage,\n\t\tcanInsertVideo,\n\t\tcanInsertAudio,\n\t\tinserterMediaCategories,\n\t] );\n\treturn categories;\n}\n"]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { Button } from '@wordpress/components';
|
|
7
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
|
+
import { focus } from '@wordpress/dom';
|
|
9
|
+
import { useRef } from '@wordpress/element';
|
|
10
|
+
import { __ } from '@wordpress/i18n';
|
|
11
|
+
import { close } from '@wordpress/icons';
|
|
12
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
13
|
+
const PREFERENCE_NAME = 'isResuableBlocksrRenameHintVisible';
|
|
14
|
+
/*
|
|
15
|
+
* This hook was added in 6.3 to help users with the transition from Reusable blocks to Patterns.
|
|
16
|
+
* It is only exported for use in the reusable-blocks package as well as block-editor.
|
|
17
|
+
* It will be removed in 6.4. and should not be used in any new code.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export function useReusableBlocksRenameHint() {
|
|
21
|
+
return useSelect(select => {
|
|
22
|
+
var _select$get;
|
|
23
|
+
|
|
24
|
+
return (_select$get = select(preferencesStore).get('core', PREFERENCE_NAME)) !== null && _select$get !== void 0 ? _select$get : true;
|
|
25
|
+
}, []);
|
|
26
|
+
}
|
|
27
|
+
/*
|
|
28
|
+
* This component was added in 6.3 to help users with the transition from Reusable blocks to Patterns.
|
|
29
|
+
* It is only exported for use in the reusable-blocks package as well as block-editor.
|
|
30
|
+
* It will be removed in 6.4. and should not be used in any new code.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
export default function ReusableBlocksRenameHint() {
|
|
34
|
+
const isReusableBlocksRenameHint = useSelect(select => {
|
|
35
|
+
var _select$get2;
|
|
36
|
+
|
|
37
|
+
return (_select$get2 = select(preferencesStore).get('core', PREFERENCE_NAME)) !== null && _select$get2 !== void 0 ? _select$get2 : true;
|
|
38
|
+
}, []);
|
|
39
|
+
const ref = useRef();
|
|
40
|
+
const {
|
|
41
|
+
set: setPreference
|
|
42
|
+
} = useDispatch(preferencesStore);
|
|
43
|
+
|
|
44
|
+
if (!isReusableBlocksRenameHint) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return createElement("div", {
|
|
49
|
+
ref: ref,
|
|
50
|
+
className: "reusable-blocks-menu-items__rename-hint"
|
|
51
|
+
}, createElement("div", {
|
|
52
|
+
className: "reusable-blocks-menu-items__rename-hint-content"
|
|
53
|
+
}, __('Reusable blocks are now synced patterns. A synced pattern will behave in exactly the same way as a reusable block.')), createElement(Button, {
|
|
54
|
+
className: "reusable-blocks-menu-items__rename-hint-dismiss",
|
|
55
|
+
icon: close,
|
|
56
|
+
iconSize: "16",
|
|
57
|
+
label: __('Dismiss hint'),
|
|
58
|
+
onClick: () => {
|
|
59
|
+
// Retain focus when dismissing the element.
|
|
60
|
+
const previousElement = focus.tabbable.findPrevious(ref.current);
|
|
61
|
+
previousElement?.focus();
|
|
62
|
+
setPreference('core', PREFERENCE_NAME, false);
|
|
63
|
+
},
|
|
64
|
+
showTooltip: false
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=reusable-block-rename-hint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/reusable-block-rename-hint.js"],"names":["Button","useDispatch","useSelect","focus","useRef","__","close","store","preferencesStore","PREFERENCE_NAME","useReusableBlocksRenameHint","select","get","ReusableBlocksRenameHint","isReusableBlocksRenameHint","ref","set","setPreference","previousElement","tabbable","findPrevious","current"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,uBAAvB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAT,QAAsB,kBAAtB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AAEA,MAAMC,eAAe,GAAG,oCAAxB;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,2BAAT,GAAuC;AAC7C,SAAOR,SAAS,CACbS,MAAF;AAAA;;AAAA,0BACCA,MAAM,CAAEH,gBAAF,CAAN,CAA2BI,GAA3B,CAAgC,MAAhC,EAAwCH,eAAxC,CADD,qDAC8D,IAD9D;AAAA,GADe,EAGf,EAHe,CAAhB;AAKA;AAED;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASI,wBAAT,GAAoC;AAClD,QAAMC,0BAA0B,GAAGZ,SAAS,CACzCS,MAAF;AAAA;;AAAA,2BACCA,MAAM,CAAEH,gBAAF,CAAN,CAA2BI,GAA3B,CAAgC,MAAhC,EAAwCH,eAAxC,CADD,uDAC8D,IAD9D;AAAA,GAD2C,EAG3C,EAH2C,CAA5C;AAMA,QAAMM,GAAG,GAAGX,MAAM,EAAlB;AAEA,QAAM;AAAEY,IAAAA,GAAG,EAAEC;AAAP,MAAyBhB,WAAW,CAAEO,gBAAF,CAA1C;;AACA,MAAK,CAAEM,0BAAP,EAAoC;AACnC,WAAO,IAAP;AACA;;AAED,SACC;AAAK,IAAA,GAAG,EAAGC,GAAX;AAAiB,IAAA,SAAS,EAAC;AAA3B,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGV,EAAE,CACH,oHADG,CADL,CADD,EAMC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,IAAI,EAAGC,KAFR;AAGC,IAAA,QAAQ,EAAC,IAHV;AAIC,IAAA,KAAK,EAAGD,EAAE,CAAE,cAAF,CAJX;AAKC,IAAA,OAAO,EAAG,MAAM;AACf;AACA,YAAMa,eAAe,GAAGf,KAAK,CAACgB,QAAN,CAAeC,YAAf,CACvBL,GAAG,CAACM,OADmB,CAAxB;AAGAH,MAAAA,eAAe,EAAEf,KAAjB;AACAc,MAAAA,aAAa,CAAE,MAAF,EAAUR,eAAV,EAA2B,KAA3B,CAAb;AACA,KAZF;AAaC,IAAA,WAAW,EAAG;AAbf,IAND,CADD;AAwBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { focus } from '@wordpress/dom';\nimport { useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { close } from '@wordpress/icons';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\nconst PREFERENCE_NAME = 'isResuableBlocksrRenameHintVisible';\n/*\n * This hook was added in 6.3 to help users with the transition from Reusable blocks to Patterns.\n * It is only exported for use in the reusable-blocks package as well as block-editor.\n * It will be removed in 6.4. and should not be used in any new code.\n */\nexport function useReusableBlocksRenameHint() {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( preferencesStore ).get( 'core', PREFERENCE_NAME ) ?? true,\n\t\t[]\n\t);\n}\n\n/*\n * This component was added in 6.3 to help users with the transition from Reusable blocks to Patterns.\n * It is only exported for use in the reusable-blocks package as well as block-editor.\n * It will be removed in 6.4. and should not be used in any new code.\n */\nexport default function ReusableBlocksRenameHint() {\n\tconst isReusableBlocksRenameHint = useSelect(\n\t\t( select ) =>\n\t\t\tselect( preferencesStore ).get( 'core', PREFERENCE_NAME ) ?? true,\n\t\t[]\n\t);\n\n\tconst ref = useRef();\n\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\tif ( ! isReusableBlocksRenameHint ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div ref={ ref } className=\"reusable-blocks-menu-items__rename-hint\">\n\t\t\t<div className=\"reusable-blocks-menu-items__rename-hint-content\">\n\t\t\t\t{ __(\n\t\t\t\t\t'Reusable blocks are now synced patterns. A synced pattern will behave in exactly the same way as a reusable block.'\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<Button\n\t\t\t\tclassName=\"reusable-blocks-menu-items__rename-hint-dismiss\"\n\t\t\t\ticon={ close }\n\t\t\t\ticonSize=\"16\"\n\t\t\t\tlabel={ __( 'Dismiss hint' ) }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\t// Retain focus when dismissing the element.\n\t\t\t\t\tconst previousElement = focus.tabbable.findPrevious(\n\t\t\t\t\t\tref.current\n\t\t\t\t\t);\n\t\t\t\t\tpreviousElement?.focus();\n\t\t\t\t\tsetPreference( 'core', PREFERENCE_NAME, false );\n\t\t\t\t} }\n\t\t\t\tshowTooltip={ false }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -15,6 +15,7 @@ import BlockTypesList from '../block-types-list';
|
|
|
15
15
|
import InserterPanel from './panel';
|
|
16
16
|
import InserterNoResults from './no-results';
|
|
17
17
|
import useBlockTypesState from './hooks/use-block-types-state';
|
|
18
|
+
import ReusableBlocksRenameHint from './reusable-block-rename-hint';
|
|
18
19
|
|
|
19
20
|
function ReusableBlocksList({
|
|
20
21
|
onHover,
|
|
@@ -59,7 +60,9 @@ export function ReusableBlocksTab({
|
|
|
59
60
|
onInsert,
|
|
60
61
|
onHover
|
|
61
62
|
}) {
|
|
62
|
-
return createElement(Fragment, null, createElement(
|
|
63
|
+
return createElement(Fragment, null, createElement("div", {
|
|
64
|
+
className: "block-editor-inserter__hint"
|
|
65
|
+
}, createElement(ReusableBlocksRenameHint, null)), createElement(ReusableBlocksList, {
|
|
63
66
|
onHover: onHover,
|
|
64
67
|
onInsert: onInsert,
|
|
65
68
|
rootClientId: rootClientId
|
|
@@ -71,7 +74,7 @@ export function ReusableBlocksTab({
|
|
|
71
74
|
href: addQueryArgs('edit.php', {
|
|
72
75
|
post_type: 'wp_block'
|
|
73
76
|
})
|
|
74
|
-
}, __('Manage
|
|
77
|
+
}, __('Manage my patterns'))));
|
|
75
78
|
}
|
|
76
79
|
export default ReusableBlocksTab;
|
|
77
80
|
//# sourceMappingURL=reusable-blocks-tab.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/reusable-blocks-tab.js"],"names":["useMemo","__","addQueryArgs","Button","BlockTypesList","InserterPanel","InserterNoResults","useBlockTypesState","ReusableBlocksList","onHover","onInsert","rootClientId","items","onSelectItem","filteredItems","filter","category","length","ReusableBlocksTab","post_type"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,MAAT,QAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AACA,OAAOC,aAAP,MAA0B,SAA1B;AACA,OAAOC,iBAAP,MAA8B,cAA9B;AACA,OAAOC,kBAAP,MAA+B,+BAA/B;;AAEA,SAASC,kBAAT,CAA6B;AAAEC,EAAAA,OAAF;AAAWC,EAAAA,QAAX;AAAqBC,EAAAA;AAArB,CAA7B,EAAmE;AAClE,QAAM,CAAEC,KAAF,IAAaC,YAAb,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/reusable-blocks-tab.js"],"names":["useMemo","__","addQueryArgs","Button","BlockTypesList","InserterPanel","InserterNoResults","useBlockTypesState","ReusableBlocksRenameHint","ReusableBlocksList","onHover","onInsert","rootClientId","items","onSelectItem","filteredItems","filter","category","length","ReusableBlocksTab","post_type"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,MAAT,QAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AACA,OAAOC,aAAP,MAA0B,SAA1B;AACA,OAAOC,iBAAP,MAA8B,cAA9B;AACA,OAAOC,kBAAP,MAA+B,+BAA/B;AACA,OAAOC,wBAAP,MAAqC,8BAArC;;AAEA,SAASC,kBAAT,CAA6B;AAAEC,EAAAA,OAAF;AAAWC,EAAAA,QAAX;AAAqBC,EAAAA;AAArB,CAA7B,EAAmE;AAClE,QAAM,CAAEC,KAAF,IAAaC,YAAb,IAA8BP,kBAAkB,CACrDK,YADqD,EAErDD,QAFqD,CAAtD;AAKA,QAAMI,aAAa,GAAGf,OAAO,CAAE,MAAM;AACpC,WAAOa,KAAK,CAACG,MAAN,CAAc,CAAE;AAAEC,MAAAA;AAAF,KAAF,KAAoBA,QAAQ,KAAK,UAA/C,CAAP;AACA,GAF4B,EAE1B,CAAEJ,KAAF,CAF0B,CAA7B;;AAIA,MAAKE,aAAa,CAACG,MAAd,KAAyB,CAA9B,EAAkC;AACjC,WAAO,cAAC,iBAAD,OAAP;AACA;;AAED,SACC,cAAC,aAAD;AAAe,IAAA,KAAK,EAAGjB,EAAE,CAAE,iBAAF;AAAzB,KACC,cAAC,cAAD;AACC,IAAA,KAAK,EAAGc,aADT;AAEC,IAAA,QAAQ,EAAGD,YAFZ;AAGC,IAAA,OAAO,EAAGJ,OAHX;AAIC,IAAA,KAAK,EAAGT,EAAE,CAAE,iBAAF;AAJX,IADD,CADD;AAUA,C,CAED;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASkB,iBAAT,CAA4B;AAAEP,EAAAA,YAAF;AAAgBD,EAAAA,QAAhB;AAA0BD,EAAAA;AAA1B,CAA5B,EAAkE;AACxE,SACC,8BACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,wBAAD,OADD,CADD,EAIC,cAAC,kBAAD;AACC,IAAA,OAAO,EAAGA,OADX;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,YAAY,EAAGC;AAHhB,IAJD,EASC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,+CADX;AAEC,IAAA,OAAO,EAAC,WAFT;AAGC,IAAA,IAAI,EAAGV,YAAY,CAAE,UAAF,EAAc;AAChCkB,MAAAA,SAAS,EAAE;AADqB,KAAd;AAHpB,KAOGnB,EAAE,CAAE,oBAAF,CAPL,CADD,CATD,CADD;AAuBA;AAED,eAAekB,iBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { addQueryArgs } from '@wordpress/url';\nimport { Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesList from '../block-types-list';\nimport InserterPanel from './panel';\nimport InserterNoResults from './no-results';\nimport useBlockTypesState from './hooks/use-block-types-state';\nimport ReusableBlocksRenameHint from './reusable-block-rename-hint';\n\nfunction ReusableBlocksList( { onHover, onInsert, rootClientId } ) {\n\tconst [ items, , , onSelectItem ] = useBlockTypesState(\n\t\trootClientId,\n\t\tonInsert\n\t);\n\n\tconst filteredItems = useMemo( () => {\n\t\treturn items.filter( ( { category } ) => category === 'reusable' );\n\t}, [ items ] );\n\n\tif ( filteredItems.length === 0 ) {\n\t\treturn <InserterNoResults />;\n\t}\n\n\treturn (\n\t\t<InserterPanel title={ __( 'Synced patterns' ) }>\n\t\t\t<BlockTypesList\n\t\t\t\titems={ filteredItems }\n\t\t\t\tonSelect={ onSelectItem }\n\t\t\t\tonHover={ onHover }\n\t\t\t\tlabel={ __( 'Synced patterns' ) }\n\t\t\t/>\n\t\t</InserterPanel>\n\t);\n}\n\n// The unwrapped component is only exported for use by unit tests.\n/**\n * List of reusable blocks shown in the \"Reusable\" tab of the inserter.\n *\n * @param {Object} props Component props.\n * @param {?string} props.rootClientId Client id of block to insert into.\n * @param {Function} props.onInsert Callback to run when item is inserted.\n * @param {Function} props.onHover Callback to run when item is hovered.\n *\n * @return {WPComponent} The component.\n */\nexport function ReusableBlocksTab( { rootClientId, onInsert, onHover } ) {\n\treturn (\n\t\t<>\n\t\t\t<div className=\"block-editor-inserter__hint\">\n\t\t\t\t<ReusableBlocksRenameHint />\n\t\t\t</div>\n\t\t\t<ReusableBlocksList\n\t\t\t\tonHover={ onHover }\n\t\t\t\tonInsert={ onInsert }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t/>\n\t\t\t<div className=\"block-editor-inserter__manage-reusable-blocks-container\">\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"block-editor-inserter__manage-reusable-blocks\"\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\thref={ addQueryArgs( 'edit.php', {\n\t\t\t\t\t\tpost_type: 'wp_block',\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Manage my patterns' ) }\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default ReusableBlocksTab;\n"]}
|