@wordpress/block-editor 15.21.1 → 15.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +2 -2
- package/build/components/block-card/index.cjs +4 -5
- package/build/components/block-card/index.cjs.map +2 -2
- package/build/components/block-editing-mode/index.cjs +13 -7
- package/build/components/block-editing-mode/index.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +35 -20
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-mover/mover-description.cjs +6 -6
- package/build/components/block-mover/mover-description.cjs.map +1 -1
- package/build/components/block-patterns-list/index.cjs.map +2 -2
- package/build/components/block-patterns-paging/index.cjs +4 -4
- package/build/components/block-patterns-paging/index.cjs.map +2 -2
- package/build/components/block-popover/use-popover-scroll.cjs.map +1 -1
- package/build/components/block-quick-navigation/index.cjs +7 -5
- package/build/components/block-quick-navigation/index.cjs.map +2 -2
- package/build/components/block-rename/modal.cjs +0 -1
- package/build/components/block-rename/modal.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +14 -6
- package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
- package/build/components/block-toolbar/edit-section-button.cjs.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.cjs +10 -4
- package/build/components/block-tools/use-block-toolbar-popover-props.cjs.map +2 -2
- package/build/components/child-layout-control/index.cjs +51 -19
- package/build/components/child-layout-control/index.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +25 -14
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/colors-gradients/dropdown.cjs +4 -1
- package/build/components/colors-gradients/dropdown.cjs.map +3 -3
- package/build/components/contrast-checker/index.cjs +22 -4
- package/build/components/contrast-checker/index.cjs.map +2 -2
- package/build/components/date-format-picker/index.cjs +0 -1
- package/build/components/date-format-picker/index.cjs.map +2 -2
- package/build/components/dimensions-tool/index.cjs +4 -5
- package/build/components/dimensions-tool/index.cjs.map +2 -2
- package/build/components/dimensions-tool/scale-tool.cjs +1 -1
- package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +153 -25
- package/build/components/global-styles/background-panel.cjs.map +3 -3
- package/build/components/global-styles/color-gradient-dropdown-item.cjs +227 -0
- package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +7 -0
- package/build/components/global-styles/color-panel.cjs +98 -375
- package/build/components/global-styles/color-panel.cjs.map +3 -3
- package/build/components/global-styles/dimensions-panel.cjs +1 -4
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/hooks.cjs +34 -0
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +82 -10
- package/build/components/global-styles/typography-panel.cjs.map +3 -3
- package/build/components/grid/grid-item-resizer.cjs.map +1 -1
- package/build/components/grid/grid-visualizer.cjs.map +1 -1
- package/build/components/iframe/index.cjs +6 -3
- package/build/components/iframe/index.cjs.map +3 -3
- package/build/components/image-editor/use-transform-image.cjs.map +1 -1
- package/build/components/inserter/get-appender-label.cjs.map +1 -1
- package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
- package/build/components/inserter/search-items.cjs.map +1 -1
- package/build/components/inspector-controls/fill.cjs +1 -3
- package/build/components/inspector-controls/fill.cjs.map +2 -2
- package/build/components/inspector-controls/groups.cjs +2 -0
- package/build/components/inspector-controls/groups.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/index.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.cjs +76 -32
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/keyboard-shortcuts/index.cjs.map +1 -1
- package/build/components/line-height-control/index.cjs.map +1 -1
- package/build/components/link-control/index.cjs +2 -3
- package/build/components/link-control/index.cjs.map +2 -2
- package/build/components/link-control/normalize-url.cjs.map +1 -1
- package/build/components/list-view/block-select-button.cjs +1 -10
- package/build/components/list-view/block-select-button.cjs.map +3 -3
- package/build/components/list-view/utils.cjs.map +1 -1
- package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
- package/build/components/provider/index.cjs.map +1 -1
- package/build/components/provider/use-block-sync.cjs +3 -1
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/before-input-rules.cjs +1 -1
- package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/paste-handler.cjs.map +1 -1
- package/build/components/rich-text/prevent-event-discovery.cjs +1 -1
- package/build/components/rich-text/prevent-event-discovery.cjs.map +1 -1
- package/build/components/url-popover/image-url-input-ui.cjs +0 -2
- package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
- package/build/components/use-block-display-information/index.cjs +10 -3
- package/build/components/use-block-display-information/index.cjs.map +2 -2
- package/build/components/writing-flow/use-tab-nav.cjs.map +1 -1
- package/build/hooks/anchor.cjs +1 -2
- package/build/hooks/anchor.cjs.map +2 -2
- package/build/hooks/background.cjs +124 -75
- package/build/hooks/background.cjs.map +3 -3
- package/build/hooks/block-fields/index.cjs +13 -2
- package/build/hooks/block-fields/index.cjs.map +2 -2
- package/build/hooks/color.cjs +0 -162
- package/build/hooks/color.cjs.map +3 -3
- package/build/hooks/contrast-checker.cjs +31 -28
- package/build/hooks/contrast-checker.cjs.map +3 -3
- package/build/hooks/custom-class-name.cjs +0 -1
- package/build/hooks/custom-class-name.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +13 -2
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/elements.cjs +142 -0
- package/build/hooks/elements.cjs.map +7 -0
- package/build/hooks/grid-visualizer.cjs +21 -11
- package/build/hooks/grid-visualizer.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +65 -10
- package/build/hooks/layout-child.cjs.map +2 -2
- package/build/hooks/layout.cjs +6 -3
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/list-view.cjs +10 -7
- package/build/hooks/list-view.cjs.map +2 -2
- package/build/hooks/spacing-visualizer.cjs.map +1 -1
- package/build/hooks/state-utils.cjs.map +1 -1
- package/build/hooks/states.cjs +2 -2
- package/build/hooks/states.cjs.map +2 -2
- package/build/hooks/style.cjs +50 -6
- package/build/hooks/style.cjs.map +2 -2
- package/build/hooks/typography.cjs +62 -10
- package/build/hooks/typography.cjs.map +3 -3
- package/build/layouts/flex.cjs +99 -6
- package/build/layouts/flex.cjs.map +2 -2
- package/build/private-apis.cjs +4 -0
- package/build/private-apis.cjs.map +2 -2
- package/build/store/actions.cjs.map +1 -1
- package/build/store/private-selectors.cjs +19 -2
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs.map +1 -1
- package/build/store/selectors.cjs.map +1 -1
- package/build/utils/block-bindings.cjs +9 -9
- package/build/utils/block-bindings.cjs.map +3 -3
- package/build/utils/color-values.cjs +10 -1
- package/build/utils/color-values.cjs.map +3 -3
- package/build/utils/dom.cjs +2 -5
- package/build/utils/dom.cjs.map +3 -3
- package/build/utils/fit-text-frontend.cjs +6 -2
- package/build/utils/fit-text-frontend.cjs.map +3 -3
- package/build/utils/fit-text-utils.cjs +1 -1
- package/build/utils/fit-text-utils.cjs.map +3 -3
- package/build/utils/format-font-style.cjs +1 -1
- package/build/utils/format-font-style.cjs.map +3 -3
- package/build/utils/format-font-weight.cjs +1 -1
- package/build/utils/format-font-weight.cjs.map +3 -3
- package/build/utils/get-editor-region.cjs +4 -2
- package/build/utils/get-editor-region.cjs.map +3 -3
- package/build/utils/get-font-styles-and-weights.cjs +8 -12
- package/build/utils/get-font-styles-and-weights.cjs.map +3 -3
- package/build/utils/get-px-from-css-unit.cjs +1 -1
- package/build/utils/get-px-from-css-unit.cjs.map +1 -1
- package/build/utils/index.cjs +1 -1
- package/build/utils/index.cjs.map +1 -1
- package/build/utils/math.cjs +1 -1
- package/build/utils/math.cjs.map +3 -3
- package/build/utils/object.cjs +8 -8
- package/build/utils/object.cjs.map +3 -3
- package/build/utils/order-inserter-block-items.cjs +1 -1
- package/build/utils/order-inserter-block-items.cjs.map +3 -3
- package/build/utils/pasting.cjs +4 -2
- package/build/utils/pasting.cjs.map +3 -3
- package/build/utils/selection.cjs +3 -2
- package/build/utils/selection.cjs.map +3 -3
- package/build/utils/sorting.cjs +9 -3
- package/build/utils/sorting.cjs.map +3 -3
- package/build/utils/transform-styles/index.cjs +3 -2
- package/build/utils/transform-styles/index.cjs.map +3 -3
- package/build/utils/transform-styles/postcss-urlrebase.d.cjs +2 -0
- package/build/utils/transform-styles/postcss-urlrebase.d.cjs.map +7 -0
- package/build/utils/transform-styles/types.cjs +19 -0
- package/build/utils/transform-styles/types.cjs.map +7 -0
- package/build/utils/types.cjs +19 -0
- package/build/utils/types.cjs.map +7 -0
- package/build-module/components/block-card/index.mjs +5 -6
- package/build-module/components/block-card/index.mjs.map +2 -2
- package/build-module/components/block-editing-mode/index.mjs +14 -8
- package/build-module/components/block-editing-mode/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +35 -21
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-mover/mover-description.mjs +6 -6
- package/build-module/components/block-mover/mover-description.mjs.map +1 -1
- package/build-module/components/block-patterns-list/index.mjs.map +2 -2
- package/build-module/components/block-patterns-paging/index.mjs +4 -4
- package/build-module/components/block-patterns-paging/index.mjs.map +2 -2
- package/build-module/components/block-popover/use-popover-scroll.mjs.map +1 -1
- package/build-module/components/block-quick-navigation/index.mjs +8 -6
- package/build-module/components/block-quick-navigation/index.mjs.map +2 -2
- package/build-module/components/block-rename/modal.mjs +0 -1
- package/build-module/components/block-rename/modal.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +14 -6
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
- package/build-module/components/block-toolbar/edit-section-button.mjs.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs +10 -4
- package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs.map +2 -2
- package/build-module/components/child-layout-control/index.mjs +51 -19
- package/build-module/components/child-layout-control/index.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +27 -15
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/colors-gradients/dropdown.mjs +4 -1
- package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
- package/build-module/components/contrast-checker/index.mjs +18 -4
- package/build-module/components/contrast-checker/index.mjs.map +2 -2
- package/build-module/components/date-format-picker/index.mjs +0 -1
- package/build-module/components/date-format-picker/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/index.mjs +4 -5
- package/build-module/components/dimensions-tool/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/scale-tool.mjs +1 -1
- package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +155 -27
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +207 -0
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +7 -0
- package/build-module/components/global-styles/color-panel.mjs +106 -387
- package/build-module/components/global-styles/color-panel.mjs.map +3 -3
- package/build-module/components/global-styles/dimensions-panel.mjs +1 -5
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +33 -0
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +84 -10
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/grid/grid-item-resizer.mjs.map +1 -1
- package/build-module/components/grid/grid-visualizer.mjs.map +1 -1
- package/build-module/components/iframe/index.mjs +6 -3
- package/build-module/components/iframe/index.mjs.map +2 -2
- package/build-module/components/image-editor/use-transform-image.mjs.map +1 -1
- package/build-module/components/inserter/get-appender-label.mjs.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
- package/build-module/components/inserter/search-items.mjs.map +1 -1
- package/build-module/components/inspector-controls/fill.mjs +1 -3
- package/build-module/components/inspector-controls/fill.mjs.map +2 -2
- package/build-module/components/inspector-controls/groups.mjs +2 -0
- package/build-module/components/inspector-controls/groups.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +76 -32
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -1
- package/build-module/components/line-height-control/index.mjs.map +1 -1
- package/build-module/components/link-control/index.mjs +2 -3
- package/build-module/components/link-control/index.mjs.map +2 -2
- package/build-module/components/link-control/normalize-url.mjs.map +1 -1
- package/build-module/components/list-view/block-select-button.mjs +2 -17
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/utils.mjs.map +1 -1
- package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
- package/build-module/components/provider/index.mjs.map +1 -1
- package/build-module/components/provider/use-block-sync.mjs +3 -1
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +1 -1
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +1 -1
- package/build-module/components/rich-text/prevent-event-discovery.mjs +1 -1
- package/build-module/components/rich-text/prevent-event-discovery.mjs.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.mjs +0 -2
- package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
- package/build-module/components/use-block-display-information/index.mjs +10 -3
- package/build-module/components/use-block-display-information/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-tab-nav.mjs.map +1 -1
- package/build-module/hooks/anchor.mjs +1 -2
- package/build-module/hooks/anchor.mjs.map +2 -2
- package/build-module/hooks/background.mjs +123 -75
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/block-fields/index.mjs +13 -2
- package/build-module/hooks/block-fields/index.mjs.map +2 -2
- package/build-module/hooks/color.mjs +2 -175
- package/build-module/hooks/color.mjs.map +2 -2
- package/build-module/hooks/contrast-checker.mjs +32 -19
- package/build-module/hooks/contrast-checker.mjs.map +2 -2
- package/build-module/hooks/custom-class-name.mjs +0 -1
- package/build-module/hooks/custom-class-name.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +12 -2
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/elements.mjs +115 -0
- package/build-module/hooks/elements.mjs.map +7 -0
- package/build-module/hooks/grid-visualizer.mjs +21 -11
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +68 -10
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +6 -3
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/list-view.mjs +10 -7
- package/build-module/hooks/list-view.mjs.map +2 -2
- package/build-module/hooks/spacing-visualizer.mjs.map +1 -1
- package/build-module/hooks/state-utils.mjs.map +1 -1
- package/build-module/hooks/states.mjs +2 -2
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/hooks/style.mjs +53 -8
- package/build-module/hooks/style.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +62 -10
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +105 -7
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/private-apis.mjs +8 -0
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs.map +1 -1
- package/build-module/store/private-selectors.mjs +18 -1
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs.map +1 -1
- package/build-module/store/selectors.mjs.map +1 -1
- package/build-module/utils/block-bindings.mjs +9 -9
- package/build-module/utils/block-bindings.mjs.map +3 -3
- package/build-module/utils/color-values.mjs +9 -1
- package/build-module/utils/color-values.mjs.map +3 -3
- package/build-module/utils/dom.mjs +2 -5
- package/build-module/utils/dom.mjs.map +3 -3
- package/build-module/utils/fit-text-frontend.mjs +6 -2
- package/build-module/utils/fit-text-frontend.mjs.map +3 -3
- package/build-module/utils/fit-text-utils.mjs +1 -1
- package/build-module/utils/fit-text-utils.mjs.map +3 -3
- package/build-module/utils/format-font-style.mjs +1 -1
- package/build-module/utils/format-font-style.mjs.map +3 -3
- package/build-module/utils/format-font-weight.mjs +1 -1
- package/build-module/utils/format-font-weight.mjs.map +3 -3
- package/build-module/utils/get-editor-region.mjs +4 -2
- package/build-module/utils/get-editor-region.mjs.map +3 -3
- package/build-module/utils/get-font-styles-and-weights.mjs +8 -12
- package/build-module/utils/get-font-styles-and-weights.mjs.map +3 -3
- package/build-module/utils/get-px-from-css-unit.mjs +1 -1
- package/build-module/utils/get-px-from-css-unit.mjs.map +1 -1
- package/build-module/utils/index.mjs +1 -1
- package/build-module/utils/index.mjs.map +1 -1
- package/build-module/utils/math.mjs +1 -1
- package/build-module/utils/math.mjs.map +3 -3
- package/build-module/utils/object.mjs +8 -8
- package/build-module/utils/object.mjs.map +3 -3
- package/build-module/utils/order-inserter-block-items.mjs +1 -1
- package/build-module/utils/order-inserter-block-items.mjs.map +3 -3
- package/build-module/utils/pasting.mjs +4 -2
- package/build-module/utils/pasting.mjs.map +3 -3
- package/build-module/utils/selection.mjs +3 -2
- package/build-module/utils/selection.mjs.map +3 -3
- package/build-module/utils/sorting.mjs +9 -3
- package/build-module/utils/sorting.mjs.map +3 -3
- package/build-module/utils/transform-styles/index.mjs +3 -2
- package/build-module/utils/transform-styles/index.mjs.map +3 -3
- package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs +1 -0
- package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs.map +7 -0
- package/build-module/utils/transform-styles/types.mjs +1 -0
- package/build-module/utils/transform-styles/types.mjs.map +7 -0
- package/build-module/utils/types.mjs +1 -0
- package/build-module/utils/types.mjs.map +7 -0
- package/build-style/content-rtl.css +2 -0
- package/build-style/content.css +2 -0
- package/build-style/style-rtl.css +34 -41
- package/build-style/style.css +34 -41
- package/build-types/utils/block-bindings.d.ts +27 -0
- package/build-types/utils/block-bindings.d.ts.map +1 -0
- package/build-types/utils/color-values.d.ts +40 -0
- package/build-types/utils/color-values.d.ts.map +1 -0
- package/build-types/utils/dom.d.ts +19 -19
- package/build-types/utils/dom.d.ts.map +1 -1
- package/build-types/utils/fit-text-frontend.d.ts +7 -0
- package/build-types/utils/fit-text-frontend.d.ts.map +1 -0
- package/build-types/utils/fit-text-utils.d.ts +15 -0
- package/build-types/utils/fit-text-utils.d.ts.map +1 -0
- package/build-types/utils/format-font-style.d.ts +12 -0
- package/build-types/utils/format-font-style.d.ts.map +1 -0
- package/build-types/utils/format-font-weight.d.ts +12 -0
- package/build-types/utils/format-font-weight.d.ts.map +1 -0
- package/build-types/utils/get-editor-region.d.ts +9 -0
- package/build-types/utils/get-editor-region.d.ts.map +1 -0
- package/build-types/utils/get-font-styles-and-weights.d.ts +16 -0
- package/build-types/utils/get-font-styles-and-weights.d.ts.map +1 -0
- package/build-types/utils/get-px-from-css-unit.d.ts +10 -0
- package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -0
- package/build-types/utils/index.d.ts +3 -0
- package/build-types/utils/index.d.ts.map +1 -0
- package/build-types/utils/math.d.ts +61 -0
- package/build-types/utils/math.d.ts.map +1 -0
- package/build-types/utils/object.d.ts +39 -0
- package/build-types/utils/object.d.ts.map +1 -0
- package/build-types/utils/order-inserter-block-items.d.ts +13 -0
- package/build-types/utils/order-inserter-block-items.d.ts.map +1 -0
- package/build-types/utils/pasting.d.ts +28 -0
- package/build-types/utils/pasting.d.ts.map +1 -0
- package/build-types/utils/selection.d.ts +21 -0
- package/build-types/utils/selection.d.ts.map +1 -0
- package/build-types/utils/sorting.d.ts +17 -0
- package/build-types/utils/sorting.d.ts.map +1 -0
- package/build-types/utils/transform-styles/index.d.ts +15 -0
- package/build-types/utils/transform-styles/index.d.ts.map +1 -0
- package/build-types/utils/transform-styles/types.d.ts +13 -0
- package/build-types/utils/transform-styles/types.d.ts.map +1 -0
- package/build-types/utils/types.d.ts +28 -0
- package/build-types/utils/types.d.ts.map +1 -0
- package/package.json +46 -40
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -0
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -0
- package/src/components/block-card/index.js +7 -13
- package/src/components/block-editing-mode/index.js +17 -9
- package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -0
- package/src/components/block-inspector/index.js +22 -20
- package/src/components/block-patterns-list/index.js +0 -1
- package/src/components/block-quick-navigation/index.js +7 -7
- package/src/components/block-rename/modal.js +0 -1
- package/src/components/block-toolbar/block-toolbar-icon.js +22 -6
- package/src/components/block-toolbar/test/block-toolbar-icon.js +99 -0
- package/src/components/block-tools/use-block-toolbar-popover-props.js +10 -4
- package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +4 -0
- package/src/components/child-layout-control/index.js +65 -20
- package/src/components/child-layout-control/test/index.js +64 -0
- package/src/components/colors-gradients/control.js +29 -12
- package/src/components/colors-gradients/dropdown.js +4 -1
- package/src/components/colors-gradients/style.scss +39 -2
- package/src/components/contrast-checker/README.md +9 -0
- package/src/components/contrast-checker/index.js +42 -3
- package/src/components/date-format-picker/index.js +0 -1
- package/src/components/default-block-appender/content.scss +3 -0
- package/src/components/dimensions-tool/index.js +4 -9
- package/src/components/dimensions-tool/scale-tool.js +1 -2
- package/src/components/dimensions-tool/test/index.js +89 -11
- package/src/components/global-styles/background-panel.js +201 -34
- package/src/components/global-styles/color-gradient-dropdown-item.js +258 -0
- package/src/components/global-styles/color-panel.js +125 -487
- package/src/components/global-styles/dimensions-panel.js +1 -5
- package/src/components/global-styles/hooks.js +45 -0
- package/src/components/global-styles/shadow-panel-components.js +0 -1
- package/src/components/global-styles/test/background-panel.js +56 -0
- package/src/components/global-styles/test/color-panel.js +172 -118
- package/src/components/global-styles/test/typography-panel.js +167 -0
- package/src/components/global-styles/typography-panel.js +100 -11
- package/src/components/iframe/index.js +8 -3
- package/src/components/inserter/media-tab/media-preview.js +0 -1
- package/src/components/inspector-controls/README.md +0 -2
- package/src/components/inspector-controls/fill.js +6 -8
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/index.js +0 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +78 -28
- package/src/components/link-control/index.js +0 -1
- package/src/components/link-control/test/index.js +2 -3
- package/src/components/list-view/block-select-button.js +2 -18
- package/src/components/preset-input-control/custom-value-controls.js +0 -1
- package/src/components/provider/use-block-sync.js +3 -1
- package/src/components/rich-text/content.scss +2 -0
- package/src/components/url-popover/image-url-input-ui.js +0 -2
- package/src/components/use-block-display-information/index.js +15 -2
- package/src/components/use-block-display-information/test/index.js +140 -0
- package/src/hooks/anchor.js +0 -1
- package/src/hooks/background.js +210 -133
- package/src/hooks/background.scss +0 -35
- package/src/hooks/block-fields/index.js +27 -2
- package/src/hooks/color.js +2 -205
- package/src/hooks/color.scss +3 -9
- package/src/hooks/contrast-checker.js +60 -17
- package/src/hooks/custom-class-name.js +0 -1
- package/src/hooks/dimensions.js +14 -3
- package/src/hooks/elements.js +140 -0
- package/src/hooks/elements.scss +8 -0
- package/src/hooks/grid-visualizer.js +59 -45
- package/src/hooks/layout-child.js +92 -14
- package/src/hooks/layout.js +6 -3
- package/src/hooks/list-view.js +10 -11
- package/src/hooks/states.js +2 -2
- package/src/hooks/style.js +91 -9
- package/src/hooks/test/background.js +59 -0
- package/src/hooks/test/block-style-state.js +14 -14
- package/src/hooks/test/dimensions.js +71 -0
- package/src/hooks/test/layout-child.js +165 -0
- package/src/hooks/test/layout.js +6 -6
- package/src/hooks/test/style.js +133 -11
- package/src/hooks/typography.js +70 -6
- package/src/layouts/flex.js +118 -15
- package/src/private-apis.js +8 -0
- package/src/store/private-selectors.js +47 -0
- package/src/store/test/private-selectors.js +166 -7
- package/src/store/test/reducer.js +61 -10
- package/src/style.scss +1 -0
- package/src/utils/block-bindings.ts +51 -0
- package/src/utils/color-values.ts +63 -0
- package/src/utils/{dom.js → dom.ts} +27 -27
- package/src/utils/{fit-text-frontend.js → fit-text-frontend.ts} +12 -4
- package/src/utils/{fit-text-utils.js → fit-text-utils.ts} +15 -7
- package/src/utils/{format-font-style.js → format-font-style.ts} +10 -3
- package/src/utils/{format-font-weight.js → format-font-weight.ts} +10 -3
- package/src/utils/{get-editor-region.js → get-editor-region.ts} +10 -6
- package/src/utils/{get-font-styles-and-weights.js → get-font-styles-and-weights.ts} +21 -17
- package/src/utils/{math.js → math.ts} +37 -30
- package/src/utils/object.ts +89 -0
- package/src/utils/{order-inserter-block-items.js → order-inserter-block-items.ts} +8 -5
- package/src/utils/{pasting.js → pasting.ts} +18 -11
- package/src/utils/{selection.js → selection.ts} +11 -4
- package/src/utils/sorting.ts +81 -0
- package/src/utils/test/color-values.js +44 -1
- package/src/utils/transform-styles/{index.js → index.ts} +25 -25
- package/src/utils/transform-styles/postcss-urlrebase.d.ts +15 -0
- package/src/utils/transform-styles/types.ts +13 -0
- package/src/utils/types.ts +29 -0
- package/src/utils/block-bindings.js +0 -46
- package/src/utils/color-values.js +0 -28
- package/src/utils/object.js +0 -67
- package/src/utils/sorting.js +0 -54
- /package/src/utils/{get-px-from-css-unit.js → get-px-from-css-unit.ts} +0 -0
- /package/src/utils/{index.js → index.ts} +0 -0
package/src/hooks/color.js
CHANGED
|
@@ -8,8 +8,7 @@ import clsx from 'clsx';
|
|
|
8
8
|
*/
|
|
9
9
|
import { addFilter } from '@wordpress/hooks';
|
|
10
10
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
11
|
-
import { useMemo
|
|
12
|
-
import { useSelect } from '@wordpress/data';
|
|
11
|
+
import { useMemo } from '@wordpress/element';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Internal dependencies
|
|
@@ -19,27 +18,9 @@ import {
|
|
|
19
18
|
getColorObjectByAttributeValues,
|
|
20
19
|
} from '../components/colors';
|
|
21
20
|
import { __experimentalGetGradientClass } from '../components/gradients';
|
|
22
|
-
import {
|
|
23
|
-
cleanEmptyObject,
|
|
24
|
-
transformStyles,
|
|
25
|
-
shouldSkipSerialization,
|
|
26
|
-
} from './utils';
|
|
21
|
+
import { transformStyles, shouldSkipSerialization } from './utils';
|
|
27
22
|
import { getBackgroundImageClasses } from './background';
|
|
28
23
|
import { useSettings } from '../components/use-settings';
|
|
29
|
-
import InspectorControls from '../components/inspector-controls';
|
|
30
|
-
import {
|
|
31
|
-
useHasColorPanel,
|
|
32
|
-
default as StylesColorPanel,
|
|
33
|
-
} from '../components/global-styles/color-panel';
|
|
34
|
-
import { extractPresetSlug } from '../utils/color-values';
|
|
35
|
-
import BlockColorContrastChecker from './contrast-checker';
|
|
36
|
-
import { store as blockEditorStore } from '../store';
|
|
37
|
-
import {
|
|
38
|
-
getStyleForState,
|
|
39
|
-
isDefaultBlockStyleState,
|
|
40
|
-
setStyleForState,
|
|
41
|
-
useBlockStyleState,
|
|
42
|
-
} from './block-style-state';
|
|
43
24
|
|
|
44
25
|
export const COLOR_SUPPORT_KEY = 'color';
|
|
45
26
|
|
|
@@ -192,190 +173,6 @@ export function addSaveProps( props, blockNameOrType, attributes ) {
|
|
|
192
173
|
return props;
|
|
193
174
|
}
|
|
194
175
|
|
|
195
|
-
function styleToAttributes( style ) {
|
|
196
|
-
const textColorValue = style?.color?.text;
|
|
197
|
-
const textColorSlug = extractPresetSlug( textColorValue, 'color' );
|
|
198
|
-
const backgroundColorValue = style?.color?.background;
|
|
199
|
-
const backgroundColorSlug = extractPresetSlug(
|
|
200
|
-
backgroundColorValue,
|
|
201
|
-
'color'
|
|
202
|
-
);
|
|
203
|
-
const gradientValue = style?.color?.gradient;
|
|
204
|
-
const gradientSlug = extractPresetSlug( gradientValue, 'gradient' );
|
|
205
|
-
const updatedStyle = { ...style };
|
|
206
|
-
updatedStyle.color = {
|
|
207
|
-
...updatedStyle.color,
|
|
208
|
-
text: textColorSlug ? undefined : textColorValue,
|
|
209
|
-
background: backgroundColorSlug ? undefined : backgroundColorValue,
|
|
210
|
-
gradient: gradientSlug ? undefined : gradientValue,
|
|
211
|
-
};
|
|
212
|
-
return {
|
|
213
|
-
style: cleanEmptyObject( updatedStyle ),
|
|
214
|
-
textColor: textColorSlug,
|
|
215
|
-
backgroundColor: backgroundColorSlug,
|
|
216
|
-
gradient: gradientSlug,
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function attributesToStyle( attributes ) {
|
|
221
|
-
return {
|
|
222
|
-
...attributes.style,
|
|
223
|
-
color: {
|
|
224
|
-
...attributes.style?.color,
|
|
225
|
-
text: attributes.textColor
|
|
226
|
-
? 'var:preset|color|' + attributes.textColor
|
|
227
|
-
: attributes.style?.color?.text,
|
|
228
|
-
background: attributes.backgroundColor
|
|
229
|
-
? 'var:preset|color|' + attributes.backgroundColor
|
|
230
|
-
: attributes.style?.color?.background,
|
|
231
|
-
gradient: attributes.gradient
|
|
232
|
-
? 'var:preset|gradient|' + attributes.gradient
|
|
233
|
-
: attributes.style?.color?.gradient,
|
|
234
|
-
},
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function ColorInspectorControl( { children, resetAllFilter } ) {
|
|
239
|
-
const attributesResetAllFilter = useCallback(
|
|
240
|
-
( attributes ) => {
|
|
241
|
-
const existingStyle = attributesToStyle( attributes );
|
|
242
|
-
const updatedStyle = resetAllFilter( existingStyle );
|
|
243
|
-
return {
|
|
244
|
-
...attributes,
|
|
245
|
-
...styleToAttributes( updatedStyle ),
|
|
246
|
-
};
|
|
247
|
-
},
|
|
248
|
-
[ resetAllFilter ]
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
return (
|
|
252
|
-
<InspectorControls
|
|
253
|
-
group="color"
|
|
254
|
-
resetAllFilter={ attributesResetAllFilter }
|
|
255
|
-
>
|
|
256
|
-
{ children }
|
|
257
|
-
</InspectorControls>
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export function ColorEdit( {
|
|
262
|
-
clientId,
|
|
263
|
-
name,
|
|
264
|
-
setAttributes,
|
|
265
|
-
settings,
|
|
266
|
-
asWrapper,
|
|
267
|
-
label,
|
|
268
|
-
defaultControls,
|
|
269
|
-
} ) {
|
|
270
|
-
const selectedState = useBlockStyleState();
|
|
271
|
-
const isEnabled = useHasColorPanel( settings );
|
|
272
|
-
|
|
273
|
-
const { style, textColor, backgroundColor, gradient } = useSelect(
|
|
274
|
-
( select ) => {
|
|
275
|
-
// Early return to avoid subscription when disabled
|
|
276
|
-
if ( ! isEnabled ) {
|
|
277
|
-
return {};
|
|
278
|
-
}
|
|
279
|
-
const {
|
|
280
|
-
style: _style,
|
|
281
|
-
textColor: _textColor,
|
|
282
|
-
backgroundColor: _backgroundColor,
|
|
283
|
-
gradient: _gradient,
|
|
284
|
-
} = select( blockEditorStore ).getBlockAttributes( clientId ) || {};
|
|
285
|
-
return {
|
|
286
|
-
style: _style,
|
|
287
|
-
textColor: _textColor,
|
|
288
|
-
backgroundColor: _backgroundColor,
|
|
289
|
-
gradient: _gradient,
|
|
290
|
-
};
|
|
291
|
-
},
|
|
292
|
-
[ clientId, isEnabled ]
|
|
293
|
-
);
|
|
294
|
-
|
|
295
|
-
const isStateSelected = ! isDefaultBlockStyleState( selectedState );
|
|
296
|
-
|
|
297
|
-
const value = useMemo( () => {
|
|
298
|
-
if ( isStateSelected ) {
|
|
299
|
-
return getStyleForState( style, selectedState );
|
|
300
|
-
}
|
|
301
|
-
return attributesToStyle( {
|
|
302
|
-
style,
|
|
303
|
-
textColor,
|
|
304
|
-
backgroundColor,
|
|
305
|
-
gradient,
|
|
306
|
-
} );
|
|
307
|
-
}, [
|
|
308
|
-
isStateSelected,
|
|
309
|
-
selectedState,
|
|
310
|
-
style,
|
|
311
|
-
textColor,
|
|
312
|
-
backgroundColor,
|
|
313
|
-
gradient,
|
|
314
|
-
] );
|
|
315
|
-
|
|
316
|
-
const onChange = isStateSelected
|
|
317
|
-
? ( newStyle ) => {
|
|
318
|
-
setAttributes( {
|
|
319
|
-
style: setStyleForState( style, selectedState, newStyle ),
|
|
320
|
-
} );
|
|
321
|
-
}
|
|
322
|
-
: ( newStyle ) => {
|
|
323
|
-
setAttributes( styleToAttributes( newStyle ) );
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
const Wrapper = asWrapper || ColorInspectorControl;
|
|
327
|
-
|
|
328
|
-
if ( ! isEnabled ) {
|
|
329
|
-
return null;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
defaultControls = defaultControls
|
|
333
|
-
? defaultControls
|
|
334
|
-
: getBlockSupport( name, [
|
|
335
|
-
COLOR_SUPPORT_KEY,
|
|
336
|
-
'__experimentalDefaultControls',
|
|
337
|
-
] );
|
|
338
|
-
|
|
339
|
-
const enableContrastChecking =
|
|
340
|
-
! isStateSelected &&
|
|
341
|
-
! value?.color?.gradient &&
|
|
342
|
-
( settings?.color?.text || settings?.color?.link ) &&
|
|
343
|
-
// Contrast checking is enabled by default.
|
|
344
|
-
// Deactivating it requires `enableContrastChecker` to have
|
|
345
|
-
// an explicit value of `false`.
|
|
346
|
-
false !==
|
|
347
|
-
getBlockSupport( name, [
|
|
348
|
-
COLOR_SUPPORT_KEY,
|
|
349
|
-
'enableContrastChecker',
|
|
350
|
-
] );
|
|
351
|
-
|
|
352
|
-
return (
|
|
353
|
-
<StylesColorPanel
|
|
354
|
-
as={ Wrapper }
|
|
355
|
-
panelId={ clientId }
|
|
356
|
-
settings={ settings }
|
|
357
|
-
value={ value }
|
|
358
|
-
onChange={ onChange }
|
|
359
|
-
defaultControls={ defaultControls }
|
|
360
|
-
label={ label }
|
|
361
|
-
enableContrastChecker={
|
|
362
|
-
false !==
|
|
363
|
-
getBlockSupport( name, [
|
|
364
|
-
COLOR_SUPPORT_KEY,
|
|
365
|
-
'enableContrastChecker',
|
|
366
|
-
] )
|
|
367
|
-
}
|
|
368
|
-
>
|
|
369
|
-
{ enableContrastChecking && (
|
|
370
|
-
<BlockColorContrastChecker
|
|
371
|
-
clientId={ clientId }
|
|
372
|
-
name={ name }
|
|
373
|
-
/>
|
|
374
|
-
) }
|
|
375
|
-
</StylesColorPanel>
|
|
376
|
-
);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
176
|
function useBlockProps( {
|
|
380
177
|
name,
|
|
381
178
|
backgroundColor,
|
package/src/hooks/color.scss
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
@use "@wordpress/base-styles/variables" as *;
|
|
2
2
|
|
|
3
3
|
.color-block-support-panel {
|
|
4
|
+
// Blocks with non-standard color attributes (e.g. Social Icons,
|
|
5
|
+
// Navigation) still render the public ContrastChecker component
|
|
6
|
+
// directly within the color panel.
|
|
4
7
|
.block-editor-contrast-checker {
|
|
5
8
|
grid-column: span 2;
|
|
6
9
|
margin-top: $grid-unit-20;
|
|
@@ -12,13 +15,4 @@
|
|
|
12
15
|
row-gap: 0;
|
|
13
16
|
}
|
|
14
17
|
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* After converting PanelColorGradientSettings to render as a ToolsPanel
|
|
18
|
-
* we need to remove the top margin when wrapping inner content due to
|
|
19
|
-
* rendering via SlotFills.
|
|
20
|
-
*/
|
|
21
|
-
.block-editor-tools-panel-color-gradient-settings__item.first {
|
|
22
|
-
margin-top: 0;
|
|
23
|
-
}
|
|
24
18
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useLayoutEffect, useReducer } from '@wordpress/element';
|
|
4
|
+
import { useEffect, useLayoutEffect, useReducer } from '@wordpress/element';
|
|
5
5
|
import { useSelect } from '@wordpress/data';
|
|
6
6
|
import { store as blocksStore } from '@wordpress/blocks';
|
|
7
7
|
import { getBlockSelector } from '@wordpress/global-styles-engine';
|
|
8
|
+
import { speak } from '@wordpress/a11y';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
11
12
|
*/
|
|
12
|
-
import
|
|
13
|
+
import { getContrastWarning } from '../components/contrast-checker';
|
|
14
|
+
|
|
13
15
|
import { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
|
|
14
16
|
|
|
15
17
|
function getComputedValue( node, property ) {
|
|
@@ -80,23 +82,47 @@ function reducer( prevColors, newColors ) {
|
|
|
80
82
|
return hasChanged ? newColors : prevColors;
|
|
81
83
|
}
|
|
82
84
|
|
|
83
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Returns a contrast warning message for a block's computed colors, or
|
|
87
|
+
* `undefined` when contrast is sufficient or checking is disabled.
|
|
88
|
+
*
|
|
89
|
+
* Colors are read from the rendered block element so that inherited values
|
|
90
|
+
* (e.g. from Global Styles or ancestor blocks) are taken into account.
|
|
91
|
+
*
|
|
92
|
+
* @param {Object} props
|
|
93
|
+
* @param {string} props.clientId Block client ID.
|
|
94
|
+
* @param {string} props.name Block name.
|
|
95
|
+
* @param {boolean} [props.enabled] Whether contrast checking is active.
|
|
96
|
+
* @param {boolean} [props.checkTextColor] Whether to evaluate the text/background pair.
|
|
97
|
+
* @param {boolean} [props.checkLinkColor] Whether to evaluate the link/background pair.
|
|
98
|
+
* @param {string} [props.messageOverride] Caller-provided copy used in place of the generic guidance.
|
|
99
|
+
*
|
|
100
|
+
* @return {?string} The warning message, if any.
|
|
101
|
+
*/
|
|
102
|
+
export default function useBlockColorContrastWarning( {
|
|
103
|
+
clientId,
|
|
104
|
+
name,
|
|
105
|
+
enabled = true,
|
|
106
|
+
checkTextColor = true,
|
|
107
|
+
checkLinkColor = true,
|
|
108
|
+
messageOverride,
|
|
109
|
+
} ) {
|
|
84
110
|
const blockEl = useBlockElement( clientId );
|
|
85
111
|
const [ colors, setColors ] = useReducer( reducer, {} );
|
|
86
112
|
|
|
87
113
|
const blockType = useSelect(
|
|
88
114
|
( select ) => {
|
|
89
|
-
return name
|
|
115
|
+
return name && enabled
|
|
90
116
|
? select( blocksStore ).getBlockType( name )
|
|
91
117
|
: undefined;
|
|
92
118
|
},
|
|
93
|
-
[ name ]
|
|
119
|
+
[ name, enabled ]
|
|
94
120
|
);
|
|
95
121
|
|
|
96
122
|
// There are so many things that can change the color of a block
|
|
97
123
|
// So we perform this check on every render.
|
|
98
124
|
useLayoutEffect( () => {
|
|
99
|
-
if ( ! blockEl || ! blockType ) {
|
|
125
|
+
if ( ! enabled || ! blockEl || ! blockType ) {
|
|
100
126
|
return;
|
|
101
127
|
}
|
|
102
128
|
|
|
@@ -112,7 +138,7 @@ export default function BlockColorContrastChecker( { clientId, name } ) {
|
|
|
112
138
|
// Runs in its own effect with dependencies so the observer is only
|
|
113
139
|
// recreated when the block element or block type changes.
|
|
114
140
|
useLayoutEffect( () => {
|
|
115
|
-
if ( ! blockEl || ! blockType ) {
|
|
141
|
+
if ( ! enabled || ! blockEl || ! blockType ) {
|
|
116
142
|
return;
|
|
117
143
|
}
|
|
118
144
|
|
|
@@ -123,19 +149,36 @@ export default function BlockColorContrastChecker( { clientId, name } ) {
|
|
|
123
149
|
observer.observe( blockEl, {
|
|
124
150
|
attributes: true,
|
|
125
151
|
attributeFilter: [ 'class', 'style' ],
|
|
152
|
+
subtree: true,
|
|
126
153
|
} );
|
|
127
154
|
|
|
128
155
|
return () => {
|
|
129
156
|
observer.disconnect();
|
|
130
157
|
};
|
|
131
|
-
}, [ blockEl, blockType ] );
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
158
|
+
}, [ enabled, blockEl, blockType ] );
|
|
159
|
+
|
|
160
|
+
const warning = enabled
|
|
161
|
+
? getContrastWarning( {
|
|
162
|
+
backgroundColor: colors.backgroundColor,
|
|
163
|
+
textColor: checkTextColor ? colors.textColor : undefined,
|
|
164
|
+
linkColor: checkLinkColor ? colors.linkColor : undefined,
|
|
165
|
+
messageOverride,
|
|
166
|
+
enableAlphaChecker: true,
|
|
167
|
+
} )
|
|
168
|
+
: null;
|
|
169
|
+
|
|
170
|
+
// The popover Notice that displays this warning is muted
|
|
171
|
+
// (`spokenMessage={ null }`), so this hook is the single source of the
|
|
172
|
+
// spoken announcement. Announce only when the warning message itself
|
|
173
|
+
// appears or changes; keying off `speakMessage` rather than the raw
|
|
174
|
+
// computed `colors` avoids re-announcing the same warning when colors
|
|
175
|
+
// recompute without changing the outcome.
|
|
176
|
+
const speakMessage = warning?.speakMessage;
|
|
177
|
+
useEffect( () => {
|
|
178
|
+
if ( speakMessage ) {
|
|
179
|
+
speak( speakMessage );
|
|
180
|
+
}
|
|
181
|
+
}, [ speakMessage ] );
|
|
182
|
+
|
|
183
|
+
return warning?.message;
|
|
141
184
|
}
|
package/src/hooks/dimensions.js
CHANGED
|
@@ -190,6 +190,14 @@ export function hasDimensionsSupport( blockName, feature = 'any' ) {
|
|
|
190
190
|
return !! support?.[ feature ];
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
export function isExplicitAspectRatio( aspectRatio ) {
|
|
194
|
+
if ( ! aspectRatio ) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return `${ aspectRatio }`.trim().toLowerCase() !== 'auto';
|
|
199
|
+
}
|
|
200
|
+
|
|
193
201
|
export default {
|
|
194
202
|
useBlockProps,
|
|
195
203
|
attributeKeys: [ 'height', 'minHeight', 'width', 'style' ],
|
|
@@ -206,8 +214,11 @@ function useBlockProps( { name, height, minHeight, style } ) {
|
|
|
206
214
|
return {};
|
|
207
215
|
}
|
|
208
216
|
|
|
217
|
+
const hasExplicitAspectRatio = isExplicitAspectRatio(
|
|
218
|
+
style?.dimensions?.aspectRatio
|
|
219
|
+
);
|
|
209
220
|
const className = clsx( {
|
|
210
|
-
'has-aspect-ratio':
|
|
221
|
+
'has-aspect-ratio': hasExplicitAspectRatio,
|
|
211
222
|
} );
|
|
212
223
|
|
|
213
224
|
// Allow dimensions-based inline style overrides to override any global styles rules that
|
|
@@ -215,12 +226,12 @@ function useBlockProps( { name, height, minHeight, style } ) {
|
|
|
215
226
|
const inlineStyleOverrides = {};
|
|
216
227
|
|
|
217
228
|
// Apply rules to unset incompatible styles.
|
|
218
|
-
// Note that
|
|
229
|
+
// Note that an explicit `aspectRatio` will win out if both an aspect ratio and height-related properties are set.
|
|
219
230
|
// This is because the aspect ratio is a newer block support, so (in theory) any aspect ratio
|
|
220
231
|
// that is set should be intentional and should override any existing height properties. The Cover block
|
|
221
232
|
// and dimensions controls have logic that will manually clear the aspect ratio if height properties
|
|
222
233
|
// are set.
|
|
223
|
-
if (
|
|
234
|
+
if ( hasExplicitAspectRatio ) {
|
|
224
235
|
// To ensure the aspect ratio does not get overridden by `minHeight` or `height` unset any existing rule.
|
|
225
236
|
inlineStyleOverrides.minHeight = 'unset';
|
|
226
237
|
inlineStyleOverrides.height = 'unset';
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { getBlockSupport } from '@wordpress/blocks';
|
|
5
|
+
import { useMemo, useCallback } from '@wordpress/element';
|
|
6
|
+
import { useSelect } from '@wordpress/data';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import InspectorControls from '../components/inspector-controls';
|
|
13
|
+
import {
|
|
14
|
+
useHasColorPanel,
|
|
15
|
+
default as StylesColorPanel,
|
|
16
|
+
} from '../components/global-styles/color-panel';
|
|
17
|
+
import { cleanEmptyObject } from './utils';
|
|
18
|
+
import { store as blockEditorStore } from '../store';
|
|
19
|
+
import { COLOR_SUPPORT_KEY } from './color';
|
|
20
|
+
import useBlockColorContrastWarning from './contrast-checker';
|
|
21
|
+
import {
|
|
22
|
+
getStyleForState,
|
|
23
|
+
isDefaultBlockStyleState,
|
|
24
|
+
setStyleForState,
|
|
25
|
+
useBlockStyleState,
|
|
26
|
+
} from './block-style-state';
|
|
27
|
+
|
|
28
|
+
function ElementsInspectorControl( { children, resetAllFilter } ) {
|
|
29
|
+
const attributesResetAllFilter = useCallback(
|
|
30
|
+
( attributes ) => {
|
|
31
|
+
const updatedStyle = resetAllFilter( attributes.style );
|
|
32
|
+
return {
|
|
33
|
+
...attributes,
|
|
34
|
+
style: cleanEmptyObject( updatedStyle ),
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
[ resetAllFilter ]
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<InspectorControls
|
|
42
|
+
group="elements"
|
|
43
|
+
resetAllFilter={ attributesResetAllFilter }
|
|
44
|
+
>
|
|
45
|
+
{ children }
|
|
46
|
+
</InspectorControls>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function ElementsEdit( {
|
|
51
|
+
clientId,
|
|
52
|
+
name,
|
|
53
|
+
setAttributes,
|
|
54
|
+
settings,
|
|
55
|
+
asWrapper,
|
|
56
|
+
label,
|
|
57
|
+
defaultControls,
|
|
58
|
+
} ) {
|
|
59
|
+
const selectedState = useBlockStyleState();
|
|
60
|
+
const isEnabled = useHasColorPanel( settings );
|
|
61
|
+
|
|
62
|
+
const style = useSelect(
|
|
63
|
+
( select ) => {
|
|
64
|
+
if ( ! isEnabled ) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
const attributes =
|
|
68
|
+
select( blockEditorStore ).getBlockAttributes( clientId );
|
|
69
|
+
return attributes?.style;
|
|
70
|
+
},
|
|
71
|
+
[ clientId, isEnabled ]
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const isStateSelected = ! isDefaultBlockStyleState( selectedState );
|
|
75
|
+
|
|
76
|
+
const value = useMemo( () => {
|
|
77
|
+
if ( isStateSelected ) {
|
|
78
|
+
return getStyleForState( style, selectedState );
|
|
79
|
+
}
|
|
80
|
+
return style;
|
|
81
|
+
}, [ isStateSelected, selectedState, style ] );
|
|
82
|
+
|
|
83
|
+
const onChange = isStateSelected
|
|
84
|
+
? ( newStyle ) => {
|
|
85
|
+
setAttributes( {
|
|
86
|
+
style: setStyleForState( style, selectedState, newStyle ),
|
|
87
|
+
} );
|
|
88
|
+
}
|
|
89
|
+
: ( newStyle ) => {
|
|
90
|
+
setAttributes( { style: cleanEmptyObject( newStyle ) } );
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// Text and background color failures are reported by the Typography and
|
|
94
|
+
// Background panels, which own those selections.
|
|
95
|
+
const enableContrastChecking =
|
|
96
|
+
! isStateSelected &&
|
|
97
|
+
!! value?.elements?.link?.color?.text &&
|
|
98
|
+
settings?.color?.link &&
|
|
99
|
+
false !==
|
|
100
|
+
getBlockSupport( name, [
|
|
101
|
+
COLOR_SUPPORT_KEY,
|
|
102
|
+
'enableContrastChecker',
|
|
103
|
+
] );
|
|
104
|
+
|
|
105
|
+
const contrastWarning = useBlockColorContrastWarning( {
|
|
106
|
+
clientId,
|
|
107
|
+
name,
|
|
108
|
+
enabled: !! enableContrastChecking,
|
|
109
|
+
checkTextColor: false,
|
|
110
|
+
messageOverride: __(
|
|
111
|
+
'This link color has poor contrast against the background. Consider increasing contrast.'
|
|
112
|
+
),
|
|
113
|
+
} );
|
|
114
|
+
|
|
115
|
+
if ( ! isEnabled ) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
defaultControls = defaultControls
|
|
120
|
+
? defaultControls
|
|
121
|
+
: getBlockSupport( name, [
|
|
122
|
+
COLOR_SUPPORT_KEY,
|
|
123
|
+
'__experimentalDefaultControls',
|
|
124
|
+
] );
|
|
125
|
+
|
|
126
|
+
const Wrapper = asWrapper || ElementsInspectorControl;
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<StylesColorPanel
|
|
130
|
+
as={ Wrapper }
|
|
131
|
+
panelId={ clientId }
|
|
132
|
+
settings={ settings }
|
|
133
|
+
value={ value }
|
|
134
|
+
onChange={ onChange }
|
|
135
|
+
defaultControls={ defaultControls }
|
|
136
|
+
label={ label }
|
|
137
|
+
contrastWarning={ contrastWarning }
|
|
138
|
+
/>
|
|
139
|
+
);
|
|
140
|
+
}
|