@wordpress/block-editor 9.6.0 → 9.8.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 +4 -0
- package/build/components/block-alignment-control/use-available-alignments.js +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build/components/block-edit-visually-button/index.js +46 -0
- package/build/components/block-edit-visually-button/index.js.map +1 -0
- package/build/components/block-list/block.js +12 -2
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/index.native.js +1 -1
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-popover/inbetween.js +5 -3
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +10 -4
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-settings-menu/index.js +2 -6
- package/build/components/block-settings-menu/index.js.map +1 -1
- package/build/components/block-styles/index.js +3 -6
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/index.js +10 -16
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +5 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +10 -2
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +126 -0
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -0
- package/build/components/block-types-list/index.js +1 -1
- package/build/components/block-types-list/index.js.map +1 -1
- package/build/components/border-radius-control/all-input-control.js +31 -3
- package/build/components/border-radius-control/all-input-control.js.map +1 -1
- package/build/components/border-radius-control/index.js +23 -7
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +21 -6
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/border-radius-control/utils.js +13 -16
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/colors/utils.js +6 -2
- package/build/components/colors/utils.js.map +1 -1
- package/build/components/colors/with-colors.js +17 -4
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/control.js +7 -4
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +5 -2
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/copy-handler/index.js +6 -0
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +2 -7
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/duotone/components.js +5 -5
- package/build/components/duotone/components.js.map +1 -1
- package/build/components/font-appearance-control/index.js +10 -4
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/font-family/index.js +1 -1
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +17 -4
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/image-size-control/index.js +3 -1
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/index.js +22 -6
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +11 -4
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/index.native.js +8 -3
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/search-items.js +22 -4
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter-list-item/index.js +2 -19
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +6 -3
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/line-height-control/index.js +6 -3
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/is-url-like.js +1 -7
- package/build/components/link-control/is-url-like.js.map +1 -1
- package/build/components/link-control/link-preview.js +0 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/use-search-handler.js +1 -7
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/list-view/block-select-button.js +5 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/expander.js +3 -1
- package/build/components/list-view/expander.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -7
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/media-upload/index.native.js +8 -3
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/preview-options/index.js +2 -2
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/{use-no-recursive-renders → recursion-provider}/index.js +40 -18
- package/build/components/recursion-provider/index.js.map +1 -0
- package/build/components/rich-text/index.js +6 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +3 -1
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-before-input-rules.js +110 -0
- package/build/components/rich-text/use-before-input-rules.js.map +1 -0
- package/build/components/rich-text/use-enter.js +0 -4
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/rich-text/use-format-types.js +8 -11
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build/components/spacing-sizes-control/all-input-control.js +53 -0
- package/build/components/spacing-sizes-control/all-input-control.js.map +1 -0
- package/build/components/spacing-sizes-control/axial-input-controls.js +69 -0
- package/build/components/spacing-sizes-control/axial-input-controls.js.map +1 -0
- package/build/components/spacing-sizes-control/index.js +100 -0
- package/build/components/spacing-sizes-control/index.js.map +1 -0
- package/build/components/spacing-sizes-control/input-controls.js +52 -0
- package/build/components/spacing-sizes-control/input-controls.js.map +1 -0
- package/build/components/spacing-sizes-control/linked-button.js +38 -0
- package/build/components/spacing-sizes-control/linked-button.js.map +1 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js +208 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -0
- package/build/components/spacing-sizes-control/utils.js +202 -0
- package/build/components/spacing-sizes-control/utils.js.map +1 -0
- package/build/components/text-decoration-control/index.js +3 -1
- package/build/components/text-decoration-control/index.js.map +1 -1
- package/build/components/text-transform-control/index.js +3 -1
- package/build/components/text-transform-control/index.js.map +1 -1
- package/build/components/url-input/index.js +1 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +4 -1
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +4 -25
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/components/writing-flow/use-drag-selection.js +9 -2
- package/build/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +4 -2
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-select-all.js +3 -1
- package/build/components/writing-flow/use-select-all.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +10 -2
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/hooks/border-radius.js +2 -7
- package/build/hooks/border-radius.js.map +1 -1
- package/build/hooks/border.js +2 -2
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +4 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/dimensions.js +15 -0
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +4 -4
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/gap.js +6 -4
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/generated-class-name.js +1 -7
- package/build/hooks/generated-class-name.js.map +1 -1
- package/build/hooks/layout.js +29 -14
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +28 -12
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +19 -8
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +4 -50
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/constrained.js +215 -0
- package/build/layouts/constrained.js.map +1 -0
- package/build/layouts/flex.js +1 -1
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +7 -151
- package/build/layouts/flow.js.map +1 -1
- package/build/layouts/index.js +3 -1
- package/build/layouts/index.js.map +1 -1
- package/build/layouts/utils.js +43 -0
- package/build/layouts/utils.js.map +1 -1
- package/build/store/actions.js +25 -3
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +4 -6
- package/build/store/selectors.js.map +1 -1
- package/build/utils/block-variation-transforms.js +15 -9
- package/build/utils/block-variation-transforms.js.map +1 -1
- package/build/utils/pasting.js +9 -1
- package/build/utils/pasting.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build-module/components/block-edit-visually-button/index.js +35 -0
- package/build-module/components/block-edit-visually-button/index.js.map +1 -0
- package/build-module/components/block-list/block.js +13 -3
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/index.native.js +1 -1
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +5 -3
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +8 -4
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-settings-menu/index.js +3 -6
- package/build-module/components/block-settings-menu/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +4 -7
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +10 -16
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +4 -1
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +8 -2
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +114 -0
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -0
- package/build-module/components/block-types-list/index.js +1 -1
- package/build-module/components/block-types-list/index.js.map +1 -1
- package/build-module/components/border-radius-control/all-input-control.js +32 -4
- package/build-module/components/border-radius-control/all-input-control.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +24 -8
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +22 -7
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js +13 -16
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/colors/utils.js +7 -3
- package/build-module/components/colors/utils.js.map +1 -1
- package/build-module/components/colors/with-colors.js +16 -3
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +7 -4
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +5 -2
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/copy-handler/index.js +7 -1
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +2 -6
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/duotone/components.js +5 -5
- package/build-module/components/duotone/components.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +7 -4
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/font-family/index.js +1 -1
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +16 -3
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/image-size-control/index.js +3 -1
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/index.js +2 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/index.native.js +9 -2
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/search-items.js +19 -5
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +1 -17
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +5 -3
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js +5 -3
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/is-url-like.js +1 -6
- package/build-module/components/link-control/is-url-like.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +0 -1
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/use-search-handler.js +1 -6
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +5 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/expander.js +3 -2
- package/build-module/components/list-view/expander.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -6
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +9 -2
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/preview-options/index.js +2 -2
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/{use-no-recursive-renders → recursion-provider}/index.js +39 -19
- package/build-module/components/recursion-provider/index.js.map +1 -0
- package/build-module/components/rich-text/index.js +5 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +3 -1
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-before-input-rules.js +96 -0
- package/build-module/components/rich-text/use-before-input-rules.js.map +1 -0
- package/build-module/components/rich-text/use-enter.js +0 -4
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/rich-text/use-format-types.js +8 -10
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/components/spacing-sizes-control/all-input-control.js +41 -0
- package/build-module/components/spacing-sizes-control/all-input-control.js.map +1 -0
- package/build-module/components/spacing-sizes-control/axial-input-controls.js +57 -0
- package/build-module/components/spacing-sizes-control/axial-input-controls.js.map +1 -0
- package/build-module/components/spacing-sizes-control/index.js +83 -0
- package/build-module/components/spacing-sizes-control/index.js.map +1 -0
- package/build-module/components/spacing-sizes-control/input-controls.js +41 -0
- package/build-module/components/spacing-sizes-control/input-controls.js.map +1 -0
- package/build-module/components/spacing-sizes-control/linked-button.js +28 -0
- package/build-module/components/spacing-sizes-control/linked-button.js.map +1 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +192 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -0
- package/build-module/components/spacing-sizes-control/utils.js +174 -0
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -0
- package/build-module/components/text-decoration-control/index.js +4 -2
- package/build-module/components/text-decoration-control/index.js.map +1 -1
- package/build-module/components/text-transform-control/index.js +4 -2
- package/build-module/components/text-transform-control/index.js.map +1 -1
- package/build-module/components/url-input/index.js +1 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +4 -1
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +5 -26
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/components/writing-flow/use-drag-selection.js +9 -2
- package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +4 -2
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-select-all.js +3 -1
- package/build-module/components/writing-flow/use-select-all.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +10 -2
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/hooks/border-radius.js +2 -7
- package/build-module/hooks/border-radius.js.map +1 -1
- package/build-module/hooks/border.js +2 -2
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +4 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/dimensions.js +13 -0
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -4
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/gap.js +3 -2
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/generated-class-name.js +1 -6
- package/build-module/hooks/generated-class-name.js.map +1 -1
- package/build-module/hooks/layout.js +29 -14
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +26 -12
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +17 -8
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +7 -53
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/constrained.js +197 -0
- package/build-module/layouts/constrained.js.map +1 -0
- package/build-module/layouts/flex.js +1 -1
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +8 -145
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/layouts/index.js +2 -1
- package/build-module/layouts/index.js.map +1 -1
- package/build-module/layouts/utils.js +40 -0
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/store/actions.js +25 -3
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +5 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/block-variation-transforms.js +14 -7
- package/build-module/utils/block-variation-transforms.js.map +1 -1
- package/build-module/utils/pasting.js +9 -1
- package/build-module/utils/pasting.js.map +1 -1
- package/build-style/style-rtl.css +154 -27
- package/build-style/style.css +154 -27
- package/package.json +30 -28
- package/src/components/block-alignment-control/use-available-alignments.js +1 -1
- package/src/components/block-edit-visually-button/index.js +39 -0
- package/src/components/block-list/block.js +13 -2
- package/src/components/block-list/index.native.js +1 -1
- package/src/components/block-popover/inbetween.js +5 -1
- package/src/components/block-popover/index.js +22 -13
- package/src/components/block-popover/style.scss +25 -2
- package/src/components/block-settings-menu/index.js +11 -15
- package/src/components/block-styles/index.js +4 -7
- package/src/components/block-styles/style.scss +10 -0
- package/src/components/block-switcher/index.js +9 -13
- package/src/components/block-switcher/test/index.js +1 -0
- package/src/components/block-toolbar/index.js +2 -0
- package/src/components/block-tools/selected-block-popover.js +7 -0
- package/src/components/block-tools/use-block-toolbar-popover-props.js +123 -0
- package/src/components/block-types-list/index.js +1 -1
- package/src/components/border-radius-control/all-input-control.js +41 -4
- package/src/components/border-radius-control/index.js +29 -6
- package/src/components/border-radius-control/input-controls.js +40 -13
- package/src/components/border-radius-control/test/utils.js +22 -60
- package/src/components/border-radius-control/utils.js +12 -16
- package/src/components/color-palette/test/__snapshots__/control.js.snap +93 -77
- package/src/components/colors/utils.js +5 -2
- package/src/components/colors/with-colors.js +11 -1
- package/src/components/colors-gradients/control.js +12 -8
- package/src/components/colors-gradients/dropdown.js +7 -2
- package/src/components/colors-gradients/style.scss +27 -5
- package/src/components/colors-gradients/test/control.js +3 -3
- package/src/components/copy-handler/index.js +18 -0
- package/src/components/date-format-picker/index.js +12 -14
- package/src/components/date-format-picker/style.scss +0 -4
- package/src/components/duotone/components.js +5 -5
- package/src/components/duotone-control/style.scss +0 -4
- package/src/components/font-appearance-control/index.js +3 -0
- package/src/components/font-appearance-control/style.scss +0 -2
- package/src/components/font-family/index.js +1 -1
- package/src/components/font-sizes/with-font-sizes.js +11 -1
- package/src/components/image-size-control/README.md +7 -0
- package/src/components/image-size-control/index.js +2 -0
- package/src/components/index.js +5 -1
- package/src/components/index.native.js +4 -1
- package/src/components/inserter/index.native.js +7 -2
- package/src/components/inserter/search-items.js +17 -5
- package/src/components/inserter-list-item/index.js +1 -17
- package/src/components/letter-spacing-control/index.js +2 -0
- package/src/components/line-height-control/index.js +2 -0
- package/src/components/link-control/is-url-like.js +1 -6
- package/src/components/link-control/link-preview.js +0 -1
- package/src/components/link-control/test/index.js +540 -893
- package/src/components/link-control/use-search-handler.js +1 -6
- package/src/components/list-view/block-select-button.js +7 -2
- package/src/components/list-view/expander.js +4 -2
- package/src/components/list-view/style.scss +11 -4
- package/src/components/list-view/use-block-selection.js +2 -8
- package/src/components/media-replace-flow/style.scss +1 -0
- package/src/components/media-upload/index.native.js +7 -3
- package/src/components/preview-options/index.js +2 -2
- package/src/components/{use-no-recursive-renders → recursion-provider}/index.js +39 -28
- package/src/components/{use-no-recursive-renders/test/use-no-recursive-renders.js → recursion-provider/test/index.js} +5 -6
- package/src/components/rich-text/README.md +13 -1
- package/src/components/rich-text/index.js +2 -0
- package/src/components/rich-text/index.native.js +2 -0
- package/src/components/rich-text/use-before-input-rules.js +91 -0
- package/src/components/rich-text/use-enter.js +0 -3
- package/src/components/rich-text/use-format-types.js +6 -6
- package/src/components/spacing-sizes-control/all-input-control.js +40 -0
- package/src/components/spacing-sizes-control/axial-input-controls.js +62 -0
- package/src/components/spacing-sizes-control/index.js +91 -0
- package/src/components/spacing-sizes-control/input-controls.js +46 -0
- package/src/components/spacing-sizes-control/linked-button.js +25 -0
- package/src/components/spacing-sizes-control/spacing-input-control.js +280 -0
- package/src/components/spacing-sizes-control/style.scss +122 -0
- package/src/components/spacing-sizes-control/test/utils.js +156 -0
- package/src/components/spacing-sizes-control/utils.js +195 -0
- package/src/components/text-decoration-control/index.js +4 -2
- package/src/components/text-transform-control/index.js +4 -2
- package/src/components/url-input/index.js +1 -1
- package/src/components/url-input/style.scss +2 -2
- package/src/components/url-popover/image-url-input-ui.js +3 -0
- package/src/components/url-popover/style.scss +0 -3
- package/src/components/writing-flow/use-arrow-nav.js +4 -33
- package/src/components/writing-flow/use-drag-selection.js +7 -1
- package/src/components/writing-flow/use-multi-selection.js +4 -1
- package/src/components/writing-flow/use-select-all.js +2 -1
- package/src/components/writing-flow/use-selection-observer.js +10 -2
- package/src/hooks/border-radius.js +2 -6
- package/src/hooks/border.js +2 -2
- package/src/hooks/color.js +13 -3
- package/src/hooks/dimensions.js +15 -0
- package/src/hooks/duotone.js +4 -4
- package/src/hooks/gap.js +7 -2
- package/src/hooks/generated-class-name.js +6 -9
- package/src/hooks/layout.js +53 -16
- package/src/hooks/margin.js +49 -17
- package/src/hooks/padding.js +41 -14
- package/src/hooks/style.js +5 -56
- package/src/hooks/test/gap.js +22 -0
- package/src/hooks/typography.scss +0 -1
- package/src/layouts/constrained.js +217 -0
- package/src/layouts/flex.js +1 -1
- package/src/layouts/flow.js +6 -164
- package/src/layouts/index.js +2 -1
- package/src/layouts/test/constrained.js +21 -0
- package/src/layouts/utils.js +34 -0
- package/src/store/actions.js +32 -4
- package/src/store/selectors.js +5 -4
- package/src/style.scss +1 -0
- package/src/utils/block-variation-transforms.js +13 -6
- package/src/utils/pasting.js +10 -1
- package/src/utils/test/block-variation-transforms.js +24 -0
- package/src/utils/test/pasting.js +10 -0
- package/build/components/block-settings-menu/block-edit-visually-button.js +0 -70
- package/build/components/block-settings-menu/block-edit-visually-button.js.map +0 -1
- package/build/components/use-no-recursive-renders/index.js.map +0 -1
- package/build-module/components/block-settings-menu/block-edit-visually-button.js +0 -56
- package/build-module/components/block-settings-menu/block-edit-visually-button.js.map +0 -1
- package/build-module/components/use-no-recursive-renders/index.js.map +0 -1
- package/src/components/block-settings-menu/block-edit-visually-button.js +0 -52
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-styles/index.js"],"names":["BlockStylesPreviewPanelSlot","scope","BlockStylesPreviewPanelFill","children","props","DEFAULT_POSITION_TOP","noop","BlockStyles","clientId","onSwitch","onHoverClassName","onSelect","stylesToRender","activeStyle","genericPreviewBlock","className","previewClassName","hoveredStyle","setHoveredStyle","containerScrollTop","setContainerScrollTop","isMobileViewport","scrollContainer","document","querySelector","scrollTop","length","debouncedSetHoveredStyle","onSelectStylePreview","style","cancel","styleItemHandler","item","name","map","buttonText","label","top","Slot"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAMA;;AACA;;AAUA;;AACA;;AAtBA;AACA;AACA;;AAIA;AACA;AACA;;AAUA;AACA;AACA;AAIA,SAASA,2BAAT,OAAkD;AAAA,MAAZ;AAAEC,IAAAA;AAAF,GAAY;AACjD,SAAO,4BAAC,gBAAD;AAAM,IAAA,IAAI,EAAI,2BAA2BA,KAAO;AAAhD,IAAP;AACA;;AAED,SAASC,2BAAT,QAAsE;AAAA,MAAhC;AAAEC,IAAAA,QAAF;AAAYF,IAAAA,KAAZ;AAAmB,OAAGG;AAAtB,GAAgC;AACrE,SACC,4BAAC,gBAAD;AAAM,IAAA,IAAI,EAAI,2BAA2BH,KAAO;AAAhD,KACC,mCAAUG,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|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-styles/index.js"],"names":["BlockStylesPreviewPanelSlot","scope","BlockStylesPreviewPanelFill","children","props","DEFAULT_POSITION_TOP","noop","BlockStyles","clientId","onSwitch","onHoverClassName","onSelect","stylesToRender","activeStyle","genericPreviewBlock","className","previewClassName","hoveredStyle","setHoveredStyle","containerScrollTop","setContainerScrollTop","isMobileViewport","scrollContainer","document","querySelector","scrollTop","length","debouncedSetHoveredStyle","onSelectStylePreview","style","cancel","styleItemHandler","item","name","map","buttonText","label","top","Slot"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAMA;;AACA;;AAUA;;AACA;;AAtBA;AACA;AACA;;AAIA;AACA;AACA;;AAUA;AACA;AACA;AAIA,SAASA,2BAAT,OAAkD;AAAA,MAAZ;AAAEC,IAAAA;AAAF,GAAY;AACjD,SAAO,4BAAC,gBAAD;AAAM,IAAA,IAAI,EAAI,2BAA2BA,KAAO;AAAhD,IAAP;AACA;;AAED,SAASC,2BAAT,QAAsE;AAAA,MAAhC;AAAEC,IAAAA,QAAF;AAAYF,IAAAA,KAAZ;AAAmB,OAAGG;AAAtB,GAAgC;AACrE,SACC,4BAAC,gBAAD;AAAM,IAAA,IAAI,EAAI,2BAA2BH,KAAO;AAAhD,KACC,mCAAUG,KAAV,EAAoBD,QAApB,CADD,CADD;AAKA,C,CAED;AACA;AACA;;;AACA,MAAME,oBAAoB,GAAG,EAA7B;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB,C,CAEA;;;AACA,SAASC,WAAT,QAKI;AAAA,MALkB;AACrBC,IAAAA,QADqB;AAErBC,IAAAA,QAAQ,GAAGH,IAFU;AAGrBI,IAAAA,gBAAgB,GAAGJ,IAHE;AAIrBL,IAAAA;AAJqB,GAKlB;AACH,QAAM;AACLU,IAAAA,QADK;AAELC,IAAAA,cAFK;AAGLC,IAAAA,WAHK;AAILC,IAAAA,mBAJK;AAKLC,IAAAA,SAAS,EAAEC;AALN,MAMF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Fb;AAGC,IAAA,mBAAmB,EAAGF,mBAHvB;AAIC,IAAA,KAAK,EAAGG;AAJT,IAND,CAnCF,CADD;AAoDA;;AAEDV,WAAW,CAAC+B,IAAZ,GAAmBtC,2BAAnB;eACeO,W","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useLayoutEffect } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tButton,\n\t__experimentalTruncate as Truncate,\n\tSlot,\n\tFill,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockStylesPreviewPanel from './preview-panel';\nimport useStylesForBlocks from './use-styles-for-block';\n\nfunction BlockStylesPreviewPanelSlot( { scope } ) {\n\treturn <Slot name={ `BlockStylesPreviewPanel/${ scope }` } />;\n}\n\nfunction BlockStylesPreviewPanelFill( { children, scope, ...props } ) {\n\treturn (\n\t\t<Fill name={ `BlockStylesPreviewPanel/${ scope }` }>\n\t\t\t<div { ...props }>{ children }</div>\n\t\t</Fill>\n\t);\n}\n\n// Top position (in px) of the Block Styles container\n// relative to the editor pane.\n// The value is the equivalent of the container's right position.\nconst DEFAULT_POSITION_TOP = 16;\n\nconst noop = () => {};\n\n// Block Styles component for the Settings Sidebar.\nfunction BlockStyles( {\n\tclientId,\n\tonSwitch = noop,\n\tonHoverClassName = noop,\n\tscope,\n} ) {\n\tconst {\n\t\tonSelect,\n\t\tstylesToRender,\n\t\tactiveStyle,\n\t\tgenericPreviewBlock,\n\t\tclassName: previewClassName,\n\t} = useStylesForBlocks( {\n\t\tclientId,\n\t\tonSwitch,\n\t} );\n\tconst [ hoveredStyle, setHoveredStyle ] = useState( null );\n\tconst [ containerScrollTop, setContainerScrollTop ] = useState( 0 );\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\n\tuseLayoutEffect( () => {\n\t\tconst scrollContainer = document.querySelector(\n\t\t\t'.interface-interface-skeleton__content'\n\t\t);\n\t\tconst scrollTop = scrollContainer?.scrollTop || 0;\n\t\tsetContainerScrollTop( scrollTop + DEFAULT_POSITION_TOP );\n\t}, [ hoveredStyle ] );\n\n\tif ( ! stylesToRender || stylesToRender.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst debouncedSetHoveredStyle = debounce( setHoveredStyle, 250 );\n\n\tconst onSelectStylePreview = ( style ) => {\n\t\tonSelect( style );\n\t\tonHoverClassName( null );\n\t\tsetHoveredStyle( null );\n\t\tdebouncedSetHoveredStyle.cancel();\n\t};\n\n\tconst styleItemHandler = ( item ) => {\n\t\tif ( hoveredStyle === item ) {\n\t\t\tdebouncedSetHoveredStyle.cancel();\n\t\t\treturn;\n\t\t}\n\t\tdebouncedSetHoveredStyle( item );\n\t\tonHoverClassName( item?.name ?? null );\n\t};\n\n\treturn (\n\t\t<div className=\"block-editor-block-styles\">\n\t\t\t<div className=\"block-editor-block-styles__variants\">\n\t\t\t\t{ stylesToRender.map( ( style ) => {\n\t\t\t\t\tconst buttonText = style.label || style.name;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-block-styles__item',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-active':\n\t\t\t\t\t\t\t\t\t\tactiveStyle.name === style.name,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tkey={ style.name }\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tlabel={ buttonText }\n\t\t\t\t\t\t\tonMouseEnter={ () => styleItemHandler( style ) }\n\t\t\t\t\t\t\tonFocus={ () => styleItemHandler( style ) }\n\t\t\t\t\t\t\tonMouseLeave={ () => styleItemHandler( null ) }\n\t\t\t\t\t\t\tonBlur={ () => styleItemHandler( null ) }\n\t\t\t\t\t\t\tonClick={ () => onSelectStylePreview( style ) }\n\t\t\t\t\t\t\taria-current={ activeStyle.name === style.name }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Truncate\n\t\t\t\t\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-styles__item-text\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ buttonText }\n\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t\t{ hoveredStyle && ! isMobileViewport && (\n\t\t\t\t<BlockStylesPreviewPanelFill\n\t\t\t\t\tscope={ scope }\n\t\t\t\t\tclassName=\"block-editor-block-styles__preview-panel\"\n\t\t\t\t\tstyle={ { top: containerScrollTop } }\n\t\t\t\t\tonMouseLeave={ () => styleItemHandler( null ) }\n\t\t\t\t>\n\t\t\t\t\t<BlockStylesPreviewPanel\n\t\t\t\t\t\tactiveStyle={ activeStyle }\n\t\t\t\t\t\tclassName={ previewClassName }\n\t\t\t\t\t\tgenericPreviewBlock={ genericPreviewBlock }\n\t\t\t\t\t\tstyle={ hoveredStyle }\n\t\t\t\t\t/>\n\t\t\t\t</BlockStylesPreviewPanelFill>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nBlockStyles.Slot = BlockStylesPreviewPanelSlot;\nexport default BlockStyles;\n"]}
|
|
@@ -27,14 +27,14 @@ var _useBlockDisplayInformation = _interopRequireDefault(require("../use-block-d
|
|
|
27
27
|
|
|
28
28
|
var _blockIcon = _interopRequireDefault(require("../block-icon"));
|
|
29
29
|
|
|
30
|
-
var _blockTitle = _interopRequireDefault(require("../block-title"));
|
|
31
|
-
|
|
32
30
|
var _blockTransformationsMenu = _interopRequireDefault(require("./block-transformations-menu"));
|
|
33
31
|
|
|
34
32
|
var _blockStylesMenu = _interopRequireDefault(require("./block-styles-menu"));
|
|
35
33
|
|
|
36
34
|
var _patternTransformationsMenu = _interopRequireDefault(require("./pattern-transformations-menu"));
|
|
37
35
|
|
|
36
|
+
var _useBlockDisplayTitle = _interopRequireDefault(require("../block-title/use-block-display-title"));
|
|
37
|
+
|
|
38
38
|
/**
|
|
39
39
|
* External dependencies
|
|
40
40
|
*/
|
|
@@ -60,11 +60,8 @@ const BlockSwitcherDropdownMenu = _ref => {
|
|
|
60
60
|
canRemove,
|
|
61
61
|
hasBlockStyles,
|
|
62
62
|
icon,
|
|
63
|
-
blockTitle,
|
|
64
63
|
patterns
|
|
65
64
|
} = (0, _data.useSelect)(select => {
|
|
66
|
-
var _getBlockType2;
|
|
67
|
-
|
|
68
65
|
const {
|
|
69
66
|
getBlockRootClientId,
|
|
70
67
|
getBlockTransformItems,
|
|
@@ -93,12 +90,12 @@ const BlockSwitcherDropdownMenu = _ref => {
|
|
|
93
90
|
} else {
|
|
94
91
|
var _getBlockType;
|
|
95
92
|
|
|
96
|
-
const isSelectionOfSameType =
|
|
93
|
+
const isSelectionOfSameType = new Set(blocks.map(_ref2 => {
|
|
97
94
|
let {
|
|
98
95
|
name
|
|
99
96
|
} = _ref2;
|
|
100
97
|
return name;
|
|
101
|
-
})).
|
|
98
|
+
})).size === 1; // When selection consists of blocks of multiple types, display an
|
|
102
99
|
// appropriate icon to communicate the non-uniformity.
|
|
103
100
|
|
|
104
101
|
_icon = isSelectionOfSameType ? (_getBlockType = getBlockType(firstBlockName)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.icon : _icons.copy;
|
|
@@ -109,10 +106,13 @@ const BlockSwitcherDropdownMenu = _ref => {
|
|
|
109
106
|
canRemove: canRemoveBlocks(clientIds, rootClientId),
|
|
110
107
|
hasBlockStyles: !!(styles !== null && styles !== void 0 && styles.length),
|
|
111
108
|
icon: _icon,
|
|
112
|
-
blockTitle: (_getBlockType2 = getBlockType(firstBlockName)) === null || _getBlockType2 === void 0 ? void 0 : _getBlockType2.title,
|
|
113
109
|
patterns: __experimentalGetPatternTransformItems(blocks, rootClientId)
|
|
114
110
|
};
|
|
115
111
|
}, [clientIds, blocks, blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon]);
|
|
112
|
+
const blockTitle = (0, _useBlockDisplayTitle.default)({
|
|
113
|
+
clientId: Array.isArray(clientIds) ? clientIds[0] : clientIds,
|
|
114
|
+
maximumLength: 35
|
|
115
|
+
});
|
|
116
116
|
const isReusable = blocks.length === 1 && (0, _blocks.isReusableBlock)(blocks[0]);
|
|
117
117
|
const isTemplate = blocks.length === 1 && (0, _blocks.isTemplatePart)(blocks[0]); // Simple block tranformation based on the `Block Transforms` API.
|
|
118
118
|
|
|
@@ -140,10 +140,7 @@ const BlockSwitcherDropdownMenu = _ref => {
|
|
|
140
140
|
showColors: true
|
|
141
141
|
}), (isReusable || isTemplate) && (0, _element.createElement)("span", {
|
|
142
142
|
className: "block-editor-block-switcher__toggle-text"
|
|
143
|
-
},
|
|
144
|
-
clientId: clientIds,
|
|
145
|
-
maximumLength: 35
|
|
146
|
-
})))
|
|
143
|
+
}, blockTitle))
|
|
147
144
|
}));
|
|
148
145
|
}
|
|
149
146
|
|
|
@@ -168,10 +165,7 @@ const BlockSwitcherDropdownMenu = _ref => {
|
|
|
168
165
|
showColors: true
|
|
169
166
|
}), (isReusable || isTemplate) && (0, _element.createElement)("span", {
|
|
170
167
|
className: "block-editor-block-switcher__toggle-text"
|
|
171
|
-
},
|
|
172
|
-
clientId: clientIds,
|
|
173
|
-
maximumLength: 35
|
|
174
|
-
}))),
|
|
168
|
+
}, blockTitle)),
|
|
175
169
|
toggleProps: {
|
|
176
170
|
describedBy: blockSwitcherDescription,
|
|
177
171
|
...toggleProps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-switcher/index.js"],"names":["BlockSwitcherDropdownMenu","clientIds","blocks","replaceBlocks","blockEditorStore","blockInformation","clientId","possibleBlockTransformations","canRemove","hasBlockStyles","icon","blockTitle","patterns","select","getBlockRootClientId","getBlockTransformItems","__experimentalGetPatternTransformItems","getBlockStyles","getBlockType","blocksStore","canRemoveBlocks","rootClientId","name","firstBlockName","_isSingleBlockSelected","length","styles","_icon","isSelectionOfSameType","map","copy","title","isReusable","isTemplate","onBlockTransform","onPatternTransform","transformedBlocks","hasPossibleBlockTransformations","hasPatternTransformation","blockSwitcherLabel","blockSwitcherDescription","showDropDown","toggleProps","position","isAlternate","className","describedBy","orientation","onClose","BlockSwitcher","getBlocksByClientId","some","block"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAMA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAjCA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;AASO,MAAMA,yBAAyB,GAAG,QAA6B;AAAA,MAA3B;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,GAA2B;AACrE,QAAM;AAAEC,IAAAA;AAAF,MAAoB,uBAAaC,YAAb,CAA1B;AACA,QAAMC,gBAAgB,GAAG,yCAA4BH,MAAM,CAAE,CAAF,CAAN,CAAYI,QAAxC,CAAzB;AACA,QAAM;AACLC,IAAAA,4BADK;AAELC,IAAAA,SAFK;AAGLC,IAAAA,cAHK;AAILC,IAAAA,IAJK;AAKLC,IAAAA,UALK;AAMLC,IAAAA;AANK,MAOF,qBACDC,MAAF,IAAc;AAAA;;AACb,UAAM;AACLC,MAAAA,oBADK;AAELC,MAAAA,sBAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAET,YAAF,CAJV;AAKA,UAAM;AAAEa,MAAAA,cAAF;AAAkBC,MAAAA;AAAlB,QAAmCL,MAAM,CAAEM,aAAF,CAA/C;AACA,UAAM;AAAEC,MAAAA;AAAF,QAAsBP,MAAM,CAAET,YAAF,CAAlC;AACA,UAAMiB,YAAY,GAAGP,oBAAoB,CACxC,uBAAWb,SAAX,EAAwB,CAAxB,CADwC,CAAzC;AAGA,UAAM,CAAE;AAAEqB,MAAAA,IAAI,EAAEC;AAAR,KAAF,IAA+BrB,MAArC;;AACA,UAAMsB,sBAAsB,GAAGtB,M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AA+B,IAChC,4BAAC,iCAAD;AACC,MAAA,SAAS,EAAC,oDADX;AAEC,MAAA,4BAA4B,EAC3B9B,4BAHF;AAKC,MAAA,MAAM,EAAGL,MALV;AAMC,MAAA,QAAQ,EAAKoB,IAAF,IAAY;AACtBY,QAAAA,gBAAgB,CAAEZ,IAAF,CAAhB;AACA0B,QAAAA,OAAO;AACP;AATF,MAhBF,EA4BGvC,cAAc,IACf,4BAAC,wBAAD;AACC,MAAA,YAAY,EAAGP,MAAM,CAAE,CAAF,CADtB;AAEC,MAAA,QAAQ,EAAG8C;AAFZ,MA7BF,CAFA;AAAA,GA/BH,CAFF,CADD,CADD;AA+EA,CAzMM;;;;AA2MA,MAAMC,aAAa,GAAG,SAAqB;AAAA,MAAnB;AAAEhD,IAAAA;AAAF,GAAmB;AACjD,QAAMC,MAAM,GAAG,qBACZW,MAAF,IACCA,MAAM,CAAET,YAAF,CAAN,CAA2B8C,mBAA3B,CAAgDjD,SAAhD,CAFa,EAGd,CAAEA,SAAF,CAHc,CAAf;;AAMA,MAAK,CAAEC,MAAM,CAACuB,MAAT,IAAmBvB,MAAM,CAACiD,IAAP,CAAeC,KAAF,IAAa,CAAEA,KAA5B,CAAxB,EAA8D;AAC7D,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,yBAAD;AAA2B,IAAA,SAAS,EAAGnD,SAAvC;AAAmD,IAAA,MAAM,EAAGC;AAA5D,IADD;AAGA,CAdM;;;eAgBQ+C,a","sourcesContent":["/**\n * External dependencies\n */\nimport { castArray, uniq } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tDropdownMenu,\n\tToolbarButton,\n\tToolbarGroup,\n\tToolbarItem,\n} from '@wordpress/components';\nimport {\n\tswitchToBlockType,\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { copy } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport BlockIcon from '../block-icon';\nimport BlockTitle from '../block-title';\nimport BlockTransformationsMenu from './block-transformations-menu';\nimport BlockStylesMenu from './block-styles-menu';\nimport PatternTransformationsMenu from './pattern-transformations-menu';\n\nexport const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst blockInformation = useBlockDisplayInformation( blocks[ 0 ].clientId );\n\tconst {\n\t\tpossibleBlockTransformations,\n\t\tcanRemove,\n\t\thasBlockStyles,\n\t\ticon,\n\t\tblockTitle,\n\t\tpatterns,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockTransformItems,\n\t\t\t\t__experimentalGetPatternTransformItems,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockStyles, getBlockType } = select( blocksStore );\n\t\t\tconst { canRemoveBlocks } = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId(\n\t\t\t\tcastArray( clientIds )[ 0 ]\n\t\t\t);\n\t\t\tconst [ { name: firstBlockName } ] = blocks;\n\t\t\tconst _isSingleBlockSelected = blocks.length === 1;\n\t\t\tconst styles =\n\t\t\t\t_isSingleBlockSelected && getBlockStyles( firstBlockName );\n\t\t\tlet _icon;\n\t\t\tif ( _isSingleBlockSelected ) {\n\t\t\t\t_icon = blockInformation?.icon; // Take into account active block variations.\n\t\t\t} else {\n\t\t\t\tconst isSelectionOfSameType =\n\t\t\t\t\tuniq( blocks.map( ( { name } ) => name ) ).length === 1;\n\t\t\t\t// When selection consists of blocks of multiple types, display an\n\t\t\t\t// appropriate icon to communicate the non-uniformity.\n\t\t\t\t_icon = isSelectionOfSameType\n\t\t\t\t\t? getBlockType( firstBlockName )?.icon\n\t\t\t\t\t: copy;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpossibleBlockTransformations: getBlockTransformItems(\n\t\t\t\t\tblocks,\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tcanRemove: canRemoveBlocks( clientIds, rootClientId ),\n\t\t\t\thasBlockStyles: !! styles?.length,\n\t\t\t\ticon: _icon,\n\t\t\t\tblockTitle: getBlockType( firstBlockName )?.title,\n\t\t\t\tpatterns: __experimentalGetPatternTransformItems(\n\t\t\t\t\tblocks,\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientIds, blocks, blockInformation?.icon ]\n\t);\n\n\tconst isReusable = blocks.length === 1 && isReusableBlock( blocks[ 0 ] );\n\tconst isTemplate = blocks.length === 1 && isTemplatePart( blocks[ 0 ] );\n\n\t// Simple block tranformation based on the `Block Transforms` API.\n\tconst onBlockTransform = ( name ) =>\n\t\treplaceBlocks( clientIds, switchToBlockType( blocks, name ) );\n\t// Pattern transformation through the `Patterns` API.\n\tconst onPatternTransform = ( transformedBlocks ) =>\n\t\treplaceBlocks( clientIds, transformedBlocks );\n\n\t/**\n\t * The `isTemplate` check is a stopgap solution here.\n\t * Ideally, the Transforms API should handle this\n\t * by allowing to exclude blocks from wildcard transformations.\n\t */\n\tconst hasPossibleBlockTransformations =\n\t\t!! possibleBlockTransformations.length && canRemove && ! isTemplate;\n\tconst hasPatternTransformation = !! patterns?.length && canRemove;\n\tif ( ! hasBlockStyles && ! hasPossibleBlockTransformations ) {\n\t\treturn (\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tdisabled\n\t\t\t\t\tclassName=\"block-editor-block-switcher__no-switcher-icon\"\n\t\t\t\t\ttitle={ blockTitle }\n\t\t\t\t\ticon={\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<BlockIcon icon={ icon } showColors />\n\t\t\t\t\t\t\t{ ( isReusable || isTemplate ) && (\n\t\t\t\t\t\t\t\t<span className=\"block-editor-block-switcher__toggle-text\">\n\t\t\t\t\t\t\t\t\t<BlockTitle\n\t\t\t\t\t\t\t\t\t\tclientId={ clientIds }\n\t\t\t\t\t\t\t\t\t\tmaximumLength={ 35 }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</span>\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/>\n\t\t\t</ToolbarGroup>\n\t\t);\n\t}\n\n\tconst blockSwitcherLabel = blockTitle;\n\n\tconst blockSwitcherDescription =\n\t\t1 === blocks.length\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: block title. */\n\t\t\t\t\t__( '%s: Change block type or style' ),\n\t\t\t\t\tblockTitle\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t/* translators: %d: number of blocks. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'Change type of %d block',\n\t\t\t\t\t\t'Change type of %d blocks',\n\t\t\t\t\t\tblocks.length\n\t\t\t\t\t),\n\t\t\t\t\tblocks.length\n\t\t\t );\n\n\tconst showDropDown =\n\t\thasBlockStyles ||\n\t\thasPossibleBlockTransformations ||\n\t\thasPatternTransformation;\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarItem>\n\t\t\t\t{ ( toggleProps ) => (\n\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\tclassName=\"block-editor-block-switcher\"\n\t\t\t\t\t\tlabel={ blockSwitcherLabel }\n\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\tposition: 'bottom right',\n\t\t\t\t\t\t\tisAlternate: true,\n\t\t\t\t\t\t\tclassName: 'block-editor-block-switcher__popover',\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-switcher__toggle\"\n\t\t\t\t\t\t\t\t\tshowColors\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ ( isReusable || isTemplate ) && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-block-switcher__toggle-text\">\n\t\t\t\t\t\t\t\t\t\t<BlockTitle\n\t\t\t\t\t\t\t\t\t\t\tclientId={ clientIds }\n\t\t\t\t\t\t\t\t\t\t\tmaximumLength={ 35 }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</span>\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\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\tdescribedBy: blockSwitcherDescription,\n\t\t\t\t\t\t\t...toggleProps,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tmenuProps={ { orientation: 'both' } }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ( { onClose } ) =>\n\t\t\t\t\t\t\tshowDropDown && (\n\t\t\t\t\t\t\t\t<div className=\"block-editor-block-switcher__container\">\n\t\t\t\t\t\t\t\t\t{ hasPatternTransformation && (\n\t\t\t\t\t\t\t\t\t\t<PatternTransformationsMenu\n\t\t\t\t\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\t\t\t\t\tpatterns={ patterns }\n\t\t\t\t\t\t\t\t\t\t\tonSelect={ (\n\t\t\t\t\t\t\t\t\t\t\t\ttransformedBlocks\n\t\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\t\tonPatternTransform(\n\t\t\t\t\t\t\t\t\t\t\t\t\ttransformedBlocks\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\tonClose();\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) }\n\t\t\t\t\t\t\t\t\t{ hasPossibleBlockTransformations && (\n\t\t\t\t\t\t\t\t\t\t<BlockTransformationsMenu\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-switcher__transforms__menugroup\"\n\t\t\t\t\t\t\t\t\t\t\tpossibleBlockTransformations={\n\t\t\t\t\t\t\t\t\t\t\t\tpossibleBlockTransformations\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\t\t\t\t\tonSelect={ ( name ) => {\n\t\t\t\t\t\t\t\t\t\t\t\tonBlockTransform( name );\n\t\t\t\t\t\t\t\t\t\t\t\tonClose();\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) }\n\t\t\t\t\t\t\t\t\t{ hasBlockStyles && (\n\t\t\t\t\t\t\t\t\t\t<BlockStylesMenu\n\t\t\t\t\t\t\t\t\t\t\thoveredBlock={ blocks[ 0 ] }\n\t\t\t\t\t\t\t\t\t\t\tonSwitch={ onClose }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t</DropdownMenu>\n\t\t\t\t) }\n\t\t\t</ToolbarItem>\n\t\t</ToolbarGroup>\n\t);\n};\n\nexport const BlockSwitcher = ( { clientIds } ) => {\n\tconst blocks = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlocksByClientId( clientIds ),\n\t\t[ clientIds ]\n\t);\n\n\tif ( ! blocks.length || blocks.some( ( block ) => ! block ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockSwitcherDropdownMenu clientIds={ clientIds } blocks={ blocks } />\n\t);\n};\n\nexport default BlockSwitcher;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-switcher/index.js"],"names":["BlockSwitcherDropdownMenu","clientIds","blocks","replaceBlocks","blockEditorStore","blockInformation","clientId","possibleBlockTransformations","canRemove","hasBlockStyles","icon","patterns","select","getBlockRootClientId","getBlockTransformItems","__experimentalGetPatternTransformItems","getBlockStyles","getBlockType","blocksStore","canRemoveBlocks","rootClientId","name","firstBlockName","_isSingleBlockSelected","length","styles","_icon","isSelectionOfSameType","Set","map","size","copy","blockTitle","Array","isArray","maximumLength","isReusable","isTemplate","onBlockTransform","onPatternTransform","transformedBlocks","hasPossibleBlockTransformations","hasPatternTransformation","blockSwitcherLabel","blockSwitcherDescription","showDropDown","toggleProps","position","isAlternate","className","describedBy","orientation","onClose","BlockSwitcher","getBlocksByClientId","some","block"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAMA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAjCA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;AASO,MAAMA,yBAAyB,GAAG,QAA6B;AAAA,MAA3B;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,GAA2B;AACrE,QAAM;AAAEC,IAAAA;AAAF,MAAoB,uBAAaC,YAAb,CAA1B;AACA,QAAMC,gBAAgB,GAAG,yCAA4BH,MAAM,CAAE,CAAF,CAAN,CAAYI,QAAxC,CAAzB;AACA,QAAM;AACLC,IAAAA,4BADK;AAELC,IAAAA,SAFK;AAGLC,IAAAA,cAHK;AAILC,IAAAA,IAJK;AAKLC,IAAAA;AALK,MAMF,qBACDC,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,oBADK;AAELC,MAAAA,sBAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAER,YAAF,CAJV;AAKA,UAAM;AAAEY,MAAAA,cAAF;AAAkBC,MAAAA;AAAlB,QAAmCL,MAAM,CAAEM,aAAF,CAA/C;AACA,UAAM;AAAEC,MAAAA;AAAF,QAAsBP,MAAM,CAAER,YAAF,CAAlC;AACA,UAAMgB,YAAY,GAAGP,oBAAoB,CACxC,uBAAWZ,SAAX,EAAwB,CAAxB,CADwC,CAAzC;A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BAAkB,CACjBC,iBADiB,CAAlB;AAGAY,QAAAA,OAAO;AACP;AAVF,MAFF,EAeGX,+BAA+B,IAChC,4BAAC,iCAAD;AACC,MAAA,SAAS,EAAC,oDADX;AAEC,MAAA,4BAA4B,EAC3BlC,4BAHF;AAKC,MAAA,MAAM,EAAGL,MALV;AAMC,MAAA,QAAQ,EAAKmB,IAAF,IAAY;AACtBiB,QAAAA,gBAAgB,CAAEjB,IAAF,CAAhB;AACA+B,QAAAA,OAAO;AACP;AATF,MAhBF,EA4BG3C,cAAc,IACf,4BAAC,wBAAD;AACC,MAAA,YAAY,EAAGP,MAAM,CAAE,CAAF,CADtB;AAEC,MAAA,QAAQ,EAAGkD;AAFZ,MA7BF,CAFA;AAAA,GA5BH,CAFF,CADD,CADD;AA4EA,CArMM;;;;AAuMA,MAAMC,aAAa,GAAG,SAAqB;AAAA,MAAnB;AAAEpD,IAAAA;AAAF,GAAmB;AACjD,QAAMC,MAAM,GAAG,qBACZU,MAAF,IACCA,MAAM,CAAER,YAAF,CAAN,CAA2BkD,mBAA3B,CAAgDrD,SAAhD,CAFa,EAGd,CAAEA,SAAF,CAHc,CAAf;;AAMA,MAAK,CAAEC,MAAM,CAACsB,MAAT,IAAmBtB,MAAM,CAACqD,IAAP,CAAeC,KAAF,IAAa,CAAEA,KAA5B,CAAxB,EAA8D;AAC7D,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,yBAAD;AAA2B,IAAA,SAAS,EAAGvD,SAAvC;AAAmD,IAAA,MAAM,EAAGC;AAA5D,IADD;AAGA,CAdM;;;eAgBQmD,a","sourcesContent":["/**\n * External dependencies\n */\nimport { castArray } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tDropdownMenu,\n\tToolbarButton,\n\tToolbarGroup,\n\tToolbarItem,\n} from '@wordpress/components';\nimport {\n\tswitchToBlockType,\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { copy } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport BlockIcon from '../block-icon';\nimport BlockTransformationsMenu from './block-transformations-menu';\nimport BlockStylesMenu from './block-styles-menu';\nimport PatternTransformationsMenu from './pattern-transformations-menu';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\n\nexport const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst blockInformation = useBlockDisplayInformation( blocks[ 0 ].clientId );\n\tconst {\n\t\tpossibleBlockTransformations,\n\t\tcanRemove,\n\t\thasBlockStyles,\n\t\ticon,\n\t\tpatterns,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockTransformItems,\n\t\t\t\t__experimentalGetPatternTransformItems,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockStyles, getBlockType } = select( blocksStore );\n\t\t\tconst { canRemoveBlocks } = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId(\n\t\t\t\tcastArray( clientIds )[ 0 ]\n\t\t\t);\n\t\t\tconst [ { name: firstBlockName } ] = blocks;\n\t\t\tconst _isSingleBlockSelected = blocks.length === 1;\n\t\t\tconst styles =\n\t\t\t\t_isSingleBlockSelected && getBlockStyles( firstBlockName );\n\t\t\tlet _icon;\n\t\t\tif ( _isSingleBlockSelected ) {\n\t\t\t\t_icon = blockInformation?.icon; // Take into account active block variations.\n\t\t\t} else {\n\t\t\t\tconst isSelectionOfSameType =\n\t\t\t\t\tnew Set( blocks.map( ( { name } ) => name ) ).size === 1;\n\t\t\t\t// When selection consists of blocks of multiple types, display an\n\t\t\t\t// appropriate icon to communicate the non-uniformity.\n\t\t\t\t_icon = isSelectionOfSameType\n\t\t\t\t\t? getBlockType( firstBlockName )?.icon\n\t\t\t\t\t: copy;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpossibleBlockTransformations: getBlockTransformItems(\n\t\t\t\t\tblocks,\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tcanRemove: canRemoveBlocks( clientIds, rootClientId ),\n\t\t\t\thasBlockStyles: !! styles?.length,\n\t\t\t\ticon: _icon,\n\t\t\t\tpatterns: __experimentalGetPatternTransformItems(\n\t\t\t\t\tblocks,\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientIds, blocks, blockInformation?.icon ]\n\t);\n\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId: Array.isArray( clientIds ) ? clientIds[ 0 ] : clientIds,\n\t\tmaximumLength: 35,\n\t} );\n\tconst isReusable = blocks.length === 1 && isReusableBlock( blocks[ 0 ] );\n\tconst isTemplate = blocks.length === 1 && isTemplatePart( blocks[ 0 ] );\n\n\t// Simple block tranformation based on the `Block Transforms` API.\n\tconst onBlockTransform = ( name ) =>\n\t\treplaceBlocks( clientIds, switchToBlockType( blocks, name ) );\n\t// Pattern transformation through the `Patterns` API.\n\tconst onPatternTransform = ( transformedBlocks ) =>\n\t\treplaceBlocks( clientIds, transformedBlocks );\n\n\t/**\n\t * The `isTemplate` check is a stopgap solution here.\n\t * Ideally, the Transforms API should handle this\n\t * by allowing to exclude blocks from wildcard transformations.\n\t */\n\tconst hasPossibleBlockTransformations =\n\t\t!! possibleBlockTransformations.length && canRemove && ! isTemplate;\n\tconst hasPatternTransformation = !! patterns?.length && canRemove;\n\tif ( ! hasBlockStyles && ! hasPossibleBlockTransformations ) {\n\t\treturn (\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tdisabled\n\t\t\t\t\tclassName=\"block-editor-block-switcher__no-switcher-icon\"\n\t\t\t\t\ttitle={ blockTitle }\n\t\t\t\t\ticon={\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<BlockIcon icon={ icon } showColors />\n\t\t\t\t\t\t\t{ ( isReusable || isTemplate ) && (\n\t\t\t\t\t\t\t\t<span className=\"block-editor-block-switcher__toggle-text\">\n\t\t\t\t\t\t\t\t\t{ blockTitle }\n\t\t\t\t\t\t\t\t</span>\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/>\n\t\t\t</ToolbarGroup>\n\t\t);\n\t}\n\n\tconst blockSwitcherLabel = blockTitle;\n\n\tconst blockSwitcherDescription =\n\t\t1 === blocks.length\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: block title. */\n\t\t\t\t\t__( '%s: Change block type or style' ),\n\t\t\t\t\tblockTitle\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t/* translators: %d: number of blocks. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'Change type of %d block',\n\t\t\t\t\t\t'Change type of %d blocks',\n\t\t\t\t\t\tblocks.length\n\t\t\t\t\t),\n\t\t\t\t\tblocks.length\n\t\t\t );\n\n\tconst showDropDown =\n\t\thasBlockStyles ||\n\t\thasPossibleBlockTransformations ||\n\t\thasPatternTransformation;\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarItem>\n\t\t\t\t{ ( toggleProps ) => (\n\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\tclassName=\"block-editor-block-switcher\"\n\t\t\t\t\t\tlabel={ blockSwitcherLabel }\n\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\tposition: 'bottom right',\n\t\t\t\t\t\t\tisAlternate: true,\n\t\t\t\t\t\t\tclassName: 'block-editor-block-switcher__popover',\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-switcher__toggle\"\n\t\t\t\t\t\t\t\t\tshowColors\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ ( isReusable || isTemplate ) && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-block-switcher__toggle-text\">\n\t\t\t\t\t\t\t\t\t\t{ blockTitle }\n\t\t\t\t\t\t\t\t\t</span>\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\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\tdescribedBy: blockSwitcherDescription,\n\t\t\t\t\t\t\t...toggleProps,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tmenuProps={ { orientation: 'both' } }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ( { onClose } ) =>\n\t\t\t\t\t\t\tshowDropDown && (\n\t\t\t\t\t\t\t\t<div className=\"block-editor-block-switcher__container\">\n\t\t\t\t\t\t\t\t\t{ hasPatternTransformation && (\n\t\t\t\t\t\t\t\t\t\t<PatternTransformationsMenu\n\t\t\t\t\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\t\t\t\t\tpatterns={ patterns }\n\t\t\t\t\t\t\t\t\t\t\tonSelect={ (\n\t\t\t\t\t\t\t\t\t\t\t\ttransformedBlocks\n\t\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\t\tonPatternTransform(\n\t\t\t\t\t\t\t\t\t\t\t\t\ttransformedBlocks\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\tonClose();\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) }\n\t\t\t\t\t\t\t\t\t{ hasPossibleBlockTransformations && (\n\t\t\t\t\t\t\t\t\t\t<BlockTransformationsMenu\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-switcher__transforms__menugroup\"\n\t\t\t\t\t\t\t\t\t\t\tpossibleBlockTransformations={\n\t\t\t\t\t\t\t\t\t\t\t\tpossibleBlockTransformations\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\t\t\t\t\tonSelect={ ( name ) => {\n\t\t\t\t\t\t\t\t\t\t\t\tonBlockTransform( name );\n\t\t\t\t\t\t\t\t\t\t\t\tonClose();\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) }\n\t\t\t\t\t\t\t\t\t{ hasBlockStyles && (\n\t\t\t\t\t\t\t\t\t\t<BlockStylesMenu\n\t\t\t\t\t\t\t\t\t\t\thoveredBlock={ blocks[ 0 ] }\n\t\t\t\t\t\t\t\t\t\t\tonSwitch={ onClose }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t</DropdownMenu>\n\t\t\t\t) }\n\t\t\t</ToolbarItem>\n\t\t</ToolbarGroup>\n\t);\n};\n\nexport const BlockSwitcher = ( { clientIds } ) => {\n\tconst blocks = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlocksByClientId( clientIds ),\n\t\t[ clientIds ]\n\t);\n\n\tif ( ! blocks.length || blocks.some( ( block ) => ! block ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockSwitcherDropdownMenu clientIds={ clientIds } blocks={ blocks } />\n\t);\n};\n\nexport default BlockSwitcher;\n"]}
|
|
@@ -37,6 +37,8 @@ var _blockLock = require("../block-lock");
|
|
|
37
37
|
|
|
38
38
|
var _convertToGroupButtons = require("../convert-to-group-buttons");
|
|
39
39
|
|
|
40
|
+
var _blockEditVisuallyButton = _interopRequireDefault(require("../block-edit-visually-button"));
|
|
41
|
+
|
|
40
42
|
var _utils = require("./utils");
|
|
41
43
|
|
|
42
44
|
var _store = require("../../store");
|
|
@@ -161,7 +163,9 @@ const BlockToolbar = _ref => {
|
|
|
161
163
|
className: "block-editor-block-toolbar__slot"
|
|
162
164
|
}), (0, _element.createElement)(_blockNameContext.default.Provider, {
|
|
163
165
|
value: blockType === null || blockType === void 0 ? void 0 : blockType.name
|
|
164
|
-
}, (0, _element.createElement)(_blockToolbarLastItem.default.Slot, null))), (0, _element.createElement)(
|
|
166
|
+
}, (0, _element.createElement)(_blockToolbarLastItem.default.Slot, null))), (0, _element.createElement)(_blockEditVisuallyButton.default, {
|
|
167
|
+
clientIds: blockClientIds
|
|
168
|
+
}), (0, _element.createElement)(_blockSettingsMenu.default, {
|
|
165
169
|
clientIds: blockClientIds
|
|
166
170
|
}));
|
|
167
171
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-toolbar/index.js"],"names":["BlockToolbar","hideDragHandle","blockClientIds","blockClientId","blockType","hasFixedToolbar","hasReducedUI","isValid","isVisual","select","getBlockName","getBlockMode","getSelectedBlockClientIds","isBlockValid","getBlockRootClientId","getSettings","blockEditorStore","selectedBlockClientIds","selectedBlockClientId","blockRootClientId","settings","rootClientId","every","id","toggleBlockHighlight","nodeRef","showMovers","gestures","showMoversGestures","ref","onChange","isFocused","displayHeaderToolbar","shouldShowMovers","length","shouldShowVisualToolbar","isMultiToolbar","classes","name"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-toolbar/index.js"],"names":["BlockToolbar","hideDragHandle","blockClientIds","blockClientId","blockType","hasFixedToolbar","hasReducedUI","isValid","isVisual","select","getBlockName","getBlockMode","getSelectedBlockClientIds","isBlockValid","getBlockRootClientId","getSettings","blockEditorStore","selectedBlockClientIds","selectedBlockClientId","blockRootClientId","settings","rootClientId","every","id","toggleBlockHighlight","nodeRef","showMovers","gestures","showMoversGestures","ref","onChange","isFocused","displayHeaderToolbar","shouldShowMovers","length","shouldShowVisualToolbar","isMultiToolbar","classes","name"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA5BA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AAcA,MAAMA,YAAY,GAAG,QAA0B;AAAA,MAAxB;AAAEC,IAAAA;AAAF,GAAwB;AAC9C,QAAM;AACLC,IAAAA,cADK;AAELC,IAAAA,aAFK;AAGLC,IAAAA,SAHK;AAILC,IAAAA,eAJK;AAKLC,IAAAA,YALK;AAMLC,IAAAA,OANK;AAOLC,IAAAA;AAPK,MAQF,qBAAaC,MAAF,IAAc;AAC5B,UAAM;AACLC,MAAAA,YADK;AAELC,MAAAA,YAFK;AAGLC,MAAAA,yBAHK;AAILC,MAAAA,YAJK;AAKLC,MAAAA,oBALK;AAMLC,MAAAA;AANK,QAOFN,MAAM,CAAEO,YAAF,CAPV;AAQA,UAAMC,sBAAsB,GAAGL,yBAAyB,EAAxD;AACA,UAAMM,qBAAqB,GAAGD,sBAAsB,CAAE,CAAF,CAApD;AACA,UAAME,iBAAiB,GAAGL,oBAAoB,CAAEI,qBAAF,CAA9C;AACA,UAAME,QAAQ,GAAGL,WAAW,EAA5B;AAEA,WAAO;AACNb,MAAAA,cAAc,EAAEe,sBADV;AAENd,MAAAA,aAAa,EAAEe,qBAFT;AAGNd,MAAAA,SAAS,EACRc,qBAAqB,IACrB,0BAAcR,YAAY,CAAEQ,qBAAF,CAA1B,CALK;AAMNb,MAAAA,eAAe,EAAEe,QAAQ,CAACf,eANpB;AAONC,MAAAA,YAAY,EAAEc,QAAQ,CAACd,YAPjB;AAQNe,MAAAA,YAAY,EAAEF,iBARR;AASNZ,MAA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,gCAAD;AAAyB,IAAA,SAAS,EAAGpC;AAArC,IAjDD,EAkDC,4BAAC,0BAAD;AAAmB,IAAA,SAAS,EAAGA;AAA/B,IAlDD,CADD;AAsDA,CAxID;AA0IA;AACA;AACA;;;eACeF,Y","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { getBlockType, hasBlockSupport } from '@wordpress/blocks';\nimport { ToolbarGroup } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockMover from '../block-mover';\nimport BlockParentSelector from '../block-parent-selector';\nimport BlockSwitcher from '../block-switcher';\nimport BlockControls from '../block-controls';\nimport __unstableBlockToolbarLastItem from './block-toolbar-last-item';\nimport BlockSettingsMenu from '../block-settings-menu';\nimport { BlockLockToolbar } from '../block-lock';\nimport { BlockGroupToolbar } from '../convert-to-group-buttons';\nimport BlockEditVisuallyButton from '../block-edit-visually-button';\nimport { useShowMoversGestures } from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport __unstableBlockNameContext from './block-name-context';\n\nconst BlockToolbar = ( { hideDragHandle } ) => {\n\tconst {\n\t\tblockClientIds,\n\t\tblockClientId,\n\t\tblockType,\n\t\thasFixedToolbar,\n\t\thasReducedUI,\n\t\tisValid,\n\t\tisVisual,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockName,\n\t\t\tgetBlockMode,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tisBlockValid,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetSettings,\n\t\t} = select( blockEditorStore );\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst selectedBlockClientId = selectedBlockClientIds[ 0 ];\n\t\tconst blockRootClientId = getBlockRootClientId( selectedBlockClientId );\n\t\tconst settings = getSettings();\n\n\t\treturn {\n\t\t\tblockClientIds: selectedBlockClientIds,\n\t\t\tblockClientId: selectedBlockClientId,\n\t\t\tblockType:\n\t\t\t\tselectedBlockClientId &&\n\t\t\t\tgetBlockType( getBlockName( selectedBlockClientId ) ),\n\t\t\thasFixedToolbar: settings.hasFixedToolbar,\n\t\t\thasReducedUI: settings.hasReducedUI,\n\t\t\trootClientId: blockRootClientId,\n\t\t\tisValid: selectedBlockClientIds.every( ( id ) =>\n\t\t\t\tisBlockValid( id )\n\t\t\t),\n\t\t\tisVisual: selectedBlockClientIds.every(\n\t\t\t\t( id ) => getBlockMode( id ) === 'visual'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\t// Handles highlighting the current block outline on hover or focus of the\n\t// block type toolbar area.\n\tconst { toggleBlockHighlight } = useDispatch( blockEditorStore );\n\tconst nodeRef = useRef();\n\tconst { showMovers, gestures: showMoversGestures } = useShowMoversGestures(\n\t\t{\n\t\t\tref: nodeRef,\n\t\t\tonChange( isFocused ) {\n\t\t\t\tif ( isFocused && hasReducedUI ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttoggleBlockHighlight( blockClientId, isFocused );\n\t\t\t},\n\t\t}\n\t);\n\n\t// Account for the cases where the block toolbar is rendered within the\n\t// header area and not contextually to the block.\n\tconst displayHeaderToolbar =\n\t\tuseViewportMatch( 'medium', '<' ) || hasFixedToolbar;\n\n\tif ( blockType ) {\n\t\tif ( ! hasBlockSupport( blockType, '__experimentalToolbar', true ) ) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tconst shouldShowMovers = displayHeaderToolbar || showMovers;\n\n\tif ( blockClientIds.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst shouldShowVisualToolbar = isValid && isVisual;\n\tconst isMultiToolbar = blockClientIds.length > 1;\n\n\tconst classes = classnames(\n\t\t'block-editor-block-toolbar',\n\t\tshouldShowMovers && 'is-showing-movers'\n\t);\n\n\treturn (\n\t\t<div className={ classes }>\n\t\t\t{ ! isMultiToolbar && ! displayHeaderToolbar && (\n\t\t\t\t<BlockParentSelector clientIds={ blockClientIds } />\n\t\t\t) }\n\t\t\t<div ref={ nodeRef } { ...showMoversGestures }>\n\t\t\t\t{ ( shouldShowVisualToolbar || isMultiToolbar ) && (\n\t\t\t\t\t<ToolbarGroup className=\"block-editor-block-toolbar__block-controls\">\n\t\t\t\t\t\t<BlockSwitcher clientIds={ blockClientIds } />\n\t\t\t\t\t\t{ ! isMultiToolbar && (\n\t\t\t\t\t\t\t<BlockLockToolbar\n\t\t\t\t\t\t\t\tclientId={ blockClientIds[ 0 ] }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<BlockMover\n\t\t\t\t\t\t\tclientIds={ blockClientIds }\n\t\t\t\t\t\t\thideDragHandle={ hideDragHandle || hasReducedUI }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ shouldShowVisualToolbar && isMultiToolbar && (\n\t\t\t\t<BlockGroupToolbar />\n\t\t\t) }\n\t\t\t{ shouldShowVisualToolbar && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\tgroup=\"parent\"\n\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\tgroup=\"block\"\n\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockControls.Slot className=\"block-editor-block-toolbar__slot\" />\n\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\tgroup=\"inline\"\n\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\tgroup=\"other\"\n\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t/>\n\t\t\t\t\t<__unstableBlockNameContext.Provider\n\t\t\t\t\t\tvalue={ blockType?.name }\n\t\t\t\t\t>\n\t\t\t\t\t\t<__unstableBlockToolbarLastItem.Slot />\n\t\t\t\t\t</__unstableBlockNameContext.Provider>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<BlockEditVisuallyButton clientIds={ blockClientIds } />\n\t\t\t<BlockSettingsMenu clientIds={ blockClientIds } />\n\t\t</div>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md\n */\nexport default BlockToolbar;\n"]}
|
|
@@ -9,6 +9,8 @@ exports.default = WrappedBlockPopover;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
12
14
|
var _lodash = require("lodash");
|
|
13
15
|
|
|
14
16
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
@@ -29,6 +31,8 @@ var _store = require("../../store");
|
|
|
29
31
|
|
|
30
32
|
var _blockPopover = _interopRequireDefault(require("../block-popover"));
|
|
31
33
|
|
|
34
|
+
var _useBlockToolbarPopoverProps = _interopRequireDefault(require("./use-block-toolbar-popover-props"));
|
|
35
|
+
|
|
32
36
|
/**
|
|
33
37
|
* External dependencies
|
|
34
38
|
*/
|
|
@@ -110,12 +114,16 @@ function SelectedBlockPopover(_ref) {
|
|
|
110
114
|
// to it when re-mounting.
|
|
111
115
|
|
|
112
116
|
const initialToolbarItemIndexRef = (0, _element.useRef)();
|
|
117
|
+
const popoverProps = (0, _useBlockToolbarPopoverProps.default)({
|
|
118
|
+
contentElement: __unstableContentRef === null || __unstableContentRef === void 0 ? void 0 : __unstableContentRef.current,
|
|
119
|
+
clientId
|
|
120
|
+
});
|
|
113
121
|
|
|
114
122
|
if (!shouldShowBreadcrumb && !shouldShowContextualToolbar) {
|
|
115
123
|
return null;
|
|
116
124
|
}
|
|
117
125
|
|
|
118
|
-
return (0, _element.createElement)(_blockPopover.default, {
|
|
126
|
+
return (0, _element.createElement)(_blockPopover.default, (0, _extends2.default)({
|
|
119
127
|
clientId: capturingClientId || clientId,
|
|
120
128
|
bottomClientId: lastClientId,
|
|
121
129
|
className: (0, _classnames.default)('block-editor-block-list__block-popover', {
|
|
@@ -123,7 +131,7 @@ function SelectedBlockPopover(_ref) {
|
|
|
123
131
|
}),
|
|
124
132
|
__unstablePopoverSlot: __unstablePopoverSlot,
|
|
125
133
|
__unstableContentRef: __unstableContentRef
|
|
126
|
-
}, shouldShowContextualToolbar && (0, _element.createElement)(_blockContextualToolbar.default // If the toolbar is being shown because of being forced
|
|
134
|
+
}, popoverProps), shouldShowContextualToolbar && (0, _element.createElement)(_blockContextualToolbar.default // If the toolbar is being shown because of being forced
|
|
127
135
|
// it should focus the toolbar right after the mount.
|
|
128
136
|
, {
|
|
129
137
|
focusOnMount: isToolbarForced.current,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/selected-block-popover.js"],"names":["selector","select","isNavigationMode","isMultiSelecting","hasMultiSelection","isTyping","getSettings","getLastMultiSelectedBlockClientId","blockEditorStore","hasFixedToolbar","lastClientId","SelectedBlockPopover","clientId","rootClientId","isEmptyDefaultBlock","capturingClientId","__unstablePopoverSlot","__unstableContentRef","isInsertionPointVisible","isBlockInsertionPointVisible","getBlockInsertionPoint","getBlockOrder","insertionPoint","order","index","isLargeViewport","isToolbarForced","stopTyping","showEmptyBlockSideInserter","shouldShowBreadcrumb","shouldShowContextualToolbar","canFocusHiddenToolbar","current","isDisabled","initialToolbarItemIndexRef","wrapperSelector","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlockRootClientId","getBlock","getBlockParents","__experimentalGetBlockListSettingsForBlocks","name","attributes","blockParentsClientIds","parentBlockListSettings","parentClientId","__experimentalCaptureToolbars","WrappedBlockPopover","selected"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAMA;;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IAAAA,QADM;AAENC,IAAAA,YAAY,EAAEyB,oBAAoB,CAAE1B,QAAF,CAF5B;AAGN8B,IAAAA,IAHM;AAIN5B,IAAAA,mBAAmB,EAClB4B,IAAI,IAAI,sCAA0B;AAAEA,MAAAA,IAAF;AAAQC,MAAAA;AAAR,KAA1B,CALH;AAMN5B,IAAAA;AANM,GAAP;AAQA;;AAEc,SAASiC,mBAAT,QAGX;AAAA,MAHyC;AAC5ChC,IAAAA,qBAD4C;AAE5CC,IAAAA;AAF4C,GAGzC;AACH,QAAMgC,QAAQ,GAAG,qBAAWd,eAAX,EAA4B,EAA5B,CAAjB;;AAEA,MAAK,CAAEc,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,QAAM;AACLrC,IAAAA,QADK;AAELC,IAAAA,YAFK;AAGL6B,IAAAA,IAHK;AAIL5B,IAAAA,mBAJK;AAKLC,IAAAA;AALK,MAMFkC,QANJ;;AAQA,MAAK,CAAEP,IAAP,EAAc;AACb,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,oBAAD;AACC,IAAA,QAAQ,EAAG9B,QADZ;AAEC,IAAA,YAAY,EAAGC,YAFhB;AAGC,IAAA,mBAAmB,EAAGC,mBAHvB;AAIC,IAAA,iBAAiB,EAAGC,iBAJrB;AAKC,IAAA,qBAAqB,EAAGC,qBALzB;AAMC,IAAA,oBAAoB,EAAGC;AANxB,IADD;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockSelectionButton from './block-selection-button';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopover from '../block-popover';\n\nfunction selector( select ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\thasMultiSelection,\n\t\tisTyping,\n\t\tgetSettings,\n\t\tgetLastMultiSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\treturn {\n\t\tisNavigationMode: isNavigationMode(),\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tisTyping: isTyping(),\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tlastClientId: hasMultiSelection()\n\t\t\t? getLastMultiSelectedBlockClientId()\n\t\t\t: null,\n\t};\n}\n\nfunction SelectedBlockPopover( {\n\tclientId,\n\trootClientId,\n\tisEmptyDefaultBlock,\n\tcapturingClientId,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\tisTyping,\n\t\thasFixedToolbar,\n\t\tlastClientId,\n\t} = useSelect( selector, [] );\n\tconst isInsertionPointVisible = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tif ( ! isBlockInsertionPointVisible() ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\t\t\treturn order[ insertionPoint.index ] === clientId;\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isToolbarForced = useRef( false );\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\tconst showEmptyBlockSideInserter =\n\t\t! isTyping && ! isNavigationMode && isEmptyDefaultBlock;\n\tconst shouldShowBreadcrumb = isNavigationMode;\n\tconst shouldShowContextualToolbar =\n\t\t! isNavigationMode &&\n\t\t! hasFixedToolbar &&\n\t\tisLargeViewport &&\n\t\t! isMultiSelecting &&\n\t\t! showEmptyBlockSideInserter &&\n\t\t! isTyping;\n\tconst canFocusHiddenToolbar =\n\t\t! isNavigationMode &&\n\t\t! shouldShowContextualToolbar &&\n\t\t! hasFixedToolbar &&\n\t\t! isEmptyDefaultBlock;\n\n\tuseShortcut(\n\t\t'core/block-editor/focus-toolbar',\n\t\t() => {\n\t\t\tisToolbarForced.current = true;\n\t\t\tstopTyping( true );\n\t\t},\n\t\t{\n\t\t\tisDisabled: ! canFocusHiddenToolbar,\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tisToolbarForced.current = false;\n\t} );\n\n\t// Stores the active toolbar item index so the block toolbar can return focus\n\t// to it when re-mounting.\n\tconst initialToolbarItemIndexRef = useRef();\n\n\tif ( ! shouldShowBreadcrumb && ! shouldShowContextualToolbar ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ capturingClientId || clientId }\n\t\t\tbottomClientId={ lastClientId }\n\t\t\tclassName={ classnames( 'block-editor-block-list__block-popover', {\n\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t} ) }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t>\n\t\t\t{ shouldShowContextualToolbar && (\n\t\t\t\t<BlockContextualToolbar\n\t\t\t\t\t// If the toolbar is being shown because of being forced\n\t\t\t\t\t// it should focus the toolbar right after the mount.\n\t\t\t\t\tfocusOnMount={ isToolbarForced.current }\n\t\t\t\t\t__experimentalInitialIndex={\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalOnIndexChange={ ( index ) => {\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current = index;\n\t\t\t\t\t} }\n\t\t\t\t\t// Resets the index whenever the active block changes so\n\t\t\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ shouldShowBreadcrumb && (\n\t\t\t\t<BlockSelectionButton\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BlockPopover>\n\t);\n}\n\nfunction wrapperSelector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlock,\n\t\tgetBlockParents,\n\t\t__experimentalGetBlockListSettingsForBlocks,\n\t} = select( blockEditorStore );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\tif ( ! clientId ) {\n\t\treturn;\n\t}\n\n\tconst { name, attributes = {} } = getBlock( clientId ) || {};\n\tconst blockParentsClientIds = getBlockParents( clientId );\n\n\t// Get Block List Settings for all ancestors of the current Block clientId.\n\tconst parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(\n\t\tblockParentsClientIds\n\t);\n\n\t// Get the clientId of the topmost parent with the capture toolbars setting.\n\tconst capturingClientId = find(\n\t\tblockParentsClientIds,\n\t\t( parentClientId ) =>\n\t\t\tparentBlockListSettings[ parentClientId ]\n\t\t\t\t?.__experimentalCaptureToolbars\n\t);\n\n\treturn {\n\t\tclientId,\n\t\trootClientId: getBlockRootClientId( clientId ),\n\t\tname,\n\t\tisEmptyDefaultBlock:\n\t\t\tname && isUnmodifiedDefaultBlock( { name, attributes } ),\n\t\tcapturingClientId,\n\t};\n}\n\nexport default function WrappedBlockPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst selected = useSelect( wrapperSelector, [] );\n\n\tif ( ! selected ) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\tclientId,\n\t\trootClientId,\n\t\tname,\n\t\tisEmptyDefaultBlock,\n\t\tcapturingClientId,\n\t} = selected;\n\n\tif ( ! name ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SelectedBlockPopover\n\t\t\tclientId={ clientId }\n\t\t\trootClientId={ rootClientId }\n\t\t\tisEmptyDefaultBlock={ isEmptyDefaultBlock }\n\t\t\tcapturingClientId={ capturingClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t/>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/selected-block-popover.js"],"names":["selector","select","isNavigationMode","isMultiSelecting","hasMultiSelection","isTyping","getSettings","getLastMultiSelectedBlockClientId","blockEditorStore","hasFixedToolbar","lastClientId","SelectedBlockPopover","clientId","rootClientId","isEmptyDefaultBlock","capturingClientId","__unstablePopoverSlot","__unstableContentRef","isInsertionPointVisible","isBlockInsertionPointVisible","getBlockInsertionPoint","getBlockOrder","insertionPoint","order","index","isLargeViewport","isToolbarForced","stopTyping","showEmptyBlockSideInserter","shouldShowBreadcrumb","shouldShowContextualToolbar","canFocusHiddenToolbar","current","isDisabled","initialToolbarItemIndexRef","popoverProps","contentElement","wrapperSelector","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlockRootClientId","getBlock","getBlockParents","__experimentalGetBlockListSettingsForBlocks","name","attributes","blockParentsClientIds","parentBlockListSettings","parentClientId","__experimentalCaptureToolbars","WrappedBlockPopover","selected"],"mappings":";;;;;;;;;AASA;;;;AANA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAtBA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AAOA,SAASA,QAAT,CAAmBC,MAAnB,EAA4B;AAC3B,QAAM;AACLC,IAAAA,gBADK;AAELC,IAAAA,gBAFK;AAGLC,IAAAA,iBAHK;AAILC,IAAAA,QAJK;AAKLC,IAAAA,WALK;AAMLC,IAAAA;AANK,MAOFN,MAAM,CAAEO,YAAF,CAPV;AAQA,SAAO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;AAAEA,MAAAA,IAAF;AAAQC,MAAAA;AAAR,KAA1B,CALH;AAMN9B,IAAAA;AANM,GAAP;AAQA;;AAEc,SAASmC,mBAAT,QAGX;AAAA,MAHyC;AAC5ClC,IAAAA,qBAD4C;AAE5CC,IAAAA;AAF4C,GAGzC;AACH,QAAMkC,QAAQ,GAAG,qBAAWd,eAAX,EAA4B,EAA5B,CAAjB;;AAEA,MAAK,CAAEc,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,QAAM;AACLvC,IAAAA,QADK;AAELC,IAAAA,YAFK;AAGL+B,IAAAA,IAHK;AAIL9B,IAAAA,mBAJK;AAKLC,IAAAA;AALK,MAMFoC,QANJ;;AAQA,MAAK,CAAEP,IAAP,EAAc;AACb,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,oBAAD;AACC,IAAA,QAAQ,EAAGhC,QADZ;AAEC,IAAA,YAAY,EAAGC,YAFhB;AAGC,IAAA,mBAAmB,EAAGC,mBAHvB;AAIC,IAAA,iBAAiB,EAAGC,iBAJrB;AAKC,IAAA,qBAAqB,EAAGC,qBALzB;AAMC,IAAA,oBAAoB,EAAGC;AANxB,IADD;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockSelectionButton from './block-selection-button';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopover from '../block-popover';\nimport useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';\n\nfunction selector( select ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\thasMultiSelection,\n\t\tisTyping,\n\t\tgetSettings,\n\t\tgetLastMultiSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\treturn {\n\t\tisNavigationMode: isNavigationMode(),\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tisTyping: isTyping(),\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tlastClientId: hasMultiSelection()\n\t\t\t? getLastMultiSelectedBlockClientId()\n\t\t\t: null,\n\t};\n}\n\nfunction SelectedBlockPopover( {\n\tclientId,\n\trootClientId,\n\tisEmptyDefaultBlock,\n\tcapturingClientId,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\tisTyping,\n\t\thasFixedToolbar,\n\t\tlastClientId,\n\t} = useSelect( selector, [] );\n\tconst isInsertionPointVisible = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tif ( ! isBlockInsertionPointVisible() ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\t\t\treturn order[ insertionPoint.index ] === clientId;\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isToolbarForced = useRef( false );\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\tconst showEmptyBlockSideInserter =\n\t\t! isTyping && ! isNavigationMode && isEmptyDefaultBlock;\n\tconst shouldShowBreadcrumb = isNavigationMode;\n\tconst shouldShowContextualToolbar =\n\t\t! isNavigationMode &&\n\t\t! hasFixedToolbar &&\n\t\tisLargeViewport &&\n\t\t! isMultiSelecting &&\n\t\t! showEmptyBlockSideInserter &&\n\t\t! isTyping;\n\tconst canFocusHiddenToolbar =\n\t\t! isNavigationMode &&\n\t\t! shouldShowContextualToolbar &&\n\t\t! hasFixedToolbar &&\n\t\t! isEmptyDefaultBlock;\n\n\tuseShortcut(\n\t\t'core/block-editor/focus-toolbar',\n\t\t() => {\n\t\t\tisToolbarForced.current = true;\n\t\t\tstopTyping( true );\n\t\t},\n\t\t{\n\t\t\tisDisabled: ! canFocusHiddenToolbar,\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tisToolbarForced.current = false;\n\t} );\n\n\t// Stores the active toolbar item index so the block toolbar can return focus\n\t// to it when re-mounting.\n\tconst initialToolbarItemIndexRef = useRef();\n\n\tconst popoverProps = useBlockToolbarPopoverProps( {\n\t\tcontentElement: __unstableContentRef?.current,\n\t\tclientId,\n\t} );\n\n\tif ( ! shouldShowBreadcrumb && ! shouldShowContextualToolbar ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ capturingClientId || clientId }\n\t\t\tbottomClientId={ lastClientId }\n\t\t\tclassName={ classnames( 'block-editor-block-list__block-popover', {\n\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t} ) }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t{ ...popoverProps }\n\t\t>\n\t\t\t{ shouldShowContextualToolbar && (\n\t\t\t\t<BlockContextualToolbar\n\t\t\t\t\t// If the toolbar is being shown because of being forced\n\t\t\t\t\t// it should focus the toolbar right after the mount.\n\t\t\t\t\tfocusOnMount={ isToolbarForced.current }\n\t\t\t\t\t__experimentalInitialIndex={\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalOnIndexChange={ ( index ) => {\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current = index;\n\t\t\t\t\t} }\n\t\t\t\t\t// Resets the index whenever the active block changes so\n\t\t\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ shouldShowBreadcrumb && (\n\t\t\t\t<BlockSelectionButton\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BlockPopover>\n\t);\n}\n\nfunction wrapperSelector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlock,\n\t\tgetBlockParents,\n\t\t__experimentalGetBlockListSettingsForBlocks,\n\t} = select( blockEditorStore );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\tif ( ! clientId ) {\n\t\treturn;\n\t}\n\n\tconst { name, attributes = {} } = getBlock( clientId ) || {};\n\tconst blockParentsClientIds = getBlockParents( clientId );\n\n\t// Get Block List Settings for all ancestors of the current Block clientId.\n\tconst parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(\n\t\tblockParentsClientIds\n\t);\n\n\t// Get the clientId of the topmost parent with the capture toolbars setting.\n\tconst capturingClientId = find(\n\t\tblockParentsClientIds,\n\t\t( parentClientId ) =>\n\t\t\tparentBlockListSettings[ parentClientId ]\n\t\t\t\t?.__experimentalCaptureToolbars\n\t);\n\n\treturn {\n\t\tclientId,\n\t\trootClientId: getBlockRootClientId( clientId ),\n\t\tname,\n\t\tisEmptyDefaultBlock:\n\t\t\tname && isUnmodifiedDefaultBlock( { name, attributes } ),\n\t\tcapturingClientId,\n\t};\n}\n\nexport default function WrappedBlockPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst selected = useSelect( wrapperSelector, [] );\n\n\tif ( ! selected ) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\tclientId,\n\t\trootClientId,\n\t\tname,\n\t\tisEmptyDefaultBlock,\n\t\tcapturingClientId,\n\t} = selected;\n\n\tif ( ! name ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SelectedBlockPopover\n\t\t\tclientId={ clientId }\n\t\t\trootClientId={ rootClientId }\n\t\t\tisEmptyDefaultBlock={ isEmptyDefaultBlock }\n\t\t\tcapturingClientId={ capturingClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useBlockToolbarPopoverProps;
|
|
7
|
+
|
|
8
|
+
var _compose = require("@wordpress/compose");
|
|
9
|
+
|
|
10
|
+
var _data = require("@wordpress/data");
|
|
11
|
+
|
|
12
|
+
var _element = require("@wordpress/element");
|
|
13
|
+
|
|
14
|
+
var _store = require("../../store");
|
|
15
|
+
|
|
16
|
+
var _useBlockRefs = require("../block-list/use-block-props/use-block-refs");
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* WordPress dependencies
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Internal dependencies
|
|
24
|
+
*/
|
|
25
|
+
// By default the toolbar sets the `shift` prop. If the user scrolls the page
|
|
26
|
+
// down the toolbar will stay on screen by adopting a sticky position at the
|
|
27
|
+
// top of the viewport.
|
|
28
|
+
const DEFAULT_PROPS = {
|
|
29
|
+
__unstableForcePosition: true,
|
|
30
|
+
__unstableShift: true
|
|
31
|
+
}; // When there isn't enough height between the top of the block and the editor
|
|
32
|
+
// canvas, the `shift` prop is set to `false`, as it will cause the block to be
|
|
33
|
+
// obscured. The `flip` behavior is enabled (by setting `forcePosition` to
|
|
34
|
+
// `false`), which positions the toolbar below the block.
|
|
35
|
+
|
|
36
|
+
const RESTRICTED_HEIGHT_PROPS = {
|
|
37
|
+
__unstableForcePosition: false,
|
|
38
|
+
__unstableShift: false
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Get the popover props for the block toolbar, determined by the space at the top of the canvas and the toolbar height.
|
|
42
|
+
*
|
|
43
|
+
* @param {Element} contentElement The DOM element that represents the editor content or canvas.
|
|
44
|
+
* @param {Element} selectedBlockElement The outer DOM element of the first selected block.
|
|
45
|
+
* @param {number} toolbarHeight The height of the toolbar in pixels.
|
|
46
|
+
*
|
|
47
|
+
* @return {Object} The popover props used to determine the position of the toolbar.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
function getProps(contentElement, selectedBlockElement, toolbarHeight) {
|
|
51
|
+
if (!contentElement || !selectedBlockElement) {
|
|
52
|
+
return DEFAULT_PROPS;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const blockRect = selectedBlockElement.getBoundingClientRect();
|
|
56
|
+
const contentRect = contentElement.getBoundingClientRect();
|
|
57
|
+
|
|
58
|
+
if (blockRect.top - contentRect.top > toolbarHeight) {
|
|
59
|
+
return DEFAULT_PROPS;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return RESTRICTED_HEIGHT_PROPS;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Determines the desired popover positioning behavior, returning a set of appropriate props.
|
|
66
|
+
*
|
|
67
|
+
* @param {Object} elements
|
|
68
|
+
* @param {Element} elements.contentElement The DOM element that represents the editor content or canvas.
|
|
69
|
+
* @param {string} elements.clientId The clientId of the first selected block.
|
|
70
|
+
*
|
|
71
|
+
* @return {Object} The popover props used to determine the position of the toolbar.
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
function useBlockToolbarPopoverProps(_ref) {
|
|
76
|
+
let {
|
|
77
|
+
contentElement,
|
|
78
|
+
clientId
|
|
79
|
+
} = _ref;
|
|
80
|
+
const selectedBlockElement = (0, _useBlockRefs.__unstableUseBlockElement)(clientId);
|
|
81
|
+
const [toolbarHeight, setToolbarHeight] = (0, _element.useState)(0);
|
|
82
|
+
const [props, setProps] = (0, _element.useState)(() => getProps(contentElement, selectedBlockElement, toolbarHeight));
|
|
83
|
+
const blockIndex = (0, _data.useSelect)(select => select(_store.store).getBlockIndex(clientId), [clientId]);
|
|
84
|
+
const popoverRef = (0, _compose.useRefEffect)(popoverNode => {
|
|
85
|
+
setToolbarHeight(popoverNode.offsetHeight);
|
|
86
|
+
}, []);
|
|
87
|
+
const updateProps = (0, _element.useCallback)(() => setProps(getProps(contentElement, selectedBlockElement, toolbarHeight)), [contentElement, selectedBlockElement, toolbarHeight]); // Update props when the block is moved. This also ensures the props are
|
|
88
|
+
// correct on initial mount, and when the selected block or content element
|
|
89
|
+
// changes (since the callback ref will update).
|
|
90
|
+
|
|
91
|
+
(0, _element.useLayoutEffect)(updateProps, [blockIndex, updateProps]); // Update props when the viewport is resized or the block is resized.
|
|
92
|
+
|
|
93
|
+
(0, _element.useLayoutEffect)(() => {
|
|
94
|
+
var _contentElement$owner, _contentView$addEvent, _selectedBlockElement;
|
|
95
|
+
|
|
96
|
+
if (!contentElement || !selectedBlockElement) {
|
|
97
|
+
return;
|
|
98
|
+
} // Update the toolbar props on viewport resize.
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
const contentView = contentElement === null || contentElement === void 0 ? void 0 : (_contentElement$owner = contentElement.ownerDocument) === null || _contentElement$owner === void 0 ? void 0 : _contentElement$owner.defaultView;
|
|
102
|
+
contentView === null || contentView === void 0 ? void 0 : (_contentView$addEvent = contentView.addEventHandler) === null || _contentView$addEvent === void 0 ? void 0 : _contentView$addEvent.call(contentView, 'resize', updateProps); // Update the toolbar props on block resize.
|
|
103
|
+
|
|
104
|
+
let resizeObserver;
|
|
105
|
+
const blockView = selectedBlockElement === null || selectedBlockElement === void 0 ? void 0 : (_selectedBlockElement = selectedBlockElement.ownerDocument) === null || _selectedBlockElement === void 0 ? void 0 : _selectedBlockElement.defaultView;
|
|
106
|
+
|
|
107
|
+
if (blockView.ResizeObserver) {
|
|
108
|
+
resizeObserver = new blockView.ResizeObserver(updateProps);
|
|
109
|
+
resizeObserver.observe(selectedBlockElement);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return () => {
|
|
113
|
+
var _contentView$removeEv;
|
|
114
|
+
|
|
115
|
+
contentView === null || contentView === void 0 ? void 0 : (_contentView$removeEv = contentView.removeEventHandler) === null || _contentView$removeEv === void 0 ? void 0 : _contentView$removeEv.call(contentView, 'resize', updateProps);
|
|
116
|
+
|
|
117
|
+
if (resizeObserver) {
|
|
118
|
+
resizeObserver.disconnect();
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}, [updateProps, contentElement, selectedBlockElement]);
|
|
122
|
+
return { ...props,
|
|
123
|
+
ref: popoverRef
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=use-block-toolbar-popover-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/use-block-toolbar-popover-props.js"],"names":["DEFAULT_PROPS","__unstableForcePosition","__unstableShift","RESTRICTED_HEIGHT_PROPS","getProps","contentElement","selectedBlockElement","toolbarHeight","blockRect","getBoundingClientRect","contentRect","top","useBlockToolbarPopoverProps","clientId","setToolbarHeight","props","setProps","blockIndex","select","blockEditorStore","getBlockIndex","popoverRef","popoverNode","offsetHeight","updateProps","contentView","ownerDocument","defaultView","addEventHandler","resizeObserver","blockView","ResizeObserver","observe","removeEventHandler","disconnect","ref"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIA;AACA;AACA;AACA,MAAMA,aAAa,GAAG;AAAEC,EAAAA,uBAAuB,EAAE,IAA3B;AAAiCC,EAAAA,eAAe,EAAE;AAAlD,CAAtB,C,CAEA;AACA;AACA;AACA;;AACA,MAAMC,uBAAuB,GAAG;AAC/BF,EAAAA,uBAAuB,EAAE,KADM;AAE/BC,EAAAA,eAAe,EAAE;A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\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useLayoutEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\n\n// By default the toolbar sets the `shift` prop. If the user scrolls the page\n// down the toolbar will stay on screen by adopting a sticky position at the\n// top of the viewport.\nconst DEFAULT_PROPS = { __unstableForcePosition: true, __unstableShift: true };\n\n// When there isn't enough height between the top of the block and the editor\n// canvas, the `shift` prop is set to `false`, as it will cause the block to be\n// obscured. The `flip` behavior is enabled (by setting `forcePosition` to\n// `false`), which positions the toolbar below the block.\nconst RESTRICTED_HEIGHT_PROPS = {\n\t__unstableForcePosition: false,\n\t__unstableShift: false,\n};\n\n/**\n * Get the popover props for the block toolbar, determined by the space at the top of the canvas and the toolbar height.\n *\n * @param {Element} contentElement The DOM element that represents the editor content or canvas.\n * @param {Element} selectedBlockElement The outer DOM element of the first selected block.\n * @param {number} toolbarHeight The height of the toolbar in pixels.\n *\n * @return {Object} The popover props used to determine the position of the toolbar.\n */\nfunction getProps( contentElement, selectedBlockElement, toolbarHeight ) {\n\tif ( ! contentElement || ! selectedBlockElement ) {\n\t\treturn DEFAULT_PROPS;\n\t}\n\n\tconst blockRect = selectedBlockElement.getBoundingClientRect();\n\tconst contentRect = contentElement.getBoundingClientRect();\n\n\tif ( blockRect.top - contentRect.top > toolbarHeight ) {\n\t\treturn DEFAULT_PROPS;\n\t}\n\n\treturn RESTRICTED_HEIGHT_PROPS;\n}\n\n/**\n * Determines the desired popover positioning behavior, returning a set of appropriate props.\n *\n * @param {Object} elements\n * @param {Element} elements.contentElement The DOM element that represents the editor content or canvas.\n * @param {string} elements.clientId The clientId of the first selected block.\n *\n * @return {Object} The popover props used to determine the position of the toolbar.\n */\nexport default function useBlockToolbarPopoverProps( {\n\tcontentElement,\n\tclientId,\n} ) {\n\tconst selectedBlockElement = useBlockElement( clientId );\n\tconst [ toolbarHeight, setToolbarHeight ] = useState( 0 );\n\tconst [ props, setProps ] = useState( () =>\n\t\tgetProps( contentElement, selectedBlockElement, toolbarHeight )\n\t);\n\tconst blockIndex = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlockIndex( clientId ),\n\t\t[ clientId ]\n\t);\n\n\tconst popoverRef = useRefEffect( ( popoverNode ) => {\n\t\tsetToolbarHeight( popoverNode.offsetHeight );\n\t}, [] );\n\n\tconst updateProps = useCallback(\n\t\t() =>\n\t\t\tsetProps(\n\t\t\t\tgetProps( contentElement, selectedBlockElement, toolbarHeight )\n\t\t\t),\n\t\t[ contentElement, selectedBlockElement, toolbarHeight ]\n\t);\n\n\t// Update props when the block is moved. This also ensures the props are\n\t// correct on initial mount, and when the selected block or content element\n\t// changes (since the callback ref will update).\n\tuseLayoutEffect( updateProps, [ blockIndex, updateProps ] );\n\n\t// Update props when the viewport is resized or the block is resized.\n\tuseLayoutEffect( () => {\n\t\tif ( ! contentElement || ! selectedBlockElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update the toolbar props on viewport resize.\n\t\tconst contentView = contentElement?.ownerDocument?.defaultView;\n\t\tcontentView?.addEventHandler?.( 'resize', updateProps );\n\n\t\t// Update the toolbar props on block resize.\n\t\tlet resizeObserver;\n\t\tconst blockView = selectedBlockElement?.ownerDocument?.defaultView;\n\t\tif ( blockView.ResizeObserver ) {\n\t\t\tresizeObserver = new blockView.ResizeObserver( updateProps );\n\t\t\tresizeObserver.observe( selectedBlockElement );\n\t\t}\n\n\t\treturn () => {\n\t\t\tcontentView?.removeEventHandler?.( 'resize', updateProps );\n\n\t\t\tif ( resizeObserver ) {\n\t\t\t\tresizeObserver.disconnect();\n\t\t\t}\n\t\t};\n\t}, [ updateProps, contentElement, selectedBlockElement ] );\n\n\treturn {\n\t\t...props,\n\t\tref: popoverRef,\n\t};\n}\n"]}
|
|
@@ -52,7 +52,7 @@ function BlockTypesList(_ref) {
|
|
|
52
52
|
className: (0, _blocks.getBlockMenuDefaultClassName)(item.id),
|
|
53
53
|
onSelect: onSelect,
|
|
54
54
|
onHover: onHover,
|
|
55
|
-
isDraggable: isDraggable,
|
|
55
|
+
isDraggable: isDraggable && !item.isDisabled,
|
|
56
56
|
isFirst: i === 0 && j === 0
|
|
57
57
|
})))), children);
|
|
58
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-types-list/index.js"],"names":["chunk","array","size","chunks","i","j","length","push","slice","BlockTypesList","items","onSelect","onHover","children","label","isDraggable","map","row","item","id"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;AAIA,SAASA,KAAT,CAAgBC,KAAhB,EAAuBC,IAAvB,EAA8B;AAC7B,QAAMC,MAAM,GAAG,EAAf;;AACA,OAAM,IAAIC,CAAC,GAAG,CAAR,EAAWC,CAAC,GAAGJ,KAAK,CAACK,MAA3B,EAAmCF,CAAC,GAAGC,CAAvC,EAA0CD,CAAC,IAAIF,IAA/C,EAAsD;AACrDC,IAAAA,MAAM,CAACI,IAAP,CAAaN,KAAK,CAACO,KAAN,CAAaJ,CAAb,EAAgBA,CAAC,GAAGF,IAApB,CAAb;AACA;;AACD,SAAOC,MAAP;AACA;;AAED,SAASM,cAAT,OAOI;AAAA,MAPqB;AACxBC,IAAAA,KAAK,GAAG,EADgB;AAExBC,IAAAA,QAFwB;AAGxBC,IAAAA,OAAO,GAAG,MAAM,CAAE,CAHM;AAIxBC,IAAAA,QAJwB;AAKxBC,IAAAA,KALwB;AAMxBC,IAAAA,WAAW,GAAG;AANU,GAOrB;AACH,SACC,4BAAC,qCAAD;AACC,IAAA,SAAS,EAAC,+BADX;AAEC,kBAAaD;AAFd,KAIGd,KAAK,CAAEU,KAAF,EAAS,CAAT,CAAL,CAAkBM,GAAlB,CAAuB,CAAEC,GAAF,EAAOb,CAAP,KACxB,4BAAC,mCAAD;AAAoB,IAAA,GAAG,EAAGA;AAA1B,KACGa,GAAG,CAACD,GAAJ,CAAS,CAAEE,IAAF,EAAQb,CAAR,KACV,4BAAC,yBAAD;AACC,IAAA,GAAG,EAAGa,IAAI,CAACC,EADZ;AAEC,IAAA,IAAI,EAAGD,IAFR;AAGC,IAAA,SAAS,EAAG,0CACXA,IAAI,CAACC,EADM,CAHb;AAMC,IAAA,QAAQ,EAAGR,QANZ;AAOC,IAAA,OAAO,EAAGC,OAPX;AAQC,IAAA,WAAW,EAAGG,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-types-list/index.js"],"names":["chunk","array","size","chunks","i","j","length","push","slice","BlockTypesList","items","onSelect","onHover","children","label","isDraggable","map","row","item","id","isDisabled"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;AAIA,SAASA,KAAT,CAAgBC,KAAhB,EAAuBC,IAAvB,EAA8B;AAC7B,QAAMC,MAAM,GAAG,EAAf;;AACA,OAAM,IAAIC,CAAC,GAAG,CAAR,EAAWC,CAAC,GAAGJ,KAAK,CAACK,MAA3B,EAAmCF,CAAC,GAAGC,CAAvC,EAA0CD,CAAC,IAAIF,IAA/C,EAAsD;AACrDC,IAAAA,MAAM,CAACI,IAAP,CAAaN,KAAK,CAACO,KAAN,CAAaJ,CAAb,EAAgBA,CAAC,GAAGF,IAApB,CAAb;AACA;;AACD,SAAOC,MAAP;AACA;;AAED,SAASM,cAAT,OAOI;AAAA,MAPqB;AACxBC,IAAAA,KAAK,GAAG,EADgB;AAExBC,IAAAA,QAFwB;AAGxBC,IAAAA,OAAO,GAAG,MAAM,CAAE,CAHM;AAIxBC,IAAAA,QAJwB;AAKxBC,IAAAA,KALwB;AAMxBC,IAAAA,WAAW,GAAG;AANU,GAOrB;AACH,SACC,4BAAC,qCAAD;AACC,IAAA,SAAS,EAAC,+BADX;AAEC,kBAAaD;AAFd,KAIGd,KAAK,CAAEU,KAAF,EAAS,CAAT,CAAL,CAAkBM,GAAlB,CAAuB,CAAEC,GAAF,EAAOb,CAAP,KACxB,4BAAC,mCAAD;AAAoB,IAAA,GAAG,EAAGA;AAA1B,KACGa,GAAG,CAACD,GAAJ,CAAS,CAAEE,IAAF,EAAQb,CAAR,KACV,4BAAC,yBAAD;AACC,IAAA,GAAG,EAAGa,IAAI,CAACC,EADZ;AAEC,IAAA,IAAI,EAAGD,IAFR;AAGC,IAAA,SAAS,EAAG,0CACXA,IAAI,CAACC,EADM,CAHb;AAMC,IAAA,QAAQ,EAAGR,QANZ;AAOC,IAAA,OAAO,EAAGC,OAPX;AAQC,IAAA,WAAW,EAAGG,WAAW,IAAI,CAAEG,IAAI,CAACE,UARrC;AASC,IAAA,OAAO,EAAGhB,CAAC,KAAK,CAAN,IAAWC,CAAC,KAAK;AAT5B,IADC,CADH,CADC,CAJH,EAqBGQ,QArBH,CADD;AAyBA;;eAEcJ,c","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockMenuDefaultClassName } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport InserterListItem from '../inserter-list-item';\nimport { InserterListboxGroup, InserterListboxRow } from '../inserter-listbox';\n\nfunction chunk( array, size ) {\n\tconst chunks = [];\n\tfor ( let i = 0, j = array.length; i < j; i += size ) {\n\t\tchunks.push( array.slice( i, i + size ) );\n\t}\n\treturn chunks;\n}\n\nfunction BlockTypesList( {\n\titems = [],\n\tonSelect,\n\tonHover = () => {},\n\tchildren,\n\tlabel,\n\tisDraggable = true,\n} ) {\n\treturn (\n\t\t<InserterListboxGroup\n\t\t\tclassName=\"block-editor-block-types-list\"\n\t\t\taria-label={ label }\n\t\t>\n\t\t\t{ chunk( items, 3 ).map( ( row, i ) => (\n\t\t\t\t<InserterListboxRow key={ i }>\n\t\t\t\t\t{ row.map( ( item, j ) => (\n\t\t\t\t\t\t<InserterListItem\n\t\t\t\t\t\t\tkey={ item.id }\n\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\tclassName={ getBlockMenuDefaultClassName(\n\t\t\t\t\t\t\t\titem.id\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\t\tisDraggable={ isDraggable && ! item.isDisabled }\n\t\t\t\t\t\t\tisFirst={ i === 0 && j === 0 }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</InserterListboxRow>\n\t\t\t) ) }\n\t\t\t{ children }\n\t\t</InserterListboxGroup>\n\t);\n}\n\nexport default BlockTypesList;\n"]}
|
|
@@ -27,19 +27,47 @@ var _utils = require("./utils");
|
|
|
27
27
|
function AllInputControl(_ref) {
|
|
28
28
|
let {
|
|
29
29
|
onChange,
|
|
30
|
+
selectedUnits,
|
|
31
|
+
setSelectedUnits,
|
|
30
32
|
values,
|
|
31
33
|
...props
|
|
32
34
|
} = _ref;
|
|
33
|
-
|
|
35
|
+
let allValue = (0, _utils.getAllValue)(values);
|
|
36
|
+
|
|
37
|
+
if (allValue === undefined) {
|
|
38
|
+
// If we don't have any value set the unit to any current selection
|
|
39
|
+
// or the most common unit from the individual radii values.
|
|
40
|
+
allValue = (0, _utils.getAllUnit)(selectedUnits);
|
|
41
|
+
}
|
|
42
|
+
|
|
34
43
|
const hasValues = (0, _utils.hasDefinedValues)(values);
|
|
35
44
|
const isMixed = hasValues && (0, _utils.hasMixedValues)(values);
|
|
36
|
-
const allPlaceholder = isMixed ? (0, _i18n.__)('Mixed') : null;
|
|
45
|
+
const allPlaceholder = isMixed ? (0, _i18n.__)('Mixed') : null; // Filter out CSS-unit-only values to prevent invalid styles.
|
|
46
|
+
|
|
47
|
+
const handleOnChange = next => {
|
|
48
|
+
const isNumeric = !isNaN(parseFloat(next));
|
|
49
|
+
const nextValue = isNumeric ? next : undefined;
|
|
50
|
+
onChange(nextValue);
|
|
51
|
+
}; // Store current unit selection for use as fallback for individual
|
|
52
|
+
// radii controls.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
const handleOnUnitChange = unit => {
|
|
56
|
+
setSelectedUnits({
|
|
57
|
+
topLeft: unit,
|
|
58
|
+
topRight: unit,
|
|
59
|
+
bottomLeft: unit,
|
|
60
|
+
bottomRight: unit
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
37
64
|
return (0, _element.createElement)(_components.__experimentalUnitControl, (0, _extends2.default)({}, props, {
|
|
38
65
|
"aria-label": (0, _i18n.__)('Border radius'),
|
|
39
66
|
disableUnits: isMixed,
|
|
40
67
|
isOnly: true,
|
|
41
68
|
value: allValue,
|
|
42
|
-
onChange:
|
|
69
|
+
onChange: handleOnChange,
|
|
70
|
+
onUnitChange: handleOnUnitChange,
|
|
43
71
|
placeholder: allPlaceholder
|
|
44
72
|
}));
|
|
45
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/border-radius-control/all-input-control.js"],"names":["AllInputControl","onChange","values","props","allValue","hasValues","isMixed","allPlaceholder"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/border-radius-control/all-input-control.js"],"names":["AllInputControl","onChange","selectedUnits","setSelectedUnits","values","props","allValue","undefined","hasValues","isMixed","allPlaceholder","handleOnChange","next","isNumeric","isNaN","parseFloat","nextValue","handleOnUnitChange","unit","topLeft","topRight","bottomLeft","bottomRight"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAQe,SAASA,eAAT,OAMX;AAAA,MANqC;AACxCC,IAAAA,QADwC;AAExCC,IAAAA,aAFwC;AAGxCC,IAAAA,gBAHwC;AAIxCC,IAAAA,MAJwC;AAKxC,OAAGC;AALqC,GAMrC;AACH,MAAIC,QAAQ,GAAG,wBAAaF,MAAb,CAAf;;AAEA,MAAKE,QAAQ,KAAKC,SAAlB,EAA8B;AAC7B;AACA;AACAD,IAAAA,QAAQ,GAAG,uBAAYJ,aAAZ,CAAX;AACA;;AAED,QAAMM,SAAS,GAAG,6BAAkBJ,MAAlB,CAAlB;AACA,QAAMK,OAAO,GAAGD,SAAS,IAAI,2BAAgBJ,MAAhB,CAA7B;AACA,QAAMM,cAAc,GAAGD,OAAO,GAAG,cAAI,OAAJ,CAAH,GAAmB,IAAjD,CAXG,CAaH;;AACA,QAAME,cAAc,GAAKC,IAAF,IAAY;AAClC,UAAMC,SAAS,GAAG,CAAEC,KAAK,CAAEC,UAAU,CAAEH,IAAF,CAAZ,CAAzB;AACA,UAAMI,SAAS,GAAGH,SAAS,GAAGD,IAAH,GAAUL,SAArC;AACAN,IAAAA,QAAQ,CAAEe,SAAF,CAAR;AACA,GAJD,CAdG,CAoBH;AACA;;;AACA,QAAMC,kBAAkB,GAAKC,IAAF,IAAY;AACtCf,IAAAA,gBAAgB,CAAE;AACjBgB,MAAAA,OAAO,EAAED,IADQ;AAEjBE,MAAAA,QAAQ,EAAEF,IAFO;AAGjBG,MAAAA,UAAU,EAAEH,IAHK;AAIjBI,MAAAA,WAAW,EAAEJ;AAJI,KAAF,CAAhB;AAMA,GAPD;;AASA,SACC,4BAAC,qCAAD,6BACMb,KADN;AAEC,kBAAa,cAAI,eAAJ,CAFd;AAGC,IAAA,YAAY,EAAGI,OAHhB;AAIC,IAAA,MAAM,MAJP;AAKC,IAAA,KAAK,EAAGH,QALT;AAMC,IAAA,QAAQ,EAAGK,cANZ;AAOC,IAAA,YAAY,EAAGM,kBAPhB;AAQC,IAAA,WAAW,EAAGP;AARf,KADD;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalUnitControl as UnitControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetAllValue,\n\tgetAllUnit,\n\thasMixedValues,\n\thasDefinedValues,\n} from './utils';\n\nexport default function AllInputControl( {\n\tonChange,\n\tselectedUnits,\n\tsetSelectedUnits,\n\tvalues,\n\t...props\n} ) {\n\tlet allValue = getAllValue( values );\n\n\tif ( allValue === undefined ) {\n\t\t// If we don't have any value set the unit to any current selection\n\t\t// or the most common unit from the individual radii values.\n\t\tallValue = getAllUnit( selectedUnits );\n\t}\n\n\tconst hasValues = hasDefinedValues( values );\n\tconst isMixed = hasValues && hasMixedValues( values );\n\tconst allPlaceholder = isMixed ? __( 'Mixed' ) : null;\n\n\t// Filter out CSS-unit-only values to prevent invalid styles.\n\tconst handleOnChange = ( next ) => {\n\t\tconst isNumeric = ! isNaN( parseFloat( next ) );\n\t\tconst nextValue = isNumeric ? next : undefined;\n\t\tonChange( nextValue );\n\t};\n\n\t// Store current unit selection for use as fallback for individual\n\t// radii controls.\n\tconst handleOnUnitChange = ( unit ) => {\n\t\tsetSelectedUnits( {\n\t\t\ttopLeft: unit,\n\t\t\ttopRight: unit,\n\t\t\tbottomLeft: unit,\n\t\t\tbottomRight: unit,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<UnitControl\n\t\t\t{ ...props }\n\t\t\taria-label={ __( 'Border radius' ) }\n\t\t\tdisableUnits={ isMixed }\n\t\t\tisOnly\n\t\t\tvalue={ allValue }\n\t\t\tonChange={ handleOnChange }\n\t\t\tonUnitChange={ handleOnUnitChange }\n\t\t\tplaceholder={ allPlaceholder }\n\t\t/>\n\t);\n}\n"]}
|