@wordpress/block-editor 8.4.0 → 8.5.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 (369) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +56 -19
  3. package/build/components/alignment-control/index.js +13 -6
  4. package/build/components/alignment-control/index.js.map +1 -1
  5. package/build/components/block-alignment-control/index.js +13 -6
  6. package/build/components/block-alignment-control/index.js.map +1 -1
  7. package/build/components/block-draggable/index.js +2 -3
  8. package/build/components/block-draggable/index.js.map +1 -1
  9. package/build/components/block-icon/index.js +4 -0
  10. package/build/components/block-icon/index.js.map +1 -1
  11. package/build/components/block-inspector/index.js +6 -1
  12. package/build/components/block-inspector/index.js.map +1 -1
  13. package/build/components/block-list/use-block-props/index.js +1 -6
  14. package/build/components/block-list/use-block-props/index.js.map +1 -1
  15. package/build/components/block-list/use-block-props/use-focus-first-element.js +14 -17
  16. package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  17. package/build/components/block-list/use-block-props/use-focus-handler.js +7 -1
  18. package/build/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
  19. package/build/components/block-list-appender/index.js +6 -1
  20. package/build/components/block-list-appender/index.js.map +1 -1
  21. package/build/components/block-lock/menu-item.js +9 -0
  22. package/build/components/block-lock/menu-item.js.map +1 -1
  23. package/build/components/block-lock/modal.js +4 -13
  24. package/build/components/block-lock/modal.js.map +1 -1
  25. package/build/components/block-lock/toolbar.js +11 -3
  26. package/build/components/block-lock/toolbar.js.map +1 -1
  27. package/build/components/block-mover/index.js +4 -0
  28. package/build/components/block-mover/index.js.map +1 -1
  29. package/build/components/block-settings-menu/block-settings-dropdown.js +50 -5
  30. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  31. package/build/components/block-switcher/index.js +1 -1
  32. package/build/components/block-switcher/index.js.map +1 -1
  33. package/build/components/block-title/index.js +2 -2
  34. package/build/components/block-title/index.js.map +1 -1
  35. package/build/components/block-title/use-block-display-title.js +1 -1
  36. package/build/components/block-title/use-block-display-title.js.map +1 -1
  37. package/build/components/block-toolbar/block-name-context.js +17 -0
  38. package/build/components/block-toolbar/block-name-context.js.map +1 -0
  39. package/build/components/block-toolbar/block-toolbar-last-item.js +20 -0
  40. package/build/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
  41. package/build/components/block-toolbar/index.js +20 -5
  42. package/build/components/block-toolbar/index.js.map +1 -1
  43. package/build/components/block-tools/index.js +0 -16
  44. package/build/components/block-tools/index.js.map +1 -1
  45. package/build/components/block-variation-transforms/index.js +92 -47
  46. package/build/components/block-variation-transforms/index.js.map +1 -1
  47. package/build/components/block-vertical-alignment-control/index.js +13 -6
  48. package/build/components/block-vertical-alignment-control/index.js.map +1 -1
  49. package/build/components/contrast-checker/index.js +4 -0
  50. package/build/components/contrast-checker/index.js.map +1 -1
  51. package/build/components/convert-to-group-buttons/index.js +8 -0
  52. package/build/components/convert-to-group-buttons/index.js.map +1 -1
  53. package/build/components/convert-to-group-buttons/toolbar.js +105 -0
  54. package/build/components/convert-to-group-buttons/toolbar.js.map +1 -0
  55. package/build/components/copy-handler/index.js +4 -0
  56. package/build/components/copy-handler/index.js.map +1 -1
  57. package/build/components/font-sizes/font-size-picker.js +4 -0
  58. package/build/components/font-sizes/font-size-picker.js.map +1 -1
  59. package/build/components/iframe/index.js +6 -9
  60. package/build/components/iframe/index.js.map +1 -1
  61. package/build/components/index.js +18 -0
  62. package/build/components/index.js.map +1 -1
  63. package/build/components/justify-content-control/index.js +13 -6
  64. package/build/components/justify-content-control/index.js.map +1 -1
  65. package/build/components/keyboard-shortcuts/index.js +1 -1
  66. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  67. package/build/components/line-height-control/index.js +10 -3
  68. package/build/components/line-height-control/index.js.map +1 -1
  69. package/build/components/list-view/block-select-button.js +25 -6
  70. package/build/components/list-view/block-select-button.js.map +1 -1
  71. package/build/components/list-view/block.js +5 -1
  72. package/build/components/list-view/block.js.map +1 -1
  73. package/build/components/list-view/branch.js +1 -1
  74. package/build/components/list-view/branch.js.map +1 -1
  75. package/build/components/media-replace-flow/index.js +4 -0
  76. package/build/components/media-replace-flow/index.js.map +1 -1
  77. package/build/components/multi-selection-inspector/index.js +1 -1
  78. package/build/components/multi-selection-inspector/index.js.map +1 -1
  79. package/build/components/rich-text/index.js +26 -4
  80. package/build/components/rich-text/index.js.map +1 -1
  81. package/build/components/rich-text/split-value.js +12 -2
  82. package/build/components/rich-text/split-value.js.map +1 -1
  83. package/build/components/rich-text/use-firefox-compat.js +49 -0
  84. package/build/components/rich-text/use-firefox-compat.js.map +1 -0
  85. package/build/components/rich-text/use-input-rules.js +34 -2
  86. package/build/components/rich-text/use-input-rules.js.map +1 -1
  87. package/build/components/skip-to-selected-block/index.js +4 -0
  88. package/build/components/skip-to-selected-block/index.js.map +1 -1
  89. package/build/components/writing-flow/index.js +9 -1
  90. package/build/components/writing-flow/index.js.map +1 -1
  91. package/build/components/writing-flow/use-arrow-nav.js +3 -44
  92. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  93. package/build/components/writing-flow/use-click-selection.js +68 -0
  94. package/build/components/writing-flow/use-click-selection.js.map +1 -0
  95. package/build/components/writing-flow/use-drag-selection.js +134 -0
  96. package/build/components/writing-flow/use-drag-selection.js.map +1 -0
  97. package/build/components/writing-flow/use-input.js +116 -0
  98. package/build/components/writing-flow/use-input.js.map +1 -0
  99. package/build/components/writing-flow/use-multi-selection.js +18 -38
  100. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  101. package/build/components/writing-flow/use-selection-observer.js +161 -0
  102. package/build/components/writing-flow/use-selection-observer.js.map +1 -0
  103. package/build/components/writing-flow/use-tab-nav.js +1 -8
  104. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  105. package/build/hooks/border-color.js +3 -3
  106. package/build/hooks/border-color.js.map +1 -1
  107. package/build/hooks/border.js +0 -14
  108. package/build/hooks/border.js.map +1 -1
  109. package/build/hooks/color.js +20 -17
  110. package/build/hooks/color.js.map +1 -1
  111. package/build/hooks/font-family.js +5 -1
  112. package/build/hooks/font-family.js.map +1 -1
  113. package/build/hooks/font-size.js +4 -2
  114. package/build/hooks/font-size.js.map +1 -1
  115. package/build/hooks/gap.js +23 -16
  116. package/build/hooks/gap.js.map +1 -1
  117. package/build/hooks/layout.js +7 -2
  118. package/build/hooks/layout.js.map +1 -1
  119. package/build/hooks/style.js +34 -3
  120. package/build/hooks/style.js.map +1 -1
  121. package/build/hooks/utils.js +29 -0
  122. package/build/hooks/utils.js.map +1 -1
  123. package/build/layouts/flex.js +76 -12
  124. package/build/layouts/flex.js.map +1 -1
  125. package/build/layouts/flow.js +9 -4
  126. package/build/layouts/flow.js.map +1 -1
  127. package/build/store/actions.js +297 -51
  128. package/build/store/actions.js.map +1 -1
  129. package/build/store/defaults.js +5 -2
  130. package/build/store/defaults.js.map +1 -1
  131. package/build/store/reducer.js +25 -13
  132. package/build/store/reducer.js.map +1 -1
  133. package/build/store/selectors.js +142 -18
  134. package/build/store/selectors.js.map +1 -1
  135. package/build/utils/dom.js +2 -1
  136. package/build/utils/dom.js.map +1 -1
  137. package/build-module/components/alignment-control/index.js +12 -4
  138. package/build-module/components/alignment-control/index.js.map +1 -1
  139. package/build-module/components/block-alignment-control/index.js +12 -4
  140. package/build-module/components/block-alignment-control/index.js.map +1 -1
  141. package/build-module/components/block-draggable/index.js +2 -3
  142. package/build-module/components/block-draggable/index.js.map +1 -1
  143. package/build-module/components/block-icon/index.js +4 -0
  144. package/build-module/components/block-icon/index.js.map +1 -1
  145. package/build-module/components/block-inspector/index.js +6 -1
  146. package/build-module/components/block-inspector/index.js.map +1 -1
  147. package/build-module/components/block-list/use-block-props/index.js +1 -4
  148. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  149. package/build-module/components/block-list/use-block-props/use-focus-first-element.js +15 -17
  150. package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  151. package/build-module/components/block-list/use-block-props/use-focus-handler.js +7 -1
  152. package/build-module/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
  153. package/build-module/components/block-list-appender/index.js +6 -1
  154. package/build-module/components/block-list-appender/index.js.map +1 -1
  155. package/build-module/components/block-lock/menu-item.js +9 -0
  156. package/build-module/components/block-lock/menu-item.js.map +1 -1
  157. package/build-module/components/block-lock/modal.js +5 -14
  158. package/build-module/components/block-lock/modal.js.map +1 -1
  159. package/build-module/components/block-lock/toolbar.js +11 -3
  160. package/build-module/components/block-lock/toolbar.js.map +1 -1
  161. package/build-module/components/block-mover/index.js +4 -0
  162. package/build-module/components/block-mover/index.js.map +1 -1
  163. package/build-module/components/block-settings-menu/block-settings-dropdown.js +50 -7
  164. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  165. package/build-module/components/block-switcher/index.js +2 -2
  166. package/build-module/components/block-switcher/index.js.map +1 -1
  167. package/build-module/components/block-title/index.js +2 -2
  168. package/build-module/components/block-title/index.js.map +1 -1
  169. package/build-module/components/block-title/use-block-display-title.js +1 -1
  170. package/build-module/components/block-title/use-block-display-title.js.map +1 -1
  171. package/build-module/components/block-toolbar/block-name-context.js +9 -0
  172. package/build-module/components/block-toolbar/block-name-context.js.map +1 -0
  173. package/build-module/components/block-toolbar/block-toolbar-last-item.js +11 -0
  174. package/build-module/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
  175. package/build-module/components/block-toolbar/index.js +16 -4
  176. package/build-module/components/block-toolbar/index.js.map +1 -1
  177. package/build-module/components/block-tools/index.js +0 -16
  178. package/build-module/components/block-tools/index.js.map +1 -1
  179. package/build-module/components/block-variation-transforms/index.js +95 -49
  180. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  181. package/build-module/components/block-vertical-alignment-control/index.js +12 -4
  182. package/build-module/components/block-vertical-alignment-control/index.js.map +1 -1
  183. package/build-module/components/contrast-checker/index.js +4 -0
  184. package/build-module/components/contrast-checker/index.js.map +1 -1
  185. package/build-module/components/convert-to-group-buttons/index.js +2 -1
  186. package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
  187. package/build-module/components/convert-to-group-buttons/toolbar.js +90 -0
  188. package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -0
  189. package/build-module/components/copy-handler/index.js +4 -0
  190. package/build-module/components/copy-handler/index.js.map +1 -1
  191. package/build-module/components/font-sizes/font-size-picker.js +4 -0
  192. package/build-module/components/font-sizes/font-size-picker.js.map +1 -1
  193. package/build-module/components/iframe/index.js +6 -9
  194. package/build-module/components/iframe/index.js.map +1 -1
  195. package/build-module/components/index.js +2 -0
  196. package/build-module/components/index.js.map +1 -1
  197. package/build-module/components/justify-content-control/index.js +12 -4
  198. package/build-module/components/justify-content-control/index.js.map +1 -1
  199. package/build-module/components/keyboard-shortcuts/index.js +1 -1
  200. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  201. package/build-module/components/line-height-control/index.js +9 -2
  202. package/build-module/components/line-height-control/index.js.map +1 -1
  203. package/build-module/components/list-view/block-select-button.js +22 -6
  204. package/build-module/components/list-view/block-select-button.js.map +1 -1
  205. package/build-module/components/list-view/block.js +5 -1
  206. package/build-module/components/list-view/block.js.map +1 -1
  207. package/build-module/components/list-view/branch.js +1 -1
  208. package/build-module/components/list-view/branch.js.map +1 -1
  209. package/build-module/components/media-replace-flow/index.js +4 -0
  210. package/build-module/components/media-replace-flow/index.js.map +1 -1
  211. package/build-module/components/multi-selection-inspector/index.js +2 -2
  212. package/build-module/components/multi-selection-inspector/index.js.map +1 -1
  213. package/build-module/components/rich-text/index.js +25 -4
  214. package/build-module/components/rich-text/index.js.map +1 -1
  215. package/build-module/components/rich-text/split-value.js +12 -2
  216. package/build-module/components/rich-text/split-value.js.map +1 -1
  217. package/build-module/components/rich-text/use-firefox-compat.js +39 -0
  218. package/build-module/components/rich-text/use-firefox-compat.js.map +1 -0
  219. package/build-module/components/rich-text/use-input-rules.js +35 -4
  220. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  221. package/build-module/components/skip-to-selected-block/index.js +4 -0
  222. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  223. package/build-module/components/writing-flow/index.js +5 -1
  224. package/build-module/components/writing-flow/index.js.map +1 -1
  225. package/build-module/components/writing-flow/use-arrow-nav.js +4 -45
  226. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  227. package/build-module/components/writing-flow/use-click-selection.js +57 -0
  228. package/build-module/components/writing-flow/use-click-selection.js.map +1 -0
  229. package/build-module/components/writing-flow/use-drag-selection.js +124 -0
  230. package/build-module/components/writing-flow/use-drag-selection.js.map +1 -0
  231. package/build-module/components/writing-flow/use-input.js +104 -0
  232. package/build-module/components/writing-flow/use-input.js.map +1 -0
  233. package/build-module/components/writing-flow/use-multi-selection.js +18 -37
  234. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  235. package/build-module/components/writing-flow/use-selection-observer.js +150 -0
  236. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -0
  237. package/build-module/components/writing-flow/use-tab-nav.js +1 -9
  238. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  239. package/build-module/hooks/border-color.js +5 -5
  240. package/build-module/hooks/border-color.js.map +1 -1
  241. package/build-module/hooks/border.js +0 -12
  242. package/build-module/hooks/border.js.map +1 -1
  243. package/build-module/hooks/color.js +19 -18
  244. package/build-module/hooks/color.js.map +1 -1
  245. package/build-module/hooks/font-family.js +3 -1
  246. package/build-module/hooks/font-family.js.map +1 -1
  247. package/build-module/hooks/font-size.js +4 -3
  248. package/build-module/hooks/font-size.js.map +1 -1
  249. package/build-module/hooks/gap.js +22 -15
  250. package/build-module/hooks/gap.js.map +1 -1
  251. package/build-module/hooks/layout.js +7 -2
  252. package/build-module/hooks/layout.js.map +1 -1
  253. package/build-module/hooks/style.js +33 -3
  254. package/build-module/hooks/style.js.map +1 -1
  255. package/build-module/hooks/utils.js +26 -0
  256. package/build-module/hooks/utils.js.map +1 -1
  257. package/build-module/layouts/flex.js +76 -13
  258. package/build-module/layouts/flex.js.map +1 -1
  259. package/build-module/layouts/flow.js +9 -5
  260. package/build-module/layouts/flow.js.map +1 -1
  261. package/build-module/store/actions.js +286 -49
  262. package/build-module/store/actions.js.map +1 -1
  263. package/build-module/store/defaults.js +5 -2
  264. package/build-module/store/defaults.js.map +1 -1
  265. package/build-module/store/reducer.js +25 -13
  266. package/build-module/store/reducer.js.map +1 -1
  267. package/build-module/store/selectors.js +138 -19
  268. package/build-module/store/selectors.js.map +1 -1
  269. package/build-module/utils/dom.js +2 -1
  270. package/build-module/utils/dom.js.map +1 -1
  271. package/build-style/style-rtl.css +107 -74
  272. package/build-style/style.css +107 -74
  273. package/build-types/utils/dom.d.ts.map +1 -1
  274. package/package.json +28 -28
  275. package/src/components/alignment-control/index.js +9 -4
  276. package/src/components/block-alignment-control/index.js +9 -4
  277. package/src/components/block-draggable/index.js +2 -5
  278. package/src/components/block-icon/index.js +3 -0
  279. package/src/components/block-inspector/index.js +4 -0
  280. package/src/components/block-list/style.scss +4 -5
  281. package/src/components/block-list/use-block-props/index.js +0 -5
  282. package/src/components/block-list/use-block-props/use-focus-first-element.js +19 -26
  283. package/src/components/block-list/use-block-props/use-focus-handler.js +8 -0
  284. package/src/components/block-list-appender/index.js +5 -0
  285. package/src/components/block-lock/menu-item.js +8 -1
  286. package/src/components/block-lock/modal.js +18 -13
  287. package/src/components/block-lock/style.scss +6 -3
  288. package/src/components/block-lock/toolbar.js +12 -2
  289. package/src/components/block-mover/index.js +3 -0
  290. package/src/components/block-mover/style.scss +4 -0
  291. package/src/components/block-settings-menu/block-settings-dropdown.js +62 -4
  292. package/src/components/block-switcher/index.js +2 -2
  293. package/src/components/block-switcher/style.scss +8 -1
  294. package/src/components/block-switcher/test/index.js +2 -2
  295. package/src/components/block-title/index.js +2 -2
  296. package/src/components/block-title/use-block-display-title.js +1 -1
  297. package/src/components/block-toolbar/block-name-context.js +8 -0
  298. package/src/components/block-toolbar/block-toolbar-last-item.js +12 -0
  299. package/src/components/block-toolbar/index.js +18 -2
  300. package/src/components/block-toolbar/style.scss +6 -0
  301. package/src/components/block-tools/index.js +0 -19
  302. package/src/components/block-tools/style.scss +3 -5
  303. package/src/components/block-variation-transforms/index.js +105 -36
  304. package/src/components/block-variation-transforms/style.scss +1 -1
  305. package/src/components/block-vertical-alignment-control/index.js +9 -4
  306. package/src/components/button-block-appender/style.scss +5 -1
  307. package/src/components/contrast-checker/index.js +3 -0
  308. package/src/components/convert-to-group-buttons/index.js +6 -1
  309. package/src/components/convert-to-group-buttons/toolbar.js +87 -0
  310. package/src/components/copy-handler/index.js +3 -0
  311. package/src/components/font-sizes/font-size-picker.js +3 -0
  312. package/src/components/iframe/index.js +5 -7
  313. package/src/components/index.js +2 -0
  314. package/src/components/justify-content-control/index.js +9 -4
  315. package/src/components/keyboard-shortcuts/index.js +1 -1
  316. package/src/components/line-height-control/index.js +8 -3
  317. package/src/components/list-view/block-select-button.js +21 -3
  318. package/src/components/list-view/block.js +8 -1
  319. package/src/components/list-view/branch.js +1 -1
  320. package/src/components/list-view/style.scss +56 -14
  321. package/src/components/media-placeholder/README.md +8 -0
  322. package/src/components/media-replace-flow/index.js +3 -0
  323. package/src/components/multi-selection-inspector/index.js +2 -2
  324. package/src/components/rich-text/index.js +24 -1
  325. package/src/components/rich-text/split-value.js +5 -1
  326. package/src/components/rich-text/use-firefox-compat.js +39 -0
  327. package/src/components/rich-text/use-input-rules.js +40 -3
  328. package/src/components/skip-to-selected-block/index.js +3 -0
  329. package/src/components/url-input/style.scss +3 -2
  330. package/src/components/writing-flow/index.js +8 -0
  331. package/src/components/writing-flow/readme.md +28 -0
  332. package/src/components/writing-flow/use-arrow-nav.js +4 -53
  333. package/src/components/writing-flow/use-click-selection.js +65 -0
  334. package/src/components/writing-flow/use-drag-selection.js +126 -0
  335. package/src/components/writing-flow/use-input.js +112 -0
  336. package/src/components/writing-flow/use-multi-selection.js +13 -36
  337. package/src/components/writing-flow/use-selection-observer.js +153 -0
  338. package/src/components/writing-flow/use-tab-nav.js +1 -11
  339. package/src/hooks/border-color.js +5 -5
  340. package/src/hooks/border.js +0 -13
  341. package/src/hooks/color.js +51 -24
  342. package/src/hooks/font-family.js +5 -2
  343. package/src/hooks/font-size.js +10 -7
  344. package/src/hooks/gap.js +25 -17
  345. package/src/hooks/layout.js +11 -1
  346. package/src/hooks/style.js +40 -4
  347. package/src/hooks/test/gap.js +25 -1
  348. package/src/hooks/test/style.js +94 -0
  349. package/src/hooks/test/utils.js +1 -1
  350. package/src/hooks/utils.js +26 -0
  351. package/src/layouts/flex.js +89 -5
  352. package/src/layouts/flow.js +15 -4
  353. package/src/store/actions.js +349 -32
  354. package/src/store/defaults.js +7 -2
  355. package/src/store/reducer.js +25 -10
  356. package/src/store/selectors.js +181 -24
  357. package/src/store/test/selectors.js +242 -5
  358. package/src/utils/dom.js +2 -1
  359. package/tsconfig.tsbuildinfo +1 -1
  360. package/build/components/block-list/use-block-props/use-multi-selection.js +0 -205
  361. package/build/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
  362. package/build/components/block-list/use-block-props/use-scroll-into-view.js +0 -77
  363. package/build/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
  364. package/build-module/components/block-list/use-block-props/use-multi-selection.js +0 -192
  365. package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
  366. package/build-module/components/block-list/use-block-props/use-scroll-into-view.js +0 -63
  367. package/build-module/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
  368. package/src/components/block-list/use-block-props/use-multi-selection.js +0 -227
  369. package/src/components/block-list/use-block-props/use-scroll-into-view.js +0 -73
@@ -1278,17 +1278,24 @@ function selectionHelper( state = {}, action ) {
1278
1278
  export function selection( state = {}, action ) {
1279
1279
  switch ( action.type ) {
1280
1280
  case 'SELECTION_CHANGE':
1281
+ if ( action.clientId ) {
1282
+ return {
1283
+ selectionStart: {
1284
+ clientId: action.clientId,
1285
+ attributeKey: action.attributeKey,
1286
+ offset: action.startOffset,
1287
+ },
1288
+ selectionEnd: {
1289
+ clientId: action.clientId,
1290
+ attributeKey: action.attributeKey,
1291
+ offset: action.endOffset,
1292
+ },
1293
+ };
1294
+ }
1295
+
1281
1296
  return {
1282
- selectionStart: {
1283
- clientId: action.clientId,
1284
- attributeKey: action.attributeKey,
1285
- offset: action.startOffset,
1286
- },
1287
- selectionEnd: {
1288
- clientId: action.clientId,
1289
- attributeKey: action.attributeKey,
1290
- offset: action.endOffset,
1291
- },
1297
+ selectionStart: action.start || state.selectionStart,
1298
+ selectionEnd: action.end || state.selectionEnd,
1292
1299
  };
1293
1300
  case 'RESET_SELECTION':
1294
1301
  const { selectionStart, selectionEnd } = action;
@@ -1298,6 +1305,14 @@ export function selection( state = {}, action ) {
1298
1305
  };
1299
1306
  case 'MULTI_SELECT':
1300
1307
  const { start, end } = action;
1308
+
1309
+ if (
1310
+ start === state.selectionStart?.clientId &&
1311
+ end === state.selectionEnd?.clientId
1312
+ ) {
1313
+ return state;
1314
+ }
1315
+
1301
1316
  return {
1302
1317
  selectionStart: { clientId: start },
1303
1318
  selectionEnd: { clientId: end },
@@ -3,7 +3,6 @@
3
3
  */
4
4
  import {
5
5
  castArray,
6
- flatMap,
7
6
  first,
8
7
  isArray,
9
8
  isBoolean,
@@ -28,10 +27,12 @@ import {
28
27
  hasBlockSupport,
29
28
  getPossibleBlockTransformations,
30
29
  parse,
30
+ switchToBlockType,
31
31
  } from '@wordpress/blocks';
32
32
  import { Platform } from '@wordpress/element';
33
33
  import { applyFilters } from '@wordpress/hooks';
34
34
  import { symbol } from '@wordpress/icons';
35
+ import { __ } from '@wordpress/i18n';
35
36
 
36
37
  /**
37
38
  * A block selection object.
@@ -215,26 +216,35 @@ export const __unstableGetClientIdsTree = createSelector(
215
216
  );
216
217
 
217
218
  /**
218
- * Returns an array containing the clientIds of all descendants
219
- * of the blocks given.
219
+ * Returns an array containing the clientIds of all descendants of the blocks
220
+ * given. Returned ids are ordered first by the order of the ids given, then
221
+ * by the order that they appear in the editor.
220
222
  *
221
223
  * @param {Object} state Global application state.
222
224
  * @param {Array} clientIds Array of blocks to inspect.
223
225
  *
224
226
  * @return {Array} ids of descendants.
225
227
  */
226
- export const getClientIdsOfDescendants = ( state, clientIds ) =>
227
- flatMap( clientIds, ( clientId ) => {
228
- const descendants = getBlockOrder( state, clientId );
229
- return [
230
- ...descendants,
231
- ...getClientIdsOfDescendants( state, descendants ),
232
- ];
233
- } );
228
+ export const getClientIdsOfDescendants = createSelector(
229
+ ( state, clientIds ) => {
230
+ const collectedIds = [];
231
+ for ( const givenId of clientIds ) {
232
+ for ( const descendantId of getBlockOrder( state, givenId ) ) {
233
+ collectedIds.push(
234
+ descendantId,
235
+ ...getClientIdsOfDescendants( state, [ descendantId ] )
236
+ );
237
+ }
238
+ }
239
+ return collectedIds;
240
+ },
241
+ ( state ) => [ state.blocks.order ]
242
+ );
234
243
 
235
244
  /**
236
- * Returns an array containing the clientIds of the top-level blocks
237
- * and their descendants of any depth (for nested blocks).
245
+ * Returns an array containing the clientIds of the top-level blocks and
246
+ * their descendants of any depth (for nested blocks). Ids are returned
247
+ * in the same order that they appear in the editor.
238
248
  *
239
249
  * @param {Object} state Global application state.
240
250
  *
@@ -242,11 +252,14 @@ export const getClientIdsOfDescendants = ( state, clientIds ) =>
242
252
  */
243
253
  export const getClientIdsWithDescendants = createSelector(
244
254
  ( state ) => {
245
- const topLevelIds = getBlockOrder( state );
246
- return [
247
- ...topLevelIds,
248
- ...getClientIdsOfDescendants( state, topLevelIds ),
249
- ];
255
+ const collectedIds = [];
256
+ for ( const topLevelId of getBlockOrder( state ) ) {
257
+ collectedIds.push(
258
+ topLevelId,
259
+ ...getClientIdsOfDescendants( state, [ topLevelId ] )
260
+ );
261
+ }
262
+ return collectedIds;
250
263
  },
251
264
  ( state ) => [ state.blocks.order ]
252
265
  );
@@ -895,6 +908,102 @@ export function getMultiSelectedBlocksEndClientId( state ) {
895
908
  return selectionEnd.clientId || null;
896
909
  }
897
910
 
911
+ /**
912
+ * Returns true if the selection is not partial.
913
+ *
914
+ * @param {Object} state Editor state.
915
+ *
916
+ * @return {boolean} Whether the selection is mergeable.
917
+ */
918
+ export function __unstableIsFullySelected( state ) {
919
+ const selectionAnchor = getSelectionStart( state );
920
+ const selectionFocus = getSelectionEnd( state );
921
+ return (
922
+ ! selectionAnchor.attributeKey &&
923
+ ! selectionFocus.attributeKey &&
924
+ typeof selectionAnchor.offset === 'undefined' &&
925
+ typeof selectionFocus.offset === 'undefined'
926
+ );
927
+ }
928
+
929
+ /**
930
+ * Check whether the selection is mergeable.
931
+ *
932
+ * @param {Object} state Editor state.
933
+ * @param {boolean} isForward Whether to merge forwards.
934
+ *
935
+ * @return {boolean} Whether the selection is mergeable.
936
+ */
937
+ export function __unstableIsSelectionMergeable( state, isForward ) {
938
+ const selectionAnchor = getSelectionStart( state );
939
+ const selectionFocus = getSelectionEnd( state );
940
+
941
+ // It's not mergeable if the start and end are within the same block.
942
+ if ( selectionAnchor.clientId === selectionFocus.clientId ) return false;
943
+
944
+ // It's not mergeable if there's no rich text selection.
945
+ if (
946
+ ! selectionAnchor.attributeKey ||
947
+ ! selectionFocus.attributeKey ||
948
+ typeof selectionAnchor.offset === 'undefined' ||
949
+ typeof selectionFocus.offset === 'undefined'
950
+ )
951
+ return false;
952
+
953
+ const anchorRootClientId = getBlockRootClientId(
954
+ state,
955
+ selectionAnchor.clientId
956
+ );
957
+ const focusRootClientId = getBlockRootClientId(
958
+ state,
959
+ selectionFocus.clientId
960
+ );
961
+
962
+ // It's not mergeable if the selection doesn't start and end in the same
963
+ // block list. Maybe in the future it should be allowed.
964
+ if ( anchorRootClientId !== focusRootClientId ) {
965
+ return false;
966
+ }
967
+
968
+ const blockOrder = getBlockOrder( state, anchorRootClientId );
969
+ const anchorIndex = blockOrder.indexOf( selectionAnchor.clientId );
970
+ const focusIndex = blockOrder.indexOf( selectionFocus.clientId );
971
+
972
+ // Reassign selection start and end based on order.
973
+ let selectionStart, selectionEnd;
974
+
975
+ if ( anchorIndex > focusIndex ) {
976
+ selectionStart = selectionFocus;
977
+ selectionEnd = selectionAnchor;
978
+ } else {
979
+ selectionStart = selectionAnchor;
980
+ selectionEnd = selectionFocus;
981
+ }
982
+
983
+ const targetBlockClientId = isForward
984
+ ? selectionEnd.clientId
985
+ : selectionStart.clientId;
986
+ const blockToMergeClientId = isForward
987
+ ? selectionStart.clientId
988
+ : selectionEnd.clientId;
989
+
990
+ const targetBlock = getBlock( state, targetBlockClientId );
991
+ const targetBlockType = getBlockType( targetBlock.name );
992
+
993
+ if ( ! targetBlockType.merge ) return false;
994
+
995
+ const blockToMerge = getBlock( state, blockToMergeClientId );
996
+
997
+ // It's mergeable if the blocks are of the same type.
998
+ if ( blockToMerge.name === targetBlock.name ) return true;
999
+
1000
+ // If the blocks are of a different type, try to transform the block being
1001
+ // merged into the same type of block.
1002
+ const blocksToMerge = switchToBlockType( blockToMerge, targetBlock.name );
1003
+
1004
+ return blocksToMerge && blocksToMerge.length;
1005
+ }
1006
+
898
1007
  /**
899
1008
  * Returns an array containing all block client IDs in the editor in the order
900
1009
  * they appear. Optionally accepts a root client ID of the block list for which
@@ -1284,10 +1393,28 @@ const canInsertBlockTypeUnmemoized = (
1284
1393
  parentName
1285
1394
  );
1286
1395
 
1396
+ let hasBlockAllowedAncestor = true;
1397
+ const blockAllowedAncestorBlocks = blockType.ancestor;
1398
+ if ( blockAllowedAncestorBlocks ) {
1399
+ const ancestors = [
1400
+ rootClientId,
1401
+ ...getBlockParents( state, rootClientId ),
1402
+ ];
1403
+
1404
+ hasBlockAllowedAncestor = some( ancestors, ( ancestorClientId ) =>
1405
+ checkAllowList(
1406
+ blockAllowedAncestorBlocks,
1407
+ getBlockName( state, ancestorClientId )
1408
+ )
1409
+ );
1410
+ }
1411
+
1287
1412
  const canInsert =
1288
- ( hasParentAllowedBlock === null && hasBlockAllowedParent === null ) ||
1289
- hasParentAllowedBlock === true ||
1290
- hasBlockAllowedParent === true;
1413
+ hasBlockAllowedAncestor &&
1414
+ ( ( hasParentAllowedBlock === null &&
1415
+ hasBlockAllowedParent === null ) ||
1416
+ hasParentAllowedBlock === true ||
1417
+ hasBlockAllowedParent === true );
1291
1418
 
1292
1419
  if ( ! canInsert ) {
1293
1420
  return canInsert;
@@ -1442,6 +1569,23 @@ export function canMoveBlocks( state, clientIds, rootClientId = null ) {
1442
1569
  );
1443
1570
  }
1444
1571
 
1572
+ /**
1573
+ * Determines if the given block type can be locked/unlocked by a user.
1574
+ *
1575
+ * @param {Object} state Editor state.
1576
+ * @param {(string|Object)} nameOrType Block name or type object.
1577
+ *
1578
+ * @return {boolean} Whether a given block type can be locked/unlocked.
1579
+ */
1580
+ export function canLockBlockType( state, nameOrType ) {
1581
+ if ( ! hasBlockSupport( nameOrType, 'lock', true ) ) {
1582
+ return false;
1583
+ }
1584
+
1585
+ // Use block editor settings as the default value.
1586
+ return !! state.settings?.canLockBlocks;
1587
+ }
1588
+
1445
1589
  /**
1446
1590
  * Returns information about how recently and frequently a block has been inserted.
1447
1591
  *
@@ -1767,6 +1911,7 @@ export const getInserterItems = createSelector(
1767
1911
  */
1768
1912
  export const getBlockTransformItems = createSelector(
1769
1913
  ( state, blocks, rootClientId = null ) => {
1914
+ const [ sourceBlock ] = blocks;
1770
1915
  const buildBlockTypeTransformItem = buildBlockTypeItem( state, {
1771
1916
  buildScope: 'transform',
1772
1917
  } );
@@ -1780,20 +1925,32 @@ export const getBlockTransformItems = createSelector(
1780
1925
  blockTypeTransformItems,
1781
1926
  ( { name } ) => name
1782
1927
  );
1928
+
1929
+ // Consider unwraping the highest priority.
1930
+ itemsByName[ '*' ] = {
1931
+ frecency: +Infinity,
1932
+ id: '*',
1933
+ isDisabled: false,
1934
+ name: '*',
1935
+ title: __( 'Unwrap' ),
1936
+ icon: itemsByName[ sourceBlock.name ]?.icon,
1937
+ };
1938
+
1783
1939
  const possibleTransforms = getPossibleBlockTransformations(
1784
1940
  blocks
1785
1941
  ).reduce( ( accumulator, block ) => {
1786
- if ( itemsByName[ block?.name ] ) {
1942
+ if ( block === '*' ) {
1943
+ accumulator.push( itemsByName[ '*' ] );
1944
+ } else if ( itemsByName[ block?.name ] ) {
1787
1945
  accumulator.push( itemsByName[ block.name ] );
1788
1946
  }
1789
1947
  return accumulator;
1790
1948
  }, [] );
1791
- const possibleBlockTransformations = orderBy(
1949
+ return orderBy(
1792
1950
  possibleTransforms,
1793
1951
  ( block ) => itemsByName[ block.name ].frecency,
1794
1952
  'desc'
1795
1953
  );
1796
- return possibleBlockTransformations;
1797
1954
  },
1798
1955
  ( state, rootClientId ) => [
1799
1956
  state.blockListSettings[ rootClientId ],
@@ -146,6 +146,41 @@ describe( 'selectors', () => {
146
146
  parent: [ 'core/post-content' ],
147
147
  } );
148
148
 
149
+ registerBlockType( 'core/test-block-ancestor', {
150
+ save: ( props ) => props.attributes.text,
151
+ category: 'text',
152
+ title: 'Test Block required as ancestor',
153
+ icon: 'test',
154
+ keywords: [ 'testing' ],
155
+ } );
156
+
157
+ registerBlockType( 'core/test-block-parent', {
158
+ save: ( props ) => props.attributes.text,
159
+ category: 'text',
160
+ title: 'Test Block required as parent',
161
+ icon: 'test',
162
+ keywords: [ 'testing' ],
163
+ } );
164
+
165
+ registerBlockType( 'core/test-block-requires-ancestor', {
166
+ save: ( props ) => props.attributes.text,
167
+ category: 'text',
168
+ title: 'Test Block that requires ancestor',
169
+ icon: 'test',
170
+ keywords: [ 'testing' ],
171
+ ancestor: [ 'core/test-block-ancestor' ],
172
+ } );
173
+
174
+ registerBlockType( 'core/test-block-requires-ancestor-parent', {
175
+ save: ( props ) => props.attributes.text,
176
+ category: 'text',
177
+ title: 'Test Block that requires both ancestor and parent',
178
+ icon: 'test',
179
+ keywords: [ 'testing' ],
180
+ parent: [ 'core/test-block-parent' ],
181
+ ancestor: [ 'core/test-block-ancestor' ],
182
+ } );
183
+
149
184
  setFreeformContentHandlerName( 'core/test-freeform' );
150
185
 
151
186
  cachedSelectors.forEach( ( { clear } ) => clear() );
@@ -158,6 +193,10 @@ describe( 'selectors', () => {
158
193
  unregisterBlockType( 'core/test-block-c' );
159
194
  unregisterBlockType( 'core/test-freeform' );
160
195
  unregisterBlockType( 'core/post-content-child' );
196
+ unregisterBlockType( 'core/test-block-ancestor' );
197
+ unregisterBlockType( 'core/test-block-parent' );
198
+ unregisterBlockType( 'core/test-block-requires-ancestor' );
199
+ unregisterBlockType( 'core/test-block-requires-ancestor-parent' );
161
200
 
162
201
  setFreeformContentHandlerName( undefined );
163
202
  } );
@@ -448,7 +487,7 @@ describe( 'selectors', () => {
448
487
  } );
449
488
 
450
489
  describe( 'getClientIdsOfDescendants', () => {
451
- it( 'should return the ids of any descendants, given an array of clientIds', () => {
490
+ it( 'should return the ids of any descendants in sequential order, given an array of clientIds', () => {
452
491
  const state = {
453
492
  blocks: {
454
493
  byClientId: {
@@ -541,8 +580,8 @@ describe( 'selectors', () => {
541
580
  getClientIdsOfDescendants( state, [ 'uuid-10' ] )
542
581
  ).toEqual( [
543
582
  'uuid-12',
544
- 'uuid-14',
545
583
  'uuid-16',
584
+ 'uuid-14',
546
585
  'uuid-18',
547
586
  'uuid-24',
548
587
  'uuid-26',
@@ -553,7 +592,7 @@ describe( 'selectors', () => {
553
592
  } );
554
593
 
555
594
  describe( 'getClientIdsWithDescendants', () => {
556
- it( 'should return the ids for top-level blocks and their descendants of any depth (for nested blocks).', () => {
595
+ it( 'should return the ids for top-level blocks and their descendants of any depth (for nested blocks) in sequential order.', () => {
557
596
  const state = {
558
597
  blocks: {
559
598
  byClientId: {
@@ -645,15 +684,15 @@ describe( 'selectors', () => {
645
684
  'uuid-6',
646
685
  'uuid-8',
647
686
  'uuid-10',
648
- 'uuid-22',
649
687
  'uuid-12',
650
- 'uuid-14',
651
688
  'uuid-16',
689
+ 'uuid-14',
652
690
  'uuid-18',
653
691
  'uuid-24',
654
692
  'uuid-26',
655
693
  'uuid-28',
656
694
  'uuid-30',
695
+ 'uuid-22',
657
696
  ] );
658
697
  } );
659
698
  } );
@@ -2475,6 +2514,198 @@ describe( 'selectors', () => {
2475
2514
  canInsertBlockType( state, 'core/post-content-child' )
2476
2515
  ).toBe( true );
2477
2516
  } );
2517
+
2518
+ it( 'should allow blocks to be inserted in a descendant of a required ancestor', () => {
2519
+ const state = {
2520
+ blocks: {
2521
+ byClientId: {
2522
+ block1: { name: 'core/test-block-ancestor' },
2523
+ block2: { name: 'core/block' },
2524
+ },
2525
+ attributes: {
2526
+ block1: {},
2527
+ block2: {},
2528
+ },
2529
+ parents: {
2530
+ block2: 'block1',
2531
+ },
2532
+ },
2533
+ blockListSettings: {
2534
+ block1: {},
2535
+ block2: {},
2536
+ },
2537
+ settings: {},
2538
+ };
2539
+ expect(
2540
+ canInsertBlockType(
2541
+ state,
2542
+ 'core/test-block-requires-ancestor',
2543
+ 'block2'
2544
+ )
2545
+ ).toBe( true );
2546
+ } );
2547
+
2548
+ it( 'should allow blocks to be inserted if both parent and ancestor restrictions are met', () => {
2549
+ const state = {
2550
+ blocks: {
2551
+ byClientId: {
2552
+ block1: { name: 'core/test-block-ancestor' },
2553
+ block2: { name: 'core/block' },
2554
+ block3: { name: 'core/test-block-parent' },
2555
+ },
2556
+ attributes: {
2557
+ block1: {},
2558
+ block2: {},
2559
+ block3: {},
2560
+ },
2561
+ parents: {
2562
+ block2: 'block1',
2563
+ block3: 'block2',
2564
+ },
2565
+ },
2566
+ blockListSettings: {
2567
+ block1: {},
2568
+ block2: {},
2569
+ block3: {},
2570
+ },
2571
+ settings: {},
2572
+ };
2573
+ expect(
2574
+ canInsertBlockType(
2575
+ state,
2576
+ 'core/test-block-requires-ancestor-parent',
2577
+ 'block3'
2578
+ )
2579
+ ).toBe( true );
2580
+ } );
2581
+
2582
+ it( 'should deny blocks from being inserted outside a required ancestor', () => {
2583
+ const state = {
2584
+ blocks: {
2585
+ byClientId: {
2586
+ block1: { name: 'core/test-block-ancestor' },
2587
+ block2: { name: 'core/block' },
2588
+ block3: { name: 'core/block' },
2589
+ },
2590
+ attributes: {
2591
+ block1: {},
2592
+ block2: {},
2593
+ block3: {},
2594
+ },
2595
+ parents: {
2596
+ block3: 'block2',
2597
+ },
2598
+ },
2599
+ blockListSettings: {
2600
+ block1: {},
2601
+ block2: {},
2602
+ block3: {},
2603
+ },
2604
+ settings: {},
2605
+ };
2606
+ expect(
2607
+ canInsertBlockType(
2608
+ state,
2609
+ 'core/test-block-requires-ancestor',
2610
+ 'block3'
2611
+ )
2612
+ ).toBe( false );
2613
+ } );
2614
+
2615
+ it( 'should deny blocks from being inserted outside of a required ancestor, even if parent matches', () => {
2616
+ const state = {
2617
+ blocks: {
2618
+ byClientId: {
2619
+ block1: { name: 'core/test-block-ancestor' },
2620
+ block2: { name: 'core/block' },
2621
+ block3: { name: 'core/test-block-parent' },
2622
+ },
2623
+ attributes: {
2624
+ block1: {},
2625
+ block2: {},
2626
+ block3: {},
2627
+ },
2628
+ parents: {
2629
+ block3: 'block2',
2630
+ },
2631
+ },
2632
+ blockListSettings: {
2633
+ block1: {},
2634
+ block2: {},
2635
+ block3: {},
2636
+ },
2637
+ settings: {},
2638
+ };
2639
+ expect(
2640
+ canInsertBlockType(
2641
+ state,
2642
+ 'core/test-block-requires-ancestor-parent',
2643
+ 'block3'
2644
+ )
2645
+ ).toBe( false );
2646
+ } );
2647
+
2648
+ it( 'should deny blocks from being inserted inside ancestor if parent restricts allowedBlocks', () => {
2649
+ const state = {
2650
+ blocks: {
2651
+ byClientId: {
2652
+ block1: { name: 'core/test-block-ancestor' },
2653
+ block2: { name: 'core/block' },
2654
+ },
2655
+ attributes: {
2656
+ block1: {},
2657
+ block2: {},
2658
+ },
2659
+ parents: {
2660
+ block2: 'block1',
2661
+ },
2662
+ },
2663
+ blockListSettings: {
2664
+ block1: {},
2665
+ block2: {
2666
+ allowedBlocks: [],
2667
+ },
2668
+ },
2669
+ settings: {},
2670
+ };
2671
+ expect(
2672
+ canInsertBlockType(
2673
+ state,
2674
+ 'core/test-block-requires-ancestor',
2675
+ 'block2'
2676
+ )
2677
+ ).toBe( false );
2678
+ } );
2679
+
2680
+ it( 'should deny blocks from being inserted inside ancestor if parent restriction is not met', () => {
2681
+ const state = {
2682
+ blocks: {
2683
+ byClientId: {
2684
+ block1: { name: 'core/test-block-ancestor' },
2685
+ block2: { name: 'core/block' },
2686
+ },
2687
+ attributes: {
2688
+ block1: {},
2689
+ block2: {},
2690
+ },
2691
+ parents: {
2692
+ block2: 'block1',
2693
+ },
2694
+ },
2695
+ blockListSettings: {
2696
+ block1: {},
2697
+ block2: {},
2698
+ },
2699
+ settings: {},
2700
+ };
2701
+ expect(
2702
+ canInsertBlockType(
2703
+ state,
2704
+ 'core/test-block-requires-ancestor-parent',
2705
+ 'block2'
2706
+ )
2707
+ ).toBe( false );
2708
+ } );
2478
2709
  } );
2479
2710
 
2480
2711
  describe( 'canInsertBlocks', () => {
@@ -2681,6 +2912,8 @@ describe( 'selectors', () => {
2681
2912
  'core/test-block-a',
2682
2913
  'core/test-block-b',
2683
2914
  'core/test-freeform',
2915
+ 'core/test-block-ancestor',
2916
+ 'core/test-block-parent',
2684
2917
  'core/block/1',
2685
2918
  'core/block/2',
2686
2919
  ] );
@@ -2695,6 +2928,8 @@ describe( 'selectors', () => {
2695
2928
  'core/test-block-a',
2696
2929
  'core/test-block-b',
2697
2930
  'core/test-freeform',
2931
+ 'core/test-block-ancestor',
2932
+ 'core/test-block-parent',
2698
2933
  'core/block/1',
2699
2934
  'core/block/2',
2700
2935
  ] );
@@ -2727,6 +2962,7 @@ describe( 'selectors', () => {
2727
2962
  },
2728
2963
  },
2729
2964
  controlledInnerBlocks: {},
2965
+ parents: {},
2730
2966
  },
2731
2967
  preferences: {
2732
2968
  insertUsage: {},
@@ -2935,6 +3171,7 @@ describe( 'selectors', () => {
2935
3171
  },
2936
3172
  },
2937
3173
  controlledInnerBlocks: {},
3174
+ parents: {},
2938
3175
  },
2939
3176
  preferences: {
2940
3177
  insertUsage: {},
package/src/utils/dom.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const BLOCK_SELECTOR = '.block-editor-block-list__block';
2
2
  const APPENDER_SELECTOR = '.block-list-appender';
3
+ const BLOCK_APPENDER_CLASS = '.block-editor-button-block-appender';
3
4
 
4
5
  /**
5
6
  * Returns true if two elements are contained within the same block.
@@ -25,7 +26,7 @@ export function isInSameBlock( a, b ) {
25
26
  */
26
27
  export function isInsideRootBlock( blockElement, element ) {
27
28
  const parentBlock = element.closest(
28
- [ BLOCK_SELECTOR, APPENDER_SELECTOR ].join( ',' )
29
+ [ BLOCK_SELECTOR, APPENDER_SELECTOR, BLOCK_APPENDER_CLASS ].join( ',' )
29
30
  );
30
31
  return parentBlock === blockElement;
31
32
  }