@wordpress/block-editor 15.19.1-next.v.202605131006.0 → 15.20.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 +15 -1
- package/build/components/block-card/index.cjs +51 -41
- package/build/components/block-card/index.cjs.map +3 -3
- package/build/components/block-heading-level-dropdown/heading-level-icon.cjs.map +3 -3
- package/build/components/block-icon/index.cjs +7 -1
- package/build/components/block-icon/index.cjs.map +3 -3
- package/build/components/block-inspector/index.cjs +156 -11
- package/build/components/block-inspector/index.cjs.map +3 -3
- package/build/components/block-inspector/inspector-pre-tabs-slot-fill.cjs +38 -0
- package/build/components/block-inspector/inspector-pre-tabs-slot-fill.cjs.map +7 -0
- package/build/components/block-list/use-block-props/index.cjs +1 -1
- package/build/components/block-list/use-block-props/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-focus-handler.cjs +3 -4
- package/build/components/block-list/use-block-props/use-focus-handler.cjs.map +3 -3
- package/build/components/block-list/use-block-props/use-is-hovered.cjs +24 -14
- package/build/components/block-list/use-block-props/use-is-hovered.cjs.map +3 -3
- package/build/components/block-lock/modal.cjs.map +3 -3
- package/build/components/block-patterns-list/index.cjs +13 -2
- package/build/components/block-patterns-list/index.cjs.map +2 -2
- package/build/components/block-popover/index.cjs +13 -3
- package/build/components/block-popover/index.cjs.map +2 -2
- package/build/components/block-toolbar/switch-section-style.cjs.map +3 -3
- package/build/components/block-visibility/modal.cjs.map +3 -3
- package/build/components/block-visibility/viewport-visibility-info.cjs.map +3 -3
- package/build/components/colors-gradients/control.cjs +7 -4
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/global-styles/advanced-panel.cjs +24 -22
- package/build/components/global-styles/advanced-panel.cjs.map +3 -3
- package/build/components/global-styles/color-panel.cjs +95 -58
- package/build/components/global-styles/color-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +11 -5
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/index.cjs +3 -0
- package/build/components/global-styles/index.cjs.map +2 -2
- package/build/components/global-styles/shadow-panel-components.cjs +38 -26
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/global-styles/state-control-badges.cjs +69 -0
- package/build/components/global-styles/state-control-badges.cjs.map +7 -0
- package/build/components/global-styles/state-control.cjs +54 -63
- package/build/components/global-styles/state-control.cjs.map +3 -3
- package/build/components/iframe/index.cjs +0 -3
- package/build/components/iframe/index.cjs.map +2 -2
- package/build/components/iframe/use-scale-canvas.cjs +4 -1
- package/build/components/iframe/use-scale-canvas.cjs.map +2 -2
- package/build/components/inserter/hooks/use-patterns-state.cjs +4 -6
- package/build/components/inserter/hooks/use-patterns-state.cjs.map +2 -2
- package/build/components/inserter/index.cjs +1 -0
- package/build/components/inserter/index.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-preview.cjs +27 -18
- package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
- package/build/components/inserter/media-tab/utils.cjs +1 -1
- package/build/components/inserter/media-tab/utils.cjs.map +2 -2
- package/build/components/inserter/panel.cjs.map +3 -3
- package/build/components/inspector-controls/block-support-tools-panel.cjs +10 -2
- package/build/components/inspector-controls/block-support-tools-panel.cjs.map +2 -2
- package/build/components/inspector-controls/fill.cjs +14 -4
- 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 +13 -8
- package/build/components/inspector-controls-tabs/index.cjs.map +3 -3
- package/build/components/inspector-controls-tabs/settings-tab.cjs +1 -4
- package/build/components/inspector-controls-tabs/settings-tab.cjs.map +3 -3
- package/build/components/inspector-controls-tabs/styles-tab.cjs +9 -0
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +3 -3
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs +11 -5
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs.map +2 -2
- package/build/components/list-view/block-select-button.cjs +20 -8
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +2 -1
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/components/preset-input-control/custom-value-controls.cjs +10 -1
- package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
- package/build/components/preset-input-control/index.cjs.map +3 -3
- package/build/components/provider/use-media-upload-settings.cjs +1 -0
- package/build/components/provider/use-media-upload-settings.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/enter.cjs +9 -2
- package/build/components/rich-text/event-listeners/enter.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/paste-handler.cjs +4 -4
- package/build/components/rich-text/event-listeners/paste-handler.cjs.map +3 -3
- package/build/hooks/background.cjs +13 -3
- package/build/hooks/background.cjs.map +2 -2
- package/build/hooks/block-fields/link/index.cjs.map +3 -3
- package/build/hooks/block-fields/media/index.cjs.map +3 -3
- package/build/hooks/block-style-state.cjs +112 -0
- package/build/hooks/block-style-state.cjs.map +7 -0
- package/build/hooks/border.cjs +13 -3
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/color.cjs +28 -9
- package/build/hooks/color.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +15 -6
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +147 -61
- package/build/hooks/layout-child.cjs.map +2 -2
- package/build/hooks/layout.cjs +263 -56
- package/build/hooks/layout.cjs.map +3 -3
- package/build/hooks/state-utils.cjs +94 -0
- package/build/hooks/state-utils.cjs.map +7 -0
- package/build/hooks/states.cjs +124 -0
- package/build/hooks/states.cjs.map +7 -0
- package/build/hooks/style.cjs +304 -17
- package/build/hooks/style.cjs.map +3 -3
- package/build/hooks/typography.cjs +14 -5
- package/build/hooks/typography.cjs.map +2 -2
- package/build/layouts/constrained.cjs +128 -55
- package/build/layouts/constrained.cjs.map +3 -3
- package/build/layouts/flex.cjs +119 -31
- package/build/layouts/flex.cjs.map +3 -3
- package/build/layouts/grid.cjs +103 -40
- package/build/layouts/grid.cjs.map +3 -3
- package/build/private-apis.cjs +2 -0
- package/build/private-apis.cjs.map +2 -2
- package/build/store/private-actions.cjs +18 -0
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-keys.cjs +10 -2
- package/build/store/private-keys.cjs.map +2 -2
- package/build/store/private-selectors.cjs +26 -2
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +70 -1
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/utils.cjs +1 -1
- package/build/store/utils.cjs.map +2 -2
- package/build/utils/color-values.cjs +44 -0
- package/build/utils/color-values.cjs.map +7 -0
- package/build-module/components/block-card/index.mjs +52 -45
- package/build-module/components/block-card/index.mjs.map +2 -2
- package/build-module/components/block-heading-level-dropdown/heading-level-icon.mjs +2 -2
- package/build-module/components/block-heading-level-dropdown/heading-level-icon.mjs.map +2 -2
- package/build-module/components/block-icon/index.mjs +8 -2
- package/build-module/components/block-icon/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +166 -13
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-inspector/inspector-pre-tabs-slot-fill.mjs +12 -0
- package/build-module/components/block-inspector/inspector-pre-tabs-slot-fill.mjs.map +7 -0
- package/build-module/components/block-list/use-block-props/index.mjs +1 -1
- package/build-module/components/block-list/use-block-props/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-focus-handler.mjs +7 -5
- package/build-module/components/block-list/use-block-props/use-focus-handler.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-is-hovered.mjs +28 -15
- package/build-module/components/block-list/use-block-props/use-is-hovered.mjs.map +2 -2
- package/build-module/components/block-lock/modal.mjs +4 -4
- package/build-module/components/block-lock/modal.mjs.map +2 -2
- package/build-module/components/block-patterns-list/index.mjs +14 -4
- package/build-module/components/block-patterns-list/index.mjs.map +2 -2
- package/build-module/components/block-popover/index.mjs +13 -3
- package/build-module/components/block-popover/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/switch-section-style.mjs +2 -2
- package/build-module/components/block-toolbar/switch-section-style.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +2 -2
- package/build-module/components/block-visibility/modal.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-visibility-info.mjs +2 -2
- package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +7 -4
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/global-styles/advanced-panel.mjs +25 -27
- package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-panel.mjs +96 -59
- package/build-module/components/global-styles/color-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +14 -5
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/index.mjs +2 -0
- package/build-module/components/global-styles/index.mjs.map +2 -2
- package/build-module/components/global-styles/shadow-panel-components.mjs +39 -28
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/global-styles/state-control-badges.mjs +48 -0
- package/build-module/components/global-styles/state-control-badges.mjs.map +7 -0
- package/build-module/components/global-styles/state-control.mjs +57 -71
- package/build-module/components/global-styles/state-control.mjs.map +2 -2
- package/build-module/components/iframe/index.mjs +0 -3
- package/build-module/components/iframe/index.mjs.map +2 -2
- package/build-module/components/iframe/use-scale-canvas.mjs +4 -1
- package/build-module/components/iframe/use-scale-canvas.mjs.map +2 -2
- package/build-module/components/inserter/hooks/use-patterns-state.mjs +8 -7
- package/build-module/components/inserter/hooks/use-patterns-state.mjs.map +2 -2
- package/build-module/components/inserter/index.mjs +1 -0
- package/build-module/components/inserter/index.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-preview.mjs +27 -19
- package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/utils.mjs +1 -1
- package/build-module/components/inserter/media-tab/utils.mjs.map +2 -2
- package/build-module/components/inserter/panel.mjs +2 -2
- package/build-module/components/inserter/panel.mjs.map +2 -2
- package/build-module/components/inspector-controls/block-support-tools-panel.mjs +10 -2
- package/build-module/components/inspector-controls/block-support-tools-panel.mjs.map +2 -2
- package/build-module/components/inspector-controls/fill.mjs +18 -5
- 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 +14 -10
- package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/settings-tab.mjs +1 -4
- package/build-module/components/inspector-controls-tabs/settings-tab.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +9 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs +11 -5
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +20 -9
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +2 -1
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/preset-input-control/custom-value-controls.mjs +10 -2
- package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
- package/build-module/components/preset-input-control/index.mjs +2 -2
- package/build-module/components/preset-input-control/index.mjs.map +2 -2
- package/build-module/components/provider/use-media-upload-settings.mjs +1 -0
- package/build-module/components/provider/use-media-upload-settings.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +9 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +2 -2
- package/build-module/hooks/background.mjs +18 -3
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/block-fields/link/index.mjs +3 -3
- package/build-module/hooks/block-fields/link/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/media/index.mjs +3 -3
- package/build-module/hooks/block-fields/media/index.mjs.map +2 -2
- package/build-module/hooks/block-style-state.mjs +79 -0
- package/build-module/hooks/block-style-state.mjs.map +7 -0
- package/build-module/hooks/border.mjs +18 -3
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/color.mjs +33 -9
- package/build-module/hooks/color.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +20 -6
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +141 -61
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +270 -58
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/state-utils.mjs +64 -0
- package/build-module/hooks/state-utils.mjs.map +7 -0
- package/build-module/hooks/states.mjs +85 -0
- package/build-module/hooks/states.mjs.map +7 -0
- package/build-module/hooks/style.mjs +309 -18
- package/build-module/hooks/style.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +19 -5
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/layouts/constrained.mjs +130 -57
- package/build-module/layouts/constrained.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +123 -35
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +105 -42
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/private-apis.mjs +4 -0
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +16 -0
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-keys.mjs +7 -1
- package/build-module/store/private-keys.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +25 -2
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +69 -1
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/utils.mjs +5 -2
- package/build-module/store/utils.mjs.map +2 -2
- package/build-module/utils/color-values.mjs +19 -0
- package/build-module/utils/color-values.mjs.map +7 -0
- package/build-style/content-rtl.css +18 -3
- package/build-style/content.css +18 -3
- package/build-style/style-rtl.css +14 -17
- package/build-style/style.css +14 -17
- package/package.json +41 -41
- package/src/components/audio-player/index.native.js +7 -3
- package/src/components/block-card/index.js +67 -60
- package/src/components/block-heading-level-dropdown/heading-level-icon.js +2 -2
- package/src/components/block-icon/index.js +5 -2
- package/src/components/block-icon/index.native.js +2 -2
- package/src/components/block-inspector/index.js +153 -7
- package/src/components/block-inspector/inspector-pre-tabs-slot-fill.js +11 -0
- package/src/components/block-list/block-selection-button.native.js +3 -3
- package/src/components/block-list/content.scss +0 -6
- package/src/components/block-list/use-block-props/index.js +1 -1
- package/src/components/block-list/use-block-props/use-focus-handler.js +8 -6
- package/src/components/block-list/use-block-props/use-is-hovered.js +32 -15
- package/src/components/block-lock/modal.js +4 -4
- package/src/components/block-patterns-list/index.js +14 -5
- package/src/components/block-patterns-list/stories/index.story.jsx +2 -0
- package/src/components/block-patterns-list/style.scss +0 -1
- package/src/components/block-popover/index.js +20 -10
- package/src/components/block-toolbar/switch-section-style.js +2 -2
- package/src/components/block-visibility/modal.js +2 -2
- package/src/components/block-visibility/viewport-visibility-info.js +2 -2
- package/src/components/colors/test/with-colors.js +1 -1
- package/src/components/colors-gradients/control.js +10 -8
- package/src/components/colors-gradients/test/control.js +98 -1
- package/src/components/global-styles/advanced-panel.js +44 -39
- package/src/components/global-styles/color-panel.js +133 -60
- package/src/components/global-styles/dimensions-panel.js +17 -4
- package/src/components/global-styles/index.js +1 -0
- package/src/components/global-styles/shadow-panel-components.js +29 -19
- package/src/components/global-styles/state-control-badges.js +58 -0
- package/src/components/global-styles/state-control.js +28 -36
- package/src/components/global-styles/test/color-panel.js +135 -0
- package/src/components/iframe/index.js +0 -3
- package/src/components/iframe/use-scale-canvas.js +8 -2
- package/src/components/inserter/hooks/use-patterns-state.js +12 -7
- package/src/components/inserter/index.js +1 -0
- package/src/components/inserter/media-tab/media-preview.js +29 -20
- package/src/components/inserter/media-tab/utils.js +1 -1
- package/src/components/inserter/panel.js +2 -2
- package/src/components/inserter/style.scss +1 -0
- package/src/components/inserter-button/index.native.js +5 -2
- package/src/components/inspector-controls/block-support-tools-panel.js +10 -2
- package/src/components/inspector-controls/fill.js +18 -5
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/index.js +9 -5
- package/src/components/inspector-controls-tabs/settings-tab.js +1 -7
- package/src/components/inspector-controls-tabs/styles-tab.js +6 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +13 -7
- package/src/components/list-view/block-select-button.js +19 -9
- package/src/components/list-view/block.js +6 -1
- package/src/components/media-replace-flow/style.scss +0 -18
- package/src/components/preset-input-control/custom-value-controls.js +13 -6
- package/src/components/preset-input-control/index.js +2 -2
- package/src/components/provider/use-media-upload-settings.js +1 -0
- package/src/components/rich-text/event-listeners/enter.js +14 -2
- package/src/components/rich-text/event-listeners/paste-handler.js +5 -4
- package/src/components/unsupported-block-details/index.native.js +6 -2
- package/src/components/video-player/index.native.js +2 -2
- package/src/components/warning/index.native.js +2 -2
- package/src/hooks/background.js +59 -37
- package/src/hooks/block-fields/link/index.js +3 -3
- package/src/hooks/block-fields/media/index.js +3 -3
- package/src/hooks/block-style-state.js +127 -0
- package/src/hooks/border.js +25 -6
- package/src/hooks/color.js +40 -18
- package/src/hooks/dimensions.js +32 -11
- package/src/hooks/layout-child.js +179 -62
- package/src/hooks/layout.js +349 -75
- package/src/hooks/layout.scss +6 -0
- package/src/hooks/state-utils.js +158 -0
- package/src/hooks/states.js +109 -0
- package/src/hooks/style.js +456 -19
- package/src/hooks/test/block-style-state.js +270 -0
- package/src/hooks/test/layout.js +185 -0
- package/src/hooks/test/state-utils.js +193 -0
- package/src/hooks/test/style.js +301 -1
- package/src/hooks/typography.js +33 -14
- package/src/layouts/constrained.js +182 -95
- package/src/layouts/flex.js +141 -36
- package/src/layouts/grid.js +122 -32
- package/src/layouts/test/flex.js +57 -20
- package/src/private-apis.js +4 -0
- package/src/store/private-actions.js +32 -0
- package/src/store/private-keys.js +4 -0
- package/src/store/private-selectors.js +44 -2
- package/src/store/reducer.js +105 -1
- package/src/store/test/private-actions.js +26 -0
- package/src/store/test/private-selectors.js +90 -0
- package/src/store/test/reducer.js +363 -0
- package/src/store/utils.js +6 -2
- package/src/utils/color-values.js +28 -0
- package/src/utils/test/color-values.js +78 -0
|
@@ -42,6 +42,7 @@ function ColorGradientControlInner( {
|
|
|
42
42
|
onColorChange,
|
|
43
43
|
onGradientChange,
|
|
44
44
|
colorValue,
|
|
45
|
+
colorSlug,
|
|
45
46
|
gradientValue,
|
|
46
47
|
clearable,
|
|
47
48
|
showTitle = true,
|
|
@@ -59,18 +60,19 @@ function ColorGradientControlInner( {
|
|
|
59
60
|
return null;
|
|
60
61
|
}
|
|
61
62
|
|
|
63
|
+
const colorPaletteOnChange = canChooseAGradient
|
|
64
|
+
? ( newColor, _index, newSlug ) => {
|
|
65
|
+
onColorChange( newColor, newSlug );
|
|
66
|
+
onGradientChange();
|
|
67
|
+
}
|
|
68
|
+
: ( newColor, _index, newSlug ) => onColorChange( newColor, newSlug );
|
|
69
|
+
|
|
62
70
|
const tabPanels = {
|
|
63
71
|
[ TAB_IDS.color ]: (
|
|
64
72
|
<ColorPalette
|
|
65
73
|
value={ colorValue }
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
? ( newColor ) => {
|
|
69
|
-
onColorChange( newColor );
|
|
70
|
-
onGradientChange();
|
|
71
|
-
}
|
|
72
|
-
: onColorChange
|
|
73
|
-
}
|
|
74
|
+
selectedSlug={ colorSlug }
|
|
75
|
+
onChange={ colorPaletteOnChange }
|
|
74
76
|
{ ...{ colors, disableCustomColors } }
|
|
75
77
|
__experimentalIsRenderedInSidebar={
|
|
76
78
|
__experimentalIsRenderedInSidebar
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { screen } from '@testing-library/react';
|
|
5
|
-
import { render } from '@ariakit/test/react';
|
|
5
|
+
import { click, render } from '@ariakit/test/react';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
@@ -131,4 +131,101 @@ describe( 'ColorPaletteControl', () => {
|
|
|
131
131
|
'components-custom-gradient-picker__control-point-button'
|
|
132
132
|
);
|
|
133
133
|
} );
|
|
134
|
+
|
|
135
|
+
describe( 'slug-based color selection', () => {
|
|
136
|
+
// Two entries that share the same hex value — used to verify that slug
|
|
137
|
+
// disambiguation works correctly.
|
|
138
|
+
const DUPLICATE_COLOR_PALETTE = [
|
|
139
|
+
{
|
|
140
|
+
color: '#000',
|
|
141
|
+
name: 'Dark Background',
|
|
142
|
+
slug: 'dark-background',
|
|
143
|
+
},
|
|
144
|
+
{ color: '#000', name: 'Dark Text', slug: 'dark-text' },
|
|
145
|
+
];
|
|
146
|
+
|
|
147
|
+
it( 'forwards colorSlug as selectedSlug to ColorPalette, marking only the slug-matched swatch as selected', async () => {
|
|
148
|
+
await render(
|
|
149
|
+
<ColorGradientControl
|
|
150
|
+
label="Test Color Gradient"
|
|
151
|
+
colorValue="#000"
|
|
152
|
+
colorSlug="dark-text"
|
|
153
|
+
colors={ DUPLICATE_COLOR_PALETTE }
|
|
154
|
+
gradients={ [] }
|
|
155
|
+
disableCustomColors={ false }
|
|
156
|
+
disableCustomGradients
|
|
157
|
+
onColorChange={ noop }
|
|
158
|
+
onGradientChange={ noop }
|
|
159
|
+
/>
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
const options = screen.getAllByRole( 'option' );
|
|
163
|
+
// 'dark-background' is index 0, 'dark-text' is index 1.
|
|
164
|
+
// With colorSlug="dark-text", only the second swatch should be selected.
|
|
165
|
+
expect( options[ 0 ] ).toHaveAttribute( 'aria-selected', 'false' );
|
|
166
|
+
expect( options[ 1 ] ).toHaveAttribute( 'aria-selected', 'true' );
|
|
167
|
+
} );
|
|
168
|
+
|
|
169
|
+
it( 'calls onColorChange with (color, slug) when a swatch is clicked (color-only palette)', async () => {
|
|
170
|
+
const onColorChange = jest.fn();
|
|
171
|
+
|
|
172
|
+
await render(
|
|
173
|
+
<ColorGradientControl
|
|
174
|
+
label="Test Color Gradient"
|
|
175
|
+
colorValue={ undefined }
|
|
176
|
+
colors={ DUPLICATE_COLOR_PALETTE }
|
|
177
|
+
gradients={ [] }
|
|
178
|
+
disableCustomColors={ false }
|
|
179
|
+
disableCustomGradients
|
|
180
|
+
onColorChange={ onColorChange }
|
|
181
|
+
onGradientChange={ noop }
|
|
182
|
+
/>
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
const options = screen.getAllByRole( 'option' );
|
|
186
|
+
// Click the second swatch: color='#000', slug='dark-text'.
|
|
187
|
+
await click( options[ 1 ] );
|
|
188
|
+
|
|
189
|
+
expect( onColorChange ).toHaveBeenCalledWith( '#000', 'dark-text' );
|
|
190
|
+
} );
|
|
191
|
+
|
|
192
|
+
it( 'calls onColorChange with (color, slug) and calls onGradientChange() when both colors and gradients are available', async () => {
|
|
193
|
+
const onColorChange = jest.fn();
|
|
194
|
+
const onGradientChange = jest.fn();
|
|
195
|
+
|
|
196
|
+
await render(
|
|
197
|
+
<ColorGradientControl
|
|
198
|
+
label="Test Color Gradient"
|
|
199
|
+
colorValue={ undefined }
|
|
200
|
+
colors={ DUPLICATE_COLOR_PALETTE }
|
|
201
|
+
gradients={ [
|
|
202
|
+
{
|
|
203
|
+
gradient:
|
|
204
|
+
'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
|
|
205
|
+
name: 'Vivid cyan blue to vivid purple',
|
|
206
|
+
slug: 'vivid-cyan-blue-to-vivid-purple',
|
|
207
|
+
},
|
|
208
|
+
] }
|
|
209
|
+
disableCustomColors={ false }
|
|
210
|
+
disableCustomGradients={ false }
|
|
211
|
+
onColorChange={ onColorChange }
|
|
212
|
+
onGradientChange={ onGradientChange }
|
|
213
|
+
/>
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
// When both colors and gradients are available the color tab is shown
|
|
217
|
+
// by default (no gradientValue). Click the first color swatch.
|
|
218
|
+
const options = screen.getAllByRole( 'option' );
|
|
219
|
+
await click( options[ 0 ] );
|
|
220
|
+
|
|
221
|
+
// First entry: color='#000', slug='dark-background'.
|
|
222
|
+
expect( onColorChange ).toHaveBeenCalledWith(
|
|
223
|
+
'#000',
|
|
224
|
+
'dark-background'
|
|
225
|
+
);
|
|
226
|
+
// Selecting a color must also clear the active gradient.
|
|
227
|
+
expect( onGradientChange ).toHaveBeenCalledTimes( 1 );
|
|
228
|
+
expect( onGradientChange ).toHaveBeenCalledWith();
|
|
229
|
+
} );
|
|
230
|
+
} );
|
|
134
231
|
} );
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
Notice,
|
|
7
|
-
__experimentalVStack as VStack,
|
|
8
|
-
} from '@wordpress/components';
|
|
4
|
+
import { TextareaControl, Notice } from '@wordpress/components';
|
|
5
|
+
import { Stack } from '@wordpress/ui';
|
|
9
6
|
import { useState } from '@wordpress/element';
|
|
10
7
|
import { __ } from '@wordpress/i18n';
|
|
11
8
|
|
|
@@ -29,6 +26,41 @@ export function validateCSS( css ) {
|
|
|
29
26
|
return true;
|
|
30
27
|
}
|
|
31
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Returns the error message string if the CSS contains HTML markup, or null if it is clean.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} css The CSS string to check.
|
|
33
|
+
* @return {string|null} An error message, or null if the CSS is valid.
|
|
34
|
+
*/
|
|
35
|
+
function getMarkupValidationError( css ) {
|
|
36
|
+
return validateCSS( css )
|
|
37
|
+
? null
|
|
38
|
+
: __( 'The custom CSS is invalid. Do not use <> markup.' );
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Full CSS validation: markup check first (fast), then a CSS parser (slower).
|
|
43
|
+
*
|
|
44
|
+
* @param {string} css The CSS string to validate.
|
|
45
|
+
* @return {string|null} An error message, or null if the CSS is valid.
|
|
46
|
+
*/
|
|
47
|
+
function getCSSValidationError( css ) {
|
|
48
|
+
if ( ! css ) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const markupError = getMarkupValidationError( css );
|
|
52
|
+
if ( markupError ) {
|
|
53
|
+
return markupError;
|
|
54
|
+
}
|
|
55
|
+
const [ transformed ] = transformStyles(
|
|
56
|
+
[ { css } ],
|
|
57
|
+
'.for-validation-only'
|
|
58
|
+
);
|
|
59
|
+
return transformed === null
|
|
60
|
+
? __( 'There is an error with your CSS structure.' )
|
|
61
|
+
: null;
|
|
62
|
+
}
|
|
63
|
+
|
|
32
64
|
export default function AdvancedPanel( {
|
|
33
65
|
value,
|
|
34
66
|
onChange,
|
|
@@ -36,51 +68,24 @@ export default function AdvancedPanel( {
|
|
|
36
68
|
help,
|
|
37
69
|
} ) {
|
|
38
70
|
// Custom CSS
|
|
39
|
-
const [ cssError, setCSSError ] = useState( null );
|
|
40
71
|
const customCSS = inheritedValue?.css;
|
|
72
|
+
const [ cssError, setCSSError ] = useState( () =>
|
|
73
|
+
getCSSValidationError( customCSS )
|
|
74
|
+
);
|
|
41
75
|
function handleOnChange( newValue ) {
|
|
42
76
|
onChange( {
|
|
43
77
|
...value,
|
|
44
78
|
css: newValue,
|
|
45
79
|
} );
|
|
46
80
|
|
|
47
|
-
|
|
48
|
-
if ( ! validateCSS( newValue ) ) {
|
|
49
|
-
setCSSError(
|
|
50
|
-
__( 'The custom CSS is invalid. Do not use <> markup.' )
|
|
51
|
-
);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Clear HTML markup error if CSS is now valid.
|
|
56
|
-
if ( cssError ) {
|
|
57
|
-
setCSSError( null );
|
|
58
|
-
}
|
|
81
|
+
setCSSError( getMarkupValidationError( newValue ) );
|
|
59
82
|
}
|
|
60
83
|
function handleOnBlur( event ) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if ( ! cssValue || ! validateCSS( cssValue ) ) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Check if the value is valid CSS structure on blur (more expensive check).
|
|
68
|
-
// Pass a wrapping selector to ensure that `transformStyles` validates the CSS.
|
|
69
|
-
// Note that the wrapping selector here is not used in the actual output of any styles.
|
|
70
|
-
const [ transformed ] = transformStyles(
|
|
71
|
-
[ { css: cssValue } ],
|
|
72
|
-
'.for-validation-only'
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
setCSSError(
|
|
76
|
-
transformed === null
|
|
77
|
-
? __( 'There is an error with your CSS structure.' )
|
|
78
|
-
: null
|
|
79
|
-
);
|
|
84
|
+
setCSSError( getCSSValidationError( event?.target?.value ) );
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
return (
|
|
83
|
-
<
|
|
88
|
+
<Stack direction="column" gap="md">
|
|
84
89
|
{ cssError && (
|
|
85
90
|
<Notice status="error" onRemove={ () => setCSSError( null ) }>
|
|
86
91
|
{ cssError }
|
|
@@ -95,6 +100,6 @@ export default function AdvancedPanel( {
|
|
|
95
100
|
spellCheck={ false }
|
|
96
101
|
help={ help }
|
|
97
102
|
/>
|
|
98
|
-
</
|
|
103
|
+
</Stack>
|
|
99
104
|
);
|
|
100
105
|
}
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
Button,
|
|
20
20
|
privateApis as componentsPrivateApis,
|
|
21
21
|
} from '@wordpress/components';
|
|
22
|
-
import {
|
|
22
|
+
import { useMemo, useRef } from '@wordpress/element';
|
|
23
23
|
import { __ } from '@wordpress/i18n';
|
|
24
24
|
import { getValueFromVariable } from '@wordpress/global-styles-engine';
|
|
25
25
|
import { reset as resetIcon } from '@wordpress/icons';
|
|
@@ -31,6 +31,7 @@ import ColorGradientControl from '../colors-gradients/control';
|
|
|
31
31
|
import { useColorsPerOrigin, useGradientsPerOrigin } from './hooks';
|
|
32
32
|
import { useToolsPanelDropdownMenuProps } from './utils';
|
|
33
33
|
import { setImmutably } from '../../utils/object';
|
|
34
|
+
import { extractPresetSlug } from '../../utils/color-values';
|
|
34
35
|
import { unlock } from '../../lock-unlock';
|
|
35
36
|
|
|
36
37
|
export function useHasColorPanel( settings ) {
|
|
@@ -144,6 +145,29 @@ export function ColorToolsPanel( {
|
|
|
144
145
|
);
|
|
145
146
|
}
|
|
146
147
|
|
|
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
|
+
|
|
147
171
|
const DEFAULT_CONTROLS = {
|
|
148
172
|
text: true,
|
|
149
173
|
background: true,
|
|
@@ -179,6 +203,7 @@ const LabeledColorIndicators = ( { indicators, label } ) => (
|
|
|
179
203
|
function ColorPanelTab( {
|
|
180
204
|
isGradient,
|
|
181
205
|
inheritedValue,
|
|
206
|
+
inheritedSlug,
|
|
182
207
|
userValue,
|
|
183
208
|
setValue,
|
|
184
209
|
colorGradientControlSettings,
|
|
@@ -190,6 +215,7 @@ function ColorPanelTab( {
|
|
|
190
215
|
enableAlpha
|
|
191
216
|
__experimentalIsRenderedInSidebar
|
|
192
217
|
colorValue={ isGradient ? undefined : inheritedValue }
|
|
218
|
+
colorSlug={ isGradient ? undefined : inheritedSlug }
|
|
193
219
|
gradientValue={ isGradient ? inheritedValue : undefined }
|
|
194
220
|
onColorChange={ isGradient ? undefined : setValue }
|
|
195
221
|
onGradientChange={ isGradient ? setValue : undefined }
|
|
@@ -341,19 +367,15 @@ export default function ColorPanel( {
|
|
|
341
367
|
const hasBackgroundGradientSupport = !! settings?.background?.gradient;
|
|
342
368
|
const showGradientColors =
|
|
343
369
|
hasGradientColors && ! hasBackgroundGradientSupport;
|
|
370
|
+
|
|
344
371
|
const decodeValue = ( rawValue ) =>
|
|
345
372
|
getValueFromVariable( { settings }, '', rawValue );
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
);
|
|
353
|
-
return colorObject
|
|
354
|
-
? 'var:preset|color|' + colorObject.slug
|
|
355
|
-
: colorValue;
|
|
356
|
-
};
|
|
373
|
+
|
|
374
|
+
const allColors = useMemo(
|
|
375
|
+
() => colors.flatMap( ( { colors: originColors } ) => originColors ),
|
|
376
|
+
[ colors ]
|
|
377
|
+
);
|
|
378
|
+
|
|
357
379
|
const encodeGradientValue = ( gradientValue ) => {
|
|
358
380
|
const allGradients = gradients.flatMap(
|
|
359
381
|
( { gradients: originGradients } ) => originGradients
|
|
@@ -375,11 +397,11 @@ export default function ColorPanel( {
|
|
|
375
397
|
const hasBackground = () =>
|
|
376
398
|
!! userBackgroundColor ||
|
|
377
399
|
( ! hasBackgroundGradientSupport && !! userGradient );
|
|
378
|
-
const setBackgroundColor = ( newColor ) => {
|
|
400
|
+
const setBackgroundColor = ( newColor, newSlug ) => {
|
|
379
401
|
const newValue = setImmutably(
|
|
380
402
|
value,
|
|
381
403
|
[ 'color', 'background' ],
|
|
382
|
-
|
|
404
|
+
encodeColorValueWithPalette( allColors, newColor, newSlug )
|
|
383
405
|
);
|
|
384
406
|
if ( ! hasBackgroundGradientSupport ) {
|
|
385
407
|
newValue.color.gradient = undefined;
|
|
@@ -413,12 +435,12 @@ export default function ColorPanel( {
|
|
|
413
435
|
inheritedValue?.elements?.link?.color?.text
|
|
414
436
|
);
|
|
415
437
|
const userLinkColor = decodeValue( value?.elements?.link?.color?.text );
|
|
416
|
-
const setLinkColor = ( newColor ) => {
|
|
438
|
+
const setLinkColor = ( newColor, newSlug ) => {
|
|
417
439
|
onChange(
|
|
418
440
|
setImmutably(
|
|
419
441
|
value,
|
|
420
442
|
[ 'elements', 'link', 'color', 'text' ],
|
|
421
|
-
|
|
443
|
+
encodeColorValueWithPalette( allColors, newColor, newSlug )
|
|
422
444
|
)
|
|
423
445
|
);
|
|
424
446
|
};
|
|
@@ -428,12 +450,12 @@ export default function ColorPanel( {
|
|
|
428
450
|
const userHoverLinkColor = decodeValue(
|
|
429
451
|
value?.elements?.link?.[ ':hover' ]?.color?.text
|
|
430
452
|
);
|
|
431
|
-
const setHoverLinkColor = ( newColor ) => {
|
|
453
|
+
const setHoverLinkColor = ( newColor, newSlug ) => {
|
|
432
454
|
onChange(
|
|
433
455
|
setImmutably(
|
|
434
456
|
value,
|
|
435
457
|
[ 'elements', 'link', ':hover', 'color', 'text' ],
|
|
436
|
-
|
|
458
|
+
encodeColorValueWithPalette( allColors, newColor, newSlug )
|
|
437
459
|
)
|
|
438
460
|
);
|
|
439
461
|
};
|
|
@@ -454,20 +476,40 @@ export default function ColorPanel( {
|
|
|
454
476
|
|
|
455
477
|
// Text Color
|
|
456
478
|
const showTextPanel = useHasTextPanel( settings );
|
|
479
|
+
const showCaptionPanel = useHasCaptionPanel( settings );
|
|
480
|
+
const showButtonPanel = useHasButtonPanel( settings );
|
|
481
|
+
const showHeadingPanel = useHasHeadingPanel( settings );
|
|
457
482
|
const textColor = decodeValue( inheritedValue?.color?.text );
|
|
458
483
|
const userTextColor = decodeValue( value?.color?.text );
|
|
459
484
|
const hasTextColor = () => !! userTextColor;
|
|
460
|
-
const setTextColor = ( newColor ) => {
|
|
485
|
+
const setTextColor = ( newColor, newSlug ) => {
|
|
461
486
|
let changedObject = setImmutably(
|
|
462
487
|
value,
|
|
463
488
|
[ 'color', 'text' ],
|
|
464
|
-
|
|
489
|
+
encodeColorValueWithPalette( allColors, newColor, newSlug )
|
|
465
490
|
);
|
|
466
|
-
|
|
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
|
+
) {
|
|
467
509
|
changedObject = setImmutably(
|
|
468
510
|
changedObject,
|
|
469
511
|
[ 'elements', 'link', 'color', 'text' ],
|
|
470
|
-
|
|
512
|
+
encodeColorValueWithPalette( allColors, newColor, newSlug )
|
|
471
513
|
);
|
|
472
514
|
}
|
|
473
515
|
|
|
@@ -480,78 +522,75 @@ export default function ColorPanel( {
|
|
|
480
522
|
{
|
|
481
523
|
name: 'caption',
|
|
482
524
|
label: __( 'Captions' ),
|
|
483
|
-
showPanel:
|
|
525
|
+
showPanel: showCaptionPanel,
|
|
484
526
|
},
|
|
485
527
|
{
|
|
486
528
|
name: 'button',
|
|
487
529
|
label: __( 'Button' ),
|
|
488
|
-
showPanel:
|
|
530
|
+
showPanel: showButtonPanel,
|
|
489
531
|
},
|
|
490
532
|
{
|
|
491
533
|
name: 'heading',
|
|
492
534
|
label: __( 'Heading' ),
|
|
493
|
-
showPanel:
|
|
535
|
+
showPanel: showHeadingPanel,
|
|
494
536
|
},
|
|
495
537
|
{
|
|
496
538
|
name: 'h1',
|
|
497
539
|
label: __( 'H1' ),
|
|
498
|
-
showPanel:
|
|
540
|
+
showPanel: showHeadingPanel,
|
|
499
541
|
},
|
|
500
542
|
{
|
|
501
543
|
name: 'h2',
|
|
502
544
|
label: __( 'H2' ),
|
|
503
|
-
showPanel:
|
|
545
|
+
showPanel: showHeadingPanel,
|
|
504
546
|
},
|
|
505
547
|
{
|
|
506
548
|
name: 'h3',
|
|
507
549
|
label: __( 'H3' ),
|
|
508
|
-
showPanel:
|
|
550
|
+
showPanel: showHeadingPanel,
|
|
509
551
|
},
|
|
510
552
|
{
|
|
511
553
|
name: 'h4',
|
|
512
554
|
label: __( 'H4' ),
|
|
513
|
-
showPanel:
|
|
555
|
+
showPanel: showHeadingPanel,
|
|
514
556
|
},
|
|
515
557
|
{
|
|
516
558
|
name: 'h5',
|
|
517
559
|
label: __( 'H5' ),
|
|
518
|
-
showPanel:
|
|
560
|
+
showPanel: showHeadingPanel,
|
|
519
561
|
},
|
|
520
562
|
{
|
|
521
563
|
name: 'h6',
|
|
522
564
|
label: __( 'H6' ),
|
|
523
|
-
showPanel:
|
|
565
|
+
showPanel: showHeadingPanel,
|
|
524
566
|
},
|
|
525
567
|
];
|
|
526
568
|
|
|
527
|
-
const resetAllFilter =
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
elements
|
|
533
|
-
|
|
534
|
-
link
|
|
535
|
-
|
|
569
|
+
const resetAllFilter = ( previousValue ) => {
|
|
570
|
+
return {
|
|
571
|
+
...previousValue,
|
|
572
|
+
color: undefined,
|
|
573
|
+
elements: {
|
|
574
|
+
...previousValue?.elements,
|
|
575
|
+
link: {
|
|
576
|
+
...previousValue?.elements?.link,
|
|
577
|
+
color: undefined,
|
|
578
|
+
':hover': {
|
|
536
579
|
color: undefined,
|
|
537
|
-
':hover': {
|
|
538
|
-
color: undefined,
|
|
539
|
-
},
|
|
540
580
|
},
|
|
541
|
-
...elements.reduce( ( acc, element ) => {
|
|
542
|
-
return {
|
|
543
|
-
...acc,
|
|
544
|
-
[ element.name ]: {
|
|
545
|
-
...previousValue?.elements?.[ element.name ],
|
|
546
|
-
color: undefined,
|
|
547
|
-
},
|
|
548
|
-
};
|
|
549
|
-
}, {} ),
|
|
550
581
|
},
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
582
|
+
...elements.reduce( ( acc, element ) => {
|
|
583
|
+
return {
|
|
584
|
+
...acc,
|
|
585
|
+
[ element.name ]: {
|
|
586
|
+
...previousValue?.elements?.[ element.name ],
|
|
587
|
+
color: undefined,
|
|
588
|
+
},
|
|
589
|
+
};
|
|
590
|
+
}, {} ),
|
|
591
|
+
},
|
|
592
|
+
};
|
|
593
|
+
};
|
|
555
594
|
|
|
556
595
|
const items = [
|
|
557
596
|
showTextPanel && {
|
|
@@ -566,6 +605,10 @@ export default function ColorPanel( {
|
|
|
566
605
|
key: 'text',
|
|
567
606
|
label: __( 'Text' ),
|
|
568
607
|
inheritedValue: textColor,
|
|
608
|
+
inheritedSlug: extractPresetSlug(
|
|
609
|
+
inheritedValue?.color?.text,
|
|
610
|
+
'color'
|
|
611
|
+
),
|
|
569
612
|
setValue: setTextColor,
|
|
570
613
|
userValue: userTextColor,
|
|
571
614
|
},
|
|
@@ -586,6 +629,10 @@ export default function ColorPanel( {
|
|
|
586
629
|
key: 'background',
|
|
587
630
|
label: __( 'Color' ),
|
|
588
631
|
inheritedValue: backgroundColor,
|
|
632
|
+
inheritedSlug: extractPresetSlug(
|
|
633
|
+
inheritedValue?.color?.background,
|
|
634
|
+
'color'
|
|
635
|
+
),
|
|
589
636
|
setValue: setBackgroundColor,
|
|
590
637
|
userValue: userBackgroundColor,
|
|
591
638
|
},
|
|
@@ -611,6 +658,10 @@ export default function ColorPanel( {
|
|
|
611
658
|
key: 'link',
|
|
612
659
|
label: __( 'Default' ),
|
|
613
660
|
inheritedValue: linkColor,
|
|
661
|
+
inheritedSlug: extractPresetSlug(
|
|
662
|
+
inheritedValue?.elements?.link?.color?.text,
|
|
663
|
+
'color'
|
|
664
|
+
),
|
|
614
665
|
setValue: setLinkColor,
|
|
615
666
|
userValue: userLinkColor,
|
|
616
667
|
},
|
|
@@ -618,6 +669,11 @@ export default function ColorPanel( {
|
|
|
618
669
|
key: 'hover',
|
|
619
670
|
label: __( 'Hover' ),
|
|
620
671
|
inheritedValue: hoverLinkColor,
|
|
672
|
+
inheritedSlug: extractPresetSlug(
|
|
673
|
+
inheritedValue?.elements?.link?.[ ':hover' ]?.color
|
|
674
|
+
?.text,
|
|
675
|
+
'color'
|
|
676
|
+
),
|
|
621
677
|
setValue: setHoverLinkColor,
|
|
622
678
|
userValue: userHoverLinkColor,
|
|
623
679
|
},
|
|
@@ -665,20 +721,28 @@ export default function ColorPanel( {
|
|
|
665
721
|
onChange( newValue );
|
|
666
722
|
};
|
|
667
723
|
|
|
668
|
-
const setElementTextColor = ( newTextColor ) => {
|
|
724
|
+
const setElementTextColor = ( newTextColor, newSlug ) => {
|
|
669
725
|
onChange(
|
|
670
726
|
setImmutably(
|
|
671
727
|
value,
|
|
672
728
|
[ 'elements', name, 'color', 'text' ],
|
|
673
|
-
|
|
729
|
+
encodeColorValueWithPalette(
|
|
730
|
+
allColors,
|
|
731
|
+
newTextColor,
|
|
732
|
+
newSlug
|
|
733
|
+
)
|
|
674
734
|
)
|
|
675
735
|
);
|
|
676
736
|
};
|
|
677
|
-
const setElementBackgroundColor = ( newBackgroundColor ) => {
|
|
737
|
+
const setElementBackgroundColor = ( newBackgroundColor, newSlug ) => {
|
|
678
738
|
const newValue = setImmutably(
|
|
679
739
|
value,
|
|
680
740
|
[ 'elements', name, 'color', 'background' ],
|
|
681
|
-
|
|
741
|
+
encodeColorValueWithPalette(
|
|
742
|
+
allColors,
|
|
743
|
+
newBackgroundColor,
|
|
744
|
+
newSlug
|
|
745
|
+
)
|
|
682
746
|
);
|
|
683
747
|
newValue.elements[ name ].color.gradient = undefined;
|
|
684
748
|
onChange( newValue );
|
|
@@ -720,6 +784,10 @@ export default function ColorPanel( {
|
|
|
720
784
|
key: 'text',
|
|
721
785
|
label: __( 'Text' ),
|
|
722
786
|
inheritedValue: elementTextColor,
|
|
787
|
+
inheritedSlug: extractPresetSlug(
|
|
788
|
+
inheritedValue?.elements?.[ name ]?.color?.text,
|
|
789
|
+
'color'
|
|
790
|
+
),
|
|
723
791
|
setValue: setElementTextColor,
|
|
724
792
|
userValue: elementTextUserColor,
|
|
725
793
|
},
|
|
@@ -728,6 +796,11 @@ export default function ColorPanel( {
|
|
|
728
796
|
key: 'background',
|
|
729
797
|
label: __( 'Background' ),
|
|
730
798
|
inheritedValue: elementBackgroundColor,
|
|
799
|
+
inheritedSlug: extractPresetSlug(
|
|
800
|
+
inheritedValue?.elements?.[ name ]?.color
|
|
801
|
+
?.background,
|
|
802
|
+
'color'
|
|
803
|
+
),
|
|
731
804
|
setValue: setElementBackgroundColor,
|
|
732
805
|
userValue: elementBackgroundUserColor,
|
|
733
806
|
},
|