@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,73 +1,73 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`Align options for group block sets Full width option 1`] = `
4
- "<!-- wp:group {\\"align\\":\\"full\\",\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
5
- <div class=\\"wp-block-group alignfull\\"></div>
4
+ "<!-- wp:group {"align":"full","layout":{"type":"constrained"}} -->
5
+ <div class="wp-block-group alignfull"></div>
6
6
  <!-- /wp:group -->"
7
7
  `;
8
8
 
9
9
  exports[`Align options for group block sets None option 1`] = `
10
- "<!-- wp:group {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
11
- <div class=\\"wp-block-group\\"></div>
10
+ "<!-- wp:group {"layout":{"type":"constrained"}} -->
11
+ <div class="wp-block-group"></div>
12
12
  <!-- /wp:group -->"
13
13
  `;
14
14
 
15
15
  exports[`Align options for group block sets Wide width option 1`] = `
16
- "<!-- wp:group {\\"align\\":\\"wide\\",\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
17
- <div class=\\"wp-block-group alignwide\\"></div>
16
+ "<!-- wp:group {"align":"wide","layout":{"type":"constrained"}} -->
17
+ <div class="wp-block-group alignwide"></div>
18
18
  <!-- /wp:group -->"
19
19
  `;
20
20
 
21
21
  exports[`Align options for media block sets Align center option 1`] = `
22
- "<!-- wp:image {\\"align\\":\\"center\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
23
- <figure class=\\"wp-block-image aligncenter size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
22
+ "<!-- wp:image {"align":"center","id":1,"sizeSlug":"large","linkDestination":"none"} -->
23
+ <figure class="wp-block-image aligncenter size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
24
24
  <!-- /wp:image -->"
25
25
  `;
26
26
 
27
27
  exports[`Align options for media block sets Align left option 1`] = `
28
- "<!-- wp:image {\\"align\\":\\"left\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
29
- <figure class=\\"wp-block-image alignleft size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
28
+ "<!-- wp:image {"align":"left","id":1,"sizeSlug":"large","linkDestination":"none"} -->
29
+ <figure class="wp-block-image alignleft size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
30
30
  <!-- /wp:image -->"
31
31
  `;
32
32
 
33
33
  exports[`Align options for media block sets Align right option 1`] = `
34
- "<!-- wp:image {\\"align\\":\\"right\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
35
- <figure class=\\"wp-block-image alignright size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
34
+ "<!-- wp:image {"align":"right","id":1,"sizeSlug":"large","linkDestination":"none"} -->
35
+ <figure class="wp-block-image alignright size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
36
36
  <!-- /wp:image -->"
37
37
  `;
38
38
 
39
39
  exports[`Align options for media block sets Full width option 1`] = `
40
- "<!-- wp:image {\\"align\\":\\"full\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
41
- <figure class=\\"wp-block-image alignfull size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
40
+ "<!-- wp:image {"align":"full","id":1,"sizeSlug":"large","linkDestination":"none"} -->
41
+ <figure class="wp-block-image alignfull size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
42
42
  <!-- /wp:image -->"
43
43
  `;
44
44
 
45
45
  exports[`Align options for media block sets None option 1`] = `
46
- "<!-- wp:image {\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
47
- <figure class=\\"wp-block-image size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
46
+ "<!-- wp:image {"id":1,"sizeSlug":"large","linkDestination":"none"} -->
47
+ <figure class="wp-block-image size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
48
48
  <!-- /wp:image -->"
49
49
  `;
50
50
 
51
51
  exports[`Align options for media block sets Wide width option 1`] = `
52
- "<!-- wp:image {\\"align\\":\\"wide\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
53
- <figure class=\\"wp-block-image alignwide size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
52
+ "<!-- wp:image {"align":"wide","id":1,"sizeSlug":"large","linkDestination":"none"} -->
53
+ <figure class="wp-block-image alignwide size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
54
54
  <!-- /wp:image -->"
55
55
  `;
56
56
 
57
57
  exports[`Align options for text block sets Align text center option 1`] = `
58
- "<!-- wp:paragraph {\\"align\\":\\"center\\"} -->
59
- <p class=\\"has-text-align-center\\"></p>
58
+ "<!-- wp:paragraph {"align":"center"} -->
59
+ <p class="has-text-align-center"></p>
60
60
  <!-- /wp:paragraph -->"
61
61
  `;
62
62
 
63
63
  exports[`Align options for text block sets Align text left option 1`] = `
64
- "<!-- wp:paragraph {\\"align\\":\\"left\\"} -->
65
- <p class=\\"has-text-align-left\\"></p>
64
+ "<!-- wp:paragraph {"align":"left"} -->
65
+ <p class="has-text-align-left"></p>
66
66
  <!-- /wp:paragraph -->"
67
67
  `;
68
68
 
69
69
  exports[`Align options for text block sets Align text right option 1`] = `
70
- "<!-- wp:paragraph {\\"align\\":\\"right\\"} -->
71
- <p class=\\"has-text-align-right\\"></p>
70
+ "<!-- wp:paragraph {"align":"right"} -->
71
+ <p class="has-text-align-right"></p>
72
72
  <!-- /wp:paragraph -->"
73
73
  `;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import {
5
+ getColorsFromDuotonePreset,
6
+ getDuotonePresetFromColors,
7
+ } from '../duotone';
8
+
9
+ describe( 'Duotone utilities', () => {
10
+ const duotonePalette = [
11
+ {
12
+ name: 'Dark grayscale',
13
+ colors: [ '#000000', '#7f7f7f' ],
14
+ slug: 'dark-grayscale',
15
+ },
16
+ {
17
+ name: 'Grayscale',
18
+ colors: [ '#000000', '#ffffff' ],
19
+ slug: 'grayscale',
20
+ },
21
+ {
22
+ name: 'Purple and yellow',
23
+ colors: [ '#8c00b7', '#fcff41' ],
24
+ slug: 'purple-yellow',
25
+ },
26
+ ];
27
+ describe( 'getColorsFromDuotonePreset', () => {
28
+ it( 'should return undefined if no arguments are provided', () => {
29
+ expect( getColorsFromDuotonePreset() ).toBeUndefined();
30
+ } );
31
+
32
+ it( 'should return undefined if no duotone preset is provided', () => {
33
+ expect(
34
+ getColorsFromDuotonePreset( undefined, duotonePalette )
35
+ ).toBeUndefined();
36
+ } );
37
+
38
+ it( 'should return undefined if a non-existent preset is provided', () => {
39
+ expect(
40
+ getColorsFromDuotonePreset(
41
+ `var:preset|duotone|does-not-exist`,
42
+ duotonePalette
43
+ )
44
+ ).toBeUndefined();
45
+ } );
46
+
47
+ it( 'should return the colors from the preset if found', () => {
48
+ expect(
49
+ getColorsFromDuotonePreset(
50
+ `var:preset|duotone|${ duotonePalette[ 2 ].slug }`,
51
+ duotonePalette
52
+ )
53
+ ).toEqual( duotonePalette[ 2 ].colors );
54
+ } );
55
+ } );
56
+
57
+ describe( 'getDuotonePresetFromColors', () => {
58
+ it( 'should return undefined if no arguments are provided', () => {
59
+ expect( getDuotonePresetFromColors() ).toBeUndefined();
60
+ } );
61
+
62
+ it( 'should return undefined if no colors are provided', () => {
63
+ expect(
64
+ getDuotonePresetFromColors( undefined, duotonePalette )
65
+ ).toBeUndefined();
66
+ } );
67
+
68
+ it( 'should return undefined if provided colors is not of valid type', () => {
69
+ const notAnArrayOfColorStrings = 'purple-yellow';
70
+ expect(
71
+ getDuotonePresetFromColors(
72
+ notAnArrayOfColorStrings,
73
+ duotonePalette
74
+ )
75
+ ).toBeUndefined();
76
+ } );
77
+
78
+ it( 'should return undefined if no duotone palette is provided', () => {
79
+ expect(
80
+ getDuotonePresetFromColors( [ '#8c00b7', '#fcff41' ] )
81
+ ).toBeUndefined();
82
+ } );
83
+
84
+ it( 'should return undefined if the provided colors do not match any preset', () => {
85
+ expect(
86
+ getDuotonePresetFromColors(
87
+ [ '#000000', '#000000' ],
88
+ duotonePalette
89
+ )
90
+ ).toBeUndefined();
91
+ } );
92
+
93
+ it( 'should return the slug of the preset if found', () => {
94
+ expect(
95
+ getDuotonePresetFromColors(
96
+ duotonePalette[ 2 ].colors,
97
+ duotonePalette
98
+ )
99
+ ).toEqual( `var:preset|duotone|${ duotonePalette[ 2 ].slug }` );
100
+ } );
101
+ } );
102
+ } );
@@ -2,68 +2,33 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
5
- import { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
6
- import { __ } from '@wordpress/i18n';
5
+ import { useMemo, useCallback } from '@wordpress/element';
7
6
 
8
7
  /**
9
8
  * Internal dependencies
10
9
  */
11
10
  import InspectorControls from '../components/inspector-controls';
12
- import { getFontAppearanceLabel } from '../components/font-appearance-control';
13
-
14
- import {
15
- LINE_HEIGHT_SUPPORT_KEY,
16
- LineHeightEdit,
17
- hasLineHeightValue,
18
- resetLineHeight,
19
- useIsLineHeightDisabled,
20
- } from './line-height';
21
- import {
22
- FONT_STYLE_SUPPORT_KEY,
23
- FONT_WEIGHT_SUPPORT_KEY,
24
- FontAppearanceEdit,
25
- hasFontAppearanceValue,
26
- resetFontAppearance,
27
- useIsFontAppearanceDisabled,
28
- useIsFontStyleDisabled,
29
- useIsFontWeightDisabled,
30
- } from './font-appearance';
31
- import {
32
- FONT_FAMILY_SUPPORT_KEY,
33
- FontFamilyEdit,
34
- hasFontFamilyValue,
35
- resetFontFamily,
36
- useIsFontFamilyDisabled,
37
- } from './font-family';
38
- import {
39
- FONT_SIZE_SUPPORT_KEY,
40
- FontSizeEdit,
41
- hasFontSizeValue,
42
- resetFontSize,
43
- useIsFontSizeDisabled,
44
- } from './font-size';
45
11
  import {
46
- TEXT_DECORATION_SUPPORT_KEY,
47
- TextDecorationEdit,
48
- hasTextDecorationValue,
49
- resetTextDecoration,
50
- useIsTextDecorationDisabled,
51
- } from './text-decoration';
52
- import {
53
- TEXT_TRANSFORM_SUPPORT_KEY,
54
- TextTransformEdit,
55
- hasTextTransformValue,
56
- resetTextTransform,
57
- useIsTextTransformDisabled,
58
- } from './text-transform';
59
- import {
60
- LETTER_SPACING_SUPPORT_KEY,
61
- LetterSpacingEdit,
62
- hasLetterSpacingValue,
63
- resetLetterSpacing,
64
- useIsLetterSpacingDisabled,
65
- } from './letter-spacing';
12
+ default as StylesTypographyPanel,
13
+ useHasTypographyPanel,
14
+ } from '../components/global-styles/typography-panel';
15
+
16
+ import { LINE_HEIGHT_SUPPORT_KEY } from './line-height';
17
+ import { FONT_FAMILY_SUPPORT_KEY } from './font-family';
18
+ import { FONT_SIZE_SUPPORT_KEY } from './font-size';
19
+ import { cleanEmptyObject, useBlockSettings } from './utils';
20
+
21
+ function omit( object, keys ) {
22
+ return Object.fromEntries(
23
+ Object.entries( object ).filter( ( [ key ] ) => ! keys.includes( key ) )
24
+ );
25
+ }
66
26
 
27
+ const LETTER_SPACING_SUPPORT_KEY = 'typography.__experimentalLetterSpacing';
28
+ const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.__experimentalTextTransform';
29
+ const TEXT_DECORATION_SUPPORT_KEY = 'typography.__experimentalTextDecoration';
30
+ const FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle';
31
+ const FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight';
67
32
  export const TYPOGRAPHY_SUPPORT_KEY = 'typography';
68
33
  export const TYPOGRAPHY_SUPPORT_KEYS = [
69
34
  LINE_HEIGHT_SUPPORT_KEY,
@@ -76,159 +41,107 @@ export const TYPOGRAPHY_SUPPORT_KEYS = [
76
41
  LETTER_SPACING_SUPPORT_KEY,
77
42
  ];
78
43
 
79
- export function TypographyPanel( props ) {
80
- const { clientId } = props;
81
- const isFontFamilyDisabled = useIsFontFamilyDisabled( props );
82
- const isFontSizeDisabled = useIsFontSizeDisabled( props );
83
- const isFontAppearanceDisabled = useIsFontAppearanceDisabled( props );
84
- const isLineHeightDisabled = useIsLineHeightDisabled( props );
85
- const isTextDecorationDisabled = useIsTextDecorationDisabled( props );
86
- const isTextTransformDisabled = useIsTextTransformDisabled( props );
87
- const isLetterSpacingDisabled = useIsLetterSpacingDisabled( props );
44
+ function styleToAttributes( style ) {
45
+ const updatedStyle = { ...omit( style, [ 'fontFamily' ] ) };
46
+ const fontSizeValue = style?.typography?.fontSize;
47
+ const fontFamilyValue = style?.typography?.fontFamily;
48
+ const fontSizeSlug = fontSizeValue?.startsWith( 'var:preset|font-size|' )
49
+ ? fontSizeValue.substring( 'var:preset|font-size|'.length )
50
+ : undefined;
51
+ const fontFamilySlug = fontFamilyValue?.startsWith(
52
+ 'var:preset|font-family|'
53
+ )
54
+ ? fontFamilyValue.substring( 'var:preset|font-family|'.length )
55
+ : undefined;
56
+ updatedStyle.typography = {
57
+ ...omit( updatedStyle.typography, [ 'fontFamily' ] ),
58
+ fontSize: fontSizeSlug ? undefined : fontSizeValue,
59
+ };
60
+ return {
61
+ style: cleanEmptyObject( updatedStyle ),
62
+ fontFamily: fontFamilySlug,
63
+ fontSize: fontSizeSlug,
64
+ };
65
+ }
66
+
67
+ function attributesToStyle( attributes ) {
68
+ return {
69
+ ...attributes.style,
70
+ typography: {
71
+ ...attributes.style?.typography,
72
+ fontFamily: attributes.fontFamily
73
+ ? 'var:preset|font-family|' + attributes.fontFamily
74
+ : undefined,
75
+ fontSize: attributes.fontSize
76
+ ? 'var:preset|font-size|' + attributes.fontSize
77
+ : attributes.style?.typography?.fontSize,
78
+ },
79
+ };
80
+ }
81
+
82
+ function TypographyInspectorControl( { children, resetAllFilter } ) {
83
+ const attributesResetAllFilter = useCallback(
84
+ ( attributes ) => {
85
+ const existingStyle = attributesToStyle( attributes );
86
+ const updatedStyle = resetAllFilter( existingStyle );
87
+ return {
88
+ ...attributes,
89
+ ...styleToAttributes( updatedStyle ),
90
+ };
91
+ },
92
+ [ resetAllFilter ]
93
+ );
94
+
95
+ return (
96
+ <InspectorControls
97
+ group="typography"
98
+ resetAllFilter={ attributesResetAllFilter }
99
+ >
100
+ { children }
101
+ </InspectorControls>
102
+ );
103
+ }
88
104
 
89
- const hasFontStyles = ! useIsFontStyleDisabled( props );
90
- const hasFontWeights = ! useIsFontWeightDisabled( props );
105
+ export function TypographyPanel( {
106
+ clientId,
107
+ name,
108
+ attributes,
109
+ setAttributes,
110
+ __unstableParentLayout,
111
+ } ) {
112
+ const settings = useBlockSettings( name, __unstableParentLayout );
113
+ const isEnabled = useHasTypographyPanel( settings );
114
+ const value = useMemo( () => {
115
+ return attributesToStyle( {
116
+ style: attributes.style,
117
+ fontFamily: attributes.fontFamily,
118
+ fontSize: attributes.fontSize,
119
+ } );
120
+ }, [ attributes.style, attributes.fontSize, attributes.fontFamily ] );
91
121
 
92
- const isDisabled = useIsTypographyDisabled( props );
93
- const isSupported = hasTypographySupport( props.name );
122
+ const onChange = ( newStyle ) => {
123
+ setAttributes( styleToAttributes( newStyle ) );
124
+ };
94
125
 
95
- if ( isDisabled || ! isSupported ) return null;
126
+ if ( ! isEnabled ) {
127
+ return null;
128
+ }
96
129
 
97
- const defaultControls = getBlockSupport( props.name, [
130
+ const defaultControls = getBlockSupport( name, [
98
131
  TYPOGRAPHY_SUPPORT_KEY,
99
132
  '__experimentalDefaultControls',
100
133
  ] );
101
134
 
102
- const createResetAllFilter = ( attribute ) => ( newAttributes ) => ( {
103
- ...newAttributes,
104
- style: {
105
- ...newAttributes.style,
106
- typography: {
107
- ...newAttributes.style?.typography,
108
- [ attribute ]: undefined,
109
- },
110
- },
111
- } );
112
-
113
135
  return (
114
- <InspectorControls group="typography">
115
- { ! isFontFamilyDisabled && (
116
- <ToolsPanelItem
117
- hasValue={ () => hasFontFamilyValue( props ) }
118
- label={ __( 'Font family' ) }
119
- onDeselect={ () => resetFontFamily( props ) }
120
- isShownByDefault={ defaultControls?.fontFamily }
121
- resetAllFilter={ ( newAttributes ) => ( {
122
- ...newAttributes,
123
- fontFamily: undefined,
124
- } ) }
125
- panelId={ clientId }
126
- >
127
- <FontFamilyEdit { ...props } />
128
- </ToolsPanelItem>
129
- ) }
130
- { ! isFontSizeDisabled && (
131
- <ToolsPanelItem
132
- hasValue={ () => hasFontSizeValue( props ) }
133
- /* translators: Ensure translation is distinct from "Letter case" */
134
- label={ __( 'Font size' ) }
135
- onDeselect={ () => resetFontSize( props ) }
136
- isShownByDefault={ defaultControls?.fontSize }
137
- resetAllFilter={ ( newAttributes ) => ( {
138
- ...newAttributes,
139
- fontSize: undefined,
140
- style: {
141
- ...newAttributes.style,
142
- typography: {
143
- ...newAttributes.style?.typography,
144
- fontSize: undefined,
145
- },
146
- },
147
- } ) }
148
- panelId={ clientId }
149
- >
150
- <FontSizeEdit { ...props } />
151
- </ToolsPanelItem>
152
- ) }
153
- { ! isFontAppearanceDisabled && (
154
- <ToolsPanelItem
155
- className="single-column"
156
- hasValue={ () => hasFontAppearanceValue( props ) }
157
- label={ getFontAppearanceLabel(
158
- hasFontStyles,
159
- hasFontWeights
160
- ) }
161
- onDeselect={ () => resetFontAppearance( props ) }
162
- isShownByDefault={ defaultControls?.fontAppearance }
163
- resetAllFilter={ ( newAttributes ) => ( {
164
- ...newAttributes,
165
- style: {
166
- ...newAttributes.style,
167
- typography: {
168
- ...newAttributes.style?.typography,
169
- fontStyle: undefined,
170
- fontWeight: undefined,
171
- },
172
- },
173
- } ) }
174
- panelId={ clientId }
175
- >
176
- <FontAppearanceEdit { ...props } />
177
- </ToolsPanelItem>
178
- ) }
179
- { ! isLineHeightDisabled && (
180
- <ToolsPanelItem
181
- className="single-column"
182
- hasValue={ () => hasLineHeightValue( props ) }
183
- label={ __( 'Line height' ) }
184
- onDeselect={ () => resetLineHeight( props ) }
185
- isShownByDefault={ defaultControls?.lineHeight }
186
- resetAllFilter={ createResetAllFilter( 'lineHeight' ) }
187
- panelId={ clientId }
188
- >
189
- <LineHeightEdit { ...props } />
190
- </ToolsPanelItem>
191
- ) }
192
- { ! isLetterSpacingDisabled && (
193
- <ToolsPanelItem
194
- className="single-column"
195
- hasValue={ () => hasLetterSpacingValue( props ) }
196
- label={ __( 'Letter spacing' ) }
197
- onDeselect={ () => resetLetterSpacing( props ) }
198
- isShownByDefault={ defaultControls?.letterSpacing }
199
- resetAllFilter={ createResetAllFilter( 'letterSpacing' ) }
200
- panelId={ clientId }
201
- >
202
- <LetterSpacingEdit { ...props } />
203
- </ToolsPanelItem>
204
- ) }
205
- { ! isTextDecorationDisabled && (
206
- <ToolsPanelItem
207
- className="single-column"
208
- hasValue={ () => hasTextDecorationValue( props ) }
209
- label={ __( 'Decoration' ) }
210
- onDeselect={ () => resetTextDecoration( props ) }
211
- isShownByDefault={ defaultControls?.textDecoration }
212
- resetAllFilter={ createResetAllFilter( 'textDecoration' ) }
213
- panelId={ clientId }
214
- >
215
- <TextDecorationEdit { ...props } />
216
- </ToolsPanelItem>
217
- ) }
218
- { ! isTextTransformDisabled && (
219
- <ToolsPanelItem
220
- hasValue={ () => hasTextTransformValue( props ) }
221
- /* translators: Ensure translation is distinct from "Font size" */
222
- label={ __( 'Letter case' ) }
223
- onDeselect={ () => resetTextTransform( props ) }
224
- isShownByDefault={ defaultControls?.textTransform }
225
- resetAllFilter={ createResetAllFilter( 'textTransform' ) }
226
- panelId={ clientId }
227
- >
228
- <TextTransformEdit { ...props } />
229
- </ToolsPanelItem>
230
- ) }
231
- </InspectorControls>
136
+ <StylesTypographyPanel
137
+ as={ TypographyInspectorControl }
138
+ panelId={ clientId }
139
+ name={ name }
140
+ settings={ settings }
141
+ value={ value }
142
+ onChange={ onChange }
143
+ defaultControls={ defaultControls }
144
+ />
232
145
  );
233
146
  }
234
147
 
@@ -237,17 +150,3 @@ export const hasTypographySupport = ( blockName ) => {
237
150
  hasBlockSupport( blockName, key )
238
151
  );
239
152
  };
240
-
241
- function useIsTypographyDisabled( props = {} ) {
242
- const configs = [
243
- useIsFontAppearanceDisabled( props ),
244
- useIsFontSizeDisabled( props ),
245
- useIsLineHeightDisabled( props ),
246
- useIsFontFamilyDisabled( props ),
247
- useIsTextDecorationDisabled( props ),
248
- useIsTextTransformDisabled( props ),
249
- useIsLetterSpacingDisabled( props ),
250
- ];
251
-
252
- return configs.filter( Boolean ).length === configs.length;
253
- }
@@ -7,6 +7,13 @@ import { isEmpty, mapValues, get } from 'lodash';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { getBlockSupport } from '@wordpress/blocks';
10
+ import { useMemo } from '@wordpress/element';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import { useSetting } from '../components';
16
+ import { useSettingsForBlockElement } from '../components/global-styles/hooks';
10
17
 
11
18
  /**
12
19
  * Removed falsy values from nested object.
@@ -177,3 +184,86 @@ export function shouldSkipSerialization( blockType, featureSet, feature ) {
177
184
 
178
185
  return skipSerialization;
179
186
  }
187
+
188
+ /**
189
+ * Based on the block and its context, returns an object of all the block settings.
190
+ * This object can be passed as a prop to all the Styles UI components
191
+ * (TypographyPanel, DimensionsPanel...).
192
+ *
193
+ * @param {string} name Block name.
194
+ * @param {*} parentLayout Parent layout.
195
+ *
196
+ * @return {Object} Settings object.
197
+ */
198
+ export function useBlockSettings( name, parentLayout ) {
199
+ const fontFamilies = useSetting( 'typography.fontFamilies' );
200
+ const fontSizes = useSetting( 'typography.fontSizes' );
201
+ const customFontSize = useSetting( 'typography.customFontSize' );
202
+ const fontStyle = useSetting( 'typography.fontStyle' );
203
+ const fontWeight = useSetting( 'typography.fontWeight' );
204
+ const lineHeight = useSetting( 'typography.lineHeight' );
205
+ const textDecoration = useSetting( 'typography.textDecoration' );
206
+ const textTransform = useSetting( 'typography.textTransform' );
207
+ const letterSpacing = useSetting( 'typography.letterSpacing' );
208
+ const padding = useSetting( 'spacing.padding' );
209
+ const margin = useSetting( 'spacing.margin' );
210
+ const blockGap = useSetting( 'spacing.blockGap' );
211
+ const spacingSizes = useSetting( 'spacing.spacingSizes' );
212
+ const units = useSetting( 'spacing.units' );
213
+ const minHeight = useSetting( 'dimensions.minHeight' );
214
+ const layout = useSetting( 'layout' );
215
+
216
+ const rawSettings = useMemo( () => {
217
+ return {
218
+ typography: {
219
+ fontFamilies: {
220
+ custom: fontFamilies,
221
+ },
222
+ fontSizes: {
223
+ custom: fontSizes,
224
+ },
225
+ customFontSize,
226
+ fontStyle,
227
+ fontWeight,
228
+ lineHeight,
229
+ textDecoration,
230
+ textTransform,
231
+ letterSpacing,
232
+ },
233
+ spacing: {
234
+ spacingSizes: {
235
+ custom: spacingSizes,
236
+ },
237
+ padding,
238
+ margin,
239
+ blockGap,
240
+ units,
241
+ },
242
+ dimensions: {
243
+ minHeight,
244
+ },
245
+ layout,
246
+ parentLayout,
247
+ };
248
+ }, [
249
+ fontFamilies,
250
+ fontSizes,
251
+ customFontSize,
252
+ fontStyle,
253
+ fontWeight,
254
+ lineHeight,
255
+ textDecoration,
256
+ textTransform,
257
+ letterSpacing,
258
+ padding,
259
+ margin,
260
+ blockGap,
261
+ spacingSizes,
262
+ units,
263
+ minHeight,
264
+ layout,
265
+ parentLayout,
266
+ ] );
267
+
268
+ return useSettingsForBlockElement( rawSettings, name );
269
+ }
@@ -347,6 +347,7 @@ function FlexWrapControl( { layout, onChange } ) {
347
347
  const { flexWrap = 'wrap' } = layout;
348
348
  return (
349
349
  <ToggleControl
350
+ __nextHasNoMarginBottom
350
351
  label={ __( 'Allow to wrap to multiple lines' ) }
351
352
  onChange={ ( value ) => {
352
353
  onChange( {