@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
@@ -4,9 +4,8 @@
4
4
  import { __, _x } from '@wordpress/i18n';
5
5
  import { Button, Modal } from '@wordpress/components';
6
6
  import { useState, useCallback, useMemo } from '@wordpress/element';
7
- import { getBlockType, createBlock, rawHandler } from '@wordpress/blocks';
8
- import { compose } from '@wordpress/compose';
9
- import { withDispatch, withSelect } from '@wordpress/data';
7
+ import { createBlock, rawHandler } from '@wordpress/blocks';
8
+ import { useDispatch, useSelect } from '@wordpress/data';
10
9
 
11
10
  /**
12
11
  * Internal dependencies
@@ -15,38 +14,86 @@ import Warning from '../warning';
15
14
  import BlockCompare from '../block-compare';
16
15
  import { store as blockEditorStore } from '../../store';
17
16
 
18
- export function BlockInvalidWarning( {
19
- convertToHTML,
20
- convertToBlocks,
21
- convertToClassic,
22
- attemptBlockRecovery,
23
- block,
24
- } ) {
25
- const hasHTMLBlock = !! getBlockType( 'core/html' );
26
- const [ compare, setCompare ] = useState( false );
17
+ const blockToBlocks = ( block ) =>
18
+ rawHandler( {
19
+ HTML: block.originalContent,
20
+ } );
21
+
22
+ export default function BlockInvalidWarning( { clientId } ) {
23
+ const { block, canInsertHTMLBlock, canInsertClassicBlock } = useSelect(
24
+ ( select ) => {
25
+ const { canInsertBlockType, getBlock, getBlockRootClientId } =
26
+ select( blockEditorStore );
27
27
 
28
- const onCompare = useCallback( () => setCompare( true ), [] );
28
+ const rootClientId = getBlockRootClientId( clientId );
29
+
30
+ return {
31
+ block: getBlock( clientId ),
32
+ canInsertHTMLBlock: canInsertBlockType(
33
+ 'core/html',
34
+ rootClientId
35
+ ),
36
+ canInsertClassicBlock: canInsertBlockType(
37
+ 'core/freeform',
38
+ rootClientId
39
+ ),
40
+ };
41
+ },
42
+ [ clientId ]
43
+ );
44
+ const { replaceBlock } = useDispatch( blockEditorStore );
45
+
46
+ const [ compare, setCompare ] = useState( false );
29
47
  const onCompareClose = useCallback( () => setCompare( false ), [] );
30
48
 
31
- // We memo the array here to prevent the children components from being updated unexpectedly.
32
- const hiddenActions = useMemo(
49
+ const convert = useMemo(
50
+ () => ( {
51
+ toClassic() {
52
+ const classicBlock = createBlock( 'core/freeform', {
53
+ content: block.originalContent,
54
+ } );
55
+ return replaceBlock( block.clientId, classicBlock );
56
+ },
57
+ toHTML() {
58
+ const htmlBlock = createBlock( 'core/html', {
59
+ content: block.originalContent,
60
+ } );
61
+ return replaceBlock( block.clientId, htmlBlock );
62
+ },
63
+ toBlocks() {
64
+ const newBlocks = blockToBlocks( block );
65
+ return replaceBlock( block.clientId, newBlocks );
66
+ },
67
+ toRecoveredBlock() {
68
+ const recoveredBlock = createBlock(
69
+ block.name,
70
+ block.attributes,
71
+ block.innerBlocks
72
+ );
73
+ return replaceBlock( block.clientId, recoveredBlock );
74
+ },
75
+ } ),
76
+ [ block, replaceBlock ]
77
+ );
78
+
79
+ const secondaryActions = useMemo(
33
80
  () =>
34
81
  [
35
82
  {
36
83
  // translators: Button to fix block content
37
84
  title: _x( 'Resolve', 'imperative verb' ),
38
- onClick: onCompare,
85
+ onClick: () => setCompare( true ),
39
86
  },
40
- hasHTMLBlock && {
87
+ canInsertHTMLBlock && {
41
88
  title: __( 'Convert to HTML' ),
42
- onClick: convertToHTML,
89
+ onClick: convert.toHTML,
43
90
  },
44
- {
91
+ canInsertClassicBlock && {
45
92
  title: __( 'Convert to Classic Block' ),
46
- onClick: convertToClassic,
93
+ onClick: convert.toClassic,
47
94
  },
48
95
  ].filter( Boolean ),
49
- [ onCompare, convertToHTML, convertToClassic ]
96
+ [ canInsertHTMLBlock, canInsertClassicBlock, convert ]
50
97
  );
51
98
 
52
99
  return (
@@ -55,13 +102,13 @@ export function BlockInvalidWarning( {
55
102
  actions={ [
56
103
  <Button
57
104
  key="recover"
58
- onClick={ attemptBlockRecovery }
105
+ onClick={ convert.toRecoveredBlock }
59
106
  variant="primary"
60
107
  >
61
108
  { __( 'Attempt Block Recovery' ) }
62
109
  </Button>,
63
110
  ] }
64
- secondaryActions={ hiddenActions }
111
+ secondaryActions={ secondaryActions }
65
112
  >
66
113
  { __( 'This block contains unexpected or invalid content.' ) }
67
114
  </Warning>
@@ -76,8 +123,8 @@ export function BlockInvalidWarning( {
76
123
  >
77
124
  <BlockCompare
78
125
  block={ block }
79
- onKeep={ convertToHTML }
80
- onConvert={ convertToBlocks }
126
+ onKeep={ convert.toHTML }
127
+ onConvert={ convert.toBlocks }
81
128
  convertor={ blockToBlocks }
82
129
  convertButtonText={ __( 'Convert to Blocks' ) }
83
130
  />
@@ -86,42 +133,3 @@ export function BlockInvalidWarning( {
86
133
  </>
87
134
  );
88
135
  }
89
-
90
- const blockToClassic = ( block ) =>
91
- createBlock( 'core/freeform', {
92
- content: block.originalContent,
93
- } );
94
- const blockToHTML = ( block ) =>
95
- createBlock( 'core/html', {
96
- content: block.originalContent,
97
- } );
98
- const blockToBlocks = ( block ) =>
99
- rawHandler( {
100
- HTML: block.originalContent,
101
- } );
102
- const recoverBlock = ( { name, attributes, innerBlocks } ) =>
103
- createBlock( name, attributes, innerBlocks );
104
-
105
- export default compose( [
106
- withSelect( ( select, { clientId } ) => ( {
107
- block: select( blockEditorStore ).getBlock( clientId ),
108
- } ) ),
109
- withDispatch( ( dispatch, { block } ) => {
110
- const { replaceBlock } = dispatch( blockEditorStore );
111
-
112
- return {
113
- convertToClassic() {
114
- replaceBlock( block.clientId, blockToClassic( block ) );
115
- },
116
- convertToHTML() {
117
- replaceBlock( block.clientId, blockToHTML( block ) );
118
- },
119
- convertToBlocks() {
120
- replaceBlock( block.clientId, blockToBlocks( block ) );
121
- },
122
- attemptBlockRecovery() {
123
- replaceBlock( block.clientId, recoverBlock( block ) );
124
- },
125
- };
126
- } ),
127
- ] )( BlockInvalidWarning );
@@ -98,7 +98,16 @@ exports[`Block Mover Picker should match snapshot 1`] = `
98
98
  }
99
99
  }
100
100
  >
101
- Svg
101
+ <Svg
102
+ colorScheme="light"
103
+ height={24}
104
+ style={{}}
105
+ viewBox="0 0 24 24"
106
+ width={24}
107
+ xmlns="http://www.w3.org/2000/svg"
108
+ >
109
+ Path
110
+ </Svg>
102
111
  </View>
103
112
  </View>
104
113
  </View>
@@ -157,7 +166,16 @@ exports[`Block Mover Picker should match snapshot 1`] = `
157
166
  }
158
167
  }
159
168
  >
160
- Svg
169
+ <Svg
170
+ colorScheme="light"
171
+ height={24}
172
+ style={{}}
173
+ viewBox="0 0 24 24"
174
+ width={24}
175
+ xmlns="http://www.w3.org/2000/svg"
176
+ >
177
+ Path
178
+ </Svg>
161
179
  </View>
162
180
  </View>
163
181
  </View>
@@ -12,7 +12,6 @@ import { Disabled } from '@wordpress/components';
12
12
  import BlockList from '../block-list';
13
13
  import Iframe from '../iframe';
14
14
  import EditorStyles from '../editor-styles';
15
- import { __unstablePresetDuotoneFilter as PresetDuotoneFilter } from '../../components/duotone';
16
15
  import { store } from '../../store';
17
16
 
18
17
  // This is used to avoid rendering the block list if the sizes change.
@@ -32,11 +31,10 @@ function ScaledBlockPreview( {
32
31
 
33
32
  const [ contentResizeListener, { height: contentHeight } ] =
34
33
  useResizeObserver();
35
- const { styles, duotone } = useSelect( ( select ) => {
34
+ const { styles } = useSelect( ( select ) => {
36
35
  const settings = select( store ).getSettings();
37
36
  return {
38
37
  styles: settings.styles,
39
- duotone: settings.__experimentalFeatures?.color?.duotone,
40
38
  };
41
39
  }, [] );
42
40
 
@@ -56,10 +54,6 @@ function ScaledBlockPreview( {
56
54
  return styles;
57
55
  }, [ styles, additionalStyles ] );
58
56
 
59
- const svgFilters = useMemo( () => {
60
- return [ ...( duotone?.default ?? [] ), ...( duotone?.theme ?? [] ) ];
61
- }, [ duotone ] );
62
-
63
57
  // Initialize on render instead of module top level, to avoid circular dependency issues.
64
58
  MemoizedBlockList = MemoizedBlockList || pure( BlockList );
65
59
 
@@ -76,7 +70,6 @@ function ScaledBlockPreview( {
76
70
  } }
77
71
  >
78
72
  <Iframe
79
- head={ <EditorStyles styles={ editorStyles } /> }
80
73
  contentRef={ useRefEffect( ( bodyElement ) => {
81
74
  const {
82
75
  ownerDocument: { documentElement },
@@ -108,16 +101,8 @@ function ScaledBlockPreview( {
108
101
  : minHeight,
109
102
  } }
110
103
  >
104
+ <EditorStyles styles={ editorStyles } />
111
105
  { contentResizeListener }
112
- {
113
- /* Filters need to be rendered before children to avoid Safari rendering issues. */
114
- svgFilters.map( ( preset ) => (
115
- <PresetDuotoneFilter
116
- preset={ preset }
117
- key={ preset.slug }
118
- />
119
- ) )
120
- }
121
106
  <MemoizedBlockList renderAppender={ false } />
122
107
  </Iframe>
123
108
  </Disabled>
@@ -17,8 +17,6 @@ import {
17
17
  */
18
18
  import { useBlockPreview } from '../';
19
19
 
20
- jest.useRealTimers();
21
-
22
20
  describe( 'useBlockPreview', () => {
23
21
  beforeAll( () => {
24
22
  registerBlockType( 'core/test-block', {
@@ -48,7 +48,8 @@ const BlockSettingsMenuControlsSlot = ( {
48
48
 
49
49
  // Check if current selection of blocks is Groupable or Ungroupable
50
50
  // and pass this props down to ConvertToGroupButton.
51
- const convertToGroupButtonProps = useConvertToGroupButtonProps();
51
+ const convertToGroupButtonProps =
52
+ useConvertToGroupButtonProps( selectedClientIds );
52
53
  const { isGroupable, isUngroupable } = convertToGroupButtonProps;
53
54
  const showConvertToGroupButton =
54
55
  ( isGroupable || isUngroupable ) && canRemove;
@@ -38,7 +38,7 @@
38
38
  gap: $grid-unit-10;
39
39
 
40
40
  .block-editor-block-styles__item {
41
- color: $gray-800;
41
+ color: $gray-900;
42
42
  box-shadow: inset 0 0 0 1px $gray-400;
43
43
  display: inline-block;
44
44
  width: calc(50% - #{$grid-unit-05});
@@ -51,7 +51,7 @@
51
51
 
52
52
  &.is-active,
53
53
  &.is-active:hover {
54
- background-color: $gray-800;
54
+ background-color: $gray-900;
55
55
  box-shadow: none;
56
56
  }
57
57
 
@@ -75,6 +75,7 @@ const BlockTransformationsMenu = ( {
75
75
 
76
76
  return (
77
77
  <Picker
78
+ testID="block-transformations-menu"
78
79
  ref={ pickerRef }
79
80
  options={ pickerOptions() }
80
81
  onChange={ onPickerSelect }
@@ -22,17 +22,18 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
22
22
  display: -webkit-flex;
23
23
  display: -ms-flexbox;
24
24
  display: flex;
25
- -webkit-align-items: normal;
26
- -webkit-box-align: normal;
27
- -ms-flex-align: normal;
28
- align-items: normal;
25
+ -webkit-align-items: stretch;
26
+ -webkit-box-align: stretch;
27
+ -ms-flex-align: stretch;
28
+ align-items: stretch;
29
29
  -webkit-flex-direction: column;
30
30
  -ms-flex-direction: column;
31
31
  flex-direction: column;
32
32
  gap: calc(4px * 1);
33
- -webkit-box-pack: justify;
34
- -webkit-justify-content: space-between;
35
- justify-content: space-between;
33
+ -webkit-box-pack: center;
34
+ -ms-flex-pack: center;
35
+ -webkit-justify-content: center;
36
+ justify-content: center;
36
37
  }
37
38
 
38
39
  .emotion-4>* {
@@ -54,17 +55,18 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
54
55
  display: -webkit-flex;
55
56
  display: -ms-flexbox;
56
57
  display: flex;
57
- -webkit-align-items: normal;
58
- -webkit-box-align: normal;
59
- -ms-flex-align: normal;
60
- align-items: normal;
58
+ -webkit-align-items: stretch;
59
+ -webkit-box-align: stretch;
60
+ -ms-flex-align: stretch;
61
+ align-items: stretch;
61
62
  -webkit-flex-direction: column;
62
63
  -ms-flex-direction: column;
63
64
  flex-direction: column;
64
65
  gap: calc(4px * 3);
65
- -webkit-box-pack: justify;
66
- -webkit-justify-content: space-between;
67
- justify-content: space-between;
66
+ -webkit-box-pack: center;
67
+ -ms-flex-pack: center;
68
+ -webkit-justify-content: center;
69
+ justify-content: center;
68
70
  }
69
71
 
70
72
  .emotion-8>* {
@@ -73,20 +73,20 @@ $swatch-gap: 12px;
73
73
  max-width: 100%;
74
74
 
75
75
  // Border styles.
76
- border-left: 1px solid rgba(0, 0, 0, 0.1);
77
- border-right: 1px solid rgba(0, 0, 0, 0.1);
78
- border-bottom: 1px solid rgba(0, 0, 0, 0.1);
76
+ border-left: 1px solid $gray-300;
77
+ border-right: 1px solid $gray-300;
78
+ border-bottom: 1px solid $gray-300;
79
79
 
80
80
  &.first {
81
81
  margin-top: $grid-unit-30;
82
- border-top-left-radius: 2px;
83
- border-top-right-radius: 2px;
84
- border-top: 1px solid rgba(0, 0, 0, 0.1);
82
+ border-top-left-radius: $radius-block-ui;
83
+ border-top-right-radius: $radius-block-ui;
84
+ border-top: 1px solid $gray-300;
85
85
  }
86
86
 
87
87
  &.last {
88
- border-bottom-left-radius: 2px;
89
- border-bottom-right-radius: 2px;
88
+ border-bottom-left-radius: $radius-block-ui;
89
+ border-bottom-right-radius: $radius-block-ui;
90
90
  }
91
91
 
92
92
  > div,
@@ -25,59 +25,69 @@ import { store as blockEditorStore } from '../../store';
25
25
  * It is used in `BlockSettingsMenuControls` to know if `ConvertToGroupButton`
26
26
  * should be rendered, to avoid ending up with an empty MenuGroup.
27
27
  *
28
+ * @param {?string[]} selectedClientIds An optional array of clientIds to group. The selected blocks
29
+ * from the block editor store are used if this is not provided.
30
+ *
28
31
  * @return {ConvertToGroupButtonProps} Returns the properties needed by `ConvertToGroupButton`.
29
32
  */
30
- export default function useConvertToGroupButtonProps() {
33
+ export default function useConvertToGroupButtonProps( selectedClientIds ) {
31
34
  const {
32
35
  clientIds,
33
36
  isGroupable,
34
37
  isUngroupable,
35
38
  blocksSelection,
36
39
  groupingBlockName,
37
- } = useSelect( ( select ) => {
38
- const {
39
- getBlockRootClientId,
40
- getBlocksByClientId,
41
- canInsertBlockType,
42
- getSelectedBlockClientIds,
43
- } = select( blockEditorStore );
44
- const { getGroupingBlockName } = select( blocksStore );
40
+ } = useSelect(
41
+ ( select ) => {
42
+ const {
43
+ getBlockRootClientId,
44
+ getBlocksByClientId,
45
+ canInsertBlockType,
46
+ getSelectedBlockClientIds,
47
+ } = select( blockEditorStore );
48
+ const { getGroupingBlockName } = select( blocksStore );
49
+
50
+ const _clientIds = selectedClientIds?.length
51
+ ? selectedClientIds
52
+ : getSelectedBlockClientIds();
53
+ const _groupingBlockName = getGroupingBlockName();
45
54
 
46
- const _clientIds = getSelectedBlockClientIds();
47
- const _groupingBlockName = getGroupingBlockName();
55
+ const rootClientId = !! _clientIds?.length
56
+ ? getBlockRootClientId( _clientIds[ 0 ] )
57
+ : undefined;
48
58
 
49
- const rootClientId = !! _clientIds?.length
50
- ? getBlockRootClientId( _clientIds[ 0 ] )
51
- : undefined;
59
+ const groupingBlockAvailable = canInsertBlockType(
60
+ _groupingBlockName,
61
+ rootClientId
62
+ );
52
63
 
53
- const groupingBlockAvailable = canInsertBlockType(
54
- _groupingBlockName,
55
- rootClientId
56
- );
64
+ const _blocksSelection = getBlocksByClientId( _clientIds );
57
65
 
58
- const _blocksSelection = getBlocksByClientId( _clientIds );
66
+ const isSingleGroupingBlock =
67
+ _blocksSelection.length === 1 &&
68
+ _blocksSelection[ 0 ]?.name === _groupingBlockName;
59
69
 
60
- const isSingleGroupingBlock =
61
- _blocksSelection.length === 1 &&
62
- _blocksSelection[ 0 ]?.name === _groupingBlockName;
70
+ // Do we have
71
+ // 1. Grouping block available to be inserted?
72
+ // 2. One or more blocks selected
73
+ const _isGroupable =
74
+ groupingBlockAvailable && _blocksSelection.length;
63
75
 
64
- // Do we have
65
- // 1. Grouping block available to be inserted?
66
- // 2. One or more blocks selected
67
- const _isGroupable = groupingBlockAvailable && _blocksSelection.length;
76
+ // Do we have a single Group Block selected and does that group have inner blocks?
77
+ const _isUngroupable =
78
+ isSingleGroupingBlock &&
79
+ !! _blocksSelection[ 0 ].innerBlocks.length;
80
+ return {
81
+ clientIds: _clientIds,
82
+ isGroupable: _isGroupable,
83
+ isUngroupable: _isUngroupable,
84
+ blocksSelection: _blocksSelection,
85
+ groupingBlockName: _groupingBlockName,
86
+ };
87
+ },
88
+ [ selectedClientIds ]
89
+ );
68
90
 
69
- // Do we have a single Group Block selected and does that group have inner blocks?
70
- const _isUngroupable =
71
- isSingleGroupingBlock &&
72
- !! _blocksSelection[ 0 ].innerBlocks.length;
73
- return {
74
- clientIds: _clientIds,
75
- isGroupable: _isGroupable,
76
- isUngroupable: _isUngroupable,
77
- blocksSelection: _blocksSelection,
78
- groupingBlockName: _groupingBlockName,
79
- };
80
- }, [] );
81
91
  return {
82
92
  clientIds,
83
93
  isGroupable,
@@ -8,6 +8,7 @@ import a11yPlugin from 'colord/plugins/a11y';
8
8
  /**
9
9
  * WordPress dependencies
10
10
  */
11
+ import { SVG } from '@wordpress/components';
11
12
  import { useCallback, useMemo } from '@wordpress/element';
12
13
 
13
14
  /**
@@ -68,7 +69,20 @@ function useDarkThemeBodyClassName( styles ) {
68
69
 
69
70
  export default function EditorStyles( { styles } ) {
70
71
  const transformedStyles = useMemo(
71
- () => transformStyles( styles, EDITOR_STYLES_SELECTOR ),
72
+ () =>
73
+ transformStyles(
74
+ styles.filter( ( style ) => style?.css ),
75
+ EDITOR_STYLES_SELECTOR
76
+ ),
77
+ [ styles ]
78
+ );
79
+
80
+ const transformedSvgs = useMemo(
81
+ () =>
82
+ styles
83
+ .filter( ( style ) => style.__unstableType === 'svgs' )
84
+ .map( ( style ) => style.assets )
85
+ .join( '' ),
72
86
  [ styles ]
73
87
  );
74
88
 
@@ -80,6 +94,20 @@ export default function EditorStyles( { styles } ) {
80
94
  { transformedStyles.map( ( css, index ) => (
81
95
  <style key={ index }>{ css }</style>
82
96
  ) ) }
97
+ <SVG
98
+ xmlns="http://www.w3.org/2000/svg"
99
+ viewBox="0 0 0 0"
100
+ width="0"
101
+ height="0"
102
+ role="none"
103
+ style={ {
104
+ visibility: 'hidden',
105
+ position: 'absolute',
106
+ left: '-9999px',
107
+ overflow: 'hidden',
108
+ } }
109
+ dangerouslySetInnerHTML={ { __html: transformedSvgs } }
110
+ />
83
111
  </>
84
112
  );
85
113
  }