@wordpress/block-editor 7.0.4 → 8.0.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 +11 -0
- package/README.md +31 -0
- package/build/components/alignment-control/ui.js +1 -2
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-icon/index.js +5 -1
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-inspector/index.js +4 -0
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/index.native.js +1 -1
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/use-multi-selection.js +21 -8
- package/build/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +0 -1
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-patterns-list/index.js +1 -8
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-settings/container.native.js +5 -2
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +22 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/preview.native.js +2 -2
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/colors-gradients/control.js +8 -47
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +81 -6
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/duotone-control/index.js +5 -2
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +27 -15
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +20 -2
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +2 -2
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/index.js +5 -4
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +4 -3
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js +62 -0
- package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/patterns-list.js +111 -0
- package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js +78 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
- package/build/components/inserter/block-patterns-tab.js +74 -45
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
- package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build/components/inserter/pattern-panel.js +19 -10
- package/build/components/inserter/pattern-panel.js.map +1 -1
- package/build/components/inspector-controls/groups.js +3 -1
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +9 -6
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/link-control/index.js +88 -35
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/link-preview.js +19 -6
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js +12 -3
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block.js +49 -23
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +92 -73
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +39 -16
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +1 -1
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +8 -58
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/rich-text/embed-handler-picker.native.js +1 -0
- package/build/components/rich-text/embed-handler-picker.native.js.map +1 -1
- package/build/components/rich-text/format-edit.js +28 -2
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/format-toolbar/index.js +2 -1
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/url-input/index.js +11 -4
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-setting/index.js +48 -9
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/border.js +5 -5
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +2 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/duotone.js +16 -5
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-appearance.js +49 -6
- package/build/hooks/font-appearance.js.map +1 -1
- package/build/hooks/font-family.js +37 -16
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +51 -9
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +8 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +8 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/letter-spacing.js +44 -7
- package/build/hooks/letter-spacing.js.map +1 -1
- package/build/hooks/line-height.js +45 -8
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/margin.js +1 -1
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +1 -1
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/text-decoration.js +42 -6
- package/build/hooks/text-decoration.js.map +1 -1
- package/build/hooks/text-transform.js +42 -6
- package/build/hooks/text-transform.js.map +1 -1
- package/build/hooks/typography.js +108 -8
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/use-cached-truthy.js +29 -0
- package/build/hooks/use-cached-truthy.js.map +1 -0
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/layouts/flex.js +120 -28
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +303 -265
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +1 -3
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +23 -22
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +44 -35
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -2
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-icon/index.js +5 -1
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +4 -0
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/index.native.js +1 -1
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-multi-selection.js +21 -8
- package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +0 -1
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +1 -6
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +6 -3
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +24 -4
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js +2 -2
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +12 -53
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +82 -6
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/duotone-control/index.js +5 -2
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +23 -15
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.js +3 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +6 -5
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +5 -4
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js +50 -0
- package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +92 -0
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +69 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab.js +75 -46
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build-module/components/inserter/pattern-panel.js +21 -13
- package/build-module/components/inserter/pattern-panel.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +3 -1
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +9 -6
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +88 -36
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +19 -7
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js +11 -3
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block.js +49 -24
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +92 -73
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +41 -18
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +1 -1
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +8 -58
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/rich-text/embed-handler-picker.native.js +1 -0
- package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +28 -3
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js +2 -1
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/url-input/index.js +11 -4
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +48 -9
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/border.js +5 -5
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +2 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/duotone.js +16 -5
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-appearance.js +45 -6
- package/build-module/hooks/font-appearance.js.map +1 -1
- package/build-module/hooks/font-family.js +33 -16
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +47 -9
- package/build-module/hooks/font-size.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/index.native.js +1 -0
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/letter-spacing.js +40 -7
- package/build-module/hooks/letter-spacing.js.map +1 -1
- package/build-module/hooks/line-height.js +41 -8
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/margin.js +1 -1
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +1 -1
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/text-decoration.js +38 -6
- package/build-module/hooks/text-decoration.js.map +1 -1
- package/build-module/hooks/text-transform.js +38 -6
- package/build-module/hooks/text-transform.js.map +1 -1
- package/build-module/hooks/typography.js +117 -17
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/use-cached-truthy.js +21 -0
- package/build-module/hooks/use-cached-truthy.js.map +1 -0
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/flex.js +124 -32
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +266 -241
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +1 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +23 -22
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +42 -30
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +160 -57
- package/build-style/style.css +160 -57
- package/package.json +13 -14
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +0 -2
- package/src/components/alignment-control/ui.js +1 -4
- package/src/components/block-draggable/style.scss +19 -4
- package/src/components/block-icon/index.js +4 -1
- package/src/components/block-inspector/index.js +5 -0
- package/src/components/block-list/index.native.js +1 -1
- package/src/components/block-list/use-block-props/use-multi-selection.js +27 -7
- package/src/components/block-navigation/dropdown.js +0 -1
- package/src/components/block-patterns-list/index.js +1 -8
- package/src/components/block-patterns-list/style.scss +22 -12
- package/src/components/block-settings/container.native.js +7 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +19 -7
- package/src/components/block-styles/preview.native.js +2 -2
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +1 -1
- package/src/components/color-palette/test/__snapshots__/control.js.snap +88 -63
- package/src/components/colors-gradients/control.js +19 -62
- package/src/components/colors-gradients/panel-color-gradient-settings.js +76 -6
- package/src/components/colors-gradients/style.scss +3 -14
- package/src/components/colors-gradients/test/control.js +0 -16
- package/src/components/duotone-control/index.js +6 -0
- package/src/components/duotone-control/style.scss +27 -12
- package/src/components/font-appearance-control/index.js +22 -14
- package/src/components/iframe/index.js +1 -1
- package/src/components/index.js +3 -4
- package/src/components/index.native.js +1 -4
- package/src/components/inner-blocks/index.js +4 -4
- package/src/components/inner-blocks/index.native.js +7 -4
- package/src/components/inserter/block-patterns-explorer/explorer.js +50 -0
- package/src/components/inserter/block-patterns-explorer/patterns-list.js +122 -0
- package/src/components/inserter/block-patterns-explorer/sidebar.js +73 -0
- package/src/components/inserter/block-patterns-tab.js +107 -80
- package/src/components/inserter/hooks/use-block-type-impressions.native.js +14 -21
- package/src/components/inserter/pattern-panel.js +33 -16
- package/src/components/inserter/style.scss +64 -1
- package/src/components/inserter/test/block-types-tab.native.js +1 -1
- package/src/components/inserter/test/fixtures/index.native.js +12 -0
- package/src/components/inspector-controls/groups.js +4 -0
- package/src/components/letter-spacing-control/index.js +12 -6
- package/src/components/link-control/README.md +7 -0
- package/src/components/link-control/index.js +99 -34
- package/src/components/link-control/link-preview.js +21 -9
- package/src/components/link-control/search-input.js +9 -3
- package/src/components/link-control/style.scss +32 -16
- package/src/components/link-control/test/index.js +179 -4
- package/src/components/list-view/block.js +67 -23
- package/src/components/list-view/branch.js +113 -91
- package/src/components/list-view/index.js +58 -19
- package/src/components/list-view/leaf.js +1 -1
- package/src/components/list-view/style.scss +14 -3
- package/src/components/list-view/use-list-view-client-ids.js +7 -66
- package/src/components/rich-text/embed-handler-picker.native.js +1 -0
- package/src/components/rich-text/format-edit.js +36 -2
- package/src/components/rich-text/format-toolbar/index.js +3 -0
- package/src/components/url-input/index.js +14 -4
- package/src/components/use-setting/index.js +49 -11
- package/src/hooks/border.js +8 -11
- package/src/hooks/color-panel.js +1 -0
- package/src/hooks/duotone.js +21 -7
- package/src/hooks/font-appearance.js +38 -7
- package/src/hooks/font-family.js +29 -13
- package/src/hooks/font-size.js +42 -6
- package/src/hooks/index.js +1 -0
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/layout.scss +3 -1
- package/src/hooks/letter-spacing.js +35 -7
- package/src/hooks/line-height.js +37 -9
- package/src/hooks/margin.js +1 -1
- package/src/hooks/padding.js +1 -1
- package/src/hooks/text-decoration.js +34 -6
- package/src/hooks/text-transform.js +34 -6
- package/src/hooks/typography.js +165 -15
- package/src/hooks/typography.scss +16 -0
- package/src/hooks/use-cached-truthy.js +20 -0
- package/src/index.js +1 -0
- package/src/layouts/flex.js +137 -41
- package/src/store/actions.js +223 -391
- package/src/store/index.js +1 -2
- package/src/store/reducer.js +36 -18
- package/src/store/selectors.js +52 -47
- package/src/store/test/actions.js +395 -694
- package/src/store/test/selectors.js +79 -21
- package/src/style.scss +1 -1
- package/src/utils/test/parse-css-unit-to-px.js +127 -167
- package/build/components/text-decoration-and-transform/index.js +0 -39
- package/build/components/text-decoration-and-transform/index.js.map +0 -1
- package/build/store/controls.js +0 -44
- package/build/store/controls.js.map +0 -1
- package/build-module/components/text-decoration-and-transform/index.js +0 -30
- package/build-module/components/text-decoration-and-transform/index.js.map +0 -1
- package/build-module/store/controls.js +0 -32
- package/build-module/store/controls.js.map +0 -1
- package/src/components/text-decoration-and-transform/index.js +0 -36
- package/src/components/text-decoration-and-transform/style.scss +0 -3
- package/src/store/controls.js +0 -39
|
@@ -34,8 +34,7 @@ const deprecatedFlags = {
|
|
|
34
34
|
settings.disableCustomFontSizes === undefined
|
|
35
35
|
? undefined
|
|
36
36
|
: ! settings.disableCustomFontSizes,
|
|
37
|
-
'typography.
|
|
38
|
-
settings.enableCustomLineHeight,
|
|
37
|
+
'typography.lineHeight': ( settings ) => settings.enableCustomLineHeight,
|
|
39
38
|
'spacing.units': ( settings ) => {
|
|
40
39
|
if ( settings.enableCustomUnits === undefined ) {
|
|
41
40
|
return;
|
|
@@ -47,7 +46,46 @@ const deprecatedFlags = {
|
|
|
47
46
|
|
|
48
47
|
return settings.enableCustomUnits;
|
|
49
48
|
},
|
|
50
|
-
'spacing.
|
|
49
|
+
'spacing.padding': ( settings ) => settings.enableCustomSpacing,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const prefixedFlags = {
|
|
53
|
+
/*
|
|
54
|
+
* These were only available in the plugin
|
|
55
|
+
* and can be removed when the minimum WordPress version
|
|
56
|
+
* for the plugin is 5.9.
|
|
57
|
+
*/
|
|
58
|
+
'border.customColor': 'border.color',
|
|
59
|
+
'border.customStyle': 'border.style',
|
|
60
|
+
'border.customWidth': 'border.width',
|
|
61
|
+
'typography.customFontStyle': 'typography.fontStyle',
|
|
62
|
+
'typography.customFontWeight': 'typography.fontWeight',
|
|
63
|
+
'typography.customLetterSpacing': 'typography.letterSpacing',
|
|
64
|
+
'typography.customTextDecorations': 'typography.textDecoration',
|
|
65
|
+
'typography.customTextTransforms': 'typography.textTransform',
|
|
66
|
+
/*
|
|
67
|
+
* These were part of WordPress 5.8 and we need to keep them.
|
|
68
|
+
*/
|
|
69
|
+
'border.customRadius': 'border.radius',
|
|
70
|
+
'spacing.customMargin': 'spacing.margin',
|
|
71
|
+
'spacing.customPadding': 'spacing.padding',
|
|
72
|
+
'typography.customLineHeight': 'typography.lineHeight',
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Remove `custom` prefixes for flags that did not land in 5.8.
|
|
77
|
+
*
|
|
78
|
+
* This provides continued support for `custom` prefixed properties. It will
|
|
79
|
+
* be removed once third party devs have had sufficient time to update themes,
|
|
80
|
+
* plugins, etc.
|
|
81
|
+
*
|
|
82
|
+
* @see https://github.com/WordPress/gutenberg/pull/34485
|
|
83
|
+
*
|
|
84
|
+
* @param {string} path Path to desired value in settings.
|
|
85
|
+
* @return {string} The value for defined setting.
|
|
86
|
+
*/
|
|
87
|
+
const removeCustomPrefixes = ( path ) => {
|
|
88
|
+
return prefixedFlags[ path ] || path;
|
|
51
89
|
};
|
|
52
90
|
|
|
53
91
|
/**
|
|
@@ -55,9 +93,7 @@ const deprecatedFlags = {
|
|
|
55
93
|
* It works with nested objects using by finding the value at path.
|
|
56
94
|
*
|
|
57
95
|
* @param {string} path The path to the setting.
|
|
58
|
-
*
|
|
59
96
|
* @return {any} Returns the value defined for the setting.
|
|
60
|
-
*
|
|
61
97
|
* @example
|
|
62
98
|
* ```js
|
|
63
99
|
* const isEnabled = useSetting( 'typography.dropCap' );
|
|
@@ -72,12 +108,14 @@ export default function useSetting( path ) {
|
|
|
72
108
|
|
|
73
109
|
// 1 - Use __experimental features, if available.
|
|
74
110
|
// We cascade to the all value if the block one is not available.
|
|
75
|
-
const
|
|
76
|
-
const
|
|
111
|
+
const normalizedPath = removeCustomPrefixes( path );
|
|
112
|
+
const defaultsPath = `__experimentalFeatures.${ normalizedPath }`;
|
|
113
|
+
const blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;
|
|
77
114
|
const experimentalFeaturesResult =
|
|
78
115
|
get( settings, blockPath ) ?? get( settings, defaultsPath );
|
|
116
|
+
|
|
79
117
|
if ( experimentalFeaturesResult !== undefined ) {
|
|
80
|
-
if ( PATHS_WITH_MERGE[
|
|
118
|
+
if ( PATHS_WITH_MERGE[ normalizedPath ] ) {
|
|
81
119
|
return (
|
|
82
120
|
experimentalFeaturesResult.user ??
|
|
83
121
|
experimentalFeaturesResult.theme ??
|
|
@@ -88,8 +126,8 @@ export default function useSetting( path ) {
|
|
|
88
126
|
}
|
|
89
127
|
|
|
90
128
|
// 2 - Use deprecated settings, otherwise.
|
|
91
|
-
const deprecatedSettingsValue = deprecatedFlags[
|
|
92
|
-
? deprecatedFlags[
|
|
129
|
+
const deprecatedSettingsValue = deprecatedFlags[ normalizedPath ]
|
|
130
|
+
? deprecatedFlags[ normalizedPath ]( settings )
|
|
93
131
|
: undefined;
|
|
94
132
|
if ( deprecatedSettingsValue !== undefined ) {
|
|
95
133
|
return deprecatedSettingsValue;
|
|
@@ -99,7 +137,7 @@ export default function useSetting( path ) {
|
|
|
99
137
|
// This is only necessary to support typography.dropCap.
|
|
100
138
|
// when __experimentalFeatures are not present (core without plugin).
|
|
101
139
|
// To remove when __experimentalFeatures are ported to core.
|
|
102
|
-
return
|
|
140
|
+
return normalizedPath === 'typography.dropCap' ? true : undefined;
|
|
103
141
|
},
|
|
104
142
|
[ blockName, path ]
|
|
105
143
|
);
|
package/src/hooks/border.js
CHANGED
|
@@ -23,20 +23,17 @@ export function BorderPanel( props ) {
|
|
|
23
23
|
const isSupported = hasBorderSupport( props.name );
|
|
24
24
|
|
|
25
25
|
const isColorSupported =
|
|
26
|
-
useSetting( 'border.
|
|
27
|
-
hasBorderSupport( props.name, 'color' );
|
|
26
|
+
useSetting( 'border.color' ) && hasBorderSupport( props.name, 'color' );
|
|
28
27
|
|
|
29
28
|
const isRadiusSupported =
|
|
30
|
-
useSetting( 'border.
|
|
29
|
+
useSetting( 'border.radius' ) &&
|
|
31
30
|
hasBorderSupport( props.name, 'radius' );
|
|
32
31
|
|
|
33
32
|
const isStyleSupported =
|
|
34
|
-
useSetting( 'border.
|
|
35
|
-
hasBorderSupport( props.name, 'style' );
|
|
33
|
+
useSetting( 'border.style' ) && hasBorderSupport( props.name, 'style' );
|
|
36
34
|
|
|
37
35
|
const isWidthSupported =
|
|
38
|
-
useSetting( 'border.
|
|
39
|
-
hasBorderSupport( props.name, 'width' );
|
|
36
|
+
useSetting( 'border.width' ) && hasBorderSupport( props.name, 'width' );
|
|
40
37
|
|
|
41
38
|
if ( isDisabled || ! isSupported ) {
|
|
42
39
|
return null;
|
|
@@ -113,10 +110,10 @@ export function shouldSkipSerialization( blockType ) {
|
|
|
113
110
|
*/
|
|
114
111
|
const useIsBorderDisabled = () => {
|
|
115
112
|
const configs = [
|
|
116
|
-
! useSetting( 'border.
|
|
117
|
-
! useSetting( 'border.
|
|
118
|
-
! useSetting( 'border.
|
|
119
|
-
! useSetting( 'border.
|
|
113
|
+
! useSetting( 'border.color' ),
|
|
114
|
+
! useSetting( 'border.radius' ),
|
|
115
|
+
! useSetting( 'border.style' ),
|
|
116
|
+
! useSetting( 'border.width' ),
|
|
120
117
|
];
|
|
121
118
|
|
|
122
119
|
return configs.every( Boolean );
|
package/src/hooks/color-panel.js
CHANGED
package/src/hooks/duotone.js
CHANGED
|
@@ -36,13 +36,14 @@ extend( [ namesPlugin ] );
|
|
|
36
36
|
* @return {Object} R, G, and B values.
|
|
37
37
|
*/
|
|
38
38
|
export function getValuesFromColors( colors = [] ) {
|
|
39
|
-
const values = { r: [], g: [], b: [] };
|
|
39
|
+
const values = { r: [], g: [], b: [], a: [] };
|
|
40
40
|
|
|
41
41
|
colors.forEach( ( color ) => {
|
|
42
42
|
const rgbColor = colord( color ).toRgb();
|
|
43
43
|
values.r.push( rgbColor.r / 255 );
|
|
44
44
|
values.g.push( rgbColor.g / 255 );
|
|
45
45
|
values.b.push( rgbColor.b / 255 );
|
|
46
|
+
values.a.push( rgbColor.a );
|
|
46
47
|
} );
|
|
47
48
|
|
|
48
49
|
return values;
|
|
@@ -55,6 +56,7 @@ export function getValuesFromColors( colors = [] ) {
|
|
|
55
56
|
* @property {number[]} r Red values.
|
|
56
57
|
* @property {number[]} g Green values.
|
|
57
58
|
* @property {number[]} b Blue values.
|
|
59
|
+
* @property {number[]} a Alpha values.
|
|
58
60
|
*/
|
|
59
61
|
|
|
60
62
|
/**
|
|
@@ -63,7 +65,7 @@ export function getValuesFromColors( colors = [] ) {
|
|
|
63
65
|
* @param {Object} props Duotone props.
|
|
64
66
|
* @param {string} props.selector Selector to apply the filter to.
|
|
65
67
|
* @param {string} props.id Unique id for this duotone filter.
|
|
66
|
-
* @param {Values} props.values R, G, and
|
|
68
|
+
* @param {Values} props.values R, G, B, and A values to filter with.
|
|
67
69
|
*
|
|
68
70
|
* @return {WPElement} Duotone element.
|
|
69
71
|
*/
|
|
@@ -93,13 +95,16 @@ ${ selector } {
|
|
|
93
95
|
<defs>
|
|
94
96
|
<filter id={ id }>
|
|
95
97
|
<feColorMatrix
|
|
98
|
+
// Use sRGB instead of linearRGB so transparency looks correct.
|
|
99
|
+
colorInterpolationFilters="sRGB"
|
|
96
100
|
type="matrix"
|
|
97
101
|
// Use perceptual brightness to convert to grayscale.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
values="
|
|
103
|
+
.299 .587 .114 0 0
|
|
104
|
+
.299 .587 .114 0 0
|
|
105
|
+
.299 .587 .114 0 0
|
|
106
|
+
.299 .587 .114 0 0
|
|
107
|
+
"
|
|
103
108
|
/>
|
|
104
109
|
<feComponentTransfer
|
|
105
110
|
// Use sRGB instead of linearRGB to be consistent with how CSS gradients work.
|
|
@@ -117,7 +122,16 @@ ${ selector } {
|
|
|
117
122
|
type="table"
|
|
118
123
|
tableValues={ values.b.join( ' ' ) }
|
|
119
124
|
/>
|
|
125
|
+
<feFuncA
|
|
126
|
+
type="table"
|
|
127
|
+
tableValues={ values.a.join( ' ' ) }
|
|
128
|
+
/>
|
|
120
129
|
</feComponentTransfer>
|
|
130
|
+
<feComposite
|
|
131
|
+
// Re-mask the image with the original transparency since the feColorMatrix above loses that information.
|
|
132
|
+
in2="SourceGraphic"
|
|
133
|
+
operator="in"
|
|
134
|
+
/>
|
|
121
135
|
</filter>
|
|
122
136
|
</defs>
|
|
123
137
|
</SVG>
|
|
@@ -36,10 +36,6 @@ export function FontAppearanceEdit( props ) {
|
|
|
36
36
|
const hasFontStyles = ! useIsFontStyleDisabled( props );
|
|
37
37
|
const hasFontWeights = ! useIsFontWeightDisabled( props );
|
|
38
38
|
|
|
39
|
-
if ( ! hasFontStyles && ! hasFontWeights ) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
39
|
const onChange = ( newStyles ) => {
|
|
44
40
|
setAttributes( {
|
|
45
41
|
style: cleanEmptyObject( {
|
|
@@ -54,7 +50,6 @@ export function FontAppearanceEdit( props ) {
|
|
|
54
50
|
};
|
|
55
51
|
|
|
56
52
|
const fontStyle = style?.typography?.fontStyle;
|
|
57
|
-
|
|
58
53
|
const fontWeight = style?.typography?.fontWeight;
|
|
59
54
|
|
|
60
55
|
return (
|
|
@@ -78,7 +73,7 @@ export function FontAppearanceEdit( props ) {
|
|
|
78
73
|
*/
|
|
79
74
|
export function useIsFontStyleDisabled( { name: blockName } = {} ) {
|
|
80
75
|
const styleSupport = hasBlockSupport( blockName, FONT_STYLE_SUPPORT_KEY );
|
|
81
|
-
const hasFontStyles = useSetting( 'typography.
|
|
76
|
+
const hasFontStyles = useSetting( 'typography.fontStyle' );
|
|
82
77
|
|
|
83
78
|
return ! styleSupport || ! hasFontStyles;
|
|
84
79
|
}
|
|
@@ -94,7 +89,7 @@ export function useIsFontStyleDisabled( { name: blockName } = {} ) {
|
|
|
94
89
|
*/
|
|
95
90
|
export function useIsFontWeightDisabled( { name: blockName } = {} ) {
|
|
96
91
|
const weightSupport = hasBlockSupport( blockName, FONT_WEIGHT_SUPPORT_KEY );
|
|
97
|
-
const hasFontWeights = useSetting( 'typography.
|
|
92
|
+
const hasFontWeights = useSetting( 'typography.fontWeight' );
|
|
98
93
|
|
|
99
94
|
return ! weightSupport || ! hasFontWeights;
|
|
100
95
|
}
|
|
@@ -112,3 +107,39 @@ export function useIsFontAppearanceDisabled( props ) {
|
|
|
112
107
|
|
|
113
108
|
return stylesDisabled && weightsDisabled;
|
|
114
109
|
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Checks if there is either a font style or weight value set within the
|
|
113
|
+
* typography styles.
|
|
114
|
+
*
|
|
115
|
+
* @param {Object} props Block props.
|
|
116
|
+
* @return {boolean} Whether or not the block has a font style or weight.
|
|
117
|
+
*/
|
|
118
|
+
export function hasFontAppearanceValue( props ) {
|
|
119
|
+
const { fontStyle, fontWeight } = props.attributes.style?.typography || {};
|
|
120
|
+
return !! fontStyle || !! fontWeight;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Resets the font style and weight block support attributes. This can be used
|
|
125
|
+
* when disabling the font appearance support controls for a block via a
|
|
126
|
+
* progressive discovery panel.
|
|
127
|
+
*
|
|
128
|
+
* @param {Object} props Block props.
|
|
129
|
+
* @param {Object} props.attributes Block's attributes.
|
|
130
|
+
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
131
|
+
*/
|
|
132
|
+
export function resetFontAppearance( { attributes = {}, setAttributes } ) {
|
|
133
|
+
const { style } = attributes;
|
|
134
|
+
|
|
135
|
+
setAttributes( {
|
|
136
|
+
style: cleanEmptyObject( {
|
|
137
|
+
...style,
|
|
138
|
+
typography: {
|
|
139
|
+
...style?.typography,
|
|
140
|
+
fontStyle: undefined,
|
|
141
|
+
fontWeight: undefined,
|
|
142
|
+
},
|
|
143
|
+
} ),
|
|
144
|
+
} );
|
|
145
|
+
}
|
package/src/hooks/font-family.js
CHANGED
|
@@ -22,8 +22,8 @@ export const FONT_FAMILY_SUPPORT_KEY = 'typography.__experimentalFontFamily';
|
|
|
22
22
|
* Filters registered block settings, extending attributes to include
|
|
23
23
|
* the `fontFamily` attribute.
|
|
24
24
|
*
|
|
25
|
-
* @param
|
|
26
|
-
* @return {Object}
|
|
25
|
+
* @param {Object} settings Original block settings
|
|
26
|
+
* @return {Object} Filtered block settings
|
|
27
27
|
*/
|
|
28
28
|
function addAttributes( settings ) {
|
|
29
29
|
if ( ! hasBlockSupport( settings, FONT_FAMILY_SUPPORT_KEY ) ) {
|
|
@@ -45,10 +45,10 @@ function addAttributes( settings ) {
|
|
|
45
45
|
/**
|
|
46
46
|
* Override props assigned to save component to inject font family.
|
|
47
47
|
*
|
|
48
|
-
* @param
|
|
49
|
-
* @param
|
|
50
|
-
* @param
|
|
51
|
-
* @return {Object}
|
|
48
|
+
* @param {Object} props Additional props applied to save element
|
|
49
|
+
* @param {Object} blockType Block type
|
|
50
|
+
* @param {Object} attributes Block attributes
|
|
51
|
+
* @return {Object} Filtered props applied to save element
|
|
52
52
|
*/
|
|
53
53
|
function addSaveProps( props, blockType, attributes ) {
|
|
54
54
|
if ( ! hasBlockSupport( blockType, FONT_FAMILY_SUPPORT_KEY ) ) {
|
|
@@ -58,7 +58,7 @@ function addSaveProps( props, blockType, attributes ) {
|
|
|
58
58
|
if (
|
|
59
59
|
hasBlockSupport(
|
|
60
60
|
blockType,
|
|
61
|
-
'
|
|
61
|
+
'typography.__experimentalSkipSerialization'
|
|
62
62
|
)
|
|
63
63
|
) {
|
|
64
64
|
return props;
|
|
@@ -103,16 +103,10 @@ function addEditProps( settings ) {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
export function FontFamilyEdit( {
|
|
106
|
-
name,
|
|
107
106
|
setAttributes,
|
|
108
107
|
attributes: { fontFamily },
|
|
109
108
|
} ) {
|
|
110
109
|
const fontFamilies = useSetting( 'typography.fontFamilies' );
|
|
111
|
-
const isDisable = useIsFontFamilyDisabled( { name } );
|
|
112
|
-
|
|
113
|
-
if ( isDisable ) {
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
110
|
|
|
117
111
|
const value = find( fontFamilies, ( { slug } ) => fontFamily === slug )
|
|
118
112
|
?.fontFamily;
|
|
@@ -152,6 +146,28 @@ export function useIsFontFamilyDisabled( { name } ) {
|
|
|
152
146
|
);
|
|
153
147
|
}
|
|
154
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Checks if there is a current value set for the font family block support.
|
|
151
|
+
*
|
|
152
|
+
* @param {Object} props Block props.
|
|
153
|
+
* @return {boolean} Whether or not the block has a font family value set.
|
|
154
|
+
*/
|
|
155
|
+
export function hasFontFamilyValue( props ) {
|
|
156
|
+
return !! props.attributes.fontFamily;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Resets the font family block support attribute. This can be used when
|
|
161
|
+
* disabling the font family support controls for a block via a progressive
|
|
162
|
+
* discovery panel.
|
|
163
|
+
*
|
|
164
|
+
* @param {Object} props Block props.
|
|
165
|
+
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
166
|
+
*/
|
|
167
|
+
export function resetFontFamily( { setAttributes } ) {
|
|
168
|
+
setAttributes( { fontFamily: undefined } );
|
|
169
|
+
}
|
|
170
|
+
|
|
155
171
|
addFilter(
|
|
156
172
|
'blocks.registerBlockType',
|
|
157
173
|
'core/fontFamily/addAttribute',
|
package/src/hooks/font-size.js
CHANGED
|
@@ -114,7 +114,6 @@ export function FontSizeEdit( props ) {
|
|
|
114
114
|
attributes: { fontSize, style },
|
|
115
115
|
setAttributes,
|
|
116
116
|
} = props;
|
|
117
|
-
const isDisabled = useIsFontSizeDisabled( props );
|
|
118
117
|
const fontSizes = useSetting( 'typography.fontSizes' );
|
|
119
118
|
|
|
120
119
|
const onChange = ( value ) => {
|
|
@@ -132,10 +131,6 @@ export function FontSizeEdit( props ) {
|
|
|
132
131
|
} );
|
|
133
132
|
};
|
|
134
133
|
|
|
135
|
-
if ( isDisabled ) {
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
134
|
const fontSizeObject = getFontSize(
|
|
140
135
|
fontSizes,
|
|
141
136
|
fontSize,
|
|
@@ -145,7 +140,48 @@ export function FontSizeEdit( props ) {
|
|
|
145
140
|
const fontSizeValue =
|
|
146
141
|
fontSizeObject?.size || style?.typography?.fontSize || fontSize;
|
|
147
142
|
|
|
148
|
-
return
|
|
143
|
+
return (
|
|
144
|
+
<FontSizePicker
|
|
145
|
+
onChange={ onChange }
|
|
146
|
+
value={ fontSizeValue }
|
|
147
|
+
withReset={ false }
|
|
148
|
+
/>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Checks if there is a current value set for the font size block support.
|
|
154
|
+
*
|
|
155
|
+
* @param {Object} props Block props.
|
|
156
|
+
* @return {boolean} Whether or not the block has a font size value set.
|
|
157
|
+
*/
|
|
158
|
+
export function hasFontSizeValue( props ) {
|
|
159
|
+
const { fontSize, style } = props.attributes;
|
|
160
|
+
return !! fontSize || !! style?.typography?.fontSize;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Resets the font size block support attribute. This can be used when
|
|
165
|
+
* disabling the font size support controls for a block via a progressive
|
|
166
|
+
* discovery panel.
|
|
167
|
+
*
|
|
168
|
+
* @param {Object} props Block props.
|
|
169
|
+
* @param {Object} props.attributes Block's attributes.
|
|
170
|
+
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
171
|
+
*/
|
|
172
|
+
export function resetFontSize( { attributes = {}, setAttributes } ) {
|
|
173
|
+
const { style } = attributes;
|
|
174
|
+
|
|
175
|
+
setAttributes( {
|
|
176
|
+
fontSize: undefined,
|
|
177
|
+
style: cleanEmptyObject( {
|
|
178
|
+
...style,
|
|
179
|
+
typography: {
|
|
180
|
+
...style?.typography,
|
|
181
|
+
fontSize: undefined,
|
|
182
|
+
},
|
|
183
|
+
} ),
|
|
184
|
+
} );
|
|
149
185
|
}
|
|
150
186
|
|
|
151
187
|
/**
|
package/src/hooks/index.js
CHANGED
|
@@ -18,3 +18,4 @@ export { useCustomSides } from './dimensions';
|
|
|
18
18
|
export { getBorderClassesAndStyles, useBorderProps } from './use-border-props';
|
|
19
19
|
export { getColorClassesAndStyles, useColorProps } from './use-color-props';
|
|
20
20
|
export { getSpacingClassesAndStyles } from './use-spacing-props';
|
|
21
|
+
export { useCachedTruthy } from './use-cached-truthy';
|
|
@@ -13,3 +13,4 @@ import './font-size';
|
|
|
13
13
|
export { getBorderClassesAndStyles, useBorderProps } from './use-border-props';
|
|
14
14
|
export { getColorClassesAndStyles, useColorProps } from './use-color-props';
|
|
15
15
|
export { getSpacingClassesAndStyles } from './use-spacing-props';
|
|
16
|
+
export { useCachedTruthy } from './use-cached-truthy';
|
package/src/hooks/layout.scss
CHANGED
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
font-size: $helptext-font-size;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
.block-editor-hooks__flex-layout-justification-controls
|
|
25
|
+
.block-editor-hooks__flex-layout-justification-controls,
|
|
26
|
+
.block-editor-hooks__flex-layout-orientation-controls {
|
|
27
|
+
margin-bottom: $grid-unit-15;
|
|
26
28
|
legend {
|
|
27
29
|
margin-bottom: $grid-unit-10;
|
|
28
30
|
}
|
|
@@ -29,12 +29,6 @@ export function LetterSpacingEdit( props ) {
|
|
|
29
29
|
setAttributes,
|
|
30
30
|
} = props;
|
|
31
31
|
|
|
32
|
-
const isDisabled = useIsLetterSpacingDisabled( props );
|
|
33
|
-
|
|
34
|
-
if ( isDisabled ) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
32
|
function onChange( newSpacing ) {
|
|
39
33
|
setAttributes( {
|
|
40
34
|
style: cleanEmptyObject( {
|
|
@@ -51,6 +45,7 @@ export function LetterSpacingEdit( props ) {
|
|
|
51
45
|
<LetterSpacingControl
|
|
52
46
|
value={ style?.typography?.letterSpacing }
|
|
53
47
|
onChange={ onChange }
|
|
48
|
+
__unstableInputWidth={ false }
|
|
54
49
|
/>
|
|
55
50
|
);
|
|
56
51
|
}
|
|
@@ -66,7 +61,40 @@ export function useIsLetterSpacingDisabled( { name: blockName } = {} ) {
|
|
|
66
61
|
blockName,
|
|
67
62
|
LETTER_SPACING_SUPPORT_KEY
|
|
68
63
|
);
|
|
69
|
-
const hasLetterSpacing = useSetting( 'typography.
|
|
64
|
+
const hasLetterSpacing = useSetting( 'typography.letterSpacing' );
|
|
70
65
|
|
|
71
66
|
return notSupported || ! hasLetterSpacing;
|
|
72
67
|
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Checks if there is a current value set for the letter spacing block support.
|
|
71
|
+
*
|
|
72
|
+
* @param {Object} props Block props.
|
|
73
|
+
* @return {boolean} Whether or not the block has a letter spacing set.
|
|
74
|
+
*/
|
|
75
|
+
export function hasLetterSpacingValue( props ) {
|
|
76
|
+
return !! props.attributes.style?.typography?.letterSpacing;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Resets the letter spacing block support attribute. This can be used when
|
|
81
|
+
* disabling the letter spacing support controls for a block via a progressive
|
|
82
|
+
* discovery panel.
|
|
83
|
+
*
|
|
84
|
+
* @param {Object} props Block props.
|
|
85
|
+
* @param {Object} props.attributes Block's attributes.
|
|
86
|
+
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
87
|
+
*/
|
|
88
|
+
export function resetLetterSpacing( { attributes = {}, setAttributes } ) {
|
|
89
|
+
const { style } = attributes;
|
|
90
|
+
|
|
91
|
+
setAttributes( {
|
|
92
|
+
style: cleanEmptyObject( {
|
|
93
|
+
...style,
|
|
94
|
+
typography: {
|
|
95
|
+
...style?.typography,
|
|
96
|
+
letterSpacing: undefined,
|
|
97
|
+
},
|
|
98
|
+
} ),
|
|
99
|
+
} );
|
|
100
|
+
}
|
package/src/hooks/line-height.js
CHANGED
|
@@ -22,12 +22,8 @@ export const LINE_HEIGHT_SUPPORT_KEY = 'typography.lineHeight';
|
|
|
22
22
|
export function LineHeightEdit( props ) {
|
|
23
23
|
const {
|
|
24
24
|
attributes: { style },
|
|
25
|
+
setAttributes,
|
|
25
26
|
} = props;
|
|
26
|
-
const isDisabled = useIsLineHeightDisabled( props );
|
|
27
|
-
|
|
28
|
-
if ( isDisabled ) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
27
|
|
|
32
28
|
const onChange = ( newLineHeightValue ) => {
|
|
33
29
|
const newStyle = {
|
|
@@ -37,9 +33,8 @@ export function LineHeightEdit( props ) {
|
|
|
37
33
|
lineHeight: newLineHeightValue,
|
|
38
34
|
},
|
|
39
35
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
} );
|
|
36
|
+
|
|
37
|
+
setAttributes( { style: cleanEmptyObject( newStyle ) } );
|
|
43
38
|
};
|
|
44
39
|
return (
|
|
45
40
|
<LineHeightControl
|
|
@@ -56,9 +51,42 @@ export function LineHeightEdit( props ) {
|
|
|
56
51
|
* @return {boolean} Whether setting is disabled.
|
|
57
52
|
*/
|
|
58
53
|
export function useIsLineHeightDisabled( { name: blockName } = {} ) {
|
|
59
|
-
const isDisabled = ! useSetting( 'typography.
|
|
54
|
+
const isDisabled = ! useSetting( 'typography.lineHeight' );
|
|
60
55
|
|
|
61
56
|
return (
|
|
62
57
|
! hasBlockSupport( blockName, LINE_HEIGHT_SUPPORT_KEY ) || isDisabled
|
|
63
58
|
);
|
|
64
59
|
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Checks if there is a current value set for the line height block support.
|
|
63
|
+
*
|
|
64
|
+
* @param {Object} props Block props.
|
|
65
|
+
* @return {boolean} Whether or not the block has a line height value set.
|
|
66
|
+
*/
|
|
67
|
+
export function hasLineHeightValue( props ) {
|
|
68
|
+
return !! props.attributes.style?.typography?.lineHeight;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Resets the line height block support attribute. This can be used when
|
|
73
|
+
* disabling the line height support controls for a block via a progressive
|
|
74
|
+
* discovery panel.
|
|
75
|
+
*
|
|
76
|
+
* @param {Object} props Block props.
|
|
77
|
+
* @param {Object} props.attributes Block's attributes.
|
|
78
|
+
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
79
|
+
*/
|
|
80
|
+
export function resetLineHeight( { attributes = {}, setAttributes } ) {
|
|
81
|
+
const { style } = attributes;
|
|
82
|
+
|
|
83
|
+
setAttributes( {
|
|
84
|
+
style: cleanEmptyObject( {
|
|
85
|
+
...style,
|
|
86
|
+
typography: {
|
|
87
|
+
...style?.typography,
|
|
88
|
+
lineHeight: undefined,
|
|
89
|
+
},
|
|
90
|
+
} ),
|
|
91
|
+
} );
|
|
92
|
+
}
|
package/src/hooks/margin.js
CHANGED
|
@@ -73,7 +73,7 @@ export function resetMargin( { attributes = {}, setAttributes } ) {
|
|
|
73
73
|
* @return {boolean} Whether margin setting is disabled.
|
|
74
74
|
*/
|
|
75
75
|
export function useIsMarginDisabled( { name: blockName } = {} ) {
|
|
76
|
-
const isDisabled = ! useSetting( 'spacing.
|
|
76
|
+
const isDisabled = ! useSetting( 'spacing.margin' );
|
|
77
77
|
const isInvalid = ! useIsDimensionsSupportValid( blockName, 'margin' );
|
|
78
78
|
|
|
79
79
|
return ! hasMarginSupport( blockName ) || isDisabled || isInvalid;
|
package/src/hooks/padding.js
CHANGED
|
@@ -73,7 +73,7 @@ export function resetPadding( { attributes = {}, setAttributes } ) {
|
|
|
73
73
|
* @return {boolean} Whether padding setting is disabled.
|
|
74
74
|
*/
|
|
75
75
|
export function useIsPaddingDisabled( { name: blockName } = {} ) {
|
|
76
|
-
const isDisabled = ! useSetting( 'spacing.
|
|
76
|
+
const isDisabled = ! useSetting( 'spacing.padding' );
|
|
77
77
|
const isInvalid = ! useIsDimensionsSupportValid( blockName, 'padding' );
|
|
78
78
|
|
|
79
79
|
return ! hasPaddingSupport( blockName ) || isDisabled || isInvalid;
|
|
@@ -29,11 +29,6 @@ export function TextDecorationEdit( props ) {
|
|
|
29
29
|
attributes: { style },
|
|
30
30
|
setAttributes,
|
|
31
31
|
} = props;
|
|
32
|
-
const isDisabled = useIsTextDecorationDisabled( props );
|
|
33
|
-
|
|
34
|
-
if ( isDisabled ) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
32
|
|
|
38
33
|
function onChange( newDecoration ) {
|
|
39
34
|
setAttributes( {
|
|
@@ -67,7 +62,40 @@ export function useIsTextDecorationDisabled( { name: blockName } = {} ) {
|
|
|
67
62
|
blockName,
|
|
68
63
|
TEXT_DECORATION_SUPPORT_KEY
|
|
69
64
|
);
|
|
70
|
-
const hasTextDecoration = useSetting( 'typography.
|
|
65
|
+
const hasTextDecoration = useSetting( 'typography.textDecoration' );
|
|
71
66
|
|
|
72
67
|
return notSupported || ! hasTextDecoration;
|
|
73
68
|
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Checks if there is a current value set for the text decoration block support.
|
|
72
|
+
*
|
|
73
|
+
* @param {Object} props Block props.
|
|
74
|
+
* @return {boolean} Whether or not the block has a text decoration set.
|
|
75
|
+
*/
|
|
76
|
+
export function hasTextDecorationValue( props ) {
|
|
77
|
+
return !! props.attributes.style?.typography?.textDecoration;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Resets the text decoration block support attribute. This can be used when
|
|
82
|
+
* disabling the text decoration support controls for a block via a progressive
|
|
83
|
+
* discovery panel.
|
|
84
|
+
*
|
|
85
|
+
* @param {Object} props Block props.
|
|
86
|
+
* @param {Object} props.attributes Block's attributes.
|
|
87
|
+
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
88
|
+
*/
|
|
89
|
+
export function resetTextDecoration( { attributes = {}, setAttributes } ) {
|
|
90
|
+
const { style } = attributes;
|
|
91
|
+
|
|
92
|
+
setAttributes( {
|
|
93
|
+
style: cleanEmptyObject( {
|
|
94
|
+
...style,
|
|
95
|
+
typography: {
|
|
96
|
+
...style?.typography,
|
|
97
|
+
textDecoration: undefined,
|
|
98
|
+
},
|
|
99
|
+
} ),
|
|
100
|
+
} );
|
|
101
|
+
}
|