@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
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useSelect } from '@wordpress/data';
|
|
10
|
+
import { useEffect } from '@wordpress/element';
|
|
11
|
+
import { symbol } from '@wordpress/icons';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import useBlockDisplayInformation from '../';
|
|
17
|
+
import { isIsolatedEditorKey } from '../../../store/private-keys';
|
|
18
|
+
|
|
19
|
+
jest.mock( '@wordpress/data/src/components/use-select', () => jest.fn() );
|
|
20
|
+
jest.mock( '../../../lock-unlock', () => ( {
|
|
21
|
+
unlock: ( value ) => ( {
|
|
22
|
+
registerPrivateActions: jest.fn(),
|
|
23
|
+
registerPrivateSelectors: jest.fn(),
|
|
24
|
+
...value,
|
|
25
|
+
} ),
|
|
26
|
+
} ) );
|
|
27
|
+
|
|
28
|
+
const groupIcon = 'group-icon';
|
|
29
|
+
|
|
30
|
+
function TestComponent( { onChange } ) {
|
|
31
|
+
const blockInformation = useBlockDisplayInformation( 'client-id' );
|
|
32
|
+
useEffect( () => {
|
|
33
|
+
onChange( blockInformation );
|
|
34
|
+
}, [ blockInformation, onChange ] );
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function setupUseSelect( {
|
|
39
|
+
attributes = {
|
|
40
|
+
anchor: 'hero',
|
|
41
|
+
metadata: {
|
|
42
|
+
name: 'Hero pattern',
|
|
43
|
+
patternName: 'theme/hero',
|
|
44
|
+
},
|
|
45
|
+
style: {
|
|
46
|
+
position: {
|
|
47
|
+
type: 'sticky',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
blockName = 'core/group',
|
|
52
|
+
blockType = {
|
|
53
|
+
name: 'core/group',
|
|
54
|
+
title: 'Group',
|
|
55
|
+
icon: groupIcon,
|
|
56
|
+
description: 'Gather blocks in a layout container.',
|
|
57
|
+
},
|
|
58
|
+
getActiveBlockVariation = () => null,
|
|
59
|
+
settings = {},
|
|
60
|
+
isWithinEditedSection = false,
|
|
61
|
+
} = {} ) {
|
|
62
|
+
useSelect.mockImplementation( ( mapSelect ) =>
|
|
63
|
+
mapSelect( () => ( {
|
|
64
|
+
getBlockName: () => blockName,
|
|
65
|
+
getBlockAttributes: () => attributes,
|
|
66
|
+
getSettings: () => settings,
|
|
67
|
+
__experimentalGetParsedPattern: () => ( {
|
|
68
|
+
title: 'Hero pattern',
|
|
69
|
+
description: 'Pattern description.',
|
|
70
|
+
} ),
|
|
71
|
+
isWithinEditedContentOnlySection: () => isWithinEditedSection,
|
|
72
|
+
getBlockType: () => blockType,
|
|
73
|
+
getActiveBlockVariation,
|
|
74
|
+
} ) )
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
describe( 'useBlockDisplayInformation', () => {
|
|
79
|
+
beforeEach( () => {
|
|
80
|
+
jest.clearAllMocks();
|
|
81
|
+
} );
|
|
82
|
+
|
|
83
|
+
it( 'displays pattern information for a pattern section that is not being edited', () => {
|
|
84
|
+
setupUseSelect();
|
|
85
|
+
const onChange = jest.fn();
|
|
86
|
+
|
|
87
|
+
render( <TestComponent onChange={ onChange } /> );
|
|
88
|
+
|
|
89
|
+
expect( onChange ).toHaveBeenCalledWith(
|
|
90
|
+
expect.objectContaining( {
|
|
91
|
+
title: 'Pattern',
|
|
92
|
+
icon: symbol,
|
|
93
|
+
description: 'Pattern description.',
|
|
94
|
+
name: 'Hero pattern',
|
|
95
|
+
} )
|
|
96
|
+
);
|
|
97
|
+
} );
|
|
98
|
+
|
|
99
|
+
it( 'displays block information for a pattern section that is being edited', () => {
|
|
100
|
+
setupUseSelect( { isWithinEditedSection: true } );
|
|
101
|
+
const onChange = jest.fn();
|
|
102
|
+
|
|
103
|
+
render( <TestComponent onChange={ onChange } /> );
|
|
104
|
+
|
|
105
|
+
expect( onChange ).toHaveBeenCalledWith(
|
|
106
|
+
expect.objectContaining( {
|
|
107
|
+
title: 'Group',
|
|
108
|
+
icon: groupIcon,
|
|
109
|
+
description: 'Gather blocks in a layout container.',
|
|
110
|
+
name: 'Hero pattern',
|
|
111
|
+
} )
|
|
112
|
+
);
|
|
113
|
+
} );
|
|
114
|
+
|
|
115
|
+
it( 'displays block information for a pattern wrapper in an isolated editor', () => {
|
|
116
|
+
setupUseSelect( {
|
|
117
|
+
attributes: {
|
|
118
|
+
metadata: {
|
|
119
|
+
name: 'Header',
|
|
120
|
+
patternName: 'theme/header-wrapper',
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
settings: {
|
|
124
|
+
[ isIsolatedEditorKey ]: true,
|
|
125
|
+
},
|
|
126
|
+
} );
|
|
127
|
+
const onChange = jest.fn();
|
|
128
|
+
|
|
129
|
+
render( <TestComponent onChange={ onChange } /> );
|
|
130
|
+
|
|
131
|
+
expect( onChange ).toHaveBeenCalledWith(
|
|
132
|
+
expect.objectContaining( {
|
|
133
|
+
title: 'Group',
|
|
134
|
+
icon: groupIcon,
|
|
135
|
+
description: 'Gather blocks in a layout container.',
|
|
136
|
+
name: 'Header',
|
|
137
|
+
} )
|
|
138
|
+
);
|
|
139
|
+
} );
|
|
140
|
+
} );
|
package/src/hooks/anchor.js
CHANGED
package/src/hooks/background.js
CHANGED
|
@@ -8,14 +8,16 @@ import clsx from 'clsx';
|
|
|
8
8
|
*/
|
|
9
9
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
10
10
|
import { useSelect } from '@wordpress/data';
|
|
11
|
-
import {
|
|
11
|
+
import { __ } from '@wordpress/i18n';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
import InspectorControls from '../components/inspector-controls';
|
|
17
17
|
import { cleanEmptyObject } from './utils';
|
|
18
|
+
import { extractPresetSlug } from '../utils/color-values';
|
|
18
19
|
import { store as blockEditorStore } from '../store';
|
|
20
|
+
import useBlockColorContrastWarning from './contrast-checker';
|
|
19
21
|
import {
|
|
20
22
|
default as StylesBackgroundPanel,
|
|
21
23
|
useHasBackgroundPanel,
|
|
@@ -126,39 +128,41 @@ export function getBackgroundImageClasses( style ) {
|
|
|
126
128
|
: '';
|
|
127
129
|
}
|
|
128
130
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
);
|
|
131
|
+
// Clears every control the Background panel owns: the background image,
|
|
132
|
+
// background color, and the gradient. The Background panel owns the gradient
|
|
133
|
+
// control for both the newer `background.gradient` support and the legacy
|
|
134
|
+
// `color.gradient` path, so "Reset all" clears the legacy value too,
|
|
135
|
+
// regardless of which path stored it.
|
|
136
|
+
export function backgroundResetAllFilter( attributes ) {
|
|
137
|
+
const updatedClassName = attributes.className?.includes( 'has-background' )
|
|
138
|
+
? attributes.className
|
|
139
|
+
.split( ' ' )
|
|
140
|
+
.filter( ( c ) => c !== 'has-background' )
|
|
141
|
+
.join( ' ' ) || undefined
|
|
142
|
+
: attributes.className;
|
|
143
|
+
return {
|
|
144
|
+
...attributes,
|
|
145
|
+
className: updatedClassName,
|
|
146
|
+
backgroundColor: undefined,
|
|
147
|
+
gradient: undefined,
|
|
148
|
+
style: cleanEmptyObject( {
|
|
149
|
+
...attributes.style,
|
|
150
|
+
background: undefined,
|
|
151
|
+
color: {
|
|
152
|
+
...attributes.style?.color,
|
|
153
|
+
background: undefined,
|
|
154
|
+
gradient: undefined,
|
|
155
|
+
},
|
|
156
|
+
} ),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function BackgroundInspectorControl( { children } ) {
|
|
160
161
|
return (
|
|
161
|
-
<InspectorControls
|
|
162
|
+
<InspectorControls
|
|
163
|
+
group="background"
|
|
164
|
+
resetAllFilter={ backgroundResetAllFilter }
|
|
165
|
+
>
|
|
162
166
|
{ children }
|
|
163
167
|
</InspectorControls>
|
|
164
168
|
);
|
|
@@ -169,122 +173,179 @@ export function BackgroundImagePanel( {
|
|
|
169
173
|
name,
|
|
170
174
|
setAttributes,
|
|
171
175
|
settings,
|
|
176
|
+
// Allows rendering outside the `background` inspector group (e.g. section
|
|
177
|
+
// blocks direct-render this panel because their support fills are gated
|
|
178
|
+
// off by editing mode). Defaults to the slot-based wrapper.
|
|
179
|
+
asWrapper,
|
|
172
180
|
} ) {
|
|
173
181
|
const selectedState = useBlockStyleState();
|
|
174
|
-
const { style, className, inheritedValue } =
|
|
175
|
-
(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
};
|
|
193
|
-
},
|
|
194
|
-
[ clientId, name ]
|
|
195
|
-
);
|
|
182
|
+
const { style, className, backgroundColor, gradient, inheritedValue } =
|
|
183
|
+
useSelect(
|
|
184
|
+
( select ) => {
|
|
185
|
+
const { getBlockAttributes, getSettings } =
|
|
186
|
+
select( blockEditorStore );
|
|
187
|
+
const _settings = getSettings();
|
|
188
|
+
const blockAttributes = getBlockAttributes( clientId );
|
|
189
|
+
return {
|
|
190
|
+
style: blockAttributes?.style,
|
|
191
|
+
className: blockAttributes?.className,
|
|
192
|
+
backgroundColor: blockAttributes?.backgroundColor,
|
|
193
|
+
gradient: blockAttributes?.gradient,
|
|
194
|
+
inheritedValue:
|
|
195
|
+
_settings[ globalStylesDataKey ]?.blocks?.[ name ],
|
|
196
|
+
};
|
|
197
|
+
},
|
|
198
|
+
[ clientId, name ]
|
|
199
|
+
);
|
|
196
200
|
|
|
197
201
|
const backgroundGradientSupported = hasBackgroundSupport(
|
|
198
202
|
name,
|
|
199
203
|
'gradient'
|
|
200
204
|
);
|
|
201
205
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
206
|
+
const colorSupport = getBlockSupport( name, 'color' );
|
|
207
|
+
const hasColorBackgroundSupport =
|
|
208
|
+
colorSupport && colorSupport.background !== false;
|
|
209
|
+
const hasColorGradientSupport = !! colorSupport?.gradients;
|
|
210
|
+
|
|
211
|
+
const isStateSelected = ! isDefaultBlockStyleState( selectedState );
|
|
212
|
+
|
|
213
|
+
// Fold the backgroundColor / gradient attribute slugs back into the style
|
|
214
|
+
// object the panel consumes. When background.gradient is supported but not
|
|
215
|
+
// yet explicitly set, fall back to color.gradient for display.
|
|
216
|
+
const styleValue = {
|
|
217
|
+
...style,
|
|
218
|
+
color: {
|
|
219
|
+
...style?.color,
|
|
220
|
+
background: backgroundColor
|
|
221
|
+
? 'var:preset|color|' + backgroundColor
|
|
222
|
+
: style?.color?.background,
|
|
223
|
+
gradient:
|
|
224
|
+
! backgroundGradientSupported && gradient
|
|
225
|
+
? 'var:preset|gradient|' + gradient
|
|
226
|
+
: style?.color?.gradient,
|
|
227
|
+
},
|
|
228
|
+
...( backgroundGradientSupported && {
|
|
229
|
+
background: {
|
|
230
|
+
...style?.background,
|
|
231
|
+
gradient: gradient
|
|
232
|
+
? 'var:preset|gradient|' + gradient
|
|
233
|
+
: style?.background?.gradient ?? style?.color?.gradient,
|
|
234
|
+
},
|
|
235
|
+
} ),
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
// Skipped for gradients, which can't be reliably evaluated for contrast.
|
|
239
|
+
const enableContrastChecking =
|
|
240
|
+
! isStateSelected &&
|
|
241
|
+
! styleValue?.color?.gradient &&
|
|
242
|
+
! styleValue?.background?.gradient &&
|
|
243
|
+
!! styleValue?.color?.background &&
|
|
244
|
+
( settings?.color?.text || settings?.color?.link ) &&
|
|
245
|
+
false !== getBlockSupport( name, [ 'color', 'enableContrastChecker' ] );
|
|
246
|
+
|
|
247
|
+
const contrastWarning = useBlockColorContrastWarning( {
|
|
248
|
+
clientId,
|
|
249
|
+
name,
|
|
250
|
+
enabled: !! enableContrastChecking,
|
|
251
|
+
messageOverride: __(
|
|
252
|
+
'This color combination has poor contrast. Consider increasing contrast between background and foreground.'
|
|
212
253
|
),
|
|
213
|
-
|
|
214
|
-
);
|
|
254
|
+
} );
|
|
215
255
|
|
|
216
256
|
if (
|
|
217
257
|
! useHasBackgroundPanel( settings ) ||
|
|
218
|
-
! hasBackgroundSupport( name )
|
|
258
|
+
( ! hasBackgroundSupport( name ) &&
|
|
259
|
+
! hasColorBackgroundSupport &&
|
|
260
|
+
! hasColorGradientSupport )
|
|
219
261
|
) {
|
|
220
262
|
return null;
|
|
221
263
|
}
|
|
222
264
|
|
|
223
|
-
const
|
|
265
|
+
const onChange = ( newStyle ) => {
|
|
266
|
+
if ( isStateSelected ) {
|
|
267
|
+
setAttributes( {
|
|
268
|
+
style: setStyleForState( style, selectedState, newStyle ),
|
|
269
|
+
} );
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
224
272
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
: newStyle
|
|
245
|
-
),
|
|
246
|
-
};
|
|
273
|
+
// Extract background color slug from style.color.background.
|
|
274
|
+
const newBackgroundColorValue = newStyle?.color?.background;
|
|
275
|
+
const newBackgroundColorSlug = extractPresetSlug(
|
|
276
|
+
newBackgroundColorValue,
|
|
277
|
+
'color'
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
// Extract gradient slug — prefer the new background.gradient path
|
|
281
|
+
// when backgroundGradientSupported, fall back to color.gradient.
|
|
282
|
+
const newGradientValue = backgroundGradientSupported
|
|
283
|
+
? newStyle?.background?.gradient
|
|
284
|
+
: newStyle?.color?.gradient;
|
|
285
|
+
const newGradientSlug = extractPresetSlug(
|
|
286
|
+
newGradientValue,
|
|
287
|
+
'gradient'
|
|
288
|
+
);
|
|
289
|
+
const cleanedColorGradient = newGradientSlug
|
|
290
|
+
? undefined
|
|
291
|
+
: newStyle?.color?.gradient;
|
|
247
292
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
293
|
+
// Drop slug-resolved values so they aren't persisted inline alongside
|
|
294
|
+
// the attribute slugs.
|
|
295
|
+
const cleanedStyle = {
|
|
296
|
+
...newStyle,
|
|
297
|
+
color: {
|
|
298
|
+
...newStyle?.color,
|
|
299
|
+
background: newBackgroundColorSlug
|
|
300
|
+
? undefined
|
|
301
|
+
: newBackgroundColorValue,
|
|
302
|
+
gradient: backgroundGradientSupported
|
|
303
|
+
? undefined
|
|
304
|
+
: cleanedColorGradient,
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
if ( backgroundGradientSupported ) {
|
|
308
|
+
// Background gradients are kept whole in `style.background.gradient`
|
|
309
|
+
// rather than extracted to the legacy `gradient` attribute.
|
|
310
|
+
cleanedStyle.background = {
|
|
311
|
+
...cleanedStyle.background,
|
|
312
|
+
gradient: newStyle?.background?.gradient,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const isMigrating =
|
|
317
|
+
backgroundGradientSupported && !! style?.color?.gradient;
|
|
318
|
+
const newAttributes = {
|
|
319
|
+
style: cleanEmptyObject( cleanedStyle ),
|
|
320
|
+
backgroundColor: newBackgroundColorSlug,
|
|
321
|
+
// The legacy `gradient` attribute is only used when the block does
|
|
322
|
+
// not support `background.gradient`; otherwise the gradient is
|
|
323
|
+
// stored in `style.background.gradient` above.
|
|
324
|
+
gradient: backgroundGradientSupported ? undefined : newGradientSlug,
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
// When migrating from color.gradient to background.gradient, preserve
|
|
328
|
+
// the has-background class so existing styles relying on it (e.g.
|
|
329
|
+
// theme padding) are not silently broken. Only add the class when a
|
|
330
|
+
// gradient value is being set — not when it is being cleared/reset.
|
|
331
|
+
// Conversely, if the gradient is cleared and has-background was added
|
|
332
|
+
// during a previous migration, remove it so it does not linger.
|
|
333
|
+
const hasNewGradient = !! newGradientSlug || !! newGradientValue;
|
|
334
|
+
if ( isMigrating && hasNewGradient ) {
|
|
335
|
+
newAttributes.className = clsx( className, 'has-background' );
|
|
336
|
+
} else if (
|
|
337
|
+
! hasNewGradient &&
|
|
338
|
+
className?.includes( 'has-background' )
|
|
339
|
+
) {
|
|
340
|
+
newAttributes.className =
|
|
341
|
+
className
|
|
342
|
+
.split( ' ' )
|
|
343
|
+
.filter( ( c ) => c !== 'has-background' )
|
|
344
|
+
.join( ' ' ) || undefined;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
setAttributes( newAttributes );
|
|
348
|
+
};
|
|
288
349
|
|
|
289
350
|
const updatedSettings = {
|
|
290
351
|
...settings,
|
|
@@ -296,15 +357,30 @@ export function BackgroundImagePanel( {
|
|
|
296
357
|
},
|
|
297
358
|
};
|
|
298
359
|
|
|
299
|
-
const
|
|
360
|
+
const backgroundDefaultControls = getBlockSupport( name, [
|
|
300
361
|
BACKGROUND_SUPPORT_KEY,
|
|
301
362
|
'__experimentalDefaultControls',
|
|
302
363
|
] );
|
|
364
|
+
const colorDefaultControls = getBlockSupport( name, [
|
|
365
|
+
'color',
|
|
366
|
+
'__experimentalDefaultControls',
|
|
367
|
+
] );
|
|
368
|
+
const defaultControls = {
|
|
369
|
+
...backgroundDefaultControls,
|
|
370
|
+
backgroundColor: colorDefaultControls?.background,
|
|
371
|
+
// Mirror the old combined control: show the gradient item by default
|
|
372
|
+
// when background color was shown by default.
|
|
373
|
+
gradient:
|
|
374
|
+
backgroundDefaultControls?.gradient ??
|
|
375
|
+
colorDefaultControls?.background,
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
const Wrapper = asWrapper || BackgroundInspectorControl;
|
|
303
379
|
|
|
304
380
|
return (
|
|
305
381
|
<StylesBackgroundPanel
|
|
306
382
|
inheritedValue={ inheritedValue }
|
|
307
|
-
as={
|
|
383
|
+
as={ Wrapper }
|
|
308
384
|
panelId={ clientId }
|
|
309
385
|
defaultValues={ BACKGROUND_BLOCK_DEFAULT_VALUES }
|
|
310
386
|
settings={ updatedSettings }
|
|
@@ -315,6 +391,7 @@ export function BackgroundImagePanel( {
|
|
|
315
391
|
? getStyleForState( style, selectedState )
|
|
316
392
|
: styleValue
|
|
317
393
|
}
|
|
394
|
+
contrastWarning={ contrastWarning }
|
|
318
395
|
/>
|
|
319
396
|
);
|
|
320
397
|
}
|
|
@@ -1,39 +1,4 @@
|
|
|
1
1
|
@use "@wordpress/base-styles/variables" as *;
|
|
2
|
-
@use "@wordpress/base-styles/colors" as *;
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* ItemGroup-like border styles for the background panel's ToolsPanelItems.
|
|
6
|
-
* Replicates the separated border of the `ItemGroup` component while
|
|
7
|
-
* allowing for hidden placeholder items (same approach as the color panel).
|
|
8
|
-
*/
|
|
9
|
-
.block-editor-background-panel__item {
|
|
10
|
-
padding: 0;
|
|
11
|
-
max-width: 100%;
|
|
12
|
-
position: relative;
|
|
13
|
-
|
|
14
|
-
// Border styles.
|
|
15
|
-
border-left: 1px solid $gray-300;
|
|
16
|
-
border-right: 1px solid $gray-300;
|
|
17
|
-
border-bottom: 1px solid $gray-300;
|
|
18
|
-
|
|
19
|
-
// Identify the first visible instance as placeholder items will not have this class.
|
|
20
|
-
&:nth-child(1 of &) {
|
|
21
|
-
border-top-left-radius: $radius-small;
|
|
22
|
-
border-top-right-radius: $radius-small;
|
|
23
|
-
border-top: 1px solid $gray-300;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Identify the last visible instance as placeholder items will not have this class.
|
|
27
|
-
&:nth-last-child(1 of &) {
|
|
28
|
-
border-bottom-left-radius: $radius-small;
|
|
29
|
-
border-bottom-right-radius: $radius-small;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
> div,
|
|
33
|
-
> div > button {
|
|
34
|
-
border-radius: inherit;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
2
|
|
|
38
3
|
.background-block-support-panel {
|
|
39
4
|
/* Increased specificity required to remove the slot wrapper's row gap */
|
|
@@ -14,6 +14,7 @@ import { useContext, useState, useMemo } from '@wordpress/element';
|
|
|
14
14
|
import { __ } from '@wordpress/i18n';
|
|
15
15
|
import { store as blockEditorStore } from '../../store';
|
|
16
16
|
import { unlock } from '../../lock-unlock';
|
|
17
|
+
import { replacePatternOverridesDefaultBinding } from '../../utils/block-bindings';
|
|
17
18
|
import BlockContext from '../../components/block-context';
|
|
18
19
|
import BlockIcon from '../../components/block-icon';
|
|
19
20
|
import useBlockDisplayTitle from '../../components/block-title/use-block-display-title';
|
|
@@ -80,15 +81,39 @@ function BlockFields( {
|
|
|
80
81
|
return _attributes;
|
|
81
82
|
}
|
|
82
83
|
|
|
84
|
+
/*
|
|
85
|
+
* The pattern overrides `__default` binding is a placeholder, not
|
|
86
|
+
* a real attribute: expand it to the block's bindable attributes
|
|
87
|
+
* before resolving values, as other bindings consumers do.
|
|
88
|
+
*/
|
|
89
|
+
const { __experimentalBlockBindingsSupportedAttributes } =
|
|
90
|
+
select( blockEditorStore ).getSettings();
|
|
91
|
+
const bindableAttributes =
|
|
92
|
+
__experimentalBlockBindingsSupportedAttributes?.[
|
|
93
|
+
blockType?.name
|
|
94
|
+
];
|
|
95
|
+
const bindings = bindableAttributes
|
|
96
|
+
? replacePatternOverridesDefaultBinding(
|
|
97
|
+
_attributes.metadata.bindings,
|
|
98
|
+
bindableAttributes
|
|
99
|
+
)
|
|
100
|
+
: _attributes.metadata.bindings;
|
|
101
|
+
|
|
83
102
|
const { getBlockBindingsSource } = unlock( select( blocksStore ) );
|
|
84
|
-
return Object.entries(
|
|
103
|
+
return Object.entries( bindings ).reduce(
|
|
85
104
|
( acc, [ attribute, binding ] ) => {
|
|
105
|
+
// Skip a `__default` binding that could not be expanded:
|
|
106
|
+
// it is not a real block attribute.
|
|
107
|
+
if ( attribute === '__default' ) {
|
|
108
|
+
return acc;
|
|
109
|
+
}
|
|
86
110
|
const source = getBlockBindingsSource( binding.source );
|
|
87
111
|
if ( ! source ) {
|
|
88
112
|
return acc;
|
|
89
113
|
}
|
|
90
114
|
const values = source.getValues( {
|
|
91
115
|
select,
|
|
116
|
+
clientId,
|
|
92
117
|
context: blockContext,
|
|
93
118
|
bindings: { [ attribute ]: binding },
|
|
94
119
|
} );
|
|
@@ -97,7 +122,7 @@ function BlockFields( {
|
|
|
97
122
|
_attributes
|
|
98
123
|
);
|
|
99
124
|
},
|
|
100
|
-
[ blockContext, clientId ]
|
|
125
|
+
[ blockContext, clientId, blockType?.name ]
|
|
101
126
|
);
|
|
102
127
|
const { selectBlock, toggleBlockHighlight } =
|
|
103
128
|
useDispatch( blockEditorStore );
|