@wordpress/block-editor 11.3.2 → 11.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +4 -4
- package/build/components/block-actions/index.js +2 -7
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js +5 -3
- package/build/components/block-alignment-control/use-available-alignments.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-tools/selected-block-popover.js +2 -2
- package/build/components/block-tools/selected-block-popover.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/colors-gradients/control.js +6 -3
- package/build/components/colors-gradients/control.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/hooks.js +106 -45
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +24 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +421 -0
- package/build/components/global-styles/typography-panel.js.map +1 -0
- package/build/components/global-styles/use-global-styles-output.js +6 -2
- package/build/components/global-styles/use-global-styles-output.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/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/link-control/index.js +15 -15
- 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 +52 -0
- package/build/components/link-control/settings.js.map +1 -0
- 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/block-contents.js +5 -4
- package/build/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js +116 -0
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -0
- package/build/components/off-canvas-editor/link-ui.js +1 -0
- package/build/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build/components/provider/index.js +2 -2
- package/build/components/provider/index.js.map +1 -1
- package/build/components/rich-text/index.js +0 -2
- package/build/components/rich-text/index.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/url-popover/index.js +6 -1
- package/build/components/url-popover/index.js.map +1 -1
- package/build/hooks/dimensions.js +8 -2
- package/build/hooks/dimensions.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 +2 -1
- 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/line-height.js +0 -42
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/metadata.js +6 -0
- package/build/hooks/metadata.js.map +1 -1
- package/build/hooks/position.js +6 -1
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/typography.js +112 -127
- package/build/hooks/typography.js.map +1 -1
- package/build/index.js +6 -6
- package/build/index.js.map +1 -1
- package/build/layouts/flow.js +23 -2
- package/build/layouts/flow.js.map +1 -1
- package/build/lock-unlock.js +19 -0
- package/build/lock-unlock.js.map +1 -0
- package/build/{experiments.js → private-apis.js} +12 -19
- package/build/private-apis.js.map +1 -0
- package/build/{experiments.native.js → private-apis.native.js} +9 -19
- package/build/private-apis.native.js.map +1 -0
- package/build/store/index.js +3 -3
- package/build/store/index.js.map +1 -1
- package/build/store/selectors.js +18 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-actions/index.js +2 -7
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +5 -3
- package/build-module/components/block-alignment-control/use-available-alignments.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-tools/selected-block-popover.js +1 -1
- package/build-module/components/block-tools/selected-block-popover.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/colors-gradients/control.js +6 -3
- package/build-module/components/colors-gradients/control.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/hooks.js +100 -46
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +2 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +400 -0
- package/build-module/components/global-styles/typography-panel.js.map +1 -0
- package/build-module/components/global-styles/use-global-styles-output.js +6 -2
- package/build-module/components/global-styles/use-global-styles-output.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/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/link-control/index.js +16 -16
- 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 +43 -0
- package/build-module/components/link-control/settings.js.map +1 -0
- 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/block-contents.js +4 -3
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js +99 -0
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -0
- package/build-module/components/off-canvas-editor/link-ui.js +1 -0
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build-module/components/provider/index.js +1 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +0 -2
- package/build-module/components/rich-text/index.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/url-popover/index.js +6 -2
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/hooks/dimensions.js +7 -1
- package/build-module/hooks/dimensions.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 +3 -2
- 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/line-height.js +0 -38
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/metadata.js +6 -0
- package/build-module/hooks/metadata.js.map +1 -1
- package/build-module/hooks/position.js +5 -1
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/typography.js +110 -123
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/flow.js +23 -2
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/lock-unlock.js +9 -0
- package/build-module/lock-unlock.js.map +1 -0
- package/build-module/private-apis.js +19 -0
- package/build-module/private-apis.js.map +1 -0
- package/build-module/private-apis.native.js +15 -0
- package/build-module/private-apis.native.js.map +1 -0
- package/build-module/store/index.js +1 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/selectors.js +18 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +35 -22
- package/build-style/style.css +35 -22
- package/package.json +31 -31
- package/src/components/block-actions/index.js +0 -9
- package/src/components/block-alignment-control/use-available-alignments.js +17 -12
- package/src/components/block-popover/inbetween.js +21 -53
- package/src/components/block-tools/selected-block-popover.js +1 -1
- package/src/components/block-types-list/index.native.js +2 -0
- package/src/components/colors-gradients/control.js +3 -0
- package/src/components/font-appearance-control/index.js +1 -1
- package/src/components/global-styles/hooks.js +186 -66
- package/src/components/global-styles/index.js +5 -0
- package/src/components/global-styles/typography-panel.js +403 -0
- package/src/components/global-styles/use-global-styles-output.js +6 -2
- 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/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/link-control/index.js +22 -22
- package/src/components/link-control/settings-drawer.js +85 -30
- package/src/components/link-control/settings.js +41 -0
- package/src/components/link-control/style.scss +39 -7
- package/src/components/link-control/test/index.js +213 -4
- package/src/components/list-view/index.js +5 -0
- package/src/components/off-canvas-editor/block-contents.js +3 -2
- package/src/components/off-canvas-editor/leaf-more-menu.js +115 -0
- package/src/components/off-canvas-editor/link-ui.js +1 -0
- package/src/components/provider/index.js +1 -1
- package/src/components/rich-text/index.js +0 -2
- package/src/components/url-input/index.js +3 -2
- package/src/components/url-popover/index.js +8 -2
- package/src/hooks/dimensions.js +13 -1
- package/src/hooks/font-family.js +0 -58
- package/src/hooks/font-size.js +1 -36
- package/src/hooks/gap.js +9 -2
- package/src/hooks/index.js +1 -0
- package/src/hooks/line-height.js +0 -33
- package/src/hooks/metadata.js +4 -0
- package/src/hooks/position.js +7 -1
- package/src/hooks/typography.js +133 -212
- package/src/index.js +1 -1
- package/src/layouts/flow.js +16 -1
- package/src/lock-unlock.js +10 -0
- package/src/private-apis.js +19 -0
- package/src/private-apis.native.js +15 -0
- package/src/store/index.js +1 -1
- package/src/store/selectors.js +16 -1
- package/tsconfig.json +20 -1
- package/build/experiments.js.map +0 -1
- package/build/experiments.native.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/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/experiments.js +0 -25
- package/build-module/experiments.js.map +0 -1
- package/build-module/experiments.native.js +0 -23
- package/build-module/experiments.native.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/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/experiments.js +0 -27
- package/src/experiments.native.js +0 -25
- package/src/hooks/font-appearance.js +0 -146
- package/src/hooks/letter-spacing.js +0 -101
- package/src/hooks/text-decoration.js +0 -102
- package/src/hooks/text-transform.js +0 -101
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { hasBlockSupport } from '@wordpress/blocks';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import FontAppearanceControl from '../components/font-appearance-control';
|
|
10
|
-
import useSetting from '../components/use-setting';
|
|
11
|
-
import { cleanEmptyObject } from './utils';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Key within block settings' support array indicating support for font style.
|
|
15
|
-
*/
|
|
16
|
-
export const FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Key within block settings' support array indicating support for font weight.
|
|
20
|
-
*/
|
|
21
|
-
export const FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Inspector control panel containing the font appearance options.
|
|
25
|
-
*
|
|
26
|
-
* @param {Object} props Block properties.
|
|
27
|
-
*
|
|
28
|
-
* @return {WPElement} Font appearance edit element.
|
|
29
|
-
*/
|
|
30
|
-
export function FontAppearanceEdit( props ) {
|
|
31
|
-
const {
|
|
32
|
-
attributes: { style },
|
|
33
|
-
setAttributes,
|
|
34
|
-
} = props;
|
|
35
|
-
|
|
36
|
-
const hasFontStyles = ! useIsFontStyleDisabled( props );
|
|
37
|
-
const hasFontWeights = ! useIsFontWeightDisabled( props );
|
|
38
|
-
|
|
39
|
-
const onChange = ( newStyles ) => {
|
|
40
|
-
setAttributes( {
|
|
41
|
-
style: cleanEmptyObject( {
|
|
42
|
-
...style,
|
|
43
|
-
typography: {
|
|
44
|
-
...style?.typography,
|
|
45
|
-
fontStyle: newStyles.fontStyle,
|
|
46
|
-
fontWeight: newStyles.fontWeight,
|
|
47
|
-
},
|
|
48
|
-
} ),
|
|
49
|
-
} );
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const fontStyle = style?.typography?.fontStyle;
|
|
53
|
-
const fontWeight = style?.typography?.fontWeight;
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<FontAppearanceControl
|
|
57
|
-
onChange={ onChange }
|
|
58
|
-
hasFontStyles={ hasFontStyles }
|
|
59
|
-
hasFontWeights={ hasFontWeights }
|
|
60
|
-
value={ { fontStyle, fontWeight } }
|
|
61
|
-
size="__unstable-large"
|
|
62
|
-
/>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Checks if font style support has been disabled either by not opting in for
|
|
68
|
-
* support or by failing to provide preset styles.
|
|
69
|
-
*
|
|
70
|
-
* @param {Object} props Block properties.
|
|
71
|
-
* @param {string} props.name Name for the block type.
|
|
72
|
-
*
|
|
73
|
-
* @return {boolean} Whether font style support has been disabled.
|
|
74
|
-
*/
|
|
75
|
-
export function useIsFontStyleDisabled( { name: blockName } = {} ) {
|
|
76
|
-
const styleSupport = hasBlockSupport( blockName, FONT_STYLE_SUPPORT_KEY );
|
|
77
|
-
const hasFontStyles = useSetting( 'typography.fontStyle' );
|
|
78
|
-
|
|
79
|
-
return ! styleSupport || ! hasFontStyles;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Checks if font weight support has been disabled either by not opting in for
|
|
84
|
-
* support or by failing to provide preset weights.
|
|
85
|
-
*
|
|
86
|
-
* @param {Object} props Block properties.
|
|
87
|
-
* @param {string} props.name Name for the block type.
|
|
88
|
-
*
|
|
89
|
-
* @return {boolean} Whether font weight support has been disabled.
|
|
90
|
-
*/
|
|
91
|
-
export function useIsFontWeightDisabled( { name: blockName } = {} ) {
|
|
92
|
-
const weightSupport = hasBlockSupport( blockName, FONT_WEIGHT_SUPPORT_KEY );
|
|
93
|
-
const hasFontWeights = useSetting( 'typography.fontWeight' );
|
|
94
|
-
|
|
95
|
-
return ! weightSupport || ! hasFontWeights;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Checks if font appearance support has been disabled.
|
|
100
|
-
*
|
|
101
|
-
* @param {Object} props Block properties.
|
|
102
|
-
*
|
|
103
|
-
* @return {boolean} Whether font appearance support has been disabled.
|
|
104
|
-
*/
|
|
105
|
-
export function useIsFontAppearanceDisabled( props ) {
|
|
106
|
-
const stylesDisabled = useIsFontStyleDisabled( props );
|
|
107
|
-
const weightsDisabled = useIsFontWeightDisabled( props );
|
|
108
|
-
|
|
109
|
-
return stylesDisabled && weightsDisabled;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Checks if there is either a font style or weight value set within the
|
|
114
|
-
* typography styles.
|
|
115
|
-
*
|
|
116
|
-
* @param {Object} props Block props.
|
|
117
|
-
* @return {boolean} Whether or not the block has a font style or weight.
|
|
118
|
-
*/
|
|
119
|
-
export function hasFontAppearanceValue( props ) {
|
|
120
|
-
const { fontStyle, fontWeight } = props.attributes.style?.typography || {};
|
|
121
|
-
return !! fontStyle || !! fontWeight;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Resets the font style and weight block support attributes. This can be used
|
|
126
|
-
* when disabling the font appearance support controls for a block via a
|
|
127
|
-
* progressive discovery panel.
|
|
128
|
-
*
|
|
129
|
-
* @param {Object} props Block props.
|
|
130
|
-
* @param {Object} props.attributes Block's attributes.
|
|
131
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
132
|
-
*/
|
|
133
|
-
export function resetFontAppearance( { attributes = {}, setAttributes } ) {
|
|
134
|
-
const { style } = attributes;
|
|
135
|
-
|
|
136
|
-
setAttributes( {
|
|
137
|
-
style: cleanEmptyObject( {
|
|
138
|
-
...style,
|
|
139
|
-
typography: {
|
|
140
|
-
...style?.typography,
|
|
141
|
-
fontStyle: undefined,
|
|
142
|
-
fontWeight: undefined,
|
|
143
|
-
},
|
|
144
|
-
} ),
|
|
145
|
-
} );
|
|
146
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { hasBlockSupport } from '@wordpress/blocks';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import LetterSpacingControl from '../components/letter-spacing-control';
|
|
10
|
-
import useSetting from '../components/use-setting';
|
|
11
|
-
import { cleanEmptyObject } from './utils';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Key within block settings' supports array indicating support for letter-spacing
|
|
15
|
-
* e.g. settings found in `block.json`.
|
|
16
|
-
*/
|
|
17
|
-
export const LETTER_SPACING_SUPPORT_KEY =
|
|
18
|
-
'typography.__experimentalLetterSpacing';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Inspector control panel containing the letter-spacing options.
|
|
22
|
-
*
|
|
23
|
-
* @param {Object} props Block properties.
|
|
24
|
-
* @return {WPElement} Letter-spacing edit element.
|
|
25
|
-
*/
|
|
26
|
-
export function LetterSpacingEdit( props ) {
|
|
27
|
-
const {
|
|
28
|
-
attributes: { style },
|
|
29
|
-
setAttributes,
|
|
30
|
-
} = props;
|
|
31
|
-
|
|
32
|
-
function onChange( newSpacing ) {
|
|
33
|
-
setAttributes( {
|
|
34
|
-
style: cleanEmptyObject( {
|
|
35
|
-
...style,
|
|
36
|
-
typography: {
|
|
37
|
-
...style?.typography,
|
|
38
|
-
letterSpacing: newSpacing,
|
|
39
|
-
},
|
|
40
|
-
} ),
|
|
41
|
-
} );
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<LetterSpacingControl
|
|
46
|
-
value={ style?.typography?.letterSpacing }
|
|
47
|
-
onChange={ onChange }
|
|
48
|
-
__unstableInputWidth={ '100%' }
|
|
49
|
-
size="__unstable-large"
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Checks if letter-spacing settings have been disabled.
|
|
56
|
-
*
|
|
57
|
-
* @param {string} name Name of the block.
|
|
58
|
-
* @return {boolean} Whether or not the setting is disabled.
|
|
59
|
-
*/
|
|
60
|
-
export function useIsLetterSpacingDisabled( { name: blockName } = {} ) {
|
|
61
|
-
const notSupported = ! hasBlockSupport(
|
|
62
|
-
blockName,
|
|
63
|
-
LETTER_SPACING_SUPPORT_KEY
|
|
64
|
-
);
|
|
65
|
-
const hasLetterSpacing = useSetting( 'typography.letterSpacing' );
|
|
66
|
-
|
|
67
|
-
return notSupported || ! hasLetterSpacing;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Checks if there is a current value set for the letter spacing block support.
|
|
72
|
-
*
|
|
73
|
-
* @param {Object} props Block props.
|
|
74
|
-
* @return {boolean} Whether or not the block has a letter spacing set.
|
|
75
|
-
*/
|
|
76
|
-
export function hasLetterSpacingValue( props ) {
|
|
77
|
-
return !! props.attributes.style?.typography?.letterSpacing;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Resets the letter spacing block support attribute. This can be used when
|
|
82
|
-
* disabling the letter spacing 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 resetLetterSpacing( { attributes = {}, setAttributes } ) {
|
|
90
|
-
const { style } = attributes;
|
|
91
|
-
|
|
92
|
-
setAttributes( {
|
|
93
|
-
style: cleanEmptyObject( {
|
|
94
|
-
...style,
|
|
95
|
-
typography: {
|
|
96
|
-
...style?.typography,
|
|
97
|
-
letterSpacing: undefined,
|
|
98
|
-
},
|
|
99
|
-
} ),
|
|
100
|
-
} );
|
|
101
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { hasBlockSupport } from '@wordpress/blocks';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import TextDecorationControl from '../components/text-decoration-control';
|
|
10
|
-
import useSetting from '../components/use-setting';
|
|
11
|
-
import { cleanEmptyObject } from './utils';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Key within block settings' supports array indicating support for text
|
|
15
|
-
* decorations e.g. settings found in `block.json`.
|
|
16
|
-
*/
|
|
17
|
-
export const TEXT_DECORATION_SUPPORT_KEY =
|
|
18
|
-
'typography.__experimentalTextDecoration';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Inspector control panel containing the text decoration options.
|
|
22
|
-
*
|
|
23
|
-
* @param {Object} props Block properties.
|
|
24
|
-
*
|
|
25
|
-
* @return {WPElement} Text decoration edit element.
|
|
26
|
-
*/
|
|
27
|
-
export function TextDecorationEdit( props ) {
|
|
28
|
-
const {
|
|
29
|
-
attributes: { style },
|
|
30
|
-
setAttributes,
|
|
31
|
-
} = props;
|
|
32
|
-
|
|
33
|
-
function onChange( newDecoration ) {
|
|
34
|
-
setAttributes( {
|
|
35
|
-
style: cleanEmptyObject( {
|
|
36
|
-
...style,
|
|
37
|
-
typography: {
|
|
38
|
-
...style?.typography,
|
|
39
|
-
textDecoration: newDecoration,
|
|
40
|
-
},
|
|
41
|
-
} ),
|
|
42
|
-
} );
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<TextDecorationControl
|
|
47
|
-
value={ style?.typography?.textDecoration }
|
|
48
|
-
onChange={ onChange }
|
|
49
|
-
size="__unstable-large"
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Checks if text-decoration settings have been disabled.
|
|
56
|
-
*
|
|
57
|
-
* @param {string} name Name of the block.
|
|
58
|
-
*
|
|
59
|
-
* @return {boolean} Whether or not the setting is disabled.
|
|
60
|
-
*/
|
|
61
|
-
export function useIsTextDecorationDisabled( { name: blockName } = {} ) {
|
|
62
|
-
const notSupported = ! hasBlockSupport(
|
|
63
|
-
blockName,
|
|
64
|
-
TEXT_DECORATION_SUPPORT_KEY
|
|
65
|
-
);
|
|
66
|
-
const hasTextDecoration = useSetting( 'typography.textDecoration' );
|
|
67
|
-
|
|
68
|
-
return notSupported || ! hasTextDecoration;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Checks if there is a current value set for the text decoration block support.
|
|
73
|
-
*
|
|
74
|
-
* @param {Object} props Block props.
|
|
75
|
-
* @return {boolean} Whether or not the block has a text decoration set.
|
|
76
|
-
*/
|
|
77
|
-
export function hasTextDecorationValue( props ) {
|
|
78
|
-
return !! props.attributes.style?.typography?.textDecoration;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Resets the text decoration block support attribute. This can be used when
|
|
83
|
-
* disabling the text decoration support controls for a block via a progressive
|
|
84
|
-
* discovery panel.
|
|
85
|
-
*
|
|
86
|
-
* @param {Object} props Block props.
|
|
87
|
-
* @param {Object} props.attributes Block's attributes.
|
|
88
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
89
|
-
*/
|
|
90
|
-
export function resetTextDecoration( { attributes = {}, setAttributes } ) {
|
|
91
|
-
const { style } = attributes;
|
|
92
|
-
|
|
93
|
-
setAttributes( {
|
|
94
|
-
style: cleanEmptyObject( {
|
|
95
|
-
...style,
|
|
96
|
-
typography: {
|
|
97
|
-
...style?.typography,
|
|
98
|
-
textDecoration: undefined,
|
|
99
|
-
},
|
|
100
|
-
} ),
|
|
101
|
-
} );
|
|
102
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { hasBlockSupport } from '@wordpress/blocks';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import TextTransformControl from '../components/text-transform-control';
|
|
10
|
-
import useSetting from '../components/use-setting';
|
|
11
|
-
import { cleanEmptyObject } from './utils';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Key within block settings' supports array indicating support for text
|
|
15
|
-
* transforms e.g. settings found in `block.json`.
|
|
16
|
-
*/
|
|
17
|
-
export const TEXT_TRANSFORM_SUPPORT_KEY =
|
|
18
|
-
'typography.__experimentalTextTransform';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Inspector control panel containing the text transform options.
|
|
22
|
-
*
|
|
23
|
-
* @param {Object} props Block properties.
|
|
24
|
-
*
|
|
25
|
-
* @return {WPElement} Text transform edit element.
|
|
26
|
-
*/
|
|
27
|
-
export function TextTransformEdit( props ) {
|
|
28
|
-
const {
|
|
29
|
-
attributes: { style },
|
|
30
|
-
setAttributes,
|
|
31
|
-
} = props;
|
|
32
|
-
|
|
33
|
-
function onChange( newTransform ) {
|
|
34
|
-
setAttributes( {
|
|
35
|
-
style: cleanEmptyObject( {
|
|
36
|
-
...style,
|
|
37
|
-
typography: {
|
|
38
|
-
...style?.typography,
|
|
39
|
-
textTransform: newTransform,
|
|
40
|
-
},
|
|
41
|
-
} ),
|
|
42
|
-
} );
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<TextTransformControl
|
|
47
|
-
value={ style?.typography?.textTransform }
|
|
48
|
-
onChange={ onChange }
|
|
49
|
-
size="__unstable-large"
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Checks if text-transform settings have been disabled.
|
|
56
|
-
*
|
|
57
|
-
* @param {string} name Name of the block.
|
|
58
|
-
*
|
|
59
|
-
* @return {boolean} Whether or not the setting is disabled.
|
|
60
|
-
*/
|
|
61
|
-
export function useIsTextTransformDisabled( { name: blockName } = {} ) {
|
|
62
|
-
const notSupported = ! hasBlockSupport(
|
|
63
|
-
blockName,
|
|
64
|
-
TEXT_TRANSFORM_SUPPORT_KEY
|
|
65
|
-
);
|
|
66
|
-
const hasTextTransforms = useSetting( 'typography.textTransform' );
|
|
67
|
-
return notSupported || ! hasTextTransforms;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Checks if there is a current value set for the text transform block support.
|
|
72
|
-
*
|
|
73
|
-
* @param {Object} props Block props.
|
|
74
|
-
* @return {boolean} Whether or not the block has a text transform set.
|
|
75
|
-
*/
|
|
76
|
-
export function hasTextTransformValue( props ) {
|
|
77
|
-
return !! props.attributes.style?.typography?.textTransform;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Resets the text transform block support attribute. This can be used when
|
|
82
|
-
* disabling the text transform 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 resetTextTransform( { attributes = {}, setAttributes } ) {
|
|
90
|
-
const { style } = attributes;
|
|
91
|
-
|
|
92
|
-
setAttributes( {
|
|
93
|
-
style: cleanEmptyObject( {
|
|
94
|
-
...style,
|
|
95
|
-
typography: {
|
|
96
|
-
...style?.typography,
|
|
97
|
-
textTransform: undefined,
|
|
98
|
-
},
|
|
99
|
-
} ),
|
|
100
|
-
} );
|
|
101
|
-
}
|