@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
@@ -174,6 +174,7 @@ describe( 'metadata', () => {
174
174
 
175
175
  it( 'should preserve custom name metadata', () => {
176
176
  registerBlockType( 'core/bar', {
177
+ apiVersion: 3,
177
178
  title: 'Bar',
178
179
  } );
179
180
  const source = [
@@ -199,6 +200,7 @@ describe( 'metadata', () => {
199
200
 
200
201
  it( 'should not preserve custom name metadata when target block does not support renaming', () => {
201
202
  registerBlockType( 'core/bar', {
203
+ apiVersion: 3,
202
204
  title: 'Bar',
203
205
  supports: {
204
206
  renaming: false,
@@ -226,6 +228,7 @@ describe( 'metadata', () => {
226
228
 
227
229
  it( 'should preserve block visibility metadata', () => {
228
230
  registerBlockType( 'core/bar', {
231
+ apiVersion: 3,
229
232
  title: 'Bar',
230
233
  } );
231
234
 
@@ -252,6 +255,7 @@ describe( 'metadata', () => {
252
255
 
253
256
  it( 'should not preserve block visibility metadata when target block does not support it', () => {
254
257
  registerBlockType( 'core/bar', {
258
+ apiVersion: 3,
255
259
  title: 'Bar',
256
260
  supports: {
257
261
  visibility: false,
@@ -16,6 +16,7 @@ const noop = () => {};
16
16
 
17
17
  describe( 'textAlign', () => {
18
18
  const blockSettings = {
19
+ apiVersion: 3,
19
20
  save: noop,
20
21
  category: 'text',
21
22
  title: 'block title',
@@ -19,6 +19,7 @@ import {
19
19
  useBlockEditContext,
20
20
  mayDisplayControlsKey,
21
21
  mayDisplayParentControlsKey,
22
+ mayDisplayPatternEditingControlsKey,
22
23
  } from '../components/block-edit/context';
23
24
  import { useSettings } from '../components';
24
25
  import { useSettingsForBlockElement } from '../components/global-styles/hooks';
@@ -521,60 +522,66 @@ export function createBlockEditFilter( features ) {
521
522
  return { ...settings, Edit: memo( settings.edit ) };
522
523
  } );
523
524
  const withBlockEditHooks = createHigherOrderComponent(
524
- ( OriginalBlockEdit ) => ( props ) => {
525
- const context = useBlockEditContext();
526
- // CAUTION: code added before this line will be executed for all
527
- // blocks, not just those that support the feature! Code added
528
- // above this line should be carefully evaluated for its impact on
529
- // performance.
530
- return [
531
- ...features.map( ( feature, i ) => {
532
- const {
533
- Edit,
534
- hasSupport,
535
- attributeKeys = [],
536
- shareWithChildBlocks,
537
- } = feature;
538
- const shouldDisplayControls =
539
- context[ mayDisplayControlsKey ] ||
540
- ( context[ mayDisplayParentControlsKey ] &&
541
- shareWithChildBlocks );
525
+ ( OriginalBlockEdit ) =>
526
+ function WithBlockEditHooks( props ) {
527
+ const context = useBlockEditContext();
528
+ // CAUTION: code added before this line will be executed for all
529
+ // blocks, not just those that support the feature! Code added
530
+ // above this line should be carefully evaluated for its impact on
531
+ // performance.
532
+ return [
533
+ ...features.map( ( feature, i ) => {
534
+ const {
535
+ Edit,
536
+ hasSupport,
537
+ attributeKeys = [],
538
+ shareWithChildBlocks,
539
+ supportsPatternEditing,
540
+ } = feature;
541
+ const shouldDisplayControls =
542
+ ( supportsPatternEditing &&
543
+ context[
544
+ mayDisplayPatternEditingControlsKey
545
+ ] ) ||
546
+ context[ mayDisplayControlsKey ] ||
547
+ ( context[ mayDisplayParentControlsKey ] &&
548
+ shareWithChildBlocks );
542
549
 
543
- if (
544
- ! shouldDisplayControls ||
545
- ! hasSupport( props.name )
546
- ) {
547
- return null;
548
- }
549
-
550
- const neededProps = {};
551
- for ( const key of attributeKeys ) {
552
- if ( props.attributes[ key ] ) {
553
- neededProps[ key ] = props.attributes[ key ];
550
+ if (
551
+ ! shouldDisplayControls ||
552
+ ! hasSupport( props.name )
553
+ ) {
554
+ return null;
554
555
  }
555
- }
556
556
 
557
- return (
558
- <Edit
559
- // We can use the index because the array length
560
- // is fixed per page load right now.
561
- key={ i }
562
- name={ props.name }
563
- isSelected={ props.isSelected }
564
- clientId={ props.clientId }
565
- setAttributes={ props.setAttributes }
566
- __unstableParentLayout={
567
- props.__unstableParentLayout
557
+ const neededProps = {};
558
+ for ( const key of attributeKeys ) {
559
+ if ( props.attributes[ key ] ) {
560
+ neededProps[ key ] = props.attributes[ key ];
568
561
  }
569
- // This component is pure, so only pass needed
570
- // props!!!
571
- { ...neededProps }
572
- />
573
- );
574
- } ),
575
- <OriginalBlockEdit key="edit" { ...props } />,
576
- ];
577
- },
562
+ }
563
+
564
+ return (
565
+ <Edit
566
+ // We can use the index because the array length
567
+ // is fixed per page load right now.
568
+ key={ i }
569
+ name={ props.name }
570
+ isSelected={ props.isSelected }
571
+ clientId={ props.clientId }
572
+ setAttributes={ props.setAttributes }
573
+ __unstableParentLayout={
574
+ props.__unstableParentLayout
575
+ }
576
+ // This component is pure, so only pass needed
577
+ // props!!!
578
+ { ...neededProps }
579
+ />
580
+ );
581
+ } ),
582
+ <OriginalBlockEdit key="edit" { ...props } />,
583
+ ];
584
+ },
578
585
  'withBlockEditHooks'
579
586
  );
580
587
  addFilter( 'editor.BlockEdit', 'core/editor/hooks', withBlockEditHooks );
@@ -610,76 +617,77 @@ const BlockPropsPure = memo( BlockProps );
610
617
 
611
618
  export function createBlockListBlockFilter( features ) {
612
619
  const withBlockListBlockHooks = createHigherOrderComponent(
613
- ( BlockListBlock ) => ( props ) => {
614
- const [ allWrapperProps, setAllWrapperProps ] = useState(
615
- Array( features.length ).fill( undefined )
616
- );
617
- return [
618
- ...features.map( ( feature, i ) => {
619
- const {
620
- hasSupport,
621
- attributeKeys = [],
622
- useBlockProps,
623
- isMatch,
624
- } = feature;
620
+ ( BlockListBlock ) =>
621
+ function WithBlockListBlockHooks( props ) {
622
+ const [ allWrapperProps, setAllWrapperProps ] = useState(
623
+ Array( features.length ).fill( undefined )
624
+ );
625
+ return [
626
+ ...features.map( ( feature, i ) => {
627
+ const {
628
+ hasSupport,
629
+ attributeKeys = [],
630
+ useBlockProps,
631
+ isMatch,
632
+ } = feature;
625
633
 
626
- const neededProps = {};
627
- for ( const key of attributeKeys ) {
628
- if ( props.attributes[ key ] ) {
629
- neededProps[ key ] = props.attributes[ key ];
634
+ const neededProps = {};
635
+ for ( const key of attributeKeys ) {
636
+ if ( props.attributes[ key ] ) {
637
+ neededProps[ key ] = props.attributes[ key ];
638
+ }
630
639
  }
631
- }
632
640
 
633
- if (
634
- // Skip rendering if none of the needed attributes are
635
- // set.
636
- ! Object.keys( neededProps ).length ||
637
- ! hasSupport( props.name ) ||
638
- ( isMatch && ! isMatch( neededProps ) )
639
- ) {
640
- return null;
641
- }
641
+ if (
642
+ // Skip rendering if none of the needed attributes are
643
+ // set.
644
+ ! Object.keys( neededProps ).length ||
645
+ ! hasSupport( props.name ) ||
646
+ ( isMatch && ! isMatch( neededProps ) )
647
+ ) {
648
+ return null;
649
+ }
642
650
 
643
- return (
644
- <BlockPropsPure
645
- // We can use the index because the array length
646
- // is fixed per page load right now.
647
- key={ i }
648
- index={ i }
649
- useBlockProps={ useBlockProps }
650
- // This component is pure, so we must pass a stable
651
- // function reference.
652
- setAllWrapperProps={ setAllWrapperProps }
653
- name={ props.name }
654
- clientId={ props.clientId }
655
- // This component is pure, so only pass needed
656
- // props!!!
657
- { ...neededProps }
658
- />
659
- );
660
- } ),
661
- <BlockListBlock
662
- key="edit"
663
- { ...props }
664
- wrapperProps={ allWrapperProps
665
- .filter( Boolean )
666
- .reduce( ( acc, wrapperProps ) => {
667
- return {
668
- ...acc,
669
- ...wrapperProps,
670
- className: clsx(
671
- acc.className,
672
- wrapperProps.className
673
- ),
674
- style: {
675
- ...acc.style,
676
- ...wrapperProps.style,
677
- },
678
- };
679
- }, props.wrapperProps || {} ) }
680
- />,
681
- ];
682
- },
651
+ return (
652
+ <BlockPropsPure
653
+ // We can use the index because the array length
654
+ // is fixed per page load right now.
655
+ key={ i }
656
+ index={ i }
657
+ useBlockProps={ useBlockProps }
658
+ // This component is pure, so we must pass a stable
659
+ // function reference.
660
+ setAllWrapperProps={ setAllWrapperProps }
661
+ name={ props.name }
662
+ clientId={ props.clientId }
663
+ // This component is pure, so only pass needed
664
+ // props!!!
665
+ { ...neededProps }
666
+ />
667
+ );
668
+ } ),
669
+ <BlockListBlock
670
+ key="edit"
671
+ { ...props }
672
+ wrapperProps={ allWrapperProps
673
+ .filter( Boolean )
674
+ .reduce( ( acc, wrapperProps ) => {
675
+ return {
676
+ ...acc,
677
+ ...wrapperProps,
678
+ className: clsx(
679
+ acc.className,
680
+ wrapperProps.className
681
+ ),
682
+ style: {
683
+ ...acc.style,
684
+ ...wrapperProps.style,
685
+ },
686
+ };
687
+ }, props.wrapperProps || {} ) }
688
+ />,
689
+ ];
690
+ },
683
691
  'withBlockListBlockHooks'
684
692
  );
685
693
  addFilter(
@@ -113,6 +113,7 @@ export default {
113
113
  style,
114
114
  blockName,
115
115
  hasBlockGapSupport,
116
+ globalBlockGapValue,
116
117
  layoutDefinitions = LAYOUT_DEFINITIONS,
117
118
  } ) {
118
119
  const {
@@ -146,13 +147,28 @@ export default {
146
147
  ? getGapCSSValue( style?.spacing?.blockGap, '0.5em' )
147
148
  : undefined;
148
149
 
150
+ // Use the global blockGap value for grid column calculations when available
151
+ // If the gap value has both top and left (separated by space), use the left value for horizontal calculations
152
+ let fallbackGapValue = '1.2rem';
153
+ if ( globalBlockGapValue ) {
154
+ const processedGap = getGapCSSValue( globalBlockGapValue, '0.5em' );
155
+ const gapParts = processedGap.split( ' ' );
156
+ fallbackGapValue =
157
+ gapParts.length > 1 ? gapParts[ 1 ] : gapParts[ 0 ];
158
+ }
159
+
149
160
  let output = '';
150
161
  const rules = [];
151
162
 
152
163
  if ( minimumColumnWidth && columnCount > 0 ) {
153
- const maxValue = `max(${ minimumColumnWidth }, ( 100% - (${
154
- blockGapValue || '1.2rem'
155
- }*${ columnCount - 1 }) ) / ${ columnCount })`;
164
+ let blockGapToUse = blockGapValue || fallbackGapValue;
165
+ // Ensure 0 values have a unit so they work in calc().
166
+ if ( blockGapToUse === '0' || blockGapToUse === 0 ) {
167
+ blockGapToUse = '0px';
168
+ }
169
+ const maxValue = `max(min( ${ minimumColumnWidth }, 100%), ( 100% - (${ blockGapToUse }*${
170
+ columnCount - 1
171
+ }) ) / ${ columnCount })`;
156
172
  rules.push(
157
173
  `grid-template-columns: repeat(auto-fill, minmax(${ maxValue }, 1fr))`,
158
174
  `container-type: inline-size`
@@ -33,7 +33,7 @@ describe( 'getLayoutStyle', () => {
33
33
  expect( result ).toBe( expected );
34
34
  } );
35
35
  it( 'should return `grid-template-columns` with max() function if both minimumColumnWidth and columnCount are provided', () => {
36
- const expected = `.my-container { grid-template-columns: repeat(auto-fill, minmax(max(12rem, ( 100% - (1.2rem*2) ) / 3), 1fr)); container-type: inline-size; }`;
36
+ const expected = `.my-container { grid-template-columns: repeat(auto-fill, minmax(max(min( 12rem, 100%), ( 100% - (1.2rem*2) ) / 3), 1fr)); container-type: inline-size; }`;
37
37
 
38
38
  const result = grid.getLayoutStyle( {
39
39
  selector: '.my-container',
@@ -157,6 +157,10 @@ export const SETTINGS_DEFAULTS = {
157
157
  // Allows to disable block locking interface.
158
158
  canLockBlocks: true,
159
159
 
160
+ // Whether the user can edit custom CSS (requires edit_css capability).
161
+ // Defaults to false for safety - PHP passes true when user has capability.
162
+ canEditCSS: false,
163
+
160
164
  // Allows to disable Openverse media category in the inserter.
161
165
  enableOpenverseMediaCategory: true,
162
166
 
@@ -36,12 +36,8 @@ import {
36
36
  reusableBlocksSelectKey,
37
37
  sectionRootClientIdKey,
38
38
  isIsolatedEditorKey,
39
- deviceTypeKey,
40
39
  } from './private-keys';
41
- import {
42
- BLOCK_VISIBILITY_VIEWPORT_ENTRIES,
43
- BLOCK_VISIBILITY_VIEWPORTS,
44
- } from '../components/block-visibility/constants';
40
+ import { BLOCK_VISIBILITY_VIEWPORTS } from '../components/block-visibility/constants';
45
41
 
46
42
  const { isContentBlock } = unlock( blocksPrivateApis );
47
43
 
@@ -703,18 +699,22 @@ export function getInsertionPoint( state ) {
703
699
  }
704
700
 
705
701
  /**
706
- * Returns true if the block is hidden, or false otherwise.
702
+ * Returns true if the block is hidden anywhere, or false otherwise.
703
+ *
704
+ * This selector checks whether a block has visibility metadata set that would
705
+ * hide it at any viewport or everywhere. It's useful for flagging blocks that
706
+ * have visibility restrictions.
707
707
  *
708
- * A block is considered hidden if:
708
+ * A block is considered hidden anywhere if:
709
709
  * - blockVisibility is false (hidden everywhere)
710
- * - blockVisibility is an object with the current device preview set to false
710
+ * - blockVisibility.viewport has any viewport set to false (hidden at specific screen sizes)
711
711
  *
712
712
  * @param {Object} state Global application state.
713
713
  * @param {string} clientId Client ID of the block.
714
714
  *
715
- * @return {boolean} Whether the block is hidden.
715
+ * @return {boolean} Whether the block is hidden anywhere.
716
716
  */
717
- export const isBlockHidden = ( state, clientId ) => {
717
+ export const isBlockHiddenAnywhere = ( state, clientId ) => {
718
718
  const blockName = getBlockName( state, clientId );
719
719
  if ( ! hasBlockSupport( blockName, 'visibility', true ) ) {
720
720
  return false;
@@ -726,79 +726,110 @@ export const isBlockHidden = ( state, clientId ) => {
726
726
  return true;
727
727
  }
728
728
 
729
- if ( ! window.__experimentalHideBlocksBasedOnScreenSize ) {
730
- return false;
729
+ if (
730
+ typeof blockVisibility?.viewport === 'object' &&
731
+ blockVisibility?.viewport !== null
732
+ ) {
733
+ // Check if the block is hidden at any viewport.
734
+ return Object.values( BLOCK_VISIBILITY_VIEWPORTS ).some(
735
+ ( viewport ) =>
736
+ blockVisibility?.viewport?.[ viewport.key ] === false
737
+ );
731
738
  }
739
+ return false;
740
+ };
732
741
 
733
- // Check viewport-specific hiding based on current device preview
734
- // Only apply when a device is explicitly selected.
735
- if ( typeof blockVisibility === 'object' && blockVisibility !== null ) {
736
- const settings = getSettings( state );
737
- const viewportType =
738
- settings[ deviceTypeKey ] ?? BLOCK_VISIBILITY_VIEWPORTS.desktop.key;
739
- const viewportKey = viewportType.toLowerCase();
740
- return blockVisibility?.[ viewportKey ] === false;
742
+ /**
743
+ * Returns true if the block is hidden everywhere (blockVisibility is false).
744
+ *
745
+ * A block is considered hidden everywhere when blockVisibility is explicitly
746
+ * set to false, which means it's hidden on all viewports.
747
+ *
748
+ * @param {Object} state Global application state.
749
+ * @param {string} clientId Client ID of the block.
750
+ *
751
+ * @return {boolean} Whether the block is hidden everywhere.
752
+ */
753
+ export const isBlockHiddenEverywhere = ( state, clientId ) => {
754
+ const blockName = getBlockName( state, clientId );
755
+ if ( ! hasBlockSupport( blockName, 'visibility', true ) ) {
756
+ return false;
741
757
  }
758
+ const attributes = state.blocks.attributes.get( clientId );
759
+ const blockVisibility = attributes?.metadata?.blockVisibility;
742
760
 
761
+ if ( blockVisibility === false ) {
762
+ return true;
763
+ }
743
764
  return false;
744
765
  };
745
766
 
746
767
  /**
747
- * Returns true if any of the provided blocks are hidden.
768
+ * Returns true if any parent block (immediate or further up the chain) is hidden everywhere.
748
769
  *
749
- * @param {Object} state Global application state.
750
- * @param {Array} clientIds Array of block client IDs to check.
751
- * @return {boolean} Whether any block is hidden.
770
+ * Checks all parent blocks in the hierarchy and returns true if any of them
771
+ * is hidden everywhere.
772
+ *
773
+ * @param {Object} state Global application state.
774
+ * @param {string} clientId Client ID of the block.
775
+ *
776
+ * @return {boolean} Whether any parent block is hidden everywhere.
752
777
  */
753
- export const areBlocksHidden = ( state, clientIds ) => {
754
- if ( ! clientIds || clientIds.length === 0 ) {
755
- return false;
756
- }
757
- return clientIds.some( ( clientId ) => isBlockHidden( state, clientId ) );
778
+ export const isBlockParentHiddenEverywhere = ( state, clientId ) => {
779
+ const parents = getBlockParents( state, clientId );
780
+ return parents.some( ( parentId ) =>
781
+ isBlockHiddenEverywhere( state, parentId )
782
+ );
758
783
  };
759
784
 
760
785
  /**
761
- * Checks if at least one block in an array is hidden according to viewport visibility metadata.
786
+ * Returns true if the block is hidden at the given viewport.
762
787
  *
763
- * This is typically used to determine if the block visibility button should be shown in the toolbar.
764
- * TODO: This is temporary for now. Later the UI will
765
- * want to know where exactly the block is hidden, e.g., to display icons or other things.
788
+ * A block is considered hidden at a viewport if:
789
+ * - blockVisibility is false (hidden everywhere)
790
+ * - blockVisibility is an object with the specified viewport set to false
766
791
  *
767
- * A block is considered hidden if:
768
- * - Its `blockVisibility` metadata is `false` (hidden everywhere), or
769
- * - Any viewport is set to `false`
792
+ * @param {Object} state Global application state.
793
+ * @param {string} clientId Client ID of the block.
794
+ * @param {string} viewport Viewport to check ('desktop', 'tablet', 'mobile').
770
795
  *
771
- * @param {Object} state Global application state.
772
- * @param {Array} clientIds Array of block client IDs to check.
773
- * @return {boolean} `true` if at least one block meets the visibility criteria, `false` otherwise.
796
+ * @return {boolean} Whether the block is hidden at the viewport.
774
797
  */
775
- export const areBlocksHiddenAnywhere = ( state, clientIds ) => {
776
- if ( ! clientIds?.length ) {
777
- return false;
798
+ export const isBlockHiddenAtViewport = ( state, clientId, viewport ) => {
799
+ if ( isBlockHiddenEverywhere( state, clientId ) ) {
800
+ return true;
778
801
  }
779
- return clientIds.some( ( clientId ) => {
780
- if ( ! clientId ) {
781
- return false;
782
- }
783
-
784
- const attributes = state.blocks.attributes.get( clientId );
785
- const blockVisibility = attributes?.metadata?.blockVisibility;
786
-
787
- // If explicitly hidden everywhere (false), return true.
788
- if ( typeof blockVisibility === 'boolean' ) {
789
- return blockVisibility === false;
790
- }
791
802
 
792
- // If not an object, block is not hidden in any viewport.
793
- if ( 'object' !== typeof blockVisibility ) {
794
- return false;
795
- }
803
+ const attributes = state.blocks.attributes.get( clientId );
804
+ const blockVisibilityViewport =
805
+ attributes?.metadata?.blockVisibility?.viewport;
806
+ if (
807
+ typeof blockVisibilityViewport === 'object' &&
808
+ blockVisibilityViewport !== null &&
809
+ typeof viewport === 'string'
810
+ ) {
811
+ return blockVisibilityViewport?.[ viewport.toLowerCase() ] === false;
812
+ }
813
+ return false;
814
+ };
796
815
 
797
- // Check viewport-specific visibility.
798
- return BLOCK_VISIBILITY_VIEWPORT_ENTRIES.some(
799
- ( [ , { key } ] ) => blockVisibility?.[ key ] === false
800
- );
801
- } );
816
+ /**
817
+ * Returns true if any parent block (immediate or further up the chain) is hidden at the given viewport.
818
+ *
819
+ * Checks all parent blocks in the hierarchy and returns true if any of them
820
+ * is hidden at the specified viewport.
821
+ *
822
+ * @param {Object} state Global application state.
823
+ * @param {string} clientId Client ID of the block.
824
+ * @param {string} viewport Viewport to check ('desktop', 'tablet', 'mobile').
825
+ *
826
+ * @return {boolean} Whether any parent block is hidden at the viewport.
827
+ */
828
+ export const isBlockParentHiddenAtViewport = ( state, clientId, viewport ) => {
829
+ const parents = getBlockParents( state, clientId );
830
+ return parents.some( ( parentId ) =>
831
+ isBlockHiddenAtViewport( state, parentId, viewport )
832
+ );
802
833
  };
803
834
 
804
835
  /**
@@ -2279,13 +2279,21 @@ export const getInserterItems = createRegistrySelector( ( select ) =>
2279
2279
  )
2280
2280
  );
2281
2281
  } else {
2282
+ const { getClosestAllowedInsertionPoint } = unlock(
2283
+ select( STORE_NAME )
2284
+ );
2282
2285
  blockTypeInserterItems = blockTypeInserterItems
2283
- .filter( ( blockType ) =>
2284
- isBlockVisibleInTheInserter(
2285
- state,
2286
- blockType,
2287
- rootClientId
2288
- )
2286
+ .filter(
2287
+ ( blockType ) =>
2288
+ isBlockVisibleInTheInserter(
2289
+ state,
2290
+ blockType,
2291
+ rootClientId
2292
+ ) &&
2293
+ getClosestAllowedInsertionPoint(
2294
+ blockType.name,
2295
+ rootClientId
2296
+ ) !== null
2289
2297
  )
2290
2298
  .map( ( blockType ) => ( {
2291
2299
  ...blockType,
@@ -60,6 +60,7 @@ const {
60
60
 
61
61
  describe( 'actions', () => {
62
62
  const defaultBlockSettings = {
63
+ apiVersion: 3,
63
64
  attributes: {
64
65
  content: {},
65
66
  },
@@ -863,6 +864,7 @@ describe( 'actions', () => {
863
864
 
864
865
  it( 'should merge the blocks if blocks of the same type', () => {
865
866
  registerBlockType( 'core/test-block', {
867
+ apiVersion: 3,
866
868
  attributes: {
867
869
  content: {},
868
870
  },
@@ -933,6 +935,7 @@ describe( 'actions', () => {
933
935
 
934
936
  it( 'should not merge the blocks have different types without transformation', () => {
935
937
  registerBlockType( 'core/test-block', {
938
+ apiVersion: 3,
936
939
  attributes: {
937
940
  content: {},
938
941
  },
@@ -986,6 +989,7 @@ describe( 'actions', () => {
986
989
 
987
990
  it( 'should transform and merge the blocks', () => {
988
991
  registerBlockType( 'core/test-block', {
992
+ apiVersion: 3,
989
993
  attributes: {
990
994
  content: {
991
995
  type: 'string',
@@ -1004,6 +1008,7 @@ describe( 'actions', () => {
1004
1008
  title: 'test block',
1005
1009
  } );
1006
1010
  registerBlockType( 'core/test-block-2', {
1011
+ apiVersion: 3,
1007
1012
  attributes: {
1008
1013
  content2: {
1009
1014
  type: 'string',
@@ -1081,6 +1086,7 @@ describe( 'actions', () => {
1081
1086
 
1082
1087
  it( 'should not merge the blocks if blockB editing mode is `disabled`', () => {
1083
1088
  registerBlockType( 'core/test-block', {
1089
+ apiVersion: 3,
1084
1090
  attributes: {
1085
1091
  content: {},
1086
1092
  },
@@ -1140,6 +1146,7 @@ describe( 'actions', () => {
1140
1146
 
1141
1147
  it( 'should not merge the blocks if blockA editing mode is `disabled`', () => {
1142
1148
  registerBlockType( 'core/test-block', {
1149
+ apiVersion: 3,
1143
1150
  attributes: {
1144
1151
  content: {},
1145
1152
  },