@wordpress/block-editor 11.5.0 → 11.7.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 +4 -0
- package/build/components/block-list/block-html.js +1 -3
- package/build/components/block-list/block-html.js.map +1 -1
- package/build/components/block-list/block-invalid-warning.js +63 -80
- package/build/components/block-list/block-invalid-warning.js.map +1 -1
- package/build/components/block-preview/auto.js +6 -23
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +1 -1
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build/components/editor-styles/index.js +20 -2
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +306 -0
- package/build/components/global-styles/border-panel.js.map +1 -0
- package/build/components/global-styles/color-panel.js +583 -0
- package/build/components/global-styles/color-panel.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +8 -30
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/get-block-css-selector.js +129 -0
- package/build/components/global-styles/get-block-css-selector.js.map +1 -0
- package/build/components/global-styles/hooks.js +109 -3
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +36 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +66 -45
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +180 -99
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/image-size-control/index.js +8 -5
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inserter/index.js +29 -17
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/menu.js +1 -1
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +4 -2
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +10 -3
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +1 -1
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +43 -7
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build/components/line-height-control/index.js +15 -1
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/index.js +1 -1
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-item.js +5 -2
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/list-view/appender.js +105 -0
- package/build/components/list-view/appender.js.map +1 -0
- package/build/components/list-view/block.js +5 -5
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +25 -5
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +37 -13
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -2
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/media-replace-flow/index.js +13 -4
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +28 -3
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +5 -3
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +9 -7
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/link-ui.js +0 -1
- package/build/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build/components/provider/use-block-sync.js +17 -3
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/rich-text/format-edit.js +2 -30
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +0 -3
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/writing-flow/use-input.js +4 -8
- package/build/components/writing-flow/use-input.js.map +1 -1
- package/build/hooks/border.js +90 -240
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +92 -229
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +4 -2
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/{color-panel.js → contrast-checker.js} +11 -49
- package/build/hooks/contrast-checker.js.map +1 -0
- package/build/hooks/custom-class-name.js +4 -4
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-class-name.native.js +3 -4
- package/build/hooks/custom-class-name.native.js.map +1 -1
- package/build/hooks/dimensions.js +0 -1
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +3 -1
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/layout.js +19 -22
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +2 -2
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +23 -26
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/supports.js +7 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +2 -2
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +50 -75
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +6 -2
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/grid.js +165 -0
- package/build/layouts/grid.js.map +1 -0
- package/build/layouts/index.js +3 -1
- package/build/layouts/index.js.map +1 -1
- package/build/private-apis.js +7 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +10 -8
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +19 -3
- package/build/store/selectors.js.map +1 -1
- package/build/utils/object.js +76 -0
- package/build/utils/object.js.map +1 -0
- package/build/utils/parse-css-unit-to-px.js +15 -9
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/components/block-list/block-html.js +1 -3
- package/build-module/components/block-list/block-html.js.map +1 -1
- package/build-module/components/block-list/block-invalid-warning.js +66 -78
- package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
- package/build-module/components/block-preview/auto.js +6 -22
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +1 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build-module/components/editor-styles/index.js +19 -2
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +291 -0
- package/build-module/components/global-styles/border-panel.js.map +1 -0
- package/build-module/components/global-styles/color-panel.js +554 -0
- package/build-module/components/global-styles/color-panel.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +7 -30
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/get-block-css-selector.js +120 -0
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +104 -3
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +3 -0
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +65 -46
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +181 -100
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/image-size-control/index.js +8 -5
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inserter/index.js +28 -16
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/menu.js +1 -1
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +4 -2
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +10 -3
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +1 -1
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +42 -7
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build-module/components/line-height-control/index.js +15 -1
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +1 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-item.js +4 -2
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/list-view/appender.js +88 -0
- package/build-module/components/list-view/appender.js.map +1 -0
- package/build-module/components/list-view/block.js +5 -4
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +22 -5
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +32 -12
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -2
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +12 -4
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +28 -4
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +5 -3
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +9 -7
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/link-ui.js +0 -1
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +17 -3
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +3 -31
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +0 -3
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/writing-flow/use-input.js +4 -8
- package/build-module/components/writing-flow/use-input.js.map +1 -1
- package/build-module/hooks/border.js +92 -240
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +90 -232
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +4 -2
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/{color-panel.js → contrast-checker.js} +10 -44
- package/build-module/hooks/contrast-checker.js.map +1 -0
- package/build-module/hooks/custom-class-name.js +4 -4
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-class-name.native.js +3 -4
- package/build-module/hooks/custom-class-name.native.js.map +1 -1
- package/build-module/hooks/dimensions.js +0 -1
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -2
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/layout.js +19 -22
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +3 -3
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +23 -26
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/supports.js +7 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +2 -2
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +48 -72
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +6 -2
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/grid.js +151 -0
- package/build-module/layouts/grid.js.map +1 -0
- package/build-module/layouts/index.js +2 -1
- package/build-module/layouts/index.js.map +1 -1
- package/build-module/private-apis.js +5 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +10 -8
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +17 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/object.js +69 -0
- package/build-module/utils/object.js.map +1 -0
- package/build-module/utils/parse-css-unit-to-px.js +15 -9
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +32 -12
- package/build-style/style.css +32 -12
- package/package.json +31 -31
- package/src/components/block-draggable/content.scss +1 -1
- package/src/components/block-inspector/style.scss +3 -0
- package/src/components/block-list/block-html.js +1 -1
- package/src/components/block-list/block-invalid-warning.js +72 -64
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +20 -2
- package/src/components/block-preview/auto.js +2 -17
- package/src/components/block-preview/test/index.js +0 -2
- package/src/components/block-settings-menu-controls/index.js +2 -1
- package/src/components/block-styles/style.scss +2 -2
- package/src/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +16 -14
- package/src/components/colors-gradients/style.scss +8 -8
- package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +48 -38
- package/src/components/editor-styles/index.js +29 -1
- package/src/components/global-styles/border-panel.js +285 -0
- package/src/components/global-styles/color-panel.js +706 -0
- package/src/components/global-styles/dimensions-panel.js +13 -42
- package/src/components/global-styles/get-block-css-selector.js +129 -0
- package/src/components/global-styles/hooks.js +154 -1
- package/src/components/global-styles/index.js +3 -0
- package/src/components/global-styles/test/use-global-styles-output.js +31 -2
- package/src/components/global-styles/typography-panel.js +67 -45
- package/src/components/global-styles/use-global-styles-output.js +176 -93
- package/src/components/global-styles/utils.js +3 -0
- package/src/components/image-size-control/index.js +4 -3
- package/src/components/image-size-control/test/index.js +2 -2
- package/src/components/inner-blocks/README.md +1 -1
- package/src/components/inserter/index.js +30 -11
- package/src/components/inserter/menu.js +0 -1
- package/src/components/inserter/quick-inserter.js +2 -0
- package/src/components/inserter/search-results.js +7 -1
- package/src/components/inserter/style.scss +3 -0
- package/src/components/inserter/tabs.js +1 -9
- package/src/components/inspector-controls-tabs/position-controls-panel.js +40 -9
- package/src/components/line-height-control/index.js +10 -1
- package/src/components/link-control/index.js +1 -1
- package/src/components/link-control/search-item.js +3 -1
- package/src/components/link-control/style.scss +0 -4
- package/src/components/link-control/test/index.js +0 -2
- package/src/components/list-view/appender.js +101 -0
- package/src/components/list-view/block.js +5 -4
- package/src/components/list-view/branch.js +30 -1
- package/src/components/list-view/index.js +43 -10
- package/src/components/list-view/style.scss +19 -0
- package/src/components/list-view/use-block-selection.js +0 -2
- package/src/components/media-replace-flow/index.js +36 -24
- package/src/components/media-replace-flow/style.scss +5 -2
- package/src/components/off-canvas-editor/appender.js +31 -5
- package/src/components/off-canvas-editor/branch.js +3 -1
- package/src/components/off-canvas-editor/index.js +7 -7
- package/src/components/off-canvas-editor/link-ui.js +0 -1
- package/src/components/provider/use-block-sync.js +21 -4
- package/src/components/rich-text/format-edit.js +2 -32
- package/src/components/rich-text/format-toolbar-container.js +1 -7
- package/src/components/url-popover/test/index.js +0 -2
- package/src/components/writing-flow/use-input.js +4 -5
- package/src/hooks/border.js +93 -225
- package/src/hooks/color.js +120 -296
- package/src/hooks/content-lock-ui.js +6 -2
- package/src/hooks/{color-panel.js → contrast-checker.js} +10 -46
- package/src/hooks/custom-class-name.js +4 -4
- package/src/hooks/custom-class-name.native.js +3 -4
- package/src/hooks/dimensions.js +0 -1
- package/src/hooks/duotone.js +8 -5
- package/src/hooks/layout.js +19 -16
- package/src/hooks/position.js +3 -3
- package/src/hooks/style.js +29 -28
- package/src/hooks/supports.js +6 -0
- package/src/hooks/test/style.js +2 -1
- package/src/hooks/test/use-typography-props.js +2 -0
- package/src/hooks/test/utils.js +0 -104
- package/src/hooks/typography.js +2 -1
- package/src/hooks/utils.js +63 -70
- package/src/layouts/constrained.js +23 -17
- package/src/layouts/grid.js +172 -0
- package/src/layouts/index.js +2 -1
- package/src/layouts/test/grid.js +21 -0
- package/src/private-apis.js +4 -0
- package/src/store/actions.js +10 -8
- package/src/store/selectors.js +20 -3
- package/src/utils/object.js +69 -0
- package/src/utils/parse-css-unit-to-px.js +14 -9
- package/src/utils/test/object.js +107 -0
- package/src/utils/test/parse-css-unit-to-px.js +1 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/hooks/border-radius.js +0 -100
- package/build/hooks/border-radius.js.map +0 -1
- package/build/hooks/color-panel.js.map +0 -1
- package/build-module/hooks/border-radius.js +0 -84
- package/build-module/hooks/border-radius.js.map +0 -1
- package/build-module/hooks/color-panel.js.map +0 -1
- package/src/hooks/border-radius.js +0 -70
package/src/hooks/color.js
CHANGED
|
@@ -8,8 +8,7 @@ import classnames from 'classnames';
|
|
|
8
8
|
*/
|
|
9
9
|
import { addFilter } from '@wordpress/hooks';
|
|
10
10
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
11
|
-
import {
|
|
12
|
-
import { useRef, useEffect, useMemo, Platform } from '@wordpress/element';
|
|
11
|
+
import { useMemo, Platform, useCallback } from '@wordpress/element';
|
|
13
12
|
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
14
13
|
|
|
15
14
|
/**
|
|
@@ -17,22 +16,22 @@ import { createHigherOrderComponent } from '@wordpress/compose';
|
|
|
17
16
|
*/
|
|
18
17
|
import {
|
|
19
18
|
getColorClassName,
|
|
20
|
-
getColorObjectByColorValue,
|
|
21
19
|
getColorObjectByAttributeValues,
|
|
22
20
|
} from '../components/colors';
|
|
23
|
-
import {
|
|
24
|
-
__experimentalGetGradientClass,
|
|
25
|
-
getGradientValueBySlug,
|
|
26
|
-
getGradientSlugByValue,
|
|
27
|
-
} from '../components/gradients';
|
|
21
|
+
import { __experimentalGetGradientClass } from '../components/gradients';
|
|
28
22
|
import {
|
|
29
23
|
cleanEmptyObject,
|
|
30
24
|
transformStyles,
|
|
31
|
-
immutableSet,
|
|
32
25
|
shouldSkipSerialization,
|
|
26
|
+
useBlockSettings,
|
|
33
27
|
} from './utils';
|
|
34
|
-
import ColorPanel from './color-panel';
|
|
35
28
|
import useSetting from '../components/use-setting';
|
|
29
|
+
import InspectorControls from '../components/inspector-controls';
|
|
30
|
+
import {
|
|
31
|
+
useHasColorPanel,
|
|
32
|
+
default as StylesColorPanel,
|
|
33
|
+
} from '../components/global-styles/color-panel';
|
|
34
|
+
import BlockColorContrastChecker from './contrast-checker';
|
|
36
35
|
|
|
37
36
|
export const COLOR_SUPPORT_KEY = 'color';
|
|
38
37
|
|
|
@@ -83,60 +82,6 @@ const hasTextColorSupport = ( blockType ) => {
|
|
|
83
82
|
return colorSupport && colorSupport.text !== false;
|
|
84
83
|
};
|
|
85
84
|
|
|
86
|
-
/**
|
|
87
|
-
* Clears a single color property from a style object.
|
|
88
|
-
*
|
|
89
|
-
* @param {Array} path Path to color property to clear within styles object.
|
|
90
|
-
* @param {Object} style Block attributes style object.
|
|
91
|
-
* @return {Object} Styles with the color property omitted.
|
|
92
|
-
*/
|
|
93
|
-
const clearColorFromStyles = ( path, style ) =>
|
|
94
|
-
cleanEmptyObject( immutableSet( style, path, undefined ) );
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Clears text color related properties from supplied attributes.
|
|
98
|
-
*
|
|
99
|
-
* @param {Object} attributes Block attributes.
|
|
100
|
-
* @return {Object} Update block attributes with text color properties omitted.
|
|
101
|
-
*/
|
|
102
|
-
const resetAllTextFilter = ( attributes ) => ( {
|
|
103
|
-
textColor: undefined,
|
|
104
|
-
style: clearColorFromStyles( [ 'color', 'text' ], attributes.style ),
|
|
105
|
-
} );
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Clears link color related properties from supplied attributes.
|
|
109
|
-
*
|
|
110
|
-
* @param {Object} attributes Block attributes.
|
|
111
|
-
* @return {Object} Update block attributes with link color properties omitted.
|
|
112
|
-
*/
|
|
113
|
-
const resetAllLinkFilter = ( attributes ) => ( {
|
|
114
|
-
style: clearColorFromStyles(
|
|
115
|
-
[ 'elements', 'link', 'color', 'text' ],
|
|
116
|
-
attributes.style
|
|
117
|
-
),
|
|
118
|
-
} );
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Clears all background color related properties including gradients from
|
|
122
|
-
* supplied block attributes.
|
|
123
|
-
*
|
|
124
|
-
* @param {Object} attributes Block attributes.
|
|
125
|
-
* @return {Object} Block attributes with background and gradient omitted.
|
|
126
|
-
*/
|
|
127
|
-
const clearBackgroundAndGradient = ( attributes ) => ( {
|
|
128
|
-
backgroundColor: undefined,
|
|
129
|
-
gradient: undefined,
|
|
130
|
-
style: {
|
|
131
|
-
...attributes.style,
|
|
132
|
-
color: {
|
|
133
|
-
...attributes.style?.color,
|
|
134
|
-
background: undefined,
|
|
135
|
-
gradient: undefined,
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
} );
|
|
139
|
-
|
|
140
85
|
/**
|
|
141
86
|
* Filters registered block settings, extending attributes to include
|
|
142
87
|
* `backgroundColor` and `textColor` attribute.
|
|
@@ -273,194 +218,112 @@ export function addEditProps( settings ) {
|
|
|
273
218
|
return settings;
|
|
274
219
|
}
|
|
275
220
|
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
],
|
|
306
|
-
[ userPalette, themePalette, defaultPalette ]
|
|
307
|
-
);
|
|
308
|
-
const userGradientPalette = useSetting( 'color.gradients.custom' );
|
|
309
|
-
const themeGradientPalette = useSetting( 'color.gradients.theme' );
|
|
310
|
-
const defaultGradientPalette = useSetting( 'color.gradients.default' );
|
|
311
|
-
const allGradients = useMemo(
|
|
312
|
-
() => [
|
|
313
|
-
...( userGradientPalette || [] ),
|
|
314
|
-
...( themeGradientPalette || [] ),
|
|
315
|
-
...( defaultGradientPalette || [] ),
|
|
316
|
-
],
|
|
317
|
-
[ userGradientPalette, themeGradientPalette, defaultGradientPalette ]
|
|
318
|
-
);
|
|
319
|
-
const areCustomSolidsEnabled = useSetting( 'color.custom' );
|
|
320
|
-
const areCustomGradientsEnabled = useSetting( 'color.customGradient' );
|
|
321
|
-
const isBackgroundEnabled = useSetting( 'color.background' );
|
|
322
|
-
const isLinkEnabled = useSetting( 'color.link' );
|
|
323
|
-
const isTextEnabled = useSetting( 'color.text' );
|
|
324
|
-
|
|
325
|
-
const solidsEnabled =
|
|
326
|
-
areCustomSolidsEnabled || ! themePalette || themePalette?.length > 0;
|
|
327
|
-
|
|
328
|
-
const gradientsEnabled =
|
|
329
|
-
areCustomGradientsEnabled ||
|
|
330
|
-
! themeGradientPalette ||
|
|
331
|
-
themeGradientPalette?.length > 0;
|
|
332
|
-
|
|
333
|
-
// Shouldn't be needed but right now the ColorGradientsPanel
|
|
334
|
-
// can trigger both onChangeColor and onChangeBackground
|
|
335
|
-
// synchronously causing our two callbacks to override changes
|
|
336
|
-
// from each other.
|
|
337
|
-
const localAttributes = useRef( attributes );
|
|
338
|
-
useEffect( () => {
|
|
339
|
-
localAttributes.current = attributes;
|
|
340
|
-
}, [ attributes ] );
|
|
341
|
-
|
|
342
|
-
if ( ! hasColorSupport( blockName ) ) {
|
|
343
|
-
return null;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
const hasLinkColor =
|
|
347
|
-
hasLinkColorSupport( blockName ) && isLinkEnabled && solidsEnabled;
|
|
348
|
-
const hasTextColor =
|
|
349
|
-
hasTextColorSupport( blockName ) && isTextEnabled && solidsEnabled;
|
|
350
|
-
const hasBackgroundColor =
|
|
351
|
-
hasBackgroundColorSupport( blockName ) &&
|
|
352
|
-
isBackgroundEnabled &&
|
|
353
|
-
solidsEnabled;
|
|
354
|
-
const hasGradientColor =
|
|
355
|
-
hasGradientSupport( blockName ) && gradientsEnabled;
|
|
356
|
-
|
|
357
|
-
if (
|
|
358
|
-
! hasLinkColor &&
|
|
359
|
-
! hasTextColor &&
|
|
360
|
-
! hasBackgroundColor &&
|
|
361
|
-
! hasGradientColor
|
|
362
|
-
) {
|
|
363
|
-
return null;
|
|
364
|
-
}
|
|
221
|
+
function styleToAttributes( style ) {
|
|
222
|
+
const textColorValue = style?.color?.text;
|
|
223
|
+
const textColorSlug = textColorValue?.startsWith( 'var:preset|color|' )
|
|
224
|
+
? textColorValue.substring( 'var:preset|color|'.length )
|
|
225
|
+
: undefined;
|
|
226
|
+
const backgroundColorValue = style?.color?.background;
|
|
227
|
+
const backgroundColorSlug = backgroundColorValue?.startsWith(
|
|
228
|
+
'var:preset|color|'
|
|
229
|
+
)
|
|
230
|
+
? backgroundColorValue.substring( 'var:preset|color|'.length )
|
|
231
|
+
: undefined;
|
|
232
|
+
const gradientValue = style?.color?.gradient;
|
|
233
|
+
const gradientSlug = gradientValue?.startsWith( 'var:preset|gradient|' )
|
|
234
|
+
? gradientValue.substring( 'var:preset|gradient|'.length )
|
|
235
|
+
: undefined;
|
|
236
|
+
const updatedStyle = { ...style };
|
|
237
|
+
updatedStyle.color = {
|
|
238
|
+
...updatedStyle.color,
|
|
239
|
+
text: textColorSlug ? undefined : textColorValue,
|
|
240
|
+
background: backgroundColorSlug ? undefined : backgroundColorValue,
|
|
241
|
+
gradient: gradientSlug ? undefined : gradientValue,
|
|
242
|
+
};
|
|
243
|
+
return {
|
|
244
|
+
style: cleanEmptyObject( updatedStyle ),
|
|
245
|
+
textColor: textColorSlug,
|
|
246
|
+
backgroundColor: backgroundColorSlug,
|
|
247
|
+
gradient: gradientSlug,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
365
250
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
251
|
+
function attributesToStyle( attributes ) {
|
|
252
|
+
return {
|
|
253
|
+
...attributes.style,
|
|
254
|
+
color: {
|
|
255
|
+
...attributes.style?.color,
|
|
256
|
+
text: attributes.textColor
|
|
257
|
+
? 'var:preset|color|' + attributes.textColor
|
|
258
|
+
: attributes.style?.color?.text,
|
|
259
|
+
background: attributes.backgroundColor
|
|
260
|
+
? 'var:preset|color|' + attributes.backgroundColor
|
|
261
|
+
: attributes.style?.color?.background,
|
|
262
|
+
gradient: attributes.gradient
|
|
263
|
+
? 'var:preset|gradient|' + attributes.gradient
|
|
264
|
+
: attributes.style?.color?.gradient,
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
}
|
|
373
268
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
...
|
|
381
|
-
|
|
382
|
-
}
|
|
383
|
-
}
|
|
269
|
+
function ColorInspectorControl( { children, resetAllFilter } ) {
|
|
270
|
+
const attributesResetAllFilter = useCallback(
|
|
271
|
+
( attributes ) => {
|
|
272
|
+
const existingStyle = attributesToStyle( attributes );
|
|
273
|
+
const updatedStyle = resetAllFilter( existingStyle );
|
|
274
|
+
return {
|
|
275
|
+
...attributes,
|
|
276
|
+
...styleToAttributes( updatedStyle ),
|
|
277
|
+
};
|
|
278
|
+
},
|
|
279
|
+
[ resetAllFilter ]
|
|
280
|
+
);
|
|
384
281
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
282
|
+
return (
|
|
283
|
+
<InspectorControls
|
|
284
|
+
group="color"
|
|
285
|
+
resetAllFilter={ attributesResetAllFilter }
|
|
286
|
+
>
|
|
287
|
+
{ children }
|
|
288
|
+
</InspectorControls>
|
|
289
|
+
);
|
|
290
|
+
}
|
|
390
291
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
292
|
+
export function ColorEdit( props ) {
|
|
293
|
+
const { clientId, name, attributes, setAttributes } = props;
|
|
294
|
+
const settings = useBlockSettings( name );
|
|
295
|
+
const isEnabled = useHasColorPanel( settings );
|
|
296
|
+
const value = useMemo( () => {
|
|
297
|
+
return attributesToStyle( {
|
|
298
|
+
style: attributes.style,
|
|
299
|
+
textColor: attributes.textColor,
|
|
300
|
+
backgroundColor: attributes.backgroundColor,
|
|
301
|
+
gradient: attributes.gradient,
|
|
302
|
+
} );
|
|
303
|
+
}, [
|
|
304
|
+
attributes.style,
|
|
305
|
+
attributes.textColor,
|
|
306
|
+
attributes.backgroundColor,
|
|
307
|
+
attributes.gradient,
|
|
308
|
+
] );
|
|
397
309
|
|
|
398
|
-
const
|
|
399
|
-
|
|
400
|
-
let newAttributes;
|
|
401
|
-
if ( slug ) {
|
|
402
|
-
const newStyle = {
|
|
403
|
-
...localAttributes.current?.style,
|
|
404
|
-
color: {
|
|
405
|
-
...localAttributes.current?.style?.color,
|
|
406
|
-
gradient: undefined,
|
|
407
|
-
},
|
|
408
|
-
};
|
|
409
|
-
newAttributes = {
|
|
410
|
-
style: cleanEmptyObject( newStyle ),
|
|
411
|
-
gradient: slug,
|
|
412
|
-
};
|
|
413
|
-
} else {
|
|
414
|
-
const newStyle = {
|
|
415
|
-
...localAttributes.current?.style,
|
|
416
|
-
color: {
|
|
417
|
-
...localAttributes.current?.style?.color,
|
|
418
|
-
gradient: value,
|
|
419
|
-
},
|
|
420
|
-
};
|
|
421
|
-
newAttributes = {
|
|
422
|
-
style: cleanEmptyObject( newStyle ),
|
|
423
|
-
gradient: undefined,
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
props.setAttributes( newAttributes );
|
|
427
|
-
localAttributes.current = {
|
|
428
|
-
...localAttributes.current,
|
|
429
|
-
...newAttributes,
|
|
430
|
-
};
|
|
310
|
+
const onChange = ( newStyle ) => {
|
|
311
|
+
setAttributes( styleToAttributes( newStyle ) );
|
|
431
312
|
};
|
|
432
313
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
? `var:preset|color|${ colorObject.slug }`
|
|
437
|
-
: value;
|
|
438
|
-
|
|
439
|
-
const newStyle = cleanEmptyObject(
|
|
440
|
-
immutableSet(
|
|
441
|
-
localAttributes.current?.style,
|
|
442
|
-
[ 'elements', 'link', 'color', 'text' ],
|
|
443
|
-
newLinkColorValue
|
|
444
|
-
)
|
|
445
|
-
);
|
|
446
|
-
props.setAttributes( { style: newStyle } );
|
|
447
|
-
localAttributes.current = {
|
|
448
|
-
...localAttributes.current,
|
|
449
|
-
...{ style: newStyle },
|
|
450
|
-
};
|
|
451
|
-
};
|
|
314
|
+
if ( ! isEnabled ) {
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
452
317
|
|
|
453
|
-
const
|
|
318
|
+
const defaultControls = getBlockSupport( props.name, [
|
|
454
319
|
COLOR_SUPPORT_KEY,
|
|
455
320
|
'__experimentalDefaultControls',
|
|
456
321
|
] );
|
|
457
322
|
|
|
458
323
|
const enableContrastChecking =
|
|
459
324
|
Platform.OS === 'web' &&
|
|
460
|
-
! gradient &&
|
|
461
|
-
|
|
462
|
-
hasBackgroundColor &&
|
|
463
|
-
( hasLinkColor || hasTextColor ) &&
|
|
325
|
+
! value?.color?.gradient &&
|
|
326
|
+
( settings?.color?.text || settings?.color?.link ) &&
|
|
464
327
|
// Contrast checking is enabled by default.
|
|
465
328
|
// Deactivating it requires `enableContrastChecker` to have
|
|
466
329
|
// an explicit value of `false`.
|
|
@@ -471,64 +334,25 @@ export function ColorEdit( props ) {
|
|
|
471
334
|
] );
|
|
472
335
|
|
|
473
336
|
return (
|
|
474
|
-
<
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
: [] ),
|
|
494
|
-
...( hasBackgroundColor || hasGradientColor
|
|
495
|
-
? [
|
|
496
|
-
{
|
|
497
|
-
label: __( 'Background' ),
|
|
498
|
-
onColorChange: hasBackgroundColor
|
|
499
|
-
? onChangeColor( 'background' )
|
|
500
|
-
: undefined,
|
|
501
|
-
colorValue: getColorObjectByAttributeValues(
|
|
502
|
-
allSolids,
|
|
503
|
-
backgroundColor,
|
|
504
|
-
style?.color?.background
|
|
505
|
-
).color,
|
|
506
|
-
gradientValue,
|
|
507
|
-
onGradientChange: hasGradientColor
|
|
508
|
-
? onChangeGradient
|
|
509
|
-
: undefined,
|
|
510
|
-
isShownByDefault:
|
|
511
|
-
defaultColorControls?.background,
|
|
512
|
-
resetAllFilter: clearBackgroundAndGradient,
|
|
513
|
-
},
|
|
514
|
-
]
|
|
515
|
-
: [] ),
|
|
516
|
-
...( hasLinkColor
|
|
517
|
-
? [
|
|
518
|
-
{
|
|
519
|
-
label: __( 'Link' ),
|
|
520
|
-
onColorChange: onChangeLinkColor,
|
|
521
|
-
colorValue: getLinkColorFromAttributeValue(
|
|
522
|
-
allSolids,
|
|
523
|
-
style?.elements?.link?.color?.text
|
|
524
|
-
),
|
|
525
|
-
isShownByDefault: defaultColorControls?.link,
|
|
526
|
-
resetAllFilter: resetAllLinkFilter,
|
|
527
|
-
},
|
|
528
|
-
]
|
|
529
|
-
: [] ),
|
|
530
|
-
] }
|
|
531
|
-
/>
|
|
337
|
+
<StylesColorPanel
|
|
338
|
+
as={ ColorInspectorControl }
|
|
339
|
+
panelId={ clientId }
|
|
340
|
+
settings={ settings }
|
|
341
|
+
value={ value }
|
|
342
|
+
onChange={ onChange }
|
|
343
|
+
defaultControls={ defaultControls }
|
|
344
|
+
enableContrastChecker={
|
|
345
|
+
false !==
|
|
346
|
+
getBlockSupport( props.name, [
|
|
347
|
+
COLOR_SUPPORT_KEY,
|
|
348
|
+
'enableContrastChecker',
|
|
349
|
+
] )
|
|
350
|
+
}
|
|
351
|
+
>
|
|
352
|
+
{ enableContrastChecking && (
|
|
353
|
+
<BlockColorContrastChecker clientId={ clientId } />
|
|
354
|
+
) }
|
|
355
|
+
</StylesColorPanel>
|
|
532
356
|
);
|
|
533
357
|
}
|
|
534
358
|
|
|
@@ -104,9 +104,13 @@ export const withBlockControls = createHigherOrderComponent(
|
|
|
104
104
|
return <BlockEdit { ...props } />;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
const showStopEditingAsBlocks = isEditingAsBlocks && ! isContentLocked;
|
|
108
|
+
const showStartEditingAsBlocks =
|
|
109
|
+
! isEditingAsBlocks && isContentLocked && props.isSelected;
|
|
110
|
+
|
|
107
111
|
return (
|
|
108
112
|
<>
|
|
109
|
-
{
|
|
113
|
+
{ showStopEditingAsBlocks && (
|
|
110
114
|
<>
|
|
111
115
|
<StopEditingAsBlocksOnOutsideSelect
|
|
112
116
|
clientId={ props.clientId }
|
|
@@ -123,7 +127,7 @@ export const withBlockControls = createHigherOrderComponent(
|
|
|
123
127
|
</BlockControls>
|
|
124
128
|
</>
|
|
125
129
|
) }
|
|
126
|
-
{
|
|
130
|
+
{ showStartEditingAsBlocks && (
|
|
127
131
|
<BlockSettingsMenuControls>
|
|
128
132
|
{ ( { onClose } ) => (
|
|
129
133
|
<MenuItem
|
|
@@ -6,45 +6,23 @@ import { useState, useEffect } from '@wordpress/element';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import ColorGradientSettingsDropdown from '../components/colors-gradients/dropdown';
|
|
10
9
|
import ContrastChecker from '../components/contrast-checker';
|
|
11
|
-
import InspectorControls from '../components/inspector-controls';
|
|
12
|
-
import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
|
|
13
10
|
import { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';
|
|
14
11
|
|
|
15
12
|
function getComputedStyle( node ) {
|
|
16
13
|
return node.ownerDocument.defaultView.getComputedStyle( node );
|
|
17
14
|
}
|
|
18
15
|
|
|
19
|
-
export default function
|
|
20
|
-
enableAlpha = false,
|
|
21
|
-
settings,
|
|
22
|
-
clientId,
|
|
23
|
-
enableContrastChecking = true,
|
|
24
|
-
} ) {
|
|
16
|
+
export default function BlockColorContrastChecker( { clientId } ) {
|
|
25
17
|
const [ detectedBackgroundColor, setDetectedBackgroundColor ] = useState();
|
|
26
18
|
const [ detectedColor, setDetectedColor ] = useState();
|
|
27
19
|
const [ detectedLinkColor, setDetectedLinkColor ] = useState();
|
|
28
20
|
const ref = useBlockRef( clientId );
|
|
29
|
-
const definedColors = settings.filter( ( setting ) => setting?.colorValue );
|
|
30
21
|
|
|
22
|
+
// There are so many things that can change the color of a block
|
|
23
|
+
// So we perform this check on every render.
|
|
24
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
25
|
useEffect( () => {
|
|
32
|
-
if ( ! enableContrastChecking ) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
if ( ! definedColors.length ) {
|
|
36
|
-
if ( detectedBackgroundColor ) {
|
|
37
|
-
setDetectedBackgroundColor();
|
|
38
|
-
}
|
|
39
|
-
if ( detectedColor ) {
|
|
40
|
-
setDetectedColor();
|
|
41
|
-
}
|
|
42
|
-
if ( detectedLinkColor ) {
|
|
43
|
-
setDetectedColor();
|
|
44
|
-
}
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
26
|
if ( ! ref.current ) {
|
|
49
27
|
return;
|
|
50
28
|
}
|
|
@@ -72,26 +50,12 @@ export default function ColorPanel( {
|
|
|
72
50
|
setDetectedBackgroundColor( backgroundColor );
|
|
73
51
|
} );
|
|
74
52
|
|
|
75
|
-
const colorGradientSettings = useMultipleOriginColorsAndGradients();
|
|
76
|
-
|
|
77
53
|
return (
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
__experimentalIsRenderedInSidebar
|
|
85
|
-
{ ...colorGradientSettings }
|
|
86
|
-
/>
|
|
87
|
-
{ enableContrastChecking && (
|
|
88
|
-
<ContrastChecker
|
|
89
|
-
backgroundColor={ detectedBackgroundColor }
|
|
90
|
-
textColor={ detectedColor }
|
|
91
|
-
enableAlphaChecker={ enableAlpha }
|
|
92
|
-
linkColor={ detectedLinkColor }
|
|
93
|
-
/>
|
|
94
|
-
) }
|
|
95
|
-
</InspectorControls>
|
|
54
|
+
<ContrastChecker
|
|
55
|
+
backgroundColor={ detectedBackgroundColor }
|
|
56
|
+
textColor={ detectedColor }
|
|
57
|
+
enableAlphaChecker
|
|
58
|
+
linkColor={ detectedLinkColor }
|
|
59
|
+
/>
|
|
96
60
|
);
|
|
97
61
|
}
|
|
@@ -18,8 +18,7 @@ import { createHigherOrderComponent } from '@wordpress/compose';
|
|
|
18
18
|
import { InspectorControls } from '../components';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* Filters registered block settings, extending attributes
|
|
22
|
-
* of the first node.
|
|
21
|
+
* Filters registered block settings, extending attributes to include `className`.
|
|
23
22
|
*
|
|
24
23
|
* @param {Object} settings Original block settings.
|
|
25
24
|
*
|
|
@@ -42,6 +41,7 @@ export function addAttribute( settings ) {
|
|
|
42
41
|
/**
|
|
43
42
|
* Override the default edit UI to include a new block inspector control for
|
|
44
43
|
* assigning the custom class name, if block supports custom class name.
|
|
44
|
+
* The control is displayed within the Advanced panel in the block inspector.
|
|
45
45
|
*
|
|
46
46
|
* @param {WPComponent} BlockEdit Original component.
|
|
47
47
|
*
|
|
@@ -89,8 +89,8 @@ export const withInspectorControl = createHigherOrderComponent(
|
|
|
89
89
|
);
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
* Override props assigned to save component to inject
|
|
93
|
-
* supports
|
|
92
|
+
* Override props assigned to save component to inject the className, if block
|
|
93
|
+
* supports customClassName. This is only applied if the block's save result is an
|
|
94
94
|
* element and not a markup string.
|
|
95
95
|
*
|
|
96
96
|
* @param {Object} extraProps Additional props applied to save element.
|
|
@@ -10,8 +10,7 @@ import { addFilter } from '@wordpress/hooks';
|
|
|
10
10
|
import { hasBlockSupport } from '@wordpress/blocks';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Filters registered block settings, extending attributes
|
|
14
|
-
* of the first node.
|
|
13
|
+
* Filters registered block settings, extending attributes to include `className`.
|
|
15
14
|
*
|
|
16
15
|
* @param {Object} settings Original block settings.
|
|
17
16
|
*
|
|
@@ -32,8 +31,8 @@ export function addAttribute( settings ) {
|
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
/**
|
|
35
|
-
* Override props assigned to save component to inject
|
|
36
|
-
* supports
|
|
34
|
+
* Override props assigned to save component to inject the className, if block
|
|
35
|
+
* supports customClassName. This is only applied if the block's save result is an
|
|
37
36
|
* element and not a markup string.
|
|
38
37
|
*
|
|
39
38
|
* @param {Object} extraProps Additional props applied to save element.
|
package/src/hooks/dimensions.js
CHANGED
package/src/hooks/duotone.js
CHANGED
|
@@ -8,7 +8,11 @@ import namesPlugin from 'colord/plugins/names';
|
|
|
8
8
|
/**
|
|
9
9
|
* WordPress dependencies
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
getBlockSupport,
|
|
13
|
+
getBlockType,
|
|
14
|
+
hasBlockSupport,
|
|
15
|
+
} from '@wordpress/blocks';
|
|
12
16
|
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
|
|
13
17
|
import { addFilter } from '@wordpress/hooks';
|
|
14
18
|
import { useMemo, useContext, createPortal } from '@wordpress/element';
|
|
@@ -269,10 +273,9 @@ function BlockDuotoneStyles( { name, duotoneStyle, id } ) {
|
|
|
269
273
|
colors = getColorsFromDuotonePreset( colors, duotonePalette );
|
|
270
274
|
}
|
|
271
275
|
|
|
272
|
-
const duotoneSupportSelectors =
|
|
273
|
-
name
|
|
274
|
-
'color.__experimentalDuotone'
|
|
275
|
-
);
|
|
276
|
+
const duotoneSupportSelectors =
|
|
277
|
+
getBlockType( name ).selectors?.filter?.duotone ||
|
|
278
|
+
getBlockSupport( name, 'color.__experimentalDuotone' );
|
|
276
279
|
|
|
277
280
|
// Extra .editor-styles-wrapper specificity is needed in the editor
|
|
278
281
|
// since we're not using inline styles to apply the filter. We need to
|