@wordpress/block-editor 15.10.1-next.v.0 → 15.11.1-next.v.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 (318) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-controls/index.cjs +1 -1
  3. package/build/components/block-controls/index.cjs.map +2 -2
  4. package/build/components/block-edit/context.cjs +5 -0
  5. package/build/components/block-edit/context.cjs.map +2 -2
  6. package/build/components/block-edit/index.cjs +3 -0
  7. package/build/components/block-edit/index.cjs.map +2 -2
  8. package/build/components/block-inspector/index.cjs +7 -27
  9. package/build/components/block-inspector/index.cjs.map +3 -3
  10. package/build/components/block-list/block.cjs +3 -0
  11. package/build/components/block-list/block.cjs.map +2 -2
  12. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs +37 -13
  13. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs.map +2 -2
  14. package/build/components/block-settings-menu-controls/index.cjs +1 -1
  15. package/build/components/block-settings-menu-controls/index.cjs.map +2 -2
  16. package/build/components/block-toolbar/index.cjs +1 -1
  17. package/build/components/block-toolbar/index.cjs.map +2 -2
  18. package/build/components/block-tools/index.cjs +2 -26
  19. package/build/components/block-tools/index.cjs.map +2 -2
  20. package/build/components/block-visibility/index.cjs +7 -9
  21. package/build/components/block-visibility/index.cjs.map +3 -3
  22. package/build/components/block-visibility/modal.cjs +13 -11
  23. package/build/components/block-visibility/modal.cjs.map +2 -2
  24. package/build/components/block-visibility/use-block-visibility.cjs +1 -1
  25. package/build/components/block-visibility/use-block-visibility.cjs.map +2 -2
  26. package/build/components/block-visibility/utils.cjs +5 -1
  27. package/build/components/block-visibility/utils.cjs.map +2 -2
  28. package/build/components/block-visibility/viewport-menu-item.cjs +11 -4
  29. package/build/components/block-visibility/viewport-menu-item.cjs.map +2 -2
  30. package/build/components/block-visibility/viewport-toolbar.cjs +4 -6
  31. package/build/components/block-visibility/viewport-toolbar.cjs.map +2 -2
  32. package/build/components/block-visibility/viewport-visibility-info.cjs +121 -0
  33. package/build/components/block-visibility/viewport-visibility-info.cjs.map +7 -0
  34. package/build/components/button-block-appender/index.cjs +23 -19
  35. package/build/components/button-block-appender/index.cjs.map +2 -2
  36. package/build/components/color-palette/with-color-context.cjs +1 -1
  37. package/build/components/color-palette/with-color-context.cjs.map +2 -2
  38. package/build/components/color-style-selector/index.cjs +1 -1
  39. package/build/components/color-style-selector/index.cjs.map +2 -2
  40. package/build/components/colors/with-colors.cjs +5 -3
  41. package/build/components/colors/with-colors.cjs.map +2 -2
  42. package/build/components/colors-gradients/dropdown.cjs +1 -1
  43. package/build/components/colors-gradients/dropdown.cjs.map +2 -2
  44. package/build/components/editable-text/index.cjs +5 -1
  45. package/build/components/editable-text/index.cjs.map +2 -2
  46. package/build/components/font-sizes/font-size-picker.cjs +2 -1
  47. package/build/components/font-sizes/font-size-picker.cjs.map +2 -2
  48. package/build/components/font-sizes/with-font-sizes.cjs +5 -3
  49. package/build/components/font-sizes/with-font-sizes.cjs.map +2 -2
  50. package/build/components/global-styles/advanced-panel.cjs +26 -13
  51. package/build/components/global-styles/advanced-panel.cjs.map +2 -2
  52. package/build/components/global-styles/filters-panel.cjs +1 -1
  53. package/build/components/global-styles/filters-panel.cjs.map +2 -2
  54. package/build/components/global-styles/shadow-panel-components.cjs +1 -1
  55. package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
  56. package/build/components/gradients/with-gradient.cjs +1 -1
  57. package/build/components/gradients/with-gradient.cjs.map +2 -2
  58. package/build/components/inspector-controls/fill.cjs +14 -25
  59. package/build/components/inspector-controls/fill.cjs.map +2 -2
  60. package/build/components/inspector-controls/index.cjs +1 -1
  61. package/build/components/inspector-controls/index.cjs.map +2 -2
  62. package/build/components/inspector-controls-tabs/index.cjs +1 -1
  63. package/build/components/inspector-controls-tabs/index.cjs.map +2 -2
  64. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs +7 -7
  65. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs.map +2 -2
  66. package/build/components/list-view/block-select-button.cjs +8 -16
  67. package/build/components/list-view/block-select-button.cjs.map +2 -2
  68. package/build/components/list-view/block.cjs +29 -34
  69. package/build/components/list-view/block.cjs.map +3 -3
  70. package/build/components/list-view/utils.cjs +3 -1
  71. package/build/components/list-view/utils.cjs.map +2 -2
  72. package/build/components/provider/index.cjs +7 -8
  73. package/build/components/provider/index.cjs.map +2 -2
  74. package/build/components/provider/with-registry-provider.cjs +1 -1
  75. package/build/components/provider/with-registry-provider.cjs.map +2 -2
  76. package/build/components/use-block-commands/index.cjs +2 -34
  77. package/build/components/use-block-commands/index.cjs.map +2 -2
  78. package/build/hooks/block-fields/index.cjs +52 -86
  79. package/build/hooks/block-fields/index.cjs.map +3 -3
  80. package/build/hooks/block-fields/link/index.cjs +2 -11
  81. package/build/hooks/block-fields/link/index.cjs.map +2 -2
  82. package/build/hooks/block-fields/media/index.cjs +9 -14
  83. package/build/hooks/block-fields/media/index.cjs.map +2 -2
  84. package/build/hooks/cross-origin-isolation.cjs +1 -1
  85. package/build/hooks/cross-origin-isolation.cjs.map +2 -2
  86. package/build/hooks/custom-css.cjs +141 -0
  87. package/build/hooks/custom-css.cjs.map +7 -0
  88. package/build/hooks/fit-text.cjs +14 -7
  89. package/build/hooks/fit-text.cjs.map +2 -2
  90. package/build/hooks/grid-visualizer.cjs +1 -1
  91. package/build/hooks/grid-visualizer.cjs.map +2 -2
  92. package/build/hooks/index.cjs +6 -1
  93. package/build/hooks/index.cjs.map +3 -3
  94. package/build/hooks/layout.cjs +10 -4
  95. package/build/hooks/layout.cjs.map +2 -2
  96. package/build/hooks/list-view.cjs +32 -11
  97. package/build/hooks/list-view.cjs.map +3 -3
  98. package/build/hooks/utils.cjs +5 -4
  99. package/build/hooks/utils.cjs.map +2 -2
  100. package/build/layouts/grid.cjs +12 -1
  101. package/build/layouts/grid.cjs.map +2 -2
  102. package/build/store/defaults.cjs +3 -0
  103. package/build/store/defaults.cjs.map +2 -2
  104. package/build/store/private-selectors.cjs +45 -37
  105. package/build/store/private-selectors.cjs.map +2 -2
  106. package/build/store/selectors.cjs +7 -1
  107. package/build/store/selectors.cjs.map +2 -2
  108. package/build/utils/fit-text-utils.cjs +5 -1
  109. package/build/utils/fit-text-utils.cjs.map +2 -2
  110. package/build-module/components/block-controls/index.mjs +1 -1
  111. package/build-module/components/block-controls/index.mjs.map +2 -2
  112. package/build-module/components/block-edit/context.mjs +4 -0
  113. package/build-module/components/block-edit/context.mjs.map +2 -2
  114. package/build-module/components/block-edit/index.mjs +4 -0
  115. package/build-module/components/block-edit/index.mjs.map +2 -2
  116. package/build-module/components/block-inspector/index.mjs +7 -27
  117. package/build-module/components/block-inspector/index.mjs.map +2 -2
  118. package/build-module/components/block-list/block.mjs +3 -0
  119. package/build-module/components/block-list/block.mjs.map +2 -2
  120. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs +37 -13
  121. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs.map +2 -2
  122. package/build-module/components/block-settings-menu-controls/index.mjs +2 -2
  123. package/build-module/components/block-settings-menu-controls/index.mjs.map +2 -2
  124. package/build-module/components/block-toolbar/index.mjs +2 -2
  125. package/build-module/components/block-toolbar/index.mjs.map +2 -2
  126. package/build-module/components/block-tools/index.mjs +2 -26
  127. package/build-module/components/block-tools/index.mjs.map +2 -2
  128. package/build-module/components/block-visibility/index.mjs +6 -9
  129. package/build-module/components/block-visibility/index.mjs.map +2 -2
  130. package/build-module/components/block-visibility/modal.mjs +13 -11
  131. package/build-module/components/block-visibility/modal.mjs.map +2 -2
  132. package/build-module/components/block-visibility/use-block-visibility.mjs +1 -1
  133. package/build-module/components/block-visibility/use-block-visibility.mjs.map +2 -2
  134. package/build-module/components/block-visibility/utils.mjs +5 -1
  135. package/build-module/components/block-visibility/utils.mjs.map +2 -2
  136. package/build-module/components/block-visibility/viewport-menu-item.mjs +11 -4
  137. package/build-module/components/block-visibility/viewport-menu-item.mjs.map +2 -2
  138. package/build-module/components/block-visibility/viewport-toolbar.mjs +4 -6
  139. package/build-module/components/block-visibility/viewport-toolbar.mjs.map +2 -2
  140. package/build-module/components/block-visibility/viewport-visibility-info.mjs +95 -0
  141. package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +7 -0
  142. package/build-module/components/button-block-appender/index.mjs +23 -19
  143. package/build-module/components/button-block-appender/index.mjs.map +2 -2
  144. package/build-module/components/color-palette/with-color-context.mjs +1 -1
  145. package/build-module/components/color-palette/with-color-context.mjs.map +2 -2
  146. package/build-module/components/color-style-selector/index.mjs +1 -1
  147. package/build-module/components/color-style-selector/index.mjs.map +2 -2
  148. package/build-module/components/colors/with-colors.mjs +5 -3
  149. package/build-module/components/colors/with-colors.mjs.map +2 -2
  150. package/build-module/components/colors-gradients/dropdown.mjs +1 -1
  151. package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
  152. package/build-module/components/editable-text/index.mjs +5 -1
  153. package/build-module/components/editable-text/index.mjs.map +2 -2
  154. package/build-module/components/font-sizes/font-size-picker.mjs +2 -1
  155. package/build-module/components/font-sizes/font-size-picker.mjs.map +2 -2
  156. package/build-module/components/font-sizes/with-font-sizes.mjs +5 -3
  157. package/build-module/components/font-sizes/with-font-sizes.mjs.map +2 -2
  158. package/build-module/components/global-styles/advanced-panel.mjs +22 -13
  159. package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
  160. package/build-module/components/global-styles/filters-panel.mjs +1 -1
  161. package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
  162. package/build-module/components/global-styles/shadow-panel-components.mjs +1 -1
  163. package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
  164. package/build-module/components/gradients/with-gradient.mjs +1 -1
  165. package/build-module/components/gradients/with-gradient.mjs.map +2 -2
  166. package/build-module/components/inspector-controls/fill.mjs +16 -22
  167. package/build-module/components/inspector-controls/fill.mjs.map +2 -2
  168. package/build-module/components/inspector-controls/index.mjs +1 -1
  169. package/build-module/components/inspector-controls/index.mjs.map +2 -2
  170. package/build-module/components/inspector-controls-tabs/index.mjs +1 -1
  171. package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
  172. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs +7 -7
  173. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs.map +2 -2
  174. package/build-module/components/list-view/block-select-button.mjs +8 -16
  175. package/build-module/components/list-view/block-select-button.mjs.map +2 -2
  176. package/build-module/components/list-view/block.mjs +31 -36
  177. package/build-module/components/list-view/block.mjs.map +2 -2
  178. package/build-module/components/list-view/utils.mjs +3 -1
  179. package/build-module/components/list-view/utils.mjs.map +2 -2
  180. package/build-module/components/provider/index.mjs +7 -8
  181. package/build-module/components/provider/index.mjs.map +2 -2
  182. package/build-module/components/provider/with-registry-provider.mjs +1 -1
  183. package/build-module/components/provider/with-registry-provider.mjs.map +2 -2
  184. package/build-module/components/use-block-commands/index.mjs +3 -37
  185. package/build-module/components/use-block-commands/index.mjs.map +2 -2
  186. package/build-module/hooks/block-fields/index.mjs +45 -87
  187. package/build-module/hooks/block-fields/index.mjs.map +2 -2
  188. package/build-module/hooks/block-fields/link/index.mjs +2 -11
  189. package/build-module/hooks/block-fields/link/index.mjs.map +2 -2
  190. package/build-module/hooks/block-fields/media/index.mjs +9 -14
  191. package/build-module/hooks/block-fields/media/index.mjs.map +2 -2
  192. package/build-module/hooks/cross-origin-isolation.mjs +1 -1
  193. package/build-module/hooks/cross-origin-isolation.mjs.map +2 -2
  194. package/build-module/hooks/custom-css.mjs +112 -0
  195. package/build-module/hooks/custom-css.mjs.map +7 -0
  196. package/build-module/hooks/fit-text.mjs +14 -7
  197. package/build-module/hooks/fit-text.mjs.map +2 -2
  198. package/build-module/hooks/grid-visualizer.mjs +1 -1
  199. package/build-module/hooks/grid-visualizer.mjs.map +2 -2
  200. package/build-module/hooks/index.mjs +6 -1
  201. package/build-module/hooks/index.mjs.map +2 -2
  202. package/build-module/hooks/layout.mjs +10 -4
  203. package/build-module/hooks/layout.mjs.map +2 -2
  204. package/build-module/hooks/list-view.mjs +33 -12
  205. package/build-module/hooks/list-view.mjs.map +2 -2
  206. package/build-module/hooks/utils.mjs +7 -5
  207. package/build-module/hooks/utils.mjs.map +2 -2
  208. package/build-module/layouts/grid.mjs +12 -1
  209. package/build-module/layouts/grid.mjs.map +2 -2
  210. package/build-module/store/defaults.mjs +3 -0
  211. package/build-module/store/defaults.mjs.map +2 -2
  212. package/build-module/store/private-selectors.mjs +42 -40
  213. package/build-module/store/private-selectors.mjs.map +2 -2
  214. package/build-module/store/selectors.mjs +7 -1
  215. package/build-module/store/selectors.mjs.map +2 -2
  216. package/build-module/utils/fit-text-utils.mjs +5 -1
  217. package/build-module/utils/fit-text-utils.mjs.map +2 -2
  218. package/build-style/style-rtl.css +3 -0
  219. package/build-style/style.css +3 -0
  220. package/package.json +39 -39
  221. package/src/components/block-controls/index.js +1 -1
  222. package/src/components/block-controls/test/index.js +1 -0
  223. package/src/components/block-edit/context.js +3 -0
  224. package/src/components/block-edit/index.js +6 -0
  225. package/src/components/block-edit/test/edit.js +10 -0
  226. package/src/components/block-inspector/index.js +16 -38
  227. package/src/components/block-list/block.js +3 -0
  228. package/src/components/block-list/block.native.js +5 -0
  229. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +49 -29
  230. package/src/components/block-patterns-list/stories/index.story.jsx +1 -1
  231. package/src/components/block-preview/test/index.js +11 -7
  232. package/src/components/block-settings-menu-controls/index.js +2 -2
  233. package/src/components/block-switcher/test/index.js +2 -0
  234. package/src/components/block-switcher/test/use-transformed.patterns.js +2 -0
  235. package/src/components/block-switcher/test/utils.js +2 -0
  236. package/src/components/block-toolbar/index.js +2 -2
  237. package/src/components/block-tools/index.js +2 -29
  238. package/src/components/block-visibility/index.js +3 -19
  239. package/src/components/block-visibility/modal.js +16 -14
  240. package/src/components/block-visibility/test/use-block-visibility.js +27 -25
  241. package/src/components/block-visibility/test/utils.js +24 -8
  242. package/src/components/block-visibility/use-block-visibility.js +1 -4
  243. package/src/components/block-visibility/utils.js +9 -1
  244. package/src/components/block-visibility/viewport-menu-item.js +11 -5
  245. package/src/components/block-visibility/viewport-toolbar.js +5 -6
  246. package/src/components/block-visibility/viewport-visibility-info.js +131 -0
  247. package/src/components/button-block-appender/index.js +2 -2
  248. package/src/components/color-palette/with-color-context.js +1 -1
  249. package/src/components/color-style-selector/index.js +2 -3
  250. package/src/components/colors/with-colors.js +23 -20
  251. package/src/components/colors-gradients/dropdown.js +2 -3
  252. package/src/components/editable-text/index.js +5 -1
  253. package/src/components/font-sizes/font-size-picker.js +1 -0
  254. package/src/components/font-sizes/with-font-sizes.js +13 -10
  255. package/src/components/global-styles/advanced-panel.js +35 -16
  256. package/src/components/global-styles/filters-panel.js +2 -3
  257. package/src/components/global-styles/shadow-panel-components.js +1 -1
  258. package/src/components/global-styles/style.scss +9 -5
  259. package/src/components/gradients/with-gradient.js +7 -4
  260. package/src/components/inner-blocks/test/index.js +2 -0
  261. package/src/components/inspector-controls/fill.js +30 -20
  262. package/src/components/inspector-controls/index.js +1 -1
  263. package/src/components/inspector-controls-tabs/index.js +5 -1
  264. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +13 -11
  265. package/src/components/link-control/test/index.js +6 -1
  266. package/src/components/list-view/block-select-button.js +16 -25
  267. package/src/components/list-view/block.js +38 -43
  268. package/src/components/list-view/utils.js +4 -2
  269. package/src/components/media-replace-flow/test/index.js +13 -11
  270. package/src/components/provider/index.js +11 -10
  271. package/src/components/provider/test/use-block-sync.js +1 -0
  272. package/src/components/provider/with-registry-provider.js +1 -1
  273. package/src/components/use-block-commands/index.js +0 -41
  274. package/src/hooks/block-fields/index.js +66 -111
  275. package/src/hooks/block-fields/link/index.js +2 -14
  276. package/src/hooks/block-fields/media/index.js +9 -21
  277. package/src/hooks/cross-origin-isolation.js +19 -18
  278. package/src/hooks/custom-css.js +176 -0
  279. package/src/hooks/fit-text.js +20 -5
  280. package/src/hooks/grid-visualizer.js +15 -14
  281. package/src/hooks/index.js +6 -1
  282. package/src/hooks/layout.js +55 -43
  283. package/src/hooks/list-view.js +46 -12
  284. package/src/hooks/test/align.js +1 -0
  285. package/src/hooks/test/allowed-blocks.js +8 -0
  286. package/src/hooks/test/auto-inspector-controls.js +4 -0
  287. package/src/hooks/test/font-size.js +1 -0
  288. package/src/hooks/test/metadata.js +4 -0
  289. package/src/hooks/test/text-align.js +1 -0
  290. package/src/hooks/utils.js +124 -116
  291. package/src/layouts/grid.js +19 -3
  292. package/src/layouts/test/grid.js +1 -1
  293. package/src/store/defaults.js +4 -0
  294. package/src/store/private-selectors.js +94 -63
  295. package/src/store/selectors.js +14 -6
  296. package/src/store/test/actions.js +7 -0
  297. package/src/store/test/private-selectors.js +116 -119
  298. package/src/store/test/reducer.js +4 -0
  299. package/src/store/test/registry-selectors.js +2 -0
  300. package/src/store/test/selectors.js +19 -0
  301. package/src/utils/fit-text-utils.js +12 -2
  302. package/build/components/block-visibility/block-visibility-info.cjs +0 -63
  303. package/build/components/block-visibility/block-visibility-info.cjs.map +0 -7
  304. package/build/components/block-visibility/menu-item.cjs +0 -109
  305. package/build/components/block-visibility/menu-item.cjs.map +0 -7
  306. package/build/components/block-visibility/toolbar.cjs +0 -92
  307. package/build/components/block-visibility/toolbar.cjs.map +0 -7
  308. package/build-module/components/block-visibility/block-visibility-info.mjs +0 -47
  309. package/build-module/components/block-visibility/block-visibility-info.mjs.map +0 -7
  310. package/build-module/components/block-visibility/menu-item.mjs +0 -88
  311. package/build-module/components/block-visibility/menu-item.mjs.map +0 -7
  312. package/build-module/components/block-visibility/toolbar.mjs +0 -71
  313. package/build-module/components/block-visibility/toolbar.mjs.map +0 -7
  314. package/src/components/block-visibility/block-visibility-info.js +0 -62
  315. package/src/components/block-visibility/menu-item.js +0 -96
  316. package/src/components/block-visibility/toolbar.js +0 -88
  317. /package/src/components/block-icon/stories/{index.story.js → index.story.ts} +0 -0
  318. /package/src/components/contrast-checker/stories/{index.story.js → index.story.ts} +0 -0
@@ -113,8 +113,10 @@ export function focusListItem( focusClientId, treeGridElement ) {
113
113
  resolve( null );
114
114
  }, 3000 );
115
115
  } ).then( ( element ) => {
116
- // Focus the first focusable in the row, which is the ListViewBlockSelectButton.
117
- focus.focusable.find( element )?.[ 0 ]?.focus();
116
+ if ( element && element.isConnected ) {
117
+ // Focus the first focusable in the row, which is the ListViewBlockSelectButton.
118
+ focus.focusable.find( element )?.[ 0 ]?.focus();
119
+ }
118
120
  } );
119
121
  }
120
122
 
@@ -8,7 +8,7 @@ import userEvent from '@testing-library/user-event';
8
8
  * WordPress dependencies
9
9
  */
10
10
  import { useState } from '@wordpress/element';
11
-
11
+ import { SlotFillProvider } from '@wordpress/components';
12
12
  /**
13
13
  * Internal dependencies
14
14
  */
@@ -19,16 +19,18 @@ const noop = () => {};
19
19
  function TestWrapper() {
20
20
  const [ mediaURL, setMediaURL ] = useState( 'https://example.media' );
21
21
  return (
22
- <MediaReplaceFlow
23
- mediaId={ 1 }
24
- mediaURL={ mediaURL }
25
- allowedTypes={ [ 'png' ] }
26
- accept="image/*"
27
- onSelect={ noop }
28
- onSelectURL={ setMediaURL }
29
- onError={ noop }
30
- onCloseModal={ noop }
31
- />
22
+ <SlotFillProvider>
23
+ <MediaReplaceFlow
24
+ mediaId={ 1 }
25
+ mediaURL={ mediaURL }
26
+ allowedTypes={ [ 'png' ] }
27
+ accept="image/*"
28
+ onSelect={ noop }
29
+ onSelectURL={ setMediaURL }
30
+ onError={ noop }
31
+ onCloseModal={ noop }
32
+ />
33
+ </SlotFillProvider>
32
34
  );
33
35
  }
34
36
 
@@ -71,18 +71,19 @@ export const ExperimentalBlockEditorProvider = withRegistryProvider(
71
71
 
72
72
  const mediaUploadSettings = useMediaUploadSettings( _settings );
73
73
 
74
- let settings = _settings;
75
-
76
- if ( window.__experimentalMediaProcessing && _settings.mediaUpload ) {
77
- // Create a new variable so that the original props.settings.mediaUpload is not modified.
78
- settings = useMemo(
79
- () => ( {
74
+ const settings = useMemo( () => {
75
+ if (
76
+ window.__experimentalMediaProcessing &&
77
+ _settings?.mediaUpload
78
+ ) {
79
+ // Create a new object so that the original props.settings.mediaUpload is not modified.
80
+ return {
80
81
  ..._settings,
81
82
  mediaUpload: mediaUpload.bind( null, registry ),
82
- } ),
83
- [ _settings, registry ]
84
- );
85
- }
83
+ };
84
+ }
85
+ return _settings;
86
+ }, [ _settings, registry ] );
86
87
 
87
88
  const { __experimentalUpdateSettings } = unlock(
88
89
  useDispatch( blockEditorStore )
@@ -39,6 +39,7 @@ const TestWrapper = withRegistryProvider( ( props ) => {
39
39
  describe( 'useBlockSync hook', () => {
40
40
  beforeAll( () => {
41
41
  registerBlockType( 'test/test-block', {
42
+ apiVersion: 3,
42
43
  title: 'Test block',
43
44
  attributes: {
44
45
  foo: { type: 'number' },
@@ -26,7 +26,7 @@ function getSubRegistry( subRegistries, registry, useSubRegistry ) {
26
26
 
27
27
  const withRegistryProvider = createHigherOrderComponent(
28
28
  ( WrappedComponent ) =>
29
- ( { useSubRegistry = true, ...props } ) => {
29
+ function WithRegistryProvider( { useSubRegistry = true, ...props } ) {
30
30
  const registry = useRegistry();
31
31
  const [ subRegistries ] = useState( () => new WeakMap() );
32
32
  const subRegistry = getSubRegistry(
@@ -16,8 +16,6 @@ import {
16
16
  plus as add,
17
17
  group,
18
18
  ungroup,
19
- seen,
20
- unseen,
21
19
  } from '@wordpress/icons';
22
20
 
23
21
  /**
@@ -25,7 +23,6 @@ import {
25
23
  */
26
24
  import BlockIcon from '../block-icon';
27
25
  import { store as blockEditorStore } from '../../store';
28
- import { cleanEmptyObject } from '../../hooks/utils';
29
26
 
30
27
  const getTransformCommands = () =>
31
28
  function useTransformCommands() {
@@ -160,7 +157,6 @@ const getQuickActionsCommands = () =>
160
157
  getBlockRootClientId,
161
158
  getBlocksByClientId,
162
159
  canRemoveBlocks,
163
- getBlockName,
164
160
  } = useSelect( blockEditorStore );
165
161
  const { getDefaultBlockName, getGroupingBlockName } =
166
162
  useSelect( blocksStore );
@@ -173,7 +169,6 @@ const getQuickActionsCommands = () =>
173
169
  duplicateBlocks,
174
170
  insertAfterBlock,
175
171
  insertBeforeBlock,
176
- updateBlockAttributes,
177
172
  } = useDispatch( blockEditorStore );
178
173
 
179
174
  const onGroup = () => {
@@ -223,11 +218,6 @@ const getQuickActionsCommands = () =>
223
218
  } );
224
219
  const canRemove = canRemoveBlocks( clientIds );
225
220
 
226
- const canToggleBlockVisibility =
227
- blocks.every( ( { clientId } ) =>
228
- hasBlockSupport( getBlockName( clientId ), 'visibility', true )
229
- ) && ! window.__experimentalHideBlocksBasedOnScreenSize;
230
-
231
221
  const commands = [];
232
222
 
233
223
  if ( canDuplicate ) {
@@ -293,37 +283,6 @@ const getQuickActionsCommands = () =>
293
283
  } );
294
284
  }
295
285
 
296
- if ( canToggleBlockVisibility ) {
297
- const hasHiddenBlock = blocks.some(
298
- ( block ) =>
299
- block.attributes.metadata?.blockVisibility === false
300
- );
301
-
302
- commands.push( {
303
- name: 'core/toggle-block-visibility',
304
- label: hasHiddenBlock ? __( 'Show' ) : __( 'Hide' ),
305
- callback: () => {
306
- const attributesByClientId = Object.fromEntries(
307
- blocks?.map( ( { clientId, attributes } ) => [
308
- clientId,
309
- {
310
- metadata: cleanEmptyObject( {
311
- ...attributes?.metadata,
312
- blockVisibility: hasHiddenBlock
313
- ? undefined
314
- : false,
315
- } ),
316
- },
317
- ] )
318
- );
319
- updateBlockAttributes( clientIds, attributesByClientId, {
320
- uniqueByBlock: true,
321
- } );
322
- },
323
- icon: hasHiddenBlock ? seen : unseen,
324
- } );
325
- }
326
-
327
286
  return {
328
287
  isLoading: false,
329
288
  commands: commands.map( ( command ) => ( {
@@ -1,13 +1,15 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { addFilter } from '@wordpress/hooks';
5
- import { privateApis as blocksPrivateApis } from '@wordpress/blocks';
4
+ import {
5
+ privateApis as blocksPrivateApis,
6
+ getBlockType,
7
+ } from '@wordpress/blocks';
6
8
  import {
7
9
  __experimentalHStack as HStack,
8
10
  __experimentalTruncate as Truncate,
9
11
  } from '@wordpress/components';
10
- import { createHigherOrderComponent } from '@wordpress/compose';
12
+ import { useSelect } from '@wordpress/data';
11
13
  import { DataForm } from '@wordpress/dataviews';
12
14
  import { useContext, useState, useMemo } from '@wordpress/element';
13
15
  import { __ } from '@wordpress/i18n';
@@ -15,6 +17,7 @@ import { __ } from '@wordpress/i18n';
15
17
  /**
16
18
  * Internal dependencies
17
19
  */
20
+ import { store as blockEditorStore } from '../../store';
18
21
  import { unlock } from '../../lock-unlock';
19
22
  import BlockIcon from '../../components/block-icon';
20
23
  import useBlockDisplayTitle from '../../components/block-title/use-block-display-title';
@@ -22,34 +25,23 @@ import useBlockDisplayInformation from '../../components/use-block-display-infor
22
25
  const { fieldsKey, formKey } = unlock( blocksPrivateApis );
23
26
  import FieldsDropdownMenu from './fields-dropdown-menu';
24
27
  import { PrivateBlockContext } from '../../components/block-list/private-block-context';
25
- import { PrivateInspectorControlsFill } from '../../components/inspector-controls/fill';
28
+ import InspectorControls from '../../components/inspector-controls/fill';
26
29
 
27
30
  // controls
28
31
  import RichText from './rich-text';
29
32
  import Media from './media';
30
33
  import Link from './link';
31
34
 
32
- const CONTROLS = {
33
- richtext: RichText,
34
- media: Media,
35
- link: Link,
36
- };
37
-
38
35
  /**
39
36
  * Creates a configured control component that wraps a custom control
40
37
  * and passes configuration as props.
41
38
  *
42
39
  * @param {Component} ControlComponent The React component for the control.
43
- * @param {string} type The type of control.
44
40
  * @param {Object} config The control configuration passed as a prop.
45
41
  *
46
42
  * @return {Function} A wrapped control component
47
43
  */
48
- function createConfiguredControl( ControlComponent, type, config ) {
49
- if ( ! ControlComponent ) {
50
- throw new Error( `Control type "${ type }" not found` );
51
- }
52
-
44
+ function createConfiguredControl( ControlComponent, config = {} ) {
53
45
  return function ConfiguredControl( props ) {
54
46
  return <ControlComponent { ...props } config={ config } />;
55
47
  };
@@ -60,7 +52,6 @@ function createConfiguredControl( ControlComponent, type, config ) {
60
52
  * @param {Object} props
61
53
  * @param {string} props.clientId The clientId of the block.
62
54
  * @param {Object} props.blockType The blockType definition.
63
- * @param {Object} props.attributes The block's attribute values.
64
55
  * @param {Function} props.setAttributes Action to set the block's attributes.
65
56
  * @param {boolean} props.isCollapsed Whether the DataForm is rendered as 'collapsed' with only the first field
66
57
  * displayed by default. When collapsed a dropdown is displayed to allow
@@ -70,7 +61,6 @@ function createConfiguredControl( ControlComponent, type, config ) {
70
61
  function BlockFields( {
71
62
  clientId,
72
63
  blockType,
73
- attributes,
74
64
  setAttributes,
75
65
  isCollapsed = false,
76
66
  } ) {
@@ -82,6 +72,11 @@ function BlockFields( {
82
72
 
83
73
  const blockTypeFields = blockType?.[ fieldsKey ];
84
74
 
75
+ const attributes = useSelect(
76
+ ( select ) => select( blockEditorStore ).getBlockAttributes( clientId ),
77
+ [ clientId ]
78
+ );
79
+
85
80
  const computedForm = useMemo( () => {
86
81
  if ( ! isCollapsed ) {
87
82
  return blockType?.[ formKey ];
@@ -104,51 +99,33 @@ function BlockFields( {
104
99
 
105
100
  return blockTypeFields.map( ( fieldDef ) => {
106
101
  const field = {
107
- id: fieldDef.id,
108
- label: fieldDef.label,
109
- type: fieldDef.type, // Use the field's type; DataForm will use built-in or custom Edit
102
+ ...fieldDef,
110
103
  };
111
104
 
112
- // If the field defines a `mapping`, then custom `getValue` and `setValue`
113
- // implementations are provided.
114
- // These functions map from the inconsistent attribute keys found on blocks
115
- // to consistent keys that the field can use internally (and back again).
116
- // When `mapping` isn't provided, we can use the field API's default
117
- // implementation of these functions.
118
- if ( fieldDef.mapping ) {
119
- field.getValue = ( { item } ) => {
120
- // Extract mapped properties from the block attributes
121
- const mappedValue = {};
122
- Object.entries( fieldDef.mapping ).forEach(
123
- ( [ key, attrKey ] ) => {
124
- mappedValue[ key ] = item[ attrKey ];
125
- }
126
- );
127
- return mappedValue;
128
- };
129
- field.setValue = ( { value } ) => {
130
- const attributeUpdates = {};
131
- Object.entries( fieldDef.mapping ).forEach(
132
- ( [ key, attrKey ] ) => {
133
- attributeUpdates[ attrKey ] = value[ key ];
134
- }
135
- );
136
- return attributeUpdates;
137
- };
138
- }
139
-
140
- // Only add custom Edit component if one exists for this type
141
- const ControlComponent = CONTROLS[ fieldDef.type ];
142
- if ( ControlComponent ) {
143
- // Use EditConfig pattern: Edit is an object with control type and config props
144
- field.Edit = createConfiguredControl(
145
- ControlComponent,
146
- fieldDef.type,
147
- {
148
- clientId,
149
- fieldDef,
150
- }
151
- );
105
+ // These should be custom Edit components, not replaced here.
106
+ //
107
+ // - rich-text control: it needs clientId
108
+ // - link control: does not need anything extra
109
+ // - media control: needs the Edit config
110
+ if (
111
+ 'string' === typeof fieldDef.Edit &&
112
+ fieldDef.Edit === 'rich-text'
113
+ ) {
114
+ field.Edit = createConfiguredControl( RichText, {
115
+ clientId,
116
+ } );
117
+ } else if (
118
+ 'string' === typeof fieldDef.Edit &&
119
+ fieldDef.Edit === 'link'
120
+ ) {
121
+ field.Edit = createConfiguredControl( Link );
122
+ } else if (
123
+ 'object' === typeof fieldDef.Edit &&
124
+ fieldDef.Edit.control === 'media'
125
+ ) {
126
+ field.Edit = createConfiguredControl( Media, {
127
+ ...fieldDef.Edit,
128
+ } );
152
129
  }
153
130
 
154
131
  return field;
@@ -216,56 +193,34 @@ function BlockFields( {
216
193
  );
217
194
  }
218
195
 
219
- const withBlockFields = createHigherOrderComponent(
220
- ( BlockEdit ) => ( props ) => {
221
- const {
222
- blockType,
223
- isSelectionWithinCurrentSection,
224
- isSectionBlock,
225
- blockEditingMode,
226
- isSelected,
227
- } = useContext( PrivateBlockContext );
228
-
229
- const shouldShowBlockFields =
230
- window?.__experimentalContentOnlyInspectorFields;
231
- const blockTypeFields = blockType?.[ fieldsKey ];
196
+ function hasBlockFieldsSupport( blockName ) {
197
+ return !! (
198
+ window?.__experimentalContentOnlyInspectorFields &&
199
+ getBlockType( blockName )?.[ fieldsKey ]
200
+ );
201
+ }
232
202
 
233
- if ( ! shouldShowBlockFields || ! blockTypeFields?.length ) {
234
- return <BlockEdit key="edit" { ...props } />;
235
- }
203
+ export function BlockFieldsPanel( props ) {
204
+ const { blockType, isSelectionWithinCurrentSection } =
205
+ useContext( PrivateBlockContext );
236
206
 
237
- return (
238
- <>
239
- <BlockEdit key="edit" { ...props } />
240
- {
241
- // Display the controls of all inner blocks for section/pattern editing.
242
- isSelectionWithinCurrentSection &&
243
- ( isSectionBlock ||
244
- blockEditingMode === 'contentOnly' ) && (
245
- <PrivateInspectorControlsFill
246
- group="content"
247
- forceDisplayControls
248
- >
249
- <BlockFields
250
- { ...props }
251
- blockType={ blockType }
252
- isCollapsed
253
- />
254
- </PrivateInspectorControlsFill>
255
- )
256
- }
257
- { ! isSelectionWithinCurrentSection && isSelected && (
258
- <PrivateInspectorControlsFill group="content">
259
- <BlockFields { ...props } blockType={ blockType } />
260
- </PrivateInspectorControlsFill>
261
- ) }
262
- </>
263
- );
264
- }
265
- );
207
+ return (
208
+ <InspectorControls group="content">
209
+ <BlockFields
210
+ { ...props }
211
+ blockType={ blockType }
212
+ isCollapsed={ isSelectionWithinCurrentSection }
213
+ />
214
+ </InspectorControls>
215
+ );
216
+ }
266
217
 
267
- addFilter(
268
- 'editor.BlockEdit',
269
- 'core/content-only-controls/block-fields',
270
- withBlockFields
271
- );
218
+ /**
219
+ * Export block support definition.
220
+ */
221
+ export default {
222
+ edit: BlockFieldsPanel,
223
+ hasSupport: hasBlockFieldsSupport,
224
+ attributeKeys: [],
225
+ supportsPatternEditing: true,
226
+ };
@@ -67,12 +67,11 @@ export function getUpdatedLinkAttributes( {
67
67
  };
68
68
  }
69
69
 
70
- export default function Link( { data, field, onChange, config = {} } ) {
70
+ export default function Link( { data, field, onChange } ) {
71
71
  const [ isLinkControlOpen, setIsLinkControlOpen ] = useState( false );
72
72
  const { popoverProps } = useInspectorPopoverPlacement( {
73
73
  isControl: true,
74
74
  } );
75
- const { fieldDef } = config;
76
75
  const value = field.getValue( { item: data } );
77
76
  const url = value?.url;
78
77
  const rel = value?.rel || '';
@@ -148,21 +147,10 @@ export default function Link( { data, field, onChange, config = {} } ) {
148
147
  );
149
148
  } }
150
149
  onRemove={ () => {
151
- // Remove all link-related properties based on what's in the mapping
152
- const removeValue = {};
153
-
154
- if ( fieldDef?.mapping ) {
155
- Object.keys( fieldDef.mapping ).forEach(
156
- ( key ) => {
157
- removeValue[ key ] = undefined;
158
- }
159
- );
160
- }
161
-
162
150
  onChange(
163
151
  field.setValue( {
164
152
  item: data,
165
- value: removeValue,
153
+ value: {},
166
154
  } )
167
155
  );
168
156
  } }
@@ -25,8 +25,7 @@ import { getMediaSelectKey } from '../../../store/private-keys';
25
25
  import { store as blockEditorStore } from '../../../store';
26
26
 
27
27
  function MediaThumbnail( { data, field, attachment, config } ) {
28
- const { fieldDef } = config;
29
- const { allowedTypes = [], multiple = false } = fieldDef.args || {};
28
+ const { allowedTypes = [], multiple = false } = config || {};
30
29
 
31
30
  if ( multiple ) {
32
31
  return 'todo multiple';
@@ -85,12 +84,11 @@ export default function Media( { data, field, onChange, config = {} } ) {
85
84
  isControl: true,
86
85
  } );
87
86
  const value = field.getValue( { item: data } );
88
- const { fieldDef } = config;
89
- const { allowedTypes = [], multiple = false } = fieldDef.args || {};
90
-
91
- // Check if featured image is supported by checking if it's in the mapping
92
- const hasFeaturedImageSupport =
93
- fieldDef?.mapping && 'featuredImage' in fieldDef.mapping;
87
+ const {
88
+ allowedTypes = [],
89
+ multiple = false,
90
+ useFeaturedImage = false,
91
+ } = config;
94
92
 
95
93
  const id = value?.id;
96
94
  const url = value?.url;
@@ -140,23 +138,14 @@ export default function Media( { data, field, onChange, config = {} } ) {
140
138
  multiple={ multiple }
141
139
  popoverProps={ popoverProps }
142
140
  onReset={ () => {
143
- // Build reset value dynamically based on mapping
144
- const resetValue = {};
145
-
146
- if ( fieldDef?.mapping ) {
147
- Object.keys( fieldDef.mapping ).forEach( ( key ) => {
148
- resetValue[ key ] = undefined;
149
- } );
150
- }
151
-
152
141
  onChange(
153
142
  field.setValue( {
154
143
  item: data,
155
- value: resetValue,
144
+ value: {},
156
145
  } )
157
146
  );
158
147
  } }
159
- { ...( hasFeaturedImageSupport && {
148
+ { ...( useFeaturedImage && {
160
149
  useFeaturedImage: !! value?.featuredImage,
161
150
  onToggleFeaturedImage: () => {
162
151
  onChange(
@@ -171,14 +160,13 @@ export default function Media( { data, field, onChange, config = {} } ) {
171
160
  } ) }
172
161
  onSelect={ ( selectedMedia ) => {
173
162
  if ( selectedMedia.id && selectedMedia.url ) {
174
- // Build new value dynamically based on what's in the mapping
175
163
  const newValue = {
176
164
  ...selectedMedia,
177
165
  mediaType: selectedMedia.media_type,
178
166
  };
179
167
 
180
168
  // Turn off featured image when manually selecting media
181
- if ( hasFeaturedImageSupport ) {
169
+ if ( useFeaturedImage ) {
182
170
  newValue.featuredImage = false;
183
171
  }
184
172
 
@@ -113,25 +113,26 @@ if ( window.crossOriginIsolated ) {
113
113
  'credentialless' in window.HTMLIFrameElement.prototype;
114
114
 
115
115
  const disableEmbedPreviews = createHigherOrderComponent(
116
- ( BlockEdit ) => ( props ) => {
117
- if ( 'core/embed' !== props.name ) {
118
- return <BlockEdit { ...props } />;
119
- }
120
-
121
- // List of embeds that do not support a preview is from packages/block-library/src/embed/variations.js.
122
- const previewable =
123
- supportsCredentialless &&
124
- ! [ 'facebook', 'smugmug' ].includes(
125
- props.attributes.providerNameSlug
116
+ ( BlockEdit ) =>
117
+ function DisableEmbedPreviews( props ) {
118
+ if ( 'core/embed' !== props.name ) {
119
+ return <BlockEdit { ...props } />;
120
+ }
121
+
122
+ // List of embeds that do not support a preview is from packages/block-library/src/embed/variations.js.
123
+ const previewable =
124
+ supportsCredentialless &&
125
+ ! [ 'facebook', 'smugmug' ].includes(
126
+ props.attributes.providerNameSlug
127
+ );
128
+
129
+ return (
130
+ <BlockEdit
131
+ { ...props }
132
+ attributes={ { ...props.attributes, previewable } }
133
+ />
126
134
  );
127
-
128
- return (
129
- <BlockEdit
130
- { ...props }
131
- attributes={ { ...props.attributes, previewable } }
132
- />
133
- );
134
- },
135
+ },
135
136
  'withDisabledEmbedPreview'
136
137
  );
137
138