@wordpress/block-editor 12.16.1-next.79a6196f.0 → 12.18.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 (376) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +32 -0
  3. package/build/components/block-draggable/index.js +11 -3
  4. package/build/components/block-draggable/index.js.map +1 -1
  5. package/build/components/block-edit/context.js +3 -1
  6. package/build/components/block-edit/context.js.map +1 -1
  7. package/build/components/block-edit/index.js +4 -2
  8. package/build/components/block-edit/index.js.map +1 -1
  9. package/build/components/block-editing-mode/index.js +6 -3
  10. package/build/components/block-editing-mode/index.js.map +1 -1
  11. package/build/components/block-inspector/index.js +5 -2
  12. package/build/components/block-inspector/index.js.map +1 -1
  13. package/build/components/block-list/block.js +4 -3
  14. package/build/components/block-list/block.js.map +1 -1
  15. package/build/components/block-list/block.native.js +9 -5
  16. package/build/components/block-list/block.native.js.map +1 -1
  17. package/build/components/block-list/index.js +30 -4
  18. package/build/components/block-list/index.js.map +1 -1
  19. package/build/components/block-list/private-block-context.js +1 -1
  20. package/build/components/block-list/private-block-context.js.map +1 -1
  21. package/build/components/block-list/use-in-between-inserter.js +1 -1
  22. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  23. package/build/components/block-popover/inbetween.js +15 -3
  24. package/build/components/block-popover/inbetween.js.map +1 -1
  25. package/build/components/block-preview/auto.js +1 -1
  26. package/build/components/block-preview/auto.js.map +1 -1
  27. package/build/components/block-removal-warning-modal/index.js +3 -2
  28. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  29. package/build/components/block-settings-menu/block-settings-dropdown.js +2 -4
  30. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  31. package/build/components/block-switcher/block-transformations-menu.js +12 -1
  32. package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
  33. package/build/components/block-switcher/index.js +119 -90
  34. package/build/components/block-switcher/index.js.map +1 -1
  35. package/build/components/block-tools/insertion-point.js +10 -3
  36. package/build/components/block-tools/insertion-point.js.map +1 -1
  37. package/build/components/font-sizes/fluid-utils.js +7 -1
  38. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  39. package/build/components/global-styles/border-panel.js +5 -14
  40. package/build/components/global-styles/border-panel.js.map +1 -1
  41. package/build/components/global-styles/effects-panel.js +7 -1
  42. package/build/components/global-styles/effects-panel.js.map +1 -1
  43. package/build/components/iframe/get-compatibility-styles.js +99 -0
  44. package/build/components/iframe/get-compatibility-styles.js.map +1 -0
  45. package/build/components/iframe/index.js +2 -3
  46. package/build/components/iframe/index.js.map +1 -1
  47. package/build/components/index.js +16 -2
  48. package/build/components/index.js.map +1 -1
  49. package/build/components/index.native.js +16 -2
  50. package/build/components/index.native.js.map +1 -1
  51. package/build/components/inspector-controls/groups.js +2 -0
  52. package/build/components/inspector-controls/groups.js.map +1 -1
  53. package/build/components/inspector-controls-tabs/styles-tab.js +3 -0
  54. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  55. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -2
  56. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  57. package/build/components/link-control/link-preview.js +30 -26
  58. package/build/components/link-control/link-preview.js.map +1 -1
  59. package/build/components/link-control/search-input.js +1 -9
  60. package/build/components/link-control/search-input.js.map +1 -1
  61. package/build/components/list-view/block-contents.js +3 -1
  62. package/build/components/list-view/block-contents.js.map +1 -1
  63. package/build/components/list-view/block.js +10 -1
  64. package/build/components/list-view/block.js.map +1 -1
  65. package/build/components/list-view/branch.js +29 -8
  66. package/build/components/list-view/branch.js.map +1 -1
  67. package/build/components/list-view/drop-indicator.js +100 -32
  68. package/build/components/list-view/drop-indicator.js.map +1 -1
  69. package/build/components/list-view/index.js +52 -4
  70. package/build/components/list-view/index.js.map +1 -1
  71. package/build/components/list-view/leaf.js +2 -2
  72. package/build/components/list-view/leaf.js.map +1 -1
  73. package/build/components/list-view/use-list-view-block-indexes.js +30 -0
  74. package/build/components/list-view/use-list-view-block-indexes.js.map +1 -0
  75. package/build/components/list-view/use-list-view-drop-zone.js +56 -5
  76. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  77. package/build/components/list-view/utils.js +92 -0
  78. package/build/components/list-view/utils.js.map +1 -1
  79. package/build/components/provider/index.js +1 -1
  80. package/build/components/provider/index.js.map +1 -1
  81. package/build/components/recursion-provider/index.js +21 -0
  82. package/build/components/recursion-provider/index.js.map +1 -1
  83. package/build/components/rich-text/index.js +30 -6
  84. package/build/components/rich-text/index.js.map +1 -1
  85. package/build/components/rich-text/native/index.native.js +9 -9
  86. package/build/components/rich-text/native/index.native.js.map +1 -1
  87. package/build/components/use-block-drop-zone/index.js +30 -7
  88. package/build/components/use-block-drop-zone/index.js.map +1 -1
  89. package/build/components/use-on-block-drop/index.js +50 -8
  90. package/build/components/use-on-block-drop/index.js.map +1 -1
  91. package/build/hooks/block-hooks.js +5 -14
  92. package/build/hooks/block-hooks.js.map +1 -1
  93. package/build/hooks/content-lock-ui.js +17 -42
  94. package/build/hooks/content-lock-ui.js.map +1 -1
  95. package/build/hooks/effects.js +66 -0
  96. package/build/hooks/effects.js.map +1 -0
  97. package/build/hooks/index.js +14 -0
  98. package/build/hooks/index.js.map +1 -1
  99. package/build/hooks/index.native.js +13 -0
  100. package/build/hooks/index.native.js.map +1 -1
  101. package/build/hooks/style.js +6 -2
  102. package/build/hooks/style.js.map +1 -1
  103. package/build/hooks/supports.js +2 -1
  104. package/build/hooks/supports.js.map +1 -1
  105. package/build/hooks/typography.native.js +2 -2
  106. package/build/hooks/typography.native.js.map +1 -1
  107. package/build/hooks/use-bindings-attributes.js +115 -0
  108. package/build/hooks/use-bindings-attributes.js.map +1 -0
  109. package/build/hooks/use-shadow-props.js +46 -0
  110. package/build/hooks/use-shadow-props.js.map +1 -0
  111. package/build/hooks/utils.js +7 -6
  112. package/build/hooks/utils.js.map +1 -1
  113. package/build/index.js +14 -0
  114. package/build/index.js.map +1 -1
  115. package/build/store/actions.js +10 -6
  116. package/build/store/actions.js.map +1 -1
  117. package/build/store/index.js +2 -0
  118. package/build/store/index.js.map +1 -1
  119. package/build/store/private-actions.js +37 -0
  120. package/build/store/private-actions.js.map +1 -1
  121. package/build/store/private-selectors.js +60 -9
  122. package/build/store/private-selectors.js.map +1 -1
  123. package/build/store/reducer.js +44 -3
  124. package/build/store/reducer.js.map +1 -1
  125. package/build/store/resolvers.js +27 -0
  126. package/build/store/resolvers.js.map +1 -0
  127. package/build/store/selectors.js +94 -56
  128. package/build/store/selectors.js.map +1 -1
  129. package/build/store/utils.js +5 -26
  130. package/build/store/utils.js.map +1 -1
  131. package/build/utils/index.js +0 -16
  132. package/build/utils/index.js.map +1 -1
  133. package/build/utils/math.js +13 -0
  134. package/build/utils/math.js.map +1 -1
  135. package/build/utils/transform-styles/index.js +37 -27
  136. package/build/utils/transform-styles/index.js.map +1 -1
  137. package/build-module/components/block-draggable/index.js +11 -3
  138. package/build-module/components/block-draggable/index.js.map +1 -1
  139. package/build-module/components/block-edit/context.js +1 -0
  140. package/build-module/components/block-edit/context.js.map +1 -1
  141. package/build-module/components/block-edit/index.js +5 -3
  142. package/build-module/components/block-edit/index.js.map +1 -1
  143. package/build-module/components/block-editing-mode/index.js +7 -4
  144. package/build-module/components/block-editing-mode/index.js.map +1 -1
  145. package/build-module/components/block-inspector/index.js +5 -2
  146. package/build-module/components/block-inspector/index.js.map +1 -1
  147. package/build-module/components/block-list/block.js +6 -5
  148. package/build-module/components/block-list/block.js.map +1 -1
  149. package/build-module/components/block-list/block.native.js +11 -7
  150. package/build-module/components/block-list/block.native.js.map +1 -1
  151. package/build-module/components/block-list/index.js +31 -5
  152. package/build-module/components/block-list/index.js.map +1 -1
  153. package/build-module/components/block-list/private-block-context.js +1 -1
  154. package/build-module/components/block-list/private-block-context.js.map +1 -1
  155. package/build-module/components/block-list/use-in-between-inserter.js +1 -1
  156. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  157. package/build-module/components/block-popover/inbetween.js +15 -3
  158. package/build-module/components/block-popover/inbetween.js.map +1 -1
  159. package/build-module/components/block-preview/auto.js +3 -3
  160. package/build-module/components/block-preview/auto.js.map +1 -1
  161. package/build-module/components/block-removal-warning-modal/index.js +3 -2
  162. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  163. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -4
  164. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  165. package/build-module/components/block-switcher/block-transformations-menu.js +12 -1
  166. package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
  167. package/build-module/components/block-switcher/index.js +116 -86
  168. package/build-module/components/block-switcher/index.js.map +1 -1
  169. package/build-module/components/block-tools/insertion-point.js +10 -3
  170. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  171. package/build-module/components/font-sizes/fluid-utils.js +7 -1
  172. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  173. package/build-module/components/global-styles/border-panel.js +5 -14
  174. package/build-module/components/global-styles/border-panel.js.map +1 -1
  175. package/build-module/components/global-styles/effects-panel.js +7 -1
  176. package/build-module/components/global-styles/effects-panel.js.map +1 -1
  177. package/build-module/components/iframe/get-compatibility-styles.js +93 -0
  178. package/build-module/components/iframe/get-compatibility-styles.js.map +1 -0
  179. package/build-module/components/iframe/index.js +2 -3
  180. package/build-module/components/iframe/index.js.map +1 -1
  181. package/build-module/components/index.js +1 -1
  182. package/build-module/components/index.js.map +1 -1
  183. package/build-module/components/index.native.js +1 -1
  184. package/build-module/components/index.native.js.map +1 -1
  185. package/build-module/components/inspector-controls/groups.js +2 -0
  186. package/build-module/components/inspector-controls/groups.js.map +1 -1
  187. package/build-module/components/inspector-controls-tabs/styles-tab.js +3 -0
  188. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  189. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -2
  190. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  191. package/build-module/components/link-control/link-preview.js +32 -28
  192. package/build-module/components/link-control/link-preview.js.map +1 -1
  193. package/build-module/components/link-control/search-input.js +1 -8
  194. package/build-module/components/link-control/search-input.js.map +1 -1
  195. package/build-module/components/list-view/block-contents.js +3 -1
  196. package/build-module/components/list-view/block-contents.js.map +1 -1
  197. package/build-module/components/list-view/block.js +10 -1
  198. package/build-module/components/list-view/block.js.map +1 -1
  199. package/build-module/components/list-view/branch.js +30 -9
  200. package/build-module/components/list-view/branch.js.map +1 -1
  201. package/build-module/components/list-view/drop-indicator.js +99 -32
  202. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  203. package/build-module/components/list-view/index.js +54 -6
  204. package/build-module/components/list-view/index.js.map +1 -1
  205. package/build-module/components/list-view/leaf.js +2 -2
  206. package/build-module/components/list-view/leaf.js.map +1 -1
  207. package/build-module/components/list-view/use-list-view-block-indexes.js +23 -0
  208. package/build-module/components/list-view/use-list-view-block-indexes.js.map +1 -0
  209. package/build-module/components/list-view/use-list-view-drop-zone.js +58 -7
  210. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  211. package/build-module/components/list-view/utils.js +91 -0
  212. package/build-module/components/list-view/utils.js.map +1 -1
  213. package/build-module/components/provider/index.js +1 -1
  214. package/build-module/components/provider/index.js.map +1 -1
  215. package/build-module/components/recursion-provider/index.js +17 -0
  216. package/build-module/components/recursion-provider/index.js.map +1 -1
  217. package/build-module/components/rich-text/index.js +30 -6
  218. package/build-module/components/rich-text/index.js.map +1 -1
  219. package/build-module/components/rich-text/native/index.native.js +9 -9
  220. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  221. package/build-module/components/use-block-drop-zone/index.js +31 -8
  222. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  223. package/build-module/components/use-on-block-drop/index.js +51 -9
  224. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  225. package/build-module/hooks/block-hooks.js +5 -14
  226. package/build-module/hooks/block-hooks.js.map +1 -1
  227. package/build-module/hooks/content-lock-ui.js +19 -43
  228. package/build-module/hooks/content-lock-ui.js.map +1 -1
  229. package/build-module/hooks/effects.js +51 -0
  230. package/build-module/hooks/effects.js.map +1 -0
  231. package/build-module/hooks/index.js +2 -0
  232. package/build-module/hooks/index.js.map +1 -1
  233. package/build-module/hooks/index.native.js +1 -0
  234. package/build-module/hooks/index.native.js.map +1 -1
  235. package/build-module/hooks/style.js +6 -2
  236. package/build-module/hooks/style.js.map +1 -1
  237. package/build-module/hooks/supports.js +2 -1
  238. package/build-module/hooks/supports.js.map +1 -1
  239. package/build-module/hooks/typography.native.js +2 -2
  240. package/build-module/hooks/typography.native.js.map +1 -1
  241. package/build-module/hooks/use-bindings-attributes.js +112 -0
  242. package/build-module/hooks/use-bindings-attributes.js.map +1 -0
  243. package/build-module/hooks/use-shadow-props.js +39 -0
  244. package/build-module/hooks/use-shadow-props.js.map +1 -0
  245. package/build-module/hooks/utils.js +9 -8
  246. package/build-module/hooks/utils.js.map +1 -1
  247. package/build-module/index.js +1 -1
  248. package/build-module/index.js.map +1 -1
  249. package/build-module/store/actions.js +10 -6
  250. package/build-module/store/actions.js.map +1 -1
  251. package/build-module/store/index.js +2 -0
  252. package/build-module/store/index.js.map +1 -1
  253. package/build-module/store/private-actions.js +35 -0
  254. package/build-module/store/private-actions.js.map +1 -1
  255. package/build-module/store/private-selectors.js +53 -8
  256. package/build-module/store/private-selectors.js.map +1 -1
  257. package/build-module/store/reducer.js +43 -3
  258. package/build-module/store/reducer.js.map +1 -1
  259. package/build-module/store/resolvers.js +20 -0
  260. package/build-module/store/resolvers.js.map +1 -0
  261. package/build-module/store/selectors.js +89 -52
  262. package/build-module/store/selectors.js.map +1 -1
  263. package/build-module/store/utils.js +3 -23
  264. package/build-module/store/utils.js.map +1 -1
  265. package/build-module/utils/index.js +0 -1
  266. package/build-module/utils/index.js.map +1 -1
  267. package/build-module/utils/math.js +12 -0
  268. package/build-module/utils/math.js.map +1 -1
  269. package/build-module/utils/transform-styles/index.js +36 -27
  270. package/build-module/utils/transform-styles/index.js.map +1 -1
  271. package/build-style/content-rtl.css +33 -16
  272. package/build-style/content.css +33 -16
  273. package/build-style/default-editor-styles-rtl.css +1 -1
  274. package/build-style/default-editor-styles.css +1 -1
  275. package/build-style/style-rtl.css +169 -114
  276. package/build-style/style.css +169 -114
  277. package/package.json +31 -31
  278. package/src/components/block-canvas/style.scss +8 -1
  279. package/src/components/block-draggable/index.js +16 -5
  280. package/src/components/block-edit/context.js +1 -0
  281. package/src/components/block-edit/index.js +4 -0
  282. package/src/components/block-editing-mode/index.js +12 -7
  283. package/src/components/block-inspector/index.js +5 -2
  284. package/src/components/block-list/block.js +5 -4
  285. package/src/components/block-list/block.native.js +13 -3
  286. package/src/components/block-list/content.scss +34 -5
  287. package/src/components/block-list/index.js +52 -16
  288. package/src/components/block-list/private-block-context.js +1 -1
  289. package/src/components/block-list/use-in-between-inserter.js +1 -2
  290. package/src/components/block-popover/inbetween.js +22 -2
  291. package/src/components/block-preview/auto.js +3 -3
  292. package/src/components/block-removal-warning-modal/index.js +3 -2
  293. package/src/components/block-settings-menu/block-settings-dropdown.js +2 -7
  294. package/src/components/block-switcher/block-transformations-menu.js +18 -1
  295. package/src/components/block-switcher/index.js +133 -111
  296. package/src/components/block-switcher/style.scss +6 -4
  297. package/src/components/block-switcher/test/index.js +113 -230
  298. package/src/components/block-toolbar/style.scss +22 -18
  299. package/src/components/block-tools/insertion-point.js +15 -2
  300. package/src/components/block-tools/style.scss +8 -7
  301. package/src/components/font-sizes/fluid-utils.js +8 -2
  302. package/src/components/font-sizes/test/fluid-utils.js +9 -0
  303. package/src/components/global-styles/border-panel.js +7 -17
  304. package/src/components/global-styles/effects-panel.js +16 -1
  305. package/src/components/iframe/get-compatibility-styles.js +120 -0
  306. package/src/components/iframe/index.js +2 -3
  307. package/src/components/index.js +4 -2
  308. package/src/components/index.native.js +4 -2
  309. package/src/components/inspector-controls/groups.js +2 -0
  310. package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
  311. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -0
  312. package/src/components/link-control/link-preview.js +31 -55
  313. package/src/components/link-control/search-input.js +1 -9
  314. package/src/components/link-control/style.scss +31 -85
  315. package/src/components/link-control/test/index.js +2 -1
  316. package/src/components/list-view/block-contents.js +5 -1
  317. package/src/components/list-view/block.js +9 -0
  318. package/src/components/list-view/branch.js +30 -10
  319. package/src/components/list-view/drop-indicator.js +139 -46
  320. package/src/components/list-view/index.js +74 -3
  321. package/src/components/list-view/leaf.js +2 -2
  322. package/src/components/list-view/style.scss +102 -13
  323. package/src/components/list-view/test/use-list-view-drop-zone.js +4 -0
  324. package/src/components/list-view/test/utils.js +218 -1
  325. package/src/components/list-view/use-list-view-block-indexes.js +29 -0
  326. package/src/components/list-view/use-list-view-drop-zone.js +78 -6
  327. package/src/components/list-view/utils.js +116 -0
  328. package/src/components/provider/index.js +3 -1
  329. package/src/components/recursion-provider/README.md +2 -2
  330. package/src/components/recursion-provider/index.js +17 -0
  331. package/src/components/rich-text/index.js +48 -10
  332. package/src/components/rich-text/native/index.native.js +10 -10
  333. package/src/components/use-block-drop-zone/index.js +60 -19
  334. package/src/components/use-block-drop-zone/test/index.js +32 -61
  335. package/src/components/use-on-block-drop/index.js +92 -11
  336. package/src/hooks/block-hooks.js +5 -17
  337. package/src/hooks/content-lock-ui.js +15 -55
  338. package/src/hooks/effects.js +57 -0
  339. package/src/hooks/index.js +2 -0
  340. package/src/hooks/index.native.js +1 -0
  341. package/src/hooks/style.js +8 -0
  342. package/src/hooks/supports.js +2 -0
  343. package/src/hooks/test/effects.js +39 -0
  344. package/src/hooks/typography.native.js +2 -2
  345. package/src/hooks/use-bindings-attributes.js +148 -0
  346. package/src/hooks/use-shadow-props.js +37 -0
  347. package/src/hooks/utils.js +10 -6
  348. package/src/index.js +2 -0
  349. package/src/store/actions.js +9 -4
  350. package/src/store/index.js +2 -0
  351. package/src/store/private-actions.js +32 -0
  352. package/src/store/private-selectors.js +78 -21
  353. package/src/store/reducer.js +49 -2
  354. package/src/store/resolvers.js +17 -0
  355. package/src/store/selectors.js +169 -161
  356. package/src/store/test/registry-selectors.js +431 -0
  357. package/src/store/test/selectors.js +14 -400
  358. package/src/store/utils.js +10 -33
  359. package/src/style.scss +0 -1
  360. package/src/utils/index.js +0 -1
  361. package/src/utils/math.js +12 -0
  362. package/src/utils/transform-styles/index.js +52 -37
  363. package/tsconfig.tsbuildinfo +1 -1
  364. package/build/components/iframe/use-compatibility-styles.js +0 -100
  365. package/build/components/iframe/use-compatibility-styles.js.map +0 -1
  366. package/build/utils/block-variation-transforms.js +0 -42
  367. package/build/utils/block-variation-transforms.js.map +0 -1
  368. package/build-module/components/iframe/use-compatibility-styles.js +0 -94
  369. package/build-module/components/iframe/use-compatibility-styles.js.map +0 -1
  370. package/build-module/utils/block-variation-transforms.js +0 -35
  371. package/build-module/utils/block-variation-transforms.js.map +0 -1
  372. package/src/components/block-switcher/test/__snapshots__/index.js.snap +0 -116
  373. package/src/components/contrast-checker/style.scss +0 -3
  374. package/src/components/iframe/use-compatibility-styles.js +0 -122
  375. package/src/utils/block-variation-transforms.js +0 -38
  376. package/src/utils/test/block-variation-transforms.js +0 -94
@@ -19,6 +19,7 @@ import {
19
19
  removeFormat,
20
20
  } from '@wordpress/rich-text';
21
21
  import { Popover } from '@wordpress/components';
22
+ import { getBlockType } from '@wordpress/blocks';
22
23
 
23
24
  /**
24
25
  * Internal dependencies
@@ -44,6 +45,7 @@ import FormatEdit from './format-edit';
44
45
  import { getAllowedFormats } from './utils';
45
46
  import { Content } from './content';
46
47
  import { withDeprecations } from './with-deprecations';
48
+ import { unlock } from '../../lock-unlock';
47
49
 
48
50
  export const keyboardShortcutContext = createContext();
49
51
  export const inputEventContext = createContext();
@@ -113,7 +115,11 @@ export function RichTextWrapper(
113
115
  props = removeNativeProps( props );
114
116
 
115
117
  const anchorRef = useRef();
116
- const { clientId, isSelected: isBlockSelected } = useBlockEditContext();
118
+ const {
119
+ clientId,
120
+ isSelected: isBlockSelected,
121
+ name: blockName,
122
+ } = useBlockEditContext();
117
123
  const selector = ( select ) => {
118
124
  // Avoid subscribing to the block editor store if the block is not
119
125
  // selected.
@@ -121,10 +127,12 @@ export function RichTextWrapper(
121
127
  return { isSelected: false };
122
128
  }
123
129
 
124
- const { getSelectionStart, getSelectionEnd } =
130
+ const { getSelectionStart, getSelectionEnd, getBlockAttributes } =
125
131
  select( blockEditorStore );
126
132
  const selectionStart = getSelectionStart();
127
133
  const selectionEnd = getSelectionEnd();
134
+ const blockBindings =
135
+ getBlockAttributes( clientId )?.metadata?.bindings;
128
136
 
129
137
  let isSelected;
130
138
 
@@ -137,18 +145,44 @@ export function RichTextWrapper(
137
145
  isSelected = selectionStart.clientId === clientId;
138
146
  }
139
147
 
148
+ // Disable Rich Text editing if block bindings specify that.
149
+ let shouldDisableEditing = false;
150
+ if ( blockBindings ) {
151
+ const blockTypeAttributes = getBlockType( blockName ).attributes;
152
+ const { getBlockBindingsSource } = unlock(
153
+ select( blockEditorStore )
154
+ );
155
+ for ( const [ attribute, args ] of Object.entries(
156
+ blockBindings
157
+ ) ) {
158
+ // If any of the attributes with source "rich-text" is part of the bindings,
159
+ // has a source with `lockAttributesEditing`, disable it.
160
+ if (
161
+ blockTypeAttributes?.[ attribute ]?.source ===
162
+ 'rich-text' &&
163
+ getBlockBindingsSource( args.source.name )
164
+ ?.lockAttributesEditing
165
+ ) {
166
+ shouldDisableEditing = true;
167
+ break;
168
+ }
169
+ }
170
+ }
171
+
140
172
  return {
141
173
  selectionStart: isSelected ? selectionStart.offset : undefined,
142
174
  selectionEnd: isSelected ? selectionEnd.offset : undefined,
143
175
  isSelected,
176
+ shouldDisableEditing,
144
177
  };
145
178
  };
146
- const { selectionStart, selectionEnd, isSelected } = useSelect( selector, [
147
- clientId,
148
- identifier,
149
- originalIsSelected,
150
- isBlockSelected,
151
- ] );
179
+ const { selectionStart, selectionEnd, isSelected, shouldDisableEditing } =
180
+ useSelect( selector, [
181
+ clientId,
182
+ identifier,
183
+ originalIsSelected,
184
+ isBlockSelected,
185
+ ] );
152
186
  const { getSelectionStart, getSelectionEnd, getBlockRootClientId } =
153
187
  useSelect( blockEditorStore );
154
188
  const { selectionChange } = useDispatch( blockEditorStore );
@@ -376,7 +410,7 @@ export function RichTextWrapper(
376
410
  useFirefoxCompat(),
377
411
  anchorRef,
378
412
  ] ) }
379
- contentEditable={ true }
413
+ contentEditable={ ! shouldDisableEditing }
380
414
  suppressContentEditableWarning={ true }
381
415
  className={ classnames(
382
416
  'block-editor-rich-text__editable',
@@ -389,7 +423,11 @@ export function RichTextWrapper(
389
423
  // select blocks when Shift Clicking into an element with
390
424
  // tabIndex because Safari will focus the element. However,
391
425
  // Safari will correctly ignore nested contentEditable elements.
392
- tabIndex={ props.tabIndex === 0 ? null : props.tabIndex }
426
+ tabIndex={
427
+ props.tabIndex === 0 && ! shouldDisableEditing
428
+ ? null
429
+ : props.tabIndex
430
+ }
393
431
  data-wp-block-attribute-key={ identifier }
394
432
  />
395
433
  </>
@@ -264,7 +264,7 @@ export class RichText extends Component {
264
264
  onCreateUndoLevel() {
265
265
  const { __unstableOnCreateUndoLevel: onCreateUndoLevel } = this.props;
266
266
  // If the content is the same, no level needs to be created.
267
- if ( this.lastHistoryValue.toString() === this.value.toString() ) {
267
+ if ( this.lastHistoryValue?.toString() === this.value?.toString() ) {
268
268
  return;
269
269
  }
270
270
 
@@ -317,7 +317,7 @@ export class RichText extends Component {
317
317
  event.nativeEvent.text
318
318
  );
319
319
  // On iOS, onChange can be triggered after selection changes, even though there are no content changes.
320
- if ( contentWithoutRootTag === this.value.toString() ) {
320
+ if ( contentWithoutRootTag === this.value?.toString() ) {
321
321
  return;
322
322
  }
323
323
  this.lastEventCount = event.nativeEvent.eventCount;
@@ -333,7 +333,7 @@ export class RichText extends Component {
333
333
  );
334
334
 
335
335
  this.debounceCreateUndoLevel();
336
- const refresh = this.value.toString() !== contentWithoutRootTag;
336
+ const refresh = this.value?.toString() !== contentWithoutRootTag;
337
337
  this.value = contentWithoutRootTag;
338
338
 
339
339
  // We don't want to refresh if our goal is just to create a record.
@@ -564,7 +564,7 @@ export class RichText extends Component {
564
564
  // Check if value is up to date with latest state of native AztecView.
565
565
  if (
566
566
  event.nativeEvent.text &&
567
- event.nativeEvent.text !== this.props.value.toString()
567
+ event.nativeEvent.text !== this.props.value?.toString()
568
568
  ) {
569
569
  this.onTextUpdate( event );
570
570
  }
@@ -589,7 +589,7 @@ export class RichText extends Component {
589
589
  // this approach is not perfectly reliable.
590
590
  const isManual =
591
591
  this.lastAztecEventType !== 'input' &&
592
- this.props.value.toString() === this.value.toString();
592
+ this.props.value?.toString() === this.value?.toString();
593
593
  if ( hasChanged && isManual ) {
594
594
  const value = this.createRecord();
595
595
  const activeFormats = getActiveFormats( value );
@@ -659,7 +659,7 @@ export class RichText extends Component {
659
659
  event.nativeEvent.text
660
660
  );
661
661
  if (
662
- contentWithoutRootTag === this.value.toString() &&
662
+ contentWithoutRootTag === this.value?.toString() &&
663
663
  realStart === this.selectionStart &&
664
664
  realEnd === this.selectionEnd
665
665
  ) {
@@ -756,7 +756,7 @@ export class RichText extends Component {
756
756
  typeof nextProps.value !== 'undefined' &&
757
757
  typeof this.props.value !== 'undefined' &&
758
758
  ( ! this.comesFromAztec || ! this.firedAfterTextChanged ) &&
759
- nextProps.value.toString() !== this.props.value.toString()
759
+ nextProps.value?.toString() !== this.props.value?.toString()
760
760
  ) {
761
761
  // Gutenberg seems to try to mirror the caret state even on events that only change the content so,
762
762
  // let's force caret update if state has selection set.
@@ -824,7 +824,7 @@ export class RichText extends Component {
824
824
  const { style, tagName } = this.props;
825
825
  const { currentFontSize } = this.state;
826
826
 
827
- if ( this.props.value.toString() !== this.value.toString() ) {
827
+ if ( this.props.value?.toString() !== this.value?.toString() ) {
828
828
  this.value = this.props.value;
829
829
  }
830
830
  const { __unstableIsSelected: prevIsSelected } = prevProps;
@@ -884,8 +884,8 @@ export class RichText extends Component {
884
884
  // On android if content is empty we need to send no content or else the placeholder will not show.
885
885
  if (
886
886
  ! this.isIOS &&
887
- ( value.toString() === '' ||
888
- value.toString() === EMPTY_PARAGRAPH_TAGS )
887
+ ( value?.toString() === '' ||
888
+ value?.toString() === EMPTY_PARAGRAPH_TAGS )
889
889
  ) {
890
890
  return '';
891
891
  }
@@ -20,6 +20,7 @@ import useOnBlockDrop from '../use-on-block-drop';
20
20
  import {
21
21
  getDistanceToNearestEdge,
22
22
  isPointContainedByRect,
23
+ isPointWithinTopAndBottomBoundariesOfRect,
23
24
  } from '../../utils/math';
24
25
  import { store as blockEditorStore } from '../../store';
25
26
 
@@ -72,6 +73,8 @@ export function getDropTargetPosition(
72
73
  let nearestIndex = 0;
73
74
  let insertPosition = 'before';
74
75
  let minDistance = Infinity;
76
+ let targetBlockIndex = null;
77
+ let nearestSide = 'right';
75
78
 
76
79
  const {
77
80
  dropZoneElement,
@@ -136,7 +139,12 @@ export function getDropTargetPosition(
136
139
  }
137
140
 
138
141
  blocksData.forEach(
139
- ( { isUnmodifiedDefaultBlock, getBoundingClientRect, blockIndex } ) => {
142
+ ( {
143
+ isUnmodifiedDefaultBlock,
144
+ getBoundingClientRect,
145
+ blockIndex,
146
+ blockOrientation,
147
+ } ) => {
140
148
  const rect = getBoundingClientRect();
141
149
 
142
150
  let [ distance, edge ] = getDistanceToNearestEdge(
@@ -144,12 +152,35 @@ export function getDropTargetPosition(
144
152
  rect,
145
153
  allowedEdges
146
154
  );
155
+ // If the the point is close to a side, prioritize that side.
156
+ const [ sideDistance, sideEdge ] = getDistanceToNearestEdge(
157
+ position,
158
+ rect,
159
+ [ 'left', 'right' ]
160
+ );
161
+
162
+ const isPointInsideRect = isPointContainedByRect( position, rect );
163
+
147
164
  // Prioritize the element if the point is inside of an unmodified default block.
148
- if (
149
- isUnmodifiedDefaultBlock &&
150
- isPointContainedByRect( position, rect )
151
- ) {
165
+ if ( isUnmodifiedDefaultBlock && isPointInsideRect ) {
152
166
  distance = 0;
167
+ } else if (
168
+ orientation === 'vertical' &&
169
+ blockOrientation !== 'horizontal' &&
170
+ ( ( isPointInsideRect && sideDistance < THRESHOLD_DISTANCE ) ||
171
+ ( ! isPointInsideRect &&
172
+ isPointWithinTopAndBottomBoundariesOfRect(
173
+ position,
174
+ rect
175
+ ) ) )
176
+ ) {
177
+ /**
178
+ * This condition should only apply when the layout is vertical (otherwise there's
179
+ * no need to create a Row) and dropzones should only activate when the block is
180
+ * either within and close to the sides of the target block or on its outer sides.
181
+ */
182
+ targetBlockIndex = blockIndex;
183
+ nearestSide = sideEdge;
153
184
  }
154
185
 
155
186
  if ( distance < minDistance ) {
@@ -175,6 +206,10 @@ export function getDropTargetPosition(
175
206
  const isAdjacentBlockUnmodifiedDefaultBlock =
176
207
  !! blocksData[ adjacentIndex ]?.isUnmodifiedDefaultBlock;
177
208
 
209
+ // If the target index is set then group with the block at that index.
210
+ if ( targetBlockIndex !== null ) {
211
+ return [ targetBlockIndex, 'group', nearestSide ];
212
+ }
178
213
  // If both blocks are not unmodified default blocks then just insert between them.
179
214
  if (
180
215
  ! isNearestBlockUnmodifiedDefaultBlock &&
@@ -284,6 +319,7 @@ export default function useBlockDropZone( {
284
319
  dropTarget.index,
285
320
  {
286
321
  operation: dropTarget.operation,
322
+ nearestSide: dropTarget.nearestSide,
287
323
  }
288
324
  );
289
325
  const throttled = useThrottle(
@@ -333,28 +369,32 @@ export default function useBlockDropZone( {
333
369
  .getElementById( `block-${ clientId }` )
334
370
  .getBoundingClientRect(),
335
371
  blockIndex: getBlockIndex( clientId ),
372
+ blockOrientation:
373
+ getBlockListSettings( clientId )?.orientation,
336
374
  };
337
375
  } );
338
376
 
339
- const [ targetIndex, operation ] = getDropTargetPosition(
340
- blocksData,
341
- { x: event.clientX, y: event.clientY },
342
- getBlockListSettings( targetRootClientId )?.orientation,
343
- {
344
- dropZoneElement,
345
- parentBlockClientId,
346
- parentBlockOrientation: parentBlockClientId
347
- ? getBlockListSettings( parentBlockClientId )
348
- ?.orientation
349
- : undefined,
350
- rootBlockIndex: getBlockIndex( targetRootClientId ),
351
- }
352
- );
377
+ const [ targetIndex, operation, nearestSide ] =
378
+ getDropTargetPosition(
379
+ blocksData,
380
+ { x: event.clientX, y: event.clientY },
381
+ getBlockListSettings( targetRootClientId )?.orientation,
382
+ {
383
+ dropZoneElement,
384
+ parentBlockClientId,
385
+ parentBlockOrientation: parentBlockClientId
386
+ ? getBlockListSettings( parentBlockClientId )
387
+ ?.orientation
388
+ : undefined,
389
+ rootBlockIndex: getBlockIndex( targetRootClientId ),
390
+ }
391
+ );
353
392
 
354
393
  registry.batch( () => {
355
394
  setDropTarget( {
356
395
  index: targetIndex,
357
396
  operation,
397
+ nearestSide,
358
398
  } );
359
399
 
360
400
  const insertionPointClientId = [
@@ -366,6 +406,7 @@ export default function useBlockDropZone( {
366
406
 
367
407
  showInsertionPoint( insertionPointClientId, targetIndex, {
368
408
  operation,
409
+ nearestSide,
369
410
  } );
370
411
  } );
371
412
  },
@@ -22,13 +22,6 @@ const elementData = [
22
22
  bottom: 900,
23
23
  right: 400,
24
24
  },
25
- // Fourth block wraps to the next row/column.
26
- {
27
- top: 0,
28
- left: 400,
29
- bottom: 300,
30
- right: 800,
31
- },
32
25
  ];
33
26
 
34
27
  const mapElements =
@@ -73,7 +66,7 @@ describe( 'getDropTargetPosition', () => {
73
66
  const orientation = 'vertical';
74
67
 
75
68
  it( 'returns `0` when the position is nearest to the start of the first block', () => {
76
- const position = { x: 0, y: 0 };
69
+ const position = { x: 32, y: 0 };
77
70
 
78
71
  const result = getDropTargetPosition(
79
72
  verticalBlocksData,
@@ -85,7 +78,7 @@ describe( 'getDropTargetPosition', () => {
85
78
  } );
86
79
 
87
80
  it( 'returns `1` when the position is nearest to the end of the first block', () => {
88
- const position = { x: 0, y: 190 };
81
+ const position = { x: 32, y: 190 };
89
82
 
90
83
  const result = getDropTargetPosition(
91
84
  verticalBlocksData,
@@ -97,7 +90,7 @@ describe( 'getDropTargetPosition', () => {
97
90
  } );
98
91
 
99
92
  it( 'returns `1` when the position is nearest to the start of the second block', () => {
100
- const position = { x: 0, y: 210 };
93
+ const position = { x: 32, y: 210 };
101
94
 
102
95
  const result = getDropTargetPosition(
103
96
  verticalBlocksData,
@@ -109,7 +102,7 @@ describe( 'getDropTargetPosition', () => {
109
102
  } );
110
103
 
111
104
  it( 'returns `2` when the position is nearest to the end of the second block', () => {
112
- const position = { x: 0, y: 450 };
105
+ const position = { x: 32, y: 450 };
113
106
 
114
107
  const result = getDropTargetPosition(
115
108
  verticalBlocksData,
@@ -121,7 +114,7 @@ describe( 'getDropTargetPosition', () => {
121
114
  } );
122
115
 
123
116
  it( 'returns `2` when the position is nearest to the start of the third block', () => {
124
- const position = { x: 0, y: 510 };
117
+ const position = { x: 32, y: 510 };
125
118
 
126
119
  const result = getDropTargetPosition(
127
120
  verticalBlocksData,
@@ -133,7 +126,7 @@ describe( 'getDropTargetPosition', () => {
133
126
  } );
134
127
 
135
128
  it( 'returns `3` when the position is nearest to the end of the third block', () => {
136
- const position = { x: 0, y: 880 };
129
+ const position = { x: 32, y: 880 };
137
130
 
138
131
  const result = getDropTargetPosition(
139
132
  verticalBlocksData,
@@ -145,7 +138,7 @@ describe( 'getDropTargetPosition', () => {
145
138
  } );
146
139
 
147
140
  it( 'returns `3` when the position is past the end of the third block', () => {
148
- const position = { x: 0, y: 920 };
141
+ const position = { x: 32, y: 920 };
149
142
 
150
143
  const result = getDropTargetPosition(
151
144
  verticalBlocksData,
@@ -155,9 +148,8 @@ describe( 'getDropTargetPosition', () => {
155
148
 
156
149
  expect( result ).toEqual( [ 3, 'insert' ] );
157
150
  } );
158
-
159
- it( 'returns `4` when the position is nearest to the start of the fourth block', () => {
160
- const position = { x: 401, y: 0 };
151
+ it( 'returns group with index 0 when position is close to the right of the first block', () => {
152
+ const position = { x: 372, y: 0 };
161
153
 
162
154
  const result = getDropTargetPosition(
163
155
  verticalBlocksData,
@@ -165,11 +157,10 @@ describe( 'getDropTargetPosition', () => {
165
157
  orientation
166
158
  );
167
159
 
168
- expect( result ).toEqual( [ 3, 'insert' ] );
160
+ expect( result ).toEqual( [ 0, 'group', 'right' ] );
169
161
  } );
170
-
171
- it( 'returns `5` when the position is nearest to the end of the fourth block', () => {
172
- const position = { x: 401, y: 300 };
162
+ it( 'returns group with index 1 when position is close to the left of the second block', () => {
163
+ const position = { x: 12, y: 212 };
173
164
 
174
165
  const result = getDropTargetPosition(
175
166
  verticalBlocksData,
@@ -177,7 +168,7 @@ describe( 'getDropTargetPosition', () => {
177
168
  orientation
178
169
  );
179
170
 
180
- expect( result ).toEqual( [ 4, 'insert' ] );
171
+ expect( result ).toEqual( [ 1, 'group', 'left' ] );
181
172
  } );
182
173
  } );
183
174
 
@@ -267,30 +258,6 @@ describe( 'getDropTargetPosition', () => {
267
258
 
268
259
  expect( result ).toEqual( [ 3, 'insert' ] );
269
260
  } );
270
-
271
- it( 'returns `3` when the position is nearest to the start of the last block', () => {
272
- const position = { x: 0, y: 401 };
273
-
274
- const result = getDropTargetPosition(
275
- horizontalBlocksData,
276
- position,
277
- orientation
278
- );
279
-
280
- expect( result ).toEqual( [ 3, 'insert' ] );
281
- } );
282
-
283
- it( 'returns `4` when the position is nearest to the end of the last block', () => {
284
- const position = { x: 300, y: 401 };
285
-
286
- const result = getDropTargetPosition(
287
- horizontalBlocksData,
288
- position,
289
- orientation
290
- );
291
-
292
- expect( result ).toEqual( [ 4, 'insert' ] );
293
- } );
294
261
  } );
295
262
 
296
263
  describe( 'Unmodified default blocks', () => {
@@ -316,14 +283,18 @@ describe( 'getDropTargetPosition', () => {
316
283
 
317
284
  // Dropping above the first block.
318
285
  expect(
319
- getDropTargetPosition( blocksData, { x: 0, y: 0 }, orientation )
286
+ getDropTargetPosition(
287
+ blocksData,
288
+ { x: 32, y: 0 },
289
+ orientation
290
+ )
320
291
  ).toEqual( [ 0, 'replace' ] );
321
292
 
322
293
  // Dropping on the top half of the first block.
323
294
  expect(
324
295
  getDropTargetPosition(
325
296
  blocksData,
326
- { x: 0, y: 20 },
297
+ { x: 32, y: 20 },
327
298
  orientation
328
299
  )
329
300
  ).toEqual( [ 0, 'replace' ] );
@@ -332,7 +303,7 @@ describe( 'getDropTargetPosition', () => {
332
303
  expect(
333
304
  getDropTargetPosition(
334
305
  blocksData,
335
- { x: 0, y: 200 },
306
+ { x: 32, y: 200 },
336
307
  orientation
337
308
  )
338
309
  ).toEqual( [ 0, 'replace' ] );
@@ -341,7 +312,7 @@ describe( 'getDropTargetPosition', () => {
341
312
  expect(
342
313
  getDropTargetPosition(
343
314
  blocksData,
344
- { x: 0, y: 211 },
315
+ { x: 32, y: 211 },
345
316
  orientation
346
317
  )
347
318
  ).toEqual( [ 0, 'replace' ] );
@@ -350,7 +321,7 @@ describe( 'getDropTargetPosition', () => {
350
321
  expect(
351
322
  getDropTargetPosition(
352
323
  blocksData,
353
- { x: 0, y: 219 },
324
+ { x: 32, y: 219 },
354
325
  orientation
355
326
  )
356
327
  ).toEqual( [ 0, 'replace' ] );
@@ -359,7 +330,7 @@ describe( 'getDropTargetPosition', () => {
359
330
  expect(
360
331
  getDropTargetPosition(
361
332
  blocksData,
362
- { x: 0, y: 230 },
333
+ { x: 32, y: 230 },
363
334
  orientation
364
335
  )
365
336
  ).toEqual( [ 0, 'replace' ] );
@@ -368,7 +339,7 @@ describe( 'getDropTargetPosition', () => {
368
339
  expect(
369
340
  getDropTargetPosition(
370
341
  blocksData,
371
- { x: 0, y: 410 },
342
+ { x: 32, y: 410 },
372
343
  orientation
373
344
  )
374
345
  ).toEqual( [ 2, 'insert' ] );
@@ -377,7 +348,7 @@ describe( 'getDropTargetPosition', () => {
377
348
  expect(
378
349
  getDropTargetPosition(
379
350
  blocksData,
380
- { x: 0, y: 421 },
351
+ { x: 32, y: 421 },
381
352
  orientation
382
353
  )
383
354
  ).toEqual( [ 2, 'insert' ] );
@@ -410,7 +381,7 @@ describe( 'getDropTargetPosition', () => {
410
381
  expect(
411
382
  getDropTargetPosition(
412
383
  blocksData,
413
- { x: 0, y: 20 },
384
+ { x: 32, y: 20 },
414
385
  orientation
415
386
  )
416
387
  ).toEqual( [ 0, 'insert' ] );
@@ -419,7 +390,7 @@ describe( 'getDropTargetPosition', () => {
419
390
  expect(
420
391
  getDropTargetPosition(
421
392
  blocksData,
422
- { x: 0, y: 200 },
393
+ { x: 32, y: 200 },
423
394
  orientation
424
395
  )
425
396
  ).toEqual( [ 1, 'replace' ] );
@@ -428,7 +399,7 @@ describe( 'getDropTargetPosition', () => {
428
399
  expect(
429
400
  getDropTargetPosition(
430
401
  blocksData,
431
- { x: 0, y: 211 },
402
+ { x: 32, y: 211 },
432
403
  orientation
433
404
  )
434
405
  ).toEqual( [ 1, 'replace' ] );
@@ -437,7 +408,7 @@ describe( 'getDropTargetPosition', () => {
437
408
  expect(
438
409
  getDropTargetPosition(
439
410
  blocksData,
440
- { x: 0, y: 219 },
411
+ { x: 32, y: 219 },
441
412
  orientation
442
413
  )
443
414
  ).toEqual( [ 1, 'replace' ] );
@@ -446,7 +417,7 @@ describe( 'getDropTargetPosition', () => {
446
417
  expect(
447
418
  getDropTargetPosition(
448
419
  blocksData,
449
- { x: 0, y: 230 },
420
+ { x: 32, y: 230 },
450
421
  orientation
451
422
  )
452
423
  ).toEqual( [ 1, 'replace' ] );
@@ -455,7 +426,7 @@ describe( 'getDropTargetPosition', () => {
455
426
  expect(
456
427
  getDropTargetPosition(
457
428
  blocksData,
458
- { x: 0, y: 410 },
429
+ { x: 32, y: 410 },
459
430
  orientation
460
431
  )
461
432
  ).toEqual( [ 1, 'replace' ] );
@@ -464,7 +435,7 @@ describe( 'getDropTargetPosition', () => {
464
435
  expect(
465
436
  getDropTargetPosition(
466
437
  blocksData,
467
- { x: 0, y: 421 },
438
+ { x: 32, y: 421 },
468
439
  orientation
469
440
  )
470
441
  ).toEqual( [ 1, 'replace' ] );