@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
@@ -1,79 +1,18 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useEffect, useState } from '@wordpress/element';
4
+ import deprecated from '@wordpress/deprecated';
5
5
 
6
6
  /**
7
- * Function to resize the editor window.
7
+ * Previously returned inline styles that sized the editor canvas to emulate a
8
+ * device preview width. Device preview is now handled by the editor's resizable
9
+ * canvas, so this hook is a no-op kept for backward compatibility.
8
10
  *
9
- * @param {string} deviceType Used for determining the size of the container (e.g. Desktop, Tablet, Mobile)
10
- *
11
- * @return {Object} Inline styles to be added to resizable container.
11
+ * @deprecated
12
12
  */
13
- export default function useResizeCanvas( deviceType ) {
14
- const [ actualWidth, updateActualWidth ] = useState( window.innerWidth );
15
-
16
- useEffect( () => {
17
- if ( deviceType === 'Desktop' ) {
18
- return;
19
- }
20
-
21
- const resizeListener = () => updateActualWidth( window.innerWidth );
22
- window.addEventListener( 'resize', resizeListener );
23
-
24
- return () => {
25
- window.removeEventListener( 'resize', resizeListener );
26
- };
27
- }, [ deviceType ] );
28
-
29
- const getCanvasWidth = ( device ) => {
30
- let deviceWidth;
31
-
32
- /*
33
- * Matches the breakpoints in packages/base-styles/_breakpoints.scss,
34
- * and breakpoints in packages/compose/src/hooks/use-viewport-match/index.js.
35
- * minus 1 to trigger the media query for device preview.
36
- */
37
- switch ( device ) {
38
- case 'Tablet':
39
- deviceWidth = 782 - 1; // preview for useViewportMatch( 'medium', '<' )
40
- break;
41
- case 'Mobile':
42
- deviceWidth = 480 - 1; // preview for useViewportMatch( 'mobile', '<' )
43
- break;
44
- default:
45
- return null;
46
- }
47
-
48
- return deviceWidth < actualWidth ? deviceWidth : actualWidth;
49
- };
50
-
51
- const contentInlineStyles = ( device ) => {
52
- const height = device === 'Mobile' ? '768px' : '1024px';
53
- const marginVertical = '40px';
54
- const marginHorizontal = 'auto';
55
-
56
- switch ( device ) {
57
- case 'Tablet':
58
- case 'Mobile':
59
- return {
60
- width: getCanvasWidth( device ),
61
- // Keeping margin styles separate to avoid warnings
62
- // when those props get overridden in the iframe component
63
- marginTop: marginVertical,
64
- marginBottom: marginVertical,
65
- marginLeft: marginHorizontal,
66
- marginRight: marginHorizontal,
67
- height,
68
- overflowY: 'auto',
69
- };
70
- default:
71
- return {
72
- marginLeft: marginHorizontal,
73
- marginRight: marginHorizontal,
74
- };
75
- }
76
- };
77
-
78
- return contentInlineStyles( deviceType );
13
+ export default function useResizeCanvas() {
14
+ deprecated( 'wp.blockEditor.useResizeCanvas', {
15
+ since: '7.1',
16
+ hint: 'Device preview is now handled by the editor canvas. This hook no longer does anything.',
17
+ } );
79
18
  }
@@ -55,7 +55,6 @@ function BlockEditAnchorControlPure( { anchor, setAttributes } ) {
55
55
  return (
56
56
  <InspectorControls group="advanced">
57
57
  <TextControl
58
- __next40pxDefaultSize
59
58
  className="html-anchor-control"
60
59
  label={ __( 'HTML anchor' ) }
61
60
  help={
@@ -8,14 +8,16 @@ import clsx from 'clsx';
8
8
  */
9
9
  import { getBlockSupport } from '@wordpress/blocks';
10
10
  import { useSelect } from '@wordpress/data';
11
- import { useCallback } from '@wordpress/element';
11
+ import { __ } from '@wordpress/i18n';
12
12
 
13
13
  /**
14
14
  * Internal dependencies
15
15
  */
16
16
  import InspectorControls from '../components/inspector-controls';
17
17
  import { cleanEmptyObject } from './utils';
18
+ import { extractPresetSlug } from '../utils/color-values';
18
19
  import { store as blockEditorStore } from '../store';
20
+ import useBlockColorContrastWarning from './contrast-checker';
19
21
  import {
20
22
  default as StylesBackgroundPanel,
21
23
  useHasBackgroundPanel,
@@ -126,39 +128,41 @@ export function getBackgroundImageClasses( style ) {
126
128
  : '';
127
129
  }
128
130
 
129
- function BackgroundInspectorControl( {
130
- children,
131
- backgroundGradientSupported = false,
132
- } ) {
133
- const resetAllFilter = useCallback(
134
- ( attributes ) => {
135
- const updatedClassName = attributes.className?.includes(
136
- 'has-background'
137
- )
138
- ? attributes.className
139
- .split( ' ' )
140
- .filter( ( c ) => c !== 'has-background' )
141
- .join( ' ' ) || undefined
142
- : attributes.className;
143
- return {
144
- ...attributes,
145
- className: updatedClassName,
146
- style: cleanEmptyObject( {
147
- ...attributes.style,
148
- background: undefined,
149
- color: backgroundGradientSupported
150
- ? {
151
- ...attributes.style?.color,
152
- gradient: undefined,
153
- }
154
- : attributes.style?.color,
155
- } ),
156
- };
157
- },
158
- [ backgroundGradientSupported ]
159
- );
131
+ // Clears every control the Background panel owns: the background image,
132
+ // background color, and the gradient. The Background panel owns the gradient
133
+ // control for both the newer `background.gradient` support and the legacy
134
+ // `color.gradient` path, so "Reset all" clears the legacy value too,
135
+ // regardless of which path stored it.
136
+ export function backgroundResetAllFilter( attributes ) {
137
+ const updatedClassName = attributes.className?.includes( 'has-background' )
138
+ ? attributes.className
139
+ .split( ' ' )
140
+ .filter( ( c ) => c !== 'has-background' )
141
+ .join( ' ' ) || undefined
142
+ : attributes.className;
143
+ return {
144
+ ...attributes,
145
+ className: updatedClassName,
146
+ backgroundColor: undefined,
147
+ gradient: undefined,
148
+ style: cleanEmptyObject( {
149
+ ...attributes.style,
150
+ background: undefined,
151
+ color: {
152
+ ...attributes.style?.color,
153
+ background: undefined,
154
+ gradient: undefined,
155
+ },
156
+ } ),
157
+ };
158
+ }
159
+
160
+ function BackgroundInspectorControl( { children } ) {
160
161
  return (
161
- <InspectorControls group="background" resetAllFilter={ resetAllFilter }>
162
+ <InspectorControls
163
+ group="background"
164
+ resetAllFilter={ backgroundResetAllFilter }
165
+ >
162
166
  { children }
163
167
  </InspectorControls>
164
168
  );
@@ -169,122 +173,179 @@ export function BackgroundImagePanel( {
169
173
  name,
170
174
  setAttributes,
171
175
  settings,
176
+ // Allows rendering outside the `background` inspector group (e.g. section
177
+ // blocks direct-render this panel because their support fills are gated
178
+ // off by editing mode). Defaults to the slot-based wrapper.
179
+ asWrapper,
172
180
  } ) {
173
181
  const selectedState = useBlockStyleState();
174
- const { style, className, inheritedValue } = useSelect(
175
- ( select ) => {
176
- const { getBlockAttributes, getSettings } =
177
- select( blockEditorStore );
178
- const _settings = getSettings();
179
- const blockAttributes = getBlockAttributes( clientId );
180
- return {
181
- style: blockAttributes?.style,
182
- className: blockAttributes?.className,
183
- /*
184
- * To ensure we pass down the right inherited values:
185
- * @TODO 1. Pass inherited value down to all block style controls,
186
- * See: packages/block-editor/src/hooks/style.js
187
- * @TODO 2. Add support for block style variations,
188
- * See implementation: packages/block-editor/src/hooks/block-style-variation.js
189
- */
190
- inheritedValue:
191
- _settings[ globalStylesDataKey ]?.blocks?.[ name ],
192
- };
193
- },
194
- [ clientId, name ]
195
- );
182
+ const { style, className, backgroundColor, gradient, inheritedValue } =
183
+ useSelect(
184
+ ( select ) => {
185
+ const { getBlockAttributes, getSettings } =
186
+ select( blockEditorStore );
187
+ const _settings = getSettings();
188
+ const blockAttributes = getBlockAttributes( clientId );
189
+ return {
190
+ style: blockAttributes?.style,
191
+ className: blockAttributes?.className,
192
+ backgroundColor: blockAttributes?.backgroundColor,
193
+ gradient: blockAttributes?.gradient,
194
+ inheritedValue:
195
+ _settings[ globalStylesDataKey ]?.blocks?.[ name ],
196
+ };
197
+ },
198
+ [ clientId, name ]
199
+ );
196
200
 
197
201
  const backgroundGradientSupported = hasBackgroundSupport(
198
202
  name,
199
203
  'gradient'
200
204
  );
201
205
 
202
- // Must be declared before the early return to follow Rules of Hooks.
203
- // Passes backgroundGradientSupported so that "Reset All" also clears
204
- // the legacy color.gradient value when background.gradient is supported.
205
- const as = useCallback(
206
- ( { children } ) => (
207
- <BackgroundInspectorControl
208
- backgroundGradientSupported={ backgroundGradientSupported }
209
- >
210
- { children }
211
- </BackgroundInspectorControl>
206
+ const colorSupport = getBlockSupport( name, 'color' );
207
+ const hasColorBackgroundSupport =
208
+ colorSupport && colorSupport.background !== false;
209
+ const hasColorGradientSupport = !! colorSupport?.gradients;
210
+
211
+ const isStateSelected = ! isDefaultBlockStyleState( selectedState );
212
+
213
+ // Fold the backgroundColor / gradient attribute slugs back into the style
214
+ // object the panel consumes. When background.gradient is supported but not
215
+ // yet explicitly set, fall back to color.gradient for display.
216
+ const styleValue = {
217
+ ...style,
218
+ color: {
219
+ ...style?.color,
220
+ background: backgroundColor
221
+ ? 'var:preset|color|' + backgroundColor
222
+ : style?.color?.background,
223
+ gradient:
224
+ ! backgroundGradientSupported && gradient
225
+ ? 'var:preset|gradient|' + gradient
226
+ : style?.color?.gradient,
227
+ },
228
+ ...( backgroundGradientSupported && {
229
+ background: {
230
+ ...style?.background,
231
+ gradient: gradient
232
+ ? 'var:preset|gradient|' + gradient
233
+ : style?.background?.gradient ?? style?.color?.gradient,
234
+ },
235
+ } ),
236
+ };
237
+
238
+ // Skipped for gradients, which can't be reliably evaluated for contrast.
239
+ const enableContrastChecking =
240
+ ! isStateSelected &&
241
+ ! styleValue?.color?.gradient &&
242
+ ! styleValue?.background?.gradient &&
243
+ !! styleValue?.color?.background &&
244
+ ( settings?.color?.text || settings?.color?.link ) &&
245
+ false !== getBlockSupport( name, [ 'color', 'enableContrastChecker' ] );
246
+
247
+ const contrastWarning = useBlockColorContrastWarning( {
248
+ clientId,
249
+ name,
250
+ enabled: !! enableContrastChecking,
251
+ messageOverride: __(
252
+ 'This color combination has poor contrast. Consider increasing contrast between background and foreground.'
212
253
  ),
213
- [ backgroundGradientSupported ]
214
- );
254
+ } );
215
255
 
216
256
  if (
217
257
  ! useHasBackgroundPanel( settings ) ||
218
- ! hasBackgroundSupport( name )
258
+ ( ! hasBackgroundSupport( name ) &&
259
+ ! hasColorBackgroundSupport &&
260
+ ! hasColorGradientSupport )
219
261
  ) {
220
262
  return null;
221
263
  }
222
264
 
223
- const isStateSelected = ! isDefaultBlockStyleState( selectedState );
265
+ const onChange = ( newStyle ) => {
266
+ if ( isStateSelected ) {
267
+ setAttributes( {
268
+ style: setStyleForState( style, selectedState, newStyle ),
269
+ } );
270
+ return;
271
+ }
224
272
 
225
- const onChange = isStateSelected
226
- ? ( newStyle ) => {
227
- setAttributes( {
228
- style: setStyleForState( style, selectedState, newStyle ),
229
- } );
230
- }
231
- : ( newStyle ) => {
232
- const isMigrating =
233
- backgroundGradientSupported && !! style?.color?.gradient;
234
- const newAttributes = {
235
- style: cleanEmptyObject(
236
- backgroundGradientSupported
237
- ? {
238
- ...newStyle,
239
- color: {
240
- ...newStyle?.color,
241
- gradient: undefined,
242
- },
243
- }
244
- : newStyle
245
- ),
246
- };
273
+ // Extract background color slug from style.color.background.
274
+ const newBackgroundColorValue = newStyle?.color?.background;
275
+ const newBackgroundColorSlug = extractPresetSlug(
276
+ newBackgroundColorValue,
277
+ 'color'
278
+ );
279
+
280
+ // Extract gradient slug — prefer the new background.gradient path
281
+ // when backgroundGradientSupported, fall back to color.gradient.
282
+ const newGradientValue = backgroundGradientSupported
283
+ ? newStyle?.background?.gradient
284
+ : newStyle?.color?.gradient;
285
+ const newGradientSlug = extractPresetSlug(
286
+ newGradientValue,
287
+ 'gradient'
288
+ );
289
+ const cleanedColorGradient = newGradientSlug
290
+ ? undefined
291
+ : newStyle?.color?.gradient;
247
292
 
248
- // When migrating from color.gradient to background.gradient, preserve
249
- // the has-background class so existing styles relying on it (e.g.
250
- // theme padding) are not silently broken. Only add the class when a
251
- // gradient value is being set — not when it is being cleared/reset.
252
- // Conversely, if the gradient is cleared and has-background was added
253
- // during a previous migration, remove it so it does not linger.
254
- if ( isMigrating && !! newStyle?.background?.gradient ) {
255
- newAttributes.className = clsx(
256
- className,
257
- 'has-background'
258
- );
259
- } else if (
260
- ! newStyle?.background?.gradient &&
261
- className?.includes( 'has-background' )
262
- ) {
263
- newAttributes.className =
264
- className
265
- .split( ' ' )
266
- .filter( ( c ) => c !== 'has-background' )
267
- .join( ' ' ) || undefined;
268
- }
269
-
270
- setAttributes( newAttributes );
271
- };
272
-
273
- // When background.gradient is supported but not yet explicitly set, fall
274
- // back to color.gradient for display. Any write from this panel migrates
275
- // the value to background.gradient and clears color.gradient atomically.
276
- const styleValue =
277
- backgroundGradientSupported &&
278
- ! style?.background?.gradient &&
279
- style?.color?.gradient
280
- ? {
281
- ...style,
282
- background: {
283
- ...style?.background,
284
- gradient: style?.color?.gradient,
285
- },
286
- }
287
- : style;
293
+ // Drop slug-resolved values so they aren't persisted inline alongside
294
+ // the attribute slugs.
295
+ const cleanedStyle = {
296
+ ...newStyle,
297
+ color: {
298
+ ...newStyle?.color,
299
+ background: newBackgroundColorSlug
300
+ ? undefined
301
+ : newBackgroundColorValue,
302
+ gradient: backgroundGradientSupported
303
+ ? undefined
304
+ : cleanedColorGradient,
305
+ },
306
+ };
307
+ if ( backgroundGradientSupported ) {
308
+ // Background gradients are kept whole in `style.background.gradient`
309
+ // rather than extracted to the legacy `gradient` attribute.
310
+ cleanedStyle.background = {
311
+ ...cleanedStyle.background,
312
+ gradient: newStyle?.background?.gradient,
313
+ };
314
+ }
315
+
316
+ const isMigrating =
317
+ backgroundGradientSupported && !! style?.color?.gradient;
318
+ const newAttributes = {
319
+ style: cleanEmptyObject( cleanedStyle ),
320
+ backgroundColor: newBackgroundColorSlug,
321
+ // The legacy `gradient` attribute is only used when the block does
322
+ // not support `background.gradient`; otherwise the gradient is
323
+ // stored in `style.background.gradient` above.
324
+ gradient: backgroundGradientSupported ? undefined : newGradientSlug,
325
+ };
326
+
327
+ // When migrating from color.gradient to background.gradient, preserve
328
+ // the has-background class so existing styles relying on it (e.g.
329
+ // theme padding) are not silently broken. Only add the class when a
330
+ // gradient value is being set — not when it is being cleared/reset.
331
+ // Conversely, if the gradient is cleared and has-background was added
332
+ // during a previous migration, remove it so it does not linger.
333
+ const hasNewGradient = !! newGradientSlug || !! newGradientValue;
334
+ if ( isMigrating && hasNewGradient ) {
335
+ newAttributes.className = clsx( className, 'has-background' );
336
+ } else if (
337
+ ! hasNewGradient &&
338
+ className?.includes( 'has-background' )
339
+ ) {
340
+ newAttributes.className =
341
+ className
342
+ .split( ' ' )
343
+ .filter( ( c ) => c !== 'has-background' )
344
+ .join( ' ' ) || undefined;
345
+ }
346
+
347
+ setAttributes( newAttributes );
348
+ };
288
349
 
289
350
  const updatedSettings = {
290
351
  ...settings,
@@ -296,15 +357,30 @@ export function BackgroundImagePanel( {
296
357
  },
297
358
  };
298
359
 
299
- const defaultControls = getBlockSupport( name, [
360
+ const backgroundDefaultControls = getBlockSupport( name, [
300
361
  BACKGROUND_SUPPORT_KEY,
301
362
  '__experimentalDefaultControls',
302
363
  ] );
364
+ const colorDefaultControls = getBlockSupport( name, [
365
+ 'color',
366
+ '__experimentalDefaultControls',
367
+ ] );
368
+ const defaultControls = {
369
+ ...backgroundDefaultControls,
370
+ backgroundColor: colorDefaultControls?.background,
371
+ // Mirror the old combined control: show the gradient item by default
372
+ // when background color was shown by default.
373
+ gradient:
374
+ backgroundDefaultControls?.gradient ??
375
+ colorDefaultControls?.background,
376
+ };
377
+
378
+ const Wrapper = asWrapper || BackgroundInspectorControl;
303
379
 
304
380
  return (
305
381
  <StylesBackgroundPanel
306
382
  inheritedValue={ inheritedValue }
307
- as={ as }
383
+ as={ Wrapper }
308
384
  panelId={ clientId }
309
385
  defaultValues={ BACKGROUND_BLOCK_DEFAULT_VALUES }
310
386
  settings={ updatedSettings }
@@ -315,6 +391,7 @@ export function BackgroundImagePanel( {
315
391
  ? getStyleForState( style, selectedState )
316
392
  : styleValue
317
393
  }
394
+ contrastWarning={ contrastWarning }
318
395
  />
319
396
  );
320
397
  }
@@ -1,39 +1,4 @@
1
1
  @use "@wordpress/base-styles/variables" as *;
2
- @use "@wordpress/base-styles/colors" as *;
3
-
4
- /**
5
- * ItemGroup-like border styles for the background panel's ToolsPanelItems.
6
- * Replicates the separated border of the `ItemGroup` component while
7
- * allowing for hidden placeholder items (same approach as the color panel).
8
- */
9
- .block-editor-background-panel__item {
10
- padding: 0;
11
- max-width: 100%;
12
- position: relative;
13
-
14
- // Border styles.
15
- border-left: 1px solid $gray-300;
16
- border-right: 1px solid $gray-300;
17
- border-bottom: 1px solid $gray-300;
18
-
19
- // Identify the first visible instance as placeholder items will not have this class.
20
- &:nth-child(1 of &) {
21
- border-top-left-radius: $radius-small;
22
- border-top-right-radius: $radius-small;
23
- border-top: 1px solid $gray-300;
24
- }
25
-
26
- // Identify the last visible instance as placeholder items will not have this class.
27
- &:nth-last-child(1 of &) {
28
- border-bottom-left-radius: $radius-small;
29
- border-bottom-right-radius: $radius-small;
30
- }
31
-
32
- > div,
33
- > div > button {
34
- border-radius: inherit;
35
- }
36
- }
37
2
 
38
3
  .background-block-support-panel {
39
4
  /* Increased specificity required to remove the slot wrapper's row gap */