@wordpress/block-editor 15.21.1 → 15.22.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 +2 -2
- package/build/components/block-card/index.cjs +4 -5
- package/build/components/block-card/index.cjs.map +2 -2
- package/build/components/block-editing-mode/index.cjs +13 -7
- package/build/components/block-editing-mode/index.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +35 -20
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-mover/mover-description.cjs +6 -6
- package/build/components/block-mover/mover-description.cjs.map +1 -1
- package/build/components/block-patterns-list/index.cjs.map +2 -2
- package/build/components/block-patterns-paging/index.cjs +4 -4
- package/build/components/block-patterns-paging/index.cjs.map +2 -2
- package/build/components/block-popover/use-popover-scroll.cjs.map +1 -1
- package/build/components/block-quick-navigation/index.cjs +7 -5
- package/build/components/block-quick-navigation/index.cjs.map +2 -2
- package/build/components/block-rename/modal.cjs +0 -1
- package/build/components/block-rename/modal.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +14 -6
- package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
- package/build/components/block-toolbar/edit-section-button.cjs.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.cjs +10 -4
- package/build/components/block-tools/use-block-toolbar-popover-props.cjs.map +2 -2
- package/build/components/child-layout-control/index.cjs +51 -19
- package/build/components/child-layout-control/index.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +25 -14
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/colors-gradients/dropdown.cjs +4 -1
- package/build/components/colors-gradients/dropdown.cjs.map +3 -3
- package/build/components/contrast-checker/index.cjs +22 -4
- package/build/components/contrast-checker/index.cjs.map +2 -2
- package/build/components/date-format-picker/index.cjs +0 -1
- package/build/components/date-format-picker/index.cjs.map +2 -2
- package/build/components/dimensions-tool/index.cjs +4 -5
- package/build/components/dimensions-tool/index.cjs.map +2 -2
- package/build/components/dimensions-tool/scale-tool.cjs +1 -1
- package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +153 -25
- package/build/components/global-styles/background-panel.cjs.map +3 -3
- package/build/components/global-styles/color-gradient-dropdown-item.cjs +227 -0
- package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +7 -0
- package/build/components/global-styles/color-panel.cjs +98 -375
- package/build/components/global-styles/color-panel.cjs.map +3 -3
- package/build/components/global-styles/dimensions-panel.cjs +1 -4
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/hooks.cjs +34 -0
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +82 -10
- package/build/components/global-styles/typography-panel.cjs.map +3 -3
- package/build/components/grid/grid-item-resizer.cjs.map +1 -1
- package/build/components/grid/grid-visualizer.cjs.map +1 -1
- package/build/components/iframe/index.cjs +6 -3
- package/build/components/iframe/index.cjs.map +3 -3
- package/build/components/image-editor/use-transform-image.cjs.map +1 -1
- package/build/components/inserter/get-appender-label.cjs.map +1 -1
- package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
- package/build/components/inserter/search-items.cjs.map +1 -1
- package/build/components/inspector-controls/fill.cjs +1 -3
- package/build/components/inspector-controls/fill.cjs.map +2 -2
- package/build/components/inspector-controls/groups.cjs +2 -0
- package/build/components/inspector-controls/groups.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/index.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.cjs +76 -32
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/keyboard-shortcuts/index.cjs.map +1 -1
- package/build/components/line-height-control/index.cjs.map +1 -1
- package/build/components/link-control/index.cjs +2 -3
- package/build/components/link-control/index.cjs.map +2 -2
- package/build/components/link-control/normalize-url.cjs.map +1 -1
- package/build/components/list-view/block-select-button.cjs +1 -10
- package/build/components/list-view/block-select-button.cjs.map +3 -3
- package/build/components/list-view/utils.cjs.map +1 -1
- package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
- package/build/components/provider/index.cjs.map +1 -1
- package/build/components/provider/use-block-sync.cjs +3 -1
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/before-input-rules.cjs +1 -1
- package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/paste-handler.cjs.map +1 -1
- package/build/components/rich-text/prevent-event-discovery.cjs +1 -1
- package/build/components/rich-text/prevent-event-discovery.cjs.map +1 -1
- package/build/components/url-popover/image-url-input-ui.cjs +0 -2
- package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
- package/build/components/use-block-display-information/index.cjs +10 -3
- package/build/components/use-block-display-information/index.cjs.map +2 -2
- package/build/components/writing-flow/use-tab-nav.cjs.map +1 -1
- package/build/hooks/anchor.cjs +1 -2
- package/build/hooks/anchor.cjs.map +2 -2
- package/build/hooks/background.cjs +124 -75
- package/build/hooks/background.cjs.map +3 -3
- package/build/hooks/block-fields/index.cjs +13 -2
- package/build/hooks/block-fields/index.cjs.map +2 -2
- package/build/hooks/color.cjs +0 -162
- package/build/hooks/color.cjs.map +3 -3
- package/build/hooks/contrast-checker.cjs +31 -28
- package/build/hooks/contrast-checker.cjs.map +3 -3
- package/build/hooks/custom-class-name.cjs +0 -1
- package/build/hooks/custom-class-name.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +13 -2
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/elements.cjs +142 -0
- package/build/hooks/elements.cjs.map +7 -0
- package/build/hooks/grid-visualizer.cjs +21 -11
- package/build/hooks/grid-visualizer.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +65 -10
- package/build/hooks/layout-child.cjs.map +2 -2
- package/build/hooks/layout.cjs +6 -3
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/list-view.cjs +10 -7
- package/build/hooks/list-view.cjs.map +2 -2
- package/build/hooks/spacing-visualizer.cjs.map +1 -1
- package/build/hooks/state-utils.cjs.map +1 -1
- package/build/hooks/states.cjs +2 -2
- package/build/hooks/states.cjs.map +2 -2
- package/build/hooks/style.cjs +50 -6
- package/build/hooks/style.cjs.map +2 -2
- package/build/hooks/typography.cjs +62 -10
- package/build/hooks/typography.cjs.map +3 -3
- package/build/layouts/flex.cjs +99 -6
- package/build/layouts/flex.cjs.map +2 -2
- package/build/private-apis.cjs +4 -0
- package/build/private-apis.cjs.map +2 -2
- package/build/store/actions.cjs.map +1 -1
- package/build/store/private-selectors.cjs +19 -2
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs.map +1 -1
- package/build/store/selectors.cjs.map +1 -1
- package/build/utils/block-bindings.cjs +9 -9
- package/build/utils/block-bindings.cjs.map +3 -3
- package/build/utils/color-values.cjs +10 -1
- package/build/utils/color-values.cjs.map +3 -3
- package/build/utils/dom.cjs +2 -5
- package/build/utils/dom.cjs.map +3 -3
- package/build/utils/fit-text-frontend.cjs +6 -2
- package/build/utils/fit-text-frontend.cjs.map +3 -3
- package/build/utils/fit-text-utils.cjs +1 -1
- package/build/utils/fit-text-utils.cjs.map +3 -3
- package/build/utils/format-font-style.cjs +1 -1
- package/build/utils/format-font-style.cjs.map +3 -3
- package/build/utils/format-font-weight.cjs +1 -1
- package/build/utils/format-font-weight.cjs.map +3 -3
- package/build/utils/get-editor-region.cjs +4 -2
- package/build/utils/get-editor-region.cjs.map +3 -3
- package/build/utils/get-font-styles-and-weights.cjs +8 -12
- package/build/utils/get-font-styles-and-weights.cjs.map +3 -3
- package/build/utils/get-px-from-css-unit.cjs +1 -1
- package/build/utils/get-px-from-css-unit.cjs.map +1 -1
- package/build/utils/index.cjs +1 -1
- package/build/utils/index.cjs.map +1 -1
- package/build/utils/math.cjs +1 -1
- package/build/utils/math.cjs.map +3 -3
- package/build/utils/object.cjs +8 -8
- package/build/utils/object.cjs.map +3 -3
- package/build/utils/order-inserter-block-items.cjs +1 -1
- package/build/utils/order-inserter-block-items.cjs.map +3 -3
- package/build/utils/pasting.cjs +4 -2
- package/build/utils/pasting.cjs.map +3 -3
- package/build/utils/selection.cjs +3 -2
- package/build/utils/selection.cjs.map +3 -3
- package/build/utils/sorting.cjs +9 -3
- package/build/utils/sorting.cjs.map +3 -3
- package/build/utils/transform-styles/index.cjs +3 -2
- package/build/utils/transform-styles/index.cjs.map +3 -3
- package/build/utils/transform-styles/postcss-urlrebase.d.cjs +2 -0
- package/build/utils/transform-styles/postcss-urlrebase.d.cjs.map +7 -0
- package/build/utils/transform-styles/types.cjs +19 -0
- package/build/utils/transform-styles/types.cjs.map +7 -0
- package/build/utils/types.cjs +19 -0
- package/build/utils/types.cjs.map +7 -0
- package/build-module/components/block-card/index.mjs +5 -6
- package/build-module/components/block-card/index.mjs.map +2 -2
- package/build-module/components/block-editing-mode/index.mjs +14 -8
- package/build-module/components/block-editing-mode/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +35 -21
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-mover/mover-description.mjs +6 -6
- package/build-module/components/block-mover/mover-description.mjs.map +1 -1
- package/build-module/components/block-patterns-list/index.mjs.map +2 -2
- package/build-module/components/block-patterns-paging/index.mjs +4 -4
- package/build-module/components/block-patterns-paging/index.mjs.map +2 -2
- package/build-module/components/block-popover/use-popover-scroll.mjs.map +1 -1
- package/build-module/components/block-quick-navigation/index.mjs +8 -6
- package/build-module/components/block-quick-navigation/index.mjs.map +2 -2
- package/build-module/components/block-rename/modal.mjs +0 -1
- package/build-module/components/block-rename/modal.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +14 -6
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
- package/build-module/components/block-toolbar/edit-section-button.mjs.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs +10 -4
- package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs.map +2 -2
- package/build-module/components/child-layout-control/index.mjs +51 -19
- package/build-module/components/child-layout-control/index.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +27 -15
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/colors-gradients/dropdown.mjs +4 -1
- package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
- package/build-module/components/contrast-checker/index.mjs +18 -4
- package/build-module/components/contrast-checker/index.mjs.map +2 -2
- package/build-module/components/date-format-picker/index.mjs +0 -1
- package/build-module/components/date-format-picker/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/index.mjs +4 -5
- package/build-module/components/dimensions-tool/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/scale-tool.mjs +1 -1
- package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +155 -27
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +207 -0
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +7 -0
- package/build-module/components/global-styles/color-panel.mjs +106 -387
- package/build-module/components/global-styles/color-panel.mjs.map +3 -3
- package/build-module/components/global-styles/dimensions-panel.mjs +1 -5
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +33 -0
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +84 -10
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/grid/grid-item-resizer.mjs.map +1 -1
- package/build-module/components/grid/grid-visualizer.mjs.map +1 -1
- package/build-module/components/iframe/index.mjs +6 -3
- package/build-module/components/iframe/index.mjs.map +2 -2
- package/build-module/components/image-editor/use-transform-image.mjs.map +1 -1
- package/build-module/components/inserter/get-appender-label.mjs.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
- package/build-module/components/inserter/search-items.mjs.map +1 -1
- package/build-module/components/inspector-controls/fill.mjs +1 -3
- package/build-module/components/inspector-controls/fill.mjs.map +2 -2
- package/build-module/components/inspector-controls/groups.mjs +2 -0
- package/build-module/components/inspector-controls/groups.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +76 -32
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -1
- package/build-module/components/line-height-control/index.mjs.map +1 -1
- package/build-module/components/link-control/index.mjs +2 -3
- package/build-module/components/link-control/index.mjs.map +2 -2
- package/build-module/components/link-control/normalize-url.mjs.map +1 -1
- package/build-module/components/list-view/block-select-button.mjs +2 -17
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/utils.mjs.map +1 -1
- package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
- package/build-module/components/provider/index.mjs.map +1 -1
- package/build-module/components/provider/use-block-sync.mjs +3 -1
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +1 -1
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +1 -1
- package/build-module/components/rich-text/prevent-event-discovery.mjs +1 -1
- package/build-module/components/rich-text/prevent-event-discovery.mjs.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.mjs +0 -2
- package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
- package/build-module/components/use-block-display-information/index.mjs +10 -3
- package/build-module/components/use-block-display-information/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-tab-nav.mjs.map +1 -1
- package/build-module/hooks/anchor.mjs +1 -2
- package/build-module/hooks/anchor.mjs.map +2 -2
- package/build-module/hooks/background.mjs +123 -75
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/block-fields/index.mjs +13 -2
- package/build-module/hooks/block-fields/index.mjs.map +2 -2
- package/build-module/hooks/color.mjs +2 -175
- package/build-module/hooks/color.mjs.map +2 -2
- package/build-module/hooks/contrast-checker.mjs +32 -19
- package/build-module/hooks/contrast-checker.mjs.map +2 -2
- package/build-module/hooks/custom-class-name.mjs +0 -1
- package/build-module/hooks/custom-class-name.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +12 -2
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/elements.mjs +115 -0
- package/build-module/hooks/elements.mjs.map +7 -0
- package/build-module/hooks/grid-visualizer.mjs +21 -11
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +68 -10
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +6 -3
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/list-view.mjs +10 -7
- package/build-module/hooks/list-view.mjs.map +2 -2
- package/build-module/hooks/spacing-visualizer.mjs.map +1 -1
- package/build-module/hooks/state-utils.mjs.map +1 -1
- package/build-module/hooks/states.mjs +2 -2
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/hooks/style.mjs +53 -8
- package/build-module/hooks/style.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +62 -10
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +105 -7
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/private-apis.mjs +8 -0
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs.map +1 -1
- package/build-module/store/private-selectors.mjs +18 -1
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs.map +1 -1
- package/build-module/store/selectors.mjs.map +1 -1
- package/build-module/utils/block-bindings.mjs +9 -9
- package/build-module/utils/block-bindings.mjs.map +3 -3
- package/build-module/utils/color-values.mjs +9 -1
- package/build-module/utils/color-values.mjs.map +3 -3
- package/build-module/utils/dom.mjs +2 -5
- package/build-module/utils/dom.mjs.map +3 -3
- package/build-module/utils/fit-text-frontend.mjs +6 -2
- package/build-module/utils/fit-text-frontend.mjs.map +3 -3
- package/build-module/utils/fit-text-utils.mjs +1 -1
- package/build-module/utils/fit-text-utils.mjs.map +3 -3
- package/build-module/utils/format-font-style.mjs +1 -1
- package/build-module/utils/format-font-style.mjs.map +3 -3
- package/build-module/utils/format-font-weight.mjs +1 -1
- package/build-module/utils/format-font-weight.mjs.map +3 -3
- package/build-module/utils/get-editor-region.mjs +4 -2
- package/build-module/utils/get-editor-region.mjs.map +3 -3
- package/build-module/utils/get-font-styles-and-weights.mjs +8 -12
- package/build-module/utils/get-font-styles-and-weights.mjs.map +3 -3
- package/build-module/utils/get-px-from-css-unit.mjs +1 -1
- package/build-module/utils/get-px-from-css-unit.mjs.map +1 -1
- package/build-module/utils/index.mjs +1 -1
- package/build-module/utils/index.mjs.map +1 -1
- package/build-module/utils/math.mjs +1 -1
- package/build-module/utils/math.mjs.map +3 -3
- package/build-module/utils/object.mjs +8 -8
- package/build-module/utils/object.mjs.map +3 -3
- package/build-module/utils/order-inserter-block-items.mjs +1 -1
- package/build-module/utils/order-inserter-block-items.mjs.map +3 -3
- package/build-module/utils/pasting.mjs +4 -2
- package/build-module/utils/pasting.mjs.map +3 -3
- package/build-module/utils/selection.mjs +3 -2
- package/build-module/utils/selection.mjs.map +3 -3
- package/build-module/utils/sorting.mjs +9 -3
- package/build-module/utils/sorting.mjs.map +3 -3
- package/build-module/utils/transform-styles/index.mjs +3 -2
- package/build-module/utils/transform-styles/index.mjs.map +3 -3
- package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs +1 -0
- package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs.map +7 -0
- package/build-module/utils/transform-styles/types.mjs +1 -0
- package/build-module/utils/transform-styles/types.mjs.map +7 -0
- package/build-module/utils/types.mjs +1 -0
- package/build-module/utils/types.mjs.map +7 -0
- package/build-style/content-rtl.css +2 -0
- package/build-style/content.css +2 -0
- package/build-style/style-rtl.css +34 -41
- package/build-style/style.css +34 -41
- package/build-types/utils/block-bindings.d.ts +27 -0
- package/build-types/utils/block-bindings.d.ts.map +1 -0
- package/build-types/utils/color-values.d.ts +40 -0
- package/build-types/utils/color-values.d.ts.map +1 -0
- package/build-types/utils/dom.d.ts +19 -19
- package/build-types/utils/dom.d.ts.map +1 -1
- package/build-types/utils/fit-text-frontend.d.ts +7 -0
- package/build-types/utils/fit-text-frontend.d.ts.map +1 -0
- package/build-types/utils/fit-text-utils.d.ts +15 -0
- package/build-types/utils/fit-text-utils.d.ts.map +1 -0
- package/build-types/utils/format-font-style.d.ts +12 -0
- package/build-types/utils/format-font-style.d.ts.map +1 -0
- package/build-types/utils/format-font-weight.d.ts +12 -0
- package/build-types/utils/format-font-weight.d.ts.map +1 -0
- package/build-types/utils/get-editor-region.d.ts +9 -0
- package/build-types/utils/get-editor-region.d.ts.map +1 -0
- package/build-types/utils/get-font-styles-and-weights.d.ts +16 -0
- package/build-types/utils/get-font-styles-and-weights.d.ts.map +1 -0
- package/build-types/utils/get-px-from-css-unit.d.ts +10 -0
- package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -0
- package/build-types/utils/index.d.ts +3 -0
- package/build-types/utils/index.d.ts.map +1 -0
- package/build-types/utils/math.d.ts +61 -0
- package/build-types/utils/math.d.ts.map +1 -0
- package/build-types/utils/object.d.ts +39 -0
- package/build-types/utils/object.d.ts.map +1 -0
- package/build-types/utils/order-inserter-block-items.d.ts +13 -0
- package/build-types/utils/order-inserter-block-items.d.ts.map +1 -0
- package/build-types/utils/pasting.d.ts +28 -0
- package/build-types/utils/pasting.d.ts.map +1 -0
- package/build-types/utils/selection.d.ts +21 -0
- package/build-types/utils/selection.d.ts.map +1 -0
- package/build-types/utils/sorting.d.ts +17 -0
- package/build-types/utils/sorting.d.ts.map +1 -0
- package/build-types/utils/transform-styles/index.d.ts +15 -0
- package/build-types/utils/transform-styles/index.d.ts.map +1 -0
- package/build-types/utils/transform-styles/types.d.ts +13 -0
- package/build-types/utils/transform-styles/types.d.ts.map +1 -0
- package/build-types/utils/types.d.ts +28 -0
- package/build-types/utils/types.d.ts.map +1 -0
- package/package.json +46 -40
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -0
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -0
- package/src/components/block-card/index.js +7 -13
- package/src/components/block-editing-mode/index.js +17 -9
- package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -0
- package/src/components/block-inspector/index.js +22 -20
- package/src/components/block-patterns-list/index.js +0 -1
- package/src/components/block-quick-navigation/index.js +7 -7
- package/src/components/block-rename/modal.js +0 -1
- package/src/components/block-toolbar/block-toolbar-icon.js +22 -6
- package/src/components/block-toolbar/test/block-toolbar-icon.js +99 -0
- package/src/components/block-tools/use-block-toolbar-popover-props.js +10 -4
- package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +4 -0
- package/src/components/child-layout-control/index.js +65 -20
- package/src/components/child-layout-control/test/index.js +64 -0
- package/src/components/colors-gradients/control.js +29 -12
- package/src/components/colors-gradients/dropdown.js +4 -1
- package/src/components/colors-gradients/style.scss +39 -2
- package/src/components/contrast-checker/README.md +9 -0
- package/src/components/contrast-checker/index.js +42 -3
- package/src/components/date-format-picker/index.js +0 -1
- package/src/components/default-block-appender/content.scss +3 -0
- package/src/components/dimensions-tool/index.js +4 -9
- package/src/components/dimensions-tool/scale-tool.js +1 -2
- package/src/components/dimensions-tool/test/index.js +89 -11
- package/src/components/global-styles/background-panel.js +201 -34
- package/src/components/global-styles/color-gradient-dropdown-item.js +258 -0
- package/src/components/global-styles/color-panel.js +125 -487
- package/src/components/global-styles/dimensions-panel.js +1 -5
- package/src/components/global-styles/hooks.js +45 -0
- package/src/components/global-styles/shadow-panel-components.js +0 -1
- package/src/components/global-styles/test/background-panel.js +56 -0
- package/src/components/global-styles/test/color-panel.js +172 -118
- package/src/components/global-styles/test/typography-panel.js +167 -0
- package/src/components/global-styles/typography-panel.js +100 -11
- package/src/components/iframe/index.js +8 -3
- package/src/components/inserter/media-tab/media-preview.js +0 -1
- package/src/components/inspector-controls/README.md +0 -2
- package/src/components/inspector-controls/fill.js +6 -8
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/index.js +0 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +78 -28
- package/src/components/link-control/index.js +0 -1
- package/src/components/link-control/test/index.js +2 -3
- package/src/components/list-view/block-select-button.js +2 -18
- package/src/components/preset-input-control/custom-value-controls.js +0 -1
- package/src/components/provider/use-block-sync.js +3 -1
- package/src/components/rich-text/content.scss +2 -0
- package/src/components/url-popover/image-url-input-ui.js +0 -2
- package/src/components/use-block-display-information/index.js +15 -2
- package/src/components/use-block-display-information/test/index.js +140 -0
- package/src/hooks/anchor.js +0 -1
- package/src/hooks/background.js +210 -133
- package/src/hooks/background.scss +0 -35
- package/src/hooks/block-fields/index.js +27 -2
- package/src/hooks/color.js +2 -205
- package/src/hooks/color.scss +3 -9
- package/src/hooks/contrast-checker.js +60 -17
- package/src/hooks/custom-class-name.js +0 -1
- package/src/hooks/dimensions.js +14 -3
- package/src/hooks/elements.js +140 -0
- package/src/hooks/elements.scss +8 -0
- package/src/hooks/grid-visualizer.js +59 -45
- package/src/hooks/layout-child.js +92 -14
- package/src/hooks/layout.js +6 -3
- package/src/hooks/list-view.js +10 -11
- package/src/hooks/states.js +2 -2
- package/src/hooks/style.js +91 -9
- package/src/hooks/test/background.js +59 -0
- package/src/hooks/test/block-style-state.js +14 -14
- package/src/hooks/test/dimensions.js +71 -0
- package/src/hooks/test/layout-child.js +165 -0
- package/src/hooks/test/layout.js +6 -6
- package/src/hooks/test/style.js +133 -11
- package/src/hooks/typography.js +70 -6
- package/src/layouts/flex.js +118 -15
- package/src/private-apis.js +8 -0
- package/src/store/private-selectors.js +47 -0
- package/src/store/test/private-selectors.js +166 -7
- package/src/store/test/reducer.js +61 -10
- package/src/style.scss +1 -0
- package/src/utils/block-bindings.ts +51 -0
- package/src/utils/color-values.ts +63 -0
- package/src/utils/{dom.js → dom.ts} +27 -27
- package/src/utils/{fit-text-frontend.js → fit-text-frontend.ts} +12 -4
- package/src/utils/{fit-text-utils.js → fit-text-utils.ts} +15 -7
- package/src/utils/{format-font-style.js → format-font-style.ts} +10 -3
- package/src/utils/{format-font-weight.js → format-font-weight.ts} +10 -3
- package/src/utils/{get-editor-region.js → get-editor-region.ts} +10 -6
- package/src/utils/{get-font-styles-and-weights.js → get-font-styles-and-weights.ts} +21 -17
- package/src/utils/{math.js → math.ts} +37 -30
- package/src/utils/object.ts +89 -0
- package/src/utils/{order-inserter-block-items.js → order-inserter-block-items.ts} +8 -5
- package/src/utils/{pasting.js → pasting.ts} +18 -11
- package/src/utils/{selection.js → selection.ts} +11 -4
- package/src/utils/sorting.ts +81 -0
- package/src/utils/test/color-values.js +44 -1
- package/src/utils/transform-styles/{index.js → index.ts} +25 -25
- package/src/utils/transform-styles/postcss-urlrebase.d.ts +15 -0
- package/src/utils/transform-styles/types.ts +13 -0
- package/src/utils/types.ts +29 -0
- package/src/utils/block-bindings.js +0 -46
- package/src/utils/color-values.js +0 -28
- package/src/utils/object.js +0 -67
- package/src/utils/sorting.js +0 -54
- /package/src/utils/{get-px-from-css-unit.js → get-px-from-css-unit.ts} +0 -0
- /package/src/utils/{index.js → index.ts} +0 -0
package/src/hooks/typography.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
|
|
5
5
|
import { useMemo, useCallback } from '@wordpress/element';
|
|
6
6
|
import { useSelect } from '@wordpress/data';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Internal dependencies
|
|
@@ -20,6 +21,7 @@ import { FONT_SIZE_SUPPORT_KEY } from './font-size';
|
|
|
20
21
|
import { TEXT_ALIGN_SUPPORT_KEY } from './text-align';
|
|
21
22
|
import { FIT_TEXT_SUPPORT_KEY } from './fit-text';
|
|
22
23
|
import { cleanEmptyObject } from './utils';
|
|
24
|
+
import { extractPresetSlug } from '../utils/color-values';
|
|
23
25
|
import { store as blockEditorStore } from '../store';
|
|
24
26
|
import {
|
|
25
27
|
getStyleForState,
|
|
@@ -27,6 +29,7 @@ import {
|
|
|
27
29
|
setStyleForState,
|
|
28
30
|
useBlockStyleState,
|
|
29
31
|
} from './block-style-state';
|
|
32
|
+
import useBlockColorContrastWarning from './contrast-checker';
|
|
30
33
|
|
|
31
34
|
function omit( object, keys ) {
|
|
32
35
|
return Object.fromEntries(
|
|
@@ -63,6 +66,7 @@ function styleToAttributes( style ) {
|
|
|
63
66
|
const updatedStyle = { ...omit( style, [ 'fontFamily' ] ) };
|
|
64
67
|
const fontSizeValue = style?.typography?.fontSize;
|
|
65
68
|
const fontFamilyValue = style?.typography?.fontFamily;
|
|
69
|
+
const textColorValue = style?.color?.text;
|
|
66
70
|
const fontSizeSlug =
|
|
67
71
|
typeof fontSizeValue === 'string' &&
|
|
68
72
|
fontSizeValue?.startsWith( 'var:preset|font-size|' )
|
|
@@ -73,14 +77,20 @@ function styleToAttributes( style ) {
|
|
|
73
77
|
)
|
|
74
78
|
? fontFamilyValue.substring( 'var:preset|font-family|'.length )
|
|
75
79
|
: undefined;
|
|
80
|
+
const textColorSlug = extractPresetSlug( textColorValue, 'color' );
|
|
76
81
|
updatedStyle.typography = {
|
|
77
82
|
...omit( updatedStyle.typography, [ 'fontFamily' ] ),
|
|
78
83
|
fontSize: fontSizeSlug ? undefined : fontSizeValue,
|
|
79
84
|
};
|
|
85
|
+
updatedStyle.color = {
|
|
86
|
+
...updatedStyle.color,
|
|
87
|
+
text: textColorSlug ? undefined : textColorValue,
|
|
88
|
+
};
|
|
80
89
|
return {
|
|
81
90
|
style: cleanEmptyObject( updatedStyle ),
|
|
82
91
|
fontFamily: fontFamilySlug,
|
|
83
92
|
fontSize: fontSizeSlug,
|
|
93
|
+
textColor: textColorSlug,
|
|
84
94
|
};
|
|
85
95
|
}
|
|
86
96
|
|
|
@@ -96,6 +106,12 @@ function attributesToStyle( attributes ) {
|
|
|
96
106
|
? 'var:preset|font-size|' + attributes.fontSize
|
|
97
107
|
: attributes.style?.typography?.fontSize,
|
|
98
108
|
},
|
|
109
|
+
color: {
|
|
110
|
+
...attributes.style?.color,
|
|
111
|
+
text: attributes.textColor
|
|
112
|
+
? 'var:preset|color|' + attributes.textColor
|
|
113
|
+
: attributes.style?.color?.text,
|
|
114
|
+
},
|
|
99
115
|
};
|
|
100
116
|
}
|
|
101
117
|
|
|
@@ -122,11 +138,20 @@ function TypographyInspectorControl( { children, resetAllFilter } ) {
|
|
|
122
138
|
);
|
|
123
139
|
}
|
|
124
140
|
|
|
125
|
-
export function TypographyPanel( {
|
|
141
|
+
export function TypographyPanel( {
|
|
142
|
+
clientId,
|
|
143
|
+
name,
|
|
144
|
+
setAttributes,
|
|
145
|
+
settings,
|
|
146
|
+
// Allows rendering outside the `typography` inspector group (e.g. section
|
|
147
|
+
// blocks direct-render this panel because their support fills are gated
|
|
148
|
+
// off by editing mode). Defaults to the slot-based wrapper.
|
|
149
|
+
asWrapper,
|
|
150
|
+
} ) {
|
|
126
151
|
const selectedState = useBlockStyleState();
|
|
127
152
|
const isEnabled = useHasTypographyPanel( settings );
|
|
128
153
|
|
|
129
|
-
const { style, fontFamily, fontSize, fitText } = useSelect(
|
|
154
|
+
const { style, fontFamily, fontSize, fitText, textColor } = useSelect(
|
|
130
155
|
( select ) => {
|
|
131
156
|
// Early return to avoid subscription when disabled.
|
|
132
157
|
if ( ! isEnabled ) {
|
|
@@ -137,12 +162,14 @@ export function TypographyPanel( { clientId, name, setAttributes, settings } ) {
|
|
|
137
162
|
fontFamily: _fontFamily,
|
|
138
163
|
fontSize: _fontSize,
|
|
139
164
|
fitText: _fitText,
|
|
165
|
+
textColor: _textColor,
|
|
140
166
|
} = select( blockEditorStore ).getBlockAttributes( clientId ) || {};
|
|
141
167
|
return {
|
|
142
168
|
style: _style,
|
|
143
169
|
fontFamily: _fontFamily,
|
|
144
170
|
fontSize: _fontSize,
|
|
145
171
|
fitText: _fitText,
|
|
172
|
+
textColor: _textColor,
|
|
146
173
|
};
|
|
147
174
|
},
|
|
148
175
|
[ clientId, isEnabled ]
|
|
@@ -154,8 +181,15 @@ export function TypographyPanel( { clientId, name, setAttributes, settings } ) {
|
|
|
154
181
|
if ( isStateSelected ) {
|
|
155
182
|
return getStyleForState( style, selectedState );
|
|
156
183
|
}
|
|
157
|
-
return attributesToStyle( { style, fontFamily, fontSize } );
|
|
158
|
-
}, [
|
|
184
|
+
return attributesToStyle( { style, fontFamily, fontSize, textColor } );
|
|
185
|
+
}, [
|
|
186
|
+
isStateSelected,
|
|
187
|
+
selectedState,
|
|
188
|
+
style,
|
|
189
|
+
fontSize,
|
|
190
|
+
fontFamily,
|
|
191
|
+
textColor,
|
|
192
|
+
] );
|
|
159
193
|
|
|
160
194
|
const onChange = isStateSelected
|
|
161
195
|
? ( newStyle ) => {
|
|
@@ -177,23 +211,53 @@ export function TypographyPanel( { clientId, name, setAttributes, settings } ) {
|
|
|
177
211
|
setAttributes( newAttributes );
|
|
178
212
|
};
|
|
179
213
|
|
|
214
|
+
// Link color failures are reported by the Elements panel, which owns the
|
|
215
|
+
// link color selection.
|
|
216
|
+
const enableContrastChecking =
|
|
217
|
+
! isStateSelected &&
|
|
218
|
+
! value?.color?.gradient &&
|
|
219
|
+
!! value?.color?.text &&
|
|
220
|
+
settings?.color?.text &&
|
|
221
|
+
false !== getBlockSupport( name, [ 'color', 'enableContrastChecker' ] );
|
|
222
|
+
|
|
223
|
+
const contrastWarning = useBlockColorContrastWarning( {
|
|
224
|
+
clientId,
|
|
225
|
+
name,
|
|
226
|
+
enabled: !! enableContrastChecking,
|
|
227
|
+
checkLinkColor: false,
|
|
228
|
+
messageOverride: __(
|
|
229
|
+
'This color has poor contrast against the background. Consider increasing contrast.'
|
|
230
|
+
),
|
|
231
|
+
} );
|
|
232
|
+
|
|
180
233
|
if ( ! isEnabled ) {
|
|
181
234
|
return null;
|
|
182
235
|
}
|
|
183
236
|
|
|
184
|
-
const
|
|
237
|
+
const typographyDefaultControls = getBlockSupport( name, [
|
|
185
238
|
TYPOGRAPHY_SUPPORT_KEY,
|
|
186
239
|
'__experimentalDefaultControls',
|
|
187
240
|
] );
|
|
241
|
+
const colorDefaultControls = getBlockSupport( name, [
|
|
242
|
+
'color',
|
|
243
|
+
'__experimentalDefaultControls',
|
|
244
|
+
] );
|
|
245
|
+
const defaultControls = {
|
|
246
|
+
...typographyDefaultControls,
|
|
247
|
+
textColor: colorDefaultControls?.text,
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const Wrapper = asWrapper || TypographyInspectorControl;
|
|
188
251
|
|
|
189
252
|
return (
|
|
190
253
|
<StylesTypographyPanel
|
|
191
|
-
as={
|
|
254
|
+
as={ Wrapper }
|
|
192
255
|
panelId={ clientId }
|
|
193
256
|
settings={ settings }
|
|
194
257
|
value={ value }
|
|
195
258
|
onChange={ onChange }
|
|
196
259
|
defaultControls={ defaultControls }
|
|
260
|
+
contrastWarning={ contrastWarning }
|
|
197
261
|
/>
|
|
198
262
|
);
|
|
199
263
|
}
|
package/src/layouts/flex.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
4
|
+
import { __, _x } from '@wordpress/i18n';
|
|
5
5
|
import {
|
|
6
6
|
justifyLeft,
|
|
7
7
|
justifyCenter,
|
|
8
8
|
justifyRight,
|
|
9
9
|
justifySpaceBetween,
|
|
10
10
|
justifyStretch,
|
|
11
|
+
justifyTop,
|
|
12
|
+
justifyCenterVertical,
|
|
13
|
+
justifyBottom,
|
|
14
|
+
justifyStretchVertical,
|
|
15
|
+
justifySpaceBetweenVertical,
|
|
11
16
|
arrowRight,
|
|
12
17
|
arrowDown,
|
|
13
18
|
} from '@wordpress/icons';
|
|
@@ -62,6 +67,29 @@ const defaultAlignments = {
|
|
|
62
67
|
vertical: 'top',
|
|
63
68
|
};
|
|
64
69
|
|
|
70
|
+
const verticalAlignmentOptions = {
|
|
71
|
+
top: {
|
|
72
|
+
icon: justifyTop,
|
|
73
|
+
label: _x( 'Align top', 'Block vertical alignment setting' ),
|
|
74
|
+
},
|
|
75
|
+
center: {
|
|
76
|
+
icon: justifyCenterVertical,
|
|
77
|
+
label: _x( 'Align middle', 'Block vertical alignment setting' ),
|
|
78
|
+
},
|
|
79
|
+
bottom: {
|
|
80
|
+
icon: justifyBottom,
|
|
81
|
+
label: _x( 'Align bottom', 'Block vertical alignment setting' ),
|
|
82
|
+
},
|
|
83
|
+
stretch: {
|
|
84
|
+
icon: justifyStretchVertical,
|
|
85
|
+
label: _x( 'Stretch to fill', 'Block vertical alignment setting' ),
|
|
86
|
+
},
|
|
87
|
+
'space-between': {
|
|
88
|
+
icon: justifySpaceBetweenVertical,
|
|
89
|
+
label: _x( 'Space between', 'Block vertical alignment setting' ),
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
65
93
|
const flexWrapOptions = [ 'wrap', 'nowrap' ];
|
|
66
94
|
|
|
67
95
|
export default {
|
|
@@ -77,6 +105,7 @@ export default {
|
|
|
77
105
|
const {
|
|
78
106
|
allowOrientation = true,
|
|
79
107
|
allowJustification = true,
|
|
108
|
+
allowVerticalAlignment = true,
|
|
80
109
|
allowWrap = true,
|
|
81
110
|
} = layoutBlockSupport;
|
|
82
111
|
const hasLayoutValue = ( key, defaultValue ) =>
|
|
@@ -84,6 +113,11 @@ export default {
|
|
|
84
113
|
( resetLayout?.[ key ] ?? defaultValue );
|
|
85
114
|
const hasJustificationValue = () =>
|
|
86
115
|
hasLayoutValue( 'justifyContent', 'left' );
|
|
116
|
+
const hasVerticalAlignmentValue = () =>
|
|
117
|
+
hasLayoutValue(
|
|
118
|
+
'verticalAlignment',
|
|
119
|
+
getDefaultVerticalAlignment( layout )
|
|
120
|
+
);
|
|
87
121
|
const hasOrientationValue = () =>
|
|
88
122
|
hasLayoutValue( 'orientation', 'horizontal' );
|
|
89
123
|
const hasWrapValue = () => hasLayoutValue( 'flexWrap', 'wrap' );
|
|
@@ -94,6 +128,16 @@ export default {
|
|
|
94
128
|
justifyContent: resetLayout?.justifyContent,
|
|
95
129
|
} )
|
|
96
130
|
);
|
|
131
|
+
const resetVerticalAlignment = () =>
|
|
132
|
+
onChange(
|
|
133
|
+
cleanEmptyObject( {
|
|
134
|
+
...layout,
|
|
135
|
+
verticalAlignment: getCompatibleVerticalAlignment(
|
|
136
|
+
resetLayout?.verticalAlignment,
|
|
137
|
+
layout?.orientation
|
|
138
|
+
),
|
|
139
|
+
} )
|
|
140
|
+
);
|
|
97
141
|
const resetOrientation = () => {
|
|
98
142
|
const { verticalAlignment, justifyContent } = layout;
|
|
99
143
|
const nextOrientation = resetLayout?.orientation;
|
|
@@ -163,6 +207,19 @@ export default {
|
|
|
163
207
|
) }
|
|
164
208
|
</Flex>
|
|
165
209
|
) }
|
|
210
|
+
{ allowVerticalAlignment && (
|
|
211
|
+
<ToolsPanelItem
|
|
212
|
+
label={ __( 'Alignment' ) }
|
|
213
|
+
hasValue={ hasVerticalAlignmentValue }
|
|
214
|
+
onDeselect={ resetVerticalAlignment }
|
|
215
|
+
panelId={ clientId }
|
|
216
|
+
>
|
|
217
|
+
<FlexLayoutVerticalAlignmentControl
|
|
218
|
+
layout={ layout }
|
|
219
|
+
onChange={ onChange }
|
|
220
|
+
/>
|
|
221
|
+
</ToolsPanelItem>
|
|
222
|
+
) }
|
|
166
223
|
{ allowWrap && (
|
|
167
224
|
<ToolsPanelItem
|
|
168
225
|
label={ __( 'Wrapping' ) }
|
|
@@ -204,6 +261,7 @@ export default {
|
|
|
204
261
|
<FlexLayoutVerticalAlignmentControl
|
|
205
262
|
layout={ layout }
|
|
206
263
|
onChange={ onChange }
|
|
264
|
+
isToolbar
|
|
207
265
|
/>
|
|
208
266
|
) }
|
|
209
267
|
</BlockControls>
|
|
@@ -325,15 +383,39 @@ export default {
|
|
|
325
383
|
},
|
|
326
384
|
};
|
|
327
385
|
|
|
328
|
-
function
|
|
329
|
-
|
|
386
|
+
function getDefaultVerticalAlignment( { orientation = 'horizontal' } = {} ) {
|
|
387
|
+
return orientation === 'horizontal'
|
|
388
|
+
? defaultAlignments.horizontal
|
|
389
|
+
: defaultAlignments.vertical;
|
|
390
|
+
}
|
|
330
391
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
392
|
+
function getCompatibleVerticalAlignment( verticalAlignment, orientation ) {
|
|
393
|
+
if (
|
|
394
|
+
( orientation === 'horizontal' &&
|
|
395
|
+
verticalAlignment === 'space-between' ) ||
|
|
396
|
+
( orientation === 'vertical' && verticalAlignment === 'stretch' )
|
|
397
|
+
) {
|
|
398
|
+
return undefined;
|
|
399
|
+
}
|
|
335
400
|
|
|
336
|
-
|
|
401
|
+
return verticalAlignment;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
function getVerticalAlignmentControls( orientation ) {
|
|
405
|
+
return orientation === 'horizontal'
|
|
406
|
+
? [ 'top', 'center', 'bottom', 'stretch' ]
|
|
407
|
+
: [ 'top', 'center', 'bottom', 'space-between' ];
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function FlexLayoutVerticalAlignmentControl( {
|
|
411
|
+
layout,
|
|
412
|
+
onChange,
|
|
413
|
+
isToolbar = false,
|
|
414
|
+
} ) {
|
|
415
|
+
const { orientation = 'horizontal' } = layout;
|
|
416
|
+
|
|
417
|
+
const { verticalAlignment = getDefaultVerticalAlignment( layout ) } =
|
|
418
|
+
layout;
|
|
337
419
|
|
|
338
420
|
const onVerticalAlignmentChange = ( value ) => {
|
|
339
421
|
onChange( {
|
|
@@ -341,17 +423,38 @@ function FlexLayoutVerticalAlignmentControl( { layout, onChange } ) {
|
|
|
341
423
|
verticalAlignment: value,
|
|
342
424
|
} );
|
|
343
425
|
};
|
|
426
|
+
const controls = getVerticalAlignmentControls( orientation );
|
|
427
|
+
|
|
428
|
+
if ( isToolbar ) {
|
|
429
|
+
return (
|
|
430
|
+
<BlockVerticalAlignmentControl
|
|
431
|
+
onChange={ onVerticalAlignmentChange }
|
|
432
|
+
value={ verticalAlignment }
|
|
433
|
+
controls={ controls }
|
|
434
|
+
/>
|
|
435
|
+
);
|
|
436
|
+
}
|
|
344
437
|
|
|
345
438
|
return (
|
|
346
|
-
<
|
|
439
|
+
<ToggleGroupControl
|
|
440
|
+
__next40pxDefaultSize
|
|
441
|
+
label={ __( 'Alignment' ) }
|
|
347
442
|
onChange={ onVerticalAlignmentChange }
|
|
348
443
|
value={ verticalAlignment }
|
|
349
|
-
controls
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
444
|
+
className="block-editor-hooks__flex-layout-alignment-controls"
|
|
445
|
+
>
|
|
446
|
+
{ controls.map( ( control ) => {
|
|
447
|
+
const { icon, label } = verticalAlignmentOptions[ control ];
|
|
448
|
+
return (
|
|
449
|
+
<ToggleGroupControlOptionIcon
|
|
450
|
+
key={ control }
|
|
451
|
+
value={ control }
|
|
452
|
+
icon={ icon }
|
|
453
|
+
label={ label }
|
|
454
|
+
/>
|
|
455
|
+
);
|
|
456
|
+
} ) }
|
|
457
|
+
</ToggleGroupControl>
|
|
355
458
|
);
|
|
356
459
|
}
|
|
357
460
|
|
package/src/private-apis.js
CHANGED
|
@@ -16,6 +16,11 @@ import { PrivateListView } from './components/list-view';
|
|
|
16
16
|
import InspectorControlsLastItem from './components/inspector-controls/last-item';
|
|
17
17
|
import { useHasBlockToolbar } from './components/block-toolbar/use-has-block-toolbar';
|
|
18
18
|
import { cleanEmptyObject, usePrivateStyleOverride } from './hooks/utils';
|
|
19
|
+
import {
|
|
20
|
+
getStyleForState,
|
|
21
|
+
isDefaultBlockStyleState,
|
|
22
|
+
setStyleForState,
|
|
23
|
+
} from './hooks/block-style-state';
|
|
19
24
|
import BlockQuickNavigation from './components/block-quick-navigation';
|
|
20
25
|
import { LayoutStyle } from './components/block-list/layout';
|
|
21
26
|
import BlockManager from './components/block-manager';
|
|
@@ -98,6 +103,9 @@ lock( privateApis, {
|
|
|
98
103
|
InspectorControlsLastItem,
|
|
99
104
|
useHasBlockToolbar,
|
|
100
105
|
cleanEmptyObject,
|
|
106
|
+
getStyleForState,
|
|
107
|
+
isDefaultBlockStyleState,
|
|
108
|
+
setStyleForState,
|
|
101
109
|
usePrivateStyleOverride,
|
|
102
110
|
BlockQuickNavigation,
|
|
103
111
|
LayoutStyle,
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
getBlockOrder,
|
|
15
15
|
getBlockParents,
|
|
16
16
|
getBlockEditingMode,
|
|
17
|
+
getBlockListSettings,
|
|
17
18
|
getSettings,
|
|
18
19
|
canInsertBlockType,
|
|
19
20
|
getBlockName,
|
|
@@ -1077,6 +1078,52 @@ export function getListViewExpandRevision( state ) {
|
|
|
1077
1078
|
return state.listViewExpandRevision || 0;
|
|
1078
1079
|
}
|
|
1079
1080
|
|
|
1081
|
+
/**
|
|
1082
|
+
* Returns whether a block instance participates in List View-specific UI for
|
|
1083
|
+
* its inner blocks.
|
|
1084
|
+
*
|
|
1085
|
+
* Intentionally private: this is the derived participation logic (block type
|
|
1086
|
+
* `listView` support and the `core/navigation` special case) shared by the List
|
|
1087
|
+
* View consumers. A `listView`-supporting block drops out when it has no inner
|
|
1088
|
+
* blocks and its `allowedBlocks` (`[]` or `false`) permits no block: the nested
|
|
1089
|
+
* List View panel would render no rows and no appender, so it is hidden rather
|
|
1090
|
+
* than shown empty. This is a signal, not a guarantee — a child naming this
|
|
1091
|
+
* block as its `parent` stays insertable regardless (see `canInsertBlockType`);
|
|
1092
|
+
* that edge case is accepted to keep the check cheap. Keeping the read internal
|
|
1093
|
+
* lets this computation evolve without a back-compat commitment.
|
|
1094
|
+
*
|
|
1095
|
+
* @param {Object} state Global application state.
|
|
1096
|
+
* @param {string} clientId Client ID of the block.
|
|
1097
|
+
*
|
|
1098
|
+
* @return {boolean} Whether the block participates in List View-specific UI.
|
|
1099
|
+
*/
|
|
1100
|
+
export function shouldRenderBlockListView( state, clientId ) {
|
|
1101
|
+
const blockName = getBlockName( state, clientId );
|
|
1102
|
+
|
|
1103
|
+
// The navigation block always participates; its List View is core to how it
|
|
1104
|
+
// is edited, regardless of how its menu is locked or populated.
|
|
1105
|
+
if ( blockName === 'core/navigation' ) {
|
|
1106
|
+
return true;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
if ( ! hasBlockSupport( blockName, 'listView' ) ) {
|
|
1110
|
+
return false;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
// `allowedBlocks` permits no block when it is `[]` or `false`; an unset value
|
|
1114
|
+
// is unrestricted and is intentionally not matched.
|
|
1115
|
+
const allowedBlocks = getBlockListSettings(
|
|
1116
|
+
state,
|
|
1117
|
+
clientId
|
|
1118
|
+
)?.allowedBlocks;
|
|
1119
|
+
const isEmptyAndNoAllowedBlocks =
|
|
1120
|
+
getBlockOrder( state, clientId ).length === 0 &&
|
|
1121
|
+
( allowedBlocks === false ||
|
|
1122
|
+
( Array.isArray( allowedBlocks ) && allowedBlocks.length === 0 ) );
|
|
1123
|
+
|
|
1124
|
+
return ! isEmptyAndNoAllowedBlocks;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1080
1127
|
/**
|
|
1081
1128
|
* Returns the client IDs for the viewport modal, or null if
|
|
1082
1129
|
* the modal is not open.
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
getSelectedBlockStyleState,
|
|
28
28
|
hasSelectedStyleState,
|
|
29
29
|
isSelectedBlockStyleStateShownOnCanvas,
|
|
30
|
+
shouldRenderBlockListView,
|
|
30
31
|
} from '../private-selectors';
|
|
31
32
|
import { getBlockEditingMode } from '../selectors';
|
|
32
33
|
import { deviceTypeKey } from '../private-keys';
|
|
@@ -75,6 +76,143 @@ describe( 'private selectors', () => {
|
|
|
75
76
|
} );
|
|
76
77
|
} );
|
|
77
78
|
|
|
79
|
+
describe( 'shouldRenderBlockListView', () => {
|
|
80
|
+
const blockWithListViewSupport = 'core/test-list-view-support';
|
|
81
|
+
const blockWithoutListViewSupport = 'core/test-no-list-view-support';
|
|
82
|
+
|
|
83
|
+
const createState = (
|
|
84
|
+
blockName,
|
|
85
|
+
{ allowedBlocks, innerBlocks = [] } = {}
|
|
86
|
+
) => {
|
|
87
|
+
const blockListSettings = new Map();
|
|
88
|
+
if ( allowedBlocks !== undefined ) {
|
|
89
|
+
blockListSettings.set( 'client-1', { allowedBlocks } );
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
blocks: {
|
|
94
|
+
byClientId: new Map( [
|
|
95
|
+
[ 'client-1', { name: blockName } ],
|
|
96
|
+
] ),
|
|
97
|
+
order: new Map( [ [ 'client-1', innerBlocks ] ] ),
|
|
98
|
+
parents: new Map(),
|
|
99
|
+
},
|
|
100
|
+
blockListSettings,
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
beforeAll( () => {
|
|
105
|
+
registerBlockType( blockWithListViewSupport, {
|
|
106
|
+
apiVersion: 3,
|
|
107
|
+
title: 'List View support',
|
|
108
|
+
category: 'text',
|
|
109
|
+
supports: {
|
|
110
|
+
listView: true,
|
|
111
|
+
},
|
|
112
|
+
} );
|
|
113
|
+
registerBlockType( blockWithoutListViewSupport, {
|
|
114
|
+
apiVersion: 3,
|
|
115
|
+
title: 'No List View support',
|
|
116
|
+
category: 'text',
|
|
117
|
+
} );
|
|
118
|
+
} );
|
|
119
|
+
|
|
120
|
+
afterAll( () => {
|
|
121
|
+
unregisterBlockType( blockWithListViewSupport );
|
|
122
|
+
unregisterBlockType( blockWithoutListViewSupport );
|
|
123
|
+
} );
|
|
124
|
+
|
|
125
|
+
it( 'returns true for blocks with list view support', () => {
|
|
126
|
+
const state = createState( blockWithListViewSupport );
|
|
127
|
+
|
|
128
|
+
expect( shouldRenderBlockListView( state, 'client-1' ) ).toBe(
|
|
129
|
+
true
|
|
130
|
+
);
|
|
131
|
+
} );
|
|
132
|
+
|
|
133
|
+
it( 'returns false when empty and insertion is disallowed via `allowedBlocks: []`', () => {
|
|
134
|
+
const state = createState( blockWithListViewSupport, {
|
|
135
|
+
allowedBlocks: [],
|
|
136
|
+
} );
|
|
137
|
+
|
|
138
|
+
expect( shouldRenderBlockListView( state, 'client-1' ) ).toBe(
|
|
139
|
+
false
|
|
140
|
+
);
|
|
141
|
+
} );
|
|
142
|
+
|
|
143
|
+
it( 'returns false when empty and insertion is disallowed via `allowedBlocks: false`', () => {
|
|
144
|
+
const state = createState( blockWithListViewSupport, {
|
|
145
|
+
allowedBlocks: false,
|
|
146
|
+
} );
|
|
147
|
+
|
|
148
|
+
expect( shouldRenderBlockListView( state, 'client-1' ) ).toBe(
|
|
149
|
+
false
|
|
150
|
+
);
|
|
151
|
+
} );
|
|
152
|
+
|
|
153
|
+
it( 'returns true when empty but insertion is allowed', () => {
|
|
154
|
+
// e.g. a static, still-empty gallery: nothing yet, but the user can
|
|
155
|
+
// start inserting, so its List View stays available.
|
|
156
|
+
const state = createState( blockWithListViewSupport, {
|
|
157
|
+
allowedBlocks: [ 'core/image' ],
|
|
158
|
+
} );
|
|
159
|
+
|
|
160
|
+
expect( shouldRenderBlockListView( state, 'client-1' ) ).toBe(
|
|
161
|
+
true
|
|
162
|
+
);
|
|
163
|
+
} );
|
|
164
|
+
|
|
165
|
+
it( 'returns true when empty with no allowedBlocks restriction', () => {
|
|
166
|
+
const state = createState( blockWithListViewSupport );
|
|
167
|
+
|
|
168
|
+
expect( shouldRenderBlockListView( state, 'client-1' ) ).toBe(
|
|
169
|
+
true
|
|
170
|
+
);
|
|
171
|
+
} );
|
|
172
|
+
|
|
173
|
+
it( 'returns true when insertion is disallowed but the block still has inner blocks', () => {
|
|
174
|
+
const state = createState( blockWithListViewSupport, {
|
|
175
|
+
allowedBlocks: [],
|
|
176
|
+
innerBlocks: [ 'child-1' ],
|
|
177
|
+
} );
|
|
178
|
+
|
|
179
|
+
expect( shouldRenderBlockListView( state, 'client-1' ) ).toBe(
|
|
180
|
+
true
|
|
181
|
+
);
|
|
182
|
+
} );
|
|
183
|
+
|
|
184
|
+
it( 'does not grant list view support to unsupported block types', () => {
|
|
185
|
+
const state = createState( blockWithoutListViewSupport, {
|
|
186
|
+
allowedBlocks: [],
|
|
187
|
+
} );
|
|
188
|
+
|
|
189
|
+
expect( shouldRenderBlockListView( state, 'client-1' ) ).toBe(
|
|
190
|
+
false
|
|
191
|
+
);
|
|
192
|
+
} );
|
|
193
|
+
|
|
194
|
+
it( 'preserves the navigation block special case', () => {
|
|
195
|
+
const state = createState( 'core/navigation' );
|
|
196
|
+
|
|
197
|
+
expect( shouldRenderBlockListView( state, 'client-1' ) ).toBe(
|
|
198
|
+
true
|
|
199
|
+
);
|
|
200
|
+
} );
|
|
201
|
+
|
|
202
|
+
it( 'keeps navigation in list view even when empty and insertion is disallowed', () => {
|
|
203
|
+
// The navigation special case takes precedence over the
|
|
204
|
+
// `allowedBlocks` exclusion: even with nothing to show and no
|
|
205
|
+
// insertion allowed, navigation still participates in List View.
|
|
206
|
+
const state = createState( 'core/navigation', {
|
|
207
|
+
allowedBlocks: [],
|
|
208
|
+
} );
|
|
209
|
+
|
|
210
|
+
expect( shouldRenderBlockListView( state, 'client-1' ) ).toBe(
|
|
211
|
+
true
|
|
212
|
+
);
|
|
213
|
+
} );
|
|
214
|
+
} );
|
|
215
|
+
|
|
78
216
|
describe( 'getSelectedBlockStyleState', () => {
|
|
79
217
|
it( 'returns default when the block has no selected state', () => {
|
|
80
218
|
const state = {};
|
|
@@ -89,12 +227,12 @@ describe( 'private selectors', () => {
|
|
|
89
227
|
const state = {
|
|
90
228
|
selectedBlockStyleState: {
|
|
91
229
|
clientId: 'client-1',
|
|
92
|
-
value: { viewport: 'mobile', pseudo: ':hover' },
|
|
230
|
+
value: { viewport: '@mobile', pseudo: ':hover' },
|
|
93
231
|
},
|
|
94
232
|
};
|
|
95
233
|
|
|
96
234
|
expect( getSelectedBlockStyleState( state, 'client-1' ) ).toEqual( {
|
|
97
|
-
viewport: 'mobile',
|
|
235
|
+
viewport: '@mobile',
|
|
98
236
|
pseudo: ':hover',
|
|
99
237
|
} );
|
|
100
238
|
} );
|
|
@@ -149,7 +287,7 @@ describe( 'private selectors', () => {
|
|
|
149
287
|
const state = {
|
|
150
288
|
selectedBlockStyleState: {
|
|
151
289
|
clientId: 'client-1',
|
|
152
|
-
value: { viewport: 'mobile', pseudo: 'default' },
|
|
290
|
+
value: { viewport: '@mobile', pseudo: 'default' },
|
|
153
291
|
},
|
|
154
292
|
};
|
|
155
293
|
|
|
@@ -171,7 +309,7 @@ describe( 'private selectors', () => {
|
|
|
171
309
|
const state = {
|
|
172
310
|
selectedBlockStyleState: {
|
|
173
311
|
clientId: 'client-1',
|
|
174
|
-
value: { viewport: 'mobile', pseudo: ':hover' },
|
|
312
|
+
value: { viewport: '@mobile', pseudo: ':hover' },
|
|
175
313
|
},
|
|
176
314
|
};
|
|
177
315
|
|
|
@@ -1523,6 +1661,7 @@ describe( 'private selectors', () => {
|
|
|
1523
1661
|
blockName = 'core/group',
|
|
1524
1662
|
patternName,
|
|
1525
1663
|
disableContentOnlyForUnsyncedPatterns,
|
|
1664
|
+
disableContentOnlyForTemplateParts,
|
|
1526
1665
|
templateLock,
|
|
1527
1666
|
rootTemplateLock,
|
|
1528
1667
|
} = {} ) => {
|
|
@@ -1547,10 +1686,14 @@ describe( 'private selectors', () => {
|
|
|
1547
1686
|
: {},
|
|
1548
1687
|
],
|
|
1549
1688
|
] ),
|
|
1550
|
-
settings:
|
|
1551
|
-
disableContentOnlyForUnsyncedPatterns !== undefined
|
|
1689
|
+
settings: {
|
|
1690
|
+
...( disableContentOnlyForUnsyncedPatterns !== undefined
|
|
1552
1691
|
? { disableContentOnlyForUnsyncedPatterns }
|
|
1553
|
-
: {},
|
|
1692
|
+
: {} ),
|
|
1693
|
+
...( disableContentOnlyForTemplateParts !== undefined
|
|
1694
|
+
? { disableContentOnlyForTemplateParts }
|
|
1695
|
+
: {} ),
|
|
1696
|
+
},
|
|
1554
1697
|
editedContentOnlySection: undefined,
|
|
1555
1698
|
};
|
|
1556
1699
|
};
|
|
@@ -1594,6 +1737,22 @@ describe( 'private selectors', () => {
|
|
|
1594
1737
|
expect( isSectionBlock( state, 'block-1' ) ).toBe( true );
|
|
1595
1738
|
} );
|
|
1596
1739
|
|
|
1740
|
+
it( 'should return false for template parts when disableContentOnlyForTemplateParts is true', () => {
|
|
1741
|
+
const state = createState( {
|
|
1742
|
+
blockName: 'core/template-part',
|
|
1743
|
+
disableContentOnlyForTemplateParts: true,
|
|
1744
|
+
} );
|
|
1745
|
+
expect( isSectionBlock( state, 'block-1' ) ).toBe( false );
|
|
1746
|
+
} );
|
|
1747
|
+
|
|
1748
|
+
it( 'should return true for template parts when disableContentOnlyForTemplateParts is false', () => {
|
|
1749
|
+
const state = createState( {
|
|
1750
|
+
blockName: 'core/template-part',
|
|
1751
|
+
disableContentOnlyForTemplateParts: false,
|
|
1752
|
+
} );
|
|
1753
|
+
expect( isSectionBlock( state, 'block-1' ) ).toBe( true );
|
|
1754
|
+
} );
|
|
1755
|
+
|
|
1597
1756
|
it( 'returns false when nested inside another section block', () => {
|
|
1598
1757
|
const state = {
|
|
1599
1758
|
blocks: {
|