@wordpress/block-editor 15.22.1-next.v.202606191442.0 → 15.23.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 (383) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/README.md +2 -2
  3. package/build/components/block-editing-mode/index.cjs +13 -7
  4. package/build/components/block-editing-mode/index.cjs.map +2 -2
  5. package/build/components/block-inspector/index.cjs +50 -51
  6. package/build/components/block-inspector/index.cjs.map +2 -2
  7. package/build/components/block-rename/modal.cjs +0 -1
  8. package/build/components/block-rename/modal.cjs.map +2 -2
  9. package/build/components/block-toolbar/block-toolbar-icon.cjs +14 -6
  10. package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
  11. package/build/components/colors-gradients/control.cjs +25 -14
  12. package/build/components/colors-gradients/control.cjs.map +2 -2
  13. package/build/components/colors-gradients/dropdown.cjs +4 -1
  14. package/build/components/colors-gradients/dropdown.cjs.map +3 -3
  15. package/build/components/contrast-checker/index.cjs +22 -4
  16. package/build/components/contrast-checker/index.cjs.map +2 -2
  17. package/build/components/date-format-picker/index.cjs +0 -1
  18. package/build/components/date-format-picker/index.cjs.map +2 -2
  19. package/build/components/global-styles/background-panel.cjs +153 -25
  20. package/build/components/global-styles/background-panel.cjs.map +3 -3
  21. package/build/components/global-styles/color-gradient-dropdown-item.cjs +227 -0
  22. package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +7 -0
  23. package/build/components/global-styles/color-panel.cjs +98 -375
  24. package/build/components/global-styles/color-panel.cjs.map +3 -3
  25. package/build/components/global-styles/dimensions-panel.cjs +0 -3
  26. package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
  27. package/build/components/global-styles/hooks.cjs +34 -0
  28. package/build/components/global-styles/hooks.cjs.map +2 -2
  29. package/build/components/global-styles/typography-panel.cjs +82 -10
  30. package/build/components/global-styles/typography-panel.cjs.map +3 -3
  31. package/build/components/inspector-controls/groups.cjs +2 -0
  32. package/build/components/inspector-controls/groups.cjs.map +2 -2
  33. package/build/components/inspector-controls-tabs/styles-tab.cjs +75 -31
  34. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  35. package/build/components/link-control/index.cjs +1 -2
  36. package/build/components/link-control/index.cjs.map +2 -2
  37. package/build/components/list-view/block-select-button.cjs +1 -10
  38. package/build/components/list-view/block-select-button.cjs.map +3 -3
  39. package/build/components/provider/use-block-sync.cjs +3 -1
  40. package/build/components/provider/use-block-sync.cjs.map +2 -2
  41. package/build/components/url-popover/image-url-input-ui.cjs +0 -2
  42. package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
  43. package/build/components/use-block-display-information/index.cjs +10 -3
  44. package/build/components/use-block-display-information/index.cjs.map +2 -2
  45. package/build/components/use-resize-canvas/index.cjs +16 -53
  46. package/build/components/use-resize-canvas/index.cjs.map +3 -3
  47. package/build/hooks/anchor.cjs +0 -1
  48. package/build/hooks/anchor.cjs.map +2 -2
  49. package/build/hooks/background.cjs +124 -75
  50. package/build/hooks/background.cjs.map +3 -3
  51. package/build/hooks/color.cjs +0 -162
  52. package/build/hooks/color.cjs.map +3 -3
  53. package/build/hooks/contrast-checker.cjs +31 -28
  54. package/build/hooks/contrast-checker.cjs.map +3 -3
  55. package/build/hooks/custom-class-name.cjs +0 -1
  56. package/build/hooks/custom-class-name.cjs.map +2 -2
  57. package/build/hooks/elements.cjs +142 -0
  58. package/build/hooks/elements.cjs.map +7 -0
  59. package/build/hooks/grid-visualizer.cjs +21 -11
  60. package/build/hooks/grid-visualizer.cjs.map +2 -2
  61. package/build/hooks/layout-child.cjs +38 -8
  62. package/build/hooks/layout-child.cjs.map +2 -2
  63. package/build/hooks/layout.cjs +6 -3
  64. package/build/hooks/layout.cjs.map +2 -2
  65. package/build/hooks/states.cjs +15 -23
  66. package/build/hooks/states.cjs.map +2 -2
  67. package/build/hooks/style.cjs +8 -4
  68. package/build/hooks/style.cjs.map +2 -2
  69. package/build/hooks/typography.cjs +62 -10
  70. package/build/hooks/typography.cjs.map +3 -3
  71. package/build/layouts/flex.cjs +99 -6
  72. package/build/layouts/flex.cjs.map +2 -2
  73. package/build/private-apis.cjs +0 -1
  74. package/build/private-apis.cjs.map +2 -2
  75. package/build/store/private-actions.cjs +16 -0
  76. package/build/store/private-actions.cjs.map +2 -2
  77. package/build/store/private-keys.cjs +0 -3
  78. package/build/store/private-keys.cjs.map +2 -2
  79. package/build/store/private-selectors.cjs +24 -6
  80. package/build/store/private-selectors.cjs.map +2 -2
  81. package/build/store/reducer.cjs +19 -3
  82. package/build/store/reducer.cjs.map +2 -2
  83. package/build/utils/block-bindings.cjs +9 -9
  84. package/build/utils/block-bindings.cjs.map +3 -3
  85. package/build/utils/color-values.cjs +10 -1
  86. package/build/utils/color-values.cjs.map +3 -3
  87. package/build/utils/dom.cjs +2 -5
  88. package/build/utils/dom.cjs.map +3 -3
  89. package/build/utils/fit-text-frontend.cjs +6 -2
  90. package/build/utils/fit-text-frontend.cjs.map +3 -3
  91. package/build/utils/fit-text-utils.cjs +1 -1
  92. package/build/utils/fit-text-utils.cjs.map +3 -3
  93. package/build/utils/format-font-style.cjs +1 -1
  94. package/build/utils/format-font-style.cjs.map +3 -3
  95. package/build/utils/format-font-weight.cjs +1 -1
  96. package/build/utils/format-font-weight.cjs.map +3 -3
  97. package/build/utils/get-editor-region.cjs +4 -2
  98. package/build/utils/get-editor-region.cjs.map +3 -3
  99. package/build/utils/get-font-styles-and-weights.cjs +8 -12
  100. package/build/utils/get-font-styles-and-weights.cjs.map +3 -3
  101. package/build/utils/get-px-from-css-unit.cjs +1 -1
  102. package/build/utils/get-px-from-css-unit.cjs.map +1 -1
  103. package/build/utils/index.cjs +1 -1
  104. package/build/utils/index.cjs.map +1 -1
  105. package/build/utils/math.cjs +1 -1
  106. package/build/utils/math.cjs.map +3 -3
  107. package/build/utils/object.cjs +8 -8
  108. package/build/utils/object.cjs.map +3 -3
  109. package/build/utils/order-inserter-block-items.cjs +1 -1
  110. package/build/utils/order-inserter-block-items.cjs.map +3 -3
  111. package/build/utils/pasting.cjs +4 -2
  112. package/build/utils/pasting.cjs.map +3 -3
  113. package/build/utils/selection.cjs +2 -1
  114. package/build/utils/selection.cjs.map +3 -3
  115. package/build/utils/sorting.cjs +9 -3
  116. package/build/utils/sorting.cjs.map +3 -3
  117. package/build/utils/transform-styles/index.cjs +3 -2
  118. package/build/utils/transform-styles/index.cjs.map +3 -3
  119. package/build/utils/transform-styles/postcss-urlrebase.d.cjs +2 -0
  120. package/build/utils/transform-styles/postcss-urlrebase.d.cjs.map +7 -0
  121. package/build/utils/transform-styles/types.cjs +19 -0
  122. package/build/utils/transform-styles/types.cjs.map +7 -0
  123. package/build/utils/types.cjs +19 -0
  124. package/build/utils/types.cjs.map +7 -0
  125. package/build-module/components/block-editing-mode/index.mjs +14 -8
  126. package/build-module/components/block-editing-mode/index.mjs.map +2 -2
  127. package/build-module/components/block-inspector/index.mjs +50 -51
  128. package/build-module/components/block-inspector/index.mjs.map +2 -2
  129. package/build-module/components/block-rename/modal.mjs +0 -1
  130. package/build-module/components/block-rename/modal.mjs.map +2 -2
  131. package/build-module/components/block-toolbar/block-toolbar-icon.mjs +14 -6
  132. package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
  133. package/build-module/components/colors-gradients/control.mjs +27 -15
  134. package/build-module/components/colors-gradients/control.mjs.map +2 -2
  135. package/build-module/components/colors-gradients/dropdown.mjs +4 -1
  136. package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
  137. package/build-module/components/contrast-checker/index.mjs +18 -4
  138. package/build-module/components/contrast-checker/index.mjs.map +2 -2
  139. package/build-module/components/date-format-picker/index.mjs +0 -1
  140. package/build-module/components/date-format-picker/index.mjs.map +2 -2
  141. package/build-module/components/global-styles/background-panel.mjs +155 -27
  142. package/build-module/components/global-styles/background-panel.mjs.map +2 -2
  143. package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +207 -0
  144. package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +7 -0
  145. package/build-module/components/global-styles/color-panel.mjs +106 -387
  146. package/build-module/components/global-styles/color-panel.mjs.map +3 -3
  147. package/build-module/components/global-styles/dimensions-panel.mjs +0 -3
  148. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  149. package/build-module/components/global-styles/hooks.mjs +33 -0
  150. package/build-module/components/global-styles/hooks.mjs.map +2 -2
  151. package/build-module/components/global-styles/typography-panel.mjs +84 -10
  152. package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
  153. package/build-module/components/inspector-controls/groups.mjs +2 -0
  154. package/build-module/components/inspector-controls/groups.mjs.map +2 -2
  155. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +75 -31
  156. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  157. package/build-module/components/link-control/index.mjs +1 -2
  158. package/build-module/components/link-control/index.mjs.map +2 -2
  159. package/build-module/components/list-view/block-select-button.mjs +2 -17
  160. package/build-module/components/list-view/block-select-button.mjs.map +2 -2
  161. package/build-module/components/provider/use-block-sync.mjs +3 -1
  162. package/build-module/components/provider/use-block-sync.mjs.map +2 -2
  163. package/build-module/components/url-popover/image-url-input-ui.mjs +0 -2
  164. package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
  165. package/build-module/components/use-block-display-information/index.mjs +10 -3
  166. package/build-module/components/use-block-display-information/index.mjs.map +2 -2
  167. package/build-module/components/use-resize-canvas/index.mjs +6 -53
  168. package/build-module/components/use-resize-canvas/index.mjs.map +2 -2
  169. package/build-module/hooks/anchor.mjs +0 -1
  170. package/build-module/hooks/anchor.mjs.map +2 -2
  171. package/build-module/hooks/background.mjs +123 -75
  172. package/build-module/hooks/background.mjs.map +2 -2
  173. package/build-module/hooks/color.mjs +2 -175
  174. package/build-module/hooks/color.mjs.map +2 -2
  175. package/build-module/hooks/contrast-checker.mjs +32 -19
  176. package/build-module/hooks/contrast-checker.mjs.map +2 -2
  177. package/build-module/hooks/custom-class-name.mjs +0 -1
  178. package/build-module/hooks/custom-class-name.mjs.map +2 -2
  179. package/build-module/hooks/elements.mjs +115 -0
  180. package/build-module/hooks/elements.mjs.map +7 -0
  181. package/build-module/hooks/grid-visualizer.mjs +21 -11
  182. package/build-module/hooks/grid-visualizer.mjs.map +2 -2
  183. package/build-module/hooks/layout-child.mjs +41 -8
  184. package/build-module/hooks/layout-child.mjs.map +2 -2
  185. package/build-module/hooks/layout.mjs +6 -3
  186. package/build-module/hooks/layout.mjs.map +2 -2
  187. package/build-module/hooks/states.mjs +15 -23
  188. package/build-module/hooks/states.mjs.map +2 -2
  189. package/build-module/hooks/style.mjs +9 -5
  190. package/build-module/hooks/style.mjs.map +2 -2
  191. package/build-module/hooks/typography.mjs +62 -10
  192. package/build-module/hooks/typography.mjs.map +2 -2
  193. package/build-module/layouts/flex.mjs +105 -7
  194. package/build-module/layouts/flex.mjs.map +2 -2
  195. package/build-module/private-apis.mjs +0 -2
  196. package/build-module/private-apis.mjs.map +2 -2
  197. package/build-module/store/private-actions.mjs +14 -0
  198. package/build-module/store/private-actions.mjs.map +2 -2
  199. package/build-module/store/private-keys.mjs +0 -2
  200. package/build-module/store/private-keys.mjs.map +2 -2
  201. package/build-module/store/private-selectors.mjs +22 -6
  202. package/build-module/store/private-selectors.mjs.map +2 -2
  203. package/build-module/store/reducer.mjs +17 -3
  204. package/build-module/store/reducer.mjs.map +2 -2
  205. package/build-module/utils/block-bindings.mjs +9 -9
  206. package/build-module/utils/block-bindings.mjs.map +3 -3
  207. package/build-module/utils/color-values.mjs +9 -1
  208. package/build-module/utils/color-values.mjs.map +3 -3
  209. package/build-module/utils/dom.mjs +2 -5
  210. package/build-module/utils/dom.mjs.map +3 -3
  211. package/build-module/utils/fit-text-frontend.mjs +6 -2
  212. package/build-module/utils/fit-text-frontend.mjs.map +3 -3
  213. package/build-module/utils/fit-text-utils.mjs +1 -1
  214. package/build-module/utils/fit-text-utils.mjs.map +3 -3
  215. package/build-module/utils/format-font-style.mjs +1 -1
  216. package/build-module/utils/format-font-style.mjs.map +3 -3
  217. package/build-module/utils/format-font-weight.mjs +1 -1
  218. package/build-module/utils/format-font-weight.mjs.map +3 -3
  219. package/build-module/utils/get-editor-region.mjs +4 -2
  220. package/build-module/utils/get-editor-region.mjs.map +3 -3
  221. package/build-module/utils/get-font-styles-and-weights.mjs +8 -12
  222. package/build-module/utils/get-font-styles-and-weights.mjs.map +3 -3
  223. package/build-module/utils/get-px-from-css-unit.mjs +1 -1
  224. package/build-module/utils/get-px-from-css-unit.mjs.map +1 -1
  225. package/build-module/utils/index.mjs +1 -1
  226. package/build-module/utils/index.mjs.map +1 -1
  227. package/build-module/utils/math.mjs +1 -1
  228. package/build-module/utils/math.mjs.map +3 -3
  229. package/build-module/utils/object.mjs +8 -8
  230. package/build-module/utils/object.mjs.map +3 -3
  231. package/build-module/utils/order-inserter-block-items.mjs +1 -1
  232. package/build-module/utils/order-inserter-block-items.mjs.map +3 -3
  233. package/build-module/utils/pasting.mjs +4 -2
  234. package/build-module/utils/pasting.mjs.map +3 -3
  235. package/build-module/utils/selection.mjs +2 -1
  236. package/build-module/utils/selection.mjs.map +3 -3
  237. package/build-module/utils/sorting.mjs +9 -3
  238. package/build-module/utils/sorting.mjs.map +3 -3
  239. package/build-module/utils/transform-styles/index.mjs +3 -2
  240. package/build-module/utils/transform-styles/index.mjs.map +3 -3
  241. package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs +1 -0
  242. package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs.map +7 -0
  243. package/build-module/utils/transform-styles/types.mjs +1 -0
  244. package/build-module/utils/transform-styles/types.mjs.map +7 -0
  245. package/build-module/utils/types.mjs +1 -0
  246. package/build-module/utils/types.mjs.map +7 -0
  247. package/build-style/content-rtl.css +2 -0
  248. package/build-style/content.css +2 -0
  249. package/build-style/style-rtl.css +34 -41
  250. package/build-style/style.css +34 -41
  251. package/build-types/utils/block-bindings.d.ts +27 -0
  252. package/build-types/utils/block-bindings.d.ts.map +1 -0
  253. package/build-types/utils/color-values.d.ts +40 -0
  254. package/build-types/utils/color-values.d.ts.map +1 -0
  255. package/build-types/utils/dom.d.ts +19 -19
  256. package/build-types/utils/dom.d.ts.map +1 -1
  257. package/build-types/utils/fit-text-frontend.d.ts +7 -0
  258. package/build-types/utils/fit-text-frontend.d.ts.map +1 -0
  259. package/build-types/utils/fit-text-utils.d.ts +15 -0
  260. package/build-types/utils/fit-text-utils.d.ts.map +1 -0
  261. package/build-types/utils/format-font-style.d.ts +12 -0
  262. package/build-types/utils/format-font-style.d.ts.map +1 -0
  263. package/build-types/utils/format-font-weight.d.ts +12 -0
  264. package/build-types/utils/format-font-weight.d.ts.map +1 -0
  265. package/build-types/utils/get-editor-region.d.ts +9 -0
  266. package/build-types/utils/get-editor-region.d.ts.map +1 -0
  267. package/build-types/utils/get-font-styles-and-weights.d.ts +16 -0
  268. package/build-types/utils/get-font-styles-and-weights.d.ts.map +1 -0
  269. package/build-types/utils/get-px-from-css-unit.d.ts +10 -0
  270. package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -0
  271. package/build-types/utils/index.d.ts +3 -0
  272. package/build-types/utils/index.d.ts.map +1 -0
  273. package/build-types/utils/math.d.ts +61 -0
  274. package/build-types/utils/math.d.ts.map +1 -0
  275. package/build-types/utils/object.d.ts +39 -0
  276. package/build-types/utils/object.d.ts.map +1 -0
  277. package/build-types/utils/order-inserter-block-items.d.ts +13 -0
  278. package/build-types/utils/order-inserter-block-items.d.ts.map +1 -0
  279. package/build-types/utils/pasting.d.ts +28 -0
  280. package/build-types/utils/pasting.d.ts.map +1 -0
  281. package/build-types/utils/selection.d.ts +21 -0
  282. package/build-types/utils/selection.d.ts.map +1 -0
  283. package/build-types/utils/sorting.d.ts +17 -0
  284. package/build-types/utils/sorting.d.ts.map +1 -0
  285. package/build-types/utils/transform-styles/index.d.ts +15 -0
  286. package/build-types/utils/transform-styles/index.d.ts.map +1 -0
  287. package/build-types/utils/transform-styles/types.d.ts +13 -0
  288. package/build-types/utils/transform-styles/types.d.ts.map +1 -0
  289. package/build-types/utils/types.d.ts +28 -0
  290. package/build-types/utils/types.d.ts.map +1 -0
  291. package/package.json +40 -39
  292. package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -0
  293. package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -0
  294. package/src/components/block-editing-mode/index.js +17 -9
  295. package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -0
  296. package/src/components/block-inspector/index.js +43 -53
  297. package/src/components/block-rename/modal.js +0 -1
  298. package/src/components/block-toolbar/block-toolbar-icon.js +22 -6
  299. package/src/components/block-toolbar/test/block-toolbar-icon.js +99 -0
  300. package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +4 -0
  301. package/src/components/colors-gradients/control.js +29 -12
  302. package/src/components/colors-gradients/dropdown.js +4 -1
  303. package/src/components/colors-gradients/style.scss +39 -2
  304. package/src/components/contrast-checker/README.md +9 -0
  305. package/src/components/contrast-checker/index.js +42 -3
  306. package/src/components/date-format-picker/index.js +0 -1
  307. package/src/components/default-block-appender/content.scss +3 -0
  308. package/src/components/global-styles/background-panel.js +201 -34
  309. package/src/components/global-styles/color-gradient-dropdown-item.js +258 -0
  310. package/src/components/global-styles/color-panel.js +125 -487
  311. package/src/components/global-styles/dimensions-panel.js +0 -3
  312. package/src/components/global-styles/hooks.js +45 -0
  313. package/src/components/global-styles/test/background-panel.js +56 -0
  314. package/src/components/global-styles/test/color-panel.js +172 -118
  315. package/src/components/global-styles/test/typography-panel.js +167 -0
  316. package/src/components/global-styles/typography-panel.js +100 -11
  317. package/src/components/inspector-controls/README.md +0 -2
  318. package/src/components/inspector-controls/groups.js +2 -0
  319. package/src/components/inspector-controls-tabs/styles-tab.js +74 -28
  320. package/src/components/link-control/index.js +0 -1
  321. package/src/components/link-control/test/index.js +2 -3
  322. package/src/components/list-view/block-select-button.js +2 -17
  323. package/src/components/provider/use-block-sync.js +3 -1
  324. package/src/components/rich-text/content.scss +2 -0
  325. package/src/components/url-popover/image-url-input-ui.js +0 -2
  326. package/src/components/use-block-display-information/index.js +15 -2
  327. package/src/components/use-block-display-information/test/index.js +140 -0
  328. package/src/components/use-resize-canvas/index.js +10 -71
  329. package/src/hooks/anchor.js +0 -1
  330. package/src/hooks/background.js +210 -133
  331. package/src/hooks/background.scss +0 -35
  332. package/src/hooks/color.js +2 -205
  333. package/src/hooks/color.scss +3 -9
  334. package/src/hooks/contrast-checker.js +60 -17
  335. package/src/hooks/custom-class-name.js +0 -1
  336. package/src/hooks/elements.js +140 -0
  337. package/src/hooks/elements.scss +8 -0
  338. package/src/hooks/grid-visualizer.js +59 -45
  339. package/src/hooks/layout-child.js +51 -12
  340. package/src/hooks/layout.js +6 -3
  341. package/src/hooks/states.js +32 -28
  342. package/src/hooks/style.js +11 -7
  343. package/src/hooks/test/background.js +59 -0
  344. package/src/hooks/test/block-style-state.js +14 -14
  345. package/src/hooks/test/layout.js +6 -6
  346. package/src/hooks/test/style.js +8 -8
  347. package/src/hooks/typography.js +70 -6
  348. package/src/layouts/flex.js +118 -15
  349. package/src/private-apis.js +0 -2
  350. package/src/store/private-actions.js +31 -0
  351. package/src/store/private-keys.js +0 -1
  352. package/src/store/private-selectors.js +43 -7
  353. package/src/store/reducer.js +37 -2
  354. package/src/store/test/private-selectors.js +39 -14
  355. package/src/store/test/reducer.js +91 -12
  356. package/src/style.scss +1 -0
  357. package/src/utils/block-bindings.ts +51 -0
  358. package/src/utils/color-values.ts +63 -0
  359. package/src/utils/{dom.js → dom.ts} +27 -27
  360. package/src/utils/{fit-text-frontend.js → fit-text-frontend.ts} +12 -4
  361. package/src/utils/{fit-text-utils.js → fit-text-utils.ts} +15 -7
  362. package/src/utils/{format-font-style.js → format-font-style.ts} +10 -3
  363. package/src/utils/{format-font-weight.js → format-font-weight.ts} +10 -3
  364. package/src/utils/{get-editor-region.js → get-editor-region.ts} +10 -6
  365. package/src/utils/{get-font-styles-and-weights.js → get-font-styles-and-weights.ts} +21 -17
  366. package/src/utils/{math.js → math.ts} +37 -30
  367. package/src/utils/object.ts +89 -0
  368. package/src/utils/{order-inserter-block-items.js → order-inserter-block-items.ts} +8 -5
  369. package/src/utils/{pasting.js → pasting.ts} +18 -11
  370. package/src/utils/{selection.js → selection.ts} +11 -4
  371. package/src/utils/sorting.ts +81 -0
  372. package/src/utils/test/color-values.js +44 -1
  373. package/src/utils/transform-styles/{index.js → index.ts} +25 -25
  374. package/src/utils/transform-styles/postcss-urlrebase.d.ts +15 -0
  375. package/src/utils/transform-styles/types.ts +13 -0
  376. package/src/utils/types.ts +29 -0
  377. package/src/components/use-resize-canvas/README.md +0 -37
  378. package/src/utils/block-bindings.js +0 -46
  379. package/src/utils/color-values.js +0 -28
  380. package/src/utils/object.js +0 -67
  381. package/src/utils/sorting.js +0 -54
  382. /package/src/utils/{get-px-from-css-unit.js → get-px-from-css-unit.ts} +0 -0
  383. /package/src/utils/{index.js → index.ts} +0 -0
@@ -68,14 +68,23 @@ $swatch-gap: 12px;
68
68
  background: linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%);
69
69
  }
70
70
 
71
+ // Space the in-popover contrast notice away from the color palette below it.
72
+ .block-editor-panel-color-gradient-settings__contrast-notice {
73
+ margin-bottom: $grid-unit-20;
74
+ }
75
+
71
76
  /**
72
77
  * The following styles replicate the separated border of the
73
78
  * `ItemGroup` component but allows for hidden items. This is because
74
79
  * to maintain the order of `ToolsPanel` controls, each `ToolsPanelItem`
75
80
  * must at least render a placeholder which would otherwise interfere
76
81
  * with the `:last-child` styles.
82
+ *
83
+ * Applied via the shared `block-editor-color-gradient-item` class on
84
+ * color/gradient dropdown items across the Color, Background, and
85
+ * Typography panels.
77
86
  */
78
- .block-editor-tools-panel-color-gradient-settings__item {
87
+ .block-editor-color-gradient-item {
79
88
  padding: 0;
80
89
  max-width: 100%;
81
90
  position: relative;
@@ -87,7 +96,6 @@ $swatch-gap: 12px;
87
96
 
88
97
  // Identify the first visible instance as placeholder items will not have this class.
89
98
  &:nth-child(1 of &) {
90
- margin-top: $grid-unit-30;
91
99
  border-top-left-radius: $radius-small;
92
100
  border-top-right-radius: $radius-small;
93
101
  border-top: 1px solid $gray-300;
@@ -127,6 +135,12 @@ $swatch-gap: 12px;
127
135
  text-overflow: ellipsis;
128
136
  max-width: calc(100% - ($button-size-next-default-40px + $grid-unit-05));
129
137
  }
138
+
139
+ // Reserve extra space for the always-visible contrast warning icon,
140
+ // which sits alongside the hover-revealed reset button.
141
+ > button.has-contrast-warning .block-editor-panel-color-gradient-settings__color-name {
142
+ max-width: calc(100% - ($button-size-next-default-40px + $button-size-small + $grid-unit));
143
+ }
130
144
  }
131
145
 
132
146
  .block-editor-panel-color-gradient-settings__dropdown {
@@ -161,4 +175,27 @@ $swatch-gap: 12px;
161
175
  // Show reset button on devices that do not support hover.
162
176
  opacity: 1;
163
177
  }
178
+
179
+ // While a contrast warning is in effect the warning icon occupies the
180
+ // far-right slot, so the reset button shifts left to sit beside it.
181
+ .block-editor-panel-color-gradient-settings__dropdown.has-contrast-warning + & {
182
+ right: $button-size-small + $grid-unit-05;
183
+ }
184
+ }
185
+
186
+ // Icon-only "Low contrast" warning shown to the right of the color
187
+ // control toggle whenever the selection has insufficient contrast.
188
+ // Unlike the reset button it stays visible without hover. It is not a
189
+ // menu; activating it opens the color picker popover (where the full
190
+ // warning notice lives), so it doubles as a shortcut to the fix. The
191
+ // accessible name and hover/focus tooltip come from the button label.
192
+ .block-editor-panel-color-gradient-settings__contrast-warning {
193
+ position: absolute;
194
+ right: 0;
195
+ top: $grid-unit;
196
+ margin: auto $grid-unit auto;
197
+
198
+ &.block-editor-panel-color-gradient-settings__contrast-warning {
199
+ border-radius: $radius-small;
200
+ }
164
201
  }
@@ -69,3 +69,12 @@ The text color to check the contrast of the background against.
69
69
 
70
70
  - Type: `String`
71
71
  - Required: No
72
+
73
+ #### messageOverride
74
+
75
+ Custom warning message to display (and announce) instead of the default
76
+ contrast guidance when the color combination has insufficient contrast. Useful
77
+ for providing panel-specific, more concise copy.
78
+
79
+ - Type: `String`
80
+ - Required: No
@@ -14,7 +14,28 @@ import { speak } from '@wordpress/a11y';
14
14
 
15
15
  extend( [ namesPlugin, a11yPlugin ] );
16
16
 
17
- function ContrastChecker( {
17
+ /**
18
+ * Computes a contrast warning for the given color combination, if any.
19
+ *
20
+ * Shared between the `ContrastChecker` component and the block inspector
21
+ * contrast warning indicators, which surface the result without rendering
22
+ * a notice.
23
+ *
24
+ * @param {Object} props
25
+ * @param {string} [props.backgroundColor] Background color.
26
+ * @param {string} [props.fallbackBackgroundColor] Fallback background color.
27
+ * @param {string} [props.fallbackTextColor] Fallback text color.
28
+ * @param {string} [props.fallbackLinkColor] Fallback link color.
29
+ * @param {number} [props.fontSize] Font size value in pixels.
30
+ * @param {boolean} [props.isLargeText] Whether the text is large.
31
+ * @param {string} [props.textColor] Text color.
32
+ * @param {string} [props.linkColor] Link color.
33
+ * @param {string} [props.messageOverride] Caller-provided copy used in place of the generic guidance.
34
+ * @param {boolean} [props.enableAlphaChecker] Whether to warn about transparent text.
35
+ *
36
+ * @return {?Object} `{ message, speakMessage }` when contrast is insufficient, otherwise `null`.
37
+ */
38
+ export function getContrastWarning( {
18
39
  backgroundColor,
19
40
  fallbackBackgroundColor,
20
41
  fallbackTextColor,
@@ -23,6 +44,7 @@ function ContrastChecker( {
23
44
  isLargeText,
24
45
  textColor,
25
46
  linkColor,
47
+ messageOverride,
26
48
  enableAlphaChecker = false,
27
49
  } ) {
28
50
  const currentBackgroundColor = backgroundColor || fallbackBackgroundColor;
@@ -81,6 +103,13 @@ function ContrastChecker( {
81
103
  if ( backgroundColorHasTransparency || textHasTransparency ) {
82
104
  continue;
83
105
  }
106
+ // A caller can provide panel-specific copy that is clearer and
107
+ // more concise than the generic brighter/darker guidance.
108
+ if ( messageOverride ) {
109
+ message = messageOverride;
110
+ speakMessage = messageOverride;
111
+ break;
112
+ }
84
113
  message =
85
114
  backgroundColorBrightness < colordTextColor.brightness()
86
115
  ? sprintf(
@@ -119,11 +148,21 @@ function ContrastChecker( {
119
148
  return null;
120
149
  }
121
150
 
151
+ return { message, speakMessage };
152
+ }
153
+
154
+ function ContrastChecker( props ) {
155
+ const warning = getContrastWarning( props );
156
+
157
+ if ( ! warning ) {
158
+ return null;
159
+ }
160
+
122
161
  // Note: The `Notice` component can speak messages via its `spokenMessage`
123
162
  // prop, but the contrast checker requires granular control over when the
124
163
  // announcements are made. Notably, the message will be re-announced if a
125
164
  // new color combination is selected and the contrast is still insufficient.
126
- speak( speakMessage );
165
+ speak( warning.speakMessage );
127
166
 
128
167
  return (
129
168
  <div className="block-editor-contrast-checker">
@@ -132,7 +171,7 @@ function ContrastChecker( {
132
171
  status="warning"
133
172
  isDismissible={ false }
134
173
  >
135
- { message }
174
+ { warning.message }
136
175
  </Notice>
137
176
  </div>
138
177
  );
@@ -144,7 +144,6 @@ function NonDefaultControls( { format, onChange } ) {
144
144
  />
145
145
  { isCustom && (
146
146
  <TextControl
147
- __next40pxDefaultSize
148
147
  label={ __( 'Custom format' ) }
149
148
  hideLabelFromVision
150
149
  help={ createInterpolateElement(
@@ -30,6 +30,9 @@
30
30
  // Set the opacity of the initial block appender to the same as placeholder text in an empty Paragraph block.
31
31
  opacity: 0.62;
32
32
 
33
+ // Reset the text shadow from the global styles.
34
+ text-shadow: none;
35
+
33
36
  // The following prevents user agent styles from applying margins to the appender's inner paragraph.
34
37
  // This in turn prevents layout shift due to layout styles removing margins from first and last children.
35
38
  margin-block-start: 0;
@@ -7,19 +7,24 @@ import {
7
7
  } from '@wordpress/components';
8
8
  import { useCallback } from '@wordpress/element';
9
9
  import { __ } from '@wordpress/i18n';
10
- import { getValueFromVariable } from '@wordpress/global-styles-engine';
11
10
 
12
11
  /**
13
12
  * Internal dependencies
14
13
  */
15
14
  import BackgroundImageControl from '../background-image-control';
16
- import { ColorPanelDropdown } from './color-panel';
17
- import { useGradientsPerOrigin } from './hooks';
15
+ import ColorGradientDropdownItem from './color-gradient-dropdown-item';
16
+ import { useHasBackgroundColorPanel } from './color-panel';
17
+ import { useColorGradientSettings } from './hooks';
18
18
  import { useToolsPanelDropdownMenuProps } from './utils';
19
19
  import { setImmutably } from '../../utils/object';
20
+ import {
21
+ extractPresetSlug,
22
+ encodeColorValueWithPalette,
23
+ } from '../../utils/color-values';
20
24
 
21
25
  const DEFAULT_CONTROLS = {
22
26
  backgroundImage: true,
27
+ backgroundColor: true,
23
28
  gradient: true,
24
29
  };
25
30
 
@@ -39,12 +44,17 @@ export function useHasBackgroundControl( settings, feature ) {
39
44
  * `settings.background.backgroundSize` exists also,
40
45
  * but can only be used if settings?.background?.backgroundImage is `true`.
41
46
  *
47
+ * The panel is also shown when the block has color panel background
48
+ * support (`settings.color.background`), because background color and
49
+ * the legacy `color.gradient` control are rendered here.
50
+ *
42
51
  * @param {Object} settings Site settings
43
52
  * @return {boolean} Whether site settings has activated background panel.
44
53
  */
45
54
  export function useHasBackgroundPanel( settings ) {
55
+ const hasBackgroundColor = useHasBackgroundColorPanel( settings );
46
56
  const { backgroundImage, gradient } = settings?.background || {};
47
- return backgroundImage || gradient;
57
+ return backgroundImage || gradient || hasBackgroundColor;
48
58
  }
49
59
 
50
60
  /**
@@ -92,7 +102,30 @@ export function hasBackgroundGradientValue( style ) {
92
102
  );
93
103
  }
94
104
 
95
- function BackgroundToolsPanel( {
105
+ /**
106
+ * Checks if there is a current value for the background color (written to
107
+ * `color.background`).
108
+ *
109
+ * @param {Object} style Style attribute.
110
+ * @return {boolean} Whether the block has a background color value set.
111
+ */
112
+ export function hasBackgroundColorValue( style ) {
113
+ return !! style?.color?.background;
114
+ }
115
+
116
+ /**
117
+ * Checks if there is a current value in the legacy `color.gradient` location
118
+ * (used by blocks with color panel gradient support that haven't adopted the
119
+ * `background.gradient` block support).
120
+ *
121
+ * @param {Object} style Style attribute.
122
+ * @return {boolean} Whether the block has a legacy color gradient value set.
123
+ */
124
+ export function hasLegacyColorGradientValue( style ) {
125
+ return !! style?.color?.gradient;
126
+ }
127
+
128
+ export function BackgroundToolsPanel( {
96
129
  resetAllFilter,
97
130
  onChange,
98
131
  value,
@@ -128,23 +161,46 @@ export default function BackgroundImagePanel( {
128
161
  as: Wrapper = BackgroundToolsPanel,
129
162
  value,
130
163
  onChange,
131
- inheritedValue,
164
+ inheritedValue = value,
132
165
  settings,
133
166
  panelId,
134
167
  defaultControls = DEFAULT_CONTROLS,
135
168
  defaultValues = {},
136
169
  headerLabel = __( 'Background' ),
170
+ contrastWarning,
137
171
  } ) {
138
- const gradients = useGradientsPerOrigin( settings );
139
- const areCustomGradientsEnabled = settings?.color?.customGradient;
140
- const hasGradientColors = gradients.length > 0 || areCustomGradientsEnabled;
172
+ const {
173
+ colors,
174
+ gradients,
175
+ allColors,
176
+ areCustomSolidsEnabled,
177
+ areCustomGradientsEnabled,
178
+ hasSolidColors,
179
+ hasGradientColors,
180
+ decodeValue,
181
+ encodeGradientValue,
182
+ } = useColorGradientSettings( settings );
141
183
 
142
184
  const hasBackgroundGradientControl = useHasBackgroundControl(
143
185
  settings,
144
186
  'gradient'
145
187
  );
188
+ const hasColorPanelBackgroundSupport =
189
+ useHasBackgroundColorPanel( settings );
190
+ const showBackgroundColorControl =
191
+ hasColorPanelBackgroundSupport && hasSolidColors;
192
+ // New `background.gradient` block support — gradient lives under the
193
+ // `background` style path.
146
194
  const showBackgroundGradientControl =
147
195
  hasGradientColors && hasBackgroundGradientControl;
196
+ // Legacy `color.gradient` path — only rendered when the block has
197
+ // color panel background support and hasn't adopted the newer
198
+ // `background.gradient` support. Keeps the UI consistent for blocks
199
+ // that still write gradients to `color.gradient`.
200
+ const showLegacyColorGradientControl =
201
+ hasColorPanelBackgroundSupport &&
202
+ hasGradientColors &&
203
+ ! hasBackgroundGradientControl;
148
204
  const showBackgroundImageControl = useHasBackgroundControl(
149
205
  settings,
150
206
  'backgroundImage'
@@ -152,38 +208,38 @@ export default function BackgroundImagePanel( {
152
208
 
153
209
  const resetAllFilter = useCallback(
154
210
  ( previousValue ) => {
211
+ const clearsColorBackground = showBackgroundColorControl;
212
+ const clearsColorGradient =
213
+ hasBackgroundGradientControl || showLegacyColorGradientControl;
214
+ if ( ! clearsColorBackground && ! clearsColorGradient ) {
215
+ return { ...previousValue, background: {} };
216
+ }
155
217
  return {
156
218
  ...previousValue,
157
219
  background: {},
158
- color: hasBackgroundGradientControl
159
- ? {
160
- ...previousValue?.color,
161
- gradient: undefined,
162
- }
163
- : previousValue?.color,
220
+ color: {
221
+ ...previousValue?.color,
222
+ ...( clearsColorBackground && { background: undefined } ),
223
+ ...( clearsColorGradient && { gradient: undefined } ),
224
+ },
164
225
  };
165
226
  },
166
- [ hasBackgroundGradientControl ]
227
+ [
228
+ hasBackgroundGradientControl,
229
+ showBackgroundColorControl,
230
+ showLegacyColorGradientControl,
231
+ ]
167
232
  );
168
233
 
169
- if ( ! showBackgroundGradientControl && ! showBackgroundImageControl ) {
234
+ if (
235
+ ! showBackgroundImageControl &&
236
+ ! showBackgroundColorControl &&
237
+ ! showBackgroundGradientControl &&
238
+ ! showLegacyColorGradientControl
239
+ ) {
170
240
  return null;
171
241
  }
172
242
 
173
- const decodeValue = ( rawValue ) =>
174
- getValueFromVariable( { settings }, '', rawValue );
175
- const encodeGradientValue = ( gradientValue ) => {
176
- const allGradients = gradients.flatMap(
177
- ( { gradients: originGradients } ) => originGradients
178
- );
179
- const gradientObject = allGradients.find(
180
- ( { gradient } ) => gradient === gradientValue
181
- );
182
- return gradientObject
183
- ? 'var:preset|gradient|' + gradientObject.slug
184
- : gradientValue;
185
- };
186
-
187
243
  const resetBackground = () =>
188
244
  onChange(
189
245
  setImmutably(
@@ -203,6 +259,50 @@ export default function BackgroundImagePanel( {
203
259
  onChange( newValue );
204
260
  };
205
261
 
262
+ // Background color (written to `color.background`).
263
+ const backgroundColor = decodeValue( inheritedValue?.color?.background );
264
+ const userBackgroundColor = decodeValue( value?.color?.background );
265
+ const setBackgroundColor = ( newColor, newSlug ) => {
266
+ const newValue = setImmutably(
267
+ value,
268
+ [ 'color', 'background' ],
269
+ encodeColorValueWithPalette( allColors, newColor, newSlug )
270
+ );
271
+ // Legacy `color.gradient` is mutually exclusive with
272
+ // `color.background`. `background.gradient` is independent and
273
+ // should not be touched.
274
+ if ( showLegacyColorGradientControl ) {
275
+ newValue.color.gradient = undefined;
276
+ }
277
+ onChange( newValue );
278
+ };
279
+ const resetBackgroundColor = () => {
280
+ const newValue = setImmutably(
281
+ value,
282
+ [ 'color', 'background' ],
283
+ undefined
284
+ );
285
+ if ( showLegacyColorGradientControl ) {
286
+ newValue.color.gradient = undefined;
287
+ }
288
+ onChange( newValue );
289
+ };
290
+
291
+ // Legacy `color.gradient` setters.
292
+ const legacyColorGradient = decodeValue( inheritedValue?.color?.gradient );
293
+ const userLegacyColorGradient = decodeValue( value?.color?.gradient );
294
+ const setLegacyColorGradient = ( newGradient ) => {
295
+ const newValue = setImmutably(
296
+ value,
297
+ [ 'color', 'gradient' ],
298
+ encodeGradientValue( newGradient )
299
+ );
300
+ newValue.color.background = undefined;
301
+ onChange( newValue );
302
+ };
303
+ const resetLegacyColorGradient = () =>
304
+ onChange( setImmutably( value, [ 'color', 'gradient' ], undefined ) );
305
+
206
306
  // Get current gradient value, decoding preset slug references.
207
307
  // Fall back to color.gradient for legacy blocks that haven't migrated
208
308
  // to background.gradient yet (mirrors block inspector fallback in
@@ -237,7 +337,7 @@ export default function BackgroundImagePanel( {
237
337
  >
238
338
  { showBackgroundImageControl && (
239
339
  <ToolsPanelItem
240
- className="block-editor-background-panel__item"
340
+ className="block-editor-color-gradient-item"
241
341
  hasValue={ () => hasBackgroundImageValue( value ) }
242
342
  label={ __( 'Image' ) }
243
343
  onDeselect={ resetBackground }
@@ -254,9 +354,49 @@ export default function BackgroundImagePanel( {
254
354
  />
255
355
  </ToolsPanelItem>
256
356
  ) }
357
+ { showBackgroundColorControl && (
358
+ <ColorGradientDropdownItem
359
+ label={ __( 'Color' ) }
360
+ hasValue={ () => hasBackgroundColorValue( value ) }
361
+ resetValue={ resetBackgroundColor }
362
+ isShownByDefault={ defaultControls.backgroundColor }
363
+ indicators={ [ userBackgroundColor ?? backgroundColor ] }
364
+ contrastWarning={ contrastWarning }
365
+ tabs={ [
366
+ {
367
+ key: 'background',
368
+ label: __( 'Color' ),
369
+ inheritedValue:
370
+ userBackgroundColor ?? backgroundColor,
371
+ // Resolve the slug from the same source as the
372
+ // displayed value (user value first, then the
373
+ // inherited fallback). For a block instance the
374
+ // selection lives in `value` while `inheritedValue`
375
+ // only holds the global styles fallback, so reading
376
+ // the slug from `inheritedValue` alone would miss it
377
+ // and two same-hex presets would both appear selected.
378
+ inheritedSlug:
379
+ extractPresetSlug(
380
+ value?.color?.background,
381
+ 'color'
382
+ ) ??
383
+ extractPresetSlug(
384
+ inheritedValue?.color?.background,
385
+ 'color'
386
+ ),
387
+ setValue: setBackgroundColor,
388
+ userValue: userBackgroundColor,
389
+ },
390
+ ] }
391
+ colorGradientControlSettings={ {
392
+ colors,
393
+ disableCustomColors: ! areCustomSolidsEnabled,
394
+ } }
395
+ panelId={ panelId }
396
+ />
397
+ ) }
257
398
  { showBackgroundGradientControl && (
258
- <ColorPanelDropdown
259
- className="block-editor-background-panel__item"
399
+ <ColorGradientDropdownItem
260
400
  label={ __( 'Gradient' ) }
261
401
  hasValue={ () => hasBackgroundGradientValue( value ) }
262
402
  resetValue={ resetGradient }
@@ -280,6 +420,33 @@ export default function BackgroundImagePanel( {
280
420
  panelId={ panelId }
281
421
  />
282
422
  ) }
423
+ { showLegacyColorGradientControl && (
424
+ <ColorGradientDropdownItem
425
+ label={ __( 'Gradient' ) }
426
+ hasValue={ () => hasLegacyColorGradientValue( value ) }
427
+ resetValue={ resetLegacyColorGradient }
428
+ isShownByDefault={ defaultControls.gradient }
429
+ indicators={ [
430
+ userLegacyColorGradient ?? legacyColorGradient,
431
+ ] }
432
+ tabs={ [
433
+ {
434
+ key: 'gradient',
435
+ label: __( 'Gradient' ),
436
+ inheritedValue:
437
+ userLegacyColorGradient ?? legacyColorGradient,
438
+ setValue: setLegacyColorGradient,
439
+ userValue: userLegacyColorGradient,
440
+ isGradient: true,
441
+ },
442
+ ] }
443
+ colorGradientControlSettings={ {
444
+ gradients,
445
+ disableCustomGradients: ! areCustomGradientsEnabled,
446
+ } }
447
+ panelId={ panelId }
448
+ />
449
+ ) }
283
450
  </Wrapper>
284
451
  );
285
452
  }