@wordpress/block-editor 15.22.1-next.v.202606191442.0 → 15.22.1
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 +1 -1
- package/README.md +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 +32 -16
- package/build/components/block-inspector/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/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/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 +0 -3
- 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/typography-panel.cjs +82 -10
- package/build/components/global-styles/typography-panel.cjs.map +3 -3
- 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/styles-tab.cjs +75 -31
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/link-control/index.cjs +1 -2
- package/build/components/link-control/index.cjs.map +2 -2
- 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/provider/use-block-sync.cjs +3 -1
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- 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/hooks/anchor.cjs +0 -1
- 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/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/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 +38 -8
- 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/states.cjs +2 -2
- package/build/hooks/states.cjs.map +2 -2
- package/build/hooks/style.cjs +8 -4
- 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/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 +2 -1
- 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-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 +32 -16
- package/build-module/components/block-inspector/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/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/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 +0 -3
- 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/typography-panel.mjs +84 -10
- package/build-module/components/global-styles/typography-panel.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/styles-tab.mjs +75 -31
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/link-control/index.mjs +1 -2
- package/build-module/components/link-control/index.mjs.map +2 -2
- 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/provider/use-block-sync.mjs +3 -1
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- 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/hooks/anchor.mjs +0 -1
- 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/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/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 +41 -8
- 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/states.mjs +2 -2
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/hooks/style.mjs +9 -5
- 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/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 +2 -1
- 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 +40 -39
- 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-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 +20 -10
- 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-vertical-alignment-control/test/__snapshots__/index.js.snap +4 -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/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 +0 -3
- package/src/components/global-styles/hooks.js +45 -0
- 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/inspector-controls/README.md +0 -2
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +74 -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 -17
- 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/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/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 +51 -12
- package/src/hooks/layout.js +6 -3
- package/src/hooks/states.js +2 -2
- package/src/hooks/style.js +11 -7
- package/src/hooks/test/background.js +59 -0
- package/src/hooks/test/block-style-state.js +14 -14
- package/src/hooks/test/layout.js +6 -6
- package/src/hooks/test/style.js +8 -8
- package/src/hooks/typography.js +70 -6
- package/src/layouts/flex.js +118 -15
- package/src/store/test/private-selectors.js +28 -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
|
@@ -1,55 +1,39 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import clsx from 'clsx';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
12
|
-
__experimentalHStack as HStack,
|
|
13
|
-
__experimentalZStack as ZStack,
|
|
14
|
-
__experimentalDropdownContentWrapper as DropdownContentWrapper,
|
|
15
|
-
ColorIndicator,
|
|
16
|
-
Flex,
|
|
17
|
-
FlexItem,
|
|
18
|
-
Dropdown,
|
|
19
|
-
Button,
|
|
20
|
-
privateApis as componentsPrivateApis,
|
|
21
|
-
} from '@wordpress/components';
|
|
22
|
-
import { useMemo, useRef } from '@wordpress/element';
|
|
4
|
+
import { __experimentalToolsPanel as ToolsPanel } from '@wordpress/components';
|
|
5
|
+
import { useCallback, useMemo } from '@wordpress/element';
|
|
23
6
|
import { __ } from '@wordpress/i18n';
|
|
24
|
-
import { getValueFromVariable } from '@wordpress/global-styles-engine';
|
|
25
|
-
import { reset as resetIcon } from '@wordpress/icons';
|
|
26
7
|
|
|
27
8
|
/**
|
|
28
9
|
* Internal dependencies
|
|
29
10
|
*/
|
|
30
|
-
import
|
|
31
|
-
import {
|
|
11
|
+
import ColorGradientDropdownItem from './color-gradient-dropdown-item';
|
|
12
|
+
import {
|
|
13
|
+
useColorsPerOrigin,
|
|
14
|
+
useGradientsPerOrigin,
|
|
15
|
+
useColorGradientSettings,
|
|
16
|
+
} from './hooks';
|
|
32
17
|
import { useToolsPanelDropdownMenuProps } from './utils';
|
|
33
18
|
import { setImmutably } from '../../utils/object';
|
|
34
|
-
import {
|
|
35
|
-
|
|
36
|
-
|
|
19
|
+
import {
|
|
20
|
+
extractPresetSlug,
|
|
21
|
+
encodeColorValueWithPalette,
|
|
22
|
+
} from '../../utils/color-values';
|
|
23
|
+
|
|
24
|
+
// Despite the "ColorPanel" name, this gates only the element-level color
|
|
25
|
+
// controls (link, heading, button, caption, h1–h6) — surfaced as the
|
|
26
|
+
// "Elements" panel in the block inspector and the "Colors" screen in
|
|
27
|
+
// Global Styles. Top-level text and background color moved to the
|
|
28
|
+
// Typography and Background panels, so this returns false for blocks
|
|
29
|
+
// whose only color support is text and/or background.
|
|
37
30
|
export function useHasColorPanel( settings ) {
|
|
38
|
-
const hasTextPanel = useHasTextPanel( settings );
|
|
39
|
-
const hasBackgroundPanel = useHasBackgroundColorPanel( settings );
|
|
40
31
|
const hasLinkPanel = useHasLinkPanel( settings );
|
|
41
32
|
const hasHeadingPanel = useHasHeadingPanel( settings );
|
|
42
33
|
const hasButtonPanel = useHasButtonPanel( settings );
|
|
43
34
|
const hasCaptionPanel = useHasCaptionPanel( settings );
|
|
44
35
|
|
|
45
|
-
return
|
|
46
|
-
hasTextPanel ||
|
|
47
|
-
hasBackgroundPanel ||
|
|
48
|
-
hasLinkPanel ||
|
|
49
|
-
hasHeadingPanel ||
|
|
50
|
-
hasButtonPanel ||
|
|
51
|
-
hasCaptionPanel
|
|
52
|
-
);
|
|
36
|
+
return hasLinkPanel || hasHeadingPanel || hasButtonPanel || hasCaptionPanel;
|
|
53
37
|
}
|
|
54
38
|
|
|
55
39
|
export function useHasTextPanel( settings ) {
|
|
@@ -145,205 +129,13 @@ export function ColorToolsPanel( {
|
|
|
145
129
|
);
|
|
146
130
|
}
|
|
147
131
|
|
|
148
|
-
/**
|
|
149
|
-
* Encodes a color value for storage in the style object.
|
|
150
|
-
*
|
|
151
|
-
* When a `slug` is provided it is used directly (slug-based selection path).
|
|
152
|
-
* Otherwise the function falls back to looking up the hex value in the
|
|
153
|
-
* palette; if found it encodes the slug, otherwise it stores the raw hex.
|
|
154
|
-
*
|
|
155
|
-
* Extracted to module scope so it is not re-created on every render.
|
|
156
|
-
* Callers pass the flattened palette (`allColors`), computed once in `ColorPanel` from the per-origin `colors` array.
|
|
157
|
-
*
|
|
158
|
-
* @param {Array} allColors Flat array of `{ color, slug }` objects.
|
|
159
|
-
* @param {string|void} colorValue Hex or CSS color string.
|
|
160
|
-
* @param {string|void} slug Optional palette slug from slug-aware selection.
|
|
161
|
-
* @return {string|void} Encoded value suitable for the style object.
|
|
162
|
-
*/
|
|
163
|
-
function encodeColorValueWithPalette( allColors, colorValue, slug ) {
|
|
164
|
-
if ( slug ) {
|
|
165
|
-
return 'var:preset|color|' + slug;
|
|
166
|
-
}
|
|
167
|
-
const colorObject = allColors.find( ( { color } ) => color === colorValue );
|
|
168
|
-
return colorObject ? 'var:preset|color|' + colorObject.slug : colorValue;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
132
|
const DEFAULT_CONTROLS = {
|
|
172
|
-
text: true,
|
|
173
|
-
background: true,
|
|
174
133
|
link: true,
|
|
175
134
|
heading: true,
|
|
176
135
|
button: true,
|
|
177
136
|
caption: true,
|
|
178
137
|
};
|
|
179
138
|
|
|
180
|
-
const popoverProps = {
|
|
181
|
-
placement: 'left-start',
|
|
182
|
-
offset: 36,
|
|
183
|
-
shift: true,
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
const { Tabs } = unlock( componentsPrivateApis );
|
|
187
|
-
|
|
188
|
-
const LabeledColorIndicators = ( { indicators, label } ) => (
|
|
189
|
-
<HStack justify="flex-start">
|
|
190
|
-
<ZStack isLayered={ false } offset={ -8 }>
|
|
191
|
-
{ indicators.map( ( indicator, index ) => (
|
|
192
|
-
<Flex key={ index } expanded={ false }>
|
|
193
|
-
<ColorIndicator colorValue={ indicator } />
|
|
194
|
-
</Flex>
|
|
195
|
-
) ) }
|
|
196
|
-
</ZStack>
|
|
197
|
-
<FlexItem className="block-editor-panel-color-gradient-settings__color-name">
|
|
198
|
-
{ label }
|
|
199
|
-
</FlexItem>
|
|
200
|
-
</HStack>
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
function ColorPanelTab( {
|
|
204
|
-
isGradient,
|
|
205
|
-
inheritedValue,
|
|
206
|
-
inheritedSlug,
|
|
207
|
-
userValue,
|
|
208
|
-
setValue,
|
|
209
|
-
colorGradientControlSettings,
|
|
210
|
-
} ) {
|
|
211
|
-
return (
|
|
212
|
-
<ColorGradientControl
|
|
213
|
-
{ ...colorGradientControlSettings }
|
|
214
|
-
showTitle={ false }
|
|
215
|
-
enableAlpha
|
|
216
|
-
__experimentalIsRenderedInSidebar
|
|
217
|
-
colorValue={ isGradient ? undefined : inheritedValue }
|
|
218
|
-
colorSlug={ isGradient ? undefined : inheritedSlug }
|
|
219
|
-
gradientValue={ isGradient ? inheritedValue : undefined }
|
|
220
|
-
onColorChange={ isGradient ? undefined : setValue }
|
|
221
|
-
onGradientChange={ isGradient ? setValue : undefined }
|
|
222
|
-
clearable={ inheritedValue === userValue }
|
|
223
|
-
headingLevel={ 3 }
|
|
224
|
-
/>
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
export function ColorPanelDropdown( {
|
|
229
|
-
label,
|
|
230
|
-
hasValue,
|
|
231
|
-
resetValue,
|
|
232
|
-
isShownByDefault,
|
|
233
|
-
indicators,
|
|
234
|
-
tabs,
|
|
235
|
-
colorGradientControlSettings,
|
|
236
|
-
panelId,
|
|
237
|
-
className = 'block-editor-tools-panel-color-gradient-settings__item',
|
|
238
|
-
} ) {
|
|
239
|
-
const currentTab = tabs.find( ( tab ) => tab.userValue !== undefined );
|
|
240
|
-
const { key: firstTabKey, ...firstTab } = tabs[ 0 ] ?? {};
|
|
241
|
-
const colorGradientDropdownButtonRef = useRef( undefined );
|
|
242
|
-
return (
|
|
243
|
-
<ToolsPanelItem
|
|
244
|
-
className={ className }
|
|
245
|
-
hasValue={ hasValue }
|
|
246
|
-
label={ label }
|
|
247
|
-
onDeselect={ resetValue }
|
|
248
|
-
isShownByDefault={ isShownByDefault }
|
|
249
|
-
panelId={ panelId }
|
|
250
|
-
>
|
|
251
|
-
<Dropdown
|
|
252
|
-
popoverProps={ popoverProps }
|
|
253
|
-
className="block-editor-tools-panel-color-gradient-settings__dropdown"
|
|
254
|
-
renderToggle={ ( { onToggle, isOpen } ) => {
|
|
255
|
-
const toggleProps = {
|
|
256
|
-
onClick: onToggle,
|
|
257
|
-
className: clsx(
|
|
258
|
-
'block-editor-panel-color-gradient-settings__dropdown',
|
|
259
|
-
{ 'is-open': isOpen }
|
|
260
|
-
),
|
|
261
|
-
'aria-expanded': isOpen,
|
|
262
|
-
ref: colorGradientDropdownButtonRef,
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
return (
|
|
266
|
-
<>
|
|
267
|
-
<Button { ...toggleProps } __next40pxDefaultSize>
|
|
268
|
-
<LabeledColorIndicators
|
|
269
|
-
indicators={ indicators }
|
|
270
|
-
label={ label }
|
|
271
|
-
/>
|
|
272
|
-
</Button>
|
|
273
|
-
{ hasValue() && (
|
|
274
|
-
<Button
|
|
275
|
-
__next40pxDefaultSize
|
|
276
|
-
label={ __( 'Reset' ) }
|
|
277
|
-
className="block-editor-panel-color-gradient-settings__reset"
|
|
278
|
-
size="small"
|
|
279
|
-
icon={ resetIcon }
|
|
280
|
-
onClick={ () => {
|
|
281
|
-
resetValue();
|
|
282
|
-
if ( isOpen ) {
|
|
283
|
-
onToggle();
|
|
284
|
-
}
|
|
285
|
-
// Return focus to parent button
|
|
286
|
-
colorGradientDropdownButtonRef.current?.focus();
|
|
287
|
-
} }
|
|
288
|
-
/>
|
|
289
|
-
) }
|
|
290
|
-
</>
|
|
291
|
-
);
|
|
292
|
-
} }
|
|
293
|
-
renderContent={ () => (
|
|
294
|
-
<DropdownContentWrapper paddingSize="none">
|
|
295
|
-
<div className="block-editor-panel-color-gradient-settings__dropdown-content">
|
|
296
|
-
{ tabs.length === 1 && (
|
|
297
|
-
<ColorPanelTab
|
|
298
|
-
key={ firstTabKey }
|
|
299
|
-
{ ...firstTab }
|
|
300
|
-
colorGradientControlSettings={
|
|
301
|
-
colorGradientControlSettings
|
|
302
|
-
}
|
|
303
|
-
/>
|
|
304
|
-
) }
|
|
305
|
-
{ tabs.length > 1 && (
|
|
306
|
-
<Tabs defaultTabId={ currentTab?.key }>
|
|
307
|
-
<Tabs.TabList>
|
|
308
|
-
{ tabs.map( ( tab ) => (
|
|
309
|
-
<Tabs.Tab
|
|
310
|
-
key={ tab.key }
|
|
311
|
-
tabId={ tab.key }
|
|
312
|
-
>
|
|
313
|
-
{ tab.label }
|
|
314
|
-
</Tabs.Tab>
|
|
315
|
-
) ) }
|
|
316
|
-
</Tabs.TabList>
|
|
317
|
-
|
|
318
|
-
{ tabs.map( ( tab ) => {
|
|
319
|
-
const { key: tabKey, ...restTabProps } =
|
|
320
|
-
tab;
|
|
321
|
-
return (
|
|
322
|
-
<Tabs.TabPanel
|
|
323
|
-
key={ tabKey }
|
|
324
|
-
tabId={ tabKey }
|
|
325
|
-
focusable={ false }
|
|
326
|
-
>
|
|
327
|
-
<ColorPanelTab
|
|
328
|
-
key={ tabKey }
|
|
329
|
-
{ ...restTabProps }
|
|
330
|
-
colorGradientControlSettings={
|
|
331
|
-
colorGradientControlSettings
|
|
332
|
-
}
|
|
333
|
-
/>
|
|
334
|
-
</Tabs.TabPanel>
|
|
335
|
-
);
|
|
336
|
-
} ) }
|
|
337
|
-
</Tabs>
|
|
338
|
-
) }
|
|
339
|
-
</div>
|
|
340
|
-
</DropdownContentWrapper>
|
|
341
|
-
) }
|
|
342
|
-
/>
|
|
343
|
-
</ToolsPanelItem>
|
|
344
|
-
);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
139
|
export default function ColorPanel( {
|
|
348
140
|
as: Wrapper = ColorToolsPanel,
|
|
349
141
|
value,
|
|
@@ -354,80 +146,19 @@ export default function ColorPanel( {
|
|
|
354
146
|
defaultControls = DEFAULT_CONTROLS,
|
|
355
147
|
label,
|
|
356
148
|
children,
|
|
149
|
+
contrastWarning,
|
|
357
150
|
} ) {
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
hasGradientColors && ! hasBackgroundGradientSupport;
|
|
370
|
-
|
|
371
|
-
const decodeValue = ( rawValue ) =>
|
|
372
|
-
getValueFromVariable( { settings }, '', rawValue );
|
|
373
|
-
|
|
374
|
-
const allColors = useMemo(
|
|
375
|
-
() => colors.flatMap( ( { colors: originColors } ) => originColors ),
|
|
376
|
-
[ colors ]
|
|
377
|
-
);
|
|
378
|
-
|
|
379
|
-
const encodeGradientValue = ( gradientValue ) => {
|
|
380
|
-
const allGradients = gradients.flatMap(
|
|
381
|
-
( { gradients: originGradients } ) => originGradients
|
|
382
|
-
);
|
|
383
|
-
const gradientObject = allGradients.find(
|
|
384
|
-
( { gradient } ) => gradient === gradientValue
|
|
385
|
-
);
|
|
386
|
-
return gradientObject
|
|
387
|
-
? 'var:preset|gradient|' + gradientObject.slug
|
|
388
|
-
: gradientValue;
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
// BackgroundColor
|
|
392
|
-
const showBackgroundPanel = useHasBackgroundColorPanel( settings );
|
|
393
|
-
const backgroundColor = decodeValue( inheritedValue?.color?.background );
|
|
394
|
-
const userBackgroundColor = decodeValue( value?.color?.background );
|
|
395
|
-
const gradient = decodeValue( inheritedValue?.color?.gradient );
|
|
396
|
-
const userGradient = decodeValue( value?.color?.gradient );
|
|
397
|
-
const hasBackground = () =>
|
|
398
|
-
!! userBackgroundColor ||
|
|
399
|
-
( ! hasBackgroundGradientSupport && !! userGradient );
|
|
400
|
-
const setBackgroundColor = ( newColor, newSlug ) => {
|
|
401
|
-
const newValue = setImmutably(
|
|
402
|
-
value,
|
|
403
|
-
[ 'color', 'background' ],
|
|
404
|
-
encodeColorValueWithPalette( allColors, newColor, newSlug )
|
|
405
|
-
);
|
|
406
|
-
if ( ! hasBackgroundGradientSupport ) {
|
|
407
|
-
newValue.color.gradient = undefined;
|
|
408
|
-
}
|
|
409
|
-
onChange( newValue );
|
|
410
|
-
};
|
|
411
|
-
const setGradient = ( newGradient ) => {
|
|
412
|
-
const newValue = setImmutably(
|
|
413
|
-
value,
|
|
414
|
-
[ 'color', 'gradient' ],
|
|
415
|
-
encodeGradientValue( newGradient )
|
|
416
|
-
);
|
|
417
|
-
newValue.color.background = undefined;
|
|
418
|
-
onChange( newValue );
|
|
419
|
-
};
|
|
420
|
-
const resetBackground = () => {
|
|
421
|
-
const newValue = setImmutably(
|
|
422
|
-
value,
|
|
423
|
-
[ 'color', 'background' ],
|
|
424
|
-
undefined
|
|
425
|
-
);
|
|
426
|
-
if ( ! hasBackgroundGradientSupport ) {
|
|
427
|
-
newValue.color.gradient = undefined;
|
|
428
|
-
}
|
|
429
|
-
onChange( newValue );
|
|
430
|
-
};
|
|
151
|
+
const {
|
|
152
|
+
colors,
|
|
153
|
+
gradients,
|
|
154
|
+
areCustomSolidsEnabled,
|
|
155
|
+
areCustomGradientsEnabled,
|
|
156
|
+
hasSolidColors,
|
|
157
|
+
hasGradientColors,
|
|
158
|
+
allColors,
|
|
159
|
+
decodeValue,
|
|
160
|
+
encodeGradientValue,
|
|
161
|
+
} = useColorGradientSettings( settings );
|
|
431
162
|
|
|
432
163
|
// Links
|
|
433
164
|
const showLinkPanel = useHasLinkPanel( settings );
|
|
@@ -474,178 +205,91 @@ export default function ColorPanel( {
|
|
|
474
205
|
onChange( newValue );
|
|
475
206
|
};
|
|
476
207
|
|
|
477
|
-
// Text Color
|
|
478
|
-
const showTextPanel = useHasTextPanel( settings );
|
|
479
208
|
const showCaptionPanel = useHasCaptionPanel( settings );
|
|
480
209
|
const showButtonPanel = useHasButtonPanel( settings );
|
|
481
210
|
const showHeadingPanel = useHasHeadingPanel( settings );
|
|
482
|
-
const textColor = decodeValue( inheritedValue?.color?.text );
|
|
483
|
-
const userTextColor = decodeValue( value?.color?.text );
|
|
484
|
-
const hasTextColor = () => !! userTextColor;
|
|
485
|
-
const setTextColor = ( newColor, newSlug ) => {
|
|
486
|
-
let changedObject = setImmutably(
|
|
487
|
-
value,
|
|
488
|
-
[ 'color', 'text' ],
|
|
489
|
-
encodeColorValueWithPalette( allColors, newColor, newSlug )
|
|
490
|
-
);
|
|
491
|
-
// Compare raw encoded references (e.g. `var:preset|color|slug`), not
|
|
492
|
-
// decoded hex values. Two palette entries can share the same hex but
|
|
493
|
-
// carry different slugs (e.g. `var:preset|color|dark-background` and
|
|
494
|
-
// `var:preset|color|dark-text` both resolving to `#000`); comparing decoded
|
|
495
|
-
// values would conflate them and incorrectly force the link color to
|
|
496
|
-
// follow the text color even when the user deliberately chose a
|
|
497
|
-
// different palette slot.
|
|
498
|
-
//
|
|
499
|
-
// Note: this is stricter than the previous decoded comparison.
|
|
500
|
-
// If text and link were stored in different formats that resolved to
|
|
501
|
-
// the same hex (e.g. one as `var:preset|color|x` and the other as
|
|
502
|
-
// `var(--wp--preset--color--x)`), the old check would sync them
|
|
503
|
-
// and this one will not. In practice this should not arise because
|
|
504
|
-
// both values are written through the same encoding path.
|
|
505
|
-
if (
|
|
506
|
-
inheritedValue?.color?.text ===
|
|
507
|
-
inheritedValue?.elements?.link?.color?.text
|
|
508
|
-
) {
|
|
509
|
-
changedObject = setImmutably(
|
|
510
|
-
changedObject,
|
|
511
|
-
[ 'elements', 'link', 'color', 'text' ],
|
|
512
|
-
encodeColorValueWithPalette( allColors, newColor, newSlug )
|
|
513
|
-
);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
onChange( changedObject );
|
|
517
|
-
};
|
|
518
|
-
const resetTextColor = () => setTextColor( undefined );
|
|
519
211
|
|
|
520
212
|
// Elements
|
|
521
|
-
const elements =
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
213
|
+
const elements = useMemo(
|
|
214
|
+
() => [
|
|
215
|
+
{
|
|
216
|
+
name: 'caption',
|
|
217
|
+
label: __( 'Captions' ),
|
|
218
|
+
showPanel: showCaptionPanel,
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
name: 'button',
|
|
222
|
+
label: __( 'Button' ),
|
|
223
|
+
showPanel: showButtonPanel,
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
name: 'heading',
|
|
227
|
+
label: __( 'Heading' ),
|
|
228
|
+
showPanel: showHeadingPanel,
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: 'h1',
|
|
232
|
+
label: __( 'H1' ),
|
|
233
|
+
showPanel: showHeadingPanel,
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: 'h2',
|
|
237
|
+
label: __( 'H2' ),
|
|
238
|
+
showPanel: showHeadingPanel,
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: 'h3',
|
|
242
|
+
label: __( 'H3' ),
|
|
243
|
+
showPanel: showHeadingPanel,
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: 'h4',
|
|
247
|
+
label: __( 'H4' ),
|
|
248
|
+
showPanel: showHeadingPanel,
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
name: 'h5',
|
|
252
|
+
label: __( 'H5' ),
|
|
253
|
+
showPanel: showHeadingPanel,
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
name: 'h6',
|
|
257
|
+
label: __( 'H6' ),
|
|
258
|
+
showPanel: showHeadingPanel,
|
|
259
|
+
},
|
|
260
|
+
],
|
|
261
|
+
[ showCaptionPanel, showButtonPanel, showHeadingPanel ]
|
|
262
|
+
);
|
|
568
263
|
|
|
569
|
-
const resetAllFilter = (
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
color: undefined,
|
|
578
|
-
':hover': {
|
|
264
|
+
const resetAllFilter = useCallback(
|
|
265
|
+
( previousValue ) => {
|
|
266
|
+
return {
|
|
267
|
+
...previousValue,
|
|
268
|
+
elements: {
|
|
269
|
+
...previousValue?.elements,
|
|
270
|
+
link: {
|
|
271
|
+
...previousValue?.elements?.link,
|
|
579
272
|
color: undefined,
|
|
580
|
-
|
|
581
|
-
},
|
|
582
|
-
...elements.reduce( ( acc, element ) => {
|
|
583
|
-
return {
|
|
584
|
-
...acc,
|
|
585
|
-
[ element.name ]: {
|
|
586
|
-
...previousValue?.elements?.[ element.name ],
|
|
273
|
+
':hover': {
|
|
587
274
|
color: undefined,
|
|
588
275
|
},
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
hasValue: hasTextColor,
|
|
600
|
-
resetValue: resetTextColor,
|
|
601
|
-
isShownByDefault: defaultControls.text,
|
|
602
|
-
indicators: [ textColor ],
|
|
603
|
-
tabs: [
|
|
604
|
-
{
|
|
605
|
-
key: 'text',
|
|
606
|
-
label: __( 'Text' ),
|
|
607
|
-
inheritedValue: textColor,
|
|
608
|
-
inheritedSlug: extractPresetSlug(
|
|
609
|
-
inheritedValue?.color?.text,
|
|
610
|
-
'color'
|
|
611
|
-
),
|
|
612
|
-
setValue: setTextColor,
|
|
613
|
-
userValue: userTextColor,
|
|
614
|
-
},
|
|
615
|
-
],
|
|
616
|
-
},
|
|
617
|
-
showBackgroundPanel && {
|
|
618
|
-
key: 'background',
|
|
619
|
-
label: __( 'Background' ),
|
|
620
|
-
hasValue: hasBackground,
|
|
621
|
-
resetValue: resetBackground,
|
|
622
|
-
isShownByDefault: defaultControls.background,
|
|
623
|
-
indicators: [
|
|
624
|
-
( showGradientColors ? gradient : undefined ) ??
|
|
625
|
-
backgroundColor,
|
|
626
|
-
],
|
|
627
|
-
tabs: [
|
|
628
|
-
hasSolidColors && {
|
|
629
|
-
key: 'background',
|
|
630
|
-
label: __( 'Color' ),
|
|
631
|
-
inheritedValue: backgroundColor,
|
|
632
|
-
inheritedSlug: extractPresetSlug(
|
|
633
|
-
inheritedValue?.color?.background,
|
|
634
|
-
'color'
|
|
635
|
-
),
|
|
636
|
-
setValue: setBackgroundColor,
|
|
637
|
-
userValue: userBackgroundColor,
|
|
638
|
-
},
|
|
639
|
-
showGradientColors && {
|
|
640
|
-
key: 'gradient',
|
|
641
|
-
label: __( 'Gradient' ),
|
|
642
|
-
inheritedValue: gradient,
|
|
643
|
-
setValue: setGradient,
|
|
644
|
-
userValue: userGradient,
|
|
645
|
-
isGradient: true,
|
|
276
|
+
},
|
|
277
|
+
...elements.reduce( ( acc, element ) => {
|
|
278
|
+
return {
|
|
279
|
+
...acc,
|
|
280
|
+
[ element.name ]: {
|
|
281
|
+
...previousValue?.elements?.[ element.name ],
|
|
282
|
+
color: undefined,
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
}, {} ),
|
|
646
286
|
},
|
|
647
|
-
|
|
287
|
+
};
|
|
648
288
|
},
|
|
289
|
+
[ elements ]
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
const items = [
|
|
649
293
|
showLinkPanel && {
|
|
650
294
|
key: 'link',
|
|
651
295
|
label: __( 'Link' ),
|
|
@@ -653,6 +297,7 @@ export default function ColorPanel( {
|
|
|
653
297
|
resetValue: resetLink,
|
|
654
298
|
isShownByDefault: defaultControls.link,
|
|
655
299
|
indicators: [ linkColor, hoverLinkColor ],
|
|
300
|
+
contrastWarning,
|
|
656
301
|
tabs: [
|
|
657
302
|
{
|
|
658
303
|
key: 'link',
|
|
@@ -756,7 +401,6 @@ export default function ColorPanel( {
|
|
|
756
401
|
newValue.elements[ name ].color.background = undefined;
|
|
757
402
|
onChange( newValue );
|
|
758
403
|
};
|
|
759
|
-
const supportsTextColor = true;
|
|
760
404
|
// Background color is not supported for `caption`
|
|
761
405
|
// as there isn't yet a way to set padding for the element.
|
|
762
406
|
const supportsBackground = name !== 'caption';
|
|
@@ -767,30 +411,24 @@ export default function ColorPanel( {
|
|
|
767
411
|
hasValue: hasElement,
|
|
768
412
|
resetValue: resetElement,
|
|
769
413
|
isShownByDefault: defaultControls[ name ],
|
|
770
|
-
indicators:
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
: [
|
|
777
|
-
supportsTextColor
|
|
778
|
-
? elementTextColor
|
|
779
|
-
: elementGradient ?? elementBackgroundColor,
|
|
780
|
-
],
|
|
414
|
+
indicators: supportsBackground
|
|
415
|
+
? [
|
|
416
|
+
elementTextColor,
|
|
417
|
+
elementGradient ?? elementBackgroundColor,
|
|
418
|
+
]
|
|
419
|
+
: [ elementTextColor ],
|
|
781
420
|
tabs: [
|
|
782
|
-
hasSolidColors &&
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
},
|
|
421
|
+
hasSolidColors && {
|
|
422
|
+
key: 'text',
|
|
423
|
+
label: __( 'Text' ),
|
|
424
|
+
inheritedValue: elementTextColor,
|
|
425
|
+
inheritedSlug: extractPresetSlug(
|
|
426
|
+
inheritedValue?.elements?.[ name ]?.color?.text,
|
|
427
|
+
'color'
|
|
428
|
+
),
|
|
429
|
+
setValue: setElementTextColor,
|
|
430
|
+
userValue: elementTextUserColor,
|
|
431
|
+
},
|
|
794
432
|
hasSolidColors &&
|
|
795
433
|
supportsBackground && {
|
|
796
434
|
key: 'background',
|
|
@@ -828,7 +466,7 @@ export default function ColorPanel( {
|
|
|
828
466
|
{ items.map( ( item ) => {
|
|
829
467
|
const { key, ...restItem } = item;
|
|
830
468
|
return (
|
|
831
|
-
<
|
|
469
|
+
<ColorGradientDropdownItem
|
|
832
470
|
key={ key }
|
|
833
471
|
{ ...restItem }
|
|
834
472
|
colorGradientControlSettings={ {
|