@wordpress/block-editor 10.5.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 (488) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/build/autocompleters/block.js +2 -6
  3. package/build/autocompleters/block.js.map +1 -1
  4. package/build/autocompleters/link.js +2 -0
  5. package/build/autocompleters/link.js.map +1 -1
  6. package/build/components/block-card/index.js +51 -3
  7. package/build/components/block-card/index.js.map +1 -1
  8. package/build/components/block-draggable/index.native.js +46 -39
  9. package/build/components/block-draggable/index.native.js.map +1 -1
  10. package/build/components/block-edit/edit.js +4 -3
  11. package/build/components/block-edit/edit.js.map +1 -1
  12. package/build/components/block-edit/edit.native.js +4 -7
  13. package/build/components/block-edit/edit.native.js.map +1 -1
  14. package/build/components/block-inspector/index.js +35 -33
  15. package/build/components/block-inspector/index.js.map +1 -1
  16. package/build/components/block-list/block-list-context.native.js +5 -8
  17. package/build/components/block-list/block-list-context.native.js.map +1 -1
  18. package/build/components/block-list/block.js +55 -24
  19. package/build/components/block-list/block.js.map +1 -1
  20. package/build/components/block-list/block.native.js +61 -28
  21. package/build/components/block-list/block.native.js.map +1 -1
  22. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +12 -4
  23. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  24. package/build/components/block-pattern-setup/index.js +3 -2
  25. package/build/components/block-pattern-setup/index.js.map +1 -1
  26. package/build/components/block-patterns-list/index.js +33 -11
  27. package/build/components/block-patterns-list/index.js.map +1 -1
  28. package/build/components/block-preview/auto.js +9 -3
  29. package/build/components/block-preview/auto.js.map +1 -1
  30. package/build/components/block-preview/index.js +5 -9
  31. package/build/components/block-preview/index.js.map +1 -1
  32. package/build/components/block-settings-menu/block-settings-dropdown.js +5 -2
  33. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  34. package/build/components/block-toolbar/index.js +5 -1
  35. package/build/components/block-toolbar/index.js.map +1 -1
  36. package/build/components/block-tools/insertion-point.js +8 -49
  37. package/build/components/block-tools/insertion-point.js.map +1 -1
  38. package/build/components/block-variation-picker/index.js +1 -2
  39. package/build/components/block-variation-picker/index.js.map +1 -1
  40. package/build/components/height-control/index.js +115 -0
  41. package/build/components/height-control/index.js.map +1 -0
  42. package/build/components/iframe/index.js +11 -8
  43. package/build/components/iframe/index.js.map +1 -1
  44. package/build/components/image-editor/use-save-image.js +2 -0
  45. package/build/components/image-editor/use-save-image.js.map +1 -1
  46. package/build/components/image-editor/zoom-dropdown.js +1 -0
  47. package/build/components/image-editor/zoom-dropdown.js.map +1 -1
  48. package/build/components/index.js +9 -0
  49. package/build/components/index.js.map +1 -1
  50. package/build/components/inner-blocks/index.js +20 -6
  51. package/build/components/inner-blocks/index.js.map +1 -1
  52. package/build/components/inner-blocks/use-inner-block-template-sync.js +25 -10
  53. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  54. package/build/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  55. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  56. package/build/components/inserter/block-patterns-tab.js +25 -46
  57. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  58. package/build/components/inserter/block-types-tab.js +3 -1
  59. package/build/components/inserter/block-types-tab.js.map +1 -1
  60. package/build/components/inserter/hooks/use-debounced-input.js +27 -0
  61. package/build/components/inserter/hooks/use-debounced-input.js.map +1 -0
  62. package/build/components/inserter/index.js +8 -3
  63. package/build/components/inserter/index.js.map +1 -1
  64. package/build/components/inserter/index.native.js +3 -4
  65. package/build/components/inserter/index.native.js.map +1 -1
  66. package/build/components/inserter/media-tab/hooks.js +103 -0
  67. package/build/components/inserter/media-tab/hooks.js.map +1 -0
  68. package/build/components/inserter/media-tab/index.js +32 -0
  69. package/build/components/inserter/media-tab/index.js.map +1 -0
  70. package/build/components/inserter/media-tab/media-list.js +100 -0
  71. package/build/components/inserter/media-tab/media-list.js.map +1 -0
  72. package/build/components/inserter/media-tab/media-panel.js +96 -0
  73. package/build/components/inserter/media-tab/media-panel.js.map +1 -0
  74. package/build/components/inserter/media-tab/media-tab.js +120 -0
  75. package/build/components/inserter/media-tab/media-tab.js.map +1 -0
  76. package/build/components/inserter/media-tab/utils.js +54 -0
  77. package/build/components/inserter/media-tab/utils.js.map +1 -0
  78. package/build/components/inserter/menu.js +35 -12
  79. package/build/components/inserter/menu.js.map +1 -1
  80. package/build/components/inserter/mobile-tab-navigation.js +70 -0
  81. package/build/components/inserter/mobile-tab-navigation.js.map +1 -0
  82. package/build/components/inserter/quick-inserter.js +1 -0
  83. package/build/components/inserter/quick-inserter.js.map +1 -1
  84. package/build/components/inserter/search-results.js +3 -1
  85. package/build/components/inserter/search-results.js.map +1 -1
  86. package/build/components/inserter/tabs.js +16 -2
  87. package/build/components/inserter/tabs.js.map +1 -1
  88. package/build/components/inserter-list-item/index.js +4 -1
  89. package/build/components/inserter-list-item/index.js.map +1 -1
  90. package/build/components/inspector-controls/groups.js +2 -0
  91. package/build/components/inspector-controls/groups.js.map +1 -1
  92. package/build/components/inspector-controls-tabs/advanced-controls-panel.js +46 -0
  93. package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
  94. package/build/components/inspector-controls-tabs/index.js +71 -0
  95. package/build/components/inspector-controls-tabs/index.js.map +1 -0
  96. package/build/components/inspector-controls-tabs/settings-tab.js +28 -0
  97. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -0
  98. package/build/components/inspector-controls-tabs/styles-tab.js +61 -0
  99. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -0
  100. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +97 -0
  101. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
  102. package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +18 -0
  103. package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
  104. package/build/components/inspector-controls-tabs/utils.js +37 -0
  105. package/build/components/inspector-controls-tabs/utils.js.map +1 -0
  106. package/build/components/link-control/index.js +1 -0
  107. package/build/components/link-control/index.js.map +1 -1
  108. package/build/components/link-control/search-input.js +0 -1
  109. package/build/components/link-control/search-input.js.map +1 -1
  110. package/build/components/link-control/use-internal-input-value.js +3 -3
  111. package/build/components/link-control/use-internal-input-value.js.map +1 -1
  112. package/build/components/list-view/block.js +5 -2
  113. package/build/components/list-view/block.js.map +1 -1
  114. package/build/components/list-view/branch.js +13 -12
  115. package/build/components/list-view/branch.js.map +1 -1
  116. package/build/components/media-upload/index.native.js +2 -3
  117. package/build/components/media-upload/index.native.js.map +1 -1
  118. package/build/components/off-canvas-editor/appender.js +104 -0
  119. package/build/components/off-canvas-editor/appender.js.map +1 -0
  120. package/build/components/off-canvas-editor/block-edit-button.js +50 -0
  121. package/build/components/off-canvas-editor/block-edit-button.js.map +1 -0
  122. package/build/components/off-canvas-editor/block.js +36 -4
  123. package/build/components/off-canvas-editor/block.js.map +1 -1
  124. package/build/components/off-canvas-editor/branch.js +3 -5
  125. package/build/components/off-canvas-editor/branch.js.map +1 -1
  126. package/build/components/off-canvas-editor/index.js +20 -11
  127. package/build/components/off-canvas-editor/index.js.map +1 -1
  128. package/build/components/off-canvas-editor/leaf.js +1 -1
  129. package/build/components/off-canvas-editor/leaf.js.map +1 -1
  130. package/build/components/off-canvas-editor/link-ui.js +185 -0
  131. package/build/components/off-canvas-editor/link-ui.js.map +1 -0
  132. package/build/components/off-canvas-editor/update-attributes.js +108 -0
  133. package/build/components/off-canvas-editor/update-attributes.js.map +1 -0
  134. package/build/components/rich-text/format-toolbar/index.js +8 -4
  135. package/build/components/rich-text/format-toolbar/index.js.map +1 -1
  136. package/build/components/rich-text/index.js +3 -3
  137. package/build/components/rich-text/index.js.map +1 -1
  138. package/build/components/rich-text/index.native.js +0 -2
  139. package/build/components/rich-text/index.native.js.map +1 -1
  140. package/build/components/rich-text/use-insert-replacement-text.js +43 -0
  141. package/build/components/rich-text/use-insert-replacement-text.js.map +1 -0
  142. package/build/components/rich-text/use-undo-automatic-change.js +9 -1
  143. package/build/components/rich-text/use-undo-automatic-change.js.map +1 -1
  144. package/build/components/rich-text/utils.js +1 -19
  145. package/build/components/rich-text/utils.js.map +1 -1
  146. package/build/components/spacing-sizes-control/spacing-input-control.js +12 -3
  147. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  148. package/build/components/ungroup-button/index.native.js +4 -2
  149. package/build/components/ungroup-button/index.native.js.map +1 -1
  150. package/build/components/url-input/index.js +46 -43
  151. package/build/components/url-input/index.js.map +1 -1
  152. package/build/components/use-block-display-information/index.js +8 -4
  153. package/build/components/use-block-display-information/index.js.map +1 -1
  154. package/build/components/use-setting/index.js +9 -1
  155. package/build/components/use-setting/index.js.map +1 -1
  156. package/build/hooks/child-layout.js +209 -0
  157. package/build/hooks/child-layout.js.map +1 -0
  158. package/build/hooks/content-lock-ui.js +1 -1
  159. package/build/hooks/content-lock-ui.js.map +1 -1
  160. package/build/hooks/dimensions.js +25 -7
  161. package/build/hooks/dimensions.js.map +1 -1
  162. package/build/hooks/layout.js +57 -1
  163. package/build/hooks/layout.js.map +1 -1
  164. package/build/hooks/min-height.js +4 -10
  165. package/build/hooks/min-height.js.map +1 -1
  166. package/build/store/reducer.js +393 -270
  167. package/build/store/reducer.js.map +1 -1
  168. package/build/store/selectors.js +57 -47
  169. package/build/store/selectors.js.map +1 -1
  170. package/build/utils/sorting.js +63 -0
  171. package/build/utils/sorting.js.map +1 -0
  172. package/build-module/autocompleters/block.js +2 -6
  173. package/build-module/autocompleters/block.js.map +1 -1
  174. package/build-module/autocompleters/link.js +2 -0
  175. package/build-module/autocompleters/link.js.map +1 -1
  176. package/build-module/components/block-card/index.js +45 -3
  177. package/build-module/components/block-card/index.js.map +1 -1
  178. package/build-module/components/block-draggable/index.native.js +40 -31
  179. package/build-module/components/block-draggable/index.native.js.map +1 -1
  180. package/build-module/components/block-edit/edit.js +4 -2
  181. package/build-module/components/block-edit/edit.js.map +1 -1
  182. package/build-module/components/block-edit/edit.native.js +4 -6
  183. package/build-module/components/block-edit/edit.native.js.map +1 -1
  184. package/build-module/components/block-inspector/index.js +32 -30
  185. package/build-module/components/block-inspector/index.js.map +1 -1
  186. package/build-module/components/block-list/block-list-context.native.js +5 -8
  187. package/build-module/components/block-list/block-list-context.native.js.map +1 -1
  188. package/build-module/components/block-list/block.js +55 -25
  189. package/build-module/components/block-list/block.js.map +1 -1
  190. package/build-module/components/block-list/block.native.js +61 -28
  191. package/build-module/components/block-list/block.native.js.map +1 -1
  192. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +13 -6
  193. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  194. package/build-module/components/block-pattern-setup/index.js +3 -2
  195. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  196. package/build-module/components/block-patterns-list/index.js +35 -13
  197. package/build-module/components/block-patterns-list/index.js.map +1 -1
  198. package/build-module/components/block-preview/auto.js +9 -3
  199. package/build-module/components/block-preview/auto.js.map +1 -1
  200. package/build-module/components/block-preview/index.js +5 -8
  201. package/build-module/components/block-preview/index.js.map +1 -1
  202. package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -2
  203. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  204. package/build-module/components/block-toolbar/index.js +6 -2
  205. package/build-module/components/block-toolbar/index.js.map +1 -1
  206. package/build-module/components/block-tools/insertion-point.js +8 -49
  207. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  208. package/build-module/components/block-variation-picker/index.js +1 -2
  209. package/build-module/components/block-variation-picker/index.js.map +1 -1
  210. package/build-module/components/height-control/index.js +103 -0
  211. package/build-module/components/height-control/index.js.map +1 -0
  212. package/build-module/components/iframe/index.js +11 -8
  213. package/build-module/components/iframe/index.js.map +1 -1
  214. package/build-module/components/image-editor/use-save-image.js +2 -0
  215. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  216. package/build-module/components/image-editor/zoom-dropdown.js +1 -0
  217. package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
  218. package/build-module/components/index.js +1 -0
  219. package/build-module/components/index.js.map +1 -1
  220. package/build-module/components/inner-blocks/index.js +22 -8
  221. package/build-module/components/inner-blocks/index.js.map +1 -1
  222. package/build-module/components/inner-blocks/use-inner-block-template-sync.js +23 -10
  223. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  224. package/build-module/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  225. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  226. package/build-module/components/inserter/block-patterns-tab.js +27 -49
  227. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  228. package/build-module/components/inserter/block-types-tab.js +3 -2
  229. package/build-module/components/inserter/block-types-tab.js.map +1 -1
  230. package/build-module/components/inserter/hooks/use-debounced-input.js +18 -0
  231. package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -0
  232. package/build-module/components/inserter/index.js +8 -3
  233. package/build-module/components/inserter/index.js.map +1 -1
  234. package/build-module/components/inserter/index.native.js +3 -5
  235. package/build-module/components/inserter/index.native.js.map +1 -1
  236. package/build-module/components/inserter/media-tab/hooks.js +89 -0
  237. package/build-module/components/inserter/media-tab/hooks.js.map +1 -0
  238. package/build-module/components/inserter/media-tab/index.js +4 -0
  239. package/build-module/components/inserter/media-tab/index.js.map +1 -0
  240. package/build-module/components/inserter/media-tab/media-list.js +86 -0
  241. package/build-module/components/inserter/media-tab/media-list.js.map +1 -0
  242. package/build-module/components/inserter/media-tab/media-panel.js +77 -0
  243. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -0
  244. package/build-module/components/inserter/media-tab/media-tab.js +100 -0
  245. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -0
  246. package/build-module/components/inserter/media-tab/utils.js +45 -0
  247. package/build-module/components/inserter/media-tab/utils.js.map +1 -0
  248. package/build-module/components/inserter/menu.js +33 -12
  249. package/build-module/components/inserter/menu.js.map +1 -1
  250. package/build-module/components/inserter/mobile-tab-navigation.js +61 -0
  251. package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -0
  252. package/build-module/components/inserter/quick-inserter.js +1 -0
  253. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  254. package/build-module/components/inserter/search-results.js +3 -2
  255. package/build-module/components/inserter/search-results.js.map +1 -1
  256. package/build-module/components/inserter/tabs.js +15 -2
  257. package/build-module/components/inserter/tabs.js.map +1 -1
  258. package/build-module/components/inserter-list-item/index.js +5 -2
  259. package/build-module/components/inserter-list-item/index.js.map +1 -1
  260. package/build-module/components/inspector-controls/groups.js +2 -0
  261. package/build-module/components/inspector-controls/groups.js.map +1 -1
  262. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +32 -0
  263. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
  264. package/build-module/components/inspector-controls-tabs/index.js +56 -0
  265. package/build-module/components/inspector-controls-tabs/index.js.map +1 -0
  266. package/build-module/components/inspector-controls-tabs/settings-tab.js +17 -0
  267. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -0
  268. package/build-module/components/inspector-controls-tabs/styles-tab.js +46 -0
  269. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -0
  270. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +81 -0
  271. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
  272. package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +8 -0
  273. package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
  274. package/build-module/components/inspector-controls-tabs/utils.js +26 -0
  275. package/build-module/components/inspector-controls-tabs/utils.js.map +1 -0
  276. package/build-module/components/link-control/index.js +1 -0
  277. package/build-module/components/link-control/index.js.map +1 -1
  278. package/build-module/components/link-control/search-input.js +0 -1
  279. package/build-module/components/link-control/search-input.js.map +1 -1
  280. package/build-module/components/link-control/use-internal-input-value.js +3 -3
  281. package/build-module/components/link-control/use-internal-input-value.js.map +1 -1
  282. package/build-module/components/list-view/block.js +5 -2
  283. package/build-module/components/list-view/block.js.map +1 -1
  284. package/build-module/components/list-view/branch.js +12 -11
  285. package/build-module/components/list-view/branch.js.map +1 -1
  286. package/build-module/components/media-upload/index.native.js +2 -4
  287. package/build-module/components/media-upload/index.native.js.map +1 -1
  288. package/build-module/components/off-canvas-editor/appender.js +89 -0
  289. package/build-module/components/off-canvas-editor/appender.js.map +1 -0
  290. package/build-module/components/off-canvas-editor/block-edit-button.js +35 -0
  291. package/build-module/components/off-canvas-editor/block-edit-button.js.map +1 -0
  292. package/build-module/components/off-canvas-editor/block.js +36 -6
  293. package/build-module/components/off-canvas-editor/block.js.map +1 -1
  294. package/build-module/components/off-canvas-editor/branch.js +3 -4
  295. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  296. package/build-module/components/off-canvas-editor/index.js +20 -12
  297. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  298. package/build-module/components/off-canvas-editor/leaf.js +1 -1
  299. package/build-module/components/off-canvas-editor/leaf.js.map +1 -1
  300. package/build-module/components/off-canvas-editor/link-ui.js +165 -0
  301. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -0
  302. package/build-module/components/off-canvas-editor/update-attributes.js +97 -0
  303. package/build-module/components/off-canvas-editor/update-attributes.js.map +1 -0
  304. package/build-module/components/rich-text/format-toolbar/index.js +6 -2
  305. package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
  306. package/build-module/components/rich-text/index.js +2 -3
  307. package/build-module/components/rich-text/index.js.map +1 -1
  308. package/build-module/components/rich-text/index.native.js +0 -2
  309. package/build-module/components/rich-text/index.native.js.map +1 -1
  310. package/build-module/components/rich-text/use-insert-replacement-text.js +33 -0
  311. package/build-module/components/rich-text/use-insert-replacement-text.js.map +1 -0
  312. package/build-module/components/rich-text/use-undo-automatic-change.js +9 -1
  313. package/build-module/components/rich-text/use-undo-automatic-change.js.map +1 -1
  314. package/build-module/components/rich-text/utils.js +1 -16
  315. package/build-module/components/rich-text/utils.js.map +1 -1
  316. package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -3
  317. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  318. package/build-module/components/ungroup-button/index.native.js +3 -2
  319. package/build-module/components/ungroup-button/index.native.js.map +1 -1
  320. package/build-module/components/url-input/index.js +46 -43
  321. package/build-module/components/url-input/index.js.map +1 -1
  322. package/build-module/components/use-block-display-information/index.js +9 -5
  323. package/build-module/components/use-block-display-information/index.js.map +1 -1
  324. package/build-module/components/use-setting/index.js +8 -1
  325. package/build-module/components/use-setting/index.js.map +1 -1
  326. package/build-module/hooks/child-layout.js +189 -0
  327. package/build-module/hooks/child-layout.js.map +1 -0
  328. package/build-module/hooks/content-lock-ui.js +1 -1
  329. package/build-module/hooks/content-lock-ui.js.map +1 -1
  330. package/build-module/hooks/dimensions.js +25 -8
  331. package/build-module/hooks/dimensions.js.map +1 -1
  332. package/build-module/hooks/layout.js +55 -0
  333. package/build-module/hooks/layout.js.map +1 -1
  334. package/build-module/hooks/min-height.js +3 -9
  335. package/build-module/hooks/min-height.js.map +1 -1
  336. package/build-module/store/reducer.js +391 -271
  337. package/build-module/store/reducer.js.map +1 -1
  338. package/build-module/store/selectors.js +54 -47
  339. package/build-module/store/selectors.js.map +1 -1
  340. package/build-module/utils/sorting.js +56 -0
  341. package/build-module/utils/sorting.js.map +1 -0
  342. package/build-style/content-rtl.css +701 -0
  343. package/build-style/content.css +701 -0
  344. package/build-style/default-editor-styles-rtl.css +14 -0
  345. package/build-style/default-editor-styles.css +14 -0
  346. package/build-style/style-rtl.css +286 -662
  347. package/build-style/style.css +286 -662
  348. package/package.json +32 -30
  349. package/src/autocompleters/block.js +2 -6
  350. package/src/autocompleters/link.js +2 -0
  351. package/src/components/alignment-control/test/index.js +4 -1
  352. package/src/components/block-alignment-control/test/index.js +4 -1
  353. package/src/components/block-card/index.js +46 -2
  354. package/src/components/block-card/style.scss +4 -0
  355. package/src/components/block-content-overlay/{style.scss → content.scss} +7 -1
  356. package/src/components/block-draggable/content.scss +20 -0
  357. package/src/components/block-draggable/index.native.js +54 -40
  358. package/src/components/block-draggable/style.scss +0 -21
  359. package/src/components/block-draggable/test/helpers.native.js +7 -9
  360. package/src/components/block-draggable/test/index.native.js +35 -45
  361. package/src/components/block-edit/edit.js +5 -2
  362. package/src/components/block-edit/edit.native.js +5 -6
  363. package/src/components/block-inspector/index.js +96 -81
  364. package/src/components/block-inspector/style.scss +9 -1
  365. package/src/components/block-list/block-list-context.native.js +5 -8
  366. package/src/components/block-list/block.js +74 -23
  367. package/src/components/block-list/block.native.js +78 -23
  368. package/src/components/block-list/{style.scss → content.scss} +1 -15
  369. package/src/components/block-list-appender/{style.scss → content.scss} +0 -0
  370. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +24 -6
  371. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -2
  372. package/src/components/block-pattern-setup/index.js +2 -1
  373. package/src/components/block-patterns-list/index.js +47 -24
  374. package/src/components/block-preview/README.md +15 -10
  375. package/src/components/block-preview/auto.js +7 -1
  376. package/src/components/block-preview/content.scss +4 -0
  377. package/src/components/block-preview/index.js +7 -12
  378. package/src/components/block-preview/style.scss +0 -7
  379. package/src/components/block-preview/test/index.js +18 -35
  380. package/src/components/block-selection-clearer/test/index.js +12 -12
  381. package/src/components/block-settings-menu/block-settings-dropdown.js +32 -20
  382. package/src/components/block-switcher/test/index.js +4 -0
  383. package/src/components/block-toolbar/index.js +12 -5
  384. package/src/components/block-toolbar/style.scss +10 -0
  385. package/src/components/block-tools/insertion-point.js +3 -47
  386. package/src/components/block-tools/style.scss +12 -5
  387. package/src/components/block-variation-picker/index.js +1 -4
  388. package/src/components/block-vertical-alignment-control/test/index.js +4 -1
  389. package/src/components/default-block-appender/{style.scss → content.scss} +0 -0
  390. package/src/components/height-control/index.js +123 -0
  391. package/src/components/height-control/stories/index.js +21 -0
  392. package/src/components/height-control/style.scss +5 -0
  393. package/src/components/iframe/index.js +25 -18
  394. package/src/components/image-editor/use-save-image.js +2 -0
  395. package/src/components/image-editor/zoom-dropdown.js +1 -0
  396. package/src/components/index.js +1 -0
  397. package/src/components/inner-blocks/{style.scss → content.scss} +0 -0
  398. package/src/components/inner-blocks/index.js +23 -6
  399. package/src/components/inner-blocks/use-inner-block-template-sync.js +28 -10
  400. package/src/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  401. package/src/components/inserter/block-patterns-tab.js +28 -71
  402. package/src/components/inserter/block-types-tab.js +3 -2
  403. package/src/components/inserter/hooks/use-debounced-input.js +17 -0
  404. package/src/components/inserter/index.js +10 -2
  405. package/src/components/inserter/index.native.js +1 -1
  406. package/src/components/inserter/media-tab/hooks.js +88 -0
  407. package/src/components/inserter/media-tab/index.js +3 -0
  408. package/src/components/inserter/media-tab/media-list.js +93 -0
  409. package/src/components/inserter/media-tab/media-panel.js +83 -0
  410. package/src/components/inserter/media-tab/media-tab.js +135 -0
  411. package/src/components/inserter/media-tab/utils.js +37 -0
  412. package/src/components/inserter/menu.js +55 -13
  413. package/src/components/inserter/mobile-tab-navigation.js +85 -0
  414. package/src/components/inserter/quick-inserter.js +1 -0
  415. package/src/components/inserter/search-results.js +3 -2
  416. package/src/components/inserter/stories/index.js +1 -1
  417. package/src/components/inserter/stories/{fixtures.js → utils/fixtures.js} +0 -0
  418. package/src/components/inserter/style.scss +176 -11
  419. package/src/components/inserter/tabs.js +12 -1
  420. package/src/components/inserter-list-item/index.js +11 -1
  421. package/src/components/inserter-list-item/style.scss +26 -0
  422. package/src/components/inspector-controls/groups.js +2 -0
  423. package/src/components/inspector-controls-tabs/advanced-controls-panel.js +37 -0
  424. package/src/components/inspector-controls-tabs/index.js +62 -0
  425. package/src/components/inspector-controls-tabs/settings-tab.js +18 -0
  426. package/src/components/inspector-controls-tabs/styles-tab.js +51 -0
  427. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +89 -0
  428. package/src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +9 -0
  429. package/src/components/inspector-controls-tabs/utils.js +28 -0
  430. package/src/components/line-height-control/test/index.js +5 -5
  431. package/src/components/link-control/README.md +1 -1
  432. package/src/components/link-control/index.js +1 -0
  433. package/src/components/link-control/search-input.js +0 -1
  434. package/src/components/link-control/test/index.js +188 -401
  435. package/src/components/link-control/use-internal-input-value.js +3 -3
  436. package/src/components/list-view/block.js +3 -0
  437. package/src/components/list-view/branch.js +10 -8
  438. package/src/components/list-view/style.scss +20 -9
  439. package/src/components/media-placeholder/{style.scss → content.scss} +0 -0
  440. package/src/components/media-replace-flow/test/index.js +37 -9
  441. package/src/components/media-upload/test/index.native.js +2 -0
  442. package/src/components/off-canvas-editor/appender.js +93 -0
  443. package/src/components/off-canvas-editor/block-edit-button.js +27 -0
  444. package/src/components/off-canvas-editor/block.js +88 -22
  445. package/src/components/off-canvas-editor/branch.js +3 -5
  446. package/src/components/off-canvas-editor/index.js +59 -33
  447. package/src/components/off-canvas-editor/leaf.js +5 -1
  448. package/src/components/off-canvas-editor/link-ui.js +166 -0
  449. package/src/components/off-canvas-editor/style.scss +17 -388
  450. package/src/components/off-canvas-editor/update-attributes.js +99 -0
  451. package/src/components/plain-text/{style.scss → content.scss} +0 -0
  452. package/src/components/recursion-provider/test/index.js +27 -29
  453. package/src/components/rich-text/content.scss +42 -0
  454. package/src/components/rich-text/format-toolbar/index.js +6 -4
  455. package/src/components/rich-text/index.js +2 -2
  456. package/src/components/rich-text/index.native.js +0 -2
  457. package/src/components/rich-text/style.scss +0 -43
  458. package/src/components/rich-text/use-insert-replacement-text.js +31 -0
  459. package/src/components/rich-text/use-undo-automatic-change.js +7 -1
  460. package/src/components/rich-text/utils.js +2 -21
  461. package/src/components/spacing-sizes-control/spacing-input-control.js +9 -0
  462. package/src/components/ungroup-button/index.native.js +6 -2
  463. package/src/components/url-input/index.js +57 -73
  464. package/src/components/url-popover/test/__snapshots__/index.js.snap +8 -6
  465. package/src/components/url-popover/test/index.js +21 -9
  466. package/src/components/use-block-display-information/index.js +14 -5
  467. package/src/components/use-setting/index.js +13 -1
  468. package/src/components/use-setting/test/index.js +99 -0
  469. package/src/content.scss +10 -0
  470. package/src/hooks/child-layout.js +190 -0
  471. package/src/hooks/content-lock-ui.js +1 -1
  472. package/src/hooks/dimensions.js +45 -7
  473. package/src/hooks/layout.js +60 -0
  474. package/src/hooks/min-height.js +2 -19
  475. package/src/store/reducer.js +459 -423
  476. package/src/store/selectors.js +56 -57
  477. package/src/store/test/performance.js +71 -0
  478. package/src/store/test/reducer.js +623 -491
  479. package/src/store/test/selectors.js +1820 -1306
  480. package/src/style.scss +4 -7
  481. package/src/utils/sorting.js +54 -0
  482. package/src/utils/test/sorting.js +49 -0
  483. package/tsconfig.tsbuildinfo +1 -1
  484. package/build/components/block-preview/live.js +0 -30
  485. package/build/components/block-preview/live.js.map +0 -1
  486. package/build-module/components/block-preview/live.js +0 -20
  487. package/build-module/components/block-preview/live.js.map +0 -1
  488. package/src/components/block-preview/live.js +0 -19
@@ -73,6 +73,7 @@ const {
73
73
  __experimentalGetPatternTransformItems,
74
74
  wasBlockJustInserted,
75
75
  __experimentalGetGlobalBlocksByName,
76
+ getLastInsertedBlockClientId,
76
77
  } = selectors;
77
78
 
78
79
  describe( 'selectors', () => {
@@ -202,10 +203,10 @@ describe( 'selectors', () => {
202
203
  it( 'returns null if no block by clientId', () => {
203
204
  const state = {
204
205
  blocks: {
205
- byClientId: {},
206
+ byClientId: new Map(),
206
207
  attributes: {},
207
- order: {},
208
- parents: {},
208
+ order: new Map(),
209
+ parents: new Map(),
209
210
  },
210
211
  };
211
212
 
@@ -220,22 +221,31 @@ describe( 'selectors', () => {
220
221
  it( 'returns block name', () => {
221
222
  const state = {
222
223
  blocks: {
223
- byClientId: {
224
- 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1': {
225
- clientId: 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1',
226
- name: 'core/paragraph',
227
- },
228
- },
229
- attributes: {
230
- 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1': {},
231
- },
232
- order: {
233
- '': [ 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1' ],
234
- 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1': [],
235
- },
236
- parents: {
237
- 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1': '',
238
- },
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
+ ),
239
249
  },
240
250
  };
241
251
 
@@ -252,54 +262,68 @@ describe( 'selectors', () => {
252
262
  it( 'should return the block', () => {
253
263
  const state = {
254
264
  blocks: {
255
- byClientId: {
256
- 123: { clientId: 123, name: 'core/paragraph' },
257
- },
258
- attributes: {
259
- 123: {},
260
- },
261
- order: {
262
- '': [ 123 ],
263
- 123: [],
264
- },
265
- parents: {
266
- 123: '',
267
- },
268
- tree: {
269
- 123: {
270
- clientId: 123,
271
- name: 'core/paragraph',
272
- attributes: {},
273
- innerBlocks: [],
274
- },
275
- },
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
+ ),
276
296
  controlledInnerBlocks: {},
277
297
  },
278
298
  };
279
299
 
280
- expect( getBlock( state, 123 ) ).toBe( state.blocks.tree[ 123 ] );
300
+ expect( getBlock( state, '123' ) ).toBe(
301
+ state.blocks.tree.get( '123' )
302
+ );
281
303
  } );
282
304
 
283
305
  it( 'should return null if the block is not present in state', () => {
284
306
  const state = {
285
307
  blocks: {
286
- byClientId: {},
287
- attributes: {},
288
- order: {},
289
- parents: {},
290
- tree: {
291
- 123: {
292
- clientId: 123,
293
- name: 'core/paragraph',
294
- attributes: {},
295
- innerBlocks: [],
296
- },
297
- },
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
+ ),
298
322
  controlledInnerBlocks: {},
299
323
  },
300
324
  };
301
325
 
302
- expect( getBlock( state, 123 ) ).toBe( null );
326
+ expect( getBlock( state, '123' ) ).toBe( null );
303
327
  } );
304
328
  } );
305
329
 
@@ -307,47 +331,57 @@ describe( 'selectors', () => {
307
331
  it( 'should return the ordered blocks', () => {
308
332
  const state = {
309
333
  blocks: {
310
- byClientId: {
311
- 23: { clientId: 23, name: 'core/heading' },
312
- 123: { clientId: 123, name: 'core/paragraph' },
313
- },
314
- attributes: {
315
- 23: {},
316
- 123: {},
317
- },
318
- order: {
319
- '': [ 123, 23 ],
320
- },
321
- parents: {
322
- 123: '',
323
- 23: '',
324
- },
325
- tree: {
326
- '': {
327
- innerBlocks: [
328
- {
329
- clientId: 123,
330
- name: 'core/paragraph',
331
- attributes: {},
332
- innerBlocks: [],
333
- },
334
- {
335
- clientId: 23,
336
- name: 'core/heading',
337
- attributes: {},
338
- innerBlocks: [],
339
- },
340
- ],
341
- },
342
- 123: {},
343
- 23: {},
344
- },
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
+ ),
345
379
  controlledInnerBlocks: {},
346
380
  },
347
381
  };
348
382
 
349
383
  expect( getBlocks( state ) ).toBe(
350
- state.blocks.tree[ '' ].innerBlocks
384
+ state.blocks.tree.get( '' ).innerBlocks
351
385
  );
352
386
  } );
353
387
  } );
@@ -356,30 +390,34 @@ describe( 'selectors', () => {
356
390
  it( 'should return parent blocks', () => {
357
391
  const state = {
358
392
  blocks: {
359
- parents: {
360
- 'client-id-01': '',
361
- 'client-id-02': 'client-id-01',
362
- 'client-id-03': 'client-id-02',
363
- 'client-id-04': 'client-id-03',
364
- },
365
- byClientId: {
366
- 'client-id-01': {
367
- clientId: 'client-id-01',
368
- name: 'core/columns',
369
- },
370
- 'client-id-02': {
371
- clientId: 'client-id-02',
372
- name: 'core/navigation',
373
- },
374
- 'client-id-03': {
375
- clientId: 'client-id-03',
376
- name: 'core/navigation-link',
377
- },
378
- 'client-id-04': {
379
- clientId: 'client-id-04',
380
- name: 'core/paragraph',
381
- },
382
- },
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
+ ),
383
421
  cache: {
384
422
  'client-id-01': {},
385
423
  'client-id-02': {},
@@ -403,35 +441,39 @@ describe( 'selectors', () => {
403
441
  describe( 'getBlockParentsByBlockName', () => {
404
442
  const state = {
405
443
  blocks: {
406
- parents: {
407
- 'client-id-01': '',
408
- 'client-id-02': 'client-id-01',
409
- 'client-id-03': 'client-id-02',
410
- 'client-id-04': 'client-id-03',
411
- 'client-id-05': 'client-id-04',
412
- },
413
- byClientId: {
414
- 'client-id-01': {
415
- clientId: 'client-id-01',
416
- name: 'core/navigation',
417
- },
418
- 'client-id-02': {
419
- clientId: 'client-id-02',
420
- name: 'core/columns',
421
- },
422
- 'client-id-03': {
423
- clientId: 'client-id-03',
424
- name: 'core/navigation',
425
- },
426
- 'client-id-04': {
427
- clientId: 'client-id-04',
428
- name: 'core/navigation-link',
429
- },
430
- 'client-id-05': {
431
- clientId: 'client-id-05',
432
- name: 'core/navigation-link',
433
- },
434
- },
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
+ ),
435
477
  cache: {
436
478
  'client-id-01': {},
437
479
  'client-id-02': {},
@@ -487,89 +529,124 @@ describe( 'selectors', () => {
487
529
  it( 'should return the ids of any descendants in sequential order, given an array of clientIds', () => {
488
530
  const state = {
489
531
  blocks: {
490
- byClientId: {
491
- 'uuid-2': { clientId: 'uuid-2', name: 'core/image' },
492
- 'uuid-4': {
493
- clientId: 'uuid-4',
494
- name: 'core/paragraph',
495
- },
496
- 'uuid-6': {
497
- clientId: 'uuid-6',
498
- name: 'core/paragraph',
499
- },
500
- 'uuid-8': { clientId: 'uuid-8', name: 'core/block' },
501
- 'uuid-10': {
502
- clientId: 'uuid-10',
503
- name: 'core/columns',
504
- },
505
- 'uuid-12': { clientId: 'uuid-12', name: 'core/column' },
506
- 'uuid-14': { clientId: 'uuid-14', name: 'core/column' },
507
- 'uuid-16': { clientId: 'uuid-16', name: 'core/quote' },
508
- 'uuid-18': { clientId: 'uuid-18', name: 'core/block' },
509
- 'uuid-20': {
510
- clientId: 'uuid-20',
511
- name: 'core/gallery',
512
- },
513
- 'uuid-22': { clientId: 'uuid-22', name: 'core/block' },
514
- 'uuid-24': {
515
- clientId: 'uuid-24',
516
- name: 'core/columns',
517
- },
518
- 'uuid-26': { clientId: 'uuid-26', name: 'core/column' },
519
- 'uuid-28': { clientId: 'uuid-28', name: 'core/column' },
520
- 'uuid-30': {
521
- clientId: 'uuid-30',
522
- name: 'core/paragraph',
523
- },
524
- },
525
- attributes: {
526
- 'uuid-2': {},
527
- 'uuid-4': {},
528
- 'uuid-6': {},
529
- 'uuid-8': {},
530
- 'uuid-10': {},
531
- 'uuid-12': {},
532
- 'uuid-14': {},
533
- 'uuid-16': {},
534
- 'uuid-18': {},
535
- 'uuid-20': {},
536
- 'uuid-22': {},
537
- 'uuid-24': {},
538
- 'uuid-26': {},
539
- 'uuid-28': {},
540
- 'uuid-30': {},
541
- },
542
- order: {
543
- '': [ 'uuid-6', 'uuid-8', 'uuid-10', 'uuid-22' ],
544
- 'uuid-2': [],
545
- 'uuid-4': [],
546
- 'uuid-6': [],
547
- 'uuid-8': [],
548
- 'uuid-10': [ 'uuid-12', 'uuid-14' ],
549
- 'uuid-12': [ 'uuid-16' ],
550
- 'uuid-14': [ 'uuid-18' ],
551
- 'uuid-16': [],
552
- 'uuid-18': [ 'uuid-24' ],
553
- 'uuid-20': [],
554
- 'uuid-22': [],
555
- 'uuid-24': [ 'uuid-26', 'uuid-28' ],
556
- 'uuid-26': [],
557
- 'uuid-28': [ 'uuid-30' ],
558
- },
559
- parents: {
560
- 'uuid-6': '',
561
- 'uuid-8': '',
562
- 'uuid-10': '',
563
- 'uuid-22': '',
564
- 'uuid-12': 'uuid-10',
565
- 'uuid-14': 'uuid-10',
566
- 'uuid-16': 'uuid-12',
567
- 'uuid-18': 'uuid-14',
568
- 'uuid-24': 'uuid-18',
569
- 'uuid-26': 'uuid-24',
570
- 'uuid-28': 'uuid-24',
571
- 'uuid-30': 'uuid-28',
572
- },
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
+ ),
573
650
  controlledInnerBlocks: {},
574
651
  },
575
652
  };
@@ -592,89 +669,124 @@ describe( 'selectors', () => {
592
669
  it( 'should return the ids for top-level blocks and their descendants of any depth (for nested blocks) in sequential order.', () => {
593
670
  const state = {
594
671
  blocks: {
595
- byClientId: {
596
- 'uuid-2': { clientId: 'uuid-2', name: 'core/image' },
597
- 'uuid-4': {
598
- clientId: 'uuid-4',
599
- name: 'core/paragraph',
600
- },
601
- 'uuid-6': {
602
- clientId: 'uuid-6',
603
- name: 'core/paragraph',
604
- },
605
- 'uuid-8': { clientId: 'uuid-8', name: 'core/block' },
606
- 'uuid-10': {
607
- clientId: 'uuid-10',
608
- name: 'core/columns',
609
- },
610
- 'uuid-12': { clientId: 'uuid-12', name: 'core/column' },
611
- 'uuid-14': { clientId: 'uuid-14', name: 'core/column' },
612
- 'uuid-16': { clientId: 'uuid-16', name: 'core/quote' },
613
- 'uuid-18': { clientId: 'uuid-18', name: 'core/block' },
614
- 'uuid-20': {
615
- clientId: 'uuid-20',
616
- name: 'core/gallery',
617
- },
618
- 'uuid-22': { clientId: 'uuid-22', name: 'core/block' },
619
- 'uuid-24': {
620
- clientId: 'uuid-24',
621
- name: 'core/columns',
622
- },
623
- 'uuid-26': { clientId: 'uuid-26', name: 'core/column' },
624
- 'uuid-28': { clientId: 'uuid-28', name: 'core/column' },
625
- 'uuid-30': {
626
- clientId: 'uuid-30',
627
- name: 'core/paragraph',
628
- },
629
- },
630
- attributes: {
631
- 'uuid-2': {},
632
- 'uuid-4': {},
633
- 'uuid-6': {},
634
- 'uuid-8': {},
635
- 'uuid-10': {},
636
- 'uuid-12': {},
637
- 'uuid-14': {},
638
- 'uuid-16': {},
639
- 'uuid-18': {},
640
- 'uuid-20': {},
641
- 'uuid-22': {},
642
- 'uuid-24': {},
643
- 'uuid-26': {},
644
- 'uuid-28': {},
645
- 'uuid-30': {},
646
- },
647
- order: {
648
- '': [ 'uuid-6', 'uuid-8', 'uuid-10', 'uuid-22' ],
649
- 'uuid-2': [],
650
- 'uuid-4': [],
651
- 'uuid-6': [],
652
- 'uuid-8': [],
653
- 'uuid-10': [ 'uuid-12', 'uuid-14' ],
654
- 'uuid-12': [ 'uuid-16' ],
655
- 'uuid-14': [ 'uuid-18' ],
656
- 'uuid-16': [],
657
- 'uuid-18': [ 'uuid-24' ],
658
- 'uuid-20': [],
659
- 'uuid-22': [],
660
- 'uuid-24': [ 'uuid-26', 'uuid-28' ],
661
- 'uuid-26': [],
662
- 'uuid-28': [ 'uuid-30' ],
663
- },
664
- parents: {
665
- 'uuid-6': '',
666
- 'uuid-8': '',
667
- 'uuid-10': '',
668
- 'uuid-22': '',
669
- 'uuid-12': 'uuid-10',
670
- 'uuid-14': 'uuid-10',
671
- 'uuid-16': 'uuid-12',
672
- 'uuid-18': 'uuid-14',
673
- 'uuid-24': 'uuid-18',
674
- 'uuid-26': 'uuid-24',
675
- 'uuid-28': 'uuid-24',
676
- 'uuid-30': 'uuid-28',
677
- },
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
+ ),
678
790
  },
679
791
  };
680
792
  expect( getClientIdsWithDescendants( state ) ).toEqual( [
@@ -698,17 +810,23 @@ describe( 'selectors', () => {
698
810
  it( 'should return the number of top-level blocks in the post', () => {
699
811
  const state = {
700
812
  blocks: {
701
- byClientId: {
702
- 23: { clientId: 23, name: 'core/heading' },
703
- 123: { clientId: 123, name: 'core/paragraph' },
704
- },
705
- attributes: {
706
- 23: {},
707
- 123: {},
708
- },
709
- order: {
710
- '': [ 123, 23 ],
711
- },
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
+ ),
712
830
  },
713
831
  };
714
832
 
@@ -718,25 +836,33 @@ describe( 'selectors', () => {
718
836
  it( 'should return the number of blocks in a nested context', () => {
719
837
  const state = {
720
838
  blocks: {
721
- byClientId: {
722
- 123: { clientId: 123, name: 'core/columns' },
723
- 456: { clientId: 456, name: 'core/paragraph' },
724
- 789: { clientId: 789, name: 'core/paragraph' },
725
- },
726
- attributes: {
727
- 123: {},
728
- 456: {},
729
- 789: {},
730
- },
731
- order: {
732
- '': [ 123 ],
733
- 123: [ 456, 789 ],
734
- },
735
- parents: {
736
- 123: '',
737
- 456: 123,
738
- 789: 123,
739
- },
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
+ ),
740
866
  },
741
867
  };
742
868
 
@@ -790,23 +916,31 @@ describe( 'selectors', () => {
790
916
  describe( 'getGlobalBlockCount', () => {
791
917
  const state = {
792
918
  blocks: {
793
- byClientId: {
794
- 123: { clientId: 123, name: 'core/heading' },
795
- 456: { clientId: 456, name: 'core/paragraph' },
796
- 789: { clientId: 789, name: 'core/paragraph' },
797
- },
798
- attributes: {
799
- 123: {},
800
- 456: {},
801
- 789: {},
802
- },
803
- order: {
804
- '': [ 123, 456 ],
805
- },
806
- parents: {
807
- 123: '',
808
- 456: '',
809
- },
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
+ ),
810
944
  },
811
945
  };
812
946
 
@@ -821,10 +955,10 @@ describe( 'selectors', () => {
821
955
  it( 'should return 0 if no blocks exist', () => {
822
956
  const emptyState = {
823
957
  blocks: {
824
- byClientId: {},
825
- attributes: {},
826
- order: {},
827
- parents: {},
958
+ byClientId: new Map(),
959
+ attributes: new Map(),
960
+ order: new Map(),
961
+ parents: new Map(),
828
962
  },
829
963
  };
830
964
  expect( getGlobalBlockCount( emptyState ) ).toBe( 0 );
@@ -837,46 +971,54 @@ describe( 'selectors', () => {
837
971
  describe( '__experimentalGetGlobalBlocksByName', () => {
838
972
  const state = {
839
973
  blocks: {
840
- byClientId: {
841
- 123: { clientId: 123, name: 'core/heading' },
842
- 456: { clientId: 456, name: 'core/paragraph' },
843
- 789: { clientId: 789, name: 'core/paragraph' },
844
- 1011: { clientId: 1011, name: 'core/group' },
845
- 1213: { clientId: 1213, name: 'core/paragraph' },
846
- 1415: { clientId: 1213, name: 'core/paragraph' },
847
- },
848
- attributes: {
849
- 123: {},
850
- 456: {},
851
- 789: {},
852
- 1011: {},
853
- 1213: {},
854
- 1415: {},
855
- },
856
- order: {
857
- '': [ 123, 456, 1011 ],
858
- 1011: [ 1415, 1213 ],
859
- },
860
- parents: {
861
- 123: '',
862
- 456: '',
863
- 1011: '',
864
- 1213: 1011,
865
- 1415: 1011,
866
- },
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
+ ),
867
1009
  },
868
1010
  };
869
1011
 
870
1012
  it( 'should return the clientIds of blocks of a given type', () => {
871
1013
  expect(
872
1014
  __experimentalGetGlobalBlocksByName( state, 'core/heading' )
873
- ).toStrictEqual( [ 123 ] );
1015
+ ).toStrictEqual( [ '123' ] );
874
1016
  } );
875
1017
 
876
1018
  it( 'should return the clientIds of blocks of a given type even if blocks are nested', () => {
877
1019
  expect(
878
1020
  __experimentalGetGlobalBlocksByName( state, 'core/paragraph' )
879
- ).toStrictEqual( [ 456, 1415, 1213 ] );
1021
+ ).toStrictEqual( [ '456', '1415', '1213' ] );
880
1022
  } );
881
1023
 
882
1024
  it( 'Should return empty array if no blocks match. The empty array should be the same reference', () => {
@@ -911,8 +1053,8 @@ describe( 'selectors', () => {
911
1053
  it( 'should return null if there is multi selection', () => {
912
1054
  const state = {
913
1055
  selection: {
914
- selectionStart: { clientId: 23 },
915
- selectionEnd: { clientId: 123 },
1056
+ selectionStart: { clientId: '23' },
1057
+ selectionEnd: { clientId: '123' },
916
1058
  },
917
1059
  };
918
1060
 
@@ -922,19 +1064,21 @@ describe( 'selectors', () => {
922
1064
  it( 'should return the selected block ClientId', () => {
923
1065
  const state = {
924
1066
  blocks: {
925
- byClientId: {
926
- 23: {
927
- name: 'fake block',
928
- },
929
- },
1067
+ byClientId: new Map(
1068
+ Object.entries( {
1069
+ 23: {
1070
+ name: 'fake block',
1071
+ },
1072
+ } )
1073
+ ),
930
1074
  },
931
1075
  selection: {
932
- selectionStart: { clientId: 23 },
933
- selectionEnd: { clientId: 23 },
1076
+ selectionStart: { clientId: '23' },
1077
+ selectionEnd: { clientId: '23' },
934
1078
  },
935
1079
  };
936
1080
 
937
- expect( getSelectedBlockClientId( state ) ).toEqual( 23 );
1081
+ expect( getSelectedBlockClientId( state ) ).toEqual( '23' );
938
1082
  } );
939
1083
  } );
940
1084
 
@@ -942,31 +1086,41 @@ describe( 'selectors', () => {
942
1086
  it( 'should return null if no block is selected', () => {
943
1087
  const state = {
944
1088
  blocks: {
945
- byClientId: {
946
- 23: { clientId: 23, name: 'core/heading' },
947
- 123: { clientId: 123, name: 'core/paragraph' },
948
- },
949
- attributes: {
950
- 23: {},
951
- 123: {},
952
- },
953
- order: {
954
- '': [ 23, 123 ],
955
- 23: [],
956
- 123: [],
957
- },
958
- parents: {
959
- 23: '',
960
- 123: '',
961
- },
962
- tree: {
963
- 23: {
964
- clientId: 23,
965
- name: 'core/heading',
966
- attributes: {},
967
- innerBlocks: [],
968
- },
969
- },
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
+ ),
970
1124
  },
971
1125
  selection: {
972
1126
  selectionStart: {},
@@ -980,35 +1134,45 @@ describe( 'selectors', () => {
980
1134
  it( 'should return null if there is multi selection', () => {
981
1135
  const state = {
982
1136
  blocks: {
983
- byClientId: {
984
- 23: { clientId: 23, name: 'core/heading' },
985
- 123: { clientId: 123, name: 'core/paragraph' },
986
- },
987
- attributes: {
988
- 23: {},
989
- 123: {},
990
- },
991
- order: {
992
- '': [ 23, 123 ],
993
- 23: [],
994
- 123: [],
995
- },
996
- parents: {
997
- 123: '',
998
- 23: '',
999
- },
1000
- tree: {
1001
- 23: {
1002
- clientId: 23,
1003
- name: 'core/heading',
1004
- attributes: {},
1005
- innerBlocks: [],
1006
- },
1007
- },
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
+ ),
1008
1172
  },
1009
1173
  selection: {
1010
- selectionStart: { clientId: 23 },
1011
- selectionEnd: { clientId: 123 },
1174
+ selectionStart: { clientId: '23' },
1175
+ selectionEnd: { clientId: '123' },
1012
1176
  },
1013
1177
  };
1014
1178
 
@@ -1018,41 +1182,51 @@ describe( 'selectors', () => {
1018
1182
  it( 'should return the selected block', () => {
1019
1183
  const state = {
1020
1184
  blocks: {
1021
- byClientId: {
1022
- 23: { clientId: 23, name: 'core/heading' },
1023
- 123: { clientId: 123, name: 'core/paragraph' },
1024
- },
1025
- attributes: {
1026
- 23: {},
1027
- 123: {},
1028
- },
1029
- order: {
1030
- '': [ 23, 123 ],
1031
- 23: [],
1032
- 123: [],
1033
- },
1034
- parents: {
1035
- 123: '',
1036
- 23: '',
1037
- },
1038
- tree: {
1039
- 23: {
1040
- clientId: 23,
1041
- name: 'core/heading',
1042
- attributes: {},
1043
- innerBlocks: [],
1044
- },
1045
- },
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
+ ),
1046
1220
  controlledInnerBlocks: {},
1047
1221
  },
1048
1222
  selection: {
1049
- selectionStart: { clientId: 23 },
1050
- selectionEnd: { clientId: 23 },
1223
+ selectionStart: { clientId: '23' },
1224
+ selectionEnd: { clientId: '23' },
1051
1225
  },
1052
1226
  };
1053
1227
 
1054
1228
  expect( getSelectedBlock( state ) ).toEqual(
1055
- getBlock( state, 23 )
1229
+ getBlock( state, '23' )
1056
1230
  );
1057
1231
  } );
1058
1232
  } );
@@ -1061,8 +1235,8 @@ describe( 'selectors', () => {
1061
1235
  it( 'should return null if the block does not exist', () => {
1062
1236
  const state = {
1063
1237
  blocks: {
1064
- order: {},
1065
- parents: {},
1238
+ order: new Map(),
1239
+ parents: new Map(),
1066
1240
  },
1067
1241
  };
1068
1242
 
@@ -1072,20 +1246,24 @@ describe( 'selectors', () => {
1072
1246
  it( 'should return root ClientId relative the block ClientId', () => {
1073
1247
  const state = {
1074
1248
  blocks: {
1075
- order: {
1076
- '': [ 123, 23 ],
1077
- 123: [ 456, 56 ],
1078
- },
1079
- parents: {
1080
- 123: '',
1081
- 23: '',
1082
- 456: 123,
1083
- 56: 123,
1084
- },
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
+ ),
1085
1263
  },
1086
1264
  };
1087
1265
 
1088
- expect( getBlockRootClientId( state, 56 ) ).toBe( 123 );
1266
+ expect( getBlockRootClientId( state, '56' ) ).toBe( '123' );
1089
1267
  } );
1090
1268
  } );
1091
1269
 
@@ -1093,8 +1271,8 @@ describe( 'selectors', () => {
1093
1271
  it( 'should return the given block if the block has no parents', () => {
1094
1272
  const state = {
1095
1273
  blocks: {
1096
- order: {},
1097
- parents: {},
1274
+ order: new Map(),
1275
+ parents: new Map(),
1098
1276
  },
1099
1277
  };
1100
1278
 
@@ -1104,16 +1282,20 @@ describe( 'selectors', () => {
1104
1282
  it( 'should return root ClientId relative the block ClientId', () => {
1105
1283
  const state = {
1106
1284
  blocks: {
1107
- order: {
1108
- '': [ 'a', 'b' ],
1109
- a: [ 'c', 'd' ],
1110
- },
1111
- parents: {
1112
- a: '',
1113
- b: '',
1114
- c: 'a',
1115
- d: 'a',
1116
- },
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
+ ),
1117
1299
  },
1118
1300
  };
1119
1301
 
@@ -1123,18 +1305,22 @@ describe( 'selectors', () => {
1123
1305
  it( 'should return the top level root ClientId relative the block ClientId', () => {
1124
1306
  const state = {
1125
1307
  blocks: {
1126
- order: {
1127
- '': [ 'a', 'b' ],
1128
- a: [ 'c', 'd' ],
1129
- d: [ 'e' ],
1130
- },
1131
- parents: {
1132
- a: '',
1133
- b: '',
1134
- c: 'a',
1135
- d: 'a',
1136
- e: 'd',
1137
- },
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
+ ),
1138
1324
  },
1139
1325
  };
1140
1326
 
@@ -1146,13 +1332,17 @@ describe( 'selectors', () => {
1146
1332
  it( 'should return empty if there is no selection', () => {
1147
1333
  const state = {
1148
1334
  blocks: {
1149
- order: {
1150
- '': [ 123, 23 ],
1151
- },
1152
- parents: {
1153
- 123: '',
1154
- 23: '',
1155
- },
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
+ ),
1156
1346
  },
1157
1347
  selection: {
1158
1348
  selectionStart: {},
@@ -1166,75 +1356,95 @@ describe( 'selectors', () => {
1166
1356
  it( 'should return the selected block clientId if there is a selection', () => {
1167
1357
  const state = {
1168
1358
  blocks: {
1169
- order: {
1170
- '': [ 5, 4, 3, 2, 1 ],
1171
- },
1172
- parents: {
1173
- 1: '',
1174
- 2: '',
1175
- 3: '',
1176
- 4: '',
1177
- 5: '',
1178
- },
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
+ ),
1179
1373
  },
1180
1374
  selection: {
1181
- selectionStart: { clientId: 2 },
1182
- selectionEnd: { clientId: 2 },
1375
+ selectionStart: { clientId: '2' },
1376
+ selectionEnd: { clientId: '2' },
1183
1377
  },
1184
1378
  };
1185
1379
 
1186
- expect( getSelectedBlockClientIds( state ) ).toEqual( [ 2 ] );
1380
+ expect( getSelectedBlockClientIds( state ) ).toEqual( [ '2' ] );
1187
1381
  } );
1188
1382
 
1189
1383
  it( 'should return selected block clientIds if there is multi selection', () => {
1190
1384
  const state = {
1191
1385
  blocks: {
1192
- order: {
1193
- '': [ 5, 4, 3, 2, 1 ],
1194
- },
1195
- parents: {
1196
- 1: '',
1197
- 2: '',
1198
- 3: '',
1199
- 4: '',
1200
- 5: '',
1201
- },
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
+ ),
1202
1400
  },
1203
1401
  selection: {
1204
- selectionStart: { clientId: 2 },
1205
- selectionEnd: { clientId: 4 },
1402
+ selectionStart: { clientId: '2' },
1403
+ selectionEnd: { clientId: '4' },
1206
1404
  },
1207
1405
  };
1208
1406
 
1209
- expect( getSelectedBlockClientIds( state ) ).toEqual( [ 4, 3, 2 ] );
1407
+ expect( getSelectedBlockClientIds( state ) ).toEqual( [
1408
+ '4',
1409
+ '3',
1410
+ '2',
1411
+ ] );
1210
1412
  } );
1211
1413
 
1212
1414
  it( 'should return selected block clientIds if there is multi selection (nested context)', () => {
1213
1415
  const state = {
1214
1416
  blocks: {
1215
- order: {
1216
- '': [ 5, 4, 3, 2, 1 ],
1217
- 4: [ 9, 8, 7, 6 ],
1218
- },
1219
- parents: {
1220
- 1: '',
1221
- 2: '',
1222
- 3: '',
1223
- 4: '',
1224
- 5: '',
1225
- 6: 4,
1226
- 7: 4,
1227
- 8: 4,
1228
- 9: 4,
1229
- },
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
+ ),
1230
1436
  },
1231
1437
  selection: {
1232
- selectionStart: { clientId: 7 },
1233
- selectionEnd: { clientId: 9 },
1438
+ selectionStart: { clientId: '7' },
1439
+ selectionEnd: { clientId: '9' },
1234
1440
  },
1235
1441
  };
1236
1442
 
1237
- expect( getSelectedBlockClientIds( state ) ).toEqual( [ 9, 8, 7 ] );
1443
+ expect( getSelectedBlockClientIds( state ) ).toEqual( [
1444
+ '9',
1445
+ '8',
1446
+ '7',
1447
+ ] );
1238
1448
  } );
1239
1449
  } );
1240
1450
 
@@ -1242,13 +1452,17 @@ describe( 'selectors', () => {
1242
1452
  it( 'should return empty if there is no multi selection', () => {
1243
1453
  const state = {
1244
1454
  blocks: {
1245
- order: {
1246
- '': [ 123, 23 ],
1247
- },
1248
- parents: {
1249
- 23: '',
1250
- 123: '',
1251
- },
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
+ ),
1252
1466
  },
1253
1467
  selection: {
1254
1468
  selectionStart: {},
@@ -1262,55 +1476,67 @@ describe( 'selectors', () => {
1262
1476
  it( 'should return selected block clientIds if there is multi selection', () => {
1263
1477
  const state = {
1264
1478
  blocks: {
1265
- order: {
1266
- '': [ 5, 4, 3, 2, 1 ],
1267
- },
1268
- parents: {
1269
- 1: '',
1270
- 2: '',
1271
- 3: '',
1272
- 4: '',
1273
- 5: '',
1274
- },
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
+ ),
1275
1493
  },
1276
1494
  selection: {
1277
- selectionStart: { clientId: 2 },
1278
- selectionEnd: { clientId: 4 },
1495
+ selectionStart: { clientId: '2' },
1496
+ selectionEnd: { clientId: '4' },
1279
1497
  },
1280
1498
  };
1281
1499
 
1282
1500
  expect( getMultiSelectedBlockClientIds( state ) ).toEqual( [
1283
- 4, 3, 2,
1501
+ '4',
1502
+ '3',
1503
+ '2',
1284
1504
  ] );
1285
1505
  } );
1286
1506
 
1287
1507
  it( 'should return selected block clientIds if there is multi selection (nested context)', () => {
1288
1508
  const state = {
1289
1509
  blocks: {
1290
- order: {
1291
- '': [ 5, 4, 3, 2, 1 ],
1292
- 4: [ 9, 8, 7, 6 ],
1293
- },
1294
- parents: {
1295
- 1: '',
1296
- 2: '',
1297
- 3: '',
1298
- 4: '',
1299
- 5: '',
1300
- 6: 4,
1301
- 7: 4,
1302
- 8: 4,
1303
- 9: 4,
1304
- },
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
+ ),
1305
1529
  },
1306
1530
  selection: {
1307
- selectionStart: { clientId: 7 },
1308
- selectionEnd: { clientId: 9 },
1531
+ selectionStart: { clientId: '7' },
1532
+ selectionEnd: { clientId: '9' },
1309
1533
  },
1310
1534
  };
1311
1535
 
1312
1536
  expect( getMultiSelectedBlockClientIds( state ) ).toEqual( [
1313
- 9, 8, 7,
1537
+ '9',
1538
+ '8',
1539
+ '7',
1314
1540
  ] );
1315
1541
  } );
1316
1542
  } );
@@ -1319,10 +1545,10 @@ describe( 'selectors', () => {
1319
1545
  it( 'should return the same reference on subsequent invocations of empty selection', () => {
1320
1546
  const state = {
1321
1547
  blocks: {
1322
- byClientId: {},
1323
- attributes: {},
1324
- order: {},
1325
- parents: {},
1548
+ byClientId: new Map(),
1549
+ attributes: new Map(),
1550
+ order: new Map(),
1551
+ parents: new Map(),
1326
1552
  },
1327
1553
  selection: {
1328
1554
  selectionStart: {},
@@ -1351,12 +1577,12 @@ describe( 'selectors', () => {
1351
1577
  it( 'returns multi selection start', () => {
1352
1578
  const state = {
1353
1579
  selection: {
1354
- selectionStart: { clientId: 2 },
1355
- selectionEnd: { clientId: 4 },
1580
+ selectionStart: { clientId: '2' },
1581
+ selectionEnd: { clientId: '4' },
1356
1582
  },
1357
1583
  };
1358
1584
 
1359
- expect( getMultiSelectedBlocksStartClientId( state ) ).toBe( 2 );
1585
+ expect( getMultiSelectedBlocksStartClientId( state ) ).toBe( '2' );
1360
1586
  } );
1361
1587
  } );
1362
1588
 
@@ -1375,12 +1601,12 @@ describe( 'selectors', () => {
1375
1601
  it( 'returns multi selection end', () => {
1376
1602
  const state = {
1377
1603
  selection: {
1378
- selectionStart: { clientId: 2 },
1379
- selectionEnd: { clientId: 4 },
1604
+ selectionStart: { clientId: '2' },
1605
+ selectionEnd: { clientId: '4' },
1380
1606
  },
1381
1607
  };
1382
1608
 
1383
- expect( getMultiSelectedBlocksEndClientId( state ) ).toBe( 4 );
1609
+ expect( getMultiSelectedBlocksEndClientId( state ) ).toBe( '4' );
1384
1610
  } );
1385
1611
  } );
1386
1612
 
@@ -1388,35 +1614,43 @@ describe( 'selectors', () => {
1388
1614
  it( 'should return the ordered block ClientIds of top-level blocks by default', () => {
1389
1615
  const state = {
1390
1616
  blocks: {
1391
- order: {
1392
- '': [ 123, 23 ],
1393
- },
1394
- parents: {
1395
- 23: '',
1396
- 123: '',
1397
- },
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
+ ),
1398
1628
  },
1399
1629
  };
1400
1630
 
1401
- expect( getBlockOrder( state ) ).toEqual( [ 123, 23 ] );
1631
+ expect( getBlockOrder( state ) ).toEqual( [ '123', '23' ] );
1402
1632
  } );
1403
1633
 
1404
1634
  it( 'should return the ordered block ClientIds at a specified rootClientId', () => {
1405
1635
  const state = {
1406
1636
  blocks: {
1407
- order: {
1408
- '': [ 123, 23 ],
1409
- 123: [ 456 ],
1410
- },
1411
- parents: {
1412
- 23: '',
1413
- 123: '',
1414
- 456: 123,
1415
- },
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
+ ),
1416
1650
  },
1417
1651
  };
1418
1652
 
1419
- expect( getBlockOrder( state, '123' ) ).toEqual( [ 456 ] );
1653
+ expect( getBlockOrder( state, '123' ) ).toEqual( [ '456' ] );
1420
1654
  } );
1421
1655
  } );
1422
1656
 
@@ -1424,36 +1658,44 @@ describe( 'selectors', () => {
1424
1658
  it( 'should return the block order', () => {
1425
1659
  const state = {
1426
1660
  blocks: {
1427
- order: {
1428
- '': [ 123, 23 ],
1429
- },
1430
- parents: {
1431
- 23: '',
1432
- 123: '',
1433
- },
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
+ ),
1434
1672
  },
1435
1673
  };
1436
1674
 
1437
- expect( getBlockIndex( state, 23 ) ).toBe( 1 );
1675
+ expect( getBlockIndex( state, '23' ) ).toBe( 1 );
1438
1676
  } );
1439
1677
 
1440
1678
  it( 'should return the block order (nested context)', () => {
1441
1679
  const state = {
1442
1680
  blocks: {
1443
- order: {
1444
- '': [ 123, 23 ],
1445
- 123: [ 456, 56 ],
1446
- },
1447
- parents: {
1448
- 23: '',
1449
- 123: '',
1450
- 56: 123,
1451
- 456: 123,
1452
- },
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
+ ),
1453
1695
  },
1454
1696
  };
1455
1697
 
1456
- expect( getBlockIndex( state, 56 ) ).toBe( 1 );
1698
+ expect( getBlockIndex( state, '56' ) ).toBe( 1 );
1457
1699
  } );
1458
1700
  } );
1459
1701
 
@@ -1461,73 +1703,91 @@ describe( 'selectors', () => {
1461
1703
  it( 'should return the previous block', () => {
1462
1704
  const state = {
1463
1705
  blocks: {
1464
- order: {
1465
- '': [ 123, 23 ],
1466
- },
1467
- parents: {
1468
- 23: '',
1469
- 123: '',
1470
- },
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
+ ),
1471
1717
  },
1472
1718
  };
1473
1719
 
1474
- expect( getPreviousBlockClientId( state, 23 ) ).toEqual( 123 );
1720
+ expect( getPreviousBlockClientId( state, '23' ) ).toEqual( '123' );
1475
1721
  } );
1476
1722
 
1477
1723
  it( 'should return the previous block (nested context)', () => {
1478
1724
  const state = {
1479
1725
  blocks: {
1480
- order: {
1481
- '': [ 123, 23 ],
1482
- 123: [ 456, 56 ],
1483
- },
1484
- parents: {
1485
- 23: '',
1486
- 123: '',
1487
- 456: 123,
1488
- 56: 123,
1489
- },
1490
- },
1491
- };
1492
-
1493
- expect( getPreviousBlockClientId( state, 56, '123' ) ).toEqual(
1494
- 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'
1495
1745
  );
1496
1746
  } );
1497
1747
 
1498
1748
  it( 'should return null for the first block', () => {
1499
1749
  const state = {
1500
1750
  blocks: {
1501
- order: {
1502
- '': [ 123, 23 ],
1503
- },
1504
- parents: {
1505
- 23: '',
1506
- 123: '',
1507
- },
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
+ ),
1508
1762
  },
1509
1763
  };
1510
1764
 
1511
- expect( getPreviousBlockClientId( state, 123 ) ).toBeNull();
1765
+ expect( getPreviousBlockClientId( state, '123' ) ).toBeNull();
1512
1766
  } );
1513
1767
 
1514
1768
  it( 'should return null for the first block (nested context)', () => {
1515
1769
  const state = {
1516
1770
  blocks: {
1517
- order: {
1518
- '': [ 123, 23 ],
1519
- 123: [ 456, 56 ],
1520
- },
1521
- parents: {
1522
- 23: '',
1523
- 123: '',
1524
- 456: 123,
1525
- 56: 123,
1526
- },
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
+ ),
1527
1785
  },
1528
1786
  };
1529
1787
 
1530
- expect( getPreviousBlockClientId( state, 456, '123' ) ).toBeNull();
1788
+ expect(
1789
+ getPreviousBlockClientId( state, '456', '123' )
1790
+ ).toBeNull();
1531
1791
  } );
1532
1792
  } );
1533
1793
 
@@ -1535,71 +1795,89 @@ describe( 'selectors', () => {
1535
1795
  it( 'should return the following block', () => {
1536
1796
  const state = {
1537
1797
  blocks: {
1538
- order: {
1539
- '': [ 123, 23 ],
1540
- },
1541
- parents: {
1542
- 23: '',
1543
- 123: '',
1544
- },
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
+ ),
1545
1809
  },
1546
1810
  };
1547
1811
 
1548
- expect( getNextBlockClientId( state, 123 ) ).toEqual( 23 );
1812
+ expect( getNextBlockClientId( state, '123' ) ).toEqual( '23' );
1549
1813
  } );
1550
1814
 
1551
1815
  it( 'should return the following block (nested context)', () => {
1552
1816
  const state = {
1553
1817
  blocks: {
1554
- order: {
1555
- '': [ 123, 23 ],
1556
- 123: [ 456, 56 ],
1557
- },
1558
- parents: {
1559
- 23: '',
1560
- 123: '',
1561
- 456: 123,
1562
- 56: 123,
1563
- },
1564
- },
1565
- };
1566
-
1567
- 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
+ );
1568
1838
  } );
1569
1839
 
1570
1840
  it( 'should return null for the last block', () => {
1571
1841
  const state = {
1572
- blocks: {
1573
- order: {
1574
- '': [ 123, 23 ],
1575
- },
1576
- parents: {
1577
- 23: '',
1578
- 123: '',
1579
- },
1842
+ blocks: {
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
+ ),
1580
1854
  },
1581
1855
  };
1582
1856
 
1583
- expect( getNextBlockClientId( state, 23 ) ).toBeNull();
1857
+ expect( getNextBlockClientId( state, '23' ) ).toBeNull();
1584
1858
  } );
1585
1859
 
1586
1860
  it( 'should return null for the last block (nested context)', () => {
1587
1861
  const state = {
1588
1862
  blocks: {
1589
- order: {
1590
- '': [ 123, 23 ],
1591
- 123: [ 456, 56 ],
1592
- },
1593
- parents: {
1594
- 23: '',
1595
- 123: '',
1596
- 456: 123,
1597
- 56: 123,
1598
- },
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
+ ),
1599
1877
  },
1600
1878
  };
1601
1879
 
1602
- expect( getNextBlockClientId( state, 56, '123' ) ).toBeNull();
1880
+ expect( getNextBlockClientId( state, '56', '123' ) ).toBeNull();
1603
1881
  } );
1604
1882
  } );
1605
1883
 
@@ -1607,23 +1885,23 @@ describe( 'selectors', () => {
1607
1885
  it( 'should return true if the block is selected', () => {
1608
1886
  const state = {
1609
1887
  selection: {
1610
- selectionStart: { clientId: 123 },
1611
- selectionEnd: { clientId: 123 },
1888
+ selectionStart: { clientId: '123' },
1889
+ selectionEnd: { clientId: '123' },
1612
1890
  },
1613
1891
  };
1614
1892
 
1615
- expect( isBlockSelected( state, 123 ) ).toBe( true );
1893
+ expect( isBlockSelected( state, '123' ) ).toBe( true );
1616
1894
  } );
1617
1895
 
1618
1896
  it( 'should return false if a multi-selection range exists', () => {
1619
1897
  const state = {
1620
1898
  selection: {
1621
- selectionStart: { clientId: 123 },
1622
- selectionEnd: { clientId: 124 },
1899
+ selectionStart: { clientId: '123' },
1900
+ selectionEnd: { clientId: '124' },
1623
1901
  },
1624
1902
  };
1625
1903
 
1626
- expect( isBlockSelected( state, 123 ) ).toBe( false );
1904
+ expect( isBlockSelected( state, '123' ) ).toBe( false );
1627
1905
  } );
1628
1906
 
1629
1907
  it( 'should return false if the block is not selected', () => {
@@ -1634,7 +1912,7 @@ describe( 'selectors', () => {
1634
1912
  },
1635
1913
  };
1636
1914
 
1637
- expect( isBlockSelected( state, 23 ) ).toBe( false );
1915
+ expect( isBlockSelected( state, '23' ) ).toBe( false );
1638
1916
  } );
1639
1917
  } );
1640
1918
 
@@ -1642,87 +1920,103 @@ describe( 'selectors', () => {
1642
1920
  it( 'should return false if the selected block is a child of the given ClientId', () => {
1643
1921
  const state = {
1644
1922
  selection: {
1645
- selectionStart: { clientId: 5 },
1646
- selectionEnd: { clientId: 5 },
1923
+ selectionStart: { clientId: '5' },
1924
+ selectionEnd: { clientId: '5' },
1647
1925
  },
1648
1926
  blocks: {
1649
- order: {
1650
- 4: [ 3, 2, 1 ],
1651
- },
1652
- parents: {
1653
- 1: 4,
1654
- 2: 4,
1655
- 3: 4,
1656
- },
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
+ ),
1657
1939
  },
1658
1940
  };
1659
1941
 
1660
- expect( hasSelectedInnerBlock( state, 4 ) ).toBe( false );
1942
+ expect( hasSelectedInnerBlock( state, '4' ) ).toBe( false );
1661
1943
  } );
1662
1944
 
1663
1945
  it( 'should return true if the selected block is a child of the given ClientId', () => {
1664
1946
  const state = {
1665
1947
  selection: {
1666
- selectionStart: { clientId: 3 },
1667
- selectionEnd: { clientId: 3 },
1948
+ selectionStart: { clientId: '3' },
1949
+ selectionEnd: { clientId: '3' },
1668
1950
  },
1669
1951
  blocks: {
1670
- order: {
1671
- 4: [ 3, 2, 1 ],
1672
- },
1673
- parents: {
1674
- 1: 4,
1675
- 2: 4,
1676
- 3: 4,
1677
- },
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
+ ),
1678
1964
  },
1679
1965
  };
1680
1966
 
1681
- expect( hasSelectedInnerBlock( state, 4 ) ).toBe( true );
1967
+ expect( hasSelectedInnerBlock( state, '4' ) ).toBe( true );
1682
1968
  } );
1683
1969
 
1684
1970
  it( 'should return true if a multi selection exists that contains children of the block with the given ClientId', () => {
1685
1971
  const state = {
1686
1972
  blocks: {
1687
- order: {
1688
- 6: [ 5, 4, 3, 2, 1 ],
1689
- },
1690
- parents: {
1691
- 1: 6,
1692
- 2: 6,
1693
- 3: 6,
1694
- 4: 6,
1695
- 5: 6,
1696
- },
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
+ ),
1697
1987
  },
1698
1988
  selection: {
1699
- selectionStart: { clientId: 2 },
1700
- selectionEnd: { clientId: 4 },
1989
+ selectionStart: { clientId: '2' },
1990
+ selectionEnd: { clientId: '4' },
1701
1991
  },
1702
1992
  };
1703
- expect( hasSelectedInnerBlock( state, 6 ) ).toBe( true );
1993
+ expect( hasSelectedInnerBlock( state, '6' ) ).toBe( true );
1704
1994
  } );
1705
1995
 
1706
1996
  it( 'should return false if a multi selection exists bot does not contains children of the block with the given ClientId', () => {
1707
1997
  const state = {
1708
1998
  blocks: {
1709
- order: {
1710
- 3: [ 2, 1 ],
1711
- 6: [ 5, 4 ],
1712
- },
1713
- parents: {
1714
- 1: 3,
1715
- 2: 3,
1716
- 4: 6,
1717
- 5: 6,
1718
- },
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
+ ),
1719
2013
  },
1720
2014
  selection: {
1721
- selectionStart: { clientId: 5 },
1722
- selectionEnd: { clientId: 4 },
2015
+ selectionStart: { clientId: '5' },
2016
+ selectionEnd: { clientId: '4' },
1723
2017
  },
1724
2018
  };
1725
- expect( hasSelectedInnerBlock( state, 3 ) ).toBe( false );
2019
+ expect( hasSelectedInnerBlock( state, '3' ) ).toBe( false );
1726
2020
  } );
1727
2021
  } );
1728
2022
 
@@ -1730,70 +2024,82 @@ describe( 'selectors', () => {
1730
2024
  it( 'should return true if the block is selected but not the last', () => {
1731
2025
  const state = {
1732
2026
  selection: {
1733
- selectionStart: { clientId: 5 },
1734
- selectionEnd: { clientId: 3 },
2027
+ selectionStart: { clientId: '5' },
2028
+ selectionEnd: { clientId: '3' },
1735
2029
  },
1736
2030
  blocks: {
1737
- order: {
1738
- '': [ 5, 4, 3, 2, 1 ],
1739
- },
1740
- parents: {
1741
- 1: '',
1742
- 2: '',
1743
- 3: '',
1744
- 4: '',
1745
- 5: '',
1746
- },
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
+ ),
1747
2045
  },
1748
2046
  };
1749
2047
 
1750
- expect( isBlockWithinSelection( state, 4 ) ).toBe( true );
2048
+ expect( isBlockWithinSelection( state, '4' ) ).toBe( true );
1751
2049
  } );
1752
2050
 
1753
2051
  it( 'should return false if the block is the last selected', () => {
1754
2052
  const state = {
1755
2053
  selection: {
1756
- selectionStart: { clientId: 5 },
1757
- selectionEnd: { clientId: 3 },
2054
+ selectionStart: { clientId: '5' },
2055
+ selectionEnd: { clientId: '3' },
1758
2056
  },
1759
2057
  blocks: {
1760
- order: {
1761
- '': [ 5, 4, 3, 2, 1 ],
1762
- },
1763
- parents: {
1764
- 1: '',
1765
- 2: '',
1766
- 3: '',
1767
- 4: '',
1768
- 5: '',
1769
- },
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
+ ),
1770
2072
  },
1771
2073
  };
1772
2074
 
1773
- expect( isBlockWithinSelection( state, 3 ) ).toBe( false );
2075
+ expect( isBlockWithinSelection( state, '3' ) ).toBe( false );
1774
2076
  } );
1775
2077
 
1776
2078
  it( 'should return false if the block is not selected', () => {
1777
2079
  const state = {
1778
2080
  selection: {
1779
- selectionStart: { clientId: 5 },
1780
- selectionEnd: { clientId: 3 },
2081
+ selectionStart: { clientId: '5' },
2082
+ selectionEnd: { clientId: '3' },
1781
2083
  },
1782
2084
  blocks: {
1783
- order: {
1784
- '': [ 5, 4, 3, 2, 1 ],
1785
- },
1786
- parents: {
1787
- 1: '',
1788
- 2: '',
1789
- 3: '',
1790
- 4: '',
1791
- 5: '',
1792
- },
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
+ ),
1793
2099
  },
1794
2100
  };
1795
2101
 
1796
- expect( isBlockWithinSelection( state, 2 ) ).toBe( false );
2102
+ expect( isBlockWithinSelection( state, '2' ) ).toBe( false );
1797
2103
  } );
1798
2104
 
1799
2105
  it( 'should return false if there is no selection', () => {
@@ -1803,20 +2109,24 @@ describe( 'selectors', () => {
1803
2109
  selectionEnd: {},
1804
2110
  },
1805
2111
  blocks: {
1806
- order: {
1807
- '': [ 5, 4, 3, 2, 1 ],
1808
- },
1809
- parents: {
1810
- 1: '',
1811
- 2: '',
1812
- 3: '',
1813
- 4: '',
1814
- 5: '',
1815
- },
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
+ ),
1816
2126
  },
1817
2127
  };
1818
2128
 
1819
- expect( isBlockWithinSelection( state, 4 ) ).toBe( false );
2129
+ expect( isBlockWithinSelection( state, '4' ) ).toBe( false );
1820
2130
  } );
1821
2131
  } );
1822
2132
 
@@ -1866,58 +2176,66 @@ describe( 'selectors', () => {
1866
2176
  describe( 'isBlockMultiSelected', () => {
1867
2177
  const state = {
1868
2178
  blocks: {
1869
- order: {
1870
- '': [ 5, 4, 3, 2, 1 ],
1871
- },
1872
- parents: {
1873
- 1: '',
1874
- 2: '',
1875
- 3: '',
1876
- 4: '',
1877
- 5: '',
1878
- },
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
+ ),
1879
2193
  },
1880
2194
  selection: {
1881
- selectionStart: { clientId: 2 },
1882
- selectionEnd: { clientId: 4 },
2195
+ selectionStart: { clientId: '2' },
2196
+ selectionEnd: { clientId: '4' },
1883
2197
  },
1884
2198
  };
1885
2199
 
1886
2200
  it( 'should return true if the block is multi selected', () => {
1887
- expect( isBlockMultiSelected( state, 3 ) ).toBe( true );
2201
+ expect( isBlockMultiSelected( state, '3' ) ).toBe( true );
1888
2202
  } );
1889
2203
 
1890
2204
  it( 'should return false if the block is not multi selected', () => {
1891
- expect( isBlockMultiSelected( state, 5 ) ).toBe( false );
2205
+ expect( isBlockMultiSelected( state, '5' ) ).toBe( false );
1892
2206
  } );
1893
2207
  } );
1894
2208
 
1895
2209
  describe( 'isFirstMultiSelectedBlock', () => {
1896
2210
  const state = {
1897
2211
  blocks: {
1898
- order: {
1899
- '': [ 5, 4, 3, 2, 1 ],
1900
- },
1901
- parents: {
1902
- 1: '',
1903
- 2: '',
1904
- 3: '',
1905
- 4: '',
1906
- 5: '',
1907
- },
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
+ ),
1908
2226
  },
1909
2227
  selection: {
1910
- selectionStart: { clientId: 2 },
1911
- selectionEnd: { clientId: 4 },
2228
+ selectionStart: { clientId: '2' },
2229
+ selectionEnd: { clientId: '4' },
1912
2230
  },
1913
2231
  };
1914
2232
 
1915
2233
  it( 'should return true if the block is first in multi selection', () => {
1916
- expect( isFirstMultiSelectedBlock( state, 4 ) ).toBe( true );
2234
+ expect( isFirstMultiSelectedBlock( state, '4' ) ).toBe( true );
1917
2235
  } );
1918
2236
 
1919
2237
  it( 'should return false if the block is not first in multi selection', () => {
1920
- expect( isFirstMultiSelectedBlock( state, 3 ) ).toBe( false );
2238
+ expect( isFirstMultiSelectedBlock( state, '3' ) ).toBe( false );
1921
2239
  } );
1922
2240
  } );
1923
2241
 
@@ -1927,7 +2245,7 @@ describe( 'selectors', () => {
1927
2245
  blocksMode: {},
1928
2246
  };
1929
2247
 
1930
- expect( getBlockMode( state, 123 ) ).toEqual( 'visual' );
2248
+ expect( getBlockMode( state, '123' ) ).toEqual( 'visual' );
1931
2249
  } );
1932
2250
 
1933
2251
  it( 'should return the block mode', () => {
@@ -1937,7 +2255,7 @@ describe( 'selectors', () => {
1937
2255
  },
1938
2256
  };
1939
2257
 
1940
- expect( getBlockMode( state, 123 ) ).toEqual( 'html' );
2258
+ expect( getBlockMode( state, '123' ) ).toEqual( 'html' );
1941
2259
  } );
1942
2260
  } );
1943
2261
 
@@ -2031,10 +2349,12 @@ describe( 'selectors', () => {
2031
2349
  const state = {
2032
2350
  draggedBlocks: [ 'block-1_grandparent' ],
2033
2351
  blocks: {
2034
- parents: {
2035
- 'block-1': 'block-1_parent',
2036
- 'block-1_parent': 'block-1_grandparent',
2037
- },
2352
+ parents: new Map(
2353
+ Object.entries( {
2354
+ 'block-1': 'block-1_parent',
2355
+ 'block-1_parent': 'block-1_grandparent',
2356
+ } )
2357
+ ),
2038
2358
  },
2039
2359
  };
2040
2360
  expect( isAncestorBeingDragged( state, 'block-1' ) ).toBe( true );
@@ -2044,10 +2364,12 @@ describe( 'selectors', () => {
2044
2364
  const state = {
2045
2365
  draggedBlocks: [ 'block-2_grandparent' ],
2046
2366
  blocks: {
2047
- parents: {
2048
- 'block-1': 'block-1_parent',
2049
- 'block-1_parent': 'block-1_grandparent',
2050
- },
2367
+ parents: new Map(
2368
+ Object.entries( {
2369
+ 'block-1': 'block-1_parent',
2370
+ 'block-1_parent': 'block-1_grandparent',
2371
+ } )
2372
+ ),
2051
2373
  },
2052
2374
  };
2053
2375
  expect( isAncestorBeingDragged( state, 'block-1' ) ).toBe( false );
@@ -2057,10 +2379,12 @@ describe( 'selectors', () => {
2057
2379
  const state = {
2058
2380
  draggedBlocks: [],
2059
2381
  blocks: {
2060
- parents: {
2061
- 'block-1': 'block-1_parent',
2062
- 'block-1_parent': 'block-1_grandparent',
2063
- },
2382
+ parents: new Map(
2383
+ Object.entries( {
2384
+ 'block-1': 'block-1_parent',
2385
+ 'block-1_parent': 'block-1_grandparent',
2386
+ } )
2387
+ ),
2064
2388
  },
2065
2389
  };
2066
2390
  expect( isAncestorBeingDragged( state, 'block-1' ) ).toBe( false );
@@ -2093,23 +2417,31 @@ describe( 'selectors', () => {
2093
2417
  selectionEnd: { clientId: 'clientId2' },
2094
2418
  },
2095
2419
  blocks: {
2096
- byClientId: {
2097
- clientId1: { clientId: 'clientId1' },
2098
- clientId2: { clientId: 'clientId2' },
2099
- },
2100
- attributes: {
2101
- clientId1: {},
2102
- clientId2: {},
2103
- },
2104
- order: {
2105
- '': [ 'clientId1' ],
2106
- clientId1: [ 'clientId2' ],
2107
- clientId2: [],
2108
- },
2109
- parents: {
2110
- clientId1: '',
2111
- clientId2: 'clientId1',
2112
- },
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
+ ),
2113
2445
  },
2114
2446
  insertionPoint: {
2115
2447
  rootClientId: undefined,
@@ -2130,19 +2462,27 @@ describe( 'selectors', () => {
2130
2462
  selectionEnd: { clientId: 'clientId1' },
2131
2463
  },
2132
2464
  blocks: {
2133
- byClientId: {
2134
- clientId1: { clientId: 'clientId1' },
2135
- },
2136
- attributes: {
2137
- clientId1: {},
2138
- },
2139
- order: {
2140
- '': [ 'clientId1' ],
2141
- clientId1: [],
2142
- },
2143
- parents: {
2144
- clientId1: '',
2145
- },
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
+ ),
2146
2486
  },
2147
2487
  insertionPoint: null,
2148
2488
  };
@@ -2160,23 +2500,31 @@ describe( 'selectors', () => {
2160
2500
  selectionEnd: { clientId: 'clientId2' },
2161
2501
  },
2162
2502
  blocks: {
2163
- byClientId: {
2164
- clientId1: { clientId: 'clientId1' },
2165
- clientId2: { clientId: 'clientId2' },
2166
- },
2167
- attributes: {
2168
- clientId1: {},
2169
- clientId2: {},
2170
- },
2171
- order: {
2172
- '': [ 'clientId1' ],
2173
- clientId1: [ 'clientId2' ],
2174
- clientId2: [],
2175
- },
2176
- parents: {
2177
- clientId1: '',
2178
- clientId2: 'clientId1',
2179
- },
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
+ ),
2180
2528
  },
2181
2529
  insertionPoint: null,
2182
2530
  };
@@ -2194,23 +2542,31 @@ describe( 'selectors', () => {
2194
2542
  selectionEnd: { clientId: 'clientId2' },
2195
2543
  },
2196
2544
  blocks: {
2197
- byClientId: {
2198
- clientId1: { clientId: 'clientId1' },
2199
- clientId2: { clientId: 'clientId2' },
2200
- },
2201
- attributes: {
2202
- clientId1: {},
2203
- clientId2: {},
2204
- },
2205
- order: {
2206
- '': [ 'clientId1', 'clientId2' ],
2207
- clientId1: [],
2208
- clientId2: [],
2209
- },
2210
- parents: {
2211
- clientId1: '',
2212
- clientId2: '',
2213
- },
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
+ ),
2214
2570
  },
2215
2571
  insertionPoint: null,
2216
2572
  };
@@ -2228,23 +2584,31 @@ describe( 'selectors', () => {
2228
2584
  selectionEnd: {},
2229
2585
  },
2230
2586
  blocks: {
2231
- byClientId: {
2232
- clientId1: { clientId: 'clientId1' },
2233
- clientId2: { clientId: 'clientId2' },
2234
- },
2235
- attributes: {
2236
- clientId1: {},
2237
- clientId2: {},
2238
- },
2239
- order: {
2240
- '': [ 'clientId1', 'clientId2' ],
2241
- clientId1: [],
2242
- clientId2: [],
2243
- },
2244
- parents: {
2245
- clientId1: '',
2246
- clientId2: '',
2247
- },
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
+ ),
2248
2612
  },
2249
2613
  insertionPoint: null,
2250
2614
  };
@@ -2281,8 +2645,8 @@ describe( 'selectors', () => {
2281
2645
  it( 'should deny blocks that are not registered', () => {
2282
2646
  const state = {
2283
2647
  blocks: {
2284
- byClientId: {},
2285
- attributes: {},
2648
+ byClientId: new Map(),
2649
+ attributes: new Map(),
2286
2650
  },
2287
2651
  blockListSettings: {},
2288
2652
  settings: {},
@@ -2293,8 +2657,8 @@ describe( 'selectors', () => {
2293
2657
  it( 'should deny blocks that are not allowed by the editor', () => {
2294
2658
  const state = {
2295
2659
  blocks: {
2296
- byClientId: {},
2297
- attributes: {},
2660
+ byClientId: new Map(),
2661
+ attributes: new Map(),
2298
2662
  },
2299
2663
  blockListSettings: {},
2300
2664
  settings: {
@@ -2309,8 +2673,8 @@ describe( 'selectors', () => {
2309
2673
  it( 'should allow blocks that are allowed by the editor', () => {
2310
2674
  const state = {
2311
2675
  blocks: {
2312
- byClientId: {},
2313
- attributes: {},
2676
+ byClientId: new Map(),
2677
+ attributes: new Map(),
2314
2678
  },
2315
2679
  blockListSettings: {},
2316
2680
  settings: {
@@ -2325,8 +2689,8 @@ describe( 'selectors', () => {
2325
2689
  it( 'should deny blocks when the editor has a template lock', () => {
2326
2690
  const state = {
2327
2691
  blocks: {
2328
- byClientId: {},
2329
- attributes: {},
2692
+ byClientId: new Map(),
2693
+ attributes: new Map(),
2330
2694
  },
2331
2695
  blockListSettings: {},
2332
2696
  settings: {
@@ -2341,8 +2705,8 @@ describe( 'selectors', () => {
2341
2705
  it( 'should deny blocks that restrict parent from being inserted into the root', () => {
2342
2706
  const state = {
2343
2707
  blocks: {
2344
- byClientId: {},
2345
- attributes: {},
2708
+ byClientId: new Map(),
2709
+ attributes: new Map(),
2346
2710
  },
2347
2711
  blockListSettings: {},
2348
2712
  settings: {},
@@ -2355,12 +2719,16 @@ describe( 'selectors', () => {
2355
2719
  it( 'should deny blocks that restrict parent from being inserted into a restricted parent', () => {
2356
2720
  const state = {
2357
2721
  blocks: {
2358
- byClientId: {
2359
- block1: { name: 'core/test-block-a' },
2360
- },
2361
- attributes: {
2362
- block1: {},
2363
- },
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
+ ),
2364
2732
  },
2365
2733
  blockListSettings: {},
2366
2734
  settings: {},
@@ -2373,12 +2741,16 @@ describe( 'selectors', () => {
2373
2741
  it( 'should allow blocks to be inserted into an allowed parent', () => {
2374
2742
  const state = {
2375
2743
  blocks: {
2376
- byClientId: {
2377
- block1: { name: 'core/test-block-b' },
2378
- },
2379
- attributes: {
2380
- block1: {},
2381
- },
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
+ ),
2382
2754
  },
2383
2755
  blockListSettings: {
2384
2756
  block1: {},
@@ -2393,12 +2765,16 @@ describe( 'selectors', () => {
2393
2765
  it( 'should deny blocks from being inserted into a block that does not allow inner blocks', () => {
2394
2766
  const state = {
2395
2767
  blocks: {
2396
- byClientId: {
2397
- block1: { name: 'core/test-block-b' },
2398
- },
2399
- attributes: {
2400
- block1: {},
2401
- },
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
+ ),
2402
2778
  },
2403
2779
  blockListSettings: {
2404
2780
  block1: {},
@@ -2413,12 +2789,16 @@ describe( 'selectors', () => {
2413
2789
  it( 'should deny restricted blocks from being inserted into a block that restricts allowedBlocks', () => {
2414
2790
  const state = {
2415
2791
  blocks: {
2416
- byClientId: {
2417
- block1: { name: 'core/test-block-a' },
2418
- },
2419
- attributes: {
2420
- block1: {},
2421
- },
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
+ ),
2422
2802
  },
2423
2803
  blockListSettings: {
2424
2804
  block1: {
@@ -2435,12 +2815,16 @@ describe( 'selectors', () => {
2435
2815
  it( 'should allow allowed blocks to be inserted into a block that restricts allowedBlocks', () => {
2436
2816
  const state = {
2437
2817
  blocks: {
2438
- byClientId: {
2439
- block1: { name: 'core/test-block-a' },
2440
- },
2441
- attributes: {
2442
- block1: {},
2443
- },
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
+ ),
2444
2828
  },
2445
2829
  blockListSettings: {
2446
2830
  block1: {
@@ -2457,12 +2841,16 @@ describe( 'selectors', () => {
2457
2841
  it( 'should prioritise parent over allowedBlocks', () => {
2458
2842
  const state = {
2459
2843
  blocks: {
2460
- byClientId: {
2461
- block1: { name: 'core/test-block-b' },
2462
- },
2463
- attributes: {
2464
- block1: {},
2465
- },
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
+ ),
2466
2854
  },
2467
2855
  blockListSettings: {
2468
2856
  block1: {
@@ -2479,12 +2867,16 @@ describe( 'selectors', () => {
2479
2867
  it( 'should deny blocks that restrict parent to core/post-content when not in editor root', () => {
2480
2868
  const state = {
2481
2869
  blocks: {
2482
- byClientId: {
2483
- block1: { name: 'core/test-block-c' },
2484
- },
2485
- attributes: {
2486
- block1: {},
2487
- },
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
+ ),
2488
2880
  },
2489
2881
  blockListSettings: {},
2490
2882
  settings: {},
@@ -2497,8 +2889,8 @@ describe( 'selectors', () => {
2497
2889
  it( 'should allow blocks that restrict parent to core/post-content when in editor root', () => {
2498
2890
  const state = {
2499
2891
  blocks: {
2500
- byClientId: {},
2501
- attributes: {},
2892
+ byClientId: new Map(),
2893
+ attributes: new Map(),
2502
2894
  },
2503
2895
  blockListSettings: {},
2504
2896
  settings: {},
@@ -2511,17 +2903,23 @@ describe( 'selectors', () => {
2511
2903
  it( 'should allow blocks to be inserted in a descendant of a required ancestor', () => {
2512
2904
  const state = {
2513
2905
  blocks: {
2514
- byClientId: {
2515
- block1: { name: 'core/test-block-ancestor' },
2516
- block2: { name: 'core/block' },
2517
- },
2518
- attributes: {
2519
- block1: {},
2520
- block2: {},
2521
- },
2522
- parents: {
2523
- block2: 'block1',
2524
- },
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
+ ),
2525
2923
  },
2526
2924
  blockListSettings: {
2527
2925
  block1: {},
@@ -2541,20 +2939,26 @@ describe( 'selectors', () => {
2541
2939
  it( 'should allow blocks to be inserted if both parent and ancestor restrictions are met', () => {
2542
2940
  const state = {
2543
2941
  blocks: {
2544
- byClientId: {
2545
- block1: { name: 'core/test-block-ancestor' },
2546
- block2: { name: 'core/block' },
2547
- block3: { name: 'core/test-block-parent' },
2548
- },
2549
- attributes: {
2550
- block1: {},
2551
- block2: {},
2552
- block3: {},
2553
- },
2554
- parents: {
2555
- block2: 'block1',
2556
- block3: 'block2',
2557
- },
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
+ ),
2558
2962
  },
2559
2963
  blockListSettings: {
2560
2964
  block1: {},
@@ -2575,19 +2979,25 @@ describe( 'selectors', () => {
2575
2979
  it( 'should deny blocks from being inserted outside a required ancestor', () => {
2576
2980
  const state = {
2577
2981
  blocks: {
2578
- byClientId: {
2579
- block1: { name: 'core/test-block-ancestor' },
2580
- block2: { name: 'core/block' },
2581
- block3: { name: 'core/block' },
2582
- },
2583
- attributes: {
2584
- block1: {},
2585
- block2: {},
2586
- block3: {},
2587
- },
2588
- parents: {
2589
- block3: 'block2',
2590
- },
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
+ ),
2591
3001
  },
2592
3002
  blockListSettings: {
2593
3003
  block1: {},
@@ -2608,19 +3018,25 @@ describe( 'selectors', () => {
2608
3018
  it( 'should deny blocks from being inserted outside of a required ancestor, even if parent matches', () => {
2609
3019
  const state = {
2610
3020
  blocks: {
2611
- byClientId: {
2612
- block1: { name: 'core/test-block-ancestor' },
2613
- block2: { name: 'core/block' },
2614
- block3: { name: 'core/test-block-parent' },
2615
- },
2616
- attributes: {
2617
- block1: {},
2618
- block2: {},
2619
- block3: {},
2620
- },
2621
- parents: {
2622
- block3: 'block2',
2623
- },
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
+ ),
2624
3040
  },
2625
3041
  blockListSettings: {
2626
3042
  block1: {},
@@ -2641,17 +3057,23 @@ describe( 'selectors', () => {
2641
3057
  it( 'should deny blocks from being inserted inside ancestor if parent restricts allowedBlocks', () => {
2642
3058
  const state = {
2643
3059
  blocks: {
2644
- byClientId: {
2645
- block1: { name: 'core/test-block-ancestor' },
2646
- block2: { name: 'core/block' },
2647
- },
2648
- attributes: {
2649
- block1: {},
2650
- block2: {},
2651
- },
2652
- parents: {
2653
- block2: 'block1',
2654
- },
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
+ ),
2655
3077
  },
2656
3078
  blockListSettings: {
2657
3079
  block1: {},
@@ -2673,17 +3095,23 @@ describe( 'selectors', () => {
2673
3095
  it( 'should deny blocks from being inserted inside ancestor if parent restriction is not met', () => {
2674
3096
  const state = {
2675
3097
  blocks: {
2676
- byClientId: {
2677
- block1: { name: 'core/test-block-ancestor' },
2678
- block2: { name: 'core/block' },
2679
- },
2680
- attributes: {
2681
- block1: {},
2682
- block2: {},
2683
- },
2684
- parents: {
2685
- block2: 'block1',
2686
- },
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
+ ),
2687
3115
  },
2688
3116
  blockListSettings: {
2689
3117
  block1: {},
@@ -2705,16 +3133,20 @@ describe( 'selectors', () => {
2705
3133
  it( 'should allow blocks', () => {
2706
3134
  const state = {
2707
3135
  blocks: {
2708
- byClientId: {
2709
- 1: { name: 'core/test-block-a' },
2710
- 2: { name: 'core/test-block-b' },
2711
- 3: { name: 'core/test-block-c' },
2712
- },
2713
- attributes: {
2714
- 1: {},
2715
- 2: {},
2716
- 3: {},
2717
- },
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
+ ),
2718
3150
  },
2719
3151
  blockListSettings: {
2720
3152
  1: {
@@ -2732,16 +3164,20 @@ describe( 'selectors', () => {
2732
3164
  it( 'should deny blocks', () => {
2733
3165
  const state = {
2734
3166
  blocks: {
2735
- byClientId: {
2736
- 1: { name: 'core/test-block-a' },
2737
- 2: { name: 'core/test-block-b' },
2738
- 3: { name: 'core/test-block-c' },
2739
- },
2740
- attributes: {
2741
- 1: {},
2742
- 2: {},
2743
- 3: {},
2744
- },
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
+ ),
2745
3181
  },
2746
3182
  blockListSettings: {
2747
3183
  1: {
@@ -2758,15 +3194,17 @@ describe( 'selectors', () => {
2758
3194
  it( 'should properly list block type and reusable block items', () => {
2759
3195
  const state = {
2760
3196
  blocks: {
2761
- byClientId: {},
2762
- attributes: {},
2763
- order: {},
2764
- parents: {},
2765
- tree: {
2766
- '': {
2767
- innerBlocks: [],
2768
- },
2769
- },
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
+ ),
2770
3208
  },
2771
3209
  settings: {
2772
3210
  __experimentalReusableBlocks: [
@@ -2827,35 +3265,45 @@ describe( 'selectors', () => {
2827
3265
  it( 'should correctly cache the return values', () => {
2828
3266
  const state = {
2829
3267
  blocks: {
2830
- byClientId: {
2831
- block3: { name: 'core/test-block-a' },
2832
- block4: { name: 'core/test-block-a' },
2833
- },
2834
- attributes: {
2835
- block3: {},
2836
- block4: {},
2837
- },
2838
- order: {
2839
- '': [ 'block3', 'block4' ],
2840
- },
2841
- parents: {
2842
- block3: '',
2843
- block4: '',
2844
- },
2845
- tree: {
2846
- block3: {
2847
- clientId: 'block3',
2848
- name: 'core/test-block-a',
2849
- attributes: {},
2850
- innerBlocks: [],
2851
- },
2852
- block4: {
2853
- clientId: 'block4',
2854
- name: 'core/test-block-a',
2855
- attributes: {},
2856
- innerBlocks: [],
2857
- },
2858
- },
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
+ ),
2859
3307
  controlledInnerBlocks: {},
2860
3308
  },
2861
3309
  settings: {
@@ -2934,28 +3382,36 @@ describe( 'selectors', () => {
2934
3382
  it( 'should set isDisabled when a block with `multiple: false` has been used', () => {
2935
3383
  const state = {
2936
3384
  blocks: {
2937
- byClientId: {
2938
- block1: {
2939
- clientId: 'block1',
2940
- name: 'core/test-block-b',
2941
- },
2942
- },
2943
- attributes: {
2944
- block1: { attribute: {} },
2945
- },
2946
- order: {
2947
- '': [ 'block1' ],
2948
- },
2949
- tree: {
2950
- block1: {
2951
- clientId: 'block1',
2952
- name: 'core/test-block-b',
2953
- attributes: {},
2954
- innerBlocks: [],
2955
- },
2956
- },
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
+ ),
2957
3413
  controlledInnerBlocks: {},
2958
- parents: {},
3414
+ parents: new Map(),
2959
3415
  },
2960
3416
  preferences: {
2961
3417
  insertUsage: {},
@@ -2973,10 +3429,10 @@ describe( 'selectors', () => {
2973
3429
  it( 'should set a frecency', () => {
2974
3430
  const state = {
2975
3431
  blocks: {
2976
- byClientId: {},
2977
- attributes: {},
2978
- order: {},
2979
- parents: {},
3432
+ byClientId: new Map(),
3433
+ attributes: new Map(),
3434
+ order: new Map(),
3435
+ parents: new Map(),
2980
3436
  cache: {},
2981
3437
  },
2982
3438
  preferences: {
@@ -3068,10 +3524,10 @@ describe( 'selectors', () => {
3068
3524
  it( 'should properly return block type items', () => {
3069
3525
  const state = {
3070
3526
  blocks: {
3071
- byClientId: {},
3072
- attributes: {},
3073
- order: {},
3074
- parents: {},
3527
+ byClientId: new Map(),
3528
+ attributes: new Map(),
3529
+ order: new Map(),
3530
+ parents: new Map(),
3075
3531
  cache: {},
3076
3532
  },
3077
3533
  settings: {},
@@ -3108,10 +3564,10 @@ describe( 'selectors', () => {
3108
3564
  it( 'should support single block object', () => {
3109
3565
  const state = {
3110
3566
  blocks: {
3111
- byClientId: {},
3112
- attributes: {},
3113
- order: {},
3114
- parents: {},
3567
+ byClientId: new Map(),
3568
+ attributes: new Map(),
3569
+ order: new Map(),
3570
+ parents: new Map(),
3115
3571
  cache: {},
3116
3572
  },
3117
3573
  settings: {},
@@ -3125,19 +3581,25 @@ describe( 'selectors', () => {
3125
3581
  it( 'should return only eligible blocks for transformation - `allowedBlocks`', () => {
3126
3582
  const state = {
3127
3583
  blocks: {
3128
- byClientId: {
3129
- block1: { name: 'core/with-tranforms-b' },
3130
- block2: { name: 'core/with-tranforms-a' },
3131
- },
3132
- attributes: {
3133
- block1: {},
3134
- block2: {},
3135
- },
3136
- order: {},
3137
- parents: {
3138
- block1: '',
3139
- block2: 'block1',
3140
- },
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
+ ),
3141
3603
  cache: {},
3142
3604
  controlledInnerBlocks: {},
3143
3605
  },
@@ -3160,28 +3622,36 @@ describe( 'selectors', () => {
3160
3622
  it( 'should take into account the usage of blocks settings `multiple` - if multiple blocks of the same type are allowed', () => {
3161
3623
  const state = {
3162
3624
  blocks: {
3163
- byClientId: {
3164
- block1: {
3165
- clientId: 'block1',
3166
- name: 'core/with-tranforms-c',
3167
- },
3168
- },
3169
- attributes: {
3170
- block1: { attribute: {} },
3171
- },
3172
- order: {
3173
- '': [ 'block1' ],
3174
- },
3175
- tree: {
3176
- block1: {
3177
- clientId: 'block1',
3178
- name: 'core/with-tranforms-c',
3179
- attributes: {},
3180
- innerBlocks: [],
3181
- },
3182
- },
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
+ ),
3183
3653
  controlledInnerBlocks: {},
3184
- parents: {},
3654
+ parents: new Map(),
3185
3655
  },
3186
3656
  preferences: {
3187
3657
  insertUsage: {},
@@ -3208,10 +3678,10 @@ describe( 'selectors', () => {
3208
3678
  it( 'should set frecency', () => {
3209
3679
  const state = {
3210
3680
  blocks: {
3211
- byClientId: {},
3212
- attributes: {},
3213
- order: {},
3214
- parents: {},
3681
+ byClientId: new Map(),
3682
+ attributes: new Map(),
3683
+ order: new Map(),
3684
+ parents: new Map(),
3215
3685
  cache: {},
3216
3686
  },
3217
3687
  preferences: {
@@ -3264,7 +3734,7 @@ describe( 'selectors', () => {
3264
3734
  } );
3265
3735
 
3266
3736
  describe( 'getTemplateLock', () => {
3267
- 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', () => {
3268
3738
  const state = {
3269
3739
  settings: { templateLock: 'all' },
3270
3740
  };
@@ -3272,7 +3742,7 @@ describe( 'selectors', () => {
3272
3742
  expect( getTemplateLock( state ) ).toBe( 'all' );
3273
3743
  } );
3274
3744
 
3275
- it( 'should return undefined if the specified clientId was not found', () => {
3745
+ it( 'should return false if the specified clientId was not found', () => {
3276
3746
  const state = {
3277
3747
  settings: { templateLock: 'all' },
3278
3748
  blockListSettings: {
@@ -3282,10 +3752,10 @@ describe( 'selectors', () => {
3282
3752
  },
3283
3753
  };
3284
3754
 
3285
- expect( getTemplateLock( state, 'ribs' ) ).toBe( undefined );
3755
+ expect( getTemplateLock( state, 'ribs' ) ).toBe( false );
3286
3756
  } );
3287
3757
 
3288
- 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', () => {
3289
3759
  const state = {
3290
3760
  settings: { templateLock: 'all' },
3291
3761
  blockListSettings: {
@@ -3295,7 +3765,7 @@ describe( 'selectors', () => {
3295
3765
  },
3296
3766
  };
3297
3767
 
3298
- expect( getTemplateLock( state, 'ribs' ) ).toBe( undefined );
3768
+ expect( getTemplateLock( state, 'chicken' ) ).toBe( false );
3299
3769
  } );
3300
3770
 
3301
3771
  it( 'should return the template lock for the specified clientId', () => {
@@ -3429,20 +3899,24 @@ describe( 'selectors', () => {
3429
3899
 
3430
3900
  describe( 'getLowestCommonAncestorWithSelectedBlock', () => {
3431
3901
  const blocks = {
3432
- order: {
3433
- '': [ 'a', 'b' ],
3434
- a: [ 'c', 'd' ],
3435
- d: [ 'e' ],
3436
- b: [ 'f' ],
3437
- },
3438
- parents: {
3439
- a: '',
3440
- b: '',
3441
- c: 'a',
3442
- d: 'a',
3443
- e: 'd',
3444
- f: 'b',
3445
- },
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
+ ),
3446
3920
  };
3447
3921
 
3448
3922
  it( 'should not be defined if there is no block selected', () => {
@@ -3541,35 +4015,39 @@ describe( 'selectors', () => {
3541
4015
  },
3542
4016
  },
3543
4017
  blocks: {
3544
- parents: {
3545
- 'client-id-01': '',
3546
- 'client-id-02': 'client-id-01',
3547
- 'client-id-03': 'client-id-02',
3548
- 'client-id-04': 'client-id-03',
3549
- 'client-id-05': 'client-id-03',
3550
- },
3551
- byClientId: {
3552
- 'client-id-01': {
3553
- clientId: 'client-id-01',
3554
- name: 'core/columns',
3555
- },
3556
- 'client-id-02': {
3557
- clientId: 'client-id-02',
3558
- name: 'core/navigation',
3559
- },
3560
- 'client-id-03': {
3561
- clientId: 'client-id-03',
3562
- name: 'core/navigation-link',
3563
- },
3564
- 'client-id-04': {
3565
- clientId: 'client-id-04',
3566
- name: 'core/navigation-link',
3567
- },
3568
- 'client-id-05': {
3569
- clientId: 'client-id-05',
3570
- name: 'core/navigation-link',
3571
- },
3572
- },
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
+ ),
3573
4051
  cache: {
3574
4052
  'client-id-01': {},
3575
4053
  'client-id-02': {},
@@ -3577,9 +4055,11 @@ describe( 'selectors', () => {
3577
4055
  'client-id-04': {},
3578
4056
  'client-id-05': {},
3579
4057
  },
3580
- order: {
3581
- 'client-id-03': [ 'client-id-04', 'client-id-05' ],
3582
- },
4058
+ order: new Map(
4059
+ Object.entries( {
4060
+ 'client-id-03': [ 'client-id-04', 'client-id-05' ],
4061
+ } )
4062
+ ),
3583
4063
  controlledInnerBlocks: {},
3584
4064
  },
3585
4065
  };
@@ -3611,14 +4091,18 @@ describe( 'selectors', () => {
3611
4091
  describe( '__experimentalGetAllowedPatterns', () => {
3612
4092
  const state = {
3613
4093
  blocks: {
3614
- byClientId: {
3615
- block1: { name: 'core/test-block-a' },
3616
- block2: { name: 'core/test-block-b' },
3617
- },
3618
- attributes: {
3619
- block1: {},
3620
- block2: {},
3621
- },
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
+ ),
3622
4106
  },
3623
4107
  blockListSettings: {
3624
4108
  block1: {
@@ -3670,7 +4154,7 @@ describe( 'selectors', () => {
3670
4154
  it( 'should return empty array if only patterns hidden from UI exist', () => {
3671
4155
  expect(
3672
4156
  __experimentalGetAllowedPatterns( {
3673
- blocks: { byClientId: {} },
4157
+ blocks: { byClientId: new Map() },
3674
4158
  blockListSettings: {},
3675
4159
  settings: {
3676
4160
  __experimentalBlockPatterns: [
@@ -3742,9 +4226,11 @@ describe( 'selectors', () => {
3742
4226
  describe( '__experimentalGetPatternsByBlockTypes', () => {
3743
4227
  const state = {
3744
4228
  blocks: {
3745
- byClientId: {
3746
- block1: { name: 'core/test-block-a' },
3747
- },
4229
+ byClientId: new Map(
4230
+ Object.entries( {
4231
+ block1: { name: 'core/test-block-a' },
4232
+ } )
4233
+ ),
3748
4234
  },
3749
4235
  blockListSettings: {
3750
4236
  block1: {
@@ -3816,10 +4302,12 @@ describe( 'selectors', () => {
3816
4302
  describe( '__experimentalGetPatternTransformItems', () => {
3817
4303
  const state = {
3818
4304
  blocks: {
3819
- byClientId: {
3820
- block1: { name: 'core/test-block-a' },
3821
- block2: { name: 'core/test-block-b' },
3822
- },
4305
+ byClientId: new Map(
4306
+ Object.entries( {
4307
+ block1: { name: 'core/test-block-a' },
4308
+ block2: { name: 'core/test-block-b' },
4309
+ } )
4310
+ ),
3823
4311
  controlledInnerBlocks: { 'block2-clientId': true },
3824
4312
  },
3825
4313
  blockListSettings: {
@@ -4073,10 +4561,10 @@ describe( 'getInserterItems with core blocks prioritization', () => {
4073
4561
  it( 'should prioritize core blocks by sorting them at the top of the returned list', () => {
4074
4562
  const state = {
4075
4563
  blocks: {
4076
- byClientId: {},
4077
- attributes: {},
4078
- order: {},
4079
- parents: {},
4564
+ byClientId: new Map(),
4565
+ attributes: new Map(),
4566
+ order: new Map(),
4567
+ parents: new Map(),
4080
4568
  cache: {},
4081
4569
  },
4082
4570
  settings: {},
@@ -4104,11 +4592,13 @@ describe( '__unstableGetClientIdWithClientIdsTree', () => {
4104
4592
  it( "should return a stripped down block object containing only its client ID and its inner blocks' client IDs", () => {
4105
4593
  const state = {
4106
4594
  blocks: {
4107
- order: {
4108
- '': [ 'foo' ],
4109
- foo: [ 'bar', 'baz' ],
4110
- bar: [ 'qux' ],
4111
- },
4595
+ order: new Map(
4596
+ Object.entries( {
4597
+ '': [ 'foo' ],
4598
+ foo: [ 'bar', 'baz' ],
4599
+ bar: [ 'qux' ],
4600
+ } )
4601
+ ),
4112
4602
  },
4113
4603
  };
4114
4604
 
@@ -4130,11 +4620,13 @@ describe( '__unstableGetClientIdsTree', () => {
4130
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", () => {
4131
4621
  const state = {
4132
4622
  blocks: {
4133
- order: {
4134
- '': [ 'foo' ],
4135
- foo: [ 'bar', 'baz' ],
4136
- bar: [ 'qux' ],
4137
- },
4623
+ order: new Map(
4624
+ Object.entries( {
4625
+ '': [ 'foo' ],
4626
+ foo: [ 'bar', 'baz' ],
4627
+ bar: [ 'qux' ],
4628
+ } )
4629
+ ),
4138
4630
  },
4139
4631
  };
4140
4632
 
@@ -4150,11 +4642,13 @@ describe( '__unstableGetClientIdsTree', () => {
4150
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", () => {
4151
4643
  const state = {
4152
4644
  blocks: {
4153
- order: {
4154
- '': [ 'foo' ],
4155
- foo: [ 'bar', 'baz' ],
4156
- bar: [ 'qux' ],
4157
- },
4645
+ order: new Map(
4646
+ Object.entries( {
4647
+ '': [ 'foo' ],
4648
+ foo: [ 'bar', 'baz' ],
4649
+ bar: [ 'qux' ],
4650
+ } )
4651
+ ),
4158
4652
  },
4159
4653
  };
4160
4654
 
@@ -4172,3 +4666,23 @@ describe( '__unstableGetClientIdsTree', () => {
4172
4666
  ] );
4173
4667
  } );
4174
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
+ } );