@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
|
@@ -11,6 +11,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
11
11
|
import { GridVisualizer, useGridLayoutSync } from '../components/grid';
|
|
12
12
|
import { store as blockEditorStore } from '../store';
|
|
13
13
|
import { unlock } from '../lock-unlock';
|
|
14
|
+
import { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
|
|
14
15
|
import useBlockVisibility from '../components/block-visibility/use-block-visibility';
|
|
15
16
|
import { deviceTypeKey } from '../store/private-keys';
|
|
16
17
|
import { BLOCK_VISIBILITY_VIEWPORTS } from '../components/block-visibility/constants';
|
|
@@ -20,60 +21,73 @@ function GridLayoutSync( props ) {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
function GridTools( { clientId, layout } ) {
|
|
23
|
-
const { isVisible, blockVisibility, deviceType
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} = select( blockEditorStore );
|
|
24
|
+
const { isVisible, blockVisibility, deviceType } = useSelect(
|
|
25
|
+
( select ) => {
|
|
26
|
+
const {
|
|
27
|
+
isBlockSelected,
|
|
28
|
+
hasSelectedInnerBlock,
|
|
29
|
+
isDraggingBlocks,
|
|
30
|
+
getTemplateLock,
|
|
31
|
+
getBlockEditingMode,
|
|
32
|
+
getBlockAttributes,
|
|
33
|
+
getSettings,
|
|
34
|
+
} = select( blockEditorStore );
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
// These calls are purposely ordered from least expensive to most expensive.
|
|
37
|
+
// Hides the visualizer in cases where the user is not or cannot interact with it.
|
|
38
|
+
// Also hide if a child block is selected, because layout-child.js will render
|
|
39
|
+
// the visualizer in that case (with proper childGridClientId handling).
|
|
40
|
+
if (
|
|
41
|
+
( ! isDraggingBlocks() && ! isBlockSelected( clientId ) ) ||
|
|
42
|
+
getTemplateLock( clientId ) ||
|
|
43
|
+
getBlockEditingMode( clientId ) !== 'default' ||
|
|
44
|
+
hasSelectedInnerBlock( clientId )
|
|
45
|
+
) {
|
|
46
|
+
return { isVisible: false };
|
|
47
|
+
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
const attributes = getBlockAttributes( clientId );
|
|
50
|
+
const settings = getSettings();
|
|
51
|
+
const currentDeviceType =
|
|
52
|
+
settings?.[ deviceTypeKey ]?.toLowerCase() ||
|
|
53
|
+
BLOCK_VISIBILITY_VIEWPORTS.desktop.key;
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
return {
|
|
56
|
+
isVisible: true,
|
|
57
|
+
blockVisibility: attributes?.metadata?.blockVisibility,
|
|
58
|
+
deviceType: currentDeviceType,
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
[ clientId ]
|
|
62
|
+
);
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
clientId,
|
|
65
|
-
currentDeviceType
|
|
66
|
-
),
|
|
67
|
-
};
|
|
68
|
-
},
|
|
69
|
-
[ clientId ]
|
|
70
|
-
);
|
|
64
|
+
// Get the block's DOM element to derive the canvas iframe window,
|
|
65
|
+
// so viewport detection matches the actual block rendering context
|
|
66
|
+
const blockElement = useBlockElement( clientId );
|
|
67
|
+
const rawCanvasView = blockElement?.ownerDocument?.defaultView;
|
|
68
|
+
const canvasView = rawCanvasView === null ? undefined : rawCanvasView;
|
|
71
69
|
|
|
72
|
-
const { isBlockCurrentlyHidden } = useBlockVisibility( {
|
|
70
|
+
const { isBlockCurrentlyHidden, currentViewport } = useBlockVisibility( {
|
|
73
71
|
blockVisibility,
|
|
74
72
|
deviceType,
|
|
73
|
+
view: canvasView,
|
|
75
74
|
} );
|
|
76
75
|
|
|
76
|
+
// Check whether any ancestor is hidden at the viewport actually detected
|
|
77
|
+
// from the canvas, so it stays consistent with how blocks are hidden.
|
|
78
|
+
const isAnyAncestorHidden = useSelect(
|
|
79
|
+
( select ) => {
|
|
80
|
+
if ( ! isVisible ) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
const { isBlockParentHiddenAtViewport } = unlock(
|
|
84
|
+
select( blockEditorStore )
|
|
85
|
+
);
|
|
86
|
+
return isBlockParentHiddenAtViewport( clientId, currentViewport );
|
|
87
|
+
},
|
|
88
|
+
[ clientId, currentViewport, isVisible ]
|
|
89
|
+
);
|
|
90
|
+
|
|
77
91
|
return (
|
|
78
92
|
<>
|
|
79
93
|
<GridLayoutSync clientId={ clientId } />
|
|
@@ -9,6 +9,7 @@ import { useState } from '@wordpress/element';
|
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
11
|
import { store as blockEditorStore } from '../store';
|
|
12
|
+
import { unlock } from '../lock-unlock';
|
|
12
13
|
import { useStyleOverride } from './utils';
|
|
13
14
|
import { useLayout } from '../components/block-list/layout';
|
|
14
15
|
import {
|
|
@@ -16,18 +17,41 @@ import {
|
|
|
16
17
|
GridItemResizer,
|
|
17
18
|
GridItemMovers,
|
|
18
19
|
} from '../components/grid';
|
|
20
|
+
import { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
|
|
19
21
|
import useBlockVisibility from '../components/block-visibility/use-block-visibility';
|
|
20
22
|
import { deviceTypeKey } from '../store/private-keys';
|
|
21
23
|
import { BLOCK_VISIBILITY_VIEWPORTS } from '../components/block-visibility/constants';
|
|
24
|
+
import {
|
|
25
|
+
DEFAULT_BLOCK_STYLE_STATE,
|
|
26
|
+
getStyleForState,
|
|
27
|
+
} from './block-style-state';
|
|
22
28
|
|
|
23
29
|
// Used for generating the instance ID
|
|
24
30
|
const LAYOUT_CHILD_BLOCK_PROPS_REFERENCE = {};
|
|
25
31
|
// Keep in sync with WP_Theme_JSON_Gutenberg::RESPONSIVE_BREAKPOINTS.
|
|
26
32
|
const RESPONSIVE_BREAKPOINTS = {
|
|
27
|
-
mobile: '@media (width <= 480px)',
|
|
28
|
-
tablet: '@media (480px < width <= 782px)',
|
|
33
|
+
'@mobile': '@media (width <= 480px)',
|
|
34
|
+
'@tablet': '@media (480px < width <= 782px)',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// These are the serialized `selfStretch` values. `max` used to be called
|
|
38
|
+
// "Fixed" in the UI, but was renamed and replaced by `fixedNoShrink`.
|
|
39
|
+
const FLEX_CHILD_LAYOUT_VALUES = {
|
|
40
|
+
fit: 'fit',
|
|
41
|
+
grow: 'fill',
|
|
42
|
+
max: 'fixed',
|
|
43
|
+
fixed: 'fixedNoShrink',
|
|
29
44
|
};
|
|
30
45
|
|
|
46
|
+
const FLEX_SIZE_VALUES = [
|
|
47
|
+
FLEX_CHILD_LAYOUT_VALUES.max,
|
|
48
|
+
FLEX_CHILD_LAYOUT_VALUES.fixed,
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
function isFlexSizeValue( value ) {
|
|
52
|
+
return FLEX_SIZE_VALUES.includes( value );
|
|
53
|
+
}
|
|
54
|
+
|
|
31
55
|
function serializeRule( { selector, declarations } ) {
|
|
32
56
|
return `${ selector } {
|
|
33
57
|
${ Object.entries( declarations )
|
|
@@ -60,6 +84,7 @@ export function getChildLayoutStyleRules( {
|
|
|
60
84
|
columnSpan,
|
|
61
85
|
rowSpan,
|
|
62
86
|
} = effectiveLayout;
|
|
87
|
+
const baseSelfStretch = layout.selfStretch;
|
|
63
88
|
const { columnCount, minimumColumnWidth } = parentLayout;
|
|
64
89
|
const rules = [];
|
|
65
90
|
|
|
@@ -69,10 +94,30 @@ export function getChildLayoutStyleRules( {
|
|
|
69
94
|
hasViewportOverride( 'selfStretch' ) ||
|
|
70
95
|
hasViewportOverride( 'flexSize' )
|
|
71
96
|
) {
|
|
72
|
-
if (
|
|
97
|
+
if (
|
|
98
|
+
hasViewportOverrides &&
|
|
99
|
+
( selfStretch === FLEX_CHILD_LAYOUT_VALUES.fit ||
|
|
100
|
+
selfStretch === FLEX_CHILD_LAYOUT_VALUES.grow ) &&
|
|
101
|
+
isFlexSizeValue( baseSelfStretch ) &&
|
|
102
|
+
layout.flexSize
|
|
103
|
+
) {
|
|
104
|
+
declarations[ 'flex-basis' ] = 'unset';
|
|
105
|
+
if ( baseSelfStretch === FLEX_CHILD_LAYOUT_VALUES.fixed ) {
|
|
106
|
+
declarations[ 'flex-shrink' ] = 'unset';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if ( isFlexSizeValue( selfStretch ) && flexSize ) {
|
|
73
110
|
declarations[ 'flex-basis' ] = flexSize;
|
|
111
|
+
if ( selfStretch === FLEX_CHILD_LAYOUT_VALUES.fixed ) {
|
|
112
|
+
declarations[ 'flex-shrink' ] = '0';
|
|
113
|
+
} else if (
|
|
114
|
+
hasViewportOverrides &&
|
|
115
|
+
baseSelfStretch === FLEX_CHILD_LAYOUT_VALUES.fixed
|
|
116
|
+
) {
|
|
117
|
+
declarations[ 'flex-shrink' ] = 'unset';
|
|
118
|
+
}
|
|
74
119
|
declarations[ 'box-sizing' ] = 'border-box';
|
|
75
|
-
} else if ( selfStretch ===
|
|
120
|
+
} else if ( selfStretch === FLEX_CHILD_LAYOUT_VALUES.grow ) {
|
|
76
121
|
declarations[ 'flex-grow' ] = '1';
|
|
77
122
|
}
|
|
78
123
|
}
|
|
@@ -213,7 +258,10 @@ export function getResponsiveChildLayoutStyles( {
|
|
|
213
258
|
|
|
214
259
|
return Object.entries( RESPONSIVE_BREAKPOINTS )
|
|
215
260
|
.map( ( [ viewport, mediaQuery ] ) => {
|
|
216
|
-
const viewportLayout = style
|
|
261
|
+
const viewportLayout = getStyleForState( style, {
|
|
262
|
+
viewport,
|
|
263
|
+
pseudo: DEFAULT_BLOCK_STYLE_STATE.pseudo,
|
|
264
|
+
} )?.layout;
|
|
217
265
|
if ( ! viewportLayout || ! Object.keys( viewportLayout ).length ) {
|
|
218
266
|
return '';
|
|
219
267
|
}
|
|
@@ -351,6 +399,9 @@ function GridTools( {
|
|
|
351
399
|
const parentAttributes = getBlockAttributes( _rootClientId );
|
|
352
400
|
const blockAttributes = getBlockAttributes( clientId );
|
|
353
401
|
const settings = getSettings();
|
|
402
|
+
const currentDeviceType =
|
|
403
|
+
settings?.[ deviceTypeKey ]?.toLowerCase() ||
|
|
404
|
+
BLOCK_VISIBILITY_VIEWPORTS.desktop.key;
|
|
354
405
|
|
|
355
406
|
return {
|
|
356
407
|
rootClientId: _rootClientId,
|
|
@@ -359,9 +410,7 @@ function GridTools( {
|
|
|
359
410
|
parentAttributes?.metadata?.blockVisibility,
|
|
360
411
|
blockBlockVisibility:
|
|
361
412
|
blockAttributes?.metadata?.blockVisibility,
|
|
362
|
-
deviceType:
|
|
363
|
-
settings?.[ deviceTypeKey ]?.toLowerCase() ||
|
|
364
|
-
BLOCK_VISIBILITY_VIEWPORTS.desktop.key,
|
|
413
|
+
deviceType: currentDeviceType,
|
|
365
414
|
// Check if the selected child block is itself a grid.
|
|
366
415
|
isChildBlockAGrid: blockAttributes?.layout?.type === 'grid',
|
|
367
416
|
};
|
|
@@ -369,16 +418,45 @@ function GridTools( {
|
|
|
369
418
|
[ clientId ]
|
|
370
419
|
);
|
|
371
420
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
421
|
+
// Get the block's DOM element to derive the canvas iframe window,
|
|
422
|
+
// so viewport detection matches the actual block rendering context
|
|
423
|
+
const blockElement = useBlockElement( clientId );
|
|
424
|
+
const rawCanvasView = blockElement?.ownerDocument?.defaultView;
|
|
425
|
+
const canvasView = rawCanvasView === null ? undefined : rawCanvasView;
|
|
426
|
+
|
|
427
|
+
const {
|
|
428
|
+
isBlockCurrentlyHidden: isParentBlockCurrentlyHidden,
|
|
429
|
+
currentViewport,
|
|
430
|
+
} = useBlockVisibility( {
|
|
431
|
+
blockVisibility: parentBlockVisibility,
|
|
432
|
+
deviceType,
|
|
433
|
+
view: canvasView,
|
|
434
|
+
} );
|
|
435
|
+
|
|
436
|
+
// Check whether any ancestor of the parent grid is hidden at the viewport
|
|
437
|
+
// actually detected from the canvas, so it stays consistent with how
|
|
438
|
+
// blocks are hidden.
|
|
439
|
+
const isAnyAncestorHidden = useSelect(
|
|
440
|
+
( select ) => {
|
|
441
|
+
if ( ! rootClientId ) {
|
|
442
|
+
return false;
|
|
443
|
+
}
|
|
444
|
+
const { isBlockParentHiddenAtViewport } = unlock(
|
|
445
|
+
select( blockEditorStore )
|
|
446
|
+
);
|
|
447
|
+
return isBlockParentHiddenAtViewport(
|
|
448
|
+
rootClientId,
|
|
449
|
+
currentViewport
|
|
450
|
+
);
|
|
451
|
+
},
|
|
452
|
+
[ rootClientId, currentViewport ]
|
|
453
|
+
);
|
|
377
454
|
|
|
378
455
|
const { isBlockCurrentlyHidden: isBlockItselfCurrentlyHidden } =
|
|
379
456
|
useBlockVisibility( {
|
|
380
457
|
blockVisibility: blockBlockVisibility,
|
|
381
458
|
deviceType,
|
|
459
|
+
view: canvasView,
|
|
382
460
|
} );
|
|
383
461
|
|
|
384
462
|
// Use useState() instead of useRef() so that GridItemResizer updates when ref is set.
|
|
@@ -386,7 +464,7 @@ function GridTools( {
|
|
|
386
464
|
|
|
387
465
|
const childGridClientId = isChildBlockAGrid ? clientId : undefined;
|
|
388
466
|
|
|
389
|
-
if ( ! isVisible || isParentBlockCurrentlyHidden ) {
|
|
467
|
+
if ( ! isVisible || isParentBlockCurrentlyHidden || isAnyAncestorHidden ) {
|
|
390
468
|
return null;
|
|
391
469
|
}
|
|
392
470
|
|
package/src/hooks/layout.js
CHANGED
|
@@ -52,8 +52,8 @@ const layoutBlockSupportKey = 'layout';
|
|
|
52
52
|
// Keep in sync with WP_Theme_JSON_Gutenberg::RESPONSIVE_BREAKPOINTS and
|
|
53
53
|
// packages/global-styles-engine/src/core/render.tsx.
|
|
54
54
|
const RESPONSIVE_BREAKPOINTS = {
|
|
55
|
-
mobile: '@media (width <= 480px)',
|
|
56
|
-
tablet: '@media (480px < width <= 782px)',
|
|
55
|
+
'@mobile': '@media (width <= 480px)',
|
|
56
|
+
'@tablet': '@media (480px < width <= 782px)',
|
|
57
57
|
};
|
|
58
58
|
const CHILD_LAYOUT_KEYS = [
|
|
59
59
|
'selfStretch',
|
|
@@ -252,7 +252,10 @@ export function getResponsiveLayoutStyles( {
|
|
|
252
252
|
} ) {
|
|
253
253
|
return Object.entries( RESPONSIVE_BREAKPOINTS )
|
|
254
254
|
.map( ( [ viewport, mediaQuery ] ) => {
|
|
255
|
-
const viewportStyle = attributes?.style
|
|
255
|
+
const viewportStyle = getStyleForState( attributes?.style, {
|
|
256
|
+
viewport,
|
|
257
|
+
pseudo: DEFAULT_BLOCK_STYLE_STATE.pseudo,
|
|
258
|
+
} );
|
|
256
259
|
const viewportLayout = getLayoutContainerValues(
|
|
257
260
|
viewportStyle?.layout
|
|
258
261
|
);
|
package/src/hooks/list-view.js
CHANGED
|
@@ -50,26 +50,25 @@ export function ListViewPanel( { clientId, name } ) {
|
|
|
50
50
|
useDispatch( blockEditorStore )
|
|
51
51
|
);
|
|
52
52
|
|
|
53
|
-
const isEnabled =
|
|
54
|
-
const { hasChildren, isNestedListView } = useSelect(
|
|
53
|
+
const { isEnabled, hasChildren, isNestedListView } = useSelect(
|
|
55
54
|
( select ) => {
|
|
56
|
-
const {
|
|
57
|
-
|
|
55
|
+
const {
|
|
56
|
+
getBlockCount,
|
|
57
|
+
getBlockParents,
|
|
58
|
+
shouldRenderBlockListView,
|
|
59
|
+
} = unlock( select( blockEditorStore ) );
|
|
58
60
|
|
|
59
61
|
// Avoid showing List Views for both parent and child blocks that have support.
|
|
60
62
|
// In this situation the parent will show the child in its list already.
|
|
61
63
|
// Search parents to see if there's one that also has support, and if so skip rendering.
|
|
62
64
|
// This matches closely the logic in the `BlockCard` component.
|
|
63
65
|
const parents = getBlockParents( clientId, false );
|
|
64
|
-
const _isNestedListView = parents.find( ( parentId ) =>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
parentName === 'core/navigation' ||
|
|
68
|
-
hasBlockSupport( parentName, 'listView' )
|
|
69
|
-
);
|
|
70
|
-
} );
|
|
66
|
+
const _isNestedListView = parents.find( ( parentId ) =>
|
|
67
|
+
shouldRenderBlockListView( parentId )
|
|
68
|
+
);
|
|
71
69
|
|
|
72
70
|
return {
|
|
71
|
+
isEnabled: shouldRenderBlockListView( clientId ),
|
|
73
72
|
hasChildren: !! getBlockCount( clientId ),
|
|
74
73
|
isNestedListView: _isNestedListView,
|
|
75
74
|
};
|
package/src/hooks/states.js
CHANGED
|
@@ -19,8 +19,8 @@ export const PSEUDO_STATE_LABELS = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
export const RESPONSIVE_STATE_LABELS = {
|
|
22
|
-
tablet: __( 'Tablet' ),
|
|
23
|
-
mobile: __( 'Mobile' ),
|
|
22
|
+
'@tablet': __( 'Tablet' ),
|
|
23
|
+
'@mobile': __( 'Mobile' ),
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
// Keep in sync with WP_Theme_JSON_Gutenberg::VALID_BLOCK_PSEUDO_SELECTORS
|
package/src/hooks/style.js
CHANGED
|
@@ -19,7 +19,8 @@ import { getCSSRules, compileCSS } from '@wordpress/style-engine';
|
|
|
19
19
|
*/
|
|
20
20
|
import { BACKGROUND_SUPPORT_KEY, BackgroundImagePanel } from './background';
|
|
21
21
|
import { BORDER_SUPPORT_KEY, BorderPanel, SHADOW_SUPPORT_KEY } from './border';
|
|
22
|
-
import { COLOR_SUPPORT_KEY
|
|
22
|
+
import { COLOR_SUPPORT_KEY } from './color';
|
|
23
|
+
import { ElementsEdit } from './elements';
|
|
23
24
|
import {
|
|
24
25
|
TypographyPanel,
|
|
25
26
|
TYPOGRAPHY_SUPPORT_KEY,
|
|
@@ -29,6 +30,7 @@ import {
|
|
|
29
30
|
DIMENSIONS_SUPPORT_KEY,
|
|
30
31
|
SPACING_SUPPORT_KEY,
|
|
31
32
|
DimensionsPanel,
|
|
33
|
+
isExplicitAspectRatio,
|
|
32
34
|
} from './dimensions';
|
|
33
35
|
import {
|
|
34
36
|
cleanEmptyObject,
|
|
@@ -56,8 +58,8 @@ const BORDER_SIDES = [ 'Top', 'Right', 'Bottom', 'Left' ];
|
|
|
56
58
|
// Keep in sync with WP_Theme_JSON_Gutenberg::RESPONSIVE_BREAKPOINTS and
|
|
57
59
|
// packages/global-styles-engine/src/core/render.tsx.
|
|
58
60
|
const RESPONSIVE_BREAKPOINTS = {
|
|
59
|
-
mobile: '@media (width <= 480px)',
|
|
60
|
-
tablet: '@media (480px < width <= 782px)',
|
|
61
|
+
'@mobile': '@media (width <= 480px)',
|
|
62
|
+
'@tablet': '@media (480px < width <= 782px)',
|
|
61
63
|
};
|
|
62
64
|
|
|
63
65
|
const styleSupportKeys = [
|
|
@@ -134,6 +136,72 @@ function getStateFallbackBorderStyles( stateStyles ) {
|
|
|
134
136
|
return cleanEmptyObject( { border: cleanEmptyObject( fallbackBorder ) } );
|
|
135
137
|
}
|
|
136
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Returns background reset CSS for a state that sets a solid background color.
|
|
141
|
+
*
|
|
142
|
+
* When a state sets `color.background` (a solid color) without also setting a
|
|
143
|
+
* gradient (`color.gradient` or `background.gradient`), any gradient applied to
|
|
144
|
+
* the default state via an inline `background` shorthand or `background-image`
|
|
145
|
+
* declaration must be explicitly cleared. Without this, the gradient image layer
|
|
146
|
+
* remains visible even though the solid hover color wins `background-color`.
|
|
147
|
+
*
|
|
148
|
+
* @param {Object} stateStyles State style object.
|
|
149
|
+
* @param {string} selector CSS selector for the generated style.
|
|
150
|
+
* @return {string|undefined} CSS string with background-image reset, or undefined.
|
|
151
|
+
*/
|
|
152
|
+
function getStateBackgroundResetCSS( stateStyles, selector ) {
|
|
153
|
+
const hasSolidBackground = !! stateStyles?.color?.background;
|
|
154
|
+
|
|
155
|
+
if ( ! hasSolidBackground ) {
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const hasColorGradient = !! stateStyles?.color?.gradient;
|
|
160
|
+
const hasBackgroundGradient =
|
|
161
|
+
!! stateStyles?.background?.gradient ||
|
|
162
|
+
!! stateStyles?.background?.backgroundImage;
|
|
163
|
+
|
|
164
|
+
if ( hasColorGradient || hasBackgroundGradient ) {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const declaration = 'background-image: unset !important';
|
|
169
|
+
return selector
|
|
170
|
+
? `${ selector } { ${ declaration }; }`
|
|
171
|
+
: `${ declaration };`;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Returns fallback dimension styles that keep state styles aligned with the
|
|
176
|
+
* default dimensions block-support output.
|
|
177
|
+
*
|
|
178
|
+
* @param {Object} stateStyles State style object.
|
|
179
|
+
* @return {Object|undefined} Style object containing fallback dimension styles.
|
|
180
|
+
*/
|
|
181
|
+
function getStateFallbackDimensionStyles( stateStyles ) {
|
|
182
|
+
const dimensions = stateStyles?.dimensions;
|
|
183
|
+
if ( ! dimensions ) {
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if ( isExplicitAspectRatio( dimensions.aspectRatio ) ) {
|
|
188
|
+
return {
|
|
189
|
+
dimensions: {
|
|
190
|
+
minHeight: 'unset',
|
|
191
|
+
height: 'unset',
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if ( dimensions.minHeight || dimensions.height ) {
|
|
197
|
+
return {
|
|
198
|
+
dimensions: {
|
|
199
|
+
aspectRatio: 'unset',
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
137
205
|
/**
|
|
138
206
|
* Generates CSS for a block instance state style object.
|
|
139
207
|
*
|
|
@@ -146,14 +214,25 @@ function getStateFallbackBorderStyles( stateStyles ) {
|
|
|
146
214
|
* @return {string} Generated stylesheet.
|
|
147
215
|
*/
|
|
148
216
|
export function getStateStylesCSS( stateStyles, selector ) {
|
|
149
|
-
const
|
|
217
|
+
const fallbackDimensionStyles =
|
|
218
|
+
getStateFallbackDimensionStyles( stateStyles );
|
|
219
|
+
const stylesWithDimensionFallbacks = fallbackDimensionStyles
|
|
220
|
+
? mergeStyleObjects( stateStyles, fallbackDimensionStyles )
|
|
221
|
+
: stateStyles;
|
|
222
|
+
const css = compileCSS( stylesWithDimensionFallbacks, { selector } );
|
|
150
223
|
const importantCSS = css ? css.replace( /;/g, ' !important;' ) : undefined;
|
|
151
224
|
const fallbackBorderStyles = getStateFallbackBorderStyles( stateStyles );
|
|
152
225
|
const fallbackCSS = fallbackBorderStyles
|
|
153
226
|
? compileCSS( fallbackBorderStyles, { selector } )
|
|
154
227
|
: undefined;
|
|
228
|
+
const backgroundResetCSS = getStateBackgroundResetCSS(
|
|
229
|
+
stateStyles,
|
|
230
|
+
selector
|
|
231
|
+
);
|
|
155
232
|
|
|
156
|
-
return [ importantCSS, fallbackCSS ]
|
|
233
|
+
return [ importantCSS, fallbackCSS, backgroundResetCSS ]
|
|
234
|
+
.filter( Boolean )
|
|
235
|
+
.join( '\n' );
|
|
157
236
|
}
|
|
158
237
|
|
|
159
238
|
function isPlainObject( value ) {
|
|
@@ -341,7 +420,10 @@ export function getResponsiveStateCSSRules( style, name, baseSelector ) {
|
|
|
341
420
|
|
|
342
421
|
Object.entries( RESPONSIVE_BREAKPOINTS ).forEach(
|
|
343
422
|
( [ viewport, mediaQuery ] ) => {
|
|
344
|
-
const viewportStyles = style
|
|
423
|
+
const viewportStyles = getStyleForState( style, {
|
|
424
|
+
viewport,
|
|
425
|
+
pseudo: DEFAULT_BLOCK_STYLE_STATE.pseudo,
|
|
426
|
+
} );
|
|
345
427
|
if ( ! viewportStyles ) {
|
|
346
428
|
return;
|
|
347
429
|
}
|
|
@@ -386,8 +468,8 @@ export function getResponsiveStateCSSRules( style, name, baseSelector ) {
|
|
|
386
468
|
* Returns the style value used to force-preview a selected state on canvas.
|
|
387
469
|
*
|
|
388
470
|
* Responsive pseudo states inherit from their default-viewport pseudo state.
|
|
389
|
-
* For example, selecting
|
|
390
|
-
* `:hover`, with
|
|
471
|
+
* For example, selecting `@mobile + :hover` should preview styles from
|
|
472
|
+
* `:hover`, with `@mobile.:hover` values layered on top when present.
|
|
391
473
|
*
|
|
392
474
|
* @param {Object} style Block style object.
|
|
393
475
|
* @param {Object} selectedState Selected block style state.
|
|
@@ -770,7 +852,7 @@ function BlockStyleControls( {
|
|
|
770
852
|
|
|
771
853
|
return (
|
|
772
854
|
<BlockStyleStateProvider value={ selectedState }>
|
|
773
|
-
<
|
|
855
|
+
<ElementsEdit { ...passedProps } />
|
|
774
856
|
<BackgroundImagePanel { ...passedProps } />
|
|
775
857
|
<TypographyPanel { ...passedProps } />
|
|
776
858
|
<BorderPanel { ...passedProps } />
|
|
@@ -3,10 +3,69 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
5
|
setBackgroundStyleDefaults,
|
|
6
|
+
backgroundResetAllFilter,
|
|
6
7
|
BACKGROUND_BLOCK_DEFAULT_VALUES,
|
|
7
8
|
} from '../background';
|
|
8
9
|
|
|
9
10
|
describe( 'background', () => {
|
|
11
|
+
describe( 'backgroundResetAllFilter', () => {
|
|
12
|
+
it( 'clears every background-owned value, including a custom legacy color.gradient', () => {
|
|
13
|
+
const result = backgroundResetAllFilter( {
|
|
14
|
+
backgroundColor: 'primary',
|
|
15
|
+
gradient: 'vivid-cyan-blue',
|
|
16
|
+
className: 'is-style-fancy has-background',
|
|
17
|
+
style: {
|
|
18
|
+
color: {
|
|
19
|
+
text: 'var:preset|color|contrast',
|
|
20
|
+
background: 'var:preset|color|base',
|
|
21
|
+
gradient:
|
|
22
|
+
'linear-gradient(135deg,rgb(100,100,200) 0%,rgb(200,100,100) 100%)',
|
|
23
|
+
},
|
|
24
|
+
spacing: { padding: '10px' },
|
|
25
|
+
background: { backgroundImage: { url: 'image.png' } },
|
|
26
|
+
},
|
|
27
|
+
} );
|
|
28
|
+
|
|
29
|
+
// Background color and gradient attributes are cleared.
|
|
30
|
+
expect( result.backgroundColor ).toBeUndefined();
|
|
31
|
+
expect( result.gradient ).toBeUndefined();
|
|
32
|
+
|
|
33
|
+
// The legacy `color.gradient` (a raw/custom value) is cleared. This
|
|
34
|
+
// is the regression guard: it was previously kept for blocks
|
|
35
|
+
// without `background.gradient` support.
|
|
36
|
+
expect( result.style?.color?.gradient ).toBeUndefined();
|
|
37
|
+
expect( result.style?.color?.background ).toBeUndefined();
|
|
38
|
+
expect( result.style?.background ).toBeUndefined();
|
|
39
|
+
|
|
40
|
+
// Unrelated styles are preserved.
|
|
41
|
+
expect( result.style?.color?.text ).toBe(
|
|
42
|
+
'var:preset|color|contrast'
|
|
43
|
+
);
|
|
44
|
+
expect( result.style?.spacing ).toEqual( { padding: '10px' } );
|
|
45
|
+
|
|
46
|
+
// The `has-background` class is removed, other classes remain.
|
|
47
|
+
expect( result.className ).toBe( 'is-style-fancy' );
|
|
48
|
+
} );
|
|
49
|
+
|
|
50
|
+
it( 'drops className entirely when has-background was its only value', () => {
|
|
51
|
+
const result = backgroundResetAllFilter( {
|
|
52
|
+
className: 'has-background',
|
|
53
|
+
style: {
|
|
54
|
+
color: { gradient: 'linear-gradient(0deg,#000,#fff)' },
|
|
55
|
+
},
|
|
56
|
+
} );
|
|
57
|
+
expect( result.className ).toBeUndefined();
|
|
58
|
+
} );
|
|
59
|
+
|
|
60
|
+
it( 'leaves className untouched when has-background is not present', () => {
|
|
61
|
+
const result = backgroundResetAllFilter( {
|
|
62
|
+
className: 'is-style-fancy',
|
|
63
|
+
style: {},
|
|
64
|
+
} );
|
|
65
|
+
expect( result.className ).toBe( 'is-style-fancy' );
|
|
66
|
+
} );
|
|
67
|
+
} );
|
|
68
|
+
|
|
10
69
|
describe( 'setBackgroundStyleDefaults', () => {
|
|
11
70
|
const backgroundStyles = {
|
|
12
71
|
backgroundImage: { id: 123, url: 'image.png' },
|