@wordpress/block-editor 11.3.3 → 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.
Files changed (192) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/block-popover/inbetween.js +10 -33
  3. package/build/components/block-popover/inbetween.js.map +1 -1
  4. package/build/components/block-types-list/index.native.js +2 -0
  5. package/build/components/block-types-list/index.native.js.map +1 -1
  6. package/build/components/colors-gradients/control.js +6 -3
  7. package/build/components/colors-gradients/control.js.map +1 -1
  8. package/build/components/font-appearance-control/index.js +0 -3
  9. package/build/components/font-appearance-control/index.js.map +1 -1
  10. package/build/components/global-styles/hooks.js +106 -45
  11. package/build/components/global-styles/hooks.js.map +1 -1
  12. package/build/components/global-styles/index.js +24 -0
  13. package/build/components/global-styles/index.js.map +1 -1
  14. package/build/components/global-styles/typography-panel.js +421 -0
  15. package/build/components/global-styles/typography-panel.js.map +1 -0
  16. package/build/components/global-styles/use-global-styles-output.js +6 -2
  17. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  18. package/build/components/iframe/index.js +17 -11
  19. package/build/components/iframe/index.js.map +1 -1
  20. package/build/components/image-editor/aspect-ratio-dropdown.js +2 -1
  21. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  22. package/build/components/image-size-control/index.js +6 -11
  23. package/build/components/image-size-control/index.js.map +1 -1
  24. package/build/components/inserter/block-patterns-tab.js +9 -15
  25. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  26. package/build/components/inserter/block-types-tab.native.js +4 -1
  27. package/build/components/inserter/block-types-tab.native.js.map +1 -1
  28. package/build/components/inserter/reusable-blocks-tab.native.js +4 -1
  29. package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  30. package/build/components/inserter/search-results.native.js +4 -1
  31. package/build/components/inserter/search-results.native.js.map +1 -1
  32. package/build/components/link-control/index.js +15 -15
  33. package/build/components/link-control/index.js.map +1 -1
  34. package/build/components/link-control/settings-drawer.js +72 -30
  35. package/build/components/link-control/settings-drawer.js.map +1 -1
  36. package/build/components/link-control/settings.js +52 -0
  37. package/build/components/link-control/settings.js.map +1 -0
  38. package/build/components/list-view/index.js +6 -1
  39. package/build/components/list-view/index.js.map +1 -1
  40. package/build/components/off-canvas-editor/block-contents.js +3 -2
  41. package/build/components/off-canvas-editor/block-contents.js.map +1 -1
  42. package/build/components/off-canvas-editor/leaf-more-menu.js +116 -0
  43. package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -0
  44. package/build/components/off-canvas-editor/link-ui.js +1 -0
  45. package/build/components/off-canvas-editor/link-ui.js.map +1 -1
  46. package/build/components/rich-text/index.js +0 -2
  47. package/build/components/rich-text/index.js.map +1 -1
  48. package/build/components/url-input/index.js +2 -2
  49. package/build/components/url-input/index.js.map +1 -1
  50. package/build/hooks/dimensions.js +6 -0
  51. package/build/hooks/dimensions.js.map +1 -1
  52. package/build/hooks/font-family.js +2 -76
  53. package/build/hooks/font-family.js.map +1 -1
  54. package/build/hooks/font-size.js +3 -51
  55. package/build/hooks/font-size.js.map +1 -1
  56. package/build/hooks/gap.js +2 -1
  57. package/build/hooks/gap.js.map +1 -1
  58. package/build/hooks/index.js +2 -0
  59. package/build/hooks/index.js.map +1 -1
  60. package/build/hooks/line-height.js +0 -42
  61. package/build/hooks/line-height.js.map +1 -1
  62. package/build/hooks/typography.js +112 -127
  63. package/build/hooks/typography.js.map +1 -1
  64. package/build/private-apis.js +3 -0
  65. package/build/private-apis.js.map +1 -1
  66. package/build/store/selectors.js +18 -1
  67. package/build/store/selectors.js.map +1 -1
  68. package/build-module/components/block-popover/inbetween.js +10 -33
  69. package/build-module/components/block-popover/inbetween.js.map +1 -1
  70. package/build-module/components/block-types-list/index.native.js +2 -0
  71. package/build-module/components/block-types-list/index.native.js.map +1 -1
  72. package/build-module/components/colors-gradients/control.js +6 -3
  73. package/build-module/components/colors-gradients/control.js.map +1 -1
  74. package/build-module/components/font-appearance-control/index.js +2 -1
  75. package/build-module/components/font-appearance-control/index.js.map +1 -1
  76. package/build-module/components/global-styles/hooks.js +100 -46
  77. package/build-module/components/global-styles/hooks.js.map +1 -1
  78. package/build-module/components/global-styles/index.js +2 -1
  79. package/build-module/components/global-styles/index.js.map +1 -1
  80. package/build-module/components/global-styles/typography-panel.js +400 -0
  81. package/build-module/components/global-styles/typography-panel.js.map +1 -0
  82. package/build-module/components/global-styles/use-global-styles-output.js +6 -2
  83. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  84. package/build-module/components/iframe/index.js +17 -11
  85. package/build-module/components/iframe/index.js.map +1 -1
  86. package/build-module/components/image-editor/aspect-ratio-dropdown.js +2 -1
  87. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  88. package/build-module/components/image-size-control/index.js +7 -12
  89. package/build-module/components/image-size-control/index.js.map +1 -1
  90. package/build-module/components/inserter/block-patterns-tab.js +9 -15
  91. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  92. package/build-module/components/inserter/block-types-tab.native.js +3 -1
  93. package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
  94. package/build-module/components/inserter/reusable-blocks-tab.native.js +3 -1
  95. package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  96. package/build-module/components/inserter/search-results.native.js +3 -1
  97. package/build-module/components/inserter/search-results.native.js.map +1 -1
  98. package/build-module/components/link-control/index.js +16 -16
  99. package/build-module/components/link-control/index.js.map +1 -1
  100. package/build-module/components/link-control/settings-drawer.js +68 -30
  101. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  102. package/build-module/components/link-control/settings.js +43 -0
  103. package/build-module/components/link-control/settings.js.map +1 -0
  104. package/build-module/components/list-view/index.js +6 -1
  105. package/build-module/components/list-view/index.js.map +1 -1
  106. package/build-module/components/off-canvas-editor/block-contents.js +3 -2
  107. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
  108. package/build-module/components/off-canvas-editor/leaf-more-menu.js +99 -0
  109. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -0
  110. package/build-module/components/off-canvas-editor/link-ui.js +1 -0
  111. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
  112. package/build-module/components/rich-text/index.js +0 -2
  113. package/build-module/components/rich-text/index.js.map +1 -1
  114. package/build-module/components/url-input/index.js +2 -2
  115. package/build-module/components/url-input/index.js.map +1 -1
  116. package/build-module/hooks/dimensions.js +6 -0
  117. package/build-module/hooks/dimensions.js.map +1 -1
  118. package/build-module/hooks/font-family.js +3 -69
  119. package/build-module/hooks/font-family.js.map +1 -1
  120. package/build-module/hooks/font-size.js +6 -47
  121. package/build-module/hooks/font-size.js.map +1 -1
  122. package/build-module/hooks/gap.js +3 -2
  123. package/build-module/hooks/gap.js.map +1 -1
  124. package/build-module/hooks/index.js +1 -0
  125. package/build-module/hooks/index.js.map +1 -1
  126. package/build-module/hooks/line-height.js +0 -38
  127. package/build-module/hooks/line-height.js.map +1 -1
  128. package/build-module/hooks/typography.js +110 -123
  129. package/build-module/hooks/typography.js.map +1 -1
  130. package/build-module/private-apis.js +2 -0
  131. package/build-module/private-apis.js.map +1 -1
  132. package/build-module/store/selectors.js +18 -1
  133. package/build-module/store/selectors.js.map +1 -1
  134. package/build-style/style-rtl.css +35 -22
  135. package/build-style/style.css +35 -22
  136. package/package.json +31 -31
  137. package/src/components/block-popover/inbetween.js +21 -53
  138. package/src/components/block-types-list/index.native.js +2 -0
  139. package/src/components/colors-gradients/control.js +3 -0
  140. package/src/components/font-appearance-control/index.js +1 -1
  141. package/src/components/global-styles/hooks.js +186 -66
  142. package/src/components/global-styles/index.js +5 -0
  143. package/src/components/global-styles/typography-panel.js +403 -0
  144. package/src/components/global-styles/use-global-styles-output.js +6 -2
  145. package/src/components/iframe/index.js +20 -18
  146. package/src/components/image-editor/aspect-ratio-dropdown.js +1 -0
  147. package/src/components/image-size-control/index.js +10 -12
  148. package/src/components/image-size-control/style.scss +3 -21
  149. package/src/components/inserter/block-patterns-tab.js +9 -23
  150. package/src/components/inserter/block-types-tab.native.js +2 -0
  151. package/src/components/inserter/reusable-blocks-tab.native.js +2 -0
  152. package/src/components/inserter/search-results.native.js +2 -0
  153. package/src/components/link-control/index.js +22 -22
  154. package/src/components/link-control/settings-drawer.js +85 -30
  155. package/src/components/link-control/settings.js +41 -0
  156. package/src/components/link-control/style.scss +39 -7
  157. package/src/components/link-control/test/index.js +213 -4
  158. package/src/components/list-view/index.js +5 -0
  159. package/src/components/off-canvas-editor/block-contents.js +2 -1
  160. package/src/components/off-canvas-editor/leaf-more-menu.js +115 -0
  161. package/src/components/off-canvas-editor/link-ui.js +1 -0
  162. package/src/components/rich-text/index.js +0 -2
  163. package/src/components/url-input/index.js +3 -2
  164. package/src/hooks/dimensions.js +12 -0
  165. package/src/hooks/font-family.js +0 -58
  166. package/src/hooks/font-size.js +1 -36
  167. package/src/hooks/gap.js +9 -2
  168. package/src/hooks/index.js +1 -0
  169. package/src/hooks/line-height.js +0 -33
  170. package/src/hooks/typography.js +133 -212
  171. package/src/private-apis.js +2 -0
  172. package/src/store/selectors.js +16 -1
  173. package/build/hooks/font-appearance.js +0 -188
  174. package/build/hooks/font-appearance.js.map +0 -1
  175. package/build/hooks/letter-spacing.js +0 -129
  176. package/build/hooks/letter-spacing.js.map +0 -1
  177. package/build/hooks/text-decoration.js +0 -130
  178. package/build/hooks/text-decoration.js.map +0 -1
  179. package/build/hooks/text-transform.js +0 -130
  180. package/build/hooks/text-transform.js.map +0 -1
  181. package/build-module/hooks/font-appearance.js +0 -161
  182. package/build-module/hooks/font-appearance.js.map +0 -1
  183. package/build-module/hooks/letter-spacing.js +0 -107
  184. package/build-module/hooks/letter-spacing.js.map +0 -1
  185. package/build-module/hooks/text-decoration.js +0 -108
  186. package/build-module/hooks/text-decoration.js.map +0 -1
  187. package/build-module/hooks/text-transform.js +0 -108
  188. package/build-module/hooks/text-transform.js.map +0 -1
  189. package/src/hooks/font-appearance.js +0 -146
  190. package/src/hooks/letter-spacing.js +0 -101
  191. package/src/hooks/text-decoration.js +0 -102
  192. package/src/hooks/text-transform.js +0 -101
@@ -1,107 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- /**
4
- * WordPress dependencies
5
- */
6
- import { hasBlockSupport } from '@wordpress/blocks';
7
- /**
8
- * Internal dependencies
9
- */
10
-
11
- import LetterSpacingControl from '../components/letter-spacing-control';
12
- import useSetting from '../components/use-setting';
13
- import { cleanEmptyObject } from './utils';
14
- /**
15
- * Key within block settings' supports array indicating support for letter-spacing
16
- * e.g. settings found in `block.json`.
17
- */
18
-
19
- export const LETTER_SPACING_SUPPORT_KEY = 'typography.__experimentalLetterSpacing';
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
-
27
- export function LetterSpacingEdit(props) {
28
- var _style$typography;
29
-
30
- const {
31
- attributes: {
32
- style
33
- },
34
- setAttributes
35
- } = props;
36
-
37
- function onChange(newSpacing) {
38
- setAttributes({
39
- style: cleanEmptyObject({ ...style,
40
- typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
41
- letterSpacing: newSpacing
42
- }
43
- })
44
- });
45
- }
46
-
47
- return createElement(LetterSpacingControl, {
48
- value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.letterSpacing,
49
- onChange: onChange,
50
- __unstableInputWidth: '100%',
51
- size: "__unstable-large"
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
-
61
- export function useIsLetterSpacingDisabled() {
62
- let {
63
- name: blockName
64
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
65
- const notSupported = !hasBlockSupport(blockName, LETTER_SPACING_SUPPORT_KEY);
66
- const hasLetterSpacing = useSetting('typography.letterSpacing');
67
- return notSupported || !hasLetterSpacing;
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
-
76
- export function hasLetterSpacingValue(props) {
77
- var _props$attributes$sty, _props$attributes$sty2;
78
-
79
- return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.typography) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.letterSpacing);
80
- }
81
- /**
82
- * Resets the letter spacing block support attribute. This can be used when
83
- * disabling the letter spacing 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
-
91
- export function resetLetterSpacing(_ref) {
92
- let {
93
- attributes = {},
94
- setAttributes
95
- } = _ref;
96
- const {
97
- style
98
- } = attributes;
99
- setAttributes({
100
- style: cleanEmptyObject({ ...style,
101
- typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
102
- letterSpacing: undefined
103
- }
104
- })
105
- });
106
- }
107
- //# sourceMappingURL=letter-spacing.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/letter-spacing.js"],"names":["hasBlockSupport","LetterSpacingControl","useSetting","cleanEmptyObject","LETTER_SPACING_SUPPORT_KEY","LetterSpacingEdit","props","attributes","style","setAttributes","onChange","newSpacing","typography","letterSpacing","useIsLetterSpacingDisabled","name","blockName","notSupported","hasLetterSpacing","hasLetterSpacingValue","resetLetterSpacing","undefined"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,sCAAjC;AACA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,SAASC,gBAAT,QAAiC,SAAjC;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,0BAA0B,GACtC,wCADM;AAGP;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,iBAAT,CAA4BC,KAA5B,EAAoC;AAAA;;AAC1C,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;;AAKA,WAASI,QAAT,CAAmBC,UAAnB,EAAgC;AAC/BF,IAAAA,aAAa,CAAE;AACdD,MAAAA,KAAK,EAAEL,gBAAgB,CAAE,EACxB,GAAGK,KADqB;AAExBI,QAAAA,UAAU,EAAE,EACX,IAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEI,UAAV,CADW;AAEXC,UAAAA,aAAa,EAAEF;AAFJ;AAFY,OAAF;AADT,KAAF,CAAb;AASA;;AAED,SACC,cAAC,oBAAD;AACC,IAAA,KAAK,EAAGH,KAAH,aAAGA,KAAH,4CAAGA,KAAK,CAAEI,UAAV,sDAAG,kBAAmBC,aAD5B;AAEC,IAAA,QAAQ,EAAGH,QAFZ;AAGC,IAAA,oBAAoB,EAAG,MAHxB;AAIC,IAAA,IAAI,EAAC;AAJN,IADD;AAQA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,0BAAT,GAAgE;AAAA,MAA3B;AAAEC,IAAAA,IAAI,EAAEC;AAAR,GAA2B,uEAAL,EAAK;AACtE,QAAMC,YAAY,GAAG,CAAEjB,eAAe,CACrCgB,SADqC,EAErCZ,0BAFqC,CAAtC;AAIA,QAAMc,gBAAgB,GAAGhB,UAAU,CAAE,0BAAF,CAAnC;AAEA,SAAOe,YAAY,IAAI,CAAEC,gBAAzB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,qBAAT,CAAgCb,KAAhC,EAAwC;AAAA;;AAC9C,SAAO,CAAC,2BAAEA,KAAK,CAACC,UAAN,CAAiBC,KAAnB,4EAAE,sBAAwBI,UAA1B,mDAAE,uBAAoCC,aAAtC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASO,kBAAT,OAAkE;AAAA,MAArC;AAAEb,IAAAA,UAAU,GAAG,EAAf;AAAmBE,IAAAA;AAAnB,GAAqC;AACxE,QAAM;AAAED,IAAAA;AAAF,MAAYD,UAAlB;AAEAE,EAAAA,aAAa,CAAE;AACdD,IAAAA,KAAK,EAAEL,gBAAgB,CAAE,EACxB,GAAGK,KADqB;AAExBI,MAAAA,UAAU,EAAE,EACX,IAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEI,UAAV,CADW;AAEXC,QAAAA,aAAa,EAAEQ;AAFJ;AAFY,KAAF;AADT,GAAF,CAAb;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport LetterSpacingControl from '../components/letter-spacing-control';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Key within block settings' supports array indicating support for letter-spacing\n * e.g. settings found in `block.json`.\n */\nexport const LETTER_SPACING_SUPPORT_KEY =\n\t'typography.__experimentalLetterSpacing';\n\n/**\n * Inspector control panel containing the letter-spacing options.\n *\n * @param {Object} props Block properties.\n * @return {WPElement} Letter-spacing edit element.\n */\nexport function LetterSpacingEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tfunction onChange( newSpacing ) {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\ttypography: {\n\t\t\t\t\t...style?.typography,\n\t\t\t\t\tletterSpacing: newSpacing,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<LetterSpacingControl\n\t\t\tvalue={ style?.typography?.letterSpacing }\n\t\t\tonChange={ onChange }\n\t\t\t__unstableInputWidth={ '100%' }\n\t\t\tsize=\"__unstable-large\"\n\t\t/>\n\t);\n}\n\n/**\n * Checks if letter-spacing settings have been disabled.\n *\n * @param {string} name Name of the block.\n * @return {boolean} Whether or not the setting is disabled.\n */\nexport function useIsLetterSpacingDisabled( { name: blockName } = {} ) {\n\tconst notSupported = ! hasBlockSupport(\n\t\tblockName,\n\t\tLETTER_SPACING_SUPPORT_KEY\n\t);\n\tconst hasLetterSpacing = useSetting( 'typography.letterSpacing' );\n\n\treturn notSupported || ! hasLetterSpacing;\n}\n\n/**\n * Checks if there is a current value set for the letter spacing block support.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a letter spacing set.\n */\nexport function hasLetterSpacingValue( props ) {\n\treturn !! props.attributes.style?.typography?.letterSpacing;\n}\n\n/**\n * Resets the letter spacing block support attribute. This can be used when\n * disabling the letter spacing support controls for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetLetterSpacing( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\ttypography: {\n\t\t\t\t...style?.typography,\n\t\t\t\tletterSpacing: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n"]}
@@ -1,108 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- /**
4
- * WordPress dependencies
5
- */
6
- import { hasBlockSupport } from '@wordpress/blocks';
7
- /**
8
- * Internal dependencies
9
- */
10
-
11
- import TextDecorationControl from '../components/text-decoration-control';
12
- import useSetting from '../components/use-setting';
13
- import { cleanEmptyObject } from './utils';
14
- /**
15
- * Key within block settings' supports array indicating support for text
16
- * decorations e.g. settings found in `block.json`.
17
- */
18
-
19
- export const TEXT_DECORATION_SUPPORT_KEY = 'typography.__experimentalTextDecoration';
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
-
28
- export function TextDecorationEdit(props) {
29
- var _style$typography;
30
-
31
- const {
32
- attributes: {
33
- style
34
- },
35
- setAttributes
36
- } = props;
37
-
38
- function onChange(newDecoration) {
39
- setAttributes({
40
- style: cleanEmptyObject({ ...style,
41
- typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
42
- textDecoration: newDecoration
43
- }
44
- })
45
- });
46
- }
47
-
48
- return createElement(TextDecorationControl, {
49
- value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.textDecoration,
50
- onChange: onChange,
51
- size: "__unstable-large"
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
-
62
- export function useIsTextDecorationDisabled() {
63
- let {
64
- name: blockName
65
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
66
- const notSupported = !hasBlockSupport(blockName, TEXT_DECORATION_SUPPORT_KEY);
67
- const hasTextDecoration = useSetting('typography.textDecoration');
68
- return notSupported || !hasTextDecoration;
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
-
77
- export function hasTextDecorationValue(props) {
78
- var _props$attributes$sty, _props$attributes$sty2;
79
-
80
- return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.typography) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.textDecoration);
81
- }
82
- /**
83
- * Resets the text decoration block support attribute. This can be used when
84
- * disabling the text decoration support controls for a block via a progressive
85
- * discovery panel.
86
- *
87
- * @param {Object} props Block props.
88
- * @param {Object} props.attributes Block's attributes.
89
- * @param {Object} props.setAttributes Function to set block's attributes.
90
- */
91
-
92
- export function resetTextDecoration(_ref) {
93
- let {
94
- attributes = {},
95
- setAttributes
96
- } = _ref;
97
- const {
98
- style
99
- } = attributes;
100
- setAttributes({
101
- style: cleanEmptyObject({ ...style,
102
- typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
103
- textDecoration: undefined
104
- }
105
- })
106
- });
107
- }
108
- //# sourceMappingURL=text-decoration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/text-decoration.js"],"names":["hasBlockSupport","TextDecorationControl","useSetting","cleanEmptyObject","TEXT_DECORATION_SUPPORT_KEY","TextDecorationEdit","props","attributes","style","setAttributes","onChange","newDecoration","typography","textDecoration","useIsTextDecorationDisabled","name","blockName","notSupported","hasTextDecoration","hasTextDecorationValue","resetTextDecoration","undefined"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,qBAAP,MAAkC,uCAAlC;AACA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,SAASC,gBAAT,QAAiC,SAAjC;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,2BAA2B,GACvC,yCADM;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,kBAAT,CAA6BC,KAA7B,EAAqC;AAAA;;AAC3C,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;;AAKA,WAASI,QAAT,CAAmBC,aAAnB,EAAmC;AAClCF,IAAAA,aAAa,CAAE;AACdD,MAAAA,KAAK,EAAEL,gBAAgB,CAAE,EACxB,GAAGK,KADqB;AAExBI,QAAAA,UAAU,EAAE,EACX,IAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEI,UAAV,CADW;AAEXC,UAAAA,cAAc,EAAEF;AAFL;AAFY,OAAF;AADT,KAAF,CAAb;AASA;;AAED,SACC,cAAC,qBAAD;AACC,IAAA,KAAK,EAAGH,KAAH,aAAGA,KAAH,4CAAGA,KAAK,CAAEI,UAAV,sDAAG,kBAAmBC,cAD5B;AAEC,IAAA,QAAQ,EAAGH,QAFZ;AAGC,IAAA,IAAI,EAAC;AAHN,IADD;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,2BAAT,GAAiE;AAAA,MAA3B;AAAEC,IAAAA,IAAI,EAAEC;AAAR,GAA2B,uEAAL,EAAK;AACvE,QAAMC,YAAY,GAAG,CAAEjB,eAAe,CACrCgB,SADqC,EAErCZ,2BAFqC,CAAtC;AAIA,QAAMc,iBAAiB,GAAGhB,UAAU,CAAE,2BAAF,CAApC;AAEA,SAAOe,YAAY,IAAI,CAAEC,iBAAzB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,sBAAT,CAAiCb,KAAjC,EAAyC;AAAA;;AAC/C,SAAO,CAAC,2BAAEA,KAAK,CAACC,UAAN,CAAiBC,KAAnB,4EAAE,sBAAwBI,UAA1B,mDAAE,uBAAoCC,cAAtC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASO,mBAAT,OAAmE;AAAA,MAArC;AAAEb,IAAAA,UAAU,GAAG,EAAf;AAAmBE,IAAAA;AAAnB,GAAqC;AACzE,QAAM;AAAED,IAAAA;AAAF,MAAYD,UAAlB;AAEAE,EAAAA,aAAa,CAAE;AACdD,IAAAA,KAAK,EAAEL,gBAAgB,CAAE,EACxB,GAAGK,KADqB;AAExBI,MAAAA,UAAU,EAAE,EACX,IAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEI,UAAV,CADW;AAEXC,QAAAA,cAAc,EAAEQ;AAFL;AAFY,KAAF;AADT,GAAF,CAAb;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport TextDecorationControl from '../components/text-decoration-control';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Key within block settings' supports array indicating support for text\n * decorations e.g. settings found in `block.json`.\n */\nexport const TEXT_DECORATION_SUPPORT_KEY =\n\t'typography.__experimentalTextDecoration';\n\n/**\n * Inspector control panel containing the text decoration options.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Text decoration edit element.\n */\nexport function TextDecorationEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tfunction onChange( newDecoration ) {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\ttypography: {\n\t\t\t\t\t...style?.typography,\n\t\t\t\t\ttextDecoration: newDecoration,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<TextDecorationControl\n\t\t\tvalue={ style?.typography?.textDecoration }\n\t\t\tonChange={ onChange }\n\t\t\tsize=\"__unstable-large\"\n\t\t/>\n\t);\n}\n\n/**\n * Checks if text-decoration settings have been disabled.\n *\n * @param {string} name Name of the block.\n *\n * @return {boolean} Whether or not the setting is disabled.\n */\nexport function useIsTextDecorationDisabled( { name: blockName } = {} ) {\n\tconst notSupported = ! hasBlockSupport(\n\t\tblockName,\n\t\tTEXT_DECORATION_SUPPORT_KEY\n\t);\n\tconst hasTextDecoration = useSetting( 'typography.textDecoration' );\n\n\treturn notSupported || ! hasTextDecoration;\n}\n\n/**\n * Checks if there is a current value set for the text decoration block support.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a text decoration set.\n */\nexport function hasTextDecorationValue( props ) {\n\treturn !! props.attributes.style?.typography?.textDecoration;\n}\n\n/**\n * Resets the text decoration block support attribute. This can be used when\n * disabling the text decoration support controls for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetTextDecoration( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\ttypography: {\n\t\t\t\t...style?.typography,\n\t\t\t\ttextDecoration: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n"]}
@@ -1,108 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- /**
4
- * WordPress dependencies
5
- */
6
- import { hasBlockSupport } from '@wordpress/blocks';
7
- /**
8
- * Internal dependencies
9
- */
10
-
11
- import TextTransformControl from '../components/text-transform-control';
12
- import useSetting from '../components/use-setting';
13
- import { cleanEmptyObject } from './utils';
14
- /**
15
- * Key within block settings' supports array indicating support for text
16
- * transforms e.g. settings found in `block.json`.
17
- */
18
-
19
- export const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.__experimentalTextTransform';
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
-
28
- export function TextTransformEdit(props) {
29
- var _style$typography;
30
-
31
- const {
32
- attributes: {
33
- style
34
- },
35
- setAttributes
36
- } = props;
37
-
38
- function onChange(newTransform) {
39
- setAttributes({
40
- style: cleanEmptyObject({ ...style,
41
- typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
42
- textTransform: newTransform
43
- }
44
- })
45
- });
46
- }
47
-
48
- return createElement(TextTransformControl, {
49
- value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.textTransform,
50
- onChange: onChange,
51
- size: "__unstable-large"
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
-
62
- export function useIsTextTransformDisabled() {
63
- let {
64
- name: blockName
65
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
66
- const notSupported = !hasBlockSupport(blockName, TEXT_TRANSFORM_SUPPORT_KEY);
67
- const hasTextTransforms = useSetting('typography.textTransform');
68
- return notSupported || !hasTextTransforms;
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
-
77
- export function hasTextTransformValue(props) {
78
- var _props$attributes$sty, _props$attributes$sty2;
79
-
80
- return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.typography) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.textTransform);
81
- }
82
- /**
83
- * Resets the text transform block support attribute. This can be used when
84
- * disabling the text transform support controls for a block via a progressive
85
- * discovery panel.
86
- *
87
- * @param {Object} props Block props.
88
- * @param {Object} props.attributes Block's attributes.
89
- * @param {Object} props.setAttributes Function to set block's attributes.
90
- */
91
-
92
- export function resetTextTransform(_ref) {
93
- let {
94
- attributes = {},
95
- setAttributes
96
- } = _ref;
97
- const {
98
- style
99
- } = attributes;
100
- setAttributes({
101
- style: cleanEmptyObject({ ...style,
102
- typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
103
- textTransform: undefined
104
- }
105
- })
106
- });
107
- }
108
- //# sourceMappingURL=text-transform.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/text-transform.js"],"names":["hasBlockSupport","TextTransformControl","useSetting","cleanEmptyObject","TEXT_TRANSFORM_SUPPORT_KEY","TextTransformEdit","props","attributes","style","setAttributes","onChange","newTransform","typography","textTransform","useIsTextTransformDisabled","name","blockName","notSupported","hasTextTransforms","hasTextTransformValue","resetTextTransform","undefined"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,sCAAjC;AACA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,SAASC,gBAAT,QAAiC,SAAjC;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,0BAA0B,GACtC,wCADM;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,iBAAT,CAA4BC,KAA5B,EAAoC;AAAA;;AAC1C,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;;AAKA,WAASI,QAAT,CAAmBC,YAAnB,EAAkC;AACjCF,IAAAA,aAAa,CAAE;AACdD,MAAAA,KAAK,EAAEL,gBAAgB,CAAE,EACxB,GAAGK,KADqB;AAExBI,QAAAA,UAAU,EAAE,EACX,IAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEI,UAAV,CADW;AAEXC,UAAAA,aAAa,EAAEF;AAFJ;AAFY,OAAF;AADT,KAAF,CAAb;AASA;;AAED,SACC,cAAC,oBAAD;AACC,IAAA,KAAK,EAAGH,KAAH,aAAGA,KAAH,4CAAGA,KAAK,CAAEI,UAAV,sDAAG,kBAAmBC,aAD5B;AAEC,IAAA,QAAQ,EAAGH,QAFZ;AAGC,IAAA,IAAI,EAAC;AAHN,IADD;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,0BAAT,GAAgE;AAAA,MAA3B;AAAEC,IAAAA,IAAI,EAAEC;AAAR,GAA2B,uEAAL,EAAK;AACtE,QAAMC,YAAY,GAAG,CAAEjB,eAAe,CACrCgB,SADqC,EAErCZ,0BAFqC,CAAtC;AAIA,QAAMc,iBAAiB,GAAGhB,UAAU,CAAE,0BAAF,CAApC;AACA,SAAOe,YAAY,IAAI,CAAEC,iBAAzB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,qBAAT,CAAgCb,KAAhC,EAAwC;AAAA;;AAC9C,SAAO,CAAC,2BAAEA,KAAK,CAACC,UAAN,CAAiBC,KAAnB,4EAAE,sBAAwBI,UAA1B,mDAAE,uBAAoCC,aAAtC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASO,kBAAT,OAAkE;AAAA,MAArC;AAAEb,IAAAA,UAAU,GAAG,EAAf;AAAmBE,IAAAA;AAAnB,GAAqC;AACxE,QAAM;AAAED,IAAAA;AAAF,MAAYD,UAAlB;AAEAE,EAAAA,aAAa,CAAE;AACdD,IAAAA,KAAK,EAAEL,gBAAgB,CAAE,EACxB,GAAGK,KADqB;AAExBI,MAAAA,UAAU,EAAE,EACX,IAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEI,UAAV,CADW;AAEXC,QAAAA,aAAa,EAAEQ;AAFJ;AAFY,KAAF;AADT,GAAF,CAAb;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport TextTransformControl from '../components/text-transform-control';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Key within block settings' supports array indicating support for text\n * transforms e.g. settings found in `block.json`.\n */\nexport const TEXT_TRANSFORM_SUPPORT_KEY =\n\t'typography.__experimentalTextTransform';\n\n/**\n * Inspector control panel containing the text transform options.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Text transform edit element.\n */\nexport function TextTransformEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tfunction onChange( newTransform ) {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\ttypography: {\n\t\t\t\t\t...style?.typography,\n\t\t\t\t\ttextTransform: newTransform,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<TextTransformControl\n\t\t\tvalue={ style?.typography?.textTransform }\n\t\t\tonChange={ onChange }\n\t\t\tsize=\"__unstable-large\"\n\t\t/>\n\t);\n}\n\n/**\n * Checks if text-transform settings have been disabled.\n *\n * @param {string} name Name of the block.\n *\n * @return {boolean} Whether or not the setting is disabled.\n */\nexport function useIsTextTransformDisabled( { name: blockName } = {} ) {\n\tconst notSupported = ! hasBlockSupport(\n\t\tblockName,\n\t\tTEXT_TRANSFORM_SUPPORT_KEY\n\t);\n\tconst hasTextTransforms = useSetting( 'typography.textTransform' );\n\treturn notSupported || ! hasTextTransforms;\n}\n\n/**\n * Checks if there is a current value set for the text transform block support.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a text transform set.\n */\nexport function hasTextTransformValue( props ) {\n\treturn !! props.attributes.style?.typography?.textTransform;\n}\n\n/**\n * Resets the text transform block support attribute. This can be used when\n * disabling the text transform support controls for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetTextTransform( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\ttypography: {\n\t\t\t\t...style?.typography,\n\t\t\t\ttextTransform: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n"]}
@@ -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
- }