@wordpress/block-editor 10.4.0 → 11.0.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 (638) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +0 -1
  3. package/build/autocompleters/block.js +2 -6
  4. package/build/autocompleters/block.js.map +1 -1
  5. package/build/autocompleters/link.js +2 -0
  6. package/build/autocompleters/link.js.map +1 -1
  7. package/build/components/block-card/index.js +51 -3
  8. package/build/components/block-card/index.js.map +1 -1
  9. package/build/components/block-draggable/index.native.js +46 -39
  10. package/build/components/block-draggable/index.native.js.map +1 -1
  11. package/build/components/block-edit/edit.js +4 -3
  12. package/build/components/block-edit/edit.js.map +1 -1
  13. package/build/components/block-edit/edit.native.js +4 -7
  14. package/build/components/block-edit/edit.native.js.map +1 -1
  15. package/build/components/block-inspector/index.js +35 -33
  16. package/build/components/block-inspector/index.js.map +1 -1
  17. package/build/components/block-list/block-list-context.native.js +5 -8
  18. package/build/components/block-list/block-list-context.native.js.map +1 -1
  19. package/build/components/block-list/block.js +55 -24
  20. package/build/components/block-list/block.js.map +1 -1
  21. package/build/components/block-list/block.native.js +61 -28
  22. package/build/components/block-list/block.native.js.map +1 -1
  23. package/build/components/block-lock/menu-item.js +1 -1
  24. package/build/components/block-lock/menu-item.js.map +1 -1
  25. package/build/components/block-lock/modal.js +16 -9
  26. package/build/components/block-lock/modal.js.map +1 -1
  27. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +12 -4
  28. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  29. package/build/components/block-pattern-setup/index.js +3 -2
  30. package/build/components/block-pattern-setup/index.js.map +1 -1
  31. package/build/components/block-patterns-list/index.js +33 -11
  32. package/build/components/block-patterns-list/index.js.map +1 -1
  33. package/build/components/block-preview/auto.js +9 -3
  34. package/build/components/block-preview/auto.js.map +1 -1
  35. package/build/components/block-preview/index.js +5 -9
  36. package/build/components/block-preview/index.js.map +1 -1
  37. package/build/components/block-settings-menu/block-settings-dropdown.js +5 -2
  38. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  39. package/build/components/block-styles/utils.js +3 -3
  40. package/build/components/block-styles/utils.js.map +1 -1
  41. package/build/components/block-switcher/index.js +19 -4
  42. package/build/components/block-switcher/index.js.map +1 -1
  43. package/build/components/block-toolbar/index.js +5 -1
  44. package/build/components/block-toolbar/index.js.map +1 -1
  45. package/build/components/block-tools/insertion-point.js +8 -49
  46. package/build/components/block-tools/insertion-point.js.map +1 -1
  47. package/build/components/block-tools/selected-block-popover.js +27 -4
  48. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  49. package/build/components/block-variation-picker/index.js +1 -2
  50. package/build/components/block-variation-picker/index.js.map +1 -1
  51. package/build/components/colors/with-colors.js +4 -3
  52. package/build/components/colors/with-colors.js.map +1 -1
  53. package/build/components/font-sizes/fluid-utils.js +24 -40
  54. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  55. package/build/components/font-sizes/with-font-sizes.js +7 -5
  56. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  57. package/build/components/height-control/index.js +115 -0
  58. package/build/components/height-control/index.js.map +1 -0
  59. package/build/components/iframe/index.js +11 -8
  60. package/build/components/iframe/index.js.map +1 -1
  61. package/build/components/image-editor/use-save-image.js +2 -0
  62. package/build/components/image-editor/use-save-image.js.map +1 -1
  63. package/build/components/image-editor/zoom-dropdown.js +1 -0
  64. package/build/components/image-editor/zoom-dropdown.js.map +1 -1
  65. package/build/components/index.js +18 -0
  66. package/build/components/index.js.map +1 -1
  67. package/build/components/inner-blocks/index.js +25 -9
  68. package/build/components/inner-blocks/index.js.map +1 -1
  69. package/build/components/inner-blocks/use-inner-block-template-sync.js +25 -10
  70. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  71. package/build/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  72. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  73. package/build/components/inserter/block-patterns-tab.js +25 -46
  74. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  75. package/build/components/inserter/block-types-tab.js +3 -1
  76. package/build/components/inserter/block-types-tab.js.map +1 -1
  77. package/build/components/inserter/hooks/use-debounced-input.js +27 -0
  78. package/build/components/inserter/hooks/use-debounced-input.js.map +1 -0
  79. package/build/components/inserter/index.js +8 -3
  80. package/build/components/inserter/index.js.map +1 -1
  81. package/build/components/inserter/index.native.js +3 -4
  82. package/build/components/inserter/index.native.js.map +1 -1
  83. package/build/components/inserter/media-tab/hooks.js +103 -0
  84. package/build/components/inserter/media-tab/hooks.js.map +1 -0
  85. package/build/components/inserter/media-tab/index.js +32 -0
  86. package/build/components/inserter/media-tab/index.js.map +1 -0
  87. package/build/components/inserter/media-tab/media-list.js +100 -0
  88. package/build/components/inserter/media-tab/media-list.js.map +1 -0
  89. package/build/components/inserter/media-tab/media-panel.js +96 -0
  90. package/build/components/inserter/media-tab/media-panel.js.map +1 -0
  91. package/build/components/inserter/media-tab/media-tab.js +120 -0
  92. package/build/components/inserter/media-tab/media-tab.js.map +1 -0
  93. package/build/components/inserter/media-tab/utils.js +54 -0
  94. package/build/components/inserter/media-tab/utils.js.map +1 -0
  95. package/build/components/inserter/menu.js +35 -12
  96. package/build/components/inserter/menu.js.map +1 -1
  97. package/build/components/inserter/mobile-tab-navigation.js +70 -0
  98. package/build/components/inserter/mobile-tab-navigation.js.map +1 -0
  99. package/build/components/inserter/quick-inserter.js +1 -0
  100. package/build/components/inserter/quick-inserter.js.map +1 -1
  101. package/build/components/inserter/reusable-blocks-tab.js +4 -1
  102. package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
  103. package/build/components/inserter/search-results.js +3 -1
  104. package/build/components/inserter/search-results.js.map +1 -1
  105. package/build/components/inserter/tabs.js +16 -2
  106. package/build/components/inserter/tabs.js.map +1 -1
  107. package/build/components/inserter-list-item/index.js +4 -1
  108. package/build/components/inserter-list-item/index.js.map +1 -1
  109. package/build/components/inspector-controls/groups.js +2 -0
  110. package/build/components/inspector-controls/groups.js.map +1 -1
  111. package/build/components/inspector-controls-tabs/advanced-controls-panel.js +46 -0
  112. package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
  113. package/build/components/inspector-controls-tabs/index.js +71 -0
  114. package/build/components/inspector-controls-tabs/index.js.map +1 -0
  115. package/build/components/inspector-controls-tabs/settings-tab.js +28 -0
  116. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -0
  117. package/build/components/inspector-controls-tabs/styles-tab.js +61 -0
  118. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -0
  119. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +97 -0
  120. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
  121. package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +18 -0
  122. package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
  123. package/build/components/inspector-controls-tabs/utils.js +37 -0
  124. package/build/components/inspector-controls-tabs/utils.js.map +1 -0
  125. package/build/components/link-control/index.js +19 -34
  126. package/build/components/link-control/index.js.map +1 -1
  127. package/build/components/link-control/search-input.js +1 -2
  128. package/build/components/link-control/search-input.js.map +1 -1
  129. package/build/components/link-control/use-internal-input-value.js +26 -0
  130. package/build/components/link-control/use-internal-input-value.js.map +1 -0
  131. package/build/components/list-view/block.js +10 -5
  132. package/build/components/list-view/block.js.map +1 -1
  133. package/build/components/list-view/branch.js +22 -15
  134. package/build/components/list-view/branch.js.map +1 -1
  135. package/build/components/media-upload/index.native.js +2 -3
  136. package/build/components/media-upload/index.native.js.map +1 -1
  137. package/build/components/off-canvas-editor/appender.js +104 -0
  138. package/build/components/off-canvas-editor/appender.js.map +1 -0
  139. package/build/components/off-canvas-editor/block-contents.js +100 -0
  140. package/build/components/off-canvas-editor/block-contents.js.map +1 -0
  141. package/build/components/off-canvas-editor/block-edit-button.js +50 -0
  142. package/build/components/off-canvas-editor/block-edit-button.js.map +1 -0
  143. package/build/components/off-canvas-editor/block-select-button.js +119 -0
  144. package/build/components/off-canvas-editor/block-select-button.js.map +1 -0
  145. package/build/components/off-canvas-editor/block.js +324 -0
  146. package/build/components/off-canvas-editor/block.js.map +1 -0
  147. package/build/components/off-canvas-editor/branch.js +179 -0
  148. package/build/components/off-canvas-editor/branch.js.map +1 -0
  149. package/build/components/off-canvas-editor/context.js +19 -0
  150. package/build/components/off-canvas-editor/context.js.map +1 -0
  151. package/build/components/off-canvas-editor/drop-indicator.js +118 -0
  152. package/build/components/off-canvas-editor/drop-indicator.js.map +1 -0
  153. package/build/components/off-canvas-editor/expander.js +41 -0
  154. package/build/components/off-canvas-editor/expander.js.map +1 -0
  155. package/build/components/off-canvas-editor/index.js +213 -0
  156. package/build/components/off-canvas-editor/index.js.map +1 -0
  157. package/build/components/off-canvas-editor/leaf.js +60 -0
  158. package/build/components/off-canvas-editor/leaf.js.map +1 -0
  159. package/build/components/off-canvas-editor/link-ui.js +185 -0
  160. package/build/components/off-canvas-editor/link-ui.js.map +1 -0
  161. package/build/components/off-canvas-editor/update-attributes.js +108 -0
  162. package/build/components/off-canvas-editor/update-attributes.js.map +1 -0
  163. package/build/components/off-canvas-editor/use-block-selection.js +139 -0
  164. package/build/components/off-canvas-editor/use-block-selection.js.map +1 -0
  165. package/build/components/off-canvas-editor/use-list-view-client-ids.js +33 -0
  166. package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
  167. package/build/components/off-canvas-editor/use-list-view-drop-zone.js +235 -0
  168. package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
  169. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +60 -0
  170. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
  171. package/build/components/off-canvas-editor/utils.js +60 -0
  172. package/build/components/off-canvas-editor/utils.js.map +1 -0
  173. package/build/components/rich-text/format-toolbar/index.js +8 -4
  174. package/build/components/rich-text/format-toolbar/index.js.map +1 -1
  175. package/build/components/rich-text/index.js +3 -3
  176. package/build/components/rich-text/index.js.map +1 -1
  177. package/build/components/rich-text/index.native.js +0 -2
  178. package/build/components/rich-text/index.native.js.map +1 -1
  179. package/build/components/rich-text/use-insert-replacement-text.js +43 -0
  180. package/build/components/rich-text/use-insert-replacement-text.js.map +1 -0
  181. package/build/components/rich-text/use-undo-automatic-change.js +9 -1
  182. package/build/components/rich-text/use-undo-automatic-change.js.map +1 -1
  183. package/build/components/rich-text/utils.js +1 -19
  184. package/build/components/rich-text/utils.js.map +1 -1
  185. package/build/components/spacing-sizes-control/spacing-input-control.js +12 -3
  186. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  187. package/build/components/ungroup-button/index.native.js +4 -2
  188. package/build/components/ungroup-button/index.native.js.map +1 -1
  189. package/build/components/url-input/index.js +46 -43
  190. package/build/components/url-input/index.js.map +1 -1
  191. package/build/components/url-popover/index.js +31 -2
  192. package/build/components/url-popover/index.js.map +1 -1
  193. package/build/components/use-block-display-information/index.js +8 -4
  194. package/build/components/use-block-display-information/index.js.map +1 -1
  195. package/build/components/use-setting/index.js +10 -2
  196. package/build/components/use-setting/index.js.map +1 -1
  197. package/build/hooks/child-layout.js +209 -0
  198. package/build/hooks/child-layout.js.map +1 -0
  199. package/build/hooks/color-panel.js +17 -1
  200. package/build/hooks/color-panel.js.map +1 -1
  201. package/build/hooks/color.js +1 -1
  202. package/build/hooks/color.js.map +1 -1
  203. package/build/hooks/content-lock-ui.js +14 -7
  204. package/build/hooks/content-lock-ui.js.map +1 -1
  205. package/build/hooks/dimensions.js +65 -16
  206. package/build/hooks/dimensions.js.map +1 -1
  207. package/build/hooks/layout.js +59 -3
  208. package/build/hooks/layout.js.map +1 -1
  209. package/build/hooks/margin.js +4 -2
  210. package/build/hooks/margin.js.map +1 -1
  211. package/build/hooks/min-height.js +139 -0
  212. package/build/hooks/min-height.js.map +1 -0
  213. package/build/hooks/padding.js +4 -2
  214. package/build/hooks/padding.js.map +1 -1
  215. package/build/hooks/style.js +3 -2
  216. package/build/hooks/style.js.map +1 -1
  217. package/build/layouts/flex.js +22 -21
  218. package/build/layouts/flex.js.map +1 -1
  219. package/build/store/actions.js +26 -0
  220. package/build/store/actions.js.map +1 -1
  221. package/build/store/reducer.js +420 -265
  222. package/build/store/reducer.js.map +1 -1
  223. package/build/store/selectors.js +73 -49
  224. package/build/store/selectors.js.map +1 -1
  225. package/build/utils/sorting.js +63 -0
  226. package/build/utils/sorting.js.map +1 -0
  227. package/build-module/autocompleters/block.js +2 -6
  228. package/build-module/autocompleters/block.js.map +1 -1
  229. package/build-module/autocompleters/link.js +2 -0
  230. package/build-module/autocompleters/link.js.map +1 -1
  231. package/build-module/components/block-card/index.js +45 -3
  232. package/build-module/components/block-card/index.js.map +1 -1
  233. package/build-module/components/block-draggable/index.native.js +40 -31
  234. package/build-module/components/block-draggable/index.native.js.map +1 -1
  235. package/build-module/components/block-edit/edit.js +4 -2
  236. package/build-module/components/block-edit/edit.js.map +1 -1
  237. package/build-module/components/block-edit/edit.native.js +4 -6
  238. package/build-module/components/block-edit/edit.native.js.map +1 -1
  239. package/build-module/components/block-inspector/index.js +32 -30
  240. package/build-module/components/block-inspector/index.js.map +1 -1
  241. package/build-module/components/block-list/block-list-context.native.js +5 -8
  242. package/build-module/components/block-list/block-list-context.native.js.map +1 -1
  243. package/build-module/components/block-list/block.js +55 -25
  244. package/build-module/components/block-list/block.js.map +1 -1
  245. package/build-module/components/block-list/block.native.js +61 -28
  246. package/build-module/components/block-list/block.native.js.map +1 -1
  247. package/build-module/components/block-lock/menu-item.js +2 -2
  248. package/build-module/components/block-lock/menu-item.js.map +1 -1
  249. package/build-module/components/block-lock/modal.js +17 -10
  250. package/build-module/components/block-lock/modal.js.map +1 -1
  251. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +13 -6
  252. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  253. package/build-module/components/block-pattern-setup/index.js +3 -2
  254. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  255. package/build-module/components/block-patterns-list/index.js +35 -13
  256. package/build-module/components/block-patterns-list/index.js.map +1 -1
  257. package/build-module/components/block-preview/auto.js +9 -3
  258. package/build-module/components/block-preview/auto.js.map +1 -1
  259. package/build-module/components/block-preview/index.js +5 -8
  260. package/build-module/components/block-preview/index.js.map +1 -1
  261. package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -2
  262. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  263. package/build-module/components/block-styles/utils.js +3 -3
  264. package/build-module/components/block-styles/utils.js.map +1 -1
  265. package/build-module/components/block-switcher/index.js +19 -4
  266. package/build-module/components/block-switcher/index.js.map +1 -1
  267. package/build-module/components/block-toolbar/index.js +6 -2
  268. package/build-module/components/block-toolbar/index.js.map +1 -1
  269. package/build-module/components/block-tools/insertion-point.js +8 -49
  270. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  271. package/build-module/components/block-tools/selected-block-popover.js +27 -5
  272. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  273. package/build-module/components/block-variation-picker/index.js +1 -2
  274. package/build-module/components/block-variation-picker/index.js.map +1 -1
  275. package/build-module/components/colors/with-colors.js +5 -4
  276. package/build-module/components/colors/with-colors.js.map +1 -1
  277. package/build-module/components/font-sizes/fluid-utils.js +24 -40
  278. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  279. package/build-module/components/font-sizes/with-font-sizes.js +8 -6
  280. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  281. package/build-module/components/height-control/index.js +103 -0
  282. package/build-module/components/height-control/index.js.map +1 -0
  283. package/build-module/components/iframe/index.js +11 -8
  284. package/build-module/components/iframe/index.js.map +1 -1
  285. package/build-module/components/image-editor/use-save-image.js +2 -0
  286. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  287. package/build-module/components/image-editor/zoom-dropdown.js +1 -0
  288. package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
  289. package/build-module/components/index.js +2 -0
  290. package/build-module/components/index.js.map +1 -1
  291. package/build-module/components/inner-blocks/index.js +27 -11
  292. package/build-module/components/inner-blocks/index.js.map +1 -1
  293. package/build-module/components/inner-blocks/use-inner-block-template-sync.js +23 -10
  294. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  295. package/build-module/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  296. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  297. package/build-module/components/inserter/block-patterns-tab.js +27 -49
  298. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  299. package/build-module/components/inserter/block-types-tab.js +3 -2
  300. package/build-module/components/inserter/block-types-tab.js.map +1 -1
  301. package/build-module/components/inserter/hooks/use-debounced-input.js +18 -0
  302. package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -0
  303. package/build-module/components/inserter/index.js +8 -3
  304. package/build-module/components/inserter/index.js.map +1 -1
  305. package/build-module/components/inserter/index.native.js +3 -5
  306. package/build-module/components/inserter/index.native.js.map +1 -1
  307. package/build-module/components/inserter/media-tab/hooks.js +89 -0
  308. package/build-module/components/inserter/media-tab/hooks.js.map +1 -0
  309. package/build-module/components/inserter/media-tab/index.js +4 -0
  310. package/build-module/components/inserter/media-tab/index.js.map +1 -0
  311. package/build-module/components/inserter/media-tab/media-list.js +86 -0
  312. package/build-module/components/inserter/media-tab/media-list.js.map +1 -0
  313. package/build-module/components/inserter/media-tab/media-panel.js +77 -0
  314. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -0
  315. package/build-module/components/inserter/media-tab/media-tab.js +100 -0
  316. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -0
  317. package/build-module/components/inserter/media-tab/utils.js +45 -0
  318. package/build-module/components/inserter/media-tab/utils.js.map +1 -0
  319. package/build-module/components/inserter/menu.js +33 -12
  320. package/build-module/components/inserter/menu.js.map +1 -1
  321. package/build-module/components/inserter/mobile-tab-navigation.js +61 -0
  322. package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -0
  323. package/build-module/components/inserter/quick-inserter.js +1 -0
  324. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  325. package/build-module/components/inserter/reusable-blocks-tab.js +3 -1
  326. package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
  327. package/build-module/components/inserter/search-results.js +3 -2
  328. package/build-module/components/inserter/search-results.js.map +1 -1
  329. package/build-module/components/inserter/tabs.js +15 -2
  330. package/build-module/components/inserter/tabs.js.map +1 -1
  331. package/build-module/components/inserter-list-item/index.js +5 -2
  332. package/build-module/components/inserter-list-item/index.js.map +1 -1
  333. package/build-module/components/inspector-controls/groups.js +2 -0
  334. package/build-module/components/inspector-controls/groups.js.map +1 -1
  335. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +32 -0
  336. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
  337. package/build-module/components/inspector-controls-tabs/index.js +56 -0
  338. package/build-module/components/inspector-controls-tabs/index.js.map +1 -0
  339. package/build-module/components/inspector-controls-tabs/settings-tab.js +17 -0
  340. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -0
  341. package/build-module/components/inspector-controls-tabs/styles-tab.js +46 -0
  342. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -0
  343. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +81 -0
  344. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
  345. package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +8 -0
  346. package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
  347. package/build-module/components/inspector-controls-tabs/utils.js +26 -0
  348. package/build-module/components/inspector-controls-tabs/utils.js.map +1 -0
  349. package/build-module/components/link-control/index.js +18 -34
  350. package/build-module/components/link-control/index.js.map +1 -1
  351. package/build-module/components/link-control/search-input.js +1 -2
  352. package/build-module/components/link-control/search-input.js.map +1 -1
  353. package/build-module/components/link-control/use-internal-input-value.js +18 -0
  354. package/build-module/components/link-control/use-internal-input-value.js.map +1 -0
  355. package/build-module/components/list-view/block.js +10 -5
  356. package/build-module/components/list-view/block.js.map +1 -1
  357. package/build-module/components/list-view/branch.js +21 -14
  358. package/build-module/components/list-view/branch.js.map +1 -1
  359. package/build-module/components/media-upload/index.native.js +2 -4
  360. package/build-module/components/media-upload/index.native.js.map +1 -1
  361. package/build-module/components/off-canvas-editor/appender.js +89 -0
  362. package/build-module/components/off-canvas-editor/appender.js.map +1 -0
  363. package/build-module/components/off-canvas-editor/block-contents.js +85 -0
  364. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -0
  365. package/build-module/components/off-canvas-editor/block-edit-button.js +35 -0
  366. package/build-module/components/off-canvas-editor/block-edit-button.js.map +1 -0
  367. package/build-module/components/off-canvas-editor/block-select-button.js +101 -0
  368. package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -0
  369. package/build-module/components/off-canvas-editor/block.js +298 -0
  370. package/build-module/components/off-canvas-editor/block.js.map +1 -0
  371. package/build-module/components/off-canvas-editor/branch.js +164 -0
  372. package/build-module/components/off-canvas-editor/branch.js.map +1 -0
  373. package/build-module/components/off-canvas-editor/context.js +7 -0
  374. package/build-module/components/off-canvas-editor/context.js.map +1 -0
  375. package/build-module/components/off-canvas-editor/drop-indicator.js +111 -0
  376. package/build-module/components/off-canvas-editor/drop-indicator.js.map +1 -0
  377. package/build-module/components/off-canvas-editor/expander.js +32 -0
  378. package/build-module/components/off-canvas-editor/expander.js.map +1 -0
  379. package/build-module/components/off-canvas-editor/index.js +189 -0
  380. package/build-module/components/off-canvas-editor/index.js.map +1 -0
  381. package/build-module/components/off-canvas-editor/leaf.js +45 -0
  382. package/build-module/components/off-canvas-editor/leaf.js.map +1 -0
  383. package/build-module/components/off-canvas-editor/link-ui.js +165 -0
  384. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -0
  385. package/build-module/components/off-canvas-editor/update-attributes.js +97 -0
  386. package/build-module/components/off-canvas-editor/update-attributes.js.map +1 -0
  387. package/build-module/components/off-canvas-editor/use-block-selection.js +124 -0
  388. package/build-module/components/off-canvas-editor/use-block-selection.js.map +1 -0
  389. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +24 -0
  390. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
  391. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +220 -0
  392. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
  393. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +50 -0
  394. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
  395. package/build-module/components/off-canvas-editor/utils.js +44 -0
  396. package/build-module/components/off-canvas-editor/utils.js.map +1 -0
  397. package/build-module/components/rich-text/format-toolbar/index.js +6 -2
  398. package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
  399. package/build-module/components/rich-text/index.js +2 -3
  400. package/build-module/components/rich-text/index.js.map +1 -1
  401. package/build-module/components/rich-text/index.native.js +0 -2
  402. package/build-module/components/rich-text/index.native.js.map +1 -1
  403. package/build-module/components/rich-text/use-insert-replacement-text.js +33 -0
  404. package/build-module/components/rich-text/use-insert-replacement-text.js.map +1 -0
  405. package/build-module/components/rich-text/use-undo-automatic-change.js +9 -1
  406. package/build-module/components/rich-text/use-undo-automatic-change.js.map +1 -1
  407. package/build-module/components/rich-text/utils.js +1 -16
  408. package/build-module/components/rich-text/utils.js.map +1 -1
  409. package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -3
  410. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  411. package/build-module/components/ungroup-button/index.native.js +3 -2
  412. package/build-module/components/ungroup-button/index.native.js.map +1 -1
  413. package/build-module/components/url-input/index.js +46 -43
  414. package/build-module/components/url-input/index.js.map +1 -1
  415. package/build-module/components/url-popover/index.js +30 -3
  416. package/build-module/components/url-popover/index.js.map +1 -1
  417. package/build-module/components/use-block-display-information/index.js +9 -5
  418. package/build-module/components/use-block-display-information/index.js.map +1 -1
  419. package/build-module/components/use-setting/index.js +9 -2
  420. package/build-module/components/use-setting/index.js.map +1 -1
  421. package/build-module/hooks/child-layout.js +189 -0
  422. package/build-module/hooks/child-layout.js.map +1 -0
  423. package/build-module/hooks/color-panel.js +17 -1
  424. package/build-module/hooks/color-panel.js.map +1 -1
  425. package/build-module/hooks/color.js +1 -1
  426. package/build-module/hooks/color.js.map +1 -1
  427. package/build-module/hooks/content-lock-ui.js +16 -9
  428. package/build-module/hooks/content-lock-ui.js.map +1 -1
  429. package/build-module/hooks/dimensions.js +60 -16
  430. package/build-module/hooks/dimensions.js.map +1 -1
  431. package/build-module/hooks/layout.js +57 -2
  432. package/build-module/hooks/layout.js.map +1 -1
  433. package/build-module/hooks/margin.js +4 -2
  434. package/build-module/hooks/margin.js.map +1 -1
  435. package/build-module/hooks/min-height.js +116 -0
  436. package/build-module/hooks/min-height.js.map +1 -0
  437. package/build-module/hooks/padding.js +4 -2
  438. package/build-module/hooks/padding.js.map +1 -1
  439. package/build-module/hooks/style.js +4 -3
  440. package/build-module/hooks/style.js.map +1 -1
  441. package/build-module/layouts/flex.js +23 -22
  442. package/build-module/layouts/flex.js.map +1 -1
  443. package/build-module/store/actions.js +22 -0
  444. package/build-module/store/actions.js.map +1 -1
  445. package/build-module/store/reducer.js +415 -265
  446. package/build-module/store/reducer.js.map +1 -1
  447. package/build-module/store/selectors.js +66 -48
  448. package/build-module/store/selectors.js.map +1 -1
  449. package/build-module/utils/sorting.js +56 -0
  450. package/build-module/utils/sorting.js.map +1 -0
  451. package/build-style/content-rtl.css +701 -0
  452. package/build-style/content.css +701 -0
  453. package/build-style/default-editor-styles-rtl.css +14 -0
  454. package/build-style/default-editor-styles.css +14 -0
  455. package/build-style/style-rtl.css +305 -668
  456. package/build-style/style.css +305 -668
  457. package/package.json +32 -30
  458. package/src/autocompleters/block.js +2 -6
  459. package/src/autocompleters/link.js +2 -0
  460. package/src/components/alignment-control/README.md +1 -1
  461. package/src/components/alignment-control/test/index.js +4 -1
  462. package/src/components/block-alignment-control/test/index.js +4 -1
  463. package/src/components/block-alignment-control/test/index.native.js +4 -4
  464. package/src/components/block-card/index.js +46 -2
  465. package/src/components/block-card/style.scss +4 -0
  466. package/src/components/block-content-overlay/{style.scss → content.scss} +7 -1
  467. package/src/components/block-draggable/content.scss +20 -0
  468. package/src/components/block-draggable/index.native.js +54 -40
  469. package/src/components/block-draggable/style.scss +0 -21
  470. package/src/components/block-draggable/test/helpers.native.js +7 -9
  471. package/src/components/block-draggable/test/index.native.js +35 -45
  472. package/src/components/block-edit/edit.js +5 -2
  473. package/src/components/block-edit/edit.native.js +5 -6
  474. package/src/components/block-inspector/index.js +96 -81
  475. package/src/components/block-inspector/style.scss +9 -1
  476. package/src/components/block-list/block-list-context.native.js +5 -8
  477. package/src/components/block-list/block.js +74 -23
  478. package/src/components/block-list/block.native.js +78 -23
  479. package/src/components/block-list/{style.scss → content.scss} +11 -20
  480. package/src/components/block-list-appender/{style.scss → content.scss} +0 -0
  481. package/src/components/block-lock/menu-item.js +5 -2
  482. package/src/components/block-lock/modal.js +19 -36
  483. package/src/components/block-lock/style.scss +8 -17
  484. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +24 -6
  485. package/src/components/block-mover/style.scss +0 -1
  486. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -2
  487. package/src/components/block-pattern-setup/index.js +2 -1
  488. package/src/components/block-patterns-list/index.js +47 -24
  489. package/src/components/block-popover/style.scss +1 -1
  490. package/src/components/block-preview/README.md +15 -10
  491. package/src/components/block-preview/auto.js +7 -1
  492. package/src/components/block-preview/content.scss +4 -0
  493. package/src/components/block-preview/index.js +7 -12
  494. package/src/components/block-preview/style.scss +0 -7
  495. package/src/components/block-preview/test/index.js +18 -35
  496. package/src/components/block-selection-clearer/test/index.js +12 -12
  497. package/src/components/block-settings-menu/block-settings-dropdown.js +32 -20
  498. package/src/components/block-styles/utils.js +3 -3
  499. package/src/components/block-switcher/index.js +19 -4
  500. package/src/components/block-switcher/test/index.js +4 -0
  501. package/src/components/block-toolbar/index.js +12 -5
  502. package/src/components/block-toolbar/style.scss +10 -0
  503. package/src/components/block-tools/insertion-point.js +3 -47
  504. package/src/components/block-tools/selected-block-popover.js +80 -34
  505. package/src/components/block-tools/style.scss +27 -5
  506. package/src/components/block-variation-picker/index.js +1 -4
  507. package/src/components/block-vertical-alignment-control/test/index.js +4 -1
  508. package/src/components/colors/with-colors.js +13 -23
  509. package/src/components/default-block-appender/{style.scss → content.scss} +1 -0
  510. package/src/components/font-sizes/fluid-utils.js +37 -64
  511. package/src/components/font-sizes/test/fluid-utils.js +5 -5
  512. package/src/components/font-sizes/with-font-sizes.js +14 -11
  513. package/src/components/height-control/index.js +123 -0
  514. package/src/components/height-control/stories/index.js +21 -0
  515. package/src/components/height-control/style.scss +5 -0
  516. package/src/components/iframe/index.js +25 -18
  517. package/src/components/image-editor/use-save-image.js +2 -0
  518. package/src/components/image-editor/zoom-dropdown.js +1 -0
  519. package/src/components/index.js +2 -0
  520. package/src/components/inner-blocks/{style.scss → content.scss} +0 -0
  521. package/src/components/inner-blocks/index.js +30 -10
  522. package/src/components/inner-blocks/use-inner-block-template-sync.js +28 -10
  523. package/src/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  524. package/src/components/inserter/block-patterns-tab.js +28 -71
  525. package/src/components/inserter/block-types-tab.js +3 -2
  526. package/src/components/inserter/hooks/use-debounced-input.js +17 -0
  527. package/src/components/inserter/index.js +10 -2
  528. package/src/components/inserter/index.native.js +1 -1
  529. package/src/components/inserter/media-tab/hooks.js +88 -0
  530. package/src/components/inserter/media-tab/index.js +3 -0
  531. package/src/components/inserter/media-tab/media-list.js +93 -0
  532. package/src/components/inserter/media-tab/media-panel.js +83 -0
  533. package/src/components/inserter/media-tab/media-tab.js +135 -0
  534. package/src/components/inserter/media-tab/utils.js +37 -0
  535. package/src/components/inserter/menu.js +55 -13
  536. package/src/components/inserter/mobile-tab-navigation.js +85 -0
  537. package/src/components/inserter/quick-inserter.js +1 -0
  538. package/src/components/inserter/reusable-blocks-tab.js +4 -2
  539. package/src/components/inserter/search-results.js +3 -2
  540. package/src/components/inserter/stories/index.js +1 -1
  541. package/src/components/inserter/stories/{fixtures.js → utils/fixtures.js} +0 -0
  542. package/src/components/inserter/style.scss +184 -18
  543. package/src/components/inserter/tabs.js +12 -1
  544. package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
  545. package/src/components/inserter-list-item/index.js +11 -1
  546. package/src/components/inserter-list-item/style.scss +26 -0
  547. package/src/components/inspector-controls/groups.js +2 -0
  548. package/src/components/inspector-controls-tabs/advanced-controls-panel.js +37 -0
  549. package/src/components/inspector-controls-tabs/index.js +62 -0
  550. package/src/components/inspector-controls-tabs/settings-tab.js +18 -0
  551. package/src/components/inspector-controls-tabs/styles-tab.js +51 -0
  552. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +89 -0
  553. package/src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +9 -0
  554. package/src/components/inspector-controls-tabs/utils.js +28 -0
  555. package/src/components/line-height-control/test/index.js +5 -5
  556. package/src/components/link-control/README.md +1 -1
  557. package/src/components/link-control/index.js +24 -39
  558. package/src/components/link-control/search-input.js +1 -2
  559. package/src/components/link-control/test/index.js +400 -582
  560. package/src/components/link-control/use-internal-input-value.js +22 -0
  561. package/src/components/list-view/block.js +7 -3
  562. package/src/components/list-view/branch.js +21 -14
  563. package/src/components/list-view/style.scss +20 -9
  564. package/src/components/media-placeholder/{style.scss → content.scss} +0 -0
  565. package/src/components/media-replace-flow/test/index.js +37 -9
  566. package/src/components/media-upload/test/index.native.js +2 -0
  567. package/src/components/off-canvas-editor/README.md +5 -0
  568. package/src/components/off-canvas-editor/appender.js +93 -0
  569. package/src/components/off-canvas-editor/block-contents.js +89 -0
  570. package/src/components/off-canvas-editor/block-edit-button.js +27 -0
  571. package/src/components/off-canvas-editor/block-select-button.js +113 -0
  572. package/src/components/off-canvas-editor/block.js +401 -0
  573. package/src/components/off-canvas-editor/branch.js +208 -0
  574. package/src/components/off-canvas-editor/context.js +8 -0
  575. package/src/components/off-canvas-editor/drop-indicator.js +126 -0
  576. package/src/components/off-canvas-editor/expander.js +26 -0
  577. package/src/components/off-canvas-editor/index.js +242 -0
  578. package/src/components/off-canvas-editor/leaf.js +52 -0
  579. package/src/components/off-canvas-editor/link-ui.js +166 -0
  580. package/src/components/off-canvas-editor/style.scss +26 -0
  581. package/src/components/off-canvas-editor/test/utils.js +50 -0
  582. package/src/components/off-canvas-editor/update-attributes.js +99 -0
  583. package/src/components/off-canvas-editor/use-block-selection.js +169 -0
  584. package/src/components/off-canvas-editor/use-list-view-client-ids.js +29 -0
  585. package/src/components/off-canvas-editor/use-list-view-drop-zone.js +260 -0
  586. package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +58 -0
  587. package/src/components/off-canvas-editor/utils.js +58 -0
  588. package/src/components/plain-text/{style.scss → content.scss} +0 -0
  589. package/src/components/recursion-provider/test/index.js +27 -29
  590. package/src/components/responsive-block-control/test/index.js +69 -92
  591. package/src/components/rich-text/content.scss +42 -0
  592. package/src/components/rich-text/format-toolbar/index.js +6 -4
  593. package/src/components/rich-text/index.js +2 -2
  594. package/src/components/rich-text/index.native.js +0 -2
  595. package/src/components/rich-text/style.scss +0 -43
  596. package/src/components/rich-text/use-insert-replacement-text.js +31 -0
  597. package/src/components/rich-text/use-undo-automatic-change.js +7 -1
  598. package/src/components/rich-text/utils.js +2 -21
  599. package/src/components/spacing-sizes-control/spacing-input-control.js +9 -0
  600. package/src/components/ungroup-button/index.native.js +6 -2
  601. package/src/components/url-input/index.js +57 -73
  602. package/src/components/url-popover/README.md +12 -3
  603. package/src/components/url-popover/index.js +33 -3
  604. package/src/components/url-popover/test/__snapshots__/index.js.snap +8 -6
  605. package/src/components/url-popover/test/index.js +21 -9
  606. package/src/components/use-block-display-information/index.js +14 -5
  607. package/src/components/use-setting/index.js +20 -2
  608. package/src/components/use-setting/test/index.js +99 -0
  609. package/src/content.scss +10 -0
  610. package/src/hooks/child-layout.js +190 -0
  611. package/src/hooks/color-panel.js +13 -1
  612. package/src/hooks/color.js +2 -0
  613. package/src/hooks/content-lock-ui.js +47 -35
  614. package/src/hooks/dimensions.js +119 -21
  615. package/src/hooks/layout.js +62 -3
  616. package/src/hooks/margin.js +4 -3
  617. package/src/hooks/min-height.js +104 -0
  618. package/src/hooks/padding.js +4 -3
  619. package/src/hooks/style.js +10 -2
  620. package/src/hooks/test/style.js +4 -0
  621. package/src/hooks/test/use-typography-props.js +1 -1
  622. package/src/layouts/flex.js +43 -38
  623. package/src/store/actions.js +22 -0
  624. package/src/store/reducer.js +480 -434
  625. package/src/store/selectors.js +70 -64
  626. package/src/store/test/actions.js +18 -0
  627. package/src/store/test/performance.js +71 -0
  628. package/src/store/test/reducer.js +662 -490
  629. package/src/store/test/selectors.js +1839 -1306
  630. package/src/style.scss +4 -7
  631. package/src/utils/sorting.js +54 -0
  632. package/src/utils/test/sorting.js +49 -0
  633. package/tsconfig.tsbuildinfo +1 -1
  634. package/build/components/block-preview/live.js +0 -30
  635. package/build/components/block-preview/live.js.map +0 -1
  636. package/build-module/components/block-preview/live.js +0 -20
  637. package/build-module/components/block-preview/live.js.map +0 -1
  638. package/src/components/block-preview/live.js +0 -19
@@ -44,6 +44,7 @@ const {
44
44
  isBlockMultiSelected,
45
45
  isFirstMultiSelectedBlock,
46
46
  getBlockMode,
47
+ __experimentalIsBlockInterfaceHidden: isBlockInterfaceHidden,
47
48
  isTyping,
48
49
  isDraggingBlocks,
49
50
  getDraggedBlockClientIds,
@@ -72,6 +73,7 @@ const {
72
73
  __experimentalGetPatternTransformItems,
73
74
  wasBlockJustInserted,
74
75
  __experimentalGetGlobalBlocksByName,
76
+ getLastInsertedBlockClientId,
75
77
  } = selectors;
76
78
 
77
79
  describe( 'selectors', () => {
@@ -201,10 +203,10 @@ describe( 'selectors', () => {
201
203
  it( 'returns null if no block by clientId', () => {
202
204
  const state = {
203
205
  blocks: {
204
- byClientId: {},
206
+ byClientId: new Map(),
205
207
  attributes: {},
206
- order: {},
207
- parents: {},
208
+ order: new Map(),
209
+ parents: new Map(),
208
210
  },
209
211
  };
210
212
 
@@ -219,22 +221,31 @@ describe( 'selectors', () => {
219
221
  it( 'returns block name', () => {
220
222
  const state = {
221
223
  blocks: {
222
- byClientId: {
223
- 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1': {
224
- clientId: 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1',
225
- name: 'core/paragraph',
226
- },
227
- },
228
- attributes: {
229
- 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1': {},
230
- },
231
- order: {
232
- '': [ 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1' ],
233
- 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1': [],
234
- },
235
- parents: {
236
- 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1': '',
237
- },
224
+ byClientId: new Map(
225
+ Object.entries( {
226
+ 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1': {
227
+ clientId:
228
+ 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1',
229
+ name: 'core/paragraph',
230
+ },
231
+ } )
232
+ ),
233
+ attributes: new Map(
234
+ Object.entries( {
235
+ 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1': {},
236
+ } )
237
+ ),
238
+ order: new Map(
239
+ Object.entries( {
240
+ '': [ 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1' ],
241
+ 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1': [],
242
+ } )
243
+ ),
244
+ parents: new Map(
245
+ Object.entries( {
246
+ 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1': '',
247
+ } )
248
+ ),
238
249
  },
239
250
  };
240
251
 
@@ -251,54 +262,68 @@ describe( 'selectors', () => {
251
262
  it( 'should return the block', () => {
252
263
  const state = {
253
264
  blocks: {
254
- byClientId: {
255
- 123: { clientId: 123, name: 'core/paragraph' },
256
- },
257
- attributes: {
258
- 123: {},
259
- },
260
- order: {
261
- '': [ 123 ],
262
- 123: [],
263
- },
264
- parents: {
265
- 123: '',
266
- },
267
- tree: {
268
- 123: {
269
- clientId: 123,
270
- name: 'core/paragraph',
271
- attributes: {},
272
- innerBlocks: [],
273
- },
274
- },
265
+ byClientId: new Map(
266
+ Object.entries( {
267
+ 123: { clientId: '123', name: 'core/paragraph' },
268
+ } )
269
+ ),
270
+ attributes: new Map(
271
+ Object.entries( {
272
+ 123: {},
273
+ } )
274
+ ),
275
+ order: new Map(
276
+ Object.entries( {
277
+ '': [ '123' ],
278
+ 123: [],
279
+ } )
280
+ ),
281
+ parents: new Map(
282
+ Object.entries( {
283
+ 123: '',
284
+ } )
285
+ ),
286
+ tree: new Map(
287
+ Object.entries( {
288
+ 123: {
289
+ clientId: '123',
290
+ name: 'core/paragraph',
291
+ attributes: {},
292
+ innerBlocks: [],
293
+ },
294
+ } )
295
+ ),
275
296
  controlledInnerBlocks: {},
276
297
  },
277
298
  };
278
299
 
279
- expect( getBlock( state, 123 ) ).toBe( state.blocks.tree[ 123 ] );
300
+ expect( getBlock( state, '123' ) ).toBe(
301
+ state.blocks.tree.get( '123' )
302
+ );
280
303
  } );
281
304
 
282
305
  it( 'should return null if the block is not present in state', () => {
283
306
  const state = {
284
307
  blocks: {
285
- byClientId: {},
286
- attributes: {},
287
- order: {},
288
- parents: {},
289
- tree: {
290
- 123: {
291
- clientId: 123,
292
- name: 'core/paragraph',
293
- attributes: {},
294
- innerBlocks: [],
295
- },
296
- },
308
+ byClientId: new Map(),
309
+ attributes: new Map(),
310
+ order: new Map(),
311
+ parents: new Map(),
312
+ tree: new Map(
313
+ Object.entries( {
314
+ 123: {
315
+ clientId: '123',
316
+ name: 'core/paragraph',
317
+ attributes: {},
318
+ innerBlocks: [],
319
+ },
320
+ } )
321
+ ),
297
322
  controlledInnerBlocks: {},
298
323
  },
299
324
  };
300
325
 
301
- expect( getBlock( state, 123 ) ).toBe( null );
326
+ expect( getBlock( state, '123' ) ).toBe( null );
302
327
  } );
303
328
  } );
304
329
 
@@ -306,47 +331,57 @@ describe( 'selectors', () => {
306
331
  it( 'should return the ordered blocks', () => {
307
332
  const state = {
308
333
  blocks: {
309
- byClientId: {
310
- 23: { clientId: 23, name: 'core/heading' },
311
- 123: { clientId: 123, name: 'core/paragraph' },
312
- },
313
- attributes: {
314
- 23: {},
315
- 123: {},
316
- },
317
- order: {
318
- '': [ 123, 23 ],
319
- },
320
- parents: {
321
- 123: '',
322
- 23: '',
323
- },
324
- tree: {
325
- '': {
326
- innerBlocks: [
327
- {
328
- clientId: 123,
329
- name: 'core/paragraph',
330
- attributes: {},
331
- innerBlocks: [],
332
- },
333
- {
334
- clientId: 23,
335
- name: 'core/heading',
336
- attributes: {},
337
- innerBlocks: [],
338
- },
339
- ],
340
- },
341
- 123: {},
342
- 23: {},
343
- },
334
+ byClientId: new Map(
335
+ Object.entries( {
336
+ 23: { clientId: '23', name: 'core/heading' },
337
+ 123: { clientId: '123', name: 'core/paragraph' },
338
+ } )
339
+ ),
340
+ attributes: new Map(
341
+ Object.entries( {
342
+ 23: {},
343
+ 123: {},
344
+ } )
345
+ ),
346
+ order: new Map(
347
+ Object.entries( {
348
+ '': [ '123', '23' ],
349
+ } )
350
+ ),
351
+ parents: new Map(
352
+ Object.entries( {
353
+ 123: '',
354
+ 23: '',
355
+ } )
356
+ ),
357
+ tree: new Map(
358
+ Object.entries( {
359
+ '': {
360
+ innerBlocks: [
361
+ {
362
+ clientId: '123',
363
+ name: 'core/paragraph',
364
+ attributes: {},
365
+ innerBlocks: [],
366
+ },
367
+ {
368
+ clientId: '23',
369
+ name: 'core/heading',
370
+ attributes: {},
371
+ innerBlocks: [],
372
+ },
373
+ ],
374
+ },
375
+ 123: {},
376
+ 23: {},
377
+ } )
378
+ ),
344
379
  controlledInnerBlocks: {},
345
380
  },
346
381
  };
347
382
 
348
383
  expect( getBlocks( state ) ).toBe(
349
- state.blocks.tree[ '' ].innerBlocks
384
+ state.blocks.tree.get( '' ).innerBlocks
350
385
  );
351
386
  } );
352
387
  } );
@@ -355,30 +390,34 @@ describe( 'selectors', () => {
355
390
  it( 'should return parent blocks', () => {
356
391
  const state = {
357
392
  blocks: {
358
- parents: {
359
- 'client-id-01': '',
360
- 'client-id-02': 'client-id-01',
361
- 'client-id-03': 'client-id-02',
362
- 'client-id-04': 'client-id-03',
363
- },
364
- byClientId: {
365
- 'client-id-01': {
366
- clientId: 'client-id-01',
367
- name: 'core/columns',
368
- },
369
- 'client-id-02': {
370
- clientId: 'client-id-02',
371
- name: 'core/navigation',
372
- },
373
- 'client-id-03': {
374
- clientId: 'client-id-03',
375
- name: 'core/navigation-link',
376
- },
377
- 'client-id-04': {
378
- clientId: 'client-id-04',
379
- name: 'core/paragraph',
380
- },
381
- },
393
+ parents: new Map(
394
+ Object.entries( {
395
+ 'client-id-01': '',
396
+ 'client-id-02': 'client-id-01',
397
+ 'client-id-03': 'client-id-02',
398
+ 'client-id-04': 'client-id-03',
399
+ } )
400
+ ),
401
+ byClientId: new Map(
402
+ Object.entries( {
403
+ 'client-id-01': {
404
+ clientId: 'client-id-01',
405
+ name: 'core/columns',
406
+ },
407
+ 'client-id-02': {
408
+ clientId: 'client-id-02',
409
+ name: 'core/navigation',
410
+ },
411
+ 'client-id-03': {
412
+ clientId: 'client-id-03',
413
+ name: 'core/navigation-link',
414
+ },
415
+ 'client-id-04': {
416
+ clientId: 'client-id-04',
417
+ name: 'core/paragraph',
418
+ },
419
+ } )
420
+ ),
382
421
  cache: {
383
422
  'client-id-01': {},
384
423
  'client-id-02': {},
@@ -402,35 +441,39 @@ describe( 'selectors', () => {
402
441
  describe( 'getBlockParentsByBlockName', () => {
403
442
  const state = {
404
443
  blocks: {
405
- parents: {
406
- 'client-id-01': '',
407
- 'client-id-02': 'client-id-01',
408
- 'client-id-03': 'client-id-02',
409
- 'client-id-04': 'client-id-03',
410
- 'client-id-05': 'client-id-04',
411
- },
412
- byClientId: {
413
- 'client-id-01': {
414
- clientId: 'client-id-01',
415
- name: 'core/navigation',
416
- },
417
- 'client-id-02': {
418
- clientId: 'client-id-02',
419
- name: 'core/columns',
420
- },
421
- 'client-id-03': {
422
- clientId: 'client-id-03',
423
- name: 'core/navigation',
424
- },
425
- 'client-id-04': {
426
- clientId: 'client-id-04',
427
- name: 'core/navigation-link',
428
- },
429
- 'client-id-05': {
430
- clientId: 'client-id-05',
431
- name: 'core/navigation-link',
432
- },
433
- },
444
+ parents: new Map(
445
+ Object.entries( {
446
+ 'client-id-01': '',
447
+ 'client-id-02': 'client-id-01',
448
+ 'client-id-03': 'client-id-02',
449
+ 'client-id-04': 'client-id-03',
450
+ 'client-id-05': 'client-id-04',
451
+ } )
452
+ ),
453
+ byClientId: new Map(
454
+ Object.entries( {
455
+ 'client-id-01': {
456
+ clientId: 'client-id-01',
457
+ name: 'core/navigation',
458
+ },
459
+ 'client-id-02': {
460
+ clientId: 'client-id-02',
461
+ name: 'core/columns',
462
+ },
463
+ 'client-id-03': {
464
+ clientId: 'client-id-03',
465
+ name: 'core/navigation',
466
+ },
467
+ 'client-id-04': {
468
+ clientId: 'client-id-04',
469
+ name: 'core/navigation-link',
470
+ },
471
+ 'client-id-05': {
472
+ clientId: 'client-id-05',
473
+ name: 'core/navigation-link',
474
+ },
475
+ } )
476
+ ),
434
477
  cache: {
435
478
  'client-id-01': {},
436
479
  'client-id-02': {},
@@ -486,89 +529,124 @@ describe( 'selectors', () => {
486
529
  it( 'should return the ids of any descendants in sequential order, given an array of clientIds', () => {
487
530
  const state = {
488
531
  blocks: {
489
- byClientId: {
490
- 'uuid-2': { clientId: 'uuid-2', name: 'core/image' },
491
- 'uuid-4': {
492
- clientId: 'uuid-4',
493
- name: 'core/paragraph',
494
- },
495
- 'uuid-6': {
496
- clientId: 'uuid-6',
497
- name: 'core/paragraph',
498
- },
499
- 'uuid-8': { clientId: 'uuid-8', name: 'core/block' },
500
- 'uuid-10': {
501
- clientId: 'uuid-10',
502
- name: 'core/columns',
503
- },
504
- 'uuid-12': { clientId: 'uuid-12', name: 'core/column' },
505
- 'uuid-14': { clientId: 'uuid-14', name: 'core/column' },
506
- 'uuid-16': { clientId: 'uuid-16', name: 'core/quote' },
507
- 'uuid-18': { clientId: 'uuid-18', name: 'core/block' },
508
- 'uuid-20': {
509
- clientId: 'uuid-20',
510
- name: 'core/gallery',
511
- },
512
- 'uuid-22': { clientId: 'uuid-22', name: 'core/block' },
513
- 'uuid-24': {
514
- clientId: 'uuid-24',
515
- name: 'core/columns',
516
- },
517
- 'uuid-26': { clientId: 'uuid-26', name: 'core/column' },
518
- 'uuid-28': { clientId: 'uuid-28', name: 'core/column' },
519
- 'uuid-30': {
520
- clientId: 'uuid-30',
521
- name: 'core/paragraph',
522
- },
523
- },
524
- attributes: {
525
- 'uuid-2': {},
526
- 'uuid-4': {},
527
- 'uuid-6': {},
528
- 'uuid-8': {},
529
- 'uuid-10': {},
530
- 'uuid-12': {},
531
- 'uuid-14': {},
532
- 'uuid-16': {},
533
- 'uuid-18': {},
534
- 'uuid-20': {},
535
- 'uuid-22': {},
536
- 'uuid-24': {},
537
- 'uuid-26': {},
538
- 'uuid-28': {},
539
- 'uuid-30': {},
540
- },
541
- order: {
542
- '': [ 'uuid-6', 'uuid-8', 'uuid-10', 'uuid-22' ],
543
- 'uuid-2': [],
544
- 'uuid-4': [],
545
- 'uuid-6': [],
546
- 'uuid-8': [],
547
- 'uuid-10': [ 'uuid-12', 'uuid-14' ],
548
- 'uuid-12': [ 'uuid-16' ],
549
- 'uuid-14': [ 'uuid-18' ],
550
- 'uuid-16': [],
551
- 'uuid-18': [ 'uuid-24' ],
552
- 'uuid-20': [],
553
- 'uuid-22': [],
554
- 'uuid-24': [ 'uuid-26', 'uuid-28' ],
555
- 'uuid-26': [],
556
- 'uuid-28': [ 'uuid-30' ],
557
- },
558
- parents: {
559
- 'uuid-6': '',
560
- 'uuid-8': '',
561
- 'uuid-10': '',
562
- 'uuid-22': '',
563
- 'uuid-12': 'uuid-10',
564
- 'uuid-14': 'uuid-10',
565
- 'uuid-16': 'uuid-12',
566
- 'uuid-18': 'uuid-14',
567
- 'uuid-24': 'uuid-18',
568
- 'uuid-26': 'uuid-24',
569
- 'uuid-28': 'uuid-24',
570
- 'uuid-30': 'uuid-28',
571
- },
532
+ byClientId: new Map(
533
+ Object.entries( {
534
+ 'uuid-2': {
535
+ clientId: 'uuid-2',
536
+ name: 'core/image',
537
+ },
538
+ 'uuid-4': {
539
+ clientId: 'uuid-4',
540
+ name: 'core/paragraph',
541
+ },
542
+ 'uuid-6': {
543
+ clientId: 'uuid-6',
544
+ name: 'core/paragraph',
545
+ },
546
+ 'uuid-8': {
547
+ clientId: 'uuid-8',
548
+ name: 'core/block',
549
+ },
550
+ 'uuid-10': {
551
+ clientId: 'uuid-10',
552
+ name: 'core/columns',
553
+ },
554
+ 'uuid-12': {
555
+ clientId: 'uuid-12',
556
+ name: 'core/column',
557
+ },
558
+ 'uuid-14': {
559
+ clientId: 'uuid-14',
560
+ name: 'core/column',
561
+ },
562
+ 'uuid-16': {
563
+ clientId: 'uuid-16',
564
+ name: 'core/quote',
565
+ },
566
+ 'uuid-18': {
567
+ clientId: 'uuid-18',
568
+ name: 'core/block',
569
+ },
570
+ 'uuid-20': {
571
+ clientId: 'uuid-20',
572
+ name: 'core/gallery',
573
+ },
574
+ 'uuid-22': {
575
+ clientId: 'uuid-22',
576
+ name: 'core/block',
577
+ },
578
+ 'uuid-24': {
579
+ clientId: 'uuid-24',
580
+ name: 'core/columns',
581
+ },
582
+ 'uuid-26': {
583
+ clientId: 'uuid-26',
584
+ name: 'core/column',
585
+ },
586
+ 'uuid-28': {
587
+ clientId: 'uuid-28',
588
+ name: 'core/column',
589
+ },
590
+ 'uuid-30': {
591
+ clientId: 'uuid-30',
592
+ name: 'core/paragraph',
593
+ },
594
+ } )
595
+ ),
596
+ attributes: new Map(
597
+ Object.entries( {
598
+ 'uuid-2': {},
599
+ 'uuid-4': {},
600
+ 'uuid-6': {},
601
+ 'uuid-8': {},
602
+ 'uuid-10': {},
603
+ 'uuid-12': {},
604
+ 'uuid-14': {},
605
+ 'uuid-16': {},
606
+ 'uuid-18': {},
607
+ 'uuid-20': {},
608
+ 'uuid-22': {},
609
+ 'uuid-24': {},
610
+ 'uuid-26': {},
611
+ 'uuid-28': {},
612
+ 'uuid-30': {},
613
+ } )
614
+ ),
615
+ order: new Map(
616
+ Object.entries( {
617
+ '': [ 'uuid-6', 'uuid-8', 'uuid-10', 'uuid-22' ],
618
+ 'uuid-2': [],
619
+ 'uuid-4': [],
620
+ 'uuid-6': [],
621
+ 'uuid-8': [],
622
+ 'uuid-10': [ 'uuid-12', 'uuid-14' ],
623
+ 'uuid-12': [ 'uuid-16' ],
624
+ 'uuid-14': [ 'uuid-18' ],
625
+ 'uuid-16': [],
626
+ 'uuid-18': [ 'uuid-24' ],
627
+ 'uuid-20': [],
628
+ 'uuid-22': [],
629
+ 'uuid-24': [ 'uuid-26', 'uuid-28' ],
630
+ 'uuid-26': [],
631
+ 'uuid-28': [ 'uuid-30' ],
632
+ } )
633
+ ),
634
+ parents: new Map(
635
+ Object.entries( {
636
+ 'uuid-6': '',
637
+ 'uuid-8': '',
638
+ 'uuid-10': '',
639
+ 'uuid-22': '',
640
+ 'uuid-12': 'uuid-10',
641
+ 'uuid-14': 'uuid-10',
642
+ 'uuid-16': 'uuid-12',
643
+ 'uuid-18': 'uuid-14',
644
+ 'uuid-24': 'uuid-18',
645
+ 'uuid-26': 'uuid-24',
646
+ 'uuid-28': 'uuid-24',
647
+ 'uuid-30': 'uuid-28',
648
+ } )
649
+ ),
572
650
  controlledInnerBlocks: {},
573
651
  },
574
652
  };
@@ -591,89 +669,124 @@ describe( 'selectors', () => {
591
669
  it( 'should return the ids for top-level blocks and their descendants of any depth (for nested blocks) in sequential order.', () => {
592
670
  const state = {
593
671
  blocks: {
594
- byClientId: {
595
- 'uuid-2': { clientId: 'uuid-2', name: 'core/image' },
596
- 'uuid-4': {
597
- clientId: 'uuid-4',
598
- name: 'core/paragraph',
599
- },
600
- 'uuid-6': {
601
- clientId: 'uuid-6',
602
- name: 'core/paragraph',
603
- },
604
- 'uuid-8': { clientId: 'uuid-8', name: 'core/block' },
605
- 'uuid-10': {
606
- clientId: 'uuid-10',
607
- name: 'core/columns',
608
- },
609
- 'uuid-12': { clientId: 'uuid-12', name: 'core/column' },
610
- 'uuid-14': { clientId: 'uuid-14', name: 'core/column' },
611
- 'uuid-16': { clientId: 'uuid-16', name: 'core/quote' },
612
- 'uuid-18': { clientId: 'uuid-18', name: 'core/block' },
613
- 'uuid-20': {
614
- clientId: 'uuid-20',
615
- name: 'core/gallery',
616
- },
617
- 'uuid-22': { clientId: 'uuid-22', name: 'core/block' },
618
- 'uuid-24': {
619
- clientId: 'uuid-24',
620
- name: 'core/columns',
621
- },
622
- 'uuid-26': { clientId: 'uuid-26', name: 'core/column' },
623
- 'uuid-28': { clientId: 'uuid-28', name: 'core/column' },
624
- 'uuid-30': {
625
- clientId: 'uuid-30',
626
- name: 'core/paragraph',
627
- },
628
- },
629
- attributes: {
630
- 'uuid-2': {},
631
- 'uuid-4': {},
632
- 'uuid-6': {},
633
- 'uuid-8': {},
634
- 'uuid-10': {},
635
- 'uuid-12': {},
636
- 'uuid-14': {},
637
- 'uuid-16': {},
638
- 'uuid-18': {},
639
- 'uuid-20': {},
640
- 'uuid-22': {},
641
- 'uuid-24': {},
642
- 'uuid-26': {},
643
- 'uuid-28': {},
644
- 'uuid-30': {},
645
- },
646
- order: {
647
- '': [ 'uuid-6', 'uuid-8', 'uuid-10', 'uuid-22' ],
648
- 'uuid-2': [],
649
- 'uuid-4': [],
650
- 'uuid-6': [],
651
- 'uuid-8': [],
652
- 'uuid-10': [ 'uuid-12', 'uuid-14' ],
653
- 'uuid-12': [ 'uuid-16' ],
654
- 'uuid-14': [ 'uuid-18' ],
655
- 'uuid-16': [],
656
- 'uuid-18': [ 'uuid-24' ],
657
- 'uuid-20': [],
658
- 'uuid-22': [],
659
- 'uuid-24': [ 'uuid-26', 'uuid-28' ],
660
- 'uuid-26': [],
661
- 'uuid-28': [ 'uuid-30' ],
662
- },
663
- parents: {
664
- 'uuid-6': '',
665
- 'uuid-8': '',
666
- 'uuid-10': '',
667
- 'uuid-22': '',
668
- 'uuid-12': 'uuid-10',
669
- 'uuid-14': 'uuid-10',
670
- 'uuid-16': 'uuid-12',
671
- 'uuid-18': 'uuid-14',
672
- 'uuid-24': 'uuid-18',
673
- 'uuid-26': 'uuid-24',
674
- 'uuid-28': 'uuid-24',
675
- 'uuid-30': 'uuid-28',
676
- },
672
+ byClientId: new Map(
673
+ Object.entries( {
674
+ 'uuid-2': {
675
+ clientId: 'uuid-2',
676
+ name: 'core/image',
677
+ },
678
+ 'uuid-4': {
679
+ clientId: 'uuid-4',
680
+ name: 'core/paragraph',
681
+ },
682
+ 'uuid-6': {
683
+ clientId: 'uuid-6',
684
+ name: 'core/paragraph',
685
+ },
686
+ 'uuid-8': {
687
+ clientId: 'uuid-8',
688
+ name: 'core/block',
689
+ },
690
+ 'uuid-10': {
691
+ clientId: 'uuid-10',
692
+ name: 'core/columns',
693
+ },
694
+ 'uuid-12': {
695
+ clientId: 'uuid-12',
696
+ name: 'core/column',
697
+ },
698
+ 'uuid-14': {
699
+ clientId: 'uuid-14',
700
+ name: 'core/column',
701
+ },
702
+ 'uuid-16': {
703
+ clientId: 'uuid-16',
704
+ name: 'core/quote',
705
+ },
706
+ 'uuid-18': {
707
+ clientId: 'uuid-18',
708
+ name: 'core/block',
709
+ },
710
+ 'uuid-20': {
711
+ clientId: 'uuid-20',
712
+ name: 'core/gallery',
713
+ },
714
+ 'uuid-22': {
715
+ clientId: 'uuid-22',
716
+ name: 'core/block',
717
+ },
718
+ 'uuid-24': {
719
+ clientId: 'uuid-24',
720
+ name: 'core/columns',
721
+ },
722
+ 'uuid-26': {
723
+ clientId: 'uuid-26',
724
+ name: 'core/column',
725
+ },
726
+ 'uuid-28': {
727
+ clientId: 'uuid-28',
728
+ name: 'core/column',
729
+ },
730
+ 'uuid-30': {
731
+ clientId: 'uuid-30',
732
+ name: 'core/paragraph',
733
+ },
734
+ } )
735
+ ),
736
+ attributes: new Map(
737
+ Object.entries( {
738
+ 'uuid-2': {},
739
+ 'uuid-4': {},
740
+ 'uuid-6': {},
741
+ 'uuid-8': {},
742
+ 'uuid-10': {},
743
+ 'uuid-12': {},
744
+ 'uuid-14': {},
745
+ 'uuid-16': {},
746
+ 'uuid-18': {},
747
+ 'uuid-20': {},
748
+ 'uuid-22': {},
749
+ 'uuid-24': {},
750
+ 'uuid-26': {},
751
+ 'uuid-28': {},
752
+ 'uuid-30': {},
753
+ } )
754
+ ),
755
+ order: new Map(
756
+ Object.entries( {
757
+ '': [ 'uuid-6', 'uuid-8', 'uuid-10', 'uuid-22' ],
758
+ 'uuid-2': [],
759
+ 'uuid-4': [],
760
+ 'uuid-6': [],
761
+ 'uuid-8': [],
762
+ 'uuid-10': [ 'uuid-12', 'uuid-14' ],
763
+ 'uuid-12': [ 'uuid-16' ],
764
+ 'uuid-14': [ 'uuid-18' ],
765
+ 'uuid-16': [],
766
+ 'uuid-18': [ 'uuid-24' ],
767
+ 'uuid-20': [],
768
+ 'uuid-22': [],
769
+ 'uuid-24': [ 'uuid-26', 'uuid-28' ],
770
+ 'uuid-26': [],
771
+ 'uuid-28': [ 'uuid-30' ],
772
+ } )
773
+ ),
774
+ parents: new Map(
775
+ Object.entries( {
776
+ 'uuid-6': '',
777
+ 'uuid-8': '',
778
+ 'uuid-10': '',
779
+ 'uuid-22': '',
780
+ 'uuid-12': 'uuid-10',
781
+ 'uuid-14': 'uuid-10',
782
+ 'uuid-16': 'uuid-12',
783
+ 'uuid-18': 'uuid-14',
784
+ 'uuid-24': 'uuid-18',
785
+ 'uuid-26': 'uuid-24',
786
+ 'uuid-28': 'uuid-24',
787
+ 'uuid-30': 'uuid-28',
788
+ } )
789
+ ),
677
790
  },
678
791
  };
679
792
  expect( getClientIdsWithDescendants( state ) ).toEqual( [
@@ -697,17 +810,23 @@ describe( 'selectors', () => {
697
810
  it( 'should return the number of top-level blocks in the post', () => {
698
811
  const state = {
699
812
  blocks: {
700
- byClientId: {
701
- 23: { clientId: 23, name: 'core/heading' },
702
- 123: { clientId: 123, name: 'core/paragraph' },
703
- },
704
- attributes: {
705
- 23: {},
706
- 123: {},
707
- },
708
- order: {
709
- '': [ 123, 23 ],
710
- },
813
+ byClientId: new Map(
814
+ Object.entries( {
815
+ 23: { clientId: '23', name: 'core/heading' },
816
+ 123: { clientId: '123', name: 'core/paragraph' },
817
+ } )
818
+ ),
819
+ attributes: new Map(
820
+ Object.entries( {
821
+ 23: {},
822
+ 123: {},
823
+ } )
824
+ ),
825
+ order: new Map(
826
+ Object.entries( {
827
+ '': [ '123', '23' ],
828
+ } )
829
+ ),
711
830
  },
712
831
  };
713
832
 
@@ -717,25 +836,33 @@ describe( 'selectors', () => {
717
836
  it( 'should return the number of blocks in a nested context', () => {
718
837
  const state = {
719
838
  blocks: {
720
- byClientId: {
721
- 123: { clientId: 123, name: 'core/columns' },
722
- 456: { clientId: 456, name: 'core/paragraph' },
723
- 789: { clientId: 789, name: 'core/paragraph' },
724
- },
725
- attributes: {
726
- 123: {},
727
- 456: {},
728
- 789: {},
729
- },
730
- order: {
731
- '': [ 123 ],
732
- 123: [ 456, 789 ],
733
- },
734
- parents: {
735
- 123: '',
736
- 456: 123,
737
- 789: 123,
738
- },
839
+ byClientId: new Map(
840
+ Object.entries( {
841
+ 123: { clientId: '123', name: 'core/columns' },
842
+ 456: { clientId: '456', name: 'core/paragraph' },
843
+ 789: { clientId: '789', name: 'core/paragraph' },
844
+ } )
845
+ ),
846
+ attributes: new Map(
847
+ Object.entries( {
848
+ 123: {},
849
+ 456: {},
850
+ 789: {},
851
+ } )
852
+ ),
853
+ order: new Map(
854
+ Object.entries( {
855
+ '': [ '123' ],
856
+ 123: [ '456', '789' ],
857
+ } )
858
+ ),
859
+ parents: new Map(
860
+ Object.entries( {
861
+ 123: '',
862
+ 456: '123',
863
+ 789: '123',
864
+ } )
865
+ ),
739
866
  },
740
867
  };
741
868
 
@@ -789,23 +916,31 @@ describe( 'selectors', () => {
789
916
  describe( 'getGlobalBlockCount', () => {
790
917
  const state = {
791
918
  blocks: {
792
- byClientId: {
793
- 123: { clientId: 123, name: 'core/heading' },
794
- 456: { clientId: 456, name: 'core/paragraph' },
795
- 789: { clientId: 789, name: 'core/paragraph' },
796
- },
797
- attributes: {
798
- 123: {},
799
- 456: {},
800
- 789: {},
801
- },
802
- order: {
803
- '': [ 123, 456 ],
804
- },
805
- parents: {
806
- 123: '',
807
- 456: '',
808
- },
919
+ byClientId: new Map(
920
+ Object.entries( {
921
+ 123: { clientId: '123', name: 'core/heading' },
922
+ 456: { clientId: '456', name: 'core/paragraph' },
923
+ 789: { clientId: '789', name: 'core/paragraph' },
924
+ } )
925
+ ),
926
+ attributes: new Map(
927
+ Object.entries( {
928
+ 123: {},
929
+ 456: {},
930
+ 789: {},
931
+ } )
932
+ ),
933
+ order: new Map(
934
+ Object.entries( {
935
+ '': [ '123', '456' ],
936
+ } )
937
+ ),
938
+ parents: new Map(
939
+ Object.entries( {
940
+ 123: '',
941
+ 456: '',
942
+ } )
943
+ ),
809
944
  },
810
945
  };
811
946
 
@@ -820,10 +955,10 @@ describe( 'selectors', () => {
820
955
  it( 'should return 0 if no blocks exist', () => {
821
956
  const emptyState = {
822
957
  blocks: {
823
- byClientId: {},
824
- attributes: {},
825
- order: {},
826
- parents: {},
958
+ byClientId: new Map(),
959
+ attributes: new Map(),
960
+ order: new Map(),
961
+ parents: new Map(),
827
962
  },
828
963
  };
829
964
  expect( getGlobalBlockCount( emptyState ) ).toBe( 0 );
@@ -836,46 +971,54 @@ describe( 'selectors', () => {
836
971
  describe( '__experimentalGetGlobalBlocksByName', () => {
837
972
  const state = {
838
973
  blocks: {
839
- byClientId: {
840
- 123: { clientId: 123, name: 'core/heading' },
841
- 456: { clientId: 456, name: 'core/paragraph' },
842
- 789: { clientId: 789, name: 'core/paragraph' },
843
- 1011: { clientId: 1011, name: 'core/group' },
844
- 1213: { clientId: 1213, name: 'core/paragraph' },
845
- 1415: { clientId: 1213, name: 'core/paragraph' },
846
- },
847
- attributes: {
848
- 123: {},
849
- 456: {},
850
- 789: {},
851
- 1011: {},
852
- 1213: {},
853
- 1415: {},
854
- },
855
- order: {
856
- '': [ 123, 456, 1011 ],
857
- 1011: [ 1415, 1213 ],
858
- },
859
- parents: {
860
- 123: '',
861
- 456: '',
862
- 1011: '',
863
- 1213: 1011,
864
- 1415: 1011,
865
- },
974
+ byClientId: new Map(
975
+ Object.entries( {
976
+ 123: { clientId: '123', name: 'core/heading' },
977
+ 456: { clientId: '456', name: 'core/paragraph' },
978
+ 789: { clientId: '789', name: 'core/paragraph' },
979
+ 1011: { clientId: '1011', name: 'core/group' },
980
+ 1213: { clientId: '1213', name: 'core/paragraph' },
981
+ 1415: { clientId: '1213', name: 'core/paragraph' },
982
+ } )
983
+ ),
984
+ attributes: new Map(
985
+ Object.entries( {
986
+ 123: {},
987
+ 456: {},
988
+ 789: {},
989
+ 1011: {},
990
+ 1213: {},
991
+ 1415: {},
992
+ } )
993
+ ),
994
+ order: new Map(
995
+ Object.entries( {
996
+ '': [ '123', '456', '1011' ],
997
+ 1011: [ '1415', '1213' ],
998
+ } )
999
+ ),
1000
+ parents: new Map(
1001
+ Object.entries( {
1002
+ 123: '',
1003
+ 456: '',
1004
+ 1011: '',
1005
+ 1213: '1011',
1006
+ 1415: '1011',
1007
+ } )
1008
+ ),
866
1009
  },
867
1010
  };
868
1011
 
869
1012
  it( 'should return the clientIds of blocks of a given type', () => {
870
1013
  expect(
871
1014
  __experimentalGetGlobalBlocksByName( state, 'core/heading' )
872
- ).toStrictEqual( [ 123 ] );
1015
+ ).toStrictEqual( [ '123' ] );
873
1016
  } );
874
1017
 
875
1018
  it( 'should return the clientIds of blocks of a given type even if blocks are nested', () => {
876
1019
  expect(
877
1020
  __experimentalGetGlobalBlocksByName( state, 'core/paragraph' )
878
- ).toStrictEqual( [ 456, 1415, 1213 ] );
1021
+ ).toStrictEqual( [ '456', '1415', '1213' ] );
879
1022
  } );
880
1023
 
881
1024
  it( 'Should return empty array if no blocks match. The empty array should be the same reference', () => {
@@ -910,8 +1053,8 @@ describe( 'selectors', () => {
910
1053
  it( 'should return null if there is multi selection', () => {
911
1054
  const state = {
912
1055
  selection: {
913
- selectionStart: { clientId: 23 },
914
- selectionEnd: { clientId: 123 },
1056
+ selectionStart: { clientId: '23' },
1057
+ selectionEnd: { clientId: '123' },
915
1058
  },
916
1059
  };
917
1060
 
@@ -921,19 +1064,21 @@ describe( 'selectors', () => {
921
1064
  it( 'should return the selected block ClientId', () => {
922
1065
  const state = {
923
1066
  blocks: {
924
- byClientId: {
925
- 23: {
926
- name: 'fake block',
927
- },
928
- },
1067
+ byClientId: new Map(
1068
+ Object.entries( {
1069
+ 23: {
1070
+ name: 'fake block',
1071
+ },
1072
+ } )
1073
+ ),
929
1074
  },
930
1075
  selection: {
931
- selectionStart: { clientId: 23 },
932
- selectionEnd: { clientId: 23 },
1076
+ selectionStart: { clientId: '23' },
1077
+ selectionEnd: { clientId: '23' },
933
1078
  },
934
1079
  };
935
1080
 
936
- expect( getSelectedBlockClientId( state ) ).toEqual( 23 );
1081
+ expect( getSelectedBlockClientId( state ) ).toEqual( '23' );
937
1082
  } );
938
1083
  } );
939
1084
 
@@ -941,31 +1086,41 @@ describe( 'selectors', () => {
941
1086
  it( 'should return null if no block is selected', () => {
942
1087
  const state = {
943
1088
  blocks: {
944
- byClientId: {
945
- 23: { clientId: 23, name: 'core/heading' },
946
- 123: { clientId: 123, name: 'core/paragraph' },
947
- },
948
- attributes: {
949
- 23: {},
950
- 123: {},
951
- },
952
- order: {
953
- '': [ 23, 123 ],
954
- 23: [],
955
- 123: [],
956
- },
957
- parents: {
958
- 23: '',
959
- 123: '',
960
- },
961
- tree: {
962
- 23: {
963
- clientId: 23,
964
- name: 'core/heading',
965
- attributes: {},
966
- innerBlocks: [],
967
- },
968
- },
1089
+ byClientId: new Map(
1090
+ Object.entries( {
1091
+ 23: { clientId: '23', name: 'core/heading' },
1092
+ 123: { clientId: '123', name: 'core/paragraph' },
1093
+ } )
1094
+ ),
1095
+ attributes: new Map(
1096
+ Object.entries( {
1097
+ 23: {},
1098
+ 123: {},
1099
+ } )
1100
+ ),
1101
+ order: new Map(
1102
+ Object.entries( {
1103
+ '': [ '23', '123' ],
1104
+ 23: [],
1105
+ 123: [],
1106
+ } )
1107
+ ),
1108
+ parents: new Map(
1109
+ Object.entries( {
1110
+ 23: '',
1111
+ 123: '',
1112
+ } )
1113
+ ),
1114
+ tree: new Map(
1115
+ Object.entries( {
1116
+ 23: {
1117
+ clientId: '23',
1118
+ name: 'core/heading',
1119
+ attributes: {},
1120
+ innerBlocks: [],
1121
+ },
1122
+ } )
1123
+ ),
969
1124
  },
970
1125
  selection: {
971
1126
  selectionStart: {},
@@ -979,35 +1134,45 @@ describe( 'selectors', () => {
979
1134
  it( 'should return null if there is multi selection', () => {
980
1135
  const state = {
981
1136
  blocks: {
982
- byClientId: {
983
- 23: { clientId: 23, name: 'core/heading' },
984
- 123: { clientId: 123, name: 'core/paragraph' },
985
- },
986
- attributes: {
987
- 23: {},
988
- 123: {},
989
- },
990
- order: {
991
- '': [ 23, 123 ],
992
- 23: [],
993
- 123: [],
994
- },
995
- parents: {
996
- 123: '',
997
- 23: '',
998
- },
999
- tree: {
1000
- 23: {
1001
- clientId: 23,
1002
- name: 'core/heading',
1003
- attributes: {},
1004
- innerBlocks: [],
1005
- },
1006
- },
1137
+ byClientId: new Map(
1138
+ Object.entries( {
1139
+ 23: { clientId: '23', name: 'core/heading' },
1140
+ 123: { clientId: '123', name: 'core/paragraph' },
1141
+ } )
1142
+ ),
1143
+ attributes: new Map(
1144
+ Object.entries( {
1145
+ 23: {},
1146
+ 123: {},
1147
+ } )
1148
+ ),
1149
+ order: new Map(
1150
+ Object.entries( {
1151
+ '': [ '23', '123' ],
1152
+ 23: [],
1153
+ 123: [],
1154
+ } )
1155
+ ),
1156
+ parents: new Map(
1157
+ Object.entries( {
1158
+ 123: '',
1159
+ 23: '',
1160
+ } )
1161
+ ),
1162
+ tree: new Map(
1163
+ Object.entries( {
1164
+ 23: {
1165
+ clientId: '23',
1166
+ name: 'core/heading',
1167
+ attributes: {},
1168
+ innerBlocks: [],
1169
+ },
1170
+ } )
1171
+ ),
1007
1172
  },
1008
1173
  selection: {
1009
- selectionStart: { clientId: 23 },
1010
- selectionEnd: { clientId: 123 },
1174
+ selectionStart: { clientId: '23' },
1175
+ selectionEnd: { clientId: '123' },
1011
1176
  },
1012
1177
  };
1013
1178
 
@@ -1017,41 +1182,51 @@ describe( 'selectors', () => {
1017
1182
  it( 'should return the selected block', () => {
1018
1183
  const state = {
1019
1184
  blocks: {
1020
- byClientId: {
1021
- 23: { clientId: 23, name: 'core/heading' },
1022
- 123: { clientId: 123, name: 'core/paragraph' },
1023
- },
1024
- attributes: {
1025
- 23: {},
1026
- 123: {},
1027
- },
1028
- order: {
1029
- '': [ 23, 123 ],
1030
- 23: [],
1031
- 123: [],
1032
- },
1033
- parents: {
1034
- 123: '',
1035
- 23: '',
1036
- },
1037
- tree: {
1038
- 23: {
1039
- clientId: 23,
1040
- name: 'core/heading',
1041
- attributes: {},
1042
- innerBlocks: [],
1043
- },
1044
- },
1185
+ byClientId: new Map(
1186
+ Object.entries( {
1187
+ 23: { clientId: '23', name: 'core/heading' },
1188
+ 123: { clientId: '123', name: 'core/paragraph' },
1189
+ } )
1190
+ ),
1191
+ attributes: new Map(
1192
+ Object.entries( {
1193
+ 23: {},
1194
+ 123: {},
1195
+ } )
1196
+ ),
1197
+ order: new Map(
1198
+ Object.entries( {
1199
+ '': [ '23', '123' ],
1200
+ 23: [],
1201
+ 123: [],
1202
+ } )
1203
+ ),
1204
+ parents: new Map(
1205
+ Object.entries( {
1206
+ 123: '',
1207
+ 23: '',
1208
+ } )
1209
+ ),
1210
+ tree: new Map(
1211
+ Object.entries( {
1212
+ 23: {
1213
+ clientId: '23',
1214
+ name: 'core/heading',
1215
+ attributes: {},
1216
+ innerBlocks: [],
1217
+ },
1218
+ } )
1219
+ ),
1045
1220
  controlledInnerBlocks: {},
1046
1221
  },
1047
1222
  selection: {
1048
- selectionStart: { clientId: 23 },
1049
- selectionEnd: { clientId: 23 },
1223
+ selectionStart: { clientId: '23' },
1224
+ selectionEnd: { clientId: '23' },
1050
1225
  },
1051
1226
  };
1052
1227
 
1053
1228
  expect( getSelectedBlock( state ) ).toEqual(
1054
- getBlock( state, 23 )
1229
+ getBlock( state, '23' )
1055
1230
  );
1056
1231
  } );
1057
1232
  } );
@@ -1060,8 +1235,8 @@ describe( 'selectors', () => {
1060
1235
  it( 'should return null if the block does not exist', () => {
1061
1236
  const state = {
1062
1237
  blocks: {
1063
- order: {},
1064
- parents: {},
1238
+ order: new Map(),
1239
+ parents: new Map(),
1065
1240
  },
1066
1241
  };
1067
1242
 
@@ -1071,20 +1246,24 @@ describe( 'selectors', () => {
1071
1246
  it( 'should return root ClientId relative the block ClientId', () => {
1072
1247
  const state = {
1073
1248
  blocks: {
1074
- order: {
1075
- '': [ 123, 23 ],
1076
- 123: [ 456, 56 ],
1077
- },
1078
- parents: {
1079
- 123: '',
1080
- 23: '',
1081
- 456: 123,
1082
- 56: 123,
1083
- },
1249
+ order: new Map(
1250
+ Object.entries( {
1251
+ '': [ '123', '23' ],
1252
+ 123: [ '456', '56' ],
1253
+ } )
1254
+ ),
1255
+ parents: new Map(
1256
+ Object.entries( {
1257
+ 123: '',
1258
+ 23: '',
1259
+ 456: '123',
1260
+ 56: '123',
1261
+ } )
1262
+ ),
1084
1263
  },
1085
1264
  };
1086
1265
 
1087
- expect( getBlockRootClientId( state, 56 ) ).toBe( 123 );
1266
+ expect( getBlockRootClientId( state, '56' ) ).toBe( '123' );
1088
1267
  } );
1089
1268
  } );
1090
1269
 
@@ -1092,8 +1271,8 @@ describe( 'selectors', () => {
1092
1271
  it( 'should return the given block if the block has no parents', () => {
1093
1272
  const state = {
1094
1273
  blocks: {
1095
- order: {},
1096
- parents: {},
1274
+ order: new Map(),
1275
+ parents: new Map(),
1097
1276
  },
1098
1277
  };
1099
1278
 
@@ -1103,16 +1282,20 @@ describe( 'selectors', () => {
1103
1282
  it( 'should return root ClientId relative the block ClientId', () => {
1104
1283
  const state = {
1105
1284
  blocks: {
1106
- order: {
1107
- '': [ 'a', 'b' ],
1108
- a: [ 'c', 'd' ],
1109
- },
1110
- parents: {
1111
- a: '',
1112
- b: '',
1113
- c: 'a',
1114
- d: 'a',
1115
- },
1285
+ order: new Map(
1286
+ Object.entries( {
1287
+ '': [ 'a', 'b' ],
1288
+ a: [ 'c', 'd' ],
1289
+ } )
1290
+ ),
1291
+ parents: new Map(
1292
+ Object.entries( {
1293
+ a: '',
1294
+ b: '',
1295
+ c: 'a',
1296
+ d: 'a',
1297
+ } )
1298
+ ),
1116
1299
  },
1117
1300
  };
1118
1301
 
@@ -1122,18 +1305,22 @@ describe( 'selectors', () => {
1122
1305
  it( 'should return the top level root ClientId relative the block ClientId', () => {
1123
1306
  const state = {
1124
1307
  blocks: {
1125
- order: {
1126
- '': [ 'a', 'b' ],
1127
- a: [ 'c', 'd' ],
1128
- d: [ 'e' ],
1129
- },
1130
- parents: {
1131
- a: '',
1132
- b: '',
1133
- c: 'a',
1134
- d: 'a',
1135
- e: 'd',
1136
- },
1308
+ order: new Map(
1309
+ Object.entries( {
1310
+ '': [ 'a', 'b' ],
1311
+ a: [ 'c', 'd' ],
1312
+ d: [ 'e' ],
1313
+ } )
1314
+ ),
1315
+ parents: new Map(
1316
+ Object.entries( {
1317
+ a: '',
1318
+ b: '',
1319
+ c: 'a',
1320
+ d: 'a',
1321
+ e: 'd',
1322
+ } )
1323
+ ),
1137
1324
  },
1138
1325
  };
1139
1326
 
@@ -1145,13 +1332,17 @@ describe( 'selectors', () => {
1145
1332
  it( 'should return empty if there is no selection', () => {
1146
1333
  const state = {
1147
1334
  blocks: {
1148
- order: {
1149
- '': [ 123, 23 ],
1150
- },
1151
- parents: {
1152
- 123: '',
1153
- 23: '',
1154
- },
1335
+ order: new Map(
1336
+ Object.entries( {
1337
+ '': [ '123', '23' ],
1338
+ } )
1339
+ ),
1340
+ parents: new Map(
1341
+ Object.entries( {
1342
+ 123: '',
1343
+ 23: '',
1344
+ } )
1345
+ ),
1155
1346
  },
1156
1347
  selection: {
1157
1348
  selectionStart: {},
@@ -1165,75 +1356,95 @@ describe( 'selectors', () => {
1165
1356
  it( 'should return the selected block clientId if there is a selection', () => {
1166
1357
  const state = {
1167
1358
  blocks: {
1168
- order: {
1169
- '': [ 5, 4, 3, 2, 1 ],
1170
- },
1171
- parents: {
1172
- 1: '',
1173
- 2: '',
1174
- 3: '',
1175
- 4: '',
1176
- 5: '',
1177
- },
1359
+ order: new Map(
1360
+ Object.entries( {
1361
+ '': [ '5', '4', '3', '2', '1' ],
1362
+ } )
1363
+ ),
1364
+ parents: new Map(
1365
+ Object.entries( {
1366
+ 1: '',
1367
+ 2: '',
1368
+ 3: '',
1369
+ 4: '',
1370
+ 5: '',
1371
+ } )
1372
+ ),
1178
1373
  },
1179
1374
  selection: {
1180
- selectionStart: { clientId: 2 },
1181
- selectionEnd: { clientId: 2 },
1375
+ selectionStart: { clientId: '2' },
1376
+ selectionEnd: { clientId: '2' },
1182
1377
  },
1183
1378
  };
1184
1379
 
1185
- expect( getSelectedBlockClientIds( state ) ).toEqual( [ 2 ] );
1380
+ expect( getSelectedBlockClientIds( state ) ).toEqual( [ '2' ] );
1186
1381
  } );
1187
1382
 
1188
1383
  it( 'should return selected block clientIds if there is multi selection', () => {
1189
1384
  const state = {
1190
1385
  blocks: {
1191
- order: {
1192
- '': [ 5, 4, 3, 2, 1 ],
1193
- },
1194
- parents: {
1195
- 1: '',
1196
- 2: '',
1197
- 3: '',
1198
- 4: '',
1199
- 5: '',
1200
- },
1386
+ order: new Map(
1387
+ Object.entries( {
1388
+ '': [ '5', '4', '3', '2', '1' ],
1389
+ } )
1390
+ ),
1391
+ parents: new Map(
1392
+ Object.entries( {
1393
+ 1: '',
1394
+ 2: '',
1395
+ 3: '',
1396
+ 4: '',
1397
+ 5: '',
1398
+ } )
1399
+ ),
1201
1400
  },
1202
1401
  selection: {
1203
- selectionStart: { clientId: 2 },
1204
- selectionEnd: { clientId: 4 },
1402
+ selectionStart: { clientId: '2' },
1403
+ selectionEnd: { clientId: '4' },
1205
1404
  },
1206
1405
  };
1207
1406
 
1208
- expect( getSelectedBlockClientIds( state ) ).toEqual( [ 4, 3, 2 ] );
1407
+ expect( getSelectedBlockClientIds( state ) ).toEqual( [
1408
+ '4',
1409
+ '3',
1410
+ '2',
1411
+ ] );
1209
1412
  } );
1210
1413
 
1211
1414
  it( 'should return selected block clientIds if there is multi selection (nested context)', () => {
1212
1415
  const state = {
1213
1416
  blocks: {
1214
- order: {
1215
- '': [ 5, 4, 3, 2, 1 ],
1216
- 4: [ 9, 8, 7, 6 ],
1217
- },
1218
- parents: {
1219
- 1: '',
1220
- 2: '',
1221
- 3: '',
1222
- 4: '',
1223
- 5: '',
1224
- 6: 4,
1225
- 7: 4,
1226
- 8: 4,
1227
- 9: 4,
1228
- },
1417
+ order: new Map(
1418
+ Object.entries( {
1419
+ '': [ '5', '4', '3', '2', '1' ],
1420
+ 4: [ '9', '8', '7', '6' ],
1421
+ } )
1422
+ ),
1423
+ parents: new Map(
1424
+ Object.entries( {
1425
+ 1: '',
1426
+ 2: '',
1427
+ 3: '',
1428
+ 4: '',
1429
+ 5: '',
1430
+ 6: '4',
1431
+ 7: '4',
1432
+ 8: '4',
1433
+ 9: '4',
1434
+ } )
1435
+ ),
1229
1436
  },
1230
1437
  selection: {
1231
- selectionStart: { clientId: 7 },
1232
- selectionEnd: { clientId: 9 },
1438
+ selectionStart: { clientId: '7' },
1439
+ selectionEnd: { clientId: '9' },
1233
1440
  },
1234
1441
  };
1235
1442
 
1236
- expect( getSelectedBlockClientIds( state ) ).toEqual( [ 9, 8, 7 ] );
1443
+ expect( getSelectedBlockClientIds( state ) ).toEqual( [
1444
+ '9',
1445
+ '8',
1446
+ '7',
1447
+ ] );
1237
1448
  } );
1238
1449
  } );
1239
1450
 
@@ -1241,13 +1452,17 @@ describe( 'selectors', () => {
1241
1452
  it( 'should return empty if there is no multi selection', () => {
1242
1453
  const state = {
1243
1454
  blocks: {
1244
- order: {
1245
- '': [ 123, 23 ],
1246
- },
1247
- parents: {
1248
- 23: '',
1249
- 123: '',
1250
- },
1455
+ order: new Map(
1456
+ Object.entries( {
1457
+ '': [ '123', '23' ],
1458
+ } )
1459
+ ),
1460
+ parents: new Map(
1461
+ Object.entries( {
1462
+ 23: '',
1463
+ 123: '',
1464
+ } )
1465
+ ),
1251
1466
  },
1252
1467
  selection: {
1253
1468
  selectionStart: {},
@@ -1261,55 +1476,67 @@ describe( 'selectors', () => {
1261
1476
  it( 'should return selected block clientIds if there is multi selection', () => {
1262
1477
  const state = {
1263
1478
  blocks: {
1264
- order: {
1265
- '': [ 5, 4, 3, 2, 1 ],
1266
- },
1267
- parents: {
1268
- 1: '',
1269
- 2: '',
1270
- 3: '',
1271
- 4: '',
1272
- 5: '',
1273
- },
1479
+ order: new Map(
1480
+ Object.entries( {
1481
+ '': [ '5', '4', '3', '2', '1' ],
1482
+ } )
1483
+ ),
1484
+ parents: new Map(
1485
+ Object.entries( {
1486
+ 1: '',
1487
+ 2: '',
1488
+ 3: '',
1489
+ 4: '',
1490
+ 5: '',
1491
+ } )
1492
+ ),
1274
1493
  },
1275
1494
  selection: {
1276
- selectionStart: { clientId: 2 },
1277
- selectionEnd: { clientId: 4 },
1495
+ selectionStart: { clientId: '2' },
1496
+ selectionEnd: { clientId: '4' },
1278
1497
  },
1279
1498
  };
1280
1499
 
1281
1500
  expect( getMultiSelectedBlockClientIds( state ) ).toEqual( [
1282
- 4, 3, 2,
1501
+ '4',
1502
+ '3',
1503
+ '2',
1283
1504
  ] );
1284
1505
  } );
1285
1506
 
1286
1507
  it( 'should return selected block clientIds if there is multi selection (nested context)', () => {
1287
1508
  const state = {
1288
1509
  blocks: {
1289
- order: {
1290
- '': [ 5, 4, 3, 2, 1 ],
1291
- 4: [ 9, 8, 7, 6 ],
1292
- },
1293
- parents: {
1294
- 1: '',
1295
- 2: '',
1296
- 3: '',
1297
- 4: '',
1298
- 5: '',
1299
- 6: 4,
1300
- 7: 4,
1301
- 8: 4,
1302
- 9: 4,
1303
- },
1510
+ order: new Map(
1511
+ Object.entries( {
1512
+ '': [ '5', '4', '3', '2', '1' ],
1513
+ 4: [ '9', '8', '7', '6' ],
1514
+ } )
1515
+ ),
1516
+ parents: new Map(
1517
+ Object.entries( {
1518
+ 1: '',
1519
+ 2: '',
1520
+ 3: '',
1521
+ 4: '',
1522
+ 5: '',
1523
+ 6: '4',
1524
+ 7: '4',
1525
+ 8: '4',
1526
+ 9: '4',
1527
+ } )
1528
+ ),
1304
1529
  },
1305
1530
  selection: {
1306
- selectionStart: { clientId: 7 },
1307
- selectionEnd: { clientId: 9 },
1531
+ selectionStart: { clientId: '7' },
1532
+ selectionEnd: { clientId: '9' },
1308
1533
  },
1309
1534
  };
1310
1535
 
1311
1536
  expect( getMultiSelectedBlockClientIds( state ) ).toEqual( [
1312
- 9, 8, 7,
1537
+ '9',
1538
+ '8',
1539
+ '7',
1313
1540
  ] );
1314
1541
  } );
1315
1542
  } );
@@ -1318,10 +1545,10 @@ describe( 'selectors', () => {
1318
1545
  it( 'should return the same reference on subsequent invocations of empty selection', () => {
1319
1546
  const state = {
1320
1547
  blocks: {
1321
- byClientId: {},
1322
- attributes: {},
1323
- order: {},
1324
- parents: {},
1548
+ byClientId: new Map(),
1549
+ attributes: new Map(),
1550
+ order: new Map(),
1551
+ parents: new Map(),
1325
1552
  },
1326
1553
  selection: {
1327
1554
  selectionStart: {},
@@ -1350,12 +1577,12 @@ describe( 'selectors', () => {
1350
1577
  it( 'returns multi selection start', () => {
1351
1578
  const state = {
1352
1579
  selection: {
1353
- selectionStart: { clientId: 2 },
1354
- selectionEnd: { clientId: 4 },
1580
+ selectionStart: { clientId: '2' },
1581
+ selectionEnd: { clientId: '4' },
1355
1582
  },
1356
1583
  };
1357
1584
 
1358
- expect( getMultiSelectedBlocksStartClientId( state ) ).toBe( 2 );
1585
+ expect( getMultiSelectedBlocksStartClientId( state ) ).toBe( '2' );
1359
1586
  } );
1360
1587
  } );
1361
1588
 
@@ -1374,12 +1601,12 @@ describe( 'selectors', () => {
1374
1601
  it( 'returns multi selection end', () => {
1375
1602
  const state = {
1376
1603
  selection: {
1377
- selectionStart: { clientId: 2 },
1378
- selectionEnd: { clientId: 4 },
1604
+ selectionStart: { clientId: '2' },
1605
+ selectionEnd: { clientId: '4' },
1379
1606
  },
1380
1607
  };
1381
1608
 
1382
- expect( getMultiSelectedBlocksEndClientId( state ) ).toBe( 4 );
1609
+ expect( getMultiSelectedBlocksEndClientId( state ) ).toBe( '4' );
1383
1610
  } );
1384
1611
  } );
1385
1612
 
@@ -1387,35 +1614,43 @@ describe( 'selectors', () => {
1387
1614
  it( 'should return the ordered block ClientIds of top-level blocks by default', () => {
1388
1615
  const state = {
1389
1616
  blocks: {
1390
- order: {
1391
- '': [ 123, 23 ],
1392
- },
1393
- parents: {
1394
- 23: '',
1395
- 123: '',
1396
- },
1617
+ order: new Map(
1618
+ Object.entries( {
1619
+ '': [ '123', '23' ],
1620
+ } )
1621
+ ),
1622
+ parents: new Map(
1623
+ Object.entries( {
1624
+ 23: '',
1625
+ 123: '',
1626
+ } )
1627
+ ),
1397
1628
  },
1398
1629
  };
1399
1630
 
1400
- expect( getBlockOrder( state ) ).toEqual( [ 123, 23 ] );
1631
+ expect( getBlockOrder( state ) ).toEqual( [ '123', '23' ] );
1401
1632
  } );
1402
1633
 
1403
1634
  it( 'should return the ordered block ClientIds at a specified rootClientId', () => {
1404
1635
  const state = {
1405
1636
  blocks: {
1406
- order: {
1407
- '': [ 123, 23 ],
1408
- 123: [ 456 ],
1409
- },
1410
- parents: {
1411
- 23: '',
1412
- 123: '',
1413
- 456: 123,
1414
- },
1637
+ order: new Map(
1638
+ Object.entries( {
1639
+ '': [ '123', '23' ],
1640
+ 123: [ '456' ],
1641
+ } )
1642
+ ),
1643
+ parents: new Map(
1644
+ Object.entries( {
1645
+ 23: '',
1646
+ 123: '',
1647
+ 456: '123',
1648
+ } )
1649
+ ),
1415
1650
  },
1416
1651
  };
1417
1652
 
1418
- expect( getBlockOrder( state, '123' ) ).toEqual( [ 456 ] );
1653
+ expect( getBlockOrder( state, '123' ) ).toEqual( [ '456' ] );
1419
1654
  } );
1420
1655
  } );
1421
1656
 
@@ -1423,36 +1658,44 @@ describe( 'selectors', () => {
1423
1658
  it( 'should return the block order', () => {
1424
1659
  const state = {
1425
1660
  blocks: {
1426
- order: {
1427
- '': [ 123, 23 ],
1428
- },
1429
- parents: {
1430
- 23: '',
1431
- 123: '',
1432
- },
1661
+ order: new Map(
1662
+ Object.entries( {
1663
+ '': [ '123', '23' ],
1664
+ } )
1665
+ ),
1666
+ parents: new Map(
1667
+ Object.entries( {
1668
+ 23: '',
1669
+ 123: '',
1670
+ } )
1671
+ ),
1433
1672
  },
1434
1673
  };
1435
1674
 
1436
- expect( getBlockIndex( state, 23 ) ).toBe( 1 );
1675
+ expect( getBlockIndex( state, '23' ) ).toBe( 1 );
1437
1676
  } );
1438
1677
 
1439
1678
  it( 'should return the block order (nested context)', () => {
1440
1679
  const state = {
1441
1680
  blocks: {
1442
- order: {
1443
- '': [ 123, 23 ],
1444
- 123: [ 456, 56 ],
1445
- },
1446
- parents: {
1447
- 23: '',
1448
- 123: '',
1449
- 56: 123,
1450
- 456: 123,
1451
- },
1681
+ order: new Map(
1682
+ Object.entries( {
1683
+ '': [ '123', '23' ],
1684
+ 123: [ '456', '56' ],
1685
+ } )
1686
+ ),
1687
+ parents: new Map(
1688
+ Object.entries( {
1689
+ 23: '',
1690
+ 123: '',
1691
+ 56: '123',
1692
+ 456: '123',
1693
+ } )
1694
+ ),
1452
1695
  },
1453
1696
  };
1454
1697
 
1455
- expect( getBlockIndex( state, 56 ) ).toBe( 1 );
1698
+ expect( getBlockIndex( state, '56' ) ).toBe( 1 );
1456
1699
  } );
1457
1700
  } );
1458
1701
 
@@ -1460,73 +1703,91 @@ describe( 'selectors', () => {
1460
1703
  it( 'should return the previous block', () => {
1461
1704
  const state = {
1462
1705
  blocks: {
1463
- order: {
1464
- '': [ 123, 23 ],
1465
- },
1466
- parents: {
1467
- 23: '',
1468
- 123: '',
1469
- },
1706
+ order: new Map(
1707
+ Object.entries( {
1708
+ '': [ '123', '23' ],
1709
+ } )
1710
+ ),
1711
+ parents: new Map(
1712
+ Object.entries( {
1713
+ 23: '',
1714
+ 123: '',
1715
+ } )
1716
+ ),
1470
1717
  },
1471
1718
  };
1472
1719
 
1473
- expect( getPreviousBlockClientId( state, 23 ) ).toEqual( 123 );
1720
+ expect( getPreviousBlockClientId( state, '23' ) ).toEqual( '123' );
1474
1721
  } );
1475
1722
 
1476
1723
  it( 'should return the previous block (nested context)', () => {
1477
1724
  const state = {
1478
1725
  blocks: {
1479
- order: {
1480
- '': [ 123, 23 ],
1481
- 123: [ 456, 56 ],
1482
- },
1483
- parents: {
1484
- 23: '',
1485
- 123: '',
1486
- 456: 123,
1487
- 56: 123,
1488
- },
1489
- },
1490
- };
1491
-
1492
- expect( getPreviousBlockClientId( state, 56, '123' ) ).toEqual(
1493
- 456
1726
+ order: new Map(
1727
+ Object.entries( {
1728
+ '': [ '123', '23' ],
1729
+ 123: [ '456', '56' ],
1730
+ } )
1731
+ ),
1732
+ parents: new Map(
1733
+ Object.entries( {
1734
+ 23: '',
1735
+ 123: '',
1736
+ 456: '123',
1737
+ 56: '123',
1738
+ } )
1739
+ ),
1740
+ },
1741
+ };
1742
+
1743
+ expect( getPreviousBlockClientId( state, '56', '123' ) ).toEqual(
1744
+ '456'
1494
1745
  );
1495
1746
  } );
1496
1747
 
1497
1748
  it( 'should return null for the first block', () => {
1498
1749
  const state = {
1499
1750
  blocks: {
1500
- order: {
1501
- '': [ 123, 23 ],
1502
- },
1503
- parents: {
1504
- 23: '',
1505
- 123: '',
1506
- },
1751
+ order: new Map(
1752
+ Object.entries( {
1753
+ '': [ '123', '23' ],
1754
+ } )
1755
+ ),
1756
+ parents: new Map(
1757
+ Object.entries( {
1758
+ 23: '',
1759
+ 123: '',
1760
+ } )
1761
+ ),
1507
1762
  },
1508
1763
  };
1509
1764
 
1510
- expect( getPreviousBlockClientId( state, 123 ) ).toBeNull();
1765
+ expect( getPreviousBlockClientId( state, '123' ) ).toBeNull();
1511
1766
  } );
1512
1767
 
1513
1768
  it( 'should return null for the first block (nested context)', () => {
1514
1769
  const state = {
1515
1770
  blocks: {
1516
- order: {
1517
- '': [ 123, 23 ],
1518
- 123: [ 456, 56 ],
1519
- },
1520
- parents: {
1521
- 23: '',
1522
- 123: '',
1523
- 456: 123,
1524
- 56: 123,
1525
- },
1771
+ order: new Map(
1772
+ Object.entries( {
1773
+ '': [ '123', '23' ],
1774
+ 123: [ '456', '56' ],
1775
+ } )
1776
+ ),
1777
+ parents: new Map(
1778
+ Object.entries( {
1779
+ 23: '',
1780
+ 123: '',
1781
+ 456: '123',
1782
+ 56: '123',
1783
+ } )
1784
+ ),
1526
1785
  },
1527
1786
  };
1528
1787
 
1529
- expect( getPreviousBlockClientId( state, 456, '123' ) ).toBeNull();
1788
+ expect(
1789
+ getPreviousBlockClientId( state, '456', '123' )
1790
+ ).toBeNull();
1530
1791
  } );
1531
1792
  } );
1532
1793
 
@@ -1534,71 +1795,89 @@ describe( 'selectors', () => {
1534
1795
  it( 'should return the following block', () => {
1535
1796
  const state = {
1536
1797
  blocks: {
1537
- order: {
1538
- '': [ 123, 23 ],
1539
- },
1540
- parents: {
1541
- 23: '',
1542
- 123: '',
1543
- },
1798
+ order: new Map(
1799
+ Object.entries( {
1800
+ '': [ '123', '23' ],
1801
+ } )
1802
+ ),
1803
+ parents: new Map(
1804
+ Object.entries( {
1805
+ 23: '',
1806
+ 123: '',
1807
+ } )
1808
+ ),
1544
1809
  },
1545
1810
  };
1546
1811
 
1547
- expect( getNextBlockClientId( state, 123 ) ).toEqual( 23 );
1812
+ expect( getNextBlockClientId( state, '123' ) ).toEqual( '23' );
1548
1813
  } );
1549
1814
 
1550
1815
  it( 'should return the following block (nested context)', () => {
1551
1816
  const state = {
1552
1817
  blocks: {
1553
- order: {
1554
- '': [ 123, 23 ],
1555
- 123: [ 456, 56 ],
1556
- },
1557
- parents: {
1558
- 23: '',
1559
- 123: '',
1560
- 456: 123,
1561
- 56: 123,
1562
- },
1563
- },
1564
- };
1565
-
1566
- expect( getNextBlockClientId( state, 456, '123' ) ).toEqual( 56 );
1818
+ order: new Map(
1819
+ Object.entries( {
1820
+ '': [ '123', '23' ],
1821
+ 123: [ '456', '56' ],
1822
+ } )
1823
+ ),
1824
+ parents: new Map(
1825
+ Object.entries( {
1826
+ 23: '',
1827
+ 123: '',
1828
+ 456: '123',
1829
+ 56: '123',
1830
+ } )
1831
+ ),
1832
+ },
1833
+ };
1834
+
1835
+ expect( getNextBlockClientId( state, '456', '123' ) ).toEqual(
1836
+ '56'
1837
+ );
1567
1838
  } );
1568
1839
 
1569
1840
  it( 'should return null for the last block', () => {
1570
1841
  const state = {
1571
1842
  blocks: {
1572
- order: {
1573
- '': [ 123, 23 ],
1574
- },
1575
- parents: {
1576
- 23: '',
1577
- 123: '',
1578
- },
1843
+ order: new Map(
1844
+ Object.entries( {
1845
+ '': [ '123', '23' ],
1846
+ } )
1847
+ ),
1848
+ parents: new Map(
1849
+ Object.entries( {
1850
+ 23: '',
1851
+ 123: '',
1852
+ } )
1853
+ ),
1579
1854
  },
1580
1855
  };
1581
1856
 
1582
- expect( getNextBlockClientId( state, 23 ) ).toBeNull();
1857
+ expect( getNextBlockClientId( state, '23' ) ).toBeNull();
1583
1858
  } );
1584
1859
 
1585
1860
  it( 'should return null for the last block (nested context)', () => {
1586
1861
  const state = {
1587
1862
  blocks: {
1588
- order: {
1589
- '': [ 123, 23 ],
1590
- 123: [ 456, 56 ],
1591
- },
1592
- parents: {
1593
- 23: '',
1594
- 123: '',
1595
- 456: 123,
1596
- 56: 123,
1597
- },
1863
+ order: new Map(
1864
+ Object.entries( {
1865
+ '': [ '123', '23' ],
1866
+ 123: [ '456', '56' ],
1867
+ } )
1868
+ ),
1869
+ parents: new Map(
1870
+ Object.entries( {
1871
+ 23: '',
1872
+ 123: '',
1873
+ 456: '123',
1874
+ 56: '123',
1875
+ } )
1876
+ ),
1598
1877
  },
1599
1878
  };
1600
1879
 
1601
- expect( getNextBlockClientId( state, 56, '123' ) ).toBeNull();
1880
+ expect( getNextBlockClientId( state, '56', '123' ) ).toBeNull();
1602
1881
  } );
1603
1882
  } );
1604
1883
 
@@ -1606,23 +1885,23 @@ describe( 'selectors', () => {
1606
1885
  it( 'should return true if the block is selected', () => {
1607
1886
  const state = {
1608
1887
  selection: {
1609
- selectionStart: { clientId: 123 },
1610
- selectionEnd: { clientId: 123 },
1888
+ selectionStart: { clientId: '123' },
1889
+ selectionEnd: { clientId: '123' },
1611
1890
  },
1612
1891
  };
1613
1892
 
1614
- expect( isBlockSelected( state, 123 ) ).toBe( true );
1893
+ expect( isBlockSelected( state, '123' ) ).toBe( true );
1615
1894
  } );
1616
1895
 
1617
1896
  it( 'should return false if a multi-selection range exists', () => {
1618
1897
  const state = {
1619
1898
  selection: {
1620
- selectionStart: { clientId: 123 },
1621
- selectionEnd: { clientId: 124 },
1899
+ selectionStart: { clientId: '123' },
1900
+ selectionEnd: { clientId: '124' },
1622
1901
  },
1623
1902
  };
1624
1903
 
1625
- expect( isBlockSelected( state, 123 ) ).toBe( false );
1904
+ expect( isBlockSelected( state, '123' ) ).toBe( false );
1626
1905
  } );
1627
1906
 
1628
1907
  it( 'should return false if the block is not selected', () => {
@@ -1633,7 +1912,7 @@ describe( 'selectors', () => {
1633
1912
  },
1634
1913
  };
1635
1914
 
1636
- expect( isBlockSelected( state, 23 ) ).toBe( false );
1915
+ expect( isBlockSelected( state, '23' ) ).toBe( false );
1637
1916
  } );
1638
1917
  } );
1639
1918
 
@@ -1641,87 +1920,103 @@ describe( 'selectors', () => {
1641
1920
  it( 'should return false if the selected block is a child of the given ClientId', () => {
1642
1921
  const state = {
1643
1922
  selection: {
1644
- selectionStart: { clientId: 5 },
1645
- selectionEnd: { clientId: 5 },
1923
+ selectionStart: { clientId: '5' },
1924
+ selectionEnd: { clientId: '5' },
1646
1925
  },
1647
1926
  blocks: {
1648
- order: {
1649
- 4: [ 3, 2, 1 ],
1650
- },
1651
- parents: {
1652
- 1: 4,
1653
- 2: 4,
1654
- 3: 4,
1655
- },
1927
+ order: new Map(
1928
+ Object.entries( {
1929
+ 4: [ '3', '2', '1' ],
1930
+ } )
1931
+ ),
1932
+ parents: new Map(
1933
+ Object.entries( {
1934
+ 1: '4',
1935
+ 2: '4',
1936
+ 3: '4',
1937
+ } )
1938
+ ),
1656
1939
  },
1657
1940
  };
1658
1941
 
1659
- expect( hasSelectedInnerBlock( state, 4 ) ).toBe( false );
1942
+ expect( hasSelectedInnerBlock( state, '4' ) ).toBe( false );
1660
1943
  } );
1661
1944
 
1662
1945
  it( 'should return true if the selected block is a child of the given ClientId', () => {
1663
1946
  const state = {
1664
1947
  selection: {
1665
- selectionStart: { clientId: 3 },
1666
- selectionEnd: { clientId: 3 },
1948
+ selectionStart: { clientId: '3' },
1949
+ selectionEnd: { clientId: '3' },
1667
1950
  },
1668
1951
  blocks: {
1669
- order: {
1670
- 4: [ 3, 2, 1 ],
1671
- },
1672
- parents: {
1673
- 1: 4,
1674
- 2: 4,
1675
- 3: 4,
1676
- },
1952
+ order: new Map(
1953
+ Object.entries( {
1954
+ 4: [ '3', '2', '1' ],
1955
+ } )
1956
+ ),
1957
+ parents: new Map(
1958
+ Object.entries( {
1959
+ 1: '4',
1960
+ 2: '4',
1961
+ 3: '4',
1962
+ } )
1963
+ ),
1677
1964
  },
1678
1965
  };
1679
1966
 
1680
- expect( hasSelectedInnerBlock( state, 4 ) ).toBe( true );
1967
+ expect( hasSelectedInnerBlock( state, '4' ) ).toBe( true );
1681
1968
  } );
1682
1969
 
1683
1970
  it( 'should return true if a multi selection exists that contains children of the block with the given ClientId', () => {
1684
1971
  const state = {
1685
1972
  blocks: {
1686
- order: {
1687
- 6: [ 5, 4, 3, 2, 1 ],
1688
- },
1689
- parents: {
1690
- 1: 6,
1691
- 2: 6,
1692
- 3: 6,
1693
- 4: 6,
1694
- 5: 6,
1695
- },
1973
+ order: new Map(
1974
+ Object.entries( {
1975
+ 6: [ '5', '4', '3', '2', '1' ],
1976
+ } )
1977
+ ),
1978
+ parents: new Map(
1979
+ Object.entries( {
1980
+ 1: '6',
1981
+ 2: '6',
1982
+ 3: '6',
1983
+ 4: '6',
1984
+ 5: '6',
1985
+ } )
1986
+ ),
1696
1987
  },
1697
1988
  selection: {
1698
- selectionStart: { clientId: 2 },
1699
- selectionEnd: { clientId: 4 },
1989
+ selectionStart: { clientId: '2' },
1990
+ selectionEnd: { clientId: '4' },
1700
1991
  },
1701
1992
  };
1702
- expect( hasSelectedInnerBlock( state, 6 ) ).toBe( true );
1993
+ expect( hasSelectedInnerBlock( state, '6' ) ).toBe( true );
1703
1994
  } );
1704
1995
 
1705
1996
  it( 'should return false if a multi selection exists bot does not contains children of the block with the given ClientId', () => {
1706
1997
  const state = {
1707
- blocks: {
1708
- order: {
1709
- 3: [ 2, 1 ],
1710
- 6: [ 5, 4 ],
1711
- },
1712
- parents: {
1713
- 1: 3,
1714
- 2: 3,
1715
- 4: 6,
1716
- 5: 6,
1717
- },
1998
+ blocks: {
1999
+ order: new Map(
2000
+ Object.entries( {
2001
+ 3: [ '2', '1' ],
2002
+ 6: [ '5', '4' ],
2003
+ } )
2004
+ ),
2005
+ parents: new Map(
2006
+ Object.entries( {
2007
+ 1: '3',
2008
+ 2: '3',
2009
+ 4: '6',
2010
+ 5: '6',
2011
+ } )
2012
+ ),
1718
2013
  },
1719
2014
  selection: {
1720
- selectionStart: { clientId: 5 },
1721
- selectionEnd: { clientId: 4 },
2015
+ selectionStart: { clientId: '5' },
2016
+ selectionEnd: { clientId: '4' },
1722
2017
  },
1723
2018
  };
1724
- expect( hasSelectedInnerBlock( state, 3 ) ).toBe( false );
2019
+ expect( hasSelectedInnerBlock( state, '3' ) ).toBe( false );
1725
2020
  } );
1726
2021
  } );
1727
2022
 
@@ -1729,70 +2024,82 @@ describe( 'selectors', () => {
1729
2024
  it( 'should return true if the block is selected but not the last', () => {
1730
2025
  const state = {
1731
2026
  selection: {
1732
- selectionStart: { clientId: 5 },
1733
- selectionEnd: { clientId: 3 },
2027
+ selectionStart: { clientId: '5' },
2028
+ selectionEnd: { clientId: '3' },
1734
2029
  },
1735
2030
  blocks: {
1736
- order: {
1737
- '': [ 5, 4, 3, 2, 1 ],
1738
- },
1739
- parents: {
1740
- 1: '',
1741
- 2: '',
1742
- 3: '',
1743
- 4: '',
1744
- 5: '',
1745
- },
2031
+ order: new Map(
2032
+ Object.entries( {
2033
+ '': [ '5', '4', '3', '2', '1' ],
2034
+ } )
2035
+ ),
2036
+ parents: new Map(
2037
+ Object.entries( {
2038
+ 1: '',
2039
+ 2: '',
2040
+ 3: '',
2041
+ 4: '',
2042
+ 5: '',
2043
+ } )
2044
+ ),
1746
2045
  },
1747
2046
  };
1748
2047
 
1749
- expect( isBlockWithinSelection( state, 4 ) ).toBe( true );
2048
+ expect( isBlockWithinSelection( state, '4' ) ).toBe( true );
1750
2049
  } );
1751
2050
 
1752
2051
  it( 'should return false if the block is the last selected', () => {
1753
2052
  const state = {
1754
2053
  selection: {
1755
- selectionStart: { clientId: 5 },
1756
- selectionEnd: { clientId: 3 },
2054
+ selectionStart: { clientId: '5' },
2055
+ selectionEnd: { clientId: '3' },
1757
2056
  },
1758
2057
  blocks: {
1759
- order: {
1760
- '': [ 5, 4, 3, 2, 1 ],
1761
- },
1762
- parents: {
1763
- 1: '',
1764
- 2: '',
1765
- 3: '',
1766
- 4: '',
1767
- 5: '',
1768
- },
2058
+ order: new Map(
2059
+ Object.entries( {
2060
+ '': [ '5', '4', '3', '2', '1' ],
2061
+ } )
2062
+ ),
2063
+ parents: new Map(
2064
+ Object.entries( {
2065
+ 1: '',
2066
+ 2: '',
2067
+ 3: '',
2068
+ 4: '',
2069
+ 5: '',
2070
+ } )
2071
+ ),
1769
2072
  },
1770
2073
  };
1771
2074
 
1772
- expect( isBlockWithinSelection( state, 3 ) ).toBe( false );
2075
+ expect( isBlockWithinSelection( state, '3' ) ).toBe( false );
1773
2076
  } );
1774
2077
 
1775
2078
  it( 'should return false if the block is not selected', () => {
1776
2079
  const state = {
1777
2080
  selection: {
1778
- selectionStart: { clientId: 5 },
1779
- selectionEnd: { clientId: 3 },
2081
+ selectionStart: { clientId: '5' },
2082
+ selectionEnd: { clientId: '3' },
1780
2083
  },
1781
2084
  blocks: {
1782
- order: {
1783
- '': [ 5, 4, 3, 2, 1 ],
1784
- },
1785
- parents: {
1786
- 1: '',
1787
- 2: '',
1788
- 3: '',
1789
- 4: '',
1790
- 5: '',
1791
- },
2085
+ order: new Map(
2086
+ Object.entries( {
2087
+ '': [ '5', '4', '3', '2', '1' ],
2088
+ } )
2089
+ ),
2090
+ parents: new Map(
2091
+ Object.entries( {
2092
+ 1: '',
2093
+ 2: '',
2094
+ 3: '',
2095
+ 4: '',
2096
+ 5: '',
2097
+ } )
2098
+ ),
1792
2099
  },
1793
2100
  };
1794
2101
 
1795
- expect( isBlockWithinSelection( state, 2 ) ).toBe( false );
2102
+ expect( isBlockWithinSelection( state, '2' ) ).toBe( false );
1796
2103
  } );
1797
2104
 
1798
2105
  it( 'should return false if there is no selection', () => {
@@ -1802,20 +2109,24 @@ describe( 'selectors', () => {
1802
2109
  selectionEnd: {},
1803
2110
  },
1804
2111
  blocks: {
1805
- order: {
1806
- '': [ 5, 4, 3, 2, 1 ],
1807
- },
1808
- parents: {
1809
- 1: '',
1810
- 2: '',
1811
- 3: '',
1812
- 4: '',
1813
- 5: '',
1814
- },
2112
+ order: new Map(
2113
+ Object.entries( {
2114
+ '': [ '5', '4', '3', '2', '1' ],
2115
+ } )
2116
+ ),
2117
+ parents: new Map(
2118
+ Object.entries( {
2119
+ 1: '',
2120
+ 2: '',
2121
+ 3: '',
2122
+ 4: '',
2123
+ 5: '',
2124
+ } )
2125
+ ),
1815
2126
  },
1816
2127
  };
1817
2128
 
1818
- expect( isBlockWithinSelection( state, 4 ) ).toBe( false );
2129
+ expect( isBlockWithinSelection( state, '4' ) ).toBe( false );
1819
2130
  } );
1820
2131
  } );
1821
2132
 
@@ -1865,58 +2176,66 @@ describe( 'selectors', () => {
1865
2176
  describe( 'isBlockMultiSelected', () => {
1866
2177
  const state = {
1867
2178
  blocks: {
1868
- order: {
1869
- '': [ 5, 4, 3, 2, 1 ],
1870
- },
1871
- parents: {
1872
- 1: '',
1873
- 2: '',
1874
- 3: '',
1875
- 4: '',
1876
- 5: '',
1877
- },
2179
+ order: new Map(
2180
+ Object.entries( {
2181
+ '': [ '5', '4', '3', '2', '1' ],
2182
+ } )
2183
+ ),
2184
+ parents: new Map(
2185
+ Object.entries( {
2186
+ 1: '',
2187
+ 2: '',
2188
+ 3: '',
2189
+ 4: '',
2190
+ 5: '',
2191
+ } )
2192
+ ),
1878
2193
  },
1879
2194
  selection: {
1880
- selectionStart: { clientId: 2 },
1881
- selectionEnd: { clientId: 4 },
2195
+ selectionStart: { clientId: '2' },
2196
+ selectionEnd: { clientId: '4' },
1882
2197
  },
1883
2198
  };
1884
2199
 
1885
2200
  it( 'should return true if the block is multi selected', () => {
1886
- expect( isBlockMultiSelected( state, 3 ) ).toBe( true );
2201
+ expect( isBlockMultiSelected( state, '3' ) ).toBe( true );
1887
2202
  } );
1888
2203
 
1889
2204
  it( 'should return false if the block is not multi selected', () => {
1890
- expect( isBlockMultiSelected( state, 5 ) ).toBe( false );
2205
+ expect( isBlockMultiSelected( state, '5' ) ).toBe( false );
1891
2206
  } );
1892
2207
  } );
1893
2208
 
1894
2209
  describe( 'isFirstMultiSelectedBlock', () => {
1895
2210
  const state = {
1896
2211
  blocks: {
1897
- order: {
1898
- '': [ 5, 4, 3, 2, 1 ],
1899
- },
1900
- parents: {
1901
- 1: '',
1902
- 2: '',
1903
- 3: '',
1904
- 4: '',
1905
- 5: '',
1906
- },
2212
+ order: new Map(
2213
+ Object.entries( {
2214
+ '': [ '5', '4', '3', '2', '1' ],
2215
+ } )
2216
+ ),
2217
+ parents: new Map(
2218
+ Object.entries( {
2219
+ 1: '',
2220
+ 2: '',
2221
+ 3: '',
2222
+ 4: '',
2223
+ 5: '',
2224
+ } )
2225
+ ),
1907
2226
  },
1908
2227
  selection: {
1909
- selectionStart: { clientId: 2 },
1910
- selectionEnd: { clientId: 4 },
2228
+ selectionStart: { clientId: '2' },
2229
+ selectionEnd: { clientId: '4' },
1911
2230
  },
1912
2231
  };
1913
2232
 
1914
2233
  it( 'should return true if the block is first in multi selection', () => {
1915
- expect( isFirstMultiSelectedBlock( state, 4 ) ).toBe( true );
2234
+ expect( isFirstMultiSelectedBlock( state, '4' ) ).toBe( true );
1916
2235
  } );
1917
2236
 
1918
2237
  it( 'should return false if the block is not first in multi selection', () => {
1919
- expect( isFirstMultiSelectedBlock( state, 3 ) ).toBe( false );
2238
+ expect( isFirstMultiSelectedBlock( state, '3' ) ).toBe( false );
1920
2239
  } );
1921
2240
  } );
1922
2241
 
@@ -1926,7 +2245,7 @@ describe( 'selectors', () => {
1926
2245
  blocksMode: {},
1927
2246
  };
1928
2247
 
1929
- expect( getBlockMode( state, 123 ) ).toEqual( 'visual' );
2248
+ expect( getBlockMode( state, '123' ) ).toEqual( 'visual' );
1930
2249
  } );
1931
2250
 
1932
2251
  it( 'should return the block mode', () => {
@@ -1936,7 +2255,25 @@ describe( 'selectors', () => {
1936
2255
  },
1937
2256
  };
1938
2257
 
1939
- expect( getBlockMode( state, 123 ) ).toEqual( 'html' );
2258
+ expect( getBlockMode( state, '123' ) ).toEqual( 'html' );
2259
+ } );
2260
+ } );
2261
+
2262
+ describe( 'isBlockInterfaceHidden', () => {
2263
+ it( 'should return the true if toggled true in state', () => {
2264
+ const state = {
2265
+ isBlockInterfaceHidden: true,
2266
+ };
2267
+
2268
+ expect( isBlockInterfaceHidden( state ) ).toBe( true );
2269
+ } );
2270
+
2271
+ it( 'should return false if toggled false in state', () => {
2272
+ const state = {
2273
+ isBlockInterfaceHidden: false,
2274
+ };
2275
+
2276
+ expect( isBlockInterfaceHidden( state ) ).toBe( false );
1940
2277
  } );
1941
2278
  } );
1942
2279
 
@@ -2012,10 +2349,12 @@ describe( 'selectors', () => {
2012
2349
  const state = {
2013
2350
  draggedBlocks: [ 'block-1_grandparent' ],
2014
2351
  blocks: {
2015
- parents: {
2016
- 'block-1': 'block-1_parent',
2017
- 'block-1_parent': 'block-1_grandparent',
2018
- },
2352
+ parents: new Map(
2353
+ Object.entries( {
2354
+ 'block-1': 'block-1_parent',
2355
+ 'block-1_parent': 'block-1_grandparent',
2356
+ } )
2357
+ ),
2019
2358
  },
2020
2359
  };
2021
2360
  expect( isAncestorBeingDragged( state, 'block-1' ) ).toBe( true );
@@ -2025,10 +2364,12 @@ describe( 'selectors', () => {
2025
2364
  const state = {
2026
2365
  draggedBlocks: [ 'block-2_grandparent' ],
2027
2366
  blocks: {
2028
- parents: {
2029
- 'block-1': 'block-1_parent',
2030
- 'block-1_parent': 'block-1_grandparent',
2031
- },
2367
+ parents: new Map(
2368
+ Object.entries( {
2369
+ 'block-1': 'block-1_parent',
2370
+ 'block-1_parent': 'block-1_grandparent',
2371
+ } )
2372
+ ),
2032
2373
  },
2033
2374
  };
2034
2375
  expect( isAncestorBeingDragged( state, 'block-1' ) ).toBe( false );
@@ -2038,10 +2379,12 @@ describe( 'selectors', () => {
2038
2379
  const state = {
2039
2380
  draggedBlocks: [],
2040
2381
  blocks: {
2041
- parents: {
2042
- 'block-1': 'block-1_parent',
2043
- 'block-1_parent': 'block-1_grandparent',
2044
- },
2382
+ parents: new Map(
2383
+ Object.entries( {
2384
+ 'block-1': 'block-1_parent',
2385
+ 'block-1_parent': 'block-1_grandparent',
2386
+ } )
2387
+ ),
2045
2388
  },
2046
2389
  };
2047
2390
  expect( isAncestorBeingDragged( state, 'block-1' ) ).toBe( false );
@@ -2074,23 +2417,31 @@ describe( 'selectors', () => {
2074
2417
  selectionEnd: { clientId: 'clientId2' },
2075
2418
  },
2076
2419
  blocks: {
2077
- byClientId: {
2078
- clientId1: { clientId: 'clientId1' },
2079
- clientId2: { clientId: 'clientId2' },
2080
- },
2081
- attributes: {
2082
- clientId1: {},
2083
- clientId2: {},
2084
- },
2085
- order: {
2086
- '': [ 'clientId1' ],
2087
- clientId1: [ 'clientId2' ],
2088
- clientId2: [],
2089
- },
2090
- parents: {
2091
- clientId1: '',
2092
- clientId2: 'clientId1',
2093
- },
2420
+ byClientId: new Map(
2421
+ Object.entries( {
2422
+ clientId1: { clientId: 'clientId1' },
2423
+ clientId2: { clientId: 'clientId2' },
2424
+ } )
2425
+ ),
2426
+ attributes: new Map(
2427
+ Object.entries( {
2428
+ clientId1: {},
2429
+ clientId2: {},
2430
+ } )
2431
+ ),
2432
+ order: new Map(
2433
+ Object.entries( {
2434
+ '': [ 'clientId1' ],
2435
+ clientId1: [ 'clientId2' ],
2436
+ clientId2: [],
2437
+ } )
2438
+ ),
2439
+ parents: new Map(
2440
+ Object.entries( {
2441
+ clientId1: '',
2442
+ clientId2: 'clientId1',
2443
+ } )
2444
+ ),
2094
2445
  },
2095
2446
  insertionPoint: {
2096
2447
  rootClientId: undefined,
@@ -2111,19 +2462,27 @@ describe( 'selectors', () => {
2111
2462
  selectionEnd: { clientId: 'clientId1' },
2112
2463
  },
2113
2464
  blocks: {
2114
- byClientId: {
2115
- clientId1: { clientId: 'clientId1' },
2116
- },
2117
- attributes: {
2118
- clientId1: {},
2119
- },
2120
- order: {
2121
- '': [ 'clientId1' ],
2122
- clientId1: [],
2123
- },
2124
- parents: {
2125
- clientId1: '',
2126
- },
2465
+ byClientId: new Map(
2466
+ Object.entries( {
2467
+ clientId1: { clientId: 'clientId1' },
2468
+ } )
2469
+ ),
2470
+ attributes: new Map(
2471
+ Object.entries( {
2472
+ clientId1: {},
2473
+ } )
2474
+ ),
2475
+ order: new Map(
2476
+ Object.entries( {
2477
+ '': [ 'clientId1' ],
2478
+ clientId1: [],
2479
+ } )
2480
+ ),
2481
+ parents: new Map(
2482
+ Object.entries( {
2483
+ clientId1: '',
2484
+ } )
2485
+ ),
2127
2486
  },
2128
2487
  insertionPoint: null,
2129
2488
  };
@@ -2141,23 +2500,31 @@ describe( 'selectors', () => {
2141
2500
  selectionEnd: { clientId: 'clientId2' },
2142
2501
  },
2143
2502
  blocks: {
2144
- byClientId: {
2145
- clientId1: { clientId: 'clientId1' },
2146
- clientId2: { clientId: 'clientId2' },
2147
- },
2148
- attributes: {
2149
- clientId1: {},
2150
- clientId2: {},
2151
- },
2152
- order: {
2153
- '': [ 'clientId1' ],
2154
- clientId1: [ 'clientId2' ],
2155
- clientId2: [],
2156
- },
2157
- parents: {
2158
- clientId1: '',
2159
- clientId2: 'clientId1',
2160
- },
2503
+ byClientId: new Map(
2504
+ Object.entries( {
2505
+ clientId1: { clientId: 'clientId1' },
2506
+ clientId2: { clientId: 'clientId2' },
2507
+ } )
2508
+ ),
2509
+ attributes: new Map(
2510
+ Object.entries( {
2511
+ clientId1: {},
2512
+ clientId2: {},
2513
+ } )
2514
+ ),
2515
+ order: new Map(
2516
+ Object.entries( {
2517
+ '': [ 'clientId1' ],
2518
+ clientId1: [ 'clientId2' ],
2519
+ clientId2: [],
2520
+ } )
2521
+ ),
2522
+ parents: new Map(
2523
+ Object.entries( {
2524
+ clientId1: '',
2525
+ clientId2: 'clientId1',
2526
+ } )
2527
+ ),
2161
2528
  },
2162
2529
  insertionPoint: null,
2163
2530
  };
@@ -2175,23 +2542,31 @@ describe( 'selectors', () => {
2175
2542
  selectionEnd: { clientId: 'clientId2' },
2176
2543
  },
2177
2544
  blocks: {
2178
- byClientId: {
2179
- clientId1: { clientId: 'clientId1' },
2180
- clientId2: { clientId: 'clientId2' },
2181
- },
2182
- attributes: {
2183
- clientId1: {},
2184
- clientId2: {},
2185
- },
2186
- order: {
2187
- '': [ 'clientId1', 'clientId2' ],
2188
- clientId1: [],
2189
- clientId2: [],
2190
- },
2191
- parents: {
2192
- clientId1: '',
2193
- clientId2: '',
2194
- },
2545
+ byClientId: new Map(
2546
+ Object.entries( {
2547
+ clientId1: { clientId: 'clientId1' },
2548
+ clientId2: { clientId: 'clientId2' },
2549
+ } )
2550
+ ),
2551
+ attributes: new Map(
2552
+ Object.entries( {
2553
+ clientId1: {},
2554
+ clientId2: {},
2555
+ } )
2556
+ ),
2557
+ order: new Map(
2558
+ Object.entries( {
2559
+ '': [ 'clientId1', 'clientId2' ],
2560
+ clientId1: [],
2561
+ clientId2: [],
2562
+ } )
2563
+ ),
2564
+ parents: new Map(
2565
+ Object.entries( {
2566
+ clientId1: '',
2567
+ clientId2: '',
2568
+ } )
2569
+ ),
2195
2570
  },
2196
2571
  insertionPoint: null,
2197
2572
  };
@@ -2209,23 +2584,31 @@ describe( 'selectors', () => {
2209
2584
  selectionEnd: {},
2210
2585
  },
2211
2586
  blocks: {
2212
- byClientId: {
2213
- clientId1: { clientId: 'clientId1' },
2214
- clientId2: { clientId: 'clientId2' },
2215
- },
2216
- attributes: {
2217
- clientId1: {},
2218
- clientId2: {},
2219
- },
2220
- order: {
2221
- '': [ 'clientId1', 'clientId2' ],
2222
- clientId1: [],
2223
- clientId2: [],
2224
- },
2225
- parents: {
2226
- clientId1: '',
2227
- clientId2: '',
2228
- },
2587
+ byClientId: new Map(
2588
+ Object.entries( {
2589
+ clientId1: { clientId: 'clientId1' },
2590
+ clientId2: { clientId: 'clientId2' },
2591
+ } )
2592
+ ),
2593
+ attributes: new Map(
2594
+ Object.entries( {
2595
+ clientId1: {},
2596
+ clientId2: {},
2597
+ } )
2598
+ ),
2599
+ order: new Map(
2600
+ Object.entries( {
2601
+ '': [ 'clientId1', 'clientId2' ],
2602
+ clientId1: [],
2603
+ clientId2: [],
2604
+ } )
2605
+ ),
2606
+ parents: new Map(
2607
+ Object.entries( {
2608
+ clientId1: '',
2609
+ clientId2: '',
2610
+ } )
2611
+ ),
2229
2612
  },
2230
2613
  insertionPoint: null,
2231
2614
  };
@@ -2262,8 +2645,8 @@ describe( 'selectors', () => {
2262
2645
  it( 'should deny blocks that are not registered', () => {
2263
2646
  const state = {
2264
2647
  blocks: {
2265
- byClientId: {},
2266
- attributes: {},
2648
+ byClientId: new Map(),
2649
+ attributes: new Map(),
2267
2650
  },
2268
2651
  blockListSettings: {},
2269
2652
  settings: {},
@@ -2274,8 +2657,8 @@ describe( 'selectors', () => {
2274
2657
  it( 'should deny blocks that are not allowed by the editor', () => {
2275
2658
  const state = {
2276
2659
  blocks: {
2277
- byClientId: {},
2278
- attributes: {},
2660
+ byClientId: new Map(),
2661
+ attributes: new Map(),
2279
2662
  },
2280
2663
  blockListSettings: {},
2281
2664
  settings: {
@@ -2290,8 +2673,8 @@ describe( 'selectors', () => {
2290
2673
  it( 'should allow blocks that are allowed by the editor', () => {
2291
2674
  const state = {
2292
2675
  blocks: {
2293
- byClientId: {},
2294
- attributes: {},
2676
+ byClientId: new Map(),
2677
+ attributes: new Map(),
2295
2678
  },
2296
2679
  blockListSettings: {},
2297
2680
  settings: {
@@ -2306,8 +2689,8 @@ describe( 'selectors', () => {
2306
2689
  it( 'should deny blocks when the editor has a template lock', () => {
2307
2690
  const state = {
2308
2691
  blocks: {
2309
- byClientId: {},
2310
- attributes: {},
2692
+ byClientId: new Map(),
2693
+ attributes: new Map(),
2311
2694
  },
2312
2695
  blockListSettings: {},
2313
2696
  settings: {
@@ -2322,8 +2705,8 @@ describe( 'selectors', () => {
2322
2705
  it( 'should deny blocks that restrict parent from being inserted into the root', () => {
2323
2706
  const state = {
2324
2707
  blocks: {
2325
- byClientId: {},
2326
- attributes: {},
2708
+ byClientId: new Map(),
2709
+ attributes: new Map(),
2327
2710
  },
2328
2711
  blockListSettings: {},
2329
2712
  settings: {},
@@ -2336,12 +2719,16 @@ describe( 'selectors', () => {
2336
2719
  it( 'should deny blocks that restrict parent from being inserted into a restricted parent', () => {
2337
2720
  const state = {
2338
2721
  blocks: {
2339
- byClientId: {
2340
- block1: { name: 'core/test-block-a' },
2341
- },
2342
- attributes: {
2343
- block1: {},
2344
- },
2722
+ byClientId: new Map(
2723
+ Object.entries( {
2724
+ block1: { name: 'core/test-block-a' },
2725
+ } )
2726
+ ),
2727
+ attributes: new Map(
2728
+ Object.entries( {
2729
+ block1: {},
2730
+ } )
2731
+ ),
2345
2732
  },
2346
2733
  blockListSettings: {},
2347
2734
  settings: {},
@@ -2354,12 +2741,16 @@ describe( 'selectors', () => {
2354
2741
  it( 'should allow blocks to be inserted into an allowed parent', () => {
2355
2742
  const state = {
2356
2743
  blocks: {
2357
- byClientId: {
2358
- block1: { name: 'core/test-block-b' },
2359
- },
2360
- attributes: {
2361
- block1: {},
2362
- },
2744
+ byClientId: new Map(
2745
+ Object.entries( {
2746
+ block1: { name: 'core/test-block-b' },
2747
+ } )
2748
+ ),
2749
+ attributes: new Map(
2750
+ Object.entries( {
2751
+ block1: {},
2752
+ } )
2753
+ ),
2363
2754
  },
2364
2755
  blockListSettings: {
2365
2756
  block1: {},
@@ -2374,12 +2765,16 @@ describe( 'selectors', () => {
2374
2765
  it( 'should deny blocks from being inserted into a block that does not allow inner blocks', () => {
2375
2766
  const state = {
2376
2767
  blocks: {
2377
- byClientId: {
2378
- block1: { name: 'core/test-block-b' },
2379
- },
2380
- attributes: {
2381
- block1: {},
2382
- },
2768
+ byClientId: new Map(
2769
+ Object.entries( {
2770
+ block1: { name: 'core/test-block-b' },
2771
+ } )
2772
+ ),
2773
+ attributes: new Map(
2774
+ Object.entries( {
2775
+ block1: {},
2776
+ } )
2777
+ ),
2383
2778
  },
2384
2779
  blockListSettings: {
2385
2780
  block1: {},
@@ -2394,12 +2789,16 @@ describe( 'selectors', () => {
2394
2789
  it( 'should deny restricted blocks from being inserted into a block that restricts allowedBlocks', () => {
2395
2790
  const state = {
2396
2791
  blocks: {
2397
- byClientId: {
2398
- block1: { name: 'core/test-block-a' },
2399
- },
2400
- attributes: {
2401
- block1: {},
2402
- },
2792
+ byClientId: new Map(
2793
+ Object.entries( {
2794
+ block1: { name: 'core/test-block-a' },
2795
+ } )
2796
+ ),
2797
+ attributes: new Map(
2798
+ Object.entries( {
2799
+ block1: {},
2800
+ } )
2801
+ ),
2403
2802
  },
2404
2803
  blockListSettings: {
2405
2804
  block1: {
@@ -2416,12 +2815,16 @@ describe( 'selectors', () => {
2416
2815
  it( 'should allow allowed blocks to be inserted into a block that restricts allowedBlocks', () => {
2417
2816
  const state = {
2418
2817
  blocks: {
2419
- byClientId: {
2420
- block1: { name: 'core/test-block-a' },
2421
- },
2422
- attributes: {
2423
- block1: {},
2424
- },
2818
+ byClientId: new Map(
2819
+ Object.entries( {
2820
+ block1: { name: 'core/test-block-a' },
2821
+ } )
2822
+ ),
2823
+ attributes: new Map(
2824
+ Object.entries( {
2825
+ block1: {},
2826
+ } )
2827
+ ),
2425
2828
  },
2426
2829
  blockListSettings: {
2427
2830
  block1: {
@@ -2438,12 +2841,16 @@ describe( 'selectors', () => {
2438
2841
  it( 'should prioritise parent over allowedBlocks', () => {
2439
2842
  const state = {
2440
2843
  blocks: {
2441
- byClientId: {
2442
- block1: { name: 'core/test-block-b' },
2443
- },
2444
- attributes: {
2445
- block1: {},
2446
- },
2844
+ byClientId: new Map(
2845
+ Object.entries( {
2846
+ block1: { name: 'core/test-block-b' },
2847
+ } )
2848
+ ),
2849
+ attributes: new Map(
2850
+ Object.entries( {
2851
+ block1: {},
2852
+ } )
2853
+ ),
2447
2854
  },
2448
2855
  blockListSettings: {
2449
2856
  block1: {
@@ -2460,12 +2867,16 @@ describe( 'selectors', () => {
2460
2867
  it( 'should deny blocks that restrict parent to core/post-content when not in editor root', () => {
2461
2868
  const state = {
2462
2869
  blocks: {
2463
- byClientId: {
2464
- block1: { name: 'core/test-block-c' },
2465
- },
2466
- attributes: {
2467
- block1: {},
2468
- },
2870
+ byClientId: new Map(
2871
+ Object.entries( {
2872
+ block1: { name: 'core/test-block-c' },
2873
+ } )
2874
+ ),
2875
+ attributes: new Map(
2876
+ Object.entries( {
2877
+ block1: {},
2878
+ } )
2879
+ ),
2469
2880
  },
2470
2881
  blockListSettings: {},
2471
2882
  settings: {},
@@ -2478,8 +2889,8 @@ describe( 'selectors', () => {
2478
2889
  it( 'should allow blocks that restrict parent to core/post-content when in editor root', () => {
2479
2890
  const state = {
2480
2891
  blocks: {
2481
- byClientId: {},
2482
- attributes: {},
2892
+ byClientId: new Map(),
2893
+ attributes: new Map(),
2483
2894
  },
2484
2895
  blockListSettings: {},
2485
2896
  settings: {},
@@ -2492,17 +2903,23 @@ describe( 'selectors', () => {
2492
2903
  it( 'should allow blocks to be inserted in a descendant of a required ancestor', () => {
2493
2904
  const state = {
2494
2905
  blocks: {
2495
- byClientId: {
2496
- block1: { name: 'core/test-block-ancestor' },
2497
- block2: { name: 'core/block' },
2498
- },
2499
- attributes: {
2500
- block1: {},
2501
- block2: {},
2502
- },
2503
- parents: {
2504
- block2: 'block1',
2505
- },
2906
+ byClientId: new Map(
2907
+ Object.entries( {
2908
+ block1: { name: 'core/test-block-ancestor' },
2909
+ block2: { name: 'core/block' },
2910
+ } )
2911
+ ),
2912
+ attributes: new Map(
2913
+ Object.entries( {
2914
+ block1: {},
2915
+ block2: {},
2916
+ } )
2917
+ ),
2918
+ parents: new Map(
2919
+ Object.entries( {
2920
+ block2: 'block1',
2921
+ } )
2922
+ ),
2506
2923
  },
2507
2924
  blockListSettings: {
2508
2925
  block1: {},
@@ -2522,20 +2939,26 @@ describe( 'selectors', () => {
2522
2939
  it( 'should allow blocks to be inserted if both parent and ancestor restrictions are met', () => {
2523
2940
  const state = {
2524
2941
  blocks: {
2525
- byClientId: {
2526
- block1: { name: 'core/test-block-ancestor' },
2527
- block2: { name: 'core/block' },
2528
- block3: { name: 'core/test-block-parent' },
2529
- },
2530
- attributes: {
2531
- block1: {},
2532
- block2: {},
2533
- block3: {},
2534
- },
2535
- parents: {
2536
- block2: 'block1',
2537
- block3: 'block2',
2538
- },
2942
+ byClientId: new Map(
2943
+ Object.entries( {
2944
+ block1: { name: 'core/test-block-ancestor' },
2945
+ block2: { name: 'core/block' },
2946
+ block3: { name: 'core/test-block-parent' },
2947
+ } )
2948
+ ),
2949
+ attributes: new Map(
2950
+ Object.entries( {
2951
+ block1: {},
2952
+ block2: {},
2953
+ block3: {},
2954
+ } )
2955
+ ),
2956
+ parents: new Map(
2957
+ Object.entries( {
2958
+ block2: 'block1',
2959
+ block3: 'block2',
2960
+ } )
2961
+ ),
2539
2962
  },
2540
2963
  blockListSettings: {
2541
2964
  block1: {},
@@ -2556,19 +2979,25 @@ describe( 'selectors', () => {
2556
2979
  it( 'should deny blocks from being inserted outside a required ancestor', () => {
2557
2980
  const state = {
2558
2981
  blocks: {
2559
- byClientId: {
2560
- block1: { name: 'core/test-block-ancestor' },
2561
- block2: { name: 'core/block' },
2562
- block3: { name: 'core/block' },
2563
- },
2564
- attributes: {
2565
- block1: {},
2566
- block2: {},
2567
- block3: {},
2568
- },
2569
- parents: {
2570
- block3: 'block2',
2571
- },
2982
+ byClientId: new Map(
2983
+ Object.entries( {
2984
+ block1: { name: 'core/test-block-ancestor' },
2985
+ block2: { name: 'core/block' },
2986
+ block3: { name: 'core/block' },
2987
+ } )
2988
+ ),
2989
+ attributes: new Map(
2990
+ Object.entries( {
2991
+ block1: {},
2992
+ block2: {},
2993
+ block3: {},
2994
+ } )
2995
+ ),
2996
+ parents: new Map(
2997
+ Object.entries( {
2998
+ block3: 'block2',
2999
+ } )
3000
+ ),
2572
3001
  },
2573
3002
  blockListSettings: {
2574
3003
  block1: {},
@@ -2589,19 +3018,25 @@ describe( 'selectors', () => {
2589
3018
  it( 'should deny blocks from being inserted outside of a required ancestor, even if parent matches', () => {
2590
3019
  const state = {
2591
3020
  blocks: {
2592
- byClientId: {
2593
- block1: { name: 'core/test-block-ancestor' },
2594
- block2: { name: 'core/block' },
2595
- block3: { name: 'core/test-block-parent' },
2596
- },
2597
- attributes: {
2598
- block1: {},
2599
- block2: {},
2600
- block3: {},
2601
- },
2602
- parents: {
2603
- block3: 'block2',
2604
- },
3021
+ byClientId: new Map(
3022
+ Object.entries( {
3023
+ block1: { name: 'core/test-block-ancestor' },
3024
+ block2: { name: 'core/block' },
3025
+ block3: { name: 'core/test-block-parent' },
3026
+ } )
3027
+ ),
3028
+ attributes: new Map(
3029
+ Object.entries( {
3030
+ block1: {},
3031
+ block2: {},
3032
+ block3: {},
3033
+ } )
3034
+ ),
3035
+ parents: new Map(
3036
+ Object.entries( {
3037
+ block3: 'block2',
3038
+ } )
3039
+ ),
2605
3040
  },
2606
3041
  blockListSettings: {
2607
3042
  block1: {},
@@ -2622,17 +3057,23 @@ describe( 'selectors', () => {
2622
3057
  it( 'should deny blocks from being inserted inside ancestor if parent restricts allowedBlocks', () => {
2623
3058
  const state = {
2624
3059
  blocks: {
2625
- byClientId: {
2626
- block1: { name: 'core/test-block-ancestor' },
2627
- block2: { name: 'core/block' },
2628
- },
2629
- attributes: {
2630
- block1: {},
2631
- block2: {},
2632
- },
2633
- parents: {
2634
- block2: 'block1',
2635
- },
3060
+ byClientId: new Map(
3061
+ Object.entries( {
3062
+ block1: { name: 'core/test-block-ancestor' },
3063
+ block2: { name: 'core/block' },
3064
+ } )
3065
+ ),
3066
+ attributes: new Map(
3067
+ Object.entries( {
3068
+ block1: {},
3069
+ block2: {},
3070
+ } )
3071
+ ),
3072
+ parents: new Map(
3073
+ Object.entries( {
3074
+ block2: 'block1',
3075
+ } )
3076
+ ),
2636
3077
  },
2637
3078
  blockListSettings: {
2638
3079
  block1: {},
@@ -2654,17 +3095,23 @@ describe( 'selectors', () => {
2654
3095
  it( 'should deny blocks from being inserted inside ancestor if parent restriction is not met', () => {
2655
3096
  const state = {
2656
3097
  blocks: {
2657
- byClientId: {
2658
- block1: { name: 'core/test-block-ancestor' },
2659
- block2: { name: 'core/block' },
2660
- },
2661
- attributes: {
2662
- block1: {},
2663
- block2: {},
2664
- },
2665
- parents: {
2666
- block2: 'block1',
2667
- },
3098
+ byClientId: new Map(
3099
+ Object.entries( {
3100
+ block1: { name: 'core/test-block-ancestor' },
3101
+ block2: { name: 'core/block' },
3102
+ } )
3103
+ ),
3104
+ attributes: new Map(
3105
+ Object.entries( {
3106
+ block1: {},
3107
+ block2: {},
3108
+ } )
3109
+ ),
3110
+ parents: new Map(
3111
+ Object.entries( {
3112
+ block2: 'block1',
3113
+ } )
3114
+ ),
2668
3115
  },
2669
3116
  blockListSettings: {
2670
3117
  block1: {},
@@ -2686,16 +3133,20 @@ describe( 'selectors', () => {
2686
3133
  it( 'should allow blocks', () => {
2687
3134
  const state = {
2688
3135
  blocks: {
2689
- byClientId: {
2690
- 1: { name: 'core/test-block-a' },
2691
- 2: { name: 'core/test-block-b' },
2692
- 3: { name: 'core/test-block-c' },
2693
- },
2694
- attributes: {
2695
- 1: {},
2696
- 2: {},
2697
- 3: {},
2698
- },
3136
+ byClientId: new Map(
3137
+ Object.entries( {
3138
+ 1: { name: 'core/test-block-a' },
3139
+ 2: { name: 'core/test-block-b' },
3140
+ 3: { name: 'core/test-block-c' },
3141
+ } )
3142
+ ),
3143
+ attributes: new Map(
3144
+ Object.entries( {
3145
+ 1: {},
3146
+ 2: {},
3147
+ 3: {},
3148
+ } )
3149
+ ),
2699
3150
  },
2700
3151
  blockListSettings: {
2701
3152
  1: {
@@ -2713,16 +3164,20 @@ describe( 'selectors', () => {
2713
3164
  it( 'should deny blocks', () => {
2714
3165
  const state = {
2715
3166
  blocks: {
2716
- byClientId: {
2717
- 1: { name: 'core/test-block-a' },
2718
- 2: { name: 'core/test-block-b' },
2719
- 3: { name: 'core/test-block-c' },
2720
- },
2721
- attributes: {
2722
- 1: {},
2723
- 2: {},
2724
- 3: {},
2725
- },
3167
+ byClientId: new Map(
3168
+ Object.entries( {
3169
+ 1: { name: 'core/test-block-a' },
3170
+ 2: { name: 'core/test-block-b' },
3171
+ 3: { name: 'core/test-block-c' },
3172
+ } )
3173
+ ),
3174
+ attributes: new Map(
3175
+ Object.entries( {
3176
+ 1: {},
3177
+ 2: {},
3178
+ 3: {},
3179
+ } )
3180
+ ),
2726
3181
  },
2727
3182
  blockListSettings: {
2728
3183
  1: {
@@ -2739,15 +3194,17 @@ describe( 'selectors', () => {
2739
3194
  it( 'should properly list block type and reusable block items', () => {
2740
3195
  const state = {
2741
3196
  blocks: {
2742
- byClientId: {},
2743
- attributes: {},
2744
- order: {},
2745
- parents: {},
2746
- tree: {
2747
- '': {
2748
- innerBlocks: [],
2749
- },
2750
- },
3197
+ byClientId: new Map(),
3198
+ attributes: new Map(),
3199
+ order: new Map(),
3200
+ parents: new Map(),
3201
+ tree: new Map(
3202
+ Object.entries( {
3203
+ '': {
3204
+ innerBlocks: [],
3205
+ },
3206
+ } )
3207
+ ),
2751
3208
  },
2752
3209
  settings: {
2753
3210
  __experimentalReusableBlocks: [
@@ -2808,35 +3265,45 @@ describe( 'selectors', () => {
2808
3265
  it( 'should correctly cache the return values', () => {
2809
3266
  const state = {
2810
3267
  blocks: {
2811
- byClientId: {
2812
- block3: { name: 'core/test-block-a' },
2813
- block4: { name: 'core/test-block-a' },
2814
- },
2815
- attributes: {
2816
- block3: {},
2817
- block4: {},
2818
- },
2819
- order: {
2820
- '': [ 'block3', 'block4' ],
2821
- },
2822
- parents: {
2823
- block3: '',
2824
- block4: '',
2825
- },
2826
- tree: {
2827
- block3: {
2828
- clientId: 'block3',
2829
- name: 'core/test-block-a',
2830
- attributes: {},
2831
- innerBlocks: [],
2832
- },
2833
- block4: {
2834
- clientId: 'block4',
2835
- name: 'core/test-block-a',
2836
- attributes: {},
2837
- innerBlocks: [],
2838
- },
2839
- },
3268
+ byClientId: new Map(
3269
+ Object.entries( {
3270
+ block3: { name: 'core/test-block-a' },
3271
+ block4: { name: 'core/test-block-a' },
3272
+ } )
3273
+ ),
3274
+ attributes: new Map(
3275
+ Object.entries( {
3276
+ block3: {},
3277
+ block4: {},
3278
+ } )
3279
+ ),
3280
+ order: new Map(
3281
+ Object.entries( {
3282
+ '': [ 'block3', 'block4' ],
3283
+ } )
3284
+ ),
3285
+ parents: new Map(
3286
+ Object.entries( {
3287
+ block3: '',
3288
+ block4: '',
3289
+ } )
3290
+ ),
3291
+ tree: new Map(
3292
+ Object.entries( {
3293
+ block3: {
3294
+ clientId: 'block3',
3295
+ name: 'core/test-block-a',
3296
+ attributes: {},
3297
+ innerBlocks: [],
3298
+ },
3299
+ block4: {
3300
+ clientId: 'block4',
3301
+ name: 'core/test-block-a',
3302
+ attributes: {},
3303
+ innerBlocks: [],
3304
+ },
3305
+ } )
3306
+ ),
2840
3307
  controlledInnerBlocks: {},
2841
3308
  },
2842
3309
  settings: {
@@ -2915,28 +3382,36 @@ describe( 'selectors', () => {
2915
3382
  it( 'should set isDisabled when a block with `multiple: false` has been used', () => {
2916
3383
  const state = {
2917
3384
  blocks: {
2918
- byClientId: {
2919
- block1: {
2920
- clientId: 'block1',
2921
- name: 'core/test-block-b',
2922
- },
2923
- },
2924
- attributes: {
2925
- block1: { attribute: {} },
2926
- },
2927
- order: {
2928
- '': [ 'block1' ],
2929
- },
2930
- tree: {
2931
- block1: {
2932
- clientId: 'block1',
2933
- name: 'core/test-block-b',
2934
- attributes: {},
2935
- innerBlocks: [],
2936
- },
2937
- },
3385
+ byClientId: new Map(
3386
+ Object.entries( {
3387
+ block1: {
3388
+ clientId: 'block1',
3389
+ name: 'core/test-block-b',
3390
+ },
3391
+ } )
3392
+ ),
3393
+ attributes: new Map(
3394
+ Object.entries( {
3395
+ block1: { attribute: {} },
3396
+ } )
3397
+ ),
3398
+ order: new Map(
3399
+ Object.entries( {
3400
+ '': [ 'block1' ],
3401
+ } )
3402
+ ),
3403
+ tree: new Map(
3404
+ Object.entries( {
3405
+ block1: {
3406
+ clientId: 'block1',
3407
+ name: 'core/test-block-b',
3408
+ attributes: {},
3409
+ innerBlocks: [],
3410
+ },
3411
+ } )
3412
+ ),
2938
3413
  controlledInnerBlocks: {},
2939
- parents: {},
3414
+ parents: new Map(),
2940
3415
  },
2941
3416
  preferences: {
2942
3417
  insertUsage: {},
@@ -2954,10 +3429,10 @@ describe( 'selectors', () => {
2954
3429
  it( 'should set a frecency', () => {
2955
3430
  const state = {
2956
3431
  blocks: {
2957
- byClientId: {},
2958
- attributes: {},
2959
- order: {},
2960
- parents: {},
3432
+ byClientId: new Map(),
3433
+ attributes: new Map(),
3434
+ order: new Map(),
3435
+ parents: new Map(),
2961
3436
  cache: {},
2962
3437
  },
2963
3438
  preferences: {
@@ -3049,10 +3524,10 @@ describe( 'selectors', () => {
3049
3524
  it( 'should properly return block type items', () => {
3050
3525
  const state = {
3051
3526
  blocks: {
3052
- byClientId: {},
3053
- attributes: {},
3054
- order: {},
3055
- parents: {},
3527
+ byClientId: new Map(),
3528
+ attributes: new Map(),
3529
+ order: new Map(),
3530
+ parents: new Map(),
3056
3531
  cache: {},
3057
3532
  },
3058
3533
  settings: {},
@@ -3089,10 +3564,10 @@ describe( 'selectors', () => {
3089
3564
  it( 'should support single block object', () => {
3090
3565
  const state = {
3091
3566
  blocks: {
3092
- byClientId: {},
3093
- attributes: {},
3094
- order: {},
3095
- parents: {},
3567
+ byClientId: new Map(),
3568
+ attributes: new Map(),
3569
+ order: new Map(),
3570
+ parents: new Map(),
3096
3571
  cache: {},
3097
3572
  },
3098
3573
  settings: {},
@@ -3106,19 +3581,25 @@ describe( 'selectors', () => {
3106
3581
  it( 'should return only eligible blocks for transformation - `allowedBlocks`', () => {
3107
3582
  const state = {
3108
3583
  blocks: {
3109
- byClientId: {
3110
- block1: { name: 'core/with-tranforms-b' },
3111
- block2: { name: 'core/with-tranforms-a' },
3112
- },
3113
- attributes: {
3114
- block1: {},
3115
- block2: {},
3116
- },
3117
- order: {},
3118
- parents: {
3119
- block1: '',
3120
- block2: 'block1',
3121
- },
3584
+ byClientId: new Map(
3585
+ Object.entries( {
3586
+ block1: { name: 'core/with-tranforms-b' },
3587
+ block2: { name: 'core/with-tranforms-a' },
3588
+ } )
3589
+ ),
3590
+ attributes: new Map(
3591
+ Object.entries( {
3592
+ block1: {},
3593
+ block2: {},
3594
+ } )
3595
+ ),
3596
+ order: new Map(),
3597
+ parents: new Map(
3598
+ Object.entries( {
3599
+ block1: '',
3600
+ block2: 'block1',
3601
+ } )
3602
+ ),
3122
3603
  cache: {},
3123
3604
  controlledInnerBlocks: {},
3124
3605
  },
@@ -3141,28 +3622,36 @@ describe( 'selectors', () => {
3141
3622
  it( 'should take into account the usage of blocks settings `multiple` - if multiple blocks of the same type are allowed', () => {
3142
3623
  const state = {
3143
3624
  blocks: {
3144
- byClientId: {
3145
- block1: {
3146
- clientId: 'block1',
3147
- name: 'core/with-tranforms-c',
3148
- },
3149
- },
3150
- attributes: {
3151
- block1: { attribute: {} },
3152
- },
3153
- order: {
3154
- '': [ 'block1' ],
3155
- },
3156
- tree: {
3157
- block1: {
3158
- clientId: 'block1',
3159
- name: 'core/with-tranforms-c',
3160
- attributes: {},
3161
- innerBlocks: [],
3162
- },
3163
- },
3625
+ byClientId: new Map(
3626
+ Object.entries( {
3627
+ block1: {
3628
+ clientId: 'block1',
3629
+ name: 'core/with-tranforms-c',
3630
+ },
3631
+ } )
3632
+ ),
3633
+ attributes: new Map(
3634
+ Object.entries( {
3635
+ block1: { attribute: {} },
3636
+ } )
3637
+ ),
3638
+ order: new Map(
3639
+ Object.entries( {
3640
+ '': [ 'block1' ],
3641
+ } )
3642
+ ),
3643
+ tree: new Map(
3644
+ Object.entries( {
3645
+ block1: {
3646
+ clientId: 'block1',
3647
+ name: 'core/with-tranforms-c',
3648
+ attributes: {},
3649
+ innerBlocks: [],
3650
+ },
3651
+ } )
3652
+ ),
3164
3653
  controlledInnerBlocks: {},
3165
- parents: {},
3654
+ parents: new Map(),
3166
3655
  },
3167
3656
  preferences: {
3168
3657
  insertUsage: {},
@@ -3189,10 +3678,10 @@ describe( 'selectors', () => {
3189
3678
  it( 'should set frecency', () => {
3190
3679
  const state = {
3191
3680
  blocks: {
3192
- byClientId: {},
3193
- attributes: {},
3194
- order: {},
3195
- parents: {},
3681
+ byClientId: new Map(),
3682
+ attributes: new Map(),
3683
+ order: new Map(),
3684
+ parents: new Map(),
3196
3685
  cache: {},
3197
3686
  },
3198
3687
  preferences: {
@@ -3245,7 +3734,7 @@ describe( 'selectors', () => {
3245
3734
  } );
3246
3735
 
3247
3736
  describe( 'getTemplateLock', () => {
3248
- it( 'should return the general template lock if no clientId was set', () => {
3737
+ it( 'should return the general template lock if no clientId was specified', () => {
3249
3738
  const state = {
3250
3739
  settings: { templateLock: 'all' },
3251
3740
  };
@@ -3253,7 +3742,7 @@ describe( 'selectors', () => {
3253
3742
  expect( getTemplateLock( state ) ).toBe( 'all' );
3254
3743
  } );
3255
3744
 
3256
- it( 'should return undefined if the specified clientId was not found', () => {
3745
+ it( 'should return false if the specified clientId was not found', () => {
3257
3746
  const state = {
3258
3747
  settings: { templateLock: 'all' },
3259
3748
  blockListSettings: {
@@ -3263,10 +3752,10 @@ describe( 'selectors', () => {
3263
3752
  },
3264
3753
  };
3265
3754
 
3266
- expect( getTemplateLock( state, 'ribs' ) ).toBe( undefined );
3755
+ expect( getTemplateLock( state, 'ribs' ) ).toBe( false );
3267
3756
  } );
3268
3757
 
3269
- it( 'should return undefined if template lock was not set on the specified block', () => {
3758
+ it( 'should return false if template lock was not set on the specified block', () => {
3270
3759
  const state = {
3271
3760
  settings: { templateLock: 'all' },
3272
3761
  blockListSettings: {
@@ -3276,7 +3765,7 @@ describe( 'selectors', () => {
3276
3765
  },
3277
3766
  };
3278
3767
 
3279
- expect( getTemplateLock( state, 'ribs' ) ).toBe( undefined );
3768
+ expect( getTemplateLock( state, 'chicken' ) ).toBe( false );
3280
3769
  } );
3281
3770
 
3282
3771
  it( 'should return the template lock for the specified clientId', () => {
@@ -3410,20 +3899,24 @@ describe( 'selectors', () => {
3410
3899
 
3411
3900
  describe( 'getLowestCommonAncestorWithSelectedBlock', () => {
3412
3901
  const blocks = {
3413
- order: {
3414
- '': [ 'a', 'b' ],
3415
- a: [ 'c', 'd' ],
3416
- d: [ 'e' ],
3417
- b: [ 'f' ],
3418
- },
3419
- parents: {
3420
- a: '',
3421
- b: '',
3422
- c: 'a',
3423
- d: 'a',
3424
- e: 'd',
3425
- f: 'b',
3426
- },
3902
+ order: new Map(
3903
+ Object.entries( {
3904
+ '': [ 'a', 'b' ],
3905
+ a: [ 'c', 'd' ],
3906
+ d: [ 'e' ],
3907
+ b: [ 'f' ],
3908
+ } )
3909
+ ),
3910
+ parents: new Map(
3911
+ Object.entries( {
3912
+ a: '',
3913
+ b: '',
3914
+ c: 'a',
3915
+ d: 'a',
3916
+ e: 'd',
3917
+ f: 'b',
3918
+ } )
3919
+ ),
3427
3920
  };
3428
3921
 
3429
3922
  it( 'should not be defined if there is no block selected', () => {
@@ -3522,35 +4015,39 @@ describe( 'selectors', () => {
3522
4015
  },
3523
4016
  },
3524
4017
  blocks: {
3525
- parents: {
3526
- 'client-id-01': '',
3527
- 'client-id-02': 'client-id-01',
3528
- 'client-id-03': 'client-id-02',
3529
- 'client-id-04': 'client-id-03',
3530
- 'client-id-05': 'client-id-03',
3531
- },
3532
- byClientId: {
3533
- 'client-id-01': {
3534
- clientId: 'client-id-01',
3535
- name: 'core/columns',
3536
- },
3537
- 'client-id-02': {
3538
- clientId: 'client-id-02',
3539
- name: 'core/navigation',
3540
- },
3541
- 'client-id-03': {
3542
- clientId: 'client-id-03',
3543
- name: 'core/navigation-link',
3544
- },
3545
- 'client-id-04': {
3546
- clientId: 'client-id-04',
3547
- name: 'core/navigation-link',
3548
- },
3549
- 'client-id-05': {
3550
- clientId: 'client-id-05',
3551
- name: 'core/navigation-link',
3552
- },
3553
- },
4018
+ parents: new Map(
4019
+ Object.entries( {
4020
+ 'client-id-01': '',
4021
+ 'client-id-02': 'client-id-01',
4022
+ 'client-id-03': 'client-id-02',
4023
+ 'client-id-04': 'client-id-03',
4024
+ 'client-id-05': 'client-id-03',
4025
+ } )
4026
+ ),
4027
+ byClientId: new Map(
4028
+ Object.entries( {
4029
+ 'client-id-01': {
4030
+ clientId: 'client-id-01',
4031
+ name: 'core/columns',
4032
+ },
4033
+ 'client-id-02': {
4034
+ clientId: 'client-id-02',
4035
+ name: 'core/navigation',
4036
+ },
4037
+ 'client-id-03': {
4038
+ clientId: 'client-id-03',
4039
+ name: 'core/navigation-link',
4040
+ },
4041
+ 'client-id-04': {
4042
+ clientId: 'client-id-04',
4043
+ name: 'core/navigation-link',
4044
+ },
4045
+ 'client-id-05': {
4046
+ clientId: 'client-id-05',
4047
+ name: 'core/navigation-link',
4048
+ },
4049
+ } )
4050
+ ),
3554
4051
  cache: {
3555
4052
  'client-id-01': {},
3556
4053
  'client-id-02': {},
@@ -3558,9 +4055,11 @@ describe( 'selectors', () => {
3558
4055
  'client-id-04': {},
3559
4056
  'client-id-05': {},
3560
4057
  },
3561
- order: {
3562
- 'client-id-03': [ 'client-id-04', 'client-id-05' ],
3563
- },
4058
+ order: new Map(
4059
+ Object.entries( {
4060
+ 'client-id-03': [ 'client-id-04', 'client-id-05' ],
4061
+ } )
4062
+ ),
3564
4063
  controlledInnerBlocks: {},
3565
4064
  },
3566
4065
  };
@@ -3592,14 +4091,18 @@ describe( 'selectors', () => {
3592
4091
  describe( '__experimentalGetAllowedPatterns', () => {
3593
4092
  const state = {
3594
4093
  blocks: {
3595
- byClientId: {
3596
- block1: { name: 'core/test-block-a' },
3597
- block2: { name: 'core/test-block-b' },
3598
- },
3599
- attributes: {
3600
- block1: {},
3601
- block2: {},
3602
- },
4094
+ byClientId: new Map(
4095
+ Object.entries( {
4096
+ block1: { name: 'core/test-block-a' },
4097
+ block2: { name: 'core/test-block-b' },
4098
+ } )
4099
+ ),
4100
+ attributes: new Map(
4101
+ Object.entries( {
4102
+ block1: {},
4103
+ block2: {},
4104
+ } )
4105
+ ),
3603
4106
  },
3604
4107
  blockListSettings: {
3605
4108
  block1: {
@@ -3651,7 +4154,7 @@ describe( 'selectors', () => {
3651
4154
  it( 'should return empty array if only patterns hidden from UI exist', () => {
3652
4155
  expect(
3653
4156
  __experimentalGetAllowedPatterns( {
3654
- blocks: { byClientId: {} },
4157
+ blocks: { byClientId: new Map() },
3655
4158
  blockListSettings: {},
3656
4159
  settings: {
3657
4160
  __experimentalBlockPatterns: [
@@ -3723,9 +4226,11 @@ describe( 'selectors', () => {
3723
4226
  describe( '__experimentalGetPatternsByBlockTypes', () => {
3724
4227
  const state = {
3725
4228
  blocks: {
3726
- byClientId: {
3727
- block1: { name: 'core/test-block-a' },
3728
- },
4229
+ byClientId: new Map(
4230
+ Object.entries( {
4231
+ block1: { name: 'core/test-block-a' },
4232
+ } )
4233
+ ),
3729
4234
  },
3730
4235
  blockListSettings: {
3731
4236
  block1: {
@@ -3797,10 +4302,12 @@ describe( 'selectors', () => {
3797
4302
  describe( '__experimentalGetPatternTransformItems', () => {
3798
4303
  const state = {
3799
4304
  blocks: {
3800
- byClientId: {
3801
- block1: { name: 'core/test-block-a' },
3802
- block2: { name: 'core/test-block-b' },
3803
- },
4305
+ byClientId: new Map(
4306
+ Object.entries( {
4307
+ block1: { name: 'core/test-block-a' },
4308
+ block2: { name: 'core/test-block-b' },
4309
+ } )
4310
+ ),
3804
4311
  controlledInnerBlocks: { 'block2-clientId': true },
3805
4312
  },
3806
4313
  blockListSettings: {
@@ -4054,10 +4561,10 @@ describe( 'getInserterItems with core blocks prioritization', () => {
4054
4561
  it( 'should prioritize core blocks by sorting them at the top of the returned list', () => {
4055
4562
  const state = {
4056
4563
  blocks: {
4057
- byClientId: {},
4058
- attributes: {},
4059
- order: {},
4060
- parents: {},
4564
+ byClientId: new Map(),
4565
+ attributes: new Map(),
4566
+ order: new Map(),
4567
+ parents: new Map(),
4061
4568
  cache: {},
4062
4569
  },
4063
4570
  settings: {},
@@ -4085,11 +4592,13 @@ describe( '__unstableGetClientIdWithClientIdsTree', () => {
4085
4592
  it( "should return a stripped down block object containing only its client ID and its inner blocks' client IDs", () => {
4086
4593
  const state = {
4087
4594
  blocks: {
4088
- order: {
4089
- '': [ 'foo' ],
4090
- foo: [ 'bar', 'baz' ],
4091
- bar: [ 'qux' ],
4092
- },
4595
+ order: new Map(
4596
+ Object.entries( {
4597
+ '': [ 'foo' ],
4598
+ foo: [ 'bar', 'baz' ],
4599
+ bar: [ 'qux' ],
4600
+ } )
4601
+ ),
4093
4602
  },
4094
4603
  };
4095
4604
 
@@ -4111,11 +4620,13 @@ describe( '__unstableGetClientIdsTree', () => {
4111
4620
  it( "should return the full content tree starting from the given root, consisting of stripped down block object containing only its client ID and its inner blocks' client IDs", () => {
4112
4621
  const state = {
4113
4622
  blocks: {
4114
- order: {
4115
- '': [ 'foo' ],
4116
- foo: [ 'bar', 'baz' ],
4117
- bar: [ 'qux' ],
4118
- },
4623
+ order: new Map(
4624
+ Object.entries( {
4625
+ '': [ 'foo' ],
4626
+ foo: [ 'bar', 'baz' ],
4627
+ bar: [ 'qux' ],
4628
+ } )
4629
+ ),
4119
4630
  },
4120
4631
  };
4121
4632
 
@@ -4131,11 +4642,13 @@ describe( '__unstableGetClientIdsTree', () => {
4131
4642
  it( "should return the full content tree starting from the root, consisting of stripped down block object containing only its client ID and its inner blocks' client IDs", () => {
4132
4643
  const state = {
4133
4644
  blocks: {
4134
- order: {
4135
- '': [ 'foo' ],
4136
- foo: [ 'bar', 'baz' ],
4137
- bar: [ 'qux' ],
4138
- },
4645
+ order: new Map(
4646
+ Object.entries( {
4647
+ '': [ 'foo' ],
4648
+ foo: [ 'bar', 'baz' ],
4649
+ bar: [ 'qux' ],
4650
+ } )
4651
+ ),
4139
4652
  },
4140
4653
  };
4141
4654
 
@@ -4153,3 +4666,23 @@ describe( '__unstableGetClientIdsTree', () => {
4153
4666
  ] );
4154
4667
  } );
4155
4668
  } );
4669
+
4670
+ describe( 'getLastInsertedBlockClientId', () => {
4671
+ it( 'should return undefined if no blocks have been inserted', () => {
4672
+ const state = {
4673
+ lastBlockInserted: {},
4674
+ };
4675
+
4676
+ expect( getLastInsertedBlockClientId( state ) ).toEqual( undefined );
4677
+ } );
4678
+
4679
+ it( 'should return clientId if blocks have been inserted', () => {
4680
+ const state = {
4681
+ lastBlockInserted: {
4682
+ clientId: '123456',
4683
+ },
4684
+ };
4685
+
4686
+ expect( getLastInsertedBlockClientId( state ) ).toEqual( '123456' );
4687
+ } );
4688
+ } );