@wordpress/block-editor 8.1.2 → 8.3.0-next.e230fbab09.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 +6 -26
- package/build/autocompleters/link.js +78 -0
- package/build/autocompleters/link.js.map +1 -0
- package/build/components/autocomplete/index.js +3 -1
- package/build/components/autocomplete/index.js.map +1 -1
- package/build/components/block-actions/index.js +1 -1
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-breadcrumb/index.js +4 -2
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-compare/index.js +2 -2
- package/build/components/block-compare/index.js.map +1 -1
- package/build/components/block-controls/index.js +1 -1
- package/build/components/block-controls/index.js.map +1 -1
- package/build/components/block-draggable/index.js +1 -1
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-edit/edit.js +1 -1
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-list/block-html.js +1 -1
- package/build/components/block-list/block-html.js.map +1 -1
- package/build/components/block-list/block-invalid-warning.js +1 -1
- package/build/components/block-list/block-invalid-warning.js.map +1 -1
- package/build/components/block-list/block-list-item.native.js +4 -4
- package/build/components/block-list/block-list-item.native.js.map +1 -1
- package/build/components/block-list/block-selection-button.native.js +4 -3
- package/build/components/block-list/block-selection-button.native.js.map +1 -1
- package/build/components/block-list/block.js +17 -3
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +6 -6
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +5 -5
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js +3 -0
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-list/use-block-props/use-multi-selection.js +25 -27
- package/build/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build/components/block-media-update-progress/index.native.js +4 -4
- package/build/components/block-media-update-progress/index.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +3 -3
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/index.native.js +1 -1
- package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build/components/block-mover/mover-description.js +4 -4
- package/build/components/block-mover/mover-description.js.map +1 -1
- package/build/components/block-mover/mover-description.native.js +5 -5
- package/build/components/block-mover/mover-description.native.js.map +1 -1
- package/build/components/block-settings/container.native.js +1 -5
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +7 -12
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/preview.native.js +1 -1
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/block-switcher/index.js +2 -1
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/use-transformed-patterns.js +0 -1
- package/build/components/block-switcher/use-transformed-patterns.js.map +1 -1
- package/build/components/block-title/index.js +7 -62
- package/build/components/block-title/index.js.map +1 -1
- package/build/components/block-title/use-block-display-title.js +94 -0
- package/build/components/block-title/use-block-display-title.js.map +1 -0
- package/build/components/block-toolbar/utils.js +9 -1
- package/build/components/block-toolbar/utils.js.map +1 -1
- package/build/components/block-tools/block-popover.js +1 -1
- package/build/components/block-tools/block-popover.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +2 -1
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-types-list/index.native.js +1 -1
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/border-radius-control/index.js +2 -2
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/utils.js +10 -6
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/contrast-checker/index.js +3 -3
- package/build/components/contrast-checker/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/index.js +1 -1
- package/build/components/convert-to-group-buttons/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +1 -3
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build/components/copy-handler/index.js +3 -3
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +3 -3
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +38 -1
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +4 -4
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +1 -1
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-block-type-impressions.native.js +2 -2
- package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build/components/inserter/index.js +3 -3
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +7 -7
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/menu.native.js +3 -3
- package/build/components/inserter/menu.native.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +20 -8
- 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.js +28 -11
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -1
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +3 -3
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/line-height-control/index.js +63 -45
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/line-height-control/index.native.js +3 -1
- package/build/components/line-height-control/index.native.js.map +1 -1
- package/build/components/link-control/index.js +2 -2
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/search-results.js +2 -2
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/link-control/use-rich-url-data.js +1 -1
- package/build/components/link-control/use-rich-url-data.js.map +1 -1
- package/build/components/link-control/use-search-handler.js +2 -2
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/list-view/block-contents.js +8 -4
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block-select-button.js +2 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +20 -9
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +2 -1
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +49 -41
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +139 -0
- package/build/components/list-view/use-block-selection.js.map +1 -0
- package/build/components/list-view/use-list-view-expand-selected-item.js +60 -0
- package/build/components/list-view/use-list-view-expand-selected-item.js.map +1 -0
- package/build/components/list-view/utils.js +29 -1
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/media-placeholder/index.native.js +7 -5
- package/build/components/media-placeholder/index.native.js.map +1 -1
- package/build/components/media-replace-flow/index.js +20 -24
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/media-upload/index.native.js +4 -3
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/media-upload-progress/index.native.js +2 -2
- package/build/components/media-upload-progress/index.native.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +3 -3
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/plain-text/index.native.js +3 -3
- package/build/components/plain-text/index.native.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +2 -2
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.native.js +1 -1
- package/build/components/rich-text/format-toolbar-container.native.js.map +1 -1
- package/build/components/rich-text/index.js +7 -12
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +3 -3
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +7 -12
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/url-input/index.js +11 -11
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +1 -1
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +2 -2
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/writing-flow/index.js +1 -0
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +22 -24
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-select-all.js +3 -2
- package/build/components/writing-flow/use-select-all.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +4 -3
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/align.js +1 -1
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/anchor.js +1 -1
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border.js +2 -14
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +2 -2
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/custom-class-name.js +40 -0
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/duotone.js +22 -4
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/generated-class-name.js +3 -3
- package/build/hooks/generated-class-name.js.map +1 -1
- package/build/hooks/line-height.js +2 -0
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/lock.js +1 -1
- package/build/hooks/lock.js.map +1 -1
- package/build/hooks/style.js +32 -13
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/flow.js +7 -5
- package/build/layouts/flow.js.map +1 -1
- package/build/store/actions.js +55 -48
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +2 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/index.js +1 -2
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +13 -13
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +6 -6
- package/build/store/selectors.js.map +1 -1
- package/build/utils/index.js +0 -14
- package/build/utils/index.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +3 -3
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build/utils/pasting.js +91 -0
- package/build/utils/pasting.js.map +1 -0
- package/build/utils/transform-styles/ast/parse.js +5 -5
- package/build/utils/transform-styles/ast/parse.js.map +1 -1
- package/build/utils/transform-styles/transforms/url-rewrite.js +2 -2
- package/build/utils/transform-styles/transforms/url-rewrite.js.map +1 -1
- package/build-module/autocompleters/link.js +64 -0
- package/build-module/autocompleters/link.js.map +1 -0
- package/build-module/components/autocomplete/index.js +2 -1
- package/build-module/components/autocomplete/index.js.map +1 -1
- package/build-module/components/block-actions/index.js +1 -1
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +4 -2
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-compare/index.js +2 -2
- package/build-module/components/block-compare/index.js.map +1 -1
- package/build-module/components/block-controls/index.js +1 -1
- package/build-module/components/block-controls/index.js.map +1 -1
- package/build-module/components/block-draggable/index.js +1 -1
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-edit/edit.js +1 -1
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-list/block-html.js +1 -1
- package/build-module/components/block-list/block-html.js.map +1 -1
- package/build-module/components/block-list/block-invalid-warning.js +1 -1
- package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
- package/build-module/components/block-list/block-list-item.native.js +4 -4
- 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 +4 -3
- package/build-module/components/block-list/block-selection-button.native.js.map +1 -1
- package/build-module/components/block-list/block.js +18 -4
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +7 -7
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +5 -5
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +2 -0
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-multi-selection.js +23 -28
- package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build-module/components/block-media-update-progress/index.native.js +4 -4
- package/build-module/components/block-media-update-progress/index.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +3 -3
- 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 +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-mover/mover-description.js +4 -4
- package/build-module/components/block-mover/mover-description.js.map +1 -1
- package/build-module/components/block-mover/mover-description.native.js +5 -5
- package/build-module/components/block-mover/mover-description.native.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +2 -6
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +7 -13
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js +1 -1
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/block-switcher/index.js +2 -1
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/use-transformed-patterns.js +0 -1
- package/build-module/components/block-switcher/use-transformed-patterns.js.map +1 -1
- package/build-module/components/block-title/index.js +7 -58
- package/build-module/components/block-title/index.js.map +1 -1
- package/build-module/components/block-title/use-block-display-title.js +80 -0
- package/build-module/components/block-title/use-block-display-title.js.map +1 -0
- package/build-module/components/block-toolbar/utils.js +9 -1
- package/build-module/components/block-toolbar/utils.js.map +1 -1
- package/build-module/components/block-tools/block-popover.js +1 -1
- package/build-module/components/block-tools/block-popover.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +2 -1
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +1 -1
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +3 -3
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js +11 -7
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/contrast-checker/index.js +3 -3
- package/build-module/components/contrast-checker/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/index.js +1 -1
- package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +1 -3
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build-module/components/copy-handler/index.js +2 -2
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +3 -3
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +5 -4
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +4 -4
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +1 -1
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js +2 -2
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build-module/components/inserter/index.js +3 -3
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +7 -7
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/menu.native.js +3 -3
- package/build-module/components/inserter/menu.native.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +20 -8
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-items.js +1 -1
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter/search-results.js +28 -11
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -1
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +3 -3
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js +61 -45
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/line-height-control/index.native.js +3 -1
- package/build-module/components/line-height-control/index.native.js.map +1 -1
- package/build-module/components/link-control/index.js +2 -2
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/search-results.js +2 -2
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/link-control/use-rich-url-data.js +1 -1
- package/build-module/components/link-control/use-rich-url-data.js.map +1 -1
- package/build-module/components/link-control/use-search-handler.js +2 -2
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +8 -4
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +2 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +20 -9
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +2 -1
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +46 -42
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +123 -0
- package/build-module/components/list-view/use-block-selection.js.map +1 -0
- package/build-module/components/list-view/use-list-view-expand-selected-item.js +50 -0
- package/build-module/components/list-view/use-list-view-expand-selected-item.js.map +1 -0
- package/build-module/components/list-view/utils.js +25 -0
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/media-placeholder/index.native.js +7 -5
- package/build-module/components/media-placeholder/index.native.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +22 -27
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +4 -3
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/media-upload-progress/index.native.js +2 -2
- package/build-module/components/media-upload-progress/index.native.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +3 -3
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/plain-text/index.native.js +3 -3
- package/build-module/components/plain-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +2 -2
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.native.js +1 -1
- package/build-module/components/rich-text/format-toolbar-container.native.js.map +1 -1
- package/build-module/components/rich-text/index.js +7 -12
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +3 -3
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +6 -12
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/url-input/index.js +11 -11
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +1 -1
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +2 -2
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/writing-flow/index.js +1 -0
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +21 -21
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-select-all.js +3 -2
- package/build-module/components/writing-flow/use-select-all.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +4 -3
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/align.js +1 -1
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/anchor.js +1 -1
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border.js +2 -14
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +2 -2
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +38 -0
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/duotone.js +23 -5
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/generated-class-name.js +3 -3
- package/build-module/hooks/generated-class-name.js.map +1 -1
- package/build-module/hooks/line-height.js +2 -0
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/lock.js +1 -1
- package/build-module/hooks/lock.js.map +1 -1
- package/build-module/hooks/style.js +31 -13
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/flow.js +7 -5
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/store/actions.js +52 -45
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +2 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/index.js +1 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +13 -13
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +6 -6
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/index.js +0 -1
- package/build-module/utils/index.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +3 -3
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/utils/pasting.js +80 -0
- package/build-module/utils/pasting.js.map +1 -0
- package/build-module/utils/transform-styles/ast/parse.js +5 -5
- package/build-module/utils/transform-styles/ast/parse.js.map +1 -1
- package/build-module/utils/transform-styles/transforms/url-rewrite.js +2 -2
- package/build-module/utils/transform-styles/transforms/url-rewrite.js.map +1 -1
- package/build-style/style-rtl.css +10 -12
- package/build-style/style.css +10 -12
- package/package.json +27 -26
- package/src/autocompleters/link.js +62 -0
- package/src/autocompleters/style.scss +8 -0
- package/src/components/alignment-control/test/index.js +2 -2
- package/src/components/autocomplete/index.js +2 -0
- package/src/components/block-actions/index.js +1 -1
- package/src/components/block-alignment-control/test/index.js +1 -1
- package/src/components/block-breadcrumb/index.js +5 -2
- package/src/components/block-compare/index.js +2 -2
- package/src/components/block-controls/index.js +1 -1
- package/src/components/block-draggable/index.js +1 -1
- package/src/components/block-draggable/stories/index.js +1 -1
- package/src/components/block-edit/edit.js +1 -1
- package/src/components/block-list/block-html.js +1 -1
- package/src/components/block-list/block-invalid-warning.js +1 -1
- package/src/components/block-list/block-list-item.native.js +4 -4
- package/src/components/block-list/block-selection-button.native.js +3 -3
- package/src/components/block-list/block.js +28 -4
- package/src/components/block-list/block.native.js +7 -6
- package/src/components/block-list/index.native.js +5 -5
- package/src/components/block-list/style.scss +3 -1
- package/src/components/block-list/use-block-props/use-block-class-names.js +1 -1
- package/src/components/block-list/use-block-props/use-focus-first-element.js +3 -0
- package/src/components/block-list/use-block-props/use-multi-selection.js +22 -30
- package/src/components/block-media-update-progress/index.native.js +4 -4
- package/src/components/block-media-update-progress/test/index.native.js +2 -2
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +3 -3
- package/src/components/block-mobile-toolbar/index.native.js +2 -2
- package/src/components/block-mover/mover-description.js +4 -4
- package/src/components/block-mover/mover-description.native.js +5 -5
- package/src/components/block-settings/container.native.js +5 -6
- package/src/components/block-settings-menu/block-settings-dropdown.js +7 -8
- package/src/components/block-styles/preview.native.js +1 -1
- package/src/components/block-switcher/index.js +4 -1
- package/src/components/block-switcher/use-transformed-patterns.js +0 -1
- package/src/components/block-title/README.md +17 -1
- package/src/components/block-title/index.js +7 -62
- package/src/components/block-title/test/index.js +21 -3
- package/src/components/block-title/use-block-display-title.js +83 -0
- package/src/components/block-toolbar/utils.js +12 -2
- package/src/components/block-tools/block-popover.js +1 -1
- package/src/components/block-tools/block-selection-button.js +4 -1
- package/src/components/block-types-list/index.native.js +1 -1
- package/src/components/border-radius-control/index.js +5 -3
- package/src/components/border-radius-control/test/utils.js +10 -10
- package/src/components/border-radius-control/utils.js +10 -8
- package/src/components/contrast-checker/index.js +3 -3
- package/src/components/convert-to-group-buttons/index.js +1 -1
- package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +1 -6
- package/src/components/copy-handler/index.js +2 -2
- package/src/components/font-sizes/with-font-sizes.js +3 -3
- package/src/components/image-size-control/test/index.js +1 -1
- package/src/components/index.js +1 -0
- package/src/components/index.native.js +11 -4
- package/src/components/inserter/block-patterns-tab.js +13 -17
- package/src/components/inserter/block-types-tab.js +1 -1
- package/src/components/inserter/hooks/use-block-type-impressions.native.js +2 -2
- package/src/components/inserter/index.js +3 -3
- package/src/components/inserter/index.native.js +7 -7
- package/src/components/inserter/menu.js +1 -1
- package/src/components/inserter/menu.native.js +3 -3
- package/src/components/inserter/quick-inserter.js +32 -10
- package/src/components/inserter/search-items.js +1 -1
- package/src/components/inserter/search-results.js +55 -43
- package/src/components/inserter/test/fixtures/index.native.js +1 -1
- package/src/components/inserter/test/reusable-blocks-tab.js +2 -2
- package/src/components/justify-content-control/README.md +1 -1
- package/src/components/keyboard-shortcuts/index.js +1 -1
- package/src/components/letter-spacing-control/index.js +1 -1
- package/src/components/line-height-control/README.md +13 -2
- package/src/components/line-height-control/index.js +66 -43
- package/src/components/line-height-control/index.native.js +2 -0
- package/src/components/line-height-control/stories/index.js +33 -0
- package/src/components/line-height-control/test/index.js +61 -0
- package/src/components/link-control/index.js +2 -2
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/link-control/search-results.js +2 -2
- package/src/components/link-control/test/index.js +142 -144
- package/src/components/link-control/use-rich-url-data.js +1 -1
- package/src/components/link-control/use-search-handler.js +2 -2
- package/src/components/list-view/README.md +2 -2
- package/src/components/list-view/block-contents.js +10 -3
- package/src/components/list-view/block-select-button.js +1 -2
- package/src/components/list-view/block.js +30 -10
- package/src/components/list-view/branch.js +1 -0
- package/src/components/list-view/index.js +56 -30
- package/src/components/list-view/test/utils.js +50 -0
- package/src/components/list-view/use-block-selection.js +163 -0
- package/src/components/list-view/use-list-view-expand-selected-item.js +58 -0
- package/src/components/list-view/utils.js +31 -0
- package/src/components/media-placeholder/index.native.js +11 -9
- package/src/components/media-replace-flow/README.md +7 -0
- package/src/components/media-replace-flow/index.js +20 -26
- package/src/components/media-replace-flow/test/index.js +100 -0
- package/src/components/media-upload/index.native.js +3 -2
- package/src/components/media-upload-progress/index.native.js +2 -2
- package/src/components/navigable-toolbar/index.js +3 -3
- package/src/components/plain-text/index.native.js +3 -3
- package/src/components/responsive-block-control/test/index.js +6 -6
- package/src/components/rich-text/format-toolbar-container.js +2 -2
- package/src/components/rich-text/format-toolbar-container.native.js +1 -1
- package/src/components/rich-text/index.js +7 -14
- package/src/components/rich-text/index.native.js +3 -3
- package/src/components/rich-text/use-paste-handler.js +7 -14
- package/src/components/url-input/index.js +11 -11
- package/src/components/use-block-drop-zone/test/index.js +1 -1
- package/src/components/use-moving-animation/index.js +1 -1
- package/src/components/use-on-block-drop/index.js +2 -2
- package/src/components/writing-flow/index.js +1 -0
- package/src/components/writing-flow/use-multi-selection.js +17 -20
- package/src/components/writing-flow/use-select-all.js +6 -2
- package/src/components/writing-flow/use-tab-nav.js +6 -3
- package/src/hooks/align.js +1 -1
- package/src/hooks/anchor.js +1 -1
- package/src/hooks/border.js +8 -19
- package/src/hooks/color.js +2 -2
- package/src/hooks/custom-class-name.js +45 -0
- package/src/hooks/duotone.js +27 -3
- package/src/hooks/generated-class-name.js +3 -3
- package/src/hooks/line-height.js +2 -0
- package/src/hooks/lock.js +1 -1
- package/src/hooks/style.js +31 -13
- package/src/hooks/test/align.js +1 -1
- package/src/hooks/typography.scss +0 -4
- package/src/layouts/flow.js +10 -5
- package/src/store/actions.js +24 -14
- package/src/store/defaults.js +2 -2
- package/src/store/index.js +0 -1
- package/src/store/reducer.js +13 -12
- package/src/store/selectors.js +6 -6
- package/src/store/test/actions.js +2 -2
- package/src/store/test/reducer.js +10 -1
- package/src/store/test/selectors.js +1 -1
- package/src/style.scss +0 -1
- package/src/utils/index.js +0 -1
- package/src/utils/parse-css-unit-to-px.js +3 -3
- package/src/utils/pasting.js +77 -0
- package/src/utils/test/parse-css-unit-to-px.js +5 -5
- package/src/utils/test/pasting.js +84 -0
- package/src/utils/transform-styles/ast/parse.js +5 -5
- package/src/utils/transform-styles/transforms/url-rewrite.js +2 -2
- package/build/utils/get-paste-event-data.js +0 -56
- package/build/utils/get-paste-event-data.js.map +0 -1
- package/build/utils/theme.js +0 -63
- package/build/utils/theme.js.map +0 -1
- package/build-module/utils/get-paste-event-data.js +0 -47
- package/build-module/utils/get-paste-event-data.js.map +0 -1
- package/build-module/utils/theme.js +0 -53
- package/build-module/utils/theme.js.map +0 -1
- package/src/components/line-height-control/style.scss +0 -8
- package/src/components/writing-flow/test/use-multi-selection.js +0 -36
- package/src/utils/get-paste-event-data.js +0 -42
- package/src/utils/theme.js +0 -48
|
@@ -73,7 +73,8 @@ function InserterSearchResults(_ref) {
|
|
|
73
73
|
maxBlockTypes,
|
|
74
74
|
showBlockDirectory = false,
|
|
75
75
|
isDraggable = true,
|
|
76
|
-
shouldFocusBlock = true
|
|
76
|
+
shouldFocusBlock = true,
|
|
77
|
+
prioritizePatterns
|
|
77
78
|
} = _ref;
|
|
78
79
|
const debouncedSpeak = (0, _compose.useDebounce)(_a11y.speak, 500);
|
|
79
80
|
const [destinationRootClientId, onInsertBlocks] = (0, _useInsertionPoint.default)({
|
|
@@ -86,14 +87,28 @@ function InserterSearchResults(_ref) {
|
|
|
86
87
|
});
|
|
87
88
|
const [blockTypes, blockTypeCategories, blockTypeCollections, onSelectBlockType] = (0, _useBlockTypesState.default)(destinationRootClientId, onInsertBlocks);
|
|
88
89
|
const [patterns,, onSelectBlockPattern] = (0, _usePatternsState.default)(onInsertBlocks, destinationRootClientId);
|
|
89
|
-
const filteredBlockTypes = (0, _element.useMemo)(() => {
|
|
90
|
-
const results = (0, _searchItems.searchBlockItems)((0, _lodash.orderBy)(blockTypes, ['frecency'], ['desc']), blockTypeCategories, blockTypeCollections, filterValue);
|
|
91
|
-
return maxBlockTypes !== undefined ? results.slice(0, maxBlockTypes) : results;
|
|
92
|
-
}, [filterValue, blockTypes, blockTypeCategories, blockTypeCollections, maxBlockTypes]);
|
|
93
90
|
const filteredBlockPatterns = (0, _element.useMemo)(() => {
|
|
91
|
+
if (maxBlockPatterns === 0) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
|
|
94
95
|
const results = (0, _searchItems.searchItems)(patterns, filterValue);
|
|
95
96
|
return maxBlockPatterns !== undefined ? results.slice(0, maxBlockPatterns) : results;
|
|
96
|
-
}, [filterValue, patterns, maxBlockPatterns]);
|
|
97
|
+
}, [filterValue, patterns, maxBlockPatterns]);
|
|
98
|
+
let maxBlockTypesToShow = maxBlockTypes;
|
|
99
|
+
|
|
100
|
+
if (prioritizePatterns && filteredBlockPatterns.length > 2) {
|
|
101
|
+
maxBlockTypesToShow = 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const filteredBlockTypes = (0, _element.useMemo)(() => {
|
|
105
|
+
if (maxBlockTypesToShow === 0) {
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const results = (0, _searchItems.searchBlockItems)((0, _lodash.orderBy)(blockTypes, ['frecency'], ['desc']), blockTypeCategories, blockTypeCollections, filterValue);
|
|
110
|
+
return maxBlockTypesToShow !== undefined ? results.slice(0, maxBlockTypesToShow) : results;
|
|
111
|
+
}, [filterValue, blockTypes, blockTypeCategories, blockTypeCollections, maxBlockTypes]); // Announce search results on change.
|
|
97
112
|
|
|
98
113
|
(0, _element.useEffect)(() => {
|
|
99
114
|
if (!filterValue) {
|
|
@@ -111,7 +126,7 @@ function InserterSearchResults(_ref) {
|
|
|
111
126
|
});
|
|
112
127
|
const currentShownPatterns = (0, _compose.useAsyncList)(currentShownBlockTypes.length === filteredBlockTypes.length ? filteredBlockPatterns : EMPTY_ARRAY);
|
|
113
128
|
const hasItems = !(0, _lodash.isEmpty)(filteredBlockTypes) || !(0, _lodash.isEmpty)(filteredBlockPatterns);
|
|
114
|
-
|
|
129
|
+
const blocksUI = !!filteredBlockTypes.length && (0, _element.createElement)(_panel.default, {
|
|
115
130
|
title: (0, _element.createElement)(_components.VisuallyHidden, null, (0, _i18n.__)('Blocks'))
|
|
116
131
|
}, (0, _element.createElement)(_blockTypesList.default, {
|
|
117
132
|
items: currentShownBlockTypes,
|
|
@@ -119,9 +134,8 @@ function InserterSearchResults(_ref) {
|
|
|
119
134
|
onHover: onHover,
|
|
120
135
|
label: (0, _i18n.__)('Blocks'),
|
|
121
136
|
isDraggable: isDraggable
|
|
122
|
-
}))
|
|
123
|
-
|
|
124
|
-
}), !!filteredBlockPatterns.length && (0, _element.createElement)(_panel.default, {
|
|
137
|
+
}));
|
|
138
|
+
const patternsUI = !!filteredBlockPatterns.length && (0, _element.createElement)(_panel.default, {
|
|
125
139
|
title: (0, _element.createElement)(_components.VisuallyHidden, null, (0, _i18n.__)('Block Patterns'))
|
|
126
140
|
}, (0, _element.createElement)("div", {
|
|
127
141
|
className: "block-editor-inserter__quick-inserter-patterns"
|
|
@@ -130,7 +144,10 @@ function InserterSearchResults(_ref) {
|
|
|
130
144
|
blockPatterns: filteredBlockPatterns,
|
|
131
145
|
onClickPattern: onSelectBlockPattern,
|
|
132
146
|
isDraggable: isDraggable
|
|
133
|
-
})))
|
|
147
|
+
})));
|
|
148
|
+
return (0, _element.createElement)(_inserterListbox.default, null, !showBlockDirectory && !hasItems && (0, _element.createElement)(_noResults.default, null), prioritizePatterns ? patternsUI : blocksUI, !!filteredBlockTypes.length && !!filteredBlockPatterns.length && (0, _element.createElement)("div", {
|
|
149
|
+
className: "block-editor-inserter__quick-inserter-separator"
|
|
150
|
+
}), prioritizePatterns ? blocksUI : patternsUI, showBlockDirectory && (0, _element.createElement)(_inserterMenuExtension.default.Slot, {
|
|
134
151
|
fillProps: {
|
|
135
152
|
onSelect: onSelectBlockType,
|
|
136
153
|
onHover,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/search-results.js"],"names":["INITIAL_INSERTER_RESULTS","EMPTY_ARRAY","InserterSearchResults","filterValue","onSelect","onHover","rootClientId","clientId","isAppender","__experimentalInsertionIndex","maxBlockPatterns","maxBlockTypes","showBlockDirectory","isDraggable","shouldFocusBlock","debouncedSpeak","speak","destinationRootClientId","onInsertBlocks","insertionIndex","blockTypes","blockTypeCategories","blockTypeCollections","onSelectBlockType","patterns","onSelectBlockPattern","filteredBlockTypes","results","undefined","slice","filteredBlockPatterns","count","length","resultsFoundMessage","currentShownBlockTypes","step","currentShownPatterns","hasItems","fills"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AAYA,MAAMA,wBAAwB,GAAG,CAAjC;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,WAAW,GAAG,EAApB;;AAEA,SAASC,qBAAT,OAaI;AAAA,MAb4B;AAC/BC,IAAAA,WAD+B;AAE/BC,IAAAA,QAF+B;AAG/BC,IAAAA,OAH+B;AAI/BC,IAAAA,YAJ+B;AAK/BC,IAAAA,QAL+B;AAM/BC,IAAAA,UAN+B;AAO/BC,IAAAA,4BAP+B;AAQ/BC,IAAAA,gBAR+B;AAS/BC,IAAAA,aAT+B;AAU/BC,IAAAA,kBAAkB,GAAG,KAVU;AAW/BC,IAAAA,WAAW,GAAG,IAXiB;AAY/BC,IAAAA,gBAAgB,GAAG;AAZY,GAa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C,IAAA,KAAK,EACJ,4BAAC,0BAAD,QACG,cAAI,gBAAJ,CADH;AAFF,KAOC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,0BAAD;AACC,IAAA,aAAa,EAAGI,oBADjB;AAEC,IAAA,aAAa,EAAGN,qBAFjB;AAGC,IAAA,cAAc,EAAGL,oBAHlB;AAIC,IAAA,WAAW,EAAGZ;AAJf,IADD,CAPD,CAzBF,EA2CGD,kBAAkB,IACnB,4BAAC,8BAAD,CAAiC,IAAjC;AACC,IAAA,SAAS,EAAG;AACXR,MAAAA,QAAQ,EAAEmB,iBADC;AAEXlB,MAAAA,OAFW;AAGXF,MAAAA,WAHW;AAIXkC,MAAAA,QAJW;AAKX/B,MAAAA,YAAY,EAAEW;AALH;AADb,KASKqB,KAAF,IAAa;AACd,QAAKA,KAAK,CAACN,MAAX,EAAoB;AACnB,aAAOM,KAAP;AACA;;AACD,QAAK,CAAED,QAAP,EAAkB;AACjB,aAAO,4BAAC,kBAAD,OAAP;AACA;;AACD,WAAO,IAAP;AACA,GAjBF,CA5CF,CADD;AAmEA;;eAEcnC,qB","sourcesContent":["/**\n * External dependencies\n */\nimport { orderBy, isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { VisuallyHidden } from '@wordpress/components';\nimport { useDebounce, useAsyncList } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesList from '../block-types-list';\nimport BlockPatternsList from '../block-patterns-list';\nimport __unstableInserterMenuExtension from '../inserter-menu-extension';\nimport InserterPanel from './panel';\nimport InserterNoResults from './no-results';\nimport useInsertionPoint from './hooks/use-insertion-point';\nimport usePatternsState from './hooks/use-patterns-state';\nimport useBlockTypesState from './hooks/use-block-types-state';\nimport { searchBlockItems, searchItems } from './search-items';\nimport InserterListbox from '../inserter-listbox';\n\nconst INITIAL_INSERTER_RESULTS = 9;\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation and rerendering the component.\n *\n * @type {Array}\n */\nconst EMPTY_ARRAY = [];\n\nfunction InserterSearchResults( {\n\tfilterValue,\n\tonSelect,\n\tonHover,\n\trootClientId,\n\tclientId,\n\tisAppender,\n\t__experimentalInsertionIndex,\n\tmaxBlockPatterns,\n\tmaxBlockTypes,\n\tshowBlockDirectory = false,\n\tisDraggable = true,\n\tshouldFocusBlock = true,\n} ) {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\tonSelect,\n\t\trootClientId,\n\t\tclientId,\n\t\tisAppender,\n\t\tinsertionIndex: __experimentalInsertionIndex,\n\t\tshouldFocusBlock,\n\t} );\n\tconst [\n\t\tblockTypes,\n\t\tblockTypeCategories,\n\t\tblockTypeCollections,\n\t\tonSelectBlockType,\n\t] = useBlockTypesState( destinationRootClientId, onInsertBlocks );\n\tconst [ patterns, , onSelectBlockPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId\n\t);\n\n\tconst filteredBlockTypes = useMemo( () => {\n\t\tconst results = searchBlockItems(\n\t\t\torderBy( blockTypes, [ 'frecency' ], [ 'desc' ] ),\n\t\t\tblockTypeCategories,\n\t\t\tblockTypeCollections,\n\t\t\tfilterValue\n\t\t);\n\n\t\treturn maxBlockTypes !== undefined\n\t\t\t? results.slice( 0, maxBlockTypes )\n\t\t\t: results;\n\t}, [\n\t\tfilterValue,\n\t\tblockTypes,\n\t\tblockTypeCategories,\n\t\tblockTypeCollections,\n\t\tmaxBlockTypes,\n\t] );\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tconst results = searchItems( patterns, filterValue );\n\t\treturn maxBlockPatterns !== undefined\n\t\t\t? results.slice( 0, maxBlockPatterns )\n\t\t\t: results;\n\t}, [ filterValue, patterns, maxBlockPatterns ] );\n\n\t// Announce search results on change\n\tuseEffect( () => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockTypes.length + filteredBlockPatterns.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ filterValue, debouncedSpeak ] );\n\n\tconst currentShownBlockTypes = useAsyncList( filteredBlockTypes, {\n\t\tstep: INITIAL_INSERTER_RESULTS,\n\t} );\n\tconst currentShownPatterns = useAsyncList(\n\t\tcurrentShownBlockTypes.length === filteredBlockTypes.length\n\t\t\t? filteredBlockPatterns\n\t\t\t: EMPTY_ARRAY\n\t);\n\n\tconst hasItems =\n\t\t! isEmpty( filteredBlockTypes ) || ! isEmpty( filteredBlockPatterns );\n\n\treturn (\n\t\t<InserterListbox>\n\t\t\t{ ! showBlockDirectory && ! hasItems && <InserterNoResults /> }\n\n\t\t\t{ !! filteredBlockTypes.length && (\n\t\t\t\t<InserterPanel\n\t\t\t\t\ttitle={\n\t\t\t\t\t\t<VisuallyHidden>{ __( 'Blocks' ) }</VisuallyHidden>\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<BlockTypesList\n\t\t\t\t\t\titems={ currentShownBlockTypes }\n\t\t\t\t\t\tonSelect={ onSelectBlockType }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\tlabel={ __( 'Blocks' ) }\n\t\t\t\t\t\tisDraggable={ isDraggable }\n\t\t\t\t\t/>\n\t\t\t\t</InserterPanel>\n\t\t\t) }\n\n\t\t\t{ !! filteredBlockTypes.length &&\n\t\t\t\t!! filteredBlockPatterns.length && (\n\t\t\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\t\t\t\t) }\n\n\t\t\t{ !! filteredBlockPatterns.length && (\n\t\t\t\t<InserterPanel\n\t\t\t\t\ttitle={\n\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t{ __( 'Block Patterns' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<div className=\"block-editor-inserter__quick-inserter-patterns\">\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tshownPatterns={ currentShownPatterns }\n\t\t\t\t\t\t\tblockPatterns={ filteredBlockPatterns }\n\t\t\t\t\t\t\tonClickPattern={ onSelectBlockPattern }\n\t\t\t\t\t\t\tisDraggable={ isDraggable }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</InserterPanel>\n\t\t\t) }\n\n\t\t\t{ showBlockDirectory && (\n\t\t\t\t<__unstableInserterMenuExtension.Slot\n\t\t\t\t\tfillProps={ {\n\t\t\t\t\t\tonSelect: onSelectBlockType,\n\t\t\t\t\t\tonHover,\n\t\t\t\t\t\tfilterValue,\n\t\t\t\t\t\thasItems,\n\t\t\t\t\t\trootClientId: destinationRootClientId,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ ( fills ) => {\n\t\t\t\t\t\tif ( fills.length ) {\n\t\t\t\t\t\t\treturn fills;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( ! hasItems ) {\n\t\t\t\t\t\t\treturn <InserterNoResults />;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t} }\n\t\t\t\t</__unstableInserterMenuExtension.Slot>\n\t\t\t) }\n\t\t</InserterListbox>\n\t);\n}\n\nexport default InserterSearchResults;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/search-results.js"],"names":["INITIAL_INSERTER_RESULTS","EMPTY_ARRAY","InserterSearchResults","filterValue","onSelect","onHover","rootClientId","clientId","isAppender","__experimentalInsertionIndex","maxBlockPatterns","maxBlockTypes","showBlockDirectory","isDraggable","shouldFocusBlock","prioritizePatterns","debouncedSpeak","speak","destinationRootClientId","onInsertBlocks","insertionIndex","blockTypes","blockTypeCategories","blockTypeCollections","onSelectBlockType","patterns","onSelectBlockPattern","filteredBlockPatterns","results","undefined","slice","maxBlockTypesToShow","length","filteredBlockTypes","count","resultsFoundMessage","currentShownBlockTypes","step","currentShownPatterns","hasItems","blocksUI","patternsUI","fills"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AAYA,MAAMA,wBAAwB,GAAG,CAAjC;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,WAAW,GAAG,EAApB;;AAEA,SAASC,qBAAT,OAcI;AAAA,MAd4B;AAC/BC,IAAAA,WAD+B;AAE/BC,IAAAA,QAF+B;AAG/BC,IAAAA,OAH+B;AAI/BC,IAAAA,YAJ+B;AAK/BC,IAAAA,QAL+B;AAM/BC,IAAAA,UAN+B;AAO/BC,IAAAA,4BAP+B;AAQ/BC,IAAAA,gBAR+B;AAS/BC,IAAAA,aAT+B;AAU/BC,IAAAA,kBAAkB,GAAG,KAVU;AAW/BC,IAAAA,WAAW,GAAG,IAXiB;AAY/BC,IAAAA,gBAAgB,GAAG,IAZY;AAa/BC,IAAAA;AAb+B,GAc5B;AACH,QAAMC,cAAc,GAAG,0BAAaC,WAAb,EAAoB,GAApB,CAAvB;AAEA,QAAM,CAAEC,uBAAF,EAA2BC,cAA3B,IAA8C,gCAAmB;AACtEf,IAAAA,QADsE;AAEtEE,IAAAA,YAFsE;AAGtEC,IAAAA,QAHsE;AAItEC,IAAAA,UAJsE;AAKtEY,IAAAA,cAAc,EAAEX,4BALsD;AAMtEK,IAAAA;AANsE,GAAnB,CAApD;AAQA,QAAM,CACLO,UADK,EAELC,mBAFK,EAGLC,oBAHK,EAILC,iBAJK,IAKF,iCAAoBN,uBAApB,EAA6CC,cAA7C,CALJ;AAMA,QAAM,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AD,QACG,CAAED,kBAAF,IAAwB,CAAE2B,QAA1B,IAAsC,4BAAC,kBAAD,OADzC,EAGGxB,kBAAkB,GAAG0B,UAAH,GAAgBD,QAHrC,EAKG,CAAC,CAAEP,kBAAkB,CAACD,MAAtB,IACD,CAAC,CAAEL,qBAAqB,CAACK,MADxB,IAEA;AAAK,IAAA,SAAS,EAAC;AAAf,IAPH,EAUGjB,kBAAkB,GAAGyB,QAAH,GAAcC,UAVnC,EAYG7B,kBAAkB,IACnB,4BAAC,8BAAD,CAAiC,IAAjC;AACC,IAAA,SAAS,EAAG;AACXR,MAAAA,QAAQ,EAAEoB,iBADC;AAEXnB,MAAAA,OAFW;AAGXF,MAAAA,WAHW;AAIXoC,MAAAA,QAJW;AAKXjC,MAAAA,YAAY,EAAEY;AALH;AADb,KASKwB,KAAF,IAAa;AACd,QAAKA,KAAK,CAACV,MAAX,EAAoB;AACnB,aAAOU,KAAP;AACA;;AACD,QAAK,CAAEH,QAAP,EAAkB;AACjB,aAAO,4BAAC,kBAAD,OAAP;AACA;;AACD,WAAO,IAAP;AACA,GAjBF,CAbF,CADD;AAoCA;;eAEcrC,qB","sourcesContent":["/**\n * External dependencies\n */\nimport { orderBy, isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { VisuallyHidden } from '@wordpress/components';\nimport { useDebounce, useAsyncList } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesList from '../block-types-list';\nimport BlockPatternsList from '../block-patterns-list';\nimport __unstableInserterMenuExtension from '../inserter-menu-extension';\nimport InserterPanel from './panel';\nimport InserterNoResults from './no-results';\nimport useInsertionPoint from './hooks/use-insertion-point';\nimport usePatternsState from './hooks/use-patterns-state';\nimport useBlockTypesState from './hooks/use-block-types-state';\nimport { searchBlockItems, searchItems } from './search-items';\nimport InserterListbox from '../inserter-listbox';\n\nconst INITIAL_INSERTER_RESULTS = 9;\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation and rerendering the component.\n *\n * @type {Array}\n */\nconst EMPTY_ARRAY = [];\n\nfunction InserterSearchResults( {\n\tfilterValue,\n\tonSelect,\n\tonHover,\n\trootClientId,\n\tclientId,\n\tisAppender,\n\t__experimentalInsertionIndex,\n\tmaxBlockPatterns,\n\tmaxBlockTypes,\n\tshowBlockDirectory = false,\n\tisDraggable = true,\n\tshouldFocusBlock = true,\n\tprioritizePatterns,\n} ) {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\tonSelect,\n\t\trootClientId,\n\t\tclientId,\n\t\tisAppender,\n\t\tinsertionIndex: __experimentalInsertionIndex,\n\t\tshouldFocusBlock,\n\t} );\n\tconst [\n\t\tblockTypes,\n\t\tblockTypeCategories,\n\t\tblockTypeCollections,\n\t\tonSelectBlockType,\n\t] = useBlockTypesState( destinationRootClientId, onInsertBlocks );\n\tconst [ patterns, , onSelectBlockPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId\n\t);\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tif ( maxBlockPatterns === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst results = searchItems( patterns, filterValue );\n\t\treturn maxBlockPatterns !== undefined\n\t\t\t? results.slice( 0, maxBlockPatterns )\n\t\t\t: results;\n\t}, [ filterValue, patterns, maxBlockPatterns ] );\n\n\tlet maxBlockTypesToShow = maxBlockTypes;\n\tif ( prioritizePatterns && filteredBlockPatterns.length > 2 ) {\n\t\tmaxBlockTypesToShow = 0;\n\t}\n\n\tconst filteredBlockTypes = useMemo( () => {\n\t\tif ( maxBlockTypesToShow === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst results = searchBlockItems(\n\t\t\torderBy( blockTypes, [ 'frecency' ], [ 'desc' ] ),\n\t\t\tblockTypeCategories,\n\t\t\tblockTypeCollections,\n\t\t\tfilterValue\n\t\t);\n\n\t\treturn maxBlockTypesToShow !== undefined\n\t\t\t? results.slice( 0, maxBlockTypesToShow )\n\t\t\t: results;\n\t}, [\n\t\tfilterValue,\n\t\tblockTypes,\n\t\tblockTypeCategories,\n\t\tblockTypeCollections,\n\t\tmaxBlockTypes,\n\t] );\n\n\t// Announce search results on change.\n\tuseEffect( () => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockTypes.length + filteredBlockPatterns.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ filterValue, debouncedSpeak ] );\n\n\tconst currentShownBlockTypes = useAsyncList( filteredBlockTypes, {\n\t\tstep: INITIAL_INSERTER_RESULTS,\n\t} );\n\tconst currentShownPatterns = useAsyncList(\n\t\tcurrentShownBlockTypes.length === filteredBlockTypes.length\n\t\t\t? filteredBlockPatterns\n\t\t\t: EMPTY_ARRAY\n\t);\n\n\tconst hasItems =\n\t\t! isEmpty( filteredBlockTypes ) || ! isEmpty( filteredBlockPatterns );\n\n\tconst blocksUI = !! filteredBlockTypes.length && (\n\t\t<InserterPanel\n\t\t\ttitle={ <VisuallyHidden>{ __( 'Blocks' ) }</VisuallyHidden> }\n\t\t>\n\t\t\t<BlockTypesList\n\t\t\t\titems={ currentShownBlockTypes }\n\t\t\t\tonSelect={ onSelectBlockType }\n\t\t\t\tonHover={ onHover }\n\t\t\t\tlabel={ __( 'Blocks' ) }\n\t\t\t\tisDraggable={ isDraggable }\n\t\t\t/>\n\t\t</InserterPanel>\n\t);\n\n\tconst patternsUI = !! filteredBlockPatterns.length && (\n\t\t<InserterPanel\n\t\t\ttitle={\n\t\t\t\t<VisuallyHidden>{ __( 'Block Patterns' ) }</VisuallyHidden>\n\t\t\t}\n\t\t>\n\t\t\t<div className=\"block-editor-inserter__quick-inserter-patterns\">\n\t\t\t\t<BlockPatternsList\n\t\t\t\t\tshownPatterns={ currentShownPatterns }\n\t\t\t\t\tblockPatterns={ filteredBlockPatterns }\n\t\t\t\t\tonClickPattern={ onSelectBlockPattern }\n\t\t\t\t\tisDraggable={ isDraggable }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</InserterPanel>\n\t);\n\n\treturn (\n\t\t<InserterListbox>\n\t\t\t{ ! showBlockDirectory && ! hasItems && <InserterNoResults /> }\n\n\t\t\t{ prioritizePatterns ? patternsUI : blocksUI }\n\n\t\t\t{ !! filteredBlockTypes.length &&\n\t\t\t\t!! filteredBlockPatterns.length && (\n\t\t\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\t\t\t\t) }\n\n\t\t\t{ prioritizePatterns ? blocksUI : patternsUI }\n\n\t\t\t{ showBlockDirectory && (\n\t\t\t\t<__unstableInserterMenuExtension.Slot\n\t\t\t\t\tfillProps={ {\n\t\t\t\t\t\tonSelect: onSelectBlockType,\n\t\t\t\t\t\tonHover,\n\t\t\t\t\t\tfilterValue,\n\t\t\t\t\t\thasItems,\n\t\t\t\t\t\trootClientId: destinationRootClientId,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ ( fills ) => {\n\t\t\t\t\t\tif ( fills.length ) {\n\t\t\t\t\t\t\treturn fills;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( ! hasItems ) {\n\t\t\t\t\t\t\treturn <InserterNoResults />;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t} }\n\t\t\t\t</__unstableInserterMenuExtension.Slot>\n\t\t\t) }\n\t\t</InserterListbox>\n\t);\n}\n\nexport default InserterSearchResults;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/keyboard-shortcuts/index.js"],"names":["KeyboardShortcuts","KeyboardShortcutsRegister","registerShortcut","keyboardShortcutsStore","name","category","description","keyCombination","modifier","character","aliases","Register"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,SAASA,iBAAT,GAA6B;AAC5B,SAAO,IAAP;AACA;;AAED,SAASC,yBAAT,GAAqC;AACpC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAuB,uBAAaC,wBAAb,CAA7B;AACA,0BAAW,MAAM;AAChBD,IAAAA,gBAAgB,CAAE;AACjBE,MAAAA,IAAI,EAAE,6BADW;AAEjBC,MAAAA,QAAQ,EAAE,OAFO;AAGjBC,MAAAA,WAAW,EAAE,cAAI,kCAAJ,CAHI;AAIjBC,MAAAA,cAAc,EAAE;AACfC,QAAAA,QAAQ,EAAE,cADK;AAEfC,QAAAA,SAAS,EAAE;AAFI;AAJC,KAAF,CAAhB;AAUAP,IAAAA,gBAAgB,CAAE;AACjBE,MAAAA,IAAI,EAAE,0BADW;AAEjBC,MAAAA,QAAQ,EAAE,OAFO;AAGjBC,MAAAA,WAAW,EAAE,cAAI,+BAAJ,CAHI;AAIjBC,MAAAA,cAAc,EAAE;AACfC,QAAAA,QAAQ,EAAE,QADK;AAEfC,QAAAA,SAAS,EAAE;AAFI;AAJC,KAAF,CAAhB;AAUAP,IAAAA,gBAAgB,CAAE;AACjBE,MAAAA,IAAI,EAAE,iCADW;AAEjBC,MAAAA,QAAQ,EAAE,OAFO;AAGjBC,MAAAA,WAAW,EAAE,cACZ,kDADY,CAHI;AAMjBC,MAAAA,cAAc,EAAE;AACfC,QAAAA,QAAQ,EAAE,YADK;AAEfC,QAAAA,SAAS,EAAE;AAFI;AANC,KAAF,CAAhB;AAYAP,IAAAA,gBAAgB,CAAE;AACjBE,MAAAA,IAAI,EAAE,gCADW;AAEjBC,MAAAA,QAAQ,EAAE,OAFO;AAGjBC,MAAAA,WAAW,EAAE,cACZ,iDADY,CAHI;AAMjBC,MAAAA,cAAc,EAAE;AACfC,QAAAA,QAAQ,E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IjBC,MAAAA,cAAc,EAAE;AACfC,QAAAA,QAAQ,EAAE,WADK;AAEfC,QAAAA,SAAS,EAAE;AAFI;AAJC,KAAF,CAAhB;AAUAP,IAAAA,gBAAgB,CAAE;AACjBE,MAAAA,IAAI,EAAE,6BADW;AAEjBC,MAAAA,QAAQ,EAAE,OAFO;AAGjBC,MAAAA,WAAW,EAAE,cAAI,kCAAJ,CAHI;AAIjBC,MAAAA,cAAc,EAAE;AACfC,QAAAA,QAAQ,EAAE,WADK;AAEfC,QAAAA,SAAS,EAAE;AAFI;AAJC,KAAF,CAAhB;AASA,GA7GD,EA6GG,CAAEP,gBAAF,CA7GH;AA+GA,SAAO,IAAP;AACA;;AAEDF,iBAAiB,CAACW,QAAlB,GAA6BV,yBAA7B;eAEeD,iB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { __ } from '@wordpress/i18n';\n\nfunction KeyboardShortcuts() {\n\treturn null;\n}\n\nfunction KeyboardShortcutsRegister() {\n\t// Registering the shortcuts
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/keyboard-shortcuts/index.js"],"names":["KeyboardShortcuts","KeyboardShortcutsRegister","registerShortcut","keyboardShortcutsStore","name","category","description","keyCombination","modifier","character","aliases","Register"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,SAASA,iBAAT,GAA6B;AAC5B,SAAO,IAAP;AACA;;AAED,SAASC,yBAAT,GAAqC;AACpC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAuB,uBAAaC,wBAAb,CAA7B;AACA,0BAAW,MAAM;AAChBD,IAAAA,gBAAgB,CAAE;AACjBE,MAAAA,IAAI,EAAE,6BADW;AAEjBC,MAAAA,QAAQ,EAAE,OAFO;AAGjBC,MAAAA,WAAW,EAAE,cAAI,kCAAJ,CAHI;AAIj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;AAEDF,iBAAiB,CAACW,QAAlB,GAA6BV,yBAA7B;eAEeD,iB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { __ } from '@wordpress/i18n';\n\nfunction KeyboardShortcuts() {\n\treturn null;\n}\n\nfunction KeyboardShortcutsRegister() {\n\t// Registering the shortcuts.\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/block-editor/duplicate',\n\t\t\tcategory: 'block',\n\t\t\tdescription: __( 'Duplicate the selected block(s).' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryShift',\n\t\t\t\tcharacter: 'd',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/block-editor/remove',\n\t\t\tcategory: 'block',\n\t\t\tdescription: __( 'Remove the selected block(s).' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/block-editor/insert-before',\n\t\t\tcategory: 'block',\n\t\t\tdescription: __(\n\t\t\t\t'Insert a new block before the selected block(s).'\n\t\t\t),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryAlt',\n\t\t\t\tcharacter: 't',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/block-editor/insert-after',\n\t\t\tcategory: 'block',\n\t\t\tdescription: __(\n\t\t\t\t'Insert a new block after the selected block(s).'\n\t\t\t),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryAlt',\n\t\t\t\tcharacter: 'y',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/block-editor/delete-multi-selection',\n\t\t\tcategory: 'block',\n\t\t\tdescription: __( 'Remove multiple selected blocks.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tcharacter: 'del',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tcharacter: 'backspace',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/block-editor/select-all',\n\t\t\tcategory: 'selection',\n\t\t\tdescription: __(\n\t\t\t\t'Select all text when typing. Press again to select all blocks.'\n\t\t\t),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'a',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/block-editor/unselect',\n\t\t\tcategory: 'selection',\n\t\t\tdescription: __( 'Clear selection.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tcharacter: 'escape',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/block-editor/focus-toolbar',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the nearest toolbar.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'alt',\n\t\t\t\tcharacter: 'F10',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/block-editor/move-up',\n\t\t\tcategory: 'block',\n\t\t\tdescription: __( 'Move the selected block(s) up.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'secondary',\n\t\t\t\tcharacter: 't',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/block-editor/move-down',\n\t\t\tcategory: 'block',\n\t\t\tdescription: __( 'Move the selected block(s) down.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'secondary',\n\t\t\t\tcharacter: 'y',\n\t\t\t},\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\treturn null;\n}\n\nKeyboardShortcuts.Register = KeyboardShortcutsRegister;\n\nexport default KeyboardShortcuts;\n"]}
|
|
@@ -42,9 +42,9 @@ function LetterSpacingControl(_ref) {
|
|
|
42
42
|
const units = (0, _components.__experimentalUseCustomUnits)({
|
|
43
43
|
availableUnits: (0, _useSetting.default)('spacing.units') || ['px', 'em', 'rem'],
|
|
44
44
|
defaultValues: {
|
|
45
|
-
px:
|
|
46
|
-
em:
|
|
47
|
-
rem:
|
|
45
|
+
px: 2,
|
|
46
|
+
em: 0.2,
|
|
47
|
+
rem: 0.2
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
return (0, _element.createElement)(_components.__experimentalUnitControl, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/letter-spacing-control/index.js"],"names":["LetterSpacingControl","value","onChange","__unstableInputWidth","units","availableUnits","defaultValues","px","em","rem"],"mappings":";;;;;;;;;;;AAGA;;AAIA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,oBAAT,OAIX;AAAA,MAJ0C;AAC7CC,IAAAA,KAD6C;AAE7CC,IAAAA,QAF6C;AAG7CC,IAAAA,oBAAoB,GAAG;AAHsB,GAI1C;AACH,QAAMC,KAAK,GAAG,8CAAgB;AAC7BC,IAAAA,cAAc,EAAE,yBAAY,eAAZ,KAAiC,CAAE,IAAF,EAAQ,IAAR,EAAc,KAAd,CADpB;AAE7BC,IAAAA,aAAa,EAAE;AAAEC,MAAAA,EAAE,EAAE,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/letter-spacing-control/index.js"],"names":["LetterSpacingControl","value","onChange","__unstableInputWidth","units","availableUnits","defaultValues","px","em","rem"],"mappings":";;;;;;;;;;;AAGA;;AAIA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,oBAAT,OAIX;AAAA,MAJ0C;AAC7CC,IAAAA,KAD6C;AAE7CC,IAAAA,QAF6C;AAG7CC,IAAAA,oBAAoB,GAAG;AAHsB,GAI1C;AACH,QAAMC,KAAK,GAAG,8CAAgB;AAC7BC,IAAAA,cAAc,EAAE,yBAAY,eAAZ,KAAiC,CAAE,IAAF,EAAQ,IAAR,EAAc,KAAd,CADpB;AAE7BC,IAAAA,aAAa,EAAE;AAAEC,MAAAA,EAAE,EAAE,CAAN;AAASC,MAAAA,EAAE,EAAE,GAAb;AAAkBC,MAAAA,GAAG,EAAE;AAAvB;AAFc,GAAhB,CAAd;AAIA,SACC,4BAAC,qCAAD;AACC,IAAA,KAAK,EAAG,cAAI,gBAAJ,CADT;AAEC,IAAA,KAAK,EAAGR,KAFT;AAGC,IAAA,oBAAoB,EAAGE,oBAHxB;AAIC,IAAA,KAAK,EAAGC,KAJT;AAKC,IAAA,QAAQ,EAAGF;AALZ,IADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../../components/use-setting';\n\n/**\n * Control for letter-spacing.\n *\n * @param {Object} props Component props.\n * @param {string} props.value Currently selected letter-spacing.\n * @param {Function} props.onChange Handles change in letter-spacing selection.\n * @param {string|number|undefined} props.__unstableInputWidth Input width to pass through to inner UnitControl. Should be a valid CSS value.\n *\n * @return {WPElement} Letter-spacing control.\n */\nexport default function LetterSpacingControl( {\n\tvalue,\n\tonChange,\n\t__unstableInputWidth = '60px',\n} ) {\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [ 'px', 'em', 'rem' ],\n\t\tdefaultValues: { px: 2, em: 0.2, rem: 0.2 },\n\t} );\n\treturn (\n\t\t<UnitControl\n\t\t\tlabel={ __( 'Letter spacing' ) }\n\t\t\tvalue={ value }\n\t\t\t__unstableInputWidth={ __unstableInputWidth }\n\t\t\tunits={ units }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -7,12 +9,12 @@ exports.default = LineHeightControl;
|
|
|
7
9
|
|
|
8
10
|
var _element = require("@wordpress/element");
|
|
9
11
|
|
|
12
|
+
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
|
13
|
+
|
|
10
14
|
var _i18n = require("@wordpress/i18n");
|
|
11
15
|
|
|
12
16
|
var _components = require("@wordpress/components");
|
|
13
17
|
|
|
14
|
-
var _keycodes = require("@wordpress/keycodes");
|
|
15
|
-
|
|
16
18
|
var _utils = require("./utils");
|
|
17
19
|
|
|
18
20
|
/**
|
|
@@ -25,68 +27,84 @@ var _utils = require("./utils");
|
|
|
25
27
|
function LineHeightControl(_ref) {
|
|
26
28
|
let {
|
|
27
29
|
value: lineHeight,
|
|
28
|
-
onChange
|
|
30
|
+
onChange,
|
|
31
|
+
|
|
32
|
+
/** Start opting into the new margin-free styles that will become the default in a future version. */
|
|
33
|
+
__nextHasNoMarginBottom = false,
|
|
34
|
+
__unstableInputWidth = '60px'
|
|
29
35
|
} = _ref;
|
|
30
36
|
const isDefined = (0, _utils.isLineHeightDefined)(lineHeight);
|
|
31
37
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} = event;
|
|
36
|
-
|
|
37
|
-
if (keyCode === _keycodes.ZERO && !isDefined) {
|
|
38
|
-
/**
|
|
39
|
-
* Prevents the onChange callback from firing, which prevents
|
|
40
|
-
* the logic from assuming the change was triggered from
|
|
41
|
-
* an input arrow CLICK.
|
|
42
|
-
*/
|
|
43
|
-
event.preventDefault();
|
|
44
|
-
onChange('0');
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const handleOnChange = nextValue => {
|
|
49
|
-
// Set the next value without modification if lineHeight has been defined
|
|
50
|
-
if (isDefined) {
|
|
51
|
-
onChange(nextValue);
|
|
52
|
-
return;
|
|
53
|
-
} // Otherwise...
|
|
54
|
-
|
|
38
|
+
const adjustNextValue = (nextValue, wasTypedOrPasted) => {
|
|
39
|
+
// Set the next value without modification if lineHeight has been defined.
|
|
40
|
+
if (isDefined) return nextValue;
|
|
55
41
|
/**
|
|
56
|
-
* The following logic handles the initial up/down
|
|
57
|
-
*
|
|
58
|
-
*
|
|
42
|
+
* The following logic handles the initial step up/down action
|
|
43
|
+
* (from an undefined value state) so that the next values are better suited for
|
|
44
|
+
* line-height rendering. For example, the first step up should immediately
|
|
45
|
+
* go to 1.6, rather than the normally expected 0.1.
|
|
46
|
+
*
|
|
47
|
+
* Step up/down actions can be triggered by keydowns of the up/down arrow keys,
|
|
48
|
+
* or by clicking the spin buttons.
|
|
59
49
|
*/
|
|
60
50
|
|
|
61
|
-
|
|
62
|
-
let adjustedNextValue = nextValue;
|
|
63
|
-
|
|
64
51
|
switch (nextValue) {
|
|
65
52
|
case `${_utils.STEP}`:
|
|
66
|
-
// Increment by step value
|
|
67
|
-
|
|
68
|
-
break;
|
|
53
|
+
// Increment by step value.
|
|
54
|
+
return _utils.BASE_DEFAULT_VALUE + _utils.STEP;
|
|
69
55
|
|
|
70
56
|
case '0':
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
57
|
+
{
|
|
58
|
+
// This means the user explicitly input '0', rather than stepped down
|
|
59
|
+
// from an undefined value state.
|
|
60
|
+
if (wasTypedOrPasted) return nextValue; // Decrement by step value.
|
|
61
|
+
|
|
62
|
+
return _utils.BASE_DEFAULT_VALUE - _utils.STEP;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
case '':
|
|
66
|
+
return _utils.BASE_DEFAULT_VALUE;
|
|
67
|
+
|
|
68
|
+
default:
|
|
69
|
+
return nextValue;
|
|
74
70
|
}
|
|
71
|
+
};
|
|
75
72
|
|
|
76
|
-
|
|
73
|
+
const stateReducer = (state, action) => {
|
|
74
|
+
var _action$payload$event;
|
|
75
|
+
|
|
76
|
+
// Be careful when changing this — cross-browser behavior of the
|
|
77
|
+
// `inputType` field in `input` events are inconsistent.
|
|
78
|
+
// For example, Firefox emits an input event with inputType="insertReplacementText"
|
|
79
|
+
// on spin button clicks, while other browsers do not even emit an input event.
|
|
80
|
+
const wasTypedOrPasted = ['insertText', 'insertFromPaste'].includes((_action$payload$event = action.payload.event.nativeEvent) === null || _action$payload$event === void 0 ? void 0 : _action$payload$event.inputType);
|
|
81
|
+
state.value = adjustNextValue(state.value, wasTypedOrPasted);
|
|
82
|
+
return state;
|
|
77
83
|
};
|
|
78
84
|
|
|
79
85
|
const value = isDefined ? lineHeight : _utils.RESET_VALUE;
|
|
86
|
+
|
|
87
|
+
if (!__nextHasNoMarginBottom) {
|
|
88
|
+
(0, _deprecated.default)('Bottom margin styles for wp.blockEditor.LineHeightControl', {
|
|
89
|
+
since: '6.0',
|
|
90
|
+
version: '6.4',
|
|
91
|
+
hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version'
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const deprecatedStyles = __nextHasNoMarginBottom ? undefined : {
|
|
96
|
+
marginBottom: 24
|
|
97
|
+
};
|
|
80
98
|
return (0, _element.createElement)("div", {
|
|
81
|
-
className: "block-editor-line-height-control"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
99
|
+
className: "block-editor-line-height-control",
|
|
100
|
+
style: deprecatedStyles
|
|
101
|
+
}, (0, _element.createElement)(_components.__experimentalNumberControl, {
|
|
102
|
+
__unstableInputWidth: __unstableInputWidth,
|
|
103
|
+
__unstableStateReducer: stateReducer,
|
|
104
|
+
onChange: onChange,
|
|
86
105
|
label: (0, _i18n.__)('Line height'),
|
|
87
106
|
placeholder: _utils.BASE_DEFAULT_VALUE,
|
|
88
107
|
step: _utils.STEP,
|
|
89
|
-
type: "number",
|
|
90
108
|
value: value,
|
|
91
109
|
min: 0
|
|
92
110
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/line-height-control/index.js"],"names":["LineHeightControl","value","lineHeight","onChange","isDefined","
|
|
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;AAQe,SAASA,iBAAT,OAMX;AAAA,MANuC;AAC1CC,IAAAA,KAAK,EAAEC,UADmC;AAE1CC,IAAAA,QAF0C;;AAG1C;AACAC,IAAAA,uBAAuB,GAAG,KAJgB;AAK1CC,IAAAA,oBAAoB,GAAG;AALmB,GAMvC;AACH,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,YAASA,SAAT;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;AAGAN,IAAAA,KAAK,CAACZ,KAAN,GAAcM,eAAe,CAAEM,KAAK,CAACZ,KAAR,EAAeQ,gBAAf,CAA7B;AACA,WAAOI,KAAP;AACA,GAVD;;AAYA,QAAMZ,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,EACH;AAJF,KAFD;AASA;;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","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\nexport default function 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\tstate.value = adjustNextValue( state.value, wasTypedOrPasted );\n\t\treturn state;\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:\n\t\t\t\t\t'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"]}
|
|
@@ -34,7 +34,9 @@ function LineHeightControl(_ref) {
|
|
|
34
34
|
max: 5,
|
|
35
35
|
step: _utils.STEP,
|
|
36
36
|
value: value,
|
|
37
|
-
onChange: onChange
|
|
37
|
+
onChange: onChange // TODO: should be updated to avoid using `false`, in order to
|
|
38
|
+
// align with the web version of `UnitControl`
|
|
39
|
+
,
|
|
38
40
|
units: false
|
|
39
41
|
});
|
|
40
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/line-height-control/index.native.js"],"names":["LineHeightControl","value","lineHeight","onChange","isDefined","BASE_DEFAULT_VALUE","STEP"],"mappings":";;;;;;;;;AAGA;;AACA;;AAIA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGe,SAASA,iBAAT,OAA8D;AAAA,MAAlC;AAAEC,IAAAA,KAAK,EAAEC,UAAT;AAAqBC,IAAAA;AAArB,GAAkC;AAC5E,QAAMC,SAAS,GAAG,gCAAqBF,UAArB,CAAlB;AACA,QAAMD,KAAK,GAAGG,SAAS,GAAGF,UAAH,GAAgBG,yBAAvC;AACA,SACC,4BAAC,uBAAD;AACC,IAAA,KAAK,EAAG,cAAI,aAAJ,CADT,CAEC;AAFD;AAGC,IAAA,GAAG,EAAG,CAHP;AAIC,IAAA,GAAG,EAAG,CAJP;AAKC,IAAA,IAAI,EAAGC,WALR;AAMC,IAAA,KAAK,EAAGL,KANT;AAOC,IAAA,QAAQ,EAAGE,QAPZ;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/line-height-control/index.native.js"],"names":["LineHeightControl","value","lineHeight","onChange","isDefined","BASE_DEFAULT_VALUE","STEP"],"mappings":";;;;;;;;;AAGA;;AACA;;AAIA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGe,SAASA,iBAAT,OAA8D;AAAA,MAAlC;AAAEC,IAAAA,KAAK,EAAEC,UAAT;AAAqBC,IAAAA;AAArB,GAAkC;AAC5E,QAAMC,SAAS,GAAG,gCAAqBF,UAArB,CAAlB;AACA,QAAMD,KAAK,GAAGG,SAAS,GAAGF,UAAH,GAAgBG,yBAAvC;AACA,SACC,4BAAC,uBAAD;AACC,IAAA,KAAK,EAAG,cAAI,aAAJ,CADT,CAEC;AAFD;AAGC,IAAA,GAAG,EAAG,CAHP;AAIC,IAAA,GAAG,EAAG,CAJP;AAKC,IAAA,IAAI,EAAGC,WALR;AAMC,IAAA,KAAK,EAAGL,KANT;AAOC,IAAA,QAAQ,EAAGE,QAPZ,CAQC;AACA;AATD;AAUC,IAAA,KAAK,EAAG;AAVT,IADD;AAcA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { UnitControl } from '@wordpress/components';\n/**\n * Internal dependencies\n */\nimport { BASE_DEFAULT_VALUE, STEP, isLineHeightDefined } from './utils';\n\nexport default function LineHeightControl( { value: lineHeight, onChange } ) {\n\tconst isDefined = isLineHeightDefined( lineHeight );\n\tconst value = isDefined ? lineHeight : BASE_DEFAULT_VALUE;\n\treturn (\n\t\t<UnitControl\n\t\t\tlabel={ __( 'Line Height' ) }\n\t\t\t// Set minimun value of 1 since lower values break on Android\n\t\t\tmin={ 1 }\n\t\t\tmax={ 5 }\n\t\t\tstep={ STEP }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\t// TODO: should be updated to avoid using `false`, in order to\n\t\t\t// align with the web version of `UnitControl`\n\t\t\tunits={ false }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -254,7 +254,7 @@ function LinkControl(_ref) {
|
|
|
254
254
|
keyCode
|
|
255
255
|
} = event;
|
|
256
256
|
|
|
257
|
-
if (keyCode === _keycodes.ENTER && !currentInputIsEmpty //
|
|
257
|
+
if (keyCode === _keycodes.ENTER && !currentInputIsEmpty // Disallow submitting empty values.
|
|
258
258
|
) {
|
|
259
259
|
event.preventDefault();
|
|
260
260
|
handleSubmit();
|
|
@@ -308,7 +308,7 @@ function LinkControl(_ref) {
|
|
|
308
308
|
label: (0, _i18n.__)('Submit'),
|
|
309
309
|
icon: _icons.keyboardReturn,
|
|
310
310
|
className: "block-editor-link-control__search-submit",
|
|
311
|
-
disabled: currentInputIsEmpty //
|
|
311
|
+
disabled: currentInputIsEmpty // Disallow submitting empty values.
|
|
312
312
|
|
|
313
313
|
})))), errorMessage && (0, _element.createElement)(_components.Notice, {
|
|
314
314
|
className: "block-editor-link-control__search-error",
|
|
@@ -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","current","whichFocusTargetIndex","nextFocusTarget","focus","focusable","find","stopEditing","contains","ownerDocument","activeElement","createPage","isCreatingPage","errorMessage","handleSelectSuggestion","updatedValue","handleSubmit","handleSubmitWithEnter","event","keyCode","ENTER","preventDefault","shownUnlinkControl","showSettingsDrawer","showTextControl","keyboardReturn","ViewerFill"],"mappings":";;;;;;;;;AAYA;;AATA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAxBA;AACA;AACA;;AAIA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAT,OAmBI;AAAA;;AAAA,MAnBkB;AACrBC,IAAAA,sBADqB;AAErBC,IAAAA,KAFqB;AAGrBC,IAAAA,QAAQ,GAAGC,gCAHU;AAIrBC,IAAAA,QAAQ,GAAGC,YAJU;AAKrBC,IAAAA,QALqB;AAMrBC,IAAAA,aAAa,GAAG,KANK;AAOrBC,IAAAA,eAAe,GAAG,IAPG;AAQrBC,IAAA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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\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 ] );\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 { createPage, isCreatingPage, errorMessage } = useCreatePage(\n\t\tcreateSuggestion\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":["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","current","whichFocusTargetIndex","nextFocusTarget","focus","focusable","find","stopEditing","contains","ownerDocument","activeElement","createPage","isCreatingPage","errorMessage","handleSelectSuggestion","updatedValue","handleSubmit","handleSubmitWithEnter","event","keyCode","ENTER","preventDefault","shownUnlinkControl","showSettingsDrawer","showTextControl","keyboardReturn","ViewerFill"],"mappings":";;;;;;;;;AAYA;;AATA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAxBA;AACA;AACA;;AAIA;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;A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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\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 ] );\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 { createPage, isCreatingPage, errorMessage } = useCreatePage(\n\t\tcreateSuggestion\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"]}
|
|
@@ -98,7 +98,7 @@ const LinkControlSearchInput = (0, _element.forwardRef)((_ref, ref) => {
|
|
|
98
98
|
let suggestion = selectedSuggestion;
|
|
99
99
|
|
|
100
100
|
if (_constants.CREATE_TYPE === selectedSuggestion.type) {
|
|
101
|
-
// Create a new page and call onSelect with the output from the onCreateSuggestion callback
|
|
101
|
+
// Create a new page and call onSelect with the output from the onCreateSuggestion callback.
|
|
102
102
|
try {
|
|
103
103
|
var _suggestion;
|
|
104
104
|
|
|
@@ -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","noop","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,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,GAAGC,YAPtB;AAQCC,IAAAA,QAAQ,GAAGD,YARZ;AASCE,IAAAA,QAAQ,GAAGF,YATZ;AAUCG,IAAAA,eAAe,GAAG,IAVnB;AAWCC,IAAAA,iBAAiB,GAAKC,KAAF,IACnB,4BAAC,sBAAD,EAA+BA,KAA/B,CAZF;AAcCC,IAAAA,gBAAgB,GAAG,IAdpB;AAeCC,IAAAA,gBAAgB,GAAG,IAfpB;AAgBCC,IAAAA,sBAAsB,GAAG,KAhB1B;AAiBCC,IAAAA,gBAAgB,GAAG,EAjBpB;AAkBCC,IAAAA,iBAAiB,GAAG,IAlBrB;AAmBCC,IAAAA,0BAnBD;AAoBCC,IAAAA,QAAQ,GAAG;AApBZ,GAuBI;AACJ,QAAMC,o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AAI;AAAER,UAAAA,GAAG,EAAEpC;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 { noop, 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 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
|
|
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","noop","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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AzB,CAAL;AAAuC,WAAGyB;AAA1C,OAFO,EAGPA,UAHO,CAAR;AAKA;AACD,GAzBD;;AA2BA,QAAMc,YAAY,GAAG,yBAAYtC,SAAZ,EAAuB;AAC3C,oBAAgB,CAAEgB;AADyB,GAAvB,CAArB;AAIA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,UAAD;AACC,IAAA,KAAK,EAAGA,QAAQ,GAAG,KAAH,GAAWuB,SAD5B;AAEC,IAAA,SAAS,EAAGD,YAFb;AAGC,IAAA,KAAK,EAAGzC,KAHT;AAIC,IAAA,QAAQ,EAAGyB,aAJZ;AAKC,IAAA,WAAW,EAAGrB,WAAH,aAAGA,WAAH,cAAGA,WAAH,GAAkB,cAAI,oBAAJ,CAL9B;AAMC,IAAA,+BAA+B,EAC9BM,eAAe,GAAGkB,uBAAH,GAA6B,IAP9C;AASC,IAAA,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,EAAE5C,KAAF,aAAEA,KAAF,8BAAEA,KAAK,CAAE6C,IAAP,EAAF,wCAAE,YAAeL,MAAjB,CAAxB,EAAkD;AACjDG,QAAAA,KAAK,CAACG,cAAN;AACA,OAFD,MAEO;AACNf,QAAAA,oBAAoB,CACnBa,aAAa,IAAI;AAAER,UAAAA,GAAG,EAAEpC;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 { noop, 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 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"]}
|