@wordpress/block-editor 8.5.7 → 9.1.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 (462) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +5 -2
  3. package/build/components/block-alignment-control/constants.js +48 -0
  4. package/build/components/block-alignment-control/constants.js.map +1 -0
  5. package/build/components/block-alignment-control/ui.js +9 -40
  6. package/build/components/block-alignment-control/ui.js.map +1 -1
  7. package/build/components/block-alignment-control/ui.native.js +92 -0
  8. package/build/components/block-alignment-control/ui.native.js.map +1 -0
  9. package/build/components/block-alignment-matrix-control/index.js +1 -6
  10. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  11. package/build/components/block-content-overlay/index.js +5 -74
  12. package/build/components/block-content-overlay/index.js.map +1 -1
  13. package/build/components/block-draggable/draggable-chip.native.js +64 -0
  14. package/build/components/block-draggable/draggable-chip.native.js.map +1 -0
  15. package/build/components/block-draggable/dropping-insertion-point.native.js +157 -0
  16. package/build/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
  17. package/build/components/block-draggable/index.native.js +484 -0
  18. package/build/components/block-draggable/index.native.js.map +1 -0
  19. package/build/components/block-draggable/use-scroll-when-dragging.native.js +130 -0
  20. package/build/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
  21. package/build/components/block-list/block-list-context.native.js +195 -0
  22. package/build/components/block-list/block-list-context.native.js.map +1 -0
  23. package/build/components/block-list/block-list-item-cell.native.js +67 -0
  24. package/build/components/block-list/block-list-item-cell.native.js.map +1 -0
  25. package/build/components/block-list/block-list-item.native.js +12 -9
  26. package/build/components/block-list/block-list-item.native.js.map +1 -1
  27. package/build/components/block-list/block.native.js +29 -6
  28. package/build/components/block-list/block.native.js.map +1 -1
  29. package/build/components/block-list/index.native.js +75 -23
  30. package/build/components/block-list/index.native.js.map +1 -1
  31. package/build/components/block-list/use-block-props/index.js +8 -4
  32. package/build/components/block-list/use-block-props/index.js.map +1 -1
  33. package/build/components/block-list/use-block-props/use-block-class-names.js +1 -7
  34. package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  35. package/build/components/block-list/use-in-between-inserter.js +1 -1
  36. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  37. package/build/components/block-lock/modal.js +34 -4
  38. package/build/components/block-lock/modal.js.map +1 -1
  39. package/build/components/block-lock/toolbar.js +2 -1
  40. package/build/components/block-lock/toolbar.js.map +1 -1
  41. package/build/components/block-lock/use-block-lock.js +4 -1
  42. package/build/components/block-lock/use-block-lock.js.map +1 -1
  43. package/build/components/block-mobile-toolbar/index.native.js +9 -3
  44. package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
  45. package/build/components/block-mover/button.js +4 -4
  46. package/build/components/block-mover/button.js.map +1 -1
  47. package/build/components/block-mover/index.js +39 -65
  48. package/build/components/block-mover/index.js.map +1 -1
  49. package/build/components/block-mover/index.native.js +17 -4
  50. package/build/components/block-mover/index.native.js.map +1 -1
  51. package/build/components/block-navigation/dropdown.js +11 -5
  52. package/build/components/block-navigation/dropdown.js.map +1 -1
  53. package/build/components/block-popover/inbetween.js +191 -0
  54. package/build/components/block-popover/inbetween.js.map +1 -0
  55. package/build/components/block-popover/index.js +85 -0
  56. package/build/components/block-popover/index.js.map +1 -0
  57. package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
  58. package/build/components/block-popover/use-popover-scroll.js.map +1 -0
  59. package/build/components/block-preview/index.js +1 -1
  60. package/build/components/block-preview/index.js.map +1 -1
  61. package/build/components/block-styles/index.js +1 -10
  62. package/build/components/block-styles/index.js.map +1 -1
  63. package/build/components/block-tools/back-compat.js +2 -2
  64. package/build/components/block-tools/back-compat.js.map +1 -1
  65. package/build/components/block-tools/block-selection-button.js +4 -2
  66. package/build/components/block-tools/block-selection-button.js.map +1 -1
  67. package/build/components/block-tools/index.js +5 -5
  68. package/build/components/block-tools/index.js.map +1 -1
  69. package/build/components/block-tools/insertion-point.js +14 -121
  70. package/build/components/block-tools/insertion-point.js.map +1 -1
  71. package/build/components/block-tools/selected-block-popover.js +216 -0
  72. package/build/components/block-tools/selected-block-popover.js.map +1 -0
  73. package/build/components/border-radius-control/input-controls.js +10 -3
  74. package/build/components/border-radius-control/input-controls.js.map +1 -1
  75. package/build/components/color-style-selector/index.js +9 -0
  76. package/build/components/color-style-selector/index.js.map +1 -1
  77. package/build/components/colors-gradients/dropdown.js +149 -44
  78. package/build/components/colors-gradients/dropdown.js.map +1 -1
  79. package/build/components/duotone-control/index.js +5 -1
  80. package/build/components/duotone-control/index.js.map +1 -1
  81. package/build/components/image-editor/use-save-image.js +3 -1
  82. package/build/components/image-editor/use-save-image.js.map +1 -1
  83. package/build/components/index.js +5 -23
  84. package/build/components/index.js.map +1 -1
  85. package/build/components/inserter/index.native.js +31 -9
  86. package/build/components/inserter/index.native.js.map +1 -1
  87. package/build/components/link-control/constants.js +11 -1
  88. package/build/components/link-control/constants.js.map +1 -1
  89. package/build/components/link-control/search-results.js +4 -3
  90. package/build/components/link-control/search-results.js.map +1 -1
  91. package/build/components/link-control/use-search-handler.js +4 -4
  92. package/build/components/link-control/use-search-handler.js.map +1 -1
  93. package/build/components/list-view/block.js +15 -15
  94. package/build/components/list-view/block.js.map +1 -1
  95. package/build/components/list-view/branch.js +9 -13
  96. package/build/components/list-view/branch.js.map +1 -1
  97. package/build/components/list-view/context.js +1 -4
  98. package/build/components/list-view/context.js.map +1 -1
  99. package/build/components/list-view/drop-indicator.js +0 -1
  100. package/build/components/list-view/drop-indicator.js.map +1 -1
  101. package/build/components/list-view/index.js +15 -32
  102. package/build/components/list-view/index.js.map +1 -1
  103. package/build/components/navigable-toolbar/index.js +12 -2
  104. package/build/components/navigable-toolbar/index.js.map +1 -1
  105. package/build/components/rich-text/format-toolbar-container.js +0 -1
  106. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  107. package/build/components/rich-text/index.js +1 -6
  108. package/build/components/rich-text/index.js.map +1 -1
  109. package/build/components/rich-text/index.native.js +0 -4
  110. package/build/components/rich-text/index.native.js.map +1 -1
  111. package/build/components/url-input/index.js +11 -4
  112. package/build/components/url-input/index.js.map +1 -1
  113. package/build/components/use-block-display-information/index.js +3 -1
  114. package/build/components/use-block-display-information/index.js.map +1 -1
  115. package/build/components/use-block-drop-zone/index.native.js +167 -0
  116. package/build/components/use-block-drop-zone/index.native.js.map +1 -0
  117. package/build/components/use-on-block-drop/index.native.js +95 -0
  118. package/build/components/use-on-block-drop/index.native.js.map +1 -0
  119. package/build/components/use-setting/index.js +42 -18
  120. package/build/components/use-setting/index.js.map +1 -1
  121. package/build/hooks/anchor.js.map +1 -1
  122. package/build/hooks/border.js +463 -44
  123. package/build/hooks/border.js.map +1 -1
  124. package/build/hooks/color-panel.js +14 -7
  125. package/build/hooks/color-panel.js.map +1 -1
  126. package/build/hooks/dimensions.js +2 -2
  127. package/build/hooks/dimensions.js.map +1 -1
  128. package/build/hooks/index.js +3 -1
  129. package/build/hooks/index.js.map +1 -1
  130. package/build/hooks/margin.js +64 -12
  131. package/build/hooks/margin.js.map +1 -1
  132. package/build/hooks/padding.js +60 -12
  133. package/build/hooks/padding.js.map +1 -1
  134. package/build/hooks/settings.js +32 -0
  135. package/build/hooks/settings.js.map +1 -0
  136. package/build/hooks/style.js +14 -13
  137. package/build/hooks/style.js.map +1 -1
  138. package/build/hooks/typography.js +6 -2
  139. package/build/hooks/typography.js.map +1 -1
  140. package/build/hooks/use-border-props.js +22 -32
  141. package/build/hooks/use-border-props.js.map +1 -1
  142. package/build/store/actions.js +14 -2
  143. package/build/store/actions.js.map +1 -1
  144. package/build/store/defaults.js +0 -1
  145. package/build/store/defaults.js.map +1 -1
  146. package/build/store/reducer.js +0 -26
  147. package/build/store/reducer.js.map +1 -1
  148. package/build/store/selectors.js +47 -15
  149. package/build/store/selectors.js.map +1 -1
  150. package/build-module/components/block-alignment-control/constants.js +36 -0
  151. package/build-module/components/block-alignment-control/constants.js.map +1 -0
  152. package/build-module/components/block-alignment-control/ui.js +4 -35
  153. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  154. package/build-module/components/block-alignment-control/ui.native.js +78 -0
  155. package/build-module/components/block-alignment-control/ui.native.js.map +1 -0
  156. package/build-module/components/block-alignment-matrix-control/index.js +1 -6
  157. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  158. package/build-module/components/block-content-overlay/index.js +4 -70
  159. package/build-module/components/block-content-overlay/index.js.map +1 -1
  160. package/build-module/components/block-draggable/draggable-chip.native.js +50 -0
  161. package/build-module/components/block-draggable/draggable-chip.native.js.map +1 -0
  162. package/build-module/components/block-draggable/dropping-insertion-point.native.js +137 -0
  163. package/build-module/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
  164. package/build-module/components/block-draggable/index.native.js +449 -0
  165. package/build-module/components/block-draggable/index.native.js.map +1 -0
  166. package/build-module/components/block-draggable/use-scroll-when-dragging.native.js +120 -0
  167. package/build-module/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
  168. package/build-module/components/block-list/block-list-context.native.js +179 -0
  169. package/build-module/components/block-list/block-list-context.native.js.map +1 -0
  170. package/build-module/components/block-list/block-list-item-cell.native.js +59 -0
  171. package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -0
  172. package/build-module/components/block-list/block-list-item.native.js +12 -9
  173. package/build-module/components/block-list/block-list-item.native.js.map +1 -1
  174. package/build-module/components/block-list/block.native.js +28 -6
  175. package/build-module/components/block-list/block.native.js.map +1 -1
  176. package/build-module/components/block-list/index.native.js +72 -23
  177. package/build-module/components/block-list/index.native.js.map +1 -1
  178. package/build-module/components/block-list/use-block-props/index.js +9 -5
  179. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  180. package/build-module/components/block-list/use-block-props/use-block-class-names.js +1 -7
  181. package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  182. package/build-module/components/block-list/use-in-between-inserter.js +1 -1
  183. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  184. package/build-module/components/block-lock/modal.js +34 -5
  185. package/build-module/components/block-lock/modal.js.map +1 -1
  186. package/build-module/components/block-lock/toolbar.js +2 -1
  187. package/build-module/components/block-lock/toolbar.js.map +1 -1
  188. package/build-module/components/block-lock/use-block-lock.js +4 -1
  189. package/build-module/components/block-lock/use-block-lock.js.map +1 -1
  190. package/build-module/components/block-mobile-toolbar/index.native.js +8 -3
  191. package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
  192. package/build-module/components/block-mover/button.js +5 -5
  193. package/build-module/components/block-mover/button.js.map +1 -1
  194. package/build-module/components/block-mover/index.js +38 -63
  195. package/build-module/components/block-mover/index.js.map +1 -1
  196. package/build-module/components/block-mover/index.native.js +18 -5
  197. package/build-module/components/block-mover/index.native.js.map +1 -1
  198. package/build-module/components/block-navigation/dropdown.js +10 -5
  199. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  200. package/build-module/components/block-popover/inbetween.js +173 -0
  201. package/build-module/components/block-popover/inbetween.js.map +1 -0
  202. package/build-module/components/block-popover/index.js +72 -0
  203. package/build-module/components/block-popover/index.js.map +1 -0
  204. package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  205. package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
  206. package/build-module/components/block-preview/index.js +1 -1
  207. package/build-module/components/block-preview/index.js.map +1 -1
  208. package/build-module/components/block-styles/index.js +1 -9
  209. package/build-module/components/block-styles/index.js.map +1 -1
  210. package/build-module/components/block-tools/back-compat.js +1 -1
  211. package/build-module/components/block-tools/back-compat.js.map +1 -1
  212. package/build-module/components/block-tools/block-selection-button.js +3 -2
  213. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  214. package/build-module/components/block-tools/index.js +3 -3
  215. package/build-module/components/block-tools/index.js.map +1 -1
  216. package/build-module/components/block-tools/insertion-point.js +16 -121
  217. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  218. package/build-module/components/block-tools/selected-block-popover.js +199 -0
  219. package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
  220. package/build-module/components/border-radius-control/input-controls.js +11 -4
  221. package/build-module/components/border-radius-control/input-controls.js.map +1 -1
  222. package/build-module/components/color-style-selector/index.js +6 -0
  223. package/build-module/components/color-style-selector/index.js.map +1 -1
  224. package/build-module/components/colors-gradients/dropdown.js +151 -46
  225. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  226. package/build-module/components/duotone-control/index.js +4 -1
  227. package/build-module/components/duotone-control/index.js.map +1 -1
  228. package/build-module/components/image-editor/use-save-image.js +2 -1
  229. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  230. package/build-module/components/index.js +1 -3
  231. package/build-module/components/index.js.map +1 -1
  232. package/build-module/components/inserter/index.native.js +32 -11
  233. package/build-module/components/inserter/index.native.js.map +1 -1
  234. package/build-module/components/link-control/constants.js +5 -0
  235. package/build-module/components/link-control/constants.js.map +1 -1
  236. package/build-module/components/link-control/search-results.js +3 -4
  237. package/build-module/components/link-control/search-results.js.map +1 -1
  238. package/build-module/components/link-control/use-search-handler.js +5 -5
  239. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  240. package/build-module/components/list-view/block.js +15 -16
  241. package/build-module/components/list-view/block.js.map +1 -1
  242. package/build-module/components/list-view/branch.js +9 -13
  243. package/build-module/components/list-view/branch.js.map +1 -1
  244. package/build-module/components/list-view/context.js +1 -4
  245. package/build-module/components/list-view/context.js.map +1 -1
  246. package/build-module/components/list-view/drop-indicator.js +0 -1
  247. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  248. package/build-module/components/list-view/index.js +15 -31
  249. package/build-module/components/list-view/index.js.map +1 -1
  250. package/build-module/components/navigable-toolbar/index.js +12 -2
  251. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  252. package/build-module/components/rich-text/format-toolbar-container.js +0 -1
  253. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  254. package/build-module/components/rich-text/index.js +1 -5
  255. package/build-module/components/rich-text/index.js.map +1 -1
  256. package/build-module/components/rich-text/index.native.js +0 -4
  257. package/build-module/components/rich-text/index.native.js.map +1 -1
  258. package/build-module/components/url-input/index.js +11 -4
  259. package/build-module/components/url-input/index.js.map +1 -1
  260. package/build-module/components/use-block-display-information/index.js +3 -1
  261. package/build-module/components/use-block-display-information/index.js.map +1 -1
  262. package/build-module/components/use-block-drop-zone/index.native.js +148 -0
  263. package/build-module/components/use-block-drop-zone/index.native.js.map +1 -0
  264. package/build-module/components/use-on-block-drop/index.native.js +83 -0
  265. package/build-module/components/use-on-block-drop/index.native.js.map +1 -0
  266. package/build-module/components/use-setting/index.js +43 -19
  267. package/build-module/components/use-setting/index.js.map +1 -1
  268. package/build-module/hooks/anchor.js.map +1 -1
  269. package/build-module/hooks/border.js +453 -44
  270. package/build-module/hooks/border.js.map +1 -1
  271. package/build-module/hooks/color-panel.js +11 -6
  272. package/build-module/hooks/color-panel.js.map +1 -1
  273. package/build-module/hooks/dimensions.js +5 -5
  274. package/build-module/hooks/dimensions.js.map +1 -1
  275. package/build-module/hooks/index.js +2 -1
  276. package/build-module/hooks/index.js.map +1 -1
  277. package/build-module/hooks/margin.js +61 -13
  278. package/build-module/hooks/margin.js.map +1 -1
  279. package/build-module/hooks/padding.js +57 -13
  280. package/build-module/hooks/padding.js.map +1 -1
  281. package/build-module/hooks/settings.js +29 -0
  282. package/build-module/hooks/settings.js.map +1 -0
  283. package/build-module/hooks/style.js +15 -14
  284. package/build-module/hooks/style.js.map +1 -1
  285. package/build-module/hooks/typography.js +6 -2
  286. package/build-module/hooks/typography.js.map +1 -1
  287. package/build-module/hooks/use-border-props.js +21 -30
  288. package/build-module/hooks/use-border-props.js.map +1 -1
  289. package/build-module/store/actions.js +14 -2
  290. package/build-module/store/actions.js.map +1 -1
  291. package/build-module/store/defaults.js +0 -1
  292. package/build-module/store/defaults.js.map +1 -1
  293. package/build-module/store/reducer.js +0 -24
  294. package/build-module/store/reducer.js.map +1 -1
  295. package/build-module/store/selectors.js +44 -15
  296. package/build-module/store/selectors.js.map +1 -1
  297. package/build-style/style-rtl.css +148 -410
  298. package/build-style/style.css +148 -410
  299. package/package.json +28 -28
  300. package/src/components/block-alignment-control/constants.js +45 -0
  301. package/src/components/block-alignment-control/ui.js +69 -109
  302. package/src/components/block-alignment-control/ui.native.js +86 -0
  303. package/src/components/block-alignment-matrix-control/index.js +1 -5
  304. package/src/components/block-content-overlay/index.js +9 -79
  305. package/src/components/block-content-overlay/style.scss +2 -11
  306. package/src/components/block-draggable/draggable-chip.native.js +49 -0
  307. package/src/components/block-draggable/dropping-insertion-point.native.js +181 -0
  308. package/src/components/block-draggable/dropping-insertion-point.native.scss +8 -0
  309. package/src/components/block-draggable/index.native.js +458 -0
  310. package/src/components/block-draggable/style.native.scss +19 -0
  311. package/src/components/block-draggable/use-scroll-when-dragging.native.js +135 -0
  312. package/src/components/block-list/block-list-context.native.js +175 -0
  313. package/src/components/block-list/block-list-item-cell.native.js +49 -0
  314. package/src/components/block-list/block-list-item.native.js +7 -11
  315. package/src/components/block-list/block.native.js +38 -8
  316. package/src/components/block-list/index.native.js +54 -13
  317. package/src/components/block-list/style.scss +7 -18
  318. package/src/components/block-list/test/block-list-context.native.js +253 -0
  319. package/src/components/block-list/test/fixtures/block-list-context.native.js +79 -0
  320. package/src/components/block-list/use-block-props/index.js +10 -5
  321. package/src/components/block-list/use-block-props/use-block-class-names.js +1 -11
  322. package/src/components/block-list/use-in-between-inserter.js +1 -1
  323. package/src/components/block-lock/modal.js +42 -3
  324. package/src/components/block-lock/toolbar.js +2 -2
  325. package/src/components/block-lock/use-block-lock.js +4 -1
  326. package/src/components/block-mobile-toolbar/index.native.js +8 -1
  327. package/src/components/block-mover/button.js +5 -7
  328. package/src/components/block-mover/index.js +37 -60
  329. package/src/components/block-mover/index.native.js +22 -6
  330. package/src/components/block-mover/stories/index.js +110 -0
  331. package/src/components/block-mover/style.scss +48 -138
  332. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +6 -0
  333. package/src/components/block-navigation/dropdown.js +12 -8
  334. package/src/components/block-popover/README.md +41 -0
  335. package/src/components/block-popover/inbetween.js +188 -0
  336. package/src/components/block-popover/index.js +75 -0
  337. package/src/components/block-popover/style.scss +28 -0
  338. package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  339. package/src/components/block-preview/index.js +1 -4
  340. package/src/components/block-styles/index.js +1 -12
  341. package/src/components/block-switcher/style.scss +2 -43
  342. package/src/components/block-toolbar/style.scss +0 -12
  343. package/src/components/block-tools/back-compat.js +1 -1
  344. package/src/components/block-tools/block-selection-button.js +3 -1
  345. package/src/components/block-tools/index.js +6 -4
  346. package/src/components/block-tools/insertion-point.js +19 -152
  347. package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -151
  348. package/src/components/block-tools/style.scss +12 -135
  349. package/src/components/border-radius-control/input-controls.js +16 -8
  350. package/src/components/border-radius-control/style.scss +7 -3
  351. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  352. package/src/components/color-style-selector/index.js +18 -9
  353. package/src/components/colors-gradients/dropdown.js +156 -62
  354. package/src/components/colors-gradients/style.scss +51 -23
  355. package/src/components/default-block-appender/style.scss +1 -2
  356. package/src/components/duotone-control/index.js +8 -1
  357. package/src/components/duotone-control/style.scss +1 -7
  358. package/src/components/gradients/README.md +29 -0
  359. package/src/components/image-editor/use-save-image.js +2 -1
  360. package/src/components/image-size-control/README.md +1 -1
  361. package/src/components/index.js +1 -3
  362. package/src/components/inserter/index.native.js +60 -25
  363. package/src/components/inserter/style.native.scss +25 -3
  364. package/src/components/inserter/style.scss +2 -1
  365. package/src/components/link-control/constants.js +11 -0
  366. package/src/components/link-control/search-results.js +4 -5
  367. package/src/components/link-control/use-search-handler.js +11 -5
  368. package/src/components/list-view/block.js +24 -34
  369. package/src/components/list-view/branch.js +10 -20
  370. package/src/components/list-view/context.js +1 -4
  371. package/src/components/list-view/drop-indicator.js +0 -1
  372. package/src/components/list-view/index.js +11 -41
  373. package/src/components/list-view/style.scss +2 -1
  374. package/src/components/navigable-toolbar/README.md +16 -0
  375. package/src/components/navigable-toolbar/index.js +12 -2
  376. package/src/components/preview-options/style.scss +0 -4
  377. package/src/components/rich-text/format-toolbar-container.js +0 -1
  378. package/src/components/rich-text/index.js +1 -3
  379. package/src/components/rich-text/index.native.js +0 -4
  380. package/src/components/rich-text/style.scss +2 -8
  381. package/src/components/url-input/index.js +9 -4
  382. package/src/components/use-block-display-information/index.js +2 -0
  383. package/src/components/use-block-drop-zone/index.native.js +173 -0
  384. package/src/components/use-on-block-drop/index.native.js +119 -0
  385. package/src/components/use-setting/index.js +57 -21
  386. package/src/hooks/anchor.js +1 -1
  387. package/src/hooks/border.js +429 -72
  388. package/src/hooks/color-panel.js +13 -9
  389. package/src/hooks/color.scss +0 -62
  390. package/src/hooks/dimensions.js +44 -38
  391. package/src/hooks/index.js +2 -1
  392. package/src/hooks/margin.js +64 -15
  393. package/src/hooks/padding.js +60 -15
  394. package/src/hooks/padding.scss +12 -0
  395. package/src/hooks/settings.js +32 -0
  396. package/src/hooks/style.js +25 -39
  397. package/src/hooks/test/settings.js +48 -0
  398. package/src/hooks/typography.js +2 -0
  399. package/src/hooks/use-border-props.js +15 -32
  400. package/src/store/actions.js +14 -2
  401. package/src/store/defaults.js +0 -1
  402. package/src/store/reducer.js +0 -21
  403. package/src/store/selectors.js +46 -15
  404. package/src/store/test/actions.js +0 -18
  405. package/src/store/test/reducer.js +0 -19
  406. package/src/store/test/selectors.js +17 -19
  407. package/src/style.scss +2 -3
  408. package/tsconfig.tsbuildinfo +1 -1
  409. package/build/components/block-mobile-toolbar/index.js +0 -42
  410. package/build/components/block-mobile-toolbar/index.js.map +0 -1
  411. package/build/components/block-tools/block-popover.js +0 -327
  412. package/build/components/block-tools/block-popover.js.map +0 -1
  413. package/build/components/block-tools/use-popover-scroll.js.map +0 -1
  414. package/build/components/border-style-control/index.js +0 -60
  415. package/build/components/border-style-control/index.js.map +0 -1
  416. package/build/components/colors-gradients/tools-panel-color-dropdown.js +0 -89
  417. package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
  418. package/build/components/list-view/appender.js +0 -93
  419. package/build/components/list-view/appender.js.map +0 -1
  420. package/build/components/list-view/list-item.js +0 -62
  421. package/build/components/list-view/list-item.js.map +0 -1
  422. package/build/components/rich-text/use-caret-in-format.js +0 -43
  423. package/build/components/rich-text/use-caret-in-format.js.map +0 -1
  424. package/build/hooks/border-color.js +0 -302
  425. package/build/hooks/border-color.js.map +0 -1
  426. package/build/hooks/border-style.js +0 -96
  427. package/build/hooks/border-style.js.map +0 -1
  428. package/build/hooks/border-width.js +0 -162
  429. package/build/hooks/border-width.js.map +0 -1
  430. package/build-module/components/block-mobile-toolbar/index.js +0 -31
  431. package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
  432. package/build-module/components/block-tools/block-popover.js +0 -306
  433. package/build-module/components/block-tools/block-popover.js.map +0 -1
  434. package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
  435. package/build-module/components/border-style-control/index.js +0 -50
  436. package/build-module/components/border-style-control/index.js.map +0 -1
  437. package/build-module/components/colors-gradients/tools-panel-color-dropdown.js +0 -75
  438. package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
  439. package/build-module/components/list-view/appender.js +0 -76
  440. package/build-module/components/list-view/appender.js.map +0 -1
  441. package/build-module/components/list-view/list-item.js +0 -47
  442. package/build-module/components/list-view/list-item.js.map +0 -1
  443. package/build-module/components/rich-text/use-caret-in-format.js +0 -33
  444. package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
  445. package/build-module/hooks/border-color.js +0 -276
  446. package/build-module/hooks/border-color.js.map +0 -1
  447. package/build-module/hooks/border-style.js +0 -78
  448. package/build-module/hooks/border-style.js.map +0 -1
  449. package/build-module/hooks/border-width.js +0 -143
  450. package/build-module/hooks/border-width.js.map +0 -1
  451. package/src/components/block-alignment-matrix-control/style.scss +0 -10
  452. package/src/components/block-mobile-toolbar/index.js +0 -24
  453. package/src/components/block-mobile-toolbar/style.scss +0 -29
  454. package/src/components/border-style-control/index.js +0 -47
  455. package/src/components/border-style-control/style.scss +0 -18
  456. package/src/components/colors-gradients/tools-panel-color-dropdown.js +0 -85
  457. package/src/components/list-view/appender.js +0 -82
  458. package/src/components/list-view/list-item.js +0 -59
  459. package/src/components/rich-text/use-caret-in-format.js +0 -28
  460. package/src/hooks/border-color.js +0 -315
  461. package/src/hooks/border-style.js +0 -64
  462. package/src/hooks/border-width.js +0 -139
@@ -0,0 +1,135 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { useWindowDimensions } from 'react-native';
5
+ import {
6
+ useSharedValue,
7
+ useAnimatedRef,
8
+ scrollTo,
9
+ useAnimatedReaction,
10
+ withTiming,
11
+ withRepeat,
12
+ cancelAnimation,
13
+ Easing,
14
+ } from 'react-native-reanimated';
15
+
16
+ /**
17
+ * Internal dependencies
18
+ */
19
+ import { useBlockListContext } from '../block-list/block-list-context';
20
+
21
+ const SCROLL_INACTIVE_DISTANCE_PX = 50;
22
+ const SCROLL_INTERVAL_MS = 1000;
23
+ const VELOCITY_MULTIPLIER = 5000;
24
+
25
+ /**
26
+ * React hook that scrolls the scroll container when a block is being dragged.
27
+ *
28
+ * @return {Function[]} `startScrolling`, `scrollOnDragOver`, `stopScrolling`
29
+ * functions to be called in `onDragStart`, `onDragOver`
30
+ * and `onDragEnd` events respectively. Additionally,
31
+ * `scrollHandler` function is returned which should be
32
+ * called in the `onScroll` event of the block list.
33
+ */
34
+ export default function useScrollWhenDragging() {
35
+ const { scrollRef } = useBlockListContext();
36
+ const animatedScrollRef = useAnimatedRef();
37
+ animatedScrollRef( scrollRef );
38
+
39
+ const { height: windowHeight } = useWindowDimensions();
40
+
41
+ const velocityY = useSharedValue( 0 );
42
+ const offsetY = useSharedValue( 0 );
43
+ const dragStartY = useSharedValue( 0 );
44
+ const animationTimer = useSharedValue( 0 );
45
+ const isAnimationTimerActive = useSharedValue( false );
46
+ const isScrollActive = useSharedValue( false );
47
+
48
+ const scroll = {
49
+ offsetY: useSharedValue( 0 ),
50
+ maxOffsetY: useSharedValue( 0 ),
51
+ };
52
+ const scrollHandler = ( event ) => {
53
+ 'worklet';
54
+ const { contentSize, contentOffset, layoutMeasurement } = event;
55
+ scroll.offsetY.value = contentOffset.y;
56
+ scroll.maxOffsetY.value = contentSize.height - layoutMeasurement.height;
57
+ };
58
+
59
+ const stopScrolling = () => {
60
+ 'worklet';
61
+ cancelAnimation( animationTimer );
62
+
63
+ isAnimationTimerActive.value = false;
64
+ isScrollActive.value = false;
65
+ velocityY.value = 0;
66
+ };
67
+
68
+ const startScrolling = ( y ) => {
69
+ 'worklet';
70
+ stopScrolling();
71
+ offsetY.value = scroll.offsetY.value;
72
+ dragStartY.value = y;
73
+
74
+ animationTimer.value = 0;
75
+ animationTimer.value = withRepeat(
76
+ withTiming( 1, {
77
+ duration: SCROLL_INTERVAL_MS,
78
+ easing: Easing.linear,
79
+ } ),
80
+ -1,
81
+ true
82
+ );
83
+ isAnimationTimerActive.value = true;
84
+ };
85
+
86
+ const scrollOnDragOver = ( y ) => {
87
+ 'worklet';
88
+ const dragDistance = Math.max(
89
+ Math.abs( y - dragStartY.value ) - SCROLL_INACTIVE_DISTANCE_PX,
90
+ 0
91
+ );
92
+ const distancePercentage = dragDistance / windowHeight;
93
+
94
+ if ( ! isScrollActive.value ) {
95
+ isScrollActive.value = dragDistance > 0;
96
+ } else if ( y > dragStartY.value ) {
97
+ // User is dragging downwards.
98
+ velocityY.value = VELOCITY_MULTIPLIER * distancePercentage;
99
+ } else if ( y < dragStartY.value ) {
100
+ // User is dragging upwards.
101
+ velocityY.value = -VELOCITY_MULTIPLIER * distancePercentage;
102
+ } else {
103
+ velocityY.value = 0;
104
+ }
105
+ };
106
+
107
+ useAnimatedReaction(
108
+ () => animationTimer.value,
109
+ ( value, previous ) => {
110
+ if ( velocityY.value === 0 ) {
111
+ return;
112
+ }
113
+
114
+ const delta = Math.abs( value - previous );
115
+ let newOffset = offsetY.value + delta * velocityY.value;
116
+
117
+ if ( scroll.maxOffsetY.value !== 0 ) {
118
+ newOffset = Math.max(
119
+ 0,
120
+ Math.min( scroll.maxOffsetY.value, newOffset )
121
+ );
122
+ } else {
123
+ // Scroll values are empty until receiving the first scroll event.
124
+ // In that case, the max offset is unknown and we can't clamp the
125
+ // new offset value.
126
+ newOffset = Math.max( 0, newOffset );
127
+ }
128
+
129
+ offsetY.value = newOffset;
130
+ scrollTo( animatedScrollRef, 0, offsetY.value, false );
131
+ }
132
+ );
133
+
134
+ return [ startScrolling, scrollOnDragOver, stopScrolling, scrollHandler ];
135
+ }
@@ -0,0 +1,175 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { orderBy } from 'lodash';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { createContext, useContext } from '@wordpress/element';
10
+
11
+ export const DEFAULT_BLOCK_LIST_CONTEXT = {
12
+ scrollRef: null,
13
+ blocksLayouts: { current: {} },
14
+ findBlockLayoutByClientId,
15
+ getBlockLayoutsOrderedByYCoord,
16
+ findBlockLayoutByPosition,
17
+ updateBlocksLayouts,
18
+ };
19
+
20
+ const Context = createContext( DEFAULT_BLOCK_LIST_CONTEXT );
21
+ const { Provider, Consumer } = Context;
22
+
23
+ /**
24
+ * Finds a block's layout data by position.
25
+ *
26
+ * @param {Object} data Blocks layouts object.
27
+ * @param {Object} position Position to use for finding the block.
28
+ * @param {number} position.x X coordinate.
29
+ * @param {number} position.y Y coordinate.
30
+ *
31
+ * @return {Object|undefined} Found block layout data that matches the provided position. If none is found, `undefined` will be returned.
32
+ */
33
+ function findBlockLayoutByPosition( data, position ) {
34
+ // Only enabled for root level blocks
35
+ return Object.values( data ).find( ( block ) => {
36
+ return (
37
+ position.x >= block.x &&
38
+ position.x <= block.x + block.width &&
39
+ position.y >= block.y &&
40
+ position.y <= block.y + block.height
41
+ );
42
+ } );
43
+ }
44
+
45
+ /**
46
+ * Finds a block's layout data by its client Id.
47
+ *
48
+ * @param {Object} data Blocks layouts object.
49
+ * @param {string} clientId Block's clientId.
50
+ *
51
+ * @return {Object} Found block layout data.
52
+ */
53
+ function findBlockLayoutByClientId( data, clientId ) {
54
+ return Object.entries( data ).reduce( ( acc, entry ) => {
55
+ const item = entry[ 1 ];
56
+ if ( acc ) {
57
+ return acc;
58
+ }
59
+ if ( item?.clientId === clientId ) {
60
+ return item;
61
+ }
62
+ if ( item?.innerBlocks && Object.keys( item.innerBlocks ).length > 0 ) {
63
+ return findBlockLayoutByClientId( item.innerBlocks, clientId );
64
+ }
65
+ return null;
66
+ }, null );
67
+ }
68
+
69
+ /**
70
+ * Deletes the layout data of a block by its client Id.
71
+ *
72
+ * @param {Object} data Blocks layouts object.
73
+ * @param {string} clientId Block's clientsId.
74
+ *
75
+ * @return {Object} Updated data object.
76
+ */
77
+ export function deleteBlockLayoutByClientId( data, clientId ) {
78
+ return Object.keys( data ).reduce( ( acc, key ) => {
79
+ if ( key !== clientId ) {
80
+ acc[ key ] = data[ key ];
81
+ }
82
+ if (
83
+ data[ key ]?.innerBlocks &&
84
+ Object.keys( data[ key ].innerBlocks ).length > 0
85
+ ) {
86
+ if ( acc[ key ] ) {
87
+ acc[ key ].innerBlocks = deleteBlockLayoutByClientId(
88
+ data[ key ].innerBlocks,
89
+ clientId
90
+ );
91
+ }
92
+ }
93
+ return acc;
94
+ }, {} );
95
+ }
96
+
97
+ /**
98
+ * Orders the block's layout data by its Y coordinate.
99
+ *
100
+ * @param {Object} data Blocks layouts object.
101
+ *
102
+ * @return {Object} Blocks layouts object ordered by its Y coordinate.
103
+ */
104
+ function getBlockLayoutsOrderedByYCoord( data ) {
105
+ // Only enabled for root level blocks.
106
+ // Using lodash orderBy due to hermes not having
107
+ // stable support for native .sort(). It will be
108
+ // supported in the React Native version 0.68.0.
109
+ return orderBy( data, [ 'y', 'asc' ] );
110
+ }
111
+
112
+ /**
113
+ * Updates or deletes a block's layout data in the blocksLayouts object,
114
+ * in case of deletion, the layout data is not required.
115
+ *
116
+ * @param {Object} blocksLayouts Blocks layouts object.
117
+ * @param {Object} blockData Block's layout data to add or remove to/from the blockLayouts object.
118
+ * @param {string} blockData.clientId Block's clientId.
119
+ * @param {?string} blockData.rootClientId Optional. Block's rootClientId.
120
+ * @param {?boolean} blockData.shouldRemove Optional. Flag to remove it from the blocksLayout list.
121
+ * @param {number} blockData.width Block's width.
122
+ * @param {number} blockData.height Block's height.
123
+ * @param {number} blockData.x Block's x coordinate (relative to the parent).
124
+ * @param {number} blockData.y Block's y coordinate (relative to the parent).
125
+ */
126
+
127
+ function updateBlocksLayouts( blocksLayouts, blockData ) {
128
+ const { clientId, rootClientId, shouldRemove, ...layoutProps } = blockData;
129
+
130
+ if ( clientId && shouldRemove ) {
131
+ blocksLayouts.current = deleteBlockLayoutByClientId(
132
+ blocksLayouts.current,
133
+ clientId
134
+ );
135
+ return;
136
+ }
137
+
138
+ if ( clientId && ! rootClientId ) {
139
+ blocksLayouts.current[ clientId ] = {
140
+ clientId,
141
+ rootClientId,
142
+ ...layoutProps,
143
+ innerBlocks: {
144
+ ...blocksLayouts.current[ clientId ]?.innerBlocks,
145
+ },
146
+ };
147
+ } else if ( clientId && rootClientId ) {
148
+ const block = findBlockLayoutByClientId(
149
+ blocksLayouts.current,
150
+ rootClientId
151
+ );
152
+
153
+ if ( block ) {
154
+ block.innerBlocks[ clientId ] = {
155
+ clientId,
156
+ rootClientId,
157
+ ...layoutProps,
158
+ innerBlocks: {
159
+ ...block.innerBlocks[ clientId ]?.innerBlocks,
160
+ },
161
+ };
162
+ }
163
+ }
164
+ }
165
+
166
+ export { Provider as BlockListProvider, Consumer as BlockListConsumer };
167
+
168
+ /**
169
+ * Hook that returns the block list context.
170
+ *
171
+ * @return {Object} Block list context
172
+ */
173
+ export const useBlockListContext = () => {
174
+ return useContext( Context );
175
+ };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { View } from 'react-native';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { useEffect, useCallback } from '@wordpress/element';
10
+
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import { useBlockListContext } from './block-list-context';
15
+
16
+ function BlockListItemCell( { children, clientId, rootClientId, onLayout } ) {
17
+ const { blocksLayouts, updateBlocksLayouts } = useBlockListContext();
18
+
19
+ useEffect( () => {
20
+ return () => {
21
+ updateBlocksLayouts( blocksLayouts, {
22
+ clientId,
23
+ shouldRemove: true,
24
+ } );
25
+ };
26
+ }, [] );
27
+
28
+ const onCellLayout = useCallback(
29
+ ( event ) => {
30
+ const {
31
+ nativeEvent: { layout },
32
+ } = event;
33
+ updateBlocksLayouts( blocksLayouts, {
34
+ clientId,
35
+ rootClientId,
36
+ ...layout,
37
+ } );
38
+
39
+ if ( onLayout ) {
40
+ onLayout( event );
41
+ }
42
+ },
43
+ [ clientId, rootClientId, updateBlocksLayouts, onLayout ]
44
+ );
45
+
46
+ return <View onLayout={ onCellLayout }>{ children }</View>;
47
+ }
48
+
49
+ export default BlockListItemCell;
@@ -121,6 +121,7 @@ export class BlockListItem extends Component {
121
121
  blockWidth,
122
122
  ...restProps
123
123
  } = this.props;
124
+
124
125
  const readableContentViewStyle =
125
126
  contentResizeMode === 'stretch' && stretchStyle;
126
127
  const { isContainerRelated } = alignmentHelpers;
@@ -162,25 +163,20 @@ export class BlockListItem extends Component {
162
163
  }
163
164
 
164
165
  render() {
165
- const {
166
- gridProperties,
167
- clientId,
168
- parentWidth,
169
- items,
170
- blockWidth,
171
- } = this.props;
166
+ const { parentWidth, blockWidth, isGridItem } = this.props;
172
167
 
173
168
  if ( ! blockWidth ) {
174
169
  return null;
175
170
  }
176
171
 
177
- if ( gridProperties ) {
172
+ if ( isGridItem ) {
173
+ const { numOfColumns, tileCount, tileIndex } = this.props;
178
174
  return (
179
175
  <Grid
180
- numOfColumns={ gridProperties.numColumns }
181
- tileCount={ items.length }
182
- index={ items.indexOf( clientId ) }
183
176
  maxWidth={ parentWidth }
177
+ numOfColumns={ numOfColumns }
178
+ tileCount={ tileCount }
179
+ index={ tileIndex }
184
180
  >
185
181
  { this.renderContent() }
186
182
  </Grid>
@@ -31,6 +31,7 @@ import BlockEdit from '../block-edit';
31
31
  import BlockInvalidWarning from './block-invalid-warning';
32
32
  import BlockMobileToolbar from '../block-mobile-toolbar';
33
33
  import { store as blockEditorStore } from '../../store';
34
+ import BlockDraggable from '../block-draggable';
34
35
 
35
36
  const emptyArray = [];
36
37
  function BlockForType( {
@@ -47,6 +48,7 @@ function BlockForType( {
47
48
  onDeleteBlock,
48
49
  onReplace,
49
50
  parentWidth,
51
+ parentBlockAlignment,
50
52
  wrapperProps,
51
53
  blockWidth,
52
54
  baseGlobalStyles,
@@ -95,6 +97,7 @@ function BlockForType( {
95
97
  contentStyle={ contentStyle }
96
98
  onDeleteBlock={ onDeleteBlock }
97
99
  blockWidth={ blockWidth }
100
+ parentBlockAlignment={ parentBlockAlignment }
98
101
  />
99
102
  <View onLayout={ getBlockWidth } />
100
103
  </GlobalStylesContext.Provider>
@@ -187,6 +190,8 @@ class BlockListBlock extends Component {
187
190
  marginHorizontal,
188
191
  isInnerBlockSelected,
189
192
  name,
193
+ draggingEnabled,
194
+ draggingClientId,
190
195
  } = this.props;
191
196
 
192
197
  if ( ! attributes || ! blockType ) {
@@ -254,14 +259,22 @@ class BlockListBlock extends Component {
254
259
  ] }
255
260
  />
256
261
  ) }
257
- { isValid ? (
258
- this.getBlockForType()
259
- ) : (
260
- <BlockInvalidWarning
261
- blockTitle={ title }
262
- icon={ icon }
263
- />
264
- ) }
262
+ <BlockDraggable
263
+ clientId={ clientId }
264
+ draggingClientId={ draggingClientId }
265
+ enabled={ draggingEnabled }
266
+ >
267
+ { () =>
268
+ isValid ? (
269
+ this.getBlockForType()
270
+ ) : (
271
+ <BlockInvalidWarning
272
+ blockTitle={ title }
273
+ icon={ icon }
274
+ />
275
+ )
276
+ }
277
+ </BlockDraggable>
265
278
  <View
266
279
  style={ styles.neutralToolbar }
267
280
  ref={ this.anchorNodeRef }
@@ -276,6 +289,7 @@ class BlockListBlock extends Component {
276
289
  blockWidth={ blockWidth }
277
290
  anchorNodeRef={ this.anchorNodeRef.current }
278
291
  isFullWidth={ isFullWidthToolbar }
292
+ draggingClientId={ draggingClientId }
279
293
  />
280
294
  ) }
281
295
  </View>
@@ -306,6 +320,7 @@ export default compose( [
306
320
  withSelect( ( select, { clientId } ) => {
307
321
  const {
308
322
  getBlockIndex,
323
+ getBlockCount,
309
324
  getSettings,
310
325
  isBlockSelected,
311
326
  getBlock,
@@ -313,6 +328,7 @@ export default compose( [
313
328
  getLowestCommonAncestorWithSelectedBlock,
314
329
  getBlockParents,
315
330
  hasSelectedInnerBlock,
331
+ getBlockHierarchyRootClientId,
316
332
  } = select( blockEditorStore );
317
333
 
318
334
  const order = getBlockIndex( clientId );
@@ -357,6 +373,18 @@ export default compose( [
357
373
  const baseGlobalStyles = getSettings()
358
374
  ?.__experimentalGlobalStylesBaseStyles;
359
375
 
376
+ const hasInnerBlocks = getBlockCount( clientId ) > 0;
377
+ // For blocks with inner blocks, we only enable the dragging in the nested
378
+ // blocks if any of them are selected. This way we prevent the long-press
379
+ // gesture from being disabled for elements within the block UI.
380
+ const draggingEnabled =
381
+ ! hasInnerBlocks ||
382
+ isSelected ||
383
+ ! hasSelectedInnerBlock( clientId, true );
384
+ // Dragging nested blocks is not supported yet. For this reason, the block to be dragged
385
+ // will be the top in the hierarchy.
386
+ const draggingClientId = getBlockHierarchyRootClientId( clientId );
387
+
360
388
  return {
361
389
  icon,
362
390
  name: name || 'core/missing',
@@ -364,6 +392,8 @@ export default compose( [
364
392
  title,
365
393
  attributes,
366
394
  blockType,
395
+ draggingClientId,
396
+ draggingEnabled,
367
397
  isSelected,
368
398
  isInnerBlockSelected,
369
399
  isValid,
@@ -25,10 +25,15 @@ import { __ } from '@wordpress/i18n';
25
25
  import styles from './style.scss';
26
26
  import BlockListAppender from '../block-list-appender';
27
27
  import BlockListItem from './block-list-item';
28
+ import BlockListItemCell from './block-list-item-cell';
29
+ import {
30
+ BlockListProvider,
31
+ BlockListConsumer,
32
+ DEFAULT_BLOCK_LIST_CONTEXT,
33
+ } from './block-list-context';
34
+ import { BlockDraggableWrapper } from '../block-draggable';
28
35
  import { store as blockEditorStore } from '../../store';
29
36
 
30
- const BlockListContext = createContext();
31
-
32
37
  export const OnCaretVerticalPositionChange = createContext();
33
38
 
34
39
  const stylesMemo = {};
@@ -78,6 +83,9 @@ export class BlockList extends Component {
78
83
  );
79
84
  this.renderEmptyList = this.renderEmptyList.bind( this );
80
85
  this.getExtraData = this.getExtraData.bind( this );
86
+ this.getCellRendererComponent = this.getCellRendererComponent.bind(
87
+ this
88
+ );
81
89
 
82
90
  this.onLayout = this.onLayout.bind( this );
83
91
 
@@ -154,6 +162,18 @@ export class BlockList extends Component {
154
162
  return this.extraData;
155
163
  }
156
164
 
165
+ getCellRendererComponent( { children, item, onLayout } ) {
166
+ const { rootClientId } = this.props;
167
+ return (
168
+ <BlockListItemCell
169
+ children={ children }
170
+ clientId={ item }
171
+ onLayout={ onLayout }
172
+ rootClientId={ rootClientId }
173
+ />
174
+ );
175
+ }
176
+
157
177
  onLayout( { nativeEvent } ) {
158
178
  const { layout } = nativeEvent;
159
179
  const { blockWidth } = this.state;
@@ -170,20 +190,27 @@ export class BlockList extends Component {
170
190
  }
171
191
 
172
192
  render() {
173
- const { isRootList } = this.props;
193
+ const { isRootList, isRTL } = this.props;
174
194
  // Use of Context to propagate the main scroll ref to its children e.g InnerBlocks.
175
195
  const blockList = isRootList ? (
176
- <BlockListContext.Provider value={ this.scrollViewRef }>
177
- { this.renderList() }
178
- </BlockListContext.Provider>
196
+ <BlockListProvider
197
+ value={ {
198
+ ...DEFAULT_BLOCK_LIST_CONTEXT,
199
+ scrollRef: this.scrollViewRef,
200
+ } }
201
+ >
202
+ <BlockDraggableWrapper isRTL={ isRTL }>
203
+ { ( { onScroll } ) => this.renderList( { onScroll } ) }
204
+ </BlockDraggableWrapper>
205
+ </BlockListProvider>
179
206
  ) : (
180
- <BlockListContext.Consumer>
181
- { ( ref ) =>
207
+ <BlockListConsumer>
208
+ { ( { scrollRef } ) =>
182
209
  this.renderList( {
183
- parentScrollRef: ref,
210
+ parentScrollRef: scrollRef,
184
211
  } )
185
212
  }
186
- </BlockListContext.Consumer>
213
+ </BlockListConsumer>
187
214
  );
188
215
 
189
216
  return (
@@ -212,7 +239,7 @@ export class BlockList extends Component {
212
239
  contentResizeMode,
213
240
  blockWidth,
214
241
  } = this.props;
215
- const { parentScrollRef } = extraProps;
242
+ const { parentScrollRef, onScroll } = extraProps;
216
243
 
217
244
  const {
218
245
  blockToolbar,
@@ -279,6 +306,7 @@ export class BlockList extends Component {
279
306
  data={ blockClientIds }
280
307
  keyExtractor={ identity }
281
308
  renderItem={ this.renderItem }
309
+ CellRendererComponent={ this.getCellRendererComponent }
282
310
  shouldPreventAutomaticScroll={
283
311
  this.shouldFlatListPreventAutomaticScroll
284
312
  }
@@ -286,6 +314,7 @@ export class BlockList extends Component {
286
314
  ListHeaderComponent={ header }
287
315
  ListEmptyComponent={ ! isReadOnly && this.renderEmptyList }
288
316
  ListFooterComponent={ this.renderBlockListFooter }
317
+ onScroll={ onScroll }
289
318
  />
290
319
  { this.shouldShowInnerBlockAppender() && (
291
320
  <View
@@ -321,6 +350,15 @@ export class BlockList extends Component {
321
350
  gridProperties,
322
351
  } = this.props;
323
352
  const { blockWidth } = this.state;
353
+
354
+ // Extracting the grid item properties here to avoid
355
+ // re-renders in the blockListItem component.
356
+ const isGridItem = !! gridProperties;
357
+ const gridItemProps = gridProperties && {
358
+ numOfColumns: gridProperties.numColumns,
359
+ tileCount: blockClientIds.length,
360
+ tileIndex: blockClientIds.indexOf( clientId ),
361
+ };
324
362
  return (
325
363
  <BlockListItem
326
364
  isStackedHorizontally={ isStackedHorizontally }
@@ -337,8 +375,8 @@ export class BlockList extends Component {
337
375
  this.shouldShowInnerBlockAppender
338
376
  }
339
377
  blockWidth={ blockWidth }
340
- gridProperties={ gridProperties }
341
- items={ blockClientIds }
378
+ isGridItem={ isGridItem }
379
+ { ...gridItemProps }
342
380
  />
343
381
  );
344
382
  }
@@ -401,6 +439,8 @@ export default compose( [
401
439
 
402
440
  const isFloatingToolbarVisible =
403
441
  !! selectedBlockClientId && hasRootInnerBlocks;
442
+ const isRTL = getSettings().isRTL;
443
+
404
444
  return {
405
445
  blockClientIds,
406
446
  blockCount,
@@ -411,6 +451,7 @@ export default compose( [
411
451
  isFloatingToolbarVisible,
412
452
  isStackedHorizontally,
413
453
  maxWidth,
454
+ isRTL,
414
455
  };
415
456
  }
416
457
  ),
@@ -262,12 +262,17 @@
262
262
  right: $border-width;
263
263
  bottom: $border-width;
264
264
  box-shadow: 0 0 0 $border-width var(--wp-admin-theme-color);
265
- border-radius: $radius-block-ui - $border-width; // Border is outset, so subtract the width to achieve correct radius.
265
+ // Border is outset, so subtract the width to achieve correct radius.
266
+ border-radius: $radius-block-ui - $border-width;
266
267
  }
267
268
  }
268
269
 
269
270
  &.is-selected {
270
- cursor: unset;
271
+ cursor: default;
272
+
273
+ &.rich-text {
274
+ cursor: unset;
275
+ }
271
276
 
272
277
  &::after {
273
278
  box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color); // Selected not focussed.
@@ -303,22 +308,6 @@
303
308
  }
304
309
  }
305
310
 
306
- // Active entity spotlight.
307
- // Disable if focus mode is active.
308
- .is-root-container:not(.is-focus-mode) .block-editor-block-list__block.has-active-entity {
309
- opacity: 0.5;
310
- transition: opacity 0.1s linear;
311
- @include reduce-motion("transition");
312
-
313
- &.is-active-entity,
314
- &.has-child-selected,
315
- &:not(.has-child-selected) .block-editor-block-list__block,
316
- &.is-active-entity .block-editor-block-list__block,
317
- .is-active-entity .block-editor-block-list__block {
318
- opacity: 1;
319
- }
320
- }
321
-
322
311
  .wp-block[data-align="left"] > *,
323
312
  .wp-block[data-align="right"] > *,
324
313
  .wp-block.alignleft,