@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
|
@@ -23,15 +23,51 @@ import { useGetNumberOfBlocksBeforeCell } from '../grid/use-get-number-of-blocks
|
|
|
23
23
|
import { store as blockEditorStore } from '../../store';
|
|
24
24
|
import { useSettings } from '../use-settings';
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
// These are the serialized `selfStretch` values. `max` used to be called
|
|
27
|
+
// "Fixed" in the UI, but was renamed and replaced by `fixedNoShrink`.
|
|
28
|
+
const FLEX_CHILD_LAYOUT_VALUES = {
|
|
29
|
+
fit: 'fit',
|
|
30
|
+
grow: 'fill',
|
|
31
|
+
max: 'fixed',
|
|
32
|
+
fixed: 'fixedNoShrink',
|
|
33
|
+
};
|
|
28
34
|
|
|
29
|
-
|
|
35
|
+
const FLEX_SIZE_VALUES = [
|
|
36
|
+
FLEX_CHILD_LAYOUT_VALUES.max,
|
|
37
|
+
FLEX_CHILD_LAYOUT_VALUES.fixed,
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
function isFlexSizeValue( value ) {
|
|
41
|
+
return FLEX_SIZE_VALUES.includes( value );
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function maxSizeLabel( parentLayout ) {
|
|
45
|
+
const { orientation = 'horizontal' } = parentLayout ?? {};
|
|
46
|
+
return orientation === 'horizontal'
|
|
47
|
+
? _x( 'Max', 'Block with maximum width in flex layout' )
|
|
48
|
+
: _x( 'Max', 'Block with maximum height in flex layout' );
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function helpText( flexControlValue, parentLayout ) {
|
|
52
|
+
const { orientation = 'horizontal' } = parentLayout ?? {};
|
|
53
|
+
|
|
54
|
+
if ( flexControlValue === FLEX_CHILD_LAYOUT_VALUES.grow ) {
|
|
30
55
|
return __( 'Stretch to fill available space.' );
|
|
31
56
|
}
|
|
32
|
-
if (
|
|
57
|
+
if (
|
|
58
|
+
flexControlValue === FLEX_CHILD_LAYOUT_VALUES.max &&
|
|
59
|
+
orientation === 'horizontal'
|
|
60
|
+
) {
|
|
61
|
+
return __( 'Specify a maximum width.' );
|
|
62
|
+
} else if ( flexControlValue === FLEX_CHILD_LAYOUT_VALUES.max ) {
|
|
63
|
+
return __( 'Specify a maximum height.' );
|
|
64
|
+
}
|
|
65
|
+
if (
|
|
66
|
+
flexControlValue === FLEX_CHILD_LAYOUT_VALUES.fixed &&
|
|
67
|
+
orientation === 'horizontal'
|
|
68
|
+
) {
|
|
33
69
|
return __( 'Specify a fixed width.' );
|
|
34
|
-
} else if (
|
|
70
|
+
} else if ( flexControlValue === FLEX_CHILD_LAYOUT_VALUES.fixed ) {
|
|
35
71
|
return __( 'Specify a fixed height.' );
|
|
36
72
|
}
|
|
37
73
|
return __( 'Fit contents.' );
|
|
@@ -99,6 +135,8 @@ function FlexControls( {
|
|
|
99
135
|
} ) {
|
|
100
136
|
const { selfStretch, flexSize } = childLayout;
|
|
101
137
|
const { orientation = 'horizontal' } = parentLayout ?? {};
|
|
138
|
+
const flexControlValue = selfStretch || FLEX_CHILD_LAYOUT_VALUES.fit;
|
|
139
|
+
const hasFlexSizeValue = isFlexSizeValue( flexControlValue );
|
|
102
140
|
const hasFlexValue = () => !! selfStretch;
|
|
103
141
|
const flexResetLabel =
|
|
104
142
|
orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );
|
|
@@ -121,13 +159,13 @@ function FlexControls( {
|
|
|
121
159
|
};
|
|
122
160
|
|
|
123
161
|
useEffect( () => {
|
|
124
|
-
if ( selfStretch
|
|
162
|
+
if ( isFlexSizeValue( selfStretch ) && ! flexSize ) {
|
|
125
163
|
onChange( {
|
|
126
164
|
...childLayout,
|
|
127
|
-
selfStretch:
|
|
165
|
+
selfStretch: FLEX_CHILD_LAYOUT_VALUES.fit,
|
|
128
166
|
} );
|
|
129
167
|
}
|
|
130
|
-
}, [] );
|
|
168
|
+
}, [] ); // eslint-disable-line react-hooks/exhaustive-deps
|
|
131
169
|
|
|
132
170
|
return (
|
|
133
171
|
<VStack
|
|
@@ -142,10 +180,12 @@ function FlexControls( {
|
|
|
142
180
|
<ToggleGroupControl
|
|
143
181
|
size="__unstable-large"
|
|
144
182
|
label={ childLayoutOrientation( parentLayout ) }
|
|
145
|
-
value={
|
|
146
|
-
help={ helpText(
|
|
183
|
+
value={ flexControlValue }
|
|
184
|
+
help={ helpText( flexControlValue, parentLayout ) }
|
|
147
185
|
onChange={ ( value ) => {
|
|
148
|
-
const newFlexSize = value
|
|
186
|
+
const newFlexSize = isFlexSizeValue( value )
|
|
187
|
+
? flexSize
|
|
188
|
+
: null;
|
|
149
189
|
onChange( {
|
|
150
190
|
selfStretch: value,
|
|
151
191
|
flexSize: newFlexSize,
|
|
@@ -154,37 +194,42 @@ function FlexControls( {
|
|
|
154
194
|
isBlock
|
|
155
195
|
>
|
|
156
196
|
<ToggleGroupControlOption
|
|
157
|
-
key=
|
|
158
|
-
value=
|
|
197
|
+
key={ FLEX_CHILD_LAYOUT_VALUES.fit }
|
|
198
|
+
value={ FLEX_CHILD_LAYOUT_VALUES.fit }
|
|
159
199
|
label={ _x(
|
|
160
200
|
'Fit',
|
|
161
201
|
'Intrinsic block width in flex layout'
|
|
162
202
|
) }
|
|
163
203
|
/>
|
|
164
204
|
<ToggleGroupControlOption
|
|
165
|
-
key=
|
|
166
|
-
value=
|
|
205
|
+
key={ FLEX_CHILD_LAYOUT_VALUES.grow }
|
|
206
|
+
value={ FLEX_CHILD_LAYOUT_VALUES.grow }
|
|
167
207
|
label={ _x(
|
|
168
208
|
'Grow',
|
|
169
209
|
'Block with expanding width in flex layout'
|
|
170
210
|
) }
|
|
171
211
|
/>
|
|
172
212
|
<ToggleGroupControlOption
|
|
173
|
-
key=
|
|
174
|
-
value=
|
|
213
|
+
key={ FLEX_CHILD_LAYOUT_VALUES.max }
|
|
214
|
+
value={ FLEX_CHILD_LAYOUT_VALUES.max }
|
|
215
|
+
label={ maxSizeLabel( parentLayout ) }
|
|
216
|
+
/>
|
|
217
|
+
<ToggleGroupControlOption
|
|
218
|
+
key={ FLEX_CHILD_LAYOUT_VALUES.fixed }
|
|
219
|
+
value={ FLEX_CHILD_LAYOUT_VALUES.fixed }
|
|
175
220
|
label={ _x(
|
|
176
221
|
'Fixed',
|
|
177
222
|
'Block with fixed width in flex layout'
|
|
178
223
|
) }
|
|
179
224
|
/>
|
|
180
225
|
</ToggleGroupControl>
|
|
181
|
-
{
|
|
226
|
+
{ hasFlexSizeValue && (
|
|
182
227
|
<UnitControl
|
|
183
228
|
size="__unstable-large"
|
|
184
229
|
units={ units }
|
|
185
230
|
onChange={ ( value ) => {
|
|
186
231
|
onChange( {
|
|
187
|
-
selfStretch,
|
|
232
|
+
selfStretch: flexControlValue,
|
|
188
233
|
flexSize: value,
|
|
189
234
|
} );
|
|
190
235
|
} }
|
|
@@ -199,7 +244,7 @@ function FlexControls( {
|
|
|
199
244
|
}
|
|
200
245
|
|
|
201
246
|
export function childLayoutOrientation( parentLayout ) {
|
|
202
|
-
const { orientation = 'horizontal' } = parentLayout;
|
|
247
|
+
const { orientation = 'horizontal' } = parentLayout ?? {};
|
|
203
248
|
return orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );
|
|
204
249
|
}
|
|
205
250
|
|
|
@@ -14,6 +14,10 @@ import { __experimentalToolsPanel as ToolsPanel } from '@wordpress/components';
|
|
|
14
14
|
*/
|
|
15
15
|
import ChildLayoutControl from '../';
|
|
16
16
|
|
|
17
|
+
jest.mock( '../../use-settings', () => ( {
|
|
18
|
+
useSettings: () => [ undefined ],
|
|
19
|
+
} ) );
|
|
20
|
+
|
|
17
21
|
jest.mock( '@wordpress/data/src/components/use-select', () =>
|
|
18
22
|
jest.fn( ( mapSelect ) => {
|
|
19
23
|
if ( typeof mapSelect === 'function' ) {
|
|
@@ -123,4 +127,64 @@ describe( 'ChildLayoutControl', () => {
|
|
|
123
127
|
columnSpan: 1,
|
|
124
128
|
} );
|
|
125
129
|
} );
|
|
130
|
+
|
|
131
|
+
it( 'shows legacy fixed flex sizing as max', () => {
|
|
132
|
+
renderControl( {
|
|
133
|
+
parentLayout: {
|
|
134
|
+
type: 'flex',
|
|
135
|
+
orientation: 'horizontal',
|
|
136
|
+
},
|
|
137
|
+
value: {
|
|
138
|
+
selfStretch: 'fixed',
|
|
139
|
+
flexSize: '320px',
|
|
140
|
+
},
|
|
141
|
+
} );
|
|
142
|
+
|
|
143
|
+
expect( screen.getByRole( 'radio', { name: 'Max' } ) ).toBeChecked();
|
|
144
|
+
} );
|
|
145
|
+
|
|
146
|
+
it( 'sets fixedNoShrink when selecting fixed flex sizing', async () => {
|
|
147
|
+
const user = userEvent.setup();
|
|
148
|
+
const onChange = jest.fn();
|
|
149
|
+
|
|
150
|
+
renderControl( {
|
|
151
|
+
parentLayout: {
|
|
152
|
+
type: 'flex',
|
|
153
|
+
orientation: 'horizontal',
|
|
154
|
+
},
|
|
155
|
+
value: {},
|
|
156
|
+
onChange,
|
|
157
|
+
} );
|
|
158
|
+
|
|
159
|
+
await user.click( screen.getByRole( 'radio', { name: 'Fixed' } ) );
|
|
160
|
+
|
|
161
|
+
expect( onChange ).toHaveBeenCalledWith( {
|
|
162
|
+
selfStretch: 'fixedNoShrink',
|
|
163
|
+
flexSize: undefined,
|
|
164
|
+
} );
|
|
165
|
+
} );
|
|
166
|
+
|
|
167
|
+
it( 'sets legacy fixed when selecting max sizing', async () => {
|
|
168
|
+
const user = userEvent.setup();
|
|
169
|
+
const onChange = jest.fn();
|
|
170
|
+
|
|
171
|
+
renderControl( {
|
|
172
|
+
parentLayout: {
|
|
173
|
+
type: 'flex',
|
|
174
|
+
orientation: 'horizontal',
|
|
175
|
+
},
|
|
176
|
+
value: {
|
|
177
|
+
selfStretch: 'fixedNoShrink',
|
|
178
|
+
flexSize: '320px',
|
|
179
|
+
},
|
|
180
|
+
onChange,
|
|
181
|
+
} );
|
|
182
|
+
|
|
183
|
+
await user.click( screen.getByRole( 'radio', { name: 'Max' } ) );
|
|
184
|
+
|
|
185
|
+
expect( onChange ).toHaveBeenCalledWith( {
|
|
186
|
+
selfStretch: 'fixed',
|
|
187
|
+
flexSize: '320px',
|
|
188
|
+
} );
|
|
189
|
+
} );
|
|
126
190
|
} );
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
__experimentalVStack as VStack,
|
|
13
13
|
ColorPalette,
|
|
14
14
|
GradientPicker,
|
|
15
|
+
Notice,
|
|
15
16
|
privateApis as componentsPrivateApis,
|
|
16
17
|
} from '@wordpress/components';
|
|
17
18
|
|
|
@@ -48,6 +49,7 @@ function ColorGradientControlInner( {
|
|
|
48
49
|
showTitle = true,
|
|
49
50
|
enableAlpha,
|
|
50
51
|
headingLevel,
|
|
52
|
+
noticeProps,
|
|
51
53
|
} ) {
|
|
52
54
|
const canChooseAColor =
|
|
53
55
|
onColorChange &&
|
|
@@ -67,20 +69,35 @@ function ColorGradientControlInner( {
|
|
|
67
69
|
}
|
|
68
70
|
: ( newColor, _index, newSlug ) => onColorChange( newColor, newSlug );
|
|
69
71
|
|
|
72
|
+
const colorPalette = (
|
|
73
|
+
<ColorPalette
|
|
74
|
+
value={ colorValue }
|
|
75
|
+
selectedSlug={ colorSlug }
|
|
76
|
+
onChange={ colorPaletteOnChange }
|
|
77
|
+
{ ...{ colors, disableCustomColors } }
|
|
78
|
+
__experimentalIsRenderedInSidebar={
|
|
79
|
+
__experimentalIsRenderedInSidebar
|
|
80
|
+
}
|
|
81
|
+
clearable={ clearable }
|
|
82
|
+
enableAlpha={ enableAlpha }
|
|
83
|
+
headingLevel={ headingLevel }
|
|
84
|
+
/>
|
|
85
|
+
);
|
|
86
|
+
|
|
70
87
|
const tabPanels = {
|
|
88
|
+
// The `ColorPalette` must stay at a stable position in the tree whether
|
|
89
|
+
// or not a notice is present. Wrapping it in a `VStack` only when a
|
|
90
|
+
// notice appears remounts it, which resets the custom color picker back
|
|
91
|
+
// to the swatch view mid-edit. Keep `ColorPalette` last and toggle only
|
|
92
|
+
// the notice ahead of it; the notice's own bottom margin provides the
|
|
93
|
+
// spacing the wrapper used to.
|
|
71
94
|
[ TAB_IDS.color ]: (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
{
|
|
77
|
-
|
|
78
|
-
__experimentalIsRenderedInSidebar
|
|
79
|
-
}
|
|
80
|
-
clearable={ clearable }
|
|
81
|
-
enableAlpha={ enableAlpha }
|
|
82
|
-
headingLevel={ headingLevel }
|
|
83
|
-
/>
|
|
95
|
+
<>
|
|
96
|
+
{ noticeProps && (
|
|
97
|
+
<Notice isDismissible={ false } { ...noticeProps } />
|
|
98
|
+
) }
|
|
99
|
+
{ colorPalette }
|
|
100
|
+
</>
|
|
84
101
|
),
|
|
85
102
|
[ TAB_IDS.gradient ]: (
|
|
86
103
|
<GradientPicker
|
|
@@ -51,7 +51,10 @@ const WithToolsPanelItem = ( { setting, children, panelId, ...props } ) => {
|
|
|
51
51
|
: true
|
|
52
52
|
}
|
|
53
53
|
{ ...props }
|
|
54
|
-
className=
|
|
54
|
+
className={ clsx(
|
|
55
|
+
'block-editor-color-gradient-item',
|
|
56
|
+
'block-editor-tools-panel-color-gradient-settings__item'
|
|
57
|
+
) }
|
|
55
58
|
panelId={ panelId }
|
|
56
59
|
// Pass resetAllFilter if supplied due to rendering via SlotFill
|
|
57
60
|
// into parent ToolsPanel.
|
|
@@ -68,14 +68,23 @@ $swatch-gap: 12px;
|
|
|
68
68
|
background: linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
// Space the in-popover contrast notice away from the color palette below it.
|
|
72
|
+
.block-editor-panel-color-gradient-settings__contrast-notice {
|
|
73
|
+
margin-bottom: $grid-unit-20;
|
|
74
|
+
}
|
|
75
|
+
|
|
71
76
|
/**
|
|
72
77
|
* The following styles replicate the separated border of the
|
|
73
78
|
* `ItemGroup` component but allows for hidden items. This is because
|
|
74
79
|
* to maintain the order of `ToolsPanel` controls, each `ToolsPanelItem`
|
|
75
80
|
* must at least render a placeholder which would otherwise interfere
|
|
76
81
|
* with the `:last-child` styles.
|
|
82
|
+
*
|
|
83
|
+
* Applied via the shared `block-editor-color-gradient-item` class on
|
|
84
|
+
* color/gradient dropdown items across the Color, Background, and
|
|
85
|
+
* Typography panels.
|
|
77
86
|
*/
|
|
78
|
-
.block-editor-
|
|
87
|
+
.block-editor-color-gradient-item {
|
|
79
88
|
padding: 0;
|
|
80
89
|
max-width: 100%;
|
|
81
90
|
position: relative;
|
|
@@ -87,7 +96,6 @@ $swatch-gap: 12px;
|
|
|
87
96
|
|
|
88
97
|
// Identify the first visible instance as placeholder items will not have this class.
|
|
89
98
|
&:nth-child(1 of &) {
|
|
90
|
-
margin-top: $grid-unit-30;
|
|
91
99
|
border-top-left-radius: $radius-small;
|
|
92
100
|
border-top-right-radius: $radius-small;
|
|
93
101
|
border-top: 1px solid $gray-300;
|
|
@@ -127,6 +135,12 @@ $swatch-gap: 12px;
|
|
|
127
135
|
text-overflow: ellipsis;
|
|
128
136
|
max-width: calc(100% - ($button-size-next-default-40px + $grid-unit-05));
|
|
129
137
|
}
|
|
138
|
+
|
|
139
|
+
// Reserve extra space for the always-visible contrast warning icon,
|
|
140
|
+
// which sits alongside the hover-revealed reset button.
|
|
141
|
+
> button.has-contrast-warning .block-editor-panel-color-gradient-settings__color-name {
|
|
142
|
+
max-width: calc(100% - ($button-size-next-default-40px + $button-size-small + $grid-unit));
|
|
143
|
+
}
|
|
130
144
|
}
|
|
131
145
|
|
|
132
146
|
.block-editor-panel-color-gradient-settings__dropdown {
|
|
@@ -161,4 +175,27 @@ $swatch-gap: 12px;
|
|
|
161
175
|
// Show reset button on devices that do not support hover.
|
|
162
176
|
opacity: 1;
|
|
163
177
|
}
|
|
178
|
+
|
|
179
|
+
// While a contrast warning is in effect the warning icon occupies the
|
|
180
|
+
// far-right slot, so the reset button shifts left to sit beside it.
|
|
181
|
+
.block-editor-panel-color-gradient-settings__dropdown.has-contrast-warning + & {
|
|
182
|
+
right: $button-size-small + $grid-unit-05;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Icon-only "Low contrast" warning shown to the right of the color
|
|
187
|
+
// control toggle whenever the selection has insufficient contrast.
|
|
188
|
+
// Unlike the reset button it stays visible without hover. It is not a
|
|
189
|
+
// menu; activating it opens the color picker popover (where the full
|
|
190
|
+
// warning notice lives), so it doubles as a shortcut to the fix. The
|
|
191
|
+
// accessible name and hover/focus tooltip come from the button label.
|
|
192
|
+
.block-editor-panel-color-gradient-settings__contrast-warning {
|
|
193
|
+
position: absolute;
|
|
194
|
+
right: 0;
|
|
195
|
+
top: $grid-unit;
|
|
196
|
+
margin: auto $grid-unit auto;
|
|
197
|
+
|
|
198
|
+
&.block-editor-panel-color-gradient-settings__contrast-warning {
|
|
199
|
+
border-radius: $radius-small;
|
|
200
|
+
}
|
|
164
201
|
}
|
|
@@ -69,3 +69,12 @@ The text color to check the contrast of the background against.
|
|
|
69
69
|
|
|
70
70
|
- Type: `String`
|
|
71
71
|
- Required: No
|
|
72
|
+
|
|
73
|
+
#### messageOverride
|
|
74
|
+
|
|
75
|
+
Custom warning message to display (and announce) instead of the default
|
|
76
|
+
contrast guidance when the color combination has insufficient contrast. Useful
|
|
77
|
+
for providing panel-specific, more concise copy.
|
|
78
|
+
|
|
79
|
+
- Type: `String`
|
|
80
|
+
- Required: No
|
|
@@ -14,7 +14,28 @@ import { speak } from '@wordpress/a11y';
|
|
|
14
14
|
|
|
15
15
|
extend( [ namesPlugin, a11yPlugin ] );
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Computes a contrast warning for the given color combination, if any.
|
|
19
|
+
*
|
|
20
|
+
* Shared between the `ContrastChecker` component and the block inspector
|
|
21
|
+
* contrast warning indicators, which surface the result without rendering
|
|
22
|
+
* a notice.
|
|
23
|
+
*
|
|
24
|
+
* @param {Object} props
|
|
25
|
+
* @param {string} [props.backgroundColor] Background color.
|
|
26
|
+
* @param {string} [props.fallbackBackgroundColor] Fallback background color.
|
|
27
|
+
* @param {string} [props.fallbackTextColor] Fallback text color.
|
|
28
|
+
* @param {string} [props.fallbackLinkColor] Fallback link color.
|
|
29
|
+
* @param {number} [props.fontSize] Font size value in pixels.
|
|
30
|
+
* @param {boolean} [props.isLargeText] Whether the text is large.
|
|
31
|
+
* @param {string} [props.textColor] Text color.
|
|
32
|
+
* @param {string} [props.linkColor] Link color.
|
|
33
|
+
* @param {string} [props.messageOverride] Caller-provided copy used in place of the generic guidance.
|
|
34
|
+
* @param {boolean} [props.enableAlphaChecker] Whether to warn about transparent text.
|
|
35
|
+
*
|
|
36
|
+
* @return {?Object} `{ message, speakMessage }` when contrast is insufficient, otherwise `null`.
|
|
37
|
+
*/
|
|
38
|
+
export function getContrastWarning( {
|
|
18
39
|
backgroundColor,
|
|
19
40
|
fallbackBackgroundColor,
|
|
20
41
|
fallbackTextColor,
|
|
@@ -23,6 +44,7 @@ function ContrastChecker( {
|
|
|
23
44
|
isLargeText,
|
|
24
45
|
textColor,
|
|
25
46
|
linkColor,
|
|
47
|
+
messageOverride,
|
|
26
48
|
enableAlphaChecker = false,
|
|
27
49
|
} ) {
|
|
28
50
|
const currentBackgroundColor = backgroundColor || fallbackBackgroundColor;
|
|
@@ -81,6 +103,13 @@ function ContrastChecker( {
|
|
|
81
103
|
if ( backgroundColorHasTransparency || textHasTransparency ) {
|
|
82
104
|
continue;
|
|
83
105
|
}
|
|
106
|
+
// A caller can provide panel-specific copy that is clearer and
|
|
107
|
+
// more concise than the generic brighter/darker guidance.
|
|
108
|
+
if ( messageOverride ) {
|
|
109
|
+
message = messageOverride;
|
|
110
|
+
speakMessage = messageOverride;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
84
113
|
message =
|
|
85
114
|
backgroundColorBrightness < colordTextColor.brightness()
|
|
86
115
|
? sprintf(
|
|
@@ -119,11 +148,21 @@ function ContrastChecker( {
|
|
|
119
148
|
return null;
|
|
120
149
|
}
|
|
121
150
|
|
|
151
|
+
return { message, speakMessage };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function ContrastChecker( props ) {
|
|
155
|
+
const warning = getContrastWarning( props );
|
|
156
|
+
|
|
157
|
+
if ( ! warning ) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
|
|
122
161
|
// Note: The `Notice` component can speak messages via its `spokenMessage`
|
|
123
162
|
// prop, but the contrast checker requires granular control over when the
|
|
124
163
|
// announcements are made. Notably, the message will be re-announced if a
|
|
125
164
|
// new color combination is selected and the contrast is still insufficient.
|
|
126
|
-
speak( speakMessage );
|
|
165
|
+
speak( warning.speakMessage );
|
|
127
166
|
|
|
128
167
|
return (
|
|
129
168
|
<div className="block-editor-contrast-checker">
|
|
@@ -132,7 +171,7 @@ function ContrastChecker( {
|
|
|
132
171
|
status="warning"
|
|
133
172
|
isDismissible={ false }
|
|
134
173
|
>
|
|
135
|
-
{ message }
|
|
174
|
+
{ warning.message }
|
|
136
175
|
</Notice>
|
|
137
176
|
</div>
|
|
138
177
|
);
|
|
@@ -30,6 +30,9 @@
|
|
|
30
30
|
// Set the opacity of the initial block appender to the same as placeholder text in an empty Paragraph block.
|
|
31
31
|
opacity: 0.62;
|
|
32
32
|
|
|
33
|
+
// Reset the text shadow from the global styles.
|
|
34
|
+
text-shadow: none;
|
|
35
|
+
|
|
33
36
|
// The following prevents user agent styles from applying margins to the appender's inner paragraph.
|
|
34
37
|
// This in turn prevents layout shift due to layout styles removing margins from first and last children.
|
|
35
38
|
margin-block-start: 0;
|
|
@@ -56,7 +56,7 @@ function DimensionsTool( {
|
|
|
56
56
|
aspectRatioOptions, // Default options handled by AspectRatioTool.
|
|
57
57
|
defaultAspectRatio = 'auto', // Match CSS default value for aspect-ratio.
|
|
58
58
|
scaleOptions, // Default options handled by ScaleTool.
|
|
59
|
-
defaultScale = '
|
|
59
|
+
defaultScale = 'cover',
|
|
60
60
|
unitsOptions, // Default options handled by UnitControl.
|
|
61
61
|
tools = [ 'aspectRatio', 'widthHeight', 'scale' ],
|
|
62
62
|
} ) {
|
|
@@ -73,21 +73,19 @@ function DimensionsTool( {
|
|
|
73
73
|
value.aspectRatio === undefined || value.aspectRatio === 'auto'
|
|
74
74
|
? null
|
|
75
75
|
: value.aspectRatio;
|
|
76
|
-
const scale =
|
|
77
|
-
value.scale === undefined || value.scale === 'fill'
|
|
78
|
-
? null
|
|
79
|
-
: value.scale;
|
|
76
|
+
const scale = value.scale === undefined ? null : value.scale;
|
|
80
77
|
|
|
81
78
|
// Keep track of state internally, so when the value is cleared by means
|
|
82
79
|
// other than directly editing that field, it's easier to restore the
|
|
83
80
|
// previous value.
|
|
84
81
|
const [ lastScale, setLastScale ] = useState( scale );
|
|
85
82
|
const [ lastAspectRatio, setLastAspectRatio ] = useState( aspectRatio );
|
|
83
|
+
const hasCustomAspectRatio = !! ( width && height );
|
|
86
84
|
|
|
87
85
|
// 'custom' is not a valid value for CSS aspect-ratio, but it is used in the
|
|
88
86
|
// dropdown to indicate that setting both the width and height is the same
|
|
89
87
|
// as a custom aspect ratio.
|
|
90
|
-
const aspectRatioValue =
|
|
88
|
+
const aspectRatioValue = hasCustomAspectRatio ? 'custom' : aspectRatio;
|
|
91
89
|
|
|
92
90
|
const showScaleControl = aspectRatio || ( width && height );
|
|
93
91
|
|
|
@@ -197,9 +195,6 @@ function DimensionsTool( {
|
|
|
197
195
|
onChange={ ( nextScale ) => {
|
|
198
196
|
const nextValue = { ...value };
|
|
199
197
|
|
|
200
|
-
// 'fill' is CSS default, so it gets treated as null.
|
|
201
|
-
nextScale = nextScale === 'fill' ? null : nextScale;
|
|
202
|
-
|
|
203
198
|
setLastScale( nextScale );
|
|
204
199
|
|
|
205
200
|
// Update scale.
|
|
@@ -86,8 +86,7 @@ export default function ScaleTool( {
|
|
|
86
86
|
defaultValue = DEFAULT_SCALE_OPTIONS[ 0 ].value,
|
|
87
87
|
isShownByDefault = true,
|
|
88
88
|
} ) {
|
|
89
|
-
|
|
90
|
-
const displayValue = value ?? 'fill';
|
|
89
|
+
const displayValue = value ?? defaultValue;
|
|
91
90
|
|
|
92
91
|
const scaleHelp = useMemo( () => {
|
|
93
92
|
return options.reduce( ( acc, option ) => {
|
|
@@ -16,6 +16,17 @@ import { useState } from '@wordpress/element';
|
|
|
16
16
|
import DimensionsTool from '../';
|
|
17
17
|
|
|
18
18
|
const EMPTY_OBJECT = {};
|
|
19
|
+
const ASPECT_RATIO_OPTIONS = [
|
|
20
|
+
{ label: 'Original', value: 'auto' },
|
|
21
|
+
{ label: '16/9', value: '16/9' },
|
|
22
|
+
{ label: '4/3', value: '4/3' },
|
|
23
|
+
{
|
|
24
|
+
label: 'Custom',
|
|
25
|
+
value: 'custom',
|
|
26
|
+
disabled: true,
|
|
27
|
+
hidden: true,
|
|
28
|
+
},
|
|
29
|
+
];
|
|
19
30
|
|
|
20
31
|
function Example( { initialValue, onChange, ...props } ) {
|
|
21
32
|
const [ value, setValue ] = useState( initialValue );
|
|
@@ -33,16 +44,27 @@ function Example( { initialValue, onChange, ...props } ) {
|
|
|
33
44
|
} }
|
|
34
45
|
defaultScale="cover"
|
|
35
46
|
defaultAspectRatio="auto"
|
|
36
|
-
aspectRatioOptions={
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
aspectRatioOptions={ ASPECT_RATIO_OPTIONS }
|
|
48
|
+
value={ value }
|
|
49
|
+
{ ...props }
|
|
50
|
+
/>
|
|
51
|
+
</ToolsPanel>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function ControlledExample( { value, onChange, ...props } ) {
|
|
56
|
+
return (
|
|
57
|
+
<ToolsPanel
|
|
58
|
+
label="Dimensions"
|
|
59
|
+
panelId="panel-id"
|
|
60
|
+
resetAll={ () => onChange( EMPTY_OBJECT ) }
|
|
61
|
+
>
|
|
62
|
+
<DimensionsTool
|
|
63
|
+
panelId="panel-id"
|
|
64
|
+
onChange={ onChange }
|
|
65
|
+
defaultScale="cover"
|
|
66
|
+
defaultAspectRatio="auto"
|
|
67
|
+
aspectRatioOptions={ ASPECT_RATIO_OPTIONS }
|
|
46
68
|
value={ value }
|
|
47
69
|
{ ...props }
|
|
48
70
|
/>
|
|
@@ -60,6 +82,39 @@ function Example( { initialValue, onChange, ...props } ) {
|
|
|
60
82
|
// properties are treated differently from missing properties.
|
|
61
83
|
|
|
62
84
|
describe( 'DimensionsTool', () => {
|
|
85
|
+
describe( 'controlled values', () => {
|
|
86
|
+
it( 'updates the aspect ratio control when the value prop changes', () => {
|
|
87
|
+
const onChange = jest.fn();
|
|
88
|
+
const { rerender } = render(
|
|
89
|
+
<ControlledExample
|
|
90
|
+
value={ { aspectRatio: '16/9' } }
|
|
91
|
+
onChange={ onChange }
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
const aspectRatioSelect = screen.getByRole( 'combobox', {
|
|
95
|
+
name: 'Aspect ratio',
|
|
96
|
+
} );
|
|
97
|
+
|
|
98
|
+
expect( aspectRatioSelect ).toHaveValue( '16/9' );
|
|
99
|
+
|
|
100
|
+
rerender(
|
|
101
|
+
<ControlledExample
|
|
102
|
+
value={ { aspectRatio: '4/3' } }
|
|
103
|
+
onChange={ onChange }
|
|
104
|
+
/>
|
|
105
|
+
);
|
|
106
|
+
expect( aspectRatioSelect ).toHaveValue( '4/3' );
|
|
107
|
+
|
|
108
|
+
rerender(
|
|
109
|
+
<ControlledExample
|
|
110
|
+
value={ EMPTY_OBJECT }
|
|
111
|
+
onChange={ onChange }
|
|
112
|
+
/>
|
|
113
|
+
);
|
|
114
|
+
expect( aspectRatioSelect ).toHaveValue( 'auto' );
|
|
115
|
+
} );
|
|
116
|
+
} );
|
|
117
|
+
|
|
63
118
|
describe( 'updating aspectRatio', () => {
|
|
64
119
|
it( 'when starting with empty initial state, setting aspectRatio also sets scale (0000) -> (1100)', async () => {
|
|
65
120
|
const user = userEvent.setup();
|
|
@@ -323,7 +378,30 @@ describe( 'DimensionsTool', () => {
|
|
|
323
378
|
} );
|
|
324
379
|
|
|
325
380
|
describe( 'updating scale', () => {
|
|
326
|
-
|
|
381
|
+
it( 'when default scale is cover, setting scale to fill preserves the fill value', async () => {
|
|
382
|
+
const user = userEvent.setup();
|
|
383
|
+
const onChange = jest.fn();
|
|
384
|
+
|
|
385
|
+
const initialValue = {
|
|
386
|
+
aspectRatio: '16/9',
|
|
387
|
+
scale: 'cover',
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
render(
|
|
391
|
+
<Example initialValue={ initialValue } onChange={ onChange } />
|
|
392
|
+
);
|
|
393
|
+
|
|
394
|
+
const scaleFillRadio = screen.getByRole( 'radio', {
|
|
395
|
+
name: 'Fill',
|
|
396
|
+
} );
|
|
397
|
+
|
|
398
|
+
await user.click( scaleFillRadio );
|
|
399
|
+
expect( scaleFillRadio ).toBeChecked();
|
|
400
|
+
|
|
401
|
+
expect( onChange.mock.calls ).toStrictEqual( [
|
|
402
|
+
[ { aspectRatio: '16/9', scale: 'fill' } ],
|
|
403
|
+
] );
|
|
404
|
+
} );
|
|
327
405
|
} );
|
|
328
406
|
|
|
329
407
|
describe( 'updating dimensions', () => {
|