@wordpress/block-editor 9.3.0 → 9.6.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 +6 -0
- package/README.md +1 -8
- package/build/components/block-list/block-invalid-warning.native.js +54 -6
- package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build/components/block-list/block.js +2 -2
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +2 -1
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +4 -3
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/layout.js +20 -5
- package/build/components/block-list/layout.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js +5 -2
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build/components/block-lock/modal.js +37 -7
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mover/mover-description.js +95 -32
- package/build/components/block-mover/mover-description.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +8 -26
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +3 -8
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-popover/inbetween.js +1 -1
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +1 -1
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/auto.js +21 -5
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings-menu/block-edit-visually-button.js +70 -0
- package/build/components/block-settings-menu/block-edit-visually-button.js.map +1 -0
- package/build/components/block-settings-menu/block-mode-toggle.js +1 -1
- package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +5 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu/index.js +6 -2
- package/build/components/block-settings-menu/index.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +5 -2
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/block-switcher/index.js +7 -1
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-title/index.js +8 -2
- package/build/components/block-title/index.js.map +1 -1
- package/build/components/block-title/use-block-display-title.js +15 -15
- package/build/components/block-title/use-block-display-title.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +1 -7
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +4 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-types-list/index.native.js +65 -23
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/border-radius-control/index.js +2 -0
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/colors/with-colors.js +1 -1
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/control.js +46 -39
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +7 -3
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/date-format-picker/index.js +1 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/duotone/components.js +145 -0
- package/build/components/duotone/components.js.map +1 -0
- package/build/components/duotone/index.js +40 -0
- package/build/components/duotone/index.js.map +1 -0
- package/build/components/duotone/utils.js +38 -0
- package/build/components/duotone/utils.js.map +1 -0
- package/build/components/duotone-control/index.js +17 -5
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/iframe/index.js +19 -6
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/cropper.js +4 -3
- package/build/components/image-editor/cropper.js.map +1 -1
- package/build/components/image-editor/index.js +3 -1
- package/build/components/image-editor/index.js.map +1 -1
- package/build/components/index.js +14 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/block-types-tab.native.js +30 -16
- package/build/components/inserter/block-types-tab.native.js.map +1 -1
- package/build/components/inserter/index.js +3 -3
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/preview-panel.js +8 -8
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +5 -1
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/search-results.native.js +5 -2
- package/build/components/inserter/search-results.native.js.map +1 -1
- package/build/components/inserter/utils.native.js +21 -0
- package/build/components/inserter/utils.native.js.map +1 -1
- package/build/components/inserter-list-item/index.js +5 -1
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/link-control/index.js +1 -1
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +15 -7
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/branch.js +1 -7
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +1 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/media-placeholder/index.js +14 -2
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-placeholder/index.native.js +4 -4
- package/build/components/media-placeholder/index.native.js.map +1 -1
- package/build/components/media-replace-flow/index.js +6 -13
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/observe-typing/index.js +22 -8
- package/build/components/observe-typing/index.js.map +1 -1
- package/build/components/publish-date-time-picker/index.js +3 -0
- package/build/components/publish-date-time-picker/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +61 -12
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/index.js +2 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-format-types.js +36 -16
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build/components/rich-text/use-input-rules.js +4 -13
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +20 -5
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/url-popover/index.js +2 -1
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +34 -2
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +3 -47
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +1 -3
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +1 -1
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/elements/index.js +11 -3
- package/build/elements/index.js.map +1 -1
- package/build/hooks/aria-label.js +71 -0
- package/build/hooks/aria-label.js.map +1 -0
- package/build/hooks/color.js +2 -4
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/duotone.js +33 -160
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +11 -7
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +59 -18
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/style.js +41 -31
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +5 -3
- package/build/hooks/utils.js.map +1 -1
- package/build/index.js +7 -7
- package/build/index.js.map +1 -1
- package/build/layouts/flex.js +42 -38
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +35 -37
- package/build/layouts/flow.js.map +1 -1
- package/build/layouts/utils.js +35 -3
- package/build/layouts/utils.js.map +1 -1
- package/build/store/actions.js +24 -31
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +0 -4
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +23 -12
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +3 -3
- package/build/store/selectors.js.map +1 -1
- package/build/utils/selection.js +34 -0
- package/build/utils/selection.js.map +1 -0
- package/build-module/components/block-list/block-invalid-warning.native.js +50 -6
- package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build-module/components/block-list/block.js +2 -2
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +2 -1
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +3 -1
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/layout.js +19 -4
- package/build-module/components/block-list/layout.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +5 -2
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build-module/components/block-lock/modal.js +39 -8
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +2 -2
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mover/mover-description.js +97 -33
- package/build-module/components/block-mover/mover-description.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +9 -27
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +3 -8
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +1 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +1 -1
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +20 -5
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings-menu/block-edit-visually-button.js +56 -0
- package/build-module/components/block-settings-menu/block-edit-visually-button.js.map +1 -0
- package/build-module/components/block-settings-menu/block-mode-toggle.js +1 -1
- package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +6 -5
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu/index.js +6 -3
- package/build-module/components/block-settings-menu/index.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +7 -4
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/block-switcher/index.js +7 -1
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-title/index.js +8 -2
- package/build-module/components/block-title/index.js.map +1 -1
- package/build-module/components/block-title/use-block-display-title.js +15 -14
- package/build-module/components/block-title/use-block-display-title.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +1 -7
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +4 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +67 -25
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +2 -0
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/colors/with-colors.js +2 -2
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +47 -40
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +8 -4
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +1 -1
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/duotone/components.js +130 -0
- package/build-module/components/duotone/components.js.map +1 -0
- package/build-module/components/duotone/index.js +3 -0
- package/build-module/components/duotone/index.js.map +1 -0
- package/build-module/components/duotone/utils.js +30 -0
- package/build-module/components/duotone/utils.js.map +1 -0
- package/build-module/components/duotone-control/index.js +18 -6
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/iframe/index.js +19 -6
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/cropper.js +4 -3
- package/build-module/components/image-editor/cropper.js.map +1 -1
- package/build-module/components/image-editor/index.js +3 -1
- package/build-module/components/image-editor/index.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/inserter/block-types-tab.native.js +31 -15
- package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
- package/build-module/components/inserter/index.js +3 -2
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +9 -9
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +6 -2
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/search-results.native.js +6 -3
- package/build-module/components/inserter/search-results.native.js.map +1 -1
- package/build-module/components/inserter/utils.native.js +19 -0
- package/build-module/components/inserter/utils.native.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +4 -1
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/link-control/index.js +1 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +16 -8
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/branch.js +1 -6
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +1 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +14 -2
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-placeholder/index.native.js +5 -3
- package/build-module/components/media-placeholder/index.native.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +7 -13
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/observe-typing/index.js +22 -8
- package/build-module/components/observe-typing/index.js.map +1 -1
- package/build-module/components/publish-date-time-picker/index.js +2 -0
- package/build-module/components/publish-date-time-picker/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +58 -12
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-format-types.js +37 -18
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/components/rich-text/use-input-rules.js +3 -11
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +20 -5
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/url-popover/index.js +2 -1
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +35 -3
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +3 -45
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +1 -3
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/elements/index.js +7 -1
- package/build-module/elements/index.js.map +1 -1
- package/build-module/hooks/aria-label.js +59 -0
- package/build-module/hooks/aria-label.js.map +1 -0
- package/build-module/hooks/color.js +2 -3
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/duotone.js +22 -140
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +60 -19
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/style.js +44 -35
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +5 -2
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/flex.js +43 -35
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +35 -38
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/layouts/utils.js +33 -3
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/store/actions.js +14 -20
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +0 -4
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +23 -11
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +4 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/selection.js +24 -0
- package/build-module/utils/selection.js.map +1 -0
- package/build-style/style-rtl.css +43 -13
- package/build-style/style.css +43 -13
- package/package.json +28 -28
- package/src/components/block-draggable/test/helpers.native.js +3 -3
- package/src/components/block-list/block-invalid-warning.native.js +42 -7
- package/src/components/block-list/block.js +2 -2
- package/src/components/block-list/block.native.js +1 -0
- package/src/components/block-list/index.native.js +1 -1
- package/src/components/block-list/layout.js +15 -3
- package/src/components/block-list/style.scss +2 -2
- package/src/components/block-list/use-block-props/use-block-class-names.js +5 -1
- package/src/components/block-lock/modal.js +47 -9
- package/src/components/block-lock/style.scss +10 -0
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +3 -3
- package/src/components/block-mover/mover-description.js +131 -48
- package/src/components/block-mover/test/mover-description.js +55 -3
- package/src/components/block-pattern-setup/index.js +5 -25
- package/src/components/block-pattern-setup/setup-toolbar.js +2 -9
- package/src/components/block-pattern-setup/style.scss +4 -2
- package/src/components/block-popover/inbetween.js +1 -1
- package/src/components/block-popover/index.js +1 -1
- package/src/components/block-preview/auto.js +17 -3
- package/src/components/block-settings-menu/block-edit-visually-button.js +52 -0
- package/src/components/block-settings-menu/block-mode-toggle.js +1 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +7 -3
- package/src/components/block-settings-menu/index.js +15 -11
- package/src/components/block-settings-menu-controls/index.js +5 -4
- package/src/components/block-styles/preview.native.js +1 -0
- package/src/components/block-switcher/index.js +7 -1
- package/src/components/block-title/index.js +3 -2
- package/src/components/block-title/use-block-display-title.js +20 -12
- package/src/components/block-tools/block-contextual-toolbar.js +3 -1
- package/src/components/block-tools/block-selection-button.js +0 -5
- package/src/components/block-tools/index.js +4 -1
- package/src/components/block-types-list/index.native.js +76 -24
- package/src/components/block-types-list/style.native.scss +18 -0
- package/src/components/border-radius-control/index.js +2 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +0 -4
- package/src/components/colors/test/__snapshots__/with-colors.js.snap +1 -1
- package/src/components/colors/test/with-colors.js +1 -1
- package/src/components/colors/with-colors.js +2 -2
- package/src/components/colors-gradients/control.js +78 -65
- package/src/components/colors-gradients/dropdown.js +9 -2
- package/src/components/colors-gradients/style.scss +11 -8
- package/src/components/colors-gradients/test/control.js +16 -23
- package/src/components/date-format-picker/index.js +1 -0
- package/src/components/duotone/components.js +133 -0
- package/src/components/duotone/index.js +7 -0
- package/src/components/duotone/utils.js +25 -0
- package/src/components/duotone-control/index.js +12 -7
- package/src/components/duotone-control/style.scss +5 -0
- package/src/components/iframe/index.js +25 -6
- package/src/components/image-editor/cropper.js +9 -3
- package/src/components/image-editor/index.js +2 -0
- package/src/components/index.js +1 -0
- package/src/components/inserter/block-types-tab.native.js +42 -21
- package/src/components/inserter/index.js +3 -5
- package/src/components/inserter/preview-panel.js +6 -14
- package/src/components/inserter/reusable-blocks-tab.native.js +4 -2
- package/src/components/inserter/search-results.native.js +4 -2
- package/src/components/inserter/style.scss +1 -1
- package/src/components/inserter/test/block-types-tab.native.js +2 -0
- package/src/components/inserter/test/utils.native.js +37 -0
- package/src/components/inserter/utils.native.js +11 -0
- package/src/components/inserter-list-item/index.js +4 -1
- package/src/components/link-control/index.js +1 -0
- package/src/components/link-control/test/fixtures/index.js +3 -4
- package/src/components/link-control/test/index.js +64 -73
- package/src/components/list-view/block-select-button.js +29 -14
- package/src/components/list-view/branch.js +1 -6
- package/src/components/list-view/drop-indicator.js +1 -1
- package/src/components/list-view/style.scss +18 -4
- package/src/components/media-placeholder/index.js +20 -0
- package/src/components/media-placeholder/index.native.js +9 -5
- package/src/components/media-replace-flow/index.js +5 -14
- package/src/components/media-replace-flow/test/index.js +14 -4
- package/src/components/media-upload/README.md +8 -0
- package/src/components/observe-typing/index.js +17 -14
- package/src/components/publish-date-time-picker/index.js +2 -0
- package/src/components/responsive-block-control/README.md +3 -1
- package/src/components/responsive-block-control/test/index.js +1 -2
- package/src/components/rich-text/format-toolbar-container.js +63 -14
- package/src/components/rich-text/index.js +1 -0
- package/src/components/rich-text/use-format-types.js +38 -17
- package/src/components/rich-text/use-input-rules.js +6 -15
- package/src/components/rich-text/use-paste-handler.js +17 -5
- package/src/components/url-popover/index.js +1 -0
- package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -0
- package/src/components/writing-flow/use-arrow-nav.js +32 -1
- package/src/components/writing-flow/use-multi-selection.js +1 -48
- package/src/components/writing-flow/use-selection-observer.js +2 -3
- package/src/components/writing-flow/use-tab-nav.js +1 -1
- package/src/elements/index.js +8 -1
- package/src/elements/test/index.js +18 -0
- package/src/hooks/aria-label.js +67 -0
- package/src/hooks/color.js +10 -3
- package/src/hooks/duotone.js +18 -139
- package/src/hooks/index.js +2 -1
- package/src/hooks/layout.js +77 -29
- package/src/hooks/style.js +46 -39
- package/src/hooks/utils.js +7 -3
- package/src/index.js +1 -1
- package/src/layouts/flex.js +49 -43
- package/src/layouts/flow.js +35 -34
- package/src/layouts/test/flex.js +21 -0
- package/src/layouts/test/flow.js +21 -0
- package/src/layouts/test/utils.js +138 -0
- package/src/layouts/utils.js +44 -3
- package/src/store/actions.js +17 -31
- package/src/store/index.js +0 -4
- package/src/store/reducer.js +24 -11
- package/src/store/selectors.js +3 -4
- package/src/store/test/reducer.js +138 -10
- package/src/store/test/selectors.js +3 -6
- package/src/utils/selection.js +26 -0
- package/src/utils/test/selection.js +39 -0
- package/tsconfig.json +2 -1
package/src/hooks/layout.js
CHANGED
|
@@ -9,7 +9,11 @@ import { has, kebabCase } from 'lodash';
|
|
|
9
9
|
*/
|
|
10
10
|
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
|
|
11
11
|
import { addFilter } from '@wordpress/hooks';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
getBlockDefaultClassName,
|
|
14
|
+
getBlockSupport,
|
|
15
|
+
hasBlockSupport,
|
|
16
|
+
} from '@wordpress/blocks';
|
|
13
17
|
import { useSelect } from '@wordpress/data';
|
|
14
18
|
import {
|
|
15
19
|
Button,
|
|
@@ -40,35 +44,40 @@ const layoutBlockSupportKey = '__experimentalLayout';
|
|
|
40
44
|
* have the style engine generate a more extensive list of utility classnames which
|
|
41
45
|
* will then replace this method.
|
|
42
46
|
*
|
|
43
|
-
* @param {
|
|
47
|
+
* @param { Object } layout Layout object.
|
|
48
|
+
* @param { Object } layoutDefinitions An object containing layout definitions, stored in theme.json.
|
|
44
49
|
*
|
|
45
50
|
* @return { Array } Array of CSS classname strings.
|
|
46
51
|
*/
|
|
47
|
-
function
|
|
52
|
+
function useLayoutClasses( layout, layoutDefinitions ) {
|
|
53
|
+
const rootPaddingAlignment = useSelect( ( select ) => {
|
|
54
|
+
const { getSettings } = select( blockEditorStore );
|
|
55
|
+
return getSettings().__experimentalFeatures
|
|
56
|
+
?.useRootPaddingAwareAlignments;
|
|
57
|
+
}, [] );
|
|
48
58
|
const layoutClassnames = [];
|
|
49
59
|
|
|
50
|
-
if (
|
|
51
|
-
return layoutClassnames;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if ( attributes?.layout?.orientation ) {
|
|
60
|
+
if ( layoutDefinitions?.[ layout?.type || 'default' ]?.className ) {
|
|
55
61
|
layoutClassnames.push(
|
|
56
|
-
|
|
62
|
+
layoutDefinitions?.[ layout?.type || 'default' ]?.className
|
|
57
63
|
);
|
|
58
64
|
}
|
|
59
65
|
|
|
60
|
-
if (
|
|
66
|
+
if ( ( layout?.inherit || layout?.contentSize ) && rootPaddingAlignment ) {
|
|
67
|
+
layoutClassnames.push( 'has-global-padding' );
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if ( layout?.orientation ) {
|
|
71
|
+
layoutClassnames.push( `is-${ kebabCase( layout.orientation ) }` );
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if ( layout?.justifyContent ) {
|
|
61
75
|
layoutClassnames.push(
|
|
62
|
-
`is-content-justification-${ kebabCase(
|
|
63
|
-
attributes.layout.justifyContent
|
|
64
|
-
) }`
|
|
76
|
+
`is-content-justification-${ kebabCase( layout.justifyContent ) }`
|
|
65
77
|
);
|
|
66
78
|
}
|
|
67
79
|
|
|
68
|
-
if (
|
|
69
|
-
attributes?.layout?.flexWrap &&
|
|
70
|
-
attributes.layout.flexWrap === 'nowrap'
|
|
71
|
-
) {
|
|
80
|
+
if ( layout?.flexWrap && layout.flexWrap === 'nowrap' ) {
|
|
72
81
|
layoutClassnames.push( 'is-nowrap' );
|
|
73
82
|
}
|
|
74
83
|
|
|
@@ -130,15 +139,28 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
|
|
|
130
139
|
<InspectorControls>
|
|
131
140
|
<PanelBody title={ __( 'Layout' ) }>
|
|
132
141
|
{ showInheritToggle && (
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
+
<>
|
|
143
|
+
<ToggleControl
|
|
144
|
+
label={ __( 'Inner blocks use full width' ) }
|
|
145
|
+
checked={ ! inherit }
|
|
146
|
+
onChange={ () =>
|
|
147
|
+
setAttributes( {
|
|
148
|
+
layout: {
|
|
149
|
+
inherit: ! inherit,
|
|
150
|
+
},
|
|
151
|
+
} )
|
|
152
|
+
}
|
|
153
|
+
/>
|
|
154
|
+
<p className="block-editor-hooks__layout-controls-helptext">
|
|
155
|
+
{ !! inherit
|
|
156
|
+
? __(
|
|
157
|
+
'Nested blocks use theme content width with options for full and wide widths.'
|
|
158
|
+
)
|
|
159
|
+
: __(
|
|
160
|
+
'Nested blocks will fill the width of this container.'
|
|
161
|
+
) }
|
|
162
|
+
</p>
|
|
163
|
+
</>
|
|
142
164
|
) }
|
|
143
165
|
|
|
144
166
|
{ ! inherit && allowSwitching && (
|
|
@@ -256,12 +278,36 @@ export const withLayoutStyles = createHigherOrderComponent(
|
|
|
256
278
|
? defaultThemeLayout
|
|
257
279
|
: layout || defaultBlockLayout || {};
|
|
258
280
|
const layoutClasses = shouldRenderLayoutStyles
|
|
259
|
-
?
|
|
281
|
+
? useLayoutClasses( usedLayout, defaultThemeLayout?.definitions )
|
|
260
282
|
: null;
|
|
283
|
+
const selector = `.${ getBlockDefaultClassName(
|
|
284
|
+
name
|
|
285
|
+
) }.wp-container-${ id }`;
|
|
286
|
+
const blockGapSupport = useSetting( 'spacing.blockGap' );
|
|
287
|
+
const hasBlockGapSupport = blockGapSupport !== null;
|
|
288
|
+
|
|
289
|
+
// Get CSS string for the current layout type.
|
|
290
|
+
// The CSS and `style` element is only output if it is not empty.
|
|
291
|
+
let css;
|
|
292
|
+
if ( shouldRenderLayoutStyles ) {
|
|
293
|
+
const fullLayoutType = getLayoutType(
|
|
294
|
+
usedLayout?.type || 'default'
|
|
295
|
+
);
|
|
296
|
+
css = fullLayoutType?.getLayoutStyle?.( {
|
|
297
|
+
blockName: name,
|
|
298
|
+
selector,
|
|
299
|
+
layout: usedLayout,
|
|
300
|
+
layoutDefinitions: defaultThemeLayout?.definitions,
|
|
301
|
+
style: attributes?.style,
|
|
302
|
+
hasBlockGapSupport,
|
|
303
|
+
} );
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.
|
|
261
307
|
const className = classnames(
|
|
262
308
|
props?.className,
|
|
263
309
|
{
|
|
264
|
-
[ `wp-container-${ id }` ]: shouldRenderLayoutStyles,
|
|
310
|
+
[ `wp-container-${ id }` ]: shouldRenderLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.
|
|
265
311
|
},
|
|
266
312
|
layoutClasses
|
|
267
313
|
);
|
|
@@ -270,10 +316,12 @@ export const withLayoutStyles = createHigherOrderComponent(
|
|
|
270
316
|
<>
|
|
271
317
|
{ shouldRenderLayoutStyles &&
|
|
272
318
|
element &&
|
|
319
|
+
!! css &&
|
|
273
320
|
createPortal(
|
|
274
321
|
<LayoutStyle
|
|
275
322
|
blockName={ name }
|
|
276
|
-
selector={
|
|
323
|
+
selector={ selector }
|
|
324
|
+
css={ css }
|
|
277
325
|
layout={ usedLayout }
|
|
278
326
|
style={ attributes?.style }
|
|
279
327
|
/>,
|
package/src/hooks/style.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { get, has,
|
|
4
|
+
import { get, has, omit } from 'lodash';
|
|
5
5
|
import classnames from 'classnames';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
import { useContext, createPortal } from '@wordpress/element';
|
|
10
|
+
import { useContext, useMemo, createPortal } from '@wordpress/element';
|
|
11
11
|
import { addFilter } from '@wordpress/hooks';
|
|
12
12
|
import {
|
|
13
13
|
getBlockSupport,
|
|
@@ -16,7 +16,10 @@ import {
|
|
|
16
16
|
__EXPERIMENTAL_ELEMENTS as ELEMENTS,
|
|
17
17
|
} from '@wordpress/blocks';
|
|
18
18
|
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
getCSSRules,
|
|
21
|
+
generate as generateStyles,
|
|
22
|
+
} from '@wordpress/style-engine';
|
|
20
23
|
|
|
21
24
|
/**
|
|
22
25
|
* Internal dependencies
|
|
@@ -68,6 +71,9 @@ export function getInlineStyles( styles = {} ) {
|
|
|
68
71
|
const ignoredStyles = [ 'spacing.blockGap' ];
|
|
69
72
|
const output = {};
|
|
70
73
|
Object.keys( STYLE_PROPERTY ).forEach( ( propKey ) => {
|
|
74
|
+
if ( STYLE_PROPERTY[ propKey ].rootOnly ) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
71
77
|
const path = STYLE_PROPERTY[ propKey ].value;
|
|
72
78
|
const subPaths = STYLE_PROPERTY[ propKey ].properties;
|
|
73
79
|
// Ignore styles on elements because they are handled on the server.
|
|
@@ -105,28 +111,6 @@ export function getInlineStyles( styles = {} ) {
|
|
|
105
111
|
return output;
|
|
106
112
|
}
|
|
107
113
|
|
|
108
|
-
function compileElementsStyles( selector, elements = {} ) {
|
|
109
|
-
return Object.entries( elements )
|
|
110
|
-
.map( ( [ element, styles ] ) => {
|
|
111
|
-
const elementStyles = getInlineStyles( styles );
|
|
112
|
-
if ( ! isEmpty( elementStyles ) ) {
|
|
113
|
-
// The .editor-styles-wrapper selector is required on elements styles. As it is
|
|
114
|
-
// added to all other editor styles, not providing it causes reset and global
|
|
115
|
-
// styles to override element styles because of higher specificity.
|
|
116
|
-
return [
|
|
117
|
-
`.editor-styles-wrapper .${ selector } ${ ELEMENTS[ element ] }{`,
|
|
118
|
-
...Object.entries( elementStyles ).map(
|
|
119
|
-
( [ cssProperty, value ] ) =>
|
|
120
|
-
`\t${ kebabCase( cssProperty ) }: ${ value };`
|
|
121
|
-
),
|
|
122
|
-
'}',
|
|
123
|
-
].join( '\n' );
|
|
124
|
-
}
|
|
125
|
-
return '';
|
|
126
|
-
} )
|
|
127
|
-
.join( '\n' );
|
|
128
|
-
}
|
|
129
|
-
|
|
130
114
|
/**
|
|
131
115
|
* Filters registered block settings, extending attributes to include `style` attribute.
|
|
132
116
|
*
|
|
@@ -323,23 +307,46 @@ const withElementsStyles = createHigherOrderComponent(
|
|
|
323
307
|
'link'
|
|
324
308
|
);
|
|
325
309
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
310
|
+
const styles = useMemo( () => {
|
|
311
|
+
const rawElementsStyles = props.attributes.style?.elements;
|
|
312
|
+
const elementCssRules = [];
|
|
313
|
+
if (
|
|
314
|
+
rawElementsStyles &&
|
|
315
|
+
Object.keys( rawElementsStyles ).length > 0
|
|
316
|
+
) {
|
|
317
|
+
// Remove values based on whether serialization has been skipped for a specific style.
|
|
318
|
+
const filteredElementsStyles = {
|
|
319
|
+
...rawElementsStyles,
|
|
320
|
+
link: {
|
|
321
|
+
...rawElementsStyles.link,
|
|
322
|
+
color: ! skipLinkColorSerialization
|
|
323
|
+
? rawElementsStyles.link?.color
|
|
324
|
+
: undefined,
|
|
325
|
+
},
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
for ( const [ elementName, elementStyles ] of Object.entries(
|
|
329
|
+
filteredElementsStyles
|
|
330
|
+
) ) {
|
|
331
|
+
const cssRule = generateStyles( elementStyles, {
|
|
332
|
+
// The .editor-styles-wrapper selector is required on elements styles. As it is
|
|
333
|
+
// added to all other editor styles, not providing it causes reset and global
|
|
334
|
+
// styles to override element styles because of higher specificity.
|
|
335
|
+
selector: `.editor-styles-wrapper .${ blockElementsContainerIdentifier } ${ ELEMENTS[ elementName ] }`,
|
|
336
|
+
} );
|
|
337
|
+
if ( !! cssRule ) {
|
|
338
|
+
elementCssRules.push( cssRule );
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return elementCssRules.length > 0 ? elementCssRules : undefined;
|
|
343
|
+
}, [ props.attributes.style?.elements ] );
|
|
344
|
+
|
|
338
345
|
const element = useContext( BlockList.__unstableElementContext );
|
|
339
346
|
|
|
340
347
|
return (
|
|
341
348
|
<>
|
|
342
|
-
{
|
|
349
|
+
{ styles &&
|
|
343
350
|
element &&
|
|
344
351
|
createPortal(
|
|
345
352
|
<style
|
|
@@ -353,7 +360,7 @@ const withElementsStyles = createHigherOrderComponent(
|
|
|
353
360
|
<BlockListBlock
|
|
354
361
|
{ ...props }
|
|
355
362
|
className={
|
|
356
|
-
elements
|
|
363
|
+
props.attributes.style?.elements
|
|
357
364
|
? classnames(
|
|
358
365
|
props.className,
|
|
359
366
|
blockElementsContainerIdentifier
|
package/src/hooks/utils.js
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
import {
|
|
5
5
|
pickBy,
|
|
6
6
|
isEmpty,
|
|
7
|
-
isObject,
|
|
8
|
-
identity,
|
|
9
7
|
mapValues,
|
|
10
8
|
forEach,
|
|
11
9
|
get,
|
|
@@ -19,6 +17,8 @@ import {
|
|
|
19
17
|
*/
|
|
20
18
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
21
19
|
|
|
20
|
+
const identity = ( x ) => x;
|
|
21
|
+
|
|
22
22
|
/**
|
|
23
23
|
* Removed falsy values from nested object.
|
|
24
24
|
*
|
|
@@ -26,7 +26,11 @@ import { getBlockSupport } from '@wordpress/blocks';
|
|
|
26
26
|
* @return {*} Object cleaned from falsy values
|
|
27
27
|
*/
|
|
28
28
|
export const cleanEmptyObject = ( object ) => {
|
|
29
|
-
if (
|
|
29
|
+
if (
|
|
30
|
+
object === null ||
|
|
31
|
+
typeof object !== 'object' ||
|
|
32
|
+
Array.isArray( object )
|
|
33
|
+
) {
|
|
30
34
|
return object;
|
|
31
35
|
}
|
|
32
36
|
const cleanedNestedObjects = pickBy(
|
package/src/index.js
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import './hooks';
|
|
5
5
|
export {
|
|
6
|
-
PresetDuotoneFilter as __unstablePresetDuotoneFilter,
|
|
7
6
|
getBorderClassesAndStyles as __experimentalGetBorderClassesAndStyles,
|
|
8
7
|
useBorderProps as __experimentalUseBorderProps,
|
|
9
8
|
getColorClassesAndStyles as __experimentalGetColorClassesAndStyles,
|
|
10
9
|
useColorProps as __experimentalUseColorProps,
|
|
11
10
|
useCustomSides as __experimentalUseCustomSides,
|
|
12
11
|
getSpacingClassesAndStyles as __experimentalGetSpacingClassesAndStyles,
|
|
12
|
+
getGapCSSValue as __experimentalGetGapCSSValue,
|
|
13
13
|
useCachedTruthy,
|
|
14
14
|
} from './hooks';
|
|
15
15
|
export * from './components';
|
package/src/layouts/flex.js
CHANGED
|
@@ -11,14 +11,12 @@ import {
|
|
|
11
11
|
arrowDown,
|
|
12
12
|
} from '@wordpress/icons';
|
|
13
13
|
import { Button, ToggleControl, Flex, FlexItem } from '@wordpress/components';
|
|
14
|
-
import { getBlockSupport } from '@wordpress/blocks';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Internal dependencies
|
|
18
17
|
*/
|
|
19
|
-
import { appendSelectors } from './utils';
|
|
18
|
+
import { appendSelectors, getBlockGapCSS } from './utils';
|
|
20
19
|
import { getGapCSSValue } from '../hooks/gap';
|
|
21
|
-
import useSetting from '../components/use-setting';
|
|
22
20
|
import {
|
|
23
21
|
BlockControls,
|
|
24
22
|
JustifyContentControl,
|
|
@@ -107,59 +105,67 @@ export default {
|
|
|
107
105
|
</BlockControls>
|
|
108
106
|
);
|
|
109
107
|
},
|
|
110
|
-
|
|
108
|
+
getLayoutStyle: function getLayoutStyle( {
|
|
109
|
+
selector,
|
|
110
|
+
layout,
|
|
111
|
+
style,
|
|
112
|
+
blockName,
|
|
113
|
+
hasBlockGapSupport,
|
|
114
|
+
layoutDefinitions,
|
|
115
|
+
} ) {
|
|
111
116
|
const { orientation = 'horizontal' } = layout;
|
|
112
|
-
const blockGapSupport = useSetting( 'spacing.blockGap' );
|
|
113
|
-
const fallbackValue =
|
|
114
|
-
getBlockSupport( blockName, [
|
|
115
|
-
'spacing',
|
|
116
|
-
'blockGap',
|
|
117
|
-
'__experimentalDefault',
|
|
118
|
-
] ) || '0.5em';
|
|
119
117
|
|
|
120
|
-
const hasBlockGapStylesSupport = blockGapSupport !== null;
|
|
121
118
|
// If a block's block.json skips serialization for spacing or spacing.blockGap,
|
|
122
119
|
// don't apply the user-defined value to the styles.
|
|
123
120
|
const blockGapValue =
|
|
124
121
|
style?.spacing?.blockGap &&
|
|
125
122
|
! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )
|
|
126
|
-
? getGapCSSValue( style?.spacing?.blockGap
|
|
127
|
-
:
|
|
128
|
-
const justifyContent =
|
|
129
|
-
justifyContentMap[ layout.justifyContent ] ||
|
|
130
|
-
justifyContentMap.left;
|
|
123
|
+
? getGapCSSValue( style?.spacing?.blockGap )
|
|
124
|
+
: undefined;
|
|
125
|
+
const justifyContent = justifyContentMap[ layout.justifyContent ];
|
|
131
126
|
const flexWrap = flexWrapOptions.includes( layout.flexWrap )
|
|
132
127
|
? layout.flexWrap
|
|
133
128
|
: 'wrap';
|
|
134
129
|
const verticalAlignment =
|
|
135
|
-
verticalAlignmentMap[ layout.verticalAlignment ]
|
|
136
|
-
verticalAlignmentMap.center;
|
|
137
|
-
const rowOrientation = `
|
|
138
|
-
flex-direction: row;
|
|
139
|
-
align-items: ${ verticalAlignment };
|
|
140
|
-
justify-content: ${ justifyContent };
|
|
141
|
-
`;
|
|
130
|
+
verticalAlignmentMap[ layout.verticalAlignment ];
|
|
142
131
|
const alignItems =
|
|
143
132
|
alignItemsMap[ layout.justifyContent ] || alignItemsMap.left;
|
|
144
|
-
const columnOrientation = `
|
|
145
|
-
flex-direction: column;
|
|
146
|
-
align-items: ${ alignItems };
|
|
147
|
-
`;
|
|
148
133
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
${ appendSelectors( selector ) } {
|
|
152
|
-
display: flex;
|
|
153
|
-
flex-wrap: ${ flexWrap };
|
|
154
|
-
gap: ${ hasBlockGapStylesSupport ? blockGapValue : fallbackValue };
|
|
155
|
-
${ orientation === 'horizontal' ? rowOrientation : columnOrientation }
|
|
156
|
-
}
|
|
134
|
+
let output = '';
|
|
135
|
+
const rules = [];
|
|
157
136
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
)
|
|
137
|
+
if ( flexWrap && flexWrap !== 'wrap' ) {
|
|
138
|
+
rules.push( `flex-wrap: ${ flexWrap }` );
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if ( orientation === 'horizontal' ) {
|
|
142
|
+
if ( verticalAlignment ) {
|
|
143
|
+
rules.push( `align-items: ${ verticalAlignment }` );
|
|
144
|
+
}
|
|
145
|
+
if ( justifyContent ) {
|
|
146
|
+
rules.push( `justify-content: ${ justifyContent }` );
|
|
147
|
+
}
|
|
148
|
+
} else {
|
|
149
|
+
rules.push( 'flex-direction: column' );
|
|
150
|
+
rules.push( `align-items: ${ alignItems }` );
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if ( rules.length ) {
|
|
154
|
+
output = `${ appendSelectors( selector ) } {
|
|
155
|
+
${ rules.join( '; ' ) };
|
|
156
|
+
}`;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Output blockGap styles based on rules contained in layout definitions in theme.json.
|
|
160
|
+
if ( hasBlockGapSupport && blockGapValue ) {
|
|
161
|
+
output += getBlockGapCSS(
|
|
162
|
+
selector,
|
|
163
|
+
layoutDefinitions,
|
|
164
|
+
'flex',
|
|
165
|
+
blockGapValue
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
return output;
|
|
163
169
|
},
|
|
164
170
|
getOrientation( layout ) {
|
|
165
171
|
const { orientation = 'horizontal' } = layout;
|
|
@@ -324,7 +330,7 @@ function OrientationControl( { layout, onChange } ) {
|
|
|
324
330
|
<fieldset className="block-editor-hooks__flex-layout-orientation-controls">
|
|
325
331
|
<legend>{ __( 'Orientation' ) }</legend>
|
|
326
332
|
<Button
|
|
327
|
-
label={ '
|
|
333
|
+
label={ __( 'Horizontal' ) }
|
|
328
334
|
icon={ arrowRight }
|
|
329
335
|
isPressed={ orientation === 'horizontal' }
|
|
330
336
|
onClick={ () =>
|
|
@@ -335,7 +341,7 @@ function OrientationControl( { layout, onChange } ) {
|
|
|
335
341
|
}
|
|
336
342
|
/>
|
|
337
343
|
<Button
|
|
338
|
-
label={ '
|
|
344
|
+
label={ __( 'Vertical' ) }
|
|
339
345
|
icon={ arrowDown }
|
|
340
346
|
isPressed={ orientation === 'vertical' }
|
|
341
347
|
onClick={ () =>
|
package/src/layouts/flow.js
CHANGED
|
@@ -8,12 +8,13 @@ import {
|
|
|
8
8
|
} from '@wordpress/components';
|
|
9
9
|
import { __, sprintf } from '@wordpress/i18n';
|
|
10
10
|
import { Icon, positionCenter, stretchWide } from '@wordpress/icons';
|
|
11
|
+
import { getCSSRules } from '@wordpress/style-engine';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Internal dependencies
|
|
14
15
|
*/
|
|
15
16
|
import useSetting from '../components/use-setting';
|
|
16
|
-
import { appendSelectors } from './utils';
|
|
17
|
+
import { appendSelectors, getBlockGapCSS } from './utils';
|
|
17
18
|
import { getGapBoxControlValueFromStyle } from '../hooks/gap';
|
|
18
19
|
import { shouldSkipSerialization } from '../hooks/utils';
|
|
19
20
|
|
|
@@ -107,15 +108,15 @@ export default {
|
|
|
107
108
|
toolBarControls: function DefaultLayoutToolbarControls() {
|
|
108
109
|
return null;
|
|
109
110
|
},
|
|
110
|
-
|
|
111
|
+
getLayoutStyle: function getLayoutStyle( {
|
|
111
112
|
selector,
|
|
112
113
|
layout = {},
|
|
113
114
|
style,
|
|
114
115
|
blockName,
|
|
116
|
+
hasBlockGapSupport,
|
|
117
|
+
layoutDefinitions,
|
|
115
118
|
} ) {
|
|
116
119
|
const { contentSize, wideSize } = layout;
|
|
117
|
-
const blockGapSupport = useSetting( 'spacing.blockGap' );
|
|
118
|
-
const hasBlockGapStylesSupport = blockGapSupport !== null;
|
|
119
120
|
const blockGapStyleValue = getGapBoxControlValueFromStyle(
|
|
120
121
|
style?.spacing?.blockGap
|
|
121
122
|
);
|
|
@@ -125,14 +126,14 @@ export default {
|
|
|
125
126
|
blockGapStyleValue?.top &&
|
|
126
127
|
! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )
|
|
127
128
|
? blockGapStyleValue?.top
|
|
128
|
-
: '
|
|
129
|
+
: '';
|
|
129
130
|
|
|
130
131
|
let output =
|
|
131
132
|
!! contentSize || !! wideSize
|
|
132
133
|
? `
|
|
133
134
|
${ appendSelectors(
|
|
134
135
|
selector,
|
|
135
|
-
'> :where(:not(.alignleft):not(.alignright))'
|
|
136
|
+
'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'
|
|
136
137
|
) } {
|
|
137
138
|
max-width: ${ contentSize ?? wideSize };
|
|
138
139
|
margin-left: auto !important;
|
|
@@ -147,37 +148,37 @@ export default {
|
|
|
147
148
|
`
|
|
148
149
|
: '';
|
|
149
150
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if ( hasBlockGapStylesSupport ) {
|
|
169
|
-
output += `
|
|
170
|
-
${ appendSelectors( selector, '> *' ) } {
|
|
171
|
-
margin-block-start: 0;
|
|
172
|
-
margin-block-end: 0;
|
|
173
|
-
}
|
|
174
|
-
${ appendSelectors( selector, '> * + *' ) } {
|
|
175
|
-
margin-block-start: ${ blockGapValue };
|
|
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
|
+
`;
|
|
176
168
|
}
|
|
177
|
-
|
|
169
|
+
} );
|
|
178
170
|
}
|
|
179
171
|
|
|
180
|
-
|
|
172
|
+
// Output blockGap styles based on rules contained in layout definitions in theme.json.
|
|
173
|
+
if ( hasBlockGapSupport && blockGapValue ) {
|
|
174
|
+
output += getBlockGapCSS(
|
|
175
|
+
selector,
|
|
176
|
+
layoutDefinitions,
|
|
177
|
+
'default',
|
|
178
|
+
blockGapValue
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
return output;
|
|
181
182
|
},
|
|
182
183
|
getOrientation() {
|
|
183
184
|
return 'vertical';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import flex from '../flex';
|
|
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 = flex.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
|
+
} );
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import flow from '../flow';
|
|
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 = flow.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
|
+
} );
|