@wordpress/block-editor 17.1.0 → 17.2.1-next.v.202609171837.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 +32 -0
- package/README.md +214 -214
- package/build/autocompleters/block.cjs.map +2 -2
- package/build/components/alignment-control/ui.cjs.map +2 -2
- package/build/components/background-image-control/index.cjs +1 -1
- package/build/components/background-image-control/index.cjs.map +2 -2
- package/build/components/block-alignment-control/ui.cjs +21 -7
- package/build/components/block-alignment-control/ui.cjs.map +3 -3
- package/build/components/block-alignment-control/use-available-alignments.cjs +60 -13
- package/build/components/block-alignment-control/use-available-alignments.cjs.map +2 -2
- package/build/components/block-allowed-blocks/allowed-blocks-control.cjs.map +2 -2
- package/build/components/block-bindings/attribute-control.cjs +30 -30
- package/build/components/block-bindings/attribute-control.cjs.map +3 -3
- package/build/components/block-bindings/source-fields-list.cjs +27 -32
- package/build/components/block-bindings/source-fields-list.cjs.map +3 -3
- package/build/components/block-canvas/index.cjs.map +2 -2
- package/build/components/block-card/index.cjs +1 -2
- package/build/components/block-card/index.cjs.map +3 -3
- package/build/components/block-edit/edit.cjs.map +2 -2
- package/build/components/block-heading-level-dropdown/index.cjs.map +2 -2
- package/build/components/block-icon/index.cjs.map +2 -2
- package/build/components/block-inspector/edit-contents.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +27 -8
- package/build/components/block-inspector/index.cjs.map +3 -3
- package/build/components/block-keyboard-shortcuts/index.cjs.map +2 -2
- package/build/components/block-list/block-html.cjs +1 -12
- package/build/components/block-list/block-html.cjs.map +3 -3
- package/build/components/block-list/block.cjs +2 -4
- package/build/components/block-list/block.cjs.map +2 -2
- package/build/components/block-list/layout.cjs +1 -1
- package/build/components/block-list/layout.cjs.map +2 -2
- package/build/components/block-list/use-block-props/index.cjs.map +2 -2
- package/build/components/block-lock/modal.cjs +1 -3
- package/build/components/block-lock/modal.cjs.map +2 -2
- package/build/components/block-parent-selector/index.cjs +8 -5
- package/build/components/block-parent-selector/index.cjs.map +2 -2
- package/build/components/block-popover/index.cjs.map +2 -2
- package/build/components/block-rename/modal.cjs.map +2 -2
- package/build/components/block-settings-menu/block-settings-dropdown.cjs.map +2 -2
- package/build/components/block-styles/utils.cjs.map +2 -2
- package/build/components/block-switcher/index.cjs.map +2 -2
- package/build/components/block-toolbar/edit-section-button.cjs.map +2 -2
- package/build/components/block-toolbar/index.cjs +6 -4
- package/build/components/block-toolbar/index.cjs.map +2 -2
- package/build/components/block-toolbar/switch-section-style.cjs.map +2 -2
- package/build/components/block-variation-transforms/index.cjs +28 -18
- package/build/components/block-variation-transforms/index.cjs.map +3 -3
- package/build/components/block-visibility/modal.cjs.map +2 -2
- package/build/components/block-visibility/viewport-visibility-info.cjs.map +2 -2
- package/build/components/border-radius-control/index.cjs.map +2 -2
- package/build/components/color-palette/with-color-context.cjs.map +2 -2
- package/build/components/colors/with-colors.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/contrast-checker/index.cjs.map +2 -2
- package/build/components/date-format-picker/index.cjs.map +2 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +3 -3
- package/build/components/dimensions-tool/width-height-tool.cjs.map +2 -2
- package/build/components/font-sizes/with-font-sizes.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +1 -1
- package/build/components/global-styles/background-panel.cjs.map +2 -2
- package/build/components/global-styles/border-panel.cjs +1 -1
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/color-gradient-dropdown-item.cjs +1 -1
- package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +2 -2
- package/build/components/global-styles/color-panel.cjs +1 -1
- package/build/components/global-styles/color-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +1 -1
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/filters-panel.cjs +1 -1
- package/build/components/global-styles/filters-panel.cjs.map +2 -2
- package/build/components/global-styles/hooks.cjs +1 -0
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/global-styles/inheritance/index.cjs +3 -3
- package/build/components/global-styles/inheritance/index.cjs.map +2 -2
- package/build/components/global-styles/inherited-value-context.cjs +0 -5
- package/build/components/global-styles/inherited-value-context.cjs.map +2 -2
- package/build/components/global-styles/state-control-badges.cjs +0 -1
- package/build/components/global-styles/state-control-badges.cjs.map +2 -2
- package/build/components/global-styles/state-control.cjs +6 -4
- package/build/components/global-styles/state-control.cjs.map +2 -2
- package/build/components/global-styles/text-shadow-panel.cjs +254 -0
- package/build/components/global-styles/text-shadow-panel.cjs.map +7 -0
- package/build/components/global-styles/typography-panel.cjs +46 -5
- package/build/components/global-styles/typography-panel.cjs.map +2 -2
- package/build/components/global-styles/typography-utils.cjs.map +2 -2
- package/build/components/global-styles/utils.cjs.map +2 -2
- package/build/components/html-element-control/index.cjs.map +3 -3
- package/build/components/iframe/index.cjs.map +2 -2
- package/build/components/iframe/use-scale-canvas.cjs.map +2 -2
- package/build/components/image-size-control/index.cjs.map +3 -3
- package/build/components/inner-blocks/index.cjs +6 -1
- package/build/components/inner-blocks/index.cjs.map +2 -2
- package/build/components/inner-content/index.cjs.map +2 -2
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.cjs +4 -23
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.cjs.map +2 -2
- package/build/components/inserter/block-patterns-tab/utils.cjs +26 -0
- package/build/components/inserter/block-patterns-tab/utils.cjs.map +2 -2
- package/build/components/inserter/hooks/use-block-types-state.cjs.map +2 -2
- package/build/components/inserter/hooks/use-insertion-point.cjs.map +2 -2
- package/build/components/inserter/hooks/use-patterns-state.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-panel.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
- package/build/components/inserter-list-item/index.cjs.map +2 -2
- package/build/components/inspector-controls/list-view-content-popover.cjs.map +2 -2
- package/build/components/link-control/search-results.cjs.map +2 -2
- package/build/components/link-control/use-search-handler.cjs +3 -0
- package/build/components/link-control/use-search-handler.cjs.map +2 -2
- package/build/components/list-view/branch.cjs.map +2 -2
- package/build/components/list-view/drop-indicator.cjs.map +2 -2
- package/build/components/list-view/index.cjs.map +2 -2
- package/build/components/list-view/use-list-view-drop-zone.cjs.map +2 -2
- package/build/components/list-view/utils.cjs.map +2 -2
- package/build/components/media-replace-flow/index.cjs +4 -1
- package/build/components/media-replace-flow/index.cjs.map +2 -2
- package/build/components/plain-text/index.cjs +1 -2
- package/build/components/plain-text/index.cjs.map +3 -3
- package/build/components/preset-input-control/index.cjs.map +2 -2
- package/build/components/provider/index.cjs +3 -1
- package/build/components/provider/index.cjs.map +2 -2
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/publish-date-time-picker/index.cjs.map +2 -2
- package/build/components/resizable-box-popover/index.cjs +1 -1
- package/build/components/resizable-box-popover/index.cjs.map +1 -1
- package/build/components/resolution-tool/index.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/enter.cjs +8 -22
- package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
- package/build/components/rich-text/format-edit.cjs.map +2 -2
- package/build/components/rich-text/index.cjs +20 -0
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/rich-text/multiline.cjs +10 -2
- package/build/components/rich-text/multiline.cjs.map +2 -2
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.cjs.map +2 -2
- package/build/components/typewriter/index.cjs.map +2 -2
- package/build/components/use-block-commands/index.cjs.map +2 -2
- package/build/components/writing-flow/index.cjs +3 -0
- package/build/components/writing-flow/index.cjs.map +2 -2
- package/build/components/writing-flow/use-clipboard-handler.cjs.map +2 -2
- package/build/components/writing-flow/use-selection-observer.cjs +5 -3
- package/build/components/writing-flow/use-selection-observer.cjs.map +2 -2
- package/build/hooks/align.cjs +3 -5
- package/build/hooks/align.cjs.map +2 -2
- package/build/hooks/background.cjs.map +2 -2
- package/build/hooks/block-bindings.cjs.map +2 -2
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/contrast-checker.cjs.map +2 -2
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/duotone.cjs.map +2 -2
- package/build/hooks/elements.cjs.map +2 -2
- package/build/hooks/fit-text.cjs.map +2 -2
- package/build/hooks/gap.cjs +2 -1
- package/build/hooks/gap.cjs.map +3 -3
- package/build/hooks/index.cjs +4 -2
- package/build/hooks/index.cjs.map +3 -3
- package/build/hooks/layout-child.cjs.map +2 -2
- package/build/hooks/layout.cjs +15 -14
- package/build/hooks/layout.cjs.map +3 -3
- package/build/hooks/position.cjs +3 -31
- package/build/hooks/position.cjs.map +2 -2
- package/build/hooks/states.cjs +3 -2
- package/build/hooks/states.cjs.map +2 -2
- package/build/hooks/text-shadow.cjs +100 -0
- package/build/hooks/text-shadow.cjs.map +7 -0
- package/build/hooks/typography.cjs +30 -6
- package/build/hooks/typography.cjs.map +2 -2
- package/build/hooks/utils.cjs +24 -2
- package/build/hooks/utils.cjs.map +2 -2
- package/build/layouts/grid.cjs.map +2 -2
- package/build/layouts/utils.cjs +7 -2
- package/build/layouts/utils.cjs.map +2 -2
- package/build/private-apis.cjs +9 -6
- package/build/private-apis.cjs.map +2 -2
- package/build/store/actions.cjs +26 -4
- package/build/store/actions.cjs.map +3 -3
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/get-font-styles-and-weights.cjs.map +2 -2
- package/build/utils/transform-styles/index.cjs.map +1 -1
- package/build-module/autocompleters/block.mjs.map +2 -2
- package/build-module/components/alignment-control/ui.mjs.map +2 -2
- package/build-module/components/background-image-control/index.mjs +2 -2
- package/build-module/components/background-image-control/index.mjs.map +2 -2
- package/build-module/components/block-alignment-control/ui.mjs +21 -7
- package/build-module/components/block-alignment-control/ui.mjs.map +2 -2
- package/build-module/components/block-alignment-control/use-available-alignments.mjs +56 -13
- package/build-module/components/block-alignment-control/use-available-alignments.mjs.map +2 -2
- package/build-module/components/block-allowed-blocks/allowed-blocks-control.mjs.map +2 -2
- package/build-module/components/block-bindings/attribute-control.mjs +31 -32
- package/build-module/components/block-bindings/attribute-control.mjs.map +2 -2
- package/build-module/components/block-bindings/source-fields-list.mjs +25 -30
- package/build-module/components/block-bindings/source-fields-list.mjs.map +2 -2
- package/build-module/components/block-canvas/index.mjs.map +2 -2
- package/build-module/components/block-card/index.mjs +3 -8
- package/build-module/components/block-card/index.mjs.map +2 -2
- package/build-module/components/block-edit/edit.mjs.map +2 -2
- package/build-module/components/block-heading-level-dropdown/index.mjs.map +2 -2
- package/build-module/components/block-icon/index.mjs.map +2 -2
- package/build-module/components/block-inspector/edit-contents.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +29 -10
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-keyboard-shortcuts/index.mjs.map +2 -2
- package/build-module/components/block-list/block-html.mjs +1 -2
- package/build-module/components/block-list/block-html.mjs.map +2 -2
- package/build-module/components/block-list/block.mjs +2 -4
- package/build-module/components/block-list/block.mjs.map +2 -2
- package/build-module/components/block-list/layout.mjs +1 -1
- package/build-module/components/block-list/layout.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/index.mjs.map +2 -2
- package/build-module/components/block-lock/modal.mjs +1 -3
- package/build-module/components/block-lock/modal.mjs.map +2 -2
- package/build-module/components/block-parent-selector/index.mjs +8 -5
- package/build-module/components/block-parent-selector/index.mjs.map +2 -2
- package/build-module/components/block-popover/index.mjs.map +2 -2
- package/build-module/components/block-rename/modal.mjs.map +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.mjs.map +2 -2
- package/build-module/components/block-styles/utils.mjs.map +2 -2
- package/build-module/components/block-switcher/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/edit-section-button.mjs.map +2 -2
- package/build-module/components/block-toolbar/index.mjs +6 -4
- package/build-module/components/block-toolbar/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/switch-section-style.mjs.map +2 -2
- package/build-module/components/block-variation-transforms/index.mjs +30 -21
- package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +2 -2
- package/build-module/components/border-radius-control/index.mjs.map +2 -2
- package/build-module/components/color-palette/with-color-context.mjs.map +2 -2
- package/build-module/components/colors/with-colors.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/contrast-checker/index.mjs.map +2 -2
- package/build-module/components/date-format-picker/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +2 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
- package/build-module/components/dimensions-tool/width-height-tool.mjs.map +2 -2
- package/build-module/components/font-sizes/with-font-sizes.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +2 -2
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +2 -2
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +2 -2
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +2 -2
- package/build-module/components/global-styles/color-panel.mjs +2 -2
- package/build-module/components/global-styles/color-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/filters-panel.mjs +2 -2
- package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +1 -0
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/global-styles/inheritance/index.mjs +2 -2
- package/build-module/components/global-styles/inheritance/index.mjs.map +2 -2
- package/build-module/components/global-styles/inherited-value-context.mjs +0 -5
- package/build-module/components/global-styles/inherited-value-context.mjs.map +2 -2
- package/build-module/components/global-styles/state-control-badges.mjs +0 -1
- package/build-module/components/global-styles/state-control-badges.mjs.map +2 -2
- package/build-module/components/global-styles/state-control.mjs +6 -4
- package/build-module/components/global-styles/state-control.mjs.map +2 -2
- package/build-module/components/global-styles/text-shadow-panel.mjs +224 -0
- package/build-module/components/global-styles/text-shadow-panel.mjs.map +7 -0
- package/build-module/components/global-styles/typography-panel.mjs +47 -6
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/global-styles/typography-utils.mjs.map +2 -2
- package/build-module/components/global-styles/utils.mjs.map +2 -2
- package/build-module/components/html-element-control/index.mjs +2 -2
- package/build-module/components/html-element-control/index.mjs.map +2 -2
- package/build-module/components/iframe/index.mjs.map +2 -2
- package/build-module/components/iframe/use-scale-canvas.mjs.map +2 -2
- package/build-module/components/image-size-control/index.mjs +2 -2
- package/build-module/components/image-size-control/index.mjs.map +2 -2
- package/build-module/components/inner-blocks/index.mjs +6 -1
- package/build-module/components/inner-blocks/index.mjs.map +2 -2
- package/build-module/components/inner-content/index.mjs.map +2 -2
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.mjs +6 -24
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.mjs.map +2 -2
- package/build-module/components/inserter/block-patterns-tab/utils.mjs +25 -0
- package/build-module/components/inserter/block-patterns-tab/utils.mjs.map +2 -2
- package/build-module/components/inserter/hooks/use-block-types-state.mjs.map +2 -2
- package/build-module/components/inserter/hooks/use-insertion-point.mjs.map +2 -2
- package/build-module/components/inserter/hooks/use-patterns-state.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-panel.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
- package/build-module/components/inserter-list-item/index.mjs.map +2 -2
- package/build-module/components/inspector-controls/list-view-content-popover.mjs.map +2 -2
- package/build-module/components/link-control/search-results.mjs.map +2 -2
- package/build-module/components/link-control/use-search-handler.mjs +3 -0
- package/build-module/components/link-control/use-search-handler.mjs.map +2 -2
- package/build-module/components/list-view/branch.mjs.map +2 -2
- package/build-module/components/list-view/drop-indicator.mjs.map +2 -2
- package/build-module/components/list-view/index.mjs.map +2 -2
- package/build-module/components/list-view/use-list-view-drop-zone.mjs.map +2 -2
- package/build-module/components/list-view/utils.mjs.map +2 -2
- package/build-module/components/media-replace-flow/index.mjs +4 -1
- package/build-module/components/media-replace-flow/index.mjs.map +2 -2
- package/build-module/components/plain-text/index.mjs +1 -2
- package/build-module/components/plain-text/index.mjs.map +2 -2
- package/build-module/components/preset-input-control/index.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +3 -1
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/publish-date-time-picker/index.mjs.map +2 -2
- package/build-module/components/resizable-box-popover/index.mjs +1 -1
- package/build-module/components/resizable-box-popover/index.mjs.map +1 -1
- package/build-module/components/resolution-tool/index.mjs +2 -2
- package/build-module/components/resolution-tool/index.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +8 -22
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/format-edit.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +21 -0
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/rich-text/multiline.mjs +11 -3
- package/build-module/components/rich-text/multiline.mjs.map +2 -2
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.mjs.map +2 -2
- package/build-module/components/typewriter/index.mjs.map +2 -2
- package/build-module/components/use-block-commands/index.mjs.map +2 -2
- package/build-module/components/writing-flow/index.mjs +3 -0
- package/build-module/components/writing-flow/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-clipboard-handler.mjs.map +2 -2
- package/build-module/components/writing-flow/use-selection-observer.mjs +5 -3
- package/build-module/components/writing-flow/use-selection-observer.mjs.map +2 -2
- package/build-module/hooks/align.mjs +6 -6
- package/build-module/hooks/align.mjs.map +2 -2
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/block-bindings.mjs.map +2 -2
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/contrast-checker.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/duotone.mjs.map +2 -2
- package/build-module/hooks/elements.mjs.map +2 -2
- package/build-module/hooks/fit-text.mjs.map +2 -2
- package/build-module/hooks/gap.mjs +2 -1
- package/build-module/hooks/gap.mjs.map +2 -2
- package/build-module/hooks/index.mjs +4 -2
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +6 -5
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/position.mjs +5 -33
- package/build-module/hooks/position.mjs.map +2 -2
- package/build-module/hooks/states.mjs +3 -2
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/hooks/text-shadow.mjs +65 -0
- package/build-module/hooks/text-shadow.mjs.map +7 -0
- package/build-module/hooks/typography.mjs +30 -6
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/hooks/utils.mjs +24 -2
- package/build-module/hooks/utils.mjs.map +2 -2
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/layouts/utils.mjs +5 -1
- package/build-module/layouts/utils.mjs.map +2 -2
- package/build-module/private-apis.mjs +6 -2
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs +28 -5
- package/build-module/store/actions.mjs.map +3 -3
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/get-font-styles-and-weights.mjs.map +2 -2
- package/build-module/utils/transform-styles/index.mjs.map +1 -1
- package/build-style/content-rtl.css +7 -2
- package/build-style/content.css +7 -2
- package/build-style/style-rtl.css +90 -25
- package/build-style/style.css +92 -25
- package/package.json +42 -43
- package/src/autocompleters/block.jsx +4 -4
- package/src/components/alignment-control/ui.jsx +1 -1
- package/src/components/background-image-control/index.jsx +3 -3
- package/src/components/block-alignment-control/test/index.jsdom.test.jsx +267 -0
- package/src/components/block-alignment-control/ui.jsx +47 -9
- package/src/components/block-alignment-control/use-available-alignments.js +106 -20
- package/src/components/block-allowed-blocks/allowed-blocks-control.jsx +1 -1
- package/src/components/block-bindings/attribute-control.jsx +27 -29
- package/src/components/block-bindings/source-fields-list.jsx +22 -32
- package/src/components/block-bindings/test/attribute-control.jsdom.test.jsx +115 -0
- package/src/components/block-canvas/index.jsx +1 -1
- package/src/components/block-card/index.jsx +5 -11
- package/src/components/block-card/style.scss +1 -0
- package/src/components/block-edit/edit.jsx +1 -1
- package/src/components/block-heading-level-dropdown/index.jsx +1 -1
- package/src/components/block-icon/index.jsx +1 -1
- package/src/components/block-icon/test/index.browser.test.jsx +74 -0
- package/src/components/block-inspector/edit-contents.jsx +2 -2
- package/src/components/block-inspector/index.jsx +46 -15
- package/src/components/block-inspector/style.scss +16 -0
- package/src/components/block-keyboard-shortcuts/index.jsx +2 -2
- package/src/components/block-list/block-html.jsx +2 -3
- package/src/components/block-list/block.jsx +7 -5
- package/src/components/block-list/content.scss +3 -2
- package/src/components/block-list/layout.jsx +4 -1
- package/src/components/block-list/test/layout.jsdom.test.js +40 -0
- package/src/components/block-list/use-block-props/index.js +1 -1
- package/src/components/block-lock/modal.jsx +2 -3
- package/src/components/block-lock/style.scss +1 -1
- package/src/components/block-mover/style.scss +0 -13
- package/src/components/block-parent-selector/index.jsx +12 -6
- package/src/components/block-patterns-list/style.scss +1 -1
- package/src/components/block-popover/index.jsx +1 -1
- package/src/components/block-rename/modal.jsx +3 -3
- package/src/components/block-settings-menu/block-settings-dropdown.jsx +1 -1
- package/src/components/block-styles/utils.js +1 -1
- package/src/components/block-switcher/index.jsx +3 -3
- package/src/components/block-toolbar/edit-section-button.jsx +2 -2
- package/src/components/block-toolbar/index.jsx +8 -4
- package/src/components/block-toolbar/switch-section-style.jsx +1 -1
- package/src/components/block-variation-transforms/index.jsx +24 -23
- package/src/components/block-variation-transforms/test/index.jsdom.test.jsx +93 -0
- package/src/components/block-visibility/modal.jsx +7 -7
- package/src/components/block-visibility/style.scss +1 -1
- package/src/components/block-visibility/viewport-visibility-info.jsx +5 -7
- package/src/components/border-radius-control/index.jsx +2 -2
- package/src/components/border-radius-control/test/index.jsdom.test.jsx +0 -22
- package/src/components/border-radius-control/test/select.browser.test.js +30 -0
- package/src/components/color-palette/with-color-context.jsx +1 -1
- package/src/components/colors/with-colors.jsx +1 -1
- package/src/components/colors-gradients/control.jsx +2 -2
- package/src/components/colors-gradients/test/{control.jsdom.test.jsx → control.browser.test.jsx} +6 -9
- package/src/components/contrast-checker/index.jsx +2 -2
- package/src/components/date-format-picker/index.jsx +2 -2
- package/src/components/dimensions-tool/aspect-ratio-tool.jsx +4 -4
- package/src/components/dimensions-tool/test/index.jsdom.test.jsx +17 -11
- package/src/components/dimensions-tool/width-height-tool.jsx +2 -2
- package/src/components/font-sizes/with-font-sizes.jsx +2 -3
- package/src/components/global-styles/background-panel.jsx +2 -2
- package/src/components/global-styles/border-panel.jsx +2 -2
- package/src/components/global-styles/color-gradient-dropdown-item.jsx +3 -3
- package/src/components/global-styles/color-panel.jsx +3 -3
- package/src/components/global-styles/dimensions-panel.jsx +6 -6
- package/src/components/global-styles/filters-panel.jsx +2 -2
- package/src/components/global-styles/hooks.js +1 -0
- package/src/components/global-styles/inheritance/index.jsx +9 -6
- package/src/components/global-styles/inheritance/test/{index.jsdom.test.jsx → index.browser.test.jsx} +34 -28
- package/src/components/global-styles/inherited-value-context.js +1 -9
- package/src/components/global-styles/state-control-badges.jsx +0 -1
- package/src/components/global-styles/state-control.jsx +12 -3
- package/src/components/global-styles/style.scss +68 -0
- package/src/components/global-styles/test/{color-panel.jsdom.test.jsx → color-panel.browser.test.jsx} +53 -54
- package/src/components/global-styles/test/inherited-value-context-core.jsdom.test.js +17 -26
- package/src/components/global-styles/test/{typography-panel-core.jsdom.test.jsx → typography-panel-core.browser.test.jsx} +84 -39
- package/src/components/global-styles/test/{typography-panel.jsdom.test.jsx → typography-panel.browser.test.jsx} +80 -122
- package/src/components/global-styles/text-shadow-panel.tsx +257 -0
- package/src/components/global-styles/typography-panel.jsx +52 -13
- package/src/components/global-styles/typography-utils.js +2 -2
- package/src/components/global-styles/utils.js +1 -1
- package/src/components/html-element-control/index.jsx +2 -2
- package/src/components/iframe/index.jsx +1 -1
- package/src/components/iframe/use-scale-canvas.js +1 -1
- package/src/components/image-size-control/index.jsx +2 -2
- package/src/components/inner-blocks/index.jsx +9 -1
- package/src/components/inner-content/index.jsx +1 -1
- package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +7 -33
- package/src/components/inserter/block-patterns-tab/utils.js +44 -0
- package/src/components/inserter/hooks/use-block-types-state.js +2 -2
- package/src/components/inserter/hooks/use-insertion-point.js +1 -1
- package/src/components/inserter/hooks/use-patterns-state.js +1 -1
- package/src/components/inserter/media-tab/media-panel.jsx +9 -9
- package/src/components/inserter/media-tab/media-preview.jsx +1 -1
- package/src/components/inserter-list-item/index.jsx +1 -1
- package/src/components/inserter-list-item/style.scss +2 -2
- package/src/components/inspector-controls/list-view-content-popover.jsx +1 -1
- package/src/components/link-control/search-results.jsx +1 -1
- package/src/components/link-control/style.scss +1 -1
- package/src/components/link-control/test/index.jsdom.test.jsx +38 -110
- package/src/components/link-control/test/keyboard-selection.browser.test.js +110 -0
- package/src/components/link-control/use-search-handler.js +8 -3
- package/src/components/list-view/branch.jsx +1 -1
- package/src/components/list-view/drop-indicator.jsx +3 -3
- package/src/components/list-view/index.jsx +1 -1
- package/src/components/list-view/style.scss +1 -9
- package/src/components/list-view/use-list-view-drop-zone.js +1 -1
- package/src/components/list-view/utils.js +1 -1
- package/src/components/media-replace-flow/index.jsx +4 -1
- package/src/components/navigable-toolbar/test/index.browser.test.js +6 -7
- package/src/components/plain-text/README.md +3 -2
- package/src/components/plain-text/content.scss +0 -1
- package/src/components/plain-text/index.jsx +2 -3
- package/src/components/plain-text/style.scss +4 -0
- package/src/components/preset-input-control/index.jsx +2 -2
- package/src/components/preset-input-control/test/index.jsdom.test.jsx +0 -56
- package/src/components/preset-input-control/test/interaction.browser.test.js +63 -0
- package/src/components/provider/index.jsx +5 -3
- package/src/components/provider/use-block-sync.js +5 -5
- package/src/components/publish-date-time-picker/index.jsx +1 -1
- package/src/components/resizable-box-popover/index.jsx +1 -1
- package/src/components/resolution-tool/index.jsx +2 -2
- package/src/components/responsive-block-control/style.scss +1 -2
- package/src/components/responsive-block-control/test/index.jsdom.test.jsx +2 -2
- package/src/components/rich-text/event-listeners/enter.js +16 -23
- package/src/components/rich-text/format-edit.jsx +1 -1
- package/src/components/rich-text/index.jsx +39 -2
- package/src/components/rich-text/multiline.jsx +11 -3
- package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/src/components/spacing-sizes-control/test/index.jsdom.test.jsx +0 -21
- package/src/components/spacing-sizes-control/test/select.browser.test.js +58 -0
- package/src/components/typewriter/index.jsx +1 -1
- package/src/components/url-input/test/fixtures/validated-input-control-deprecation.js +1 -1
- package/src/components/use-block-commands/index.js +1 -1
- package/src/components/use-block-drop-zone/test/index.js +2 -2
- package/src/components/writing-flow/index.jsx +8 -0
- package/src/components/writing-flow/use-clipboard-handler.js +1 -1
- package/src/components/writing-flow/use-selection-observer.js +15 -6
- package/src/content.scss +1 -0
- package/src/hooks/align.jsx +22 -6
- package/src/hooks/background.jsx +1 -1
- package/src/hooks/block-bindings.jsx +1 -1
- package/src/hooks/block-hooks.scss +0 -6
- package/src/hooks/border.jsx +2 -2
- package/src/hooks/contrast-checker.js +1 -1
- package/src/hooks/dimensions.jsx +2 -2
- package/src/hooks/duotone.jsx +3 -3
- package/src/hooks/elements.jsx +3 -3
- package/src/hooks/fit-text.jsx +1 -1
- package/src/hooks/gap.js +2 -4
- package/src/hooks/index.js +3 -1
- package/src/hooks/layout-child.jsx +3 -4
- package/src/hooks/layout.jsx +17 -18
- package/src/hooks/position.jsx +5 -36
- package/src/hooks/states.jsx +6 -2
- package/src/hooks/test/layout.jsdom.test.js +44 -1
- package/src/hooks/text-shadow.ts +105 -0
- package/src/hooks/typography.jsx +58 -30
- package/src/hooks/utils.jsx +23 -1
- package/src/layouts/grid.jsx +2 -2
- package/src/layouts/test/flex.jsdom.test.jsx +4 -3
- package/src/layouts/test/utils.js +48 -1
- package/src/layouts/utils.js +19 -0
- package/src/private-apis.js +4 -0
- package/src/store/actions.js +50 -10
- package/src/store/private-selectors.js +5 -5
- package/src/store/reducer.js +6 -6
- package/src/store/selectors.js +3 -3
- package/src/store/test/actions.jsdom.test.js +60 -0
- package/src/style.scss +1 -0
- package/src/utils/get-font-styles-and-weights.ts +1 -1
- package/src/utils/transform-styles/index.ts +1 -1
- package/build/hooks/cross-origin-isolation.cjs +0 -56
- package/build/hooks/cross-origin-isolation.cjs.map +0 -7
- package/build-module/hooks/cross-origin-isolation.mjs +0 -54
- package/build-module/hooks/cross-origin-isolation.mjs.map +0 -7
- package/src/components/block-icon/test/__snapshots__/index.jsdom.test.jsx.snap +0 -27
- package/src/components/block-icon/test/index.jsdom.test.jsx +0 -67
- package/src/hooks/cross-origin-isolation.js +0 -73
- package/src/hooks/test/cross-origin-isolation.jsdom.test.js +0 -173
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/inserter/media-tab/media-panel.jsx"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport { Button, Modal, Spinner, SearchControl } from '@wordpress/components';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { useDebouncedInput, usePrevious } from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\nimport { getScrollContainer } from '@wordpress/dom';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { Stack } from '@wordpress/ui';\nimport MediaList from './media-list';\nimport MediaUpload from '../../media-upload';\nimport MediaUploadCheck from '../../media-upload/check';\nimport { useMediaResults, useDelayedLoading } from './hooks';\nimport InserterNoResults from '../no-results';\nimport BlockPatternsPaging from '../../block-patterns-paging';\n\nconst MEDIA_ITEMS_PER_PAGE = 20;\n\n// The attach flow is image-only, so the picker is constrained to images.\nconst ATTACH_ALLOWED_TYPES = [ 'image' ];\n\n/**\n * Opens the Media Library to attach images to the current post. Only rendered\n * for media categories that expose an `attach` capability (i.e. the \"Attached\n * images\" source); other sources render the panel exactly as before.\n *\n * The picker opens fresh each time with no pre-selected value, so it is purely\n * additive: selecting images attaches them, and it does not imply that\n * deselecting would detach. Detaching is a separate, explicit per-item action.\n *\n * @param {Object} props\n * @param {Function} props.onSelect Called with the selected media items.\n */\nfunction AttachImagesButton( { onSelect } ) {\n\treturn (\n\t\t<MediaUploadCheck>\n\t\t\t<MediaUpload\n\t\t\t\tmultiple=\"add\"\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tallowedTypes={ ATTACH_ALLOWED_TYPES }\n\t\t\t\ttitle={ __( 'Attach images' ) }\n\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tclassName=\"block-editor-inserter__media-panel-attach\"\n\t\t\t\t\t\tdata-unstable-ignore-focus-outside-for-relatedtarget=\".media-modal\"\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.target.focus();\n\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Attach images' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t/>\n\t\t</MediaUploadCheck>\n\t);\n}\n\nexport function MediaCategoryPanel( { rootClientId, onInsert, category } ) {\n\tconst [ search, setSearch, debouncedSearch ] = useDebouncedInput();\n\tconst [ page, setPage ] = useState( 1 );\n\t// The desktop panel persists across category switches (it's driven by the\n\t// selected category, not remounted), so reset paging whenever the source\n\t// category or the search term changes. Adjusting state during render (rather\n\t// than in an effect) keeps the query on page 1 for the very next fetch,\n\t// avoiding a wasted request for the previous page. Mirrors `usePatternsPaging`.\n\tconst previousCategory = usePrevious( category.name );\n\tconst previousSearch = usePrevious( debouncedSearch );\n\tif (\n\t\t( previousCategory !== category.name ||\n\t\t\tpreviousSearch !== debouncedSearch ) &&\n\t\tpage !== 1\n\t) {\n\t\tsetPage( 1 );\n\t}\n\tconst query = useMemo(\n\t\t() => ( {\n\t\t\tper_page: MEDIA_ITEMS_PER_PAGE,\n\t\t\tpage,\n\t\t\tsearch: debouncedSearch,\n\t\t} ),\n\t\t[ page, debouncedSearch ]\n\t);\n\tconst [ refreshKey, setRefreshKey ] = useState( 0 );\n\tconst { mediaList, isLoading, totalItems, totalPages } = useMediaResults(\n\t\tcategory,\n\t\tquery,\n\t\trefreshKey\n\t);\n\tconst numPages = totalPages || 1;\n\t// If the current set shrinks below the active page (e.g. detaching images\n\t// empties the last page), clamp back into range so the grid isn't left blank\n\t// on a page that no longer exists.\n\tif ( typeof totalPages === 'number' && page > numPages ) {\n\t\tsetPage( numPages );\n\t}\n\t// Private to core's media categories, these capabilities act on WordPress\n\t// attachments:\n\t// - `attach`/`detach`/`invalidate` manage the images attached to this post.\n\t// - `subscribe` watches the attachment cache backing them.\n\t// An external resource can never own a post's attachments, and every category\n\t// registered by an extender through the public `registerInserterMediaCategory`\n\t// API is flagged as one — so this guard stops such a category from opting into\n\t// the workflow just by setting these props.\n\tconst supportsAttachments = ! category.isExternalResource;\n\tconst attach = supportsAttachments ? category.attach : undefined;\n\tconst detach = supportsAttachments ? category.detach : undefined;\n\tconst subscribe = supportsAttachments ? category.subscribe : undefined;\n\n\t// Only show the pager for multi-page sources. Gating on the page count (not\n\t// `mediaList.length`) keeps the footer mounted while paging, since the count\n\t// persists across the fetch. It also skips the shared component's stray\n\t// single-page item count, which reads oddly here.\n\tconst showPagination = numPages > 1;\n\t// The footer holds the pager and/or the attach button; it exists when either\n\t// is present so it can own their shared top/horizontal breathing room.\n\tconst hasFooter = showPagination || !! attach;\n\tconst scrollContainerRef = useRef();\n\tconst changePage = useCallback( ( nextPage ) => {\n\t\tconst scrollContainer = getScrollContainer(\n\t\t\tscrollContainerRef.current\n\t\t);\n\t\tscrollContainer?.scrollTo( 0, 0 );\n\t\tsetPage( nextPage );\n\t}, [] );\n\tconst { createErrorNotice, createSuccessNotice, createWarningNotice } =\n\t\tuseDispatch( noticesStore );\n\n\t// Dim (rather than blank) the populated grid while a refetch is in flight,\n\t// but only once it has run long enough to be worth signalling — quick\n\t// attach/detach refetches resolve before this and show nothing.\n\tconst showRefreshing = useDelayedLoading( isLoading );\n\n\t// Invalidate the cached results and force `useMediaResults` to refetch so\n\t// the grid reflects images that were just attached or detached.\n\tconst refresh = useCallback( () => {\n\t\tif ( supportsAttachments ) {\n\t\t\tcategory.invalidate?.( query );\n\t\t}\n\t\tsetRefreshKey( ( key ) => key + 1 );\n\t}, [ category, query, supportsAttachments ] );\n\n\t// A media modal opened anywhere in the editor (a canvas block, the featured\n\t// image panel, the \"Attach images\" button) attaches its uploads to the current\n\t// post, and invalidates the cached attachment queries when it closes. Refetch\n\t// so the grid reflects the newly attached images.\n\tuseEffect( () => {\n\t\tif ( ! subscribe ) {\n\t\t\treturn;\n\t\t}\n\t\treturn subscribe( () => setRefreshKey( ( key ) => key + 1 ), query );\n\t}, [ subscribe, query ] );\n\n\tconst handleAttach = useCallback(\n\t\tasync ( selectedMedia ) => {\n\t\t\ttry {\n\t\t\t\tconst attachedCount = await attach( selectedMedia );\n\n\t\t\t\tif ( ! attachedCount ) {\n\t\t\t\t\t// This source only attaches images (the picker's \"Upload\n\t\t\t\t\t// files\" tab otherwise accepts any file type), so a selection\n\t\t\t\t\t// with no images attaches nothing.\n\t\t\t\t\tcreateWarningNotice( __( 'No images were attached.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: 'inserter-notice',\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\trefresh();\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\tcategory.postTypeLabel\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %1$d: Number of images attached. %2$s: Name of the post type e.g: \"Page\". */\n\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t'%1$d image attached to %2$s.',\n\t\t\t\t\t\t\t\t\t'%1$d images attached to %2$s.',\n\t\t\t\t\t\t\t\t\tattachedCount\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tattachedCount,\n\t\t\t\t\t\t\t\tcategory.postTypeLabel\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: %d: Number of images attached to the post. */\n\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t'%d image attached to post.',\n\t\t\t\t\t\t\t\t\t'%d images attached to post.',\n\t\t\t\t\t\t\t\t\tattachedCount\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tattachedCount\n\t\t\t\t\t\t ),\n\t\t\t\t\t{ type: 'snackbar', id: 'inserter-notice' }\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\tcreateErrorNotice( __( 'Could not attach images.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'inserter-notice',\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tattach,\n\t\t\tcategory,\n\t\t\trefresh,\n\t\t\tcreateErrorNotice,\n\t\t\tcreateSuccessNotice,\n\t\t\tcreateWarningNotice,\n\t\t]\n\t);\n\n\tconst handleDetach = useCallback(\n\t\tasync ( media ) => {\n\t\t\ttry {\n\t\t\t\tawait detach( media );\n\t\t\t\trefresh();\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\tcategory.postTypeLabel\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: Name of the post type e.g: \"Page\". */\n\t\t\t\t\t\t\t\t__( 'Image detached from %s.' ),\n\t\t\t\t\t\t\t\tcategory.postTypeLabel\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Image detached from post.' ),\n\t\t\t\t\t{ type: 'snackbar', id: 'inserter-notice' }\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\tcreateErrorNotice( __( 'Could not detach image.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'inserter-notice',\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ detach, category, refresh, createErrorNotice, createSuccessNotice ]\n\t);\n\n\t// Detaching is confirmed first: the dropdown sets the pending item, which\n\t// opens a modal, and only `confirmDetach` performs the detach.\n\tconst [ mediaPendingDetach, setMediaPendingDetach ] = useState();\n\tconst confirmDetach = useCallback( () => {\n\t\tconst media = mediaPendingDetach;\n\t\tsetMediaPendingDetach( undefined );\n\t\thandleDetach( media );\n\t}, [ handleDetach, mediaPendingDetach ] );\n\n\tconst baseCssClass = 'block-editor-inserter__media-panel';\n\tconst searchLabel = category.labels.search_items || __( 'Search' );\n\treturn (\n\t\t<div\n\t\t\tref={ scrollContainerRef }\n\t\t\tclassName={ clsx( baseCssClass, {\n\t\t\t\t// The footer supplies the breathing room beneath the grid, so the\n\t\t\t\t// list drops its own bottom padding (see styles).\n\t\t\t\t'has-footer': hasFooter,\n\t\t\t} ) }\n\t\t>\n\t\t\t<SearchControl\n\t\t\t\tclassName={ `${ baseCssClass }-search` }\n\t\t\t\tonChange={ setSearch }\n\t\t\t\tvalue={ search }\n\t\t\t\tlabel={ searchLabel }\n\t\t\t\tplaceholder={ searchLabel }\n\t\t\t/>\n\t\t\t{ isLoading && ! mediaList?.length && (\n\t\t\t\t<div className={ `${ baseCssClass }-spinner` }>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! isLoading && ! mediaList?.length && (\n\t\t\t\t<InserterNoResults>\n\t\t\t\t\t{ category.emptyMessage && ! debouncedSearch\n\t\t\t\t\t\t? // For a source with a custom empty message (e.g.\n\t\t\t\t\t\t // Attachments) and no active search, an empty result\n\t\t\t\t\t\t // means nothing is attached yet — clearer than the\n\t\t\t\t\t\t // generic \"no results found\".\n\t\t\t\t\t\t category.emptyMessage\n\t\t\t\t\t\t: __( 'No results found.' ) }\n\t\t\t\t</InserterNoResults>\n\t\t\t) }\n\t\t\t{ !! mediaList?.length && (\n\t\t\t\t// Keep the existing items visible while a refetch is in flight,\n\t\t\t\t// dimming (and gently pulsing) them rather than clearing the grid,\n\t\t\t\t// so it doesn't flicker or pop.\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( `${ baseCssClass }-results`, {\n\t\t\t\t\t\t'is-loading': showRefreshing,\n\t\t\t\t\t} ) }\n\t\t\t\t\taria-busy={ showRefreshing }\n\t\t\t\t>\n\t\t\t\t\t<MediaList\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tonClick={ onInsert }\n\t\t\t\t\t\tonDetach={ detach ? setMediaPendingDetach : undefined }\n\t\t\t\t\t\tmediaList={ mediaList }\n\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ hasFooter && (\n\t\t\t\t// A single footer wrapper owns the top and horizontal breathing\n\t\t\t\t// room, so the pager and attach button don't span the full width\n\t\t\t\t// and sit clear of the grid above (see styles).\n\t\t\t\t<Stack\n\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\tgap=\"sm\"\n\t\t\t\t\tclassName={ `${ baseCssClass }-footer` }\n\t\t\t\t>\n\t\t\t\t\t{ showPagination && (\n\t\t\t\t\t\t// Reuse the Patterns tab pager (presentational only); only\n\t\t\t\t\t\t// rendered for multi-page sources (see `showPagination`).\n\t\t\t\t\t\t<BlockPatternsPaging\n\t\t\t\t\t\t\tcurrentPage={ page }\n\t\t\t\t\t\t\tnumPages={ numPages }\n\t\t\t\t\t\t\tchangePage={ changePage }\n\t\t\t\t\t\t\ttotalItems={ totalItems }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ attach && (\n\t\t\t\t\t\t// Lines up with the \"Open Media Library\" button in the\n\t\t\t\t\t\t// adjacent column.\n\t\t\t\t\t\t<AttachImagesButton onSelect={ handleAttach } />\n\t\t\t\t\t) }\n\t\t\t\t</Stack>\n\t\t\t) }\n\t\t\t{ mediaPendingDetach && (\n\t\t\t\t// A plain `Modal` (not `ConfirmDialog`) so we can pass\n\t\t\t\t// `overlayClassName` and stack it above the options dropdown that\n\t\t\t\t// opened it (see the z-index entry in `_z-index.scss`).\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Detach image' ) }\n\t\t\t\t\tonRequestClose={ () => setMediaPendingDetach( undefined ) }\n\t\t\t\t\toverlayClassName={ `${ baseCssClass }-detach-modal` }\n\t\t\t\t>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ category.postTypeLabel\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: Name of the post type e.g: \"Page\". */\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Detach this image from the current %s? The image will remain in the Media Library.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tcategory.postTypeLabel\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'Detach this image from the current post? The image will remain in the Media Library.'\n\t\t\t\t\t\t\t ) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<div className={ `${ baseCssClass }-detach-actions` }>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ () => setMediaPendingDetach( undefined ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tonClick={ confirmDetach }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Detach' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,wBAAsD;AACtD,kBAAgC;AAChC,qBAMO;AACP,qBAA+C;AAC/C,kBAA4B;AAC5B,iBAAmC;AACnC,qBAAsC;AACtC,gBAAsB;AACtB,wBAAsB;AACtB,0BAAwB;AACxB,mBAA6B;AAC7B,mBAAmD;AACnD,wBAA8B;AAC9B,mCAAgC;AA4B3B;AA1BL,IAAM,uBAAuB;AAG7B,IAAM,uBAAuB,CAAE,OAAQ;AAcvC,SAAS,mBAAoB,EAAE,SAAS,GAAI;AAC3C,SACC,4CAAC,aAAAA,SAAA,EACA;AAAA,IAAC,oBAAAC;AAAA,IAAA;AAAA,MACA,UAAS;AAAA,MACT;AAAA,MACA,cAAe;AAAA,MACf,WAAQ,gBAAI,eAAgB;AAAA,MAC5B,QAAS,CAAE,EAAE,KAAK,MACjB;AAAA,QAAC;AAAA;AAAA,UACA,uBAAqB;AAAA,UACrB,WAAU;AAAA,UACV,wDAAqD;AAAA,UACrD,SAAU,CAAE,UAAW;AACtB,kBAAM,OAAO,MAAM;AACnB,iBAAK;AAAA,UACN;AAAA,UACA,SAAQ;AAAA,UAEN,8BAAI,eAAgB;AAAA;AAAA,MACvB;AAAA;AAAA,EAEF,GACD;AAEF;AAEO,SAAS,mBAAoB,EAAE,cAAc,UA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B,eAAS,aAAc,KAAM;AAAA,IAC9B;AACA,kBAAe,CAAE,QAAS,MAAM,CAAE;AAAA,EACnC,GAAG,CAAE,UAAU,OAAO,mBAAoB,CAAE;AAM5C,gCAAW,MAAM;AAChB,QAAK,CAAE,WAAY;AAClB;AAAA,IACD;AACA,WAAO,UAAW,MAAM,cAAe,CAAE,QAAS,MAAM,CAAE,GAAG,KAAM;AAAA,EACpE,GAAG,CAAE,WAAW,KAAM,CAAE;AAExB,QAAM,mBAAe;AAAA,IACpB,OAAQ,kBAAmB;AAC1B,UAAI;AACH,cAAM,gBAAgB,MAAM,OAAQ,aAAc;AAElD,YAAK,CAAE,eAAgB;AAItB,kCAAqB,gBAAI,0BAA2B,GAAG;AAAA,YACtD,MAAM;AAAA,YACN,IAAI;AAAA,UACL,CAAE;AACF;AAAA,QACD;AAEA,gBAAQ;AACR;AAAA,UACC,SAAS,oBACN;AAAA;AAAA,gBAEA;AAAA,cACC;AAAA,cACA;AAAA,cACA;AAAA,YACD;AAAA,YACA;AAAA,YACA,SAAS;AAAA,
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport { Button, Modal, Spinner, SearchControl } from '@wordpress/components';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { useDebouncedInput, usePrevious } from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\nimport { getScrollContainer } from '@wordpress/dom';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { Stack } from '@wordpress/ui';\nimport MediaList from './media-list';\nimport MediaUpload from '../../media-upload';\nimport MediaUploadCheck from '../../media-upload/check';\nimport { useMediaResults, useDelayedLoading } from './hooks';\nimport InserterNoResults from '../no-results';\nimport BlockPatternsPaging from '../../block-patterns-paging';\n\nconst MEDIA_ITEMS_PER_PAGE = 20;\n\n// The attach flow is image-only, so the picker is constrained to images.\nconst ATTACH_ALLOWED_TYPES = [ 'image' ];\n\n/**\n * Opens the Media Library to attach images to the current post. Only rendered\n * for media categories that expose an `attach` capability (i.e. the \"Attached\n * images\" source); other sources render the panel exactly as before.\n *\n * The picker opens fresh each time with no pre-selected value, so it is purely\n * additive: selecting images attaches them, and it does not imply that\n * deselecting would detach. Detaching is a separate, explicit per-item action.\n *\n * @param {Object} props\n * @param {Function} props.onSelect Called with the selected media items.\n */\nfunction AttachImagesButton( { onSelect } ) {\n\treturn (\n\t\t<MediaUploadCheck>\n\t\t\t<MediaUpload\n\t\t\t\tmultiple=\"add\"\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tallowedTypes={ ATTACH_ALLOWED_TYPES }\n\t\t\t\ttitle={ __( 'Attach images' ) }\n\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tclassName=\"block-editor-inserter__media-panel-attach\"\n\t\t\t\t\t\tdata-unstable-ignore-focus-outside-for-relatedtarget=\".media-modal\"\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.target.focus();\n\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Attach images' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t/>\n\t\t</MediaUploadCheck>\n\t);\n}\n\nexport function MediaCategoryPanel( { rootClientId, onInsert, category } ) {\n\tconst [ search, setSearch, debouncedSearch ] = useDebouncedInput();\n\tconst [ page, setPage ] = useState( 1 );\n\t// The desktop panel persists across category switches (it's driven by the\n\t// selected category, not remounted), so reset paging whenever the source\n\t// category or the search term changes. Adjusting state during render (rather\n\t// than in an effect) keeps the query on page 1 for the very next fetch,\n\t// avoiding a wasted request for the previous page. Mirrors `usePatternsPaging`.\n\tconst previousCategory = usePrevious( category.name );\n\tconst previousSearch = usePrevious( debouncedSearch );\n\tif (\n\t\t( previousCategory !== category.name ||\n\t\t\tpreviousSearch !== debouncedSearch ) &&\n\t\tpage !== 1\n\t) {\n\t\tsetPage( 1 );\n\t}\n\tconst query = useMemo(\n\t\t() => ( {\n\t\t\tper_page: MEDIA_ITEMS_PER_PAGE,\n\t\t\tpage,\n\t\t\tsearch: debouncedSearch,\n\t\t} ),\n\t\t[ page, debouncedSearch ]\n\t);\n\tconst [ refreshKey, setRefreshKey ] = useState( 0 );\n\tconst { mediaList, isLoading, totalItems, totalPages } = useMediaResults(\n\t\tcategory,\n\t\tquery,\n\t\trefreshKey\n\t);\n\tconst numPages = totalPages || 1;\n\t// If the current set shrinks below the active page (e.g. detaching images\n\t// empties the last page), clamp back into range so the grid isn't left blank\n\t// on a page that no longer exists.\n\tif ( typeof totalPages === 'number' && page > numPages ) {\n\t\tsetPage( numPages );\n\t}\n\t// Private to core's media categories, these capabilities act on WordPress\n\t// attachments:\n\t// - `attach`/`detach`/`invalidate` manage the images attached to this post.\n\t// - `subscribe` watches the attachment cache backing them.\n\t// An external resource can never own a post's attachments, and every category\n\t// registered by an extender through the public `registerInserterMediaCategory`\n\t// API is flagged as one — so this guard stops such a category from opting into\n\t// the workflow just by setting these props.\n\tconst supportsAttachments = ! category.isExternalResource;\n\tconst attach = supportsAttachments ? category.attach : undefined;\n\tconst detach = supportsAttachments ? category.detach : undefined;\n\tconst subscribe = supportsAttachments ? category.subscribe : undefined;\n\n\t// Only show the pager for multi-page sources. Gating on the page count (not\n\t// `mediaList.length`) keeps the footer mounted while paging, since the count\n\t// persists across the fetch. It also skips the shared component's stray\n\t// single-page item count, which reads oddly here.\n\tconst showPagination = numPages > 1;\n\t// The footer holds the pager and/or the attach button; it exists when either\n\t// is present so it can own their shared top/horizontal breathing room.\n\tconst hasFooter = showPagination || !! attach;\n\tconst scrollContainerRef = useRef();\n\tconst changePage = useCallback( ( nextPage ) => {\n\t\tconst scrollContainer = getScrollContainer(\n\t\t\tscrollContainerRef.current\n\t\t);\n\t\tscrollContainer?.scrollTo( 0, 0 );\n\t\tsetPage( nextPage );\n\t}, [] );\n\tconst { createErrorNotice, createSuccessNotice, createWarningNotice } =\n\t\tuseDispatch( noticesStore );\n\n\t// Dim (rather than blank) the populated grid while a refetch is in flight,\n\t// but only once it has run long enough to be worth signalling — quick\n\t// attach/detach refetches resolve before this and show nothing.\n\tconst showRefreshing = useDelayedLoading( isLoading );\n\n\t// Invalidate the cached results and force `useMediaResults` to refetch so\n\t// the grid reflects images that were just attached or detached.\n\tconst refresh = useCallback( () => {\n\t\tif ( supportsAttachments ) {\n\t\t\tcategory.invalidate?.( query );\n\t\t}\n\t\tsetRefreshKey( ( key ) => key + 1 );\n\t}, [ category, query, supportsAttachments ] );\n\n\t// A media modal opened anywhere in the editor (a canvas block, the featured\n\t// image panel, the \"Attach images\" button) attaches its uploads to the current\n\t// post, and invalidates the cached attachment queries when it closes. Refetch\n\t// so the grid reflects the newly attached images.\n\tuseEffect( () => {\n\t\tif ( ! subscribe ) {\n\t\t\treturn;\n\t\t}\n\t\treturn subscribe( () => setRefreshKey( ( key ) => key + 1 ), query );\n\t}, [ subscribe, query ] );\n\n\tconst handleAttach = useCallback(\n\t\tasync ( selectedMedia ) => {\n\t\t\ttry {\n\t\t\t\tconst attachedCount = await attach( selectedMedia );\n\n\t\t\t\tif ( ! attachedCount ) {\n\t\t\t\t\t// This source only attaches images (the picker's \"Upload\n\t\t\t\t\t// files\" tab otherwise accepts any file type), so a selection\n\t\t\t\t\t// with no images attaches nothing.\n\t\t\t\t\tcreateWarningNotice( __( 'No images were attached.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: 'inserter-notice',\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\trefresh();\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\tcategory.postTypeLabel\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %1$d: Number of images attached. %2$s: Name of the post type e.g: \"Page\". */\n\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t'%1$d image attached to %2$s.',\n\t\t\t\t\t\t\t\t\t'%1$d images attached to %2$s.',\n\t\t\t\t\t\t\t\t\tattachedCount\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tattachedCount,\n\t\t\t\t\t\t\t\tcategory.postTypeLabel\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: %d: Number of images attached to the post. */\n\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t'%d image attached to post.',\n\t\t\t\t\t\t\t\t\t'%d images attached to post.',\n\t\t\t\t\t\t\t\t\tattachedCount\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tattachedCount\n\t\t\t\t\t\t\t),\n\t\t\t\t\t{ type: 'snackbar', id: 'inserter-notice' }\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\tcreateErrorNotice( __( 'Could not attach images.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'inserter-notice',\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tattach,\n\t\t\tcategory,\n\t\t\trefresh,\n\t\t\tcreateErrorNotice,\n\t\t\tcreateSuccessNotice,\n\t\t\tcreateWarningNotice,\n\t\t]\n\t);\n\n\tconst handleDetach = useCallback(\n\t\tasync ( media ) => {\n\t\t\ttry {\n\t\t\t\tawait detach( media );\n\t\t\t\trefresh();\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\tcategory.postTypeLabel\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: Name of the post type e.g: \"Page\". */\n\t\t\t\t\t\t\t\t__( 'Image detached from %s.' ),\n\t\t\t\t\t\t\t\tcategory.postTypeLabel\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: __( 'Image detached from post.' ),\n\t\t\t\t\t{ type: 'snackbar', id: 'inserter-notice' }\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\tcreateErrorNotice( __( 'Could not detach image.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'inserter-notice',\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ detach, category, refresh, createErrorNotice, createSuccessNotice ]\n\t);\n\n\t// Detaching is confirmed first: the dropdown sets the pending item, which\n\t// opens a modal, and only `confirmDetach` performs the detach.\n\tconst [ mediaPendingDetach, setMediaPendingDetach ] = useState();\n\tconst confirmDetach = useCallback( () => {\n\t\tconst media = mediaPendingDetach;\n\t\tsetMediaPendingDetach( undefined );\n\t\thandleDetach( media );\n\t}, [ handleDetach, mediaPendingDetach ] );\n\n\tconst baseCssClass = 'block-editor-inserter__media-panel';\n\tconst searchLabel = category.labels.search_items || __( 'Search' );\n\treturn (\n\t\t<div\n\t\t\tref={ scrollContainerRef }\n\t\t\tclassName={ clsx( baseCssClass, {\n\t\t\t\t// The footer supplies the breathing room beneath the grid, so the\n\t\t\t\t// list drops its own bottom padding (see styles).\n\t\t\t\t'has-footer': hasFooter,\n\t\t\t} ) }\n\t\t>\n\t\t\t<SearchControl\n\t\t\t\tclassName={ `${ baseCssClass }-search` }\n\t\t\t\tonChange={ setSearch }\n\t\t\t\tvalue={ search }\n\t\t\t\tlabel={ searchLabel }\n\t\t\t\tplaceholder={ searchLabel }\n\t\t\t/>\n\t\t\t{ isLoading && ! mediaList?.length && (\n\t\t\t\t<div className={ `${ baseCssClass }-spinner` }>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! isLoading && ! mediaList?.length && (\n\t\t\t\t<InserterNoResults>\n\t\t\t\t\t{ category.emptyMessage && ! debouncedSearch\n\t\t\t\t\t\t? // For a source with a custom empty message (e.g.\n\t\t\t\t\t\t\t// Attachments) and no active search, an empty result\n\t\t\t\t\t\t\t// means nothing is attached yet — clearer than the\n\t\t\t\t\t\t\t// generic \"no results found\".\n\t\t\t\t\t\t\tcategory.emptyMessage\n\t\t\t\t\t\t: __( 'No results found.' ) }\n\t\t\t\t</InserterNoResults>\n\t\t\t) }\n\t\t\t{ !! mediaList?.length && (\n\t\t\t\t// Keep the existing items visible while a refetch is in flight,\n\t\t\t\t// dimming (and gently pulsing) them rather than clearing the grid,\n\t\t\t\t// so it doesn't flicker or pop.\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( `${ baseCssClass }-results`, {\n\t\t\t\t\t\t'is-loading': showRefreshing,\n\t\t\t\t\t} ) }\n\t\t\t\t\taria-busy={ showRefreshing }\n\t\t\t\t>\n\t\t\t\t\t<MediaList\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tonClick={ onInsert }\n\t\t\t\t\t\tonDetach={ detach ? setMediaPendingDetach : undefined }\n\t\t\t\t\t\tmediaList={ mediaList }\n\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ hasFooter && (\n\t\t\t\t// A single footer wrapper owns the top and horizontal breathing\n\t\t\t\t// room, so the pager and attach button don't span the full width\n\t\t\t\t// and sit clear of the grid above (see styles).\n\t\t\t\t<Stack\n\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\tgap=\"sm\"\n\t\t\t\t\tclassName={ `${ baseCssClass }-footer` }\n\t\t\t\t>\n\t\t\t\t\t{ showPagination && (\n\t\t\t\t\t\t// Reuse the Patterns tab pager (presentational only); only\n\t\t\t\t\t\t// rendered for multi-page sources (see `showPagination`).\n\t\t\t\t\t\t<BlockPatternsPaging\n\t\t\t\t\t\t\tcurrentPage={ page }\n\t\t\t\t\t\t\tnumPages={ numPages }\n\t\t\t\t\t\t\tchangePage={ changePage }\n\t\t\t\t\t\t\ttotalItems={ totalItems }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ attach && (\n\t\t\t\t\t\t// Lines up with the \"Open Media Library\" button in the\n\t\t\t\t\t\t// adjacent column.\n\t\t\t\t\t\t<AttachImagesButton onSelect={ handleAttach } />\n\t\t\t\t\t) }\n\t\t\t\t</Stack>\n\t\t\t) }\n\t\t\t{ mediaPendingDetach && (\n\t\t\t\t// A plain `Modal` (not `ConfirmDialog`) so we can pass\n\t\t\t\t// `overlayClassName` and stack it above the options dropdown that\n\t\t\t\t// opened it (see the z-index entry in `_z-index.scss`).\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Detach image' ) }\n\t\t\t\t\tonRequestClose={ () => setMediaPendingDetach( undefined ) }\n\t\t\t\t\toverlayClassName={ `${ baseCssClass }-detach-modal` }\n\t\t\t\t>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ category.postTypeLabel\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: Name of the post type e.g: \"Page\". */\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Detach this image from the current %s? The image will remain in the Media Library.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tcategory.postTypeLabel\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\t'Detach this image from the current post? The image will remain in the Media Library.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<div className={ `${ baseCssClass }-detach-actions` }>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ () => setMediaPendingDetach( undefined ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tonClick={ confirmDetach }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{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YACV,KAAI;AAAA,YACJ,WAAY,GAAI,YAAa;AAAA,YAE3B;AAAA;AAAA;AAAA,cAGD;AAAA,gBAAC,6BAAAC;AAAA,gBAAA;AAAA,kBACA,aAAc;AAAA,kBACd;AAAA,kBACA;AAAA,kBACA;AAAA;AAAA,cACD;AAAA,cAEC;AAAA;AAAA,cAGD,4CAAC,sBAAmB,UAAW,cAAe;AAAA;AAAA;AAAA,QAEhD;AAAA,QAEC;AAAA;AAAA;AAAA,QAID;AAAA,UAAC;AAAA;AAAA,YACA,WAAQ,gBAAI,cAAe;AAAA,YAC3B,gBAAiB,MAAM,sBAAuB,MAAU;AAAA,YACxD,kBAAmB,GAAI,YAAa;AAAA,YAEpC;AAAA,0DAAC,OACE,mBAAS,oBACR;AAAA;AAAA,oBAEA;AAAA,kBACC;AAAA,gBACD;AAAA,gBACA,SAAS;AAAA,cACV,QACC;AAAA,gBACA;AAAA,cACD,GACH;AAAA,cACA,6CAAC,SAAI,WAAY,GAAI,YAAa,mBACjC;AAAA;AAAA,kBAAC;AAAA;AAAA,oBACA,uBAAqB;AAAA,oBACrB,SAAQ;AAAA,oBACR,SAAU,MAAM,sBAAuB,MAAU;AAAA,oBAE/C,8BAAI,QAAS;AAAA;AAAA,gBAChB;AAAA,gBACA;AAAA,kBAAC;AAAA;AAAA,oBACA,uBAAqB;AAAA,oBACrB,SAAQ;AAAA,oBACR,SAAU;AAAA,oBAER,8BAAI,QAAS;AAAA;AAAA,gBAChB;AAAA,iBACD;AAAA;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EAEF;AAEF;",
|
|
6
6
|
"names": ["MediaUploadCheck", "MediaUpload", "noticesStore", "clsx", "InserterNoResults", "MediaList", "BlockPatternsPaging"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/inserter/media-tab/media-preview.jsx"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tSpinner,\n\tModal,\n\tFlex,\n\tFlexItem,\n\tButton,\n\tComposite,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useMemo, useCallback, useState } from '@wordpress/element';\nimport { cloneBlock } from '@wordpress/blocks';\nimport { moreVertical, external, linkOff } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { isBlobURL } from '@wordpress/blob';\nimport { getFilename } from '@wordpress/url';\nimport { Tooltip } from '@wordpress/ui';\nimport InserterDraggableBlocks from '../../inserter-draggable-blocks';\nimport { getBlockAndPreviewFromMedia } from './utils';\nimport { store as blockEditorStore } from '../../../store';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\nconst MEDIA_OPTIONS_POPOVER_PROPS = {\n\tplacement: 'bottom-end',\n\tclassName:\n\t\t'block-editor-inserter__media-list__item-preview-options__popover',\n};\n\nfunction MediaPreviewOptions( { category, media, onDetach } ) {\n\tif ( ! category.getReportUrl && ! onDetach ) {\n\t\treturn null;\n\t}\n\tconst reportUrl = category.getReportUrl?.( media );\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName=\"block-editor-inserter__media-list__item-preview-options\"\n\t\t\tlabel={ __( 'Options' ) }\n\t\t\tpopoverProps={ MEDIA_OPTIONS_POPOVER_PROPS }\n\t\t\ticon={ moreVertical }\n\t\t>\n\t\t\t{ () => (\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t{ reportUrl && (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\twindow.open( reportUrl, '_blank' ).focus()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: The media type to report e.g: \"image\", \"video\", \"audio\" */\n\t\t\t\t\t\t\t\t__( 'Report %s' ),\n\t\t\t\t\t\t\t\tcategory.mediaType\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t) }\n\t\t\t\t\t{ onDetach && (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => onDetach( media ) }\n\t\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ category.postTypeLabel\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: %s: Name of the post type e.g: \"Page\". */\n\t\t\t\t\t\t\t\t\t\t__( 'Detach from %s' ),\n\t\t\t\t\t\t\t\t\t\tcategory.postTypeLabel\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __( 'Detach from post' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t) }\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n\nfunction InsertExternalImageModal( { onClose, onSubmit } ) {\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Insert external image' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t\tclassName=\"block-editor-inserter-media-tab-media-preview-inserter-external-image-modal\"\n\t\t>\n\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'This image cannot be uploaded to your Media Library, but it can still be inserted as an external image.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'External images can be removed by the external provider without warning and could even have legal compliance issues related to privacy legislation.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t</VStack>\n\t\t\t<Flex\n\t\t\t\tclassName=\"block-editor-block-lock-modal__actions\"\n\t\t\t\tjustify=\"flex-end\"\n\t\t\t\texpanded={ false }\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ onSubmit }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Insert' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</Modal>\n\t);\n}\n\nexport function MediaPreview( { media, onClick, onDetach, category } ) {\n\tconst [ showExternalUploadModal, setShowExternalUploadModal ] =\n\t\tuseState( false );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst [ isInserting, setIsInserting ] = useState( false );\n\tconst [ block, preview ] = useMemo(\n\t\t() => getBlockAndPreviewFromMedia( media, category.mediaType ),\n\t\t[ media, category.mediaType ]\n\t);\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { getSettings, getBlock } = useSelect( blockEditorStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst onMediaInsert = useCallback(\n\t\t( previewBlock ) => {\n\t\t\t// Prevent multiple uploads when we're in the process of inserting.\n\t\t\tif ( isInserting ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst settings = getSettings();\n\t\t\tconst clonedBlock = cloneBlock( previewBlock );\n\t\t\tconst { id, url, caption } = clonedBlock.attributes;\n\n\t\t\t// User has no permission to upload media.\n\t\t\tif ( ! id && ! settings.mediaUpload ) {\n\t\t\t\tsetShowExternalUploadModal( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Media item already exists in library, so just insert it.\n\t\t\tif ( !! id ) {\n\t\t\t\tonClick( clonedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetIsInserting( true );\n\t\t\t// Media item does not exist in library, so try to upload it.\n\t\t\t// Fist fetch the image data. This may fail if the image host\n\t\t\t// doesn't allow CORS with the domain.\n\t\t\t// If this happens, we insert the image block using the external\n\t\t\t// URL and let the user know about the possible implications.\n\t\t\twindow\n\t\t\t\t.fetch( url )\n\t\t\t\t.then( ( response ) => response.blob() )\n\t\t\t\t.then( ( blob ) => {\n\t\t\t\t\tconst fileName = getFilename( url ) || 'image.jpg';\n\t\t\t\t\tconst file = new File( [ blob ], fileName, {\n\t\t\t\t\t\ttype: blob.type,\n\t\t\t\t\t} );\n\n\t\t\t\t\tsettings.mediaUpload( {\n\t\t\t\t\t\tfilesList: [ file ],\n\t\t\t\t\t\tadditionalData: { caption },\n\t\t\t\t\t\tonFileChange( [ img ] ) {\n\t\t\t\t\t\t\tif ( isBlobURL( img.url ) ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif ( ! getBlock( clonedBlock.clientId ) ) {\n\t\t\t\t\t\t\t\t// Ensure the block is only inserted once.\n\t\t\t\t\t\t\t\tonClick( {\n\t\t\t\t\t\t\t\t\t...clonedBlock,\n\t\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\t...clonedBlock.attributes,\n\t\t\t\t\t\t\t\t\t\tid: img.id,\n\t\t\t\t\t\t\t\t\t\turl: img.url,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t\t__( 'Image uploaded and inserted.' ),\n\t\t\t\t\t\t\t\t\t{ type: 'snackbar', id: 'inserter-notice' }\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// For subsequent calls, update the existing block.\n\t\t\t\t\t\t\t\tupdateBlockAttributes( clonedBlock.clientId, {\n\t\t\t\t\t\t\t\t\t...clonedBlock.attributes,\n\t\t\t\t\t\t\t\t\tid: img.id,\n\t\t\t\t\t\t\t\t\turl: img.url,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tsetIsInserting( false );\n\t\t\t\t\t\t},\n\t\t\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\t\t\tonError( message ) {\n\t\t\t\t\t\t\tcreateErrorNotice( message, {\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: 'inserter-notice',\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tsetIsInserting( false );\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => {\n\t\t\t\t\tsetShowExternalUploadModal( true );\n\t\t\t\t\tsetIsInserting( false );\n\t\t\t\t} );\n\t\t},\n\t\t[\n\t\t\tisInserting,\n\t\t\tgetSettings,\n\t\t\tonClick,\n\t\t\tcreateSuccessNotice,\n\t\t\tupdateBlockAttributes,\n\t\t\tcreateErrorNotice,\n\t\t\tgetBlock,\n\t\t]\n\t);\n\n\tconst title =\n\t\ttypeof media.title === 'string'\n\t\t\t? media.title\n\t\t\t: media.title?.rendered || __( 'no title' );\n\n\tconst onMouseEnter = useCallback( () => setIsHovered( true ), [] );\n\tconst onMouseLeave = useCallback( () => setIsHovered( false ), [] );\n\treturn (\n\t\t<>\n\t\t\t<InserterDraggableBlocks isEnabled blocks={ [ block ] }>\n\t\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-editor-inserter__media-list__list-item',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-hovered': isHovered,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\t\tonDragStart={ onDragStart }\n\t\t\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ /* Adding `is-hovered` class to the wrapper element is needed\n\t\t\t\t\t\tbecause the options Popover is rendered outside of this node. */ }\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\t\t\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Tooltip.Root>\n\t\t\t\t\t\t\t\t<Tooltip.Trigger\n\t\t\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t\t\t<Composite.Item\n\t\t\t\t\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\t\taria-label={ title }\n\t\t\t\t\t\t\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-inserter__media-list__item\"\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\t\tonMediaInsert( block )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<div className=\"block-editor-inserter__media-list__item-preview\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ preview }\n\t\t\t\t\t\t\t\t\t\t\t\t{ isInserting && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div className=\"block-editor-inserter__media-list__item-preview-spinner\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t</Composite.Item>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<Tooltip.Popup>{ title }</Tooltip.Popup>\n\t\t\t\t\t\t\t</Tooltip.Root>\n\t\t\t\t\t\t\t{ ! isInserting && (\n\t\t\t\t\t\t\t\t<MediaPreviewOptions\n\t\t\t\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t\t\t\t\tmedia={ media }\n\t\t\t\t\t\t\t\t\tonDetach={ onDetach }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</InserterDraggableBlocks>\n\t\t\t{ showExternalUploadModal && (\n\t\t\t\t<InsertExternalImageModal\n\t\t\t\t\tonClose={ () => setShowExternalUploadModal( false ) }\n\t\t\t\t\tonSubmit={ () => {\n\t\t\t\t\t\tonClick( cloneBlock( block ) );\n\t\t\t\t\t\tcreateSuccessNotice( __( 'Image inserted.' ), {\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'inserter-notice',\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tsetShowExternalUploadModal( false );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,wBAWO;AACP,kBAA4B;AAC5B,qBAA+C;AAC/C,oBAA2B;AAC3B,mBAAgD;AAChD,kBAAuC;AACvC,qBAAsC;AACtC,kBAA0B;AAC1B,iBAA4B;AAC5B,gBAAwB;AACxB,uCAAoC;AACpC,mBAA4C;AAC5C,mBAA0C;AAsBtC;AApBJ,IAAM,sBAAsB,CAAE,OAAQ;AACtC,IAAM,8BAA8B;AAAA,EACnC,WAAW;AAAA,EACX,WACC;AACF;AAEA,SAAS,oBAAqB,EAAE,UAAU,OAAO,SAAS,GAAI;AAC7D,MAAK,CAAE,SAAS,gBAAgB,CAAE,UAAW;AAC5C,WAAO;AAAA,EACR;AACA,QAAM,YAAY,SAAS,eAAgB,KAAM;AACjD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,WAAQ,gBAAI,SAAU;AAAA,MACtB,cAAe;AAAA,MACf,MAAO;AAAA,MAEL,gBACD,6CAAC,+BACE;AAAA,qBACD;AAAA,UAAC;AAAA;AAAA,YACA,SAAU,MACT,OAAO,KAAM,WAAW,QAAS,EAAE,MAAM;AAAA,YAE1C,MAAO;AAAA,YAEL;AAAA;AAAA,kBAED,gBAAI,WAAY;AAAA,cAChB,SAAS;AAAA,YACV;AAAA;AAAA,QACD;AAAA,QAEC,YACD;AAAA,UAAC;AAAA;AAAA,YACA,SAAU,MAAM,SAAU,KAAM;AAAA,YAChC,MAAO;AAAA,YAEL,mBAAS,oBACR;AAAA;AAAA,kBAEA,gBAAI,gBAAiB;AAAA,cACrB,SAAS;AAAA,
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tSpinner,\n\tModal,\n\tFlex,\n\tFlexItem,\n\tButton,\n\tComposite,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useMemo, useCallback, useState } from '@wordpress/element';\nimport { cloneBlock } from '@wordpress/blocks';\nimport { moreVertical, external, linkOff } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { isBlobURL } from '@wordpress/blob';\nimport { getFilename } from '@wordpress/url';\nimport { Tooltip } from '@wordpress/ui';\nimport InserterDraggableBlocks from '../../inserter-draggable-blocks';\nimport { getBlockAndPreviewFromMedia } from './utils';\nimport { store as blockEditorStore } from '../../../store';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\nconst MEDIA_OPTIONS_POPOVER_PROPS = {\n\tplacement: 'bottom-end',\n\tclassName:\n\t\t'block-editor-inserter__media-list__item-preview-options__popover',\n};\n\nfunction MediaPreviewOptions( { category, media, onDetach } ) {\n\tif ( ! category.getReportUrl && ! onDetach ) {\n\t\treturn null;\n\t}\n\tconst reportUrl = category.getReportUrl?.( media );\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName=\"block-editor-inserter__media-list__item-preview-options\"\n\t\t\tlabel={ __( 'Options' ) }\n\t\t\tpopoverProps={ MEDIA_OPTIONS_POPOVER_PROPS }\n\t\t\ticon={ moreVertical }\n\t\t>\n\t\t\t{ () => (\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t{ reportUrl && (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\twindow.open( reportUrl, '_blank' ).focus()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: The media type to report e.g: \"image\", \"video\", \"audio\" */\n\t\t\t\t\t\t\t\t__( 'Report %s' ),\n\t\t\t\t\t\t\t\tcategory.mediaType\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t) }\n\t\t\t\t\t{ onDetach && (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => onDetach( media ) }\n\t\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ category.postTypeLabel\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: %s: Name of the post type e.g: \"Page\". */\n\t\t\t\t\t\t\t\t\t\t__( 'Detach from %s' ),\n\t\t\t\t\t\t\t\t\t\tcategory.postTypeLabel\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t: __( 'Detach from post' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t) }\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n\nfunction InsertExternalImageModal( { onClose, onSubmit } ) {\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Insert external image' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t\tclassName=\"block-editor-inserter-media-tab-media-preview-inserter-external-image-modal\"\n\t\t>\n\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'This image cannot be uploaded to your Media Library, but it can still be inserted as an external image.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'External images can be removed by the external provider without warning and could even have legal compliance issues related to privacy legislation.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t</VStack>\n\t\t\t<Flex\n\t\t\t\tclassName=\"block-editor-block-lock-modal__actions\"\n\t\t\t\tjustify=\"flex-end\"\n\t\t\t\texpanded={ false }\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ onSubmit }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Insert' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</Modal>\n\t);\n}\n\nexport function MediaPreview( { media, onClick, onDetach, category } ) {\n\tconst [ showExternalUploadModal, setShowExternalUploadModal ] =\n\t\tuseState( false );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst [ isInserting, setIsInserting ] = useState( false );\n\tconst [ block, preview ] = useMemo(\n\t\t() => getBlockAndPreviewFromMedia( media, category.mediaType ),\n\t\t[ media, category.mediaType ]\n\t);\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { getSettings, getBlock } = useSelect( blockEditorStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst onMediaInsert = useCallback(\n\t\t( previewBlock ) => {\n\t\t\t// Prevent multiple uploads when we're in the process of inserting.\n\t\t\tif ( isInserting ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst settings = getSettings();\n\t\t\tconst clonedBlock = cloneBlock( previewBlock );\n\t\t\tconst { id, url, caption } = clonedBlock.attributes;\n\n\t\t\t// User has no permission to upload media.\n\t\t\tif ( ! id && ! settings.mediaUpload ) {\n\t\t\t\tsetShowExternalUploadModal( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Media item already exists in library, so just insert it.\n\t\t\tif ( !! id ) {\n\t\t\t\tonClick( clonedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetIsInserting( true );\n\t\t\t// Media item does not exist in library, so try to upload it.\n\t\t\t// Fist fetch the image data. This may fail if the image host\n\t\t\t// doesn't allow CORS with the domain.\n\t\t\t// If this happens, we insert the image block using the external\n\t\t\t// URL and let the user know about the possible implications.\n\t\t\twindow\n\t\t\t\t.fetch( url )\n\t\t\t\t.then( ( response ) => response.blob() )\n\t\t\t\t.then( ( blob ) => {\n\t\t\t\t\tconst fileName = getFilename( url ) || 'image.jpg';\n\t\t\t\t\tconst file = new File( [ blob ], fileName, {\n\t\t\t\t\t\ttype: blob.type,\n\t\t\t\t\t} );\n\n\t\t\t\t\tsettings.mediaUpload( {\n\t\t\t\t\t\tfilesList: [ file ],\n\t\t\t\t\t\tadditionalData: { caption },\n\t\t\t\t\t\tonFileChange( [ img ] ) {\n\t\t\t\t\t\t\tif ( isBlobURL( img.url ) ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif ( ! getBlock( clonedBlock.clientId ) ) {\n\t\t\t\t\t\t\t\t// Ensure the block is only inserted once.\n\t\t\t\t\t\t\t\tonClick( {\n\t\t\t\t\t\t\t\t\t...clonedBlock,\n\t\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\t...clonedBlock.attributes,\n\t\t\t\t\t\t\t\t\t\tid: img.id,\n\t\t\t\t\t\t\t\t\t\turl: img.url,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t\t__( 'Image uploaded and inserted.' ),\n\t\t\t\t\t\t\t\t\t{ type: 'snackbar', id: 'inserter-notice' }\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// For subsequent calls, update the existing block.\n\t\t\t\t\t\t\t\tupdateBlockAttributes( clonedBlock.clientId, {\n\t\t\t\t\t\t\t\t\t...clonedBlock.attributes,\n\t\t\t\t\t\t\t\t\tid: img.id,\n\t\t\t\t\t\t\t\t\turl: img.url,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tsetIsInserting( false );\n\t\t\t\t\t\t},\n\t\t\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\t\t\tonError( message ) {\n\t\t\t\t\t\t\tcreateErrorNotice( message, {\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: 'inserter-notice',\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tsetIsInserting( false );\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => {\n\t\t\t\t\tsetShowExternalUploadModal( true );\n\t\t\t\t\tsetIsInserting( false );\n\t\t\t\t} );\n\t\t},\n\t\t[\n\t\t\tisInserting,\n\t\t\tgetSettings,\n\t\t\tonClick,\n\t\t\tcreateSuccessNotice,\n\t\t\tupdateBlockAttributes,\n\t\t\tcreateErrorNotice,\n\t\t\tgetBlock,\n\t\t]\n\t);\n\n\tconst title =\n\t\ttypeof media.title === 'string'\n\t\t\t? media.title\n\t\t\t: media.title?.rendered || __( 'no title' );\n\n\tconst onMouseEnter = useCallback( () => setIsHovered( true ), [] );\n\tconst onMouseLeave = useCallback( () => setIsHovered( false ), [] );\n\treturn (\n\t\t<>\n\t\t\t<InserterDraggableBlocks isEnabled blocks={ [ block ] }>\n\t\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-editor-inserter__media-list__list-item',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-hovered': isHovered,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\t\tonDragStart={ onDragStart }\n\t\t\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ /* Adding `is-hovered` class to the wrapper element is needed\n\t\t\t\t\t\tbecause the options Popover is rendered outside of this node. */ }\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\t\t\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Tooltip.Root>\n\t\t\t\t\t\t\t\t<Tooltip.Trigger\n\t\t\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t\t\t<Composite.Item\n\t\t\t\t\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\t\taria-label={ title }\n\t\t\t\t\t\t\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-inserter__media-list__item\"\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\t\tonMediaInsert( block )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<div className=\"block-editor-inserter__media-list__item-preview\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ preview }\n\t\t\t\t\t\t\t\t\t\t\t\t{ isInserting && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div className=\"block-editor-inserter__media-list__item-preview-spinner\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t</Composite.Item>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<Tooltip.Popup>{ title }</Tooltip.Popup>\n\t\t\t\t\t\t\t</Tooltip.Root>\n\t\t\t\t\t\t\t{ ! isInserting && (\n\t\t\t\t\t\t\t\t<MediaPreviewOptions\n\t\t\t\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t\t\t\t\tmedia={ media }\n\t\t\t\t\t\t\t\t\tonDetach={ onDetach }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</InserterDraggableBlocks>\n\t\t\t{ showExternalUploadModal && (\n\t\t\t\t<InsertExternalImageModal\n\t\t\t\t\tonClose={ () => setShowExternalUploadModal( false ) }\n\t\t\t\t\tonSubmit={ () => {\n\t\t\t\t\t\tonClick( cloneBlock( block ) );\n\t\t\t\t\t\tcreateSuccessNotice( __( 'Image inserted.' ), {\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'inserter-notice',\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tsetShowExternalUploadModal( false );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,wBAWO;AACP,kBAA4B;AAC5B,qBAA+C;AAC/C,oBAA2B;AAC3B,mBAAgD;AAChD,kBAAuC;AACvC,qBAAsC;AACtC,kBAA0B;AAC1B,iBAA4B;AAC5B,gBAAwB;AACxB,uCAAoC;AACpC,mBAA4C;AAC5C,mBAA0C;AAsBtC;AApBJ,IAAM,sBAAsB,CAAE,OAAQ;AACtC,IAAM,8BAA8B;AAAA,EACnC,WAAW;AAAA,EACX,WACC;AACF;AAEA,SAAS,oBAAqB,EAAE,UAAU,OAAO,SAAS,GAAI;AAC7D,MAAK,CAAE,SAAS,gBAAgB,CAAE,UAAW;AAC5C,WAAO;AAAA,EACR;AACA,QAAM,YAAY,SAAS,eAAgB,KAAM;AACjD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,WAAQ,gBAAI,SAAU;AAAA,MACtB,cAAe;AAAA,MACf,MAAO;AAAA,MAEL,gBACD,6CAAC,+BACE;AAAA,qBACD;AAAA,UAAC;AAAA;AAAA,YACA,SAAU,MACT,OAAO,KAAM,WAAW,QAAS,EAAE,MAAM;AAAA,YAE1C,MAAO;AAAA,YAEL;AAAA;AAAA,kBAED,gBAAI,WAAY;AAAA,cAChB,SAAS;AAAA,YACV;AAAA;AAAA,QACD;AAAA,QAEC,YACD;AAAA,UAAC;AAAA;AAAA,YACA,SAAU,MAAM,SAAU,KAAM;AAAA,YAChC,MAAO;AAAA,YA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;AAAA,0BAAC;AAAA;AAAA,4BACA,cAAa;AAAA,4BACb,MAAK;AAAA,4BACL,WAAU;AAAA;AAAA,wBACX;AAAA,wBAED,SAAU,MACT,cAAe,KAAM;AAAA,wBAGtB,uDAAC,SAAI,WAAU,mDACZ;AAAA;AAAA,0BACA,eACD,4CAAC,SAAI,WAAU,2DACd,sDAAC,6BAAQ,GACV;AAAA,2BAEF;AAAA;AAAA,oBACD;AAAA;AAAA,gBAEF;AAAA,gBACA,4CAAC,kBAAQ,OAAR,EAAgB,iBAAO;AAAA,iBACzB;AAAA,cACE,CAAE,eACH;AAAA,gBAAC;AAAA;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA;AAAA;AAAA,cACD;AAAA;AAAA;AAAA,QAEF;AAAA;AAAA,IACD,GAEF;AAAA,IACE,2BACD;AAAA,MAAC;AAAA;AAAA,QACA,SAAU,MAAM,2BAA4B,KAAM;AAAA,QAClD,UAAW,MAAM;AAChB,sBAAS,0BAAY,KAAM,CAAE;AAC7B,kCAAqB,gBAAI,iBAAkB,GAAG;AAAA,YAC7C,MAAM;AAAA,YACN,IAAI;AAAA,UACL,CAAE;AACF,qCAA4B,KAAM;AAAA,QACnC;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;",
|
|
6
6
|
"names": ["VStack", "noticesStore", "blockEditorStore", "InserterDraggableBlocks", "clsx"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/inserter-list-item/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport { useMemo, useRef, memo } from '@wordpress/element';\nimport {\n\tcreateBlock,\n\tcreateBlocksFromInnerBlocksTemplate,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { __experimentalTruncate as Truncate } from '@wordpress/components';\nimport { ENTER, isAppleOS } from '@wordpress/keycodes';\nimport BlockIcon from '../block-icon';\nimport { InserterListboxItem } from '../inserter-listbox';\nimport InserterDraggableBlocks from '../inserter-draggable-blocks';\n\nfunction InserterListItem( {\n\tclassName,\n\tisFirst,\n\titem,\n\tonSelect,\n\tonHover,\n\tisDraggable,\n\t...props\n} ) {\n\tconst isDraggingRef = useRef( false );\n\tconst itemIconStyle = item.icon\n\t\t? {\n\t\t\t\tbackgroundColor: item.icon.background,\n\t\t\t\tcolor: item.icon.foreground,\n\t\t
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,qBAAsC;AACtC,oBAKO;AACP,wBAAmD;AACnD,sBAAiC;AACjC,wBAAsB;AACtB,8BAAoC;AACpC,uCAAoC;AAoE/B;AAlEL,SAAS,iBAAkB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,GAAI;AACH,QAAM,oBAAgB,uBAAQ,KAAM;AACpC,QAAM,gBAAgB,KAAK,OACxB;AAAA,IACA,iBAAiB,KAAK,KAAK;AAAA,IAC3B,OAAO,KAAK,KAAK;AAAA,
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport { useMemo, useRef, memo } from '@wordpress/element';\nimport {\n\tcreateBlock,\n\tcreateBlocksFromInnerBlocksTemplate,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { __experimentalTruncate as Truncate } from '@wordpress/components';\nimport { ENTER, isAppleOS } from '@wordpress/keycodes';\nimport BlockIcon from '../block-icon';\nimport { InserterListboxItem } from '../inserter-listbox';\nimport InserterDraggableBlocks from '../inserter-draggable-blocks';\n\nfunction InserterListItem( {\n\tclassName,\n\tisFirst,\n\titem,\n\tonSelect,\n\tonHover,\n\tisDraggable,\n\t...props\n} ) {\n\tconst isDraggingRef = useRef( false );\n\tconst itemIconStyle = item.icon\n\t\t? {\n\t\t\t\tbackgroundColor: item.icon.background,\n\t\t\t\tcolor: item.icon.foreground,\n\t\t\t}\n\t\t: {};\n\tconst blocks = useMemo(\n\t\t() => [\n\t\t\tcreateBlock(\n\t\t\t\titem.name,\n\t\t\t\titem.initialAttributes,\n\t\t\t\tcreateBlocksFromInnerBlocksTemplate( item.innerBlocks ),\n\t\t\t\titem.innerContent\n\t\t\t),\n\t\t],\n\t\t[\n\t\t\titem.name,\n\t\t\titem.initialAttributes,\n\t\t\titem.innerBlocks,\n\t\t\titem.innerContent,\n\t\t]\n\t);\n\n\tconst isSynced =\n\t\t( isReusableBlock( item ) && item.syncStatus !== 'unsynced' ) ||\n\t\tisTemplatePart( item );\n\n\treturn (\n\t\t<InserterDraggableBlocks\n\t\t\tisEnabled={ isDraggable && ! item.isDisabled }\n\t\t\tblocks={ blocks }\n\t\t\ticon={ item.icon }\n\t\t>\n\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t'block-editor-block-types-list__list-item',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'is-synced': isSynced,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t\t\tisDraggingRef.current = true;\n\t\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t\tonDragStart( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonDragEnd={ ( event ) => {\n\t\t\t\t\t\tisDraggingRef.current = false;\n\t\t\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\t\t\tonDragEnd( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<InserterListboxItem\n\t\t\t\t\t\tisFirst={ isFirst }\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-editor-block-types-list__item',\n\t\t\t\t\t\t\tclassName\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tdisabled={ item.isDisabled }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tonSelect(\n\t\t\t\t\t\t\t\titem,\n\t\t\t\t\t\t\t\tisAppleOS() ? event.metaKey : event.ctrlKey\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\tconst { keyCode } = event;\n\t\t\t\t\t\t\tif ( keyCode === ENTER ) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tonSelect(\n\t\t\t\t\t\t\t\t\titem,\n\t\t\t\t\t\t\t\t\tisAppleOS() ? event.metaKey : event.ctrlKey\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonMouseEnter={ () => {\n\t\t\t\t\t\t\tif ( isDraggingRef.current ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonHover( item );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonMouseLeave={ () => onHover( null ) }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"block-editor-block-types-list__item-icon\"\n\t\t\t\t\t\t\tstyle={ itemIconStyle }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockIcon icon={ item.icon } showColors />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span className=\"block-editor-block-types-list__item-title\">\n\t\t\t\t\t\t\t<Truncate numberOfLines={ 3 }>\n\t\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</InserterListboxItem>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</InserterDraggableBlocks>\n\t);\n}\n\nexport default memo( InserterListItem );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,qBAAsC;AACtC,oBAKO;AACP,wBAAmD;AACnD,sBAAiC;AACjC,wBAAsB;AACtB,8BAAoC;AACpC,uCAAoC;AAoE/B;AAlEL,SAAS,iBAAkB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,GAAI;AACH,QAAM,oBAAgB,uBAAQ,KAAM;AACpC,QAAM,gBAAgB,KAAK,OACxB;AAAA,IACA,iBAAiB,KAAK,KAAK;AAAA,IAC3B,OAAO,KAAK,KAAK;AAAA,EAClB,IACC,CAAC;AACJ,QAAM,aAAS;AAAA,IACd,MAAM;AAAA,UACL;AAAA,QACC,KAAK;AAAA,QACL,KAAK;AAAA,YACL,mDAAqC,KAAK,WAAY;AAAA,QACtD,KAAK;AAAA,MACN;AAAA,IACD;AAAA,IACA;AAAA,MACC,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,IACN;AAAA,EACD;AAEA,QAAM,eACH,+BAAiB,IAAK,KAAK,KAAK,eAAe,kBACjD,8BAAgB,IAAK;AAEtB,SACC;AAAA,IAAC,iCAAAA;AAAA,IAAA;AAAA,MACA,WAAY,eAAe,CAAE,KAAK;AAAA,MAClC;AAAA,MACA,MAAO,KAAK;AAAA,MAEV,WAAE,EAAE,WAAW,aAAa,UAAU,MACvC;AAAA,QAAC;AAAA;AAAA,UACA,eAAY,YAAAC;AAAA,YACX;AAAA,YACA;AAAA,cACC,aAAa;AAAA,YACd;AAAA,UACD;AAAA,UACA;AAAA,UACA,aAAc,CAAE,UAAW;AAC1B,0BAAc,UAAU;AACxB,g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BlockIcon", "Truncate"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/inspector-controls/list-view-content-popover.jsx"],
|
|
4
|
-
"sourcesContent": ["import {\n\tcreateSlotFill,\n\tPopover,\n\t__experimentalUseSlotFills as useSlotFills,\n} from '@wordpress/components';\nimport { useState, useLayoutEffect } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\n// Create private slot-fill for ListViewContentPanel\nconst LIST_VIEW_CONTENT_PANEL_SLOT = Symbol( 'ListViewContentPopover' );\nconst { Fill, Slot } = createSlotFill( LIST_VIEW_CONTENT_PANEL_SLOT );\n\nexport { Fill as ListViewContentFill };\n\n// Hook to determine popover placement for inspector controls\nfunction useInspectorPopoverPlacement() {\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn ! isMobile\n\t\t? {\n\t\t\t\tpopoverProps: {\n\t\t\t\t\tplacement: 'left-start',\n\t\t\t\t\toffset: 35,\n\t\t\t\t\tresize: false,\n\t\t\t\t},\n\t\t
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAIO;AACP,qBAA0C;AAC1C,qBAAiC;AACjC,kBAAuC;AACvC,mBAA0C;AAC1C,yBAAuB;AA6FnB;AAxFJ,IAAM,+BAA+B,uBAAQ,wBAAyB;AACtE,IAAM,EAAE,MAAM,KAAK,QAAI,kCAAgB,4BAA6B;AAKpE,SAAS,+BAA+B;AACvC,QAAM,eAAW,iCAAkB,UAAU,GAAI;AACjD,SAAO,CAAE,WACN;AAAA,IACA,cAAc;AAAA,MACb,WAAW;AAAA,MACX,QAAQ;AAAA,MACR,QAAQ;AAAA,IACT;AAAA,
|
|
4
|
+
"sourcesContent": ["import {\n\tcreateSlotFill,\n\tPopover,\n\t__experimentalUseSlotFills as useSlotFills,\n} from '@wordpress/components';\nimport { useState, useLayoutEffect } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\n// Create private slot-fill for ListViewContentPanel\nconst LIST_VIEW_CONTENT_PANEL_SLOT = Symbol( 'ListViewContentPopover' );\nconst { Fill, Slot } = createSlotFill( LIST_VIEW_CONTENT_PANEL_SLOT );\n\nexport { Fill as ListViewContentFill };\n\n// Hook to determine popover placement for inspector controls\nfunction useInspectorPopoverPlacement() {\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn ! isMobile\n\t\t? {\n\t\t\t\tpopoverProps: {\n\t\t\t\t\tplacement: 'left-start',\n\t\t\t\t\toffset: 35,\n\t\t\t\t\tresize: false,\n\t\t\t\t},\n\t\t\t}\n\t\t: {};\n}\n\n/**\n * Displays a popover for the List View block inspector support.\n * Blocks can use `<InspectorControls group=\"content\">` to display their\n * controls in this popover when inside a section with a parent that has\n * List View block support. The routing is handled automatically by\n * `InspectorControlsFill`.\n *\n * @param {Object} props\n * @param {RefObject<HTMLElement>} props.listViewRef Ref to the List View slot for the block inspector.\n */\nexport function ListViewContentPopover( { listViewRef } ) {\n\tconst { popoverProps } = useInspectorPopoverPlacement();\n\tconst fills = useSlotFills( LIST_VIEW_CONTENT_PANEL_SLOT );\n\tconst hasFills = Boolean( fills && fills.length );\n\n\t// Get both the selected client ID and the popover open state.\n\tconst { selectedClientId, isOpen } = useSelect( ( select ) => {\n\t\tconst { getSelectedBlockClientId } = select( blockEditorStore );\n\t\tconst privateSelectors = unlock( select( blockEditorStore ) );\n\n\t\treturn {\n\t\t\tselectedClientId: getSelectedBlockClientId(),\n\t\t\tisOpen: privateSelectors.isListViewContentPanelOpen(),\n\t\t};\n\t}, [] );\n\n\t// Query DOM for the selected block row element in List View.\n\tconst [ anchorElement, setAnchorElement ] = useState( null );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! selectedClientId || ! listViewRef?.current ) {\n\t\t\tsetAnchorElement( null );\n\t\t\treturn;\n\t\t}\n\n\t\t// Query for the block in list view to anchor the popover.\n\t\t// Ensures the vertical positioning of the popover matches the\n\t\t// selected block in List View.\n\t\tconst element = listViewRef.current.querySelector(\n\t\t\t`[data-block=\"${ selectedClientId }\"]`\n\t\t);\n\n\t\tsetAnchorElement( element );\n\t}, [ selectedClientId, listViewRef ] );\n\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { closeListViewContentPanel } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\t// Only render when explicitly open.\n\tif ( ! isOpen || ! hasFills || ! anchorElement ) {\n\t\treturn null;\n\t}\n\n\t// The slot rendered in the popover doesn't use `bubblesVirtually`, this has a downside\n\t// that certain context providers (like `BlockEditContext`) are not available\n\t// to fills.\n\t// The upside is that it allows nested popovers to function correctly. If `bubblesVirtually`\n\t// is set opening a nest popover triggers the `onFocusOutside` of this popover and closes it.\n\t// Is there a solution that has no trade-offs?\n\treturn (\n\t\t<Popover\n\t\t\t{ ...( popoverProps ?? {} ) }\n\t\t\tclassName=\"block-editor-inspector-list-view-content-popover\"\n\t\t\tanchor={ anchorElement }\n\t\t\tonClose={ closeListViewContentPanel }\n\t\t>\n\t\t\t<div style={ { width: '280px' } }>\n\t\t\t\t<Slot />\n\t\t\t</div>\n\t\t</Popover>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAIO;AACP,qBAA0C;AAC1C,qBAAiC;AACjC,kBAAuC;AACvC,mBAA0C;AAC1C,yBAAuB;AA6FnB;AAxFJ,IAAM,+BAA+B,uBAAQ,wBAA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MACV,QAAS;AAAA,MACT,SAAU;AAAA,MAEV,sDAAC,SAAI,OAAQ,EAAE,OAAO,QAAQ,GAC7B,sDAAC,QAAK,GACP;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": ["useSlotFills", "blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/link-control/search-results.jsx"],
|
|
4
|
-
"sourcesContent": ["import { __, sprintf } from '@wordpress/i18n';\nimport { MenuGroup } from '@wordpress/components';\nimport clsx from 'clsx';\nimport deprecated from '@wordpress/deprecated';\nimport LinkControlSearchCreate from './search-create-button';\nimport LinkControlSearchItem from './search-item';\nimport { CREATE_TYPE, LINK_ENTRY_TYPES } from './constants';\n\nfunction LinkControlSearchResults( {\n\twithCreateSuggestion,\n\tcurrentInputValue,\n\thandleSuggestionClick,\n\tsuggestionsListProps,\n\tbuildSuggestionItemProps,\n\tsuggestions,\n\tselectedSuggestion,\n\tisLoading,\n\tisInitialSuggestions,\n\tcreateSuggestionButtonText,\n\tsuggestionsQuery,\n} ) {\n\tconst resultsListClasses = clsx(\n\t\t'block-editor-link-control__search-results',\n\t\t{\n\t\t\t'is-loading': isLoading,\n\t\t}\n\t);\n\n\tconst isSingleDirectEntryResult =\n\t\tsuggestions.length === 1 &&\n\t\tLINK_ENTRY_TYPES.includes( suggestions[ 0 ].type );\n\tconst shouldShowCreateSuggestion =\n\t\twithCreateSuggestion &&\n\t\t! isSingleDirectEntryResult &&\n\t\t! isInitialSuggestions;\n\t// If the query has a specified type, then we can skip showing them in the result. See #24839.\n\tconst shouldShowSuggestionsTypes = ! suggestionsQuery?.type;\n\n\tconst labelText = isInitialSuggestions\n\t\t? __( 'Suggestions' )\n\t\t: sprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Search results for \"%s\"' ),\n\t\t\t\tcurrentInputValue\n\t\t
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA4B;AAC5B,wBAA0B;AAC1B,kBAAiB;AACjB,wBAAuB;AACvB,kCAAoC;AACpC,yBAAkC;AAClC,uBAA8C;AAsDtC;AApDR,SAAS,yBAA0B;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,yBAAqB,YAAAA;AAAA,IAC1B;AAAA,IACA;AAAA,MACC,cAAc;AAAA,IACf;AAAA,EACD;AAEA,QAAM,4BACL,YAAY,WAAW,KACvB,kCAAiB,SAAU,YAAa,CAAE,EAAE,IAAK;AAClD,QAAM,6BACL,wBACA,CAAE,6BACF,CAAE;AAEH,QAAM,6BAA6B,CAAE,kBAAkB;AAEvD,QAAM,YAAY,2BACf,gBAAI,aAAc,QAClB;AAAA;AAAA,QAEA,gBAAI,yBAA0B;AAAA,IAC9B;AAAA,
|
|
4
|
+
"sourcesContent": ["import { __, sprintf } from '@wordpress/i18n';\nimport { MenuGroup } from '@wordpress/components';\nimport clsx from 'clsx';\nimport deprecated from '@wordpress/deprecated';\nimport LinkControlSearchCreate from './search-create-button';\nimport LinkControlSearchItem from './search-item';\nimport { CREATE_TYPE, LINK_ENTRY_TYPES } from './constants';\n\nfunction LinkControlSearchResults( {\n\twithCreateSuggestion,\n\tcurrentInputValue,\n\thandleSuggestionClick,\n\tsuggestionsListProps,\n\tbuildSuggestionItemProps,\n\tsuggestions,\n\tselectedSuggestion,\n\tisLoading,\n\tisInitialSuggestions,\n\tcreateSuggestionButtonText,\n\tsuggestionsQuery,\n} ) {\n\tconst resultsListClasses = clsx(\n\t\t'block-editor-link-control__search-results',\n\t\t{\n\t\t\t'is-loading': isLoading,\n\t\t}\n\t);\n\n\tconst isSingleDirectEntryResult =\n\t\tsuggestions.length === 1 &&\n\t\tLINK_ENTRY_TYPES.includes( suggestions[ 0 ].type );\n\tconst shouldShowCreateSuggestion =\n\t\twithCreateSuggestion &&\n\t\t! isSingleDirectEntryResult &&\n\t\t! isInitialSuggestions;\n\t// If the query has a specified type, then we can skip showing them in the result. See #24839.\n\tconst shouldShowSuggestionsTypes = ! suggestionsQuery?.type;\n\n\tconst labelText = isInitialSuggestions\n\t\t? __( 'Suggestions' )\n\t\t: sprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Search results for \"%s\"' ),\n\t\t\t\tcurrentInputValue\n\t\t\t);\n\n\treturn (\n\t\t<div className=\"block-editor-link-control__search-results-wrapper\">\n\t\t\t<div\n\t\t\t\t{ ...suggestionsListProps }\n\t\t\t\tclassName={ resultsListClasses }\n\t\t\t\taria-label={ labelText }\n\t\t\t>\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t{ suggestions.map( ( suggestion, index ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tshouldShowCreateSuggestion &&\n\t\t\t\t\t\t\tCREATE_TYPE === suggestion.type\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<LinkControlSearchCreate\n\t\t\t\t\t\t\t\t\tsearchTerm={ currentInputValue }\n\t\t\t\t\t\t\t\t\tbuttonText={ createSuggestionButtonText }\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\thandleSuggestionClick( suggestion )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// Intentionally only using `type` here as\n\t\t\t\t\t\t\t\t\t// the constant is enough to uniquely\n\t\t\t\t\t\t\t\t\t// identify the single \"CREATE\" suggestion.\n\t\t\t\t\t\t\t\t\tkey={ suggestion.type }\n\t\t\t\t\t\t\t\t\titemProps={ buildSuggestionItemProps(\n\t\t\t\t\t\t\t\t\t\tsuggestion,\n\t\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tisSelected={ index === selectedSuggestion }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// If we're not handling \"Create\" suggestions above then\n\t\t\t\t\t\t// we don't want them in the main results so exit early.\n\t\t\t\t\t\tif ( CREATE_TYPE === suggestion.type ) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<LinkControlSearchItem\n\t\t\t\t\t\t\t\tkey={ `${ suggestion.id }-${ suggestion.type }` }\n\t\t\t\t\t\t\t\titemProps={ buildSuggestionItemProps(\n\t\t\t\t\t\t\t\t\tsuggestion,\n\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tsuggestion={ suggestion }\n\t\t\t\t\t\t\t\tindex={ index }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\thandleSuggestionClick( suggestion );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tisSelected={ index === selectedSuggestion }\n\t\t\t\t\t\t\t\tisURL={ LINK_ENTRY_TYPES.includes(\n\t\t\t\t\t\t\t\t\tsuggestion.type\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tsearchTerm={ currentInputValue }\n\t\t\t\t\t\t\t\tshouldShowType={ shouldShowSuggestionsTypes }\n\t\t\t\t\t\t\t\tisFrontPage={ suggestion?.isFrontPage }\n\t\t\t\t\t\t\t\tisBlogHome={ suggestion?.isBlogHome }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</MenuGroup>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport default LinkControlSearchResults;\n\nexport const __experimentalLinkControlSearchResults = ( props ) => {\n\tdeprecated( 'wp.blockEditor.__experimentalLinkControlSearchResults', {\n\t\ts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C,iBAAO;AAAA,QACR;AAEA,eACC;AAAA,UAAC,mBAAAC;AAAA,UAAA;AAAA,YAEA,WAAY;AAAA,cACX;AAAA,cACA;AAAA,YACD;AAAA,YACA;AAAA,YACA;AAAA,YACA,SAAU,MAAM;AACf,oCAAuB,UAAW;AAAA,YACnC;AAAA,YACA,YAAa,UAAU;AAAA,YACvB,OAAQ,kCAAiB;AAAA,cACxB,WAAW;AAAA,YACZ;AAAA,YACA,YAAa;AAAA,YACb,gBAAiB;AAAA,YACjB,aAAc,YAAY;AAAA,YAC1B,YAAa,YAAY;AAAA;AAAA,UAjBnB,GAAI,WAAW,EAAG,IAAK,WAAW,IAAK;AAAA,QAkB9C;AAAA,MAEF,CAAE,GACH;AAAA;AAAA,EACD,GACD;AAEF;AAEA,IAAO,yBAAQ;AAER,IAAM,yCAAyC,CAAE,UAAW;AAClE,wBAAAC,SAAY,yDAAyD;AAAA,IACpE,OAAO;AAAA,EACR,CAAE;AAEF,SAAO,4CAAC,4BAA2B,GAAG,OAAQ;AAC/C;",
|
|
6
6
|
"names": ["clsx", "LinkControlSearchCreate", "LinkControlSearchItem", "deprecated"]
|
|
7
7
|
}
|
|
@@ -57,6 +57,9 @@ var handleEntitySearch = async (val, suggestionsQuery, fetchSearchSuggestions, w
|
|
|
57
57
|
const { isInitialSuggestions } = suggestionsQuery;
|
|
58
58
|
const results = await fetchSearchSuggestions(val, suggestionsQuery);
|
|
59
59
|
results.map((result) => {
|
|
60
|
+
if (result.type !== "page") {
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
60
63
|
if (Number(result.id) === pageOnFront) {
|
|
61
64
|
result.isFrontPage = true;
|
|
62
65
|
return result;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/link-control/use-search-handler.js"],
|
|
4
|
-
"sourcesContent": ["import { useCallback } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport isURLLike from './is-url-like';\nimport normalizeUrl from './normalize-url';\nimport { CREATE_TYPE } from './constants';\nimport { store as blockEditorStore } from '../../store';\n\nexport const handleNoop = () => Promise.resolve( [] );\n\nexport const handleDirectEntry = ( val ) => {\n\tconst { url, type } = normalizeUrl( val );\n\n\treturn Promise.resolve( [\n\t\t{\n\t\t\tid: val,\n\t\t\ttitle: val,\n\t\t\turl,\n\t\t\ttype,\n\t\t},\n\t] );\n};\n\nconst handleEntitySearch = async (\n\tval,\n\tsuggestionsQuery,\n\tfetchSearchSuggestions,\n\twithCreateSuggestion,\n\tpageOnFront,\n\tpageForPosts\n) => {\n\tconst { isInitialSuggestions } = suggestionsQuery;\n\n\tconst results = await fetchSearchSuggestions( val, suggestionsQuery );\n\n\t// Identify front page and update type to match.\n\tresults.map( ( result ) => {\n\t\tif ( Number( result.id ) === pageOnFront ) {\n\t\t\tresult.isFrontPage = true;\n\t\t\treturn result;\n\t\t} else if ( Number( result.id ) === pageForPosts ) {\n\t\t\tresult.isBlogHome = true;\n\t\t\treturn result;\n\t\t}\n\n\t\treturn result;\n\t} );\n\n\t// If displaying initial suggestions just return plain results.\n\tif ( isInitialSuggestions ) {\n\t\treturn results;\n\t}\n\n\t// Here we append a faux suggestion to represent a \"CREATE\" option. This\n\t// is detected in the rendering of the search results and handled as a\n\t// special case. This is currently necessary because the suggestions\n\t// dropdown will only appear if there are valid suggestions and\n\t// therefore unless the create option is a suggestion it will not\n\t// display in scenarios where there are no results returned from the\n\t// API. In addition promoting CREATE to a first class suggestion affords\n\t// the a11y benefits afforded by `URLInput` to all suggestions (eg:\n\t// keyboard handling, ARIA roles...etc).\n\t//\n\t// Note also that the value of the `title` and `url` properties must correspond\n\t// to the text value of the `<input>`. This is because `title` is used\n\t// when creating the suggestion. Similarly `url` is used when using keyboard to select\n\t// the suggestion (the <form> `onSubmit` handler falls-back to `url`).\n\treturn isURLLike( val ) || ! withCreateSuggestion\n\t\t? results\n\t\t: results.concat( {\n\t\t\t\t// the `id` prop is intentionally omitted here because it\n\t\t\t\t// is never exposed as part of the component's public API.\n\t\t\t\t// see: https://github.com/WordPress/gutenberg/pull/19775#discussion_r378931316.\n\t\t\t\ttitle: val, // Must match the existing `<input>`s text value.\n\t\t\t\turl: val, // Must match the existing `<input>`s text value.\n\t\t\t\ttype: CREATE_TYPE,\n\t\t
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA4B;AAC5B,kBAA0B;AAC1B,yBAAsB;AACtB,2BAAyB;AACzB,uBAA4B;AAC5B,mBAA0C;AAEnC,IAAM,aAAa,MAAM,QAAQ,QAAS,CAAC,CAAE;AAE7C,IAAM,oBAAoB,CAAE,QAAS;AAC3C,QAAM,EAAE,KAAK,KAAK,QAAI,qBAAAA,SAAc,GAAI;AAExC,SAAO,QAAQ,QAAS;AAAA,IACvB;AAAA,MACC,IAAI;AAAA,MACJ,OAAO;AAAA,MACP;AAAA,MACA;AAAA,IACD;AAAA,EACD,CAAE;AACH;AAEA,IAAM,qBAAqB,OAC1B,KACA,kBACA,wBACA,sBACA,aACA,iBACI;AACJ,QAAM,EAAE,qBAAqB,IAAI;AAEjC,QAAM,UAAU,MAAM,uBAAwB,KAAK,gBAAiB;
|
|
4
|
+
"sourcesContent": ["import { useCallback } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport isURLLike from './is-url-like';\nimport normalizeUrl from './normalize-url';\nimport { CREATE_TYPE } from './constants';\nimport { store as blockEditorStore } from '../../store';\n\nexport const handleNoop = () => Promise.resolve( [] );\n\nexport const handleDirectEntry = ( val ) => {\n\tconst { url, type } = normalizeUrl( val );\n\n\treturn Promise.resolve( [\n\t\t{\n\t\t\tid: val,\n\t\t\ttitle: val,\n\t\t\turl,\n\t\t\ttype,\n\t\t},\n\t] );\n};\n\nconst handleEntitySearch = async (\n\tval,\n\tsuggestionsQuery,\n\tfetchSearchSuggestions,\n\twithCreateSuggestion,\n\tpageOnFront,\n\tpageForPosts\n) => {\n\tconst { isInitialSuggestions } = suggestionsQuery;\n\n\tconst results = await fetchSearchSuggestions( val, suggestionsQuery );\n\n\t// Identify front page and update type to match. Posts, terms and media can\n\t// share an id, so only pages are considered.\n\tresults.map( ( result ) => {\n\t\tif ( result.type !== 'page' ) {\n\t\t\treturn result;\n\t\t}\n\n\t\tif ( Number( result.id ) === pageOnFront ) {\n\t\t\tresult.isFrontPage = true;\n\t\t\treturn result;\n\t\t} else if ( Number( result.id ) === pageForPosts ) {\n\t\t\tresult.isBlogHome = true;\n\t\t\treturn result;\n\t\t}\n\n\t\treturn result;\n\t} );\n\n\t// If displaying initial suggestions just return plain results.\n\tif ( isInitialSuggestions ) {\n\t\treturn results;\n\t}\n\n\t// Here we append a faux suggestion to represent a \"CREATE\" option. This\n\t// is detected in the rendering of the search results and handled as a\n\t// special case. This is currently necessary because the suggestions\n\t// dropdown will only appear if there are valid suggestions and\n\t// therefore unless the create option is a suggestion it will not\n\t// display in scenarios where there are no results returned from the\n\t// API. In addition promoting CREATE to a first class suggestion affords\n\t// the a11y benefits afforded by `URLInput` to all suggestions (eg:\n\t// keyboard handling, ARIA roles...etc).\n\t//\n\t// Note also that the value of the `title` and `url` properties must correspond\n\t// to the text value of the `<input>`. This is because `title` is used\n\t// when creating the suggestion. Similarly `url` is used when using keyboard to select\n\t// the suggestion (the <form> `onSubmit` handler falls-back to `url`).\n\treturn isURLLike( val ) || ! withCreateSuggestion\n\t\t? results\n\t\t: results.concat( {\n\t\t\t\t// the `id` prop is intentionally omitted here because it\n\t\t\t\t// is never exposed as part of the component's public API.\n\t\t\t\t// see: https://github.com/WordPress/gutenberg/pull/19775#discussion_r378931316.\n\t\t\t\ttitle: val, // Must match the existing `<input>`s text value.\n\t\t\t\turl: val, // Must match the existing `<input>`s text value.\n\t\t\t\ttype: CREATE_TYPE,\n\t\t\t} );\n};\n\nexport default function useSearchHandler(\n\tsuggestionsQuery,\n\tallowDirectEntry,\n\twithCreateSuggestion\n) {\n\tconst { fetchSearchSuggestions, pageOnFront, pageForPosts } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tpageOnFront: getSettings().pageOnFront,\n\t\t\t\tpageForPosts: getSettings().pageForPosts,\n\t\t\t\tfetchSearchSuggestions:\n\t\t\t\t\tgetSettings().__experimentalFetchLinkSuggestions,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst directEntryHandler = allowDirectEntry\n\t\t? handleDirectEntry\n\t\t: handleNoop;\n\n\treturn useCallback(\n\t\t( val, { isInitialSuggestions } ) => {\n\t\t\treturn isURLLike( val )\n\t\t\t\t? directEntryHandler( val, { isInitialSuggestions } )\n\t\t\t\t: handleEntitySearch(\n\t\t\t\t\t\tval,\n\t\t\t\t\t\t{ ...suggestionsQuery, isInitialSuggestions },\n\t\t\t\t\t\tfetchSearchSuggestions,\n\t\t\t\t\t\twithCreateSuggestion,\n\t\t\t\t\t\tpageOnFront,\n\t\t\t\t\t\tpageForPosts\n\t\t\t\t\t);\n\t\t},\n\t\t[\n\t\t\tdirectEntryHandler,\n\t\t\tfetchSearchSuggestions,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t\tsuggestionsQuery,\n\t\t\twithCreateSuggestion,\n\t\t]\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA4B;AAC5B,kBAA0B;AAC1B,yBAAsB;AACtB,2BAAyB;AACzB,uBAA4B;AAC5B,mBAA0C;AAEnC,IAAM,aAAa,MAAM,QAAQ,QAAS,CAAC,CAAE;AAE7C,IAAM,oBAAoB,CAAE,QAAS;AAC3C,QAAM,EAAE,KAAK,KAAK,QAAI,qBAAAA,SAAc,GAAI;AAExC,SAAO,QAAQ,QAAS;AAAA,IACvB;AAAA,MACC,IAAI;AAAA,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,qBAAqB;AAAA,QAC5C;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACH;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["normalizeUrl", "isURLLike", "blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/list-view/branch.jsx"],
|
|
4
|
-
"sourcesContent": ["import {\n\t__experimentalTreeGridRow as TreeGridRow,\n\t__experimentalTreeGridCell as TreeGridCell,\n} from '@wordpress/components';\nimport { memo } from '@wordpress/element';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport { Appender } from './appender';\nimport ListViewBlock from './block';\nimport { useListViewTreeState } from './context';\nimport {\n\tBLOCK_LIST_ITEM_HEIGHT,\n\tgetDragDisplacementValues,\n\tisClientIdSelected,\n} from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Given a block, returns the total number of blocks in that subtree. This is used to help determine\n * the list position of a block.\n *\n * When a block is collapsed, we do not count their children as part of that total. In the current drag\n * implementation dragged blocks and their children are not counted.\n *\n * @param {Object} block block tree\n * @param {Object} expansionState state that notes which branches are collapsed\n * @param {Array} draggedClientIds a list of dragged client ids\n * @param {boolean} isExpandedByDefault flag to determine the default fallback expanded state.\n * @return {number} block count\n */\nfunction countBlocks(\n\tblock,\n\texpansionState,\n\tdraggedClientIds,\n\tisExpandedByDefault\n) {\n\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\tif ( isDragged ) {\n\t\treturn 0;\n\t}\n\tconst isExpanded = expansionState[ block.clientId ] ?? isExpandedByDefault;\n\tif ( ! isExpanded ) {\n\t\treturn 1;\n\t}\n\treturn block.innerBlocks.reduce(\n\t\t( count, innerBlock ) =>\n\t\t\tcount +\n\t\t\tcountBlocks(\n\t\t\t\tinnerBlock,\n\t\t\t\texpansionState,\n\t\t\t\tdraggedClientIds,\n\t\t\t\tisExpandedByDefault\n\t\t\t),\n\t\t1\n\t);\n}\n\nconst noop = () => {};\n\nfunction ListViewBranch( props ) {\n\tconst {\n\t\tblocks,\n\t\tselectBlock = noop,\n\t\tshowBlockMovers,\n\t\tselectedClientIds,\n\t\tlevel = 1,\n\t\tpath = '',\n\t\tisBranchSelected = false,\n\t\tlistPosition = 0,\n\t\tfixedListWindow,\n\t\tisExpanded,\n\t\tparentId,\n\t\tisSyncedBranch = false,\n\t\tshowAppender: showAppenderProp = true,\n\t} = props;\n\n\tconst { canParentExpand, isParentSynced } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! parentId ) {\n\t\t\t\treturn { canParentExpand: true, isParentSynced: false };\n\t\t\t}\n\t\t\tconst { canEditBlock, isSyncedBlock } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcanParentExpand: canEditBlock( parentId ),\n\t\t\t\tisParentSynced: isSyncedBlock( parentId ),\n\t\t\t};\n\t\t},\n\t\t[ parentId ]\n\t);\n\n\tconst syncedBranch = isSyncedBranch || isParentSynced;\n\n\tconst {\n\t\tblockDropPosition,\n\t\tblockDropTargetIndex,\n\t\tfirstDraggedBlockIndex,\n\t\tblockIndexes,\n\t\texpansionState,\n\t\tdraggedClientIds,\n\t} = useListViewTreeState();\n\n\tif ( ! canParentExpand ) {\n\t\treturn null;\n\t}\n\n\t// Only show the appender at the first level.\n\tconst showAppender = showAppenderProp && level === 1;\n\tconst filteredBlocks = blocks.filter( Boolean );\n\tconst blockCount = filteredBlocks.length;\n\t// The appender means an extra row in List View, so add 1 to the row count.\n\tconst rowCount = showAppender ? blockCount + 1 : blockCount;\n\tlet nextPosition = listPosition;\n\n\tconst rows = [];\n\n\t// A run of blocks outside of the render window becomes one spacer row that\n\t// stands in for their height.\n\tlet placeholderRows = 0;\n\tlet placeholderKey;\n\n\t// Adds the pending placeholder row, if there is one. Call before\n\t// adding a real row.\n\tconst pushPlaceholderRow = () => {\n\t\tif ( ! placeholderRows ) {\n\t\t\treturn;\n\t\t}\n\t\trows.push(\n\t\t\t<tr key={ `placeholder-${ placeholderKey }` }>\n\t\t\t\t<td\n\t\t\t\t\tclassName=\"block-editor-list-view-placeholder\"\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\theight: placeholderRows * BLOCK_LIST_ITEM_HEIGHT,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</tr>\n\t\t);\n\t\tplaceholderRows = 0;\n\t\tplaceholderKey = undefined;\n\t};\n\n\tfilteredBlocks.forEach( ( block, index ) => {\n\t\tconst { clientId, innerBlocks } = block;\n\n\t\t// The next sibling is offset by this block's subtree.\n\t\tconst blockListPosition = nextPosition;\n\t\tnextPosition += countBlocks(\n\t\t\tblock,\n\t\t\texpansionState,\n\t\t\tdraggedClientIds,\n\t\t\tisExpanded\n\t\t);\n\n\t\tconst isDragged = !! draggedClientIds?.includes( clientId );\n\n\t\tconst { itemInView } = fixedListWindow;\n\t\tconst blockInView = itemInView( blockListPosition );\n\n\t\tconst position = index + 1;\n\t\tconst updatedPath =\n\t\t\tpath.length > 0 ? `${ path }_${ position }` : `${ position }`;\n\t\tconst hasNestedBlocks = !! innerBlocks?.length;\n\n\t\tconst shouldExpand = hasNestedBlocks\n\t\t\t? expansionState[ clientId ] ?? isExpanded\n\t\t\t: undefined;\n\n\t\t// Make updates to the selected or dragged blocks synchronous,\n\t\t// but asynchronous for any other block.\n\t\tconst isSelected = isClientIdSelected( clientId, selectedClientIds );\n\t\tconst isSelectedBranch =\n\t\t\tisBranchSelected || ( isSelected && hasNestedBlocks );\n\n\t\t// To avoid performance issues, we only render blocks that are in view,\n\t\t// or blocks that are selected or dragged. If a block is selected,\n\t\t// it is only counted if it is the first of the block selection.\n\t\t// This prevents the entire tree from being rendered when a branch is\n\t\t// selected, or a user selects all blocks, while still enabling scroll\n\t\t// into view behavior when selecting a block or opening the list view.\n\t\t// The first and last blocks of the list are always rendered, to ensure\n\t\t// that Home and End keys work as expected.\n\t\tconst showBlock =\n\t\t\tisDragged ||\n\t\t\tblockInView ||\n\t\t\t( isSelected && clientId === selectedClientIds[ 0 ] ) ||\n\t\t\tindex === 0 ||\n\t\t\tindex === blockCount - 1;\n\n\t\tconst showNestedBlocks = hasNestedBlocks && shouldExpand && ! isDragged;\n\n\t\tif ( ! showBlock ) {\n\t\t\tplaceholderRows += 1;\n\t\t\tplaceholderKey ??= clientId;\n\n\t\t\t// Inner blocks of an off-window block may still be in view.\n\t\t\tif ( ! showNestedBlocks ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tpushPlaceholderRow();\n\n\t\t// Determine the displacement of the block while dragging. This\n\t\t// works out whether the current block should be displaced up or\n\t\t// down, relative to the dragged blocks and the drop target.\n\t\tconst { displacement, isAfterDraggedBlocks, isNesting } =\n\t\t\tgetDragDisplacementValues( {\n\t\t\t\tblockIndexes,\n\t\t\t\tblockDropTargetIndex,\n\t\t\t\tblockDropPosition,\n\t\t\t\tclientId,\n\t\t\t\tfirstDraggedBlockIndex,\n\t\t\t\tisDragged,\n\t\t\t} );\n\n\t\trows.push(\n\t\t\t<AsyncModeProvider key={ clientId } value={ ! isSelected }>\n\t\t\t\t{ showBlock && (\n\t\t\t\t\t<ListViewBlock\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\tisDragged={ isDragged }\n\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\trowCount={ rowCount }\n\t\t\t\t\t\tsiblingBlockCount={ blockCount }\n\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\tisExpanded={ isDragged ? false : shouldExpand }\n\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\tisSyncedBranch={ syncedBranch }\n\t\t\t\t\t\tdisplacement={ displacement }\n\t\t\t\t\t\tisAfterDraggedBlocks={ isAfterDraggedBlocks }\n\t\t\t\t\t\tisNesting={ isNesting }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ showNestedBlocks && (\n\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\tparentId={ clientId }\n\t\t\t\t\t\tblocks={ innerBlocks }\n\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\tlevel={ level + 1 }\n\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\tlistPosition={ blockListPosition + 1 }\n\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\tisSyncedBranch={ syncedBranch }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</AsyncModeProvider>\n\t\t);\n\t} );\n\n\tpushPlaceholderRow();\n\n\treturn (\n\t\t<>\n\t\t\t{ rows }\n\t\t\t{ showAppender && (\n\t\t\t\t<TreeGridRow\n\t\t\t\t\tlevel={ level }\n\t\t\t\t\tsetSize={ rowCount }\n\t\t\t\t\tpositionInSet={ rowCount }\n\t\t\t\t\tisExpanded\n\t\t\t\t>\n\t\t\t\t\t<TreeGridCell>\n\t\t\t\t\t\t{ ( treeGridCellProps ) => (\n\t\t\t\t\t\t\t<Appender\n\t\t\t\t\t\t\t\tclientId={ parentId }\n\t\t\t\t\t\t\t\tnestingLevel={ level }\n\t\t\t\t\t\t\t\tblockCount={ blockCount }\n\t\t\t\t\t\t\t\t{ ...treeGridCellProps }\n\t\t\t\t\t\t\t/>\n\t\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,
|
|
4
|
+
"sourcesContent": ["import {\n\t__experimentalTreeGridRow as TreeGridRow,\n\t__experimentalTreeGridCell as TreeGridCell,\n} from '@wordpress/components';\nimport { memo } from '@wordpress/element';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport { Appender } from './appender';\nimport ListViewBlock from './block';\nimport { useListViewTreeState } from './context';\nimport {\n\tBLOCK_LIST_ITEM_HEIGHT,\n\tgetDragDisplacementValues,\n\tisClientIdSelected,\n} from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Given a block, returns the total number of blocks in that subtree. This is used to help determine\n * the list position of a block.\n *\n * When a block is collapsed, we do not count their children as part of that total. In the current drag\n * implementation dragged blocks and their children are not counted.\n *\n * @param {Object} block block tree\n * @param {Object} expansionState state that notes which branches are collapsed\n * @param {Array} draggedClientIds a list of dragged client ids\n * @param {boolean} isExpandedByDefault flag to determine the default fallback expanded state.\n * @return {number} block count\n */\nfunction countBlocks(\n\tblock,\n\texpansionState,\n\tdraggedClientIds,\n\tisExpandedByDefault\n) {\n\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\tif ( isDragged ) {\n\t\treturn 0;\n\t}\n\tconst isExpanded = expansionState[ block.clientId ] ?? isExpandedByDefault;\n\tif ( ! isExpanded ) {\n\t\treturn 1;\n\t}\n\treturn block.innerBlocks.reduce(\n\t\t( count, innerBlock ) =>\n\t\t\tcount +\n\t\t\tcountBlocks(\n\t\t\t\tinnerBlock,\n\t\t\t\texpansionState,\n\t\t\t\tdraggedClientIds,\n\t\t\t\tisExpandedByDefault\n\t\t\t),\n\t\t1\n\t);\n}\n\nconst noop = () => {};\n\nfunction ListViewBranch( props ) {\n\tconst {\n\t\tblocks,\n\t\tselectBlock = noop,\n\t\tshowBlockMovers,\n\t\tselectedClientIds,\n\t\tlevel = 1,\n\t\tpath = '',\n\t\tisBranchSelected = false,\n\t\tlistPosition = 0,\n\t\tfixedListWindow,\n\t\tisExpanded,\n\t\tparentId,\n\t\tisSyncedBranch = false,\n\t\tshowAppender: showAppenderProp = true,\n\t} = props;\n\n\tconst { canParentExpand, isParentSynced } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! parentId ) {\n\t\t\t\treturn { canParentExpand: true, isParentSynced: false };\n\t\t\t}\n\t\t\tconst { canEditBlock, isSyncedBlock } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcanParentExpand: canEditBlock( parentId ),\n\t\t\t\tisParentSynced: isSyncedBlock( parentId ),\n\t\t\t};\n\t\t},\n\t\t[ parentId ]\n\t);\n\n\tconst syncedBranch = isSyncedBranch || isParentSynced;\n\n\tconst {\n\t\tblockDropPosition,\n\t\tblockDropTargetIndex,\n\t\tfirstDraggedBlockIndex,\n\t\tblockIndexes,\n\t\texpansionState,\n\t\tdraggedClientIds,\n\t} = useListViewTreeState();\n\n\tif ( ! canParentExpand ) {\n\t\treturn null;\n\t}\n\n\t// Only show the appender at the first level.\n\tconst showAppender = showAppenderProp && level === 1;\n\tconst filteredBlocks = blocks.filter( Boolean );\n\tconst blockCount = filteredBlocks.length;\n\t// The appender means an extra row in List View, so add 1 to the row count.\n\tconst rowCount = showAppender ? blockCount + 1 : blockCount;\n\tlet nextPosition = listPosition;\n\n\tconst rows = [];\n\n\t// A run of blocks outside of the render window becomes one spacer row that\n\t// stands in for their height.\n\tlet placeholderRows = 0;\n\tlet placeholderKey;\n\n\t// Adds the pending placeholder row, if there is one. Call before\n\t// adding a real row.\n\tconst pushPlaceholderRow = () => {\n\t\tif ( ! placeholderRows ) {\n\t\t\treturn;\n\t\t}\n\t\trows.push(\n\t\t\t<tr key={ `placeholder-${ placeholderKey }` }>\n\t\t\t\t<td\n\t\t\t\t\tclassName=\"block-editor-list-view-placeholder\"\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\theight: placeholderRows * BLOCK_LIST_ITEM_HEIGHT,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</tr>\n\t\t);\n\t\tplaceholderRows = 0;\n\t\tplaceholderKey = undefined;\n\t};\n\n\tfilteredBlocks.forEach( ( block, index ) => {\n\t\tconst { clientId, innerBlocks } = block;\n\n\t\t// The next sibling is offset by this block's subtree.\n\t\tconst blockListPosition = nextPosition;\n\t\tnextPosition += countBlocks(\n\t\t\tblock,\n\t\t\texpansionState,\n\t\t\tdraggedClientIds,\n\t\t\tisExpanded\n\t\t);\n\n\t\tconst isDragged = !! draggedClientIds?.includes( clientId );\n\n\t\tconst { itemInView } = fixedListWindow;\n\t\tconst blockInView = itemInView( blockListPosition );\n\n\t\tconst position = index + 1;\n\t\tconst updatedPath =\n\t\t\tpath.length > 0 ? `${ path }_${ position }` : `${ position }`;\n\t\tconst hasNestedBlocks = !! innerBlocks?.length;\n\n\t\tconst shouldExpand = hasNestedBlocks\n\t\t\t? ( expansionState[ clientId ] ?? isExpanded )\n\t\t\t: undefined;\n\n\t\t// Make updates to the selected or dragged blocks synchronous,\n\t\t// but asynchronous for any other block.\n\t\tconst isSelected = isClientIdSelected( clientId, selectedClientIds );\n\t\tconst isSelectedBranch =\n\t\t\tisBranchSelected || ( isSelected && hasNestedBlocks );\n\n\t\t// To avoid performance issues, we only render blocks that are in view,\n\t\t// or blocks that are selected or dragged. If a block is selected,\n\t\t// it is only counted if it is the first of the block selection.\n\t\t// This prevents the entire tree from being rendered when a branch is\n\t\t// selected, or a user selects all blocks, while still enabling scroll\n\t\t// into view behavior when selecting a block or opening the list view.\n\t\t// The first and last blocks of the list are always rendered, to ensure\n\t\t// that Home and End keys work as expected.\n\t\tconst showBlock =\n\t\t\tisDragged ||\n\t\t\tblockInView ||\n\t\t\t( isSelected && clientId === selectedClientIds[ 0 ] ) ||\n\t\t\tindex === 0 ||\n\t\t\tindex === blockCount - 1;\n\n\t\tconst showNestedBlocks = hasNestedBlocks && shouldExpand && ! isDragged;\n\n\t\tif ( ! showBlock ) {\n\t\t\tplaceholderRows += 1;\n\t\t\tplaceholderKey ??= clientId;\n\n\t\t\t// Inner blocks of an off-window block may still be in view.\n\t\t\tif ( ! showNestedBlocks ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tpushPlaceholderRow();\n\n\t\t// Determine the displacement of the block while dragging. This\n\t\t// works out whether the current block should be displaced up or\n\t\t// down, relative to the dragged blocks and the drop target.\n\t\tconst { displacement, isAfterDraggedBlocks, isNesting } =\n\t\t\tgetDragDisplacementValues( {\n\t\t\t\tblockIndexes,\n\t\t\t\tblockDropTargetIndex,\n\t\t\t\tblockDropPosition,\n\t\t\t\tclientId,\n\t\t\t\tfirstDraggedBlockIndex,\n\t\t\t\tisDragged,\n\t\t\t} );\n\n\t\trows.push(\n\t\t\t<AsyncModeProvider key={ clientId } value={ ! isSelected }>\n\t\t\t\t{ showBlock && (\n\t\t\t\t\t<ListViewBlock\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\tisDragged={ isDragged }\n\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\trowCount={ rowCount }\n\t\t\t\t\t\tsiblingBlockCount={ blockCount }\n\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\tisExpanded={ isDragged ? false : shouldExpand }\n\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\tisSyncedBranch={ syncedBranch }\n\t\t\t\t\t\tdisplacement={ displacement }\n\t\t\t\t\t\tisAfterDraggedBlocks={ isAfterDraggedBlocks }\n\t\t\t\t\t\tisNesting={ isNesting }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ showNestedBlocks && (\n\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\tparentId={ clientId }\n\t\t\t\t\t\tblocks={ innerBlocks }\n\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\tlevel={ level + 1 }\n\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\tlistPosition={ blockListPosition + 1 }\n\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\tisSyncedBranch={ syncedBranch }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</AsyncModeProvider>\n\t\t);\n\t} );\n\n\tpushPlaceholderRow();\n\n\treturn (\n\t\t<>\n\t\t\t{ rows }\n\t\t\t{ showAppender && (\n\t\t\t\t<TreeGridRow\n\t\t\t\t\tlevel={ level }\n\t\t\t\t\tsetSize={ rowCount }\n\t\t\t\t\tpositionInSet={ rowCount }\n\t\t\t\t\tisExpanded\n\t\t\t\t>\n\t\t\t\t\t<TreeGridCell>\n\t\t\t\t\t\t{ ( treeGridCellProps ) => (\n\t\t\t\t\t\t\t<Appender\n\t\t\t\t\t\t\t\tclientId={ parentId }\n\t\t\t\t\t\t\t\tnestingLevel={ level }\n\t\t\t\t\t\t\t\tblockCount={ blockCount }\n\t\t\t\t\t\t\t\t{ ...treeGridCellProps }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</TreeGridCell>\n\t\t\t\t</TreeGridRow>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default memo( ListViewBranch );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAGO;AACP,qBAAqB;AACrB,kBAA6C;AAC7C,sBAAyB;AACzB,mBAA0B;AAC1B,qBAAqC;AACrC,mBAIO;AACP,mBAA0C;AAC1C,yBAAuB;AAmHnB;A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eGridRow", "TreeGridCell"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/list-view/drop-indicator.jsx"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport {\n\tPopover,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { getScrollContainer } from '@wordpress/dom';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { isRTL } from '@wordpress/i18n';\nimport { Stack } from '@wordpress/ui';\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\nimport ListViewExpander from './expander';\n\nexport default function ListViewDropIndicatorPreview( {\n\tdraggedBlockClientId,\n\tlistViewRef,\n\tblockDropTarget,\n} ) {\n\tconst blockInformation = useBlockDisplayInformation( draggedBlockClientId );\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId: draggedBlockClientId,\n\t\tcontext: 'list-view',\n\t} );\n\n\tconst { rootClientId, clientId, dropPosition } = blockDropTarget || {};\n\n\tconst [ rootBlockElement, blockElement ] = useMemo( () => {\n\t\tif ( ! listViewRef.current ) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// The rootClientId will be defined whenever dropping into inner\n\t\t// block lists, but is undefined when dropping at the root level.\n\t\tconst _rootBlockElement = rootClientId\n\t\t\t? listViewRef.current.querySelector(\n\t\t\t\t\t`[data-block=\"${ rootClientId }\"]`\n\t\t\t )\n\t\t\t: undefined;\n\n\t\t// The clientId represents the sibling block, the dragged block will\n\t\t// usually be inserted adjacent to it. It will be undefined when\n\t\t// dropping a block into an empty block list.\n\t\tconst _blockElement = clientId\n\t\t\t? listViewRef.current.querySelector(\n\t\t\t\t\t`[data-block=\"${ clientId }\"]`\n\t\t\t )\n\t\t\t: undefined;\n\n\t\treturn [ _rootBlockElement, _blockElement ];\n\t}, [ listViewRef, rootClientId, clientId ] );\n\n\t// The targetElement is the element that the drop indicator will appear\n\t// before or after. When dropping into an empty block list, blockElement\n\t// is undefined, so the indicator will appear after the rootBlockElement.\n\tconst targetElement = blockElement || rootBlockElement;\n\n\tconst rtl = isRTL();\n\n\tconst getDropIndicatorWidth = useCallback(\n\t\t( targetElementRect, indent ) => {\n\t\t\tif ( ! targetElement ) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\t// Default to assuming that the width of the drop indicator\n\t\t\t// should be the same as the target element.\n\t\t\tlet width = targetElement.offsetWidth;\n\n\t\t\t// In deeply nested lists, where a scrollbar is present,\n\t\t\t// the width of the drop indicator should be the width of\n\t\t\t// the scroll container, minus the distance from the left\n\t\t\t// edge of the scroll container to the left edge of the\n\t\t\t// target element.\n\t\t\tconst scrollContainer = getScrollContainer(\n\t\t\t\ttargetElement,\n\t\t\t\t'horizontal'\n\t\t\t);\n\n\t\t\tconst ownerDocument = targetElement.ownerDocument;\n\t\t\tconst windowScroll =\n\t\t\t\tscrollContainer === ownerDocument.body ||\n\t\t\t\tscrollContainer === ownerDocument.documentElement;\n\n\t\t\tif ( scrollContainer && ! windowScroll ) {\n\t\t\t\tconst scrollContainerRect =\n\t\t\t\t\tscrollContainer.getBoundingClientRect();\n\n\t\t\t\tconst distanceBetweenContainerAndTarget = isRTL()\n\t\t\t\t\t? scrollContainerRect.right - targetElementRect.right\n\t\t\t\t\t: targetElementRect.left - scrollContainerRect.left;\n\n\t\t\t\tconst scrollContainerWidth = scrollContainer.clientWidth;\n\n\t\t\t\tif (\n\t\t\t\t\tscrollContainerWidth <\n\t\t\t\t\twidth + distanceBetweenContainerAndTarget\n\t\t\t\t) {\n\t\t\t\t\twidth =\n\t\t\t\t\t\tscrollContainerWidth -\n\t\t\t\t\t\tdistanceBetweenContainerAndTarget;\n\t\t\t\t}\n\n\t\t\t\t// LTR logic for ensuring the drop indicator does not extend\n\t\t\t\t// beyond the right edge of the scroll container.\n\t\t\t\tif (\n\t\t\t\t\t! rtl &&\n\t\t\t\t\ttargetElementRect.left + indent < scrollContainerRect.left\n\t\t\t\t) {\n\t\t\t\t\twidth -= scrollContainerRect.left - targetElementRect.left;\n\t\t\t\t\treturn width;\n\t\t\t\t}\n\n\t\t\t\t// RTL logic for ensuring the drop indicator does not extend\n\t\t\t\t// beyond the right edge of the scroll container.\n\t\t\t\tif (\n\t\t\t\t\trtl &&\n\t\t\t\t\ttargetElementRect.right - indent > scrollContainerRect.right\n\t\t\t\t) {\n\t\t\t\t\twidth -=\n\t\t\t\t\t\ttargetElementRect.right - scrollContainerRect.right;\n\t\t\t\t\treturn width;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Subtract the indent from the final width of the indicator.\n\t\t\treturn width - indent;\n\t\t},\n\t\t[ rtl, targetElement ]\n\t);\n\n\tconst style = useMemo( () => {\n\t\tif ( ! targetElement ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst targetElementRect = targetElement.getBoundingClientRect();\n\n\t\treturn {\n\t\t\twidth: getDropIndicatorWidth( targetElementRect, 0 ),\n\t\t};\n\t}, [ getDropIndicatorWidth, targetElement ] );\n\n\tconst horizontalScrollOffsetStyle = useMemo( () => {\n\t\tif ( ! targetElement ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst scrollContainer = getScrollContainer( targetElement );\n\t\tconst ownerDocument = targetElement.ownerDocument;\n\t\tconst windowScroll =\n\t\t\tscrollContainer === ownerDocument.body ||\n\t\t\tscrollContainer === ownerDocument.documentElement;\n\n\t\tif ( scrollContainer && ! windowScroll ) {\n\t\t\tconst scrollContainerRect = scrollContainer.getBoundingClientRect();\n\t\t\tconst targetElementRect = targetElement.getBoundingClientRect();\n\n\t\t\tconst distanceBetweenContainerAndTarget = rtl\n\t\t\t\t? scrollContainerRect.right - targetElementRect.right\n\t\t\t\t: targetElementRect.left - scrollContainerRect.left;\n\n\t\t\tif ( ! rtl && scrollContainerRect.left > targetElementRect.left ) {\n\t\t\t\treturn {\n\t\t\t\t\ttransform: `translateX( ${ distanceBetweenContainerAndTarget }px )`,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( rtl && scrollContainerRect.right < targetElementRect.right ) {\n\t\t\t\treturn {\n\t\t\t\t\ttransform: `translateX( ${\n\t\t\t\t\t\tdistanceBetweenContainerAndTarget * -1\n\t\t\t\t\t}px )`,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn {};\n\t}, [ rtl, targetElement ] );\n\n\tconst ariaLevel = useMemo( () => {\n\t\tif ( ! rootBlockElement ) {\n\t\t\treturn 1;\n\t\t}\n\n\t\tconst _ariaLevel = parseInt(\n\t\t\trootBlockElement.getAttribute( 'aria-level' ),\n\t\t\t10\n\t\t);\n\n\t\treturn _ariaLevel ? _ariaLevel + 1 : 1;\n\t}, [ rootBlockElement ] );\n\n\tconst hasAdjacentSelectedBranch = useMemo( () => {\n\t\tif ( ! targetElement ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn targetElement.classList.contains( 'is-branch-selected' );\n\t}, [ targetElement ] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tconst isValidDropPosition =\n\t\t\tdropPosition === 'top' ||\n\t\t\tdropPosition === 'bottom' ||\n\t\t\tdropPosition === 'inside';\n\t\tif ( ! targetElement || ! isValidDropPosition ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tcontextElement: targetElement,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst rect = targetElement.getBoundingClientRect();\n\t\t\t\t// In RTL languages, the drop indicator should be positioned\n\t\t\t\t// to the left of the target element, with the width of the\n\t\t\t\t// indicator determining the indent at the right edge of the\n\t\t\t\t// target element. In LTR languages, the drop indicator should\n\t\t\t\t// end at the right edge of the target element, with the indent\n\t\t\t\t// added to the position of the left edge of the target element.\n\t\t\t\t// let left = rtl ? rect.left : rect.left + indent;\n\t\t\t\tlet left = rect.left;\n\t\t\t\tlet top = 0;\n\n\t\t\t\t// In deeply nested lists, where a scrollbar is present,\n\t\t\t\t// the width of the drop indicator should be the width of\n\t\t\t\t// the visible area of the scroll container. Additionally,\n\t\t\t\t// the left edge of the drop indicator line needs to be\n\t\t\t\t// offset by the distance the left edge of the target element\n\t\t\t\t// and the left edge of the scroll container. The ensures\n\t\t\t\t// that the drop indicator position never breaks out of the\n\t\t\t\t// visible area of the scroll container.\n\t\t\t\tconst scrollContainer = getScrollContainer(\n\t\t\t\t\ttargetElement,\n\t\t\t\t\t'horizontal'\n\t\t\t\t);\n\n\t\t\t\tconst doc = targetElement.ownerDocument;\n\t\t\t\tconst windowScroll =\n\t\t\t\t\tscrollContainer === doc.body ||\n\t\t\t\t\tscrollContainer === doc.documentElement;\n\n\t\t\t\t// If the scroll container is not the window, offset the left position, if need be.\n\t\t\t\tif ( scrollContainer && ! windowScroll ) {\n\t\t\t\t\tconst scrollContainerRect =\n\t\t\t\t\t\tscrollContainer.getBoundingClientRect();\n\n\t\t\t\t\t// In RTL languages, a vertical scrollbar is present on the\n\t\t\t\t\t// left edge of the scroll container. The width of the\n\t\t\t\t\t// scrollbar needs to be accounted for when positioning the\n\t\t\t\t\t// drop indicator.\n\t\t\t\t\tconst scrollbarWidth = rtl\n\t\t\t\t\t\t? scrollContainer.offsetWidth -\n\t\t\t\t\t\t scrollContainer.clientWidth\n\t\t\t\t\t\t: 0;\n\n\t\t\t\t\tif ( left < scrollContainerRect.left + scrollbarWidth ) {\n\t\t\t\t\t\tleft = scrollContainerRect.left + scrollbarWidth;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( dropPosition === 'top' ) {\n\t\t\t\t\ttop = rect.top - rect.height * 2;\n\t\t\t\t} else {\n\t\t\t\t\t// `dropPosition` is either `bottom` or `inside`\n\t\t\t\t\ttop = rect.top;\n\t\t\t\t}\n\n\t\t\t\tconst width = getDropIndicatorWidth( rect, 0 );\n\t\t\t\tconst height = rect.height;\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t};\n\t}, [ targetElement, dropPosition, getDropIndicatorWidth, rtl ] );\n\n\tif ( ! targetElement ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tanimate={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tfocusOnMount={ false }\n\t\t\tclassName=\"block-editor-list-view-drop-indicator--preview\"\n\t\t\tvariant=\"unstyled\"\n\t\t\tflip={ false }\n\t\t\tresize\n\t\t>\n\t\t\t<div\n\t\t\t\tstyle={ style }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-editor-list-view-drop-indicator__line',\n\t\t\t\t\t{\n\t\t\t\t\t\t'block-editor-list-view-drop-indicator__line--darker':\n\t\t\t\t\t\t\thasAdjacentSelectedBranch,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"block-editor-list-view-leaf\"\n\t\t\t\t\taria-level={ ariaLevel }\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-editor-list-view-block-select-button',\n\t\t\t\t\t\t\t'block-editor-list-view-block-contents'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tstyle={ horizontalScrollOffsetStyle }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ListViewExpander onClick={ () => {} } />\n\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\ticon={ blockInformation?.icon }\n\t\t\t\t\t\t\tshowColors\n\t\t\t\t\t\t\tcontext=\"list-view\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Stack\n\t\t\t\t\t\t\talign=\"center\"\n\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__label-wrapper\"\n\t\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t\t\tgap=\"xs\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__title\">\n\t\t\t\t\t\t\t\t<Truncate ellipsizeMode=\"auto\">\n\t\t\t\t\t\t\t\t\t{ blockTitle }\n\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</Stack>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"block-editor-list-view-block__menu-cell\"></div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</Popover>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,wBAGO;AACP,iBAAmC;AACnC,qBAAqC;AACrC,kBAAsB;AACtB,gBAAsB;AACtB,wBAAsB;AACtB,2CAAuC;AACvC,qCAAiC;AACjC,sBAA6B;AAoSxB;AAlSU,SAAR,6BAA+C;AAAA,EACrD;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,uBAAmB,qCAAAA,SAA4B,oBAAqB;AAC1E,QAAM,iBAAa,+BAAAC,SAAsB;AAAA,IACxC,UAAU;AAAA,IACV,SAAS;AAAA,EACV,CAAE;AAEF,QAAM,EAAE,cAAc,UAAU,aAAa,IAAI,mBAAmB,CAAC;AAErE,QAAM,CAAE,kBAAkB,YAAa,QAAI,wBAAS,MAAM;AACzD,QAAK,CAAE,YAAY,SAAU;AAC5B,aAAO,CAAC;AAAA,IACT;AAIA,UAAM,oBAAoB,eACvB,YAAY,QAAQ;AAAA,MACpB,gBAAiB,YAAa;AAAA,
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport {\n\tPopover,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { getScrollContainer } from '@wordpress/dom';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { isRTL } from '@wordpress/i18n';\nimport { Stack } from '@wordpress/ui';\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\nimport ListViewExpander from './expander';\n\nexport default function ListViewDropIndicatorPreview( {\n\tdraggedBlockClientId,\n\tlistViewRef,\n\tblockDropTarget,\n} ) {\n\tconst blockInformation = useBlockDisplayInformation( draggedBlockClientId );\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId: draggedBlockClientId,\n\t\tcontext: 'list-view',\n\t} );\n\n\tconst { rootClientId, clientId, dropPosition } = blockDropTarget || {};\n\n\tconst [ rootBlockElement, blockElement ] = useMemo( () => {\n\t\tif ( ! listViewRef.current ) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// The rootClientId will be defined whenever dropping into inner\n\t\t// block lists, but is undefined when dropping at the root level.\n\t\tconst _rootBlockElement = rootClientId\n\t\t\t? listViewRef.current.querySelector(\n\t\t\t\t\t`[data-block=\"${ rootClientId }\"]`\n\t\t\t\t)\n\t\t\t: undefined;\n\n\t\t// The clientId represents the sibling block, the dragged block will\n\t\t// usually be inserted adjacent to it. It will be undefined when\n\t\t// dropping a block into an empty block list.\n\t\tconst _blockElement = clientId\n\t\t\t? listViewRef.current.querySelector(\n\t\t\t\t\t`[data-block=\"${ clientId }\"]`\n\t\t\t\t)\n\t\t\t: undefined;\n\n\t\treturn [ _rootBlockElement, _blockElement ];\n\t}, [ listViewRef, rootClientId, clientId ] );\n\n\t// The targetElement is the element that the drop indicator will appear\n\t// before or after. When dropping into an empty block list, blockElement\n\t// is undefined, so the indicator will appear after the rootBlockElement.\n\tconst targetElement = blockElement || rootBlockElement;\n\n\tconst rtl = isRTL();\n\n\tconst getDropIndicatorWidth = useCallback(\n\t\t( targetElementRect, indent ) => {\n\t\t\tif ( ! targetElement ) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\t// Default to assuming that the width of the drop indicator\n\t\t\t// should be the same as the target element.\n\t\t\tlet width = targetElement.offsetWidth;\n\n\t\t\t// In deeply nested lists, where a scrollbar is present,\n\t\t\t// the width of the drop indicator should be the width of\n\t\t\t// the scroll container, minus the distance from the left\n\t\t\t// edge of the scroll container to the left edge of the\n\t\t\t// target element.\n\t\t\tconst scrollContainer = getScrollContainer(\n\t\t\t\ttargetElement,\n\t\t\t\t'horizontal'\n\t\t\t);\n\n\t\t\tconst ownerDocument = targetElement.ownerDocument;\n\t\t\tconst windowScroll =\n\t\t\t\tscrollContainer === ownerDocument.body ||\n\t\t\t\tscrollContainer === ownerDocument.documentElement;\n\n\t\t\tif ( scrollContainer && ! windowScroll ) {\n\t\t\t\tconst scrollContainerRect =\n\t\t\t\t\tscrollContainer.getBoundingClientRect();\n\n\t\t\t\tconst distanceBetweenContainerAndTarget = isRTL()\n\t\t\t\t\t? scrollContainerRect.right - targetElementRect.right\n\t\t\t\t\t: targetElementRect.left - scrollContainerRect.left;\n\n\t\t\t\tconst scrollContainerWidth = scrollContainer.clientWidth;\n\n\t\t\t\tif (\n\t\t\t\t\tscrollContainerWidth <\n\t\t\t\t\twidth + distanceBetweenContainerAndTarget\n\t\t\t\t) {\n\t\t\t\t\twidth =\n\t\t\t\t\t\tscrollContainerWidth -\n\t\t\t\t\t\tdistanceBetweenContainerAndTarget;\n\t\t\t\t}\n\n\t\t\t\t// LTR logic for ensuring the drop indicator does not extend\n\t\t\t\t// beyond the right edge of the scroll container.\n\t\t\t\tif (\n\t\t\t\t\t! rtl &&\n\t\t\t\t\ttargetElementRect.left + indent < scrollContainerRect.left\n\t\t\t\t) {\n\t\t\t\t\twidth -= scrollContainerRect.left - targetElementRect.left;\n\t\t\t\t\treturn width;\n\t\t\t\t}\n\n\t\t\t\t// RTL logic for ensuring the drop indicator does not extend\n\t\t\t\t// beyond the right edge of the scroll container.\n\t\t\t\tif (\n\t\t\t\t\trtl &&\n\t\t\t\t\ttargetElementRect.right - indent > scrollContainerRect.right\n\t\t\t\t) {\n\t\t\t\t\twidth -=\n\t\t\t\t\t\ttargetElementRect.right - scrollContainerRect.right;\n\t\t\t\t\treturn width;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Subtract the indent from the final width of the indicator.\n\t\t\treturn width - indent;\n\t\t},\n\t\t[ rtl, targetElement ]\n\t);\n\n\tconst style = useMemo( () => {\n\t\tif ( ! targetElement ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst targetElementRect = targetElement.getBoundingClientRect();\n\n\t\treturn {\n\t\t\twidth: getDropIndicatorWidth( targetElementRect, 0 ),\n\t\t};\n\t}, [ getDropIndicatorWidth, targetElement ] );\n\n\tconst horizontalScrollOffsetStyle = useMemo( () => {\n\t\tif ( ! targetElement ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst scrollContainer = getScrollContainer( targetElement );\n\t\tconst ownerDocument = targetElement.ownerDocument;\n\t\tconst windowScroll =\n\t\t\tscrollContainer === ownerDocument.body ||\n\t\t\tscrollContainer === ownerDocument.documentElement;\n\n\t\tif ( scrollContainer && ! windowScroll ) {\n\t\t\tconst scrollContainerRect = scrollContainer.getBoundingClientRect();\n\t\t\tconst targetElementRect = targetElement.getBoundingClientRect();\n\n\t\t\tconst distanceBetweenContainerAndTarget = rtl\n\t\t\t\t? scrollContainerRect.right - targetElementRect.right\n\t\t\t\t: targetElementRect.left - scrollContainerRect.left;\n\n\t\t\tif ( ! rtl && scrollContainerRect.left > targetElementRect.left ) {\n\t\t\t\treturn {\n\t\t\t\t\ttransform: `translateX( ${ distanceBetweenContainerAndTarget }px )`,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( rtl && scrollContainerRect.right < targetElementRect.right ) {\n\t\t\t\treturn {\n\t\t\t\t\ttransform: `translateX( ${\n\t\t\t\t\t\tdistanceBetweenContainerAndTarget * -1\n\t\t\t\t\t}px )`,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn {};\n\t}, [ rtl, targetElement ] );\n\n\tconst ariaLevel = useMemo( () => {\n\t\tif ( ! rootBlockElement ) {\n\t\t\treturn 1;\n\t\t}\n\n\t\tconst _ariaLevel = parseInt(\n\t\t\trootBlockElement.getAttribute( 'aria-level' ),\n\t\t\t10\n\t\t);\n\n\t\treturn _ariaLevel ? _ariaLevel + 1 : 1;\n\t}, [ rootBlockElement ] );\n\n\tconst hasAdjacentSelectedBranch = useMemo( () => {\n\t\tif ( ! targetElement ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn targetElement.classList.contains( 'is-branch-selected' );\n\t}, [ targetElement ] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tconst isValidDropPosition =\n\t\t\tdropPosition === 'top' ||\n\t\t\tdropPosition === 'bottom' ||\n\t\t\tdropPosition === 'inside';\n\t\tif ( ! targetElement || ! isValidDropPosition ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tcontextElement: targetElement,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst rect = targetElement.getBoundingClientRect();\n\t\t\t\t// In RTL languages, the drop indicator should be positioned\n\t\t\t\t// to the left of the target element, with the width of the\n\t\t\t\t// indicator determining the indent at the right edge of the\n\t\t\t\t// target element. In LTR languages, the drop indicator should\n\t\t\t\t// end at the right edge of the target element, with the indent\n\t\t\t\t// added to the position of the left edge of the target element.\n\t\t\t\t// let left = rtl ? rect.left : rect.left + indent;\n\t\t\t\tlet left = rect.left;\n\t\t\t\tlet top = 0;\n\n\t\t\t\t// In deeply nested lists, where a scrollbar is present,\n\t\t\t\t// the width of the drop indicator should be the width of\n\t\t\t\t// the visible area of the scroll container. Additionally,\n\t\t\t\t// the left edge of the drop indicator line needs to be\n\t\t\t\t// offset by the distance the left edge of the target element\n\t\t\t\t// and the left edge of the scroll container. The ensures\n\t\t\t\t// that the drop indicator position never breaks out of the\n\t\t\t\t// visible area of the scroll container.\n\t\t\t\tconst scrollContainer = getScrollContainer(\n\t\t\t\t\ttargetElement,\n\t\t\t\t\t'horizontal'\n\t\t\t\t);\n\n\t\t\t\tconst doc = targetElement.ownerDocument;\n\t\t\t\tconst windowScroll =\n\t\t\t\t\tscrollContainer === doc.body ||\n\t\t\t\t\tscrollContainer === doc.documentElement;\n\n\t\t\t\t// If the scroll container is not the window, offset the left position, if need be.\n\t\t\t\tif ( scrollContainer && ! windowScroll ) {\n\t\t\t\t\tconst scrollContainerRect =\n\t\t\t\t\t\tscrollContainer.getBoundingClientRect();\n\n\t\t\t\t\t// In RTL languages, a vertical scrollbar is present on the\n\t\t\t\t\t// left edge of the scroll container. The width of the\n\t\t\t\t\t// scrollbar needs to be accounted for when positioning the\n\t\t\t\t\t// drop indicator.\n\t\t\t\t\tconst scrollbarWidth = rtl\n\t\t\t\t\t\t? scrollContainer.offsetWidth -\n\t\t\t\t\t\t\tscrollContainer.clientWidth\n\t\t\t\t\t\t: 0;\n\n\t\t\t\t\tif ( left < scrollContainerRect.left + scrollbarWidth ) {\n\t\t\t\t\t\tleft = scrollContainerRect.left + scrollbarWidth;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( dropPosition === 'top' ) {\n\t\t\t\t\ttop = rect.top - rect.height * 2;\n\t\t\t\t} else {\n\t\t\t\t\t// `dropPosition` is either `bottom` or `inside`\n\t\t\t\t\ttop = rect.top;\n\t\t\t\t}\n\n\t\t\t\tconst width = getDropIndicatorWidth( rect, 0 );\n\t\t\t\tconst height = rect.height;\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t};\n\t}, [ targetElement, dropPosition, getDropIndicatorWidth, rtl ] );\n\n\tif ( ! targetElement ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tanimate={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tfocusOnMount={ false }\n\t\t\tclassName=\"block-editor-list-view-drop-indicator--preview\"\n\t\t\tvariant=\"unstyled\"\n\t\t\tflip={ false }\n\t\t\tresize\n\t\t>\n\t\t\t<div\n\t\t\t\tstyle={ style }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-editor-list-view-drop-indicator__line',\n\t\t\t\t\t{\n\t\t\t\t\t\t'block-editor-list-view-drop-indicator__line--darker':\n\t\t\t\t\t\t\thasAdjacentSelectedBranch,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"block-editor-list-view-leaf\"\n\t\t\t\t\taria-level={ ariaLevel }\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-editor-list-view-block-select-button',\n\t\t\t\t\t\t\t'block-editor-list-view-block-contents'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tstyle={ horizontalScrollOffsetStyle }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ListViewExpander onClick={ () => {} } />\n\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\ticon={ blockInformation?.icon }\n\t\t\t\t\t\t\tshowColors\n\t\t\t\t\t\t\tcontext=\"list-view\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Stack\n\t\t\t\t\t\t\talign=\"center\"\n\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__label-wrapper\"\n\t\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t\t\tgap=\"xs\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__title\">\n\t\t\t\t\t\t\t\t<Truncate ellipsizeMode=\"auto\">\n\t\t\t\t\t\t\t\t\t{ blockTitle }\n\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</Stack>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"block-editor-list-view-block__menu-cell\"></div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</Popover>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,wBAGO;AACP,iBAAmC;AACnC,qBAAqC;AACrC,kBAAsB;AACtB,gBAAsB;AACtB,wBAAsB;AACtB,2CAAuC;AACvC,qCAAiC;AACjC,sBAA6B;AAoSxB;AAlSU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