@wordpress/block-editor 15.21.0 → 15.21.1
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 +17 -1
- package/build/components/block-compare/index.cjs +2 -2
- package/build/components/block-compare/index.cjs.map +2 -2
- package/build/components/block-patterns-list/index.cjs +1 -1
- package/build/components/block-patterns-list/index.cjs.map +2 -2
- package/build/components/block-switcher/block-transformations-menu.cjs +16 -15
- package/build/components/block-switcher/block-transformations-menu.cjs.map +2 -2
- package/build/components/block-switcher/index.cjs +4 -4
- package/build/components/block-switcher/index.cjs.map +2 -2
- package/build/components/global-styles/advanced-panel.cjs +23 -15
- package/build/components/global-styles/advanced-panel.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +2 -2
- package/build/components/global-styles/background-panel.cjs.map +2 -2
- package/build/components/global-styles/border-panel.cjs +2 -0
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +1 -1
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/inner-blocks/use-inner-block-template-sync.cjs +3 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.cjs.map +2 -2
- package/build/components/inserter/hooks/use-patterns-state.cjs +1 -1
- package/build/components/inserter/hooks/use-patterns-state.cjs.map +2 -2
- package/build/components/inserter/index.cjs +179 -220
- package/build/components/inserter/index.cjs.map +3 -3
- package/build/components/inserter/search-results.cjs +1 -1
- package/build/components/inserter/search-results.cjs.map +2 -2
- package/build/components/list-view/block-select-button.cjs +10 -12
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +2 -1
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/components/provider/use-block-sync.cjs +11 -2
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/before-input-rules.cjs +4 -4
- package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/delete.cjs +4 -4
- package/build/components/rich-text/event-listeners/delete.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/enter.cjs +7 -2
- package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/input-events.cjs +4 -4
- package/build/components/rich-text/event-listeners/input-events.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/input-rules.cjs +17 -4
- package/build/components/rich-text/event-listeners/input-rules.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/insert-replacement-text.cjs +4 -4
- package/build/components/rich-text/event-listeners/insert-replacement-text.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs +4 -4
- package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/shortcuts.cjs +4 -4
- package/build/components/rich-text/event-listeners/shortcuts.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/undo-automatic-change.cjs +4 -4
- package/build/components/rich-text/event-listeners/undo-automatic-change.cjs.map +3 -3
- package/build/components/rich-text/index.cjs +1 -23
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/use-block-commands/index.cjs +5 -5
- package/build/components/use-block-commands/index.cjs.map +2 -2
- package/build/hooks/anchor.cjs +11 -15
- package/build/hooks/anchor.cjs.map +2 -2
- package/build/hooks/border.cjs +0 -3
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/color.cjs +1 -4
- package/build/hooks/color.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +0 -3
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/fit-text.cjs +11 -0
- package/build/hooks/fit-text.cjs.map +2 -2
- package/build/hooks/position.cjs +19 -22
- package/build/hooks/position.cjs.map +2 -2
- package/build/hooks/supports.cjs +0 -7
- package/build/hooks/supports.cjs.map +2 -2
- package/build/store/actions.cjs +7 -3
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-actions.cjs +1 -2
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +23 -0
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +14 -6
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +60 -41
- package/build/store/selectors.cjs.map +2 -2
- package/build-module/components/block-compare/index.mjs +1 -1
- package/build-module/components/block-compare/index.mjs.map +2 -2
- package/build-module/components/block-patterns-list/index.mjs +1 -1
- package/build-module/components/block-patterns-list/index.mjs.map +2 -2
- package/build-module/components/block-switcher/block-transformations-menu.mjs +16 -15
- package/build-module/components/block-switcher/block-transformations-menu.mjs.map +2 -2
- package/build-module/components/block-switcher/index.mjs +4 -4
- package/build-module/components/block-switcher/index.mjs.map +2 -2
- package/build-module/components/global-styles/advanced-panel.mjs +23 -15
- package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +3 -3
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +2 -0
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/inner-blocks/use-inner-block-template-sync.mjs +3 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.mjs.map +2 -2
- package/build-module/components/inserter/hooks/use-patterns-state.mjs +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.mjs.map +2 -2
- package/build-module/components/inserter/index.mjs +185 -222
- package/build-module/components/inserter/index.mjs.map +3 -3
- package/build-module/components/inserter/search-results.mjs +1 -1
- package/build-module/components/inserter/search-results.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +10 -12
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +2 -1
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/provider/use-block-sync.mjs +11 -2
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/delete.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/delete.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +7 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/input-events.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/input-events.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/input-rules.mjs +17 -4
- package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/shortcuts.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/shortcuts.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +1 -23
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/use-block-commands/index.mjs +5 -5
- package/build-module/components/use-block-commands/index.mjs.map +2 -2
- package/build-module/hooks/anchor.mjs +11 -15
- package/build-module/hooks/anchor.mjs.map +2 -2
- package/build-module/hooks/border.mjs +1 -4
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/color.mjs +2 -5
- package/build-module/hooks/color.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +1 -4
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/fit-text.mjs +11 -0
- package/build-module/hooks/fit-text.mjs.map +2 -2
- package/build-module/hooks/position.mjs +20 -23
- package/build-module/hooks/position.mjs.map +2 -2
- package/build-module/hooks/supports.mjs +0 -7
- package/build-module/hooks/supports.mjs.map +2 -2
- package/build-module/store/actions.mjs +7 -3
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +1 -2
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +21 -0
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +14 -6
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +62 -42
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-style/content-rtl.css +12 -0
- package/build-style/content.css +12 -0
- package/build-style/style-rtl.css +26 -8
- package/build-style/style.css +26 -8
- package/package.json +49 -46
- package/src/components/block-breadcrumb/README.md +2 -2
- package/src/components/block-compare/README.md +6 -6
- package/src/components/block-compare/index.js +1 -3
- package/src/components/block-patterns-list/index.js +1 -1
- package/src/components/block-preview/README.md +1 -1
- package/src/components/block-switcher/block-transformations-menu.js +16 -18
- package/src/components/block-switcher/index.js +4 -4
- package/src/components/block-types-list/README.md +0 -19
- package/src/components/global-styles/advanced-panel.js +5 -1
- package/src/components/global-styles/background-panel.js +3 -3
- package/src/components/global-styles/border-panel.js +2 -0
- package/src/components/global-styles/dimensions-panel.js +12 -13
- package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -1
- package/src/components/inserter/hooks/use-patterns-state.js +1 -1
- package/src/components/inserter/index.js +257 -288
- package/src/components/inserter/search-results.js +1 -3
- package/src/components/justify-content-control/README.md +1 -1
- package/src/components/list-view/block-select-button.js +9 -13
- package/src/components/list-view/block.js +1 -0
- package/src/components/media-placeholder/README.md +1 -29
- package/src/components/media-upload/README.md +0 -19
- package/src/components/provider/test/use-block-sync.js +40 -0
- package/src/components/provider/use-block-sync.js +12 -2
- package/src/components/rich-text/event-listeners/before-input-rules.js +5 -4
- package/src/components/rich-text/event-listeners/delete.js +9 -4
- package/src/components/rich-text/event-listeners/enter.js +9 -2
- package/src/components/rich-text/event-listeners/input-events.js +13 -4
- package/src/components/rich-text/event-listeners/input-rules.js +20 -4
- package/src/components/rich-text/event-listeners/insert-replacement-text.js +9 -4
- package/src/components/rich-text/event-listeners/remove-browser-shortcuts.js +9 -4
- package/src/components/rich-text/event-listeners/shortcuts.js +13 -4
- package/src/components/rich-text/event-listeners/undo-automatic-change.js +5 -4
- package/src/components/rich-text/index.js +1 -33
- package/src/components/unit-control/README.md +1 -1
- package/src/components/url-popover/README.md +1 -1
- package/src/components/use-block-commands/index.js +5 -5
- package/src/hooks/anchor.js +9 -17
- package/src/hooks/border.js +1 -5
- package/src/hooks/color.js +1 -6
- package/src/hooks/dimensions.js +1 -5
- package/src/hooks/fit-text.js +16 -0
- package/src/hooks/position.js +23 -27
- package/src/hooks/supports.js +0 -9
- package/src/store/actions.js +13 -3
- package/src/store/private-actions.js +1 -4
- package/src/store/private-selectors.js +42 -0
- package/src/store/reducer.js +19 -7
- package/src/store/selectors.js +91 -53
- package/src/store/test/actions.js +21 -0
- package/src/store/test/reducer.js +46 -0
- package/src/store/test/selectors.js +77 -0
- package/build/components/media-upload-progress/constants.cjs +0 -46
- package/build/components/media-upload-progress/constants.cjs.map +0 -7
- package/build/components/rich-text/native/format-edit.cjs +0 -60
- package/build/components/rich-text/native/format-edit.cjs.map +0 -7
- package/build/components/rich-text/native/index.cjs +0 -28
- package/build/components/rich-text/native/index.cjs.map +0 -7
- package/build/components/rich-text/native/use-format-types.cjs +0 -139
- package/build/components/rich-text/native/use-format-types.cjs.map +0 -7
- package/build-module/components/media-upload-progress/constants.mjs +0 -16
- package/build-module/components/media-upload-progress/constants.mjs.map +0 -7
- package/build-module/components/rich-text/native/format-edit.mjs +0 -39
- package/build-module/components/rich-text/native/format-edit.mjs.map +0 -7
- package/build-module/components/rich-text/native/index.mjs +0 -7
- package/build-module/components/rich-text/native/index.mjs.map +0 -7
- package/build-module/components/rich-text/native/use-format-types.mjs +0 -114
- package/build-module/components/rich-text/native/use-format-types.mjs.map +0 -7
- package/src/components/audio-player/audio-url-parser.native.js +0 -20
- package/src/components/audio-player/index.native.js +0 -225
- package/src/components/audio-player/styles.native.scss +0 -114
- package/src/components/audio-player/test/audio-url-parser.native.js +0 -53
- package/src/components/block-alignment-control/test/index.native.js +0 -37
- package/src/components/block-alignment-control/ui.native.js +0 -86
- package/src/components/block-caption/README.md +0 -104
- package/src/components/block-caption/index.native.js +0 -89
- package/src/components/block-caption/styles.native.scss +0 -7
- package/src/components/block-controls/slot.native.js +0 -33
- package/src/components/block-draggable/draggable-chip.native.js +0 -49
- package/src/components/block-draggable/dropping-insertion-point.native.js +0 -181
- package/src/components/block-draggable/dropping-insertion-point.native.scss +0 -8
- package/src/components/block-draggable/index.native.js +0 -467
- package/src/components/block-draggable/style.native.scss +0 -19
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +0 -73
- package/src/components/block-draggable/test/helpers.native.js +0 -182
- package/src/components/block-draggable/test/index.native.js +0 -419
- package/src/components/block-draggable/use-scroll-when-dragging.native.js +0 -135
- package/src/components/block-edit/edit.native.js +0 -49
- package/src/components/block-edit/test/edit.native.js +0 -65
- package/src/components/block-heading-level-dropdown/index.native.js +0 -68
- package/src/components/block-icon/index.native.js +0 -47
- package/src/components/block-icon/style.native.scss +0 -7
- package/src/components/block-list/block-crash-boundary.native.js +0 -43
- package/src/components/block-list/block-crash-warning.native.js +0 -21
- package/src/components/block-list/block-invalid-warning.native.js +0 -70
- package/src/components/block-list/block-list-context.native.js +0 -172
- package/src/components/block-list/block-list-item-cell.native.js +0 -62
- package/src/components/block-list/block-list-item.native.js +0 -209
- package/src/components/block-list/block-list-item.native.scss +0 -16
- package/src/components/block-list/block-outline.native.js +0 -77
- package/src/components/block-list/block-selection-button.native.js +0 -100
- package/src/components/block-list/block-selection-button.native.scss +0 -34
- package/src/components/block-list/block.native.js +0 -716
- package/src/components/block-list/block.native.scss +0 -62
- package/src/components/block-list/grid-item.native.js +0 -58
- package/src/components/block-list/index.native.js +0 -437
- package/src/components/block-list/insertion-point.native.js +0 -36
- package/src/components/block-list/style.native.scss +0 -117
- package/src/components/block-list/test/block-invalid-warning.native.js +0 -62
- package/src/components/block-list/test/block-list-context.native.js +0 -243
- package/src/components/block-list/test/block-outline.native.js +0 -255
- package/src/components/block-list/test/fixtures/block-list-context.native.js +0 -79
- package/src/components/block-list/test/index.native.js +0 -205
- package/src/components/block-list/use-block-props/index.native.js +0 -10
- package/src/components/block-list/use-scroll-upon-insertion.native.js +0 -52
- package/src/components/block-list-appender/index.native.js +0 -70
- package/src/components/block-list-appender/style.native.scss +0 -8
- package/src/components/block-media-update-progress/README.md +0 -100
- package/src/components/block-media-update-progress/index.native.js +0 -299
- package/src/components/block-media-update-progress/styles.native.scss +0 -9
- package/src/components/block-media-update-progress/test/index.native.js +0 -543
- package/src/components/block-mover/index.native.js +0 -193
- package/src/components/block-mover/mover-description.native.js +0 -155
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -218
- package/src/components/block-mover/test/index.native.js +0 -186
- package/src/components/block-settings/button.native.js +0 -41
- package/src/components/block-settings/container.native.js +0 -91
- package/src/components/block-settings/container.native.scss +0 -4
- package/src/components/block-settings/index.native.js +0 -5
- package/src/components/block-styles/index.native.js +0 -94
- package/src/components/block-styles/preview.native.js +0 -109
- package/src/components/block-styles/style.native.scss +0 -64
- package/src/components/block-switcher/block-transformations-menu.native.js +0 -91
- package/src/components/block-toolbar/block-toolbar-menu.native.js +0 -477
- package/src/components/block-toolbar/index.native.js +0 -126
- package/src/components/block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap +0 -125
- package/src/components/block-toolbar/test/block-toolbar-menu.native.js +0 -405
- package/src/components/block-toolbar/test/index.native.js +0 -36
- package/src/components/block-types-list/index.native.js +0 -175
- package/src/components/block-types-list/style.native.scss +0 -25
- package/src/components/block-variation-picker/index.native.js +0 -107
- package/src/components/block-variation-picker/style.native.scss +0 -32
- package/src/components/button-block-appender/index.native.js +0 -92
- package/src/components/button-block-appender/styles.native.scss +0 -43
- package/src/components/caption/README.md +0 -44
- package/src/components/caption/index.native.js +0 -61
- package/src/components/colors-gradients/panel-color-gradient-settings.native.js +0 -59
- package/src/components/contrast-checker/index.native.js +0 -113
- package/src/components/contrast-checker/style.native.scss +0 -26
- package/src/components/convert-to-group-buttons/index.native.js +0 -79
- package/src/components/default-block-appender/index.native.js +0 -113
- package/src/components/default-block-appender/style.native.scss +0 -18
- package/src/components/floating-toolbar/floatingToolbar.android.scss +0 -4
- package/src/components/floating-toolbar/floatingToolbar.ios.scss +0 -3
- package/src/components/floating-toolbar/index.native.js +0 -141
- package/src/components/floating-toolbar/styles.native.scss +0 -43
- package/src/components/font-sizes/index.native.js +0 -7
- package/src/components/global-styles/color-panel.native.js +0 -207
- package/src/components/global-styles/test/use-global-styles-context.native.js +0 -435
- package/src/components/global-styles/use-global-styles-context.native.js +0 -592
- package/src/components/gradients/index.native.js +0 -2
- package/src/components/image-link-destinations/index.native.js +0 -152
- package/src/components/image-link-destinations/style.native.scss +0 -16
- package/src/components/index.native.js +0 -108
- package/src/components/inner-blocks/constants.native.js +0 -5
- package/src/components/inner-blocks/index.native.js +0 -221
- package/src/components/inner-blocks/warning-max-depth-exceeded.native.js +0 -124
- package/src/components/inserter/block-types-tab.native.js +0 -76
- package/src/components/inserter/hooks/use-block-type-impressions.native.js +0 -47
- package/src/components/inserter/hooks/use-clipboard-block.native.js +0 -40
- package/src/components/inserter/index.native.js +0 -424
- package/src/components/inserter/menu.native.js +0 -237
- package/src/components/inserter/no-results.native.js +0 -49
- package/src/components/inserter/reusable-blocks-tab.native.js +0 -45
- package/src/components/inserter/search-results.native.js +0 -67
- package/src/components/inserter/style.native.scss +0 -83
- package/src/components/inserter/tabs.native.js +0 -152
- package/src/components/inserter/test/__snapshots__/index.native.js.snap +0 -117
- package/src/components/inserter/test/fixtures/index.native.js +0 -12
- package/src/components/inserter/test/index.native.js +0 -273
- package/src/components/inserter/test/reusable-blocks-tab.native.js +0 -62
- package/src/components/inserter/test/utils.native.js +0 -37
- package/src/components/inserter/utils.native.js +0 -46
- package/src/components/inserter-button/index.native.js +0 -108
- package/src/components/inserter-button/style.native.scss +0 -72
- package/src/components/inspector-controls/fill.native.js +0 -62
- package/src/components/inspector-controls/slot.native.js +0 -35
- package/src/components/inspector-controls-tabs/advanced-controls-panel.native.js +0 -31
- package/src/components/line-height-control/index.native.js +0 -28
- package/src/components/media-placeholder/index.native.js +0 -258
- package/src/components/media-placeholder/styles.native.scss +0 -108
- package/src/components/media-replace-flow/index.native.js +0 -12
- package/src/components/media-upload/constants.native.js +0 -14
- package/src/components/media-upload/index.native.js +0 -356
- package/src/components/media-upload/style.native.scss +0 -4
- package/src/components/media-upload/test/index.native.js +0 -172
- package/src/components/media-upload-progress/README.md +0 -100
- package/src/components/media-upload-progress/constants.js +0 -6
- package/src/components/media-upload-progress/index.native.js +0 -233
- package/src/components/media-upload-progress/styles.native.scss +0 -15
- package/src/components/media-upload-progress/test/index.native.js +0 -220
- package/src/components/plain-text/index.native.js +0 -164
- package/src/components/plain-text/style.native.scss +0 -10
- package/src/components/provider/index.native.js +0 -32
- package/src/components/rich-text/embed-handler-picker.native.js +0 -65
- package/src/components/rich-text/file-paste-handler.native.js +0 -3
- package/src/components/rich-text/format-toolbar/index.native.js +0 -21
- package/src/components/rich-text/format-toolbar-container.native.js +0 -16
- package/src/components/rich-text/index.native.js +0 -701
- package/src/components/rich-text/input-event.native.js +0 -10
- package/src/components/rich-text/native/format-edit.js +0 -44
- package/src/components/rich-text/native/get-format-colors.native.js +0 -47
- package/src/components/rich-text/native/index.js +0 -1
- package/src/components/rich-text/native/index.native.js +0 -1389
- package/src/components/rich-text/native/style.native.scss +0 -28
- package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +0 -79
- package/src/components/rich-text/native/test/index.native.js +0 -345
- package/src/components/rich-text/native/test/performance/rich-text.native.js +0 -44
- package/src/components/rich-text/native/toolbar-button-with-options.native.js +0 -61
- package/src/components/rich-text/native/use-format-types.js +0 -146
- package/src/components/rich-text/remove-browser-shortcuts.native.js +0 -1
- package/src/components/rich-text/shortcut.native.js +0 -10
- package/src/components/ungroup-button/README.md +0 -23
- package/src/components/ungroup-button/index.native.js +0 -77
- package/src/components/unsupported-block-details/index.native.js +0 -187
- package/src/components/unsupported-block-details/style.native.scss +0 -56
- package/src/components/url-input/index.native.js +0 -33
- package/src/components/use-block-drop-zone/index.native.js +0 -207
- package/src/components/use-on-block-drop/index.native.js +0 -115
- package/src/components/use-unsupported-block-editor/index.native.js +0 -59
- package/src/components/video-player/gridicon-play.native.js +0 -13
- package/src/components/video-player/index.native.js +0 -133
- package/src/components/video-player/styles.native.scss +0 -29
- package/src/components/warning/index.native.js +0 -64
- package/src/components/warning/style.native.scss +0 -47
- package/src/hooks/align.native.js +0 -49
- package/src/hooks/custom-class-name.native.js +0 -70
- package/src/hooks/index.native.js +0 -36
- package/src/hooks/layout.native.js +0 -23
- package/src/hooks/test/__snapshots__/align.native.js.snap +0 -73
- package/src/hooks/test/__snapshots__/anchor.native.js.snap +0 -7
- package/src/hooks/test/align.native.js +0 -134
- package/src/hooks/test/anchor.native.js +0 -32
- package/src/hooks/test/use-editor-wrapper-styles.native.js +0 -282
- package/src/hooks/typography.native.js +0 -60
- package/src/hooks/use-editor-wrapper-styles.native.js +0 -250
- package/src/hooks/use-editor-wrapper-styles.native.scss +0 -12
- package/src/index.native.js +0 -6
- package/src/private-apis.native.js +0 -21
- package/src/store/defaults.native.js +0 -23
|
@@ -3,17 +3,20 @@ import clsx from "clsx";
|
|
|
3
3
|
import { speak } from "@wordpress/a11y";
|
|
4
4
|
import { __, _x, sprintf } from "@wordpress/i18n";
|
|
5
5
|
import { Dropdown, Button } from "@wordpress/components";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import { useDispatch, useSelect } from "@wordpress/data";
|
|
7
|
+
import {
|
|
8
|
+
createBlock,
|
|
9
|
+
store as blocksStore,
|
|
10
|
+
__experimentalGetBlockLabel as getBlockLabel
|
|
11
|
+
} from "@wordpress/blocks";
|
|
12
|
+
import { forwardRef } from "@wordpress/element";
|
|
10
13
|
import { plus } from "@wordpress/icons";
|
|
11
14
|
import InserterMenu from "./menu.mjs";
|
|
12
15
|
import QuickInserter from "./quick-inserter.mjs";
|
|
13
16
|
import { store as blockEditorStore } from "../../store/index.mjs";
|
|
14
17
|
import { getAppenderLabel } from "./get-appender-label.mjs";
|
|
15
18
|
import { jsx } from "react/jsx-runtime";
|
|
16
|
-
var
|
|
19
|
+
var UnforwardedInserterToggle = ({
|
|
17
20
|
onToggle,
|
|
18
21
|
disabled,
|
|
19
22
|
isOpen,
|
|
@@ -21,7 +24,7 @@ var defaultRenderToggle = ({
|
|
|
21
24
|
hasSingleBlockType,
|
|
22
25
|
appenderLabel,
|
|
23
26
|
toggleProps = {}
|
|
24
|
-
}) => {
|
|
27
|
+
}, ref) => {
|
|
25
28
|
const {
|
|
26
29
|
as: Wrapper = Button,
|
|
27
30
|
label: labelProp,
|
|
@@ -51,6 +54,7 @@ var defaultRenderToggle = ({
|
|
|
51
54
|
return /* @__PURE__ */ jsx(
|
|
52
55
|
Wrapper,
|
|
53
56
|
{
|
|
57
|
+
ref,
|
|
54
58
|
__next40pxDefaultSize: toggleProps.as ? void 0 : true,
|
|
55
59
|
icon: plus,
|
|
56
60
|
label,
|
|
@@ -65,70 +69,169 @@ var defaultRenderToggle = ({
|
|
|
65
69
|
}
|
|
66
70
|
);
|
|
67
71
|
};
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
var InserterToggle = forwardRef(UnforwardedInserterToggle);
|
|
73
|
+
var UnforwardedInserter = ({
|
|
74
|
+
clientId,
|
|
75
|
+
rootClientId,
|
|
76
|
+
disabled,
|
|
77
|
+
isAppender,
|
|
78
|
+
position,
|
|
79
|
+
selectBlockOnInsert,
|
|
80
|
+
shouldDirectInsert = true,
|
|
81
|
+
showInserterHelpPanel,
|
|
82
|
+
// This prop is experimental to give some time for the quick inserter to mature
|
|
83
|
+
// Feel free to make them stable after a few releases.
|
|
84
|
+
__experimentalIsQuick: isQuick,
|
|
85
|
+
onSelectOrClose,
|
|
86
|
+
onToggle,
|
|
87
|
+
renderToggle: renderToggleProp,
|
|
88
|
+
toggleProps
|
|
89
|
+
}, ref) => {
|
|
90
|
+
const {
|
|
91
|
+
hasItems,
|
|
92
|
+
hasSingleBlockType,
|
|
93
|
+
blockTitle,
|
|
94
|
+
allowedBlockType,
|
|
95
|
+
blockToInsert,
|
|
96
|
+
appenderLabel,
|
|
97
|
+
targetRootClientId
|
|
98
|
+
} = useSelect(
|
|
99
|
+
(select) => {
|
|
100
|
+
const {
|
|
101
|
+
getBlockRootClientId: getBlockRootClientId2,
|
|
102
|
+
hasInserterItems,
|
|
103
|
+
getAllowedBlocks,
|
|
104
|
+
getDirectInsertBlock,
|
|
105
|
+
getBlockListSettings
|
|
106
|
+
} = select(blockEditorStore);
|
|
107
|
+
const { getBlockVariations, getBlockType: getBlockType2 } = select(blocksStore);
|
|
108
|
+
const _targetRootClientId = rootClientId || getBlockRootClientId2(clientId) || void 0;
|
|
109
|
+
const allowedBlocks = getAllowedBlocks(_targetRootClientId);
|
|
110
|
+
const directInsertBlock = shouldDirectInsert && getDirectInsertBlock(_targetRootClientId);
|
|
111
|
+
const { defaultBlock } = getBlockListSettings(_targetRootClientId) ?? {};
|
|
112
|
+
const _hasSingleBlockType = allowedBlocks?.length === 1 && getBlockVariations(allowedBlocks[0].name, "inserter")?.length === 0;
|
|
113
|
+
const _allowedBlockType = _hasSingleBlockType ? allowedBlocks[0] : null;
|
|
114
|
+
let _blockToInsert = directInsertBlock || null;
|
|
115
|
+
if (!_blockToInsert && _hasSingleBlockType && defaultBlock?.name === _allowedBlockType.name) {
|
|
116
|
+
_blockToInsert = defaultBlock;
|
|
117
|
+
}
|
|
118
|
+
const defaultBlockType = directInsertBlock ? getBlockType2(directInsertBlock.name) : null;
|
|
119
|
+
return {
|
|
120
|
+
hasItems: hasInserterItems(_targetRootClientId),
|
|
121
|
+
hasSingleBlockType: _hasSingleBlockType,
|
|
122
|
+
blockTitle: _allowedBlockType ? _allowedBlockType.title : "",
|
|
123
|
+
allowedBlockType: _allowedBlockType,
|
|
124
|
+
blockToInsert: _blockToInsert,
|
|
125
|
+
appenderLabel: getAppenderLabel(
|
|
126
|
+
directInsertBlock,
|
|
127
|
+
defaultBlockType
|
|
128
|
+
),
|
|
129
|
+
targetRootClientId: _targetRootClientId
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
[rootClientId, clientId, shouldDirectInsert]
|
|
133
|
+
);
|
|
134
|
+
const { insertBlock } = useDispatch(blockEditorStore);
|
|
135
|
+
const {
|
|
136
|
+
getBlock,
|
|
137
|
+
getBlockIndex,
|
|
138
|
+
getBlockOrder,
|
|
139
|
+
getBlockRootClientId,
|
|
140
|
+
getBlockSelectionEnd,
|
|
141
|
+
getPreviousBlockClientId
|
|
142
|
+
} = useSelect(blockEditorStore);
|
|
143
|
+
const { getActiveBlockVariation, getBlockType } = useSelect(blocksStore);
|
|
144
|
+
if (!hasItems && (isAppender || targetRootClientId || clientId)) {
|
|
145
|
+
return null;
|
|
74
146
|
}
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
147
|
+
function insertOnlyAllowedBlock() {
|
|
148
|
+
const blockName = blockToInsert?.name ?? allowedBlockType.name;
|
|
149
|
+
function getAdjacentBlockAttributes(attributesToCopy) {
|
|
150
|
+
if (!attributesToCopy?.length) {
|
|
151
|
+
return {};
|
|
152
|
+
}
|
|
153
|
+
let adjacentAttributes;
|
|
154
|
+
if (clientId) {
|
|
155
|
+
const currentBlock = getBlock(clientId);
|
|
156
|
+
const previousBlock = getBlock(
|
|
157
|
+
getPreviousBlockClientId(clientId)
|
|
158
|
+
);
|
|
159
|
+
if (currentBlock?.name === previousBlock?.name) {
|
|
160
|
+
adjacentAttributes = previousBlock?.attributes;
|
|
161
|
+
}
|
|
162
|
+
} else if (targetRootClientId) {
|
|
163
|
+
const lastInnerBlock = getBlock(targetRootClientId)?.innerBlocks?.at(-1);
|
|
164
|
+
if (lastInnerBlock?.name === blockName) {
|
|
165
|
+
adjacentAttributes = lastInnerBlock.attributes;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (!adjacentAttributes) {
|
|
169
|
+
return {};
|
|
170
|
+
}
|
|
171
|
+
return Object.fromEntries(
|
|
172
|
+
attributesToCopy.filter((attr) => attr in adjacentAttributes).map((attr) => [attr, adjacentAttributes[attr]])
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
function getInsertionIndex() {
|
|
176
|
+
if (clientId) {
|
|
177
|
+
return getBlockIndex(clientId);
|
|
178
|
+
}
|
|
179
|
+
const end = getBlockSelectionEnd();
|
|
180
|
+
if (!isAppender && end && getBlockRootClientId(end) === targetRootClientId) {
|
|
181
|
+
return getBlockIndex(end) + 1;
|
|
182
|
+
}
|
|
183
|
+
return getBlockOrder(targetRootClientId).length;
|
|
184
|
+
}
|
|
185
|
+
const newAttributes = getAdjacentBlockAttributes(
|
|
186
|
+
blockToInsert?.attributesToCopy
|
|
187
|
+
);
|
|
188
|
+
const newBlock = createBlock(blockName, {
|
|
189
|
+
...blockToInsert?.attributes,
|
|
190
|
+
...newAttributes
|
|
191
|
+
});
|
|
192
|
+
insertBlock(
|
|
193
|
+
newBlock,
|
|
194
|
+
getInsertionIndex(),
|
|
195
|
+
targetRootClientId,
|
|
196
|
+
selectBlockOnInsert
|
|
197
|
+
);
|
|
198
|
+
onSelectOrClose?.(newBlock);
|
|
199
|
+
const blockTypeToInsert = getBlockType(blockName);
|
|
200
|
+
let blockLabelToInsert;
|
|
201
|
+
if (blockTypeToInsert) {
|
|
202
|
+
blockLabelToInsert = getBlockLabel(
|
|
203
|
+
blockTypeToInsert,
|
|
204
|
+
newBlock.attributes
|
|
205
|
+
);
|
|
206
|
+
if (blockLabelToInsert === blockTypeToInsert.title) {
|
|
207
|
+
blockLabelToInsert = getActiveBlockVariation(blockName, newBlock.attributes)?.title || blockLabelToInsert;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (blockLabelToInsert) {
|
|
211
|
+
const message = sprintf(
|
|
212
|
+
// translators: %s: the name of the block that has been added
|
|
213
|
+
__("%s block added"),
|
|
214
|
+
blockLabelToInsert
|
|
215
|
+
);
|
|
216
|
+
speak(message);
|
|
79
217
|
}
|
|
80
218
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
* @param {Object} options
|
|
85
|
-
* @param {Function} options.onToggle Callback to invoke when toggle is
|
|
86
|
-
* pressed.
|
|
87
|
-
* @param {boolean} options.isOpen Whether dropdown is currently open.
|
|
88
|
-
*
|
|
89
|
-
* @return {Element} Dropdown toggle element.
|
|
90
|
-
*/
|
|
91
|
-
renderToggle({ onToggle, isOpen }) {
|
|
92
|
-
const {
|
|
93
|
-
disabled,
|
|
94
|
-
blockTitle,
|
|
95
|
-
hasSingleBlockType,
|
|
96
|
-
appenderLabel,
|
|
97
|
-
toggleProps,
|
|
98
|
-
hasItems,
|
|
99
|
-
renderToggle = defaultRenderToggle
|
|
100
|
-
} = this.props;
|
|
101
|
-
return renderToggle({
|
|
102
|
-
onToggle,
|
|
219
|
+
function renderToggle({ onToggle: dropdownOnToggle, isOpen }) {
|
|
220
|
+
const toggleArgs = {
|
|
221
|
+
onToggle: dropdownOnToggle,
|
|
103
222
|
isOpen,
|
|
104
223
|
disabled: disabled || !hasItems,
|
|
105
224
|
blockTitle,
|
|
106
225
|
hasSingleBlockType,
|
|
107
226
|
appenderLabel,
|
|
108
227
|
toggleProps
|
|
109
|
-
}
|
|
228
|
+
};
|
|
229
|
+
if (renderToggleProp) {
|
|
230
|
+
return renderToggleProp(toggleArgs);
|
|
231
|
+
}
|
|
232
|
+
return /* @__PURE__ */ jsx(InserterToggle, { ref, ...toggleArgs });
|
|
110
233
|
}
|
|
111
|
-
|
|
112
|
-
* Render callback to display Dropdown content element.
|
|
113
|
-
*
|
|
114
|
-
* @param {Object} options
|
|
115
|
-
* @param {Function} options.onClose Callback to invoke when dropdown is
|
|
116
|
-
* closed.
|
|
117
|
-
*
|
|
118
|
-
* @return {Element} Dropdown content element.
|
|
119
|
-
*/
|
|
120
|
-
renderContent({ onClose }) {
|
|
121
|
-
const {
|
|
122
|
-
rootClientId,
|
|
123
|
-
clientId,
|
|
124
|
-
isAppender,
|
|
125
|
-
showInserterHelpPanel,
|
|
126
|
-
// This prop is experimental to give some time for the quick inserter to mature
|
|
127
|
-
// Feel free to make them stable after a few releases.
|
|
128
|
-
__experimentalIsQuick: isQuick,
|
|
129
|
-
onSelectOrClose,
|
|
130
|
-
selectBlockOnInsert
|
|
131
|
-
} = this.props;
|
|
234
|
+
function renderContent({ onClose }) {
|
|
132
235
|
if (isQuick) {
|
|
133
236
|
return /* @__PURE__ */ jsx(
|
|
134
237
|
QuickInserter,
|
|
@@ -140,7 +243,7 @@ var Inserter = class extends Component {
|
|
|
140
243
|
}
|
|
141
244
|
onClose();
|
|
142
245
|
},
|
|
143
|
-
rootClientId,
|
|
246
|
+
rootClientId: targetRootClientId,
|
|
144
247
|
clientId,
|
|
145
248
|
isAppender,
|
|
146
249
|
selectBlockOnInsert
|
|
@@ -154,175 +257,35 @@ var Inserter = class extends Component {
|
|
|
154
257
|
onClose();
|
|
155
258
|
},
|
|
156
259
|
onClose,
|
|
157
|
-
rootClientId,
|
|
260
|
+
rootClientId: targetRootClientId,
|
|
158
261
|
clientId,
|
|
159
262
|
isAppender,
|
|
160
263
|
showInserterHelpPanel
|
|
161
264
|
}
|
|
162
265
|
);
|
|
163
266
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
position,
|
|
167
|
-
hasSingleBlockType,
|
|
168
|
-
blockToInsert,
|
|
169
|
-
insertOnlyAllowedBlock,
|
|
170
|
-
__experimentalIsQuick: isQuick,
|
|
171
|
-
onSelectOrClose
|
|
172
|
-
} = this.props;
|
|
173
|
-
if (hasSingleBlockType || blockToInsert) {
|
|
174
|
-
return this.renderToggle({ onToggle: insertOnlyAllowedBlock });
|
|
175
|
-
}
|
|
176
|
-
return /* @__PURE__ */ jsx(
|
|
177
|
-
Dropdown,
|
|
178
|
-
{
|
|
179
|
-
className: "block-editor-inserter",
|
|
180
|
-
contentClassName: clsx("block-editor-inserter__popover", {
|
|
181
|
-
"is-quick": isQuick
|
|
182
|
-
}),
|
|
183
|
-
popoverProps: { position, shift: true },
|
|
184
|
-
onToggle: this.onToggle,
|
|
185
|
-
expandOnMobile: true,
|
|
186
|
-
headerTitle: __("Add a block"),
|
|
187
|
-
renderToggle: this.renderToggle,
|
|
188
|
-
renderContent: this.renderContent,
|
|
189
|
-
onClose: onSelectOrClose
|
|
190
|
-
}
|
|
191
|
-
);
|
|
267
|
+
if (hasSingleBlockType || blockToInsert) {
|
|
268
|
+
return renderToggle({ onToggle: insertOnlyAllowedBlock });
|
|
192
269
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const directInsertBlock = shouldDirectInsert && getDirectInsertBlock(rootClientId);
|
|
208
|
-
const { defaultBlock } = getBlockListSettings(rootClientId) ?? {};
|
|
209
|
-
const hasSingleBlockType = allowedBlocks?.length === 1 && getBlockVariations(allowedBlocks[0].name, "inserter")?.length === 0;
|
|
210
|
-
const allowedBlockType = hasSingleBlockType ? allowedBlocks[0] : null;
|
|
211
|
-
let blockToInsert = directInsertBlock || null;
|
|
212
|
-
if (!blockToInsert && hasSingleBlockType && defaultBlock?.name === allowedBlockType.name) {
|
|
213
|
-
blockToInsert = defaultBlock;
|
|
214
|
-
}
|
|
215
|
-
const defaultBlockType = directInsertBlock ? getBlockType(directInsertBlock.name) : null;
|
|
216
|
-
const appenderLabel = getAppenderLabel(
|
|
217
|
-
directInsertBlock,
|
|
218
|
-
defaultBlockType
|
|
219
|
-
);
|
|
220
|
-
return {
|
|
221
|
-
hasItems: hasInserterItems(rootClientId),
|
|
222
|
-
hasSingleBlockType,
|
|
223
|
-
blockTitle: allowedBlockType ? allowedBlockType.title : "",
|
|
224
|
-
allowedBlockType,
|
|
225
|
-
blockToInsert,
|
|
226
|
-
appenderLabel,
|
|
227
|
-
rootClientId
|
|
228
|
-
};
|
|
270
|
+
return /* @__PURE__ */ jsx(
|
|
271
|
+
Dropdown,
|
|
272
|
+
{
|
|
273
|
+
className: "block-editor-inserter",
|
|
274
|
+
contentClassName: clsx("block-editor-inserter__popover", {
|
|
275
|
+
"is-quick": isQuick
|
|
276
|
+
}),
|
|
277
|
+
popoverProps: { position, shift: true },
|
|
278
|
+
onToggle,
|
|
279
|
+
expandOnMobile: true,
|
|
280
|
+
headerTitle: __("Add a block"),
|
|
281
|
+
renderToggle,
|
|
282
|
+
renderContent,
|
|
283
|
+
onClose: onSelectOrClose
|
|
229
284
|
}
|
|
230
|
-
)
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const {
|
|
235
|
-
rootClientId,
|
|
236
|
-
clientId,
|
|
237
|
-
isAppender,
|
|
238
|
-
hasSingleBlockType,
|
|
239
|
-
allowedBlockType,
|
|
240
|
-
blockToInsert,
|
|
241
|
-
onSelectOrClose,
|
|
242
|
-
selectBlockOnInsert
|
|
243
|
-
} = ownProps;
|
|
244
|
-
if (!hasSingleBlockType && !blockToInsert) {
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
const blockName = blockToInsert?.name ?? allowedBlockType.name;
|
|
248
|
-
function getAdjacentBlockAttributes(attributesToCopy) {
|
|
249
|
-
if (!attributesToCopy?.length) {
|
|
250
|
-
return {};
|
|
251
|
-
}
|
|
252
|
-
const { getBlock, getPreviousBlockClientId } = select(blockEditorStore);
|
|
253
|
-
let adjacentAttributes;
|
|
254
|
-
if (clientId) {
|
|
255
|
-
const currentBlock = getBlock(clientId);
|
|
256
|
-
const previousBlock = getBlock(
|
|
257
|
-
getPreviousBlockClientId(clientId)
|
|
258
|
-
);
|
|
259
|
-
if (currentBlock?.name === previousBlock?.name) {
|
|
260
|
-
adjacentAttributes = previousBlock?.attributes;
|
|
261
|
-
}
|
|
262
|
-
} else if (rootClientId) {
|
|
263
|
-
const lastInnerBlock = getBlock(rootClientId)?.innerBlocks?.at(-1);
|
|
264
|
-
if (lastInnerBlock?.name === blockName) {
|
|
265
|
-
adjacentAttributes = lastInnerBlock.attributes;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
if (!adjacentAttributes) {
|
|
269
|
-
return {};
|
|
270
|
-
}
|
|
271
|
-
return Object.fromEntries(
|
|
272
|
-
attributesToCopy.filter((attr) => attr in adjacentAttributes).map((attr) => [
|
|
273
|
-
attr,
|
|
274
|
-
adjacentAttributes[attr]
|
|
275
|
-
])
|
|
276
|
-
);
|
|
277
|
-
}
|
|
278
|
-
function getInsertionIndex() {
|
|
279
|
-
const {
|
|
280
|
-
getBlockIndex,
|
|
281
|
-
getBlockSelectionEnd,
|
|
282
|
-
getBlockOrder,
|
|
283
|
-
getBlockRootClientId
|
|
284
|
-
} = select(blockEditorStore);
|
|
285
|
-
if (clientId) {
|
|
286
|
-
return getBlockIndex(clientId);
|
|
287
|
-
}
|
|
288
|
-
const end = getBlockSelectionEnd();
|
|
289
|
-
if (!isAppender && end && getBlockRootClientId(end) === rootClientId) {
|
|
290
|
-
return getBlockIndex(end) + 1;
|
|
291
|
-
}
|
|
292
|
-
return getBlockOrder(rootClientId).length;
|
|
293
|
-
}
|
|
294
|
-
const { insertBlock } = dispatch(blockEditorStore);
|
|
295
|
-
const newAttributes = getAdjacentBlockAttributes(
|
|
296
|
-
blockToInsert?.attributesToCopy
|
|
297
|
-
);
|
|
298
|
-
const newBlock = createBlock(blockName, {
|
|
299
|
-
...blockToInsert?.attributes || {},
|
|
300
|
-
...newAttributes
|
|
301
|
-
});
|
|
302
|
-
insertBlock(
|
|
303
|
-
newBlock,
|
|
304
|
-
getInsertionIndex(),
|
|
305
|
-
rootClientId,
|
|
306
|
-
selectBlockOnInsert
|
|
307
|
-
);
|
|
308
|
-
if (onSelectOrClose) {
|
|
309
|
-
onSelectOrClose(newBlock);
|
|
310
|
-
}
|
|
311
|
-
const message = sprintf(
|
|
312
|
-
// translators: %s: the name of the block that has been added
|
|
313
|
-
__("%s block added"),
|
|
314
|
-
allowedBlockType.title
|
|
315
|
-
);
|
|
316
|
-
speak(message);
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
}),
|
|
320
|
-
// The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as
|
|
321
|
-
// a way to detect the global Inserter.
|
|
322
|
-
ifCondition(
|
|
323
|
-
({ hasItems, isAppender, rootClientId, clientId }) => hasItems || !isAppender && !rootClientId && !clientId
|
|
324
|
-
)
|
|
325
|
-
])(Inserter);
|
|
285
|
+
);
|
|
286
|
+
};
|
|
287
|
+
var Inserter = forwardRef(UnforwardedInserter);
|
|
288
|
+
var inserter_default = Inserter;
|
|
326
289
|
export {
|
|
327
290
|
inserter_default as default
|
|
328
291
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/inserter/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { 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';\nimport { getAppenderLabel } from './get-appender-label';\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\tisOpen,\n\tblockTitle,\n\thasSingleBlockType,\n\tappenderLabel,\n\ttoggleProps = {},\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 && appenderLabel ) {\n\t\t// Block returns the full label; use directly (consistent with getBlockLabel).\n\t\tlabel = appenderLabel;\n\t} else if ( ! 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.toLowerCase()\n\t\t);\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\t__next40pxDefaultSize={ toggleProps.as ? undefined : true }\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\tisPressed={ ! hasSingleBlockType && isOpen }\n\t\t\tdisabled={ disabled }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n};\n\nclass Inserter 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 {Element} 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\tappenderLabel,\n\t\t\ttoggleProps,\n\t\t\thasItems,\n\t\t\trenderToggle = defaultRenderToggle,\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\tappenderLabel,\n\t\t\ttoggleProps,\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 {Element} 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\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\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\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\tonClose={ onClose }\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/>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tposition,\n\t\t\thasSingleBlockType,\n\t\t\tblockToInsert,\n\t\t\tinsertOnlyAllowedBlock,\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t} = this.props;\n\n\t\tif ( hasSingleBlockType || blockToInsert ) {\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={ clsx( '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 default 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\tgetBlockListSettings,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockVariations, getBlockType } = select( blocksStore );\n\n\t\t\trootClientId =\n\t\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( rootClientId );\n\t\t\tconst directInsertBlock =\n\t\t\t\tshouldDirectInsert && getDirectInsertBlock( rootClientId );\n\t\t\tconst { defaultBlock } = getBlockListSettings( rootClientId ) ?? {};\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\t\t\tconst allowedBlockType = hasSingleBlockType\n\t\t\t\t? allowedBlocks[ 0 ]\n\t\t\t\t: null;\n\n\t\t\t// Single-block-type parents get adjacent-attribute copying\n\t\t\t// without needing to set `directInsert: true`.\n\t\t\tlet blockToInsert = directInsertBlock || null;\n\t\t\tif (\n\t\t\t\t! blockToInsert &&\n\t\t\t\thasSingleBlockType &&\n\t\t\t\tdefaultBlock?.name === allowedBlockType.name\n\t\t\t) {\n\t\t\t\tblockToInsert = defaultBlock;\n\t\t\t}\n\n\t\t\tconst defaultBlockType = directInsertBlock\n\t\t\t\t? getBlockType( directInsertBlock.name )\n\t\t\t\t: null;\n\t\t\tconst appenderLabel = getAppenderLabel(\n\t\t\t\tdirectInsertBlock,\n\t\t\t\tdefaultBlockType\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\tblockToInsert,\n\t\t\t\tappenderLabel,\n\t\t\t\trootClientId,\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\tblockToInsert,\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 && ! blockToInsert ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blockName = blockToInsert?.name ?? allowedBlockType.name;\n\n\t\t\t\tfunction getAdjacentBlockAttributes( attributesToCopy ) {\n\t\t\t\t\tif ( ! attributesToCopy?.length ) {\n\t\t\t\t\t\treturn {};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst { getBlock, getPreviousBlockClientId } =\n\t\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\t\t// Find the adjacent block of the same type whose attributes\n\t\t\t\t\t// should be copied: previous sibling when inserting next to\n\t\t\t\t\t// an existing block, otherwise the last child of the root.\n\t\t\t\t\tlet adjacentAttributes;\n\t\t\t\t\tif ( 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\t\t\t\t\t\tif ( currentBlock?.name === previousBlock?.name ) {\n\t\t\t\t\t\t\tadjacentAttributes = previousBlock?.attributes;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if ( rootClientId ) {\n\t\t\t\t\t\tconst lastInnerBlock =\n\t\t\t\t\t\t\tgetBlock( rootClientId )?.innerBlocks?.at( -1 );\n\t\t\t\t\t\tif ( lastInnerBlock?.name === blockName ) {\n\t\t\t\t\t\t\tadjacentAttributes = lastInnerBlock.attributes;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( ! adjacentAttributes ) {\n\t\t\t\t\t\treturn {};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn Object.fromEntries(\n\t\t\t\t\t\tattributesToCopy\n\t\t\t\t\t\t\t.filter( ( attr ) => attr in adjacentAttributes )\n\t\t\t\t\t\t\t.map( ( attr ) => [\n\t\t\t\t\t\t\t\tattr,\n\t\t\t\t\t\t\t\tadjacentAttributes[ attr ],\n\t\t\t\t\t\t\t] )\n\t\t\t\t\t);\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\t// Attempt to augment the inserted block 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\tconst newAttributes = getAdjacentBlockAttributes(\n\t\t\t\t\tblockToInsert?.attributesToCopy\n\t\t\t\t);\n\n\t\t\t\tconst newBlock = createBlock( blockName, {\n\t\t\t\t\t...( blockToInsert?.attributes || {} ),\n\t\t\t\t\t...newAttributes,\n\t\t\t\t} );\n\n\t\t\t\tinsertBlock(\n\t\t\t\t\tnewBlock,\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( newBlock );\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] )( Inserter );\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,aAAa;AACtB,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,UAAU,cAAc;AACjC,SAAS,iBAAiB;
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tcreateBlock,\n\tstore as blocksStore,\n\t__experimentalGetBlockLabel as getBlockLabel,\n} from '@wordpress/blocks';\nimport { forwardRef } from '@wordpress/element';\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';\nimport { getAppenderLabel } from './get-appender-label';\n\nconst UnforwardedInserterToggle = (\n\t{\n\t\tonToggle,\n\t\tdisabled,\n\t\tisOpen,\n\t\tblockTitle,\n\t\thasSingleBlockType,\n\t\tappenderLabel,\n\t\ttoggleProps = {},\n\t},\n\tref\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 && appenderLabel ) {\n\t\t// Block returns the full label; use directly (consistent with getBlockLabel).\n\t\tlabel = appenderLabel;\n\t} else if ( ! 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.toLowerCase()\n\t\t);\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\tref={ ref }\n\t\t\t__next40pxDefaultSize={ toggleProps.as ? undefined : true }\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\tisPressed={ ! hasSingleBlockType && isOpen }\n\t\t\tdisabled={ disabled }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n};\n\nconst InserterToggle = forwardRef( UnforwardedInserterToggle );\n\nconst UnforwardedInserter = (\n\t{\n\t\tclientId,\n\t\trootClientId,\n\t\tdisabled,\n\t\tisAppender,\n\t\tposition,\n\t\tselectBlockOnInsert,\n\t\tshouldDirectInsert = true,\n\t\tshowInserterHelpPanel,\n\t\t// This prop is experimental to give some time for the quick inserter to mature\n\t\t// Feel free to make them stable after a few releases.\n\t\t__experimentalIsQuick: isQuick,\n\t\tonSelectOrClose,\n\t\tonToggle,\n\t\trenderToggle: renderToggleProp,\n\t\ttoggleProps,\n\t},\n\tref\n) => {\n\tconst {\n\t\thasItems,\n\t\thasSingleBlockType,\n\t\tblockTitle,\n\t\tallowedBlockType,\n\t\tblockToInsert,\n\t\tappenderLabel,\n\t\ttargetRootClientId,\n\t} = useSelect(\n\t\t( select ) => {\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\tgetBlockListSettings,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockVariations, getBlockType } = select( blocksStore );\n\n\t\t\tconst _targetRootClientId =\n\t\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( _targetRootClientId );\n\t\t\tconst directInsertBlock =\n\t\t\t\tshouldDirectInsert &&\n\t\t\t\tgetDirectInsertBlock( _targetRootClientId );\n\t\t\tconst { defaultBlock } =\n\t\t\t\tgetBlockListSettings( _targetRootClientId ) ?? {};\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\t\t\tconst _allowedBlockType = _hasSingleBlockType\n\t\t\t\t? allowedBlocks[ 0 ]\n\t\t\t\t: null;\n\n\t\t\t// Single-block-type parents get adjacent-attribute copying\n\t\t\t// without needing to set `directInsert: true`.\n\t\t\tlet _blockToInsert = directInsertBlock || null;\n\t\t\tif (\n\t\t\t\t! _blockToInsert &&\n\t\t\t\t_hasSingleBlockType &&\n\t\t\t\tdefaultBlock?.name === _allowedBlockType.name\n\t\t\t) {\n\t\t\t\t_blockToInsert = defaultBlock;\n\t\t\t}\n\n\t\t\tconst defaultBlockType = directInsertBlock\n\t\t\t\t? getBlockType( directInsertBlock.name )\n\t\t\t\t: null;\n\t\t\treturn {\n\t\t\t\thasItems: hasInserterItems( _targetRootClientId ),\n\t\t\t\thasSingleBlockType: _hasSingleBlockType,\n\t\t\t\tblockTitle: _allowedBlockType ? _allowedBlockType.title : '',\n\t\t\t\tallowedBlockType: _allowedBlockType,\n\t\t\t\tblockToInsert: _blockToInsert,\n\t\t\t\tappenderLabel: getAppenderLabel(\n\t\t\t\t\tdirectInsertBlock,\n\t\t\t\t\tdefaultBlockType\n\t\t\t\t),\n\t\t\t\ttargetRootClientId: _targetRootClientId,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId, clientId, shouldDirectInsert ]\n\t);\n\n\tconst { insertBlock } = useDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlock,\n\t\tgetBlockIndex,\n\t\tgetBlockOrder,\n\t\tgetBlockRootClientId,\n\t\tgetBlockSelectionEnd,\n\t\tgetPreviousBlockClientId,\n\t} = useSelect( blockEditorStore );\n\tconst { getActiveBlockVariation, getBlockType } = useSelect( blocksStore );\n\n\t// The global inserter (no isAppender, no rootClientId, no clientId) should\n\t// always render, even with no items.\n\tif ( ! hasItems && ( isAppender || targetRootClientId || clientId ) ) {\n\t\treturn null;\n\t}\n\n\tfunction insertOnlyAllowedBlock() {\n\t\tconst blockName = blockToInsert?.name ?? allowedBlockType.name;\n\n\t\tfunction getAdjacentBlockAttributes( attributesToCopy ) {\n\t\t\tif ( ! attributesToCopy?.length ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\t// Find the adjacent block of the same type whose attributes\n\t\t\t// should be copied: previous sibling when inserting next to\n\t\t\t// an existing block, otherwise the last child of the root.\n\t\t\tlet adjacentAttributes;\n\t\t\tif ( clientId ) {\n\t\t\t\tconst currentBlock = getBlock( clientId );\n\t\t\t\tconst previousBlock = getBlock(\n\t\t\t\t\tgetPreviousBlockClientId( clientId )\n\t\t\t\t);\n\t\t\t\tif ( currentBlock?.name === previousBlock?.name ) {\n\t\t\t\t\tadjacentAttributes = previousBlock?.attributes;\n\t\t\t\t}\n\t\t\t} else if ( targetRootClientId ) {\n\t\t\t\tconst lastInnerBlock =\n\t\t\t\t\tgetBlock( targetRootClientId )?.innerBlocks?.at( -1 );\n\t\t\t\tif ( lastInnerBlock?.name === blockName ) {\n\t\t\t\t\tadjacentAttributes = lastInnerBlock.attributes;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! adjacentAttributes ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\treturn Object.fromEntries(\n\t\t\t\tattributesToCopy\n\t\t\t\t\t.filter( ( attr ) => attr in adjacentAttributes )\n\t\t\t\t\t.map( ( attr ) => [ attr, adjacentAttributes[ attr ] ] )\n\t\t\t);\n\t\t}\n\n\t\tfunction getInsertionIndex() {\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 a selected block, we insert after the selected block.\n\t\t\tconst end = getBlockSelectionEnd();\n\t\t\tif (\n\t\t\t\t! isAppender &&\n\t\t\t\tend &&\n\t\t\t\tgetBlockRootClientId( end ) === targetRootClientId\n\t\t\t) {\n\t\t\t\treturn getBlockIndex( end ) + 1;\n\t\t\t}\n\n\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\treturn getBlockOrder( targetRootClientId ).length;\n\t\t}\n\n\t\t// Attempt to augment the inserted block with attributes from an adjacent block.\n\t\t// This ensures styling from nearby blocks is preserved in the newly inserted block.\n\t\t// See: https://github.com/WordPress/gutenberg/issues/37904\n\t\tconst newAttributes = getAdjacentBlockAttributes(\n\t\t\tblockToInsert?.attributesToCopy\n\t\t);\n\n\t\tconst newBlock = createBlock( blockName, {\n\t\t\t...blockToInsert?.attributes,\n\t\t\t...newAttributes,\n\t\t} );\n\n\t\tinsertBlock(\n\t\t\tnewBlock,\n\t\t\tgetInsertionIndex(),\n\t\t\ttargetRootClientId,\n\t\t\tselectBlockOnInsert\n\t\t);\n\n\t\tonSelectOrClose?.( newBlock );\n\n\t\tconst blockTypeToInsert = getBlockType( blockName );\n\t\tlet blockLabelToInsert;\n\t\tif ( blockTypeToInsert ) {\n\t\t\tblockLabelToInsert = getBlockLabel(\n\t\t\t\tblockTypeToInsert,\n\t\t\t\tnewBlock.attributes\n\t\t\t);\n\n\t\t\tif ( blockLabelToInsert === blockTypeToInsert.title ) {\n\t\t\t\tblockLabelToInsert =\n\t\t\t\t\tgetActiveBlockVariation( blockName, newBlock.attributes )\n\t\t\t\t\t\t?.title || blockLabelToInsert;\n\t\t\t}\n\t\t}\n\n\t\tif ( blockLabelToInsert ) {\n\t\t\tconst message = sprintf(\n\t\t\t\t// translators: %s: the name of the block that has been added\n\t\t\t\t__( '%s block added' ),\n\t\t\t\tblockLabelToInsert\n\t\t\t);\n\t\t\tspeak( message );\n\t\t}\n\t}\n\n\tfunction renderToggle( { onToggle: dropdownOnToggle, isOpen } ) {\n\t\tconst toggleArgs = {\n\t\t\tonToggle: dropdownOnToggle,\n\t\t\tisOpen,\n\t\t\tdisabled: disabled || ! hasItems,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tappenderLabel,\n\t\t\ttoggleProps,\n\t\t};\n\n\t\tif ( renderToggleProp ) {\n\t\t\treturn renderToggleProp( toggleArgs );\n\t\t}\n\n\t\treturn <InserterToggle ref={ ref } { ...toggleArgs } />;\n\t}\n\n\tfunction renderContent( { onClose } ) {\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={ targetRootClientId }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisAppender={ isAppender }\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\tonClose={ onClose }\n\t\t\t\trootClientId={ targetRootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshowInserterHelpPanel={ showInserterHelpPanel }\n\t\t\t/>\n\t\t);\n\t}\n\n\tif ( hasSingleBlockType || blockToInsert ) {\n\t\treturn renderToggle( { onToggle: insertOnlyAllowedBlock } );\n\t}\n\n\treturn (\n\t\t<Dropdown\n\t\t\tclassName=\"block-editor-inserter\"\n\t\t\tcontentClassName={ clsx( 'block-editor-inserter__popover', {\n\t\t\t\t'is-quick': isQuick,\n\t\t\t} ) }\n\t\t\tpopoverProps={ { position, shift: true } }\n\t\t\tonToggle={ onToggle }\n\t\t\texpandOnMobile\n\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\trenderToggle={ renderToggle }\n\t\t\trenderContent={ renderContent }\n\t\t\tonClose={ onSelectOrClose }\n\t\t/>\n\t);\n};\n\nconst Inserter = forwardRef( UnforwardedInserter );\n\nexport default Inserter;\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,aAAa;AACtB,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,UAAU,cAAc;AACjC,SAAS,aAAa,iBAAiB;AACvC;AAAA,EACC;AAAA,EACA,SAAS;AAAA,EACT,+BAA+B;AAAA,OACzB;AACP,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AAKrB,OAAO,kBAAkB;AACzB,OAAO,mBAAmB;AAC1B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,wBAAwB;AA8C/B;AA5CF,IAAM,4BAA4B,CACjC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc,CAAC;AAChB,GACA,QACI;AACJ,QAAM;AAAA,IACL,IAAI,UAAU;AAAA,IACd,OAAO;AAAA,IACP;AAAA,IACA,GAAG;AAAA,EACJ,IAAI;AAEJ,MAAI,QAAQ;AACZ,MAAK,CAAE,SAAS,eAAgB;AAE/B,YAAQ;AAAA,EACT,WAAY,CAAE,SAAS,oBAAqB;AAC3C,YAAQ;AAAA;AAAA,MAEP,GAAI,UAAU,qCAAsC;AAAA,MACpD,WAAW,YAAY;AAAA,IACxB;AAAA,EACD,WAAY,CAAE,OAAQ;AACrB,YAAQ,GAAI,aAAa,yCAA0C;AAAA,EACpE;AAGA,WAAS,YAAa,OAAQ;AAC7B,QAAK,UAAW;AACf,eAAU,KAAM;AAAA,IACjB;AACA,QAAK,SAAU;AACd,cAAS,KAAM;AAAA,IAChB;AAAA,EACD;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA,uBAAwB,YAAY,KAAK,SAAY;AAAA,MACrD,MAAO;AAAA,MACP;AAAA,MACA,iBAAgB;AAAA,MAChB,SAAU;AAA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AC;AAAA;AAAA,UACA,UAAW,CAAE,WAAY;AACxB,kBAAM,aACL,MAAM,QAAS,MAAO,KAAK,QAAQ,SAChC,OAAQ,CAAE,IACV;AACJ,gBACC,mBACA,OAAO,oBAAoB,YAC1B;AACD,8BAAiB,UAAW;AAAA,YAC7B;AACA,oBAAQ;AAAA,UACT;AAAA,UACA,cAAe;AAAA,UACf;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACD;AAAA,IAEF;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QACA,UAAW,MAAM;AAChB,kBAAQ;AAAA,QACT;AAAA,QACA;AAAA,QACA,cAAe;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,EAEF;AAEA,MAAK,sBAAsB,eAAgB;AAC1C,WAAO,aAAc,EAAE,UAAU,uBAAuB,CAAE;AAAA,EAC3D;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,kBAAmB,KAAM,kCAAkC;AAAA,QAC1D,YAAY;AAAA,MACb,CAAE;AAAA,MACF,cAAe,EAAE,UAAU,OAAO,KAAK;AAAA,MACvC;AAAA,MACA,gBAAc;AAAA,MACd,aAAc,GAAI,aAAc;AAAA,MAChC;AAAA,MACA;AAAA,MACA,SAAU;AAAA;AAAA,EACX;AAEF;AAEA,IAAM,WAAW,WAAY,mBAAoB;AAEjD,IAAO,mBAAQ;",
|
|
6
|
+
"names": ["getBlockRootClientId", "getBlockType"]
|
|
7
7
|
}
|
|
@@ -150,7 +150,7 @@ function InserterSearchResults({
|
|
|
150
150
|
const patternsUI = !!filteredBlockPatterns.length && /* @__PURE__ */ jsx(
|
|
151
151
|
InserterPanel,
|
|
152
152
|
{
|
|
153
|
-
title: /* @__PURE__ */ jsx(VisuallyHidden, { children: __("
|
|
153
|
+
title: /* @__PURE__ */ jsx(VisuallyHidden, { children: __("Patterns") }),
|
|
154
154
|
children: /* @__PURE__ */ jsx("div", { className: "block-editor-inserter__quick-inserter-patterns", children: /* @__PURE__ */ jsx(
|
|
155
155
|
BlockPatternsList,
|
|
156
156
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/inserter/search-results.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { useDebounce, useAsyncList } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesList from '../block-types-list';\nimport BlockPatternsList from '../block-patterns-list';\nimport __unstableInserterMenuExtension from '../inserter-menu-extension';\nimport InserterPanel from './panel';\nimport InserterNoResults from './no-results';\nimport useInsertionPoint from './hooks/use-insertion-point';\nimport usePatternsState from './hooks/use-patterns-state';\nimport useBlockTypesState from './hooks/use-block-types-state';\nimport { searchBlockItems, searchItems } from './search-items';\nimport InserterListbox from '../inserter-listbox';\nimport { orderBy } from '../../utils/sorting';\nimport { orderInserterBlockItems } from '../../utils/order-inserter-block-items';\nimport { store as blockEditorStore } from '../../store';\n\nconst INITIAL_INSERTER_RESULTS = 9;\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation and rerendering the component.\n *\n * @type {Array}\n */\nconst EMPTY_ARRAY = [];\n\nfunction InserterSearchResults( {\n\tfilterValue,\n\tonSelect,\n\tonHover,\n\tonHoverPattern,\n\trootClientId,\n\tclientId,\n\tisAppender,\n\t__experimentalInsertionIndex,\n\tmaxBlockPatterns,\n\tmaxBlockTypes,\n\tshowBlockDirectory = false,\n\tisDraggable = true,\n\tshouldFocusBlock = true,\n\tprioritizePatterns,\n\tselectBlockOnInsert,\n\tisQuick,\n} ) {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\n\tconst { prioritizedBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst blockListSettings =\n\t\t\t\tselect( blockEditorStore ).getBlockListSettings( rootClientId );\n\n\t\t\treturn {\n\t\t\t\tprioritizedBlocks:\n\t\t\t\t\tblockListSettings?.prioritizedInserterBlocks || EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\tonSelect,\n\t\trootClientId,\n\t\tclientId,\n\t\tisAppender,\n\t\tinsertionIndex: __experimentalInsertionIndex,\n\t\tshouldFocusBlock,\n\t\tselectBlockOnInsert,\n\t} );\n\tconst [\n\t\tblockTypes,\n\t\tblockTypeCategories,\n\t\tblockTypeCollections,\n\t\tonSelectBlockType,\n\t] = useBlockTypesState( destinationRootClientId, onInsertBlocks, isQuick );\n\tconst [ patterns, , onClickPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId,\n\t\tundefined,\n\t\tisQuick\n\t);\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tif ( maxBlockPatterns === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst results = searchItems( patterns, filterValue );\n\t\treturn maxBlockPatterns !== undefined\n\t\t\t? results.slice( 0, maxBlockPatterns )\n\t\t\t: results;\n\t}, [ filterValue, patterns, maxBlockPatterns ] );\n\n\tlet maxBlockTypesToShow = maxBlockTypes;\n\tif ( prioritizePatterns && filteredBlockPatterns.length > 2 ) {\n\t\tmaxBlockTypesToShow = 0;\n\t}\n\n\tconst filteredBlockTypes = useMemo( () => {\n\t\tif ( maxBlockTypesToShow === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst nonPatternBlockTypes = blockTypes.filter(\n\t\t\t( blockType ) => blockType.name !== 'core/block'\n\t\t);\n\t\tlet orderedItems = orderBy( nonPatternBlockTypes, 'frecency', 'desc' );\n\n\t\tif ( ! filterValue && prioritizedBlocks.length ) {\n\t\t\torderedItems = orderInserterBlockItems(\n\t\t\t\torderedItems,\n\t\t\t\tprioritizedBlocks\n\t\t\t);\n\t\t}\n\n\t\tconst results = searchBlockItems(\n\t\t\torderedItems,\n\t\t\tblockTypeCategories,\n\t\t\tblockTypeCollections,\n\t\t\tfilterValue\n\t\t);\n\n\t\treturn maxBlockTypesToShow !== undefined\n\t\t\t? results.slice( 0, maxBlockTypesToShow )\n\t\t\t: results;\n\t}, [\n\t\tfilterValue,\n\t\tblockTypes,\n\t\tblockTypeCategories,\n\t\tblockTypeCollections,\n\t\tmaxBlockTypesToShow,\n\t\tprioritizedBlocks,\n\t] );\n\n\t// Announce search results on change.\n\tuseEffect( () => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockTypes.length + filteredBlockPatterns.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [\n\t\tfilterValue,\n\t\tdebouncedSpeak,\n\t\tfilteredBlockTypes,\n\t\tfilteredBlockPatterns,\n\t] );\n\n\tconst currentShownBlockTypes = useAsyncList( filteredBlockTypes, {\n\t\tstep: INITIAL_INSERTER_RESULTS,\n\t} );\n\n\tconst hasItems =\n\t\tfilteredBlockTypes.length > 0 || filteredBlockPatterns.length > 0;\n\n\tconst blocksUI = !! filteredBlockTypes.length && (\n\t\t<InserterPanel\n\t\t\ttitle={ <VisuallyHidden>{ __( 'Blocks' ) }</VisuallyHidden> }\n\t\t>\n\t\t\t<BlockTypesList\n\t\t\t\titems={ currentShownBlockTypes }\n\t\t\t\tonSelect={ onSelectBlockType }\n\t\t\t\tonHover={ onHover }\n\t\t\t\tlabel={ __( 'Blocks' ) }\n\t\t\t\tisDraggable={ isDraggable }\n\t\t\t/>\n\t\t</InserterPanel>\n\t);\n\n\tconst patternsUI = !! filteredBlockPatterns.length && (\n\t\t<InserterPanel\n\t\t\ttitle={
|
|
5
|
-
"mappings": ";AAGA,SAAS,SAAS,iBAAiB;AACnC,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,sBAAsB;AAC/B,SAAS,aAAa,oBAAoB;AAC1C,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAK1B,OAAO,oBAAoB;AAC3B,OAAO,uBAAuB;AAC9B,OAAO,qCAAqC;AAC5C,OAAO,mBAAmB;AAC1B,OAAO,uBAAuB;AAC9B,OAAO,uBAAuB;AAC9B,OAAO,sBAAsB;AAC7B,OAAO,wBAAwB;AAC/B,SAAS,kBAAkB,mBAAmB;AAC9C,OAAO,qBAAqB;AAC5B,SAAS,eAAe;AACxB,SAAS,+BAA+B;AACxC,SAAS,SAAS,wBAAwB;AAgJ/B,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { useDebounce, useAsyncList } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesList from '../block-types-list';\nimport BlockPatternsList from '../block-patterns-list';\nimport __unstableInserterMenuExtension from '../inserter-menu-extension';\nimport InserterPanel from './panel';\nimport InserterNoResults from './no-results';\nimport useInsertionPoint from './hooks/use-insertion-point';\nimport usePatternsState from './hooks/use-patterns-state';\nimport useBlockTypesState from './hooks/use-block-types-state';\nimport { searchBlockItems, searchItems } from './search-items';\nimport InserterListbox from '../inserter-listbox';\nimport { orderBy } from '../../utils/sorting';\nimport { orderInserterBlockItems } from '../../utils/order-inserter-block-items';\nimport { store as blockEditorStore } from '../../store';\n\nconst INITIAL_INSERTER_RESULTS = 9;\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation and rerendering the component.\n *\n * @type {Array}\n */\nconst EMPTY_ARRAY = [];\n\nfunction InserterSearchResults( {\n\tfilterValue,\n\tonSelect,\n\tonHover,\n\tonHoverPattern,\n\trootClientId,\n\tclientId,\n\tisAppender,\n\t__experimentalInsertionIndex,\n\tmaxBlockPatterns,\n\tmaxBlockTypes,\n\tshowBlockDirectory = false,\n\tisDraggable = true,\n\tshouldFocusBlock = true,\n\tprioritizePatterns,\n\tselectBlockOnInsert,\n\tisQuick,\n} ) {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\n\tconst { prioritizedBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst blockListSettings =\n\t\t\t\tselect( blockEditorStore ).getBlockListSettings( rootClientId );\n\n\t\t\treturn {\n\t\t\t\tprioritizedBlocks:\n\t\t\t\t\tblockListSettings?.prioritizedInserterBlocks || EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\tonSelect,\n\t\trootClientId,\n\t\tclientId,\n\t\tisAppender,\n\t\tinsertionIndex: __experimentalInsertionIndex,\n\t\tshouldFocusBlock,\n\t\tselectBlockOnInsert,\n\t} );\n\tconst [\n\t\tblockTypes,\n\t\tblockTypeCategories,\n\t\tblockTypeCollections,\n\t\tonSelectBlockType,\n\t] = useBlockTypesState( destinationRootClientId, onInsertBlocks, isQuick );\n\tconst [ patterns, , onClickPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId,\n\t\tundefined,\n\t\tisQuick\n\t);\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tif ( maxBlockPatterns === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst results = searchItems( patterns, filterValue );\n\t\treturn maxBlockPatterns !== undefined\n\t\t\t? results.slice( 0, maxBlockPatterns )\n\t\t\t: results;\n\t}, [ filterValue, patterns, maxBlockPatterns ] );\n\n\tlet maxBlockTypesToShow = maxBlockTypes;\n\tif ( prioritizePatterns && filteredBlockPatterns.length > 2 ) {\n\t\tmaxBlockTypesToShow = 0;\n\t}\n\n\tconst filteredBlockTypes = useMemo( () => {\n\t\tif ( maxBlockTypesToShow === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst nonPatternBlockTypes = blockTypes.filter(\n\t\t\t( blockType ) => blockType.name !== 'core/block'\n\t\t);\n\t\tlet orderedItems = orderBy( nonPatternBlockTypes, 'frecency', 'desc' );\n\n\t\tif ( ! filterValue && prioritizedBlocks.length ) {\n\t\t\torderedItems = orderInserterBlockItems(\n\t\t\t\torderedItems,\n\t\t\t\tprioritizedBlocks\n\t\t\t);\n\t\t}\n\n\t\tconst results = searchBlockItems(\n\t\t\torderedItems,\n\t\t\tblockTypeCategories,\n\t\t\tblockTypeCollections,\n\t\t\tfilterValue\n\t\t);\n\n\t\treturn maxBlockTypesToShow !== undefined\n\t\t\t? results.slice( 0, maxBlockTypesToShow )\n\t\t\t: results;\n\t}, [\n\t\tfilterValue,\n\t\tblockTypes,\n\t\tblockTypeCategories,\n\t\tblockTypeCollections,\n\t\tmaxBlockTypesToShow,\n\t\tprioritizedBlocks,\n\t] );\n\n\t// Announce search results on change.\n\tuseEffect( () => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockTypes.length + filteredBlockPatterns.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [\n\t\tfilterValue,\n\t\tdebouncedSpeak,\n\t\tfilteredBlockTypes,\n\t\tfilteredBlockPatterns,\n\t] );\n\n\tconst currentShownBlockTypes = useAsyncList( filteredBlockTypes, {\n\t\tstep: INITIAL_INSERTER_RESULTS,\n\t} );\n\n\tconst hasItems =\n\t\tfilteredBlockTypes.length > 0 || filteredBlockPatterns.length > 0;\n\n\tconst blocksUI = !! filteredBlockTypes.length && (\n\t\t<InserterPanel\n\t\t\ttitle={ <VisuallyHidden>{ __( 'Blocks' ) }</VisuallyHidden> }\n\t\t>\n\t\t\t<BlockTypesList\n\t\t\t\titems={ currentShownBlockTypes }\n\t\t\t\tonSelect={ onSelectBlockType }\n\t\t\t\tonHover={ onHover }\n\t\t\t\tlabel={ __( 'Blocks' ) }\n\t\t\t\tisDraggable={ isDraggable }\n\t\t\t/>\n\t\t</InserterPanel>\n\t);\n\n\tconst patternsUI = !! filteredBlockPatterns.length && (\n\t\t<InserterPanel\n\t\t\ttitle={ <VisuallyHidden>{ __( 'Patterns' ) }</VisuallyHidden> }\n\t\t>\n\t\t\t<div className=\"block-editor-inserter__quick-inserter-patterns\">\n\t\t\t\t<BlockPatternsList\n\t\t\t\t\tblockPatterns={ filteredBlockPatterns }\n\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\tonHover={ onHoverPattern }\n\t\t\t\t\tisDraggable={ isDraggable }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</InserterPanel>\n\t);\n\n\treturn (\n\t\t<InserterListbox>\n\t\t\t{ ! showBlockDirectory && ! hasItems && <InserterNoResults /> }\n\n\t\t\t{ prioritizePatterns ? patternsUI : blocksUI }\n\n\t\t\t{ !! filteredBlockTypes.length &&\n\t\t\t\t!! filteredBlockPatterns.length && (\n\t\t\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\t\t\t\t) }\n\n\t\t\t{ prioritizePatterns ? blocksUI : patternsUI }\n\n\t\t\t{ showBlockDirectory && (\n\t\t\t\t<__unstableInserterMenuExtension.Slot\n\t\t\t\t\tfillProps={ {\n\t\t\t\t\t\tonSelect: onSelectBlockType,\n\t\t\t\t\t\tonHover,\n\t\t\t\t\t\tfilterValue,\n\t\t\t\t\t\thasItems,\n\t\t\t\t\t\trootClientId: destinationRootClientId,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ ( fills ) => {\n\t\t\t\t\t\tif ( fills.length ) {\n\t\t\t\t\t\t\treturn fills;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( ! hasItems ) {\n\t\t\t\t\t\t\treturn <InserterNoResults />;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t} }\n\t\t\t\t</__unstableInserterMenuExtension.Slot>\n\t\t\t) }\n\t\t</InserterListbox>\n\t);\n}\n\nexport default InserterSearchResults;\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,SAAS,iBAAiB;AACnC,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,sBAAsB;AAC/B,SAAS,aAAa,oBAAoB;AAC1C,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAK1B,OAAO,oBAAoB;AAC3B,OAAO,uBAAuB;AAC9B,OAAO,qCAAqC;AAC5C,OAAO,mBAAmB;AAC1B,OAAO,uBAAuB;AAC9B,OAAO,uBAAuB;AAC9B,OAAO,sBAAsB;AAC7B,OAAO,wBAAwB;AAC/B,SAAS,kBAAkB,mBAAmB;AAC9C,OAAO,qBAAqB;AAC5B,SAAS,eAAe;AACxB,SAAS,+BAA+B;AACxC,SAAS,SAAS,wBAAwB;AAgJ/B,cA4BT,YA5BS;AA9IX,IAAM,2BAA2B;AAOjC,IAAM,cAAc,CAAC;AAErB,SAAS,sBAAuB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,qBAAqB;AAAA,EACrB,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,iBAAiB,YAAa,OAAO,GAAI;AAE/C,QAAM,EAAE,kBAAkB,IAAI;AAAA,IAC7B,CAAE,WAAY;AACb,YAAM,oBACL,OAAQ,gBAAiB,EAAE,qBAAsB,YAAa;AAE/D,aAAO;AAAA,QACN,mBACC,mBAAmB,6BAA6B;AAAA,MAClD;AAAA,IACD;AAAA,IACA,CAAE,YAAa;AA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