@wordpress/block-editor 9.7.0 → 9.8.1-next.957ca95e4c.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 +2 -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-list-compact.native.js +73 -0
- package/build/components/block-list/block-list-compact.native.js.map +1 -0
- package/build/components/block-list/use-block-props/use-focus-first-element.js +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-popover/inbetween.js +4 -2
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +11 -7
- 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-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/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 +20 -6
- 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/with-colors.js +17 -4
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/control.js +1 -0
- package/build/components/colors-gradients/control.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-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/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +6 -2
- package/build/components/inner-blocks/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/link-control/link-preview.js +0 -1
- package/build/components/link-control/link-preview.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/use-block-selection.js +1 -7
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/rich-text/index.js +10 -0
- package/build/components/rich-text/index.js.map +1 -1
- 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 +213 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -0
- package/build/components/spacing-sizes-control/utils.js +233 -0
- package/build/components/spacing-sizes-control/utils.js.map +1 -0
- package/build/components/text-decoration-control/index.js +28 -17
- package/build/components/text-decoration-control/index.js.map +1 -1
- package/build/components/text-transform-control/index.js +21 -14
- 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/writing-flow/index.js +2 -0
- package/build/components/writing-flow/index.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 +7 -10
- 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/align.js +3 -1
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/anchor.js +3 -7
- package/build/hooks/anchor.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/font-appearance.js +2 -1
- package/build/hooks/font-appearance.js.map +1 -1
- package/build/hooks/font-family.js +3 -1
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +3 -1
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/gap.js +25 -6
- 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 +23 -13
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/letter-spacing.js +2 -1
- package/build/hooks/letter-spacing.js.map +1 -1
- package/build/hooks/line-height.js +2 -1
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/lock.js +3 -7
- package/build/hooks/lock.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/hooks/text-decoration.js +2 -1
- package/build/hooks/text-decoration.js.map +1 -1
- package/build/hooks/text-transform.js +2 -1
- package/build/hooks/text-transform.js.map +1 -1
- package/build/layouts/constrained.js +225 -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 +18 -152
- 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-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-list-compact.native.js +58 -0
- package/build-module/components/block-list/block-list-compact.native.js.map +1 -0
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +4 -2
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +9 -7
- 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-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/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 +20 -6
- 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/with-colors.js +16 -3
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +1 -0
- package/build-module/components/colors-gradients/control.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-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/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +5 -2
- package/build-module/components/inner-blocks/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/link-control/link-preview.js +0 -1
- package/build-module/components/link-control/link-preview.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/use-block-selection.js +1 -6
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/rich-text/index.js +10 -0
- package/build-module/components/rich-text/index.js.map +1 -1
- 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 +197 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -0
- package/build-module/components/spacing-sizes-control/utils.js +203 -0
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -0
- package/build-module/components/text-decoration-control/index.js +25 -18
- package/build-module/components/text-decoration-control/index.js.map +1 -1
- package/build-module/components/text-transform-control/index.js +19 -15
- 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/writing-flow/index.js +2 -0
- package/build-module/components/writing-flow/index.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 +7 -10
- 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/align.js +4 -2
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/anchor.js +3 -6
- package/build-module/hooks/anchor.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/font-appearance.js +2 -1
- package/build-module/hooks/font-appearance.js.map +1 -1
- package/build-module/hooks/font-family.js +3 -1
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +3 -1
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/gap.js +21 -4
- 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 +24 -14
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/letter-spacing.js +2 -1
- package/build-module/hooks/letter-spacing.js.map +1 -1
- package/build-module/hooks/line-height.js +2 -1
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/lock.js +3 -6
- package/build-module/hooks/lock.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/hooks/text-decoration.js +2 -1
- package/build-module/hooks/text-decoration.js.map +1 -1
- package/build-module/hooks/text-transform.js +2 -1
- package/build-module/hooks/text-transform.js.map +1 -1
- package/build-module/layouts/constrained.js +207 -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 +20 -147
- 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-style/style-rtl.css +157 -61
- package/build-style/style.css +157 -61
- 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-list-compact.native.js +62 -0
- package/src/components/block-list/style.scss +29 -6
- package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -1
- package/src/components/block-popover/inbetween.js +4 -1
- package/src/components/block-popover/index.js +22 -15
- package/src/components/block-settings-menu/index.js +11 -15
- package/src/components/block-switcher/index.js +9 -13
- package/src/components/block-switcher/test/index.js +2 -2
- 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/border-radius-control/all-input-control.js +41 -4
- package/src/components/border-radius-control/index.js +25 -5
- 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/button-block-appender/style.scss +23 -0
- package/src/components/colors/with-colors.js +11 -1
- package/src/components/colors-gradients/control.js +1 -0
- 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/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/index.js +1 -0
- package/src/components/inner-blocks/index.native.js +5 -1
- package/src/components/inserter/search-items.js +17 -5
- package/src/components/link-control/link-preview.js +0 -1
- package/src/components/link-control/test/index.js +540 -893
- package/src/components/list-view/block-select-button.js +7 -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/rich-text/index.js +9 -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 +285 -0
- package/src/components/spacing-sizes-control/style.scss +122 -0
- package/src/components/spacing-sizes-control/test/utils.js +182 -0
- package/src/components/spacing-sizes-control/utils.js +222 -0
- package/src/components/text-decoration-control/index.js +41 -30
- package/src/components/text-decoration-control/stories/index.js +37 -0
- package/src/components/text-transform-control/index.js +27 -27
- package/src/components/text-transform-control/stories/index.js +37 -0
- package/src/components/url-input/index.js +1 -1
- package/src/components/url-input/style.scss +2 -2
- package/src/components/url-popover/style.scss +0 -3
- package/src/components/writing-flow/index.js +2 -0
- package/src/components/writing-flow/use-multi-selection.js +4 -1
- package/src/components/writing-flow/use-select-all.js +10 -13
- package/src/components/writing-flow/use-selection-observer.js +10 -2
- package/src/hooks/align.js +2 -2
- package/src/hooks/anchor.js +1 -6
- 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 +14 -0
- package/src/hooks/duotone.js +4 -4
- package/src/hooks/font-appearance.js +1 -0
- package/src/hooks/font-family.js +2 -0
- package/src/hooks/font-size.js +2 -0
- package/src/hooks/gap.js +42 -19
- package/src/hooks/generated-class-name.js +6 -9
- package/src/hooks/layout.js +47 -16
- package/src/hooks/letter-spacing.js +1 -0
- package/src/hooks/line-height.js +1 -0
- package/src/hooks/lock.js +1 -6
- 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 +16 -0
- package/src/hooks/text-decoration.js +1 -0
- package/src/hooks/text-transform.js +1 -0
- package/src/hooks/typography.scss +0 -7
- package/src/layouts/constrained.js +220 -0
- package/src/layouts/flex.js +1 -1
- package/src/layouts/flow.js +17 -173
- 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 -2
- 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-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/src/components/block-settings-menu/block-edit-visually-button.js +0 -52
- package/src/components/text-decoration-control/style.scss +0 -18
- package/src/components/text-transform-control/style.scss +0 -18
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
__experimentalUseCustomUnits as useCustomUnits,
|
|
7
|
+
__experimentalUnitControl as UnitControl,
|
|
8
|
+
} from '@wordpress/components';
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
10
|
+
import { Icon, positionCenter, stretchWide } from '@wordpress/icons';
|
|
11
|
+
import { getCSSRules } from '@wordpress/style-engine';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import useSetting from '../components/use-setting';
|
|
17
|
+
import { appendSelectors, getBlockGapCSS, getAlignmentsInfo } from './utils';
|
|
18
|
+
import { getGapCSSValue } from '../hooks/gap';
|
|
19
|
+
import { shouldSkipSerialization } from '../hooks/utils';
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
name: 'constrained',
|
|
23
|
+
label: __( 'Constrained' ),
|
|
24
|
+
inspectorControls: function DefaultLayoutInspectorControls( {
|
|
25
|
+
layout,
|
|
26
|
+
onChange,
|
|
27
|
+
} ) {
|
|
28
|
+
const { wideSize, contentSize } = layout;
|
|
29
|
+
const units = useCustomUnits( {
|
|
30
|
+
availableUnits: useSetting( 'spacing.units' ) || [
|
|
31
|
+
'%',
|
|
32
|
+
'px',
|
|
33
|
+
'em',
|
|
34
|
+
'rem',
|
|
35
|
+
'vw',
|
|
36
|
+
],
|
|
37
|
+
} );
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
<div className="block-editor-hooks__layout-controls">
|
|
42
|
+
<div className="block-editor-hooks__layout-controls-unit">
|
|
43
|
+
<UnitControl
|
|
44
|
+
label={ __( 'Content' ) }
|
|
45
|
+
labelPosition="top"
|
|
46
|
+
__unstableInputWidth="80px"
|
|
47
|
+
value={ contentSize || wideSize || '' }
|
|
48
|
+
onChange={ ( nextWidth ) => {
|
|
49
|
+
nextWidth =
|
|
50
|
+
0 > parseFloat( nextWidth )
|
|
51
|
+
? '0'
|
|
52
|
+
: nextWidth;
|
|
53
|
+
onChange( {
|
|
54
|
+
...layout,
|
|
55
|
+
contentSize: nextWidth,
|
|
56
|
+
} );
|
|
57
|
+
} }
|
|
58
|
+
units={ units }
|
|
59
|
+
/>
|
|
60
|
+
<Icon icon={ positionCenter } />
|
|
61
|
+
</div>
|
|
62
|
+
<div className="block-editor-hooks__layout-controls-unit">
|
|
63
|
+
<UnitControl
|
|
64
|
+
label={ __( 'Wide' ) }
|
|
65
|
+
labelPosition="top"
|
|
66
|
+
__unstableInputWidth="80px"
|
|
67
|
+
value={ wideSize || contentSize || '' }
|
|
68
|
+
onChange={ ( nextWidth ) => {
|
|
69
|
+
nextWidth =
|
|
70
|
+
0 > parseFloat( nextWidth )
|
|
71
|
+
? '0'
|
|
72
|
+
: nextWidth;
|
|
73
|
+
onChange( {
|
|
74
|
+
...layout,
|
|
75
|
+
wideSize: nextWidth,
|
|
76
|
+
} );
|
|
77
|
+
} }
|
|
78
|
+
units={ units }
|
|
79
|
+
/>
|
|
80
|
+
<Icon icon={ stretchWide } />
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
<div className="block-editor-hooks__layout-controls-reset">
|
|
84
|
+
<Button
|
|
85
|
+
variant="secondary"
|
|
86
|
+
isSmall
|
|
87
|
+
disabled={ ! contentSize && ! wideSize }
|
|
88
|
+
onClick={ () =>
|
|
89
|
+
onChange( {
|
|
90
|
+
contentSize: undefined,
|
|
91
|
+
wideSize: undefined,
|
|
92
|
+
inherit: false,
|
|
93
|
+
} )
|
|
94
|
+
}
|
|
95
|
+
>
|
|
96
|
+
{ __( 'Reset' ) }
|
|
97
|
+
</Button>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<p className="block-editor-hooks__layout-controls-helptext">
|
|
101
|
+
{ __(
|
|
102
|
+
'Customize the width for all elements that are assigned to the center or wide columns.'
|
|
103
|
+
) }
|
|
104
|
+
</p>
|
|
105
|
+
</>
|
|
106
|
+
);
|
|
107
|
+
},
|
|
108
|
+
toolBarControls: function DefaultLayoutToolbarControls() {
|
|
109
|
+
return null;
|
|
110
|
+
},
|
|
111
|
+
getLayoutStyle: function getLayoutStyle( {
|
|
112
|
+
selector,
|
|
113
|
+
layout = {},
|
|
114
|
+
style,
|
|
115
|
+
blockName,
|
|
116
|
+
hasBlockGapSupport,
|
|
117
|
+
layoutDefinitions,
|
|
118
|
+
} ) {
|
|
119
|
+
const { contentSize, wideSize } = layout;
|
|
120
|
+
const blockGapStyleValue = getGapCSSValue( style?.spacing?.blockGap );
|
|
121
|
+
|
|
122
|
+
// If a block's block.json skips serialization for spacing or
|
|
123
|
+
// spacing.blockGap, don't apply the user-defined value to the styles.
|
|
124
|
+
let blockGapValue = '';
|
|
125
|
+
if ( ! shouldSkipSerialization( blockName, 'spacing', 'blockGap' ) ) {
|
|
126
|
+
// If an object is provided only use the 'top' value for this kind of gap.
|
|
127
|
+
if ( blockGapStyleValue?.top ) {
|
|
128
|
+
blockGapValue = getGapCSSValue( blockGapStyleValue?.top );
|
|
129
|
+
} else if ( typeof blockGapStyleValue === 'string' ) {
|
|
130
|
+
blockGapValue = getGapCSSValue( blockGapStyleValue );
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
let output =
|
|
135
|
+
!! contentSize || !! wideSize
|
|
136
|
+
? `
|
|
137
|
+
${ appendSelectors(
|
|
138
|
+
selector,
|
|
139
|
+
'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'
|
|
140
|
+
) } {
|
|
141
|
+
max-width: ${ contentSize ?? wideSize };
|
|
142
|
+
margin-left: auto !important;
|
|
143
|
+
margin-right: auto !important;
|
|
144
|
+
}
|
|
145
|
+
${ appendSelectors( selector, '> .alignwide' ) } {
|
|
146
|
+
max-width: ${ wideSize ?? contentSize };
|
|
147
|
+
}
|
|
148
|
+
${ appendSelectors( selector, '> .alignfull' ) } {
|
|
149
|
+
max-width: none;
|
|
150
|
+
}
|
|
151
|
+
`
|
|
152
|
+
: '';
|
|
153
|
+
|
|
154
|
+
// If there is custom padding, add negative margins for alignfull blocks.
|
|
155
|
+
if ( style?.spacing?.padding ) {
|
|
156
|
+
// The style object might be storing a preset so we need to make sure we get a usable value.
|
|
157
|
+
const paddingValues = getCSSRules( style );
|
|
158
|
+
paddingValues.forEach( ( rule ) => {
|
|
159
|
+
if ( rule.key === 'paddingRight' ) {
|
|
160
|
+
output += `
|
|
161
|
+
${ appendSelectors( selector, '> .alignfull' ) } {
|
|
162
|
+
margin-right: calc(${ rule.value } * -1);
|
|
163
|
+
}
|
|
164
|
+
`;
|
|
165
|
+
} else if ( rule.key === 'paddingLeft' ) {
|
|
166
|
+
output += `
|
|
167
|
+
${ appendSelectors( selector, '> .alignfull' ) } {
|
|
168
|
+
margin-left: calc(${ rule.value } * -1);
|
|
169
|
+
}
|
|
170
|
+
`;
|
|
171
|
+
}
|
|
172
|
+
} );
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Output blockGap styles based on rules contained in layout definitions in theme.json.
|
|
176
|
+
if ( hasBlockGapSupport && blockGapValue ) {
|
|
177
|
+
output += getBlockGapCSS(
|
|
178
|
+
selector,
|
|
179
|
+
layoutDefinitions,
|
|
180
|
+
'constrained',
|
|
181
|
+
blockGapValue
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
return output;
|
|
185
|
+
},
|
|
186
|
+
getOrientation() {
|
|
187
|
+
return 'vertical';
|
|
188
|
+
},
|
|
189
|
+
getAlignments( layout ) {
|
|
190
|
+
const alignmentInfo = getAlignmentsInfo( layout );
|
|
191
|
+
if ( layout.alignments !== undefined ) {
|
|
192
|
+
if ( ! layout.alignments.includes( 'none' ) ) {
|
|
193
|
+
layout.alignments.unshift( 'none' );
|
|
194
|
+
}
|
|
195
|
+
return layout.alignments.map( ( alignment ) => ( {
|
|
196
|
+
name: alignment,
|
|
197
|
+
info: alignmentInfo[ alignment ],
|
|
198
|
+
} ) );
|
|
199
|
+
}
|
|
200
|
+
const { contentSize, wideSize } = layout;
|
|
201
|
+
|
|
202
|
+
const alignments = [
|
|
203
|
+
{ name: 'left' },
|
|
204
|
+
{ name: 'center' },
|
|
205
|
+
{ name: 'right' },
|
|
206
|
+
];
|
|
207
|
+
|
|
208
|
+
if ( contentSize ) {
|
|
209
|
+
alignments.unshift( { name: 'full' } );
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if ( wideSize ) {
|
|
213
|
+
alignments.unshift( { name: 'wide', info: alignmentInfo.wide } );
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
alignments.unshift( { name: 'none', info: alignmentInfo.none } );
|
|
217
|
+
|
|
218
|
+
return alignments;
|
|
219
|
+
},
|
|
220
|
+
};
|
package/src/layouts/flex.js
CHANGED
|
@@ -120,7 +120,7 @@ export default {
|
|
|
120
120
|
const blockGapValue =
|
|
121
121
|
style?.spacing?.blockGap &&
|
|
122
122
|
! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )
|
|
123
|
-
? getGapCSSValue( style?.spacing?.blockGap )
|
|
123
|
+
? getGapCSSValue( style?.spacing?.blockGap, '0.5em' )
|
|
124
124
|
: undefined;
|
|
125
125
|
const justifyContent = justifyContentMap[ layout.justifyContent ];
|
|
126
126
|
const flexWrap = flexWrapOptions.includes( layout.flexWrap )
|
package/src/layouts/flow.js
CHANGED
|
@@ -1,174 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
Button,
|
|
6
|
-
__experimentalUseCustomUnits as useCustomUnits,
|
|
7
|
-
__experimentalUnitControl as UnitControl,
|
|
8
|
-
} from '@wordpress/components';
|
|
9
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
10
|
-
import { Icon, positionCenter, stretchWide } from '@wordpress/icons';
|
|
11
|
-
import { getCSSRules } from '@wordpress/style-engine';
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
12
5
|
|
|
13
6
|
/**
|
|
14
7
|
* Internal dependencies
|
|
15
8
|
*/
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
import { getGapBoxControlValueFromStyle } from '../hooks/gap';
|
|
9
|
+
import { getBlockGapCSS, getAlignmentsInfo } from './utils';
|
|
10
|
+
import { getGapCSSValue } from '../hooks/gap';
|
|
19
11
|
import { shouldSkipSerialization } from '../hooks/utils';
|
|
20
12
|
|
|
21
13
|
export default {
|
|
22
14
|
name: 'default',
|
|
23
15
|
label: __( 'Flow' ),
|
|
24
|
-
inspectorControls: function DefaultLayoutInspectorControls( {
|
|
25
|
-
|
|
26
|
-
onChange,
|
|
27
|
-
} ) {
|
|
28
|
-
const { wideSize, contentSize } = layout;
|
|
29
|
-
const units = useCustomUnits( {
|
|
30
|
-
availableUnits: useSetting( 'spacing.units' ) || [
|
|
31
|
-
'%',
|
|
32
|
-
'px',
|
|
33
|
-
'em',
|
|
34
|
-
'rem',
|
|
35
|
-
'vw',
|
|
36
|
-
],
|
|
37
|
-
} );
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<>
|
|
41
|
-
<div className="block-editor-hooks__layout-controls">
|
|
42
|
-
<div className="block-editor-hooks__layout-controls-unit">
|
|
43
|
-
<UnitControl
|
|
44
|
-
label={ __( 'Content' ) }
|
|
45
|
-
labelPosition="top"
|
|
46
|
-
__unstableInputWidth="80px"
|
|
47
|
-
value={ contentSize || wideSize || '' }
|
|
48
|
-
onChange={ ( nextWidth ) => {
|
|
49
|
-
nextWidth =
|
|
50
|
-
0 > parseFloat( nextWidth )
|
|
51
|
-
? '0'
|
|
52
|
-
: nextWidth;
|
|
53
|
-
onChange( {
|
|
54
|
-
...layout,
|
|
55
|
-
contentSize: nextWidth,
|
|
56
|
-
} );
|
|
57
|
-
} }
|
|
58
|
-
units={ units }
|
|
59
|
-
/>
|
|
60
|
-
<Icon icon={ positionCenter } />
|
|
61
|
-
</div>
|
|
62
|
-
<div className="block-editor-hooks__layout-controls-unit">
|
|
63
|
-
<UnitControl
|
|
64
|
-
label={ __( 'Wide' ) }
|
|
65
|
-
labelPosition="top"
|
|
66
|
-
__unstableInputWidth="80px"
|
|
67
|
-
value={ wideSize || contentSize || '' }
|
|
68
|
-
onChange={ ( nextWidth ) => {
|
|
69
|
-
nextWidth =
|
|
70
|
-
0 > parseFloat( nextWidth )
|
|
71
|
-
? '0'
|
|
72
|
-
: nextWidth;
|
|
73
|
-
onChange( {
|
|
74
|
-
...layout,
|
|
75
|
-
wideSize: nextWidth,
|
|
76
|
-
} );
|
|
77
|
-
} }
|
|
78
|
-
units={ units }
|
|
79
|
-
/>
|
|
80
|
-
<Icon icon={ stretchWide } />
|
|
81
|
-
</div>
|
|
82
|
-
</div>
|
|
83
|
-
<div className="block-editor-hooks__layout-controls-reset">
|
|
84
|
-
<Button
|
|
85
|
-
variant="secondary"
|
|
86
|
-
isSmall
|
|
87
|
-
disabled={ ! contentSize && ! wideSize }
|
|
88
|
-
onClick={ () =>
|
|
89
|
-
onChange( {
|
|
90
|
-
contentSize: undefined,
|
|
91
|
-
wideSize: undefined,
|
|
92
|
-
inherit: false,
|
|
93
|
-
} )
|
|
94
|
-
}
|
|
95
|
-
>
|
|
96
|
-
{ __( 'Reset' ) }
|
|
97
|
-
</Button>
|
|
98
|
-
</div>
|
|
99
|
-
|
|
100
|
-
<p className="block-editor-hooks__layout-controls-helptext">
|
|
101
|
-
{ __(
|
|
102
|
-
'Customize the width for all elements that are assigned to the center or wide columns.'
|
|
103
|
-
) }
|
|
104
|
-
</p>
|
|
105
|
-
</>
|
|
106
|
-
);
|
|
16
|
+
inspectorControls: function DefaultLayoutInspectorControls() {
|
|
17
|
+
return null;
|
|
107
18
|
},
|
|
108
19
|
toolBarControls: function DefaultLayoutToolbarControls() {
|
|
109
20
|
return null;
|
|
110
21
|
},
|
|
111
22
|
getLayoutStyle: function getLayoutStyle( {
|
|
112
23
|
selector,
|
|
113
|
-
layout = {},
|
|
114
24
|
style,
|
|
115
25
|
blockName,
|
|
116
26
|
hasBlockGapSupport,
|
|
117
27
|
layoutDefinitions,
|
|
118
28
|
} ) {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
style?.spacing?.blockGap
|
|
122
|
-
);
|
|
29
|
+
const blockGapStyleValue = getGapCSSValue( style?.spacing?.blockGap );
|
|
30
|
+
|
|
123
31
|
// If a block's block.json skips serialization for spacing or
|
|
124
32
|
// spacing.blockGap, don't apply the user-defined value to the styles.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
? `
|
|
134
|
-
${ appendSelectors(
|
|
135
|
-
selector,
|
|
136
|
-
'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'
|
|
137
|
-
) } {
|
|
138
|
-
max-width: ${ contentSize ?? wideSize };
|
|
139
|
-
margin-left: auto !important;
|
|
140
|
-
margin-right: auto !important;
|
|
141
|
-
}
|
|
142
|
-
${ appendSelectors( selector, '> .alignwide' ) } {
|
|
143
|
-
max-width: ${ wideSize ?? contentSize };
|
|
144
|
-
}
|
|
145
|
-
${ appendSelectors( selector, '> .alignfull' ) } {
|
|
146
|
-
max-width: none;
|
|
147
|
-
}
|
|
148
|
-
`
|
|
149
|
-
: '';
|
|
150
|
-
|
|
151
|
-
// If there is custom padding, add negative margins for alignfull blocks.
|
|
152
|
-
if ( style?.spacing?.padding ) {
|
|
153
|
-
// The style object might be storing a preset so we need to make sure we get a usable value.
|
|
154
|
-
const paddingValues = getCSSRules( style );
|
|
155
|
-
paddingValues.forEach( ( rule ) => {
|
|
156
|
-
if ( rule.key === 'paddingRight' ) {
|
|
157
|
-
output += `
|
|
158
|
-
${ appendSelectors( selector, '> .alignfull' ) } {
|
|
159
|
-
margin-right: calc(${ rule.value } * -1);
|
|
160
|
-
}
|
|
161
|
-
`;
|
|
162
|
-
} else if ( rule.key === 'paddingLeft' ) {
|
|
163
|
-
output += `
|
|
164
|
-
${ appendSelectors( selector, '> .alignfull' ) } {
|
|
165
|
-
margin-left: calc(${ rule.value } * -1);
|
|
166
|
-
}
|
|
167
|
-
`;
|
|
168
|
-
}
|
|
169
|
-
} );
|
|
33
|
+
let blockGapValue = '';
|
|
34
|
+
if ( ! shouldSkipSerialization( blockName, 'spacing', 'blockGap' ) ) {
|
|
35
|
+
// If an object is provided only use the 'top' value for this kind of gap.
|
|
36
|
+
if ( blockGapStyleValue?.top ) {
|
|
37
|
+
blockGapValue = getGapCSSValue( blockGapStyleValue?.top );
|
|
38
|
+
} else if ( typeof blockGapStyleValue === 'string' ) {
|
|
39
|
+
blockGapValue = getGapCSSValue( blockGapStyleValue );
|
|
40
|
+
}
|
|
170
41
|
}
|
|
171
42
|
|
|
43
|
+
let output = '';
|
|
44
|
+
|
|
172
45
|
// Output blockGap styles based on rules contained in layout definitions in theme.json.
|
|
173
46
|
if ( hasBlockGapSupport && blockGapValue ) {
|
|
174
47
|
output += getBlockGapCSS(
|
|
@@ -215,32 +88,3 @@ export default {
|
|
|
215
88
|
return alignments;
|
|
216
89
|
},
|
|
217
90
|
};
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Helper method to assign contextual info to clarify
|
|
221
|
-
* alignment settings.
|
|
222
|
-
*
|
|
223
|
-
* Besides checking if `contentSize` and `wideSize` have a
|
|
224
|
-
* value, we now show this information only if their values
|
|
225
|
-
* are not a `css var`. This needs to change when parsing
|
|
226
|
-
* css variables land.
|
|
227
|
-
*
|
|
228
|
-
* @see https://github.com/WordPress/gutenberg/pull/34710#issuecomment-918000752
|
|
229
|
-
*
|
|
230
|
-
* @param {Object} layout The layout object.
|
|
231
|
-
* @return {Object} An object with contextual info per alignment.
|
|
232
|
-
*/
|
|
233
|
-
function getAlignmentsInfo( layout ) {
|
|
234
|
-
const { contentSize, wideSize } = layout;
|
|
235
|
-
const alignmentInfo = {};
|
|
236
|
-
const sizeRegex = /^(?!0)\d+(px|em|rem|vw|vh|%)?$/i;
|
|
237
|
-
if ( sizeRegex.test( contentSize ) ) {
|
|
238
|
-
// translators: %s: container size (i.e. 600px etc)
|
|
239
|
-
alignmentInfo.none = sprintf( __( 'Max %s wide' ), contentSize );
|
|
240
|
-
}
|
|
241
|
-
if ( sizeRegex.test( wideSize ) ) {
|
|
242
|
-
// translators: %s: container size (i.e. 600px etc)
|
|
243
|
-
alignmentInfo.wide = sprintf( __( 'Max %s wide' ), wideSize );
|
|
244
|
-
}
|
|
245
|
-
return alignmentInfo;
|
|
246
|
-
}
|
package/src/layouts/index.js
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import constrained from '../constrained';
|
|
5
|
+
|
|
6
|
+
describe( 'getLayoutStyle', () => {
|
|
7
|
+
it( 'should return an empty string if no non-default params are provided', () => {
|
|
8
|
+
const expected = '';
|
|
9
|
+
|
|
10
|
+
const result = constrained.getLayoutStyle( {
|
|
11
|
+
selector: '.my-container',
|
|
12
|
+
layout: {},
|
|
13
|
+
style: {},
|
|
14
|
+
blockName: 'test-block',
|
|
15
|
+
hasBlockGapSupport: false,
|
|
16
|
+
layoutDefinitions: undefined,
|
|
17
|
+
} );
|
|
18
|
+
|
|
19
|
+
expect( result ).toBe( expected );
|
|
20
|
+
} );
|
|
21
|
+
} );
|
package/src/layouts/utils.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Utility to generate the proper CSS selector for layout styles.
|
|
3
8
|
*
|
|
@@ -62,3 +67,32 @@ export function getBlockGapCSS(
|
|
|
62
67
|
}
|
|
63
68
|
return output;
|
|
64
69
|
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Helper method to assign contextual info to clarify
|
|
73
|
+
* alignment settings.
|
|
74
|
+
*
|
|
75
|
+
* Besides checking if `contentSize` and `wideSize` have a
|
|
76
|
+
* value, we now show this information only if their values
|
|
77
|
+
* are not a `css var`. This needs to change when parsing
|
|
78
|
+
* css variables land.
|
|
79
|
+
*
|
|
80
|
+
* @see https://github.com/WordPress/gutenberg/pull/34710#issuecomment-918000752
|
|
81
|
+
*
|
|
82
|
+
* @param {Object} layout The layout object.
|
|
83
|
+
* @return {Object} An object with contextual info per alignment.
|
|
84
|
+
*/
|
|
85
|
+
export function getAlignmentsInfo( layout ) {
|
|
86
|
+
const { contentSize, wideSize } = layout;
|
|
87
|
+
const alignmentInfo = {};
|
|
88
|
+
const sizeRegex = /^(?!0)\d+(px|em|rem|vw|vh|%)?$/i;
|
|
89
|
+
if ( sizeRegex.test( contentSize ) ) {
|
|
90
|
+
// translators: %s: container size (i.e. 600px etc)
|
|
91
|
+
alignmentInfo.none = sprintf( __( 'Max %s wide' ), contentSize );
|
|
92
|
+
}
|
|
93
|
+
if ( sizeRegex.test( wideSize ) ) {
|
|
94
|
+
// translators: %s: container size (i.e. 600px etc)
|
|
95
|
+
alignmentInfo.wide = sprintf( __( 'Max %s wide' ), wideSize );
|
|
96
|
+
}
|
|
97
|
+
return alignmentInfo;
|
|
98
|
+
}
|
package/src/store/actions.js
CHANGED
|
@@ -1002,7 +1002,7 @@ export const __unstableExpandSelection =
|
|
|
1002
1002
|
*/
|
|
1003
1003
|
export const mergeBlocks =
|
|
1004
1004
|
( firstBlockClientId, secondBlockClientId ) =>
|
|
1005
|
-
( { select, dispatch } ) => {
|
|
1005
|
+
( { registry, select, dispatch } ) => {
|
|
1006
1006
|
const blocks = [ firstBlockClientId, secondBlockClientId ];
|
|
1007
1007
|
dispatch( { type: 'MERGE_BLOCKS', blocks } );
|
|
1008
1008
|
|
|
@@ -1010,13 +1010,41 @@ export const mergeBlocks =
|
|
|
1010
1010
|
const blockA = select.getBlock( clientIdA );
|
|
1011
1011
|
const blockAType = getBlockType( blockA.name );
|
|
1012
1012
|
|
|
1013
|
-
|
|
1013
|
+
if ( ! blockAType ) return;
|
|
1014
|
+
|
|
1015
|
+
const blockB = select.getBlock( clientIdB );
|
|
1016
|
+
|
|
1014
1017
|
if ( blockAType && ! blockAType.merge ) {
|
|
1015
|
-
|
|
1018
|
+
// If there's no merge function defined, attempt merging inner
|
|
1019
|
+
// blocks.
|
|
1020
|
+
const blocksWithTheSameType = switchToBlockType(
|
|
1021
|
+
blockB,
|
|
1022
|
+
blockAType.name
|
|
1023
|
+
);
|
|
1024
|
+
// Only focus the previous block if it's not mergeable.
|
|
1025
|
+
if ( blocksWithTheSameType?.length !== 1 ) {
|
|
1026
|
+
dispatch.selectBlock( blockA.clientId );
|
|
1027
|
+
return;
|
|
1028
|
+
}
|
|
1029
|
+
const [ blockWithSameType ] = blocksWithTheSameType;
|
|
1030
|
+
if ( blockWithSameType.innerBlocks.length < 1 ) {
|
|
1031
|
+
dispatch.selectBlock( blockA.clientId );
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
registry.batch( () => {
|
|
1035
|
+
dispatch.insertBlocks(
|
|
1036
|
+
blockWithSameType.innerBlocks,
|
|
1037
|
+
undefined,
|
|
1038
|
+
clientIdA
|
|
1039
|
+
);
|
|
1040
|
+
dispatch.removeBlock( clientIdB );
|
|
1041
|
+
dispatch.selectBlock(
|
|
1042
|
+
blockWithSameType.innerBlocks[ 0 ].clientId
|
|
1043
|
+
);
|
|
1044
|
+
} );
|
|
1016
1045
|
return;
|
|
1017
1046
|
}
|
|
1018
1047
|
|
|
1019
|
-
const blockB = select.getBlock( clientIdB );
|
|
1020
1048
|
const blockBType = getBlockType( blockB.name );
|
|
1021
1049
|
const { clientId, attributeKey, offset } = select.getSelectionStart();
|
|
1022
1050
|
const selectedBlockType =
|
package/src/store/selectors.js
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
some,
|
|
11
11
|
find,
|
|
12
12
|
filter,
|
|
13
|
-
mapKeys,
|
|
14
13
|
orderBy,
|
|
15
14
|
} from 'lodash';
|
|
16
15
|
import createSelector from 'rememo';
|
|
@@ -2078,9 +2077,11 @@ export const getBlockTransformItems = createSelector(
|
|
|
2078
2077
|
)
|
|
2079
2078
|
.map( buildBlockTypeTransformItem );
|
|
2080
2079
|
|
|
2081
|
-
const itemsByName =
|
|
2082
|
-
blockTypeTransformItems,
|
|
2083
|
-
|
|
2080
|
+
const itemsByName = Object.fromEntries(
|
|
2081
|
+
Object.entries( blockTypeTransformItems ).map( ( [ , value ] ) => [
|
|
2082
|
+
value.name,
|
|
2083
|
+
value,
|
|
2084
|
+
] )
|
|
2084
2085
|
);
|
|
2085
2086
|
|
|
2086
2087
|
// Consider unwraping the highest priority.
|
package/src/style.scss
CHANGED
|
@@ -46,8 +46,6 @@
|
|
|
46
46
|
@import "./components/responsive-block-control/style.scss";
|
|
47
47
|
@import "./components/rich-text/style.scss";
|
|
48
48
|
@import "./components/skip-to-selected-block/style.scss";
|
|
49
|
-
@import "./components/text-transform-control/style.scss";
|
|
50
|
-
@import "./components/text-decoration-control/style.scss";
|
|
51
49
|
@import "./components/tool-selector/style.scss";
|
|
52
50
|
@import "./components/url-input/style.scss";
|
|
53
51
|
@import "./components/url-popover/style.scss";
|
|
@@ -63,5 +61,6 @@
|
|
|
63
61
|
@import "./components/block-toolbar/style.scss";
|
|
64
62
|
@import "./components/inserter/style.scss";
|
|
65
63
|
@import "./components/preview-options/style.scss";
|
|
64
|
+
@import "./components/spacing-sizes-control/style.scss";
|
|
66
65
|
|
|
67
66
|
@include wordpress-admin-schemes();
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = BlockEditVisuallyButton;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
|
-
var _blocks = require("@wordpress/blocks");
|
|
15
|
-
|
|
16
|
-
var _components = require("@wordpress/components");
|
|
17
|
-
|
|
18
|
-
var _i18n = require("@wordpress/i18n");
|
|
19
|
-
|
|
20
|
-
var _data = require("@wordpress/data");
|
|
21
|
-
|
|
22
|
-
var _store = require("../../store");
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* WordPress dependencies
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Internal dependencies
|
|
30
|
-
*/
|
|
31
|
-
function BlockEditVisuallyButton(_ref) {
|
|
32
|
-
let {
|
|
33
|
-
clientIds,
|
|
34
|
-
...props
|
|
35
|
-
} = _ref;
|
|
36
|
-
const {
|
|
37
|
-
block,
|
|
38
|
-
shouldRender
|
|
39
|
-
} = (0, _data.useSelect)(select => {
|
|
40
|
-
const firstBlockClientId = clientIds[0];
|
|
41
|
-
const {
|
|
42
|
-
isBlockMultiSelected,
|
|
43
|
-
getBlockMode,
|
|
44
|
-
getBlock
|
|
45
|
-
} = select(_store.store);
|
|
46
|
-
const isSingleSelected = !isBlockMultiSelected(firstBlockClientId);
|
|
47
|
-
const isHtmlMode = getBlockMode(firstBlockClientId) === 'html';
|
|
48
|
-
return {
|
|
49
|
-
block: getBlock(firstBlockClientId),
|
|
50
|
-
shouldRender: isSingleSelected && isHtmlMode
|
|
51
|
-
};
|
|
52
|
-
}, [clientIds[0]]);
|
|
53
|
-
const {
|
|
54
|
-
replaceBlocks
|
|
55
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
56
|
-
const onClick = (0, _element.useCallback)(() => {
|
|
57
|
-
replaceBlocks(block.clientId, (0, _blocks.rawHandler)({
|
|
58
|
-
HTML: (0, _blocks.getBlockContent)(block)
|
|
59
|
-
}));
|
|
60
|
-
}, [block]);
|
|
61
|
-
|
|
62
|
-
if (!shouldRender) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return (0, _element.createElement)(_components.ToolbarGroup, null, (0, _element.createElement)(_components.ToolbarButton, (0, _extends2.default)({
|
|
67
|
-
onClick: onClick
|
|
68
|
-
}, props), (0, _i18n.__)('Edit visually')));
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=block-edit-visually-button.js.map
|