@wordpress/block-editor 9.0.0 → 9.3.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 +10 -0
- package/README.md +1 -0
- package/build/autocompleters/block.js +3 -1
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-matrix-control/index.js +4 -13
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-content-overlay/index.js +4 -82
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-context/index.js.map +1 -1
- package/build/components/block-controls/hook.js.map +1 -1
- package/build/components/block-draggable/draggable-chip.native.js +65 -0
- package/build/components/block-draggable/draggable-chip.native.js.map +1 -0
- package/build/components/block-draggable/dropping-insertion-point.native.js +157 -0
- package/build/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-draggable/index.native.js +488 -0
- package/build/components/block-draggable/index.native.js.map +1 -0
- package/build/components/block-draggable/use-scroll-when-dragging.native.js +130 -0
- package/build/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
- package/build/components/block-list/block-list-context.native.js +195 -0
- package/build/components/block-list/block-list-context.native.js.map +1 -0
- package/build/components/block-list/block-list-item-cell.native.js +67 -0
- package/build/components/block-list/block-list-item-cell.native.js.map +1 -0
- package/build/components/block-list/block-list-item.native.js +12 -9
- package/build/components/block-list/block-list-item.native.js.map +1 -1
- package/build/components/block-list/block-selection-button.native.js.map +1 -1
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +27 -5
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.js +34 -32
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/index.native.js +75 -23
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +8 -4
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-custom-class-name.js.map +1 -1
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +1 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-list-appender/index.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/index.native.js +10 -3
- package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.native.js +17 -4
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +1 -1
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-popover/inbetween.js +19 -8
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +5 -16
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +1 -1
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-selection-clearer/index.js.map +1 -1
- package/build/components/block-settings-menu/block-mode-toggle.js +3 -7
- package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +6 -3
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/index.js +6 -3
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/menu-items.js +3 -7
- package/build/components/block-styles/menu-items.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build/components/block-toolbar/index.native.js.map +1 -1
- package/build/components/block-toolbar/utils.js +5 -8
- package/build/components/block-toolbar/utils.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +1 -0
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +1 -29
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +16 -2
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +10 -3
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/color-style-selector/index.js.map +1 -1
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +122 -41
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +35 -60
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/convert-to-group-buttons/toolbar.js +22 -5
- package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build/components/copy-handler/index.js +17 -1
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/default-block-appender/index.js.map +1 -1
- package/build/components/default-block-appender/index.native.js.map +1 -1
- package/build/components/default-style-picker/index.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/iframe/index.js +51 -50
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +3 -1
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/image-size-control/index.js +3 -1
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/index.js +31 -13
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/block-types-tab.native.js.map +1 -1
- package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +1 -1
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/library.js +3 -7
- package/build/components/inserter/library.js.map +1 -1
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/menu.native.js.map +1 -1
- package/build/components/inserter/no-results.native.js.map +1 -1
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-items.js +1 -1
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter/search-results.native.js.map +1 -1
- package/build/components/inspector-popover-header/index.js +56 -0
- package/build/components/inspector-popover-header/index.js.map +1 -0
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/constants.js +11 -1
- package/build/components/link-control/constants.js.map +1 -1
- package/build/components/link-control/index.js +4 -4
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-create-button.js +1 -3
- package/build/components/link-control/search-create-button.js.map +1 -1
- package/build/components/link-control/search-input.js +5 -3
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/search-results.js +4 -3
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +3 -7
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/link-control/use-search-handler.js +4 -4
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +0 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/list-view/utils.js +1 -7
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/media-placeholder/index.js +4 -6
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +20 -7
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/media-upload/index.native.js +10 -4
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +12 -2
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/plain-text/index.native.js +62 -7
- package/build/components/plain-text/index.native.js.map +1 -1
- package/build/components/preview-options/index.js +4 -0
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +5 -3
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/publish-date-time-picker/index.js +53 -0
- package/build/components/publish-date-time-picker/index.js.map +1 -0
- package/build/components/rich-text/embed-handler-picker.native.js +4 -8
- package/build/components/rich-text/embed-handler-picker.native.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +0 -1
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/index.js +2 -2
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +5 -1
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build/components/rich-text/use-mark-persistent.js.map +1 -1
- package/build/components/skip-to-selected-block/index.js.map +1 -1
- package/build/components/ungroup-button/index.native.js +3 -7
- package/build/components/ungroup-button/index.native.js.map +1 -1
- package/build/components/url-input/index.js +18 -4
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.native.js +167 -0
- package/build/components/use-block-drop-zone/index.native.js.map +1 -0
- package/build/components/use-display-block-controls/index.native.js.map +1 -1
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.native.js +95 -0
- package/build/components/use-on-block-drop/index.native.js.map +1 -0
- package/build/components/use-setting/index.js.map +1 -1
- package/build/components/warning/index.js +6 -1
- package/build/components/warning/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +12 -12
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/components/writing-flow/use-click-selection.js.map +1 -1
- package/build/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build/components/writing-flow/use-input.js +15 -0
- package/build/components/writing-flow/use-input.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-select-all.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/elements/index.js +9 -0
- package/build/elements/index.js.map +1 -0
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border.js +2 -7
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +14 -7
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color-panel.native.js.map +1 -1
- package/build/hooks/color.js +8 -88
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/dimensions.js +14 -4
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/layout.js +38 -1
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/style.js +14 -13
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +6 -2
- package/build/hooks/typography.js.map +1 -1
- package/build/index.js +14 -0
- package/build/index.js.map +1 -1
- package/build/layouts/flex.js +5 -2
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +14 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +17 -2
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +30 -2
- package/build/store/selectors.js.map +1 -1
- package/build/utils/pasting.js.map +1 -1
- package/build/utils/transform-styles/transforms/wrap.js.map +1 -1
- package/build-module/autocompleters/block.js +4 -1
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js +3 -11
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-content-overlay/index.js +3 -78
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-context/index.js.map +1 -1
- package/build-module/components/block-controls/hook.js.map +1 -1
- package/build-module/components/block-draggable/draggable-chip.native.js +51 -0
- package/build-module/components/block-draggable/draggable-chip.native.js.map +1 -0
- package/build-module/components/block-draggable/dropping-insertion-point.native.js +137 -0
- package/build-module/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +453 -0
- package/build-module/components/block-draggable/index.native.js.map +1 -0
- package/build-module/components/block-draggable/use-scroll-when-dragging.native.js +120 -0
- package/build-module/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
- package/build-module/components/block-list/block-list-context.native.js +179 -0
- package/build-module/components/block-list/block-list-context.native.js.map +1 -0
- package/build-module/components/block-list/block-list-item-cell.native.js +59 -0
- package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -0
- package/build-module/components/block-list/block-list-item.native.js +12 -9
- package/build-module/components/block-list/block-list-item.native.js.map +1 -1
- package/build-module/components/block-list/block-selection-button.native.js.map +1 -1
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +26 -5
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.js +35 -33
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/index.native.js +72 -23
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +9 -5
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +9 -3
- package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +18 -5
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +1 -1
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +19 -8
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +5 -15
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +1 -1
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-selection-clearer/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-mode-toggle.js +3 -5
- package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +9 -3
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/index.js +5 -2
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/menu-items.js +3 -5
- package/build-module/components/block-styles/menu-items.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build-module/components/block-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-toolbar/utils.js +3 -5
- package/build-module/components/block-toolbar/utils.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +1 -0
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +2 -29
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +13 -2
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +11 -4
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/color-style-selector/index.js.map +1 -1
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +124 -43
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +36 -64
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js +23 -6
- package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build-module/components/copy-handler/index.js +18 -2
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/default-block-appender/index.js.map +1 -1
- package/build-module/components/default-block-appender/index.native.js.map +1 -1
- package/build-module/components/default-style-picker/index.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/iframe/index.js +52 -51
- package/build-module/components/iframe/index.js.map +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 +2 -1
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/image-size-control/index.js +4 -1
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/index.js +4 -2
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +1 -1
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/library.js +2 -5
- package/build-module/components/inserter/library.js.map +1 -1
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/menu.native.js.map +1 -1
- package/build-module/components/inserter/no-results.native.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-items.js +2 -2
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter/search-results.native.js.map +1 -1
- package/build-module/components/inspector-popover-header/index.js +46 -0
- package/build-module/components/inspector-popover-header/index.js.map +1 -0
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/constants.js +5 -0
- package/build-module/components/link-control/constants.js.map +1 -1
- package/build-module/components/link-control/index.js +2 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-create-button.js +1 -2
- package/build-module/components/link-control/search-create-button.js.map +1 -1
- package/build-module/components/link-control/search-input.js +3 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/search-results.js +3 -4
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +2 -5
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/link-control/use-search-handler.js +5 -5
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +0 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/list-view/utils.js +1 -6
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +2 -3
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +22 -9
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +8 -3
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +12 -2
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/plain-text/index.native.js +63 -8
- package/build-module/components/plain-text/index.native.js.map +1 -1
- package/build-module/components/preview-options/index.js +4 -0
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +4 -1
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/publish-date-time-picker/index.js +40 -0
- package/build-module/components/publish-date-time-picker/index.js.map +1 -0
- package/build-module/components/rich-text/embed-handler-picker.native.js +3 -5
- package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +0 -1
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -2
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +5 -1
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/components/rich-text/use-mark-persistent.js.map +1 -1
- package/build-module/components/skip-to-selected-block/index.js.map +1 -1
- package/build-module/components/ungroup-button/index.native.js +3 -5
- package/build-module/components/ungroup-button/index.native.js.map +1 -1
- package/build-module/components/url-input/index.js +15 -2
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.native.js +148 -0
- package/build-module/components/use-block-drop-zone/index.native.js.map +1 -0
- package/build-module/components/use-display-block-controls/index.native.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.native.js +83 -0
- package/build-module/components/use-on-block-drop/index.native.js.map +1 -0
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/components/warning/index.js +6 -1
- package/build-module/components/warning/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +12 -11
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/components/writing-flow/use-click-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-input.js +15 -0
- package/build-module/components/writing-flow/use-input.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-select-all.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/elements/index.js +2 -0
- package/build-module/elements/index.js.map +1 -0
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border.js +2 -7
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +11 -6
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color-panel.native.js.map +1 -1
- package/build-module/hooks/color.js +8 -88
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/dimensions.js +14 -4
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/layout.js +39 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/style.js +15 -14
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +6 -2
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/flex.js +4 -2
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +12 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +17 -2
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +25 -2
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/pasting.js.map +1 -1
- package/build-module/utils/transform-styles/transforms/wrap.js.map +1 -1
- package/build-style/style-rtl.css +79 -197
- package/build-style/style.css +79 -197
- package/package.json +30 -30
- package/src/autocompleters/block.js +2 -1
- package/src/components/block-actions/index.js +2 -3
- package/src/components/block-alignment-control/ui.js +4 -6
- package/src/components/block-alignment-matrix-control/index.js +3 -9
- package/src/components/block-breadcrumb/index.js +2 -5
- package/src/components/block-compare/test/block-view.js +2 -1
- package/src/components/block-content-overlay/index.js +10 -100
- package/src/components/block-content-overlay/style.scss +2 -11
- package/src/components/block-context/index.js +4 -4
- package/src/components/block-controls/hook.js +2 -3
- package/src/components/block-draggable/draggable-chip.native.js +49 -0
- package/src/components/block-draggable/dropping-insertion-point.native.js +181 -0
- package/src/components/block-draggable/dropping-insertion-point.native.scss +8 -0
- package/src/components/block-draggable/index.js +6 -13
- package/src/components/block-draggable/index.native.js +454 -0
- package/src/components/block-draggable/style.native.scss +19 -0
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +73 -0
- package/src/components/block-draggable/test/helpers.native.js +183 -0
- package/src/components/block-draggable/test/index.native.js +493 -0
- package/src/components/block-draggable/use-scroll-when-dragging.native.js +135 -0
- package/src/components/block-edit/test/edit.js +2 -1
- package/src/components/block-list/block-list-context.native.js +175 -0
- package/src/components/block-list/block-list-item-cell.native.js +49 -0
- package/src/components/block-list/block-list-item.native.js +11 -23
- package/src/components/block-list/block-selection-button.native.js +2 -3
- package/src/components/block-list/block.js +8 -10
- package/src/components/block-list/block.native.js +47 -23
- package/src/components/block-list/index.js +46 -47
- package/src/components/block-list/index.native.js +63 -31
- package/src/components/block-list/test/block-list-context.native.js +245 -0
- package/src/components/block-list/test/fixtures/block-list-context.native.js +79 -0
- package/src/components/block-list/use-block-props/index.js +16 -8
- package/src/components/block-list/use-block-props/use-block-custom-class-name.js +2 -3
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +2 -3
- package/src/components/block-list/use-in-between-inserter.js +3 -4
- package/src/components/block-list-appender/index.js +2 -5
- package/src/components/block-list-appender/index.native.js +2 -3
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +4 -6
- package/src/components/block-mobile-toolbar/index.native.js +9 -1
- package/src/components/block-mover/button.js +2 -3
- package/src/components/block-mover/index.native.js +26 -12
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +10 -0
- package/src/components/block-parent-selector/index.js +2 -3
- package/src/components/block-pattern-setup/index.js +3 -5
- package/src/components/block-popover/inbetween.js +21 -8
- package/src/components/block-popover/index.js +2 -16
- package/src/components/block-popover/style.scss +1 -0
- package/src/components/block-preview/auto.js +4 -8
- package/src/components/block-preview/index.js +1 -4
- package/src/components/block-selection-clearer/index.js +2 -3
- package/src/components/block-settings-menu/block-mode-toggle.js +4 -8
- package/src/components/block-settings-menu/block-settings-dropdown.js +9 -9
- package/src/components/block-styles/index.js +3 -1
- package/src/components/block-styles/menu-items.js +2 -5
- package/src/components/block-switcher/block-transformations-menu.js +2 -4
- package/src/components/block-switcher/style.scss +2 -39
- package/src/components/block-toolbar/index.native.js +2 -5
- package/src/components/block-toolbar/utils.js +3 -11
- package/src/components/block-tools/block-contextual-toolbar.js +2 -5
- package/src/components/block-tools/block-selection-button.js +1 -0
- package/src/components/block-tools/index.js +2 -3
- package/src/components/block-tools/selected-block-popover.js +1 -36
- package/src/components/block-tools/style.scss +1 -12
- package/src/components/block-types-list/index.native.js +2 -4
- package/src/components/block-variation-transforms/index.js +10 -8
- package/src/components/border-radius-control/input-controls.js +16 -8
- package/src/components/border-radius-control/style.scss +3 -2
- package/src/components/color-palette/test/control.js +2 -1
- package/src/components/color-style-selector/index.js +27 -28
- package/src/components/colors/test/with-colors.js +14 -14
- package/src/components/colors/with-colors.js +8 -12
- package/src/components/colors-gradients/dropdown.js +135 -62
- package/src/components/colors-gradients/panel-color-gradient-settings.js +30 -76
- package/src/components/colors-gradients/style.scss +52 -50
- package/src/components/colors-gradients/test/control.js +10 -10
- package/src/components/convert-to-group-buttons/toolbar.js +32 -19
- package/src/components/copy-handler/README.md +7 -2
- package/src/components/copy-handler/index.js +26 -6
- package/src/components/default-block-appender/index.js +4 -6
- package/src/components/default-block-appender/index.native.js +4 -9
- package/src/components/default-style-picker/index.js +20 -21
- package/src/components/duotone-control/style.scss +1 -7
- package/src/components/font-sizes/with-font-sizes.js +2 -3
- package/src/components/iframe/index.js +62 -54
- package/src/components/image-editor/aspect-ratio-dropdown.js +2 -6
- package/src/components/image-editor/use-save-image.js +2 -1
- package/src/components/image-size-control/index.js +4 -7
- package/src/components/index.js +4 -2
- package/src/components/inner-blocks/use-inner-block-template-sync.js +2 -3
- package/src/components/inner-blocks/use-nested-settings-update.js +6 -9
- package/src/components/inserter/block-types-tab.native.js +2 -3
- package/src/components/inserter/hooks/use-block-type-impressions.native.js +2 -3
- package/src/components/inserter/hooks/use-insertion-point.js +3 -2
- package/src/components/inserter/hooks/use-patterns-state.js +4 -5
- package/src/components/inserter/index.js +4 -6
- package/src/components/inserter/index.native.js +7 -12
- package/src/components/inserter/library.js +2 -5
- package/src/components/inserter/menu.js +14 -19
- package/src/components/inserter/menu.native.js +8 -6
- package/src/components/inserter/no-results.native.js +2 -1
- package/src/components/inserter/quick-inserter.js +2 -3
- package/src/components/inserter/search-items.js +6 -6
- package/src/components/inserter/search-results.native.js +4 -6
- package/src/components/inserter/style.scss +2 -1
- package/src/components/inspector-popover-header/README.md +76 -0
- package/src/components/inspector-popover-header/index.js +56 -0
- package/src/components/inspector-popover-header/style.scss +16 -0
- package/src/components/line-height-control/index.js +1 -2
- package/src/components/link-control/constants.js +11 -0
- package/src/components/link-control/index.js +4 -4
- package/src/components/link-control/search-create-button.js +4 -2
- package/src/components/link-control/search-input.js +3 -1
- package/src/components/link-control/search-results.js +4 -5
- package/src/components/link-control/settings-drawer.js +2 -5
- package/src/components/link-control/test/fixtures/index.js +3 -4
- package/src/components/link-control/test/index.js +24 -36
- package/src/components/link-control/use-search-handler.js +13 -7
- package/src/components/list-view/block-contents.js +2 -4
- package/src/components/list-view/branch.js +22 -23
- package/src/components/list-view/drop-indicator.js +0 -1
- package/src/components/list-view/index.js +4 -8
- package/src/components/list-view/style.scss +2 -1
- package/src/components/list-view/use-block-selection.js +5 -5
- package/src/components/list-view/use-list-view-drop-zone.js +2 -1
- package/src/components/list-view/utils.js +1 -6
- package/src/components/media-placeholder/index.js +2 -3
- package/src/components/media-replace-flow/index.js +77 -48
- package/src/components/media-upload/index.native.js +6 -2
- package/src/components/media-upload/test/index.native.js +31 -6
- package/src/components/navigable-toolbar/index.js +13 -4
- package/src/components/panel-color-settings/test/index.js +2 -1
- package/src/components/plain-text/index.native.js +60 -8
- package/src/components/preview-options/index.js +4 -0
- package/src/components/preview-options/style.scss +0 -4
- package/src/components/provider/use-block-sync.js +5 -2
- package/src/components/publish-date-time-picker/README.md +52 -0
- package/src/components/publish-date-time-picker/index.js +39 -0
- package/src/components/responsive-block-control/test/index.js +3 -2
- package/src/components/rich-text/embed-handler-picker.native.js +2 -5
- package/src/components/rich-text/format-toolbar-container.js +0 -1
- package/src/components/rich-text/index.js +10 -5
- package/src/components/rich-text/index.native.js +4 -0
- package/src/components/rich-text/style.scss +2 -8
- package/src/components/rich-text/use-format-types.js +16 -16
- package/src/components/rich-text/use-mark-persistent.js +2 -3
- package/src/components/skip-to-selected-block/index.js +2 -3
- package/src/components/ungroup-button/index.native.js +4 -8
- package/src/components/url-input/index.js +24 -21
- package/src/components/use-block-display-information/index.js +4 -6
- package/src/components/use-block-drop-zone/index.js +2 -3
- package/src/components/use-block-drop-zone/index.native.js +171 -0
- package/src/components/use-block-drop-zone/test/index.js +22 -23
- package/src/components/use-display-block-controls/index.native.js +2 -3
- package/src/components/use-no-recursive-renders/test/use-no-recursive-renders.js +2 -3
- package/src/components/use-on-block-drop/index.js +2 -5
- package/src/components/use-on-block-drop/index.native.js +115 -0
- package/src/components/use-setting/index.js +8 -6
- package/src/components/warning/index.js +47 -42
- package/src/components/warning/test/__snapshots__/index.js.snap +15 -6
- package/src/components/warning/test/index.js +1 -1
- package/src/components/writing-flow/test/index.js +22 -4
- package/src/components/writing-flow/use-arrow-nav.js +22 -10
- package/src/components/writing-flow/use-click-selection.js +2 -5
- package/src/components/writing-flow/use-drag-selection.js +6 -9
- package/src/components/writing-flow/use-input.js +12 -0
- package/src/components/writing-flow/use-multi-selection.js +2 -4
- package/src/components/writing-flow/use-select-all.js +2 -5
- package/src/components/writing-flow/use-selection-observer.js +4 -6
- package/src/components/writing-flow/use-tab-nav.js +2 -5
- package/src/elements/index.js +1 -0
- package/src/hooks/anchor.js +1 -1
- package/src/hooks/border.js +2 -11
- package/src/hooks/border.scss +0 -48
- package/src/hooks/color-panel.js +17 -13
- package/src/hooks/color-panel.native.js +2 -2
- package/src/hooks/color.js +7 -76
- package/src/hooks/color.scss +5 -58
- package/src/hooks/dimensions.js +11 -3
- package/src/hooks/font-family.js +4 -2
- package/src/hooks/gap.js +2 -3
- package/src/hooks/layout.js +54 -4
- package/src/hooks/style.js +25 -39
- package/src/hooks/test/align.js +2 -1
- package/src/hooks/test/generated-class-name.js +2 -5
- package/src/hooks/test/utils.js +2 -5
- package/src/hooks/typography.js +2 -0
- package/src/index.js +1 -0
- package/src/layouts/flex.js +11 -3
- package/src/store/actions.js +784 -728
- package/src/store/reducer.js +202 -178
- package/src/store/selectors.js +82 -54
- package/src/store/test/actions.js +2 -1
- package/src/store/test/reducer.js +8 -1
- package/src/store/test/selectors.js +17 -21
- package/src/style.scss +1 -1
- package/src/utils/pasting.js +3 -3
- package/src/utils/transform-styles/transforms/wrap.js +30 -28
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/colors/color-panel.js +0 -82
- package/build/components/colors/color-panel.js.map +0 -1
- package/build/components/colors/color-panel.native.js +0 -11
- package/build/components/colors/color-panel.native.js.map +0 -1
- package/build/components/colors-gradients/tools-panel-color-dropdown.js +0 -89
- package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
- package/build-module/components/colors/color-panel.js +0 -70
- package/build-module/components/colors/color-panel.js.map +0 -1
- package/build-module/components/colors/color-panel.native.js +0 -4
- package/build-module/components/colors/color-panel.native.js.map +0 -1
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js +0 -75
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
- package/src/components/block-alignment-matrix-control/style.scss +0 -10
- package/src/components/colors/color-panel.js +0 -91
- package/src/components/colors/color-panel.native.js +0 -3
- package/src/components/colors-gradients/tools-panel-color-dropdown.js +0 -85
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/menu.native.js"],"names":["MIN_ITEMS_FOR_SEARCH","InserterMenu","onSelect","onDismiss","rootClientId","clientId","isAppender","shouldReplaceBlock","insertionIndex","filterValue","setFilterValue","showTabs","setShowTabs","tabIndex","setTabIndex","isIOS","Platform","OS","showInsertionPoint","hideInsertionPoint","clearSelectedBlock","insertBlock","removeBlock","resetBlocks","insertDefaultBlock","blockEditorStore","items","destinationRootClientId","showReusableBlocks","select","getInserterItems","getBlockRootClientId","getBlockSelectionEnd","targetRootClientId","end","undefined","allItems","reusableBlockItems","onlyReusable","length","getBlockOrder","getBlockCount","count","blockToReplace","onClose","onInsert","item","name","initialAttributes","innerBlocks","newBlock","source","onSelectItem","AccessibilityInfo","isScreenReaderEnabled","then","enabled","timeout","setTimeout","onChangeSearch","value","onKeyboardShow","onKeyboardHide","showSearchForm","isFullScreen","styles","listProps"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AASA;;AACA;;AACA;;AACA;;AACA;;AAxBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;AAOA,MAAMA,oBAAoB,GAAG,CAA7B;;AACA,SAASC,YAAT,OAQI;AAAA,MARmB;AACtBC,IAAAA,QADsB;AAEtBC,IAAAA,S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ependencies\n */\nimport { useEffect, useState, useCallback } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { createBlock } from '@wordpress/blocks';\nimport {\n\tBottomSheet,\n\tBottomSheetConsumer,\n\tSearchControl,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport InserterSearchResults from './search-results';\nimport { store as blockEditorStore } from '../../store';\nimport InserterTabs from './tabs';\nimport styles from './style.scss';\nimport { filterInserterItems } from './utils';\n\nconst MIN_ITEMS_FOR_SEARCH = 2;\nfunction InserterMenu( {\n\tonSelect,\n\tonDismiss,\n\trootClientId,\n\tclientId,\n\tisAppender,\n\tshouldReplaceBlock,\n\tinsertionIndex,\n} ) {\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\tconst [ showTabs, setShowTabs ] = useState( true );\n\tconst [ tabIndex, setTabIndex ] = useState( 0 );\n\n\tconst isIOS = Platform.OS === 'ios';\n\n\tconst {\n\t\tshowInsertionPoint,\n\t\thideInsertionPoint,\n\t\tclearSelectedBlock,\n\t\tinsertBlock,\n\t\tremoveBlock,\n\t\tresetBlocks,\n\t\tinsertDefaultBlock,\n\t} = useDispatch( blockEditorStore );\n\n\tconst { items, destinationRootClientId, showReusableBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetInserterItems,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockSelectionEnd,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tlet targetRootClientId = rootClientId;\n\t\t\tif ( ! targetRootClientId && ! clientId && ! isAppender ) {\n\t\t\t\tconst end = getBlockSelectionEnd();\n\t\t\t\tif ( end ) {\n\t\t\t\t\ttargetRootClientId =\n\t\t\t\t\t\tgetBlockRootClientId( end ) || undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst allItems = getInserterItems( targetRootClientId );\n\t\t\tconst reusableBlockItems = filterInserterItems( allItems, {\n\t\t\t\tonlyReusable: true,\n\t\t\t} );\n\n\t\t\treturn {\n\t\t\t\titems: allItems,\n\t\t\t\tdestinationRootClientId: targetRootClientId,\n\t\t\t\tshowReusableBlocks: !! reusableBlockItems.length,\n\t\t\t};\n\t\t}\n\t);\n\n\tconst { getBlockOrder, getBlockCount } = useSelect( blockEditorStore );\n\n\tuseEffect( () => {\n\t\t// Show/Hide insertion point on Mount/Dismount\n\t\tif ( shouldReplaceBlock ) {\n\t\t\tconst count = getBlockCount();\n\t\t\t// Check if there is a rootClientId because that means it is a nested replaceable block\n\t\t\t// and we don't want to clear/reset all blocks.\n\t\t\tif ( count === 1 && ! rootClientId ) {\n\t\t\t\t// Removing the last block is not possilble with `removeBlock` action.\n\t\t\t\t// It always inserts a default block if the last of the blocks have been removed.\n\t\t\t\tclearSelectedBlock();\n\t\t\t\tresetBlocks( [] );\n\t\t\t} else {\n\t\t\t\tconst blockToReplace = getBlockOrder( destinationRootClientId )[\n\t\t\t\t\tinsertionIndex\n\t\t\t\t];\n\t\t\t\tremoveBlock( blockToReplace, false );\n\t\t\t}\n\t\t}\n\t\tshowInsertionPoint( destinationRootClientId, insertionIndex );\n\n\t\treturn hideInsertionPoint;\n\t}, [] );\n\n\tconst onClose = useCallback( () => {\n\t\t// If should replace but didn't insert any block\n\t\t// re-insert default block.\n\t\tif ( shouldReplaceBlock ) {\n\t\t\tinsertDefaultBlock( {}, destinationRootClientId, insertionIndex );\n\t\t}\n\t\tonDismiss();\n\t}, [ shouldReplaceBlock, destinationRootClientId, insertionIndex ] );\n\n\tconst onInsert = useCallback(\n\t\t( item ) => {\n\t\t\tconst { name, initialAttributes, innerBlocks } = item;\n\n\t\t\tconst newBlock = createBlock(\n\t\t\t\tname,\n\t\t\t\tinitialAttributes,\n\t\t\t\tinnerBlocks\n\t\t\t);\n\n\t\t\tinsertBlock(\n\t\t\t\tnewBlock,\n\t\t\t\tinsertionIndex,\n\t\t\t\tdestinationRootClientId,\n\t\t\t\ttrue,\n\t\t\t\t{ source: 'inserter_menu' }\n\t\t\t);\n\t\t},\n\t\t[ insertBlock, destinationRootClientId, insertionIndex ]\n\t);\n\n\tconst onSelectItem = useCallback(\n\t\t( item ) => {\n\t\t\t// Avoid a focus loop, see https://github.com/WordPress/gutenberg/issues/30562\n\t\t\tif ( Platform.OS === 'ios' ) {\n\t\t\t\tAccessibilityInfo.isScreenReaderEnabled().then( ( enabled ) => {\n\t\t\t\t\t// In testing, the bug focus loop needed a longer timeout when VoiceOver was enabled.\n\t\t\t\t\tconst timeout = enabled ? 200 : 100;\n\t\t\t\t\t// eslint-disable-next-line @wordpress/react-no-unsafe-timeout\n\t\t\t\t\tsetTimeout( () => {\n\t\t\t\t\t\tonInsert( item );\n\t\t\t\t\t}, timeout );\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tonInsert( item );\n\t\t\t}\n\t\t\tonSelect( item );\n\t\t},\n\t\t[ onInsert, onSelect ]\n\t);\n\n\tconst onChangeSearch = useCallback(\n\t\t( value ) => {\n\t\t\tsetFilterValue( value );\n\t\t},\n\t\t[ setFilterValue ]\n\t);\n\n\tconst onKeyboardShow = useCallback( () => setShowTabs( false ), [\n\t\tsetShowTabs,\n\t] );\n\n\tconst onKeyboardHide = useCallback( () => setShowTabs( true ), [\n\t\tsetShowTabs,\n\t] );\n\n\tconst showSearchForm = items.length > MIN_ITEMS_FOR_SEARCH;\n\tconst isFullScreen = ! isIOS && showSearchForm;\n\n\treturn (\n\t\t<BottomSheet\n\t\t\tisVisible={ true }\n\t\t\tonClose={ onClose }\n\t\t\tonKeyboardShow={ onKeyboardShow }\n\t\t\tonKeyboardHide={ onKeyboardHide }\n\t\t\theader={\n\t\t\t\t<>\n\t\t\t\t\t{ showSearchForm && (\n\t\t\t\t\t\t<SearchControl\n\t\t\t\t\t\t\tonChange={ onChangeSearch }\n\t\t\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ showTabs && ! filterValue && (\n\t\t\t\t\t\t<InserterTabs.Control\n\t\t\t\t\t\t\tonChangeTab={ setTabIndex }\n\t\t\t\t\t\t\tshowReusableBlocks={ showReusableBlocks }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t\thasNavigation\n\t\t\tsetMinHeightToMaxHeight={ true }\n\t\t\tcontentStyle={ styles[ 'inserter-menu__list' ] }\n\t\t\tisFullScreen={ isFullScreen }\n\t\t\tallowDragIndicator={ true }\n\t\t>\n\t\t\t<BottomSheetConsumer>\n\t\t\t\t{ ( { listProps } ) => (\n\t\t\t\t\t<TouchableHighlight\n\t\t\t\t\t\taccessible={ false }\n\t\t\t\t\t\tstyle={ styles[ 'inserter-menu__list-wrapper' ] }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! showTabs || filterValue ? (\n\t\t\t\t\t\t\t<InserterSearchResults\n\t\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\t\tfilterValue={ filterValue }\n\t\t\t\t\t\t\t\tonSelect={ onSelectItem }\n\t\t\t\t\t\t\t\tlistProps={ listProps }\n\t\t\t\t\t\t\t\tisFullScreen={ isFullScreen }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<InserterTabs\n\t\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\t\tlistProps={ listProps }\n\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\tonSelect={ onSelectItem }\n\t\t\t\t\t\t\t\tshowReusableBlocks={ showReusableBlocks }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</TouchableHighlight>\n\t\t\t\t) }\n\t\t\t</BottomSheetConsumer>\n\t\t</BottomSheet>\n\t);\n}\n\nexport default InserterMenu;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/menu.native.js"],"names":["MIN_ITEMS_FOR_SEARCH","InserterMenu","onSelect","onDismiss","rootClientId","clientId","isAppender","shouldReplaceBlock","insertionIndex","filterValue","setFilterValue","showTabs","setShowTabs","tabIndex","setTabIndex","isIOS","Platform","OS","showInsertionPoint","hideInsertionPoint","clearSelectedBlock","insertBlock","removeBlock","resetBlocks","insertDefaultBlock","blockEditorStore","items","destinationRootClientId","showReusableBlocks","select","getInserterItems","getBlockRootClientId","getBlockSelectionEnd","targetRootClientId","end","undefined","allItems","reusableBlockItems","onlyReusable","length","getBlockOrder","getBlockCount","count","blockToReplace","onClose","onInsert","item","name","initialAttributes","innerBlocks","newBlock","source","onSelectItem","AccessibilityInfo","isScreenReaderEnabled","then","enabled","timeout","setTimeout","onChangeSearch","value","onKeyboardShow","onKeyboardHide","showSearchForm","isFullScreen","styles","listProps"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AASA;;AACA;;AACA;;AACA;;AACA;;AAxBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;AAOA,MAAMA,oBAAoB,GAAG,CAA7B;;AACA,SAASC,YAAT,OAQI;AAAA,MARmB;AACtBC,IAAAA,QADsB;AAEtBC,IAAAA,SAFsB;AAGtBC,IAAAA,YAHsB;AAItBC,IAAAA,QAJsB;AAKtBC,IAAAA,UALsB;AAMtBC,IAAAA,kBANsB;AAOtBC,IAAAA;AAPsB,GAQnB;AACH,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC,uBAAU,EAAV,CAAxC;AACA,QAAM,CAAEC,QAAF,EAAYC,WAAZ,IAA4B,uBAAU,IAAV,CAAlC;AACA,QAAM,CAAEC,QAAF,EAAYC,WAAZ,IAA4B,uBAAU,CAAV,CAAlC;AAEA,QAAMC,KAAK,GAAGC,sBAASC,EAAT,KAAgB,KAA9B;AAEA,QAAM;AACLC,IAAAA,kBADK;AAELC,IAAAA,kBAFK;AAGLC,IAAAA,kBAHK;AAILC,IAAAA,WAJK;AAKLC,IAAAA,WALK;AAMLC,IAAAA,WANK;AAOLC,IAAAA;AAPK,MAQF,uBAAa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ACG;AAAA,QAAE;AAAEE,MAAAA;AAAF,KAAF;AAAA,WACD,4BAAC,+BAAD;AACC,MAAA,UAAU,EAAG,KADd;AAEC,MAAA,KAAK,EAAGD,eAAQ,6BAAR;AAFT,OAIG,CAAEtD,QAAF,IAAcF,WAAd,GACD,4BAAC,sBAAD;AACC,MAAA,YAAY,EAAGL,YADhB;AAEC,MAAA,WAAW,EAAGK,WAFf;AAGC,MAAA,QAAQ,EAAG2C,YAHZ;AAIC,MAAA,SAAS,EAAGc,SAJb;AAKC,MAAA,YAAY,EAAGF;AALhB,MADC,GASD,4BAAC,aAAD;AACC,MAAA,YAAY,EAAG5D,YADhB;AAEC,MAAA,SAAS,EAAG8D,SAFb;AAGC,MAAA,QAAQ,EAAGrD,QAHZ;AAIC,MAAA,QAAQ,EAAGuC,YAJZ;AAKC,MAAA,kBAAkB,EAAGxB;AALtB,MAbF,CADC;AAAA,GADH,CA3BD,CADD;AAwDA;;eAEc3B,Y","sourcesContent":["/**\n * External dependencies\n */\nimport { AccessibilityInfo, TouchableHighlight, Platform } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useCallback } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { createBlock } from '@wordpress/blocks';\nimport {\n\tBottomSheet,\n\tBottomSheetConsumer,\n\tSearchControl,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport InserterSearchResults from './search-results';\nimport { store as blockEditorStore } from '../../store';\nimport InserterTabs from './tabs';\nimport styles from './style.scss';\nimport { filterInserterItems } from './utils';\n\nconst MIN_ITEMS_FOR_SEARCH = 2;\nfunction InserterMenu( {\n\tonSelect,\n\tonDismiss,\n\trootClientId,\n\tclientId,\n\tisAppender,\n\tshouldReplaceBlock,\n\tinsertionIndex,\n} ) {\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\tconst [ showTabs, setShowTabs ] = useState( true );\n\tconst [ tabIndex, setTabIndex ] = useState( 0 );\n\n\tconst isIOS = Platform.OS === 'ios';\n\n\tconst {\n\t\tshowInsertionPoint,\n\t\thideInsertionPoint,\n\t\tclearSelectedBlock,\n\t\tinsertBlock,\n\t\tremoveBlock,\n\t\tresetBlocks,\n\t\tinsertDefaultBlock,\n\t} = useDispatch( blockEditorStore );\n\n\tconst { items, destinationRootClientId, showReusableBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetInserterItems,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockSelectionEnd,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tlet targetRootClientId = rootClientId;\n\t\t\tif ( ! targetRootClientId && ! clientId && ! isAppender ) {\n\t\t\t\tconst end = getBlockSelectionEnd();\n\t\t\t\tif ( end ) {\n\t\t\t\t\ttargetRootClientId =\n\t\t\t\t\t\tgetBlockRootClientId( end ) || undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst allItems = getInserterItems( targetRootClientId );\n\t\t\tconst reusableBlockItems = filterInserterItems( allItems, {\n\t\t\t\tonlyReusable: true,\n\t\t\t} );\n\n\t\t\treturn {\n\t\t\t\titems: allItems,\n\t\t\t\tdestinationRootClientId: targetRootClientId,\n\t\t\t\tshowReusableBlocks: !! reusableBlockItems.length,\n\t\t\t};\n\t\t}\n\t);\n\n\tconst { getBlockOrder, getBlockCount } = useSelect( blockEditorStore );\n\n\tuseEffect( () => {\n\t\t// Show/Hide insertion point on Mount/Dismount\n\t\tif ( shouldReplaceBlock ) {\n\t\t\tconst count = getBlockCount();\n\t\t\t// Check if there is a rootClientId because that means it is a nested replaceable block\n\t\t\t// and we don't want to clear/reset all blocks.\n\t\t\tif ( count === 1 && ! rootClientId ) {\n\t\t\t\t// Removing the last block is not possilble with `removeBlock` action.\n\t\t\t\t// It always inserts a default block if the last of the blocks have been removed.\n\t\t\t\tclearSelectedBlock();\n\t\t\t\tresetBlocks( [] );\n\t\t\t} else {\n\t\t\t\tconst blockToReplace = getBlockOrder( destinationRootClientId )[\n\t\t\t\t\tinsertionIndex\n\t\t\t\t];\n\t\t\t\tremoveBlock( blockToReplace, false );\n\t\t\t}\n\t\t}\n\t\tshowInsertionPoint( destinationRootClientId, insertionIndex );\n\n\t\treturn hideInsertionPoint;\n\t}, [] );\n\n\tconst onClose = useCallback( () => {\n\t\t// If should replace but didn't insert any block\n\t\t// re-insert default block.\n\t\tif ( shouldReplaceBlock ) {\n\t\t\tinsertDefaultBlock( {}, destinationRootClientId, insertionIndex );\n\t\t}\n\t\tonDismiss();\n\t}, [ shouldReplaceBlock, destinationRootClientId, insertionIndex ] );\n\n\tconst onInsert = useCallback(\n\t\t( item ) => {\n\t\t\tconst { name, initialAttributes, innerBlocks } = item;\n\n\t\t\tconst newBlock = createBlock(\n\t\t\t\tname,\n\t\t\t\tinitialAttributes,\n\t\t\t\tinnerBlocks\n\t\t\t);\n\n\t\t\tinsertBlock(\n\t\t\t\tnewBlock,\n\t\t\t\tinsertionIndex,\n\t\t\t\tdestinationRootClientId,\n\t\t\t\ttrue,\n\t\t\t\t{ source: 'inserter_menu' }\n\t\t\t);\n\t\t},\n\t\t[ insertBlock, destinationRootClientId, insertionIndex ]\n\t);\n\n\tconst onSelectItem = useCallback(\n\t\t( item ) => {\n\t\t\t// Avoid a focus loop, see https://github.com/WordPress/gutenberg/issues/30562\n\t\t\tif ( Platform.OS === 'ios' ) {\n\t\t\t\tAccessibilityInfo.isScreenReaderEnabled().then( ( enabled ) => {\n\t\t\t\t\t// In testing, the bug focus loop needed a longer timeout when VoiceOver was enabled.\n\t\t\t\t\tconst timeout = enabled ? 200 : 100;\n\t\t\t\t\t// eslint-disable-next-line @wordpress/react-no-unsafe-timeout\n\t\t\t\t\tsetTimeout( () => {\n\t\t\t\t\t\tonInsert( item );\n\t\t\t\t\t}, timeout );\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tonInsert( item );\n\t\t\t}\n\t\t\tonSelect( item );\n\t\t},\n\t\t[ onInsert, onSelect ]\n\t);\n\n\tconst onChangeSearch = useCallback(\n\t\t( value ) => {\n\t\t\tsetFilterValue( value );\n\t\t},\n\t\t[ setFilterValue ]\n\t);\n\n\tconst onKeyboardShow = useCallback(\n\t\t() => setShowTabs( false ),\n\t\t[ setShowTabs ]\n\t);\n\n\tconst onKeyboardHide = useCallback(\n\t\t() => setShowTabs( true ),\n\t\t[ setShowTabs ]\n\t);\n\n\tconst showSearchForm = items.length > MIN_ITEMS_FOR_SEARCH;\n\tconst isFullScreen = ! isIOS && showSearchForm;\n\n\treturn (\n\t\t<BottomSheet\n\t\t\tisVisible={ true }\n\t\t\tonClose={ onClose }\n\t\t\tonKeyboardShow={ onKeyboardShow }\n\t\t\tonKeyboardHide={ onKeyboardHide }\n\t\t\theader={\n\t\t\t\t<>\n\t\t\t\t\t{ showSearchForm && (\n\t\t\t\t\t\t<SearchControl\n\t\t\t\t\t\t\tonChange={ onChangeSearch }\n\t\t\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ showTabs && ! filterValue && (\n\t\t\t\t\t\t<InserterTabs.Control\n\t\t\t\t\t\t\tonChangeTab={ setTabIndex }\n\t\t\t\t\t\t\tshowReusableBlocks={ showReusableBlocks }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t\thasNavigation\n\t\t\tsetMinHeightToMaxHeight={ true }\n\t\t\tcontentStyle={ styles[ 'inserter-menu__list' ] }\n\t\t\tisFullScreen={ isFullScreen }\n\t\t\tallowDragIndicator={ true }\n\t\t>\n\t\t\t<BottomSheetConsumer>\n\t\t\t\t{ ( { listProps } ) => (\n\t\t\t\t\t<TouchableHighlight\n\t\t\t\t\t\taccessible={ false }\n\t\t\t\t\t\tstyle={ styles[ 'inserter-menu__list-wrapper' ] }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! showTabs || filterValue ? (\n\t\t\t\t\t\t\t<InserterSearchResults\n\t\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\t\tfilterValue={ filterValue }\n\t\t\t\t\t\t\t\tonSelect={ onSelectItem }\n\t\t\t\t\t\t\t\tlistProps={ listProps }\n\t\t\t\t\t\t\t\tisFullScreen={ isFullScreen }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<InserterTabs\n\t\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\t\tlistProps={ listProps }\n\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\tonSelect={ onSelectItem }\n\t\t\t\t\t\t\t\tshowReusableBlocks={ showReusableBlocks }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</TouchableHighlight>\n\t\t\t\t) }\n\t\t\t</BottomSheetConsumer>\n\t\t</BottomSheet>\n\t);\n}\n\nexport default InserterMenu;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/no-results.native.js"],"names":["InserterNoResults","containerStyle","textPrimaryBaseStyle","textPrimaryDarkStyle","textSecondaryBaseStyle","textSecondaryDarkStyle","styles","textPrimaryStyle","textSecondaryStyle"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAGA,SAASA,iBAAT,GAA6B;AAC5B,QAAM;AACL,6CAAyCC,cADpC;AAEL,gDAA4CC,oBAFvC;AAGL,sDAAkDC,oBAH7C;AAIL,kDAA8CC,sBAJzC;AAKL,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/no-results.native.js"],"names":["InserterNoResults","containerStyle","textPrimaryBaseStyle","textPrimaryDarkStyle","textSecondaryBaseStyle","textSecondaryDarkStyle","styles","textPrimaryStyle","textSecondaryStyle"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAGA,SAASA,iBAAT,GAA6B;AAC5B,QAAM;AACL,6CAAyCC,cADpC;AAEL,gDAA4CC,oBAFvC;AAGL,sDAAkDC,oBAH7C;AAIL,kDAA8CC,sBAJzC;AAKL,wDACCC;AANI,MAOFC,cAPJ;AAQA,QAAMC,gBAAgB,GAAG,2CACxBL,oBADwB,EAExBC,oBAFwB,CAAzB;AAIA,QAAMK,kBAAkB,GAAG,2CAC1BJ,sBAD0B,EAE1BC,sBAF0B,CAA3B;AAKA,SACC,4BAAC,iBAAD,QACC,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAGJ;AAAd,KACC,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAGM;AAAd,KACG,cAAI,iBAAJ,CADH,CADD,EAIC,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAGC;AAAd,KACG,cAAI,yBAAJ,CADH,CAJD,CADD,CADD;AAYA;;eAEcR,iB","sourcesContent":["/**\n * External dependencies\n */\nimport { View, Text } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nfunction InserterNoResults() {\n\tconst {\n\t\t'inserter-search-no-results__container': containerStyle,\n\t\t'inserter-search-no-results__text-primary': textPrimaryBaseStyle,\n\t\t'inserter-search-no-results__text-primary--dark': textPrimaryDarkStyle,\n\t\t'inserter-search-no-results__text-secondary': textSecondaryBaseStyle,\n\t\t'inserter-search-no-results__text-secondary--dark':\n\t\t\ttextSecondaryDarkStyle,\n\t} = styles;\n\tconst textPrimaryStyle = usePreferredColorSchemeStyle(\n\t\ttextPrimaryBaseStyle,\n\t\ttextPrimaryDarkStyle\n\t);\n\tconst textSecondaryStyle = usePreferredColorSchemeStyle(\n\t\ttextSecondaryBaseStyle,\n\t\ttextSecondaryDarkStyle\n\t);\n\n\treturn (\n\t\t<View>\n\t\t\t<View style={ containerStyle }>\n\t\t\t\t<Text style={ textPrimaryStyle }>\n\t\t\t\t\t{ __( 'No blocks found' ) }\n\t\t\t\t</Text>\n\t\t\t\t<Text style={ textSecondaryStyle }>\n\t\t\t\t\t{ __( 'Try another search term' ) }\n\t\t\t\t</Text>\n\t\t\t</View>\n\t\t</View>\n\t);\n}\n\nexport default InserterNoResults;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/quick-inserter.js"],"names":["SEARCH_THRESHOLD","SHOWN_BLOCK_TYPES","SHOWN_BLOCK_PATTERNS","SHOWN_BLOCK_PATTERNS_WITH_PRIORITIZATION","QuickInserter","onSelect","rootClientId","clientId","isAppender","prioritizePatterns","filterValue","setFilterValue","destinationRootClientId","onInsertBlocks","blockTypes","patterns","setInserterIsOpened","insertionIndex","select","getSettings","getBlockIndex","getBlockCount","blockEditorStore","settings","index","blockCount","__experimentalSetIsInserterOpened","showPatterns","length","showSearch","onBrowseAll","maxBlockPatterns","value"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAOA,MAAMA,gBAAgB,GAAG,CAAzB;AACA,MAAMC,iBAAiB,GAAG,CAA1B;AACA,MAAMC,oBAAoB,GAAG,CAA7B;AACA,MAAMC,wCAAwC,GAAG,CAAjD;;AAEe,SAASC,aAAT,OAMX;AAAA,MANmC;AACtCC,IAAAA,QADsC;AAEtCC,IAAAA,YAFsC;AAGtCC,IAAAA,QAHsC;AAItCC,IAAAA,UAJsC;AAKtCC,IAAAA;AALsC,GAMnC;AACH,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC,uBAAU,EAAV,CAAxC;AACA,QAAM,CAAEC,uBAAF,EAA2BC,cAA3B,IAA8C,gCAAmB;AACtER,IAAAA,QADsE;AAEtEC,IAAAA,YAFsE;AAGtEC,IAAAA,QAHsE;AAItEC,IAAAA;AAJsE,GAAnB,CAApD;AAMA,QAAM,CAAEM,UAAF,IAAiB,iCACtBF,uBADsB,EAEtBC,cAFsB,CAAvB;AAKA,QAAM,CAAEE,QAAF,IAAe,+BACpBF,cADoB,EAEpBD,uBAFoB,CAArB;AAKA,QAAM;AAAEI,IAAAA,mBAAF;AAAuBC,IAAAA;AAAvB,MAA0C,qBAC7CC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,WAAF;AAAeC,MAAAA,aAAf;AAA8BC,MAAAA;AAA9B,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/quick-inserter.js"],"names":["SEARCH_THRESHOLD","SHOWN_BLOCK_TYPES","SHOWN_BLOCK_PATTERNS","SHOWN_BLOCK_PATTERNS_WITH_PRIORITIZATION","QuickInserter","onSelect","rootClientId","clientId","isAppender","prioritizePatterns","filterValue","setFilterValue","destinationRootClientId","onInsertBlocks","blockTypes","patterns","setInserterIsOpened","insertionIndex","select","getSettings","getBlockIndex","getBlockCount","blockEditorStore","settings","index","blockCount","__experimentalSetIsInserterOpened","showPatterns","length","showSearch","onBrowseAll","maxBlockPatterns","value"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAOA,MAAMA,gBAAgB,GAAG,CAAzB;AACA,MAAMC,iBAAiB,GAAG,CAA1B;AACA,MAAMC,oBAAoB,GAAG,CAA7B;AACA,MAAMC,wCAAwC,GAAG,CAAjD;;AAEe,SAASC,aAAT,OAMX;AAAA,MANmC;AACtCC,IAAAA,QADsC;AAEtCC,IAAAA,YAFsC;AAGtCC,IAAAA,QAHsC;AAItCC,IAAAA,UAJsC;AAKtCC,IAAAA;AALsC,GAMnC;AACH,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC,uBAAU,EAAV,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WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Button, SearchControl } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport InserterSearchResults from './search-results';\nimport useInsertionPoint from './hooks/use-insertion-point';\nimport usePatternsState from './hooks/use-patterns-state';\nimport useBlockTypesState from './hooks/use-block-types-state';\nimport { store as blockEditorStore } from '../../store';\n\nconst SEARCH_THRESHOLD = 6;\nconst SHOWN_BLOCK_TYPES = 6;\nconst SHOWN_BLOCK_PATTERNS = 2;\nconst SHOWN_BLOCK_PATTERNS_WITH_PRIORITIZATION = 4;\n\nexport default function QuickInserter( {\n\tonSelect,\n\trootClientId,\n\tclientId,\n\tisAppender,\n\tprioritizePatterns,\n} ) {\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\tonSelect,\n\t\trootClientId,\n\t\tclientId,\n\t\tisAppender,\n\t} );\n\tconst [ blockTypes ] = useBlockTypesState(\n\t\tdestinationRootClientId,\n\t\tonInsertBlocks\n\t);\n\n\tconst [ patterns ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId\n\t);\n\n\tconst { setInserterIsOpened, insertionIndex } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, getBlockIndex, getBlockCount } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst settings = getSettings();\n\t\t\tconst index = getBlockIndex( clientId );\n\t\t\tconst blockCount = getBlockCount();\n\n\t\t\treturn {\n\t\t\t\tsetInserterIsOpened: settings.__experimentalSetIsInserterOpened,\n\t\t\t\tinsertionIndex: index === -1 ? blockCount : index,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst showPatterns =\n\t\tpatterns.length && ( !! filterValue || prioritizePatterns );\n\tconst showSearch =\n\t\t( showPatterns && patterns.length > SEARCH_THRESHOLD ) ||\n\t\tblockTypes.length > SEARCH_THRESHOLD;\n\n\tuseEffect( () => {\n\t\tif ( setInserterIsOpened ) {\n\t\t\tsetInserterIsOpened( false );\n\t\t}\n\t}, [ setInserterIsOpened ] );\n\n\t// When clicking Browse All select the appropriate block so as\n\t// the insertion point can work as expected.\n\tconst onBrowseAll = () => {\n\t\tsetInserterIsOpened( { rootClientId, insertionIndex, filterValue } );\n\t};\n\n\tlet maxBlockPatterns = 0;\n\tif ( showPatterns ) {\n\t\tmaxBlockPatterns = prioritizePatterns\n\t\t\t? SHOWN_BLOCK_PATTERNS_WITH_PRIORITIZATION\n\t\t\t: SHOWN_BLOCK_PATTERNS;\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames( 'block-editor-inserter__quick-inserter', {\n\t\t\t\t'has-search': showSearch,\n\t\t\t\t'has-expand': setInserterIsOpened,\n\t\t\t} ) }\n\t\t>\n\t\t\t{ showSearch && (\n\t\t\t\t<SearchControl\n\t\t\t\t\tclassName=\"block-editor-inserter__search\"\n\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tsetFilterValue( value );\n\t\t\t\t\t} }\n\t\t\t\t\tlabel={ __( 'Search for blocks and patterns' ) }\n\t\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t<div className=\"block-editor-inserter__quick-inserter-results\">\n\t\t\t\t<InserterSearchResults\n\t\t\t\t\tfilterValue={ filterValue }\n\t\t\t\t\tonSelect={ onSelect }\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\tmaxBlockPatterns={ maxBlockPatterns }\n\t\t\t\t\tmaxBlockTypes={ SHOWN_BLOCK_TYPES }\n\t\t\t\t\tisDraggable={ false }\n\t\t\t\t\tprioritizePatterns={ prioritizePatterns }\n\t\t\t\t/>\n\t\t\t</div>\n\n\t\t\t{ setInserterIsOpened && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"block-editor-inserter__quick-inserter-expand\"\n\t\t\t\t\tonClick={ onBrowseAll }\n\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t'Browse all. This will open the main inserter panel in the editor toolbar.'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Browse all' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -63,7 +63,7 @@ const getNormalizedSearchTerms = function () {
|
|
|
63
63
|
exports.getNormalizedSearchTerms = getNormalizedSearchTerms;
|
|
64
64
|
|
|
65
65
|
const removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => {
|
|
66
|
-
return
|
|
66
|
+
return unmatchedTerms.filter(term => !getNormalizedSearchTerms(unprocessedTerms).some(unprocessedTerm => unprocessedTerm.includes(term)));
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
const searchBlockItems = (items, categories, collections, searchInput) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/search-items.js"],"names":["defaultGetName","item","name","defaultGetTitle","title","defaultGetDescription","description","defaultGetKeywords","keywords","defaultGetCategory","category","defaultGetCollection","normalizeSearchInput","input","replace","toLowerCase","getNormalizedSearchTerms","removeMatchingTerms","unmatchedTerms","unprocessedTerms","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/search-items.js"],"names":["defaultGetName","item","name","defaultGetTitle","title","defaultGetDescription","description","defaultGetKeywords","keywords","defaultGetCategory","category","defaultGetCollection","normalizeSearchInput","input","replace","toLowerCase","getNormalizedSearchTerms","removeMatchingTerms","unmatchedTerms","unprocessedTerms","filter","term","some","unprocessedTerm","includes","searchBlockItems","items","categories","collections","searchInput","normalizedSearchTerms","length","config","getCategory","slug","getCollection","split","searchItems","rankedItems","map","getItemSearchRank","rank","sort","rank1","rank2","searchTerm","getName","getTitle","getDescription","getKeywords","collection","normalizedSearchInput","normalizedTitle","startsWith","terms","join","isCoreBlockVariation","id"],"mappings":";;;;;;;;AAGA;;AAHA;AACA;AACA;AAGA;AACA,MAAMA,cAAc,GAAKC,IAAF,IAAYA,IAAI,CAACC,IAAL,IAAa,EAAhD;;AACA,MAAMC,eAAe,GAAKF,IAAF,IAAYA,IAAI,CAACG,KAAzC;;AACA,MAAMC,qBAAqB,GAAKJ,IAAF,IAAYA,IAAI,CAACK,WAAL,IAAoB,EAA9D;;AACA,MAAMC,kBAAkB,GAAKN,IAAF,IAAYA,IAAI,CAACO,QAAL,IAAiB,EAAxD;;AACA,MAAMC,kBAAkB,GAAKR,IAAF,IAAYA,IAAI,CAACS,QAA5C;;AACA,MAAMC,oBAAoB,GAAG,MAAM,IAAnC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,oBAAT,GAA4C;AAAA,MAAbC,KAAa,uEAAL,EAAK;AAC3C;AACA;AACAA,EAAAA,KAAK,GAAG,oBAAQA,KAAR,CAAR,CAH2C,CAK3C;AACA;;AACAA,EAAAA,KAAK,GAAGA,KAAK,CAACC,OAAN,CAAe,KAAf,EAAsB,EAAtB,CAAR,CAP2C,CAS3C;AACA;;AACAD,EAAAA,KAAK,GAAGA,KAAK,CAACE,WAAN,EAAR;AAEA,SAAOF,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMG,wBAAwB,GAAG,YAAkB;AAAA,MAAhBH,KAAgB,uEAAR,EAAQ;AACzD;AACA,SAAO,mBAAOD,oBAAoB,CAAEC,KAAF,CAA3B,CAAP;AACA,CAHM;;;;AAKP,MAAMI,mBAAmB,GAAG,CAAEC,cAAF,EAAkBC,gBAAlB,KAAwC;AACnE,SAAOD,cAAc,CAACE,MAAf,CACJC,IAAF,IACC,CAAEL,wBAAwB,CAAEG,gBAAF,CAAxB,CAA6CG,IAA7C,CACCC,eAAF,IAAuBA,eAAe,CAACC,QAAhB,CAA0BH,IA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;AAEA,MAAIqC,IAAI,GAAG,CAAX,CApBkE,CAsBlE;AACA;AACA;;AACA,MAAKU,qBAAqB,KAAKC,eAA/B,EAAiD;AAChDX,IAAAA,IAAI,IAAI,EAAR;AACA,GAFD,MAEO,IAAKW,eAAe,CAACC,UAAhB,CAA4BF,qBAA5B,CAAL,EAA2D;AACjEV,IAAAA,IAAI,IAAI,EAAR;AACA,GAFM,MAEA;AACN,UAAMa,KAAK,GAAG,CACbpD,IADa,EAEbE,KAFa,EAGbE,WAHa,EAIb,GAAGE,QAJU,EAKbE,QALa,EAMbwC,UANa,EAOZK,IAPY,CAON,GAPM,CAAd;AAQA,UAAMzB,qBAAqB,GAAG,mBAAOqB,qBAAP,CAA9B;AACA,UAAMjC,cAAc,GAAGD,mBAAmB,CACzCa,qBADyC,EAEzCwB,KAFyC,CAA1C;;AAKA,QAAKpC,cAAc,CAACa,MAAf,KAA0B,CAA/B,EAAmC;AAClCU,MAAAA,IAAI,IAAI,EAAR;AACA;AACD,GA/CiE,CAiDlE;;;AACA,MAAKA,IAAI,KAAK,CAAT,IAAcvC,IAAI,CAACmD,UAAL,CAAiB,OAAjB,CAAnB,EAAgD;AAC/C,UAAMG,oBAAoB,GAAGtD,IAAI,KAAKD,IAAI,CAACwD,EAA3C,CAD+C,CAE/C;;AACAhB,IAAAA,IAAI,IAAIe,oBAAoB,GAAG,CAAH,GAAO,CAAnC;AACA;;AAED,SAAOf,IAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { deburr, find, words } from 'lodash';\n\n// Default search helpers.\nconst defaultGetName = ( item ) => item.name || '';\nconst defaultGetTitle = ( item ) => item.title;\nconst defaultGetDescription = ( item ) => item.description || '';\nconst defaultGetKeywords = ( item ) => item.keywords || [];\nconst defaultGetCategory = ( item ) => item.category;\nconst defaultGetCollection = () => null;\n\n/**\n * Sanitizes the search input string.\n *\n * @param {string} input The search input to normalize.\n *\n * @return {string} The normalized search input.\n */\nfunction normalizeSearchInput( input = '' ) {\n\t// Disregard diacritics.\n\t// Input: \"média\"\n\tinput = deburr( input );\n\n\t// Accommodate leading slash, matching autocomplete expectations.\n\t// Input: \"/media\"\n\tinput = input.replace( /^\\//, '' );\n\n\t// Lowercase.\n\t// Input: \"MEDIA\"\n\tinput = input.toLowerCase();\n\n\treturn input;\n}\n\n/**\n * Converts the search term into a list of normalized terms.\n *\n * @param {string} input The search term to normalize.\n *\n * @return {string[]} The normalized list of search terms.\n */\nexport const getNormalizedSearchTerms = ( input = '' ) => {\n\t// Extract words.\n\treturn words( normalizeSearchInput( input ) );\n};\n\nconst removeMatchingTerms = ( unmatchedTerms, unprocessedTerms ) => {\n\treturn unmatchedTerms.filter(\n\t\t( term ) =>\n\t\t\t! getNormalizedSearchTerms( unprocessedTerms ).some(\n\t\t\t\t( unprocessedTerm ) => unprocessedTerm.includes( term )\n\t\t\t)\n\t);\n};\n\nexport const searchBlockItems = (\n\titems,\n\tcategories,\n\tcollections,\n\tsearchInput\n) => {\n\tconst normalizedSearchTerms = getNormalizedSearchTerms( searchInput );\n\tif ( normalizedSearchTerms.length === 0 ) {\n\t\treturn items;\n\t}\n\n\tconst config = {\n\t\tgetCategory: ( item ) =>\n\t\t\tfind( categories, { slug: item.category } )?.title,\n\t\tgetCollection: ( item ) =>\n\t\t\tcollections[ item.name.split( '/' )[ 0 ] ]?.title,\n\t};\n\n\treturn searchItems( items, searchInput, config );\n};\n\n/**\n * Filters an item list given a search term.\n *\n * @param {Array} items Item list\n * @param {string} searchInput Search input.\n * @param {Object} config Search Config.\n *\n * @return {Array} Filtered item list.\n */\nexport const searchItems = ( items = [], searchInput = '', config = {} ) => {\n\tconst normalizedSearchTerms = getNormalizedSearchTerms( searchInput );\n\tif ( normalizedSearchTerms.length === 0 ) {\n\t\treturn items;\n\t}\n\n\tconst rankedItems = items\n\t\t.map( ( item ) => {\n\t\t\treturn [ item, getItemSearchRank( item, searchInput, config ) ];\n\t\t} )\n\t\t.filter( ( [ , rank ] ) => rank > 0 );\n\n\trankedItems.sort( ( [ , rank1 ], [ , rank2 ] ) => rank2 - rank1 );\n\treturn rankedItems.map( ( [ item ] ) => item );\n};\n\n/**\n * Get the search rank for a given item and a specific search term.\n * The better the match, the higher the rank.\n * If the rank equals 0, it should be excluded from the results.\n *\n * @param {Object} item Item to filter.\n * @param {string} searchTerm Search term.\n * @param {Object} config Search Config.\n *\n * @return {number} Search Rank.\n */\nexport function getItemSearchRank( item, searchTerm, config = {} ) {\n\tconst {\n\t\tgetName = defaultGetName,\n\t\tgetTitle = defaultGetTitle,\n\t\tgetDescription = defaultGetDescription,\n\t\tgetKeywords = defaultGetKeywords,\n\t\tgetCategory = defaultGetCategory,\n\t\tgetCollection = defaultGetCollection,\n\t} = config;\n\n\tconst name = getName( item );\n\tconst title = getTitle( item );\n\tconst description = getDescription( item );\n\tconst keywords = getKeywords( item );\n\tconst category = getCategory( item );\n\tconst collection = getCollection( item );\n\n\tconst normalizedSearchInput = normalizeSearchInput( searchTerm );\n\tconst normalizedTitle = normalizeSearchInput( title );\n\n\tlet rank = 0;\n\n\t// Prefers exact matches\n\t// Then prefers if the beginning of the title matches the search term\n\t// name, keywords, categories, collection, variations match come later.\n\tif ( normalizedSearchInput === normalizedTitle ) {\n\t\trank += 30;\n\t} else if ( normalizedTitle.startsWith( normalizedSearchInput ) ) {\n\t\trank += 20;\n\t} else {\n\t\tconst terms = [\n\t\t\tname,\n\t\t\ttitle,\n\t\t\tdescription,\n\t\t\t...keywords,\n\t\t\tcategory,\n\t\t\tcollection,\n\t\t].join( ' ' );\n\t\tconst normalizedSearchTerms = words( normalizedSearchInput );\n\t\tconst unmatchedTerms = removeMatchingTerms(\n\t\t\tnormalizedSearchTerms,\n\t\t\tterms\n\t\t);\n\n\t\tif ( unmatchedTerms.length === 0 ) {\n\t\t\trank += 10;\n\t\t}\n\t}\n\n\t// Give a better rank to \"core\" namespaced items.\n\tif ( rank !== 0 && name.startsWith( 'core/' ) ) {\n\t\tconst isCoreBlockVariation = name !== item.id;\n\t\t// Give a bit better rank to \"core\" blocks over \"core\" block variations.\n\t\trank += isCoreBlockVariation ? 1 : 2;\n\t}\n\n\treturn rank;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/search-results.native.js"],"names":["InserterSearchResults","filterValue","onSelect","listProps","rootClientId","isFullScreen","blockTypes","select","allItems","blockEditorStore","getInserterItems","availableItems","allowReusable","filteredItems","items","trackBlockTypeSelected","length","handleSelect"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;AAQA,SAASA,qBAAT,OAMI;AAAA,MAN4B;AAC/BC,IAAAA,WAD+B;AAE/BC,IAAAA,QAF+B;AAG/BC,IAAAA,SAH+B;AAI/BC,IAAAA,YAJ+B;AAK/BC,IAAAA;AAL+B,GAM5B;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAiB,qBACpBC,MAAF,IAAc;AACb,UAAMC,QAAQ,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/search-results.native.js"],"names":["InserterSearchResults","filterValue","onSelect","listProps","rootClientId","isFullScreen","blockTypes","select","allItems","blockEditorStore","getInserterItems","availableItems","allowReusable","filteredItems","items","trackBlockTypeSelected","length","handleSelect"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;AAQA,SAASA,qBAAT,OAMI;AAAA,MAN4B;AAC/BC,IAAAA,WAD+B;AAE/BC,IAAAA,QAF+B;AAG/BC,IAAAA,SAH+B;AAI/BC,IAAAA,YAJ+B;AAK/BC,IAAAA;AAL+B,GAM5B;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAiB,qBACpBC,MAAF,IAAc;AACb,UAAMC,QAAQ,GACbD,MAAM,CAAEE,YAAF,CAAN,CAA2BC,gBAA3B,CAA6CN,YAA7C,CADD;AAGA,UAAMO,cAAc,GAAG,gCAAqBH,QAArB,EAA+B;AACrDI,MAAAA,aAAa,EAAE;AADsC,KAA/B,CAAvB;AAGA,UAAMC,aAAa,GAAG,8BAAaF,cAAb,EAA6BV,WAA7B,CAAtB;AAEA,WAAO;AAAEK,MAAAA,UAAU,EAAEO;AAAd,KAAP;AACA,GAXqB,EAYtB,CAAET,YAAF,EAAgBH,WAAhB,CAZsB,CAAvB;AAeA,QAAM;AAAEa,IAAAA,KAAF;AAASC,IAAAA;AAAT,MACL,sCAAyBT,UAAzB,CADD;;AAGA,MAAK,CAAEQ,KAAF,IAAW,CAAAA,KAAK,SAAL,IAAAA,KAAK,WAAL,YAAAA,KAAK,CAAEE,MAAP,MAAkB,CAAlC,EAAsC;AACrC,WAAO,4BAAC,kBAAD,OAAP;AACA;;AAED,QAAMC,YAAY,GAAG,YAAe;AACnCF,IAAAA,sBAAsB,CAAE,YAAF,CAAtB;AACAb,IAAAA,QAAQ,CAAE,YAAF,CAAR;AACA,GAHD;;AAKA,SACC,4BAAC,uBAAD;AACC,IAAA,IAAI,EAAC,QADN;AAEC,IAAA,kBAAkB,EAAGG,YAAY,GAAG,EAAH,GAAQ,CAF1C;AAGQS,IAAAA,KAHR;AAGeZ,IAAAA,QAAQ,EAAEe,YAHzB;AAGuCd,IAAAA;AAHvC,IADD;AAOA;;eAEcH,qB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { searchItems } from './search-items';\nimport BlockTypesList from '../block-types-list';\nimport InserterNoResults from './no-results';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockTypeImpressions from './hooks/use-block-type-impressions';\nimport { filterInserterItems } from './utils';\n\nfunction InserterSearchResults( {\n\tfilterValue,\n\tonSelect,\n\tlistProps,\n\trootClientId,\n\tisFullScreen,\n} ) {\n\tconst { blockTypes } = useSelect(\n\t\t( select ) => {\n\t\t\tconst allItems =\n\t\t\t\tselect( blockEditorStore ).getInserterItems( rootClientId );\n\n\t\t\tconst availableItems = filterInserterItems( allItems, {\n\t\t\t\tallowReusable: true,\n\t\t\t} );\n\t\t\tconst filteredItems = searchItems( availableItems, filterValue );\n\n\t\t\treturn { blockTypes: filteredItems };\n\t\t},\n\t\t[ rootClientId, filterValue ]\n\t);\n\n\tconst { items, trackBlockTypeSelected } =\n\t\tuseBlockTypeImpressions( blockTypes );\n\n\tif ( ! items || items?.length === 0 ) {\n\t\treturn <InserterNoResults />;\n\t}\n\n\tconst handleSelect = ( ...args ) => {\n\t\ttrackBlockTypeSelected( ...args );\n\t\tonSelect( ...args );\n\t};\n\n\treturn (\n\t\t<BlockTypesList\n\t\t\tname=\"Blocks\"\n\t\t\tinitialNumToRender={ isFullScreen ? 10 : 3 }\n\t\t\t{ ...{ items, onSelect: handleSelect, listProps } }\n\t\t/>\n\t);\n}\n\nexport default InserterSearchResults;\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = InspectorPopoverHeader;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _components = require("@wordpress/components");
|
|
11
|
+
|
|
12
|
+
var _icons = require("@wordpress/icons");
|
|
13
|
+
|
|
14
|
+
var _i18n = require("@wordpress/i18n");
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* WordPress dependencies
|
|
18
|
+
*/
|
|
19
|
+
function InspectorPopoverHeader(_ref) {
|
|
20
|
+
let {
|
|
21
|
+
title,
|
|
22
|
+
help,
|
|
23
|
+
actions = [],
|
|
24
|
+
onClose
|
|
25
|
+
} = _ref;
|
|
26
|
+
return (0, _element.createElement)(_components.__experimentalVStack, {
|
|
27
|
+
className: "block-editor-inspector-popover-header",
|
|
28
|
+
spacing: 4
|
|
29
|
+
}, (0, _element.createElement)(_components.__experimentalHStack, {
|
|
30
|
+
alignment: "center"
|
|
31
|
+
}, (0, _element.createElement)(_components.__experimentalHeading, {
|
|
32
|
+
className: "block-editor-inspector-popover-header__heading",
|
|
33
|
+
level: 2,
|
|
34
|
+
size: 13
|
|
35
|
+
}, title), (0, _element.createElement)(_components.__experimentalSpacer, null), actions.map(_ref2 => {
|
|
36
|
+
let {
|
|
37
|
+
label,
|
|
38
|
+
icon,
|
|
39
|
+
onClick
|
|
40
|
+
} = _ref2;
|
|
41
|
+
return (0, _element.createElement)(_components.Button, {
|
|
42
|
+
key: label,
|
|
43
|
+
className: "block-editor-inspector-popover-header__action",
|
|
44
|
+
label: label,
|
|
45
|
+
icon: icon,
|
|
46
|
+
variant: !icon && 'tertiary',
|
|
47
|
+
onClick: onClick
|
|
48
|
+
}, !icon && label);
|
|
49
|
+
}), onClose && (0, _element.createElement)(_components.Button, {
|
|
50
|
+
className: "block-editor-inspector-popover-header__action",
|
|
51
|
+
label: (0, _i18n.__)('Close'),
|
|
52
|
+
icon: _icons.closeSmall,
|
|
53
|
+
onClick: onClose
|
|
54
|
+
})), help && (0, _element.createElement)(_components.__experimentalText, null, help));
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-popover-header/index.js"],"names":["InspectorPopoverHeader","title","help","actions","onClose","map","label","icon","onClick","closeSmall"],"mappings":";;;;;;;;;AAGA;;AAQA;;AACA;;AAZA;AACA;AACA;AAYe,SAASA,sBAAT,OAKX;AAAA,MAL4C;AAC/CC,IAAAA,KAD+C;AAE/CC,IAAAA,IAF+C;AAG/CC,IAAAA,OAAO,GAAG,EAHqC;AAI/CC,IAAAA;AAJ+C,GAK5C;AACH,SACC,4BAAC,gCAAD;AAAQ,IAAA,SAAS,EAAC,uCAAlB;AAA0D,IAAA,OAAO,EAAG;AAApE,KACC,4BAAC,gCAAD;AAAQ,IAAA,SAAS,EAAC;AAAlB,KACC,4BAAC,iCAAD;AACC,IAAA,SAAS,EAAC,gDADX;AAEC,IAAA,KAAK,EAAG,CAFT;AAGC,IAAA,IAAI,EAAG;AAHR,KAKGH,KALH,CADD,EAQC,4BAAC,gCAAD,OARD,EASGE,OAAO,CAACE,GAAR,CAAa;AAAA,QAAE;AAAEC,MAAAA,KAAF;AAASC,MAAAA,IAAT;AAAeC,MAAAA;AAAf,KAAF;AAAA,WACd,4BAAC,kBAAD;AACC,MAAA,GAAG,EAAGF,KADP;AAEC,MAAA,SAAS,EAAC,+CAFX;AAGC,MAAA,KAAK,EAAGA,KAHT;AAIC,MAAA,IAAI,EAAGC,IAJR;AAKC,MAAA,OAAO,EAAG,CAAEA,IAAF,IAAU,UALrB;AAMC,MAAA,OAAO,EAAGC;AANX,OAQG,CAAED,IAAF,IAAUD,KARb,CADc;AAAA,GAAb,CATH,EAqBGF,OAAO,IACR,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,+CADX;AAEC,IAAA,KAAK,EAAG,cAAI,OAAJ,CAFT;AAGC,IAAA,IAAI,EAAGK,iBAHR;AAIC,IAAA,OAAO,EAAGL;AAJX,IAtBF,CADD,EA+BGF,IAAI,IAAI,4BAAC,8BAAD,QAAQA,IAAR,CA/BX,CADD;AAmCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n\t__experimentalHeading as Heading,\n\t__experimentalSpacer as Spacer,\n\tButton,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { closeSmall } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\nexport default function InspectorPopoverHeader( {\n\ttitle,\n\thelp,\n\tactions = [],\n\tonClose,\n} ) {\n\treturn (\n\t\t<VStack className=\"block-editor-inspector-popover-header\" spacing={ 4 }>\n\t\t\t<HStack alignment=\"center\">\n\t\t\t\t<Heading\n\t\t\t\t\tclassName=\"block-editor-inspector-popover-header__heading\"\n\t\t\t\t\tlevel={ 2 }\n\t\t\t\t\tsize={ 13 }\n\t\t\t\t>\n\t\t\t\t\t{ title }\n\t\t\t\t</Heading>\n\t\t\t\t<Spacer />\n\t\t\t\t{ actions.map( ( { label, icon, onClick } ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\tclassName=\"block-editor-inspector-popover-header__action\"\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\tvariant={ ! icon && 'tertiary' }\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! icon && label }\n\t\t\t\t\t</Button>\n\t\t\t\t) ) }\n\t\t\t\t{ onClose && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-inspector-popover-header__action\"\n\t\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t\t{ help && <Text>{ help }</Text> }\n\t\t</VStack>\n\t);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/line-height-control/index.js"],"names":["LineHeightControl","value","lineHeight","onChange","__nextHasNoMarginBottom","__unstableInputWidth","isDefined","adjustNextValue","nextValue","wasTypedOrPasted","STEP","BASE_DEFAULT_VALUE","stateReducer","state","action","includes","payload","event","nativeEvent","inputType","RESET_VALUE","since","version","hint","deprecatedStyles","undefined","marginBottom"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAQA,MAAMA,iBAAiB,GAAG,QAMnB;AAAA,MANqB;AAC3BC,IAAAA,KAAK,EAAEC,UADoB;AAE3BC,IAAAA,QAF2B;;AAG3B;AACAC,IAAAA,uBAAuB,GAAG,KAJC;AAK3BC,IAAAA,oBAAoB,GAAG;AALI,GAMrB;AACN,QAAMC,SAAS,GAAG,gCAAqBJ,UAArB,CAAlB;;AAEA,QAAMK,eAAe,GAAG,CAAEC,SAAF,EAAaC,gBAAb,KAAmC;AAC1D;AACA,QAAKH,SAAL,EAAiB,OAAOE,SAAP;AAEjB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACE,YAAU,GAAGA,SAAW,EAAxB;AACC,WAAM,GAAGE,WAAM,EAAf;AACC;AACA,eAAOC,4BAAqBD,WAA5B;;AACD,WAAK,GAAL;AAAU;AACT;AACA;AACA,cAAKD,gBAAL,EAAwB,OAAOD,SAAP,CAHf,CAIT;;AACA,iBAAOG,4BAAqBD,WAA5B;AACA;;AACD,WAAK,EAAL;AACC,eAAOC,yBAAP;;AACD;AACC,eAAOH,SAAP;AAdF;AAgBA,GA7BD;;AA+BA,QAAMI,YAAY,GAAG,CAAEC,KAAF,EAASC,MAAT,KAAqB;AAAA;;AACzC;AACA;AACA;AACA;AACA,UAAML,gBAAgB,GAAG,CAAE,YAAF,EAAgB,iBAAhB,EAAoCM,QAApC,0BACxBD,MAAM,CAACE,OAAP,CAAeC,KAAf,CAAqBC,WADG,0DACxB,sBAAkCC,SADV,CAAzB;AAGA,UAAMlB,KAAK,GAAGM,eAAe,CAAEM,KAAK,CAACZ,KAAR,EAAeQ,gBAAf,CAA7B;AACA,WAAO,EAAE,GAAGI,KAAL;AAAYZ,MAAAA;AAAZ,KAAP;AACA,GAVD;;AAYA,QAAMA,KAAK,GAAGK,SAAS,GAAGJ,UAAH,GAAgBkB,kBAAvC;;AAEA,MAAK,CAAEhB,uBAAP,EAAiC;AAChC,6BACC,2DADD,EAEC;AACCiB,MAAAA,KAAK,EAAE,KADR;AAECC,MAAAA,OAAO,EAAE,KAFV;AAGCC,MAAAA,IAAI,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/line-height-control/index.js"],"names":["LineHeightControl","value","lineHeight","onChange","__nextHasNoMarginBottom","__unstableInputWidth","isDefined","adjustNextValue","nextValue","wasTypedOrPasted","STEP","BASE_DEFAULT_VALUE","stateReducer","state","action","includes","payload","event","nativeEvent","inputType","RESET_VALUE","since","version","hint","deprecatedStyles","undefined","marginBottom"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAQA,MAAMA,iBAAiB,GAAG,QAMnB;AAAA,MANqB;AAC3BC,IAAAA,KAAK,EAAEC,UADoB;AAE3BC,IAAAA,QAF2B;;AAG3B;AACAC,IAAAA,uBAAuB,GAAG,KAJC;AAK3BC,IAAAA,oBAAoB,GAAG;AALI,GAMrB;AACN,QAAMC,SAAS,GAAG,gCAAqBJ,UAArB,CAAlB;;AAEA,QAAMK,eAAe,GAAG,CAAEC,SAAF,EAAaC,gBAAb,KAAmC;AAC1D;AACA,QAAKH,SAAL,EAAiB,OAAOE,SAAP;AAEjB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACE,YAAU,GAAGA,SAAW,EAAxB;AACC,WAAM,GAAGE,WAAM,EAAf;AACC;AACA,eAAOC,4BAAqBD,WAA5B;;AACD,WAAK,GAAL;AAAU;AACT;AACA;AACA,cAAKD,gBAAL,EAAwB,OAAOD,SAAP,CAHf,CAIT;;AACA,iBAAOG,4BAAqBD,WAA5B;AACA;;AACD,WAAK,EAAL;AACC,eAAOC,yBAAP;;AACD;AACC,eAAOH,SAAP;AAdF;AAgBA,GA7BD;;AA+BA,QAAMI,YAAY,GAAG,CAAEC,KAAF,EAASC,MAAT,KAAqB;AAAA;;AACzC;AACA;AACA;AACA;AACA,UAAML,gBAAgB,GAAG,CAAE,YAAF,EAAgB,iBAAhB,EAAoCM,QAApC,0BACxBD,MAAM,CAACE,OAAP,CAAeC,KAAf,CAAqBC,WADG,0DACxB,sBAAkCC,SADV,CAAzB;AAGA,UAAMlB,KAAK,GAAGM,eAAe,CAAEM,KAAK,CAACZ,KAAR,EAAeQ,gBAAf,CAA7B;AACA,WAAO,EAAE,GAAGI,KAAL;AAAYZ,MAAAA;AAAZ,KAAP;AACA,GAVD;;AAYA,QAAMA,KAAK,GAAGK,SAAS,GAAGJ,UAAH,GAAgBkB,kBAAvC;;AAEA,MAAK,CAAEhB,uBAAP,EAAiC;AAChC,6BACC,2DADD,EAEC;AACCiB,MAAAA,KAAK,EAAE,KADR;AAECC,MAAAA,OAAO,EAAE,KAFV;AAGCC,MAAAA,IAAI,EAAE;AAHP,KAFD;AAQA;;AACD,QAAMC,gBAAgB,GAAGpB,uBAAuB,GAC7CqB,SAD6C,GAE7C;AAAEC,IAAAA,YAAY,EAAE;AAAhB,GAFH;AAIA,SACC;AACC,IAAA,SAAS,EAAC,kCADX;AAEC,IAAA,KAAK,EAAGF;AAFT,KAIC,4BAAC,uCAAD;AACC,IAAA,oBAAoB,EAAGnB,oBADxB;AAEC,IAAA,sBAAsB,EAAGO,YAF1B;AAGC,IAAA,QAAQ,EAAGT,QAHZ;AAIC,IAAA,KAAK,EAAG,cAAI,aAAJ,CAJT;AAKC,IAAA,WAAW,EAAGQ,yBALf;AAMC,IAAA,IAAI,EAAGD,WANR;AAOC,IAAA,KAAK,EAAGT,KAPT;AAQC,IAAA,GAAG,EAAG;AARP,IAJD,CADD;AAiBA,CArFD;AAuFA;AACA;AACA;;;eACeD,iB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalNumberControl as NumberControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBASE_DEFAULT_VALUE,\n\tRESET_VALUE,\n\tSTEP,\n\tisLineHeightDefined,\n} from './utils';\n\nconst LineHeightControl = ( {\n\tvalue: lineHeight,\n\tonChange,\n\t/** Start opting into the new margin-free styles that will become the default in a future version. */\n\t__nextHasNoMarginBottom = false,\n\t__unstableInputWidth = '60px',\n} ) => {\n\tconst isDefined = isLineHeightDefined( lineHeight );\n\n\tconst adjustNextValue = ( nextValue, wasTypedOrPasted ) => {\n\t\t// Set the next value without modification if lineHeight has been defined.\n\t\tif ( isDefined ) return nextValue;\n\n\t\t/**\n\t\t * The following logic handles the initial step up/down action\n\t\t * (from an undefined value state) so that the next values are better suited for\n\t\t * line-height rendering. For example, the first step up should immediately\n\t\t * go to 1.6, rather than the normally expected 0.1.\n\t\t *\n\t\t * Step up/down actions can be triggered by keydowns of the up/down arrow keys,\n\t\t * or by clicking the spin buttons.\n\t\t */\n\t\tswitch ( `${ nextValue }` ) {\n\t\t\tcase `${ STEP }`:\n\t\t\t\t// Increment by step value.\n\t\t\t\treturn BASE_DEFAULT_VALUE + STEP;\n\t\t\tcase '0': {\n\t\t\t\t// This means the user explicitly input '0', rather than stepped down\n\t\t\t\t// from an undefined value state.\n\t\t\t\tif ( wasTypedOrPasted ) return nextValue;\n\t\t\t\t// Decrement by step value.\n\t\t\t\treturn BASE_DEFAULT_VALUE - STEP;\n\t\t\t}\n\t\t\tcase '':\n\t\t\t\treturn BASE_DEFAULT_VALUE;\n\t\t\tdefault:\n\t\t\t\treturn nextValue;\n\t\t}\n\t};\n\n\tconst stateReducer = ( state, action ) => {\n\t\t// Be careful when changing this — cross-browser behavior of the\n\t\t// `inputType` field in `input` events are inconsistent.\n\t\t// For example, Firefox emits an input event with inputType=\"insertReplacementText\"\n\t\t// on spin button clicks, while other browsers do not even emit an input event.\n\t\tconst wasTypedOrPasted = [ 'insertText', 'insertFromPaste' ].includes(\n\t\t\taction.payload.event.nativeEvent?.inputType\n\t\t);\n\t\tconst value = adjustNextValue( state.value, wasTypedOrPasted );\n\t\treturn { ...state, value };\n\t};\n\n\tconst value = isDefined ? lineHeight : RESET_VALUE;\n\n\tif ( ! __nextHasNoMarginBottom ) {\n\t\tdeprecated(\n\t\t\t'Bottom margin styles for wp.blockEditor.LineHeightControl',\n\t\t\t{\n\t\t\t\tsince: '6.0',\n\t\t\t\tversion: '6.4',\n\t\t\t\thint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version',\n\t\t\t}\n\t\t);\n\t}\n\tconst deprecatedStyles = __nextHasNoMarginBottom\n\t\t? undefined\n\t\t: { marginBottom: 24 };\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-line-height-control\"\n\t\t\tstyle={ deprecatedStyles }\n\t\t>\n\t\t\t<NumberControl\n\t\t\t\t__unstableInputWidth={ __unstableInputWidth }\n\t\t\t\t__unstableStateReducer={ stateReducer }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tlabel={ __( 'Line height' ) }\n\t\t\t\tplaceholder={ BASE_DEFAULT_VALUE }\n\t\t\t\tstep={ STEP }\n\t\t\t\tvalue={ value }\n\t\t\t\tmin={ 0 }\n\t\t\t/>\n\t\t</div>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/line-height-control/README.md\n */\nexport default LineHeightControl;\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.DEFAULT_LINK_SETTINGS = exports.CREATE_TYPE = void 0;
|
|
6
|
+
exports.URL_TYPE = exports.TEL_TYPE = exports.MAILTO_TYPE = exports.LINK_ENTRY_TYPES = exports.INTERNAL_TYPE = exports.DEFAULT_LINK_SETTINGS = exports.CREATE_TYPE = void 0;
|
|
7
7
|
|
|
8
8
|
var _i18n = require("@wordpress/i18n");
|
|
9
9
|
|
|
@@ -15,6 +15,16 @@ var _i18n = require("@wordpress/i18n");
|
|
|
15
15
|
// order to handle it as a unique case.
|
|
16
16
|
const CREATE_TYPE = '__CREATE__';
|
|
17
17
|
exports.CREATE_TYPE = CREATE_TYPE;
|
|
18
|
+
const TEL_TYPE = 'tel';
|
|
19
|
+
exports.TEL_TYPE = TEL_TYPE;
|
|
20
|
+
const URL_TYPE = 'URL';
|
|
21
|
+
exports.URL_TYPE = URL_TYPE;
|
|
22
|
+
const MAILTO_TYPE = 'mailto';
|
|
23
|
+
exports.MAILTO_TYPE = MAILTO_TYPE;
|
|
24
|
+
const INTERNAL_TYPE = 'internal';
|
|
25
|
+
exports.INTERNAL_TYPE = INTERNAL_TYPE;
|
|
26
|
+
const LINK_ENTRY_TYPES = [URL_TYPE, MAILTO_TYPE, TEL_TYPE, INTERNAL_TYPE];
|
|
27
|
+
exports.LINK_ENTRY_TYPES = LINK_ENTRY_TYPES;
|
|
18
28
|
const DEFAULT_LINK_SETTINGS = [{
|
|
19
29
|
id: 'opensInNewTab',
|
|
20
30
|
title: (0, _i18n.__)('Open in new tab')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/constants.js"],"names":["CREATE_TYPE","DEFAULT_LINK_SETTINGS","id","title"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA;AACA;AACA;AACO,MAAMA,WAAW,GAAG,YAApB;;AAEA,MAAMC,qBAAqB,GAAG,CACpC;AACCC,EAAAA,EAAE,EAAE,eADL;AAECC,EAAAA,KAAK,EAAE,cAAI,iBAAJ;AAFR,CADoC,CAA9B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n// Used as a unique identifier for the \"Create\" option within search results.\n// Used to help distinguish the \"Create\" suggestion within the search results in\n// order to handle it as a unique case.\nexport const CREATE_TYPE = '__CREATE__';\n\nexport const DEFAULT_LINK_SETTINGS = [\n\t{\n\t\tid: 'opensInNewTab',\n\t\ttitle: __( 'Open in new tab' ),\n\t},\n];\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/constants.js"],"names":["CREATE_TYPE","TEL_TYPE","URL_TYPE","MAILTO_TYPE","INTERNAL_TYPE","LINK_ENTRY_TYPES","DEFAULT_LINK_SETTINGS","id","title"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA;AACA;AACA;AACO,MAAMA,WAAW,GAAG,YAApB;;AACA,MAAMC,QAAQ,GAAG,KAAjB;;AACA,MAAMC,QAAQ,GAAG,KAAjB;;AACA,MAAMC,WAAW,GAAG,QAApB;;AACA,MAAMC,aAAa,GAAG,UAAtB;;AAEA,MAAMC,gBAAgB,GAAG,CAC/BH,QAD+B,EAE/BC,WAF+B,EAG/BF,QAH+B,EAI/BG,aAJ+B,CAAzB;;AAOA,MAAME,qBAAqB,GAAG,CACpC;AACCC,EAAAA,EAAE,EAAE,eADL;AAECC,EAAAA,KAAK,EAAE,cAAI,iBAAJ;AAFR,CADoC,CAA9B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n// Used as a unique identifier for the \"Create\" option within search results.\n// Used to help distinguish the \"Create\" suggestion within the search results in\n// order to handle it as a unique case.\nexport const CREATE_TYPE = '__CREATE__';\nexport const TEL_TYPE = 'tel';\nexport const URL_TYPE = 'URL';\nexport const MAILTO_TYPE = 'mailto';\nexport const INTERNAL_TYPE = 'internal';\n\nexport const LINK_ENTRY_TYPES = [\n\tURL_TYPE,\n\tMAILTO_TYPE,\n\tTEL_TYPE,\n\tINTERNAL_TYPE,\n];\n\nexport const DEFAULT_LINK_SETTINGS = [\n\t{\n\t\tid: 'opensInNewTab',\n\t\ttitle: __( 'Open in new tab' ),\n\t},\n];\n"]}
|
|
@@ -9,8 +9,6 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
-
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
12
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
13
|
|
|
16
14
|
var _components = require("@wordpress/components");
|
|
@@ -121,7 +119,7 @@ var _constants = require("./constants");
|
|
|
121
119
|
* @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.
|
|
122
120
|
* @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.
|
|
123
121
|
*/
|
|
124
|
-
|
|
122
|
+
const noop = () => {};
|
|
125
123
|
/**
|
|
126
124
|
* Renders a link control. A link control is a controlled input which maintains
|
|
127
125
|
* a value associated with a link (HTML anchor element) and relevant settings
|
|
@@ -129,6 +127,8 @@ var _constants = require("./constants");
|
|
|
129
127
|
*
|
|
130
128
|
* @param {WPLinkControlProps} props Component props.
|
|
131
129
|
*/
|
|
130
|
+
|
|
131
|
+
|
|
132
132
|
function LinkControl(_ref) {
|
|
133
133
|
var _currentInputValue$tr, _value$url, _value$url$trim;
|
|
134
134
|
|
|
@@ -136,7 +136,7 @@ function LinkControl(_ref) {
|
|
|
136
136
|
searchInputPlaceholder,
|
|
137
137
|
value,
|
|
138
138
|
settings = _constants.DEFAULT_LINK_SETTINGS,
|
|
139
|
-
onChange =
|
|
139
|
+
onChange = noop,
|
|
140
140
|
onRemove,
|
|
141
141
|
noDirectEntry = false,
|
|
142
142
|
showSuggestions = true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["LinkControl","searchInputPlaceholder","value","settings","DEFAULT_LINK_SETTINGS","onChange","noop","onRemove","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","internalInputValue","setInternalInputValue","url","internalTextValue","setInternalTextValue","title","currentInputValue","isEditingLink","setIsEditingLink","isEndingEditWithFocus","currentInputIsEmpty","trim","length","createPage","isCreatingPage","errorMessage","current","whichFocusTargetIndex","nextFocusTarget","focus","focusable","find","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","handleSubmit","handleSubmitWithEnter","event","keyCode","ENTER","preventDefault","shownUnlinkControl","showSettingsDrawer","showTextControl","keyboardReturn","ViewerFill"],"mappings":";;;;;;;;;AAYA;;AATA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AACA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EAAC,yCADX;AAEC,IAAA,MAAM,EAAC,OAFR;AAGC,IAAA,aAAa,EAAG;AAHjB,KAKGA,YALH,CAjDF,CAZF,EAwEGvC,KAAK,IAAI,CAAE+B,aAAX,IAA4B,CAAEO,cAA9B,IACD,4BAAC,oBAAD;AACC,IAAA,GAAG,EAAGtC,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAE0B,GADd,CACoB;AADpB;AAEC,IAAA,KAAK,EAAG1B,KAFT;AAGC,IAAA,WAAW,EAAG,MAAMgC,gBAAgB,CAAE,IAAF,CAHrC;AAIC,IAAA,eAAe,EAAGf,eAJnB;AAKC,IAAA,gBAAgB,EAAGyC,kBALpB;AAMC,IAAA,QAAQ,EAAGrD;AANZ,IAzEF,EAmFGsD,kBAAkB,IACnB;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,uBAAD;AACC,IAAA,KAAK,EAAG3D,KADT;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,QAAQ,EAAGE;AAHZ,IADD,CApFF,EA4FGgB,mBAAmB,IAAIA,mBAAmB,EA5F7C,CADD;AAgGA;;AAEDrB,WAAW,CAACgE,UAAZ,GAAyBA,sBAAzB;eAEehE,W","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Spinner, Notice, TextControl } from '@wordpress/components';\nimport { keyboardReturn } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport useCreatePage from './use-create-page';\nimport { ViewerFill } from './viewer-slot';\nimport { DEFAULT_LINK_SETTINGS } from './constants';\n\n/**\n * Default properties associated with a link control value.\n *\n * @typedef WPLinkControlDefaultValue\n *\n * @property {string} url Link URL.\n * @property {string=} title Link title.\n * @property {boolean=} opensInNewTab Whether link should open in a new browser\n * tab. This value is only assigned if not\n * providing a custom `settings` prop.\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Custom settings values associated with a link.\n *\n * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue\n */\n/* eslint-enable */\n\n/**\n * Custom settings values associated with a link.\n *\n * @typedef WPLinkControlSetting\n *\n * @property {string} id Identifier to use as property for setting value.\n * @property {string} title Human-readable label to show in user interface.\n */\n\n/**\n * Properties associated with a link control value, composed as a union of the\n * default properties and any custom settings values.\n *\n * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue\n */\n\n/** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */\n\n/**\n * Properties associated with a search suggestion used within the LinkControl.\n *\n * @typedef WPLinkControlSuggestion\n *\n * @property {string} id Identifier to use to uniquely identify the suggestion.\n * @property {string} type Identifies the type of the suggestion (eg: `post`,\n * `page`, `url`...etc)\n * @property {string} title Human-readable label to show in user interface.\n * @property {string} url A URL for the suggestion.\n */\n\n/** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */\n\n/**\n * @typedef WPLinkControlProps\n *\n * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to\n * render a `ToggleControl` for that setting.\n * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the\n * internal editing state of the component to respective\n * show or not show the URL input field.\n * @property {WPLinkControlValue=} value Current link value.\n * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if\n * the user selects a new link or updates settings.\n * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.\n * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.\n * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.\n * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.\n * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.\n * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.\n * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.\n * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.\n */\n\n/**\n * Renders a link control. A link control is a controlled input which maintains\n * a value associated with a link (HTML anchor element) and relevant settings\n * for how that link is expected to behave.\n *\n * @param {WPLinkControlProps} props Component props.\n */\nfunction LinkControl( {\n\tsearchInputPlaceholder,\n\tvalue,\n\tsettings = DEFAULT_LINK_SETTINGS,\n\tonChange = noop,\n\tonRemove,\n\tnoDirectEntry = false,\n\tshowSuggestions = true,\n\tshowInitialSuggestions,\n\tforceIsEditingLink,\n\tcreateSuggestion,\n\twithCreateSuggestion,\n\tinputValue: propInputValue = '',\n\tsuggestionsQuery = {},\n\tnoURLSuggestion = false,\n\tcreateSuggestionButtonText,\n\thasRichPreviews = false,\n\thasTextControl = false,\n\trenderControlBottom = null,\n} ) {\n\tif ( withCreateSuggestion === undefined && createSuggestion ) {\n\t\twithCreateSuggestion = true;\n\t}\n\n\tconst isMounting = useRef( true );\n\tconst wrapperNode = useRef();\n\tconst textInputRef = useRef();\n\n\tconst [ internalInputValue, setInternalInputValue ] = useState(\n\t\tvalue?.url || ''\n\t);\n\tconst [ internalTextValue, setInternalTextValue ] = useState(\n\t\tvalue?.title || ''\n\t);\n\tconst currentInputValue = propInputValue || internalInputValue;\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\n\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst currentInputIsEmpty = ! currentInputValue?.trim()?.length;\n\n\tconst { createPage, isCreatingPage, errorMessage } = useCreatePage(\n\t\tcreateSuggestion\n\t);\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tforceIsEditingLink !== undefined &&\n\t\t\tforceIsEditingLink !== isEditingLink\n\t\t) {\n\t\t\tsetIsEditingLink( forceIsEditingLink );\n\t\t}\n\t}, [ forceIsEditingLink ] );\n\n\tuseEffect( () => {\n\t\t// We don't auto focus into the Link UI on mount\n\t\t// because otherwise using the keyboard to select text\n\t\t// *within* the link format is not possible.\n\t\tif ( isMounting.current ) {\n\t\t\tisMounting.current = false;\n\t\t\treturn;\n\t\t}\n\t\t// Unless we are mounting, we always want to focus either:\n\t\t// - the URL input\n\t\t// - the first focusable element in the Link UI.\n\t\t// But in editing mode if there is a text input present then\n\t\t// the URL input is at index 1. If not then it is at index 0.\n\t\tconst whichFocusTargetIndex = textInputRef?.current ? 1 : 0;\n\n\t\t// Scenario - when:\n\t\t// - switching between editable and non editable LinkControl\n\t\t// - clicking on a link\n\t\t// ...then move focus to the *first* element to avoid focus loss\n\t\t// and to ensure focus is *within* the Link UI.\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperNode.current )[\n\t\t\t\twhichFocusTargetIndex\n\t\t\t] || wrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * If the value's `text` property changes then sync this\n\t\t * back up with state.\n\t\t */\n\t\tif ( value?.title && value.title !== internalTextValue ) {\n\t\t\tsetInternalTextValue( value.title );\n\t\t}\n\n\t\t/**\n\t\t * Update the state value internalInputValue if the url value changes\n\t\t * for example when clicking on another anchor\n\t\t */\n\t\tif ( value?.url ) {\n\t\t\tsetInternalInputValue( value.url );\n\t\t}\n\t}, [ value ] );\n\n\t/**\n\t * Cancels editing state and marks that focus may need to be restored after\n\t * the next render, if focus was within the wrapper when editing finished.\n\t */\n\tfunction stopEditing() {\n\t\tisEndingEditWithFocus.current = !! wrapperNode.current?.contains(\n\t\t\twrapperNode.current.ownerDocument.activeElement\n\t\t);\n\n\t\tsetIsEditingLink( false );\n\t}\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\tonChange( {\n\t\t\t...updatedValue,\n\t\t\ttitle: internalTextValue || updatedValue?.title,\n\t\t} );\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif (\n\t\t\tcurrentInputValue !== value?.url ||\n\t\t\tinternalTextValue !== value?.title\n\t\t) {\n\t\t\tonChange( {\n\t\t\t\turl: currentInputValue,\n\t\t\t\ttitle: internalTextValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\n\t\tif (\n\t\t\tkeyCode === ENTER &&\n\t\t\t! currentInputIsEmpty // Disallow submitting empty values.\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\thandleSubmit();\n\t\t}\n\t};\n\n\tconst shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showSettingsDrawer = !! settings?.length;\n\n\t// Only show text control once a URL value has been committed\n\t// and it isn't just empty whitespace.\n\t// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.\n\tconst showTextControl = value?.url?.trim()?.length > 0 && hasTextControl;\n\n\treturn (\n\t\t<div\n\t\t\ttabIndex={ -1 }\n\t\t\tref={ wrapperNode }\n\t\t\tclassName=\"block-editor-link-control\"\n\t\t>\n\t\t\t{ isCreatingPage && (\n\t\t\t\t<div className=\"block-editor-link-control__loading\">\n\t\t\t\t\t<Spinner /> { __( 'Creating' ) }…\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ ( isEditingLink || ! value ) && ! isCreatingPage && (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t\t'block-editor-link-control__search-input-wrapper': true,\n\t\t\t\t\t\t\t'has-text-control': showTextControl,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTextControl && (\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\tref={ textInputRef }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__text-content\"\n\t\t\t\t\t\t\t\tlabel=\"Text\"\n\t\t\t\t\t\t\t\tvalue={ internalTextValue }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextValue }\n\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t<LinkControlSearchInput\n\t\t\t\t\t\t\tcurrentLink={ value }\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__search-input\"\n\t\t\t\t\t\t\tplaceholder={ searchInputPlaceholder }\n\t\t\t\t\t\t\tvalue={ currentInputValue }\n\t\t\t\t\t\t\twithCreateSuggestion={ withCreateSuggestion }\n\t\t\t\t\t\t\tonCreateSuggestion={ createPage }\n\t\t\t\t\t\t\tonChange={ setInternalInputValue }\n\t\t\t\t\t\t\tonSelect={ handleSelectSuggestion }\n\t\t\t\t\t\t\tshowInitialSuggestions={ showInitialSuggestions }\n\t\t\t\t\t\t\tallowDirectEntry={ ! noDirectEntry }\n\t\t\t\t\t\t\tshowSuggestions={ showSuggestions }\n\t\t\t\t\t\t\tsuggestionsQuery={ suggestionsQuery }\n\t\t\t\t\t\t\twithURLSuggestion={ ! noURLSuggestion }\n\t\t\t\t\t\t\tcreateSuggestionButtonText={\n\t\t\t\t\t\t\t\tcreateSuggestionButtonText\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tuseLabel={ showTextControl }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tonClick={ handleSubmit }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Submit' ) }\n\t\t\t\t\t\t\t\t\ticon={ keyboardReturn }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\t\t\t\tdisabled={ currentInputIsEmpty } // Disallow submitting empty values.\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</LinkControlSearchInput>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ errorMessage && (\n\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-error\"\n\t\t\t\t\t\t\tstatus=\"error\"\n\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ errorMessage }\n\t\t\t\t\t\t</Notice>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ value && ! isEditingLink && ! isCreatingPage && (\n\t\t\t\t<LinkPreview\n\t\t\t\t\tkey={ value?.url } // force remount when URL changes to avoid race conditions for rich previews\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonEditClick={ () => setIsEditingLink( true ) }\n\t\t\t\t\thasRichPreviews={ hasRichPreviews }\n\t\t\t\t\thasUnlinkControl={ shownUnlinkControl }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ showSettingsDrawer && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["noop","LinkControl","searchInputPlaceholder","value","settings","DEFAULT_LINK_SETTINGS","onChange","onRemove","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","internalInputValue","setInternalInputValue","url","internalTextValue","setInternalTextValue","title","currentInputValue","isEditingLink","setIsEditingLink","isEndingEditWithFocus","currentInputIsEmpty","trim","length","createPage","isCreatingPage","errorMessage","current","whichFocusTargetIndex","nextFocusTarget","focus","focusable","find","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","handleSubmit","handleSubmitWithEnter","event","keyCode","ENTER","preventDefault","shownUnlinkControl","showSettingsDrawer","showTextControl","keyboardReturn","ViewerFill"],"mappings":";;;;;;;;;AAWA;;AARA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,WAAT,OAmBI;AAAA;;AAAA,MAnBkB;AACrBC,IAAAA,sBADqB;AAErBC,IAAAA,KAFqB;AAGrBC,IAAAA,QAAQ,GAAGC,gCAHU;AAIrBC,IAAAA,QAAQ,GAAGN,IAJU;AAKrBO,IAAAA,QALqB;AAMrBC,IAAAA,aAAa,GAAG,KANK;AAOrBC,IAAAA,eAAe,GAAG,IAP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AC+D,UAAZ,GAAyBA,sBAAzB;eAEe/D,W","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Spinner, Notice, TextControl } from '@wordpress/components';\nimport { keyboardReturn } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport useCreatePage from './use-create-page';\nimport { ViewerFill } from './viewer-slot';\nimport { DEFAULT_LINK_SETTINGS } from './constants';\n\n/**\n * Default properties associated with a link control value.\n *\n * @typedef WPLinkControlDefaultValue\n *\n * @property {string} url Link URL.\n * @property {string=} title Link title.\n * @property {boolean=} opensInNewTab Whether link should open in a new browser\n * tab. This value is only assigned if not\n * providing a custom `settings` prop.\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Custom settings values associated with a link.\n *\n * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue\n */\n/* eslint-enable */\n\n/**\n * Custom settings values associated with a link.\n *\n * @typedef WPLinkControlSetting\n *\n * @property {string} id Identifier to use as property for setting value.\n * @property {string} title Human-readable label to show in user interface.\n */\n\n/**\n * Properties associated with a link control value, composed as a union of the\n * default properties and any custom settings values.\n *\n * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue\n */\n\n/** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */\n\n/**\n * Properties associated with a search suggestion used within the LinkControl.\n *\n * @typedef WPLinkControlSuggestion\n *\n * @property {string} id Identifier to use to uniquely identify the suggestion.\n * @property {string} type Identifies the type of the suggestion (eg: `post`,\n * `page`, `url`...etc)\n * @property {string} title Human-readable label to show in user interface.\n * @property {string} url A URL for the suggestion.\n */\n\n/** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */\n\n/**\n * @typedef WPLinkControlProps\n *\n * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to\n * render a `ToggleControl` for that setting.\n * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the\n * internal editing state of the component to respective\n * show or not show the URL input field.\n * @property {WPLinkControlValue=} value Current link value.\n * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if\n * the user selects a new link or updates settings.\n * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.\n * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.\n * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.\n * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.\n * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.\n * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.\n * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.\n * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.\n */\n\nconst noop = () => {};\n\n/**\n * Renders a link control. A link control is a controlled input which maintains\n * a value associated with a link (HTML anchor element) and relevant settings\n * for how that link is expected to behave.\n *\n * @param {WPLinkControlProps} props Component props.\n */\nfunction LinkControl( {\n\tsearchInputPlaceholder,\n\tvalue,\n\tsettings = DEFAULT_LINK_SETTINGS,\n\tonChange = noop,\n\tonRemove,\n\tnoDirectEntry = false,\n\tshowSuggestions = true,\n\tshowInitialSuggestions,\n\tforceIsEditingLink,\n\tcreateSuggestion,\n\twithCreateSuggestion,\n\tinputValue: propInputValue = '',\n\tsuggestionsQuery = {},\n\tnoURLSuggestion = false,\n\tcreateSuggestionButtonText,\n\thasRichPreviews = false,\n\thasTextControl = false,\n\trenderControlBottom = null,\n} ) {\n\tif ( withCreateSuggestion === undefined && createSuggestion ) {\n\t\twithCreateSuggestion = true;\n\t}\n\n\tconst isMounting = useRef( true );\n\tconst wrapperNode = useRef();\n\tconst textInputRef = useRef();\n\n\tconst [ internalInputValue, setInternalInputValue ] = useState(\n\t\tvalue?.url || ''\n\t);\n\tconst [ internalTextValue, setInternalTextValue ] = useState(\n\t\tvalue?.title || ''\n\t);\n\tconst currentInputValue = propInputValue || internalInputValue;\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\n\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst currentInputIsEmpty = ! currentInputValue?.trim()?.length;\n\n\tconst { createPage, isCreatingPage, errorMessage } =\n\t\tuseCreatePage( createSuggestion );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tforceIsEditingLink !== undefined &&\n\t\t\tforceIsEditingLink !== isEditingLink\n\t\t) {\n\t\t\tsetIsEditingLink( forceIsEditingLink );\n\t\t}\n\t}, [ forceIsEditingLink ] );\n\n\tuseEffect( () => {\n\t\t// We don't auto focus into the Link UI on mount\n\t\t// because otherwise using the keyboard to select text\n\t\t// *within* the link format is not possible.\n\t\tif ( isMounting.current ) {\n\t\t\tisMounting.current = false;\n\t\t\treturn;\n\t\t}\n\t\t// Unless we are mounting, we always want to focus either:\n\t\t// - the URL input\n\t\t// - the first focusable element in the Link UI.\n\t\t// But in editing mode if there is a text input present then\n\t\t// the URL input is at index 1. If not then it is at index 0.\n\t\tconst whichFocusTargetIndex = textInputRef?.current ? 1 : 0;\n\n\t\t// Scenario - when:\n\t\t// - switching between editable and non editable LinkControl\n\t\t// - clicking on a link\n\t\t// ...then move focus to the *first* element to avoid focus loss\n\t\t// and to ensure focus is *within* the Link UI.\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperNode.current )[\n\t\t\t\twhichFocusTargetIndex\n\t\t\t] || wrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * If the value's `text` property changes then sync this\n\t\t * back up with state.\n\t\t */\n\t\tif ( value?.title && value.title !== internalTextValue ) {\n\t\t\tsetInternalTextValue( value.title );\n\t\t}\n\n\t\t/**\n\t\t * Update the state value internalInputValue if the url value changes\n\t\t * for example when clicking on another anchor\n\t\t */\n\t\tif ( value?.url ) {\n\t\t\tsetInternalInputValue( value.url );\n\t\t}\n\t}, [ value ] );\n\n\t/**\n\t * Cancels editing state and marks that focus may need to be restored after\n\t * the next render, if focus was within the wrapper when editing finished.\n\t */\n\tfunction stopEditing() {\n\t\tisEndingEditWithFocus.current = !! wrapperNode.current?.contains(\n\t\t\twrapperNode.current.ownerDocument.activeElement\n\t\t);\n\n\t\tsetIsEditingLink( false );\n\t}\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\tonChange( {\n\t\t\t...updatedValue,\n\t\t\ttitle: internalTextValue || updatedValue?.title,\n\t\t} );\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif (\n\t\t\tcurrentInputValue !== value?.url ||\n\t\t\tinternalTextValue !== value?.title\n\t\t) {\n\t\t\tonChange( {\n\t\t\t\turl: currentInputValue,\n\t\t\t\ttitle: internalTextValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\n\t\tif (\n\t\t\tkeyCode === ENTER &&\n\t\t\t! currentInputIsEmpty // Disallow submitting empty values.\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\thandleSubmit();\n\t\t}\n\t};\n\n\tconst shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showSettingsDrawer = !! settings?.length;\n\n\t// Only show text control once a URL value has been committed\n\t// and it isn't just empty whitespace.\n\t// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.\n\tconst showTextControl = value?.url?.trim()?.length > 0 && hasTextControl;\n\n\treturn (\n\t\t<div\n\t\t\ttabIndex={ -1 }\n\t\t\tref={ wrapperNode }\n\t\t\tclassName=\"block-editor-link-control\"\n\t\t>\n\t\t\t{ isCreatingPage && (\n\t\t\t\t<div className=\"block-editor-link-control__loading\">\n\t\t\t\t\t<Spinner /> { __( 'Creating' ) }…\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ ( isEditingLink || ! value ) && ! isCreatingPage && (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t\t'block-editor-link-control__search-input-wrapper': true,\n\t\t\t\t\t\t\t'has-text-control': showTextControl,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTextControl && (\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\tref={ textInputRef }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__text-content\"\n\t\t\t\t\t\t\t\tlabel=\"Text\"\n\t\t\t\t\t\t\t\tvalue={ internalTextValue }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextValue }\n\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t<LinkControlSearchInput\n\t\t\t\t\t\t\tcurrentLink={ value }\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__search-input\"\n\t\t\t\t\t\t\tplaceholder={ searchInputPlaceholder }\n\t\t\t\t\t\t\tvalue={ currentInputValue }\n\t\t\t\t\t\t\twithCreateSuggestion={ withCreateSuggestion }\n\t\t\t\t\t\t\tonCreateSuggestion={ createPage }\n\t\t\t\t\t\t\tonChange={ setInternalInputValue }\n\t\t\t\t\t\t\tonSelect={ handleSelectSuggestion }\n\t\t\t\t\t\t\tshowInitialSuggestions={ showInitialSuggestions }\n\t\t\t\t\t\t\tallowDirectEntry={ ! noDirectEntry }\n\t\t\t\t\t\t\tshowSuggestions={ showSuggestions }\n\t\t\t\t\t\t\tsuggestionsQuery={ suggestionsQuery }\n\t\t\t\t\t\t\twithURLSuggestion={ ! noURLSuggestion }\n\t\t\t\t\t\t\tcreateSuggestionButtonText={\n\t\t\t\t\t\t\t\tcreateSuggestionButtonText\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tuseLabel={ showTextControl }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tonClick={ handleSubmit }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Submit' ) }\n\t\t\t\t\t\t\t\t\ticon={ keyboardReturn }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\t\t\t\tdisabled={ currentInputIsEmpty } // Disallow submitting empty values.\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</LinkControlSearchInput>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ errorMessage && (\n\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-error\"\n\t\t\t\t\t\t\tstatus=\"error\"\n\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ errorMessage }\n\t\t\t\t\t\t</Notice>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ value && ! isEditingLink && ! isCreatingPage && (\n\t\t\t\t<LinkPreview\n\t\t\t\t\tkey={ value?.url } // force remount when URL changes to avoid race conditions for rich previews\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonEditClick={ () => setIsEditingLink( true ) }\n\t\t\t\t\thasRichPreviews={ hasRichPreviews }\n\t\t\t\t\thasUnlinkControl={ shownUnlinkControl }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ showSettingsDrawer && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
|
|
@@ -13,8 +13,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
13
13
|
|
|
14
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
15
|
|
|
16
|
-
var _lodash = require("lodash");
|
|
17
|
-
|
|
18
16
|
var _i18n = require("@wordpress/i18n");
|
|
19
17
|
|
|
20
18
|
var _components = require("@wordpress/components");
|
|
@@ -44,7 +42,7 @@ const LinkControlSearchCreate = _ref => {
|
|
|
44
42
|
let text;
|
|
45
43
|
|
|
46
44
|
if (buttonText) {
|
|
47
|
-
text =
|
|
45
|
+
text = typeof buttonText === 'function' ? buttonText(searchTerm) : buttonText;
|
|
48
46
|
} else {
|
|
49
47
|
text = (0, _element.createInterpolateElement)((0, _i18n.sprintf)(
|
|
50
48
|
/* translators: %s: search term. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-create-button.js"],"names":["LinkControlSearchCreate","searchTerm","onClick","itemProps","isSelected","buttonText","text","mark","plus"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-create-button.js"],"names":["LinkControlSearchCreate","searchTerm","onClick","itemProps","isSelected","buttonText","text","mark","plus"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AAKA;;AACA;;AAEA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;AAMO,MAAMA,uBAAuB,GAAG,QAMhC;AAAA,MANkC;AACxCC,IAAAA,UADwC;AAExCC,IAAAA,OAFwC;AAGxCC,IAAAA,SAHwC;AAIxCC,IAAAA,UAJwC;AAKxCC,IAAAA;AALwC,GAMlC;;AACN,MAAK,CAAEJ,UAAP,EAAoB;AACnB,WAAO,IAAP;AACA;;AAED,MAAIK,IAAJ;;AACA,MAAKD,UAAL,EAAkB;AACjBC,IAAAA,IAAI,GACH,OAAOD,UAAP,KAAsB,UAAtB,GACGA,UAAU,CAAEJ,UAAF,CADb,GAEGI,UAHJ;AAIA,GALD,MAKO;AACNC,IAAAA,IAAI,GAAG,uCACN;AACC;AACA,kBAAI,yBAAJ,CAFD,EAGCL,UAHD,CADM,EAMN;AAAEM,MAAAA,IAAI,EAAE;AAAR,KANM,CAAP;AAQA;;AAED,SACC,4BAAC,kBAAD,6BACMJ,SADN;AAEC,IAAA,SAAS,EAAG,yBACX,iFADW,EAEX;AACC,qBAAeC;AADhB,KAFW,CAFb;AAQC,IAAA,OAAO,EAAGF;AARX,MAUC,4BAAC,WAAD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,IAAI,EAAGM;AAFR,IAVD,EAeC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGF,IADH,CADD,CAfD,CADD;AAuBA,CAnDM;;;eAqDQN,uB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { Icon, plus } from '@wordpress/icons';\n\nexport const LinkControlSearchCreate = ( {\n\tsearchTerm,\n\tonClick,\n\titemProps,\n\tisSelected,\n\tbuttonText,\n} ) => {\n\tif ( ! searchTerm ) {\n\t\treturn null;\n\t}\n\n\tlet text;\n\tif ( buttonText ) {\n\t\ttext =\n\t\t\ttypeof buttonText === 'function'\n\t\t\t\t? buttonText( searchTerm )\n\t\t\t\t: buttonText;\n\t} else {\n\t\ttext = createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Create: <mark>%s</mark>' ),\n\t\t\t\tsearchTerm\n\t\t\t),\n\t\t\t{ mark: <mark /> }\n\t\t);\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\t{ ...itemProps }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-link-control__search-create block-editor-link-control__search-item',\n\t\t\t\t{\n\t\t\t\t\t'is-selected': isSelected,\n\t\t\t\t}\n\t\t\t) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t<Icon\n\t\t\t\tclassName=\"block-editor-link-control__search-item-icon\"\n\t\t\t\ticon={ plus }\n\t\t\t/>\n\n\t\t\t<span className=\"block-editor-link-control__search-item-header\">\n\t\t\t\t<span className=\"block-editor-link-control__search-item-title\">\n\t\t\t\t\t{ text }\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t</Button>\n\t);\n};\n\nexport default LinkControlSearchCreate;\n"]}
|
|
@@ -41,6 +41,8 @@ var _useSearchHandler = _interopRequireDefault(require("./use-search-handler"));
|
|
|
41
41
|
// which will cause an unintended http request.
|
|
42
42
|
const noopSearchHandler = () => Promise.resolve([]);
|
|
43
43
|
|
|
44
|
+
const noop = () => {};
|
|
45
|
+
|
|
44
46
|
const LinkControlSearchInput = (0, _element.forwardRef)((_ref, ref) => {
|
|
45
47
|
let {
|
|
46
48
|
value,
|
|
@@ -49,9 +51,9 @@ const LinkControlSearchInput = (0, _element.forwardRef)((_ref, ref) => {
|
|
|
49
51
|
className = null,
|
|
50
52
|
placeholder = null,
|
|
51
53
|
withCreateSuggestion = false,
|
|
52
|
-
onCreateSuggestion =
|
|
53
|
-
onChange =
|
|
54
|
-
onSelect =
|
|
54
|
+
onCreateSuggestion = noop,
|
|
55
|
+
onChange = noop,
|
|
56
|
+
onSelect = noop,
|
|
55
57
|
showSuggestions = true,
|
|
56
58
|
renderSuggestions = props => (0, _element.createElement)(_searchResults.default, props),
|
|
57
59
|
fetchSuggestions = null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-input.js"],"names":["noopSearchHandler","Promise","resolve","LinkControlSearchInput","ref","value","children","currentLink","className","placeholder","withCreateSuggestion","onCreateSuggestion","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-input.js"],"names":["noopSearchHandler","Promise","resolve","noop","LinkControlSearchInput","ref","value","children","currentLink","className","placeholder","withCreateSuggestion","onCreateSuggestion","onChange","onSelect","showSuggestions","renderSuggestions","props","fetchSuggestions","allowDirectEntry","showInitialSuggestions","suggestionsQuery","withURLSuggestion","createSuggestionButtonText","useLabel","genericSearchHandler","searchHandler","instanceId","focusedSuggestion","setFocusedSuggestion","onInputChange","selection","suggestion","handleRenderSuggestions","currentInputValue","handleSuggestionClick","onSuggestionSelected","selectedSuggestion","CREATE_TYPE","type","title","url","e","Object","keys","length","inputClasses","undefined","event","hasSuggestion","trim","preventDefault"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAIA;;AAEA;;AAKA;;AACA;;AACA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAMA;AACA;AACA;AACA,MAAMA,iBAAiB,GAAG,MAAMC,OAAO,CAACC,OAAR,CAAiB,EAAjB,CAAhC;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,MAAMC,sBAAsB,GAAG,yBAC9B,OAuBCC,GAvBD,KAwBK;AAAA,MAvBJ;AACCC,IAAAA,KADD;AAECC,IAAAA,QAFD;AAGCC,IAAAA,WAAW,GAAG,EAHf;AAICC,IAAAA,SAAS,GAAG,IAJb;AAKCC,IAAAA,WAAW,GAAG,IALf;AAMCC,IAAAA,oBAAoB,GAAG,KANxB;AAOCC,IAAAA,kBAAkB,GAAGT,IAPtB;AAQC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,kCAAkC,EAAGP,aATtC;AAUC,IAAA,kCAAkC,EAAG,IAVtC;AAWC,IAAA,oCAAoC,EACnCN,sBAZF;AAcC,IAAA,QAAQ,EAAG,CAAEY,UAAF,EAAcgB,KAAd,KAAyB;AAAA;;AACnC,YAAMC,aAAa,GAAGjB,UAAU,IAAIJ,iBAApC,CADmC,CAGnC;AACA;;AACA,UAAK,CAAEqB,aAAF,IAAmB,EAAE3C,KAAF,aAAEA,KAAF,8BAAEA,KAAK,CAAE4C,IAAP,EAAF,wCAAE,YAAeL,MAAjB,CAAxB,EAAkD;AACjDG,QAAAA,KAAK,CAACG,cAAN;AACA,OAFD,MAEO;AACNf,QAAAA,oBAAoB,CACnBa,aAAa,IAAI;AAAER,UAAAA,GAAG,EAAEnC;AAAP,SADE,CAApB;AAGA;AACD,KA1BF;AA2BC,IAAA,GAAG,EAAGD;AA3BP,IADD,EA8BGE,QA9BH,CADD;AAkCA,CArI6B,CAA/B;eAwIeH,sB","sourcesContent":["/**\n * External dependencies\n */\nimport { omit } from 'lodash';\nimport classnames from 'classnames';\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { URLInput } from '../';\nimport LinkControlSearchResults from './search-results';\nimport { CREATE_TYPE } from './constants';\nimport useSearchHandler from './use-search-handler';\n\n// Must be a function as otherwise URLInput will default\n// to the fetchLinkSuggestions passed in block editor settings\n// which will cause an unintended http request.\nconst noopSearchHandler = () => Promise.resolve( [] );\n\nconst noop = () => {};\n\nconst LinkControlSearchInput = forwardRef(\n\t(\n\t\t{\n\t\t\tvalue,\n\t\t\tchildren,\n\t\t\tcurrentLink = {},\n\t\t\tclassName = null,\n\t\t\tplaceholder = null,\n\t\t\twithCreateSuggestion = false,\n\t\t\tonCreateSuggestion = noop,\n\t\t\tonChange = noop,\n\t\t\tonSelect = noop,\n\t\t\tshowSuggestions = true,\n\t\t\trenderSuggestions = ( props ) => (\n\t\t\t\t<LinkControlSearchResults { ...props } />\n\t\t\t),\n\t\t\tfetchSuggestions = null,\n\t\t\tallowDirectEntry = true,\n\t\t\tshowInitialSuggestions = false,\n\t\t\tsuggestionsQuery = {},\n\t\t\twithURLSuggestion = true,\n\t\t\tcreateSuggestionButtonText,\n\t\t\tuseLabel = false,\n\t\t},\n\t\tref\n\t) => {\n\t\tconst genericSearchHandler = useSearchHandler(\n\t\t\tsuggestionsQuery,\n\t\t\tallowDirectEntry,\n\t\t\twithCreateSuggestion,\n\t\t\twithURLSuggestion\n\t\t);\n\n\t\tconst searchHandler = showSuggestions\n\t\t\t? fetchSuggestions || genericSearchHandler\n\t\t\t: noopSearchHandler;\n\n\t\tconst instanceId = useInstanceId( LinkControlSearchInput );\n\t\tconst [ focusedSuggestion, setFocusedSuggestion ] = useState();\n\n\t\t/**\n\t\t * Handles the user moving between different suggestions. Does not handle\n\t\t * choosing an individual item.\n\t\t *\n\t\t * @param {string} selection the url of the selected suggestion.\n\t\t * @param {Object} suggestion the suggestion object.\n\t\t */\n\t\tconst onInputChange = ( selection, suggestion ) => {\n\t\t\tonChange( selection );\n\t\t\tsetFocusedSuggestion( suggestion );\n\t\t};\n\n\t\tconst handleRenderSuggestions = ( props ) =>\n\t\t\trenderSuggestions( {\n\t\t\t\t...props,\n\t\t\t\tinstanceId,\n\t\t\t\twithCreateSuggestion,\n\t\t\t\tcurrentInputValue: value,\n\t\t\t\tcreateSuggestionButtonText,\n\t\t\t\tsuggestionsQuery,\n\t\t\t\thandleSuggestionClick: ( suggestion ) => {\n\t\t\t\t\tif ( props.handleSuggestionClick ) {\n\t\t\t\t\t\tprops.handleSuggestionClick( suggestion );\n\t\t\t\t\t}\n\t\t\t\t\tonSuggestionSelected( suggestion );\n\t\t\t\t},\n\t\t\t} );\n\n\t\tconst onSuggestionSelected = async ( selectedSuggestion ) => {\n\t\t\tlet suggestion = selectedSuggestion;\n\t\t\tif ( CREATE_TYPE === selectedSuggestion.type ) {\n\t\t\t\t// Create a new page and call onSelect with the output from the onCreateSuggestion callback.\n\t\t\t\ttry {\n\t\t\t\t\tsuggestion = await onCreateSuggestion(\n\t\t\t\t\t\tselectedSuggestion.title\n\t\t\t\t\t);\n\t\t\t\t\tif ( suggestion?.url ) {\n\t\t\t\t\t\tonSelect( suggestion );\n\t\t\t\t\t}\n\t\t\t\t} catch ( e ) {}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tallowDirectEntry ||\n\t\t\t\t( suggestion && Object.keys( suggestion ).length >= 1 )\n\t\t\t) {\n\t\t\t\tonSelect(\n\t\t\t\t\t// Some direct entries don't have types or IDs, and we still need to clear the previous ones.\n\t\t\t\t\t{ ...omit( currentLink, 'id', 'url' ), ...suggestion },\n\t\t\t\t\tsuggestion\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst inputClasses = classnames( className, {\n\t\t\t'has-no-label': ! useLabel,\n\t\t} );\n\n\t\treturn (\n\t\t\t<div className=\"block-editor-link-control__search-input-container\">\n\t\t\t\t<URLInput\n\t\t\t\t\tlabel={ useLabel ? 'URL' : undefined }\n\t\t\t\t\tclassName={ inputClasses }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onInputChange }\n\t\t\t\t\tplaceholder={ placeholder ?? __( 'Search or type url' ) }\n\t\t\t\t\t__experimentalRenderSuggestions={\n\t\t\t\t\t\tshowSuggestions ? handleRenderSuggestions : null\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalFetchLinkSuggestions={ searchHandler }\n\t\t\t\t\t__experimentalHandleURLSuggestions={ true }\n\t\t\t\t\t__experimentalShowInitialSuggestions={\n\t\t\t\t\t\tshowInitialSuggestions\n\t\t\t\t\t}\n\t\t\t\t\tonSubmit={ ( suggestion, event ) => {\n\t\t\t\t\t\tconst hasSuggestion = suggestion || focusedSuggestion;\n\n\t\t\t\t\t\t// If there is no suggestion and the value (ie: any manually entered URL) is empty\n\t\t\t\t\t\t// then don't allow submission otherwise we get empty links.\n\t\t\t\t\t\tif ( ! hasSuggestion && ! value?.trim()?.length ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonSuggestionSelected(\n\t\t\t\t\t\t\t\thasSuggestion || { url: value }\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tref={ ref }\n\t\t\t\t/>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nexport default LinkControlSearchInput;\n"]}
|