@wordpress/block-editor 8.1.2 → 8.3.0-next.e230fbab09.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +6 -26
- package/build/autocompleters/link.js +78 -0
- package/build/autocompleters/link.js.map +1 -0
- package/build/components/autocomplete/index.js +3 -1
- package/build/components/autocomplete/index.js.map +1 -1
- package/build/components/block-actions/index.js +1 -1
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-breadcrumb/index.js +4 -2
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-compare/index.js +2 -2
- package/build/components/block-compare/index.js.map +1 -1
- package/build/components/block-controls/index.js +1 -1
- package/build/components/block-controls/index.js.map +1 -1
- package/build/components/block-draggable/index.js +1 -1
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-edit/edit.js +1 -1
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-list/block-html.js +1 -1
- package/build/components/block-list/block-html.js.map +1 -1
- package/build/components/block-list/block-invalid-warning.js +1 -1
- package/build/components/block-list/block-invalid-warning.js.map +1 -1
- package/build/components/block-list/block-list-item.native.js +4 -4
- package/build/components/block-list/block-list-item.native.js.map +1 -1
- package/build/components/block-list/block-selection-button.native.js +4 -3
- package/build/components/block-list/block-selection-button.native.js.map +1 -1
- package/build/components/block-list/block.js +17 -3
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +6 -6
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +5 -5
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js +3 -0
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-list/use-block-props/use-multi-selection.js +25 -27
- package/build/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build/components/block-media-update-progress/index.native.js +4 -4
- package/build/components/block-media-update-progress/index.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +3 -3
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/index.native.js +1 -1
- package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build/components/block-mover/mover-description.js +4 -4
- package/build/components/block-mover/mover-description.js.map +1 -1
- package/build/components/block-mover/mover-description.native.js +5 -5
- package/build/components/block-mover/mover-description.native.js.map +1 -1
- package/build/components/block-settings/container.native.js +1 -5
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +7 -12
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/preview.native.js +1 -1
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/block-switcher/index.js +2 -1
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/use-transformed-patterns.js +0 -1
- package/build/components/block-switcher/use-transformed-patterns.js.map +1 -1
- package/build/components/block-title/index.js +7 -62
- package/build/components/block-title/index.js.map +1 -1
- package/build/components/block-title/use-block-display-title.js +94 -0
- package/build/components/block-title/use-block-display-title.js.map +1 -0
- package/build/components/block-toolbar/utils.js +9 -1
- package/build/components/block-toolbar/utils.js.map +1 -1
- package/build/components/block-tools/block-popover.js +1 -1
- package/build/components/block-tools/block-popover.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +2 -1
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-types-list/index.native.js +1 -1
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/border-radius-control/index.js +2 -2
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/utils.js +10 -6
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/contrast-checker/index.js +3 -3
- package/build/components/contrast-checker/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/index.js +1 -1
- package/build/components/convert-to-group-buttons/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +1 -3
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build/components/copy-handler/index.js +3 -3
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +3 -3
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +38 -1
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +4 -4
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +1 -1
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-block-type-impressions.native.js +2 -2
- package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build/components/inserter/index.js +3 -3
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +7 -7
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/menu.native.js +3 -3
- package/build/components/inserter/menu.native.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +20 -8
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-items.js +1 -1
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter/search-results.js +28 -11
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -1
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +3 -3
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/line-height-control/index.js +63 -45
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/line-height-control/index.native.js +3 -1
- package/build/components/line-height-control/index.native.js.map +1 -1
- package/build/components/link-control/index.js +2 -2
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/search-results.js +2 -2
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/link-control/use-rich-url-data.js +1 -1
- package/build/components/link-control/use-rich-url-data.js.map +1 -1
- package/build/components/link-control/use-search-handler.js +2 -2
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/list-view/block-contents.js +8 -4
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block-select-button.js +2 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +20 -9
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +2 -1
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +49 -41
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +139 -0
- package/build/components/list-view/use-block-selection.js.map +1 -0
- package/build/components/list-view/use-list-view-expand-selected-item.js +60 -0
- package/build/components/list-view/use-list-view-expand-selected-item.js.map +1 -0
- package/build/components/list-view/utils.js +29 -1
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/media-placeholder/index.native.js +7 -5
- package/build/components/media-placeholder/index.native.js.map +1 -1
- package/build/components/media-replace-flow/index.js +20 -24
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/media-upload/index.native.js +4 -3
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/media-upload-progress/index.native.js +2 -2
- package/build/components/media-upload-progress/index.native.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +3 -3
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/plain-text/index.native.js +3 -3
- package/build/components/plain-text/index.native.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +2 -2
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.native.js +1 -1
- package/build/components/rich-text/format-toolbar-container.native.js.map +1 -1
- package/build/components/rich-text/index.js +7 -12
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +3 -3
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +7 -12
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/url-input/index.js +11 -11
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +1 -1
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +2 -2
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/writing-flow/index.js +1 -0
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +22 -24
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-select-all.js +3 -2
- package/build/components/writing-flow/use-select-all.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +4 -3
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/align.js +1 -1
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/anchor.js +1 -1
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border.js +2 -14
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +2 -2
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/custom-class-name.js +40 -0
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/duotone.js +22 -4
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/generated-class-name.js +3 -3
- package/build/hooks/generated-class-name.js.map +1 -1
- package/build/hooks/line-height.js +2 -0
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/lock.js +1 -1
- package/build/hooks/lock.js.map +1 -1
- package/build/hooks/style.js +32 -13
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/flow.js +7 -5
- package/build/layouts/flow.js.map +1 -1
- package/build/store/actions.js +55 -48
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +2 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/index.js +1 -2
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +13 -13
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +6 -6
- package/build/store/selectors.js.map +1 -1
- package/build/utils/index.js +0 -14
- package/build/utils/index.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +3 -3
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build/utils/pasting.js +91 -0
- package/build/utils/pasting.js.map +1 -0
- package/build/utils/transform-styles/ast/parse.js +5 -5
- package/build/utils/transform-styles/ast/parse.js.map +1 -1
- package/build/utils/transform-styles/transforms/url-rewrite.js +2 -2
- package/build/utils/transform-styles/transforms/url-rewrite.js.map +1 -1
- package/build-module/autocompleters/link.js +64 -0
- package/build-module/autocompleters/link.js.map +1 -0
- package/build-module/components/autocomplete/index.js +2 -1
- package/build-module/components/autocomplete/index.js.map +1 -1
- package/build-module/components/block-actions/index.js +1 -1
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +4 -2
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-compare/index.js +2 -2
- package/build-module/components/block-compare/index.js.map +1 -1
- package/build-module/components/block-controls/index.js +1 -1
- package/build-module/components/block-controls/index.js.map +1 -1
- package/build-module/components/block-draggable/index.js +1 -1
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-edit/edit.js +1 -1
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-list/block-html.js +1 -1
- package/build-module/components/block-list/block-html.js.map +1 -1
- package/build-module/components/block-list/block-invalid-warning.js +1 -1
- package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
- package/build-module/components/block-list/block-list-item.native.js +4 -4
- package/build-module/components/block-list/block-list-item.native.js.map +1 -1
- package/build-module/components/block-list/block-selection-button.native.js +4 -3
- package/build-module/components/block-list/block-selection-button.native.js.map +1 -1
- package/build-module/components/block-list/block.js +18 -4
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +7 -7
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +5 -5
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +2 -0
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-multi-selection.js +23 -28
- package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build-module/components/block-media-update-progress/index.native.js +4 -4
- package/build-module/components/block-media-update-progress/index.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +3 -3
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-mover/mover-description.js +4 -4
- package/build-module/components/block-mover/mover-description.js.map +1 -1
- package/build-module/components/block-mover/mover-description.native.js +5 -5
- package/build-module/components/block-mover/mover-description.native.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +2 -6
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +7 -13
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js +1 -1
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/block-switcher/index.js +2 -1
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/use-transformed-patterns.js +0 -1
- package/build-module/components/block-switcher/use-transformed-patterns.js.map +1 -1
- package/build-module/components/block-title/index.js +7 -58
- package/build-module/components/block-title/index.js.map +1 -1
- package/build-module/components/block-title/use-block-display-title.js +80 -0
- package/build-module/components/block-title/use-block-display-title.js.map +1 -0
- package/build-module/components/block-toolbar/utils.js +9 -1
- package/build-module/components/block-toolbar/utils.js.map +1 -1
- package/build-module/components/block-tools/block-popover.js +1 -1
- package/build-module/components/block-tools/block-popover.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +2 -1
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +1 -1
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +3 -3
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js +11 -7
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/contrast-checker/index.js +3 -3
- package/build-module/components/contrast-checker/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/index.js +1 -1
- package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +1 -3
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build-module/components/copy-handler/index.js +2 -2
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +3 -3
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +5 -4
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +4 -4
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +1 -1
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js +2 -2
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build-module/components/inserter/index.js +3 -3
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +7 -7
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/menu.native.js +3 -3
- package/build-module/components/inserter/menu.native.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +20 -8
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-items.js +1 -1
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter/search-results.js +28 -11
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -1
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +3 -3
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js +61 -45
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/line-height-control/index.native.js +3 -1
- package/build-module/components/line-height-control/index.native.js.map +1 -1
- package/build-module/components/link-control/index.js +2 -2
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/search-results.js +2 -2
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/link-control/use-rich-url-data.js +1 -1
- package/build-module/components/link-control/use-rich-url-data.js.map +1 -1
- package/build-module/components/link-control/use-search-handler.js +2 -2
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +8 -4
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +2 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +20 -9
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +2 -1
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +46 -42
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +123 -0
- package/build-module/components/list-view/use-block-selection.js.map +1 -0
- package/build-module/components/list-view/use-list-view-expand-selected-item.js +50 -0
- package/build-module/components/list-view/use-list-view-expand-selected-item.js.map +1 -0
- package/build-module/components/list-view/utils.js +25 -0
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/media-placeholder/index.native.js +7 -5
- package/build-module/components/media-placeholder/index.native.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +22 -27
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +4 -3
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/media-upload-progress/index.native.js +2 -2
- package/build-module/components/media-upload-progress/index.native.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +3 -3
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/plain-text/index.native.js +3 -3
- package/build-module/components/plain-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +2 -2
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.native.js +1 -1
- package/build-module/components/rich-text/format-toolbar-container.native.js.map +1 -1
- package/build-module/components/rich-text/index.js +7 -12
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +3 -3
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +6 -12
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/url-input/index.js +11 -11
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +1 -1
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +2 -2
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/writing-flow/index.js +1 -0
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +21 -21
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-select-all.js +3 -2
- package/build-module/components/writing-flow/use-select-all.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +4 -3
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/align.js +1 -1
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/anchor.js +1 -1
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border.js +2 -14
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +2 -2
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +38 -0
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/duotone.js +23 -5
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/generated-class-name.js +3 -3
- package/build-module/hooks/generated-class-name.js.map +1 -1
- package/build-module/hooks/line-height.js +2 -0
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/lock.js +1 -1
- package/build-module/hooks/lock.js.map +1 -1
- package/build-module/hooks/style.js +31 -13
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/flow.js +7 -5
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/store/actions.js +52 -45
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +2 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/index.js +1 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +13 -13
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +6 -6
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/index.js +0 -1
- package/build-module/utils/index.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +3 -3
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/utils/pasting.js +80 -0
- package/build-module/utils/pasting.js.map +1 -0
- package/build-module/utils/transform-styles/ast/parse.js +5 -5
- package/build-module/utils/transform-styles/ast/parse.js.map +1 -1
- package/build-module/utils/transform-styles/transforms/url-rewrite.js +2 -2
- package/build-module/utils/transform-styles/transforms/url-rewrite.js.map +1 -1
- package/build-style/style-rtl.css +10 -12
- package/build-style/style.css +10 -12
- package/package.json +27 -26
- package/src/autocompleters/link.js +62 -0
- package/src/autocompleters/style.scss +8 -0
- package/src/components/alignment-control/test/index.js +2 -2
- package/src/components/autocomplete/index.js +2 -0
- package/src/components/block-actions/index.js +1 -1
- package/src/components/block-alignment-control/test/index.js +1 -1
- package/src/components/block-breadcrumb/index.js +5 -2
- package/src/components/block-compare/index.js +2 -2
- package/src/components/block-controls/index.js +1 -1
- package/src/components/block-draggable/index.js +1 -1
- package/src/components/block-draggable/stories/index.js +1 -1
- package/src/components/block-edit/edit.js +1 -1
- package/src/components/block-list/block-html.js +1 -1
- package/src/components/block-list/block-invalid-warning.js +1 -1
- package/src/components/block-list/block-list-item.native.js +4 -4
- package/src/components/block-list/block-selection-button.native.js +3 -3
- package/src/components/block-list/block.js +28 -4
- package/src/components/block-list/block.native.js +7 -6
- package/src/components/block-list/index.native.js +5 -5
- package/src/components/block-list/style.scss +3 -1
- package/src/components/block-list/use-block-props/use-block-class-names.js +1 -1
- package/src/components/block-list/use-block-props/use-focus-first-element.js +3 -0
- package/src/components/block-list/use-block-props/use-multi-selection.js +22 -30
- package/src/components/block-media-update-progress/index.native.js +4 -4
- package/src/components/block-media-update-progress/test/index.native.js +2 -2
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +3 -3
- package/src/components/block-mobile-toolbar/index.native.js +2 -2
- package/src/components/block-mover/mover-description.js +4 -4
- package/src/components/block-mover/mover-description.native.js +5 -5
- package/src/components/block-settings/container.native.js +5 -6
- package/src/components/block-settings-menu/block-settings-dropdown.js +7 -8
- package/src/components/block-styles/preview.native.js +1 -1
- package/src/components/block-switcher/index.js +4 -1
- package/src/components/block-switcher/use-transformed-patterns.js +0 -1
- package/src/components/block-title/README.md +17 -1
- package/src/components/block-title/index.js +7 -62
- package/src/components/block-title/test/index.js +21 -3
- package/src/components/block-title/use-block-display-title.js +83 -0
- package/src/components/block-toolbar/utils.js +12 -2
- package/src/components/block-tools/block-popover.js +1 -1
- package/src/components/block-tools/block-selection-button.js +4 -1
- package/src/components/block-types-list/index.native.js +1 -1
- package/src/components/border-radius-control/index.js +5 -3
- package/src/components/border-radius-control/test/utils.js +10 -10
- package/src/components/border-radius-control/utils.js +10 -8
- package/src/components/contrast-checker/index.js +3 -3
- package/src/components/convert-to-group-buttons/index.js +1 -1
- package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +1 -6
- package/src/components/copy-handler/index.js +2 -2
- package/src/components/font-sizes/with-font-sizes.js +3 -3
- package/src/components/image-size-control/test/index.js +1 -1
- package/src/components/index.js +1 -0
- package/src/components/index.native.js +11 -4
- package/src/components/inserter/block-patterns-tab.js +13 -17
- package/src/components/inserter/block-types-tab.js +1 -1
- package/src/components/inserter/hooks/use-block-type-impressions.native.js +2 -2
- package/src/components/inserter/index.js +3 -3
- package/src/components/inserter/index.native.js +7 -7
- package/src/components/inserter/menu.js +1 -1
- package/src/components/inserter/menu.native.js +3 -3
- package/src/components/inserter/quick-inserter.js +32 -10
- package/src/components/inserter/search-items.js +1 -1
- package/src/components/inserter/search-results.js +55 -43
- package/src/components/inserter/test/fixtures/index.native.js +1 -1
- package/src/components/inserter/test/reusable-blocks-tab.js +2 -2
- package/src/components/justify-content-control/README.md +1 -1
- package/src/components/keyboard-shortcuts/index.js +1 -1
- package/src/components/letter-spacing-control/index.js +1 -1
- package/src/components/line-height-control/README.md +13 -2
- package/src/components/line-height-control/index.js +66 -43
- package/src/components/line-height-control/index.native.js +2 -0
- package/src/components/line-height-control/stories/index.js +33 -0
- package/src/components/line-height-control/test/index.js +61 -0
- package/src/components/link-control/index.js +2 -2
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/link-control/search-results.js +2 -2
- package/src/components/link-control/test/index.js +142 -144
- package/src/components/link-control/use-rich-url-data.js +1 -1
- package/src/components/link-control/use-search-handler.js +2 -2
- package/src/components/list-view/README.md +2 -2
- package/src/components/list-view/block-contents.js +10 -3
- package/src/components/list-view/block-select-button.js +1 -2
- package/src/components/list-view/block.js +30 -10
- package/src/components/list-view/branch.js +1 -0
- package/src/components/list-view/index.js +56 -30
- package/src/components/list-view/test/utils.js +50 -0
- package/src/components/list-view/use-block-selection.js +163 -0
- package/src/components/list-view/use-list-view-expand-selected-item.js +58 -0
- package/src/components/list-view/utils.js +31 -0
- package/src/components/media-placeholder/index.native.js +11 -9
- package/src/components/media-replace-flow/README.md +7 -0
- package/src/components/media-replace-flow/index.js +20 -26
- package/src/components/media-replace-flow/test/index.js +100 -0
- package/src/components/media-upload/index.native.js +3 -2
- package/src/components/media-upload-progress/index.native.js +2 -2
- package/src/components/navigable-toolbar/index.js +3 -3
- package/src/components/plain-text/index.native.js +3 -3
- package/src/components/responsive-block-control/test/index.js +6 -6
- package/src/components/rich-text/format-toolbar-container.js +2 -2
- package/src/components/rich-text/format-toolbar-container.native.js +1 -1
- package/src/components/rich-text/index.js +7 -14
- package/src/components/rich-text/index.native.js +3 -3
- package/src/components/rich-text/use-paste-handler.js +7 -14
- package/src/components/url-input/index.js +11 -11
- package/src/components/use-block-drop-zone/test/index.js +1 -1
- package/src/components/use-moving-animation/index.js +1 -1
- package/src/components/use-on-block-drop/index.js +2 -2
- package/src/components/writing-flow/index.js +1 -0
- package/src/components/writing-flow/use-multi-selection.js +17 -20
- package/src/components/writing-flow/use-select-all.js +6 -2
- package/src/components/writing-flow/use-tab-nav.js +6 -3
- package/src/hooks/align.js +1 -1
- package/src/hooks/anchor.js +1 -1
- package/src/hooks/border.js +8 -19
- package/src/hooks/color.js +2 -2
- package/src/hooks/custom-class-name.js +45 -0
- package/src/hooks/duotone.js +27 -3
- package/src/hooks/generated-class-name.js +3 -3
- package/src/hooks/line-height.js +2 -0
- package/src/hooks/lock.js +1 -1
- package/src/hooks/style.js +31 -13
- package/src/hooks/test/align.js +1 -1
- package/src/hooks/typography.scss +0 -4
- package/src/layouts/flow.js +10 -5
- package/src/store/actions.js +24 -14
- package/src/store/defaults.js +2 -2
- package/src/store/index.js +0 -1
- package/src/store/reducer.js +13 -12
- package/src/store/selectors.js +6 -6
- package/src/store/test/actions.js +2 -2
- package/src/store/test/reducer.js +10 -1
- package/src/store/test/selectors.js +1 -1
- package/src/style.scss +0 -1
- package/src/utils/index.js +0 -1
- package/src/utils/parse-css-unit-to-px.js +3 -3
- package/src/utils/pasting.js +77 -0
- package/src/utils/test/parse-css-unit-to-px.js +5 -5
- package/src/utils/test/pasting.js +84 -0
- package/src/utils/transform-styles/ast/parse.js +5 -5
- package/src/utils/transform-styles/transforms/url-rewrite.js +2 -2
- package/build/utils/get-paste-event-data.js +0 -56
- package/build/utils/get-paste-event-data.js.map +0 -1
- package/build/utils/theme.js +0 -63
- package/build/utils/theme.js.map +0 -1
- package/build-module/utils/get-paste-event-data.js +0 -47
- package/build-module/utils/get-paste-event-data.js.map +0 -1
- package/build-module/utils/theme.js +0 -53
- package/build-module/utils/theme.js.map +0 -1
- package/src/components/line-height-control/style.scss +0 -8
- package/src/components/writing-flow/test/use-multi-selection.js +0 -36
- package/src/utils/get-paste-event-data.js +0 -42
- package/src/utils/theme.js +0 -48
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default = void 0;
|
|
8
|
+
exports.default = exports.BLOCK_LIST_ITEM_HEIGHT = void 0;
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
@@ -25,10 +25,14 @@ var _context = require("./context");
|
|
|
25
25
|
|
|
26
26
|
var _dropIndicator = _interopRequireDefault(require("./drop-indicator"));
|
|
27
27
|
|
|
28
|
+
var _useBlockSelection = _interopRequireDefault(require("./use-block-selection"));
|
|
29
|
+
|
|
28
30
|
var _useListViewClientIds = _interopRequireDefault(require("./use-list-view-client-ids"));
|
|
29
31
|
|
|
30
32
|
var _useListViewDropZone = _interopRequireDefault(require("./use-list-view-drop-zone"));
|
|
31
33
|
|
|
34
|
+
var _useListViewExpandSelectedItem = _interopRequireDefault(require("./use-list-view-expand-selected-item"));
|
|
35
|
+
|
|
32
36
|
var _store = require("../../store");
|
|
33
37
|
|
|
34
38
|
/**
|
|
@@ -38,49 +42,39 @@ var _store = require("../../store");
|
|
|
38
42
|
/**
|
|
39
43
|
* Internal dependencies
|
|
40
44
|
*/
|
|
41
|
-
const noop = () => {};
|
|
42
|
-
|
|
43
45
|
const expanded = (state, action) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
case 'collapse':
|
|
53
|
-
return { ...state,
|
|
54
|
-
...{
|
|
55
|
-
[action.clientId]: false
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
default:
|
|
60
|
-
return state;
|
|
46
|
+
if (Array.isArray(action.clientIds)) {
|
|
47
|
+
return { ...state,
|
|
48
|
+
...action.clientIds.reduce((newState, id) => ({ ...newState,
|
|
49
|
+
[id]: action.type === 'expand'
|
|
50
|
+
}), {})
|
|
51
|
+
};
|
|
61
52
|
}
|
|
53
|
+
|
|
54
|
+
return state;
|
|
62
55
|
};
|
|
56
|
+
|
|
57
|
+
const BLOCK_LIST_ITEM_HEIGHT = 36;
|
|
63
58
|
/**
|
|
64
59
|
* Wrap `ListViewRows` with `TreeGrid`. ListViewRows is a
|
|
65
60
|
* recursive component (it renders itself), so this ensures TreeGrid is only
|
|
66
61
|
* present at the very top of the navigation grid.
|
|
67
62
|
*
|
|
68
|
-
* @param {Object}
|
|
69
|
-
* @param {Array}
|
|
70
|
-
* @param {
|
|
71
|
-
* @param {boolean}
|
|
72
|
-
* @param {boolean}
|
|
73
|
-
* @param {boolean}
|
|
74
|
-
* @param {boolean}
|
|
75
|
-
* @param {
|
|
76
|
-
* @param {Object} ref Forwarded ref
|
|
63
|
+
* @param {Object} props Components props.
|
|
64
|
+
* @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.
|
|
65
|
+
* @param {boolean} props.showNestedBlocks Flag to enable displaying nested blocks.
|
|
66
|
+
* @param {boolean} props.showBlockMovers Flag to enable block movers
|
|
67
|
+
* @param {boolean} props.__experimentalFeatures Flag to enable experimental features.
|
|
68
|
+
* @param {boolean} props.__experimentalPersistentListViewFeatures Flag to enable features for the Persistent List View experiment.
|
|
69
|
+
* @param {boolean} props.__experimentalHideContainerBlockActions Flag to hide actions of top level blocks (like core/widget-area)
|
|
70
|
+
* @param {Object} ref Forwarded ref
|
|
77
71
|
*/
|
|
78
72
|
|
|
73
|
+
exports.BLOCK_LIST_ITEM_HEIGHT = BLOCK_LIST_ITEM_HEIGHT;
|
|
79
74
|
|
|
80
75
|
function ListView(_ref, ref) {
|
|
81
76
|
let {
|
|
82
77
|
blocks,
|
|
83
|
-
onSelect = noop,
|
|
84
78
|
__experimentalFeatures,
|
|
85
79
|
__experimentalPersistentListViewFeatures,
|
|
86
80
|
__experimentalHideContainerBlockActions,
|
|
@@ -93,9 +87,6 @@ function ListView(_ref, ref) {
|
|
|
93
87
|
draggedClientIds,
|
|
94
88
|
selectedClientIds
|
|
95
89
|
} = (0, _useListViewClientIds.default)(blocks);
|
|
96
|
-
const {
|
|
97
|
-
selectBlock
|
|
98
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
99
90
|
const {
|
|
100
91
|
visibleBlockCount
|
|
101
92
|
} = (0, _data.useSelect)(select => {
|
|
@@ -108,10 +99,9 @@ function ListView(_ref, ref) {
|
|
|
108
99
|
visibleBlockCount: getGlobalBlockCount() - draggedBlockCount
|
|
109
100
|
};
|
|
110
101
|
}, [draggedClientIds]);
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}, [selectBlock, onSelect]);
|
|
102
|
+
const {
|
|
103
|
+
updateBlockSelection
|
|
104
|
+
} = (0, _useBlockSelection.default)();
|
|
115
105
|
const [expandedState, setExpandedState] = (0, _element.useReducer)(expanded, {});
|
|
116
106
|
const {
|
|
117
107
|
ref: dropZoneRef,
|
|
@@ -120,13 +110,23 @@ function ListView(_ref, ref) {
|
|
|
120
110
|
const elementRef = (0, _element.useRef)();
|
|
121
111
|
const treeGridRef = (0, _compose.useMergeRefs)([elementRef, dropZoneRef, ref]);
|
|
122
112
|
const isMounted = (0, _element.useRef)(false);
|
|
113
|
+
const {
|
|
114
|
+
setSelectedTreeId
|
|
115
|
+
} = (0, _useListViewExpandSelectedItem.default)({
|
|
116
|
+
firstSelectedBlockClientId: selectedClientIds[0],
|
|
117
|
+
setExpandedState
|
|
118
|
+
});
|
|
119
|
+
const selectEditorBlock = (0, _element.useCallback)((event, clientId) => {
|
|
120
|
+
updateBlockSelection(event, clientId);
|
|
121
|
+
setSelectedTreeId(clientId);
|
|
122
|
+
}, [setSelectedTreeId, updateBlockSelection]);
|
|
123
123
|
(0, _element.useEffect)(() => {
|
|
124
124
|
isMounted.current = true;
|
|
125
125
|
}, []); // List View renders a fixed number of items and relies on each having a fixed item height of 36px.
|
|
126
126
|
// If this value changes, we should also change the itemHeight value set in useFixedWindowList.
|
|
127
127
|
// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.
|
|
128
128
|
|
|
129
|
-
const [fixedListWindow] = (0, _compose.__experimentalUseFixedWindowList)(elementRef,
|
|
129
|
+
const [fixedListWindow] = (0, _compose.__experimentalUseFixedWindowList)(elementRef, BLOCK_LIST_ITEM_HEIGHT, visibleBlockCount, {
|
|
130
130
|
useWindowing: __experimentalPersistentListViewFeatures,
|
|
131
131
|
windowOverscan: 40
|
|
132
132
|
});
|
|
@@ -137,7 +137,7 @@ function ListView(_ref, ref) {
|
|
|
137
137
|
|
|
138
138
|
setExpandedState({
|
|
139
139
|
type: 'expand',
|
|
140
|
-
clientId
|
|
140
|
+
clientIds: [clientId]
|
|
141
141
|
});
|
|
142
142
|
}, [setExpandedState]);
|
|
143
143
|
const collapse = (0, _element.useCallback)(clientId => {
|
|
@@ -147,7 +147,7 @@ function ListView(_ref, ref) {
|
|
|
147
147
|
|
|
148
148
|
setExpandedState({
|
|
149
149
|
type: 'collapse',
|
|
150
|
-
clientId
|
|
150
|
+
clientIds: [clientId]
|
|
151
151
|
});
|
|
152
152
|
}, [setExpandedState]);
|
|
153
153
|
const expandRow = (0, _element.useCallback)(row => {
|
|
@@ -160,6 +160,13 @@ function ListView(_ref, ref) {
|
|
|
160
160
|
|
|
161
161
|
collapse(row === null || row === void 0 ? void 0 : (_row$dataset2 = row.dataset) === null || _row$dataset2 === void 0 ? void 0 : _row$dataset2.block);
|
|
162
162
|
}, [collapse]);
|
|
163
|
+
const focusRow = (0, _element.useCallback)((event, startRow, endRow) => {
|
|
164
|
+
if (event.shiftKey) {
|
|
165
|
+
var _startRow$dataset, _endRow$dataset;
|
|
166
|
+
|
|
167
|
+
updateBlockSelection(event, startRow === null || startRow === void 0 ? void 0 : (_startRow$dataset = startRow.dataset) === null || _startRow$dataset === void 0 ? void 0 : _startRow$dataset.block, endRow === null || endRow === void 0 ? void 0 : (_endRow$dataset = endRow.dataset) === null || _endRow$dataset === void 0 ? void 0 : _endRow$dataset.block);
|
|
168
|
+
}
|
|
169
|
+
}, [updateBlockSelection]);
|
|
163
170
|
const contextValue = (0, _element.useMemo)(() => ({
|
|
164
171
|
__experimentalFeatures,
|
|
165
172
|
__experimentalPersistentListViewFeatures,
|
|
@@ -180,7 +187,8 @@ function ListView(_ref, ref) {
|
|
|
180
187
|
"aria-label": (0, _i18n.__)('Block navigation structure'),
|
|
181
188
|
ref: treeGridRef,
|
|
182
189
|
onCollapseRow: collapseRow,
|
|
183
|
-
onExpandRow: expandRow
|
|
190
|
+
onExpandRow: expandRow,
|
|
191
|
+
onFocusRow: focusRow
|
|
184
192
|
}, (0, _element.createElement)(_context.ListViewContext.Provider, {
|
|
185
193
|
value: contextValue
|
|
186
194
|
}, (0, _element.createElement)(_branch.default, (0, _extends2.default)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/index.js"],"names":["noop","expanded","state","action","type","clientId","ListView","ref","blocks","onSelect","__experimentalFeatures","__experimentalPersistentListViewFeatures","__experimentalHideContainerBlockActions","showNestedBlocks","showBlockMovers","props","clientIdsTree","draggedClientIds","selectedClientIds","selectBlock","blockEditorStore","visibleBlockCount","select","getGlobalBlockCount","getClientIdsOfDescendants","draggedBlockCount","length","selectEditorBlock","expandedState","setExpandedState","dropZoneRef","target","blockDropTarget","elementRef","treeGridRef","isMounted","current","fixedListWindow","useWindowing","windowOverscan","expand","collapse","expandRow","row","dataset","block","collapseRow","contextValue","isTreeGridMounted"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAIA;;AACA;;AASA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA3BA;AACA;AACA;;AAiBA;AACA;AACA;AAQA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AACA,MAAMC,QAAQ,GAAG,CAAEC,KAAF,EAASC,MAAT,KAAqB;AACrC,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,QAAL;AACC,aAAO,EAAE,GAAGF,KAAL;AAAY,WAAG;AAAE,WAAEC,MAAM,CAACE,QAAT,GAAqB;AAAvB;AAAf,OAAP;;AACD,SAAK,UAAL;AACC,aAAO,EAAE,GAAGH,KAAL;AAAY,WAAG;AAAE,WAAEC,MAAM,CAACE,QAAT,GAAqB;AAAvB;AAAf,OAAP;;AACD;AACC,aAAOH,KAAP;AANF;AAQA,CATD;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASI,QAAT,OAWCC,GAXD,EAYE;AAAA,MAXD;AACCC,IAAAA,MADD;AAECC,IAAAA,QAAQ,GAAGT,IAFZ;AAGCU,IAAAA,sBAHD;AAICC,IAAAA,wCAJD;AAKCC,IAAAA,uC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wCAFO;AAGPC,IAAAA,uCAHO;AAIPoC,IAAAA,iBAAiB,EAAEb,SAAS,CAACC,OAJtB;AAKPnB,IAAAA,gBALO;AAMPW,IAAAA,aANO;AAOPY,IAAAA,MAPO;AAQPC,IAAAA;AARO,GAAR,CADoB,EAWpB,CACC/B,sBADD,EAECC,wCAFD,EAGCC,uCAHD,EAICuB,SAAS,CAACC,OAJX,EAKCnB,gBALD,EAMCW,aAND,EAOCY,MAPD,EAQCC,QARD,CAXoB,CAArB;AAuBA,SACC,4BAAC,uBAAD;AAAmB,IAAA,KAAK,EAAG;AAA3B,KACC,4BAAC,sBAAD;AACC,IAAA,WAAW,EAAGR,UADf;AAEC,IAAA,eAAe,EAAGD;AAFnB,IADD,EAKC,4BAAC,kCAAD;AACC,IAAA,SAAS,EAAC,6BADX;AAEC,kBAAa,cAAI,4BAAJ,CAFd;AAGC,IAAA,GAAG,EAAGE,WAHP;AAIC,IAAA,aAAa,EAAGY,WAJjB;AAKC,IAAA,WAAW,EAAGJ;AALf,KAOC,4BAAC,wBAAD,CAAiB,QAAjB;AAA0B,IAAA,KAAK,EAAGK;AAAlC,KACC,4BAAC,eAAD;AACC,IAAA,MAAM,EAAG/B,aADV;AAEC,IAAA,WAAW,EAAGW,iBAFf;AAGC,IAAA,gBAAgB,EAAGd,gBAHpB;AAIC,IAAA,eAAe,EAAGC,eAJnB;AAKC,IAAA,eAAe,EAAGuB,eALnB;AAMC,IAAA,iBAAiB,EAAGnB;AANrB,KAOMH,KAPN,EADD,CAPD,CALD,CADD;AA2BA;;eACc,yBAAYT,QAAZ,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';\nimport { AsyncModeProvider, useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseReducer,\n\tforwardRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewBranch from './branch';\nimport { ListViewContext } from './context';\nimport ListViewDropIndicator from './drop-indicator';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewDropZone from './use-list-view-drop-zone';\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\nconst expanded = ( state, action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'expand':\n\t\t\treturn { ...state, ...{ [ action.clientId ]: true } };\n\t\tcase 'collapse':\n\t\t\treturn { ...state, ...{ [ action.clientId ]: false } };\n\t\tdefault:\n\t\t\treturn state;\n\t}\n};\n\n/**\n * Wrap `ListViewRows` with `TreeGrid`. ListViewRows is a\n * recursive component (it renders itself), so this ensures TreeGrid is only\n * present at the very top of the navigation grid.\n *\n * @param {Object} props Components props.\n * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.\n * @param {Function} props.onSelect Block selection callback.\n * @param {boolean} props.showNestedBlocks Flag to enable displaying nested blocks.\n * @param {boolean} props.showBlockMovers Flag to enable block movers\n * @param {boolean} props.__experimentalFeatures Flag to enable experimental features.\n * @param {boolean} props.__experimentalPersistentListViewFeatures Flag to enable features for the Persistent List View experiment.\n * @param {boolean} props.__experimentalHideContainerBlockActions Flag to hide actions of top level blocks (like core/widget-area)\n * @param {Object} ref Forwarded ref\n */\nfunction ListView(\n\t{\n\t\tblocks,\n\t\tonSelect = noop,\n\t\t__experimentalFeatures,\n\t\t__experimentalPersistentListViewFeatures,\n\t\t__experimentalHideContainerBlockActions,\n\t\tshowNestedBlocks,\n\t\tshowBlockMovers,\n\t\t...props\n\t},\n\tref\n) {\n\tconst {\n\t\tclientIdsTree,\n\t\tdraggedClientIds,\n\t\tselectedClientIds,\n\t} = useListViewClientIds( blocks );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst { visibleBlockCount } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getGlobalBlockCount, getClientIdsOfDescendants } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\tconst draggedBlockCount =\n\t\t\t\tdraggedClientIds?.length > 0\n\t\t\t\t\t? getClientIdsOfDescendants( draggedClientIds ).length + 1\n\t\t\t\t\t: 0;\n\t\t\treturn {\n\t\t\t\tvisibleBlockCount: getGlobalBlockCount() - draggedBlockCount,\n\t\t\t};\n\t\t},\n\t\t[ draggedClientIds ]\n\t);\n\tconst selectEditorBlock = useCallback(\n\t\t( clientId ) => {\n\t\t\tselectBlock( clientId );\n\t\t\tonSelect( clientId );\n\t\t},\n\t\t[ selectBlock, onSelect ]\n\t);\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\n\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone();\n\tconst elementRef = useRef();\n\tconst treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );\n\n\tconst isMounted = useRef( false );\n\tuseEffect( () => {\n\t\tisMounted.current = true;\n\t}, [] );\n\n\t// List View renders a fixed number of items and relies on each having a fixed item height of 36px.\n\t// If this value changes, we should also change the itemHeight value set in useFixedWindowList.\n\t// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.\n\tconst [ fixedListWindow ] = useFixedWindowList(\n\t\telementRef,\n\t\t36,\n\t\tvisibleBlockCount,\n\t\t{\n\t\t\tuseWindowing: __experimentalPersistentListViewFeatures,\n\t\t\twindowOverscan: 40,\n\t\t}\n\t);\n\n\tconst expand = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'expand', clientId } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'collapse', clientId } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst expandRow = useCallback(\n\t\t( row ) => {\n\t\t\texpand( row?.dataset?.block );\n\t\t},\n\t\t[ expand ]\n\t);\n\tconst collapseRow = useCallback(\n\t\t( row ) => {\n\t\t\tcollapse( row?.dataset?.block );\n\t\t},\n\t\t[ collapse ]\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\t__experimentalFeatures,\n\t\t\t__experimentalPersistentListViewFeatures,\n\t\t\t__experimentalHideContainerBlockActions,\n\t\t\tisTreeGridMounted: isMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t} ),\n\t\t[\n\t\t\t__experimentalFeatures,\n\t\t\t__experimentalPersistentListViewFeatures,\n\t\t\t__experimentalHideContainerBlockActions,\n\t\t\tisMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t]\n\t);\n\n\treturn (\n\t\t<AsyncModeProvider value={ true }>\n\t\t\t<ListViewDropIndicator\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t<TreeGrid\n\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\tref={ treeGridRef }\n\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\tonExpandRow={ expandRow }\n\t\t\t>\n\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\tshowNestedBlocks={ showNestedBlocks }\n\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t/>\n\t\t\t\t</ListViewContext.Provider>\n\t\t\t</TreeGrid>\n\t\t</AsyncModeProvider>\n\t);\n}\nexport default forwardRef( ListView );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/index.js"],"names":["expanded","state","action","Array","isArray","clientIds","reduce","newState","id","type","BLOCK_LIST_ITEM_HEIGHT","ListView","ref","blocks","__experimentalFeatures","__experimentalPersistentListViewFeatures","__experimentalHideContainerBlockActions","showNestedBlocks","showBlockMovers","props","clientIdsTree","draggedClientIds","selectedClientIds","visibleBlockCount","select","getGlobalBlockCount","getClientIdsOfDescendants","blockEditorStore","draggedBlockCount","length","updateBlockSelection","expandedState","setExpandedState","dropZoneRef","target","blockDropTarget","elementRef","treeGridRef","isMounted","setSelectedTreeId","firstSelectedBlockClientId","selectEditorBlock","event","clientId","current","fixedListWindow","useWindowing","windowOverscan","expand","collapse","expandRow","row","dataset","block","collapseRow","focusRow","startRow","endRow","shiftKey","contextValue","isTreeGridMounted"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAIA;;AACA;;AASA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA7BA;AACA;AACA;;AAiBA;AACA;AACA;AAUA,MAAMA,QAAQ,GAAG,CAAEC,KAAF,EAASC,MAAT,KAAqB;AACrC,MAAKC,KAAK,CAACC,OAAN,CAAeF,MAAM,CAACG,SAAtB,CAAL,EAAyC;AACxC,WAAO,EACN,GAAGJ,KADG;AAEN,SAAGC,MAAM,CAACG,SAAP,CAAiBC,MAAjB,CACF,CAAEC,QAAF,EAAYC,EAAZ,MAAsB,EACrB,GAAGD,QADkB;AAErB,SAAEC,EAAF,GAAQN,MAAM,CAACO,IAAP,KAAgB;AAFH,OAAtB,CADE,EAKF,EALE;AAFG,KAAP;AAUA;;AACD,SAAOR,KAAP;AACA,CAdD;;AAgBO,MAAMS,sBAAsB,GAAG,EAA/B;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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C,kCAAD;AACC,IAAA,SAAS,EAAC,6BADX;AAEC,kBAAa,cAAI,4BAAJ,CAFd;AAGC,IAAA,GAAG,EAAGE,WAHP;AAIC,IAAA,aAAa,EAAGiB,WAJjB;AAKC,IAAA,WAAW,EAAGJ,SALf;AAMC,IAAA,UAAU,EAAGK;AANd,KAQC,4BAAC,wBAAD,CAAiB,QAAjB;AAA0B,IAAA,KAAK,EAAGI;AAAlC,KACC,4BAAC,eAAD;AACC,IAAA,MAAM,EAAGvC,aADV;AAEC,IAAA,WAAW,EAAGqB,iBAFf;AAGC,IAAA,gBAAgB,EAAGxB,gBAHpB;AAIC,IAAA,eAAe,EAAGC,eAJnB;AAKC,IAAA,eAAe,EAAG2B,eALnB;AAMC,IAAA,iBAAiB,EAAGvB;AANrB,KAOMH,KAPN,EADD,CARD,CALD,CADD;AA4BA;;eACc,yBAAYR,QAAZ,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseReducer,\n\tforwardRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewBranch from './branch';\nimport { ListViewContext } from './context';\nimport ListViewDropIndicator from './drop-indicator';\nimport useBlockSelection from './use-block-selection';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewDropZone from './use-list-view-drop-zone';\nimport useListViewExpandSelectedItem from './use-list-view-expand-selected-item';\nimport { store as blockEditorStore } from '../../store';\n\nconst expanded = ( state, action ) => {\n\tif ( Array.isArray( action.clientIds ) ) {\n\t\treturn {\n\t\t\t...state,\n\t\t\t...action.clientIds.reduce(\n\t\t\t\t( newState, id ) => ( {\n\t\t\t\t\t...newState,\n\t\t\t\t\t[ id ]: action.type === 'expand',\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t),\n\t\t};\n\t}\n\treturn state;\n};\n\nexport const BLOCK_LIST_ITEM_HEIGHT = 36;\n\n/**\n * Wrap `ListViewRows` with `TreeGrid`. ListViewRows is a\n * recursive component (it renders itself), so this ensures TreeGrid is only\n * present at the very top of the navigation grid.\n *\n * @param {Object} props Components props.\n * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.\n * @param {boolean} props.showNestedBlocks Flag to enable displaying nested blocks.\n * @param {boolean} props.showBlockMovers Flag to enable block movers\n * @param {boolean} props.__experimentalFeatures Flag to enable experimental features.\n * @param {boolean} props.__experimentalPersistentListViewFeatures Flag to enable features for the Persistent List View experiment.\n * @param {boolean} props.__experimentalHideContainerBlockActions Flag to hide actions of top level blocks (like core/widget-area)\n * @param {Object} ref Forwarded ref\n */\nfunction ListView(\n\t{\n\t\tblocks,\n\t\t__experimentalFeatures,\n\t\t__experimentalPersistentListViewFeatures,\n\t\t__experimentalHideContainerBlockActions,\n\t\tshowNestedBlocks,\n\t\tshowBlockMovers,\n\t\t...props\n\t},\n\tref\n) {\n\tconst {\n\t\tclientIdsTree,\n\t\tdraggedClientIds,\n\t\tselectedClientIds,\n\t} = useListViewClientIds( blocks );\n\n\tconst { visibleBlockCount } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getGlobalBlockCount, getClientIdsOfDescendants } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\tconst draggedBlockCount =\n\t\t\t\tdraggedClientIds?.length > 0\n\t\t\t\t\t? getClientIdsOfDescendants( draggedClientIds ).length + 1\n\t\t\t\t\t: 0;\n\t\t\treturn {\n\t\t\t\tvisibleBlockCount: getGlobalBlockCount() - draggedBlockCount,\n\t\t\t};\n\t\t},\n\t\t[ draggedClientIds ]\n\t);\n\n\tconst { updateBlockSelection } = useBlockSelection();\n\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\n\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone();\n\tconst elementRef = useRef();\n\tconst treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );\n\n\tconst isMounted = useRef( false );\n\tconst { setSelectedTreeId } = useListViewExpandSelectedItem( {\n\t\tfirstSelectedBlockClientId: selectedClientIds[ 0 ],\n\t\tsetExpandedState,\n\t} );\n\tconst selectEditorBlock = useCallback(\n\t\t( event, clientId ) => {\n\t\t\tupdateBlockSelection( event, clientId );\n\t\t\tsetSelectedTreeId( clientId );\n\t\t},\n\t\t[ setSelectedTreeId, updateBlockSelection ]\n\t);\n\tuseEffect( () => {\n\t\tisMounted.current = true;\n\t}, [] );\n\n\t// List View renders a fixed number of items and relies on each having a fixed item height of 36px.\n\t// If this value changes, we should also change the itemHeight value set in useFixedWindowList.\n\t// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.\n\tconst [ fixedListWindow ] = useFixedWindowList(\n\t\telementRef,\n\t\tBLOCK_LIST_ITEM_HEIGHT,\n\t\tvisibleBlockCount,\n\t\t{\n\t\t\tuseWindowing: __experimentalPersistentListViewFeatures,\n\t\t\twindowOverscan: 40,\n\t\t}\n\t);\n\n\tconst expand = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'expand', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'collapse', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst expandRow = useCallback(\n\t\t( row ) => {\n\t\t\texpand( row?.dataset?.block );\n\t\t},\n\t\t[ expand ]\n\t);\n\tconst collapseRow = useCallback(\n\t\t( row ) => {\n\t\t\tcollapse( row?.dataset?.block );\n\t\t},\n\t\t[ collapse ]\n\t);\n\tconst focusRow = useCallback(\n\t\t( event, startRow, endRow ) => {\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tupdateBlockSelection(\n\t\t\t\t\tevent,\n\t\t\t\t\tstartRow?.dataset?.block,\n\t\t\t\t\tendRow?.dataset?.block\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ updateBlockSelection ]\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\t__experimentalFeatures,\n\t\t\t__experimentalPersistentListViewFeatures,\n\t\t\t__experimentalHideContainerBlockActions,\n\t\t\tisTreeGridMounted: isMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t} ),\n\t\t[\n\t\t\t__experimentalFeatures,\n\t\t\t__experimentalPersistentListViewFeatures,\n\t\t\t__experimentalHideContainerBlockActions,\n\t\t\tisMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t]\n\t);\n\n\treturn (\n\t\t<AsyncModeProvider value={ true }>\n\t\t\t<ListViewDropIndicator\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t<TreeGrid\n\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\tref={ treeGridRef }\n\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\tonExpandRow={ expandRow }\n\t\t\t\tonFocusRow={ focusRow }\n\t\t\t>\n\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\tshowNestedBlocks={ showNestedBlocks }\n\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t/>\n\t\t\t\t</ListViewContext.Provider>\n\t\t\t</TreeGrid>\n\t\t</AsyncModeProvider>\n\t);\n}\nexport default forwardRef( ListView );\n"]}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useBlockSelection;
|
|
7
|
+
|
|
8
|
+
var _lodash = require("lodash");
|
|
9
|
+
|
|
10
|
+
var _a11y = require("@wordpress/a11y");
|
|
11
|
+
|
|
12
|
+
var _i18n = require("@wordpress/i18n");
|
|
13
|
+
|
|
14
|
+
var _data = require("@wordpress/data");
|
|
15
|
+
|
|
16
|
+
var _element = require("@wordpress/element");
|
|
17
|
+
|
|
18
|
+
var _keycodes = require("@wordpress/keycodes");
|
|
19
|
+
|
|
20
|
+
var _blocks = require("@wordpress/blocks");
|
|
21
|
+
|
|
22
|
+
var _store = require("../../store");
|
|
23
|
+
|
|
24
|
+
var _utils = require("./utils");
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* External dependencies
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* WordPress dependencies
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Internal dependencies
|
|
36
|
+
*/
|
|
37
|
+
function useBlockSelection() {
|
|
38
|
+
const {
|
|
39
|
+
clearSelectedBlock,
|
|
40
|
+
multiSelect,
|
|
41
|
+
selectBlock
|
|
42
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
43
|
+
const {
|
|
44
|
+
getBlockName,
|
|
45
|
+
getBlockParents,
|
|
46
|
+
getBlockSelectionStart,
|
|
47
|
+
getBlockSelectionEnd,
|
|
48
|
+
getSelectedBlockClientIds,
|
|
49
|
+
hasMultiSelection,
|
|
50
|
+
hasSelectedBlock
|
|
51
|
+
} = (0, _data.useSelect)(_store.store);
|
|
52
|
+
const {
|
|
53
|
+
getBlockType
|
|
54
|
+
} = (0, _data.useSelect)(_blocks.store);
|
|
55
|
+
const updateBlockSelection = (0, _element.useCallback)(async (event, clientId, destinationClientId) => {
|
|
56
|
+
if (!(event !== null && event !== void 0 && event.shiftKey)) {
|
|
57
|
+
await clearSelectedBlock();
|
|
58
|
+
selectBlock(clientId);
|
|
59
|
+
return;
|
|
60
|
+
} // To handle multiple block selection via the `SHIFT` key, prevent
|
|
61
|
+
// the browser default behavior of opening the link in a new window.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
const isKeyPress = event.type === 'keydown' && (event.keyCode === _keycodes.UP || event.keyCode === _keycodes.DOWN); // Handle clicking on a block when no blocks are selected, and return early.
|
|
66
|
+
|
|
67
|
+
if (!isKeyPress && !hasSelectedBlock() && !hasMultiSelection()) {
|
|
68
|
+
selectBlock(clientId, null);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const selectedBlocks = getSelectedBlockClientIds();
|
|
73
|
+
const clientIdWithParents = [...getBlockParents(clientId), clientId];
|
|
74
|
+
|
|
75
|
+
if (isKeyPress && !selectedBlocks.some(blockId => clientIdWithParents.includes(blockId))) {
|
|
76
|
+
// Ensure that shift-selecting blocks via the keyboard only
|
|
77
|
+
// expands the current selection if focusing over already
|
|
78
|
+
// selected blocks. Otherwise, clear the selection so that
|
|
79
|
+
// a user can create a new selection entirely by keyboard.
|
|
80
|
+
await clearSelectedBlock();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let startTarget = getBlockSelectionStart();
|
|
84
|
+
let endTarget = clientId; // Handle keyboard behavior for selecting multiple blocks.
|
|
85
|
+
|
|
86
|
+
if (isKeyPress) {
|
|
87
|
+
if (!hasSelectedBlock() && !hasMultiSelection()) {
|
|
88
|
+
// Set the starting point of the selection to the currently
|
|
89
|
+
// focused block, if there are no blocks currently selected.
|
|
90
|
+
// This ensures that as the selection is expanded or contracted,
|
|
91
|
+
// the starting point of the selection is anchored to that block.
|
|
92
|
+
startTarget = clientId;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (destinationClientId) {
|
|
96
|
+
// If the user presses UP or DOWN, we want to ensure that the block they're
|
|
97
|
+
// moving to is the target for selection, and not the currently focused one.
|
|
98
|
+
endTarget = destinationClientId;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const startParents = getBlockParents(startTarget);
|
|
103
|
+
const endParents = getBlockParents(endTarget);
|
|
104
|
+
const {
|
|
105
|
+
start,
|
|
106
|
+
end
|
|
107
|
+
} = (0, _utils.getCommonDepthClientIds)(startTarget, endTarget, startParents, endParents);
|
|
108
|
+
await multiSelect(start, end, null); // Announce deselected block, or number of deselected blocks if
|
|
109
|
+
// the total number of blocks deselected is greater than one.
|
|
110
|
+
|
|
111
|
+
const updatedSelectedBlocks = getSelectedBlockClientIds();
|
|
112
|
+
const selectionDiff = (0, _lodash.difference)(selectedBlocks, updatedSelectedBlocks);
|
|
113
|
+
let label;
|
|
114
|
+
|
|
115
|
+
if (selectionDiff.length === 1) {
|
|
116
|
+
var _getBlockType;
|
|
117
|
+
|
|
118
|
+
const title = (_getBlockType = getBlockType(getBlockName(selectionDiff[0]))) === null || _getBlockType === void 0 ? void 0 : _getBlockType.title;
|
|
119
|
+
|
|
120
|
+
if (title) {
|
|
121
|
+
label = (0, _i18n.sprintf)(
|
|
122
|
+
/* translators: %s: block name */
|
|
123
|
+
(0, _i18n.__)('%s deselected.'), title);
|
|
124
|
+
}
|
|
125
|
+
} else if (selectionDiff.length > 1) {
|
|
126
|
+
label = (0, _i18n.sprintf)(
|
|
127
|
+
/* translators: %s: number of deselected blocks */
|
|
128
|
+
(0, _i18n.__)('%s blocks deselected.'), selectionDiff.length);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (label) {
|
|
132
|
+
(0, _a11y.speak)(label);
|
|
133
|
+
}
|
|
134
|
+
}, [clearSelectedBlock, getBlockName, getBlockType, getBlockParents, getBlockSelectionStart, getBlockSelectionEnd, getSelectedBlockClientIds, hasMultiSelection, hasSelectedBlock, multiSelect, selectBlock]);
|
|
135
|
+
return {
|
|
136
|
+
updateBlockSelection
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=use-block-selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/use-block-selection.js"],"names":["useBlockSelection","clearSelectedBlock","multiSelect","selectBlock","blockEditorStore","getBlockName","getBlockParents","getBlockSelectionStart","getBlockSelectionEnd","getSelectedBlockClientIds","hasMultiSelection","hasSelectedBlock","getBlockType","blocksStore","updateBlockSelection","event","clientId","destinationClientId","shiftKey","preventDefault","isKeyPress","type","keyCode","UP","DOWN","selectedBlocks","clientIdWithParents","some","blockId","includes","startTarget","endTarget","startParents","endParents","start","end","updatedSelectedBlocks","selectionDiff","label","length","title"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;AAIe,SAASA,iBAAT,GAA6B;AAC3C,QAAM;AAAEC,IAAAA,kBAAF;AAAsBC,IAAAA,WAAtB;AAAmCC,IAAAA;AAAnC,MAAmD,uBACxDC,YADwD,CAAzD;AAGA,QAAM;AACLC,IAAAA,YADK;AAELC,IAAAA,eAFK;AAGLC,IAAAA,sBAHK;AAILC,IAAAA,oBAJK;AAKLC,IAAAA,yBALK;AAMLC,IAAAA,iBANK;AAOLC,IAAAA;AAPK,MAQF,qBAAWP,YAAX,CARJ;AAUA,QAAM;AAAEQ,IAAAA;AAAF,MAAmB,qBAAWC,aAAX,CAAzB;AAEA,QAAMC,oBAAoB,GAAG,0BAC5B,OAAQC,KAAR,EAAeC,QAAf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;AACA,UAAMG,UAAU,GAAG3B,eAAe,CAAEyB,SAAF,CAAlC;AAEA,UAAM;AAAEG,MAAAA,KAAF;AAASC,MAAAA;AAAT,QAAiB,oCACtBL,WADsB,EAEtBC,SAFsB,EAGtBC,YAHsB,EAItBC,UAJsB,CAAvB;AAMA,UAAM/B,WAAW,CAAEgC,KAAF,EAASC,GAAT,EAAc,IAAd,CAAjB,CAxEiD,CA0EjD;AACA;;AACA,UAAMC,qBAAqB,GAAG3B,yBAAyB,EAAvD;AAEA,UAAM4B,aAAa,GAAG,wBACrBZ,cADqB,EAErBW,qBAFqB,CAAtB;AAKA,QAAIE,KAAJ;;AACA,QAAKD,aAAa,CAACE,MAAd,KAAyB,CAA9B,EAAkC;AAAA;;AACjC,YAAMC,KAAK,oBAAG5B,YAAY,CAAEP,YAAY,CAAEgC,aAAa,CAAE,CAAF,CAAf,CAAd,CAAf,kDAAG,cACXG,KADH;;AAEA,UAAKA,KAAL,EAAa;AACZF,QAAAA,KAAK,GAAG;AACP;AACA,sBAAI,gBAAJ,CAFO,EAGPE,KAHO,CAAR;AAKA;AACD,KAVD,MAUO,IAAKH,aAAa,CAACE,MAAd,GAAuB,CAA5B,EAAgC;AACtCD,MAAAA,KAAK,GAAG;AACP;AACA,oBAAI,uBAAJ,CAFO,EAGPD,aAAa,CAACE,MAHP,CAAR;AAKA;;AAED,QAAKD,KAAL,EAAa;AACZ,uBAAOA,KAAP;AACA;AACD,GA1G2B,EA2G5B,CACCrC,kBADD,EAECI,YAFD,EAGCO,YAHD,EAICN,eAJD,EAKCC,sBALD,EAMCC,oBAND,EAOCC,yBAPD,EAQCC,iBARD,EASCC,gBATD,EAUCT,WAVD,EAWCC,WAXD,CA3G4B,CAA7B;AA0HA,SAAO;AACNW,IAAAA;AADM,GAAP;AAGA","sourcesContent":["/**\n * External dependencies\n */\nimport { difference } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\nimport { UP, DOWN } from '@wordpress/keycodes';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getCommonDepthClientIds } from './utils';\n\nexport default function useBlockSelection() {\n\tconst { clearSelectedBlock, multiSelect, selectBlock } = useDispatch(\n\t\tblockEditorStore\n\t);\n\tconst {\n\t\tgetBlockName,\n\t\tgetBlockParents,\n\t\tgetBlockSelectionStart,\n\t\tgetBlockSelectionEnd,\n\t\tgetSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\thasSelectedBlock,\n\t} = useSelect( blockEditorStore );\n\n\tconst { getBlockType } = useSelect( blocksStore );\n\n\tconst updateBlockSelection = useCallback(\n\t\tasync ( event, clientId, destinationClientId ) => {\n\t\t\tif ( ! event?.shiftKey ) {\n\t\t\t\tawait clearSelectedBlock();\n\t\t\t\tselectBlock( clientId );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// To handle multiple block selection via the `SHIFT` key, prevent\n\t\t\t// the browser default behavior of opening the link in a new window.\n\t\t\tevent.preventDefault();\n\n\t\t\tconst isKeyPress =\n\t\t\t\tevent.type === 'keydown' &&\n\t\t\t\t( event.keyCode === UP || event.keyCode === DOWN );\n\n\t\t\t// Handle clicking on a block when no blocks are selected, and return early.\n\t\t\tif (\n\t\t\t\t! isKeyPress &&\n\t\t\t\t! hasSelectedBlock() &&\n\t\t\t\t! hasMultiSelection()\n\t\t\t) {\n\t\t\t\tselectBlock( clientId, null );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectedBlocks = getSelectedBlockClientIds();\n\t\t\tconst clientIdWithParents = [\n\t\t\t\t...getBlockParents( clientId ),\n\t\t\t\tclientId,\n\t\t\t];\n\n\t\t\tif (\n\t\t\t\tisKeyPress &&\n\t\t\t\t! selectedBlocks.some( ( blockId ) =>\n\t\t\t\t\tclientIdWithParents.includes( blockId )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// Ensure that shift-selecting blocks via the keyboard only\n\t\t\t\t// expands the current selection if focusing over already\n\t\t\t\t// selected blocks. Otherwise, clear the selection so that\n\t\t\t\t// a user can create a new selection entirely by keyboard.\n\t\t\t\tawait clearSelectedBlock();\n\t\t\t}\n\n\t\t\tlet startTarget = getBlockSelectionStart();\n\t\t\tlet endTarget = clientId;\n\n\t\t\t// Handle keyboard behavior for selecting multiple blocks.\n\t\t\tif ( isKeyPress ) {\n\t\t\t\tif ( ! hasSelectedBlock() && ! hasMultiSelection() ) {\n\t\t\t\t\t// Set the starting point of the selection to the currently\n\t\t\t\t\t// focused block, if there are no blocks currently selected.\n\t\t\t\t\t// This ensures that as the selection is expanded or contracted,\n\t\t\t\t\t// the starting point of the selection is anchored to that block.\n\t\t\t\t\tstartTarget = clientId;\n\t\t\t\t}\n\t\t\t\tif ( destinationClientId ) {\n\t\t\t\t\t// If the user presses UP or DOWN, we want to ensure that the block they're\n\t\t\t\t\t// moving to is the target for selection, and not the currently focused one.\n\t\t\t\t\tendTarget = destinationClientId;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst startParents = getBlockParents( startTarget );\n\t\t\tconst endParents = getBlockParents( endTarget );\n\n\t\t\tconst { start, end } = getCommonDepthClientIds(\n\t\t\t\tstartTarget,\n\t\t\t\tendTarget,\n\t\t\t\tstartParents,\n\t\t\t\tendParents\n\t\t\t);\n\t\t\tawait multiSelect( start, end, null );\n\n\t\t\t// Announce deselected block, or number of deselected blocks if\n\t\t\t// the total number of blocks deselected is greater than one.\n\t\t\tconst updatedSelectedBlocks = getSelectedBlockClientIds();\n\n\t\t\tconst selectionDiff = difference(\n\t\t\t\tselectedBlocks,\n\t\t\t\tupdatedSelectedBlocks\n\t\t\t);\n\n\t\t\tlet label;\n\t\t\tif ( selectionDiff.length === 1 ) {\n\t\t\t\tconst title = getBlockType( getBlockName( selectionDiff[ 0 ] ) )\n\t\t\t\t\t?.title;\n\t\t\t\tif ( title ) {\n\t\t\t\t\tlabel = sprintf(\n\t\t\t\t\t\t/* translators: %s: block name */\n\t\t\t\t\t\t__( '%s deselected.' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else if ( selectionDiff.length > 1 ) {\n\t\t\t\tlabel = sprintf(\n\t\t\t\t\t/* translators: %s: number of deselected blocks */\n\t\t\t\t\t__( '%s blocks deselected.' ),\n\t\t\t\t\tselectionDiff.length\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif ( label ) {\n\t\t\t\tspeak( label );\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tclearSelectedBlock,\n\t\t\tgetBlockName,\n\t\t\tgetBlockType,\n\t\t\tgetBlockParents,\n\t\t\tgetBlockSelectionStart,\n\t\t\tgetBlockSelectionEnd,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\thasMultiSelection,\n\t\t\thasSelectedBlock,\n\t\t\tmultiSelect,\n\t\t\tselectBlock,\n\t\t]\n\t);\n\n\treturn {\n\t\tupdateBlockSelection,\n\t};\n}\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useListViewExpandSelectedItem;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _data = require("@wordpress/data");
|
|
11
|
+
|
|
12
|
+
var _store = require("../../store");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* WordPress dependencies
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Internal dependencies
|
|
20
|
+
*/
|
|
21
|
+
function useListViewExpandSelectedItem(_ref) {
|
|
22
|
+
let {
|
|
23
|
+
firstSelectedBlockClientId,
|
|
24
|
+
setExpandedState
|
|
25
|
+
} = _ref;
|
|
26
|
+
const [selectedTreeId, setSelectedTreeId] = (0, _element.useState)(null);
|
|
27
|
+
const {
|
|
28
|
+
selectedBlockParentClientIds
|
|
29
|
+
} = (0, _data.useSelect)(select => {
|
|
30
|
+
const {
|
|
31
|
+
getBlockParents
|
|
32
|
+
} = select(_store.store);
|
|
33
|
+
return {
|
|
34
|
+
selectedBlockParentClientIds: getBlockParents(firstSelectedBlockClientId, false)
|
|
35
|
+
};
|
|
36
|
+
}, [firstSelectedBlockClientId]);
|
|
37
|
+
const parentClientIds = Array.isArray(selectedBlockParentClientIds) && selectedBlockParentClientIds.length ? selectedBlockParentClientIds : null; // Expand tree when a block is selected.
|
|
38
|
+
|
|
39
|
+
(0, _element.useEffect)(() => {
|
|
40
|
+
// If the selectedTreeId is the same as the selected block,
|
|
41
|
+
// it means that the block was selected using the block list tree.
|
|
42
|
+
if (selectedTreeId === firstSelectedBlockClientId) {
|
|
43
|
+
return;
|
|
44
|
+
} // If the selected block has parents, get the top-level parent.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
if (parentClientIds) {
|
|
48
|
+
// If the selected block has parents,
|
|
49
|
+
// expand the tree branch.
|
|
50
|
+
setExpandedState({
|
|
51
|
+
type: 'expand',
|
|
52
|
+
clientIds: selectedBlockParentClientIds
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}, [firstSelectedBlockClientId]);
|
|
56
|
+
return {
|
|
57
|
+
setSelectedTreeId
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=use-list-view-expand-selected-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/use-list-view-expand-selected-item.js"],"names":["useListViewExpandSelectedItem","firstSelectedBlockClientId","setExpandedState","selectedTreeId","setSelectedTreeId","selectedBlockParentClientIds","select","getBlockParents","blockEditorStore","parentClientIds","Array","isArray","length","type","clientIds"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGe,SAASA,6BAAT,OAGX;AAAA,MAHmD;AACtDC,IAAAA,0BADsD;AAEtDC,IAAAA;AAFsD,GAGnD;AACH,QAAM,CAAEC,cAAF,EAAkBC,iBAAlB,IAAwC,uBAAU,IAAV,CAA9C;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAmC,qBACtCC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAsBD,MAAM,CAAEE,YAAF,CAAlC;AACA,WAAO;AACNH,MAAAA,4BAA4B,EAAEE,eAAe,CAC5CN,0BAD4C,EAE5C,KAF4C;AADvC,KAAP;AAMA,GATuC,EAUxC,CAAEA,0BAAF,CAVwC,CAAzC;AAaA,QAAMQ,eAAe,GACpBC,KAAK,CAACC,OAAN,CAAeN,4BAAf,KACAA,4BAA4B,CAACO,MAD7B,GAEGP,4BAFH,GAGG,IAJJ,CAfG,CAqBH;;AACA,0BAAW,MAAM;AAChB;AACA;AACA,QAAKF,cAAc,KAAKF,0BAAxB,EAAqD;AACpD;AACA,KALe,CAOhB;;;AACA,QAAKQ,eAAL,EAAuB;AACtB;AACA;AACAP,MAAAA,gBAAgB,CAAE;AACjBW,QAAAA,IAAI,EAAE,QADW;AAEjBC,QAAAA,SAAS,EAAET;AAFM,OAAF,CAAhB;AAIA;AACD,GAhBD,EAgBG,CAAEJ,0BAAF,CAhBH;AAkBA,SAAO;AACNG,IAAAA;AADM,GAAP;AAGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport default function useListViewExpandSelectedItem( {\n\tfirstSelectedBlockClientId,\n\tsetExpandedState,\n} ) {\n\tconst [ selectedTreeId, setSelectedTreeId ] = useState( null );\n\tconst { selectedBlockParentClientIds } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParents } = select( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tselectedBlockParentClientIds: getBlockParents(\n\t\t\t\t\tfirstSelectedBlockClientId,\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ firstSelectedBlockClientId ]\n\t);\n\n\tconst parentClientIds =\n\t\tArray.isArray( selectedBlockParentClientIds ) &&\n\t\tselectedBlockParentClientIds.length\n\t\t\t? selectedBlockParentClientIds\n\t\t\t: null;\n\n\t// Expand tree when a block is selected.\n\tuseEffect( () => {\n\t\t// If the selectedTreeId is the same as the selected block,\n\t\t// it means that the block was selected using the block list tree.\n\t\tif ( selectedTreeId === firstSelectedBlockClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If the selected block has parents, get the top-level parent.\n\t\tif ( parentClientIds ) {\n\t\t\t// If the selected block has parents,\n\t\t\t// expand the tree branch.\n\t\t\tsetExpandedState( {\n\t\t\t\ttype: 'expand',\n\t\t\t\tclientIds: selectedBlockParentClientIds,\n\t\t\t} );\n\t\t}\n\t}, [ firstSelectedBlockClientId ] );\n\n\treturn {\n\t\tsetSelectedTreeId,\n\t};\n}\n"]}
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.getBlockPositionDescription = void 0;
|
|
7
|
+
exports.getCommonDepthClientIds = getCommonDepthClientIds;
|
|
8
|
+
exports.isClientIdSelected = void 0;
|
|
7
9
|
|
|
8
10
|
var _lodash = require("lodash");
|
|
9
11
|
|
|
@@ -33,6 +35,32 @@ const getBlockPositionDescription = (position, siblingCount, level) => (0, _i18n
|
|
|
33
35
|
exports.getBlockPositionDescription = getBlockPositionDescription;
|
|
34
36
|
|
|
35
37
|
const isClientIdSelected = (clientId, selectedBlockClientIds) => (0, _lodash.isArray)(selectedBlockClientIds) && selectedBlockClientIds.length ? selectedBlockClientIds.indexOf(clientId) !== -1 : selectedBlockClientIds === clientId;
|
|
38
|
+
/**
|
|
39
|
+
* From a start and end clientId of potentially different nesting levels,
|
|
40
|
+
* return the nearest-depth ids that have a common level of depth in the
|
|
41
|
+
* nesting hierarchy. For multiple block selection, this ensure that the
|
|
42
|
+
* selection is always at the same nesting level, and not split across
|
|
43
|
+
* separate levels.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} startId The first id of a selection.
|
|
46
|
+
* @param {string} endId The end id of a selection, usually one that has been clicked on.
|
|
47
|
+
* @param {string[]} startParents An array of ancestor ids for the start id, in descending order.
|
|
48
|
+
* @param {string[]} endParents An array of ancestor ids for the end id, in descending order.
|
|
49
|
+
* @return {Object} An object containing the start and end ids.
|
|
50
|
+
*/
|
|
51
|
+
|
|
36
52
|
|
|
37
53
|
exports.isClientIdSelected = isClientIdSelected;
|
|
54
|
+
|
|
55
|
+
function getCommonDepthClientIds(startId, endId, startParents, endParents) {
|
|
56
|
+
const startPath = [...startParents, startId];
|
|
57
|
+
const endPath = [...endParents, endId];
|
|
58
|
+
const depth = Math.min(startPath.length, endPath.length) - 1;
|
|
59
|
+
const start = startPath[depth];
|
|
60
|
+
const end = endPath[depth];
|
|
61
|
+
return {
|
|
62
|
+
start,
|
|
63
|
+
end
|
|
64
|
+
};
|
|
65
|
+
}
|
|
38
66
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/utils.js"],"names":["getBlockPositionDescription","position","siblingCount","level","isClientIdSelected","clientId","selectedBlockClientIds","length","indexOf"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/utils.js"],"names":["getBlockPositionDescription","position","siblingCount","level","isClientIdSelected","clientId","selectedBlockClientIds","length","indexOf","getCommonDepthClientIds","startId","endId","startParents","endParents","startPath","endPath","depth","Math","min","start","end"],"mappings":";;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGO,MAAMA,2BAA2B,GAAG,CAAEC,QAAF,EAAYC,YAAZ,EAA0BC,KAA1B,KAC1C;AACC;AACA,cAAI,gCAAJ,CAFD,EAGCF,QAHD,EAICC,YAJD,EAKCC,KALD,CADM;AASP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMC,kBAAkB,GAAG,CAAEC,QAAF,EAAYC,sBAAZ,KACjC,qBAASA,sBAAT,KAAqCA,sBAAsB,CAACC,MAA5D,GACGD,sBAAsB,CAACE,OAAvB,CAAgCH,QAAhC,MAA+C,CAAC,CADnD,GAEGC,sBAAsB,KAAKD,QAHxB;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASI,uBAAT,CACNC,OADM,EAENC,KAFM,EAGNC,YAHM,EAINC,UAJM,EAKL;AACD,QAAMC,SAAS,GAAG,CAAE,GAAGF,YAAL,EAAmBF,OAAnB,CAAlB;AACA,QAAMK,OAAO,GAAG,CAAE,GAAGF,UAAL,EAAiBF,KAAjB,CAAhB;AACA,QAAMK,KAAK,GAAGC,IAAI,CAACC,GAAL,CAAUJ,SAAS,CAACP,MAApB,EAA4BQ,OAAO,CAACR,MAApC,IAA+C,CAA7D;AACA,QAAMY,KAAK,GAAGL,SAAS,CAAEE,KAAF,CAAvB;AACA,QAAMI,GAAG,GAAGL,OAAO,CAAEC,KAAF,CAAnB;AAEA,SAAO;AACNG,IAAAA,KADM;AAENC,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/**\n * External dependencies\n */\nimport { isArray } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\nexport const getBlockPositionDescription = ( position, siblingCount, level ) =>\n\tsprintf(\n\t\t/* translators: 1: The numerical position of the block. 2: The total number of blocks. 3. The level of nesting for the block. */\n\t\t__( 'Block %1$d of %2$d, Level %3$d' ),\n\t\tposition,\n\t\tsiblingCount,\n\t\tlevel\n\t);\n\n/**\n * Returns true if the client ID occurs within the block selection or multi-selection,\n * or false otherwise.\n *\n * @param {string} clientId Block client ID.\n * @param {string|string[]} selectedBlockClientIds Selected block client ID, or an array of multi-selected blocks client IDs.\n *\n * @return {boolean} Whether the block is in multi-selection set.\n */\nexport const isClientIdSelected = ( clientId, selectedBlockClientIds ) =>\n\tisArray( selectedBlockClientIds ) && selectedBlockClientIds.length\n\t\t? selectedBlockClientIds.indexOf( clientId ) !== -1\n\t\t: selectedBlockClientIds === clientId;\n\n/**\n * From a start and end clientId of potentially different nesting levels,\n * return the nearest-depth ids that have a common level of depth in the\n * nesting hierarchy. For multiple block selection, this ensure that the\n * selection is always at the same nesting level, and not split across\n * separate levels.\n *\n * @param {string} startId The first id of a selection.\n * @param {string} endId The end id of a selection, usually one that has been clicked on.\n * @param {string[]} startParents An array of ancestor ids for the start id, in descending order.\n * @param {string[]} endParents An array of ancestor ids for the end id, in descending order.\n * @return {Object} An object containing the start and end ids.\n */\nexport function getCommonDepthClientIds(\n\tstartId,\n\tendId,\n\tstartParents,\n\tendParents\n) {\n\tconst startPath = [ ...startParents, startId ];\n\tconst endPath = [ ...endParents, endId ];\n\tconst depth = Math.min( startPath.length, endPath.length ) - 1;\n\tconst start = startPath[ depth ];\n\tconst end = endPath[ depth ];\n\n\treturn {\n\t\tstart,\n\t\tend,\n\t};\n}\n"]}
|
|
@@ -34,7 +34,7 @@ var _styles = _interopRequireDefault(require("./styles.scss"));
|
|
|
34
34
|
/**
|
|
35
35
|
* Internal dependencies
|
|
36
36
|
*/
|
|
37
|
-
//
|
|
37
|
+
// Remove duplicates after gallery append.
|
|
38
38
|
const dedupMedia = media => (0, _lodash.uniqWith)(media, (media1, media2) => media1.id === media2.id || media1.url === media2.url);
|
|
39
39
|
|
|
40
40
|
function MediaPlaceholder(props) {
|
|
@@ -57,10 +57,10 @@ function MediaPlaceholder(props) {
|
|
|
57
57
|
hideContent,
|
|
58
58
|
autoOpenMediaUpload,
|
|
59
59
|
onSelectURL
|
|
60
|
-
} = props; //
|
|
60
|
+
} = props; // Use ref to keep media array current for callbacks during rerenders.
|
|
61
61
|
|
|
62
62
|
const mediaRef = (0, _element.useRef)(value);
|
|
63
|
-
mediaRef.current = value; //
|
|
63
|
+
mediaRef.current = value; // Append and deduplicate media array for gallery use case.
|
|
64
64
|
|
|
65
65
|
const setMedia = multiple && addToGallery ? selected => onSelect(dedupMedia([...mediaRef.current, ...selected])) : onSelect;
|
|
66
66
|
const isOneType = allowedTypes.length === 1;
|
|
@@ -118,12 +118,14 @@ function MediaPlaceholder(props) {
|
|
|
118
118
|
style: _styles.default.emptyStateDescription
|
|
119
119
|
}, instructions));
|
|
120
120
|
} else if (isAppender && !disableMediaButtons) {
|
|
121
|
-
return (0, _element.createElement)(
|
|
121
|
+
return (0, _element.createElement)(_reactNative.View, {
|
|
122
|
+
testID: "media-placeholder-appender-icon"
|
|
123
|
+
}, (0, _element.createElement)(_icons.Icon, {
|
|
122
124
|
icon: _icons.plusCircleFilled,
|
|
123
125
|
style: addMediaButtonStyle,
|
|
124
126
|
color: addMediaButtonStyle.color,
|
|
125
127
|
size: addMediaButtonStyle.size
|
|
126
|
-
});
|
|
128
|
+
}));
|
|
127
129
|
}
|
|
128
130
|
};
|
|
129
131
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/media-placeholder/index.native.js"],"names":["dedupMedia","media","media1","media2","id","url","MediaPlaceholder","props","addToGallery","allowedTypes","labels","icon","onSelect","onFocus","__experimentalOnlyMediaLibrary","isAppender","disableMediaButtons","getStylesFromColorScheme","multiple","value","children","height","backgroundColor","hideContent","autoOpenMediaUpload","onSelectURL","mediaRef","current","setMedia","selected","isOneType","length","isImage","includes","MEDIA_TYPE_IMAGE","isVideo","MEDIA_TYPE_VIDEO","isAudio","MEDIA_TYPE_AUDIO","placeholderTitle","title","undefined","instructions","accessibilityHint","emptyStateTitleStyle","styles","emptyStateTitle","emptyStateTitleDark","addMediaButtonStyle","addMediaButton","addMediaButtonDark","renderContent","modalIcon","emptyStateDescription","plusCircleFilled","color","size","appenderStyle","appender","appenderDark","emptyStateContainerStyle","emptyStateContainer","emptyStateContainerDark","flex","open","getMediaOptions","event"],"mappings":";;;;;;;;;AAiBA;;AAdA;;AACA;;AAKA;;AACA;;AAMA;;AAEA;;AAKA;;AAvBA;AACA;AACA;;AAIA;AACA;AACA;;AAYA;AACA;AACA;AAGA;AACA,MAAMA,UAAU,GAAKC,KAAF,IAClB,sBACCA,KADD,EAEC,CAAEC,MAAF,EAAUC,MAAV,KACCD,MAAM,CAACE,EAAP,KAAcD,MAAM,CAACC,EAArB,IAA2BF,MAAM,CAACG,GAAP,KAAeF,MAAM,CAACE,GAHnD,CADD;;AAOA,SAASC,gBAAT,CAA2BC,KAA3B,EAAmC;AAClC,QAAM;AACLC,IAAAA,YADK;AAELC,IAAAA,YAAY,GAAG,EAFV;AAGLC,IAAAA,MAAM,GAAG,EAHJ;AAILC,IAAAA,IAJK;AAKLC,IAAAA,QALK;AAMLC,IAAAA,OANK;AAOLC,IAAAA,8BAPK;AAQLC,IAAAA,UARK;AASLC,IAAAA,mBATK;AAULC,IAAAA,wBAVK;AAWLC,IAAAA,QAXK;AAYLC,IAAAA,KAAK,GAAG,EAZH;AAaLC,IAAAA,QAbK;AAcLC,IAAAA,MAdK;AAeLC,IAAAA,eAfK;AAgBLC,IAAAA,WAhBK;AAiBLC,IAAAA,mBAjBK;AAkBLC,IAAAA;AAlBK,MAmBFlB,KAnBJ,CADkC,CAsBlC;;AACA,QAAMmB,QAAQ,GAAG,qBAAQP,KAAR,CAAjB;AACAO,EAAAA,QAAQ,CAACC,OAAT,GAAmBR,KAAnB,CAxBkC,CA0BlC;;AACA,QAAMS,QAAQ,GACbV,QAAQ,IAAIV,YAAZ,GACKqB,QAAF,IACAjB,QAAQ,CACPZ,UAAU,CAAE,CAAE,GAAG0B,QAAQ,CAACC,OAAd,EAAuB,GAAGE,QAA1B,CAAF,CADH,CAFX,GAKGjB,QANJ;AA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uBAFiD,CAAzD;AAKA,SACC,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAG;AAAEC,MAAAA,IAAI,EAAE;AAAR;AAAd,KACC,4BAAC,wBAAD;AACC,IAAA,YAAY,EAAGtD,YADhB;AAEC,IAAA,QAAQ,EAAGmB,QAFZ;AAGC,IAAA,WAAW,EAAGH,WAHf;AAIC,IAAA,8BAA8B,EAC7BX,8BALF;AAOC,IAAA,QAAQ,EAAGI,QAPZ;AAQC,IAAA,gBAAgB,EAAG,KARpB;AASC,IAAA,QAAQ,EAAGM,mBATZ;AAUC,IAAA,MAAM,EAAG,QAAiC;AAAA,UAA/B;AAAEwC,QAAAA,IAAF;AAAQC,QAAAA;AAAR,OAA+B;AACzC,aACC,4BAAC,qCAAD;AACC,QAAA,kBAAkB,EAAG;AACpB;AACA,sBAAI,iBAAJ,CAFoB,EAGpB1B,gBAHoB,CADtB;AAMC,QAAA,iBAAiB,EAAG,QANrB;AAOC,QAAA,iBAAiB,EAAGI,iBAPrB;AAQC,QAAA,OAAO,EAAKuB,KAAF,IAAa;AACtBrD,UAAAA,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAIqD,KAAJ,CAAP;AACAF,UAAAA,IAAI;AACJ;AAXF,SAaC,4BAAC,iBAAD;AACC,QAAA,KAAK,EAAG,CACP,CACCJ,wBADD,EAECvC,MAAM,IAAI;AAAEA,UAAAA;AAAF,SAFX,EAGCC,eAAe,IAAI;AAAEA,UAAAA;AAAF,SAHpB,CADO,EAMPP,UAAU,IAAI0C,aANP;AADT,SAUGQ,eAAe,EAVlB,EAWG,CAAE1C,WAAF,IAAiB4B,aAAa,EAXjC,CAbD,CADD;AA6BA;AAxCF,IADD,CADD;AA8CA;;eAEc,uCAA0B7C,gBAA1B,C","sourcesContent":["/**\n * External dependencies\n */\nimport { View, Text, TouchableWithoutFeedback } from 'react-native';\nimport { uniqWith } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tMediaUpload,\n\tMEDIA_TYPE_IMAGE,\n\tMEDIA_TYPE_VIDEO,\n\tMEDIA_TYPE_AUDIO,\n} from '@wordpress/block-editor';\nimport { withPreferredColorScheme } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\nimport { Icon, plusCircleFilled } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport styles from './styles.scss';\n\n// remove duplicates after gallery append\nconst dedupMedia = ( media ) =>\n\tuniqWith(\n\t\tmedia,\n\t\t( media1, media2 ) =>\n\t\t\tmedia1.id === media2.id || media1.url === media2.url\n\t);\n\nfunction MediaPlaceholder( props ) {\n\tconst {\n\t\taddToGallery,\n\t\tallowedTypes = [],\n\t\tlabels = {},\n\t\ticon,\n\t\tonSelect,\n\t\tonFocus,\n\t\t__experimentalOnlyMediaLibrary,\n\t\tisAppender,\n\t\tdisableMediaButtons,\n\t\tgetStylesFromColorScheme,\n\t\tmultiple,\n\t\tvalue = [],\n\t\tchildren,\n\t\theight,\n\t\tbackgroundColor,\n\t\thideContent,\n\t\tautoOpenMediaUpload,\n\t\tonSelectURL,\n\t} = props;\n\n\t// use ref to keep media array current for callbacks during rerenders\n\tconst mediaRef = useRef( value );\n\tmediaRef.current = value;\n\n\t// append and deduplicate media array for gallery use case\n\tconst setMedia =\n\t\tmultiple && addToGallery\n\t\t\t? ( selected ) =>\n\t\t\t\t\tonSelect(\n\t\t\t\t\t\tdedupMedia( [ ...mediaRef.current, ...selected ] )\n\t\t\t\t\t)\n\t\t\t: onSelect;\n\n\tconst isOneType = allowedTypes.length === 1;\n\tconst isImage = isOneType && allowedTypes.includes( MEDIA_TYPE_IMAGE );\n\tconst isVideo = isOneType && allowedTypes.includes( MEDIA_TYPE_VIDEO );\n\tconst isAudio = isOneType && allowedTypes.includes( MEDIA_TYPE_AUDIO );\n\n\tlet placeholderTitle = labels.title;\n\tif ( placeholderTitle === undefined ) {\n\t\tplaceholderTitle = __( 'Media' );\n\t\tif ( isImage ) {\n\t\t\tplaceholderTitle = __( 'Image' );\n\t\t} else if ( isVideo ) {\n\t\t\tplaceholderTitle = __( 'Video' );\n\t\t} else if ( isAudio ) {\n\t\t\tplaceholderTitle = __( 'Audio' );\n\t\t}\n\t}\n\n\tlet instructions = labels.instructions;\n\tif ( instructions === undefined ) {\n\t\tif ( isImage ) {\n\t\t\tinstructions = __( 'ADD IMAGE' );\n\t\t} else if ( isVideo ) {\n\t\t\tinstructions = __( 'ADD VIDEO' );\n\t\t} else if ( isAudio ) {\n\t\t\tinstructions = __( 'ADD AUDIO' );\n\t\t} else {\n\t\t\tinstructions = __( 'ADD IMAGE OR VIDEO' );\n\t\t}\n\t}\n\n\tlet accessibilityHint = __( 'Double tap to select' );\n\tif ( isImage ) {\n\t\taccessibilityHint = __( 'Double tap to select an image' );\n\t} else if ( isVideo ) {\n\t\taccessibilityHint = __( 'Double tap to select a video' );\n\t} else if ( isAudio ) {\n\t\taccessibilityHint = __( 'Double tap to select an audio file' );\n\t}\n\n\tconst emptyStateTitleStyle = getStylesFromColorScheme(\n\t\tstyles.emptyStateTitle,\n\t\tstyles.emptyStateTitleDark\n\t);\n\tconst addMediaButtonStyle = getStylesFromColorScheme(\n\t\tstyles.addMediaButton,\n\t\tstyles.addMediaButtonDark\n\t);\n\n\tconst renderContent = () => {\n\t\tif ( isAppender === undefined || ! isAppender ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<View style={ styles.modalIcon }>{ icon }</View>\n\t\t\t\t\t<Text style={ emptyStateTitleStyle }>\n\t\t\t\t\t\t{ placeholderTitle }\n\t\t\t\t\t</Text>\n\t\t\t\t\t{ children }\n\t\t\t\t\t<Text style={ styles.emptyStateDescription }>\n\t\t\t\t\t\t{ instructions }\n\t\t\t\t\t</Text>\n\t\t\t\t</>\n\t\t\t);\n\t\t} else if ( isAppender && ! disableMediaButtons ) {\n\t\t\treturn (\n\t\t\t\t<Icon\n\t\t\t\t\ticon={ plusCircleFilled }\n\t\t\t\t\tstyle={ addMediaButtonStyle }\n\t\t\t\t\tcolor={ addMediaButtonStyle.color }\n\t\t\t\t\tsize={ addMediaButtonStyle.size }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\t};\n\n\tif ( isAppender && disableMediaButtons ) {\n\t\treturn null;\n\t}\n\n\tconst appenderStyle = getStylesFromColorScheme(\n\t\tstyles.appender,\n\t\tstyles.appenderDark\n\t);\n\tconst emptyStateContainerStyle = getStylesFromColorScheme(\n\t\tstyles.emptyStateContainer,\n\t\tstyles.emptyStateContainerDark\n\t);\n\n\treturn (\n\t\t<View style={ { flex: 1 } }>\n\t\t\t<MediaUpload\n\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\tonSelect={ setMedia }\n\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t__experimentalOnlyMediaLibrary={\n\t\t\t\t\t__experimentalOnlyMediaLibrary\n\t\t\t\t}\n\t\t\t\tmultiple={ multiple }\n\t\t\t\tisReplacingMedia={ false }\n\t\t\t\tautoOpen={ autoOpenMediaUpload }\n\t\t\t\trender={ ( { open, getMediaOptions } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TouchableWithoutFeedback\n\t\t\t\t\t\t\taccessibilityLabel={ sprintf(\n\t\t\t\t\t\t\t\t/* translators: accessibility text for the media block empty state. %s: media type */\n\t\t\t\t\t\t\t\t__( '%s block. Empty' ),\n\t\t\t\t\t\t\t\tplaceholderTitle\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\t\t\t\taccessibilityHint={ accessibilityHint }\n\t\t\t\t\t\t\tonPress={ ( event ) => {\n\t\t\t\t\t\t\t\tonFocus?.( event );\n\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\temptyStateContainerStyle,\n\t\t\t\t\t\t\t\t\t\theight && { height },\n\t\t\t\t\t\t\t\t\t\tbackgroundColor && { backgroundColor },\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\tisAppender && appenderStyle,\n\t\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ getMediaOptions() }\n\t\t\t\t\t\t\t\t{ ! hideContent && renderContent() }\n\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t</TouchableWithoutFeedback>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t</View>\n\t);\n}\n\nexport default withPreferredColorScheme( MediaPlaceholder );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/media-placeholder/index.native.js"],"names":["dedupMedia","media","media1","media2","id","url","MediaPlaceholder","props","addToGallery","allowedTypes","labels","icon","onSelect","onFocus","__experimentalOnlyMediaLibrary","isAppender","disableMediaButtons","getStylesFromColorScheme","multiple","value","children","height","backgroundColor","hideContent","autoOpenMediaUpload","onSelectURL","mediaRef","current","setMedia","selected","isOneType","length","isImage","includes","MEDIA_TYPE_IMAGE","isVideo","MEDIA_TYPE_VIDEO","isAudio","MEDIA_TYPE_AUDIO","placeholderTitle","title","undefined","instructions","accessibilityHint","emptyStateTitleStyle","styles","emptyStateTitle","emptyStateTitleDark","addMediaButtonStyle","addMediaButton","addMediaButtonDark","renderContent","modalIcon","emptyStateDescription","plusCircleFilled","color","size","appenderStyle","appender","appenderDark","emptyStateContainerStyle","emptyStateContainer","emptyStateContainerDark","flex","open","getMediaOptions","event"],"mappings":";;;;;;;;;AAiBA;;AAdA;;AACA;;AAKA;;AACA;;AAMA;;AAEA;;AAKA;;AAvBA;AACA;AACA;;AAIA;AACA;AACA;;AAYA;AACA;AACA;AAGA;AACA,MAAMA,UAAU,GAAKC,KAAF,IAClB,sBACCA,KADD,EAEC,CAAEC,MAAF,EAAUC,MAAV,KACCD,MAAM,CAACE,EAAP,KAAc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,EAAG,KARpB;AASC,IAAA,QAAQ,EAAGM,mBATZ;AAUC,IAAA,MAAM,EAAG,QAAiC;AAAA,UAA/B;AAAEwC,QAAAA,IAAF;AAAQC,QAAAA;AAAR,OAA+B;AACzC,aACC,4BAAC,qCAAD;AACC,QAAA,kBAAkB,EAAG;AACpB;AACA,sBAAI,iBAAJ,CAFoB,EAGpB1B,gBAHoB,CADtB;AAMC,QAAA,iBAAiB,EAAG,QANrB;AAOC,QAAA,iBAAiB,EAAGI,iBAPrB;AAQC,QAAA,OAAO,EAAKuB,KAAF,IAAa;AACtBrD,UAAAA,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAIqD,KAAJ,CAAP;AACAF,UAAAA,IAAI;AACJ;AAXF,SAaC,4BAAC,iBAAD;AACC,QAAA,KAAK,EAAG,CACP,CACCJ,wBADD,EAECvC,MAAM,IAAI;AAAEA,UAAAA;AAAF,SAFX,EAGCC,eAAe,IAAI;AAAEA,UAAAA;AAAF,SAHpB,CADO,EAMPP,UAAU,IAAI0C,aANP;AADT,SAUGQ,eAAe,EAVlB,EAWG,CAAE1C,WAAF,IAAiB4B,aAAa,EAXjC,CAbD,CADD;AA6BA;AAxCF,IADD,CADD;AA8CA;;eAEc,uCAA0B7C,gBAA1B,C","sourcesContent":["/**\n * External dependencies\n */\nimport { View, Text, TouchableWithoutFeedback } from 'react-native';\nimport { uniqWith } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tMediaUpload,\n\tMEDIA_TYPE_IMAGE,\n\tMEDIA_TYPE_VIDEO,\n\tMEDIA_TYPE_AUDIO,\n} from '@wordpress/block-editor';\nimport { withPreferredColorScheme } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\nimport { Icon, plusCircleFilled } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport styles from './styles.scss';\n\n// Remove duplicates after gallery append.\nconst dedupMedia = ( media ) =>\n\tuniqWith(\n\t\tmedia,\n\t\t( media1, media2 ) =>\n\t\t\tmedia1.id === media2.id || media1.url === media2.url\n\t);\n\nfunction MediaPlaceholder( props ) {\n\tconst {\n\t\taddToGallery,\n\t\tallowedTypes = [],\n\t\tlabels = {},\n\t\ticon,\n\t\tonSelect,\n\t\tonFocus,\n\t\t__experimentalOnlyMediaLibrary,\n\t\tisAppender,\n\t\tdisableMediaButtons,\n\t\tgetStylesFromColorScheme,\n\t\tmultiple,\n\t\tvalue = [],\n\t\tchildren,\n\t\theight,\n\t\tbackgroundColor,\n\t\thideContent,\n\t\tautoOpenMediaUpload,\n\t\tonSelectURL,\n\t} = props;\n\n\t// Use ref to keep media array current for callbacks during rerenders.\n\tconst mediaRef = useRef( value );\n\tmediaRef.current = value;\n\n\t// Append and deduplicate media array for gallery use case.\n\tconst setMedia =\n\t\tmultiple && addToGallery\n\t\t\t? ( selected ) =>\n\t\t\t\t\tonSelect(\n\t\t\t\t\t\tdedupMedia( [ ...mediaRef.current, ...selected ] )\n\t\t\t\t\t)\n\t\t\t: onSelect;\n\n\tconst isOneType = allowedTypes.length === 1;\n\tconst isImage = isOneType && allowedTypes.includes( MEDIA_TYPE_IMAGE );\n\tconst isVideo = isOneType && allowedTypes.includes( MEDIA_TYPE_VIDEO );\n\tconst isAudio = isOneType && allowedTypes.includes( MEDIA_TYPE_AUDIO );\n\n\tlet placeholderTitle = labels.title;\n\tif ( placeholderTitle === undefined ) {\n\t\tplaceholderTitle = __( 'Media' );\n\t\tif ( isImage ) {\n\t\t\tplaceholderTitle = __( 'Image' );\n\t\t} else if ( isVideo ) {\n\t\t\tplaceholderTitle = __( 'Video' );\n\t\t} else if ( isAudio ) {\n\t\t\tplaceholderTitle = __( 'Audio' );\n\t\t}\n\t}\n\n\tlet instructions = labels.instructions;\n\tif ( instructions === undefined ) {\n\t\tif ( isImage ) {\n\t\t\tinstructions = __( 'ADD IMAGE' );\n\t\t} else if ( isVideo ) {\n\t\t\tinstructions = __( 'ADD VIDEO' );\n\t\t} else if ( isAudio ) {\n\t\t\tinstructions = __( 'ADD AUDIO' );\n\t\t} else {\n\t\t\tinstructions = __( 'ADD IMAGE OR VIDEO' );\n\t\t}\n\t}\n\n\tlet accessibilityHint = __( 'Double tap to select' );\n\tif ( isImage ) {\n\t\taccessibilityHint = __( 'Double tap to select an image' );\n\t} else if ( isVideo ) {\n\t\taccessibilityHint = __( 'Double tap to select a video' );\n\t} else if ( isAudio ) {\n\t\taccessibilityHint = __( 'Double tap to select an audio file' );\n\t}\n\n\tconst emptyStateTitleStyle = getStylesFromColorScheme(\n\t\tstyles.emptyStateTitle,\n\t\tstyles.emptyStateTitleDark\n\t);\n\tconst addMediaButtonStyle = getStylesFromColorScheme(\n\t\tstyles.addMediaButton,\n\t\tstyles.addMediaButtonDark\n\t);\n\n\tconst renderContent = () => {\n\t\tif ( isAppender === undefined || ! isAppender ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<View style={ styles.modalIcon }>{ icon }</View>\n\t\t\t\t\t<Text style={ emptyStateTitleStyle }>\n\t\t\t\t\t\t{ placeholderTitle }\n\t\t\t\t\t</Text>\n\t\t\t\t\t{ children }\n\t\t\t\t\t<Text style={ styles.emptyStateDescription }>\n\t\t\t\t\t\t{ instructions }\n\t\t\t\t\t</Text>\n\t\t\t\t</>\n\t\t\t);\n\t\t} else if ( isAppender && ! disableMediaButtons ) {\n\t\t\treturn (\n\t\t\t\t<View testID=\"media-placeholder-appender-icon\">\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ plusCircleFilled }\n\t\t\t\t\t\tstyle={ addMediaButtonStyle }\n\t\t\t\t\t\tcolor={ addMediaButtonStyle.color }\n\t\t\t\t\t\tsize={ addMediaButtonStyle.size }\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t);\n\t\t}\n\t};\n\n\tif ( isAppender && disableMediaButtons ) {\n\t\treturn null;\n\t}\n\n\tconst appenderStyle = getStylesFromColorScheme(\n\t\tstyles.appender,\n\t\tstyles.appenderDark\n\t);\n\tconst emptyStateContainerStyle = getStylesFromColorScheme(\n\t\tstyles.emptyStateContainer,\n\t\tstyles.emptyStateContainerDark\n\t);\n\n\treturn (\n\t\t<View style={ { flex: 1 } }>\n\t\t\t<MediaUpload\n\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\tonSelect={ setMedia }\n\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t__experimentalOnlyMediaLibrary={\n\t\t\t\t\t__experimentalOnlyMediaLibrary\n\t\t\t\t}\n\t\t\t\tmultiple={ multiple }\n\t\t\t\tisReplacingMedia={ false }\n\t\t\t\tautoOpen={ autoOpenMediaUpload }\n\t\t\t\trender={ ( { open, getMediaOptions } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TouchableWithoutFeedback\n\t\t\t\t\t\t\taccessibilityLabel={ sprintf(\n\t\t\t\t\t\t\t\t/* translators: accessibility text for the media block empty state. %s: media type */\n\t\t\t\t\t\t\t\t__( '%s block. Empty' ),\n\t\t\t\t\t\t\t\tplaceholderTitle\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\t\t\t\taccessibilityHint={ accessibilityHint }\n\t\t\t\t\t\t\tonPress={ ( event ) => {\n\t\t\t\t\t\t\t\tonFocus?.( event );\n\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\temptyStateContainerStyle,\n\t\t\t\t\t\t\t\t\t\theight && { height },\n\t\t\t\t\t\t\t\t\t\tbackgroundColor && { backgroundColor },\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\tisAppender && appenderStyle,\n\t\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ getMediaOptions() }\n\t\t\t\t\t\t\t\t{ ! hideContent && renderContent() }\n\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t</TouchableWithoutFeedback>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t</View>\n\t);\n}\n\nexport default withPreferredColorScheme( MediaPlaceholder );\n"]}
|