@wordpress/block-editor 11.3.6 → 11.5.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 +3 -1
- package/build/components/block-lock/modal.js +1 -0
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-popover/inbetween.js +10 -33
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/index.js +2 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-types-list/index.native.js +2 -0
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/child-layout-control/index.js +107 -0
- package/build/components/child-layout-control/index.js.map +1 -0
- package/build/components/colors-gradients/control.js +6 -3
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/date-format-picker/index.js +3 -3
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +0 -3
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +594 -0
- package/build/components/global-styles/dimensions-panel.js.map +1 -0
- package/build/components/global-styles/hooks.js +142 -45
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +38 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +434 -0
- package/build/components/global-styles/typography-panel.js.map +1 -0
- package/build/components/global-styles/use-global-styles-output.js +7 -3
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/iframe/index.js +17 -11
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js +2 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build/components/image-size-control/index.js +6 -11
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/index.native.js +23 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +9 -15
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.native.js +4 -1
- package/build/components/inserter/block-types-tab.native.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +4 -1
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/search-results.native.js +4 -1
- package/build/components/inserter/search-results.native.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.js +38 -9
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/link-control/index.js +55 -28
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +72 -30
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/link-control/settings.js +53 -0
- package/build/components/link-control/settings.js.map +1 -0
- package/build/components/list-view/block.js +4 -2
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/expander.js +2 -1
- package/build/components/list-view/expander.js.map +1 -1
- package/build/components/list-view/index.js +6 -1
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +5 -10
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +3 -2
- package/build/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +1 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +7 -3
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js +24 -4
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build/components/off-canvas-editor/link-ui.js +2 -0
- package/build/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build/components/responsive-block-control/index.js +1 -0
- package/build/components/responsive-block-control/index.js.map +1 -1
- package/build/components/rich-text/index.js +9 -45
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-delete.js +73 -0
- package/build/components/rich-text/use-delete.js.map +1 -0
- package/build/components/rich-text/use-input-rules.js +14 -6
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/url-input/index.js +2 -2
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +4 -1
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/hooks/align.js +3 -1
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/dimensions.js +78 -190
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +94 -25
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-family.js +2 -76
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +3 -51
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/gap.js +0 -201
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +14 -5
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/line-height.js +0 -42
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/margin.js +7 -163
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +7 -163
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/typography.js +98 -128
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +75 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/flex.js +1 -0
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +24 -12
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +53 -47
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +22 -1
- package/build/store/selectors.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +36 -3
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/components/block-lock/modal.js +1 -0
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +10 -33
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/index.js +2 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +2 -0
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +98 -0
- package/build-module/components/child-layout-control/index.js.map +1 -0
- package/build-module/components/colors-gradients/control.js +6 -3
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +4 -4
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +2 -1
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +574 -0
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +138 -46
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +3 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +415 -0
- package/build-module/components/global-styles/typography-panel.js.map +1 -0
- package/build-module/components/global-styles/use-global-styles-output.js +7 -3
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +17 -11
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +2 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/components/image-size-control/index.js +7 -12
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/index.native.js +2 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +9 -15
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.native.js +3 -1
- package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +3 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/search-results.native.js +3 -1
- package/build-module/components/inserter/search-results.native.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +39 -9
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/link-control/index.js +56 -28
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +68 -30
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/link-control/settings.js +44 -0
- package/build-module/components/link-control/settings.js.map +1 -0
- package/build-module/components/list-view/block.js +4 -2
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/expander.js +2 -1
- package/build-module/components/list-view/expander.js.map +1 -1
- package/build-module/components/list-view/index.js +6 -1
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +5 -10
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +3 -2
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +1 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +7 -3
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js +27 -7
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build-module/components/off-canvas-editor/link-ui.js +2 -0
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build-module/components/responsive-block-control/index.js +1 -0
- package/build-module/components/responsive-block-control/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +9 -45
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-delete.js +62 -0
- package/build-module/components/rich-text/use-delete.js.map +1 -0
- package/build-module/components/rich-text/use-input-rules.js +14 -6
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/url-input/index.js +2 -2
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +4 -1
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/hooks/align.js +3 -1
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/dimensions.js +81 -187
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +86 -24
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-family.js +3 -69
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +6 -47
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/gap.js +0 -182
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +14 -5
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/line-height.js +0 -38
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/margin.js +4 -143
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +4 -143
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/typography.js +97 -123
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +70 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/flex.js +1 -0
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +24 -12
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +53 -45
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +22 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +36 -3
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +54 -64
- package/build-style/style.css +54 -64
- package/package.json +31 -31
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
- package/src/components/block-lock/modal.js +1 -0
- package/src/components/block-lock/style.scss +0 -9
- package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +15 -15
- package/src/components/block-popover/inbetween.js +21 -53
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/src/components/block-styles/index.js +5 -1
- package/src/components/block-types-list/index.native.js +2 -0
- package/src/components/child-layout-control/index.js +106 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/colors-gradients/control.js +3 -0
- package/src/components/date-format-picker/index.js +6 -8
- package/src/components/date-format-picker/style.scss +0 -5
- package/src/components/font-appearance-control/index.js +1 -1
- package/src/components/global-styles/dimensions-panel.js +627 -0
- package/src/components/global-styles/hooks.js +229 -66
- package/src/components/global-styles/index.js +9 -0
- package/src/components/global-styles/typography-panel.js +428 -0
- package/src/components/global-styles/use-global-styles-output.js +10 -5
- package/src/components/global-styles/utils.js +2 -0
- package/src/components/iframe/index.js +20 -18
- package/src/components/image-editor/aspect-ratio-dropdown.js +1 -0
- package/src/components/image-size-control/index.js +10 -12
- package/src/components/image-size-control/style.scss +3 -21
- package/src/components/index.native.js +5 -0
- package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
- package/src/components/inserter/block-patterns-tab.js +9 -23
- package/src/components/inserter/block-types-tab.native.js +2 -0
- package/src/components/inserter/reusable-blocks-tab.native.js +2 -0
- package/src/components/inserter/search-results.native.js +2 -0
- package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
- package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
- package/src/components/inspector-controls/fill.js +32 -8
- package/src/components/link-control/index.js +69 -34
- package/src/components/link-control/settings-drawer.js +85 -29
- package/src/components/link-control/settings.js +42 -0
- package/src/components/link-control/style.scss +63 -37
- package/src/components/link-control/test/index.js +347 -9
- package/src/components/list-view/block.js +7 -1
- package/src/components/list-view/expander.js +1 -0
- package/src/components/list-view/index.js +5 -0
- package/src/components/media-replace-flow/style.scss +7 -9
- package/src/components/media-replace-flow/test/index.js +1 -1
- package/src/components/off-canvas-editor/appender.js +13 -16
- package/src/components/off-canvas-editor/block-contents.js +2 -1
- package/src/components/off-canvas-editor/branch.js +1 -0
- package/src/components/off-canvas-editor/index.js +8 -2
- package/src/components/off-canvas-editor/leaf-more-menu.js +52 -15
- package/src/components/off-canvas-editor/link-ui.js +2 -0
- package/src/components/responsive-block-control/index.js +1 -0
- package/src/components/rich-text/index.js +8 -46
- package/src/components/rich-text/use-delete.js +59 -0
- package/src/components/rich-text/use-input-rules.js +13 -5
- package/src/components/url-input/index.js +3 -2
- package/src/components/url-popover/stories/index.js +1 -0
- package/src/components/writing-flow/use-selection-observer.js +5 -1
- package/src/hooks/align.js +1 -1
- package/src/hooks/dimensions.js +97 -269
- package/src/hooks/duotone.js +100 -30
- package/src/hooks/font-family.js +0 -58
- package/src/hooks/font-size.js +1 -36
- package/src/hooks/gap.js +0 -201
- package/src/hooks/index.js +1 -0
- package/src/hooks/layout.js +19 -6
- package/src/hooks/line-height.js +0 -33
- package/src/hooks/margin.js +1 -164
- package/src/hooks/padding.js +1 -163
- package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
- package/src/hooks/test/duotone.js +102 -0
- package/src/hooks/typography.js +112 -213
- package/src/hooks/utils.js +90 -0
- package/src/layouts/flex.js +1 -0
- package/src/store/actions.js +12 -4
- package/src/store/reducer.js +68 -43
- package/src/store/selectors.js +20 -1
- package/src/store/test/actions.js +4 -2
- package/src/utils/parse-css-unit-to-px.js +35 -5
- package/src/utils/test/parse-css-unit-to-px.js +12 -0
- package/build/hooks/child-layout.js +0 -213
- package/build/hooks/child-layout.js.map +0 -1
- package/build/hooks/font-appearance.js +0 -188
- package/build/hooks/font-appearance.js.map +0 -1
- package/build/hooks/letter-spacing.js +0 -129
- package/build/hooks/letter-spacing.js.map +0 -1
- package/build/hooks/min-height.js +0 -139
- package/build/hooks/min-height.js.map +0 -1
- package/build/hooks/text-decoration.js +0 -130
- package/build/hooks/text-decoration.js.map +0 -1
- package/build/hooks/text-transform.js +0 -130
- package/build/hooks/text-transform.js.map +0 -1
- package/build-module/hooks/child-layout.js +0 -193
- package/build-module/hooks/child-layout.js.map +0 -1
- package/build-module/hooks/font-appearance.js +0 -161
- package/build-module/hooks/font-appearance.js.map +0 -1
- package/build-module/hooks/letter-spacing.js +0 -107
- package/build-module/hooks/letter-spacing.js.map +0 -1
- package/build-module/hooks/min-height.js +0 -116
- package/build-module/hooks/min-height.js.map +0 -1
- package/build-module/hooks/text-decoration.js +0 -108
- package/build-module/hooks/text-decoration.js.map +0 -1
- package/build-module/hooks/text-transform.js +0 -108
- package/build-module/hooks/text-transform.js.map +0 -1
- package/src/hooks/child-layout.js +0 -195
- package/src/hooks/font-appearance.js +0 -146
- package/src/hooks/letter-spacing.js +0 -101
- package/src/hooks/min-height.js +0 -104
- package/src/hooks/text-decoration.js +0 -102
- package/src/hooks/text-transform.js +0 -101
package/src/hooks/dimensions.js
CHANGED
|
@@ -1,109 +1,89 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
9
|
-
import {
|
|
10
|
-
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
11
|
-
__experimentalVStack as VStack,
|
|
12
|
-
} from '@wordpress/components';
|
|
13
|
-
import { Platform, useState } from '@wordpress/element';
|
|
14
|
-
import { __ } from '@wordpress/i18n';
|
|
15
|
-
import { getBlockSupport } from '@wordpress/blocks';
|
|
4
|
+
import { useState, useEffect, useCallback } from '@wordpress/element';
|
|
16
5
|
import { useDispatch } from '@wordpress/data';
|
|
6
|
+
import { getBlockSupport } from '@wordpress/blocks';
|
|
7
|
+
import deprecated from '@wordpress/deprecated';
|
|
17
8
|
|
|
18
9
|
/**
|
|
19
10
|
* Internal dependencies
|
|
20
11
|
*/
|
|
21
12
|
import InspectorControls from '../components/inspector-controls';
|
|
22
13
|
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
} from './gap';
|
|
29
|
-
import {
|
|
30
|
-
MarginEdit,
|
|
31
|
-
MarginVisualizer,
|
|
32
|
-
hasMarginSupport,
|
|
33
|
-
hasMarginValue,
|
|
34
|
-
resetMargin,
|
|
35
|
-
useIsMarginDisabled,
|
|
36
|
-
} from './margin';
|
|
37
|
-
import {
|
|
38
|
-
MinHeightEdit,
|
|
39
|
-
hasMinHeightSupport,
|
|
40
|
-
hasMinHeightValue,
|
|
41
|
-
resetMinHeight,
|
|
42
|
-
useIsMinHeightDisabled,
|
|
43
|
-
} from './min-height';
|
|
44
|
-
import {
|
|
45
|
-
PaddingEdit,
|
|
46
|
-
PaddingVisualizer,
|
|
47
|
-
hasPaddingSupport,
|
|
48
|
-
hasPaddingValue,
|
|
49
|
-
resetPadding,
|
|
50
|
-
useIsPaddingDisabled,
|
|
51
|
-
} from './padding';
|
|
52
|
-
import {
|
|
53
|
-
ChildLayoutEdit,
|
|
54
|
-
hasChildLayoutSupport,
|
|
55
|
-
hasChildLayoutValue,
|
|
56
|
-
resetChildLayout,
|
|
57
|
-
useIsChildLayoutDisabled,
|
|
58
|
-
childLayoutOrientation,
|
|
59
|
-
} from './child-layout';
|
|
60
|
-
import useSetting from '../components/use-setting';
|
|
14
|
+
DimensionsPanel as StylesDimensionsPanel,
|
|
15
|
+
useHasDimensionsPanel,
|
|
16
|
+
} from '../components/global-styles';
|
|
17
|
+
import { MarginVisualizer } from './margin';
|
|
18
|
+
import { PaddingVisualizer } from './padding';
|
|
61
19
|
import { store as blockEditorStore } from '../store';
|
|
62
20
|
import { unlock } from '../lock-unlock';
|
|
63
21
|
|
|
22
|
+
import { cleanEmptyObject, useBlockSettings } from './utils';
|
|
23
|
+
|
|
64
24
|
export const DIMENSIONS_SUPPORT_KEY = 'dimensions';
|
|
65
25
|
export const SPACING_SUPPORT_KEY = 'spacing';
|
|
66
26
|
export const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];
|
|
67
27
|
export const AXIAL_SIDES = [ 'vertical', 'horizontal' ];
|
|
68
28
|
|
|
69
|
-
function
|
|
70
|
-
const [
|
|
29
|
+
function useVisualizer() {
|
|
30
|
+
const [ property, setProperty ] = useState( false );
|
|
71
31
|
const { hideBlockInterface, showBlockInterface } = unlock(
|
|
72
32
|
useDispatch( blockEditorStore )
|
|
73
33
|
);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
34
|
+
useEffect( () => {
|
|
35
|
+
if ( ! property ) {
|
|
36
|
+
showBlockInterface();
|
|
37
|
+
} else {
|
|
38
|
+
hideBlockInterface();
|
|
39
|
+
}
|
|
40
|
+
}, [ property, showBlockInterface, hideBlockInterface ] );
|
|
41
|
+
|
|
42
|
+
return [ property, setProperty ];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function DimensionsInspectorControl( { children, resetAllFilter } ) {
|
|
46
|
+
const attributesResetAllFilter = useCallback(
|
|
47
|
+
( attributes ) => {
|
|
48
|
+
const existingStyle = attributes.style;
|
|
49
|
+
const updatedStyle = resetAllFilter( existingStyle );
|
|
50
|
+
return {
|
|
51
|
+
...attributes,
|
|
52
|
+
style: updatedStyle,
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
[ resetAllFilter ]
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<InspectorControls
|
|
60
|
+
group="dimensions"
|
|
61
|
+
resetAllFilter={ attributesResetAllFilter }
|
|
62
|
+
>
|
|
63
|
+
{ children }
|
|
64
|
+
</InspectorControls>
|
|
65
|
+
);
|
|
85
66
|
}
|
|
86
67
|
|
|
87
|
-
/**
|
|
88
|
-
* Inspector controls for dimensions support.
|
|
89
|
-
*
|
|
90
|
-
* @param {Object} props Block props.
|
|
91
|
-
*
|
|
92
|
-
* @return {WPElement} Inspector controls for dimensions and spacing support features.
|
|
93
|
-
*/
|
|
94
68
|
export function DimensionsPanel( props ) {
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
const
|
|
69
|
+
const {
|
|
70
|
+
clientId,
|
|
71
|
+
name,
|
|
72
|
+
attributes,
|
|
73
|
+
setAttributes,
|
|
74
|
+
__unstableParentLayout,
|
|
75
|
+
} = props;
|
|
76
|
+
const settings = useBlockSettings( name, __unstableParentLayout );
|
|
77
|
+
const isEnabled = useHasDimensionsPanel( settings );
|
|
78
|
+
const value = attributes.style;
|
|
79
|
+
const [ visualizedProperty, setVisualizedProperty ] = useVisualizer();
|
|
80
|
+
const onChange = ( newStyle ) => {
|
|
81
|
+
setAttributes( {
|
|
82
|
+
style: cleanEmptyObject( newStyle ),
|
|
83
|
+
} );
|
|
84
|
+
};
|
|
105
85
|
|
|
106
|
-
if (
|
|
86
|
+
if ( ! isEnabled ) {
|
|
107
87
|
return null;
|
|
108
88
|
}
|
|
109
89
|
|
|
@@ -111,133 +91,36 @@ export function DimensionsPanel( props ) {
|
|
|
111
91
|
DIMENSIONS_SUPPORT_KEY,
|
|
112
92
|
'__experimentalDefaultControls',
|
|
113
93
|
] );
|
|
114
|
-
|
|
115
94
|
const defaultSpacingControls = getBlockSupport( props.name, [
|
|
116
95
|
SPACING_SUPPORT_KEY,
|
|
117
96
|
'__experimentalDefaultControls',
|
|
118
97
|
] );
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
style: {
|
|
124
|
-
...newAttributes.style,
|
|
125
|
-
[ featureSet ]: {
|
|
126
|
-
...newAttributes.style?.[ featureSet ],
|
|
127
|
-
[ attribute ]: undefined,
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
} );
|
|
131
|
-
|
|
132
|
-
const spacingClassnames = classnames( {
|
|
133
|
-
'tools-panel-item-spacing': spacingSizes && spacingSizes.length > 0,
|
|
134
|
-
} );
|
|
135
|
-
|
|
136
|
-
const { __unstableParentLayout: parentLayout } = props;
|
|
98
|
+
const defaultControls = {
|
|
99
|
+
...defaultDimensionsControls,
|
|
100
|
+
...defaultSpacingControls,
|
|
101
|
+
};
|
|
137
102
|
|
|
138
103
|
return (
|
|
139
104
|
<>
|
|
140
|
-
<
|
|
141
|
-
{
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
isShownByDefault={ defaultSpacingControls?.padding }
|
|
152
|
-
panelId={ props.clientId }
|
|
153
|
-
>
|
|
154
|
-
<PaddingEdit
|
|
155
|
-
onMouseOver={ paddingMouseOver.onMouseOver }
|
|
156
|
-
onMouseOut={ paddingMouseOver.onMouseOut }
|
|
157
|
-
{ ...props }
|
|
158
|
-
/>
|
|
159
|
-
</ToolsPanelItem>
|
|
160
|
-
) }
|
|
161
|
-
{ ! isMarginDisabled && (
|
|
162
|
-
<ToolsPanelItem
|
|
163
|
-
className={ spacingClassnames }
|
|
164
|
-
hasValue={ () => hasMarginValue( props ) }
|
|
165
|
-
label={ __( 'Margin' ) }
|
|
166
|
-
onDeselect={ () => resetMargin( props ) }
|
|
167
|
-
resetAllFilter={ createResetAllFilter(
|
|
168
|
-
'margin',
|
|
169
|
-
'spacing'
|
|
170
|
-
) }
|
|
171
|
-
isShownByDefault={ defaultSpacingControls?.margin }
|
|
172
|
-
panelId={ props.clientId }
|
|
173
|
-
>
|
|
174
|
-
<MarginEdit
|
|
175
|
-
onMouseOver={ marginMouseOver.onMouseOver }
|
|
176
|
-
onMouseOut={ marginMouseOver.onMouseOut }
|
|
177
|
-
{ ...props }
|
|
178
|
-
/>
|
|
179
|
-
</ToolsPanelItem>
|
|
180
|
-
) }
|
|
181
|
-
{ ! isGapDisabled && (
|
|
182
|
-
<ToolsPanelItem
|
|
183
|
-
className={ spacingClassnames }
|
|
184
|
-
hasValue={ () => hasGapValue( props ) }
|
|
185
|
-
label={ __( 'Block spacing' ) }
|
|
186
|
-
onDeselect={ () => resetGap( props ) }
|
|
187
|
-
resetAllFilter={ createResetAllFilter(
|
|
188
|
-
'blockGap',
|
|
189
|
-
'spacing'
|
|
190
|
-
) }
|
|
191
|
-
isShownByDefault={ defaultSpacingControls?.blockGap }
|
|
192
|
-
panelId={ props.clientId }
|
|
193
|
-
>
|
|
194
|
-
<GapEdit { ...props } />
|
|
195
|
-
</ToolsPanelItem>
|
|
196
|
-
) }
|
|
197
|
-
{ ! isMinHeightDisabled && (
|
|
198
|
-
<ToolsPanelItem
|
|
199
|
-
hasValue={ () => hasMinHeightValue( props ) }
|
|
200
|
-
label={ __( 'Min. height' ) }
|
|
201
|
-
onDeselect={ () => resetMinHeight( props ) }
|
|
202
|
-
resetAllFilter={ createResetAllFilter(
|
|
203
|
-
'minHeight',
|
|
204
|
-
'dimensions'
|
|
205
|
-
) }
|
|
206
|
-
isShownByDefault={
|
|
207
|
-
defaultDimensionsControls?.minHeight
|
|
208
|
-
}
|
|
209
|
-
panelId={ props.clientId }
|
|
210
|
-
>
|
|
211
|
-
<MinHeightEdit { ...props } />
|
|
212
|
-
</ToolsPanelItem>
|
|
213
|
-
) }
|
|
214
|
-
{ ! isChildLayoutDisabled && (
|
|
215
|
-
<VStack
|
|
216
|
-
as={ ToolsPanelItem }
|
|
217
|
-
spacing={ 2 }
|
|
218
|
-
hasValue={ () => hasChildLayoutValue( props ) }
|
|
219
|
-
label={ childLayoutOrientation( parentLayout ) }
|
|
220
|
-
onDeselect={ () => resetChildLayout( props ) }
|
|
221
|
-
resetAllFilter={ createResetAllFilter(
|
|
222
|
-
'selfStretch',
|
|
223
|
-
'layout'
|
|
224
|
-
) }
|
|
225
|
-
isShownByDefault={ false }
|
|
226
|
-
panelId={ props.clientId }
|
|
227
|
-
>
|
|
228
|
-
<ChildLayoutEdit { ...props } />
|
|
229
|
-
</VStack>
|
|
230
|
-
) }
|
|
231
|
-
</InspectorControls>
|
|
232
|
-
{ ! isPaddingDisabled && (
|
|
105
|
+
<StylesDimensionsPanel
|
|
106
|
+
as={ DimensionsInspectorControl }
|
|
107
|
+
panelId={ clientId }
|
|
108
|
+
name={ name }
|
|
109
|
+
settings={ settings }
|
|
110
|
+
value={ value }
|
|
111
|
+
onChange={ onChange }
|
|
112
|
+
defaultControls={ defaultControls }
|
|
113
|
+
onVisualize={ setVisualizedProperty }
|
|
114
|
+
/>
|
|
115
|
+
{ !! settings?.spacing?.padding && (
|
|
233
116
|
<PaddingVisualizer
|
|
234
|
-
forceShow={
|
|
117
|
+
forceShow={ visualizedProperty === 'padding' }
|
|
235
118
|
{ ...props }
|
|
236
119
|
/>
|
|
237
120
|
) }
|
|
238
|
-
{
|
|
121
|
+
{ !! settings?.spacing?.margin && (
|
|
239
122
|
<MarginVisualizer
|
|
240
|
-
forceShow={
|
|
123
|
+
forceShow={ visualizedProperty === 'margin' }
|
|
241
124
|
{ ...props }
|
|
242
125
|
/>
|
|
243
126
|
) }
|
|
@@ -246,80 +129,13 @@ export function DimensionsPanel( props ) {
|
|
|
246
129
|
}
|
|
247
130
|
|
|
248
131
|
/**
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
* @param {Object} props Block props.
|
|
252
|
-
*
|
|
253
|
-
* @return {boolean} Whether there is support.
|
|
254
|
-
*/
|
|
255
|
-
export function hasDimensionsSupport( props ) {
|
|
256
|
-
if ( Platform.OS !== 'web' ) {
|
|
257
|
-
return false;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
const { name: blockName } = props;
|
|
261
|
-
|
|
262
|
-
return (
|
|
263
|
-
hasGapSupport( blockName ) ||
|
|
264
|
-
hasMinHeightSupport( blockName ) ||
|
|
265
|
-
hasPaddingSupport( blockName ) ||
|
|
266
|
-
hasMarginSupport( blockName ) ||
|
|
267
|
-
hasChildLayoutSupport( props )
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Determines whether dimensions support has been disabled.
|
|
273
|
-
*
|
|
274
|
-
* @param {Object} props Block properties.
|
|
275
|
-
*
|
|
276
|
-
* @return {boolean} If spacing support is completely disabled.
|
|
277
|
-
*/
|
|
278
|
-
const useIsDimensionsDisabled = ( props = {} ) => {
|
|
279
|
-
const gapDisabled = useIsGapDisabled( props );
|
|
280
|
-
const minHeightDisabled = useIsMinHeightDisabled( props );
|
|
281
|
-
const paddingDisabled = useIsPaddingDisabled( props );
|
|
282
|
-
const marginDisabled = useIsMarginDisabled( props );
|
|
283
|
-
const childLayoutDisabled = useIsChildLayoutDisabled( props );
|
|
284
|
-
|
|
285
|
-
return (
|
|
286
|
-
gapDisabled &&
|
|
287
|
-
minHeightDisabled &&
|
|
288
|
-
paddingDisabled &&
|
|
289
|
-
marginDisabled &&
|
|
290
|
-
childLayoutDisabled
|
|
291
|
-
);
|
|
292
|
-
};
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Custom hook to retrieve which padding/margin/blockGap is supported
|
|
296
|
-
* e.g. top, right, bottom or left.
|
|
297
|
-
*
|
|
298
|
-
* Sides are opted into by default. It is only if a specific side is set to
|
|
299
|
-
* false that it is omitted.
|
|
300
|
-
*
|
|
301
|
-
* @param {string} blockName Block name.
|
|
302
|
-
* @param {string} feature The feature custom sides relate to e.g. padding or margins.
|
|
303
|
-
*
|
|
304
|
-
* @return {string[] | undefined} Strings representing the custom sides available.
|
|
132
|
+
* @deprecated
|
|
305
133
|
*/
|
|
306
|
-
export function useCustomSides(
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// Return if the setting is an array of sides (e.g. `[ 'top', 'bottom' ]`).
|
|
315
|
-
if ( Array.isArray( support[ feature ] ) ) {
|
|
316
|
-
return support[ feature ];
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
// Finally, attempt to return `.sides` if the setting is an object.
|
|
320
|
-
if ( support[ feature ]?.sides ) {
|
|
321
|
-
return support[ feature ].sides;
|
|
322
|
-
}
|
|
134
|
+
export function useCustomSides() {
|
|
135
|
+
deprecated( 'wp.blockEditor.__experimentalUseCustomSides', {
|
|
136
|
+
since: '6.3',
|
|
137
|
+
version: '6.4',
|
|
138
|
+
} );
|
|
323
139
|
}
|
|
324
140
|
|
|
325
141
|
/**
|
|
@@ -347,5 +163,17 @@ export function useIsDimensionsSupportValid( blockName, feature ) {
|
|
|
347
163
|
return false;
|
|
348
164
|
}
|
|
349
165
|
|
|
166
|
+
if (
|
|
167
|
+
sides?.length &&
|
|
168
|
+
feature === 'blockGap' &&
|
|
169
|
+
! AXIAL_SIDES.every( ( side ) => sides.includes( side ) )
|
|
170
|
+
) {
|
|
171
|
+
// eslint-disable-next-line no-console
|
|
172
|
+
console.warn(
|
|
173
|
+
`The ${ feature } support for the "${ blockName }" block can not be configured to support arbitrary sides.`
|
|
174
|
+
);
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
|
|
350
178
|
return true;
|
|
351
179
|
}
|
package/src/hooks/duotone.js
CHANGED
|
@@ -75,9 +75,34 @@ function useMultiOriginPresets( { presetSetting, defaultSetting } ) {
|
|
|
75
75
|
);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
export function getColorsFromDuotonePreset( duotone, duotonePalette ) {
|
|
79
|
+
if ( ! duotone ) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const preset = duotonePalette?.find( ( { slug } ) => {
|
|
83
|
+
return duotone === `var:preset|duotone|${ slug }`;
|
|
84
|
+
} );
|
|
85
|
+
|
|
86
|
+
return preset ? preset.colors : undefined;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function getDuotonePresetFromColors( colors, duotonePalette ) {
|
|
90
|
+
if ( ! colors || ! Array.isArray( colors ) ) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const preset = duotonePalette?.find( ( duotonePreset ) => {
|
|
95
|
+
return duotonePreset?.colors?.every(
|
|
96
|
+
( val, index ) => val === colors[ index ]
|
|
97
|
+
);
|
|
98
|
+
} );
|
|
99
|
+
|
|
100
|
+
return preset ? `var:preset|duotone|${ preset.slug }` : undefined;
|
|
101
|
+
}
|
|
102
|
+
|
|
78
103
|
function DuotonePanel( { attributes, setAttributes } ) {
|
|
79
104
|
const style = attributes?.style;
|
|
80
|
-
const
|
|
105
|
+
const duotoneStyle = style?.color?.duotone;
|
|
81
106
|
|
|
82
107
|
const duotonePalette = useMultiOriginPresets( {
|
|
83
108
|
presetSetting: 'color.duotone',
|
|
@@ -96,6 +121,10 @@ function DuotonePanel( { attributes, setAttributes } ) {
|
|
|
96
121
|
return null;
|
|
97
122
|
}
|
|
98
123
|
|
|
124
|
+
const duotonePresetOrColors = ! Array.isArray( duotoneStyle )
|
|
125
|
+
? getColorsFromDuotonePreset( duotoneStyle, duotonePalette )
|
|
126
|
+
: duotoneStyle;
|
|
127
|
+
|
|
99
128
|
return (
|
|
100
129
|
<BlockControls group="block" __experimentalShareWithChildBlocks>
|
|
101
130
|
<DuotoneControl
|
|
@@ -103,13 +132,18 @@ function DuotonePanel( { attributes, setAttributes } ) {
|
|
|
103
132
|
colorPalette={ colorPalette }
|
|
104
133
|
disableCustomDuotone={ disableCustomDuotone }
|
|
105
134
|
disableCustomColors={ disableCustomColors }
|
|
106
|
-
value={
|
|
135
|
+
value={ duotonePresetOrColors }
|
|
107
136
|
onChange={ ( newDuotone ) => {
|
|
137
|
+
const maybePreset = getDuotonePresetFromColors(
|
|
138
|
+
newDuotone,
|
|
139
|
+
duotonePalette
|
|
140
|
+
);
|
|
141
|
+
|
|
108
142
|
const newStyle = {
|
|
109
143
|
...style,
|
|
110
144
|
color: {
|
|
111
145
|
...style?.color,
|
|
112
|
-
duotone: newDuotone,
|
|
146
|
+
duotone: maybePreset ?? newDuotone, // use preset or fallback to custom colors.
|
|
113
147
|
},
|
|
114
148
|
};
|
|
115
149
|
setAttributes( { style: newStyle } );
|
|
@@ -168,12 +202,16 @@ const withDuotoneControls = createHigherOrderComponent(
|
|
|
168
202
|
[ props.clientId ]
|
|
169
203
|
);
|
|
170
204
|
|
|
205
|
+
// CAUTION: code added before this line will be executed
|
|
206
|
+
// for all blocks, not just those that support duotone. Code added
|
|
207
|
+
// above this line should be carefully evaluated for its impact on
|
|
208
|
+
// performance.
|
|
171
209
|
return (
|
|
172
210
|
<>
|
|
173
|
-
<BlockEdit { ...props } />
|
|
174
211
|
{ hasDuotoneSupport && ! isContentLocked && (
|
|
175
212
|
<DuotonePanel { ...props } />
|
|
176
213
|
) }
|
|
214
|
+
<BlockEdit { ...props } />
|
|
177
215
|
</>
|
|
178
216
|
);
|
|
179
217
|
},
|
|
@@ -211,6 +249,49 @@ function scopeSelector( scope, selector ) {
|
|
|
211
249
|
return selectorsScoped.join( ', ' );
|
|
212
250
|
}
|
|
213
251
|
|
|
252
|
+
function BlockDuotoneStyles( { name, duotoneStyle, id } ) {
|
|
253
|
+
const duotonePalette = useMultiOriginPresets( {
|
|
254
|
+
presetSetting: 'color.duotone',
|
|
255
|
+
defaultSetting: 'color.defaultDuotone',
|
|
256
|
+
} );
|
|
257
|
+
|
|
258
|
+
const element = useContext( BlockList.__unstableElementContext );
|
|
259
|
+
|
|
260
|
+
// Portals cannot exist without a container.
|
|
261
|
+
// Guard against empty Duotone styles.
|
|
262
|
+
if ( ! element || ! duotoneStyle ) {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
let colors = duotoneStyle;
|
|
267
|
+
|
|
268
|
+
if ( ! Array.isArray( colors ) && colors !== 'unset' ) {
|
|
269
|
+
colors = getColorsFromDuotonePreset( colors, duotonePalette );
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const duotoneSupportSelectors = getBlockSupport(
|
|
273
|
+
name,
|
|
274
|
+
'color.__experimentalDuotone'
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
// Extra .editor-styles-wrapper specificity is needed in the editor
|
|
278
|
+
// since we're not using inline styles to apply the filter. We need to
|
|
279
|
+
// override duotone applied by global styles and theme.json.
|
|
280
|
+
const selectorsGroup = scopeSelector(
|
|
281
|
+
`.editor-styles-wrapper .${ id }`,
|
|
282
|
+
duotoneSupportSelectors
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
return createPortal(
|
|
286
|
+
<InlineDuotone
|
|
287
|
+
selector={ selectorsGroup }
|
|
288
|
+
id={ id }
|
|
289
|
+
colors={ colors }
|
|
290
|
+
/>,
|
|
291
|
+
element
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
|
|
214
295
|
/**
|
|
215
296
|
* Override the default block element to include duotone styles.
|
|
216
297
|
*
|
|
@@ -224,37 +305,26 @@ const withDuotoneStyles = createHigherOrderComponent(
|
|
|
224
305
|
props.name,
|
|
225
306
|
'color.__experimentalDuotone'
|
|
226
307
|
);
|
|
227
|
-
const colors = props?.attributes?.style?.color?.duotone;
|
|
228
|
-
|
|
229
|
-
if ( ! duotoneSupport || ! colors ) {
|
|
230
|
-
return <BlockListBlock { ...props } />;
|
|
231
|
-
}
|
|
232
308
|
|
|
233
309
|
const id = `wp-duotone-${ useInstanceId( BlockListBlock ) }`;
|
|
310
|
+
const className = duotoneSupport
|
|
311
|
+
? classnames( props?.className, id )
|
|
312
|
+
: props?.className;
|
|
313
|
+
const duotoneStyle = props?.attributes?.style?.color?.duotone;
|
|
234
314
|
|
|
235
|
-
//
|
|
236
|
-
//
|
|
237
|
-
//
|
|
238
|
-
|
|
239
|
-
`.editor-styles-wrapper .${ id }`,
|
|
240
|
-
duotoneSupport
|
|
241
|
-
);
|
|
242
|
-
|
|
243
|
-
const className = classnames( props?.className, id );
|
|
244
|
-
|
|
245
|
-
const element = useContext( BlockList.__unstableElementContext );
|
|
246
|
-
|
|
315
|
+
// CAUTION: code added before this line will be executed
|
|
316
|
+
// for all blocks, not just those that support duotone. Code added
|
|
317
|
+
// above this line should be carefully evaluated for its impact on
|
|
318
|
+
// performance.
|
|
247
319
|
return (
|
|
248
320
|
<>
|
|
249
|
-
{
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
element
|
|
257
|
-
) }
|
|
321
|
+
{ duotoneSupport && duotoneStyle && (
|
|
322
|
+
<BlockDuotoneStyles
|
|
323
|
+
name={ props?.name }
|
|
324
|
+
duotoneStyle={ duotoneStyle }
|
|
325
|
+
id={ id }
|
|
326
|
+
/>
|
|
327
|
+
) }
|
|
258
328
|
<BlockListBlock { ...props } className={ className } />
|
|
259
329
|
</>
|
|
260
330
|
);
|
package/src/hooks/font-family.js
CHANGED
|
@@ -13,8 +13,6 @@ import TokenList from '@wordpress/token-list';
|
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
|
-
import useSetting from '../components/use-setting';
|
|
17
|
-
import FontFamilyControl from '../components/font-family';
|
|
18
16
|
import { shouldSkipSerialization } from './utils';
|
|
19
17
|
import { TYPOGRAPHY_SUPPORT_KEY } from './typography';
|
|
20
18
|
|
|
@@ -105,62 +103,6 @@ function addEditProps( settings ) {
|
|
|
105
103
|
return settings;
|
|
106
104
|
}
|
|
107
105
|
|
|
108
|
-
export function FontFamilyEdit( {
|
|
109
|
-
setAttributes,
|
|
110
|
-
attributes: { fontFamily },
|
|
111
|
-
} ) {
|
|
112
|
-
const fontFamilies = useSetting( 'typography.fontFamilies' );
|
|
113
|
-
|
|
114
|
-
const value = fontFamilies?.find(
|
|
115
|
-
( { slug } ) => fontFamily === slug
|
|
116
|
-
)?.fontFamily;
|
|
117
|
-
|
|
118
|
-
function onChange( newValue ) {
|
|
119
|
-
const predefinedFontFamily = fontFamilies?.find(
|
|
120
|
-
( { fontFamily: f } ) => f === newValue
|
|
121
|
-
);
|
|
122
|
-
setAttributes( {
|
|
123
|
-
fontFamily: predefinedFontFamily?.slug,
|
|
124
|
-
} );
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return (
|
|
128
|
-
<FontFamilyControl
|
|
129
|
-
className="block-editor-hooks-font-family-control"
|
|
130
|
-
fontFamilies={ fontFamilies }
|
|
131
|
-
value={ value }
|
|
132
|
-
onChange={ onChange }
|
|
133
|
-
size="__unstable-large"
|
|
134
|
-
__nextHasNoMarginBottom
|
|
135
|
-
/>
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Custom hook that checks if font-family functionality is disabled.
|
|
141
|
-
*
|
|
142
|
-
* @param {string} name The name of the block.
|
|
143
|
-
* @return {boolean} Whether setting is disabled.
|
|
144
|
-
*/
|
|
145
|
-
export function useIsFontFamilyDisabled( { name } ) {
|
|
146
|
-
const fontFamilies = useSetting( 'typography.fontFamilies' );
|
|
147
|
-
return (
|
|
148
|
-
! fontFamilies ||
|
|
149
|
-
fontFamilies.length === 0 ||
|
|
150
|
-
! hasBlockSupport( name, FONT_FAMILY_SUPPORT_KEY )
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Checks if there is a current value set for the font family block support.
|
|
156
|
-
*
|
|
157
|
-
* @param {Object} props Block props.
|
|
158
|
-
* @return {boolean} Whether or not the block has a font family value set.
|
|
159
|
-
*/
|
|
160
|
-
export function hasFontFamilyValue( props ) {
|
|
161
|
-
return !! props.attributes.fontFamily;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
106
|
/**
|
|
165
107
|
* Resets the font family block support attribute. This can be used when
|
|
166
108
|
* disabling the font family support controls for a block via a progressive
|