@wordpress/block-editor 12.16.0 → 12.16.1-next.79a6196f.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 (650) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +3 -6
  3. package/build/components/block-canvas/index.js +0 -2
  4. package/build/components/block-canvas/index.js.map +1 -1
  5. package/build/components/block-card/index.js +1 -1
  6. package/build/components/block-card/index.js.map +1 -1
  7. package/build/components/block-draggable/draggable-chip.js +6 -1
  8. package/build/components/block-draggable/draggable-chip.js.map +1 -1
  9. package/build/components/block-draggable/index.js +76 -6
  10. package/build/components/block-draggable/index.js.map +1 -1
  11. package/build/components/block-draggable/index.native.js +0 -6
  12. package/build/components/block-draggable/index.native.js.map +1 -1
  13. package/build/components/block-draggable/use-scroll-when-dragging.native.js +1 -1
  14. package/build/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -1
  15. package/build/components/block-editing-mode/index.js +2 -3
  16. package/build/components/block-editing-mode/index.js.map +1 -1
  17. package/build/components/block-inspector/index.js +1 -1
  18. package/build/components/block-inspector/index.js.map +1 -1
  19. package/build/components/block-list/block-list-item-cell.native.js +1 -0
  20. package/build/components/block-list/block-list-item-cell.native.js.map +1 -1
  21. package/build/components/block-list/block.js +245 -102
  22. package/build/components/block-list/block.js.map +1 -1
  23. package/build/components/block-list/block.native.js +46 -20
  24. package/build/components/block-list/block.native.js.map +1 -1
  25. package/build/components/block-list/index.native.js +3 -5
  26. package/build/components/block-list/index.native.js.map +1 -1
  27. package/build/components/block-list/private-block-context.js +14 -0
  28. package/build/components/block-list/private-block-context.js.map +1 -0
  29. package/build/components/block-list/use-block-props/index.js +33 -96
  30. package/build/components/block-list/use-block-props/index.js.map +1 -1
  31. package/build/components/block-list/use-in-between-inserter.js +3 -2
  32. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  33. package/build/components/block-list/use-scroll-upon-insertion.native.js +41 -0
  34. package/build/components/block-list/use-scroll-upon-insertion.native.js.map +1 -0
  35. package/build/components/block-lock/toolbar.js +21 -27
  36. package/build/components/block-lock/toolbar.js.map +1 -1
  37. package/build/components/block-mover/index.js +2 -1
  38. package/build/components/block-mover/index.js.map +1 -1
  39. package/build/components/block-patterns-list/index.js +4 -4
  40. package/build/components/block-patterns-list/index.js.map +1 -1
  41. package/build/components/block-switcher/index.js +4 -4
  42. package/build/components/block-switcher/index.js.map +1 -1
  43. package/build/components/block-toolbar/index.js +1 -2
  44. package/build/components/block-toolbar/index.js.map +1 -1
  45. package/build/components/block-tools/block-toolbar-popover.js +0 -2
  46. package/build/components/block-tools/block-toolbar-popover.js.map +1 -1
  47. package/build/components/block-variation-transforms/index.js +29 -2
  48. package/build/components/block-variation-transforms/index.js.map +1 -1
  49. package/build/components/border-radius-control/linked-button.js +1 -1
  50. package/build/components/border-radius-control/linked-button.js.map +1 -1
  51. package/build/components/colors/utils.js +10 -2
  52. package/build/components/colors/utils.js.map +1 -1
  53. package/build/components/colors/with-colors.js +6 -2
  54. package/build/components/colors/with-colors.js.map +1 -1
  55. package/build/components/font-sizes/utils.js +10 -2
  56. package/build/components/font-sizes/utils.js.map +1 -1
  57. package/build/components/global-styles/border-panel.js +2 -1
  58. package/build/components/global-styles/border-panel.js.map +1 -1
  59. package/build/components/global-styles/color-panel.js +2 -1
  60. package/build/components/global-styles/color-panel.js.map +1 -1
  61. package/build/components/global-styles/dimensions-panel.js +4 -3
  62. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  63. package/build/components/global-styles/effects-panel.js +2 -1
  64. package/build/components/global-styles/effects-panel.js.map +1 -1
  65. package/build/components/global-styles/filters-panel.js +1 -4
  66. package/build/components/global-styles/filters-panel.js.map +1 -1
  67. package/build/components/global-styles/get-global-styles-changes.js +192 -0
  68. package/build/components/global-styles/get-global-styles-changes.js.map +1 -0
  69. package/build/components/global-styles/hooks.js +3 -2
  70. package/build/components/global-styles/hooks.js.map +1 -1
  71. package/build/components/global-styles/image-settings-panel.js +7 -1
  72. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  73. package/build/components/global-styles/index.js +7 -0
  74. package/build/components/global-styles/index.js.map +1 -1
  75. package/build/components/global-styles/typography-panel.js +33 -15
  76. package/build/components/global-styles/typography-panel.js.map +1 -1
  77. package/build/components/global-styles/use-global-styles-output.js +22 -8
  78. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  79. package/build/components/global-styles/utils.js +8 -1
  80. package/build/components/global-styles/utils.js.map +1 -1
  81. package/build/components/height-control/index.js +6 -2
  82. package/build/components/height-control/index.js.map +1 -1
  83. package/build/components/image-size-control/index.js +2 -2
  84. package/build/components/image-size-control/index.js.map +1 -1
  85. package/build/components/index.native.js +6 -5
  86. package/build/components/index.native.js.map +1 -1
  87. package/build/components/inner-blocks/index.js +61 -22
  88. package/build/components/inner-blocks/index.js.map +1 -1
  89. package/build/components/inner-blocks/index.native.js +18 -4
  90. package/build/components/inner-blocks/index.native.js.map +1 -1
  91. package/build/components/inner-blocks/use-inner-block-template-sync.js +5 -6
  92. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  93. package/build/components/inner-blocks/use-nested-settings-update.js +5 -9
  94. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  95. package/build/components/inserter/block-patterns-explorer/pattern-list.js +1 -1
  96. package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  97. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +10 -9
  98. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  99. package/build/components/inserter/block-patterns-tab/patterns-filter.js +10 -10
  100. package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  101. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +9 -9
  102. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
  103. package/build/components/inserter/block-patterns-tab/utils.js +10 -14
  104. package/build/components/inserter/block-patterns-tab/utils.js.map +1 -1
  105. package/build/components/inserter/hooks/use-block-types-state.js +4 -14
  106. package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
  107. package/build/components/inserter/hooks/use-patterns-state.js +1 -1
  108. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  109. package/build/components/inserter/index.js +1 -2
  110. package/build/components/inserter/index.js.map +1 -1
  111. package/build/components/inserter/library.js +3 -7
  112. package/build/components/inserter/library.js.map +1 -1
  113. package/build/components/inserter/menu.js +14 -28
  114. package/build/components/inserter/menu.js.map +1 -1
  115. package/build/components/inserter/tabs.js +21 -21
  116. package/build/components/inserter/tabs.js.map +1 -1
  117. package/build/components/inserter-draggable-blocks/index.js +1 -1
  118. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  119. package/build/components/inserter-list-item/index.js +2 -4
  120. package/build/components/inserter-list-item/index.js.map +1 -1
  121. package/build/components/inspector-controls/block-support-tools-panel.js +3 -1
  122. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  123. package/build/components/inspector-controls-tabs/index.js +34 -23
  124. package/build/components/inspector-controls-tabs/index.js.map +1 -1
  125. package/build/components/list-view/block-select-button.js +4 -0
  126. package/build/components/list-view/block-select-button.js.map +1 -1
  127. package/build/components/list-view/block.js +57 -3
  128. package/build/components/list-view/block.js.map +1 -1
  129. package/build/components/media-upload-progress/constants.js +19 -0
  130. package/build/components/media-upload-progress/constants.js.map +1 -0
  131. package/build/components/media-upload-progress/index.native.js +42 -17
  132. package/build/components/media-upload-progress/index.native.js.map +1 -1
  133. package/build/components/navigable-toolbar/index.js +9 -14
  134. package/build/components/navigable-toolbar/index.js.map +1 -1
  135. package/build/components/plain-text/index.native.js +8 -3
  136. package/build/components/plain-text/index.native.js.map +1 -1
  137. package/build/components/provider/index.js +3 -1
  138. package/build/components/provider/index.js.map +1 -1
  139. package/build/components/provider/use-block-sync.js +7 -1
  140. package/build/components/provider/use-block-sync.js.map +1 -1
  141. package/build/components/rich-text/index.js +17 -7
  142. package/build/components/rich-text/index.js.map +1 -1
  143. package/build/components/rich-text/native/index.native.js +16 -24
  144. package/build/components/rich-text/native/index.native.js.map +1 -1
  145. package/build/components/rich-text/use-input-rules.js +2 -2
  146. package/build/components/rich-text/use-input-rules.js.map +1 -1
  147. package/build/components/rich-text/use-mark-persistent.js +1 -1
  148. package/build/components/rich-text/use-mark-persistent.js.map +1 -1
  149. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  150. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  151. package/build/components/url-input/index.js +9 -6
  152. package/build/components/url-input/index.js.map +1 -1
  153. package/build/components/use-block-commands/index.js +14 -18
  154. package/build/components/use-block-commands/index.js.map +1 -1
  155. package/build/components/use-block-drop-zone/index.js +51 -22
  156. package/build/components/use-block-drop-zone/index.js.map +1 -1
  157. package/build/components/use-moving-animation/index.js +100 -92
  158. package/build/components/use-moving-animation/index.js.map +1 -1
  159. package/build/components/use-on-block-drop/index.js +8 -11
  160. package/build/components/use-on-block-drop/index.js.map +1 -1
  161. package/build/components/writing-flow/index.js +0 -1
  162. package/build/components/writing-flow/index.js.map +1 -1
  163. package/build/components/writing-flow/use-drag-selection.js +15 -4
  164. package/build/components/writing-flow/use-drag-selection.js.map +1 -1
  165. package/build/components/writing-flow/use-selection-observer.js +73 -27
  166. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  167. package/build/components/writing-flow/use-tab-nav.js +7 -4
  168. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  169. package/build/hooks/align.js +1 -1
  170. package/build/hooks/align.js.map +1 -1
  171. package/build/hooks/anchor.js +1 -1
  172. package/build/hooks/anchor.js.map +1 -1
  173. package/build/hooks/aria-label.js +9 -1
  174. package/build/hooks/aria-label.js.map +1 -1
  175. package/build/hooks/background.js +185 -20
  176. package/build/hooks/background.js.map +1 -1
  177. package/build/hooks/border.js +5 -10
  178. package/build/hooks/border.js.map +1 -1
  179. package/build/hooks/color.js +13 -11
  180. package/build/hooks/color.js.map +1 -1
  181. package/build/hooks/custom-class-name.js +1 -1
  182. package/build/hooks/custom-class-name.js.map +1 -1
  183. package/build/hooks/custom-class-name.native.js +9 -1
  184. package/build/hooks/custom-class-name.native.js.map +1 -1
  185. package/build/hooks/dimensions.js +4 -9
  186. package/build/hooks/dimensions.js.map +1 -1
  187. package/build/hooks/font-family.js +7 -3
  188. package/build/hooks/font-family.js.map +1 -1
  189. package/build/hooks/font-size.js +1 -1
  190. package/build/hooks/font-size.js.map +1 -1
  191. package/build/hooks/index.js +4 -4
  192. package/build/hooks/index.js.map +1 -1
  193. package/build/hooks/index.native.js +5 -3
  194. package/build/hooks/index.native.js.map +1 -1
  195. package/build/hooks/layout.js +10 -4
  196. package/build/hooks/layout.js.map +1 -1
  197. package/build/hooks/style.js +1 -1
  198. package/build/hooks/style.js.map +1 -1
  199. package/build/hooks/typography.js +4 -9
  200. package/build/hooks/typography.js.map +1 -1
  201. package/build/hooks/typography.native.js +43 -18
  202. package/build/hooks/typography.native.js.map +1 -1
  203. package/build/hooks/use-typography-props.js +10 -2
  204. package/build/hooks/use-typography-props.js.map +1 -1
  205. package/build/hooks/utils.js +48 -5
  206. package/build/hooks/utils.js.map +1 -1
  207. package/build/private-apis.js +2 -4
  208. package/build/private-apis.js.map +1 -1
  209. package/build/private-apis.native.js +0 -2
  210. package/build/private-apis.native.js.map +1 -1
  211. package/build/store/actions.js +0 -16
  212. package/build/store/actions.js.map +1 -1
  213. package/build/store/private-actions.js +51 -5
  214. package/build/store/private-actions.js.map +1 -1
  215. package/build/store/private-selectors.js +12 -0
  216. package/build/store/private-selectors.js.map +1 -1
  217. package/build/store/reducer.js +14 -6
  218. package/build/store/reducer.js.map +1 -1
  219. package/build/store/selectors.js +1 -13
  220. package/build/store/selectors.js.map +1 -1
  221. package/build/store/undo-ignore.js +12 -0
  222. package/build/store/undo-ignore.js.map +1 -0
  223. package/build/store/utils.js +1 -1
  224. package/build/store/utils.js.map +1 -1
  225. package/build/utils/get-px-from-css-unit.js +16 -0
  226. package/build/utils/get-px-from-css-unit.js.map +1 -0
  227. package/build/utils/index.js +2 -2
  228. package/build/utils/index.js.map +1 -1
  229. package/build/utils/object.js +17 -38
  230. package/build/utils/object.js.map +1 -1
  231. package/build/utils/use-can-block-toolbar-be-focused.js +46 -0
  232. package/build/utils/use-can-block-toolbar-be-focused.js.map +1 -0
  233. package/build-module/components/block-canvas/index.js +0 -2
  234. package/build-module/components/block-canvas/index.js.map +1 -1
  235. package/build-module/components/block-card/index.js +1 -1
  236. package/build-module/components/block-card/index.js.map +1 -1
  237. package/build-module/components/block-draggable/draggable-chip.js +6 -1
  238. package/build-module/components/block-draggable/draggable-chip.js.map +1 -1
  239. package/build-module/components/block-draggable/index.js +76 -6
  240. package/build-module/components/block-draggable/index.js.map +1 -1
  241. package/build-module/components/block-draggable/index.native.js +1 -7
  242. package/build-module/components/block-draggable/index.native.js.map +1 -1
  243. package/build-module/components/block-draggable/use-scroll-when-dragging.native.js +1 -1
  244. package/build-module/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -1
  245. package/build-module/components/block-editing-mode/index.js +3 -4
  246. package/build-module/components/block-editing-mode/index.js.map +1 -1
  247. package/build-module/components/block-inspector/index.js +1 -1
  248. package/build-module/components/block-inspector/index.js.map +1 -1
  249. package/build-module/components/block-list/block-list-item-cell.native.js +1 -0
  250. package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -1
  251. package/build-module/components/block-list/block.js +249 -106
  252. package/build-module/components/block-list/block.js.map +1 -1
  253. package/build-module/components/block-list/block.native.js +48 -22
  254. package/build-module/components/block-list/block.native.js.map +1 -1
  255. package/build-module/components/block-list/index.native.js +3 -5
  256. package/build-module/components/block-list/index.native.js.map +1 -1
  257. package/build-module/components/block-list/private-block-context.js +6 -0
  258. package/build-module/components/block-list/private-block-context.js.map +1 -0
  259. package/build-module/components/block-list/use-block-props/index.js +34 -97
  260. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  261. package/build-module/components/block-list/use-in-between-inserter.js +3 -2
  262. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  263. package/build-module/components/block-list/use-scroll-upon-insertion.native.js +33 -0
  264. package/build-module/components/block-list/use-scroll-upon-insertion.native.js.map +1 -0
  265. package/build-module/components/block-lock/toolbar.js +22 -28
  266. package/build-module/components/block-lock/toolbar.js.map +1 -1
  267. package/build-module/components/block-mover/index.js +2 -1
  268. package/build-module/components/block-mover/index.js.map +1 -1
  269. package/build-module/components/block-patterns-list/index.js +5 -5
  270. package/build-module/components/block-patterns-list/index.js.map +1 -1
  271. package/build-module/components/block-switcher/index.js +4 -4
  272. package/build-module/components/block-switcher/index.js.map +1 -1
  273. package/build-module/components/block-toolbar/index.js +1 -2
  274. package/build-module/components/block-toolbar/index.js.map +1 -1
  275. package/build-module/components/block-tools/block-toolbar-popover.js +0 -2
  276. package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -1
  277. package/build-module/components/block-variation-transforms/index.js +30 -3
  278. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  279. package/build-module/components/border-radius-control/linked-button.js +1 -1
  280. package/build-module/components/border-radius-control/linked-button.js.map +1 -1
  281. package/build-module/components/colors/utils.js +9 -1
  282. package/build-module/components/colors/utils.js.map +1 -1
  283. package/build-module/components/colors/with-colors.js +5 -1
  284. package/build-module/components/colors/with-colors.js.map +1 -1
  285. package/build-module/components/font-sizes/utils.js +9 -1
  286. package/build-module/components/font-sizes/utils.js.map +1 -1
  287. package/build-module/components/global-styles/border-panel.js +3 -2
  288. package/build-module/components/global-styles/border-panel.js.map +1 -1
  289. package/build-module/components/global-styles/color-panel.js +3 -2
  290. package/build-module/components/global-styles/color-panel.js.map +1 -1
  291. package/build-module/components/global-styles/dimensions-panel.js +5 -4
  292. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  293. package/build-module/components/global-styles/effects-panel.js +3 -2
  294. package/build-module/components/global-styles/effects-panel.js.map +1 -1
  295. package/build-module/components/global-styles/filters-panel.js +2 -5
  296. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  297. package/build-module/components/global-styles/get-global-styles-changes.js +184 -0
  298. package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -0
  299. package/build-module/components/global-styles/hooks.js +3 -2
  300. package/build-module/components/global-styles/hooks.js.map +1 -1
  301. package/build-module/components/global-styles/image-settings-panel.js +7 -1
  302. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  303. package/build-module/components/global-styles/index.js +1 -0
  304. package/build-module/components/global-styles/index.js.map +1 -1
  305. package/build-module/components/global-styles/typography-panel.js +35 -17
  306. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  307. package/build-module/components/global-styles/use-global-styles-output.js +15 -1
  308. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  309. package/build-module/components/global-styles/utils.js +7 -0
  310. package/build-module/components/global-styles/utils.js.map +1 -1
  311. package/build-module/components/height-control/index.js +6 -2
  312. package/build-module/components/height-control/index.js.map +1 -1
  313. package/build-module/components/image-size-control/index.js +2 -2
  314. package/build-module/components/image-size-control/index.js.map +1 -1
  315. package/build-module/components/index.native.js +2 -1
  316. package/build-module/components/index.native.js.map +1 -1
  317. package/build-module/components/inner-blocks/index.js +62 -23
  318. package/build-module/components/inner-blocks/index.js.map +1 -1
  319. package/build-module/components/inner-blocks/index.native.js +18 -4
  320. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  321. package/build-module/components/inner-blocks/use-inner-block-template-sync.js +5 -6
  322. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  323. package/build-module/components/inner-blocks/use-nested-settings-update.js +6 -10
  324. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  325. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
  326. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  327. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +11 -10
  328. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  329. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +11 -11
  330. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  331. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +11 -11
  332. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
  333. package/build-module/components/inserter/block-patterns-tab/utils.js +7 -11
  334. package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -1
  335. package/build-module/components/inserter/hooks/use-block-types-state.js +4 -14
  336. package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
  337. package/build-module/components/inserter/hooks/use-patterns-state.js +2 -2
  338. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  339. package/build-module/components/inserter/index.js +1 -2
  340. package/build-module/components/inserter/index.js.map +1 -1
  341. package/build-module/components/inserter/library.js +3 -7
  342. package/build-module/components/inserter/library.js.map +1 -1
  343. package/build-module/components/inserter/menu.js +14 -28
  344. package/build-module/components/inserter/menu.js.map +1 -1
  345. package/build-module/components/inserter/tabs.js +22 -22
  346. package/build-module/components/inserter/tabs.js.map +1 -1
  347. package/build-module/components/inserter-draggable-blocks/index.js +2 -2
  348. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  349. package/build-module/components/inserter-list-item/index.js +2 -4
  350. package/build-module/components/inserter-list-item/index.js.map +1 -1
  351. package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -1
  352. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  353. package/build-module/components/inspector-controls-tabs/index.js +35 -24
  354. package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
  355. package/build-module/components/list-view/block-select-button.js +4 -0
  356. package/build-module/components/list-view/block-select-button.js.map +1 -1
  357. package/build-module/components/list-view/block.js +58 -4
  358. package/build-module/components/list-view/block.js.map +1 -1
  359. package/build-module/components/media-upload-progress/constants.js +7 -0
  360. package/build-module/components/media-upload-progress/constants.js.map +1 -0
  361. package/build-module/components/media-upload-progress/index.native.js +37 -8
  362. package/build-module/components/media-upload-progress/index.native.js.map +1 -1
  363. package/build-module/components/navigable-toolbar/index.js +9 -14
  364. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  365. package/build-module/components/plain-text/index.native.js +6 -1
  366. package/build-module/components/plain-text/index.native.js.map +1 -1
  367. package/build-module/components/provider/index.js +3 -1
  368. package/build-module/components/provider/index.js.map +1 -1
  369. package/build-module/components/provider/use-block-sync.js +7 -1
  370. package/build-module/components/provider/use-block-sync.js.map +1 -1
  371. package/build-module/components/rich-text/index.js +17 -7
  372. package/build-module/components/rich-text/index.js.map +1 -1
  373. package/build-module/components/rich-text/native/index.native.js +16 -23
  374. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  375. package/build-module/components/rich-text/use-input-rules.js +2 -2
  376. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  377. package/build-module/components/rich-text/use-mark-persistent.js +1 -1
  378. package/build-module/components/rich-text/use-mark-persistent.js.map +1 -1
  379. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  380. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  381. package/build-module/components/url-input/index.js +9 -6
  382. package/build-module/components/url-input/index.js.map +1 -1
  383. package/build-module/components/use-block-commands/index.js +14 -18
  384. package/build-module/components/use-block-commands/index.js.map +1 -1
  385. package/build-module/components/use-block-drop-zone/index.js +51 -23
  386. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  387. package/build-module/components/use-moving-animation/index.js +102 -94
  388. package/build-module/components/use-moving-animation/index.js.map +1 -1
  389. package/build-module/components/use-on-block-drop/index.js +8 -11
  390. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  391. package/build-module/components/writing-flow/index.js +0 -1
  392. package/build-module/components/writing-flow/index.js.map +1 -1
  393. package/build-module/components/writing-flow/use-drag-selection.js +15 -4
  394. package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
  395. package/build-module/components/writing-flow/use-selection-observer.js +73 -27
  396. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  397. package/build-module/components/writing-flow/use-tab-nav.js +7 -4
  398. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  399. package/build-module/hooks/align.js +1 -1
  400. package/build-module/hooks/align.js.map +1 -1
  401. package/build-module/hooks/anchor.js +1 -1
  402. package/build-module/hooks/anchor.js.map +1 -1
  403. package/build-module/hooks/aria-label.js +7 -1
  404. package/build-module/hooks/aria-label.js.map +1 -1
  405. package/build-module/hooks/background.js +181 -19
  406. package/build-module/hooks/background.js.map +1 -1
  407. package/build-module/hooks/border.js +2 -8
  408. package/build-module/hooks/border.js.map +1 -1
  409. package/build-module/hooks/color.js +11 -9
  410. package/build-module/hooks/color.js.map +1 -1
  411. package/build-module/hooks/custom-class-name.js +1 -1
  412. package/build-module/hooks/custom-class-name.js.map +1 -1
  413. package/build-module/hooks/custom-class-name.native.js +7 -1
  414. package/build-module/hooks/custom-class-name.native.js.map +1 -1
  415. package/build-module/hooks/dimensions.js +1 -7
  416. package/build-module/hooks/dimensions.js.map +1 -1
  417. package/build-module/hooks/font-family.js +6 -2
  418. package/build-module/hooks/font-family.js.map +1 -1
  419. package/build-module/hooks/font-size.js +1 -1
  420. package/build-module/hooks/font-size.js.map +1 -1
  421. package/build-module/hooks/index.js +5 -5
  422. package/build-module/hooks/index.js.map +1 -1
  423. package/build-module/hooks/index.native.js +6 -4
  424. package/build-module/hooks/index.native.js.map +1 -1
  425. package/build-module/hooks/layout.js +9 -3
  426. package/build-module/hooks/layout.js.map +1 -1
  427. package/build-module/hooks/style.js +1 -1
  428. package/build-module/hooks/style.js.map +1 -1
  429. package/build-module/hooks/typography.js +1 -7
  430. package/build-module/hooks/typography.js.map +1 -1
  431. package/build-module/hooks/typography.native.js +43 -17
  432. package/build-module/hooks/typography.native.js.map +1 -1
  433. package/build-module/hooks/use-typography-props.js +9 -1
  434. package/build-module/hooks/use-typography-props.js.map +1 -1
  435. package/build-module/hooks/utils.js +47 -5
  436. package/build-module/hooks/utils.js.map +1 -1
  437. package/build-module/private-apis.js +2 -4
  438. package/build-module/private-apis.js.map +1 -1
  439. package/build-module/private-apis.native.js +0 -2
  440. package/build-module/private-apis.native.js.map +1 -1
  441. package/build-module/store/actions.js +0 -15
  442. package/build-module/store/actions.js.map +1 -1
  443. package/build-module/store/private-actions.js +49 -4
  444. package/build-module/store/private-actions.js.map +1 -1
  445. package/build-module/store/private-selectors.js +11 -0
  446. package/build-module/store/private-selectors.js.map +1 -1
  447. package/build-module/store/reducer.js +14 -6
  448. package/build-module/store/reducer.js.map +1 -1
  449. package/build-module/store/selectors.js +1 -12
  450. package/build-module/store/selectors.js.map +1 -1
  451. package/build-module/store/undo-ignore.js +5 -0
  452. package/build-module/store/undo-ignore.js.map +1 -0
  453. package/build-module/store/utils.js +2 -2
  454. package/build-module/store/utils.js.map +1 -1
  455. package/build-module/utils/get-px-from-css-unit.js +9 -0
  456. package/build-module/utils/get-px-from-css-unit.js.map +1 -0
  457. package/build-module/utils/index.js +1 -1
  458. package/build-module/utils/index.js.map +1 -1
  459. package/build-module/utils/object.js +16 -37
  460. package/build-module/utils/object.js.map +1 -1
  461. package/build-module/utils/use-can-block-toolbar-be-focused.js +40 -0
  462. package/build-module/utils/use-can-block-toolbar-be-focused.js.map +1 -0
  463. package/build-style/content-rtl.css +7 -6
  464. package/build-style/content.css +7 -6
  465. package/build-style/style-rtl.css +51 -8
  466. package/build-style/style.css +51 -8
  467. package/package.json +31 -31
  468. package/src/components/alignment-control/README.md +0 -5
  469. package/src/components/block-alignment-control/README.md +0 -5
  470. package/src/components/block-alignment-matrix-control/README.md +0 -10
  471. package/src/components/block-breadcrumb/README.md +0 -5
  472. package/src/components/block-canvas/index.js +0 -2
  473. package/src/components/block-canvas/style.scss +6 -0
  474. package/src/components/block-caption/README.md +0 -5
  475. package/src/components/block-card/README.md +0 -5
  476. package/src/components/block-card/index.js +1 -1
  477. package/src/components/block-draggable/draggable-chip.js +11 -1
  478. package/src/components/block-draggable/index.js +116 -4
  479. package/src/components/block-draggable/index.native.js +0 -5
  480. package/src/components/block-draggable/style.scss +35 -0
  481. package/src/components/block-draggable/test/helpers.native.js +8 -7
  482. package/src/components/block-draggable/use-scroll-when-dragging.native.js +1 -1
  483. package/src/components/block-editing-mode/index.js +3 -3
  484. package/src/components/block-icon/README.md +0 -5
  485. package/src/components/block-inspector/README.md +0 -5
  486. package/src/components/block-inspector/index.js +3 -1
  487. package/src/components/block-list/block-list-item-cell.native.js +5 -1
  488. package/src/components/block-list/block.js +290 -119
  489. package/src/components/block-list/block.native.js +55 -21
  490. package/src/components/block-list/content.scss +14 -10
  491. package/src/components/block-list/index.native.js +3 -5
  492. package/src/components/block-list/{block-list-block-context.js → private-block-context.js} +1 -1
  493. package/src/components/block-list/use-block-props/index.js +32 -128
  494. package/src/components/block-list/use-in-between-inserter.js +4 -1
  495. package/src/components/block-list/use-scroll-upon-insertion.native.js +52 -0
  496. package/src/components/block-lock/toolbar.js +23 -34
  497. package/src/components/block-mover/README.md +0 -5
  498. package/src/components/block-mover/index.js +1 -1
  499. package/src/components/block-parent-selector/README.md +0 -5
  500. package/src/components/block-patterns-list/README.md +0 -5
  501. package/src/components/block-patterns-list/index.js +8 -5
  502. package/src/components/block-switcher/index.js +49 -59
  503. package/src/components/block-toolbar/README.md +0 -5
  504. package/src/components/block-toolbar/index.js +1 -2
  505. package/src/components/block-tools/block-toolbar-popover.js +4 -10
  506. package/src/components/block-types-list/README.md +0 -5
  507. package/src/components/block-variation-picker/README.md +0 -5
  508. package/src/components/block-variation-transforms/README.md +0 -5
  509. package/src/components/block-variation-transforms/index.js +49 -3
  510. package/src/components/border-radius-control/linked-button.js +1 -1
  511. package/src/components/caption/README.md +0 -5
  512. package/src/components/color-palette/test/__snapshots__/control.js.snap +0 -1
  513. package/src/components/colors/utils.js +8 -1
  514. package/src/components/colors/with-colors.js +3 -1
  515. package/src/components/contrast-checker/README.md +0 -4
  516. package/src/components/copy-handler/README.md +0 -10
  517. package/src/components/font-sizes/utils.js +7 -1
  518. package/src/components/global-styles/border-panel.js +2 -1
  519. package/src/components/global-styles/color-panel.js +2 -1
  520. package/src/components/global-styles/dimensions-panel.js +4 -3
  521. package/src/components/global-styles/effects-panel.js +2 -1
  522. package/src/components/global-styles/filters-panel.js +2 -5
  523. package/src/components/global-styles/get-global-styles-changes.js +210 -0
  524. package/src/components/global-styles/hooks.js +5 -0
  525. package/src/components/global-styles/image-settings-panel.js +6 -0
  526. package/src/components/global-styles/index.js +1 -0
  527. package/src/components/global-styles/test/get-global-styles-changes.js +234 -0
  528. package/src/components/global-styles/typography-panel.js +47 -14
  529. package/src/components/global-styles/use-global-styles-output.js +9 -5
  530. package/src/components/global-styles/utils.js +7 -0
  531. package/src/components/height-control/README.md +2 -7
  532. package/src/components/height-control/index.js +4 -0
  533. package/src/components/image-size-control/index.js +5 -2
  534. package/src/components/index.native.js +2 -2
  535. package/src/components/inner-blocks/index.js +68 -29
  536. package/src/components/inner-blocks/index.native.js +19 -7
  537. package/src/components/inner-blocks/use-inner-block-template-sync.js +5 -7
  538. package/src/components/inner-blocks/use-nested-settings-update.js +6 -13
  539. package/src/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
  540. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +15 -15
  541. package/src/components/inserter/block-patterns-tab/patterns-filter.js +15 -13
  542. package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +15 -18
  543. package/src/components/inserter/block-patterns-tab/utils.js +11 -12
  544. package/src/components/inserter/hooks/use-block-types-state.js +9 -11
  545. package/src/components/inserter/hooks/use-patterns-state.js +2 -2
  546. package/src/components/inserter/index.js +0 -1
  547. package/src/components/inserter/library.js +2 -8
  548. package/src/components/inserter/menu.js +13 -31
  549. package/src/components/inserter/style.scss +6 -4
  550. package/src/components/inserter/tabs.js +34 -25
  551. package/src/components/inserter-draggable-blocks/index.js +2 -2
  552. package/src/components/inserter-list-item/index.js +6 -6
  553. package/src/components/inspector-controls/block-support-tools-panel.js +2 -0
  554. package/src/components/inspector-controls-tabs/index.js +39 -28
  555. package/src/components/inspector-controls-tabs/style.scss +3 -2
  556. package/src/components/letter-spacing-control/README.md +0 -5
  557. package/src/components/line-height-control/README.md +0 -5
  558. package/src/components/list-view/README.md +0 -5
  559. package/src/components/list-view/block-select-button.js +4 -0
  560. package/src/components/list-view/block.js +73 -2
  561. package/src/components/list-view/style.scss +6 -0
  562. package/src/components/media-upload-progress/constants.js +6 -0
  563. package/src/components/media-upload-progress/index.native.js +66 -14
  564. package/src/components/media-upload-progress/test/index.native.js +2 -2
  565. package/src/components/multi-selection-inspector/README.md +0 -5
  566. package/src/components/navigable-toolbar/index.js +13 -11
  567. package/src/components/plain-text/index.native.js +6 -1
  568. package/src/components/provider/index.js +1 -1
  569. package/src/components/provider/test/use-block-sync.js +20 -17
  570. package/src/components/provider/use-block-sync.js +6 -0
  571. package/src/components/rich-text/index.js +18 -6
  572. package/src/components/rich-text/native/index.native.js +16 -24
  573. package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +3 -3
  574. package/src/components/rich-text/native/test/index.native.js +72 -5
  575. package/src/components/rich-text/use-input-rules.js +2 -2
  576. package/src/components/rich-text/use-mark-persistent.js +1 -2
  577. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  578. package/src/components/text-decoration-control/README.md +40 -0
  579. package/src/components/text-transform-control/README.md +0 -4
  580. package/src/components/ungroup-button/README.md +0 -5
  581. package/src/components/unit-control/README.md +0 -4
  582. package/src/components/url-input/index.js +11 -11
  583. package/src/components/use-block-commands/index.js +18 -21
  584. package/src/components/use-block-drop-zone/index.js +85 -34
  585. package/src/components/use-moving-animation/index.js +107 -103
  586. package/src/components/use-on-block-drop/index.js +7 -23
  587. package/src/components/use-on-block-drop/test/index.js +12 -26
  588. package/src/components/use-resize-canvas/README.md +0 -4
  589. package/src/components/use-settings/README.md +0 -4
  590. package/src/components/writing-flow/index.js +0 -1
  591. package/src/components/writing-flow/use-drag-selection.js +18 -4
  592. package/src/components/writing-flow/use-selection-observer.js +99 -37
  593. package/src/components/writing-flow/use-tab-nav.js +7 -7
  594. package/src/hooks/align.js +1 -5
  595. package/src/hooks/anchor.js +1 -5
  596. package/src/hooks/aria-label.js +8 -5
  597. package/src/hooks/background.js +253 -21
  598. package/src/hooks/border.js +2 -13
  599. package/src/hooks/color.js +19 -14
  600. package/src/hooks/custom-class-name.js +1 -5
  601. package/src/hooks/custom-class-name.native.js +8 -5
  602. package/src/hooks/dimensions.js +1 -7
  603. package/src/hooks/font-family.js +4 -7
  604. package/src/hooks/font-size.js +1 -6
  605. package/src/hooks/index.js +19 -5
  606. package/src/hooks/index.native.js +17 -4
  607. package/src/hooks/layout.js +5 -2
  608. package/src/hooks/style.js +1 -6
  609. package/src/hooks/test/anchor.js +4 -9
  610. package/src/hooks/test/custom-class-name.js +3 -8
  611. package/src/hooks/test/style.js +4 -14
  612. package/src/hooks/typography.js +1 -7
  613. package/src/hooks/typography.native.js +31 -33
  614. package/src/hooks/use-typography-props.js +7 -1
  615. package/src/hooks/utils.js +76 -6
  616. package/src/private-apis.js +2 -4
  617. package/src/private-apis.native.js +0 -2
  618. package/src/store/actions.js +0 -15
  619. package/src/store/private-actions.js +44 -4
  620. package/src/store/private-selectors.js +11 -0
  621. package/src/store/reducer.js +16 -5
  622. package/src/store/selectors.js +5 -13
  623. package/src/store/undo-ignore.js +4 -0
  624. package/src/store/utils.js +2 -2
  625. package/src/style.scss +1 -0
  626. package/src/utils/get-px-from-css-unit.js +8 -0
  627. package/src/utils/index.js +1 -1
  628. package/src/utils/object.js +16 -35
  629. package/src/utils/test/object.js +1 -96
  630. package/src/utils/use-can-block-toolbar-be-focused.js +48 -0
  631. package/build/components/block-list/block-list-block-context.js +0 -14
  632. package/build/components/block-list/block-list-block-context.js.map +0 -1
  633. package/build/hooks/custom-fields.js +0 -106
  634. package/build/hooks/custom-fields.js.map +0 -1
  635. package/build/utils/parse-css-unit-to-px.js +0 -302
  636. package/build/utils/parse-css-unit-to-px.js.map +0 -1
  637. package/build/utils/use-should-contextual-toolbar-show.js +0 -63
  638. package/build/utils/use-should-contextual-toolbar-show.js.map +0 -1
  639. package/build-module/components/block-list/block-list-block-context.js +0 -6
  640. package/build-module/components/block-list/block-list-block-context.js.map +0 -1
  641. package/build-module/hooks/custom-fields.js +0 -99
  642. package/build-module/hooks/custom-fields.js.map +0 -1
  643. package/build-module/utils/parse-css-unit-to-px.js +0 -294
  644. package/build-module/utils/parse-css-unit-to-px.js.map +0 -1
  645. package/build-module/utils/use-should-contextual-toolbar-show.js +0 -57
  646. package/build-module/utils/use-should-contextual-toolbar-show.js.map +0 -1
  647. package/src/hooks/custom-fields.js +0 -115
  648. package/src/utils/parse-css-unit-to-px.js +0 -329
  649. package/src/utils/test/parse-css-unit-to-px.js +0 -172
  650. package/src/utils/use-should-contextual-toolbar-show.js +0 -85
@@ -6,7 +6,7 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { useMemo, useCallback, RawHTML } from '@wordpress/element';
9
+ import { useCallback, RawHTML, useContext } from '@wordpress/element';
10
10
  import {
11
11
  getBlockType,
12
12
  getSaveContent,
@@ -15,16 +15,13 @@ import {
15
15
  switchToBlockType,
16
16
  getDefaultBlockName,
17
17
  isUnmodifiedBlock,
18
+ isReusableBlock,
19
+ getBlockDefaultClassName,
18
20
  store as blocksStore,
19
21
  } from '@wordpress/blocks';
20
22
  import { withFilters } from '@wordpress/components';
21
- import {
22
- withDispatch,
23
- withSelect,
24
- useDispatch,
25
- useSelect,
26
- } from '@wordpress/data';
27
- import { compose, pure, ifCondition } from '@wordpress/compose';
23
+ import { withDispatch, useDispatch, useSelect } from '@wordpress/data';
24
+ import { compose, pure } from '@wordpress/compose';
28
25
  import { safeHTML } from '@wordpress/dom';
29
26
 
30
27
  /**
@@ -38,7 +35,9 @@ import BlockHtml from './block-html';
38
35
  import { useBlockProps } from './use-block-props';
39
36
  import { store as blockEditorStore } from '../../store';
40
37
  import { useLayout } from './layout';
41
- import { BlockListBlockContext } from './block-list-block-context';
38
+ import { PrivateBlockContext } from './private-block-context';
39
+
40
+ import { unlock } from '../../lock-unlock';
42
41
 
43
42
  /**
44
43
  * Merges wrapper props with special handling for classNames and styles.
@@ -101,44 +100,11 @@ function BlockListBlock( {
101
100
  toggleSelection,
102
101
  } ) {
103
102
  const {
104
- themeSupportsLayout,
105
- isTemporarilyEditingAsBlocks,
106
- blockEditingMode,
107
103
  mayDisplayControls,
108
104
  mayDisplayParentControls,
109
- } = useSelect(
110
- ( select ) => {
111
- const {
112
- getSettings,
113
- __unstableGetTemporarilyEditingAsBlocks,
114
- getBlockEditingMode,
115
- getBlockName,
116
- isFirstMultiSelectedBlock,
117
- getMultiSelectedBlockClientIds,
118
- hasSelectedInnerBlock,
119
- } = select( blockEditorStore );
120
- const { hasBlockSupport } = select( blocksStore );
121
- return {
122
- themeSupportsLayout: getSettings().supportsLayout,
123
- isTemporarilyEditingAsBlocks:
124
- __unstableGetTemporarilyEditingAsBlocks() === clientId,
125
- blockEditingMode: getBlockEditingMode( clientId ),
126
- mayDisplayControls:
127
- isSelected ||
128
- ( isFirstMultiSelectedBlock( clientId ) &&
129
- getMultiSelectedBlockClientIds().every(
130
- ( id ) => getBlockName( id ) === name
131
- ) ),
132
- mayDisplayParentControls:
133
- hasBlockSupport(
134
- getBlockName( clientId ),
135
- '__experimentalExposeControlsToChildren',
136
- false
137
- ) && hasSelectedInnerBlock( clientId ),
138
- };
139
- },
140
- [ clientId, isSelected, name ]
141
- );
105
+ themeSupportsLayout,
106
+ ...context
107
+ } = useContext( PrivateBlockContext );
142
108
  const { removeBlock } = useDispatch( blockEditorStore );
143
109
  const onRemove = useCallback( () => removeBlock( clientId ), [ clientId ] );
144
110
 
@@ -172,12 +138,6 @@ function BlockListBlock( {
172
138
 
173
139
  const blockType = getBlockType( name );
174
140
 
175
- if ( blockEditingMode === 'disabled' ) {
176
- wrapperProps = {
177
- ...wrapperProps,
178
- tabIndex: -1,
179
- };
180
- }
181
141
  // Determine whether the block has props to apply to the wrapper.
182
142
  if ( blockType?.getEditWrapperProps ) {
183
143
  wrapperProps = mergeWrapperProps(
@@ -241,30 +201,28 @@ function BlockListBlock( {
241
201
  } else if ( blockType?.apiVersion > 1 ) {
242
202
  block = blockEdit;
243
203
  } else {
244
- block = <Block { ...wrapperProps }>{ blockEdit }</Block>;
204
+ block = <Block>{ blockEdit }</Block>;
245
205
  }
246
206
 
247
207
  const { 'data-align': dataAlign, ...restWrapperProps } = wrapperProps ?? {};
248
208
 
249
- const value = {
250
- clientId,
251
- className: classnames(
252
- {
253
- 'is-editing-disabled': blockEditingMode === 'disabled',
254
- 'is-content-locked-temporarily-editing-as-blocks':
255
- isTemporarilyEditingAsBlocks,
256
- },
257
- dataAlign && themeSupportsLayout && `align${ dataAlign }`,
258
- ! ( dataAlign && isSticky ) && className
259
- ),
260
- wrapperProps: restWrapperProps,
261
- isAligned,
262
- };
263
-
264
- const memoizedValue = useMemo( () => value, Object.values( value ) );
209
+ restWrapperProps.className = classnames(
210
+ restWrapperProps.className,
211
+ dataAlign && themeSupportsLayout && `align${ dataAlign }`,
212
+ ! ( dataAlign && isSticky ) && className
213
+ );
265
214
 
215
+ // We set a new context with the adjusted and filtered wrapperProps (through
216
+ // `editor.BlockListBlock`), which the `BlockListBlockProvider` did not have
217
+ // access to.
266
218
  return (
267
- <BlockListBlockContext.Provider value={ memoizedValue }>
219
+ <PrivateBlockContext.Provider
220
+ value={ {
221
+ wrapperProps: restWrapperProps,
222
+ isAligned,
223
+ ...context,
224
+ } }
225
+ >
268
226
  <BlockCrashBoundary
269
227
  fallback={
270
228
  <Block className="has-warning">
@@ -274,52 +232,10 @@ function BlockListBlock( {
274
232
  >
275
233
  { block }
276
234
  </BlockCrashBoundary>
277
- </BlockListBlockContext.Provider>
235
+ </PrivateBlockContext.Provider>
278
236
  );
279
237
  }
280
238
 
281
- const applyWithSelect = withSelect( ( select, { clientId, rootClientId } ) => {
282
- const {
283
- isBlockSelected,
284
- getBlockMode,
285
- isSelectionEnabled,
286
- getTemplateLock,
287
- __unstableGetBlockWithoutInnerBlocks,
288
- canRemoveBlock,
289
- canMoveBlock,
290
- } = select( blockEditorStore );
291
- const block = __unstableGetBlockWithoutInnerBlocks( clientId );
292
- const isSelected = isBlockSelected( clientId );
293
- const templateLock = getTemplateLock( rootClientId );
294
- const canRemove = canRemoveBlock( clientId, rootClientId );
295
- const canMove = canMoveBlock( clientId, rootClientId );
296
-
297
- // The fallback to `{}` is a temporary fix.
298
- // This function should never be called when a block is not present in
299
- // the state. It happens now because the order in withSelect rendering
300
- // is not correct.
301
- const { name, attributes, isValid } = block || {};
302
-
303
- // Do not add new properties here, use `useSelect` instead to avoid
304
- // leaking new props to the public API (editor.BlockListBlock filter).
305
- return {
306
- mode: getBlockMode( clientId ),
307
- isSelectionEnabled: isSelectionEnabled(),
308
- isLocked: !! templateLock,
309
- canRemove,
310
- canMove,
311
- // Users of the editor.BlockListBlock filter used to be able to
312
- // access the block prop.
313
- // Ideally these blocks would rely on the clientId prop only.
314
- // This is kept for backward compatibility reasons.
315
- block,
316
- name,
317
- attributes,
318
- isValid,
319
- isSelected,
320
- };
321
- } );
322
-
323
239
  const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
324
240
  const {
325
241
  updateBlockAttributes,
@@ -558,13 +474,268 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
558
474
  };
559
475
  } );
560
476
 
561
- export default compose(
562
- pure,
563
- applyWithSelect,
477
+ // This component is used by the BlockListBlockProvider component below. It will
478
+ // add the props necessary for the `editor.BlockListBlock` filters.
479
+ BlockListBlock = compose(
564
480
  applyWithDispatch,
565
- // Block is sometimes not mounted at the right time, causing it be undefined
566
- // see issue for more info
567
- // https://github.com/WordPress/gutenberg/issues/17013
568
- ifCondition( ( { block } ) => !! block ),
569
481
  withFilters( 'editor.BlockListBlock' )
570
482
  )( BlockListBlock );
483
+
484
+ // This component provides all the information we need through a single store
485
+ // subscription (useSelect mapping). Only the necesssary props are passed down
486
+ // to the BlockListBlock component, which is a filtered component, so these
487
+ // props are public API. To avoid adding to the public API, we use a private
488
+ // context to pass the rest of the information to the filtered BlockListBlock
489
+ // component, and useBlockProps.
490
+ function BlockListBlockProvider( props ) {
491
+ const { clientId, rootClientId } = props;
492
+ const selectedProps = useSelect(
493
+ ( select ) => {
494
+ const {
495
+ isBlockSelected,
496
+ getBlockMode,
497
+ isSelectionEnabled,
498
+ getTemplateLock,
499
+ __unstableGetBlockWithoutInnerBlocks,
500
+ canRemoveBlock,
501
+ canMoveBlock,
502
+
503
+ getSettings,
504
+ __unstableGetTemporarilyEditingAsBlocks,
505
+ getBlockEditingMode,
506
+ getBlockName,
507
+ isFirstMultiSelectedBlock,
508
+ getMultiSelectedBlockClientIds,
509
+ hasSelectedInnerBlock,
510
+
511
+ getBlockIndex,
512
+ isTyping,
513
+ isBlockMultiSelected,
514
+ isBlockSubtreeDisabled,
515
+ isBlockHighlighted,
516
+ __unstableIsFullySelected,
517
+ __unstableSelectionHasUnmergeableBlock,
518
+ isBlockBeingDragged,
519
+ hasBlockMovingClientId,
520
+ canInsertBlockType,
521
+ getBlockRootClientId,
522
+ __unstableHasActiveBlockOverlayActive,
523
+ __unstableGetEditorMode,
524
+ getSelectedBlocksInitialCaretPosition,
525
+ } = unlock( select( blockEditorStore ) );
526
+ const block = __unstableGetBlockWithoutInnerBlocks( clientId );
527
+
528
+ // This is a temporary fix.
529
+ // This function should never be called when a block is not
530
+ // present in the state. It happens now because the order in
531
+ // withSelect rendering is not correct.
532
+ if ( ! block ) {
533
+ return;
534
+ }
535
+
536
+ const {
537
+ hasBlockSupport: _hasBlockSupport,
538
+ getActiveBlockVariation,
539
+ } = select( blocksStore );
540
+ const _isSelected = isBlockSelected( clientId );
541
+ const templateLock = getTemplateLock( rootClientId );
542
+ const canRemove = canRemoveBlock( clientId, rootClientId );
543
+ const canMove = canMoveBlock( clientId, rootClientId );
544
+ const { name: blockName, attributes, isValid } = block;
545
+ const blockType = getBlockType( blockName );
546
+ const match = getActiveBlockVariation( blockName, attributes );
547
+ const { outlineMode, supportsLayout } = getSettings();
548
+ const isMultiSelected = isBlockMultiSelected( clientId );
549
+ const checkDeep = true;
550
+ const isAncestorOfSelectedBlock = hasSelectedInnerBlock(
551
+ clientId,
552
+ checkDeep
553
+ );
554
+ const typing = isTyping();
555
+ const hasLightBlockWrapper = blockType?.apiVersion > 1;
556
+ const movingClientId = hasBlockMovingClientId();
557
+
558
+ return {
559
+ mode: getBlockMode( clientId ),
560
+ isSelectionEnabled: isSelectionEnabled(),
561
+ isLocked: !! templateLock,
562
+ canRemove,
563
+ canMove,
564
+ // Users of the editor.BlockListBlock filter used to be able to
565
+ // access the block prop.
566
+ // Ideally these blocks would rely on the clientId prop only.
567
+ // This is kept for backward compatibility reasons.
568
+ block,
569
+ name: blockName,
570
+ attributes,
571
+ isValid,
572
+ isSelected: _isSelected,
573
+ themeSupportsLayout: supportsLayout,
574
+ isTemporarilyEditingAsBlocks:
575
+ __unstableGetTemporarilyEditingAsBlocks() === clientId,
576
+ blockEditingMode: getBlockEditingMode( clientId ),
577
+ mayDisplayControls:
578
+ _isSelected ||
579
+ ( isFirstMultiSelectedBlock( clientId ) &&
580
+ getMultiSelectedBlockClientIds().every(
581
+ ( id ) => getBlockName( id ) === blockName
582
+ ) ),
583
+ mayDisplayParentControls:
584
+ _hasBlockSupport(
585
+ getBlockName( clientId ),
586
+ '__experimentalExposeControlsToChildren',
587
+ false
588
+ ) && hasSelectedInnerBlock( clientId ),
589
+ index: getBlockIndex( clientId ),
590
+ blockApiVersion: blockType?.apiVersion || 1,
591
+ blockTitle: match?.title || blockType?.title,
592
+ isSubtreeDisabled: isBlockSubtreeDisabled( clientId ),
593
+ isOutlineEnabled: outlineMode,
594
+ hasOverlay: __unstableHasActiveBlockOverlayActive( clientId ),
595
+ initialPosition:
596
+ _isSelected && __unstableGetEditorMode() === 'edit'
597
+ ? getSelectedBlocksInitialCaretPosition()
598
+ : undefined,
599
+ isHighlighted: isBlockHighlighted( clientId ),
600
+ isMultiSelected,
601
+ isPartiallySelected:
602
+ isMultiSelected &&
603
+ ! __unstableIsFullySelected() &&
604
+ ! __unstableSelectionHasUnmergeableBlock(),
605
+ isReusable: isReusableBlock( blockType ),
606
+ isDragging: isBlockBeingDragged( clientId ),
607
+ hasChildSelected: isAncestorOfSelectedBlock,
608
+ removeOutline: _isSelected && outlineMode && typing,
609
+ isBlockMovingMode: !! movingClientId,
610
+ canInsertMovingBlock:
611
+ movingClientId &&
612
+ canInsertBlockType(
613
+ getBlockName( movingClientId ),
614
+ getBlockRootClientId( clientId )
615
+ ),
616
+ isEditingDisabled:
617
+ getBlockEditingMode( clientId ) === 'disabled',
618
+ className: hasLightBlockWrapper
619
+ ? attributes.className
620
+ : undefined,
621
+ defaultClassName: hasLightBlockWrapper
622
+ ? getBlockDefaultClassName( blockName )
623
+ : undefined,
624
+ };
625
+ },
626
+ [ clientId, rootClientId ]
627
+ );
628
+
629
+ const {
630
+ mode,
631
+ isSelectionEnabled,
632
+ isLocked,
633
+ canRemove,
634
+ canMove,
635
+ block,
636
+ name,
637
+ attributes,
638
+ isValid,
639
+ isSelected,
640
+ themeSupportsLayout,
641
+ isTemporarilyEditingAsBlocks,
642
+ blockEditingMode,
643
+ mayDisplayControls,
644
+ mayDisplayParentControls,
645
+ index,
646
+ blockApiVersion,
647
+ blockTitle,
648
+ isSubtreeDisabled,
649
+ isOutlineEnabled,
650
+ hasOverlay,
651
+ initialPosition,
652
+ isHighlighted,
653
+ isMultiSelected,
654
+ isPartiallySelected,
655
+ isReusable,
656
+ isDragging,
657
+ hasChildSelected,
658
+ removeOutline,
659
+ isBlockMovingMode,
660
+ canInsertMovingBlock,
661
+ isEditingDisabled,
662
+ className,
663
+ defaultClassName,
664
+ } = selectedProps;
665
+
666
+ // Block is sometimes not mounted at the right time, causing it be
667
+ // undefined see issue for more info
668
+ // https://github.com/WordPress/gutenberg/issues/17013
669
+ if ( ! selectedProps ) {
670
+ return null;
671
+ }
672
+
673
+ const privateContext = {
674
+ clientId,
675
+ className,
676
+ index,
677
+ mode,
678
+ name,
679
+ blockApiVersion,
680
+ blockTitle,
681
+ isSelected,
682
+ isSubtreeDisabled,
683
+ isOutlineEnabled,
684
+ hasOverlay,
685
+ initialPosition,
686
+ blockEditingMode,
687
+ isHighlighted,
688
+ isMultiSelected,
689
+ isPartiallySelected,
690
+ isReusable,
691
+ isDragging,
692
+ hasChildSelected,
693
+ removeOutline,
694
+ isBlockMovingMode,
695
+ canInsertMovingBlock,
696
+ isEditingDisabled,
697
+ isTemporarilyEditingAsBlocks,
698
+ defaultClassName,
699
+ mayDisplayControls,
700
+ mayDisplayParentControls,
701
+ themeSupportsLayout,
702
+ };
703
+
704
+ // Here we separate between the props passed to BlockListBlock and any other
705
+ // information we selected for internal use. BlockListBlock is a filtered
706
+ // component and thus ALL the props are PUBLIC API.
707
+
708
+ // Note that the context value doesn't have to be memoized in this case
709
+ // because when it changes, this component will be re-rendered anyway, and
710
+ // none of the consumers (BlockListBlock and useBlockProps) are memoized or
711
+ // "pure". This is different from the public BlockEditContext, where
712
+ // consumers might be memoized or "pure".
713
+ return (
714
+ <PrivateBlockContext.Provider value={ privateContext }>
715
+ <BlockListBlock
716
+ { ...props }
717
+ // WARNING: all the following props are public API (through the
718
+ // editor.BlockListBlock filter) and normally nothing new should
719
+ // be added to it.
720
+ { ...{
721
+ mode,
722
+ isSelectionEnabled,
723
+ isLocked,
724
+ canRemove,
725
+ canMove,
726
+ // Users of the editor.BlockListBlock filter used to be able
727
+ // to access the block prop. Ideally these blocks would rely
728
+ // on the clientId prop only. This is kept for backward
729
+ // compatibility reasons.
730
+ block,
731
+ name,
732
+ attributes,
733
+ isValid,
734
+ isSelected,
735
+ } }
736
+ />
737
+ </PrivateBlockContext.Provider>
738
+ );
739
+ }
740
+
741
+ export default pure( BlockListBlockProvider );
@@ -2,16 +2,18 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { Pressable, View } from 'react-native';
5
+ import classnames from 'classnames';
5
6
 
6
7
  /**
7
8
  * WordPress dependencies
8
9
  */
9
- import { useCallback, useMemo, useState } from '@wordpress/element';
10
+ import { useCallback, useMemo, useState, useRef } from '@wordpress/element';
10
11
  import {
11
12
  GlobalStylesContext,
12
13
  getMergedGlobalStyles,
13
14
  useMobileGlobalStylesColors,
14
15
  useGlobalStyles,
16
+ withFilters,
15
17
  } from '@wordpress/components';
16
18
  import {
17
19
  __experimentalGetAccessibleBlockLabel as getAccessibleBlockLabel,
@@ -38,24 +40,41 @@ import BlockInvalidWarning from './block-invalid-warning';
38
40
  import BlockOutline from './block-outline';
39
41
  import { store as blockEditorStore } from '../../store';
40
42
  import { useLayout } from './layout';
43
+ import useScrollUponInsertion from './use-scroll-upon-insertion';
41
44
  import { useSettings } from '../use-settings';
42
45
 
43
46
  const EMPTY_ARRAY = [];
44
47
 
45
- // Helper function to memoize the wrapperProps since getEditWrapperProps always returns a new reference.
46
- const wrapperPropsCache = new WeakMap();
47
- const emptyObj = {};
48
- function getWrapperProps( value, getWrapperPropsFunction ) {
49
- if ( ! getWrapperPropsFunction ) {
50
- return emptyObj;
48
+ /**
49
+ * Merges wrapper props with special handling for classNames and styles.
50
+ *
51
+ * @param {Object} propsA
52
+ * @param {Object} propsB
53
+ *
54
+ * @return {Object} Merged props.
55
+ */
56
+ function mergeWrapperProps( propsA, propsB ) {
57
+ const newProps = {
58
+ ...propsA,
59
+ ...propsB,
60
+ };
61
+
62
+ // May be set to undefined, so check if the property is set!
63
+ if (
64
+ propsA?.hasOwnProperty( 'className' ) &&
65
+ propsB?.hasOwnProperty( 'className' )
66
+ ) {
67
+ newProps.className = classnames( propsA.className, propsB.className );
51
68
  }
52
- const cachedValue = wrapperPropsCache.get( value );
53
- if ( ! cachedValue ) {
54
- const wrapperProps = getWrapperPropsFunction( value );
55
- wrapperPropsCache.set( value, wrapperProps );
56
- return wrapperProps;
69
+
70
+ if (
71
+ propsA?.hasOwnProperty( 'style' ) &&
72
+ propsB?.hasOwnProperty( 'style' )
73
+ ) {
74
+ newProps.style = { ...propsA.style, ...propsB.style };
57
75
  }
58
- return cachedValue;
76
+
77
+ return newProps;
59
78
  }
60
79
 
61
80
  function BlockWrapper( {
@@ -85,6 +104,18 @@ function BlockWrapper( {
85
104
  ];
86
105
  const accessible = ! ( isSelected || isDescendentBlockSelected );
87
106
 
107
+ const ref = useRef();
108
+ const [ isLayoutCalculated, setIsLayoutCalculated ] = useState();
109
+ useScrollUponInsertion( {
110
+ clientId,
111
+ isSelected,
112
+ isLayoutCalculated,
113
+ elementRef: ref,
114
+ } );
115
+ const onLayout = useCallback( () => {
116
+ setIsLayoutCalculated( true );
117
+ }, [] );
118
+
88
119
  return (
89
120
  <Pressable
90
121
  accessibilityLabel={ accessibilityLabel }
@@ -93,6 +124,8 @@ function BlockWrapper( {
93
124
  disabled={ ! isTouchable }
94
125
  onPress={ onFocus }
95
126
  style={ blockWrapperStyle }
127
+ ref={ ref }
128
+ onLayout={ onLayout }
96
129
  >
97
130
  <BlockOutline
98
131
  blockCategory={ blockCategory }
@@ -136,6 +169,7 @@ function BlockListBlock( {
136
169
  rootClientId,
137
170
  setAttributes,
138
171
  toggleSelection,
172
+ wrapperProps,
139
173
  } ) {
140
174
  const {
141
175
  baseGlobalStyles,
@@ -252,12 +286,11 @@ function BlockListBlock( {
252
286
  [ blockWidth, setBlockWidth ]
253
287
  );
254
288
 
255
- // Block level styles.
256
- let wrapperProps = {};
289
+ // Determine whether the block has props to apply to the wrapper.
257
290
  if ( blockType?.getEditWrapperProps ) {
258
- wrapperProps = getWrapperProps(
259
- attributes,
260
- blockType.getEditWrapperProps
291
+ wrapperProps = mergeWrapperProps(
292
+ wrapperProps,
293
+ blockType.getEditWrapperProps( attributes )
261
294
  );
262
295
  }
263
296
 
@@ -266,7 +299,7 @@ function BlockListBlock( {
266
299
  return getMergedGlobalStyles(
267
300
  baseGlobalStyles,
268
301
  globalStyle,
269
- wrapperProps.style,
302
+ wrapperProps?.style,
270
303
  attributes,
271
304
  defaultColors,
272
305
  name,
@@ -284,7 +317,7 @@ function BlockListBlock( {
284
317
  // eslint-disable-next-line react-hooks/exhaustive-deps
285
318
  JSON.stringify( globalStyle ),
286
319
  // eslint-disable-next-line react-hooks/exhaustive-deps
287
- JSON.stringify( wrapperProps.style ),
320
+ JSON.stringify( wrapperProps?.style ),
288
321
  // eslint-disable-next-line react-hooks/exhaustive-deps
289
322
  JSON.stringify(
290
323
  Object.fromEntries(
@@ -651,5 +684,6 @@ export default compose(
651
684
  // Block is sometimes not mounted at the right time, causing it be undefined
652
685
  // see issue for more info
653
686
  // https://github.com/WordPress/gutenberg/issues/17013
654
- ifCondition( ( { block } ) => !! block )
687
+ ifCondition( ( { block } ) => !! block ),
688
+ withFilters( 'editor.BlockListBlock' )
655
689
  )( BlockListBlock );
@@ -17,6 +17,20 @@
17
17
  }
18
18
  }
19
19
 
20
+
21
+ // Hide selections on this element, otherwise Safari will include it stacked
22
+ // under your actual selection.
23
+ // This uses a CSS hack to show the rules to Safari only. Failing here is okay,
24
+ // it just makes the selection indication slightly less precise. That makes this
25
+ // hack a progressive enhancement. Stylelint is disabled to allow the hack to work.
26
+ /* stylelint-disable */
27
+ _::-webkit-full-page-media, _:future, :root .block-editor-block-list__layout::selection,
28
+ _::-webkit-full-page-media, _:future, :root .has-multi-selection .block-editor-block-list__layout::selection {
29
+ background-color: transparent;
30
+ }
31
+ /* stylelint-enable */
32
+
33
+
20
34
  // Note to developers refactoring this, please test navigation mode, and
21
35
  // multi selection and hovering the block switcher to highlight the block.
22
36
  // Also be sure to test partial selections in Safari, as it draws the
@@ -24,16 +38,6 @@
24
38
  .block-editor-block-list__layout {
25
39
  position: relative;
26
40
 
27
- // Hide selections on this element, otherwise Safari will include it stacked
28
- // under your actual selection.
29
- &::selection {
30
- background: transparent;
31
- }
32
-
33
- .has-multi-selection &::selection {
34
- background: transparent;
35
- }
36
-
37
41
  // Block multi selection
38
42
  // Apply a rounded radius to the entire block when multi selected, but with low specificity
39
43
  // so explicit radii set by tools are preserved.
@@ -139,7 +139,7 @@ export default function BlockList( {
139
139
  insertBlock( newBlock, blockCount );
140
140
  };
141
141
 
142
- const scrollViewRef = useRef( null );
142
+ const scrollRef = useRef( null );
143
143
 
144
144
  const shouldFlatListPreventAutomaticScroll = () =>
145
145
  blockInsertionPointIsVisible;
@@ -239,7 +239,7 @@ export default function BlockList( {
239
239
  <BlockListProvider
240
240
  value={ {
241
241
  ...DEFAULT_BLOCK_LIST_CONTEXT,
242
- scrollRef: scrollViewRef.current,
242
+ scrollRef: scrollRef.current,
243
243
  } }
244
244
  >
245
245
  <BlockDraggableWrapper isRTL={ isRTL }>
@@ -249,9 +249,7 @@ export default function BlockList( {
249
249
  ? { removeClippedSubviews: false }
250
250
  : {} ) } // Disable clipping on Android to fix focus losing. See https://github.com/wordpress-mobile/gutenberg-mobile/pull/741#issuecomment-472746541
251
251
  accessibilityLabel="block-list"
252
- innerRef={ ( ref ) => {
253
- scrollViewRef.current = ref;
254
- } }
252
+ ref={ scrollRef }
255
253
  extraScrollHeight={ extraScrollHeight }
256
254
  keyboardShouldPersistTaps="always"
257
255
  scrollViewStyle={ { flex: 1 } }
@@ -3,4 +3,4 @@
3
3
  */
4
4
  import { createContext } from '@wordpress/element';
5
5
 
6
- export const BlockListBlockContext = createContext( null );
6
+ export const PrivateBlockContext = createContext( null );