@wordpress/block-editor 11.3.6 → 11.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (357) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/build/components/block-lock/modal.js +1 -0
  3. package/build/components/block-lock/modal.js.map +1 -1
  4. package/build/components/block-popover/inbetween.js +10 -33
  5. package/build/components/block-popover/inbetween.js.map +1 -1
  6. package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
  7. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  8. package/build/components/block-styles/index.js +2 -1
  9. package/build/components/block-styles/index.js.map +1 -1
  10. package/build/components/block-types-list/index.native.js +2 -0
  11. package/build/components/block-types-list/index.native.js.map +1 -1
  12. package/build/components/child-layout-control/index.js +107 -0
  13. package/build/components/child-layout-control/index.js.map +1 -0
  14. package/build/components/colors-gradients/control.js +6 -3
  15. package/build/components/colors-gradients/control.js.map +1 -1
  16. package/build/components/date-format-picker/index.js +3 -3
  17. package/build/components/date-format-picker/index.js.map +1 -1
  18. package/build/components/font-appearance-control/index.js +0 -3
  19. package/build/components/font-appearance-control/index.js.map +1 -1
  20. package/build/components/global-styles/dimensions-panel.js +594 -0
  21. package/build/components/global-styles/dimensions-panel.js.map +1 -0
  22. package/build/components/global-styles/hooks.js +142 -45
  23. package/build/components/global-styles/hooks.js.map +1 -1
  24. package/build/components/global-styles/index.js +38 -0
  25. package/build/components/global-styles/index.js.map +1 -1
  26. package/build/components/global-styles/typography-panel.js +434 -0
  27. package/build/components/global-styles/typography-panel.js.map +1 -0
  28. package/build/components/global-styles/use-global-styles-output.js +7 -3
  29. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  30. package/build/components/global-styles/utils.js +2 -0
  31. package/build/components/global-styles/utils.js.map +1 -1
  32. package/build/components/iframe/index.js +17 -11
  33. package/build/components/iframe/index.js.map +1 -1
  34. package/build/components/image-editor/aspect-ratio-dropdown.js +2 -1
  35. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  36. package/build/components/image-size-control/index.js +6 -11
  37. package/build/components/image-size-control/index.js.map +1 -1
  38. package/build/components/index.native.js +23 -0
  39. package/build/components/index.native.js.map +1 -1
  40. package/build/components/inserter/block-patterns-tab.js +9 -15
  41. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  42. package/build/components/inserter/block-types-tab.native.js +4 -1
  43. package/build/components/inserter/block-types-tab.native.js.map +1 -1
  44. package/build/components/inserter/reusable-blocks-tab.native.js +4 -1
  45. package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  46. package/build/components/inserter/search-results.native.js +4 -1
  47. package/build/components/inserter/search-results.native.js.map +1 -1
  48. package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
  49. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  50. package/build/components/inspector-controls/fill.js +38 -9
  51. package/build/components/inspector-controls/fill.js.map +1 -1
  52. package/build/components/link-control/index.js +55 -28
  53. package/build/components/link-control/index.js.map +1 -1
  54. package/build/components/link-control/settings-drawer.js +72 -30
  55. package/build/components/link-control/settings-drawer.js.map +1 -1
  56. package/build/components/link-control/settings.js +53 -0
  57. package/build/components/link-control/settings.js.map +1 -0
  58. package/build/components/list-view/block.js +4 -2
  59. package/build/components/list-view/block.js.map +1 -1
  60. package/build/components/list-view/expander.js +2 -1
  61. package/build/components/list-view/expander.js.map +1 -1
  62. package/build/components/list-view/index.js +6 -1
  63. package/build/components/list-view/index.js.map +1 -1
  64. package/build/components/off-canvas-editor/appender.js +5 -10
  65. package/build/components/off-canvas-editor/appender.js.map +1 -1
  66. package/build/components/off-canvas-editor/block-contents.js +3 -2
  67. package/build/components/off-canvas-editor/block-contents.js.map +1 -1
  68. package/build/components/off-canvas-editor/branch.js +1 -0
  69. package/build/components/off-canvas-editor/branch.js.map +1 -1
  70. package/build/components/off-canvas-editor/index.js +7 -3
  71. package/build/components/off-canvas-editor/index.js.map +1 -1
  72. package/build/components/off-canvas-editor/leaf-more-menu.js +24 -4
  73. package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  74. package/build/components/off-canvas-editor/link-ui.js +2 -0
  75. package/build/components/off-canvas-editor/link-ui.js.map +1 -1
  76. package/build/components/responsive-block-control/index.js +1 -0
  77. package/build/components/responsive-block-control/index.js.map +1 -1
  78. package/build/components/rich-text/index.js +9 -45
  79. package/build/components/rich-text/index.js.map +1 -1
  80. package/build/components/rich-text/use-delete.js +73 -0
  81. package/build/components/rich-text/use-delete.js.map +1 -0
  82. package/build/components/rich-text/use-input-rules.js +14 -6
  83. package/build/components/rich-text/use-input-rules.js.map +1 -1
  84. package/build/components/url-input/index.js +2 -2
  85. package/build/components/url-input/index.js.map +1 -1
  86. package/build/components/writing-flow/use-selection-observer.js +4 -1
  87. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  88. package/build/hooks/align.js +3 -1
  89. package/build/hooks/align.js.map +1 -1
  90. package/build/hooks/dimensions.js +78 -190
  91. package/build/hooks/dimensions.js.map +1 -1
  92. package/build/hooks/duotone.js +94 -25
  93. package/build/hooks/duotone.js.map +1 -1
  94. package/build/hooks/font-family.js +2 -76
  95. package/build/hooks/font-family.js.map +1 -1
  96. package/build/hooks/font-size.js +3 -51
  97. package/build/hooks/font-size.js.map +1 -1
  98. package/build/hooks/gap.js +0 -201
  99. package/build/hooks/gap.js.map +1 -1
  100. package/build/hooks/index.js +2 -0
  101. package/build/hooks/index.js.map +1 -1
  102. package/build/hooks/layout.js +14 -5
  103. package/build/hooks/layout.js.map +1 -1
  104. package/build/hooks/line-height.js +0 -42
  105. package/build/hooks/line-height.js.map +1 -1
  106. package/build/hooks/margin.js +7 -163
  107. package/build/hooks/margin.js.map +1 -1
  108. package/build/hooks/padding.js +7 -163
  109. package/build/hooks/padding.js.map +1 -1
  110. package/build/hooks/typography.js +98 -128
  111. package/build/hooks/typography.js.map +1 -1
  112. package/build/hooks/utils.js +75 -0
  113. package/build/hooks/utils.js.map +1 -1
  114. package/build/layouts/flex.js +1 -0
  115. package/build/layouts/flex.js.map +1 -1
  116. package/build/store/actions.js +24 -12
  117. package/build/store/actions.js.map +1 -1
  118. package/build/store/reducer.js +53 -47
  119. package/build/store/reducer.js.map +1 -1
  120. package/build/store/selectors.js +22 -1
  121. package/build/store/selectors.js.map +1 -1
  122. package/build/utils/parse-css-unit-to-px.js +36 -3
  123. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  124. package/build-module/components/block-lock/modal.js +1 -0
  125. package/build-module/components/block-lock/modal.js.map +1 -1
  126. package/build-module/components/block-popover/inbetween.js +10 -33
  127. package/build-module/components/block-popover/inbetween.js.map +1 -1
  128. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
  129. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  130. package/build-module/components/block-styles/index.js +2 -1
  131. package/build-module/components/block-styles/index.js.map +1 -1
  132. package/build-module/components/block-types-list/index.native.js +2 -0
  133. package/build-module/components/block-types-list/index.native.js.map +1 -1
  134. package/build-module/components/child-layout-control/index.js +98 -0
  135. package/build-module/components/child-layout-control/index.js.map +1 -0
  136. package/build-module/components/colors-gradients/control.js +6 -3
  137. package/build-module/components/colors-gradients/control.js.map +1 -1
  138. package/build-module/components/date-format-picker/index.js +4 -4
  139. package/build-module/components/date-format-picker/index.js.map +1 -1
  140. package/build-module/components/font-appearance-control/index.js +2 -1
  141. package/build-module/components/font-appearance-control/index.js.map +1 -1
  142. package/build-module/components/global-styles/dimensions-panel.js +574 -0
  143. package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
  144. package/build-module/components/global-styles/hooks.js +138 -46
  145. package/build-module/components/global-styles/hooks.js.map +1 -1
  146. package/build-module/components/global-styles/index.js +3 -1
  147. package/build-module/components/global-styles/index.js.map +1 -1
  148. package/build-module/components/global-styles/typography-panel.js +415 -0
  149. package/build-module/components/global-styles/typography-panel.js.map +1 -0
  150. package/build-module/components/global-styles/use-global-styles-output.js +7 -3
  151. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  152. package/build-module/components/global-styles/utils.js +2 -0
  153. package/build-module/components/global-styles/utils.js.map +1 -1
  154. package/build-module/components/iframe/index.js +17 -11
  155. package/build-module/components/iframe/index.js.map +1 -1
  156. package/build-module/components/image-editor/aspect-ratio-dropdown.js +2 -1
  157. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  158. package/build-module/components/image-size-control/index.js +7 -12
  159. package/build-module/components/image-size-control/index.js.map +1 -1
  160. package/build-module/components/index.native.js +2 -1
  161. package/build-module/components/index.native.js.map +1 -1
  162. package/build-module/components/inserter/block-patterns-tab.js +9 -15
  163. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  164. package/build-module/components/inserter/block-types-tab.native.js +3 -1
  165. package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
  166. package/build-module/components/inserter/reusable-blocks-tab.native.js +3 -1
  167. package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  168. package/build-module/components/inserter/search-results.native.js +3 -1
  169. package/build-module/components/inserter/search-results.native.js.map +1 -1
  170. package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
  171. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  172. package/build-module/components/inspector-controls/fill.js +39 -9
  173. package/build-module/components/inspector-controls/fill.js.map +1 -1
  174. package/build-module/components/link-control/index.js +56 -28
  175. package/build-module/components/link-control/index.js.map +1 -1
  176. package/build-module/components/link-control/settings-drawer.js +68 -30
  177. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  178. package/build-module/components/link-control/settings.js +44 -0
  179. package/build-module/components/link-control/settings.js.map +1 -0
  180. package/build-module/components/list-view/block.js +4 -2
  181. package/build-module/components/list-view/block.js.map +1 -1
  182. package/build-module/components/list-view/expander.js +2 -1
  183. package/build-module/components/list-view/expander.js.map +1 -1
  184. package/build-module/components/list-view/index.js +6 -1
  185. package/build-module/components/list-view/index.js.map +1 -1
  186. package/build-module/components/off-canvas-editor/appender.js +5 -10
  187. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  188. package/build-module/components/off-canvas-editor/block-contents.js +3 -2
  189. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
  190. package/build-module/components/off-canvas-editor/branch.js +1 -0
  191. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  192. package/build-module/components/off-canvas-editor/index.js +7 -3
  193. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  194. package/build-module/components/off-canvas-editor/leaf-more-menu.js +27 -7
  195. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  196. package/build-module/components/off-canvas-editor/link-ui.js +2 -0
  197. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
  198. package/build-module/components/responsive-block-control/index.js +1 -0
  199. package/build-module/components/responsive-block-control/index.js.map +1 -1
  200. package/build-module/components/rich-text/index.js +9 -45
  201. package/build-module/components/rich-text/index.js.map +1 -1
  202. package/build-module/components/rich-text/use-delete.js +62 -0
  203. package/build-module/components/rich-text/use-delete.js.map +1 -0
  204. package/build-module/components/rich-text/use-input-rules.js +14 -6
  205. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  206. package/build-module/components/url-input/index.js +2 -2
  207. package/build-module/components/url-input/index.js.map +1 -1
  208. package/build-module/components/writing-flow/use-selection-observer.js +4 -1
  209. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  210. package/build-module/hooks/align.js +3 -1
  211. package/build-module/hooks/align.js.map +1 -1
  212. package/build-module/hooks/dimensions.js +81 -187
  213. package/build-module/hooks/dimensions.js.map +1 -1
  214. package/build-module/hooks/duotone.js +86 -24
  215. package/build-module/hooks/duotone.js.map +1 -1
  216. package/build-module/hooks/font-family.js +3 -69
  217. package/build-module/hooks/font-family.js.map +1 -1
  218. package/build-module/hooks/font-size.js +6 -47
  219. package/build-module/hooks/font-size.js.map +1 -1
  220. package/build-module/hooks/gap.js +0 -182
  221. package/build-module/hooks/gap.js.map +1 -1
  222. package/build-module/hooks/index.js +1 -0
  223. package/build-module/hooks/index.js.map +1 -1
  224. package/build-module/hooks/layout.js +14 -5
  225. package/build-module/hooks/layout.js.map +1 -1
  226. package/build-module/hooks/line-height.js +0 -38
  227. package/build-module/hooks/line-height.js.map +1 -1
  228. package/build-module/hooks/margin.js +4 -143
  229. package/build-module/hooks/margin.js.map +1 -1
  230. package/build-module/hooks/padding.js +4 -143
  231. package/build-module/hooks/padding.js.map +1 -1
  232. package/build-module/hooks/typography.js +97 -123
  233. package/build-module/hooks/typography.js.map +1 -1
  234. package/build-module/hooks/utils.js +70 -0
  235. package/build-module/hooks/utils.js.map +1 -1
  236. package/build-module/layouts/flex.js +1 -0
  237. package/build-module/layouts/flex.js.map +1 -1
  238. package/build-module/store/actions.js +24 -12
  239. package/build-module/store/actions.js.map +1 -1
  240. package/build-module/store/reducer.js +53 -45
  241. package/build-module/store/reducer.js.map +1 -1
  242. package/build-module/store/selectors.js +22 -1
  243. package/build-module/store/selectors.js.map +1 -1
  244. package/build-module/utils/parse-css-unit-to-px.js +36 -3
  245. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  246. package/build-style/style-rtl.css +54 -64
  247. package/build-style/style.css +54 -64
  248. package/package.json +31 -31
  249. package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
  250. package/src/components/block-lock/modal.js +1 -0
  251. package/src/components/block-lock/style.scss +0 -9
  252. package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
  253. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +15 -15
  254. package/src/components/block-popover/inbetween.js +21 -53
  255. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
  256. package/src/components/block-styles/index.js +5 -1
  257. package/src/components/block-types-list/index.native.js +2 -0
  258. package/src/components/child-layout-control/index.js +106 -0
  259. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  260. package/src/components/colors-gradients/control.js +3 -0
  261. package/src/components/date-format-picker/index.js +6 -8
  262. package/src/components/date-format-picker/style.scss +0 -5
  263. package/src/components/font-appearance-control/index.js +1 -1
  264. package/src/components/global-styles/dimensions-panel.js +627 -0
  265. package/src/components/global-styles/hooks.js +229 -66
  266. package/src/components/global-styles/index.js +9 -0
  267. package/src/components/global-styles/typography-panel.js +428 -0
  268. package/src/components/global-styles/use-global-styles-output.js +10 -5
  269. package/src/components/global-styles/utils.js +2 -0
  270. package/src/components/iframe/index.js +20 -18
  271. package/src/components/image-editor/aspect-ratio-dropdown.js +1 -0
  272. package/src/components/image-size-control/index.js +10 -12
  273. package/src/components/image-size-control/style.scss +3 -21
  274. package/src/components/index.native.js +5 -0
  275. package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
  276. package/src/components/inserter/block-patterns-tab.js +9 -23
  277. package/src/components/inserter/block-types-tab.native.js +2 -0
  278. package/src/components/inserter/reusable-blocks-tab.native.js +2 -0
  279. package/src/components/inserter/search-results.native.js +2 -0
  280. package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
  281. package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
  282. package/src/components/inspector-controls/fill.js +32 -8
  283. package/src/components/link-control/index.js +69 -34
  284. package/src/components/link-control/settings-drawer.js +85 -29
  285. package/src/components/link-control/settings.js +42 -0
  286. package/src/components/link-control/style.scss +63 -37
  287. package/src/components/link-control/test/index.js +347 -9
  288. package/src/components/list-view/block.js +7 -1
  289. package/src/components/list-view/expander.js +1 -0
  290. package/src/components/list-view/index.js +5 -0
  291. package/src/components/media-replace-flow/style.scss +7 -9
  292. package/src/components/media-replace-flow/test/index.js +1 -1
  293. package/src/components/off-canvas-editor/appender.js +13 -16
  294. package/src/components/off-canvas-editor/block-contents.js +2 -1
  295. package/src/components/off-canvas-editor/branch.js +1 -0
  296. package/src/components/off-canvas-editor/index.js +8 -2
  297. package/src/components/off-canvas-editor/leaf-more-menu.js +52 -15
  298. package/src/components/off-canvas-editor/link-ui.js +2 -0
  299. package/src/components/responsive-block-control/index.js +1 -0
  300. package/src/components/rich-text/index.js +8 -46
  301. package/src/components/rich-text/use-delete.js +59 -0
  302. package/src/components/rich-text/use-input-rules.js +13 -5
  303. package/src/components/url-input/index.js +3 -2
  304. package/src/components/url-popover/stories/index.js +1 -0
  305. package/src/components/writing-flow/use-selection-observer.js +5 -1
  306. package/src/hooks/align.js +1 -1
  307. package/src/hooks/dimensions.js +97 -269
  308. package/src/hooks/duotone.js +100 -30
  309. package/src/hooks/font-family.js +0 -58
  310. package/src/hooks/font-size.js +1 -36
  311. package/src/hooks/gap.js +0 -201
  312. package/src/hooks/index.js +1 -0
  313. package/src/hooks/layout.js +19 -6
  314. package/src/hooks/line-height.js +0 -33
  315. package/src/hooks/margin.js +1 -164
  316. package/src/hooks/padding.js +1 -163
  317. package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
  318. package/src/hooks/test/duotone.js +102 -0
  319. package/src/hooks/typography.js +112 -213
  320. package/src/hooks/utils.js +90 -0
  321. package/src/layouts/flex.js +1 -0
  322. package/src/store/actions.js +12 -4
  323. package/src/store/reducer.js +68 -43
  324. package/src/store/selectors.js +20 -1
  325. package/src/store/test/actions.js +4 -2
  326. package/src/utils/parse-css-unit-to-px.js +35 -5
  327. package/src/utils/test/parse-css-unit-to-px.js +12 -0
  328. package/build/hooks/child-layout.js +0 -213
  329. package/build/hooks/child-layout.js.map +0 -1
  330. package/build/hooks/font-appearance.js +0 -188
  331. package/build/hooks/font-appearance.js.map +0 -1
  332. package/build/hooks/letter-spacing.js +0 -129
  333. package/build/hooks/letter-spacing.js.map +0 -1
  334. package/build/hooks/min-height.js +0 -139
  335. package/build/hooks/min-height.js.map +0 -1
  336. package/build/hooks/text-decoration.js +0 -130
  337. package/build/hooks/text-decoration.js.map +0 -1
  338. package/build/hooks/text-transform.js +0 -130
  339. package/build/hooks/text-transform.js.map +0 -1
  340. package/build-module/hooks/child-layout.js +0 -193
  341. package/build-module/hooks/child-layout.js.map +0 -1
  342. package/build-module/hooks/font-appearance.js +0 -161
  343. package/build-module/hooks/font-appearance.js.map +0 -1
  344. package/build-module/hooks/letter-spacing.js +0 -107
  345. package/build-module/hooks/letter-spacing.js.map +0 -1
  346. package/build-module/hooks/min-height.js +0 -116
  347. package/build-module/hooks/min-height.js.map +0 -1
  348. package/build-module/hooks/text-decoration.js +0 -108
  349. package/build-module/hooks/text-decoration.js.map +0 -1
  350. package/build-module/hooks/text-transform.js +0 -108
  351. package/build-module/hooks/text-transform.js.map +0 -1
  352. package/src/hooks/child-layout.js +0 -195
  353. package/src/hooks/font-appearance.js +0 -146
  354. package/src/hooks/letter-spacing.js +0 -101
  355. package/src/hooks/min-height.js +0 -104
  356. package/src/hooks/text-decoration.js +0 -102
  357. 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,104 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { getBlockSupport } from '@wordpress/blocks';
5
- import { __ } from '@wordpress/i18n';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
- import useSetting from '../components/use-setting';
11
- import HeightControl from '../components/height-control';
12
- import { DIMENSIONS_SUPPORT_KEY } from './dimensions';
13
- import { cleanEmptyObject } from './utils';
14
-
15
- /**
16
- * Determines if there is minHeight support.
17
- *
18
- * @param {string|Object} blockType Block name or Block Type object.
19
- * @return {boolean} Whether there is support.
20
- */
21
- export function hasMinHeightSupport( blockType ) {
22
- const support = getBlockSupport( blockType, DIMENSIONS_SUPPORT_KEY );
23
- return !! ( true === support || support?.minHeight );
24
- }
25
-
26
- /**
27
- * Checks if there is a current value in the minHeight block support attributes.
28
- *
29
- * @param {Object} props Block props.
30
- * @return {boolean} Whether or not the block has a minHeight value set.
31
- */
32
- export function hasMinHeightValue( props ) {
33
- return props.attributes.style?.dimensions?.minHeight !== undefined;
34
- }
35
-
36
- /**
37
- * Resets the minHeight block support attributes. This can be used when disabling
38
- * the padding support controls for a block via a `ToolsPanel`.
39
- *
40
- * @param {Object} props Block props.
41
- * @param {Object} props.attributes Block's attributes.
42
- * @param {Object} props.setAttributes Function to set block's attributes.
43
- */
44
- export function resetMinHeight( { attributes = {}, setAttributes } ) {
45
- const { style } = attributes;
46
-
47
- setAttributes( {
48
- style: cleanEmptyObject( {
49
- ...style,
50
- dimensions: {
51
- ...style?.dimensions,
52
- minHeight: undefined,
53
- },
54
- } ),
55
- } );
56
- }
57
-
58
- /**
59
- * Custom hook that checks if minHeight controls have been disabled.
60
- *
61
- * @param {string} name The name of the block.
62
- * @return {boolean} Whether minHeight control is disabled.
63
- */
64
- export function useIsMinHeightDisabled( { name: blockName } = {} ) {
65
- const isDisabled = ! useSetting( 'dimensions.minHeight' );
66
- return ! hasMinHeightSupport( blockName ) || isDisabled;
67
- }
68
-
69
- /**
70
- * Inspector control panel containing the minHeight related configuration.
71
- *
72
- * @param {Object} props Block props.
73
- * @return {WPElement} Edit component for height.
74
- */
75
- export function MinHeightEdit( props ) {
76
- const {
77
- attributes: { style },
78
- setAttributes,
79
- } = props;
80
-
81
- if ( useIsMinHeightDisabled( props ) ) {
82
- return null;
83
- }
84
-
85
- const onChange = ( next ) => {
86
- const newStyle = {
87
- ...style,
88
- dimensions: {
89
- ...style?.dimensions,
90
- minHeight: next,
91
- },
92
- };
93
-
94
- setAttributes( { style: cleanEmptyObject( newStyle ) } );
95
- };
96
-
97
- return (
98
- <HeightControl
99
- label={ __( 'Min. height' ) }
100
- value={ style?.dimensions?.minHeight }
101
- onChange={ onChange }
102
- />
103
- );
104
- }
@@ -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
- }