@wordpress/block-editor 11.5.0 → 11.7.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 (345) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +4 -0
  3. package/build/components/block-list/block-html.js +1 -3
  4. package/build/components/block-list/block-html.js.map +1 -1
  5. package/build/components/block-list/block-invalid-warning.js +63 -80
  6. package/build/components/block-list/block-invalid-warning.js.map +1 -1
  7. package/build/components/block-preview/auto.js +6 -23
  8. package/build/components/block-preview/auto.js.map +1 -1
  9. package/build/components/block-settings-menu-controls/index.js +1 -1
  10. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  11. package/build/components/block-switcher/block-transformations-menu.native.js +1 -0
  12. package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  13. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
  14. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  15. package/build/components/editor-styles/index.js +20 -2
  16. package/build/components/editor-styles/index.js.map +1 -1
  17. package/build/components/global-styles/border-panel.js +306 -0
  18. package/build/components/global-styles/border-panel.js.map +1 -0
  19. package/build/components/global-styles/color-panel.js +583 -0
  20. package/build/components/global-styles/color-panel.js.map +1 -0
  21. package/build/components/global-styles/dimensions-panel.js +8 -30
  22. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  23. package/build/components/global-styles/get-block-css-selector.js +129 -0
  24. package/build/components/global-styles/get-block-css-selector.js.map +1 -0
  25. package/build/components/global-styles/hooks.js +109 -3
  26. package/build/components/global-styles/hooks.js.map +1 -1
  27. package/build/components/global-styles/index.js +36 -0
  28. package/build/components/global-styles/index.js.map +1 -1
  29. package/build/components/global-styles/typography-panel.js +66 -45
  30. package/build/components/global-styles/typography-panel.js.map +1 -1
  31. package/build/components/global-styles/use-global-styles-output.js +180 -99
  32. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  33. package/build/components/global-styles/utils.js +2 -1
  34. package/build/components/global-styles/utils.js.map +1 -1
  35. package/build/components/image-size-control/index.js +8 -5
  36. package/build/components/image-size-control/index.js.map +1 -1
  37. package/build/components/inserter/index.js +29 -17
  38. package/build/components/inserter/index.js.map +1 -1
  39. package/build/components/inserter/menu.js +1 -1
  40. package/build/components/inserter/menu.js.map +1 -1
  41. package/build/components/inserter/quick-inserter.js +4 -2
  42. package/build/components/inserter/quick-inserter.js.map +1 -1
  43. package/build/components/inserter/search-results.js +10 -3
  44. package/build/components/inserter/search-results.js.map +1 -1
  45. package/build/components/inserter/tabs.js +1 -1
  46. package/build/components/inserter/tabs.js.map +1 -1
  47. package/build/components/inspector-controls-tabs/position-controls-panel.js +43 -7
  48. package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  49. package/build/components/line-height-control/index.js +15 -1
  50. package/build/components/line-height-control/index.js.map +1 -1
  51. package/build/components/link-control/index.js +1 -1
  52. package/build/components/link-control/index.js.map +1 -1
  53. package/build/components/link-control/search-item.js +5 -2
  54. package/build/components/link-control/search-item.js.map +1 -1
  55. package/build/components/list-view/appender.js +105 -0
  56. package/build/components/list-view/appender.js.map +1 -0
  57. package/build/components/list-view/block.js +5 -5
  58. package/build/components/list-view/block.js.map +1 -1
  59. package/build/components/list-view/branch.js +25 -5
  60. package/build/components/list-view/branch.js.map +1 -1
  61. package/build/components/list-view/index.js +37 -13
  62. package/build/components/list-view/index.js.map +1 -1
  63. package/build/components/list-view/use-block-selection.js +1 -2
  64. package/build/components/list-view/use-block-selection.js.map +1 -1
  65. package/build/components/media-replace-flow/index.js +13 -4
  66. package/build/components/media-replace-flow/index.js.map +1 -1
  67. package/build/components/off-canvas-editor/appender.js +28 -3
  68. package/build/components/off-canvas-editor/appender.js.map +1 -1
  69. package/build/components/off-canvas-editor/branch.js +5 -3
  70. package/build/components/off-canvas-editor/branch.js.map +1 -1
  71. package/build/components/off-canvas-editor/index.js +9 -7
  72. package/build/components/off-canvas-editor/index.js.map +1 -1
  73. package/build/components/off-canvas-editor/link-ui.js +0 -1
  74. package/build/components/off-canvas-editor/link-ui.js.map +1 -1
  75. package/build/components/provider/use-block-sync.js +17 -3
  76. package/build/components/provider/use-block-sync.js.map +1 -1
  77. package/build/components/rich-text/format-edit.js +2 -30
  78. package/build/components/rich-text/format-edit.js.map +1 -1
  79. package/build/components/rich-text/format-toolbar-container.js +0 -3
  80. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  81. package/build/components/writing-flow/use-input.js +4 -8
  82. package/build/components/writing-flow/use-input.js.map +1 -1
  83. package/build/hooks/border.js +90 -240
  84. package/build/hooks/border.js.map +1 -1
  85. package/build/hooks/color.js +92 -229
  86. package/build/hooks/color.js.map +1 -1
  87. package/build/hooks/content-lock-ui.js +4 -2
  88. package/build/hooks/content-lock-ui.js.map +1 -1
  89. package/build/hooks/{color-panel.js → contrast-checker.js} +11 -49
  90. package/build/hooks/contrast-checker.js.map +1 -0
  91. package/build/hooks/custom-class-name.js +4 -4
  92. package/build/hooks/custom-class-name.js.map +1 -1
  93. package/build/hooks/custom-class-name.native.js +3 -4
  94. package/build/hooks/custom-class-name.native.js.map +1 -1
  95. package/build/hooks/dimensions.js +0 -1
  96. package/build/hooks/dimensions.js.map +1 -1
  97. package/build/hooks/duotone.js +3 -1
  98. package/build/hooks/duotone.js.map +1 -1
  99. package/build/hooks/layout.js +19 -22
  100. package/build/hooks/layout.js.map +1 -1
  101. package/build/hooks/position.js +2 -2
  102. package/build/hooks/position.js.map +1 -1
  103. package/build/hooks/style.js +23 -26
  104. package/build/hooks/style.js.map +1 -1
  105. package/build/hooks/supports.js +7 -1
  106. package/build/hooks/supports.js.map +1 -1
  107. package/build/hooks/typography.js +2 -2
  108. package/build/hooks/typography.js.map +1 -1
  109. package/build/hooks/utils.js +50 -75
  110. package/build/hooks/utils.js.map +1 -1
  111. package/build/layouts/constrained.js +6 -2
  112. package/build/layouts/constrained.js.map +1 -1
  113. package/build/layouts/grid.js +165 -0
  114. package/build/layouts/grid.js.map +1 -0
  115. package/build/layouts/index.js +3 -1
  116. package/build/layouts/index.js.map +1 -1
  117. package/build/private-apis.js +7 -1
  118. package/build/private-apis.js.map +1 -1
  119. package/build/store/actions.js +10 -8
  120. package/build/store/actions.js.map +1 -1
  121. package/build/store/selectors.js +19 -3
  122. package/build/store/selectors.js.map +1 -1
  123. package/build/utils/object.js +76 -0
  124. package/build/utils/object.js.map +1 -0
  125. package/build/utils/parse-css-unit-to-px.js +15 -9
  126. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  127. package/build-module/components/block-list/block-html.js +1 -3
  128. package/build-module/components/block-list/block-html.js.map +1 -1
  129. package/build-module/components/block-list/block-invalid-warning.js +66 -78
  130. package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
  131. package/build-module/components/block-preview/auto.js +6 -22
  132. package/build-module/components/block-preview/auto.js.map +1 -1
  133. package/build-module/components/block-settings-menu-controls/index.js +1 -1
  134. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  135. package/build-module/components/block-switcher/block-transformations-menu.native.js +1 -0
  136. package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  137. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
  138. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  139. package/build-module/components/editor-styles/index.js +19 -2
  140. package/build-module/components/editor-styles/index.js.map +1 -1
  141. package/build-module/components/global-styles/border-panel.js +291 -0
  142. package/build-module/components/global-styles/border-panel.js.map +1 -0
  143. package/build-module/components/global-styles/color-panel.js +554 -0
  144. package/build-module/components/global-styles/color-panel.js.map +1 -0
  145. package/build-module/components/global-styles/dimensions-panel.js +7 -30
  146. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  147. package/build-module/components/global-styles/get-block-css-selector.js +120 -0
  148. package/build-module/components/global-styles/get-block-css-selector.js.map +1 -0
  149. package/build-module/components/global-styles/hooks.js +104 -3
  150. package/build-module/components/global-styles/hooks.js.map +1 -1
  151. package/build-module/components/global-styles/index.js +3 -0
  152. package/build-module/components/global-styles/index.js.map +1 -1
  153. package/build-module/components/global-styles/typography-panel.js +65 -46
  154. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  155. package/build-module/components/global-styles/use-global-styles-output.js +181 -100
  156. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  157. package/build-module/components/global-styles/utils.js +2 -1
  158. package/build-module/components/global-styles/utils.js.map +1 -1
  159. package/build-module/components/image-size-control/index.js +8 -5
  160. package/build-module/components/image-size-control/index.js.map +1 -1
  161. package/build-module/components/inserter/index.js +28 -16
  162. package/build-module/components/inserter/index.js.map +1 -1
  163. package/build-module/components/inserter/menu.js +1 -1
  164. package/build-module/components/inserter/menu.js.map +1 -1
  165. package/build-module/components/inserter/quick-inserter.js +4 -2
  166. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  167. package/build-module/components/inserter/search-results.js +10 -3
  168. package/build-module/components/inserter/search-results.js.map +1 -1
  169. package/build-module/components/inserter/tabs.js +1 -1
  170. package/build-module/components/inserter/tabs.js.map +1 -1
  171. package/build-module/components/inspector-controls-tabs/position-controls-panel.js +42 -7
  172. package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  173. package/build-module/components/line-height-control/index.js +15 -1
  174. package/build-module/components/line-height-control/index.js.map +1 -1
  175. package/build-module/components/link-control/index.js +1 -1
  176. package/build-module/components/link-control/index.js.map +1 -1
  177. package/build-module/components/link-control/search-item.js +4 -2
  178. package/build-module/components/link-control/search-item.js.map +1 -1
  179. package/build-module/components/list-view/appender.js +88 -0
  180. package/build-module/components/list-view/appender.js.map +1 -0
  181. package/build-module/components/list-view/block.js +5 -4
  182. package/build-module/components/list-view/block.js.map +1 -1
  183. package/build-module/components/list-view/branch.js +22 -5
  184. package/build-module/components/list-view/branch.js.map +1 -1
  185. package/build-module/components/list-view/index.js +32 -12
  186. package/build-module/components/list-view/index.js.map +1 -1
  187. package/build-module/components/list-view/use-block-selection.js +1 -2
  188. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  189. package/build-module/components/media-replace-flow/index.js +12 -4
  190. package/build-module/components/media-replace-flow/index.js.map +1 -1
  191. package/build-module/components/off-canvas-editor/appender.js +28 -4
  192. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  193. package/build-module/components/off-canvas-editor/branch.js +5 -3
  194. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  195. package/build-module/components/off-canvas-editor/index.js +9 -7
  196. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  197. package/build-module/components/off-canvas-editor/link-ui.js +0 -1
  198. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
  199. package/build-module/components/provider/use-block-sync.js +17 -3
  200. package/build-module/components/provider/use-block-sync.js.map +1 -1
  201. package/build-module/components/rich-text/format-edit.js +3 -31
  202. package/build-module/components/rich-text/format-edit.js.map +1 -1
  203. package/build-module/components/rich-text/format-toolbar-container.js +0 -3
  204. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  205. package/build-module/components/writing-flow/use-input.js +4 -8
  206. package/build-module/components/writing-flow/use-input.js.map +1 -1
  207. package/build-module/hooks/border.js +92 -240
  208. package/build-module/hooks/border.js.map +1 -1
  209. package/build-module/hooks/color.js +90 -232
  210. package/build-module/hooks/color.js.map +1 -1
  211. package/build-module/hooks/content-lock-ui.js +4 -2
  212. package/build-module/hooks/content-lock-ui.js.map +1 -1
  213. package/build-module/hooks/{color-panel.js → contrast-checker.js} +10 -44
  214. package/build-module/hooks/contrast-checker.js.map +1 -0
  215. package/build-module/hooks/custom-class-name.js +4 -4
  216. package/build-module/hooks/custom-class-name.js.map +1 -1
  217. package/build-module/hooks/custom-class-name.native.js +3 -4
  218. package/build-module/hooks/custom-class-name.native.js.map +1 -1
  219. package/build-module/hooks/dimensions.js +0 -1
  220. package/build-module/hooks/dimensions.js.map +1 -1
  221. package/build-module/hooks/duotone.js +4 -2
  222. package/build-module/hooks/duotone.js.map +1 -1
  223. package/build-module/hooks/layout.js +19 -22
  224. package/build-module/hooks/layout.js.map +1 -1
  225. package/build-module/hooks/position.js +3 -3
  226. package/build-module/hooks/position.js.map +1 -1
  227. package/build-module/hooks/style.js +23 -26
  228. package/build-module/hooks/style.js.map +1 -1
  229. package/build-module/hooks/supports.js +7 -1
  230. package/build-module/hooks/supports.js.map +1 -1
  231. package/build-module/hooks/typography.js +2 -2
  232. package/build-module/hooks/typography.js.map +1 -1
  233. package/build-module/hooks/utils.js +48 -72
  234. package/build-module/hooks/utils.js.map +1 -1
  235. package/build-module/layouts/constrained.js +6 -2
  236. package/build-module/layouts/constrained.js.map +1 -1
  237. package/build-module/layouts/grid.js +151 -0
  238. package/build-module/layouts/grid.js.map +1 -0
  239. package/build-module/layouts/index.js +2 -1
  240. package/build-module/layouts/index.js.map +1 -1
  241. package/build-module/private-apis.js +5 -1
  242. package/build-module/private-apis.js.map +1 -1
  243. package/build-module/store/actions.js +10 -8
  244. package/build-module/store/actions.js.map +1 -1
  245. package/build-module/store/selectors.js +17 -3
  246. package/build-module/store/selectors.js.map +1 -1
  247. package/build-module/utils/object.js +69 -0
  248. package/build-module/utils/object.js.map +1 -0
  249. package/build-module/utils/parse-css-unit-to-px.js +15 -9
  250. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  251. package/build-style/style-rtl.css +32 -12
  252. package/build-style/style.css +32 -12
  253. package/package.json +31 -31
  254. package/src/components/block-draggable/content.scss +1 -1
  255. package/src/components/block-inspector/style.scss +3 -0
  256. package/src/components/block-list/block-html.js +1 -1
  257. package/src/components/block-list/block-invalid-warning.js +72 -64
  258. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +20 -2
  259. package/src/components/block-preview/auto.js +2 -17
  260. package/src/components/block-preview/test/index.js +0 -2
  261. package/src/components/block-settings-menu-controls/index.js +2 -1
  262. package/src/components/block-styles/style.scss +2 -2
  263. package/src/components/block-switcher/block-transformations-menu.native.js +1 -0
  264. package/src/components/color-palette/test/__snapshots__/control.js.snap +16 -14
  265. package/src/components/colors-gradients/style.scss +8 -8
  266. package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +48 -38
  267. package/src/components/editor-styles/index.js +29 -1
  268. package/src/components/global-styles/border-panel.js +285 -0
  269. package/src/components/global-styles/color-panel.js +706 -0
  270. package/src/components/global-styles/dimensions-panel.js +13 -42
  271. package/src/components/global-styles/get-block-css-selector.js +129 -0
  272. package/src/components/global-styles/hooks.js +154 -1
  273. package/src/components/global-styles/index.js +3 -0
  274. package/src/components/global-styles/test/use-global-styles-output.js +31 -2
  275. package/src/components/global-styles/typography-panel.js +67 -45
  276. package/src/components/global-styles/use-global-styles-output.js +176 -93
  277. package/src/components/global-styles/utils.js +3 -0
  278. package/src/components/image-size-control/index.js +4 -3
  279. package/src/components/image-size-control/test/index.js +2 -2
  280. package/src/components/inner-blocks/README.md +1 -1
  281. package/src/components/inserter/index.js +30 -11
  282. package/src/components/inserter/menu.js +0 -1
  283. package/src/components/inserter/quick-inserter.js +2 -0
  284. package/src/components/inserter/search-results.js +7 -1
  285. package/src/components/inserter/style.scss +3 -0
  286. package/src/components/inserter/tabs.js +1 -9
  287. package/src/components/inspector-controls-tabs/position-controls-panel.js +40 -9
  288. package/src/components/line-height-control/index.js +10 -1
  289. package/src/components/link-control/index.js +1 -1
  290. package/src/components/link-control/search-item.js +3 -1
  291. package/src/components/link-control/style.scss +0 -4
  292. package/src/components/link-control/test/index.js +0 -2
  293. package/src/components/list-view/appender.js +101 -0
  294. package/src/components/list-view/block.js +5 -4
  295. package/src/components/list-view/branch.js +30 -1
  296. package/src/components/list-view/index.js +43 -10
  297. package/src/components/list-view/style.scss +19 -0
  298. package/src/components/list-view/use-block-selection.js +0 -2
  299. package/src/components/media-replace-flow/index.js +36 -24
  300. package/src/components/media-replace-flow/style.scss +5 -2
  301. package/src/components/off-canvas-editor/appender.js +31 -5
  302. package/src/components/off-canvas-editor/branch.js +3 -1
  303. package/src/components/off-canvas-editor/index.js +7 -7
  304. package/src/components/off-canvas-editor/link-ui.js +0 -1
  305. package/src/components/provider/use-block-sync.js +21 -4
  306. package/src/components/rich-text/format-edit.js +2 -32
  307. package/src/components/rich-text/format-toolbar-container.js +1 -7
  308. package/src/components/url-popover/test/index.js +0 -2
  309. package/src/components/writing-flow/use-input.js +4 -5
  310. package/src/hooks/border.js +93 -225
  311. package/src/hooks/color.js +120 -296
  312. package/src/hooks/content-lock-ui.js +6 -2
  313. package/src/hooks/{color-panel.js → contrast-checker.js} +10 -46
  314. package/src/hooks/custom-class-name.js +4 -4
  315. package/src/hooks/custom-class-name.native.js +3 -4
  316. package/src/hooks/dimensions.js +0 -1
  317. package/src/hooks/duotone.js +8 -5
  318. package/src/hooks/layout.js +19 -16
  319. package/src/hooks/position.js +3 -3
  320. package/src/hooks/style.js +29 -28
  321. package/src/hooks/supports.js +6 -0
  322. package/src/hooks/test/style.js +2 -1
  323. package/src/hooks/test/use-typography-props.js +2 -0
  324. package/src/hooks/test/utils.js +0 -104
  325. package/src/hooks/typography.js +2 -1
  326. package/src/hooks/utils.js +63 -70
  327. package/src/layouts/constrained.js +23 -17
  328. package/src/layouts/grid.js +172 -0
  329. package/src/layouts/index.js +2 -1
  330. package/src/layouts/test/grid.js +21 -0
  331. package/src/private-apis.js +4 -0
  332. package/src/store/actions.js +10 -8
  333. package/src/store/selectors.js +20 -3
  334. package/src/utils/object.js +69 -0
  335. package/src/utils/parse-css-unit-to-px.js +14 -9
  336. package/src/utils/test/object.js +107 -0
  337. package/src/utils/test/parse-css-unit-to-px.js +1 -2
  338. package/tsconfig.tsbuildinfo +1 -1
  339. package/build/hooks/border-radius.js +0 -100
  340. package/build/hooks/border-radius.js.map +0 -1
  341. package/build/hooks/color-panel.js.map +0 -1
  342. package/build-module/hooks/border-radius.js +0 -84
  343. package/build-module/hooks/border-radius.js.map +0 -1
  344. package/build-module/hooks/color-panel.js.map +0 -1
  345. package/src/hooks/border-radius.js +0 -70
@@ -35,11 +35,12 @@ const layoutBlockSupportKey = '__experimentalLayout';
35
35
  /**
36
36
  * Generates the utility classnames for the given block's layout attributes.
37
37
  *
38
- * @param { Object } block Block object.
38
+ * @param { Object } blockAttributes Block attributes.
39
+ * @param { string } blockName Block name.
39
40
  *
40
41
  * @return { Array } Array of CSS classname strings.
41
42
  */
42
- export function useLayoutClasses( block = {} ) {
43
+ export function useLayoutClasses( blockAttributes = {}, blockName = '' ) {
43
44
  const rootPaddingAlignment = useSelect( ( select ) => {
44
45
  const { getSettings } = select( blockEditorStore );
45
46
  return getSettings().__experimentalFeatures
@@ -47,11 +48,10 @@ export function useLayoutClasses( block = {} ) {
47
48
  }, [] );
48
49
  const globalLayoutSettings = useSetting( 'layout' ) || {};
49
50
 
50
- const { attributes = {}, name } = block;
51
- const { layout } = attributes;
51
+ const { layout } = blockAttributes;
52
52
 
53
53
  const { default: defaultBlockLayout } =
54
- getBlockSupport( name, layoutBlockSupportKey ) || {};
54
+ getBlockSupport( blockName, layoutBlockSupportKey ) || {};
55
55
  const usedLayout =
56
56
  layout?.inherit || layout?.contentSize || layout?.wideSize
57
57
  ? { ...layout, type: 'constrained' }
@@ -63,10 +63,13 @@ export function useLayoutClasses( block = {} ) {
63
63
  globalLayoutSettings?.definitions?.[ usedLayout?.type || 'default' ]
64
64
  ?.className
65
65
  ) {
66
- layoutClassnames.push(
66
+ const baseClassName =
67
67
  globalLayoutSettings?.definitions?.[ usedLayout?.type || 'default' ]
68
- ?.className
69
- );
68
+ ?.className;
69
+ const compoundClassName = `wp-block-${ blockName
70
+ .split( '/' )
71
+ .pop() }-${ baseClassName }`;
72
+ layoutClassnames.push( baseClassName, compoundClassName );
70
73
  }
71
74
 
72
75
  if (
@@ -100,14 +103,14 @@ export function useLayoutClasses( block = {} ) {
100
103
  /**
101
104
  * Generates a CSS rule with the given block's layout styles.
102
105
  *
103
- * @param { Object } block Block object.
104
- * @param { string } selector A selector to use in generating the CSS rule.
106
+ * @param { Object } blockAttributes Block attributes.
107
+ * @param { string } blockName Block name.
108
+ * @param { string } selector A selector to use in generating the CSS rule.
105
109
  *
106
110
  * @return { string } CSS rule.
107
111
  */
108
- export function useLayoutStyles( block = {}, selector ) {
109
- const { attributes = {}, name } = block;
110
- const { layout = {}, style = {} } = attributes;
112
+ export function useLayoutStyles( blockAttributes = {}, blockName, selector ) {
113
+ const { layout = {}, style = {} } = blockAttributes;
111
114
  // Update type for blocks using legacy layouts.
112
115
  const usedLayout =
113
116
  layout?.inherit || layout?.contentSize || layout?.wideSize
@@ -118,7 +121,7 @@ export function useLayoutStyles( block = {}, selector ) {
118
121
  const blockGapSupport = useSetting( 'spacing.blockGap' );
119
122
  const hasBlockGapSupport = blockGapSupport !== null;
120
123
  const css = fullLayoutType?.getLayoutStyle?.( {
121
- blockName: name,
124
+ blockName,
122
125
  selector,
123
126
  layout,
124
127
  layoutDefinitions: globalLayoutSettings?.definitions,
@@ -351,7 +354,7 @@ export const withInspectorControls = createHigherOrderComponent(
351
354
  */
352
355
  export const withLayoutStyles = createHigherOrderComponent(
353
356
  ( BlockListBlock ) => ( props ) => {
354
- const { name, attributes, block } = props;
357
+ const { name, attributes } = props;
355
358
  const hasLayoutBlockSupport = hasBlockSupport(
356
359
  name,
357
360
  layoutBlockSupportKey
@@ -373,7 +376,7 @@ export const withLayoutStyles = createHigherOrderComponent(
373
376
  ? { ...layout, type: 'constrained' }
374
377
  : layout || defaultBlockLayout || {};
375
378
  const layoutClasses = hasLayoutBlockSupport
376
- ? useLayoutClasses( block )
379
+ ? useLayoutClasses( attributes, name )
377
380
  : null;
378
381
  // Higher specificity to override defaults from theme.json.
379
382
  const selector = `.wp-container-${ id }.wp-container-${ id }`;
@@ -6,7 +6,7 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { __, sprintf } from '@wordpress/i18n';
9
+ import { __, _x, sprintf } from '@wordpress/i18n';
10
10
  import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
11
11
  import {
12
12
  BaseControl,
@@ -49,7 +49,7 @@ const DEFAULT_OPTION = {
49
49
  const STICKY_OPTION = {
50
50
  key: 'sticky',
51
51
  value: 'sticky',
52
- name: __( 'Sticky' ),
52
+ name: _x( 'Sticky', 'Name for the value of the CSS position property' ),
53
53
  className: OPTION_CLASSNAME,
54
54
  __experimentalHint: __(
55
55
  'The block will stick to the top of the window instead of scrolling.'
@@ -59,7 +59,7 @@ const STICKY_OPTION = {
59
59
  const FIXED_OPTION = {
60
60
  key: 'fixed',
61
61
  value: 'fixed',
62
- name: __( 'Fixed' ),
62
+ name: _x( 'Fixed', 'Name for the value of the CSS position property' ),
63
63
  className: OPTION_CLASSNAME,
64
64
  __experimentalHint: __(
65
65
  'The block will not move when the page is scrolled.'
@@ -384,39 +384,40 @@ const withElementsStyles = createHigherOrderComponent(
384
384
  );
385
385
 
386
386
  const styles = useMemo( () => {
387
- const rawElementsStyles = props.attributes.style?.elements;
387
+ // The .editor-styles-wrapper selector is required on elements styles. As it is
388
+ // added to all other editor styles, not providing it causes reset and global
389
+ // styles to override element styles because of higher specificity.
390
+ const elements = [
391
+ {
392
+ styles: ! skipLinkColorSerialization
393
+ ? props.attributes.style?.elements?.link
394
+ : undefined,
395
+ selector: `.editor-styles-wrapper .${ blockElementsContainerIdentifier } ${ ELEMENTS.link }`,
396
+ },
397
+ {
398
+ styles: ! skipLinkColorSerialization
399
+ ? props.attributes.style?.elements?.link?.[ ':hover' ]
400
+ : undefined,
401
+ selector: `.editor-styles-wrapper .${ blockElementsContainerIdentifier } ${ ELEMENTS.link }:hover`,
402
+ },
403
+ ];
388
404
  const elementCssRules = [];
389
- if (
390
- rawElementsStyles &&
391
- Object.keys( rawElementsStyles ).length > 0
392
- ) {
393
- // Remove values based on whether serialization has been skipped for a specific style.
394
- const filteredElementsStyles = {
395
- ...rawElementsStyles,
396
- link: {
397
- ...rawElementsStyles.link,
398
- color: ! skipLinkColorSerialization
399
- ? rawElementsStyles.link?.color
400
- : undefined,
401
- },
402
- };
403
-
404
- for ( const [ elementName, elementStyles ] of Object.entries(
405
- filteredElementsStyles
406
- ) ) {
405
+ for ( const { styles: elementStyles, selector } of elements ) {
406
+ if ( elementStyles ) {
407
407
  const cssRule = compileCSS( elementStyles, {
408
- // The .editor-styles-wrapper selector is required on elements styles. As it is
409
- // added to all other editor styles, not providing it causes reset and global
410
- // styles to override element styles because of higher specificity.
411
- selector: `.editor-styles-wrapper .${ blockElementsContainerIdentifier } ${ ELEMENTS[ elementName ] }`,
408
+ selector,
412
409
  } );
413
- if ( !! cssRule ) {
414
- elementCssRules.push( cssRule );
415
- }
410
+ elementCssRules.push( cssRule );
416
411
  }
417
412
  }
418
- return elementCssRules.length > 0 ? elementCssRules : undefined;
419
- }, [ props.attributes.style?.elements ] );
413
+ return elementCssRules.length > 0
414
+ ? elementCssRules.join( '' )
415
+ : undefined;
416
+ }, [
417
+ props.attributes.style?.elements,
418
+ blockElementsContainerIdentifier,
419
+ skipLinkColorSerialization,
420
+ ] );
420
421
 
421
422
  const element = useContext( BlockList.__unstableElementContext );
422
423
 
@@ -20,6 +20,11 @@ const FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle';
20
20
  * Key within block settings' support array indicating support for font weight.
21
21
  */
22
22
  const FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight';
23
+ /**
24
+ * Key within block settings' supports array indicating support for text
25
+ * columns e.g. settings found in `block.json`.
26
+ */
27
+ const TEXT_COLUMNS_SUPPORT_KEY = 'typography.textColumns';
23
28
  /**
24
29
  * Key within block settings' supports array indicating support for text
25
30
  * decorations e.g. settings found in `block.json`.
@@ -42,6 +47,7 @@ const TYPOGRAPHY_SUPPORT_KEYS = [
42
47
  FONT_STYLE_SUPPORT_KEY,
43
48
  FONT_WEIGHT_SUPPORT_KEY,
44
49
  FONT_FAMILY_SUPPORT_KEY,
50
+ TEXT_COLUMNS_SUPPORT_KEY,
45
51
  TEXT_DECORATION_SUPPORT_KEY,
46
52
  TEXT_TRANSFORM_SUPPORT_KEY,
47
53
  LETTER_SPACING_SUPPORT_KEY,
@@ -21,7 +21,7 @@ describe( 'getInlineStyles', () => {
21
21
  expect(
22
22
  getInlineStyles( {
23
23
  color: { text: 'red', background: 'black' },
24
- typography: { lineHeight: 1.5, fontSize: 10 },
24
+ typography: { lineHeight: 1.5, fontSize: 10, textColumns: 2 },
25
25
  border: {
26
26
  radius: '10px',
27
27
  width: '1em',
@@ -44,6 +44,7 @@ describe( 'getInlineStyles', () => {
44
44
  borderStyle: 'dotted',
45
45
  borderWidth: '1em',
46
46
  color: 'red',
47
+ columnCount: 2,
47
48
  lineHeight: 1.5,
48
49
  fontSize: 10,
49
50
  marginBottom: '15px',
@@ -12,6 +12,7 @@ describe( 'getTypographyClassesAndStyles', () => {
12
12
  typography: {
13
13
  letterSpacing: '22px',
14
14
  fontSize: '2rem',
15
+ textColumns: 3,
15
16
  textTransform: 'uppercase',
16
17
  },
17
18
  },
@@ -19,6 +20,7 @@ describe( 'getTypographyClassesAndStyles', () => {
19
20
  expect( getTypographyClassesAndStyles( attributes ) ).toEqual( {
20
21
  className: 'has-tofu-font-family has-large-font-size',
21
22
  style: {
23
+ columnCount: 3,
22
24
  letterSpacing: '22px',
23
25
  fontSize: '2rem',
24
26
  textTransform: 'uppercase',
@@ -7,113 +7,9 @@ import { applyFilters } from '@wordpress/hooks';
7
7
  * Internal dependencies
8
8
  */
9
9
  import '../anchor';
10
- import { immutableSet } from '../utils';
11
10
 
12
11
  const noop = () => {};
13
12
 
14
- describe( 'immutableSet', () => {
15
- describe( 'handling falsy values properly', () => {
16
- it( 'should create a new object if `undefined` is passed', () => {
17
- const result = immutableSet( undefined, 'test', 1 );
18
-
19
- expect( result ).toEqual( { test: 1 } );
20
- } );
21
-
22
- it( 'should create a new object if `null` is passed', () => {
23
- const result = immutableSet( null, 'test', 1 );
24
-
25
- expect( result ).toEqual( { test: 1 } );
26
- } );
27
-
28
- it( 'should create a new object if `false` is passed', () => {
29
- const result = immutableSet( false, 'test', 1 );
30
-
31
- expect( result ).toEqual( { test: 1 } );
32
- } );
33
-
34
- it( 'should create a new object if `0` is passed', () => {
35
- const result = immutableSet( 0, 'test', 1 );
36
-
37
- expect( result ).toEqual( { test: 1 } );
38
- } );
39
-
40
- it( 'should create a new object if an empty string is passed', () => {
41
- const result = immutableSet( '', 'test', 1 );
42
-
43
- expect( result ).toEqual( { test: 1 } );
44
- } );
45
-
46
- it( 'should create a new object if a NaN is passed', () => {
47
- const result = immutableSet( NaN, 'test', 1 );
48
-
49
- expect( result ).toEqual( { test: 1 } );
50
- } );
51
- } );
52
-
53
- describe( 'manages data assignment properly', () => {
54
- it( 'assigns value properly when it does not exist', () => {
55
- const result = immutableSet( {}, 'test', 1 );
56
-
57
- expect( result ).toEqual( { test: 1 } );
58
- } );
59
-
60
- it( 'overrides existing values', () => {
61
- const result = immutableSet( { test: 1 }, 'test', 2 );
62
-
63
- expect( result ).toEqual( { test: 2 } );
64
- } );
65
-
66
- describe( 'with array notation access', () => {
67
- it( 'assigns values at deeper levels', () => {
68
- const result = immutableSet( {}, [ 'foo', 'bar', 'baz' ], 5 );
69
-
70
- expect( result ).toEqual( { foo: { bar: { baz: 5 } } } );
71
- } );
72
-
73
- it( 'overrides existing values at deeper levels', () => {
74
- const result = immutableSet(
75
- { foo: { bar: { baz: 1 } } },
76
- [ 'foo', 'bar', 'baz' ],
77
- 5
78
- );
79
-
80
- expect( result ).toEqual( { foo: { bar: { baz: 5 } } } );
81
- } );
82
-
83
- it( 'keeps other properties intact', () => {
84
- const result = immutableSet(
85
- { foo: { bar: { baz: 1 } } },
86
- [ 'foo', 'bar', 'test' ],
87
- 5
88
- );
89
-
90
- expect( result ).toEqual( {
91
- foo: { bar: { baz: 1, test: 5 } },
92
- } );
93
- } );
94
- } );
95
- } );
96
-
97
- describe( 'does not mutate the original object', () => {
98
- it( 'clones the object at the first level', () => {
99
- const input = {};
100
- const result = immutableSet( input, 'test', 1 );
101
-
102
- expect( result ).not.toBe( input );
103
- } );
104
-
105
- it( 'clones the object at deeper levels', () => {
106
- const input = { foo: { bar: { baz: 1 } } };
107
- const result = immutableSet( input, [ 'foo', 'bar', 'baz' ], 2 );
108
-
109
- expect( result ).not.toBe( input );
110
- expect( result.foo ).not.toBe( input.foo );
111
- expect( result.foo.bar ).not.toBe( input.foo.bar );
112
- expect( result.foo.bar.baz ).not.toBe( input.foo.bar.baz );
113
- } );
114
- } );
115
- } );
116
-
117
13
  describe( 'anchor', () => {
118
14
  const blockSettings = {
119
15
  save: noop,
@@ -27,6 +27,7 @@ function omit( object, keys ) {
27
27
  const LETTER_SPACING_SUPPORT_KEY = 'typography.__experimentalLetterSpacing';
28
28
  const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.__experimentalTextTransform';
29
29
  const TEXT_DECORATION_SUPPORT_KEY = 'typography.__experimentalTextDecoration';
30
+ const TEXT_COLUMNS_SUPPORT_KEY = 'typography.textColumns';
30
31
  const FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle';
31
32
  const FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight';
32
33
  export const TYPOGRAPHY_SUPPORT_KEY = 'typography';
@@ -36,6 +37,7 @@ export const TYPOGRAPHY_SUPPORT_KEYS = [
36
37
  FONT_STYLE_SUPPORT_KEY,
37
38
  FONT_WEIGHT_SUPPORT_KEY,
38
39
  FONT_FAMILY_SUPPORT_KEY,
40
+ TEXT_COLUMNS_SUPPORT_KEY,
39
41
  TEXT_DECORATION_SUPPORT_KEY,
40
42
  TEXT_TRANSFORM_SUPPORT_KEY,
41
43
  LETTER_SPACING_SUPPORT_KEY,
@@ -136,7 +138,6 @@ export function TypographyPanel( {
136
138
  <StylesTypographyPanel
137
139
  as={ TypographyInspectorControl }
138
140
  panelId={ clientId }
139
- name={ name }
140
141
  settings={ settings }
141
142
  value={ value }
142
143
  onChange={ onChange }
@@ -14,6 +14,7 @@ import { useMemo } from '@wordpress/element';
14
14
  */
15
15
  import { useSetting } from '../components';
16
16
  import { useSettingsForBlockElement } from '../components/global-styles/hooks';
17
+ import { immutableSet } from '../utils/object';
17
18
 
18
19
  /**
19
20
  * Removed falsy values from nested object.
@@ -37,76 +38,6 @@ export const cleanEmptyObject = ( object ) => {
37
38
  return isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;
38
39
  };
39
40
 
40
- /**
41
- * Converts a path to an array of its fragments.
42
- * Supports strings, numbers and arrays:
43
- *
44
- * 'foo' => [ 'foo' ]
45
- * 2 => [ '2' ]
46
- * [ 'foo', 'bar' ] => [ 'foo', 'bar' ]
47
- *
48
- * @param {string|number|Array} path Path
49
- * @return {Array} Normalized path.
50
- */
51
- function normalizePath( path ) {
52
- if ( Array.isArray( path ) ) {
53
- return path;
54
- } else if ( typeof path === 'number' ) {
55
- return [ path.toString() ];
56
- }
57
-
58
- return [ path ];
59
- }
60
-
61
- /**
62
- * Clones an object.
63
- * Non-object values are returned unchanged.
64
- *
65
- * @param {*} object Object to clone.
66
- * @return {*} Cloned object, or original literal non-object value.
67
- */
68
- function cloneObject( object ) {
69
- if ( typeof object === 'object' ) {
70
- return {
71
- ...Object.fromEntries(
72
- Object.entries( object ).map( ( [ key, value ] ) => [
73
- key,
74
- cloneObject( value ),
75
- ] )
76
- ),
77
- };
78
- }
79
-
80
- return object;
81
- }
82
-
83
- /**
84
- * Perform an immutable set.
85
- * Handles nullish initial values.
86
- * Clones all nested objects in the specified object.
87
- *
88
- * @param {Object} object Object to set a value in.
89
- * @param {number|string|Array} path Path in the object to modify.
90
- * @param {*} value New value to set.
91
- * @return {Object} Cloned object with the new value set.
92
- */
93
- export function immutableSet( object, path, value ) {
94
- const normalizedPath = normalizePath( path );
95
- const newObject = object ? cloneObject( object ) : {};
96
-
97
- normalizedPath.reduce( ( acc, key, i ) => {
98
- if ( acc[ key ] === undefined ) {
99
- acc[ key ] = {};
100
- }
101
- if ( i === normalizedPath.length - 1 ) {
102
- acc[ key ] = value;
103
- }
104
- return acc[ key ];
105
- }, newObject );
106
-
107
- return newObject;
108
- }
109
-
110
41
  export function transformStyles(
111
42
  activeSupports,
112
43
  migrationPaths,
@@ -202,6 +133,7 @@ export function useBlockSettings( name, parentLayout ) {
202
133
  const fontStyle = useSetting( 'typography.fontStyle' );
203
134
  const fontWeight = useSetting( 'typography.fontWeight' );
204
135
  const lineHeight = useSetting( 'typography.lineHeight' );
136
+ const textColumns = useSetting( 'typography.textColumns' );
205
137
  const textDecoration = useSetting( 'typography.textDecoration' );
206
138
  const textTransform = useSetting( 'typography.textTransform' );
207
139
  const letterSpacing = useSetting( 'typography.letterSpacing' );
@@ -212,9 +144,45 @@ export function useBlockSettings( name, parentLayout ) {
212
144
  const units = useSetting( 'spacing.units' );
213
145
  const minHeight = useSetting( 'dimensions.minHeight' );
214
146
  const layout = useSetting( 'layout' );
147
+ const borderColor = useSetting( 'border.color' );
148
+ const borderRadius = useSetting( 'border.radius' );
149
+ const borderStyle = useSetting( 'border.style' );
150
+ const borderWidth = useSetting( 'border.width' );
151
+ const customColorsEnabled = useSetting( 'color.custom' );
152
+ const customColors = useSetting( 'color.palette.custom' );
153
+ const themeColors = useSetting( 'color.palette.theme' );
154
+ const defaultColors = useSetting( 'color.palette.default' );
155
+ const defaultPalette = useSetting( 'color.defaultPalette' );
156
+ const userGradientPalette = useSetting( 'color.gradients.custom' );
157
+ const themeGradientPalette = useSetting( 'color.gradients.theme' );
158
+ const defaultGradientPalette = useSetting( 'color.gradients.default' );
159
+ const defaultGradients = useSetting( 'color.defaultGradients' );
160
+ const areCustomGradientsEnabled = useSetting( 'color.customGradient' );
161
+ const isBackgroundEnabled = useSetting( 'color.background' );
162
+ const isLinkEnabled = useSetting( 'color.link' );
163
+ const isTextEnabled = useSetting( 'color.text' );
215
164
 
216
165
  const rawSettings = useMemo( () => {
217
166
  return {
167
+ color: {
168
+ palette: {
169
+ custom: customColors,
170
+ theme: themeColors,
171
+ default: defaultColors,
172
+ },
173
+ gradients: {
174
+ custom: userGradientPalette,
175
+ theme: themeGradientPalette,
176
+ default: defaultGradientPalette,
177
+ },
178
+ defaultGradients,
179
+ defaultPalette,
180
+ custom: customColorsEnabled,
181
+ customGradient: areCustomGradientsEnabled,
182
+ background: isBackgroundEnabled,
183
+ link: isLinkEnabled,
184
+ text: isTextEnabled,
185
+ },
218
186
  typography: {
219
187
  fontFamilies: {
220
188
  custom: fontFamilies,
@@ -226,6 +194,7 @@ export function useBlockSettings( name, parentLayout ) {
226
194
  fontStyle,
227
195
  fontWeight,
228
196
  lineHeight,
197
+ textColumns,
229
198
  textDecoration,
230
199
  textTransform,
231
200
  letterSpacing,
@@ -239,6 +208,12 @@ export function useBlockSettings( name, parentLayout ) {
239
208
  blockGap,
240
209
  units,
241
210
  },
211
+ border: {
212
+ color: borderColor,
213
+ radius: borderRadius,
214
+ style: borderStyle,
215
+ width: borderWidth,
216
+ },
242
217
  dimensions: {
243
218
  minHeight,
244
219
  },
@@ -252,6 +227,7 @@ export function useBlockSettings( name, parentLayout ) {
252
227
  fontStyle,
253
228
  fontWeight,
254
229
  lineHeight,
230
+ textColumns,
255
231
  textDecoration,
256
232
  textTransform,
257
233
  letterSpacing,
@@ -263,6 +239,23 @@ export function useBlockSettings( name, parentLayout ) {
263
239
  minHeight,
264
240
  layout,
265
241
  parentLayout,
242
+ borderColor,
243
+ borderRadius,
244
+ borderStyle,
245
+ borderWidth,
246
+ customColorsEnabled,
247
+ customColors,
248
+ themeColors,
249
+ defaultColors,
250
+ defaultPalette,
251
+ userGradientPalette,
252
+ themeGradientPalette,
253
+ defaultGradientPalette,
254
+ defaultGradients,
255
+ areCustomGradientsEnabled,
256
+ isBackgroundEnabled,
257
+ isLinkEnabled,
258
+ isTextEnabled,
266
259
  ] );
267
260
 
268
261
  return useSettingsForBlockElement( rawSettings, name );
@@ -32,8 +32,10 @@ export default {
32
32
  inspectorControls: function DefaultLayoutInspectorControls( {
33
33
  layout,
34
34
  onChange,
35
+ layoutBlockSupport = {},
35
36
  } ) {
36
37
  const { wideSize, contentSize, justifyContent = 'center' } = layout;
38
+ const { allowJustification = true } = layoutBlockSupport;
37
39
  const onJustificationChange = ( value ) => {
38
40
  onChange( {
39
41
  ...layout,
@@ -117,23 +119,27 @@ export default {
117
119
  'Customize the width for all elements that are assigned to the center or wide columns.'
118
120
  ) }
119
121
  </p>
120
- <ToggleGroupControl
121
- __nextHasNoMarginBottom
122
- label={ __( 'Justification' ) }
123
- value={ justifyContent }
124
- onChange={ onJustificationChange }
125
- >
126
- { justificationOptions.map( ( { value, icon, label } ) => {
127
- return (
128
- <ToggleGroupControlOptionIcon
129
- key={ value }
130
- value={ value }
131
- icon={ icon }
132
- label={ label }
133
- />
134
- );
135
- } ) }
136
- </ToggleGroupControl>
122
+ { allowJustification && (
123
+ <ToggleGroupControl
124
+ __nextHasNoMarginBottom
125
+ label={ __( 'Justification' ) }
126
+ value={ justifyContent }
127
+ onChange={ onJustificationChange }
128
+ >
129
+ { justificationOptions.map(
130
+ ( { value, icon, label } ) => {
131
+ return (
132
+ <ToggleGroupControlOptionIcon
133
+ key={ value }
134
+ value={ value }
135
+ icon={ icon }
136
+ label={ label }
137
+ />
138
+ );
139
+ }
140
+ ) }
141
+ </ToggleGroupControl>
142
+ ) }
137
143
  </>
138
144
  );
139
145
  },