@wordpress/block-editor 8.1.2-next.f435e9e01b.0 → 8.2.1-next.a55ed9455a.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 +11 -1
- 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 +1 -1
- 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/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 +1 -1
- 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/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 +1 -1
- 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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["noop","classnames","Button","Spinner","Notice","TextControl","keyboardReturn","__","useRef","useState","useEffect","focus","ENTER","LinkControlSettingsDrawer","LinkControlSearchInput","LinkPreview","useCreatePage","ViewerFill","DEFAULT_LINK_SETTINGS","LinkControl","searchInputPlaceholder","value","settings","onChange","onRemove","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","internalInputValue","setInternalInputValue","url","internalTextValue","setInternalTextValue","title","currentInputValue","isEditingLink","setIsEditingLink","isEndingEditWithFocus","currentInputIsEmpty","trim","length","current","whichFocusTargetIndex","nextFocusTarget","focusable","find","stopEditing","contains","ownerDocument","activeElement","createPage","isCreatingPage","errorMessage","handleSelectSuggestion","updatedValue","handleSubmit","handleSubmitWithEnter","event","keyCode","preventDefault","shownUnlinkControl","showSettingsDrawer","showTextControl"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,MAA1B,EAAkCC,WAAlC,QAAqD,uBAArD;AACA,SAASC,cAAT,QAA+B,kBAA/B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,QAAjB,EAA2BC,SAA3B,QAA4C,oBAA5C;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,KAAT,QAAsB,qBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,mBAAtC;AACA,OAAOC,sBAAP,MAAmC,gBAAnC;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,SAASC,UAAT,QAA2B,eAA3B;AACA,SAASC,qBAAT,QAAsC,aAAtC;AAEA;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,SAASC,WAAT,OAmBI;AAAA;;AAAA,MAnBkB;AACrBC,IAAAA,sBADqB;AAErBC,IAAAA,KAFqB;AAGrBC,IAAAA,QAAQ,GAAGJ,qBAHU;AAIrBK,IAAAA,QAAQ,GAAGvB,IAJU;AAKrBwB,IAAAA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Af,KACC,cAAC,yBAAD;AACC,IAAA,KAAK,EAAGvD,KADT;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IADD,CApFF,EA4FGe,mBAAmB,IAAIA,mBAAmB,EA5F7C,CADD;AAgGA;;AAEDnB,WAAW,CAACF,UAAZ,GAAyBA,UAAzB;AAEA,eAAeE,WAAf","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":["noop","classnames","Button","Spinner","Notice","TextControl","keyboardReturn","__","useRef","useState","useEffect","focus","ENTER","LinkControlSettingsDrawer","LinkControlSearchInput","LinkPreview","useCreatePage","ViewerFill","DEFAULT_LINK_SETTINGS","LinkControl","searchInputPlaceholder","value","settings","onChange","onRemove","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","internalInputValue","setInternalInputValue","url","internalTextValue","setInternalTextValue","title","currentInputValue","isEditingLink","setIsEditingLink","isEndingEditWithFocus","currentInputIsEmpty","trim","length","current","whichFocusTargetIndex","nextFocusTarget","focusable","find","stopEditing","contains","ownerDocument","activeElement","createPage","isCreatingPage","errorMessage","handleSelectSuggestion","updatedValue","handleSubmit","handleSubmitWithEnter","event","keyCode","preventDefault","shownUnlinkControl","showSettingsDrawer","showTextControl"],"mappings":";;AAA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AQ,EAAGC;AAHZ,IADD,CApFF,EA4FGe,mBAAmB,IAAIA,mBAAmB,EA5F7C,CADD;AAgGA;;AAEDnB,WAAW,CAACF,UAAZ,GAAyBA,UAAzB;AAEA,eAAeE,WAAf","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"]}
|
|
@@ -82,7 +82,7 @@ const LinkControlSearchInput = forwardRef((_ref, ref) => {
|
|
|
82
82
|
let suggestion = selectedSuggestion;
|
|
83
83
|
|
|
84
84
|
if (CREATE_TYPE === selectedSuggestion.type) {
|
|
85
|
-
// Create a new page and call onSelect with the output from the onCreateSuggestion callback
|
|
85
|
+
// Create a new page and call onSelect with the output from the onCreateSuggestion callback.
|
|
86
86
|
try {
|
|
87
87
|
var _suggestion;
|
|
88
88
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-input.js"],"names":["noop","omit","classnames","useInstanceId","forwardRef","useState","__","URLInput","LinkControlSearchResults","CREATE_TYPE","useSearchHandler","noopSearchHandler","Promise","resolve","LinkControlSearchInput","ref","value","children","currentLink","className","placeholder","withCreateSuggestion","onCreateSuggestion","onChange","onSelect","showSuggestions","renderSuggestions","props","fetchSuggestions","allowDirectEntry","showInitialSuggestions","suggestionsQuery","withURLSuggestion","createSuggestionButtonText","useLabel","genericSearchHandler","searchHandler","instanceId","focusedSuggestion","setFocusedSuggestion","onInputChange","selection","suggestion","handleRenderSuggestions","currentInputValue","handleSuggestionClick","onSuggestionSelected","selectedSuggestion","type","title","url","e","Object","keys","length","inputClasses","undefined","event","has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O;AACNd,QAAAA,oBAAoB,CACnBY,aAAa,IAAI;AAAER,UAAAA,GAAG,EAAElC;AAAP,SADE,CAApB;AAGA;AACD,KA1BF;AA2BC,IAAA,GAAG,EAAGD;AA3BP,IADD,EA8BGE,QA9BH,CADD;AAkCA,CArIuC,CAAzC;AAwIA,eAAeH,sBAAf","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":["noop","omit","classnames","useInstanceId","forwardRef","useState","__","URLInput","LinkControlSearchResults","CREATE_TYPE","useSearchHandler","noopSearchHandler","Promise","resolve","LinkControlSearchInput","ref","value","children","currentLink","className","placeholder","withCreateSuggestion","onCreateSuggestion","onChange","onSelect","showSuggestions","renderSuggestions","props","fetchSuggestions","allowDirectEntry","showInitialSuggestions","suggestionsQuery","withURLSuggestion","createSuggestionButtonText","useLabel","genericSearchHandler","searchHandler","instanceId","focusedSuggestion","setFocusedSuggestion","onInputChange","selection","suggestion","handleRenderSuggestions","currentInputValue","handleSuggestionClick","onSuggestionSelected","selectedSuggestion","type","title","url","e","Object","keys","length","inputClasses","undefined","event","hasSuggestion","trim","preventDefault"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,IAAf,QAA2B,QAA3B;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,UAAT,EAAqBC,QAArB,QAAqC,oBAArC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,KAAzB;AACA,OAAOC,wBAAP,MAAqC,kBAArC;AACA,SAASC,WAAT,QAA4B,aAA5B;AACA,OAAOC,gBAAP,MAA6B,sBAA7B,C,CAEA;AACA;AACA;;AACA,MAAMC,iBAAiB,GAAG,MAAMC,OAAO,CAACC,OAAR,CAAiB,EAAjB,CAAhC;;AAEA,MAAMC,sBAAsB,GAAGV,UAAU,CACxC,OAuBCW,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,GAAGtB,IAPtB;AAQCuB,IAAAA,QAAQ,GAAGvB,IARZ;AASCwB,IAAAA,QAAQ,GAAGxB,IATZ;AAUCyB,IAAAA,eAAe,GAAG,IAVnB;AAWCC,IAAAA,iBAAiB,GAAKC,KAAF,IACnB,cAAC,wBAAD,EAA+BA,KAA/B,CAZF;AAcCC,IAAAA,gBAAgB,GAAG,IAdpB;AAeCC,IAAAA,gBAAgB,GAAG,IAfpB;AAgBCC,IAAAA,sBAAsB,GAAG,KAhB1B;AAiBCC,IAAAA,gBAAgB,G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,KAAF,aAAEA,KAAF,8BAAEA,KAAK,CAAE2C,IAAP,EAAF,wCAAE,YAAeL,MAAjB,CAAxB,EAAkD;AACjDG,QAAAA,KAAK,CAACG,cAAN;AACA,OAFD,MAEO;AACNd,QAAAA,oBAAoB,CACnBY,aAAa,IAAI;AAAER,UAAAA,GAAG,EAAElC;AAAP,SADE,CAApB;AAGA;AACD,KA1BF;AA2BC,IAAA,GAAG,EAAGD;AA3BP,IADD,EA8BGE,QA9BH,CADD;AAkCA,CArIuC,CAAzC;AAwIA,eAAeH,sBAAf","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"]}
|
|
@@ -51,7 +51,7 @@ export default function LinkControlSearchResults(_ref) {
|
|
|
51
51
|
// so we conditionally render it as a wrapper to visually hide the label
|
|
52
52
|
// when that is required.
|
|
53
53
|
|
|
54
|
-
const searchResultsLabel = createElement(isInitialSuggestions ? Fragment : VisuallyHidden, {}, //
|
|
54
|
+
const searchResultsLabel = createElement(isInitialSuggestions ? Fragment : VisuallyHidden, {}, // Empty props.
|
|
55
55
|
createElement("span", {
|
|
56
56
|
className: "block-editor-link-control__search-results-label",
|
|
57
57
|
id: searchResultsLabelId
|
|
@@ -75,7 +75,7 @@ export default function LinkControlSearchResults(_ref) {
|
|
|
75
75
|
isSelected: index === selectedSuggestion
|
|
76
76
|
});
|
|
77
77
|
} // If we're not handling "Create" suggestions above then
|
|
78
|
-
// we don't want them in the main results so exit early
|
|
78
|
+
// we don't want them in the main results so exit early.
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
if (CREATE_TYPE === suggestion.type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-results.js"],"names":["__","sprintf","VisuallyHidden","classnames","createElement","Fragment","LinkControlSearchCreate","LinkControlSearchItem","CREATE_TYPE","LinkControlSearchResults","instanceId","withCreateSuggestion","currentInputValue","handleSuggestionClick","suggestionsListProps","buildSuggestionItemProps","suggestions","selectedSuggestion","isLoading","isInitialSuggestions","createSuggestionButtonText","suggestionsQuery","resultsListClasses","directLinkEntryTypes","isSingleDirectEntryResult","length","includes","type","toLowerCase","shouldShowCreateSuggestion","shouldShowSuggestionsTypes","searchResultsLabelId","labelText","searchResultsLabel","map","suggestion","index","id","isFrontPage"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,cAAT,QAA+B,uBAA/B;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,OAAO,EAAG,MAAM;AACfvB,QAAAA,qBAAqB,CAAEsB,UAAF,CAArB;AACA,OAVF;AAWC,MAAA,UAAU,EAAGC,KAAK,KAAKnB,kBAXxB;AAYC,MAAA,KAAK,EAAGM,oBAAoB,CAACG,QAArB,CACPS,UAAU,CAACR,IAAX,CAAgBC,WAAhB,EADO,CAZT;AAeC,MAAA,UAAU,EAAGhB,iBAfd;AAgBC,MAAA,cAAc,EAAGkB,0BAhBlB;AAiBC,MAAA,WAAW,EAAGK,UAAH,aAAGA,UAAH,uBAAGA,UAAU,CAAEG;AAjB3B,MADD;AAqBA,GApDC,CALH,CAFD,CADD;AAgEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { VisuallyHidden } from '@wordpress/components';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { createElement, Fragment } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSearchCreate from './search-create-button';\nimport LinkControlSearchItem from './search-item';\nimport { CREATE_TYPE } from './constants';\n\nexport default function LinkControlSearchResults( {\n\tinstanceId,\n\twithCreateSuggestion,\n\tcurrentInputValue,\n\thandleSuggestionClick,\n\tsuggestionsListProps,\n\tbuildSuggestionItemProps,\n\tsuggestions,\n\tselectedSuggestion,\n\tisLoading,\n\tisInitialSuggestions,\n\tcreateSuggestionButtonText,\n\tsuggestionsQuery,\n} ) {\n\tconst resultsListClasses = classnames(\n\t\t'block-editor-link-control__search-results',\n\t\t{\n\t\t\t'is-loading': isLoading,\n\t\t}\n\t);\n\n\tconst directLinkEntryTypes = [ 'url', 'mailto', 'tel', 'internal' ];\n\tconst isSingleDirectEntryResult =\n\t\tsuggestions.length === 1 &&\n\t\tdirectLinkEntryTypes.includes( suggestions[ 0 ].type.toLowerCase() );\n\tconst shouldShowCreateSuggestion =\n\t\twithCreateSuggestion &&\n\t\t! isSingleDirectEntryResult &&\n\t\t! isInitialSuggestions;\n\t// If the query has a specified type, then we can skip showing them in the result. See #24839.\n\tconst shouldShowSuggestionsTypes = ! suggestionsQuery?.type;\n\n\t// According to guidelines aria-label should be added if the label\n\t// itself is not visible.\n\t// See: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role\n\tconst searchResultsLabelId = `block-editor-link-control-search-results-label-${ instanceId }`;\n\tconst labelText = isInitialSuggestions\n\t\t? __( 'Recently updated' )\n\t\t: sprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Search results for \"%s\"' ),\n\t\t\t\tcurrentInputValue\n\t\t );\n\n\t// VisuallyHidden rightly doesn't accept custom classNames\n\t// so we conditionally render it as a wrapper to visually hide the label\n\t// when that is required.\n\tconst searchResultsLabel = createElement(\n\t\tisInitialSuggestions ? Fragment : VisuallyHidden,\n\t\t{}, //
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-results.js"],"names":["__","sprintf","VisuallyHidden","classnames","createElement","Fragment","LinkControlSearchCreate","LinkControlSearchItem","CREATE_TYPE","LinkControlSearchResults","instanceId","withCreateSuggestion","currentInputValue","handleSuggestionClick","suggestionsListProps","buildSuggestionItemProps","suggestions","selectedSuggestion","isLoading","isInitialSuggestions","createSuggestionButtonText","suggestionsQuery","resultsListClasses","directLinkEntryTypes","isSingleDirectEntryResult","length","includes","type","toLowerCase","shouldShowCreateSuggestion","shouldShowSuggestionsTypes","searchResultsLabelId","labelText","searchResultsLabel","map","suggestion","index","id","isFrontPage"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,cAAT,QAA+B,uBAA/B;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,SAASC,aAAT,EAAwBC,QAAxB,QAAwC,oBAAxC;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,wBAApC;AACA,OAAOC,qBAAP,MAAkC,eAAlC;AACA,SAASC,WAAT,QAA4B,aAA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O,CAZT;AAeC,MAAA,UAAU,EAAGhB,iBAfd;AAgBC,MAAA,cAAc,EAAGkB,0BAhBlB;AAiBC,MAAA,WAAW,EAAGK,UAAH,aAAGA,UAAH,uBAAGA,UAAU,CAAEG;AAjB3B,MADD;AAqBA,GApDC,CALH,CAFD,CADD;AAgEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { VisuallyHidden } from '@wordpress/components';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { createElement, Fragment } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSearchCreate from './search-create-button';\nimport LinkControlSearchItem from './search-item';\nimport { CREATE_TYPE } from './constants';\n\nexport default function LinkControlSearchResults( {\n\tinstanceId,\n\twithCreateSuggestion,\n\tcurrentInputValue,\n\thandleSuggestionClick,\n\tsuggestionsListProps,\n\tbuildSuggestionItemProps,\n\tsuggestions,\n\tselectedSuggestion,\n\tisLoading,\n\tisInitialSuggestions,\n\tcreateSuggestionButtonText,\n\tsuggestionsQuery,\n} ) {\n\tconst resultsListClasses = classnames(\n\t\t'block-editor-link-control__search-results',\n\t\t{\n\t\t\t'is-loading': isLoading,\n\t\t}\n\t);\n\n\tconst directLinkEntryTypes = [ 'url', 'mailto', 'tel', 'internal' ];\n\tconst isSingleDirectEntryResult =\n\t\tsuggestions.length === 1 &&\n\t\tdirectLinkEntryTypes.includes( suggestions[ 0 ].type.toLowerCase() );\n\tconst shouldShowCreateSuggestion =\n\t\twithCreateSuggestion &&\n\t\t! isSingleDirectEntryResult &&\n\t\t! isInitialSuggestions;\n\t// If the query has a specified type, then we can skip showing them in the result. See #24839.\n\tconst shouldShowSuggestionsTypes = ! suggestionsQuery?.type;\n\n\t// According to guidelines aria-label should be added if the label\n\t// itself is not visible.\n\t// See: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role\n\tconst searchResultsLabelId = `block-editor-link-control-search-results-label-${ instanceId }`;\n\tconst labelText = isInitialSuggestions\n\t\t? __( 'Recently updated' )\n\t\t: sprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Search results for \"%s\"' ),\n\t\t\t\tcurrentInputValue\n\t\t );\n\n\t// VisuallyHidden rightly doesn't accept custom classNames\n\t// so we conditionally render it as a wrapper to visually hide the label\n\t// when that is required.\n\tconst searchResultsLabel = createElement(\n\t\tisInitialSuggestions ? Fragment : VisuallyHidden,\n\t\t{}, // Empty props.\n\t\t<span\n\t\t\tclassName=\"block-editor-link-control__search-results-label\"\n\t\t\tid={ searchResultsLabelId }\n\t\t>\n\t\t\t{ labelText }\n\t\t</span>\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-link-control__search-results-wrapper\">\n\t\t\t{ searchResultsLabel }\n\t\t\t<div\n\t\t\t\t{ ...suggestionsListProps }\n\t\t\t\tclassName={ resultsListClasses }\n\t\t\t\taria-labelledby={ searchResultsLabelId }\n\t\t\t>\n\t\t\t\t{ suggestions.map( ( suggestion, index ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tshouldShowCreateSuggestion &&\n\t\t\t\t\t\tCREATE_TYPE === suggestion.type\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<LinkControlSearchCreate\n\t\t\t\t\t\t\t\tsearchTerm={ currentInputValue }\n\t\t\t\t\t\t\t\tbuttonText={ createSuggestionButtonText }\n\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\thandleSuggestionClick( suggestion )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// Intentionally only using `type` here as\n\t\t\t\t\t\t\t\t// the constant is enough to uniquely\n\t\t\t\t\t\t\t\t// identify the single \"CREATE\" suggestion.\n\t\t\t\t\t\t\t\tkey={ suggestion.type }\n\t\t\t\t\t\t\t\titemProps={ buildSuggestionItemProps(\n\t\t\t\t\t\t\t\t\tsuggestion,\n\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tisSelected={ index === selectedSuggestion }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// If we're not handling \"Create\" suggestions above then\n\t\t\t\t\t// we don't want them in the main results so exit early.\n\t\t\t\t\tif ( CREATE_TYPE === suggestion.type ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<LinkControlSearchItem\n\t\t\t\t\t\t\tkey={ `${ suggestion.id }-${ suggestion.type }` }\n\t\t\t\t\t\t\titemProps={ buildSuggestionItemProps(\n\t\t\t\t\t\t\t\tsuggestion,\n\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tsuggestion={ suggestion }\n\t\t\t\t\t\t\tindex={ index }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\thandleSuggestionClick( suggestion );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisSelected={ index === selectedSuggestion }\n\t\t\t\t\t\t\tisURL={ directLinkEntryTypes.includes(\n\t\t\t\t\t\t\t\tsuggestion.type.toLowerCase()\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tsearchTerm={ currentInputValue }\n\t\t\t\t\t\t\tshouldShowType={ shouldShowSuggestionsTypes }\n\t\t\t\t\t\t\tisFrontPage={ suggestion?.isFrontPage }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/use-rich-url-data.js"],"names":["store","blockEditorStore","useSelect","useEffect","useReducer","reducer","state","action","type","isFetching","richData","Error","useRemoteUrlData","url","dispatch","fetchRichUrlData","select","getSettings","__experimentalFetchRichUrlData","length","AbortController","controller","window","signal","then","urlData","catch","aborted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AL,IACAJ,gBADA,IAEA,OAAOK,eAAP,KAA2B,WAH5B,EAIE;AACDN,MAAAA,QAAQ,CAAE;AACTN,QAAAA,IAAI,EAAE;AADG,OAAF,CAAR;AAIA,YAAMa,UAAU,GAAG,IAAIC,MAAM,CAACF,eAAX,EAAnB;AAEA,YAAMG,MAAM,GAAGF,UAAU,CAACE,MAA1B;AAEAR,MAAAA,gBAAgB,CAAEF,GAAF,EAAO;AACtBU,QAAAA;AADsB,OAAP,CAAhB,CAGEC,IAHF,CAGUC,OAAF,IAAe;AACrBX,QAAAA,QAAQ,CAAE;AACTN,UAAAA,IAAI,EAAE,UADG;AAETE,UAAAA,QAAQ,EAAEe;AAFD,SAAF,CAAR;AAIA,OARF,EASEC,KATF,CASS,MAAM;AACb;AACA,YAAK,CAAEH,MAAM,CAACI,OAAd,EAAwB;AACvBb,UAAAA,QAAQ,CAAE;AACTN,YAAAA,IAAI,EAAE;AADG,WAAF,CAAR;AAGA;AACD,OAhBF,EATC,CA0BD;;AACA,aAAO,MAAM;AACZa,QAAAA,UAAU,CAACO,KAAX;AACA,OAFD;AAGA;AACD,GAvCQ,EAuCN,CAAEf,GAAF,CAvCM,CAAT;AAyCA,SAAOP,KAAP;AACA;;AAED,eAAeM,gBAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useEffect, useReducer } from '@wordpress/element';\n\nfunction reducer( state, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RESOLVED':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisFetching: false,\n\t\t\t\trichData: action.richData,\n\t\t\t};\n\t\tcase 'ERROR':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisFetching: false,\n\t\t\t\trichData: null,\n\t\t\t};\n\t\tcase 'LOADING':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisFetching: true,\n\t\t\t};\n\t\tdefault:\n\t\t\tthrow new Error( `Unexpected action type ${ action.type }` );\n\t}\n}\n\nfunction useRemoteUrlData( url ) {\n\tconst [ state, dispatch ] = useReducer( reducer, {\n\t\trichData: null,\n\t\tisFetching: false,\n\t} );\n\n\tconst { fetchRichUrlData } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tfetchRichUrlData: getSettings().__experimentalFetchRichUrlData,\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t// Only make the request if we have an actual URL\n\t\t// and the fetching util is available. In some editors\n\t\t// there may not be such a util.\n\t\tif (\n\t\t\turl?.length &&\n\t\t\tfetchRichUrlData &&\n\t\t\ttypeof AbortController !== 'undefined'\n\t\t) {\n\t\t\tdispatch( {\n\t\t\t\ttype: 'LOADING',\n\t\t\t} );\n\n\t\t\tconst controller = new window.AbortController();\n\n\t\t\tconst signal = controller.signal;\n\n\t\t\tfetchRichUrlData( url, {\n\t\t\t\tsignal,\n\t\t\t} )\n\t\t\t\t.then( ( urlData ) => {\n\t\t\t\t\tdispatch( {\n\t\t\t\t\t\ttype: 'RESOLVED',\n\t\t\t\t\t\trichData: urlData,\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => {\n\t\t\t\t\t// Avoid setting state on unmounted component\n\t\t\t\t\tif ( ! signal.aborted ) {\n\t\t\t\t\t\tdispatch( {\n\t\t\t\t\t\t\ttype: 'ERROR',\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t// Cleanup: when the URL changes the abort the current request
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/use-rich-url-data.js"],"names":["store","blockEditorStore","useSelect","useEffect","useReducer","reducer","state","action","type","isFetching","richData","Error","useRemoteUrlData","url","dispatch","fetchRichUrlData","select","getSettings","__experimentalFetchRichUrlData","length","AbortController","controller","window","signal","then","urlData","catch","aborted","abort"],"mappings":"AAAA;AACA;AACA;AACA,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P,KAA2B,WAH5B,EAIE;AACDN,MAAAA,QAAQ,CAAE;AACTN,QAAAA,IAAI,EAAE;AADG,OAAF,CAAR;AAIA,YAAMa,UAAU,GAAG,IAAIC,MAAM,CAACF,eAAX,EAAnB;AAEA,YAAMG,MAAM,GAAGF,UAAU,CAACE,MAA1B;AAEAR,MAAAA,gBAAgB,CAAEF,GAAF,EAAO;AACtBU,QAAAA;AADsB,OAAP,CAAhB,CAGEC,IAHF,CAGUC,OAAF,IAAe;AACrBX,QAAAA,QAAQ,CAAE;AACTN,UAAAA,IAAI,EAAE,UADG;AAETE,UAAAA,QAAQ,EAAEe;AAFD,SAAF,CAAR;AAIA,OARF,EASEC,KATF,CASS,MAAM;AACb;AACA,YAAK,CAAEH,MAAM,CAACI,OAAd,EAAwB;AACvBb,UAAAA,QAAQ,CAAE;AACTN,YAAAA,IAAI,EAAE;AADG,WAAF,CAAR;AAGA;AACD,OAhBF,EATC,CA0BD;;AACA,aAAO,MAAM;AACZa,QAAAA,UAAU,CAACO,KAAX;AACA,OAFD;AAGA;AACD,GAvCQ,EAuCN,CAAEf,GAAF,CAvCM,CAAT;AAyCA,SAAOP,KAAP;AACA;;AAED,eAAeM,gBAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useEffect, useReducer } from '@wordpress/element';\n\nfunction reducer( state, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RESOLVED':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisFetching: false,\n\t\t\t\trichData: action.richData,\n\t\t\t};\n\t\tcase 'ERROR':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisFetching: false,\n\t\t\t\trichData: null,\n\t\t\t};\n\t\tcase 'LOADING':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisFetching: true,\n\t\t\t};\n\t\tdefault:\n\t\t\tthrow new Error( `Unexpected action type ${ action.type }` );\n\t}\n}\n\nfunction useRemoteUrlData( url ) {\n\tconst [ state, dispatch ] = useReducer( reducer, {\n\t\trichData: null,\n\t\tisFetching: false,\n\t} );\n\n\tconst { fetchRichUrlData } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tfetchRichUrlData: getSettings().__experimentalFetchRichUrlData,\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t// Only make the request if we have an actual URL\n\t\t// and the fetching util is available. In some editors\n\t\t// there may not be such a util.\n\t\tif (\n\t\t\turl?.length &&\n\t\t\tfetchRichUrlData &&\n\t\t\ttypeof AbortController !== 'undefined'\n\t\t) {\n\t\t\tdispatch( {\n\t\t\t\ttype: 'LOADING',\n\t\t\t} );\n\n\t\t\tconst controller = new window.AbortController();\n\n\t\t\tconst signal = controller.signal;\n\n\t\t\tfetchRichUrlData( url, {\n\t\t\t\tsignal,\n\t\t\t} )\n\t\t\t\t.then( ( urlData ) => {\n\t\t\t\t\tdispatch( {\n\t\t\t\t\t\ttype: 'RESOLVED',\n\t\t\t\t\t\trichData: urlData,\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => {\n\t\t\t\t\t// Avoid setting state on unmounted component\n\t\t\t\t\tif ( ! signal.aborted ) {\n\t\t\t\t\t\tdispatch( {\n\t\t\t\t\t\t\ttype: 'ERROR',\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t// Cleanup: when the URL changes the abort the current request.\n\t\t\treturn () => {\n\t\t\t\tcontroller.abort();\n\t\t\t};\n\t\t}\n\t}, [ url ] );\n\n\treturn state;\n}\n\nexport default useRemoteUrlData;\n"]}
|
|
@@ -91,9 +91,9 @@ const handleEntitySearch = async (val, suggestionsQuery, fetchSearchSuggestions,
|
|
|
91
91
|
// is never exposed as part of the component's public API.
|
|
92
92
|
// see: https://github.com/WordPress/gutenberg/pull/19775#discussion_r378931316.
|
|
93
93
|
title: val,
|
|
94
|
-
//
|
|
94
|
+
// Must match the existing `<input>`s text value.
|
|
95
95
|
url: val,
|
|
96
|
-
//
|
|
96
|
+
// Must match the existing `<input>`s text value.
|
|
97
97
|
type: CREATE_TYPE
|
|
98
98
|
});
|
|
99
99
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/use-search-handler.js"],"names":["getProtocol","prependHTTP","useCallback","useSelect","startsWith","isURLLike","CREATE_TYPE","store","blockEditorStore","handleNoop","Promise","resolve","handleDirectEntry","val","type","protocol","includes","id","title","url","handleEntitySearch","suggestionsQuery","fetchSearchSuggestions","directEntryHandler","withCreateSuggestion","withURLSuggestion","pageOnFront","isInitialSuggestions","resultsIncludeFrontPage","results","all","map","result","Number","isFrontPage","couldBeURL","concat","useSearchHandler","allowDirectEntry","select","getSettings","__experimentalFetchLinkSuggestions"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,WAAtB,QAAyC,gBAAzC;AACA,SAASC,WAAT,QAA4B,oBAA5B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,QAA3B;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,SAASC,WAAT,QAA4B,aAA5B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,OAAO,MAAMC,UAAU,GAAG,MAAMC,OAAO,CAACC,OAAR,CAAiB,EAAjB,CAAzB;AAEP,OAAO,MAAMC,iBAAiB,GAAKC,GAAF,IAAW;AAC3C,MAAIC,IAAI,GAAG,KAAX;AAEA,QAAMC,QAAQ,GAAGf,WAAW,CAAEa,GAAF,CAAX,IAAsB,EAAvC;;AAEA,MAAKE,QAAQ,CAACC,QAAT,CAAmB,QAAnB,CAAL,EAAqC;AACpCF,IAAAA,IAAI,GAAG,QAAP;AACA;;AAED,MAAKC,QAAQ,CAACC,QAAT,C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B,SAAS,CAAEQ,GAAF,CAAT,GACJU,kBAAkB,CAAEV,GAAF,EAAO;AAAEc,MAAAA;AAAF,KAAP,CADd,GAEJP,kBAAkB,CAClBP,GADkB,EAElB,EAAE,GAAGQ,gBAAL;AAAuBM,MAAAA;AAAvB,KAFkB,EAGlBL,sBAHkB,EAIlBC,kBAJkB,EAKlBC,oBALkB,EAMlBC,iBANkB,EAOlBC,WAPkB,CAFrB;AAWA,GAbgB,EAcjB,CAAEH,kBAAF,EAAsBD,sBAAtB,EAA8CE,oBAA9C,CAdiB,CAAlB;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getProtocol, prependHTTP } from '@wordpress/url';\nimport { useCallback } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * External dependencies\n */\nimport { startsWith } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport isURLLike from './is-url-like';\nimport { CREATE_TYPE } from './constants';\nimport { store as blockEditorStore } from '../../store';\n\nexport const handleNoop = () => Promise.resolve( [] );\n\nexport const handleDirectEntry = ( val ) => {\n\tlet type = 'URL';\n\n\tconst protocol = getProtocol( val ) || '';\n\n\tif ( protocol.includes( 'mailto' ) ) {\n\t\ttype = 'mailto';\n\t}\n\n\tif ( protocol.includes( 'tel' ) ) {\n\t\ttype = 'tel';\n\t}\n\n\tif ( startsWith( val, '#' ) ) {\n\t\ttype = 'internal';\n\t}\n\n\treturn Promise.resolve( [\n\t\t{\n\t\t\tid: val,\n\t\t\ttitle: val,\n\t\t\turl: type === 'URL' ? prependHTTP( val ) : val,\n\t\t\ttype,\n\t\t},\n\t] );\n};\n\nconst handleEntitySearch = async (\n\tval,\n\tsuggestionsQuery,\n\tfetchSearchSuggestions,\n\tdirectEntryHandler,\n\twithCreateSuggestion,\n\twithURLSuggestion,\n\tpageOnFront\n) => {\n\tconst { isInitialSuggestions } = suggestionsQuery;\n\tlet resultsIncludeFrontPage = false;\n\n\tlet results = await Promise.all( [\n\t\tfetchSearchSuggestions( val, suggestionsQuery ),\n\t\tdirectEntryHandler( val ),\n\t] );\n\n\t// Identify front page and update type to match.\n\tresults[ 0 ] = results[ 0 ].map( ( result ) => {\n\t\tif ( Number( result.id ) === pageOnFront ) {\n\t\t\tresultsIncludeFrontPage = true;\n\t\t\tresult.isFrontPage = true;\n\t\t\treturn result;\n\t\t}\n\n\t\treturn result;\n\t} );\n\n\tconst couldBeURL = ! val.includes( ' ' );\n\n\t// If it's potentially a URL search then concat on a URL search suggestion\n\t// just for good measure. That way once the actual results run out we always\n\t// have a URL option to fallback on.\n\tif (\n\t\t! resultsIncludeFrontPage &&\n\t\tcouldBeURL &&\n\t\twithURLSuggestion &&\n\t\t! isInitialSuggestions\n\t) {\n\t\tresults = results[ 0 ].concat( results[ 1 ] );\n\t} else {\n\t\tresults = results[ 0 ];\n\t}\n\n\t// If displaying initial suggestions just return plain results.\n\tif ( isInitialSuggestions ) {\n\t\treturn results;\n\t}\n\n\t// Here we append a faux suggestion to represent a \"CREATE\" option. This\n\t// is detected in the rendering of the search results and handled as a\n\t// special case. This is currently necessary because the suggestions\n\t// dropdown will only appear if there are valid suggestions and\n\t// therefore unless the create option is a suggestion it will not\n\t// display in scenarios where there are no results returned from the\n\t// API. In addition promoting CREATE to a first class suggestion affords\n\t// the a11y benefits afforded by `URLInput` to all suggestions (eg:\n\t// keyboard handling, ARIA roles...etc).\n\t//\n\t// Note also that the value of the `title` and `url` properties must correspond\n\t// to the text value of the `<input>`. This is because `title` is used\n\t// when creating the suggestion. Similarly `url` is used when using keyboard to select\n\t// the suggestion (the <form> `onSubmit` handler falls-back to `url`).\n\treturn isURLLike( val ) || ! withCreateSuggestion\n\t\t? results\n\t\t: results.concat( {\n\t\t\t\t// the `id` prop is intentionally ommitted here because it\n\t\t\t\t// is never exposed as part of the component's public API.\n\t\t\t\t// see: https://github.com/WordPress/gutenberg/pull/19775#discussion_r378931316.\n\t\t\t\ttitle: val, //
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/use-search-handler.js"],"names":["getProtocol","prependHTTP","useCallback","useSelect","startsWith","isURLLike","CREATE_TYPE","store","blockEditorStore","handleNoop","Promise","resolve","handleDirectEntry","val","type","protocol","includes","id","title","url","handleEntitySearch","suggestionsQuery","fetchSearchSuggestions","directEntryHandler","withCreateSuggestion","withURLSuggestion","pageOnFront","isInitialSuggestions","resultsIncludeFrontPage","results","all","map","result","Number","isFrontPage","couldBeURL","concat","useSearchHandler","allowDirectEntry","select","getSettings","__experimentalFetchLinkSuggestions"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,WAAtB,QAAyC,gBAAzC;AACA,SAASC,WAAT,QAA4B,oBAA5B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,QAA3B;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,SAASC,WAAT,QAA4B,aAA5B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,OAAO,MAAMC,UAAU,GAAG,MAAMC,OAAO,CAACC,OAAR,CAAiB,EAAjB,CAAzB;AAEP,OAAO,MAAMC,iBAAiB,GAAKC,GAAF,IAAW;AAC3C,MAAIC,IAAI,GAAG,KAAX;AAEA,QAAMC,QAAQ,GAAGf,WAAW,CAAEa,GAAF,CAAX,IAAsB,EAAvC;;AAEA,MAAKE,QAAQ,CAACC,QAAT,CAAmB,QAAnB,CAAL,EAAqC;AACpCF,IAAAA,IAAI,GAAG,QAAP;AACA;;AAED,MAAKC,QAAQ,CAACC,QAAT,CAAmB,KAAnB,CAAL,EAAkC;AACjCF,IAAAA,IAAI,GAAG,KAAP;AACA;;AAED,MAAKV,UAAU,CAAES,GAAF,EAAO,GAAP,CAAf,EAA8B;AAC7BC,IAAAA,IAAI,GAAG,UAAP;AACA;;AAED,SAAOJ,OAAO,CAACC,OAAR,CAAiB,CACvB;AACCM,IAAAA,EAAE,EAAEJ,GADL;A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iBANkB,EAOlBC,WAPkB,CAFrB;AAWA,GAbgB,EAcjB,CAAEH,kBAAF,EAAsBD,sBAAtB,EAA8CE,oBAA9C,CAdiB,CAAlB;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getProtocol, prependHTTP } from '@wordpress/url';\nimport { useCallback } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * External dependencies\n */\nimport { startsWith } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport isURLLike from './is-url-like';\nimport { CREATE_TYPE } from './constants';\nimport { store as blockEditorStore } from '../../store';\n\nexport const handleNoop = () => Promise.resolve( [] );\n\nexport const handleDirectEntry = ( val ) => {\n\tlet type = 'URL';\n\n\tconst protocol = getProtocol( val ) || '';\n\n\tif ( protocol.includes( 'mailto' ) ) {\n\t\ttype = 'mailto';\n\t}\n\n\tif ( protocol.includes( 'tel' ) ) {\n\t\ttype = 'tel';\n\t}\n\n\tif ( startsWith( val, '#' ) ) {\n\t\ttype = 'internal';\n\t}\n\n\treturn Promise.resolve( [\n\t\t{\n\t\t\tid: val,\n\t\t\ttitle: val,\n\t\t\turl: type === 'URL' ? prependHTTP( val ) : val,\n\t\t\ttype,\n\t\t},\n\t] );\n};\n\nconst handleEntitySearch = async (\n\tval,\n\tsuggestionsQuery,\n\tfetchSearchSuggestions,\n\tdirectEntryHandler,\n\twithCreateSuggestion,\n\twithURLSuggestion,\n\tpageOnFront\n) => {\n\tconst { isInitialSuggestions } = suggestionsQuery;\n\tlet resultsIncludeFrontPage = false;\n\n\tlet results = await Promise.all( [\n\t\tfetchSearchSuggestions( val, suggestionsQuery ),\n\t\tdirectEntryHandler( val ),\n\t] );\n\n\t// Identify front page and update type to match.\n\tresults[ 0 ] = results[ 0 ].map( ( result ) => {\n\t\tif ( Number( result.id ) === pageOnFront ) {\n\t\t\tresultsIncludeFrontPage = true;\n\t\t\tresult.isFrontPage = true;\n\t\t\treturn result;\n\t\t}\n\n\t\treturn result;\n\t} );\n\n\tconst couldBeURL = ! val.includes( ' ' );\n\n\t// If it's potentially a URL search then concat on a URL search suggestion\n\t// just for good measure. That way once the actual results run out we always\n\t// have a URL option to fallback on.\n\tif (\n\t\t! resultsIncludeFrontPage &&\n\t\tcouldBeURL &&\n\t\twithURLSuggestion &&\n\t\t! isInitialSuggestions\n\t) {\n\t\tresults = results[ 0 ].concat( results[ 1 ] );\n\t} else {\n\t\tresults = results[ 0 ];\n\t}\n\n\t// If displaying initial suggestions just return plain results.\n\tif ( isInitialSuggestions ) {\n\t\treturn results;\n\t}\n\n\t// Here we append a faux suggestion to represent a \"CREATE\" option. This\n\t// is detected in the rendering of the search results and handled as a\n\t// special case. This is currently necessary because the suggestions\n\t// dropdown will only appear if there are valid suggestions and\n\t// therefore unless the create option is a suggestion it will not\n\t// display in scenarios where there are no results returned from the\n\t// API. In addition promoting CREATE to a first class suggestion affords\n\t// the a11y benefits afforded by `URLInput` to all suggestions (eg:\n\t// keyboard handling, ARIA roles...etc).\n\t//\n\t// Note also that the value of the `title` and `url` properties must correspond\n\t// to the text value of the `<input>`. This is because `title` is used\n\t// when creating the suggestion. Similarly `url` is used when using keyboard to select\n\t// the suggestion (the <form> `onSubmit` handler falls-back to `url`).\n\treturn isURLLike( val ) || ! withCreateSuggestion\n\t\t? results\n\t\t: results.concat( {\n\t\t\t\t// the `id` prop is intentionally ommitted here because it\n\t\t\t\t// is never exposed as part of the component's public API.\n\t\t\t\t// see: https://github.com/WordPress/gutenberg/pull/19775#discussion_r378931316.\n\t\t\t\ttitle: val, // Must match the existing `<input>`s text value.\n\t\t\t\turl: val, // Must match the existing `<input>`s text value.\n\t\t\t\ttype: CREATE_TYPE,\n\t\t } );\n};\n\nexport default function useSearchHandler(\n\tsuggestionsQuery,\n\tallowDirectEntry,\n\twithCreateSuggestion,\n\twithURLSuggestion\n) {\n\tconst { fetchSearchSuggestions, pageOnFront } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\n\t\treturn {\n\t\t\tpageOnFront: getSettings().pageOnFront,\n\t\t\tfetchSearchSuggestions: getSettings()\n\t\t\t\t.__experimentalFetchLinkSuggestions,\n\t\t};\n\t}, [] );\n\n\tconst directEntryHandler = allowDirectEntry\n\t\t? handleDirectEntry\n\t\t: handleNoop;\n\n\treturn useCallback(\n\t\t( val, { isInitialSuggestions } ) => {\n\t\t\treturn isURLLike( val )\n\t\t\t\t? directEntryHandler( val, { isInitialSuggestions } )\n\t\t\t\t: handleEntitySearch(\n\t\t\t\t\t\tval,\n\t\t\t\t\t\t{ ...suggestionsQuery, isInitialSuggestions },\n\t\t\t\t\t\tfetchSearchSuggestions,\n\t\t\t\t\t\tdirectEntryHandler,\n\t\t\t\t\t\twithCreateSuggestion,\n\t\t\t\t\t\twithURLSuggestion,\n\t\t\t\t\t\tpageOnFront\n\t\t\t\t );\n\t\t},\n\t\t[ directEntryHandler, fetchSearchSuggestions, withCreateSuggestion ]\n\t);\n}\n"]}
|
|
@@ -28,6 +28,7 @@ const ListViewBlockContents = forwardRef((_ref, ref) => {
|
|
|
28
28
|
siblingBlockCount,
|
|
29
29
|
level,
|
|
30
30
|
isExpanded,
|
|
31
|
+
selectedClientIds,
|
|
31
32
|
...props
|
|
32
33
|
} = _ref;
|
|
33
34
|
const {
|
|
@@ -38,12 +39,10 @@ const ListViewBlockContents = forwardRef((_ref, ref) => {
|
|
|
38
39
|
selectedBlockInBlockEditor
|
|
39
40
|
} = useSelect(select => {
|
|
40
41
|
const {
|
|
41
|
-
getBlockRootClientId,
|
|
42
42
|
hasBlockMovingClientId,
|
|
43
43
|
getSelectedBlockClientId
|
|
44
44
|
} = select(blockEditorStore);
|
|
45
45
|
return {
|
|
46
|
-
rootClientId: getBlockRootClientId(clientId) || '',
|
|
47
46
|
blockMovingClientId: hasBlockMovingClientId(),
|
|
48
47
|
selectedBlockInBlockEditor: getSelectedBlockClientId()
|
|
49
48
|
};
|
|
@@ -51,9 +50,14 @@ const ListViewBlockContents = forwardRef((_ref, ref) => {
|
|
|
51
50
|
const isBlockMoveTarget = blockMovingClientId && selectedBlockInBlockEditor === clientId;
|
|
52
51
|
const className = classnames('block-editor-list-view-block-contents', {
|
|
53
52
|
'is-dropping-before': isBlockMoveTarget
|
|
54
|
-
});
|
|
53
|
+
}); // Only include all selected blocks if the currently clicked on block
|
|
54
|
+
// is one of the selected blocks. This ensures that if a user attempts
|
|
55
|
+
// to drag a block that isn't part of the selection, they're still able
|
|
56
|
+
// to drag it and rearrange its position.
|
|
57
|
+
|
|
58
|
+
const draggableClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId];
|
|
55
59
|
return createElement(BlockDraggable, {
|
|
56
|
-
clientIds:
|
|
60
|
+
clientIds: draggableClientIds
|
|
57
61
|
}, _ref2 => {
|
|
58
62
|
let {
|
|
59
63
|
draggable,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-contents.js"],"names":["classnames","useSelect","forwardRef","ListViewBlockSelectButton","BlockDraggable","store","blockEditorStore","ListViewBlockContents","ref","onClick","onToggleExpanded","block","isSelected","position","siblingBlockCount","level","isExpanded","props","clientId","blockMovingClientId","selectedBlockInBlockEditor","select","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-contents.js"],"names":["classnames","useSelect","forwardRef","ListViewBlockSelectButton","BlockDraggable","store","blockEditorStore","ListViewBlockContents","ref","onClick","onToggleExpanded","block","isSelected","position","siblingBlockCount","level","isExpanded","selectedClientIds","props","clientId","blockMovingClientId","selectedBlockInBlockEditor","select","hasBlockMovingClientId","getSelectedBlockClientId","isBlockMoveTarget","className","draggableClientIds","includes","draggable","onDragStart","onDragEnd"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC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EC,MAAA,SAAS,EAAGkB,SAFb;AAGC,MAAA,KAAK,EAAGf,KAHT;AAIC,MAAA,OAAO,EAAGF,OAJX;AAKC,MAAA,gBAAgB,EAAGC,gBALpB;AAMC,MAAA,UAAU,EAAGE,UANd;AAOC,MAAA,QAAQ,EAAGC,QAPZ;AAQC,MAAA,iBAAiB,EAAGC,iBARrB;AASC,MAAA,KAAK,EAAGC,KATT;AAUC,MAAA,SAAS,EAAGc,SAVb;AAWC,MAAA,WAAW,EAAGC,WAXf;AAYC,MAAA,SAAS,EAAGC,SAZb;AAaC,MAAA,UAAU,EAAGf;AAbd,OAcME,KAdN,EADC;AAAA,GADH,CADD;AAsBA,CArEsC,CAAxC;AAwEA,eAAeX,qBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ListViewBlockSelectButton from './block-select-button';\nimport BlockDraggable from '../block-draggable';\nimport { store as blockEditorStore } from '../../store';\n\nconst ListViewBlockContents = forwardRef(\n\t(\n\t\t{\n\t\t\tonClick,\n\t\t\tonToggleExpanded,\n\t\t\tblock,\n\t\t\tisSelected,\n\t\t\tposition,\n\t\t\tsiblingBlockCount,\n\t\t\tlevel,\n\t\t\tisExpanded,\n\t\t\tselectedClientIds,\n\t\t\t...props\n\t\t},\n\t\tref\n\t) => {\n\t\tconst { clientId } = block;\n\n\t\tconst { blockMovingClientId, selectedBlockInBlockEditor } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\thasBlockMovingClientId,\n\t\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\t} = select( blockEditorStore );\n\t\t\t\treturn {\n\t\t\t\t\tblockMovingClientId: hasBlockMovingClientId(),\n\t\t\t\t\tselectedBlockInBlockEditor: getSelectedBlockClientId(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\n\t\tconst isBlockMoveTarget =\n\t\t\tblockMovingClientId && selectedBlockInBlockEditor === clientId;\n\n\t\tconst className = classnames( 'block-editor-list-view-block-contents', {\n\t\t\t'is-dropping-before': isBlockMoveTarget,\n\t\t} );\n\n\t\t// Only include all selected blocks if the currently clicked on block\n\t\t// is one of the selected blocks. This ensures that if a user attempts\n\t\t// to drag a block that isn't part of the selection, they're still able\n\t\t// to drag it and rearrange its position.\n\t\tconst draggableClientIds = selectedClientIds.includes( clientId )\n\t\t\t? selectedClientIds\n\t\t\t: [ clientId ];\n\n\t\treturn (\n\t\t\t<BlockDraggable clientIds={ draggableClientIds }>\n\t\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t\t<ListViewBlockSelectButton\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\tonToggleExpanded={ onToggleExpanded }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\tsiblingBlockCount={ siblingBlockCount }\n\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\t\tonDragStart={ onDragStart }\n\t\t\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockDraggable>\n\t\t);\n\t}\n);\n\nexport default ListViewBlockContents;\n"]}
|
|
@@ -57,7 +57,6 @@ function ListViewBlockSelectButton(_ref, ref) {
|
|
|
57
57
|
|
|
58
58
|
function onKeyDownHandler(event) {
|
|
59
59
|
if (event.keyCode === ENTER || event.keyCode === SPACE) {
|
|
60
|
-
event.preventDefault();
|
|
61
60
|
onClick(event);
|
|
62
61
|
}
|
|
63
62
|
}
|
|
@@ -81,7 +80,8 @@ function ListViewBlockSelectButton(_ref, ref) {
|
|
|
81
80
|
icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon,
|
|
82
81
|
showColors: true
|
|
83
82
|
}), createElement(BlockTitle, {
|
|
84
|
-
clientId: clientId
|
|
83
|
+
clientId: clientId,
|
|
84
|
+
maximumLength: 35
|
|
85
85
|
}), (blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.anchor) && createElement("span", {
|
|
86
86
|
className: "block-editor-list-view-block-select-button__anchor"
|
|
87
87
|
}, blockInformation.anchor), isSelected && createElement(VisuallyHidden, null, __('(selected block)'))), createElement("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-select-button.js"],"names":["classnames","Button","VisuallyHidden","useInstanceId","forwardRef","__","BlockIcon","useBlockDisplayInformation","getBlockPositionDescription","BlockTitle","ListViewExpander","SPACE","ENTER","ListViewBlockSelectButton","ref","className","block","clientId","isSelected","onClick","onToggleExpanded","position","siblingBlockCount","level","tabIndex","onFocus","onDragStart","onDragEnd","draggable","isExpanded","blockInformation","instanceId","descriptionId","blockPositionDescription","onDragStartHandler","event","dataTransfer","clearData","onKeyDownHandler","keyCode","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-select-button.js"],"names":["classnames","Button","VisuallyHidden","useInstanceId","forwardRef","__","BlockIcon","useBlockDisplayInformation","getBlockPositionDescription","BlockTitle","ListViewExpander","SPACE","ENTER","ListViewBlockSelectButton","ref","className","block","clientId","isSelected","onClick","onToggleExpanded","position","siblingBlockCount","level","tabIndex","onFocus","onDragStart","onDragEnd","draggable","isExpanded","blockInformation","instanceId","descriptionId","blockPositionDescription","onDragStartHandler","event","dataTransfer","clearData","onKeyDownHandler","keyCode","icon","anchor"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,cAAjB,QAAuC,uBAAvC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ies\n */\nimport { Button, VisuallyHidden } from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { getBlockPositionDescription } from './utils';\nimport BlockTitle from '../block-title';\nimport ListViewExpander from './expander';\nimport { SPACE, ENTER } from '@wordpress/keycodes';\n\nfunction ListViewBlockSelectButton(\n\t{\n\t\tclassName,\n\t\tblock: { clientId },\n\t\tisSelected,\n\t\tonClick,\n\t\tonToggleExpanded,\n\t\tposition,\n\t\tsiblingBlockCount,\n\t\tlevel,\n\t\ttabIndex,\n\t\tonFocus,\n\t\tonDragStart,\n\t\tonDragEnd,\n\t\tdraggable,\n\t\tisExpanded,\n\t},\n\tref\n) {\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst instanceId = useInstanceId( ListViewBlockSelectButton );\n\tconst descriptionId = `list-view-block-select-button__${ instanceId }`;\n\tconst blockPositionDescription = getBlockPositionDescription(\n\t\tposition,\n\t\tsiblingBlockCount,\n\t\tlevel\n\t);\n\n\t// The `href` attribute triggers the browser's native HTML drag operations.\n\t// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.\n\t// We need to clear any HTML drag data to prevent `pasteHandler` from firing\n\t// inside the `useOnBlockDrop` hook.\n\tconst onDragStartHandler = ( event ) => {\n\t\tevent.dataTransfer.clearData();\n\t\tonDragStart( event );\n\t};\n\n\tfunction onKeyDownHandler( event ) {\n\t\tif ( event.keyCode === ENTER || event.keyCode === SPACE ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-list-view-block-select-button',\n\t\t\t\t\tclassName\n\t\t\t\t) }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tonKeyDown={ onKeyDownHandler }\n\t\t\t\taria-describedby={ descriptionId }\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tonDragStart={ onDragStartHandler }\n\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\tdraggable={ draggable }\n\t\t\t\thref={ `#block-${ clientId }` }\n\t\t\t\taria-expanded={ isExpanded }\n\t\t\t>\n\t\t\t\t<ListViewExpander onClick={ onToggleExpanded } />\n\t\t\t\t<BlockIcon icon={ blockInformation?.icon } showColors />\n\t\t\t\t<BlockTitle clientId={ clientId } maximumLength={ 35 } />\n\t\t\t\t{ blockInformation?.anchor && (\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__anchor\">\n\t\t\t\t\t\t{ blockInformation.anchor }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t{ isSelected && (\n\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t{ __( '(selected block)' ) }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\n\t\t\t</Button>\n\t\t\t<div\n\t\t\t\tclassName=\"block-editor-list-view-block-select-button__description\"\n\t\t\t\tid={ descriptionId }\n\t\t\t>\n\t\t\t\t{ blockPositionDescription }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default forwardRef( ListViewBlockSelectButton );\n"]}
|
|
@@ -38,7 +38,8 @@ function ListViewBlock(_ref) {
|
|
|
38
38
|
siblingBlockCount,
|
|
39
39
|
showBlockMovers,
|
|
40
40
|
path,
|
|
41
|
-
isExpanded
|
|
41
|
+
isExpanded,
|
|
42
|
+
selectedClientIds
|
|
42
43
|
} = _ref;
|
|
43
44
|
const cellRef = useRef(null);
|
|
44
45
|
const [isHovered, setIsHovered] = useState(false);
|
|
@@ -82,10 +83,14 @@ function ListViewBlock(_ref) {
|
|
|
82
83
|
highlightBlock(clientId, false);
|
|
83
84
|
}, [clientId, setIsHovered, highlightBlock]);
|
|
84
85
|
const selectEditorBlock = useCallback(event => {
|
|
85
|
-
event
|
|
86
|
-
selectBlock(clientId);
|
|
86
|
+
selectBlock(event, clientId);
|
|
87
87
|
}, [clientId, selectBlock]);
|
|
88
|
+
const selectDuplicatedBlock = useCallback(newClientId => {
|
|
89
|
+
selectBlock(undefined, newClientId);
|
|
90
|
+
}, [selectBlock]);
|
|
88
91
|
const toggleExpanded = useCallback(event => {
|
|
92
|
+
// Prevent shift+click from opening link in a new window when toggling.
|
|
93
|
+
event.preventDefault();
|
|
89
94
|
event.stopPropagation();
|
|
90
95
|
|
|
91
96
|
if (isExpanded === true) {
|
|
@@ -94,7 +99,7 @@ function ListViewBlock(_ref) {
|
|
|
94
99
|
expand(clientId);
|
|
95
100
|
}
|
|
96
101
|
}, [clientId, expand, collapse, isExpanded]);
|
|
97
|
-
const showBlockActions = withExperimentalFeatures && ( //hide actions for blocks like core/widget-areas
|
|
102
|
+
const showBlockActions = withExperimentalFeatures && ( // hide actions for blocks like core/widget-areas
|
|
98
103
|
!hideContainerBlockActions || hideContainerBlockActions && level > 1);
|
|
99
104
|
const hideBlockActions = withExperimentalFeatures && !showBlockActions;
|
|
100
105
|
let colSpan;
|
|
@@ -112,8 +117,13 @@ function ListViewBlock(_ref) {
|
|
|
112
117
|
'has-single-cell': hideBlockActions
|
|
113
118
|
});
|
|
114
119
|
const blockInformation = useBlockDisplayInformation(clientId);
|
|
115
|
-
const settingsAriaLabel = sprintf( // translators: %s: The title of the block.
|
|
116
|
-
__('Options for %s block'), blockInformation.title);
|
|
120
|
+
const settingsAriaLabel = blockInformation ? sprintf( // translators: %s: The title of the block.
|
|
121
|
+
__('Options for %s block'), blockInformation.title) : __('Options'); // Only include all selected blocks if the currently clicked on block
|
|
122
|
+
// is one of the selected blocks. This ensures that if a user attempts
|
|
123
|
+
// to alter a block that isn't part of the selection, they're still able
|
|
124
|
+
// to do so.
|
|
125
|
+
|
|
126
|
+
const dropdownClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId];
|
|
117
127
|
return createElement(ListViewLeaf, {
|
|
118
128
|
className: classes,
|
|
119
129
|
onMouseEnter: onMouseEnter,
|
|
@@ -150,7 +160,8 @@ function ListViewBlock(_ref) {
|
|
|
150
160
|
ref: ref,
|
|
151
161
|
tabIndex: tabIndex,
|
|
152
162
|
onFocus: onFocus,
|
|
153
|
-
isExpanded: isExpanded
|
|
163
|
+
isExpanded: isExpanded,
|
|
164
|
+
selectedClientIds: selectedClientIds
|
|
154
165
|
}));
|
|
155
166
|
}), hasRenderedMovers && createElement(Fragment, null, createElement(TreeGridCell, {
|
|
156
167
|
className: moverCellClassName,
|
|
@@ -190,7 +201,7 @@ function ListViewBlock(_ref) {
|
|
|
190
201
|
onFocus
|
|
191
202
|
} = _ref5;
|
|
192
203
|
return createElement(BlockSettingsDropdown, {
|
|
193
|
-
clientIds:
|
|
204
|
+
clientIds: dropdownClientIds,
|
|
194
205
|
icon: moreVertical,
|
|
195
206
|
label: settingsAriaLabel,
|
|
196
207
|
toggleProps: {
|
|
@@ -200,7 +211,7 @@ function ListViewBlock(_ref) {
|
|
|
200
211
|
onFocus
|
|
201
212
|
},
|
|
202
213
|
disableOpenOnArrowDown: true,
|
|
203
|
-
__experimentalSelectBlock:
|
|
214
|
+
__experimentalSelectBlock: selectDuplicatedBlock
|
|
204
215
|
});
|
|
205
216
|
}));
|
|
206
217
|
}
|